diff --git a/docs/rule-decisions.md b/docs/rule-decisions.md index a7cdb331..6ffe8126 100644 --- a/docs/rule-decisions.md +++ b/docs/rule-decisions.md @@ -190,7 +190,9 @@ A row that names a pull request is in the code of that branch until it merges. | A145 | 2026-11-27 | Form 8908 / Form 3800 | Form 8908 gives a homebuilder a credit for each new energy efficient home sold or leased; line 7 adds the same credit passed through on partnership and S corporation K-1s (code AM). With K-1s that show cents, is each K-1 rounded before the add, or only the total? | Form 1040 instructions: "include cents when adding the amounts and round off only the total" (`irs-1040-inst-2025::sec::rounding-off-to-whole::b01`). | Line 8 goes to Form 3800 line 1p (`irs-8908-face-2025::sec::face-page-2::b01`), whose Part V lists each pass-through entity's credit by its EIN, one whole-dollar amount each (`irs-3800-inst-2025::sec::part-v-3::b01`). | Text B, the same rule as row A96 (Form 8846 line 5) and Form 8826 line 7: each K-1 rounds first, so line 8 equals Form 3800 line 1p. | At most $1 for each K-1. | `federal/8908/resolveInfo.ts` | Silent: the statute sets no rounding. | | A146 | 2026-11-27 | Form 8908 | Items A to C ask, for each home the builder claims, whether the builder built it, had a basis in it and had it certified before the sale. One of several homes answers No. Is the credit lost for every home, or only for that one? | The items: "For each home for which you are claiming the credit, ..." (`irs-8908-inst-2025::sec::specific-instructions::b01`). | The form: "If you answered 'No' to question A, B, or C, STOP, you cannot claim the credit" (`irs-8908-face-2025::sec::face-page-1::b02`). | Text A: a home that answers No is not claimed, and the items show Yes for the homes that are. The form stops only when no home is left. The credit is "for each qualified new energy efficient home" (`irs-8908-inst-2025::sec::purpose-of-form::b01`), so one home that fails does not take the others' credit away. | Yes: in the made-up taxpayer `edelle`, a house that was not certified in time loses its $2,500, not the whole $20,000. | `federal/8908/resolveInfo.ts` | 45L(a)(1): supports. The credit is "the applicable amount for each qualified new energy efficient home". | | A147 | 2026-11-28 | FTB 3503 / Schedule P (540) | FTB 3503 gives a California credit of 55% of the value of land given with the Wildlife Conservation Board's approval. On Schedule P (540) it is one of the Section B2 credits that share the tax left, one after another. Where does it go in that order? | Section B2: "Generally, it is to your advantage to apply credits with limited carryovers before credits with no limitation on carryover. However, you may apply credits with no limitation on carryover first, if that is to your advantage" (`ca-540-sched-p-inst-2025::sec::section-b2-instructions::b01`). | FTB 3503: a credit from 2015 on carries over "15 years or until exhausted" (`ca-3503-form-2025::sec::f-carryover::b01`); the low-income housing credit is "required to be applied after any business credits are applied" (`ca-540-sched-p-inst-2025::sec::how-to-compute-the-limitation::b01`); the enterprise zone and TTA carryovers have 10 years (A90 to A92). | After the motion picture, enterprise zone and TTA credits, before the research, orphan drug and low-income housing credits: a limited carryover goes before an unlimited one, and the longer 15-year carryover after the 10-year ones. One order for every return. | None in the made-up taxpayer `kari` (one credit). Only when the tax left cannot cover all: with a $10,000 TTA carryover, $20,000 of this credit and $25,000 of tax, the TTA credit takes $10,000 and this credit $15,000 (the other order: $20,000 and $5,000). | `state/ca/3503/creditUsed.ts` | Silent on the order. R&TC 17053.30(d)(2) sets the 15-year carryover (`ca-rtc-2025::sec::s17053.30::d`). | -| A148 | 2026-11-28 | FTB 3547, Schedule P (540) | FTB 3547 gives a business that hauls donated food to a charity a California credit of half the transport costs (code 204); it offsets tax in Schedule P (540) Section A2, next to FTB 3541's motion picture credits and FTB 3807's LAMBRA credit. In what order are they used? | Section A2: "complete column (a) through column (d) for each credit in each section before going to the next section" (`ca-540-sched-p-inst-2025::sec::section-a2-instructions::b01`): no order inside the section. | Section B2's general rule, credits "with limited carryovers before credits with no limitation" (`::section-b2-instructions::b01`): this credit carries over "until exhausted" (`ca-3547-form-2025::sec::g-carryover::b01`), the film (A75) and LAMBRA (A82) credits for 9 and 10 years. | Text B: code 204 takes the line after the film and LAMBRA credits. One order for every return. | Only when the tax over TMT cannot cover every Section A2 credit; the part of code 204 not used carries over with no limit. In `padan` it is the only Section A2 credit. | `state/ca/3547/creditUsed.ts` | Not in the library: California law. R&TC 17053.12(d) (`ca-rtc-2025::sec::s17053.12::d`): the carryover runs "until the credit has been exhausted". | +| A148 | 2026-11-28 | FTB 3547, Schedule P (540) | FTB 3547 gives a business that hauls donated food to a charity a California credit of half the transport costs (code 204); it offsets tax in Schedule P (540) Section A2, next to FTB 3541's motion picture credits and FTB 3807's LAMBRA credit. In what order are they used? | Section A2: "complete column (a) through column (d) for each credit in each section before going to the next section" (`ca-540-sched-p-inst-2025::sec::section-a2-instructions::b01`): no order inside the section. | Section B2's general rule, credits "with limited carryovers before credits with no limitation" (`::section-b2-instructions::b01`): this credit carries over "until exhausted" (`ca-3547-form-2025::sec::g-carryover::b01`), the film (A75) and LAMBRA (A82) credits for 9 and 10 years. | Text B: code 204 takes the line after the film and LAMBRA credits, and after the disabled access credit (205), which also has no limit: there the Credit Table's printed order decides (A150). One order for every return. | Only when the tax over TMT cannot cover every Section A2 credit; the part of code 204 not used carries over with no limit. In `padan` it is the only Section A2 credit. | `state/ca/3547/creditUsed.ts` | Not in the library: California law. R&TC 17053.12(d) (`ca-rtc-2025::sec::s17053.12::d`): the carryover runs "until the credit has been exhausted". | +| A149 | 2026-11-28 | FTB 3548, Schedule CA (540) | FTB 3548 gives a small business a California credit of 50% of up to $250 of what it spends to make its place accessible, and the business may not also deduct the amount of the credit. By how much does the California deduction fall: the credit for this year's own expenditures (line 4), or the credit claimed on the return (lines 9a and 9b)? | FTB 3548: "Any deduction allowed for these same expenditures must be reduced by the amount of credit claimed and/or assigned to an affiliated corporation for the current taxable year (the amount shown on line 9a and 9b)" (`ca-3548-form-2025::sec::f-limitations::b03`). | FTB Pub 1001, the Schedule CA adjustments guide: "No deduction is permitted for any amount for which a disabled access credit is allowed. California law conforms to this provision, but the maximum credit is $125" (`ftb-pub-1001-2025::sec::enter-on-schedule-ca-540-part-i-or-7::b04`). | Text B: Schedule CA (540) line 3 column C takes off line 4. Line 9a also holds the K-1 credits and last year's carryover, which are not credits for this year's expenditures, and it depends on the tax, which depends on this deduction. | Only when the tax limits line 9a or line 9a holds a K-1 credit or a carryover. In the `leya` scenario column C is $125, not $471. | `state/ca/3548/resolveInfo.ts` | R&TC 17053.42(a) allows the credit "in accordance with Section 44" (`ca-rtc-2025::sec::s17053.42::a`); section 44(d)(7) denies a deduction for "the amount of the credit determined under this section" (`usc-26-2025::sec::s44::d-7`): the credit determined, as text B. | +| A150 | 2026-11-28 | FTB 3548, Schedule P (540) | FTB 3548's disabled access credit (code 205) offsets tax in Schedule P (540) Section A2, next to FTB 3541's motion picture credits, FTB 3807's LAMBRA credit and FTB 3547's donated agricultural products transportation credit (204). In what order are they used? | Section A2: "complete column (a) through column (d) for each credit in each section before going to the next section" (`ca-540-sched-p-inst-2025::sec::section-a2-instructions::b01`): no order inside the section. | Section B2's general rule, credits "with limited carryovers before credits with no limitation on carryover" (`::section-b2-instructions::b01`); the disabled access credit carries over "until exhausted" (`ca-3548-form-2025::sec::h-carryover::b01`). | Text B applied in Section A2: the disabled access credit takes the line after the film and LAMBRA credits. FTB 3547's credit (204) also carries over "until exhausted" (`ca-3547-form-2025::sec::g-carryover::b01`), so the rule does not order the two; the Credit Table prints 205 before 204 (`ca-540-sched-p-inst-2025::sec::credit-table::b01`), and code 205 takes the line before code 204. One order for every return. | Only when the tax over TMT cannot cover all of them: then the disabled access credit gets what is left, and carries the rest. | `state/ca/3548/creditUsed.ts` | R&TC 17053.42(c): the excess "may be carried over ... until the credit is exhausted" (`ca-rtc-2025::sec::s17053.42::c`). | The last column names the subdivision read in the law library. Rows A33 to A57 were added after the check, so their last column is the author's note, not a read of the statute. On the day of the check the library held the statute only (the regulations were added after it): no regulations, no California law, and no statutory notes, so no effective date was checked. Row 12 was marked for research; section 55(b)(1)(A) settles it: the tentative minimum tax "shall be reduced by the alternative minimum tax foreign tax credit". diff --git a/engine/src/facts/index.ts b/engine/src/facts/index.ts index 59a25736..f841e382 100644 --- a/engine/src/facts/index.ts +++ b/engine/src/facts/index.ts @@ -19,6 +19,7 @@ export * from "./kinds/caAmtCaliforniaAmounts.js"; export * from "./kinds/caCaliforniaAmounts.js"; export * from "./kinds/caChildUnearnedIncome.js"; export * from "./kinds/caDependentCare.js"; +export * from "./kinds/caDisabledAccess.js"; export * from "./kinds/caEarlierYearReturn.js"; export * from "./kinds/caEarnedIncomeCredit.js"; export * from "./kinds/caEmployeeClassification.js"; diff --git a/engine/src/facts/kinds/caDisabledAccess.ts b/engine/src/facts/kinds/caDisabledAccess.ts new file mode 100644 index 00000000..77d6d4c6 --- /dev/null +++ b/engine/src/facts/kinds/caDisabledAccess.ts @@ -0,0 +1,77 @@ +/* + * FTB 3548, the California disabled access credit of an eligible small + * business: 50% of the eligible access expenditures up to $250 + * (ca-3548-form-2025::sec::b-description::b01). + * + * The expenditures and the eligible small business test are the federal + * disabled access facts (disabledAccess.ts): the same expenditures, the same + * test (ca-3548-form-2025::sec::e-definitions::b01), stated once. This kind + * holds what only California asks: + * - one fact per entity that passed a California credit through on a Schedule + * K-1 (100S, 541, 565 or 568) (line 5). The California K-1 itself is not in + * the engine: the credit is stated as the K-1 prints it; + * - last year's carryover (line 7), from the 2024 FTB 3548 line 10; + * - whether the taxpayer's own business is a disregarded single member LLC, + * whose credit has its own limit (ca-3548-form-2025::sec::f-limitations::b02). + */ + +type FactRow = { key: string; value: unknown; category: string }; + +/* Line 5: one entity's pass-through credit (ca-3548-form-2025::sec::line-5-pass-through-disabled-access-credit::b01). */ +export interface CaDisabledAccessPassThroughFactValue { + /* The entity's name, for the schedule the line asks for. */ + entityName: string; + /* The entity's identification number (California corporation number, Secretary of State file number or FEIN). */ + entityId: string; + /* The credit as the Schedule K-1 (100S, 541, 565 or 568) reports it. */ + credit: number; + /* The credit came through a disregarded single member LLC (ca-3548-form-2025::sec::f-limitations::b02). */ + throughDisregardedSmllc?: boolean; +} + +export interface CaDisabledAccessPassThroughFact { + key: string; + value: CaDisabledAccessPassThroughFactValue; +} + +export const CA_DISABLED_ACCESS_KEYS = { + /* + * Line 7: "Credit carryover from prior year" (the form), the 2024 FTB 3548 + * line 10. A number; 0 when none. The credit carries over "until exhausted" + * (ca-3548-form-2025::sec::h-carryover::b01). + */ + carryover: "prior_year.ca_disabled_access_credit_carryover", + /* + * A boolean: the taxpayer's own business that paid the expenditures is a + * disregarded single member LLC. Its credit "that can be utilized is limited + * to the difference between the taxpayer's regular tax figured with the + * income of the disregarded entity, and the taxpayer's regular tax figured + * without" it (ca-3548-form-2025::sec::f-limitations::b02). Absent: the + * taxpayer runs the business directly. + */ + ownBusinessDisregardedSmllc: "ca_disabled_access.own_business_disregarded_smllc", +} as const; + +const PASS_THROUGH_CATEGORY = "state_local_tax"; +const PASS_THROUGH_PREFIX = "ca_disabled_access_pass_through."; + +export function makeCaDisabledAccessPassThroughFactKey(entitySlug: string): string { + return `${PASS_THROUGH_PREFIX}${entitySlug}`; +} + +export function isCaDisabledAccessPassThroughFactKey(key: string): boolean { + const parts = key.split("."); + return parts.length === 2 && `${parts[0]}.` === PASS_THROUGH_PREFIX && parts[1] !== ""; +} + +/* Every pass-through credit fact, in the order recorded. */ +export function getCaDisabledAccessPassThroughFacts( + facts: ReadonlyArray, +): CaDisabledAccessPassThroughFact[] { + return facts + .filter( + (row) => + row.category === PASS_THROUGH_CATEGORY && isCaDisabledAccessPassThroughFactKey(row.key), + ) + .map((row) => ({ key: row.key, value: row.value as CaDisabledAccessPassThroughFactValue })); +} diff --git a/engine/src/federal/8826/QUESTIONS.md b/engine/src/federal/8826/QUESTIONS.md index 25940e0c..a5a4f430 100644 --- a/engine/src/federal/8826/QUESTIONS.md +++ b/engine/src/federal/8826/QUESTIONS.md @@ -16,7 +16,7 @@ The form (Rev. September 2017) and its instructions publish no example with numb 7. **Cents boxes.** Every line is whole dollars (the 1040 rule, `irs-1040-inst-2025::sec::rounding-off-to-whole::b01`). Line 1 rounds the total of the expenditures once; line 6 rounds 50% of line 5, so an odd line 5 rounds the half dollar up ($2,851 gives $1,426). The cents box prints 00 next to each amount, as the form prints on lines 2 and 4. Done. 8. **Line 6 is split by expenditures.** Each group of expenditures takes a share of line 6 in proportion to its amount (`prorateDollars`), and that share comes off its expense line. The instructions say only "To the extent of the credit shown on line 6" (`line-6::b01`). Done; the total is exact and the split between two Schedule C lines can move by $1. 9. **Expenditures deducted in Part V.** The Schedule C instructions list the deduction for removing barriers under Part V, other expenses (`irs-1040sc-inst-2025::sec::part-v::b03`). Done (2026-11-27): a fact with `deductedOn: "otherExpenses"` names the Part V entry by its description (`otherExpense`), and its part of line 6 comes off that entry, so lines 48 and 27b fall with it. The engine does not check the $15,000 limit of that deduction: the entry is the business's stated amount. -10. **California adds the whole reduction back.** "California law conforms to this provision, but the maximum credit is $125 (50% of eligible expenses up to $250)" (`ftb-pub-1001-2025::sec::enter-on-schedule-ca-540-part-i-or-7::b04`). California denies a deduction only for the California credit (FTB 3548). The engine does not file FTB 3548, so it claims no California credit, and Schedule CA line 3 column B subtracts the whole federal reduction. Not now: FTB 3548 is a form of its own; a taxpayer who claims it outside the engine would subtract $125 less, at most. Schedule CA (540NR) is not changed: it does not take the work opportunity credit either. +10. **California adds the whole reduction back.** "California law conforms to this provision, but the maximum credit is $125 (50% of eligible expenses up to $250)" (`ftb-pub-1001-2025::sec::enter-on-schedule-ca-540-part-i-or-7::b04`). California denies a deduction only for the California credit (FTB 3548). Schedule CA line 3 column B subtracts the whole federal reduction, and since FTB 3548 has rules (2026-11-28) column C adds back its line 4 (decision A149, `state/ca/3548/QUESTIONS.md`). Schedule CA (540NR) is not changed: it does not take the work opportunity credit either. 11. **The election.** The taxpayer "Elects (by filing Form 8826) to claim the disabled access credit" (`purpose-of-form::b01`). A disabled access fact is the claim. The decision `decisions.scope.must_file_8826` false with a fact present makes Form 3800 line 1e a gap, because the Schedule C reduction reads only facts (`form3800.ts`). Done. 12. **A K-1 alone.** "Taxpayers, other than partnerships or S corporations, whose only source of this credit is from those pass-through entities, are not required to complete or file this form" (`purpose-of-form::b01`). The form files then only with the decision; Form 3800 takes the K-1 directly. Done. 13. **Gaps (unsupported, with a reason).** Not now, each for the reason given: diff --git a/engine/src/state/ca/3547/QUESTIONS.md b/engine/src/state/ca/3547/QUESTIONS.md index 1a00db2b..4b48dd60 100644 --- a/engine/src/state/ca/3547/QUESTIONS.md +++ b/engine/src/state/ca/3547/QUESTIONS.md @@ -17,7 +17,8 @@ Each is decided by the author, with a `DECISION` comment and a row in `docs/rule - Text A: "complete column (a) through column (d) for each credit in each section before going to the next section" (`ca-540-sched-p-inst-2025::sec::section-a2-instructions::b01`): no order inside a section. - Text B: "Generally, it is to your advantage to apply credits with limited carryovers before credits with no limitation on carryover" (`::section-b2-instructions::b01`). -- Done: code 204 takes the line after FTB 3541's original and new credits and FTB 3807's LAMBRA credit. This credit's carryover has no limit ("until exhausted", `ca-3547-form-2025::sec::g-carryover::b01`); theirs are limited to 9 and 10 years. The `DECISION` comment is above `agTransportScheduleLine` in `creditUsed.ts`. +- Done: code 204 takes the line after FTB 3541's original and new credits and FTB 3807's LAMBRA credit. This credit's carryover has no limit ("until exhausted", `ca-3547-form-2025::sec::g-carryover::b01`); theirs are limited to 9 and 10 years. The `DECISION` comment is above `agTransportScheduleLine` in `creditUsed.ts` Row A148. +- After the join with FTB 3548: code 204 also comes after FTB 3548's disabled access credit (205). Both carry over with no limit, so text B does not order them; the Credit Table prints 205 before 204 (`ca-540-sched-p-inst-2025::sec::credit-table::b01`), and the engine follows the printed order (row A150). - Dollars: only when the tax over TMT cannot cover every Section A2 credit; the part of code 204 not used then carries over with no limit. ## Should we do this now @@ -90,7 +91,7 @@ Each is an `unsupported` reason. Not now: each needs a computation the engine do - Form 540NR: the credit limits of Form 540NR and Schedule P (540NR) are not figured for this credit. Line 7a is a gap, and Form 540NR lines 58 to 63 name FTB 3547 (`540nr/californiaForms.ts`). The model forms (FTB 3807, FTB 3809) do the same. - Form 541, 100, 100S, 565, 568: entity returns are not in the engine (out of scope). - Form 540 line 35 above $5,000,000 (item 5): the limit runs across every business credit, and no form figures it yet. -- A fourth Section A2 credit: FTB 3541's two Section A2 credits and the LAMBRA credit fill lines 6 to 8, and the engine does not fill line 9. Code 204 and the Section A2 rows are then a gap. Schedule P (540) has four Section A2 rows; a fifth credit needs an attached statement, which no form has yet. +- A fourth Section A2 credit: any three of FTB 3541's two Section A2 credits, the LAMBRA credit and FTB 3548's disabled access credit fill lines 6 to 8, and the engine does not fill line 9. Code 204 and the Section A2 rows are then a gap. Schedule P (540) has four Section A2 rows; a fifth credit needs an attached statement, which no form has yet. - A K-1 credit on a return that files FTB 3801: Schedule CA line 5 column C goes through FTB 3801's Schedule E worksheet, which does not take it. - A charitable deduction for the costs (Schedule A): the costs fact has no such choice. The credit is for a business "engaged in the business of processing, distributing, or selling agricultural products" (`::c-qualifications::b01`), whose costs are a Schedule C or F expense. Schedule CA Part II line 12 column B is a gap on every return already. - Not a gap: a carryover with no current FTB 3547 is still FTB 3547 line 5. The credit is current, not a repealed credit of FTB 3540 (code 175 there is the former agricultural products credit of 1989 to 1991). diff --git a/engine/src/state/ca/3547/creditUsed.ts b/engine/src/state/ca/3547/creditUsed.ts index bee40080..9ce3050b 100644 --- a/engine/src/state/ca/3547/creditUsed.ts +++ b/engine/src/state/ca/3547/creditUsed.ts @@ -11,12 +11,14 @@ import { numberOrBlank } from "../../../money.js"; import { unsupported, type Unsupported } from "../../../types.js"; import { filmCreditsAvailable, SECTION_A2_FILM_LINES } from "../3541/creditUsed.js"; import type { Form3541FilingInfo } from "../3541/filingInfo.js"; +import { disabledAccessCreditOffered } from "../3548/creditUsed.js"; +import type { Form3548FilingInfo } from "../3548/filingInfo.js"; import { lambraCreditOffered, type Info as Form3807Info } from "../3807/figures.js"; import type { Form3547FilingInfo } from "./filingInfo.js"; import { BUSINESS_CREDIT_LIMIT, line2, line3, line4, line5, line6 } from "./lines.js"; export type ReadField = (fieldId: string) => unknown; -export type Info = Form3547FilingInfo & Form3541FilingInfo & Form3807Info; +export type Info = Form3547FilingInfo & Form3541FilingInfo & Form3807Info & Form3548FilingInfo; const FORM_540_LINE_35 = "form-540.line.35_total_tax_after_credits"; /* The last Schedule P (540) Section A2 line the engine fills (schedule-p/sectionA2.ts). */ @@ -41,7 +43,7 @@ const NO_SCHEDULE_P = unsupported( "The credit cannot reduce regular tax below tentative minimum tax (ca-3547-form-2025::sec::d-definitions::b04), which Schedule P (540) Section A2 figures; the decision says Schedule P (540) does not file, though a Section A2 credit attaches it (ca-540-sched-p-inst-2025::sec::b-who-must-file::b01).", ); const NO_SECTION_A2_LINE = unsupported( - "FTB 3541's original and new credits and FTB 3807's LAMBRA credit fill Schedule P (540) Section A2 lines 6 to 8, so code 204 goes on line 9, which the engine does not fill.", + "FTB 3541's original and new credits, FTB 3807's LAMBRA credit and FTB 3548's disabled access credit fill Schedule P (540) Section A2 lines 6 to 8, so code 204 goes on line 9, which the engine does not fill.", ); const isGap = (value: unknown): value is Unsupported => @@ -114,8 +116,8 @@ export function agTransportCreditOffered( /* * DECISION (2026-11-28, by the author): in Schedule P (540) Section A2 the * donated agricultural products transportation credit takes the line after - * FTB 3541's original and new motion picture credits and FTB 3807's LAMBRA - * credit. + * FTB 3541's original and new motion picture credits, FTB 3807's LAMBRA + * credit and FTB 3548's disabled access credit (decision A148). * - Schedule P (540) Section A2: "Follow the Credit Table Instructions to find * out in which section to claim your credit. Then complete column (a) * through column (d) for each credit in each section before going to the @@ -127,9 +129,14 @@ export function agTransportCreditOffered( * limit ("until exhausted", ca-3547-form-2025::sec::g-carryover::b01), and * the film (9 years) and LAMBRA (10 years) carryovers are limited, so they go * first. - * The engine puts code 204 after them, the same order on every return. It - * changes dollars only when the tax over TMT cannot cover every Section A2 - * credit; the credit not used then carries over with no limit. + * The engine puts code 204 after them, the same order on every return. The + * disabled access credit (205) also carries over with no limit ("until + * exhausted", ca-3548-form-2025::sec::h-carryover::b01), so the carryover + * rule does not order the two; the Credit Table prints code 205 before code + * 204 (ca-540-sched-p-inst-2025::sec::credit-table::b01), and the engine + * follows that order (decision A150). It changes dollars only when the tax + * over TMT cannot cover every Section A2 credit; the credit not used then + * carries over with no limit. */ export function agTransportScheduleLine( read: ReadField, @@ -139,8 +146,11 @@ export function agTransportScheduleLine( if (film === undefined || isGap(film)) return film; const lambra = lambraCreditOffered(read, info); if (lambra === undefined || isGap(lambra)) return lambra; + const disabledAccess = disabledAccessCreditOffered(read, info); + if (disabledAccess === undefined || isGap(disabledAccess)) return disabledAccess; const filmA2 = film.filter((credit) => credit.program.section === "A2").length; - const line = SECTION_A2_FILM_LINES[0] + filmA2 + (lambra > 0 ? 1 : 0); + const before = filmA2 + (lambra > 0 ? 1 : 0) + (disabledAccess > 0 ? 1 : 0); + const line = SECTION_A2_FILM_LINES[0] + before; return line > LAST_SECTION_A2_LINE ? NO_SECTION_A2_LINE : line; } diff --git a/engine/src/state/ca/3548/QUESTIONS.md b/engine/src/state/ca/3548/QUESTIONS.md new file mode 100644 index 00000000..531582f2 --- /dev/null +++ b/engine/src/state/ca/3548/QUESTIONS.md @@ -0,0 +1,77 @@ +# FTB 3548: open points + +The form and its instructions (`ca-3548-form-2025`) publish no example with numbers. The one number the texts state is the maximum: "the maximum credit is $125 (50% of eligible expenses up to $250)" (`ftb-pub-1001-2025::sec::enter-on-schedule-ca-540-part-i-or-7::b04`); it is a unit test. The made-up taxpayer `leya` covers every line; `flann` now files FTB 3548 too. + +## Two texts conflict + +Each is decided by the author, with a `DECISION` comment and a row in `docs/rule-decisions.md`. + +1. **The California deduction falls by line 4, not by lines 9a and 9b.** + - Text A, FTB 3548: "Any deduction allowed for these same expenditures must be reduced by the amount of credit claimed and/or assigned to an affiliated corporation for the current taxable year (the amount shown on line 9a and 9b)" (`ca-3548-form-2025::sec::f-limitations::b03`). + - Text B, FTB Pub 1001: "No deduction is permitted for any amount for which a disabled access credit is allowed. California law conforms to this provision, but the maximum credit is $125" (`ftb-pub-1001-2025::sec::enter-on-schedule-ca-540-part-i-or-7::b04`). R&TC 17053.42(a) allows the credit "in accordance with Section 44" (`ca-rtc-2025::sec::s17053.42::a`), and section 44(d)(7) denies a deduction for "the amount of the credit determined under this section" (`usc-26-2025::sec::s44::d-7`). + - Done: text B. Line 9a also holds the K-1 credits and last year's carryover, which are not credits for this year's expenditures, and it depends on the tax, which depends on this deduction. Comment in `resolveInfo.ts` (`californiaDisabledAccessCredit`). + - Dollars: only when the tax limits line 9a, or line 9a holds a K-1 credit or a carryover. In `leya`, column C is $125 (line 4), not $471 (line 9a). + - A third reading, from the blind fill: the smaller of line 4 and lines 9a + 9b, with this year's own credit counted as claimed before the K-1 credit and the carryover. It keeps text A's "claimed" but drops the K-1 credit and the carryover. Neither text states it, and "Apply the carryover to the earliest taxable year" (`ca-3548-form-2025::sec::h-carryover::b01`) sets no order inside one year, so the order is a further choice (carryover first gives $10 in the case below, not $100). Dollars: own credit $125, carryover $90, tax over TMT $100: column C is $125 in the engine, $100 under this reading. The engine keeps text B: the statute names the credit determined, which does not depend on the tax. + - For `docs/law-findings.md`: the instruction (line 9a and 9b) and the statute (the credit determined) disagree; both texts are above. +2. **Schedule P (540) Section A2 order.** Section A2 sets no order; Section B2 says to apply credits with limited carryovers first (`ca-540-sched-p-inst-2025::sec::section-b2-instructions::b01`). The disabled access credit carries over "until exhausted" (`ca-3548-form-2025::sec::h-carryover::b01`), so it takes the line after FTB 3541's film credits and FTB 3807's LAMBRA credit. FTB 3547's credit (204) also carries over with no limit, so the rule does not order the two; the Credit Table prints 205 before 204 (`ca-540-sched-p-inst-2025::sec::credit-table::b01`), and code 205 takes the line before code 204. Comment in `creditUsed.ts`; row A150. Dollars: only when the tax over TMT cannot cover all of them. + +## Should we do this now + +3. **The expenditures are the federal facts.** Line 1 is "the total eligible access expenditures paid or incurred during the current taxable year" (`::line-1::b01`); the federal Form 8826 line 1 is the same total (`federal/8826`). The engine reads the federal disabled access facts once, so no cost is stated twice. The eligible small business test is the same text (`::e-definitions::b01`), with the same two prior-year answers. Done. +4. **Who files.** A taxpayer with own expenditures from an eligible business, a K-1 credit, or a carryover files with a California return. The election is "by filing form FTB 3548" (`::e-definitions::b01`); the decision `decisions.scope.must_file_3548` false is a taxpayer who does not claim it. Then Schedule CA column C stays blank. Done. +5. **The own credit counts first under the $125 cap.** Line 6 caps lines 4 and 5 together at $125. Schedule CA takes off line 4 whole, so a K-1 credit above the cap is the part lost. No text says which part is lost. Dollars: none on the tax; Schedule CA moves only when line 4 plus line 5 is above $125 (`leya`: $125 + $40, the $40 is lost). +6. **Schedule CA line 3: two entries, not one net amount.** Column B keeps the federal credit that came off Schedule C (Form 8826 line 6). Column C takes off the California credit (line 4). One net amount would give the same California AGI. Own reading; no dollar change. +7. **Line 9b is 0, line 9c is 0 up to $5,000,000 of tax.** "If you are not a corporation, enter 0" (the form). Business credits cannot reduce a net tax of $5,000,000 or less by more than $5,000,000, so line 9c is 0 then; above it the credit is a gap (FTB 3807 does the same). Done. +8. **Line 10 keeps the credit the tax could not use.** "the unused credit can be carried over to succeeding years until exhausted" (`::h-carryover::b01`); line 10's instruction: "Include any such amounts here" (`::line-9c::b02`). Unlike FTB 3507, the texts agree. Done. +9. **Rounding.** Line 1 is the federal line 1: the expenditures with cents, rounded once. Line 5 adds the K-1 credits with cents and rounds the total. Line 4 rounds half of line 3, so $201 gives $101. At most $1. +10. **The header.** The facility is the address of the business of the first expenditure fact (Schedule C line E). A business with no address of its own is run from the home (`irs-1040sc-inst-2025::sec::line-e::b01`), so the home address prints. Two businesses at two addresses print the first. With only K-1 credits the facility is the entity's, so it is blank. The Secretary of State file number is an LLC's or a corporation's: blank. No dollars. +11. **The credit name.** The Credit Table name, "Disabled Access for Eligible Small Businesses", does not fit the name box of Form 540 line 43 or Schedule P (540); the line prints "Disabled Access", and code 205 names the credit. No dollars. +12. **Basis.** "Taxpayers that claim this credit cannot increase the basis of the property ... by the amount of credit" (`::f-limitations::b04`). Capitalized expenditures are already a gap on Form 8826; FTB 3548 lines 1 to 8 and Schedule CA line 3 column C share that gap. +13. **Schedule S (540) line 2 with this credit.** Line 2 is "Form 540, line 48 (without other state tax credit and PTE elective tax credit)" (`ca-540-sched-s-inst-2025::sec::part-ii-figure-your-other-state-tax-credit::b01`), so it takes off line 9a. No scenario files both forms, so a unit test locks it: `flann` with another state's tax gives line 2 = $10,623 − $125 = $10,498 (`tests/unit/state/ca/3548/form.test.ts`). Done. + +### Not now: the gaps (unsupported, with a reason) + +Each case below is unsupported with a reason. None is reached by a common return of the target user, and each needs a part of the engine that does not exist yet. + +- **Form 540NR.** Line 9a needs Form 540NR and Schedule P (540NR) limits for this credit; Schedule CA (540NR) gets no column C entry. The model forms (FTB 3807, FTB 3507) do the same. +- **A disregarded single member LLC.** Its credit is limited to the regular tax with its income less the tax without it (`::f-limitations::b02`); the engine figures the tax once. The fact `ca_disabled_access.own_business_disregarded_smllc` (own business) and `throughDisregardedSmllc` (a K-1 row) mark it. Lines 1 to 8 still print. +- **A tax over $5,000,000.** The business credit limit and the FTB 3870 election can apply. +- **Schedule P (540) line 9.** With two film credits and a LAMBRA credit, the disabled access credit would take Section A2 line 9, which the engine does not fill. FTB 3547's credit comes after it, so with three credits before it, code 204 has no line either. +- **No Schedule P (540).** The decision says it does not file, though a Section A2 credit attaches it. +- **Federal Form 8826 gaps** (capitalized expenditures, a controlled group, a business that is not on Schedule C): lines 1 to 8 share them. +- **A carryover with no current credit** is still on FTB 3548 (line 7), so it needs no FTB 3540. +- **Entities** (S corporation 1/3 rule, assigned credits, Form 100S, 541, 565, 568): the entity's own return is not in the engine. + +## Pattern change + +None. Before: California credits on Form 540 lines 43 to 45 came from the list in `540/credits.ts`, each read from its own `creditUsed.ts`. After: the same; FTB 3548 is one more entry, and its facts reuse the federal Form 8826 expenditure facts with one new California fact kind (carryover, K-1 rows) of the existing shape. + +## Second opinions + +- **Blind fill** (14 cases, from the blank form and instructions only): every form line matches; one difference in dollars, on the Schedule CA reduction. + - Cases 9 and 13, the Schedule CA (540) line 3 column C reduction: the engine $125 (line 4), the blind fill $100 and $60 (the smaller of line 4 and line 9a, the tax limiting line 9a). Kept for the engine: decision item 1 (row A149), with the blind fill's reading recorded there. + - Line 9c: 0 in the engine, blank in the blind fill (no FTB 3870 election). No dollar change (item 7). + - Line 6 with lines 4 and 5 both blank (a carryover alone, case 8): 0 in the engine, blank in the blind fill. No dollar change. + - Blind doubts that match the engine: the K-1 credit above the $125 cap is lost (item 5), a business that is not an eligible small business gets no own credit but keeps its K-1 credit, and the rounding of lines 1, 4 and 5 (item 9). +- **PolicyEngine-US 2.154.2** (commit c1fea42a38): it does not model FTB 3548 or federal Form 8826. No California variable or parameter names the disabled access credit, R&TC 17053.42 or section 44; its California credits are the dependent care, renter, earned income, young child and foster youth credits. Nothing to compare. +- **Other projects:** the repository names no other reference implementation of California business credits. + +## Proposals for a discussion + +None. + +## Confidence by field group + +| Field group | Confidence | +| --- | --- | +| Header (name, number, facility) | Stated rule; the facility of a home business is own reading (item 10) | +| Lines 1, 3, 4 (with the printed line 2) | Published number ($250 gives $125) and the form's arithmetic | +| Line 5 | Stated rule | +| Line 6 and its $125 cap | Stated rule | +| Lines 7, 8 | Stated rule | +| Line 9a | Stated rule (Schedule P (540) column (b)); Section A2 order is decision item 2 | +| Lines 9b, 9c | Stated rule; 9c above $5,000,000 is unsupported | +| Line 10 | Stated rule | +| Who files | Stated rule | +| Form 540 lines 43 to 45, Schedule S line 2 | Stated rule (the FTB 3807 model) | +| Schedule CA (540) line 3 column C | Decision item 1; two entries is own reading (item 6) | diff --git a/engine/src/state/ca/3548/bindings.ts b/engine/src/state/ca/3548/bindings.ts index 95f46931..a6b45f9f 100644 --- a/engine/src/state/ca/3548/bindings.ts +++ b/engine/src/state/ca/3548/bindings.ts @@ -1,9 +1,162 @@ -/* Drafted by the write-binding-rules skill. Mark hand edits with // MANUAL EDIT:. */ +/* + * FTB 3548, Disabled Access Credit for Eligible Small Businesses, for an + * individual on Form 540. Lines 1 to 4 figure the credit of the taxpayer's own + * expenditures (the federal disabled access facts), line 5 adds the stated K-1 + * credits, line 6 caps the year's credit at $125, line 7 is last year's + * carryover (lines.ts). Line 9a is the credit Schedule P (540) Section A2 lets + * the return use (creditUsed.ts); line 10 carries the rest. + */ -import { defineForm } from "../../../defineForm.js"; +import { defineForm, type BindingFn, type FormAccessor } from "../../../defineForm.js"; +import { namesOnReturn } from "../../../federal/returnNames.js"; +import { numberOrBlank } from "../../../money.js"; +import { unsupported, type Unsupported } from "../../../types.js"; +import { + disabledAccessCreditUsed, + disabledAccessLines, + passThroughCredits, + type DisabledAccessLines, +} from "./creditUsed.js"; import type { Form3548FilingInfo } from "./filingInfo.js"; +import { + ASSIGNED_CREDIT_OF_AN_INDIVIDUAL, + BUSINESS_CREDIT_LIMIT, + line10Of, + line5Of, + type OwnCreditLines, +} from "./lines.js"; import type { Form3548 } from "./types.js"; +type Info = Form3548FilingInfo; +type Form = FormAccessor; +type Bindings = Partial<{ [K in keyof Form3548]: BindingFn }>; +type Value = number | Unsupported | undefined; + +const isGap = (value: unknown): value is Unsupported => + typeof value === "object" && value !== null && "unsupported" in value; +const readOf = (form: Form) => (fieldId: string) => form[fieldId]; + +const files = (info: Info, formId: string) => info.mustFile?.[formId]?.value === true; + +/* One of lines 1 to 8, or the gap, or undefined while an answer waits. */ +const line = + (pick: (lines: DisabledAccessLines) => number | undefined) => + (_: Form, info: Info): Value => { + const lines = disabledAccessLines(info); + return lines === undefined || isGap(lines) ? lines : pick(lines); + }; + +/* One of lines 1 to 4: they wait only on the own expenditures, not on lines 5 and 7. */ +const ownLine = + (pick: (lines: OwnCreditLines) => number) => + (_: Form, info: Info): Value => { + const form = info.form3548; + if (form?.gap !== undefined) return unsupported(form.gap); + return form?.own === undefined ? undefined : pick(form.own); + }; + +/* Line 9a: 0 with nothing available; else Schedule P (540) Section A2 column (b). */ +function line9a(form: Form, info: Info): Value { + const lines = disabledAccessLines(info); + if (lines === undefined || isGap(lines)) return lines; + if (lines.line8 <= 0) return 0; + return disabledAccessCreditUsed(readOf(form), info); +} + +const OVER_LIMIT = unsupported( + "Line 9c: Form 540 line 35 is over $5,000,000, so the business credit limitation and the FTB 3870 election can apply; the engine does not figure them.", +); +const NOT_FORM_540 = unsupported( + "Line 9c is figured only against Form 540 line 35; a Form 540NR, fiduciary or entity return is not in the engine for this credit.", +); + +/* + * Line 9c: the credit "disallowed due to the $5,000,000 credit limitation" + * and elected refundable on FTB 3870; "Do not include credit limited by your + * tax" (ca-3548-form-2025::sec::line-9c::b01). Business credits cannot reduce + * a net tax of $5,000,000 or less by more than $5,000,000, so with Form 540 + * line 35 at most that nothing is disallowed and the line is 0; above it the + * engine does not figure the limit. + */ +function line9c(form: Form, info: Info): Value { + const lines = disabledAccessLines(info); + if (lines === undefined || isGap(lines)) return lines; + if (lines.line8 <= 0) return 0; + if (files(info, "form-540nr") || !files(info, "form-540")) return NOT_FORM_540; + const line35 = numberOrBlank(form["form-540.line.35_total_tax_after_credits"]); + if (line35 === undefined) return undefined; + return line35 > BUSINESS_CREDIT_LIMIT ? OVER_LIMIT : 0; +} + +/* Line 10: line 8 less lines 9a, 9b and 9c. */ +function line10(form: Form, info: Info): Value { + const lines = disabledAccessLines(info); + if (lines === undefined || isGap(lines)) return lines; + const claimed = line9a(form, info); + const refundable = line9c(form, info); + if (typeof claimed !== "number") return claimed; + if (typeof refundable !== "number") return refundable; + return line10Of(lines.line8, claimed, ASSIGNED_CREDIT_OF_AN_INDIVIDUAL, refundable); +} + +const lines: Bindings = { + // Line 1: "the total eligible access expenditures paid or incurred during the current taxable year" (ca-3548-form-2025::sec::line-1::b01). + "0.line.1_eligible_access_expenditures": ownLine((own) => own.line1), + "0.line.3_smaller_of_line_1_or_2": ownLine((own) => own.line3), + "0.line.4_current_year_credit": ownLine((own) => own.line4), + /* + * Line 5: the K-1 credits, added (ca-3548-form-2025::sec::line-5-pass-through-disabled-access-credit::b01). + * It does not wait on the own expenditures; blank with no K-1 credit. + */ + "0.line.5_pass_through_credit_k1": (_, info) => { + const credits = passThroughCredits(info); + if (info.form3548 === undefined || credits === undefined) return undefined; + return credits.length > 0 ? line5Of(credits) : undefined; + }, + "0.line.6_total_current_year_credit": line((figures) => figures.line6), + "0.line.7_credit_carryover_prior_year": line((figures) => figures.line7), + "0.line.8_total_available_credit": line((figures) => figures.line8), + "0.line.9a_credit_claimed": line9a, + // "If you are not a corporation, enter 0" (the form; ca-3548-form-2025::sec::line-9b::b01). + "0.line.9b_total_credit_assigned": (_, info) => + info.form3548 === undefined ? undefined : ASSIGNED_CREDIT_OF_AN_INDIVIDUAL, + "0.line.9c_credit_elected_refundable": line9c, + "0.line.10_credit_carryover_future_years": line10, +}; + +/* + * The header: the names on the return and the taxpayer's number; an + * individual files with an SSN or ITIN, and the Secretary of State file number + * is an LLC's or a corporation's, so it is blank. The facility is the business + * that paid the expenditures, at its Schedule C line E address; a business with + * no address of its own is run from the home ("If you conducted the business + * from your home ... you don't have to complete this line", + * irs-1040sc-inst-2025::sec::line-e::b01), so the home address is the + * facility. With only K-1 credits the facility is the entity's: blank. + */ +const facility = (info: Info) => { + const form = info.form3548; + if (form === undefined || !form.hasOwnExpenditures) return undefined; + if (form.facility !== undefined) return form.facility; + return { + street: info.homeAddressLine1, + city: info.homeAddressCity, + state: info.homeAddressState, + zip: info.homeAddressZip, + }; +}; + +const header: Bindings = { + "0.header.id_number_type": (_, info) => (info.form3548 ? "ssn_or_itin" : undefined), + "0.header.id_number": (_, info) => info.taxpayerSSN, + "0.header.name_on_return": (_, info) => namesOnReturn(info), + "0.header.sos_file_number": () => undefined, + "0.header.facility_address": (_, info) => facility(info)?.street, + "0.header.facility_city": (_, info) => facility(info)?.city, + "0.header.facility_state": (_, info) => facility(info)?.state, + "0.header.facility_zip": (_, info) => facility(info)?.zip, +}; + export function register(): void { - defineForm("form-3548", { bindings: {} }); + defineForm("form-3548", { bindings: { ...header, ...lines } }); } diff --git a/engine/src/state/ca/3548/creditUsed.ts b/engine/src/state/ca/3548/creditUsed.ts new file mode 100644 index 00000000..2695e614 --- /dev/null +++ b/engine/src/state/ca/3548/creditUsed.ts @@ -0,0 +1,179 @@ +/* + * FTB 3548's lines 1 to 8 from the filing info, and the credit the return + * takes: code 205, one line in Schedule P (540) Section A2 ("Offset Tax in + * Section: A2", ca-540-sched-p-inst-2025::sec::credit-table::b01). The form's + * bindings, Schedule P (540), Form 540 lines 43 to 45 and Schedule S line 2 + * read it here. `read` takes a full field id. + */ + +import type { BaseFilingInfo } from "../../../filingInfo.js"; +import { numberOrBlank } from "../../../money.js"; +import { unsupported, type Unsupported } from "../../../types.js"; +import { filmCreditsAvailable, SECTION_A2_FILM_LINES } from "../3541/creditUsed.js"; +import type { Form3541FilingInfo } from "../3541/filingInfo.js"; +import { lambraCreditOffered, type Info as Form3807Info } from "../3807/figures.js"; +import type { Form3548FilingInfo } from "./filingInfo.js"; +import { BUSINESS_CREDIT_LIMIT, line5Of, line6Of, line7Of, line8Of } from "./lines.js"; + +export type ReadField = (fieldId: string) => unknown; +type Info = Form3548FilingInfo & Form3541FilingInfo & Form3807Info; + +const FORM_540_LINE_35 = "form-540.line.35_total_tax_after_credits"; +/* Section A2 has lines 6 to 9; the engine fills lines 6 to 8 (schedule-p/sectionA2.ts). */ +const LAST_FILLED_A2_LINE = 8; + +const files = (info: BaseFilingInfo, formId: string) => info.mustFile?.[formId]?.value === true; +export const files3548 = (info: BaseFilingInfo) => files(info, "form-3548"); + +const isGap = (value: unknown): value is Unsupported => + typeof value === "object" && value !== null && "unsupported" in value; + +const NONRESIDENT_RETURN = unsupported( + "FTB 3548 line 9a on a Form 540NR return needs the credit limits of Form 540NR and Schedule P (540NR), which the engine does not figure for this credit.", +); +const NOT_FORM_540 = unsupported( + "FTB 3548 line 9a is figured only against Form 540; a fiduciary or entity return (Form 541, 100, 100S, 565, 568) is not in the engine.", +); +const DISREGARDED_SMLLC = unsupported( + "A disabled access credit from a disregarded single member LLC is limited to the regular tax with that LLC's income less the regular tax without it (ca-3548-form-2025::sec::f-limitations::b02), which needs the tax figured twice; the engine does not figure it.", +); +const OVER_BUSINESS_CREDIT_LIMIT = unsupported( + "Form 540 line 35 is over $5,000,000, so the business credit limitation and the FTB 3870 election (ca-3548-form-2025::sec::credit-limitation::b01, ::line-9c::b01) can apply to the disabled access credit; the engine does not figure them.", +); +const NO_SCHEDULE_P = unsupported( + "The disabled access credit cannot reduce regular tax below tentative minimum tax (ca-3548-form-2025::sec::f-limitations::b03), which Schedule P (540) Section A2 figures (ca-540-sched-p-inst-2025::sec::credit-table::b01); the decision says Schedule P (540) does not file, though a Section A2 credit attaches it (::b-who-must-file::b01).", +); +const NO_A2_LINE = unsupported( + "Schedule P (540) Section A2 already holds two motion picture credits and the LAMBRA credit, so the disabled access credit would take line 9, which the engine does not fill.", +); + +/* Lines 1 to 8; lines 1 to 4 are undefined with no expenditures of the taxpayer's own business. */ +export interface DisabledAccessLines { + line1?: number; + line3?: number; + line4?: number; + line5?: number; + line6: number; + line7: number; + line8: number; +} + +/* Every stated pass-through credit, or undefined while one waits. */ +export function passThroughCredits(info: Form3548FilingInfo): number[] | undefined { + const credits = (info.form3548?.passThroughRows ?? []).map((row) => row.credit); + return credits.every((credit) => credit !== undefined) ? (credits as number[]) : undefined; +} + +/* + * Lines 1 to 8, the gap of lines 1 to 4, or undefined while an answer waits. + * Line 5 is blank with no K-1 credit. + */ +export function disabledAccessLines( + info: Form3548FilingInfo, +): DisabledAccessLines | Unsupported | undefined { + const form = info.form3548; + if (form === undefined) return undefined; + if (form.gap !== undefined) return unsupported(form.gap); + if (form.hasOwnExpenditures && form.own === undefined) return undefined; + const credits = passThroughCredits(info); + if (credits === undefined || form.carryover === undefined) return undefined; + const line5 = credits.length > 0 ? line5Of(credits) : undefined; + const line6 = line6Of(form.own?.line4, line5); + const line7 = line7Of(form.carryover); + return { ...form.own, line5, line6, line7, line8: line8Of(line6, line7) }; +} + +/* A case of the whole return Schedule P (540) cannot figure for this credit, else undefined. */ +export function disabledAccessReturnGap(info: Form3548FilingInfo): Unsupported | undefined { + if (files(info, "form-540nr")) return NONRESIDENT_RETURN; + if (!files(info, "form-540")) return NOT_FORM_540; + const form = info.form3548; + const smllcRow = (form?.passThroughRows ?? []).some((row) => row.throughDisregardedSmllc); + if (form?.ownThroughSmllc === true || smllcRow) return DISREGARDED_SMLLC; + return undefined; +} + +/* + * Schedule P (540) Section A2 column (a) for code 205: line 8, the credit + * available. 0 with no FTB 3548. Above $5,000,000 of tax the business credit + * limit can bind, and the engine does not figure it. + */ +export function disabledAccessCreditOffered( + read: ReadField, + info: Form3548FilingInfo, +): number | Unsupported | undefined { + if (!files3548(info)) return 0; + const lines = disabledAccessLines(info); + if (lines === undefined || isGap(lines)) return lines; + if (lines.line8 <= 0) return 0; + const gap = disabledAccessReturnGap(info); + if (gap !== undefined) return gap; + const line35 = numberOrBlank(read(FORM_540_LINE_35)); + if (line35 === undefined) return undefined; + if (line35 > BUSINESS_CREDIT_LIMIT) return OVER_BUSINESS_CREDIT_LIMIT; + return lines.line8; +} + +/* + * DECISION (2026-11-28, by the author): in Schedule P (540) Section A2 the + * disabled access credit takes the line after FTB 3541's motion picture + * credits and FTB 3807's LAMBRA credit, and before FTB 3547's donated + * agricultural products transportation credit (decision A150). + * - Schedule P (540) Section A2: "Follow the Credit Table Instructions to find + * out in which section to claim your credit. Then complete column (a) + * through column (d) for each credit in each section before going to the + * next section" (ca-540-sched-p-inst-2025::sec::section-a2-instructions::b01): + * no order inside the section. + * - Section B2's rule for an order: "Generally, it is to your advantage to + * apply credits with limited carryovers before credits with no limitation on + * carryover" (::section-b2-instructions::b01). The disabled access credit + * carries over "until exhausted" (ca-3548-form-2025::sec::h-carryover::b01); + * the LAMBRA carryover is limited to 10 years and the film credits to 9. + * The engine applies that rule in Section A2 too, so the credits with no + * limit on their carryover go last, the same order on every return. FTB + * 3547's credit (204) also carries over "until exhausted" + * (ca-3547-form-2025::sec::g-carryover::b01), so that rule does not order the + * two; the Credit Table prints code 205 before code 204 + * (ca-540-sched-p-inst-2025::sec::credit-table::b01), and the engine follows + * the printed order. It changes dollars only when the tax over TMT cannot + * cover all of them. + */ +export function disabledAccessScheduleLine( + read: ReadField, + info: Info, +): number | Unsupported | undefined { + const film = filmCreditsAvailable(info); + if (film === undefined || isGap(film)) return film; + const lambra = lambraCreditOffered(read, info); + if (lambra === undefined || isGap(lambra)) return lambra; + const filmA2 = film.filter((credit) => credit.program.section === "A2").length; + const line = SECTION_A2_FILM_LINES[0] + filmA2 + (lambra > 0 ? 1 : 0); + return line > LAST_FILLED_A2_LINE ? NO_A2_LINE : line; +} + +/* + * Line 9a: Schedule P (540) column (b) of the code 205 line + * (ca-540-sched-p-inst-2025::sec::how-to-claim-your-credits::b01); "This amount + * may be less than the amount on line 8 if your credit is limited by your tax + * liability" (ca-3548-form-2025::sec::line-9a::b01). 0 with no FTB 3548 or no + * credit available. A gap passes through, so Form 540 never drops the credit + * in silence. Undefined while it waits. + */ +export function disabledAccessCreditUsed( + read: ReadField, + info: Info, +): number | Unsupported | undefined { + const offered = disabledAccessCreditOffered(read, info); + if (typeof offered !== "number") return offered; + if (offered <= 0) return 0; + if (!files(info, "schedule-p")) return NO_SCHEDULE_P; + const line = disabledAccessScheduleLine(read, info); + if (typeof line !== "number") return line; + return numberOrBlank(read(`schedule-p.2.part3.${line}_credit_used_col_b`)); +} + +/* The same for a reader typed with only the base filing info (Form 540, Schedule S). */ +export const disabledAccessCreditOnReturn = ( + read: ReadField, + info: BaseFilingInfo, +): number | Unsupported | undefined => disabledAccessCreditUsed(read, info as Info); diff --git a/engine/src/state/ca/3548/filingInfo.ts b/engine/src/state/ca/3548/filingInfo.ts index d4a9f498..1373f014 100644 --- a/engine/src/state/ca/3548/filingInfo.ts +++ b/engine/src/state/ca/3548/filingInfo.ts @@ -1,3 +1,45 @@ import type { BaseFilingInfo } from "../../../filingInfo.js"; +import type { OwnCreditLines } from "./lines.js"; -export interface Form3548FilingInfo extends BaseFilingInfo {} +/* One line 5 entity. A field is undefined while its answer waits. */ +export interface DisabledAccessPassThroughRow { + factKey: string; + entityName?: string; + entityId?: string; + /* As stated, with cents. */ + credit?: number; + /* The credit came through a disregarded single member LLC (ca-3548-form-2025::sec::f-limitations::b02). */ + throughDisregardedSmllc: boolean; +} + +/* The facility of the header: the first business's address, or the home address. */ +export interface DisabledAccessFacility { + street?: string; + city?: string; + state?: string; + zip?: string; +} + +/* + * FTB 3548 reads its inputs here. Schedule P (540), Form 540 lines 43 to 45, + * Schedule S line 2 and Schedule CA (540) read the form's figures through + * creditUsed.ts and resolveInfo.ts. + */ +export interface Form3548FilingInfo extends BaseFilingInfo { + /* Undefined while FTB 3548 does not file. */ + form3548?: { + /* Lines 1, 3 and 4; undefined with no expenditures of the taxpayer's own business, or while they wait. */ + own?: OwnCreditLines; + /* The return has expenditures of the taxpayer's own business. */ + hasOwnExpenditures: boolean; + /* Why lines 1 to 4 cannot be figured. */ + gap?: string; + /* The own business is a disregarded single member LLC. */ + ownThroughSmllc: boolean; + /* Line 5, one entry per entity with a credit above 0 or not stated yet. */ + passThroughRows: DisabledAccessPassThroughRow[]; + /* Line 7: the carryover from 2024; undefined while it waits. */ + carryover?: number; + facility?: DisabledAccessFacility; + }; +} diff --git a/engine/src/state/ca/3548/lines.ts b/engine/src/state/ca/3548/lines.ts new file mode 100644 index 00000000..ea99c87a --- /dev/null +++ b/engine/src/state/ca/3548/lines.ts @@ -0,0 +1,84 @@ +/* + * FTB 3548, Disabled Access Credit for Eligible Small Businesses: the + * arithmetic, pure. Written by hand from ca-3548-form-2025; the form and its + * instructions publish no example with numbers (QUESTIONS.md). + */ + +import { atLeast, roundDollars, sum } from "../../../money.js"; + +/* Line 2: "Maximum amount of eligible access expenditures", printed $250 (ca-3548-form-2025::sec::face-page-1::b01). */ +export const MAXIMUM_EXPENDITURES = 250; + +/* Line 4: "Multiply line 3 by 50% (.50)" (ca-3548-form-2025::sec::face-page-1::b01). */ +export const CREDIT_RATE = 0.5; + +/* + * Line 6: "Add line 4 and line 5, but do not enter more than $125" (the form); + * "The maximum credit per eligible small business per taxable year is $125" + * (ca-3548-form-2025::sec::b-description::b01). + */ +export const CREDIT_LIMIT = 125; + +/* + * "there is a $5,000,000 limitation on the application of business credits" + * for taxable years 2024 to 2026 (ca-3548-form-2025::sec::credit-limitation::b01). + */ +export const BUSINESS_CREDIT_LIMIT = 5_000_000; + +/* "Use credit code 205 when you claim this credit" (ca-3548-form-2025::sec::line-9a::b01). */ +export const DISABLED_ACCESS_CREDIT_CODE = "205"; +/* + * The Credit Table names code 205 "Disabled Access for Eligible Small + * Businesses" (ca-540-sched-p-inst-2025::sec::credit-table::b01). The name box + * of Form 540 line 43 and Schedule P (540) is short, so the line takes the + * first words; the code names the credit (QUESTIONS.md). + */ +export const DISABLED_ACCESS_CREDIT_NAME = "Disabled Access"; + +/* Line 9b: "If you are not a corporation, enter 0" (the form). The engine figures individual returns only. */ +export const ASSIGNED_CREDIT_OF_AN_INDIVIDUAL = 0; + +/* Line 3: "Enter the smaller of line 1 or line 2" (the form). */ +export const line3Of = (line1: number): number => Math.min(atLeast(0, line1), MAXIMUM_EXPENDITURES); + +/* Line 4: "Multiply line 3 by 50% (.50)", to the nearest dollar. */ +export const line4Of = (line3: number): number => roundDollars(line3 * CREDIT_RATE); + +/* + * Line 5: "add the amounts and enter the total" + * (ca-3548-form-2025::sec::line-5-pass-through-disabled-access-credit::b01). The + * stated K-1 credits keep their cents while adding; only the total is rounded. + */ +export const line5Of = (credits: readonly number[]): number => roundDollars(sum(...credits)); + +/* Line 6: "Add line 4 and line 5, but do not enter more than $125"; a blank line counts 0. */ +export const line6Of = (line4: number | undefined, line5: number | undefined): number => + Math.min(sum(line4, line5), CREDIT_LIMIT); + +/* Line 7: last year's line 10 in whole dollars. */ +export const line7Of = (carryover: number): number => roundDollars(atLeast(0, carryover)); + +/* Line 8: "Add line 6 and line 7" (the form). */ +export const line8Of = (line6: number, line7: number): number => line6 + line7; + +/* + * Line 10: "Add lines 9a, 9b, and 9c, subtract the result from line 8" (the + * form). The credit the tax could not use carries over "until exhausted" + * (ca-3548-form-2025::sec::h-carryover::b01; ::line-9c::b02, "Include any such + * amounts here"). + */ +export const line10Of = (line8: number, line9a: number, line9b: number, line9c: number): number => + atLeast(0, line8 - sum(line9a, line9b, line9c)); + +/* Lines 1 to 4 of the taxpayer's own expenditures, whole dollars. */ +export interface OwnCreditLines { + line1: number; + line3: number; + line4: number; +} + +/* Lines 1, 3 and 4 from line 1 (the federal Form 8826 line 1 total, already rounded). */ +export function ownCreditLines(line1: number): OwnCreditLines { + const line3 = line3Of(line1); + return { line1, line3, line4: line4Of(line3) }; +} diff --git a/engine/src/state/ca/3548/resolveInfo.ts b/engine/src/state/ca/3548/resolveInfo.ts index df0e4b9f..71820ad1 100644 --- a/engine/src/state/ca/3548/resolveInfo.ts +++ b/engine/src/state/ca/3548/resolveInfo.ts @@ -1,20 +1,198 @@ -import { resolveMustFile, type ResolverInputs } from "../../../resolverInputs.js"; -import type { Form3548FilingInfo } from "./filingInfo.js"; +import { + CA_DISABLED_ACCESS_KEYS, + getCaDisabledAccessPassThroughFacts, + type CaDisabledAccessPassThroughFact, +} from "../../../facts/index.js"; +import { disabledAccessFiguresOf } from "../../../federal/8826/resolveInfo.js"; +import { num, resolveMustFile, type ResolverInputs } from "../../../resolverInputs.js"; +import type { + DisabledAccessFacility, + DisabledAccessPassThroughRow, + Form3548FilingInfo, +} from "./filingInfo.js"; +import { ownCreditLines, type OwnCreditLines } from "./lines.js"; + +const MUST_FILE_KEY = "decisions.scope.must_file_3548"; +const MUST_FILE_540_KEY = "decisions.scope.must_file_ca_540"; +const MUST_FILE_540NR_KEY = "decisions.scope.must_file_540nr"; + +const finite = (value: unknown) => + typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined; +const filled = (value: unknown) => + typeof value === "string" && value.trim() !== "" ? value.trim() : undefined; + +function rowOf(fact: CaDisabledAccessPassThroughFact): DisabledAccessPassThroughRow { + const value = fact.value ?? ({} as Partial); + return { + factKey: fact.key, + entityName: filled(value.entityName), + entityId: filled(value.entityId), + credit: finite(value.credit), + throughDisregardedSmllc: value.throughDisregardedSmllc === true, + }; +} + +const complete = (row: DisabledAccessPassThroughRow) => + row.entityName !== undefined && row.entityId !== undefined && row.credit !== undefined; + +/* The pass-through credits above 0, or not stated yet. A stated credit of 0 is no row. */ +const passThroughRowsOf = (inputs: ResolverInputs) => + getCaDisabledAccessPassThroughFacts(inputs.facts) + .map(rowOf) + .filter((row) => row.credit === undefined || row.credit > 0); + +/* + * The taxpayer's own expenditures: the federal disabled access facts, "the + * total eligible access expenditures paid or incurred during the current + * taxable year" (ca-3548-form-2025::sec::line-1::b01), and the same eligible + * small business test (ca-3548-form-2025::sec::e-definitions::b01; + * federal/8826/lines.ts). Not eligible: no own credit. Federal Form 8826's gap + * (capitalized expenditures, a controlled group, a business that is not a + * Schedule C business) is a gap here too: line 1 needs the group's + * expenditures, or the deduction the credit lowers cannot be placed. + */ +function ownCreditOf(inputs: ResolverInputs) { + const figures = disabledAccessFiguresOf(inputs); + const keys = [...figures.factKeys, ...figures.malformedKeys]; + const claims = keys.length > 0 && figures.eligible !== false; + const gap = + claims && figures.gap !== undefined + ? `FTB 3548 reads the same expenditures as federal Form 8826, which cannot figure them: ${figures.gap}` + : undefined; + const own: OwnCreditLines | undefined = + claims && figures.lines !== undefined ? ownCreditLines(figures.lines.line1) : undefined; + const address = figures.credits[0]?.business.address; + const facility: DisabledAccessFacility | undefined = + claims && address !== undefined ? { ...address } : undefined; + return { + keys: claims ? keys : [], + missing: claims ? [...figures.missing, ...figures.malformedKeys] : [], + own, + gap, + facility, + hasOwnExpenditures: claims, + }; +} + +/* + * The fact keys that put a California disabled access credit on the return: + * the taxpayer's own expenditures from an eligible small business (or the test + * waits on an answer), a pass-through credit row, or a 2024 carryover above 0. + * Schedule P (540) reads them: a Section A2 credit attaches it. + */ +export function disabledAccessCreditFactKeys(inputs: ResolverInputs): string[] { + const carryover = (num(inputs, CA_DISABLED_ACCESS_KEYS.carryover) ?? 0) > 0; + return [ + ...ownCreditOf(inputs).keys, + ...passThroughRowsOf(inputs).map((row) => row.factKey), + ...(carryover ? [CA_DISABLED_ACCESS_KEYS.carryover] : []), + ]; +} + +const filesCaliforniaOf = (inputs: ResolverInputs) => + inputs.decisionByKey.get(MUST_FILE_540_KEY) === true || + inputs.decisionByKey.get(MUST_FILE_540NR_KEY) === true; /* - * Who files: "Eligible small businesses use form FTB 3548, Disabled Access Credit for Eligible - * Small Businesses, to figure a credit for expenditures to provide access to disabled - * individuals" (ca-3548-form-2025, "A Purpose"). - * The instructions are not in the corpus yet, so no block id is cited. - * The form has no rules yet, so no fact turns it on: only the decision does. + * Schedule P (540) attaches with "credits that are reported in Part III, + * Section A1, Section A2, or Section C" (ca-540-sched-p-inst-2025::sec::b-who-must-file::b01), + * and code 205 offsets tax in Section A2 (::credit-table::b01). + */ +export function disabledAccessSectionA2Fallback(inputs: ResolverInputs, files540: boolean) { + const keys = disabledAccessCreditFactKeys(inputs); + return { + rule: `fallback: Form 540 files (${files540}) with ${keys.length} disabled access credit input(s) (FTB 3548, Section A2)`, + value: + files540 && + keys.length > 0 && + resolve3548Info(inputs).mustFile?.["form-3548"]?.value === true, + triggeredByFactKeys: keys, + triggeredByDecisionKeys: [MUST_FILE_540_KEY, MUST_FILE_KEY], + }; +} + +/* + * Who files: an eligible small business that elects the credit "by filing + * form FTB 3548", and a shareholder, beneficiary, partner or member who + * received the credit on a Schedule K-1 (ca-3548-form-2025::sec::e-definitions::b01, + * ::a-purpose::b01), attached to the California return (the form's heading), + * and a taxpayer with a carryover from 2024 (line 7). The form files with a + * California return that has one of these (an answer not stated yet counts, so + * it is asked). The explicit decision still wins: false is a taxpayer who does + * not claim the California credit. */ export function resolve3548Info(inputs: ResolverInputs): Form3548FilingInfo { + const filesCalifornia = filesCaliforniaOf(inputs); + const keys = disabledAccessCreditFactKeys(inputs); + const resolution = resolveMustFile(inputs.decisionByKey, { + explicitKey: MUST_FILE_KEY, + fallbacks: [ + { + rule: `fallback: a California return (${filesCalifornia}) with ${keys.length} disabled access credit input(s)`, + value: filesCalifornia && keys.length > 0, + triggeredByFactKeys: keys, + triggeredByDecisionKeys: [MUST_FILE_540_KEY, MUST_FILE_540NR_KEY], + }, + ], + }); + if (resolution.value !== true) { + return { mustFile: { "form-3548": resolution }, missingInputs: { "form-3548": [] } }; + } + const own = ownCreditOf(inputs); + const rows = passThroughRowsOf(inputs); + const carryover = num(inputs, CA_DISABLED_ACCESS_KEYS.carryover); return { - mustFile: { - "form-3548": resolveMustFile(inputs.decisionByKey, { - explicitKey: "decisions.scope.must_file_3548", - fallbacks: [{ rule: "fallback: the form has no rules yet", value: false }], - }), + mustFile: { "form-3548": resolution }, + /* The prior-year test answers, each row while an answer inside it is missing, and line 7. */ + missingInputs: { + "form-3548": [ + ...own.missing, + ...rows.filter((row) => !complete(row)).map((row) => row.factKey), + ...(carryover === undefined ? [CA_DISABLED_ACCESS_KEYS.carryover] : []), + ], + }, + form3548: { + own: own.own, + hasOwnExpenditures: own.hasOwnExpenditures, + gap: own.gap, + ownThroughSmllc: + own.hasOwnExpenditures && + inputs.factByKey.get(CA_DISABLED_ACCESS_KEYS.ownBusinessDisregardedSmllc) === true, + passThroughRows: rows, + carryover, + facility: own.facility, }, }; } + +/* + * The California credit for the taxpayer's own expenditures that lowers their + * California deduction (Schedule CA (540) line 3 column C): line 4 while FTB + * 3548 files; the gap of lines 1 to 4; or that they wait. Undefined with no + * such credit above 0. + * + * DECISION (2026-11-28, by the author): the California deduction falls by + * line 4, the credit for this year's own expenditures, not by lines 9a and 9b. + * Text A, FTB 3548: "Any deduction allowed for these same expenditures must + * be reduced by the amount of credit claimed and/or assigned to an affiliated + * corporation for the current taxable year (the amount shown on line 9a and + * 9b)" (ca-3548-form-2025::sec::f-limitations::b03). Text B, FTB Publication + * 1001, the guide to the Schedule CA adjustments: "No deduction is permitted + * for any amount for which a disabled access credit is allowed. California + * law conforms to this provision, but the maximum credit is $125" + * (ftb-pub-1001-2025::sec::enter-on-schedule-ca-540-part-i-or-7::b04); the + * credit is "allowed in accordance with Section 44" (ca-rtc-2025::sec::s17053.42::a). + * The engine follows text B: line 9a also holds the K-1 credits and last + * year's carryover, which are not credits for this year's expenditures, and it + * depends on the tax, which depends on this deduction. + */ +export function californiaDisabledAccessCredit( + inputs: ResolverInputs, +): number | { gap: string } | { waits: true } | undefined { + const info = resolve3548Info(inputs).form3548; + if (info === undefined || !info.hasOwnExpenditures) return undefined; + if (info.gap !== undefined) return { gap: info.gap }; + const credit = info.own?.line4; + if (credit === undefined) return { waits: true }; + return credit > 0 ? credit : undefined; +} diff --git a/engine/src/state/ca/540/credits.ts b/engine/src/state/ca/540/credits.ts index 1a8c7522..c59a8bdb 100644 --- a/engine/src/state/ca/540/credits.ts +++ b/engine/src/state/ca/540/credits.ts @@ -3,9 +3,9 @@ * 3506. Lines 43 to 45 hold the other credits the engine figures: the prison * inmate labor credit (FTB 3507), the credit for prior year AMT (FTB 3510), the passive credits (FTB 3801-CR), * the enterprise zone credit (FTB 3805Z), the LAMBRA credit (FTB 3807), the - * TTA credit carryovers (FTB 3809), the natural heritage preservation credit - * (FTB 3503), the donated agricultural products transportation credit - * (FTB 3547), the other + * TTA credit carryovers (FTB 3809), the disabled access credit (FTB 3548), the + * donated agricultural products transportation credit (FTB 3547), the natural + * heritage preservation credit (FTB 3503), the other * state tax credit (Schedule S) and the PTE elective tax credit (FTB 3804-CR). * They are unsupported when no such * form files. Line 46 stays unsupported in bindings.ts and reads as blank. @@ -25,6 +25,8 @@ import { files3510, priorYearAmtCreditUsed, priorYearAmtCreditWaits } from "../3 import { files3541, filmCreditsUsed } from "../3541/creditUsed.js"; import { agTransportCreditOnReturn, files3547 } from "../3547/creditUsed.js"; import { AG_TRANSPORT_CREDIT_CODE, AG_TRANSPORT_CREDIT_NAME } from "../3547/lines.js"; +import { disabledAccessCreditOnReturn, files3548 } from "../3548/creditUsed.js"; +import { DISABLED_ACCESS_CREDIT_CODE, DISABLED_ACCESS_CREDIT_NAME } from "../3548/lines.js"; import { files3801Cr, passiveCreditsUsed } from "../3801-cr/creditUsed.js"; import { files3804Cr, pteCreditOnReturn } from "../3804-cr/creditUsed.js"; import { PTE_CREDIT_CODE, PTE_CREDIT_NAME } from "../3804-cr/lines.js"; @@ -99,8 +101,9 @@ function otherStateCreditUsed(form: Form540Form, info: Form540FilingInfo) { * completed (ca-540-sched-p-inst-2025::sec::how-to-claim-your-credits::b01), * in Part III order: line 4 (prison inmate labor, FTB 3507), lines 6 and 7 * (FTB 3541's original and new credits), the next Section A2 line (the LAMBRA - * credit, FTB 3807), the line after it (FTB 3547's credit, code 204, the - * DECISION in 3547/creditUsed.ts), line 10 (prior year AMT), lines 16 to 18 (FTB 3541's + * credit, FTB 3807), the next line (FTB 3548's disabled access credit, code + * 205), the line after it (FTB 3547's credit, code 204; the DECISIONs in + * 3548/creditUsed.ts and 3547/creditUsed.ts), line 10 (prior year AMT), lines 16 to 18 (FTB 3541's * other film credits, FTB 3805Z's enterprise zone credit, FTB 3809's TTA * credit, FTB 3503's natural heritage preservation credit, code 213, the * DECISION in 3503/creditUsed.ts, then FTB 3801-CR's passive credits), line 20 (other state tax), line @@ -143,6 +146,8 @@ function otherCredits( if (typeof enterpriseZone !== "number") return enterpriseZone; const tta = ttaCreditUsed(read, info); if (typeof tta !== "number") return tta; + const disabledAccess = disabledAccessCreditOnReturn(read, info); + if (typeof disabledAccess !== "number") return disabledAccess; const heritage = naturalHeritageCreditUsed(read, info); if (typeof heritage !== "number") return heritage; const filmIn = (section: string) => @@ -154,6 +159,11 @@ function otherCredits( { name: PRISON_LABOR_CREDIT_NAME, code: PRISON_LABOR_CREDIT_CODE, amount: prisonLabor }, ...filmIn("A2"), { name: LAMBRA_CREDIT_NAME, code: LAMBRA_CREDIT_CODE, amount: lambra }, + { + name: DISABLED_ACCESS_CREDIT_NAME, + code: DISABLED_ACCESS_CREDIT_CODE, + amount: disabledAccess, + }, { name: AG_TRANSPORT_CREDIT_NAME, code: AG_TRANSPORT_CREDIT_CODE, amount: agTransport }, { name: PRIOR_YEAR_AMT_CREDIT_NAME, code: PRIOR_YEAR_AMT_CREDIT_CODE, amount: priorYearAmt }, ...filmIn("B2"), @@ -186,7 +196,8 @@ const filesOtherCreditForm = (info: Form540FilingInfo) => files3807(info) || files3809(info) || files3503(info) || - files3547(info); + files3547(info) || + files3548(info); /* * "To claim only one or two credits, enter the credit name, code, and amount of diff --git a/engine/src/state/ca/formsWithNoRules.ts b/engine/src/state/ca/formsWithNoRules.ts index cdef92b9..0a8c90e1 100644 --- a/engine/src/state/ca/formsWithNoRules.ts +++ b/engine/src/state/ca/formsWithNoRules.ts @@ -16,8 +16,6 @@ import type { Form3531FilingInfo } from "./3531/filingInfo.js"; import { resolve3531Info } from "./3531/resolveInfo.js"; import type { Form3540FilingInfo } from "./3540/filingInfo.js"; import { resolve3540Info } from "./3540/resolveInfo.js"; -import type { Form3548FilingInfo } from "./3548/filingInfo.js"; -import { resolve3548Info } from "./3548/resolveInfo.js"; import type { Form3554FilingInfo } from "./3554/filingInfo.js"; import { resolve3554Info } from "./3554/resolveInfo.js"; import type { Form3568FilingInfo } from "./3568/filingInfo.js"; @@ -57,7 +55,6 @@ export type CaliforniaFormsWithNoRulesFilingInfo = ScheduleXFilingInfo & Form3523FilingInfo & Form3531FilingInfo & Form3540FilingInfo & - Form3548FilingInfo & Form3554FilingInfo & Form3568FilingInfo & Form3592FilingInfo & @@ -83,7 +80,6 @@ export const CALIFORNIA_FORMS_WITH_NO_RULES_RESOLVERS: ReadonlyArray< resolve3523Info, resolve3531Info, resolve3540Info, - resolve3548Info, resolve3554Info, resolve3568Info, resolve3592Info, diff --git a/engine/src/state/ca/laterForms.ts b/engine/src/state/ca/laterForms.ts index b0efc736..7d1c55be 100644 --- a/engine/src/state/ca/laterForms.ts +++ b/engine/src/state/ca/laterForms.ts @@ -18,6 +18,8 @@ import type { Form3541FilingInfo } from "./3541/filingInfo.js"; import { resolve3541Info } from "./3541/resolveInfo.js"; import type { Form3547FilingInfo } from "./3547/filingInfo.js"; import { resolve3547Info } from "./3547/resolveInfo.js"; +import type { Form3548FilingInfo } from "./3548/filingInfo.js"; +import { resolve3548Info } from "./3548/resolveInfo.js"; import type { Form3800CaFilingInfo } from "./3800-ca/filingInfo.js"; import { resolve3800CaInfo } from "./3800-ca/resolveInfo.js"; import type { Form3801CRFilingInfo } from "./3801-cr/filingInfo.js"; @@ -90,6 +92,7 @@ export type LaterCaliforniaFormsFilingInfo = Form540NRFilingInfo & Form3809FilingInfo & Form3503FilingInfo & Form3547FilingInfo & + Form3548FilingInfo & ScheduleP540NRFilingInfo; export const LATER_CALIFORNIA_FORMS_RESOLVERS: ReadonlyArray< @@ -122,5 +125,6 @@ export const LATER_CALIFORNIA_FORMS_RESOLVERS: ReadonlyArray< resolve3809Info, resolve3503Info, resolve3547Info, + resolve3548Info, resolveScheduleP540NRInfo, ]; diff --git a/engine/src/state/ca/schedule-ca/activities.ts b/engine/src/state/ca/schedule-ca/activities.ts index 8b4f7bf7..e0e0bac1 100644 --- a/engine/src/state/ca/schedule-ca/activities.ts +++ b/engine/src/state/ca/schedule-ca/activities.ts @@ -19,6 +19,7 @@ import { num, type ResolverInputs, } from "../../../resolverInputs.js"; +import { californiaDisabledAccessCredit } from "../3548/resolveInfo.js"; import { form3801Scope } from "../3801/formScope.js"; import type { Form3885AActivity } from "../3885a/filingInfo.js"; import { californiaAdjustment, form3885AFigures } from "../3885a/lines.js"; @@ -129,6 +130,7 @@ export function resolveActivityAdjustments(inputs: ResolverInputs) { caEmployeeAmounts: amounts, caBusinessCreditAddBack: addBack > 0 ? addBack : undefined, caFederalResearchReduction: researchReduction > 0 ? researchReduction : undefined, + caDisabledAccessCredit: californiaDisabledAccessCredit(inputs), caFarmLaborCredits: farmCredit.credit > 0 ? farmCredit : undefined, businessDepreciationAdjustment: adjustmentFor(inputs, "business"), rentalDepreciationAdjustment: adjustmentFor(inputs, "rental"), diff --git a/engine/src/state/ca/schedule-ca/answerLines.ts b/engine/src/state/ca/schedule-ca/answerLines.ts index d0763321..b5770411 100644 --- a/engine/src/state/ca/schedule-ca/answerLines.ts +++ b/engine/src/state/ca/schedule-ca/answerLines.ts @@ -132,9 +132,8 @@ function recaptureColumn(info: ScheduleCaFilingInfo, side: "subtraction" | "addi * - Form 8826: "California law conforms to this provision, but the maximum * credit is $125" (ftb-pub-1001-2025::sec::enter-on-schedule-ca-540-part-i-or-7::b04): * no deduction for an amount the California credit (FTB 3548) allows. The - * engine does not file FTB 3548, so no California credit reduces the - * California deduction, and the whole federal reduction comes back - * (federal/8826/QUESTIONS.md). + * whole federal reduction comes back here, and column C takes the + * California credit off (disabledAccessColumn). * - Form 8820: "Enter the amount of the federal Orphan Drug Credit that * reduced the federal deduction for qualified clinical testing expenses on * Schedule CA (540), Part I ... line 3, line 5, or line 6, column B" @@ -149,6 +148,23 @@ function recaptureColumn(info: ScheduleCaFilingInfo, side: "subtraction" | "addi const businessCreditColumn = (info: ScheduleCaFilingInfo, side: "subtraction" | "addition") => side === "subtraction" ? (info.caBusinessCreditAddBack ?? 0) : 0; +/* + * FTB 3548 line 4: "This credit is taken in lieu of any deduction or credit + * otherwise allowable for the same eligible access expenditures. Any deduction + * allowed for these same expenditures must be reduced by the amount of credit" + * (ca-3548-form-2025::sec::f-limitations::b03; the amount is the DECISION in + * 3548/resolveInfo.ts). The federal Schedule C line holds the expenditures less + * the federal credit, and column B gives that credit back (businessCreditColumn), + * so column C takes the California credit off: each credit is its own entry. + * Column C only; a gap or an answer that waits stops the line. + */ +function disabledAccessColumn(info: ScheduleCaFilingInfo, side: "subtraction" | "addition") { + const credit = info.caDisabledAccessCredit; + if (side === "subtraction" || credit === undefined) return 0; + if (typeof credit === "number") return credit; + return "gap" in credit ? unsupported(credit.gap) : undefined; +} + /* * The federal research credit reduced the Schedule C research expenses * (Form 6765 without the section 280C election). California "requires the @@ -179,11 +195,14 @@ export function line3Column(info: ScheduleCaFilingInfo, side: "subtraction" | "a if (info.businessDepreciationAdjustment?.waits) return undefined; const recapture = recaptureColumn(info, side); if (recapture !== undefined && typeof recapture !== "number") return recapture; + const disabledAccess = disabledAccessColumn(info, side); + if (typeof disabledAccess !== "number") return disabledAccess; const total = (employee ?? 0) + (depreciation ?? 0) + (recapture ?? 0) + businessCreditColumn(info, side) + + disabledAccess + agTransport; return positive(total); } diff --git a/engine/src/state/ca/schedule-ca/filingInfo.ts b/engine/src/state/ca/schedule-ca/filingInfo.ts index 6ab4f44e..f288e9f4 100644 --- a/engine/src/state/ca/schedule-ca/filingInfo.ts +++ b/engine/src/state/ca/schedule-ca/filingInfo.ts @@ -62,6 +62,8 @@ export interface ScheduleCaFilingInfo caBusinessCreditAddBack?: number; /** Line 3 columns B and C: the federal research credit (Form 6765 line 28) that reduced the Schedule C research expenses; undefined with none. */ caFederalResearchReduction?: number; + /** Line 3 column C: FTB 3548 line 4, the California credit that lowers the deduction for the same expenditures; undefined with none. */ + caDisabledAccessCredit?: number | { gap: string } | { waits: true }; /** Line 6 column B: the farms' Forms 5884 and 8844 credits and the labor hired they took off Schedule F line 22; undefined with none. */ caFarmLaborCredits?: { credit: number; reduction: number }; /** Line 3 (businesses) and line 5 (rentals) columns B and C: the FTB 3885A differences. */ diff --git a/engine/src/state/ca/schedule-p/partIII.ts b/engine/src/state/ca/schedule-p/partIII.ts index 9bae5d4d..2a405428 100644 --- a/engine/src/state/ca/schedule-p/partIII.ts +++ b/engine/src/state/ca/schedule-p/partIII.ts @@ -230,8 +230,8 @@ function codedCreditRow(page: 2 | 3, line: 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19, se export const partIIICreditRows: Unsupported = Object.fromEntries([ /* * Line 4 holds FTB 3507's credit (prisonLaborRow.ts). Lines 6 to 8 hold - * FTB 3541's original and new credits, then FTB 3807's, then FTB 3547's - * (sectionA2.ts). + * FTB 3541's original and new credits, then FTB 3807's, FTB 3548's and + * FTB 3547's (sectionA2.ts). */ ...codedCreditRow(2, 9, "Section A2"), ...row( diff --git a/engine/src/state/ca/schedule-p/resolveInfo.ts b/engine/src/state/ca/schedule-p/resolveInfo.ts index e7487c1c..41b6f90e 100644 --- a/engine/src/state/ca/schedule-p/resolveInfo.ts +++ b/engine/src/state/ca/schedule-p/resolveInfo.ts @@ -13,6 +13,7 @@ import { import { prisonLaborCreditFactKeys } from "../3507/resolveInfo.js"; import { claimsCaPriorYearAmtCredit } from "../3510/resolveInfo.js"; import { agTransportSectionA2Fallback } from "../3547/resolveInfo.js"; +import { disabledAccessSectionA2Fallback } from "../3548/resolveInfo.js"; import { lambraSectionA2Fallback } from "../3807/resolveInfo.js"; import { filmSectionA2Fallback, moreThanTwoCreditsFallback } from "./creditCount.js"; import type { SchedulePFilingInfo } from "./filingInfo.js"; @@ -80,6 +81,7 @@ export function resolveSchedulePInfo(inputs: ResolverInputs): SchedulePFilingInf moreThanTwoCreditsFallback(inputs, files540), filmSectionA2Fallback(inputs, files540), lambraSectionA2Fallback(inputs, files540), + disabledAccessSectionA2Fallback(inputs, files540), agTransportSectionA2Fallback(inputs, files540), ], }); diff --git a/engine/src/state/ca/schedule-p/sectionA2.ts b/engine/src/state/ca/schedule-p/sectionA2.ts index 39b9c942..16317f79 100644 --- a/engine/src/state/ca/schedule-p/sectionA2.ts +++ b/engine/src/state/ca/schedule-p/sectionA2.ts @@ -1,9 +1,10 @@ /* * Schedule P (540) Part III, Section A2 lines 6 to 8: FTB 3541's original * (223) and new (237) motion picture credits, then FTB 3807's LAMBRA credit - * (198; the DECISION in 3807/creditUsed.ts), then FTB 3547's donated - * agricultural products transportation credit (204; the DECISION in - * 3547/creditUsed.ts). Each "cannot reduce regular tax + * (198; the DECISION in 3807/creditUsed.ts), then FTB 3548's disabled access + * credit (205) and FTB 3547's donated agricultural products transportation + * credit (204; the DECISIONs in 3548/creditUsed.ts and 3547/creditUsed.ts). + * Each "cannot reduce regular tax * below TMT" (ca-3541-inst-2025::sec::c-limitations::b01) and offsets tax in * Section A2 (ca-540-sched-p-inst-2025::sec::credit-table::b01, ::b02, ::b06). * Column (b) is the smaller of column (a) and the previous line's column (c): @@ -21,13 +22,20 @@ import type { Form3541FilingInfo } from "../3541/filingInfo.js"; import { agTransportCreditOffered } from "../3547/creditUsed.js"; import type { Form3547FilingInfo } from "../3547/filingInfo.js"; import { AG_TRANSPORT_CREDIT_CODE, AG_TRANSPORT_CREDIT_NAME } from "../3547/lines.js"; +import { disabledAccessCreditOffered, disabledAccessScheduleLine } from "../3548/creditUsed.js"; +import type { Form3548FilingInfo } from "../3548/filingInfo.js"; +import { DISABLED_ACCESS_CREDIT_CODE, DISABLED_ACCESS_CREDIT_NAME } from "../3548/lines.js"; import { scheduleCreditRow, type CreditRow } from "../3804-cr/lines.js"; import { lambraCreditOffered, type Info as Form3807Info } from "../3807/figures.js"; import { LAMBRA_CREDIT_CODE, LAMBRA_CREDIT_NAME } from "../3807/lines.js"; import type { SchedulePFilingInfo } from "./filingInfo.js"; import type { ScheduleP } from "./types.js"; -type Info = SchedulePFilingInfo & Form3541FilingInfo & Form3807Info & Form3547FilingInfo; +type Info = SchedulePFilingInfo & + Form3541FilingInfo & + Form3807Info & + Form3548FilingInfo & + Form3547FilingInfo; type Bindings = Partial<{ [K in keyof ScheduleP]: BindingFn }>; type Form = FormAccessor; @@ -48,7 +56,7 @@ const noCreditReason = (line: number) => /* Four Section A2 credits: the engine fills lines 6 to 8 only. */ const MORE_CREDITS_THAN_LINES = - "The return has more Section A2 credits than lines 6 to 8 hold (FTB 3541's original and new credits, FTB 3807's and FTB 3547's); the engine does not fill line 9."; + "The return has more Section A2 credits than lines 6 to 8 hold (FTB 3541's original and new credits, FTB 3807's, FTB 3548's and FTB 3547's); the engine does not fill line 9."; const BALANCES_BEFORE_A2: Array = [ "1.part3.5_child_dependent_care_credit_col_c", @@ -67,12 +75,14 @@ function balanceBeforeA2(form: Form): number | undefined { const isGap = (value: unknown): value is Unsupported => typeof value === "object" && value !== null && "unsupported" in value; -/* The film credits of Section A2, then the LAMBRA credit and FTB 3547's credit when above 0. */ +/* The film credits of Section A2, then the LAMBRA credit, FTB 3548's and FTB 3547's credits when above 0. */ function sectionA2Credits(form: Form, info: Info): A2Credit[] | Unsupported | undefined { const film = filmCreditsAvailable(info); if (film === undefined || isGap(film)) return film; const lambra = lambraCreditOffered((fieldId) => form[fieldId], info); if (lambra === undefined || isGap(lambra)) return lambra; + const disabledAccess = disabledAccessA2Credit(form, info); + if (disabledAccess === undefined || isGap(disabledAccess)) return disabledAccess; const agTransport = agTransportCreditOffered((fieldId) => form[fieldId], info); if (agTransport === undefined || isGap(agTransport)) return agTransport; return [ @@ -86,12 +96,31 @@ function sectionA2Credits(form: Form, info: Info): A2Credit[] | Unsupported | un ...(lambra > 0 ? [{ code: LAMBRA_CREDIT_CODE, name: LAMBRA_CREDIT_NAME, available: lambra }] : []), + ...disabledAccess, ...(agTransport > 0 ? [{ code: AG_TRANSPORT_CREDIT_CODE, name: AG_TRANSPORT_CREDIT_NAME, available: agTransport }] : []), ]; } +/* + * FTB 3548's disabled access credit (205), after the LAMBRA credit and before + * FTB 3547's credit (the DECISION in 3548/creditUsed.ts); none with no credit. + * On line 9, which the engine does not fill, the credit is a gap + * (disabledAccessScheduleLine). + */ +function disabledAccessA2Credit(form: Form, info: Info): A2Credit[] | Unsupported | undefined { + const read = (fieldId: string) => form[fieldId]; + const offered = disabledAccessCreditOffered(read, info); + if (offered === undefined || isGap(offered)) return offered; + if (offered <= 0) return []; + const line = disabledAccessScheduleLine(read, info); + if (line === undefined || isGap(line)) return line; + return [ + { code: DISABLED_ACCESS_CREDIT_CODE, name: DISABLED_ACCESS_CREDIT_NAME, available: offered }, + ]; +} + function sectionA2Rows(form: Form, credits: A2Credit[]) { let balance = balanceBeforeA2(form); if (balance === undefined) return undefined; diff --git a/engine/src/state/ca/schedule-s/returnAmounts.ts b/engine/src/state/ca/schedule-s/returnAmounts.ts index a9e184a3..2f40fa83 100644 --- a/engine/src/state/ca/schedule-s/returnAmounts.ts +++ b/engine/src/state/ca/schedule-s/returnAmounts.ts @@ -12,6 +12,7 @@ import { prisonLaborCreditOnReturn } from "../3507/creditUsed.js"; import { PRIOR_YEAR_AMT_CREDIT_USED, priorYearAmtCreditWaits } from "../3510/creditUsed.js"; import { filmCreditsUsedTotal } from "../3541/creditUsed.js"; import { agTransportCreditOnReturn } from "../3547/creditUsed.js"; +import { disabledAccessCreditOnReturn } from "../3548/creditUsed.js"; import { passiveCreditsUsedTotal } from "../3801-cr/creditUsed.js"; import { enterpriseZoneCreditUsed } from "../3805z/creditUsed.js"; import { lambraCreditOnReturn } from "../3807/creditUsed.js"; @@ -72,12 +73,15 @@ export function californiaTaxLiability( const film = filmCreditsUsedTotal(read, info); if (typeof film !== "number") return film; /* - * On lines 43 to 45 too, in Schedule P (540) order: FTB 3807's LAMBRA credit - * and FTB 3547's credit (Section A2), then FTB 3805Z's enterprise zone, FTB - * 3809's TTA and FTB 3503's natural heritage preservation credits (Section B2). + * On lines 43 to 45 too, in Schedule P (540) order: FTB 3807's LAMBRA credit, + * FTB 3548's disabled access credit and FTB 3547's credit (Section A2), then + * FTB 3805Z's enterprise zone, FTB 3809's TTA and FTB 3503's natural heritage + * preservation credits (Section B2). */ const lambra = lambraCreditOnReturn(read, info); if (typeof lambra !== "number") return lambra; + const disabledAccess = disabledAccessCreditOnReturn(read, info); + if (typeof disabledAccess !== "number") return disabledAccess; const agTransport = agTransportCreditOnReturn(read, info); if (typeof agTransport !== "number") return agTransport; const enterpriseZone = enterpriseZoneCreditUsed(read, info); @@ -92,6 +96,7 @@ export function californiaTaxLiability( prisonLabor, film, lambra, + disabledAccess, agTransport, enterpriseZone, tta, diff --git a/engine/tests/integration/requiredInputs.test.ts b/engine/tests/integration/requiredInputs.test.ts index ffeb6cbd..e9282a4c 100644 --- a/engine/tests/integration/requiredInputs.test.ts +++ b/engine/tests/integration/requiredInputs.test.ts @@ -608,6 +608,17 @@ const OPTIONAL: Array<[RegExp, string]> = [ "credit (FTB 3547 line 3, one K-1); whether the taxpayer has one is Cade's question. FTB " + "3547 lists the fact again while an answer inside it (name, number, credit) is missing", ], + [ + /^ca_disabled_access_pass_through\.[^.]+$/, + "each fact is a whole entity's pass-through disabled access credit (FTB 3548 line 5, one " + + "K-1); whether the taxpayer has one is Cade's question. FTB 3548 lists the fact again " + + "while an answer inside it (name, number, credit) is missing", + ], + [ + /^ca_disabled_access\.own_business_disregarded_smllc$/, + "recorded only when the business that paid the expenditures is a disregarded single member " + + "LLC (FTB 3548 line 9a's limit); absent, the taxpayer runs the business directly", + ], [ /^ca_film_credit\.[^.]+$/, "each fact is one whole California Film Commission credit certificate (one FTB 3541); " + diff --git a/engine/tests/scenarios/synthetic/flann/README.md b/engine/tests/scenarios/synthetic/flann/README.md index ecf9bff7..d23b5088 100644 --- a/engine/tests/scenarios/synthetic/flann/README.md +++ b/engine/tests/scenarios/synthetic/flann/README.md @@ -9,11 +9,12 @@ The scenario covers the branches that `elam` cannot: the employee test, line 1 w - Form 8826 lines 1, 3, 5, 6 and 8. Line 7 is blank: no K-1. - Schedule C line 21: the repairs less line 6. - Form 3800 Part III line 1e and Schedule 3 line 6a. -- Schedule CA (540) line 3 column B: California allows the whole deduction, less only a California credit, and the engine files no FTB 3548. So the expense the federal credit took off comes back as a subtraction (ftb-pub-1001-2025::sec::enter-on-schedule-ca-540-part-i-or-7::b04). Form 540 line 14 takes it. +- Schedule CA (540) line 3 column B: California allows the whole deduction, less only a California credit. So the expense the federal credit took off comes back as a subtraction (ftb-pub-1001-2025::sec::enter-on-schedule-ca-540-part-i-or-7::b04). Form 540 line 14 takes it. +- FTB 3548, the California credit for the same expenditure: $125, used in full through Schedule P (540) Section A2 and taken on Form 540 line 43. Its $125 comes off the deduction in Schedule CA line 3 column C (decision A149). His 2024 return had no FTB 3548, so line 7 is 0. Simplifications: the expenditure and the 2024 answers are stated from the company's books, payroll and the contractor's invoice, which no official form holds. No California estimated tax was paid, so Form 540 shows an amount owed. -Forms that file: Form 1040, Schedules 1, 2, 3, C and SE, Forms 3800, 6251, 8826 and 8995, Schedule CA (540) and Form 540. +Forms that file: Form 1040, Schedules 1, 2, 3, C and SE, Forms 3800, 6251, 8826 and 8995, Schedule CA (540), Schedule P (540), FTB 3548 and Form 540. ## Hand check @@ -34,4 +35,10 @@ Forms that file: Form 1040, Schedules 1, 2, 3, C and SE, Forms 3800, 6251, 8826 | Form 3800 line 1e and line 38; Schedule 3 line 6a | 8826 line 8; the limit is 20,768 − 11,437 | 1,426 | | Form 1040 line 37 | 20,768 − 1,426 + 24,505 − 36,000 | 7,847 | | Schedule CA line 3 column B | the credit that reduced line 21 | 1,426 | -| Form 540 line 14, line 17 | 161,173 − 1,426 | 1,426 / 159,747 | +| FTB 3548 lines 1, 3, 4, 6, 8 | 3,101; smaller of 3,101 and 250; × 50%; no K-1; no carryover | 3,101 / 250 / 125 / 125 / 125 | +| Schedule CA line 3 column C | FTB 3548 line 4 | 125 | +| Form 540 lines 14, 16, 17 | 161,173 − 1,426 + 125 | 1,426 / 125 / 159,872 | +| Form 540 lines 19, 31, 35 | 159,872 − 5,706; rate schedule; less 153 | 154,166 / 10,776 / 10,623 | +| Schedule P Part III line 3 | 10,623 − 4,699 (TMT) | 5,924 | +| Schedule P line 6 (a), (b); FTB 3548 line 9a | the whole 125 fits | 125 / 125 / 125 | +| Form 540 lines 43, 48, 111 | code 205; 10,623 − 125 | 125 / 10,498 / 10,498 | diff --git a/engine/tests/scenarios/synthetic/flann/docs/Flann-CA540-Golden.pdf b/engine/tests/scenarios/synthetic/flann/docs/Flann-CA540-Golden.pdf index dacf4500..f1e68fa6 100644 Binary files a/engine/tests/scenarios/synthetic/flann/docs/Flann-CA540-Golden.pdf and b/engine/tests/scenarios/synthetic/flann/docs/Flann-CA540-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/flann/docs/Flann-Form3548-Golden.pdf b/engine/tests/scenarios/synthetic/flann/docs/Flann-Form3548-Golden.pdf new file mode 100644 index 00000000..6cb55a6e Binary files /dev/null and b/engine/tests/scenarios/synthetic/flann/docs/Flann-Form3548-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/flann/docs/Flann-ScheduleCA-Golden.pdf b/engine/tests/scenarios/synthetic/flann/docs/Flann-ScheduleCA-Golden.pdf index dba83037..4ef7a231 100644 Binary files a/engine/tests/scenarios/synthetic/flann/docs/Flann-ScheduleCA-Golden.pdf and b/engine/tests/scenarios/synthetic/flann/docs/Flann-ScheduleCA-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/flann/docs/Flann-ScheduleP-Golden.pdf b/engine/tests/scenarios/synthetic/flann/docs/Flann-ScheduleP-Golden.pdf new file mode 100644 index 00000000..8424d759 Binary files /dev/null and b/engine/tests/scenarios/synthetic/flann/docs/Flann-ScheduleP-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/flann/expected.ts b/engine/tests/scenarios/synthetic/flann/expected.ts index 45557c10..cf02b1f5 100644 --- a/engine/tests/scenarios/synthetic/flann/expected.ts +++ b/engine/tests/scenarios/synthetic/flann/expected.ts @@ -267,10 +267,46 @@ const EXPECTED: Record> = { "schedule-ca.3.line.c27_federal": 161173, // Line 27. Column B. Subtractions. "schedule-ca.3.line.c27_subtractions": 1426, + // Line 3 column C: FTB 3548 line 4, the California credit off the same deduction. + "schedule-ca.0.line.b3_additions": 125, + "schedule-ca.2.line.b10_additions": 125, + "schedule-ca.3.line.c27_additions": 125, // Line 30. Enter the larger of the amount on line 29 or your standard deduction shown below: "schedule-ca.5.page2.total_itemized_30_standard_or_itemized": 5706, }, }, + "schedule-p": { + engineFields: { + "schedule-p.0.line.1_standard_deduction": 5706, + "schedule-p.0.line.14_total_adjustments_preferences": 5706, + "schedule-p.0.line.15_taxable_income": 154166, + "schedule-p.1.line.19_combine_lines_14_through_18": 159872, + "schedule-p.1.line.21_alternative_minimum_taxable_income": 159872, + "schedule-p.1.line.22_exemption_amount": 92749, + "schedule-p.1.line.23_amti_less_exemption": 67123, + "schedule-p.1.line.24_tentative_minimum_tax": 4699, + "schedule-p.1.line.25_regular_tax_before_credits": 10776, + "schedule-p.1.part3.1_tax_from_form_540_line_35": 10623, + "schedule-p.1.part3.2_tentative_minimum_tax": 4699, + "schedule-p.1.part3.3_excess_tax_offset_by_credits_col_c": 5924, + // Section A2 line 6: code 205, the whole $125 used. + "schedule-p.2.part3.6_credit_amount_col_a": 125, + "schedule-p.2.part3.6_credit_used_col_b": 125, + "schedule-p.2.part3.6_tax_balance_col_c": 5799, + "schedule-p.2.part3.11_tax_balance_col_c": 10498, + }, + }, + "form-3548": { + engineFields: { + // Line 1: the $3,101.40 remodel, rounded; line 3 the $250 cap; line 4 half of it. + "form-3548.0.line.1_eligible_access_expenditures": 3101, + "form-3548.0.line.3_smaller_of_line_1_or_2": 250, + "form-3548.0.line.4_current_year_credit": 125, + "form-3548.0.line.6_total_current_year_credit": 125, + "form-3548.0.line.8_total_available_credit": 125, + "form-3548.0.line.9a_credit_claimed": 125, + }, + }, "form-540": { engineFields: { // Exemptions. For line 7, line 8, line 9, and line 10: Multiply the number you enter in the @@ -285,30 +321,39 @@ const EXPECTED: Record> = { "form-540.line.14_ca_adjustments_subtractions": 1426, // Line 15. Subtract line 14 from line 13. If less than zero, enter the result in parentheses "form-540.line.15_ca_agi_before_additions": 159747, + // Line 16: Schedule CA line 27 column C, FTB 3548's credit. + "form-540.line.16_ca_adjustments_additions": 125, // Line 17. California adjusted gross income. Combine line 15 and line 16. - "form-540.line.17_ca_agi": 159747, + "form-540.line.17_ca_agi": 159872, // Line 18. Enter the larger of your California itemized deductions from Schedule CA (540), P "form-540.line.18_deductions": 5706, // Line 19. Subtract line 18 from line 17. This is your taxable income. If less than zero, en - "form-540.line.19_taxable_income": 154041, + "form-540.line.19_taxable_income": 154166, // Line 31. Tax amount. - "form-540.line.31_tax_amount": 10764, + "form-540.line.31_tax_amount": 10776, // Line 32. Exemption credits. Enter the amount from line 11. If your federal adjusted gross "form-540.line.32_exemption_credits": 153, // Line 33. Subtract line 32 from line 31. If less than zero, enter 0. - "form-540.line.33_tax_after_exemption_credits": 10611, + "form-540.line.33_tax_after_exemption_credits": 10623, // Line 35. Add line 33 and line 34. - "form-540.line.35_total_tax_after_credits": 10611, + "form-540.line.35_total_tax_after_credits": 10623, + // Line 43: FTB 3548 line 9a, code 205. + "form-540.line.43_credit_amount": 125, + "form-540.line.47_total_credits": 125, // Line 48. Subtract line 47 from line 35. If less than zero, enter 0. - "form-540.line.48_tax_after_credits": 10611, + "form-540.line.48_tax_after_credits": 10498, // Line 64. Add line 48, line 61, line 62, and line 63. This is your total tax. - "form-540.line.64_total_tax": 10611, + "form-540.line.64_total_tax": 10498, // Line 100. Tax due. If line 95 is less than line 64, subtract line 95 from line 64. - "form-540.line.100_tax_due": 10611, + "form-540.line.100_tax_due": 10498, // Amount You Owe. Line 111. Amount You Owe. If you do not have an amount on line 99, add lin - "form-540.line.111_amount_you_owe": 10611, + "form-540.line.111_amount_you_owe": 10498, // Line 114. Total amount due. See instructions. Enclose, but do not staple, any payment. - "form-540.line.114_total_amount_due": 10611, + "form-540.line.114_total_amount_due": 10498, + }, + renderedText: { + "form-540.line.43_credit_name": "Disabled Access", + "form-540.line.43_credit_code": "205", }, }, }; diff --git a/engine/tests/scenarios/synthetic/flann/facts.ts b/engine/tests/scenarios/synthetic/flann/facts.ts index 13e8a69f..3421c47b 100644 --- a/engine/tests/scenarios/synthetic/flann/facts.ts +++ b/engine/tests/scenarios/synthetic/flann/facts.ts @@ -6,6 +6,7 @@ */ import { + CA_DISABLED_ACCESS_KEYS, CA_EMPLOYEE_CLASSIFICATION_KEYS, DISABLED_ACCESS_KEYS, makeBusinessFactKey, @@ -128,6 +129,7 @@ export const flannFacts: TaxFactRow[] = [ 24, `${VERBAL}: 2024 payroll records, employees with 30 or more hours a week for 20 or more weeks.`, ), + fact("other", CA_DISABLED_ACCESS_KEYS.carryover, 0, `${VERBAL}: no FTB 3548 in 2024.`), fact( "self_employment", CA_EMPLOYEE_CLASSIFICATION_KEYS.classifiedAsEmployee, diff --git a/engine/tests/scenarios/synthetic/flann/index.ts b/engine/tests/scenarios/synthetic/flann/index.ts index d6bf2e13..5e8a13fe 100644 --- a/engine/tests/scenarios/synthetic/flann/index.ts +++ b/engine/tests/scenarios/synthetic/flann/index.ts @@ -3,7 +3,8 @@ * (Schedule C) with 2024 gross receipts above $1 million and 24 full-time * employees that made its office restroom accessible. Form 8826 lines 1 to 8, * Schedule C line 21 less the credit, Form 3800 line 1e, Schedule 3 line 6a, - * and Schedule CA line 3 column B, which adds the reduced expense back. + * and Schedule CA line 3 column B, which adds the reduced expense back. FTB + * 3548 takes the $125 California credit, which column C takes off again. * UNVERIFIED: no answer key; the expected values are engine output checked by * hand, so a failure means "the engine changed". */ @@ -27,13 +28,15 @@ export const FORM_IDS = [ "schedule-3", "form-1040", "schedule-ca", + "schedule-p", + "form-3548", "form-540", ]; export const flannScenario: Scenario = { name: "flann", description: - "Single Fresno cleaning company owner, eligible by the employee test, with an accessible restroom: Form 8826 lines 1 to 8, Schedule C line 21 less the credit, Form 3800 line 1e, Schedule 3 line 6a, Schedule CA line 3 column B.", + "Single Fresno cleaning company owner, eligible by the employee test, with an accessible restroom: Form 8826 lines 1 to 8, Schedule C line 21 less the credit, Form 3800 line 1e, Schedule 3 line 6a, Schedule CA line 3 columns B and C, FTB 3548 and Form 540 line 43.", verification: "unverified", taxYear: FLANN_TAX_YEAR, userId: FLANN_USER_ID, diff --git a/engine/tests/scenarios/synthetic/leya/README.md b/engine/tests/scenarios/synthetic/leya/README.md new file mode 100644 index 00000000..789545ad --- /dev/null +++ b/engine/tests/scenarios/synthetic/leya/README.md @@ -0,0 +1,60 @@ +# leya (synthetic, unverified) + +Leya Calderwick is a made-up taxpayer. No filed return, benchmark case or +answer key stands behind her values. The lines below were checked by hand +against the forms and their instructions, then the engine's output was locked. + +## Who she is + +- Single, a full-year California resident (Eureka). +- She runs a music lesson studio (Schedule C) in a storefront built in 1962: + $66,500 of receipts. In 2025 the studio built a ramp over its front step + ($520, repairs) and paid a sign language interpreter for a deaf student + ($220, contract labor). Its 2024 receipts were $49,000, so it is an + eligible small business. +- She is a partner in Old Town Second Street Partners. Its Schedule K-1 (565) + passes through a $40 California disabled access credit. +- Her 2024 FTB 3548 line 10 carried $400 to 2025. +- She paid $4,000 of federal estimated tax and no California estimated tax. + +## Documents + +None. The expenditures and the 2024 receipts come from the studio's books +and invoices, which no official form holds. The K-1 and her 2024 return are +not in the engine: their amounts are her answers. The K-1's income is left +out on purpose: the engine has no California K-1, so the scenario tests the +credit alone. + +## What it covers + +- FTB 3548 lines 1 to 10. Line 6 stops at $125, so the K-1 credit is lost. + Line 9a is limited by the tax, and line 10 carries the rest. Lines 9b and + 9c print 0. +- Schedule P (540) Section A2 line 6 (code 205), which the credit attaches. +- Form 540 line 43 (name, code, amount). +- Schedule CA (540) line 3: column B gives back the $245 federal credit that + came off Schedule C; column C takes off the $125 California credit. +- Federal Form 8826, Form 3800 line 1e and Schedule 3 line 6a, from the same + expenditure facts. + +## Hand check + +| Line | Value | How | +| --- | --- | --- | +| 8826 lines 1, 3, 6 | 740; 490; 245 | 520 + 220; 740 − 250; × 50% | +| Sch C lines 11, 21 | 2,527; 1,728 | 2,600 − 73; 1,900 − 172 (line 6 split by expenditures) | +| Sch C line 31 | 40,145 | 66,500 − 26,355 | +| Sch SE lines 12, 13 | 5,672; 2,836 | 37,074 × 15.3%; half | +| 1040 line 11a | 37,309 | 40,145 − 2,836 | +| 3548 lines 1, 3, 4 | 740; 250; 125 | the 8826 line 1 total; smaller of 740 and 250; × 50% | +| 3548 lines 5, 6 | 40; 125 | the K-1; 125 + 40, but not more than 125 | +| 3548 lines 7, 8 | 400; 525 | 2024 line 10; 125 + 400 | +| Sch CA line 3 B, C | 245; 125 | federal line 6; FTB 3548 line 4 (decision A149) | +| 540 lines 14, 16, 17 | 245; 125; 37,189 | 37,309 − 245 + 125 | +| 540 lines 19, 31, 35 | 31,483; 624; 471 | 37,189 − 5,706; tax table; less 153 | +| Sch P lines 21, 24 | 37,189; 0 | AMTI; under the 92,749 exemption | +| Sch P Part III line 3 | 471 | 471 − 0 | +| Sch P line 6 (a), (b), (c), (d) | 525; 471; 0; 54 | line 8; smaller of 525 and 471; 471 − 471; 525 − 471 | +| 3548 lines 9a, 9b, 9c, 10 | 471; 0; 0; 54 | Sch P line 6 (b); not a corporation; tax under $5,000,000; 525 − 471 | +| 540 lines 43, 47, 48 | 471; 471; 0 | code 205; 471; 471 − 471 | +| 1040 lines 16, 20, 24, 37 | 1,829; 245; 7,256; 3,256 | tax table on 17,247; 8826 via 3800; 1,584 + 5,672; 7,256 − 4,000 | diff --git a/engine/tests/scenarios/synthetic/leya/decisions.ts b/engine/tests/scenarios/synthetic/leya/decisions.ts new file mode 100644 index 00000000..ce76f1b9 --- /dev/null +++ b/engine/tests/scenarios/synthetic/leya/decisions.ts @@ -0,0 +1,24 @@ +/* The made-up taxpayer's answers (README.md). */ + +import type { AIDecisionRow } from "../../../../src/facts/rows.js"; +import { decisionRow } from "../../../helpers/fixtureBuilders.js"; +import { LEYA_TAX_YEAR, LEYA_USER_ID } from "./facts.js"; + +const dec = (key: string, decision: unknown, rationale: string) => + decisionRow({ userId: LEYA_USER_ID, taxYear: LEYA_TAX_YEAR, key, decision, rationale }); + +export const leyaDecisions: AIDecisionRow[] = [ + dec("decisions.scope.must_file_federal", true, "Self-employment income is over $400."), + dec("decisions.scope.filing_status", "single", "Not married at the end of 2025."), + dec("decisions.scope.has_digital_assets", false, "No digital asset activity."), + dec("decisions.scope.has_reportable_sales", false, "No sales of stock or other property."), + dec("decisions.scope.has_foreign_financial_account", false, "No foreign accounts."), + dec("decisions.scope.has_foreign_trust", false, "No foreign trust."), + dec("decisions.itemize_vs_standard", "standard", "No itemized deductions."), + dec("decisions.scope.must_file_ca_540", true, "Full-year California resident."), + dec("decisions.scope.ca_residency", "full_year", "Lived in Eureka all of 2025."), + dec("decisions.scope.mailing_same_as_principal_residence", true, "Mailing address is the home."), + dec("decisions.scope.use_tax_zero_reason", "no_use_tax_owed", "No out-of-state purchases."), + dec("decisions.refund.refund_full_overpayment_federal", true, "Refund any overpayment."), + dec("decisions.refund.refund_full_overpayment_ca", true, "Refund any CA overpayment."), +]; diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-1040-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-1040-Golden.pdf new file mode 100644 index 00000000..607f6aa6 Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-1040-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-CA540-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-CA540-Golden.pdf new file mode 100644 index 00000000..dc734e2b Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-CA540-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-Form3548-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-Form3548-Golden.pdf new file mode 100644 index 00000000..027b4398 Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-Form3548-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-Form3800-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-Form3800-Golden.pdf new file mode 100644 index 00000000..3dc0bf57 Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-Form3800-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-Form6251-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-Form6251-Golden.pdf new file mode 100644 index 00000000..d8ad34b7 Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-Form6251-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-Form8826-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-Form8826-Golden.pdf new file mode 100644 index 00000000..35643227 Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-Form8826-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-Form8995-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-Form8995-Golden.pdf new file mode 100644 index 00000000..86d05390 Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-Form8995-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-Schedule1-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-Schedule1-Golden.pdf new file mode 100644 index 00000000..ff74f7c1 Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-Schedule1-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-Schedule2-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-Schedule2-Golden.pdf new file mode 100644 index 00000000..2f6301e6 Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-Schedule2-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-Schedule3-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-Schedule3-Golden.pdf new file mode 100644 index 00000000..8044ccca Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-Schedule3-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-ScheduleC-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-ScheduleC-Golden.pdf new file mode 100644 index 00000000..97cd90bf Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-ScheduleC-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-ScheduleCA-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-ScheduleCA-Golden.pdf new file mode 100644 index 00000000..3b876272 Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-ScheduleCA-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-ScheduleP-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-ScheduleP-Golden.pdf new file mode 100644 index 00000000..2327c57c Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-ScheduleP-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/docs/Leya-ScheduleSe-Golden.pdf b/engine/tests/scenarios/synthetic/leya/docs/Leya-ScheduleSe-Golden.pdf new file mode 100644 index 00000000..82a92687 Binary files /dev/null and b/engine/tests/scenarios/synthetic/leya/docs/Leya-ScheduleSe-Golden.pdf differ diff --git a/engine/tests/scenarios/synthetic/leya/expected.ts b/engine/tests/scenarios/synthetic/leya/expected.ts new file mode 100644 index 00000000..2d3a5050 --- /dev/null +++ b/engine/tests/scenarios/synthetic/leya/expected.ts @@ -0,0 +1,386 @@ +/* + * leya — LOCKED expected values, drafted from the engine's + * output on 2026-11-28 (scripts/draftExpected.ts). + * + * UNVERIFIED: no CPA return or filed-return check stands behind these + * values. They are engine output, checked by hand, so a failure means + * "the engine changed", not "the engine is wrong". + * + * Edit by hand. Change a value only after you verify it against the form + * instructions or a filed return (scripts/compareFiled). + */ + +import type { ExpectedResults } from "../../../types.js"; + +const EXPECTED: Record> = { + "form-8826": { + engineFields: { + // Line 1 — Total eligible access expenditures (dollars) + "form-8826.0.line.1_total_eligible_access_expenditures_dollars": 740, + // Line 3 — Subtract line 2 from line 1. If zero or less, enter -0- (dollars) + "form-8826.0.line.3_subtract_2_from_1_dollars": 490, + // Line 5 — Enter the smaller of line 3 or line 4 (dollars) + "form-8826.0.line.5_smaller_of_3_or_4_dollars": 490, + // Line 6 — Multiply line 5 by 50% (0.50) (dollars) + "form-8826.0.line.6_multiply_5_by_50_percent_dollars": 245, + // Line 8 — Add lines 6 and 7, but do not enter more than $5,000 (dollars) + "form-8826.0.line.8_total_disabled_access_credit_dollars": 245, + }, + }, + "schedule-c": { + engineFields: { + // Line 1 — Gross receipts or sales + "schedule-c.0.line.1": 66500, + // Line 3 — Subtract line 2 from line 1 + "schedule-c.0.line.3": 66500, + // Line 5 — Gross profit. Subtract line 4 from line 3 + "schedule-c.0.line.5": 66500, + // Line 7 — Gross income. Add lines 5 and 6 + "schedule-c.0.line.7": 66500, + // Line 8 — Advertising + "schedule-c.0.line.8": 800, + // Line 18 — Office expense + "schedule-c.0.line.18": 600, + // Line 11 — Contract labor + "schedule-c.0.line.11": 2527, + // Line 20b — Rent or lease: Other business property + "schedule-c.0.line.20b": 14400, + // Line 21 — Repairs and maintenance + "schedule-c.0.line.21": 1728, + // Line 22 — Supplies (not included in Part III) + "schedule-c.0.line.22": 3000, + // Line 15 — Insurance (other than health) + "schedule-c.0.line.15": 1200, + // Line 25 — Utilities + "schedule-c.0.line.25": 2100, + // Line 28 — Total expenses before expenses for business use of home. Add lines 8 through 27b + "schedule-c.0.line.28": 26355, + // Line 29 — Tentative profit or (loss). Subtract line 28 from line 7 + "schedule-c.0.line.29": 40145, + // Line 31 — Net profit or (loss). Subtract line 30 from line 29 + "schedule-c.0.line.31": 40145, + }, + }, + "schedule-se": { + engineFields: { + // Line 2 — Net profit or (loss) from Schedule C, line 31; and Schedule K-1 (Form 1065), box + "schedule-se.0.line.2": 40145, + // Line 3 — Combine lines 1a, 1b, and 2 + "schedule-se.0.line.3": 40145, + // Line 4a — If line 3 is more than zero, multiply line 3 by 92.35% (0.9235). Otherwise, ente + "schedule-se.0.line.4a": 37074, + // Line 4c — Combine lines 4a and 4b. If less than $400, stop; you don't owe self-employment + "schedule-se.0.line.4c": 37074, + // Line 6 — Add lines 4c and 5b + "schedule-se.0.line.6": 37074, + // Line 9 — Subtract line 8d from line 7. If zero or less, enter -0- + "schedule-se.0.line.9": 176100, + // Line 10 — Multiply the smaller of line 6 or line 9 by 12.4% (0.124) + "schedule-se.0.line.10": 4597, + // Line 11 — Multiply line 6 by 2.9% (0.029) + "schedule-se.0.line.11": 1075, + // Line 12 — Self-employment tax. Add lines 10 and 11 + "schedule-se.0.line.12": 5672, + // Line 13 — Deduction for one-half of self-employment tax. Multiply line 12 by 50% (0.50) + "schedule-se.0.line.13": 2836, + }, + }, + "schedule-1": { + engineFields: { + // Line 3 — Business income or (loss). Attach Schedule C + "schedule-1.0.line.3": 40145, + // Line 10 — Combine lines 1 through 7 and 9. This is your additional income + "schedule-1.0.line.10": 40145, + // Line 15 — Deductible part of self-employment tax (attach Schedule SE) + "schedule-1.1.line.15": 2836, + // Line 26 — Adjustments to income. Add lines 11 through 23 and 25 + "schedule-1.1.line.26": 2836, + }, + }, + "form-8995": { + engineFields: { + // Line 1i — (c) Qualified business income or (loss) + "form-8995.0.line.1i_c": 37309, + // Line 2 — Total qualified business income or (loss). Combine lines 1i through 1v, column (c + "form-8995.0.line.2": 37309, + // Line 4 — Total qualified business income. Combine lines 2 and 3. If zero or less, enter -0 + "form-8995.0.line.4": 37309, + // Line 5 — Qualified business income component. Multiply line 4 by 20% (0.20) + "form-8995.0.line.5": 7462, + // Line 10 — Qualified business income deduction before the income limitation. Add lines 5 an + "form-8995.0.line.10": 7462, + // Line 11 — Taxable income before qualified business income deduction + "form-8995.0.line.11": 21559, + // Line 13 — Subtract line 12 from line 11. If zero or less, enter -0- + "form-8995.0.line.13": 21559, + // Line 14 — Income limitation. Multiply line 13 by 20% (0.20) + "form-8995.0.line.14": 4312, + // Line 15 — Qualified business income deduction. Enter the smaller of line 10 or line 14 + "form-8995.0.line.15": 4312, + }, + }, + "form-6251": { + engineFields: { + // Line 1a — Subtract Schedule 1-A (Form 1040), line 37, from Form 1040, 1040-SR, or 1040-NR, + "form-6251.0.line.1a_deductions_less_schedule_1a": 20062, + // Line 1b — Subtract line 1a from Form 1040, 1040-SR, or 1040-NR, line 11b (if less than zer + "form-6251.0.line.1b_taxable_income_start": 17247, + // Line 2a — If filing Schedule A (Form 1040), enter the taxes from Schedule A, line 7; other + "form-6251.0.line.2a_taxes_or_standard_deduction": 15750, + // Line 4 — Alternative minimum taxable income. Combine lines 1b through 3 + "form-6251.0.line.4_alternative_minimum_taxable_income": 32997, + // Line 5 — Exemption + "form-6251.0.line.5_exemption": 88100, + // Line 10 — Add Form 1040 or 1040-SR, line 16 (minus any tax from Form 4972), and Schedule 2 + "form-6251.0.line.10_regular_tax_less_credits": 1829, + }, + }, + "form-3800": { + engineFields: { + // Line 1 — Credits not subject to the passive activity limit from Part III, line 2: combine + "form-3800.0.line.1_credits_not_passive_limited": 245, + // Line 6 — Add lines 1, 3, 4, and 5 + "form-3800.0.line.6_total_credits_not_allowed_tmt": 245, + // Line 7 — Regular tax before credits + "form-3800.0.line.7_regular_tax_before_credits": 1829, + // Line 9 — Add lines 7 and 8 + "form-3800.0.line.9_regular_tax_plus_amt": 1829, + // Line 11 — Net income tax. Subtract line 10c from line 9 + "form-3800.0.line.11_net_income_tax": 1829, + // Line 12 — Net regular tax. Subtract line 10c from line 7. If zero or less, enter -0- + "form-3800.0.line.12_net_regular_tax": 1829, + // Line 16 — Subtract line 15 from line 11. If zero or less, enter -0- + "form-3800.0.line.16_net_income_tax_less_line_15": 1829, + // Line 17 — Enter the smaller of line 6 or line 16. This is the amount of your credit allowe + "form-3800.0.line.17_credit_allowed_after_38c1_limit": 245, + // Line 27 — Subtract line 13 from line 11. If zero or less, enter -0- + "form-3800.1.line.27_subtract_line_13_from_11": 1829, + // Line 28 — Add lines 17 and 26 + "form-3800.1.line.28_add_lines_17_and_26": 245, + // Line 29 — Subtract line 28 from line 27. If zero or less, enter -0- + "form-3800.1.line.29_subtract_line_28_from_27": 1584, + // Line 38 — Credit allowed for the current year. Add lines 28 and 37 + "form-3800.1.line.38_credit_allowed_current_year": 245, + // Line 1e — Form 8826 — (e) Credits not subject to the passive activity limits + "form-3800.2.part3.1e_form_8826_col_e": 245, + // Line 1e — Form 8826 — (g) Combine columns (e) and (f) with the credit from column (d) allo + "form-3800.2.part3.1e_form_8826_col_g": 245, + // Line 2 — Add lines 1a–1zz — (e) Credits not subject to the passive activity limits + "form-3800.2.part3.2_add_lines_1a_1zz_col_e": 245, + // Line 2 — Add lines 1a–1zz — (g) Combine columns (e) and (f) with the credit from column (d + "form-3800.2.part3.2_add_lines_1a_1zz_col_g": 245, + // Line 6 — Add lines 2, 3, and 5: (e) Credits not subject to the passive activity limits + "form-3800.3.part3.6_add_lines_2_3_5_col_e": 245, + // Line 6 — Add lines 2, 3, and 5: (g) Combine columns (e) and (f) with the credit from colum + "form-3800.3.part3.6_add_lines_2_3_5_col_g": 245, + }, + }, + "schedule-2": { + engineFields: { + // Line 4 — Self-employment tax. Attach Schedule SE + "schedule-2.0.line.4_self_employment_tax": 5672, + // Line 21 — Add lines 4, 7 through 16, 18, and 19. Total other taxes. Enter here and on Form + "schedule-2.1.line.21_total_other_taxes": 5672, + }, + }, + "schedule-3": { + engineFields: { + // Line 6a — General business credit. Attach Form 3800 + "schedule-3.0.line.6a": 245, + // Line 7 — Total other nonrefundable credits. Add lines 6a through 6z + "schedule-3.0.line.7": 245, + // Line 8 — Add lines 1 through 4, 5a, 5b, and 7. Enter here and on Form 1040, line 20 + "schedule-3.0.line.8": 245, + }, + }, + "form-1040": { + engineFields: { + // Line 8 — Additional income from Schedule 1, line 10 + "form-1040.line.8": 40145, + // Line 9 — Add lines 1z, 2b, 3b, 4b, 5b, 6b, 7a, and 8. This is your total income + "form-1040.line.9": 40145, + // Line 10 — Adjustments to income from Schedule 1, line 26 + "form-1040.line.10": 2836, + // Line 11a — Subtract line 10 from line 9. This is your adjusted gross income + "form-1040.line.11a": 37309, + // Line 11b — Amount from line 11a (adjusted gross income) + "form-1040.line.11b": 37309, + // Line 12e — Standard deduction or itemized deductions (from Schedule A) + "form-1040.line.12e": 15750, + // Line 13a — Qualified business income deduction from Form 8995 or Form 8995-A + "form-1040.line.13a": 4312, + // Line 14 — Add lines 12e, 13a, and 13b + "form-1040.line.14": 20062, + // Line 15 — Subtract line 14 from line 11b. Taxable income + "form-1040.line.15": 17247, + // Line 16 — Tax (see instructions) + "form-1040.line.16": 1829, + // Line 18 — Add lines 16 and 17 + "form-1040.line.18": 1829, + // Line 20 — Amount from Schedule 3, line 8 + "form-1040.line.20": 245, + // Line 21 — Add lines 19 and 20 + "form-1040.line.21": 245, + // Line 22 — Subtract line 21 from line 18. If zero or less, enter -0- + "form-1040.line.22": 1584, + // Line 23 — Other taxes, including self-employment tax, from Schedule 2, line 21 + "form-1040.line.23": 5672, + // Line 24 — Add lines 22 and 23. Total tax + "form-1040.line.24": 7256, + // Line 26 — 2025 estimated tax payments and amount applied from 2024 return + "form-1040.line.26": 4000, + // Line 33 — Add lines 25d, 26, and 32. Total payments + "form-1040.line.33": 4000, + // Line 37 — Amount you owe + "form-1040.line.37": 3256, + }, + }, + "schedule-ca": { + engineFields: { + // Line 3 . Business income or (loss). See instructions. Column A. Federal Amounts. + "schedule-ca.0.line.b3_federal": 40145, + // Line 3 . Column B. Subtractions. + "schedule-ca.0.line.b3_subtractions": 245, + // Line 3 . Column C. Additions. + "schedule-ca.0.line.b3_additions": 125, + // Line 10. Total. Add Section A, line 1z through line 7a, and Section B, line 1 through line + "schedule-ca.2.line.b10_federal": 40145, + // Line 10. Column B. Subtractions. + "schedule-ca.2.line.b10_subtractions": 245, + // Line 10. Column C. Additions. + "schedule-ca.2.line.b10_additions": 125, + // Line 15. Deductible part of self-employment tax. See instructions. Column A. Federal Amoun + "schedule-ca.2.line.c15_federal": 2836, + // Line 26. Add line 11 through line 23 and line 25 in columns A, B, and C. See instructions. + "schedule-ca.3.line.c26_federal": 2836, + // Line 27. Total. Subtract line 26 from line 10 in columns A, B, and C. See instructions. Co + "schedule-ca.3.line.c27_federal": 37309, + // Line 27. Column B. Subtractions. + "schedule-ca.3.line.c27_subtractions": 245, + // Line 27. Column C. Additions. + "schedule-ca.3.line.c27_additions": 125, + // Line 30. Enter the larger of the amount on line 29 or your standard deduction shown below: + "schedule-ca.5.page2.total_itemized_30_standard_or_itemized": 5706, + }, + }, + "schedule-p": { + engineFields: { + // Part 1 . Line 1 . If you itemized deductions, go to line 2 . If you did not itemize deduct + "schedule-p.0.line.1_standard_deduction": 5706, + // Line 14 . Total Adjustments and Preferences. Combine line 1 through line 13 . + "schedule-p.0.line.14_total_adjustments_preferences": 5706, + // Line 15 . Enter taxable income from Form 540, line 19 . See instructions. + "schedule-p.0.line.15_taxable_income": 31483, + // Line 19 . Combine line 14 through line 18 . + "schedule-p.1.line.19_combine_lines_14_through_18": 37189, + // Line 21 . Alternative Minimum Taxable Income. Subtract line 20 from line 19 (if married/Re + "schedule-p.1.line.21_alternative_minimum_taxable_income": 37189, + // Part 2 . Line 22 . Exemption Amount. (If this schedule is for a certain child under age 24 + "schedule-p.1.line.22_exemption_amount": 92749, + // Line 25 . Regular tax before credits from Form 540, line 31 . + "schedule-p.1.line.25_regular_tax_before_credits": 624, + // Part 3 . Line 1 . Enter the amount from Form 540, line 35 . + "schedule-p.1.part3.1_tax_from_form_540_line_35": 471, + // Section A. Line 3 . Subtract line 2 from line 1 . If zero or less enter 0 and see instruct + "schedule-p.1.part3.3_excess_tax_offset_by_credits_col_c": 471, + // Line 6 . Column A. Credit amount. + "schedule-p.2.part3.6_credit_amount_col_a": 525, + // Line 6 . Column B*. Credit used this year. *If the taxpayer is subject to the business cre + "schedule-p.2.part3.6_credit_used_col_b": 471, + // Line 6 . Column D. Credit carryover. + "schedule-p.2.part3.6_credit_carryover_col_d": 54, + }, + renderedText: { + "schedule-p.2.part3.6_credit_code": "205", + "schedule-p.2.part3.6_credit_name": "Disabled Access", + }, + }, + "form-3548": { + engineFields: { + // Line 1. Eligible access expenditures. See instructions. + "form-3548.0.line.1_eligible_access_expenditures": 740, + // Line 3. Enter the smaller of line 1 or line 2. + "form-3548.0.line.3_smaller_of_line_1_or_2": 250, + // Line 4. Current year credit. Multiply line 3 by 50% (.50). + "form-3548.0.line.4_current_year_credit": 125, + // Line 5. Pass-through Disabled Access Credit(s) from Schedule K-1 (100S, 541, 565, or 568). + "form-3548.0.line.5_pass_through_credit_k1": 40, + // Line 6. Total current year Disabled Access Credit. Add line 4 and line 5, but do not enter + "form-3548.0.line.6_total_current_year_credit": 125, + // Line 7. Credit carryover from prior year. + "form-3548.0.line.7_credit_carryover_prior_year": 400, + // Line 8. Total available Disabled Access Credit. Add line 6 and line 7. + "form-3548.0.line.8_total_available_credit": 525, + // Line 9a. Credit claimed. Enter the amount of the credit claimed on the current year tax re + "form-3548.0.line.9a_credit_claimed": 471, + // Line 9b, verified zero: "If you are not a corporation, enter 0". + "form-3548.0.line.9b_total_credit_assigned": 0, + // Line 9c, verified zero: Form 540 line 35 is under $5,000,000, so the limit disallows nothing. + "form-3548.0.line.9c_credit_elected_refundable": 0, + // Line 10. Credit carryover available for future years. Add lines 9a, 9b, and 9c, subtract t + "form-3548.0.line.10_credit_carryover_future_years": 54, + }, + renderedText: { + "form-3548.0.header.name_on_return": "Leya Calderwick", + "form-3548.0.header.facility_address": "412 Second Street", + "form-3548.0.header.facility_city": "Eureka", + "form-3548.0.header.facility_state": "CA", + "form-3548.0.header.facility_zip": "95501", + }, + renderedBlank: ["form-3548.0.header.sos_file_number"], + }, + "form-540": { + engineFields: { + // Exemptions. For line 7, line 8, line 9, and line 10: Multiply the number you enter in the + "form-540.line.7_personal_exemption_count": 1, + // Multiply the number you put in the line 7 box by $153. Enter this number into this field. + "form-540.line.7_personal_exemption_amount": 153, + // Line 11. Exemption amount: Add line 7 through line 10. Transfer this amount to line 32. Wh + "form-540.line.11_total_exemption_amount": 153, + // Line 13. Enter federal adjusted gross income (A G I) from federal Form 1040 or 1040-SR, li + "form-540.line.13_federal_agi": 37309, + // Line 14. California adjustments – subtractions. Enter the amount from Schedule CA (540), P + "form-540.line.14_ca_adjustments_subtractions": 245, + // Line 15. Subtract line 14 from line 13. If less than zero, enter the result in parentheses + "form-540.line.15_ca_agi_before_additions": 37064, + // Line 16. California adjustments – additions. Enter the amount from Schedule CA (540), Part + "form-540.line.16_ca_adjustments_additions": 125, + // Line 17. California adjusted gross income. Combine line 15 and line 16. + "form-540.line.17_ca_agi": 37189, + // Line 18. Enter the larger of your California itemized deductions from Schedule CA (540), P + "form-540.line.18_deductions": 5706, + // Line 19. Subtract line 18 from line 17. This is your taxable income. If less than zero, en + "form-540.line.19_taxable_income": 31483, + // Line 31. Tax amount. + "form-540.line.31_tax_amount": 624, + // Line 32. Exemption credits. Enter the amount from line 11. If your federal adjusted gross + "form-540.line.32_exemption_credits": 153, + // Line 33. Subtract line 32 from line 31. If less than zero, enter 0. + "form-540.line.33_tax_after_exemption_credits": 471, + // Line 35. Add line 33 and line 34. + "form-540.line.35_total_tax_after_credits": 471, + // Line 43. Enter credit amount + "form-540.line.43_credit_amount": 471, + // Line 47. Add line 40 through line 46. These are your total credits. + "form-540.line.47_total_credits": 471, + // Line 48, verified zero: the credit takes all of line 35. + "form-540.line.48_tax_after_credits": 0, + }, + // One other credit: line 43 holds it by name and code; lines 44 and 45 stay blank. + renderedText: { + "form-540.line.43_credit_name": "Disabled Access", + "form-540.line.43_credit_code": "205", + }, + renderedBlank: ["form-540.line.44_credit_amount", "form-540.line.45_schedule_p_credits"], + }, +}; + +export function leyaExpected(formId: string): ExpectedResults { + const expected = EXPECTED[formId] ?? {}; + return { + engineFields: expected.engineFields ?? {}, + renderedText: expected.renderedText ?? {}, + renderedBlank: expected.renderedBlank ?? [], + renderedChecked: expected.renderedChecked ?? [], + }; +} diff --git a/engine/tests/scenarios/synthetic/leya/facts.ts b/engine/tests/scenarios/synthetic/leya/facts.ts new file mode 100644 index 00000000..cc9180e7 --- /dev/null +++ b/engine/tests/scenarios/synthetic/leya/facts.ts @@ -0,0 +1,174 @@ +/* + * A made-up single filer (README.md): every name, number and address is + * invented. Leya Calderwick runs a music lesson studio in Eureka. The + * studio's disabled access expenditures and its 2024 receipts are what she + * states from the studio's books and the invoices; no official form holds + * them. The partnership's California credit is stated as its Schedule K-1 + * (565) prints it; the K-1's income is left out, because the engine has no + * California K-1, so the scenario tests the credit alone. + */ + +import { + CA_DISABLED_ACCESS_KEYS, + CA_EMPLOYEE_CLASSIFICATION_KEYS, + DISABLED_ACCESS_KEYS, + ESTIMATED_TAX_KEYS, + PRIOR_YEAR_KEYS, + makeBusinessFactKey, + makeCaDisabledAccessPassThroughFactKey, + makeDisabledAccessFactKey, + makeEstimatedTaxPaymentFactKey, + type BusinessFactValue, + type CaDisabledAccessPassThroughFactValue, + type DatedAmountFactValue, + type DisabledAccessFactValue, +} from "../../../../src/facts/index.js"; +import type { TaxFactRow } from "../../../../src/facts/rows.js"; +import { identityFact } from "../../../helpers/fixtureBuilders.js"; + +export const LEYA_USER_ID = "leya-synthetic"; +export const LEYA_TAX_YEAR = 2025; + +const CREATED_AT = "2026-11-28T00:00:00Z"; +const VERBAL = "Stated by Leya, 2026-11-28"; + +const fact = (category: string, key: string, value: unknown, sourceNote: string): TaxFactRow => ({ + id: `f-${key}`, + userId: LEYA_USER_ID, + taxYear: LEYA_TAX_YEAR, + category, + key, + value, + sourceNote, + createdAt: CREATED_AT, +}); + +const HOME = { street: "1817 Buhne Street", city: "Eureka", state: "CA", zip: "95501" }; + +const STUDIO_KEY = makeBusinessFactKey("calderwick-music"); + +/* Her music lesson studio (Schedule C), in a storefront built in 1962. */ +const studio: BusinessFactValue = { + owner: "taxpayer", + activity: "Music lessons", + code: "611600", + name: "Calderwick Music Studio", + address: { street: "412 Second Street", city: "Eureka", state: "CA", zip: "95501" }, + accountingMethod: "cash", + materiallyParticipated: true, + startedThisYear: false, + paymentsRequire1099: false, + sellsGoods: false, + grossReceipts: 66500, + expenses: { + advertising: 800, + // Line 11 before the credit: holds the $220 interpreter. + contractLabor: 2600, + insurance: 1200, + office: 600, + rentOtherProperty: 14400, + // Line 21 before the credit: holds the $520 entrance ramp. + repairs: 1900, + supplies: 3000, + utilities: 2100, + }, + specifiedService: false, + w2WagesPaid: 0, + qualifiedPropertyUbia: 0, +}; + +/* Removing a barrier: a ramp over the storefront's front step (line 1). */ +const ramp: DisabledAccessFactValue = { + businessKey: STUDIO_KEY, + expenditures: 520, + deductedOn: "repairs", +}; + +/* A sign language interpreter for a deaf student's lessons and recital (line 1). */ +const interpreter: DisabledAccessFactValue = { + businessKey: STUDIO_KEY, + expenditures: 220, + deductedOn: "contractLabor", +}; + +/* Line 5: the partnership that owns her storefront's building made its shared entrance accessible. */ +const passThrough: CaDisabledAccessPassThroughFactValue = { + entityName: "Old Town Second Street Partners", + entityId: "202110517734", + credit: 40, +}; + +const PAYMENTS: Array<[string, DatedAmountFactValue]> = [ + ["2025-04", { date: "2025-04-15", amount: 1000 }], + ["2025-06", { date: "2025-06-16", amount: 1000 }], + ["2025-09", { date: "2025-09-15", amount: 1000 }], + ["2026-01", { date: "2026-01-15", amount: 1000 }], +]; + +const idFact = (suffix: string, value: string) => + identityFact({ userId: LEYA_USER_ID, taxYear: LEYA_TAX_YEAR, suffix, value }); + +export const leyaFacts: TaxFactRow[] = [ + idFact("name.first", "Leya"), + idFact("name.last", "Calderwick"), + idFact("ssn", "400-00-3548"), + idFact("dob", "08/19/1986"), + idFact("address.street", HOME.street), + idFact("address.city", HOME.city), + idFact("address.state", HOME.state), + idFact("address.zip", HOME.zip), + idFact("address.county", "Humboldt"), + idFact("occupation", "Music teacher"), + idFact("phone", "707-555-0162"), + fact("self_employment", STUDIO_KEY, studio, `${VERBAL}: the studio's books.`), + fact( + "self_employment", + makeDisabledAccessFactKey("entrance-ramp"), + ramp, + `${VERBAL}: the studio's books and the carpenter's invoice.`, + ), + fact( + "self_employment", + makeDisabledAccessFactKey("sign-interpreter"), + interpreter, + `${VERBAL}: the studio's books and the interpreter's invoices.`, + ), + fact( + "self_employment", + DISABLED_ACCESS_KEYS.priorYearGrossReceipts, + 49000, + `${VERBAL}: 2024 Schedule C line 3.`, + ), + fact( + "self_employment", + CA_EMPLOYEE_CLASSIFICATION_KEYS.classifiedAsEmployee, + false, + `${VERBAL}: she owns the studio; no one classifies her as an employee.`, + ), + fact( + "state_local_tax", + makeCaDisabledAccessPassThroughFactKey("old-town-second-street"), + passThrough, + "Schedule K-1 (565) from Old Town Second Street Partners and its statement.", + ), + fact("other", CA_DISABLED_ACCESS_KEYS.carryover, 400, "Her filed 2024 FTB 3548, line 10."), + ...PAYMENTS.map(([slug, value]) => + fact( + "estimated_payments", + makeEstimatedTaxPaymentFactKey(slug), + value, + `${VERBAL}: IRS Direct Pay confirmation.`, + ), + ), + fact( + "estimated_payments", + ESTIMATED_TAX_KEYS.priorYearOverpaymentApplied, + 0, + `${VERBAL}: no 2024 overpayment applied.`, + ), + fact("estimated_payments", PRIOR_YEAR_KEYS.federalTax, 3600, `${VERBAL}: 2024 return.`), + fact("estimated_payments", PRIOR_YEAR_KEYS.federalAgi, 22400, `${VERBAL}: 2024 Form 1040.`), + fact("estimated_payments", PRIOR_YEAR_KEYS.filedJointReturn, false, `${VERBAL}: single in 2024.`), + fact("health_coverage", "health_coverage.full_year_mec", true, `${VERBAL}: covered all year.`), + fact("use_tax", "use_tax.owed_amount", 0, `${VERBAL}: no out-of-state purchases.`), +]; diff --git a/engine/tests/scenarios/synthetic/leya/index.ts b/engine/tests/scenarios/synthetic/leya/index.ts new file mode 100644 index 00000000..48dc27aa --- /dev/null +++ b/engine/tests/scenarios/synthetic/leya/index.ts @@ -0,0 +1,49 @@ +/* + * Made-up taxpayer (README.md): a single full-year California resident whose + * music studio made its storefront accessible. FTB 3548 adds her own credit, + * a partnership's pass-through credit and a 2024 carryover; Schedule P (540) + * Section A2 lets the small tax use only part of it, and line 10 carries the + * rest. Form 540 line 43 takes the credit, and Schedule CA (540) line 3 + * column C takes it off the deduction. No answer key: the expected values are + * hand-checked, locked engine output. + */ + +import { lockedGoldenPath } from "../../../helpers/scenarioPdfName.js"; +import type { Scenario } from "../../../types.js"; +import { leyaDecisions } from "./decisions.js"; +import { leyaExpected } from "./expected.js"; +import { LEYA_TAX_YEAR, LEYA_USER_ID, leyaFacts } from "./facts.js"; + +/* Every form the engine files for these facts, upstreams first. */ +const FORM_IDS = [ + "form-8826", + "schedule-c", + "schedule-se", + "schedule-1", + "form-8995", + "form-6251", + "form-3800", + "schedule-2", + "schedule-3", + "form-1040", + "schedule-ca", + "schedule-p", + "form-3548", + "form-540", +]; + +export const leyaScenario: Scenario = { + name: "leya", + description: + "Single Eureka music teacher with the California disabled access credit (own expenditures, a K-1 credit, a 2024 carryover): FTB 3548 lines 1 to 10, line 9a limited by the tax in Schedule P (540) Section A2, Form 540 line 43, Schedule CA line 3 columns B and C.", + taxYear: LEYA_TAX_YEAR, + userId: LEYA_USER_ID, + verification: "unverified", + facts: leyaFacts, + decisions: leyaDecisions, + forms: FORM_IDS.map((formId) => ({ + formId, + expected: leyaExpected(formId), + goldenPdfPath: lockedGoldenPath("leya", formId), + })), +}; diff --git a/engine/tests/unit/state/ca/3548/creditUsed.test.ts b/engine/tests/unit/state/ca/3548/creditUsed.test.ts new file mode 100644 index 00000000..5a35b746 --- /dev/null +++ b/engine/tests/unit/state/ca/3548/creditUsed.test.ts @@ -0,0 +1,54 @@ +/* + * FTB 3548's credit offered to Schedule P (540): the cases of the whole return + * a scenario does not reach (a Form 540NR return, a tax over $5,000,000). + */ + +import { describe, expect, it } from "vitest"; +import { + disabledAccessCreditOffered, + disabledAccessLines, +} from "../../../../../src/state/ca/3548/creditUsed.js"; +import type { Form3548FilingInfo } from "../../../../../src/state/ca/3548/filingInfo.js"; +import { ownCreditLines } from "../../../../../src/state/ca/3548/lines.js"; + +const resolution = (value: boolean) => ({ value, rule: "test" }) as never; + +function infoWith(forms: Record): Form3548FilingInfo { + return { + mustFile: Object.fromEntries( + Object.entries(forms).map(([formId, value]) => [formId, resolution(value)]), + ), + form3548: { + own: ownCreditLines(740), + hasOwnExpenditures: true, + ownThroughSmllc: false, + passThroughRows: [], + carryover: 0, + }, + } as Form3548FilingInfo; +} + +const readLine35 = (amount: number) => (fieldId: string) => + fieldId === "form-540.line.35_total_tax_after_credits" ? amount : undefined; +const reasonOf = (result: unknown) => (result as { reason?: string } | undefined)?.reason ?? ""; + +describe("FTB 3548 credit offered", () => { + it("is line 8 on Form 540 with a tax of $5,000,000 or less", () => { + const info = infoWith({ "form-3548": true, "form-540": true }); + expect(disabledAccessLines(info)).toMatchObject({ line4: 125, line6: 125, line8: 125 }); + expect(disabledAccessCreditOffered(readLine35(5_000_000), info)).toBe(125); + }); + + it("is a gap above $5,000,000 of tax, where the business credit limit can bind", () => { + const info = infoWith({ "form-3548": true, "form-540": true }); + expect(reasonOf(disabledAccessCreditOffered(readLine35(5_000_001), info))).toContain( + "$5,000,000", + ); + }); + + it("is a gap on a Form 540NR return, and 0 when FTB 3548 does not file", () => { + const nonresident = infoWith({ "form-3548": true, "form-540nr": true }); + expect(reasonOf(disabledAccessCreditOffered(readLine35(1000), nonresident))).toContain("540NR"); + expect(disabledAccessCreditOffered(readLine35(1000), infoWith({ "form-540": true }))).toBe(0); + }); +}); diff --git a/engine/tests/unit/state/ca/3548/form.test.ts b/engine/tests/unit/state/ca/3548/form.test.ts new file mode 100644 index 00000000..1bc62e88 --- /dev/null +++ b/engine/tests/unit/state/ca/3548/form.test.ts @@ -0,0 +1,330 @@ +/* + * FTB 3548 on a whole return: who files, what it asks, line 9a's limits, the + * gaps, Schedule P (540) Section A2, Form 540 line 43, Schedule CA (540) line + * 3 column C, Schedule S line 2 and "no facts, nothing changes". The synthetic + * leya scenario is the base; flann is the base of Schedule S line 2. + */ + +import { describe, expect, it } from "vitest"; +import { + CA_DISABLED_ACCESS_KEYS, + DISABLED_ACCESS_KEYS, + isCaDisabledAccessPassThroughFactKey, + isDisabledAccessFactKey, + isOtherStateTaxFactKey, + makeCaDisabledAccessPassThroughFactKey, + type CaDisabledAccessPassThroughFactValue, +} from "../../../../../src/facts/index.js"; +import type { AIDecisionRow, TaxFactRow } from "../../../../../src/facts/rows.js"; +import { evaluateScenario } from "../../../../../src/index.js"; +import { decisionRow } from "../../../../helpers/fixtureBuilders.js"; +import { elyasScenario as elyas } from "../../../../scenarios/synthetic/elyas/index.js"; +import { flannScenario as flann } from "../../../../scenarios/synthetic/flann/index.js"; +import { leyaScenario as base } from "../../../../scenarios/synthetic/leya/index.js"; + +const decision = (key: string, value: unknown): AIDecisionRow => + decisionRow({ userId: base.userId, taxYear: base.taxYear, key, decision: value, rationale: "t" }); + +const withDecision = (key: string, value: unknown) => [ + ...base.decisions.filter((each) => each.decisionKey !== key), + decision(key, value), +]; + +const row = (category: string, key: string, value: unknown): TaxFactRow => ({ + id: `f-${key}`, + userId: base.userId, + taxYear: base.taxYear, + category, + key, + value, + sourceNote: "test", + createdAt: "2026-11-28T00:00:00Z", +}); + +const passThrough = (slug: string, value: Partial) => + row("state_local_tax", makeCaDisabledAccessPassThroughFactKey(slug), value); + +const isCaliforniaKey = (key: string) => + key === CA_DISABLED_ACCESS_KEYS.carryover || isCaDisabledAccessPassThroughFactKey(key); +const isOwnKey = (key: string) => + isDisabledAccessFactKey(key) || + key === DISABLED_ACCESS_KEYS.priorYearGrossReceipts || + key === DISABLED_ACCESS_KEYS.priorYearFullTimeEmployees; + +const without = (test: (key: string) => boolean, facts = base.facts) => + facts.filter((fact) => !test(fact.key)); +const replacing = (key: string, value: unknown, category = "other") => [ + ...base.facts.filter((fact) => fact.key !== key), + row(category, key, value), +]; + +function evaluate(facts: TaxFactRow[], decisions: AIDecisionRow[] = base.decisions) { + const result = evaluateScenario({ + filing: { id: "form-3548-test", taxYear: base.taxYear }, + facts, + decisions, + authEmail: null, + }); + const files = (formId: string) => { + const form = result.forms.get(formId); + return form?.mustFile.ok ? form.mustFile.value : undefined; + }; + const field = (formId: string, id: string) => + result.forms.get(formId)?.fields.find((each) => each.fieldId === `${formId}.${id}`)?.result; + const value = (formId: string, id: string) => { + const found = field(formId, id); + return found?.ok ? found.value : undefined; + }; + const line = (id: string) => value("form-3548", `0.line.${id}`); + const form540 = (id: string) => value("form-540", `line.${id}`); + const missing = result.forms.get("form-3548")?.missingInputs ?? []; + return { files, field, value, line, form540, missing }; +} + +const isGap = (result: unknown) => + (result as { unsupported?: boolean } | undefined)?.unsupported === true; +const reasonOf = (result: unknown) => (result as { reason?: string } | undefined)?.reason ?? ""; + +const K1 = { entityName: "Mad River Lofts LP", entityId: "202210998811" }; + +describe("FTB 3548 who files", () => { + it("leya: files with her own expenditures, a K-1 credit and a carryover, and asks nothing", () => { + const run = evaluate(base.facts); + expect(run.files("form-3548")).toBe(true); + expect(run.files("schedule-p")).toBe(true); + expect(run.missing).toEqual([]); + }); + + it("files with a K-1 credit alone, with a carryover alone", () => { + const k1 = evaluate(without(isOwnKey)); + expect(k1.files("form-3548")).toBe(true); + expect(k1.line("1_eligible_access_expenditures")).toBeUndefined(); + expect(k1.line("4_current_year_credit")).toBeUndefined(); + expect([k1.line("5_pass_through_credit_k1"), k1.line("6_total_current_year_credit")]).toEqual([ + 40, 40, + ]); + // With only a K-1 credit the facility is the entity's: blank. + expect(k1.value("form-3548", "0.header.facility_address")).toBeUndefined(); + const carry = evaluate( + without((key) => isOwnKey(key) || isCaDisabledAccessPassThroughFactKey(key)), + ); + expect(carry.files("form-3548")).toBe(true); + expect(carry.line("8_total_available_credit")).toBe(400); + }); + + it("does not file with no credit input, without a California return, or when the decision says no", () => { + const none = without((key) => isOwnKey(key) || isCaliforniaKey(key)); + expect(evaluate(none).files("form-3548")).toBe(false); + const no540 = withDecision("decisions.scope.must_file_ca_540", false); + expect(evaluate(base.facts, no540).files("form-3548")).toBe(false); + const no = evaluate(base.facts, withDecision("decisions.scope.must_file_3548", false)); + expect(no.files("form-3548")).toBe(false); + // Not claimed: no credit on Form 540 and no California reduction on Schedule CA. + expect(no.value("schedule-ca", "0.line.b3_additions")).toBeUndefined(); + expect(no.value("schedule-ca", "0.line.b3_subtractions")).toBe(245); + }); + + it("a business that is not eligible has no own credit; its K-1 credit still files", () => { + const facts = [ + ...replacing(DISABLED_ACCESS_KEYS.priorYearGrossReceipts, 1_400_000, "self_employment"), + row("self_employment", DISABLED_ACCESS_KEYS.priorYearFullTimeEmployees, 45), + ]; + const run = evaluate(facts); + expect(run.files("form-3548")).toBe(true); + expect(run.line("1_eligible_access_expenditures")).toBeUndefined(); + expect(run.line("6_total_current_year_credit")).toBe(40); + expect(run.value("schedule-ca", "0.line.b3_additions")).toBeUndefined(); + const alone = evaluate(without(isCaliforniaKey, facts)); + expect(alone.files("form-3548")).toBe(false); + }); + + it("asks for line 7 when it is not stated, and for a row that is not complete", () => { + const partial = passThrough("partial", { entityName: "Half Done LP" }); + const facts = [...without(isCaliforniaKey), partial]; + const run = evaluate(facts); + expect(run.files("form-3548")).toBe(true); + expect(run.missing).toEqual([partial.key, CA_DISABLED_ACCESS_KEYS.carryover]); + expect(run.line("4_current_year_credit")).toBe(125); + expect(run.line("8_total_available_credit")).toBeUndefined(); + expect(run.line("9a_credit_claimed")).toBeUndefined(); + }); + + it("asks the prior-year test answer when it is not stated", () => { + const run = evaluate(without((key) => key === DISABLED_ACCESS_KEYS.priorYearGrossReceipts)); + expect(run.files("form-3548")).toBe(true); + expect(run.missing).toContain(DISABLED_ACCESS_KEYS.priorYearGrossReceipts); + expect(run.line("1_eligible_access_expenditures")).toBeUndefined(); + }); +}); + +describe("FTB 3548 line 9a, Schedule P (540) and Form 540", () => { + it("leya: the tax over TMT limits line 9a, and line 10 carries the rest", () => { + const run = evaluate(base.facts); + expect(run.value("schedule-p", "1.part3.3_excess_tax_offset_by_credits_col_c")).toBe(471); + expect(run.value("schedule-p", "2.part3.6_credit_code")).toBe("205"); + expect(run.value("schedule-p", "2.part3.6_credit_amount_col_a")).toBe(525); + expect(run.value("schedule-p", "2.part3.6_credit_used_col_b")).toBe(471); + expect(run.value("schedule-p", "2.part3.6_credit_carryover_col_d")).toBe(54); + expect(run.line("9a_credit_claimed")).toBe(471); + expect([ + run.line("9b_total_credit_assigned"), + run.line("9c_credit_elected_refundable"), + ]).toEqual([0, 0]); + expect(run.line("10_credit_carryover_future_years")).toBe(54); + expect([run.form540("43_credit_name"), run.form540("43_credit_code")]).toEqual([ + "Disabled Access", + "205", + ]); + expect(run.form540("43_credit_amount")).toBe(471); + expect(run.form540("48_tax_after_credits")).toBe(0); + }); + + it("a larger tax uses the whole credit, and line 10 is 0", () => { + const facts = replacing(CA_DISABLED_ACCESS_KEYS.carryover, 0); + const run = evaluate(facts); + expect(run.line("8_total_available_credit")).toBe(125); + expect(run.line("9a_credit_claimed")).toBe(125); + expect(run.line("10_credit_carryover_future_years")).toBe(0); + expect(run.form540("48_tax_after_credits")).toBe(471 - 125); + }); + + it("is a gap when the decision says Schedule P (540) does not file", () => { + const run = evaluate(base.facts, withDecision("decisions.scope.must_file_schedule_p", false)); + const claimed = run.field("form-3548", "0.line.9a_credit_claimed"); + expect(isGap(claimed)).toBe(true); + expect(reasonOf(claimed)).toContain("Schedule P (540)"); + expect(isGap(run.field("form-540", "line.43_credit_amount"))).toBe(true); + expect(run.line("8_total_available_credit")).toBe(525); + }); + + it("a disregarded single member LLC is a gap for line 9a, not for lines 1 to 8", () => { + const facts = [ + ...base.facts, + row("self_employment", CA_DISABLED_ACCESS_KEYS.ownBusinessDisregardedSmllc, true), + ]; + const run = evaluate(facts); + expect(run.line("8_total_available_credit")).toBe(525); + const claimed = run.field("form-3548", "0.line.9a_credit_claimed"); + expect(reasonOf(claimed)).toContain("single member LLC"); + expect(isGap(run.field("form-540", "line.43_credit_amount"))).toBe(true); + const k1 = passThrough("smllc", { ...K1, credit: 30, throughDisregardedSmllc: true }); + const viaK1 = evaluate([...base.facts, k1]); + expect(isGap(viaK1.field("form-3548", "0.line.9a_credit_claimed"))).toBe(true); + }); +}); + +describe("FTB 3548 and Schedule S (540) line 2", () => { + /* + * Line 2: "Residents – Form 540, line 48 (without other state tax credit and + * PTE elective tax credit)" (ca-540-sched-s-inst-2025::sec::part-ii-figure-your-other-state-tax-credit::b01), + * so line 48 has the disabled access credit taken off. flann (Form 540 line + * 35 $10,623, line 9a $125) with elyas's Massachusetts tax. + */ + const isOtherState = (fact: TaxFactRow) => isOtherStateTaxFactKey(fact.key); + const flannWithOtherState = [...flann.facts, ...elyas.facts.filter(isOtherState)]; + const scheduleS = (decisions: AIDecisionRow[]) => { + const result = evaluateScenario({ + filing: { id: "form-3548-schedule-s", taxYear: flann.taxYear }, + facts: flannWithOtherState, + decisions, + authEmail: null, + }); + const found = (formId: string, id: string) => + result.forms.get(formId)?.fields.find((each) => each.fieldId === `${formId}.${id}`)?.result; + const value = (formId: string, id: string) => { + const field = found(formId, id); + return field?.ok ? field.value : undefined; + }; + return { + line2: value("schedule-s", "0.line.2_california_tax_liability"), + line35: value("form-540", "line.35_total_tax_after_credits"), + line9a: value("form-3548", "0.line.9a_credit_claimed"), + }; + }; + + it("flann: line 2 is Form 540 line 35 less FTB 3548 line 9a", () => { + expect(scheduleS(flann.decisions)).toEqual({ line2: 10498, line35: 10623, line9a: 125 }); + }); + + it("flann: with the credit not claimed, line 2 is line 35", () => { + const noCredit = [ + ...flann.decisions.filter((each) => each.decisionKey !== "decisions.scope.must_file_3548"), + decisionRow({ + userId: flann.userId, + taxYear: flann.taxYear, + key: "decisions.scope.must_file_3548", + decision: false, + rationale: "t", + }), + ]; + // Without the credit Schedule CA adds back no $125 (column C), so line 35 is $12 lower too. + expect(scheduleS(noCredit)).toEqual({ line2: 10611, line35: 10611, line9a: undefined }); + }); +}); + +describe("FTB 3548 and Schedule CA (540) line 3", () => { + it("leya: column B gives back the federal credit, column C takes the California credit off", () => { + const run = evaluate(base.facts); + expect(run.value("schedule-ca", "0.line.b3_subtractions")).toBe(245); + expect(run.value("schedule-ca", "0.line.b3_additions")).toBe(125); + expect(run.form540("16_ca_adjustments_additions")).toBe(125); + }); + + it("expenditures under $250 have no federal credit, only the California one", () => { + const facts = base.facts.map((fact) => + isDisabledAccessFactKey(fact.key) + ? { ...fact, value: { ...(fact.value as object), expenditures: 90 } } + : fact, + ); + const run = evaluate(facts); + expect(run.line("1_eligible_access_expenditures")).toBe(180); + expect(run.line("4_current_year_credit")).toBe(90); + expect(run.value("form-8826", "0.line.6_multiply_5_by_50_percent_dollars")).toBe(0); + expect(run.value("schedule-ca", "0.line.b3_subtractions")).toBeUndefined(); + expect(run.value("schedule-ca", "0.line.b3_additions")).toBe(90); + }); + + it("capitalized expenditures are a gap on lines 1 to 8 and on line 3 column C", () => { + const facts = base.facts.map((fact) => + isDisabledAccessFactKey(fact.key) + ? { ...fact, value: { ...(fact.value as object), deductedOn: "capitalized" } } + : fact, + ); + const run = evaluate(facts); + expect(isGap(run.field("form-3548", "0.line.1_eligible_access_expenditures"))).toBe(true); + expect(isGap(run.field("form-3548", "0.line.8_total_available_credit"))).toBe(true); + expect(isGap(run.field("schedule-ca", "0.line.b3_additions"))).toBe(true); + }); +}); + +describe("FTB 3548 header", () => { + it("leya: the facility is the studio's address", () => { + const run = evaluate(base.facts); + expect(run.value("form-3548", "0.header.id_number_type")).toBe("ssn_or_itin"); + expect(run.value("form-3548", "0.header.name_on_return")).toBe("Leya Calderwick"); + expect(run.value("form-3548", "0.header.facility_address")).toBe("412 Second Street"); + expect(run.value("form-3548", "0.header.sos_file_number")).toBeUndefined(); + }); + + it("a business with no address of its own is at the home address", () => { + const facts = base.facts.map((fact) => + fact.key === "business.calderwick-music" + ? { ...fact, value: { ...(fact.value as object), address: undefined } } + : fact, + ); + const run = evaluate(facts); + expect(run.value("form-3548", "0.header.facility_address")).toBe("1817 Buhne Street"); + expect(run.value("form-3548", "0.header.facility_zip")).toBe("95501"); + }); +}); + +describe("FTB 3548: no facts, nothing changes", () => { + it("with no disabled access facts, Schedule CA and Form 540 have no trace of the credit", () => { + const run = evaluate(without((key) => isOwnKey(key) || isCaliforniaKey(key))); + expect(run.files("form-3548")).toBe(false); + expect(run.files("schedule-p")).toBe(false); + expect(run.value("schedule-ca", "0.line.b3_subtractions")).toBeUndefined(); + expect(run.value("schedule-ca", "0.line.b3_additions")).toBeUndefined(); + expect(isGap(run.field("form-540", "line.43_credit_amount"))).toBe(true); + }); +}); diff --git a/engine/tests/unit/state/ca/3548/lines.test.ts b/engine/tests/unit/state/ca/3548/lines.test.ts new file mode 100644 index 00000000..f8b7f086 --- /dev/null +++ b/engine/tests/unit/state/ca/3548/lines.test.ts @@ -0,0 +1,87 @@ +/* + * FTB 3548 arithmetic. The form and its instructions publish no example with + * a full computation (QUESTIONS.md); the one number the texts state is the + * maximum: 50% of $250 is $125. The rest are limit tests: totals equal their + * parts, the credit never passes its limits, and each edge. + */ + +import { describe, expect, it } from "vitest"; +import { + ASSIGNED_CREDIT_OF_AN_INDIVIDUAL, + BUSINESS_CREDIT_LIMIT, + CREDIT_LIMIT, + CREDIT_RATE, + DISABLED_ACCESS_CREDIT_CODE, + MAXIMUM_EXPENDITURES, + line10Of, + line3Of, + line4Of, + line5Of, + line6Of, + line7Of, + line8Of, + ownCreditLines, +} from "../../../../../src/state/ca/3548/lines.js"; + +describe("FTB 3548 constants", () => { + it("is 50% of up to $250, at most $125, code 205, a $5,000,000 business credit limit", () => { + expect([MAXIMUM_EXPENDITURES, CREDIT_RATE, CREDIT_LIMIT]).toEqual([250, 0.5, 125]); + expect(DISABLED_ACCESS_CREDIT_CODE).toBe("205"); + expect(BUSINESS_CREDIT_LIMIT).toBe(5_000_000); + expect(ASSIGNED_CREDIT_OF_AN_INDIVIDUAL).toBe(0); + }); +}); + +describe("FTB 3548 lines 1 to 4", () => { + it("FTB Pub 1001 (enter-on-schedule-ca-540-part-i-or-7::b04): 50% of $250 is the $125 maximum", () => { + expect(ownCreditLines(250)).toEqual({ line1: 250, line3: 250, line4: 125 }); + }); + + it("line 3 is the smaller of line 1 and $250, at each edge", () => { + expect([line3Of(0), line3Of(249), line3Of(250), line3Of(251), line3Of(10_000)]).toEqual([ + 0, 249, 250, 250, 250, + ]); + }); + + it("line 4 is half of line 3, an odd dollar rounding the half up", () => { + expect([line4Of(0), line4Of(100), line4Of(201), line4Of(250)]).toEqual([0, 50, 101, 125]); + }); + + it("the own credit is never more than $125, however large the expenditures", () => { + for (const line1 of [0, 1, 99, 250, 251, 740, 3101, 1_000_000]) { + const { line4 } = ownCreditLines(line1); + expect(line4).toBeLessThanOrEqual(CREDIT_LIMIT); + expect(line4).toBeGreaterThanOrEqual(0); + } + }); +}); + +describe("FTB 3548 lines 5 to 10", () => { + it("line 5 keeps the K-1 cents while adding and rounds the total once", () => { + expect(line5Of([20.4, 20.4])).toBe(41); + expect(line5Of([40])).toBe(40); + }); + + it("line 6 adds lines 4 and 5 and stops at $125", () => { + expect(line6Of(90, 30)).toBe(120); + expect(line6Of(125, 40)).toBe(125); + expect(line6Of(100, 25)).toBe(125); + expect(line6Of(undefined, 300)).toBe(125); + expect(line6Of(60, undefined)).toBe(60); + }); + + it("line 7 is last year's line 10 in whole dollars; line 8 adds lines 6 and 7", () => { + expect(line7Of(399.6)).toBe(400); + expect(line8Of(125, 400)).toBe(525); + }); + + it("line 10 is line 8 less lines 9a to 9c, never below 0, and the parts add to line 8", () => { + expect(line10Of(525, 471, 0, 0)).toBe(54); + expect(line10Of(125, 125, 0, 0)).toBe(0); + expect(line10Of(100, 0, 0, 0)).toBe(100); + expect(line10Of(100, 150, 0, 0)).toBe(0); + const line8 = 300; + const claimed = 120; + expect(claimed + line10Of(line8, claimed, 0, 0)).toBe(line8); + }); +}); diff --git a/engine/tests/unit/state/ca/3548/threeCredits.test.ts b/engine/tests/unit/state/ca/3548/threeCredits.test.ts new file mode 100644 index 00000000..58172cf2 --- /dev/null +++ b/engine/tests/unit/state/ca/3548/threeCredits.test.ts @@ -0,0 +1,118 @@ +/* + * FTB 3548, FTB 3547 and FTB 3503 on one California return. The base is the + * flann scenario: FTB 3548's $125 credit, Form 540 line 35 of $10,623 and a + * tentative minimum tax of $4,699, so Schedule P (540) line 3 is $5,924. The + * test adds a 2024 FTB 3547 carryover, a 2024 FTB 3503 carryover of $1,000 + * and elyas's Massachusetts tax ($1,500 on $30,000), so Schedule S files. + * + * The order (decisions A147, A148 and A150): Section A2 takes the disabled + * access credit (205) on line 6, then the donated agricultural products + * transportation credit (204) on line 7; Section B2 takes the natural heritage + * preservation credit (213) on line 16; Section B3 line 20 takes the other + * state tax credit. + */ + +import { describe, expect, it } from "vitest"; +import { + CA_AG_TRANSPORT_KEYS, + CA_NATURAL_HERITAGE_KEYS, + isOtherStateTaxFactKey, +} from "../../../../../src/facts/index.js"; +import type { TaxFactRow } from "../../../../../src/facts/rows.js"; +import { evaluateScenario } from "../../../../../src/index.js"; +import { elyasScenario as elyas } from "../../../../scenarios/synthetic/elyas/index.js"; +import { flannScenario as flann } from "../../../../scenarios/synthetic/flann/index.js"; + +const row = (category: string, key: string, value: unknown): TaxFactRow => ({ + id: `f-${key}`, + userId: flann.userId, + taxYear: flann.taxYear, + category, + key, + value, + sourceNote: "test", + createdAt: "2026-11-28T00:00:00Z", +}); + +/* No trips of her own this year: FTB 3547 has only the carryover (line 5). */ +const agTransport = (carryover: number) => [ + row("self_employment", CA_AG_TRANSPORT_KEYS.costs, { + method: "actual", + actualCosts: 0, + deductedOn: "not_deducted", + }), + row("other", CA_AG_TRANSPORT_KEYS.carryover, carryover), +]; + +function evaluate(agTransportCarryover: number) { + const facts = [ + ...flann.facts, + ...elyas.facts.filter((fact) => isOtherStateTaxFactKey(fact.key)), + ...agTransport(agTransportCarryover), + row("other", CA_NATURAL_HERITAGE_KEYS.carryover, 1000), + ]; + const result = evaluateScenario({ + filing: { id: "california-three-credits-test", taxYear: flann.taxYear }, + facts, + decisions: flann.decisions, + authEmail: null, + }); + const value = (formId: string, id: string) => { + const found = result.forms + .get(formId) + ?.fields.find((each) => each.fieldId === `${formId}.${id}`)?.result; + return found?.ok ? found.value : undefined; + }; + const columns = (page: 2 | 3, line: number) => + [ + "credit_code", + "credit_amount_col_a", + "credit_used_col_b", + "tax_balance_col_c", + "credit_carryover_col_d", + ].map((column) => value("schedule-p", `${page}.part3.${line}_${column}`)); + return { value, columns }; +} + +describe("FTB 3548, FTB 3547 and FTB 3503 on one return", () => { + it("each credit takes the tax the credits before it leave, once", () => { + const run = evaluate(300); + expect(run.value("form-540", "line.35_total_tax_after_credits")).toBe(10623); + expect(run.value("schedule-p", "1.part3.3_excess_tax_offset_by_credits_col_c")).toBe(5924); + // Line 6: 205, 125 used; 5,924 − 125 = 5,799 left above TMT. + expect(run.columns(2, 6)).toEqual(["205", 125, 125, 5799, 0]); + // Line 7: 204, 300 used; 5,799 − 300 = 5,499. + expect(run.columns(2, 7)).toEqual(["204", 300, 300, 5499, 0]); + // Line 11: 10,623 − 125 − 300 = 10,198; line 16: 213, 10,198 − 1,000 = 9,198. + expect(run.value("schedule-p", "2.part3.11_tax_balance_col_c")).toBe(10198); + expect(run.columns(3, 16)).toEqual(["213", 1000, 1000, 9198, 0]); + // Schedule S line 2: Form 540 line 48 without the other state credit: 10,623 − 125 − 300 − 1,000. + expect(run.value("schedule-s", "0.line.2_california_tax_liability")).toBe(9198); + expect(run.value("schedule-p", "3.part3.20_other_state_tax_credit_used_col_b")).toBe(1500); + // Four credits: lines 43 and 44 stay blank, line 45 is 125 + 300 + 1,000 + 1,500. + expect(run.value("form-540", "line.43_credit_amount")).toBeUndefined(); + expect(run.value("form-540", "line.44_credit_amount")).toBeUndefined(); + expect(run.value("form-540", "line.45_schedule_p_credits")).toBe(2925); + // Line 48: 10,623 − 2,925. + expect(run.value("form-540", "line.48_tax_after_credits")).toBe(7698); + expect(run.value("form-3548", "0.line.9a_credit_claimed")).toBe(125); + expect(run.value("form-3547", "0.line.7a_credit_claimed")).toBe(300); + expect(run.value("form-3503", "0.line.7a_credit_claimed")).toBe(1000); + }); + + it("when TMT limits Section A2, code 205 is used first and code 204 carries the rest", () => { + const run = evaluate(6000); + expect(run.columns(2, 6)).toEqual(["205", 125, 125, 5799, 0]); + // Line 7: the smaller of 6,000 and 5,799; 6,000 − 5,799 = 201 carries over. + expect(run.columns(2, 7)).toEqual(["204", 6000, 5799, 0, 201]); + expect(run.value("form-3547", "0.line.8_credit_carryover_future_years")).toBe(201); + // Line 11: 10,623 − 125 − 5,799 = 4,699, the TMT; line 16: 4,699 − 1,000. + expect(run.columns(3, 16)).toEqual(["213", 1000, 1000, 3699, 0]); + expect(run.value("schedule-s", "0.line.2_california_tax_liability")).toBe(3699); + // Schedule S line 12: line 2 × 0.1877 = 694, under the 1,500 paid. + expect(run.value("schedule-s", "0.line.12_other_state_tax_credit")).toBe(694); + // Line 45: 125 + 5,799 + 1,000 + 694 = 7,618; line 48: 10,623 − 7,618. + expect(run.value("form-540", "line.45_schedule_p_credits")).toBe(7618); + expect(run.value("form-540", "line.48_tax_after_credits")).toBe(3005); + }); +});