One payment had to name one document and could take no discount or processor fee, so paying several invoices from one deposit meant several entries and the fee had nowhere to go. This adds the kernel's exact settlement arithmetic (applications total, net deposit), a Ledger::settle that posts one entry for a customer's or vendor's documents, and the gross method and gross fee A-8/A-4 chose. - kernel::settle: sum(cash)+sum(discounts)=applications, sum(cash)-fee= deposit, None on overflow or a negative deposit. Kani settle_is_exact plus the Decimal bridge. - Ledger::settle / settlement_lines: one party and one kind per settlement, one application per document, each cash+discount within payment_room; a discount within the terms (discount_max and discount_by) needs no reason, a larger or later one does; a bill with an asset line is refused with D-49's remedy; a fee is a customer payment's only and posts gross. - Rows are payment lines in application order, then discount lines, the fee line and the cash line, so a journaled event's line indices are stable; replay tags exactly the line an event names and leaves an unmatched line unattached (never refuses). - receive_payment_with and pay_bill_with become one-application calls. - Roles: sales_allowances (4100), purchase_discounts (6995) and payment_processing_fees (6060), constants used on demand but not added to control_accounts() (existing charts may use those codes for other things). - Lean: settle posts through Step.document, so settle_posts_a_document_step and settle_unattached, no new constructor; both in Audit.lean. - Core tests: bill_on_terms_with_discount, late_discount_needs_a_reason, discount_on_an_asset_bill_is_refused_with_the_remedy, a_fee_posts_gross_to_receivables_and_net_to_the_bank, a_settlement_names_its_lines_and_refuses_a_document_twice, and equipment_bill_payment_is_investing_cash in the cash-flow suite. - Bookspec B-42 is stated, with its id BS-arap-6; the catalogue and index now record it as CONVENTION. just check and just prove green.
101 lines
3.6 KiB
Lean4
101 lines
3.6 KiB
Lean4
import Wanderbooks
|
|
|
|
/-! `just prove` runs this file: each headline theorem's axioms are printed,
|
|
and must be only Lean's standard three (`propext`, `Quot.sound`,
|
|
`Classical.choice`) or fewer. No `sorryAx`, nothing assumed. -/
|
|
|
|
open Wanderbooks
|
|
|
|
#print axioms Accepted.net_zero
|
|
#print axioms sum_movements
|
|
#print axioms movement_with_reversal
|
|
#print axioms accepted_reversal_iff
|
|
#print axioms accounting_equation
|
|
#print axioms balance_after_line
|
|
#print axioms trial_balance_iff
|
|
#print axioms closingEntry_net
|
|
#print axioms closingEntry_zeroes
|
|
#print axioms closingEntry_accepted
|
|
#print axioms net_closings_is_net_income
|
|
#print axioms plugLast_total
|
|
#print axioms plugLast_keeps
|
|
#print axioms runPart_telescopes
|
|
#print axioms closePart_total
|
|
#print axioms trueUp_total
|
|
#print axioms trueUp_running
|
|
#print axioms closePart_eq_trueUp
|
|
#print axioms cumulative_drift
|
|
#print axioms statement_after_close
|
|
#print axioms statement_unmoved_by_close
|
|
#print axioms Reachable.inv
|
|
#print axioms Reachable.books_net_zero
|
|
#print axioms Reachable.trial_balance
|
|
#print axioms Reachable.trial_balance_through
|
|
#print axioms Reachable.accounting_equation
|
|
#print axioms Reachable.accounting_equation_through
|
|
#print axioms Steps.extends
|
|
#print axioms Steps.frozen
|
|
#print axioms close_zeroes
|
|
#print axioms close_credits_net_income
|
|
#print axioms statements_add_up
|
|
#print axioms Apportion.ranks_perm
|
|
#print axioms Apportion.apportion_sum
|
|
#print axioms Apportion.apportion_sum_of_shortfall
|
|
#print axioms Apportion.rem_pos_of_rank_lt
|
|
#print axioms Apportion.apportion_drift
|
|
#print axioms Apportion.allocW_sum
|
|
#print axioms Apportion.allocW_drift
|
|
#print axioms Apportion.allocW_cumulative_drift
|
|
#print axioms Apportion.allocW_cumulative_total
|
|
#print axioms Step.record_changes_no_figure
|
|
#print axioms Reachable.records
|
|
#print axioms net_splits_by_flow
|
|
#print axioms applyCash_conserves
|
|
#print axioms applyCash_exhausts
|
|
#print axioms applyCash_neg
|
|
#print axioms entry_flows_sum
|
|
#print axioms flows_reversal
|
|
#print axioms constructive_nets
|
|
#print axioms constructive_neg
|
|
#print axioms constructive_sections_net
|
|
#print axioms stmt_flows_sum
|
|
#print axioms stmt_flows_reversal
|
|
#print axioms cashflow_sections_sum_to_cash_change
|
|
#print axioms secNet_cash_is_movement
|
|
#print axioms operating_reconciliation_ties
|
|
#print axioms operating_reconciliation_ties_all
|
|
#print axioms cashflow_reversal_nets
|
|
#print axioms Reachable.cashflow_foots
|
|
#print axioms Reachable.cashflow_is_change_in_cash
|
|
#print axioms reverseTarget_involutive
|
|
#print axioms capitalTarget_odd
|
|
#print axioms partyTarget_odd
|
|
#print axioms sumOver_movement_reversal
|
|
#print axioms Prorate.cum_mono
|
|
#print axioms Prorate.cum_le
|
|
#print axioms Prorate.cum_full
|
|
#print axioms Prorate.parts_telescope
|
|
#print axioms Prorate.prorate_total
|
|
#print axioms Prorate.prorate_nonneg
|
|
#print axioms Prorate.part_within_a_unit
|
|
#print axioms Prorate.roundUnit_near
|
|
#print axioms Prorate.roundUnit_scale
|
|
#print axioms Prorate.cum_near
|
|
#print axioms Prorate.cum_dvd
|
|
#print axioms Prorate.part_near
|
|
#print axioms Prorate.chargeMid_eq_cum
|
|
#print axioms Prorate.chargeLast_eq_cum
|
|
#print axioms Prorate.chargeLast_start
|
|
#print axioms Prorate.chargeLast_mono
|
|
#print axioms Prorate.kernel_parts_total
|
|
#print axioms Prorate.kernel_parts_nonneg
|
|
#print axioms Documents.control_agrees
|
|
#print axioms Documents.control_agrees_through
|
|
#print axioms Documents.Step.document_unattached
|
|
#print axioms Documents.settle_posts_a_document_step
|
|
#print axioms Documents.settle_unattached
|
|
#print axioms Documents.Step.reverse_moves
|
|
#print axioms Documents.reverse_twice
|
|
#print axioms Documents.Reachable.unattached_zero
|
|
#print axioms Documents.Reachable.control_is_documents
|