merge: the adapter runs settlements, recoveries, invoice numbers and vendor references; a fee above the cash is its own refusal (X-H1b's wanderbooks half; reviewed, re-checked)
Wanderbooks passes every bookspec example for the options it picked: 80 run, 80 passed, 11 for options it did not pick. The settlement refusal that read a fee above the cash out of one half of an error message's 'or' is now a typed refusal (LedgerError::FeeAboveCash), checked before the kernel's settle at the same point, so no refusal's order changes; the remaining message names only what is left (an amount too large, a negative fee). BS-arap-10's pick is ignore-case-spaces-and-hyphens, as plan P4b S4 decided and the engine always did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
81bc16c386
11 files changed
+377
-23
No files matched your search
@@ -6703,9 +6703,22 @@ impl Ledger {
|
||||
discounts.push(app.discount);
|
||||
}
|
||||
let fee_amount = params.fee.as_ref().map_or(Decimal::ZERO, |f| f.amount);
|
||||
// A fee above the cash is its own refusal; the kernel would also
|
||||
// answer `None` for it, with no way to say which of its refusals it
|
||||
// was. A sum that overflows is left to the kernel (too large).
|
||||
if let Some(total_cash) = cash
|
||||
.iter()
|
||||
.try_fold(Decimal::ZERO, |sum, c| sum.checked_add(*c))
|
||||
&& fee_amount > total_cash
|
||||
{
|
||||
return Err(LedgerError::FeeAboveCash {
|
||||
fee: fee_amount,
|
||||
cash: total_cash,
|
||||
});
|
||||
}
|
||||
let settlement = kernel::settle(&cash, &discounts, fee_amount).ok_or_else(|| {
|
||||
LedgerError::InvalidSettlement(
|
||||
"the cash and discounts don't cover the applications exactly, or the fee is above the cash"
|
||||
"the settlement's figures aren't exact: an amount is too large, or the fee is negative"
|
||||
.into(),
|
||||
)
|
||||
})?;
|
||||
|
||||
Reference in new issue
Block a user