policyengine-household-wizard 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist/{index-B_OXaS4a.cjs → index-BfoPBFne.cjs} +1 -1
- package/dist/{index-DWM0giHt.js → index-DoD0AXHz.js} +72 -70
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/us-household/adapters/v1Payload.d.ts.map +1 -1
- package/dist/us-household/draft.d.ts.map +1 -1
- package/dist/us-household/normalize.d.ts.map +1 -1
- package/dist/us-household/serialize.d.ts.map +1 -1
- package/dist/us-household/types.d.ts +8 -0
- package/dist/us-household/types.d.ts.map +1 -1
- package/dist/us-household/validate.d.ts.map +1 -1
- package/dist/us-household-adapters.cjs +1 -1
- package/dist/us-household-adapters.js +1 -1
- package/dist/us-household.cjs +1 -1
- package/dist/us-household.js +213 -200
- package/package.json +1 -1
- package/src/us-household/adapters/v1Payload.ts +4 -0
- package/src/us-household/draft.ts +1 -0
- package/src/us-household/normalize.ts +3 -0
- package/src/us-household/serialize.ts +6 -0
- package/src/us-household/types.ts +8 -0
- package/src/us-household/validate.ts +15 -0
package/package.json
CHANGED
|
@@ -367,6 +367,10 @@ export function toV1HouseholdPayload(
|
|
|
367
367
|
const spmUnits: V1GroupCollection = {
|
|
368
368
|
[keys.spmUnit]: { members: [...memberIds] },
|
|
369
369
|
};
|
|
370
|
+
const childcare = toAmount(draft.childcareExpenses);
|
|
371
|
+
if (childcare !== undefined) {
|
|
372
|
+
spmUnits[keys.spmUnit].spm_unit_pre_subsidy_childcare_expenses = yearMap(year, childcare);
|
|
373
|
+
}
|
|
370
374
|
const households: V1GroupCollection = {
|
|
371
375
|
[keys.household]: householdRecord,
|
|
372
376
|
};
|
|
@@ -46,6 +46,7 @@ export function cloneDraft(draft: USHouseholdDraft): USHouseholdDraft {
|
|
|
46
46
|
zip: draft.zip,
|
|
47
47
|
maritalStatus: draft.maritalStatus,
|
|
48
48
|
year: draft.year,
|
|
49
|
+
childcareExpenses: draft.childcareExpenses,
|
|
49
50
|
extras: draft.extras ? structuredClone(draft.extras) : undefined,
|
|
50
51
|
people: draft.people.map((person) => ({
|
|
51
52
|
...person,
|
|
@@ -110,6 +110,7 @@ interface LegacyDraftShape {
|
|
|
110
110
|
partnerAge?: number | string | null;
|
|
111
111
|
spouseAge?: number | string | null;
|
|
112
112
|
year?: number;
|
|
113
|
+
childcareExpenses?: number | string | null;
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
function coerceAge(value: unknown): number | null {
|
|
@@ -233,6 +234,8 @@ export function normalizeLegacyDraft(
|
|
|
233
234
|
}
|
|
234
235
|
const legacy = raw as LegacyDraftShape;
|
|
235
236
|
const draft = createBlankDraft(options.year ?? legacy.year ?? DEFAULT_HOUSEHOLD_YEAR);
|
|
237
|
+
const childcare = coerceNumber(legacy.childcareExpenses);
|
|
238
|
+
if (childcare !== undefined) draft.childcareExpenses = childcare;
|
|
236
239
|
|
|
237
240
|
// Location.
|
|
238
241
|
if (typeof legacy.state === 'string' && isUSStateCode(legacy.state)) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createBlankDraft } from './draft';
|
|
2
|
+
import { toAmount } from './amount';
|
|
2
3
|
import type { USHouseholdDraft, USPersonDraft } from './types';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -10,6 +11,7 @@ import type { USHouseholdDraft, USPersonDraft } from './types';
|
|
|
10
11
|
* &p=adult:35:e50000,adult:33:e20000,dep:6`
|
|
11
12
|
*
|
|
12
13
|
* Fields are pipe-separated within each person; people are comma-separated.
|
|
14
|
+
* `childcare=3000` carries annual household childcare costs, including 0.
|
|
13
15
|
* Only the keys below are written: other person fields, such as tips,
|
|
14
16
|
* investment income and expenses, are dropped from links for now.
|
|
15
17
|
* Income/flag keys are single letters to keep the URL short:
|
|
@@ -103,6 +105,8 @@ export function serializeDraft(draft: USHouseholdDraft): string {
|
|
|
103
105
|
if (draft.zip) params.set('zip', draft.zip);
|
|
104
106
|
if (draft.maritalStatus) params.set('marital', draft.maritalStatus);
|
|
105
107
|
params.set('year', String(draft.year));
|
|
108
|
+
const childcare = toAmount(draft.childcareExpenses);
|
|
109
|
+
if (childcare !== undefined) params.set('childcare', String(childcare));
|
|
106
110
|
if (draft.people.length > 0) {
|
|
107
111
|
params.set('p', draft.people.map(serializePerson).join(','));
|
|
108
112
|
}
|
|
@@ -112,6 +116,8 @@ export function serializeDraft(draft: USHouseholdDraft): string {
|
|
|
112
116
|
export function deserializeDraft(query: string | URLSearchParams): USHouseholdDraft {
|
|
113
117
|
const params = typeof query === 'string' ? new URLSearchParams(query) : query;
|
|
114
118
|
const draft = createBlankDraft();
|
|
119
|
+
const childcare = toAmount(params.get('childcare'));
|
|
120
|
+
if (childcare !== undefined) draft.childcareExpenses = childcare;
|
|
115
121
|
|
|
116
122
|
const state = params.get('state');
|
|
117
123
|
if (state) draft.state = state;
|
|
@@ -202,6 +202,14 @@ export interface USHouseholdDraft {
|
|
|
202
202
|
* differentiates them. Order is significant for UI labels ("Adult 1", etc.).
|
|
203
203
|
*/
|
|
204
204
|
people: USPersonDraft[];
|
|
205
|
+
/**
|
|
206
|
+
* Annual household childcare costs before childcare subsidies, in dollars.
|
|
207
|
+
* The V1 adapter sends this total once as the SPM-unit input
|
|
208
|
+
* `spm_unit_pre_subsidy_childcare_expenses`; the model allocates costs among
|
|
209
|
+
* children and subtracts subsidies. Do not repeat the total for each child.
|
|
210
|
+
* Leave unset when the app does not ask about childcare costs.
|
|
211
|
+
*/
|
|
212
|
+
childcareExpenses?: number;
|
|
205
213
|
/** Year the household is being modeled for. */
|
|
206
214
|
year: number;
|
|
207
215
|
/** App-controlled household-level fields ignored by the shared adapters. */
|
|
@@ -47,6 +47,21 @@ export function validate(
|
|
|
47
47
|
const { requireCounty = false, requireAges = true } = options;
|
|
48
48
|
const issues: ValidationIssue[] = [];
|
|
49
49
|
|
|
50
|
+
const childcare = toAmount(draft.childcareExpenses);
|
|
51
|
+
if (draft.childcareExpenses != null && childcare === undefined) {
|
|
52
|
+
issues.push({
|
|
53
|
+
code: 'childcareExpenses.invalid',
|
|
54
|
+
path: 'childcareExpenses',
|
|
55
|
+
message: 'Childcare expenses must be a finite amount.',
|
|
56
|
+
});
|
|
57
|
+
} else if (childcare !== undefined && childcare < 0) {
|
|
58
|
+
issues.push({
|
|
59
|
+
code: 'childcareExpenses.negative',
|
|
60
|
+
path: 'childcareExpenses',
|
|
61
|
+
message: 'Childcare expenses cannot be negative.',
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
if (!draft.state) {
|
|
51
66
|
issues.push({
|
|
52
67
|
code: 'state.required',
|