aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/store/ledger.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/app/store/ledger.rs b/src/app/store/ledger.rs
index 841f7b3..df65b58 100644
--- a/src/app/store/ledger.rs
+++ b/src/app/store/ledger.rs
@@ -9,7 +9,7 @@ pub struct EstimatedLedger<'a> {
pub equity_change_events: Vec<&'a EquityChangeEvent>,
pub account_symbol_quantity: BigDecimal,
pub account_symbol_cost_basis_price: BigDecimal,
- pub account_symbol_cost_basis_total_usd: BigDecimal,
+ pub account_symbol_cost_basis_total: BigDecimal,
pub account_symbol_last_effective_price: BigDecimal,
pub account_symbol_last_update_timestamp: chrono::DateTime<chrono::Utc>,
}
@@ -41,13 +41,15 @@ impl EstimatedLedger<'_> {
acsym_events.push(event);
}
+ let cost_basis_price = (cost_basis_total.clone() / quantity.clone()).with_scale_round(2, ROUNDING_MODE);
+
EstimatedLedger {
fiduciary_account,
equity_symbol,
equity_change_events: acsym_events,
- account_symbol_quantity: quantity.clone(),
- account_symbol_cost_basis_price: (cost_basis_total.clone() / quantity).with_scale_round(2, ROUNDING_MODE),
- account_symbol_cost_basis_total_usd: cost_basis_total.with_scale_round(2, ROUNDING_MODE),
+ account_symbol_quantity: quantity,
+ account_symbol_cost_basis_price: cost_basis_price,
+ account_symbol_cost_basis_total: cost_basis_total.with_scale_round(2, ROUNDING_MODE),
account_symbol_last_effective_price: last_event.map_or_else(|| BigDecimal::zero().with_scale(2), |ev| ev.estimated_price()),
account_symbol_last_update_timestamp: last_event.map_or_else(|| chrono::DateTime::<chrono::Utc>::MIN_UTC, |ev| ev.equity_change_timestamp),
}