{ "why": "DS-A is single-sided expenditure lines. Every task above JE-01 assumes double-entry structure, so the transformation is a prerequisite, not a detail.", "steps": [ "Group DS-A rows by payment_id → one JE header. payment_id is the natural batch key; invoice_line_number and invoice_line_distribution_number become line detail.", "Debit: the expense account from `account`, carrying department / fund_code / program as the coding block.", "Credit: cash if payment_method settles immediately (e.g. Automated Clearing House), otherwise AP — one credit leg per header, so headers foot by construction before defects are injected.", "Period: derive from fiscal_year + fiscal_year_period. Posting timestamp from load_dttm; transaction date from invoice_date; settlement date from payment_date. Keeping all three distinct is what makes JE-03 and JE-16 possible.", "Preparer: assign a synthetic user per department with a plausible activity distribution — DS-A has no user field and JE-12 needs one.", "Entry source: mark interface vs manual. Derive interface batches from load_dttm clustering (the microsecond timestamps cluster naturally), and designate a minority as manual — manual entries are where L3 and L4 defects live.", "Only then inject defects, from the defect ledger, so every seeded defect has a known clean counterfactual." ] }