Refine data structure and index page

This commit is contained in:
wjsjwr 2024-12-29 21:38:30 +08:00
parent 12d71a0103
commit ed52f9a34e
12 changed files with 247 additions and 131 deletions

View File

@ -9,5 +9,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="bulma" level="application" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="file://$PROJECT_DIR$" libraries="{bulma}" />
</component>
</project>

View File

@ -11,15 +11,18 @@
</component>
<component name="ChangeListManager">
<list default="true" id="76b3b902-7a5c-4bcd-9c1b-8241d748fb44" name="更改" comment="Add index page">
<change afterPath="$PROJECT_DIR$/bookkeeper/templates/base.html.j2" afterDir="false" />
<change afterPath="$PROJECT_DIR$/bookkeeper/templates/index.html.j2" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/dataSources/244cc0b1-ac8c-4e66-a440-fb727301f139.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources/244cc0b1-ac8c-4e66-a440-fb727301f139.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/jsLibraryMappings.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/bookkeeper/templates/nav.html.j2" afterDir="false" />
<change afterPath="$PROJECT_DIR$/bookkeeper/templates/tx.html.j2" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/finance-consumer.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/finance-consumer.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/Cargo.lock" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/Cargo.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/Cargo.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/Rocket.toml" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/Rocket.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/entity/src/transaction.rs" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/entity/src/transaction.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/migration/src/m20220101_000001_create_table.rs" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/migration/src/m20220101_000001_create_table.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/src/main.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/templates/base.html.j2" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/templates/base.html.j2" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/templates/index.html.j2" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/templates/index.html.j2" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -54,12 +57,15 @@
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
"Cargo.Run bookkeeper.executor": "Run",
"DefaultHtmlFileTemplate": "HTML File",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"RunOnceActivity.rust.reset.selective.auto.import": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"git-widget-placeholder": "main",
"last_opened_file_path": "D:/code/finance-consumer/bookkeeper/templates",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
@ -73,6 +79,11 @@
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\code\finance-consumer\bookkeeper\templates" />
</key>
</component>
<component name="RsExternalLinterProjectSettings">
<option name="runOnTheFly" value="true" />
</component>
@ -145,7 +156,8 @@
<workItem from="1735129640321" duration="9106000" />
<workItem from="1735391132866" duration="1139000" />
<workItem from="1735392290940" duration="620000" />
<workItem from="1735392928494" duration="12825000" />
<workItem from="1735392928494" duration="12910000" />
<workItem from="1735470376833" duration="8472000" />
</task>
<task id="LOCAL-00001" summary="Add bookkeeper">
<option name="closed" value="true" />
@ -171,7 +183,15 @@
<option name="project" value="LOCAL" />
<updated>1735137853863</updated>
</task>
<option name="localTasksCounter" value="4" />
<task id="LOCAL-00004" summary="Add index page">
<option name="closed" value="true" />
<created>1735406260589</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1735406260589</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">

6
bookkeeper/Cargo.lock generated
View File

