Ledger Current Account Design - RodrigoMattosoSilveira/EnterpriseRemoteSystems GitHub Wiki
14.1 Summary formulas
For each currency independently:
credits = sum(total_price where cd_flag = CREDIT and active)
debits = sum(total_price where cd_flag = DEBIT and active)
balance = credits - debits
14.2 Projected earnings
Projected earnings should be computed separately from posted balances and shown as an estimate.
Recommended formula:
projected_earnings = posted_earnings_to_date + estimated_remaining_earnings_to_projected_end
Estimated remaining earnings by method
- daily wages: remaining eligible workdays × daily rate
- salary: remaining days × normalized daily salary
- commission: estimated based on configurable rolling average production or last known average
Because commission projection is uncertain, the UI should label it explicitly as estimated and show basis.
14.3 Reversal rules
- original entry stays immutable
- reversal entry mirrors source, currency, quantity, and amount
- reversal flips credit/debit
- both entries become linked