test(core): the adapter runs a platform's payout, an asset's tag and the K-1's tax-basis note through the engine
The bookspec schema gained a `payout` event, a `tag_asset` event, an `asset_tag` query and a note on the tax-basis property line (BS-revenue-1, BS-asset-3, BS-partner-17). The adapter runs each through the engine and rebuilds none of it: a payout goes through `payouts::payout_plan`, which refuses unless gross less fee is the deposit to the cent, and its plan's lines post as one entry; a tag goes through `Store::set_asset_tag`, which refuses a tag of a wrong form and one another asset holds or ever held; the tax-basis line's note is `Note::PrepaidAtBook` read off the worksheet. The engine's InvalidPayout, InvalidAssetTag and AssetTagTaken are worded as the examples word them. Thirteen examples were added and every one the engine's picks reach passes: five are for options wanderbooks did not pick (no-tags, every-prepaid-is-cash, every-prepaid-is-property, left-open, whole-payment-to-each) and are skipped, so the skipped count is 22 + 5 = 27 and 112 of 139 run. A prepaid contract credited straight to capital is property (1,500.00 each) and a service paid through Due to Members is cash (1,000.00 each); the contract enters the tax capital at its book amount with the note; a 1,000.00 check naming Dana Studio at 600.00 counts 600.00 toward Dana's 1099. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e45c62348a
commit
a87e2d0a7a
8 files changed
+138
-11
No files matched your search
@@ -196,6 +196,19 @@ impl Books<'_> {
|
||||
]))
|
||||
}
|
||||
|
||||
/// The tag the asset carries, or `"none"` (BS-asset-3).
|
||||
pub(crate) fn answer_asset_tag(&self, q: &Query) -> Result<Value, Refusal> {
|
||||
let name = q.asset.as_deref().ok_or_else(|| self.missing("asset"))?;
|
||||
let a = self
|
||||
.l()
|
||||
.get_asset(self.asset(name, name))
|
||||
.expect("a registered asset");
|
||||
Ok(json_figures([(
|
||||
"tag".to_string(),
|
||||
a.tag.clone().unwrap_or_else(|| "none".to_string()),
|
||||
)]))
|
||||
}
|
||||
|
||||
pub(crate) fn answer_asset_basis(&self, q: &Query) -> Result<Value, Refusal> {
|
||||
let name = q.asset.as_deref().ok_or_else(|| self.missing("asset"))?;
|
||||
let a = self
|
||||
@@ -443,6 +456,25 @@ pub(crate) fn check_register_totals(b: &Books<'_>, x: &Expect) {
|
||||
named(ex, x, &what, &figures);
|
||||
}
|
||||
|
||||
/// Check one `asset_tag` expectation: the tag the asset carries now, or
|
||||
/// `"none"` (BS-asset-3); every value listed.
|
||||
pub(crate) fn check_asset_tag(b: &Books<'_>, x: &Expect) {
|
||||
let ex = b.ex;
|
||||
undated(ex, x);
|
||||
let name = x
|
||||
.asset
|
||||
.as_deref()
|
||||
.unwrap_or_else(|| panic!("{}: asset_tag names its asset", ex.id));
|
||||
let what = format!("{} asset_tag of {name}", ex.id);
|
||||
let a = b
|
||||
.l()
|
||||
.get_asset(b.asset(name, &what))
|
||||
.expect("a registered asset");
|
||||
exactly(ex, x, &BTreeSet::from(["tag".to_string()]));
|
||||
let got = a.tag.clone().unwrap_or_else(|| "none".to_string());
|
||||
assert_eq!(got, x.figures(&ex.id)["tag"], "{what}: tag");
|
||||
}
|
||||
|
||||
/// Check one `asset_basis` expectation: the asset's basis facts and the
|
||||
/// tax figures they give (BS-asset-4): `rule`,
|
||||
/// `contributor_adjusted_basis`, `fmv_at_contribution`, `tax_basis_723`,
|
||||
|
||||
@@ -104,6 +104,7 @@ impl Books<'_> {
|
||||
"register_row" => self.answer_register_row(q),
|
||||
"register_totals" => self.answer_register_totals(q),
|
||||
"asset_basis" => self.answer_asset_basis(q),
|
||||
"asset_tag" => self.answer_asset_tag(q),
|
||||
"period" => {
|
||||
let (from, to) = self.q_period(q)?;
|
||||
Ok(json_figures([
|
||||
|
||||
@@ -43,6 +43,10 @@ impl Books<'_> {
|
||||
format!("{name}.contributions_cash"),
|
||||
Value::String(figure(row.contributions_cash)),
|
||||
);
|
||||
m.insert(
|
||||
format!("{name}.contributions_property_note"),
|
||||
Value::String(property_note(&row.contributions_property).to_string()),
|
||||
);
|
||||
for (line, tax) in [
|
||||
("beginning", &row.beginning),
|
||||
("contributions_property", &row.contributions_property),
|
||||
@@ -173,6 +177,10 @@ pub(crate) fn check_k1_tax_basis(b: &Books<'_>, x: &Expect) {
|
||||
format!("{m}.contributions_cash"),
|
||||
figure(row.contributions_cash),
|
||||
);
|
||||
figures.insert(
|
||||
format!("{m}.contributions_property_note"),
|
||||
property_note(&row.contributions_property).to_string(),
|
||||
);
|
||||
for (line, tax) in [
|
||||
("beginning", &row.beginning),
|
||||
("contributions_property", &row.contributions_property),
|
||||
@@ -191,6 +199,23 @@ pub(crate) fn check_k1_tax_basis(b: &Books<'_>, x: &Expect) {
|
||||
named(ex, x, &what, &figures);
|
||||
}
|
||||
|
||||
/// The note a property line carries (BS-partner-17): `prepaid_at_book` when
|
||||
/// property contributed to a prepaid account with no fixed asset behind it
|
||||
/// was taken at its book amount for the preparer to confirm, `none` when the
|
||||
/// line carries no note.
|
||||
fn property_note(line: &ledger_core::tax_capital::TaxLine) -> &'static str {
|
||||
use ledger_core::tax_capital::Note;
|
||||
if line
|
||||
.notes
|
||||
.iter()
|
||||
.any(|n| matches!(n, Note::PrepaidAtBook { .. }))
|
||||
{
|
||||
"prepaid_at_book"
|
||||
} else {
|
||||
"none"
|
||||
}
|
||||
}
|
||||
|
||||
/// The causes `k1_reconciliation` reports, each member's every one.
|
||||
pub(crate) const RECONCILING_CAUSES: [&str; 5] = [
|
||||
"beginning",
|
||||
|
||||
Reference in new issue
Block a user