@ -433,6 +433,8 @@ dependencies = [
"rust_decimal",
"sea-orm",
"sea-orm-rocket",
"serde",
"serde_json",
]
[[package]]
@ -3029,9 +3031,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.133"
version = "1.0.134"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377"
checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d"
dependencies = [
"itoa",
"memchr",

View File

@ -11,6 +11,8 @@ migration = { path = "migration" }
entity ={ path = "entity"}
rust_decimal = "1.36.0"
sea-orm-rocket = "0.5.4"
serde_json = "1.0.134"
serde = { version = "1.0.216", features = ["derive"] }
[workspace]
members = [".", "entity", "migration"]

View File

@ -15,14 +15,11 @@ pub struct Model {
pub buy: Decimal,
pub volume: i32,
pub net_buy: Decimal,
pub sell_date: Option<Date>,
pub sell: Option<Decimal>,
pub net_sell: Option<Decimal>,
pub sold_volume: Option<i32>,
#[sea_orm(column_type = "JsonBinary", nullable)]
pub split_pieces: Option<Json>,
pub gain: Option<Decimal>,
pub net_gain: Option<Decimal>,
pub is_done: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View File

@ -30,13 +30,10 @@ impl MigrationTrait for Migration {
.col(decimal(Transaction::Buy))
.col(integer(Transaction::Volume))
.col(decimal(Transaction::NetBuy))
.col(date_null(Transaction::SellDate))
.col(decimal_null(Transaction::Sell))
.col(decimal_null(Transaction::NetSell))
.col(integer_null(Transaction::SoldVolume))
.col(json_binary_null(Transaction::SplitPieces))
.col(decimal_null(Transaction::Gain))
.col(decimal_null(Transaction::NetGain))
.col(boolean(Transaction::IsDone))
.to_owned(),
)
.await?;
@ -79,11 +76,8 @@ enum Transaction {
Buy,
Volume,
NetBuy,
Sell,
SellDate,
NetSell,
SoldVolume,
SplitPieces,
Gain,
NetGain,
IsDone,
}

View File

@ -19,6 +19,7 @@ use sea_orm::{ActiveModelTrait, ColumnTrait, ConnectOptions, DatabaseConnection,
use sea_orm_rocket::{rocket::figment::Figment, Config, Connection, Database};
use std::str::FromStr;
use std::time::Duration;
use serde::{Deserialize, Serialize};
#[derive(sea_orm_rocket::Database, Debug)]
#[database("bookkeeper")]
@ -69,32 +70,88 @@ async fn index(conn: Connection<'_, Db>) -> Template {
}
#[derive(FromForm)]
struct TransBuy<'r> {
struct TransModel<'r> {
code: usize,
name: &'r str,
buy: &'r str,
volume: usize,
#[field(validate = range(100..))]
volume: i32,
net_buy: &'r str,
date: &'r str,
split_pieces: Vec<SplitPieceForm<'r>>,
}
#[post("/buy", data = "<trans_buy>")]
async fn buy(trans_buy: Form<TransBuy<'_>>, conn: Connection<'_, Db>) -> Flash<Redirect> {
let record = transaction::ActiveModel {
code: Set(trans_buy.code as i32),
name: Set(trans_buy.name.to_string()),
buy: Set(Decimal::from_str(trans_buy.buy).unwrap()),
volume: Set(trans_buy.volume as i32),
net_buy: Set(Decimal::from_str(trans_buy.net_buy).unwrap()),
date: Set(NaiveDate::parse_from_str(trans_buy.date, "%Y-%m-%d").unwrap()),
..Default::default()
};
#[derive(FromForm, Serialize)]
struct SplitPieceForm<'r> {
date: &'r str,
sell: &'r str,
net_sell: &'r str,
#[field(validate = range(100..))]
volume: i32,
}
#[derive(Deserialize, Serialize)]
struct SplitPiece{
date: NaiveDate,
sell: Decimal,
net_sell: Decimal,
volume: i32,
}
#[post("/add", data = "<trans>")]
async fn add(trans: Form<TransModel<'_>>, conn: Connection<'_, Db>) -> Flash<Redirect> {
let record = translate(trans);
record.insert(conn.into_inner()).await.unwrap();
Flash::success(Redirect::to("/"), "OK!")
}
/// translate from form to active model of transaction
fn translate(trans: Form<TransModel>) -> transaction::ActiveModel {
let mut record = transaction::ActiveModel {
code: Set(trans.code as i32),
name: Set(trans.name.to_string()),
buy: Set(Decimal::from_str(trans.buy).unwrap()),
volume: Set(trans.volume),
net_buy: Set(Decimal::from_str(trans.net_buy).unwrap()),
date: Set(NaiveDate::parse_from_str(trans.date, "%Y-%m-%d").unwrap()),
is_done: Set(false),
..Default::default()
};
if trans.split_pieces.len() > 0 {
let mut sp: Vec<SplitPiece> = Vec::new();
for split_piece in trans.split_pieces.iter() {
sp.push(SplitPiece{
date: NaiveDate::parse_from_str(split_piece.date, "%Y-%m-%d").unwrap(),
sell: Decimal::from_str(split_piece.sell).unwrap(),
net_sell: Decimal::from_str(split_piece.net_sell).unwrap(),
volume: split_piece.volume,
})
}
let total: i32 = sp.iter().fold(0, |acc, e| { acc + e.volume });
if total == trans.volume {
record.is_done = Set(true);
let sell_int = sp.iter().fold(Decimal::new(0, 4), |acc, e| {
acc + e.sell * Decimal::from(e.volume)
});
let buy = Decimal::from_str(trans.buy).unwrap() * Decimal::from(total);
record.gain = Set(Option::from((sell_int - buy) / buy * Decimal::from(100)));
let net_sell_int = sp.iter().fold(Decimal::from(0), |acc, e| { acc + e.net_sell });
let net_buy = Decimal::from_str(trans.net_buy).unwrap();
record.net_gain = Set(Option::from((net_sell_int - net_buy) / net_buy * Decimal::from(100)));
}
let v: serde_json::value::Value = serde_json::to_value(sp).unwrap();
record.split_pieces = Set(Option::from(v));
}
record
}
async fn run_migrations(rocket: Rocket<Build>) -> fairing::Result {
let conn = &Db::fetch(&rocket).unwrap().conn;
let _ = migration::Migrator::up(conn, None).await;
@ -108,5 +165,5 @@ async fn rocket() -> _ {
.attach(Db::init())
.attach(AdHoc::try_on_ignite("Migrations", run_migrations))
.attach(Template::fairing())
.mount("/", routes![index, buy])
.mount("/", routes![index, add])
}

View File

@ -7,74 +7,6 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/bulma.min.css">
</head>
<body>
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item" href="https://bulma.io">
<svg width="640" height="160" viewBox="0 0 640 160" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd"
d="M170 132.571V27.5908C170 25.5451 170.915 23.93 172.746 22.7456C174.576 21.5612 176.729 20.969 179.206 20.969H210.377C232.019 20.969 242.84 30.4441 242.84 49.3943C242.84 62.5303 238.264 71.0902 229.112 75.074C234.603 77.2275 238.748 80.2692 241.548 84.1992C244.347 88.1292 245.747 93.8627 245.747 101.4V104.791C245.747 116.743 242.84 125.437 237.026 130.875C231.211 136.312 223.351 139.031 213.445 139.031H179.206C176.514 139.031 174.307 138.385 172.584 137.093C170.861 135.801 170 134.293 170 132.571ZM190.834 120.619H209.085C219.529 120.619 224.751 114.751 224.751 103.015V100.431C224.751 94.401 223.432 90.0404 220.794 87.3486C218.156 84.6568 214.253 83.3109 209.085 83.3109H190.834V120.619ZM190.834 66.8371H208.923C213.122 66.8371 216.326 65.5989 218.533 63.1225C220.74 60.646 221.844 57.2544 221.844 52.9475C221.844 48.7483 220.686 45.4374 218.371 43.0148C216.057 40.5922 212.853 39.3809 208.762 39.3809H190.834V66.8371ZM260.283 103.015V27.4293C260.283 25.2759 261.306 23.6608 263.351 22.5841C265.397 21.5074 267.873 20.969 270.781 20.969C273.688 20.969 276.164 21.5074 278.21 22.5841C280.256 23.6608 281.279 25.2759 281.279 27.4293V103.015C281.279 115.397 287.2 121.588 299.044 121.588C310.888 121.588 316.81 115.397 316.81 103.015V27.4293C316.81 25.2759 317.833 23.6608 319.879 22.5841C321.925 21.5074 324.401 20.969 327.308 20.969C330.215 20.969 332.692 21.5074 334.738 22.5841C336.783 23.6608 337.806 25.2759 337.806 27.4293V103.015C337.806 115.72 334.28 125.061 327.227 131.036C320.175 137.012 310.781 140 299.044 140C287.308 140 277.914 137.039 270.861 131.117C263.809 125.195 260.283 115.828 260.283 103.015ZM356.703 132.409V27.4293C356.703 25.2759 357.725 23.6608 359.771 22.5841C361.817 21.5074 364.293 20.969 367.201 20.969C370.108 20.969 372.584 21.5074 374.63 22.5841C376.676 23.6608 377.699 25.2759 377.699 27.4293V120.619H417.106C419.044 120.619 420.579 121.534 421.709 123.365C422.84 125.195 423.405 127.349 423.405 129.825C423.405 132.301 422.84 134.455 421.709 136.285C420.579 138.116 419.044 139.031 417.106 139.031H365.908C363.432 139.031 361.279 138.439 359.448 137.254C357.618 136.07 356.703 134.455 356.703 132.409ZM434.872 132.409V31.467C434.872 27.9138 435.868 25.2759 437.86 23.5532C439.852 21.8304 442.355 20.969 445.37 20.969C449.354 20.969 452.423 21.6689 454.576 23.0686C456.729 24.4684 459.098 27.4832 461.682 32.1131L481.548 68.2907L501.413 32.1131C503.997 27.4832 506.393 24.4684 508.6 23.0686C510.808 21.6689 513.903 20.969 517.887 20.969C520.902 20.969 523.405 21.8304 525.397 23.5532C527.389 25.2759 528.385 27.9138 528.385 31.467V132.409C528.385 134.455 527.335 136.07 525.236 137.254C523.136 138.439 520.686 139.031 517.887 139.031C514.98 139.031 512.503 138.439 510.458 137.254C508.412 136.07 507.389 134.455 507.389 132.409V62.961L488.493 96.5545C486.985 99.354 484.616 100.754 481.386 100.754C478.264 100.754 475.949 99.354 474.441 96.5545L455.868 61.6689V132.409C455.868 134.455 454.818 136.07 452.719 137.254C450.619 138.439 448.17 139.031 445.37 139.031C442.463 139.031 439.987 138.439 437.941 137.254C435.895 136.07 434.872 134.455 434.872 132.409ZM539.529 130.31C539.529 130.094 539.637 129.556 539.852 128.694L571.023 27.1063C571.669 24.8452 573.257 23.0956 575.787 21.8573C578.318 20.6191 581.198 20 584.428 20C587.658 20 590.565 20.6191 593.149 21.8573C595.734 23.0956 597.349 24.8452 597.995 27.1063L629.166 128.694C629.381 129.556 629.489 130.094 629.489 130.31C629.489 132.678 628.035 134.724 625.128 136.447C622.221 138.17 619.26 139.031 616.245 139.031C612.261 139.031 609.892 137.631 609.139 134.832L603.001 113.351H566.016L559.879 134.832C559.125 137.631 556.756 139.031 552.773 139.031C549.65 139.031 546.662 138.197 543.809 136.528C540.956 134.859 539.529 132.786 539.529 130.31ZM570.377 96.8775H598.479L584.428 47.2948L570.377 96.8775Z"
fill="black" class="bd-svg-black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 110L10 40L50 0L100 50L70 80L110 120L50 160L0 110Z"
fill="#00D1B2"/>
</svg>
</a>
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item">
Home
</a>
<a class="navbar-item">
Documentation
</a>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">
More
</a>
<div class="navbar-dropdown">
<a class="navbar-item">
About
</a>
<a class="navbar-item is-selected">
Jobs
</a>
<a class="navbar-item">
Contact
</a>
<hr class="navbar-divider">
<a class="navbar-item">
Report an issue
</a>
</div>
</div>
</div>
<div class="navbar-end">
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary">
<strong>Sign up</strong>
</a>
<a class="button is-light">
Log in
</a>
</div>
</div>
</div>
</div>
</nav>
{% block content %}<div></div>{% endblock content %}
{% block content %}{% endblock content %}
</body>
</html>

View File

@ -1,8 +1,8 @@
{% extends "base" %}
{% extends "nav" %}
{% block title %}交易{% endblock title %}
{% block content %}
{% block container %}
<div class="">
<table class="table is-fullwidth is-striped">
<table class="table is-fullwidth is-striped is-bordered">
<thead>
<tr>
<th>代码</th>
@ -10,53 +10,68 @@
<th>买入日期</th>
<th>买入价</th>
<th>成交量</th>
<th><abbr title="买入+佣金+过户费等各种手续费">实际买入</abbr></th>
<th><abbr title="买入金额+佣金+过户费等各种手续费">实际买入</abbr></th>
<th>卖出日期</th>
<th>卖出价</th>
<th>成交量</th>
<th><abbr title="卖出价-佣金-各种手续费">实际卖出价</abbr></th>
<th><abbr title="卖出金额-佣金-各种手续费">实际卖出</abbr></th>
<th>收益</th>
<th>实际收益</th>
<th><abbr title="已完成">O</abbr></th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for r in rows %}
<tr>
{% if r.split_pieces %}
{% for p in r.split_pieces %}
<tr class="{% if r.is_done %}{% if r.net_gain|float > 0 %}is-success{% else %}is-danger{% endif %}{% else %}is-warning{% endif %}">
{% if loop.index == 1 %}
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">{{ r.code }}</td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">{{ r.name }}</td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">{{ r.date }}</td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">{{ r.buy }}</td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">{{ r.volume }}</td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">{{ r.net_buy }}</td>
<td>{{ p.date or "" }}</td>
<td>{{ p.sell or "" }}</td>
<td>{{ p.volume or "" }}</td>
<td>{{ p.net_sell or "" }}</td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">{{ (r.gain or 0)|float|round(4) }}%</td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">{{ (r.net_gain or 0)|float|round(4) }}%</td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">
<a href="#">修改</a>
</td>
{% else %}
<td>{{ p.date or "" }}</td>
<td>{{ p.sell or "" }}</td>
<td>{{ p.volume or "" }}</td>
<td>{{ p.net_sell or "" }}</td>
{% endif %}
</tr>
{% endfor %}
{% else %}
<tr class="is-warning">
<td>{{ r.code }}</td>
<td>{{ r.name }}</td>
<td>{{ r.date }}</td>
<td>{{ r.buy }}</td>
<td>{{ r.volume }}</td>
<td>{{ r.net_buy }}</td>
{% if r.split_pieces %}
<td></td>
<td></td>
<td>}</td>
<td></td>
{% else %}
<td>{{ r.sell_date or "" }}</td>
<td>{{ r.sell or "" }}</td>
<td>{{ r.sold_volume or "" }}</td>
<td>{{ r.net_sell or "" }}</td>
{% endif %}
<td>{{ r.gain or "" }}</td>
<td>{{ r.net_gain or "" }}</td>
<td>
{% if r.sold_volume == r.volume %}
{% else %}
{% endif %}
</td>
<td>
<a href="#">卖出</a>
</td>
<td></td>
<td>-</td>
<td>-</td>
<td><a href="#">修改</a></td>
</tr>
{% endif %}
{% endfor %}
<tr class="is-light">
<td colspan="14" style="text-align: center"><a id="addEntry">添加</a></td>
</tr>
</tbody>
</table>
</div>
{% endblock content %}
{% endblock container %}

View File

@ -0,0 +1,29 @@
{% extends "base" %}
{% block content %}
<nav class="navbar" role="navigation" aria-label="main navigation">
<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item" href="/">Home</a>
<a class="navbar-item">Report</a>
<!-- <div class="navbar-item has-dropdown is-hoverable">-->
<!-- <a class="navbar-link">More</a>-->
<!-- <div class="navbar-dropdown">-->
<!-- <a class="navbar-item">About</a>-->
<!-- <a class="navbar-item is-selected">Jobs</a>-->
<!-- <hr class="navbar-divider">-->
<!-- <a class="navbar-item">Report an issue</a>-->
<!-- </div>-->
<!-- </div>-->
</div>
<!-- <div class="navbar-end">-->
<!-- <div class="navbar-item">-->
<!-- <div class="buttons">-->
<!-- <a class="button is-primary"><strong>Sign up</strong></a>-->
<!-- <a class="button is-light">Log in</a>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</div>
</nav>
{% block container %}{% endblock container %}
{% endblock content %}

View File

@ -0,0 +1,61 @@
<div class="">
<table class="table is-fullwidth is-striped">
<thead>
<tr>
<th>代码</th>
<th>名称</th>
<th>买入日期</th>
<th>买入价</th>
<th>成交量</th>
<th><abbr title="买入价+佣金+过户费等各种手续费">实际买入价</abbr></th>
<th>卖出日期</th>
<th>卖出价</th>
<th>成交量</th>
<th><abbr title="卖出价-佣金-各种手续费">实际卖出价</abbr></th>
<th>收益</th>
<th>实际收益</th>
<th><abbr title="已完成">O</abbr></th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for r in rows %}
<tr>
<td>{{ r.code }}</td>
<td>{{ r.name }}</td>
<td>{{ r.date }}</td>
<td>{{ r.buy }}</td>
<td>{{ r.volume }}</td>
<td>{{ r.net_buy }}</td>
{% if r.split_pieces %}
<td></td>
<td></td>
<td>}</td>
<td></td>
{% else %}
<td>{{ r.sell_date or "" }}</td>
<td>{{ r.sell or "" }}</td>
<td>{{ r.sold_volume or "" }}</td>
<td>{{ r.net_sell or "" }}</td>
{% endif %}
<td>{{ r.gain or "" }}</td>
<td>{{ r.net_gain or "" }}</td>
<td>
{% if r.sold_volume == r.volume %}
{% else %}
{% endif %}
</td>
<td>
<a href="#">修改</a>
</td>
</tr>
{% endfor %}
<tr>
<td colspan="14" style="text-align: center"><a id="addEntry">添加</a></td>
</tr>
</tbody>
</table>
</div>