mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 09:45:36 +00:00
fix(cli): no totals line for one investor side
A foreign- or domestic-only summary has no totals now, so the table says why instead of printing "Total - IDR". The CLI test checks the nulls and the table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V3syn2fN2LNo5pvTSqc6eh
This commit is contained in:
parent
860d4daf77
commit
ae7a1e2b5c
2 changed files with 36 additions and 12 deletions
|
|
@ -978,6 +978,7 @@ pub fn print_broker_summary(summary: &BrokerSummary) -> Result<(), IdxError> {
|
|||
}
|
||||
println!("{table}");
|
||||
|
||||
if summary.total_value.is_some() {
|
||||
let mut totals = format!(
|
||||
"Total {} IDR, {} lots",
|
||||
format_compact_option(summary.total_value),
|
||||
|
|
@ -990,6 +991,9 @@ pub fn print_broker_summary(summary: &BrokerSummary) -> Result<(), IdxError> {
|
|||
totals.push_str(&format!("; foreign net {:+}", format_compact(net)));
|
||||
}
|
||||
println!("{totals}.");
|
||||
} else if summary.investor != BrokerInvestor::All {
|
||||
println!("No totals: for one investor side the source totals only that side's buying.");
|
||||
}
|
||||
for (kind, label) in [
|
||||
(BrokerKind::Foreign, "Foreign brokers"),
|
||||
(BrokerKind::StateOwned, "State-owned brokers"),
|
||||
|
|
|
|||
|
|
@ -2495,7 +2495,27 @@ fn broker_summary_json_names_brokers_and_keeps_source_totals() {
|
|||
assert_eq!(filtered["investor"], "foreign");
|
||||
assert_eq!(filtered["board"], "regular");
|
||||
assert_eq!(filtered["buyers"][0]["code"], "KZ");
|
||||
assert!(filtered["foreign_net_value"].is_null());
|
||||
for field in [
|
||||
"total_value",
|
||||
"total_lots",
|
||||
"average_price",
|
||||
"foreign_net_value",
|
||||
] {
|
||||
assert!(filtered[field].is_null(), "{field}: {filtered}");
|
||||
}
|
||||
let table = run_success_stdout(mock_bin("broker-filtered-table").args([
|
||||
"stocks",
|
||||
"broker",
|
||||
"BBCA",
|
||||
"--date",
|
||||
"2026-10-16",
|
||||
"--investor",
|
||||
"foreign",
|
||||
"--board",
|
||||
"regular",
|
||||
]));
|
||||
assert!(!table.contains("Total "), "{table}");
|
||||
assert!(table.contains("No totals"), "{table}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue