refactor(core): proportional shares in the kernel, one copy

The K-1/1065 worksheet, the 1099 worksheet, the parties' shares, the
conventions' template split and the cash-flow government split each
computed "whole x weight / total, round, hand out the leftover" for
themselves. Six copies meant six places for a rounding or sign change to
reach a filed figure.

Put the shape in kernel::allocate: share_of (the engine's division,
rounded at Decimal's 28 significant digits, truncating on a machine
integer), share_floor_with (the exact floor to a step by multiplication,
the 1099 correction loop's arithmetic), and split_by_weights_with (the
split, with the leftover policy named: largest remainder, first absorbs,
last absorbs; the running policy stays apportion_cumulative). Each site
keeps its own mode, step, sign and leftover policy, so every figure is
the same to the digit; the frozen periods rules only gain a doc line
naming the kernel policy they equal.

Amount gains checked_div, the engine's division as distinct from
checked_div_exact.

All goldens and existing tests pass unchanged.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
This commit is contained in:
swaitsandDeepSeek V4.1 Flash committed 2026-11-09 00:14:26 -07:00
1 parent 127d33fb0b
commit 24b59e7b85
9 files changed
+394 -84

No files matched your search

+8
View File
@@ -120,6 +120,10 @@ pub struct MemberClose {
/// (owner, 2026-10-13). A loss splits as the negation of the same gain.
/// Closes journaled under the rules of 2026-10-13 replay with it, in cents
/// whatever the currency; new closes split with [`allocate_cumulative`].
/// The arithmetic equals [`crate::kernel::split_by_weights_with`] with
/// total one, the cent as its step, toward zero and
/// [`crate::kernel::Leftover::LargestRemainder`], the sign applied after;
/// it stays here, frozen, because posted closes replay with it.
pub fn allocate(
amount: rust_decimal::Decimal,
shares: &[rust_decimal::Decimal],
@@ -180,6 +184,10 @@ pub fn allocate_last_absorbs(
/// (replay of a legacy close with a huge journaled amount, BS-entry-4).
/// The same split, to the cent, for every amount [`allocate_last_absorbs`]
/// accepts: this is the frozen rule, only its overflow now an error.
/// The arithmetic equals [`crate::kernel::split_by_weights_with`] with
/// total one, the cent as its step, half away from zero and
/// [`crate::kernel::Leftover::LastAbsorbs`]; it stays here, frozen,
/// because posted closes replay with it.
pub fn try_allocate_last_absorbs(
amount: rust_decimal::Decimal,
shares: &[rust_decimal::Decimal],