Skip to content

Commit cdcdfcb

Browse files
authored
fix(TaxForm): add missing fields (#1170)
1 parent 4eb7024 commit cdcdfcb

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

server/lib/pdf-lib-utils.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,17 @@ function fillValueForField<Values>(
216216
const transform = field.transform || (v => v);
217217
const transformedValue = transform(value, allValues);
218218
if (!isNil(transformedValue) && transformedValue !== '') {
219-
const formField = form.getTextField(formPath);
220-
formField.setAlignment(TextAlignment.Left);
221-
const content = transformedValue.toString().trim();
222-
setTextFieldContentWithFont(formField, content, font);
219+
const formField = form.getField(formPath);
220+
if (formField.constructor.name === 'PDFCheckBox') {
221+
if (value) {
222+
form.getCheckBox(formPath).check();
223+
}
224+
} else {
225+
const textField = form.getTextField(formPath);
226+
textField.setAlignment(TextAlignment.Left);
227+
const content = transformedValue.toString().trim();
228+
setTextFieldContentWithFont(textField, content, font);
229+
}
223230
}
224231
}
225232
}

server/lib/tax-forms/w8-ben-e.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { addSignature, fillPDFFormFromValues, PDFFieldDefinition } from '../pdf-
22
import { PDFDocument, PDFFont } from 'pdf-lib';
33
import { getFullName } from './utils.js';
44
import { isNil } from 'lodash-es';
5-
import { W8BenETaxFormValues } from './frontend-types.js';
5+
import { NFFEStatus, W8BenETaxFormValues } from './frontend-types.js';
66
import { getCountryName } from '../i18n.js';
77
import dayjs from '../dayjs.js';
88

@@ -136,6 +136,30 @@ export const W8BenEFieldsDefinition: Partial<Record<keyof W8BenETaxFormValues, P
136136
reference: 'topmostSubform[0].Page2[0].f2_4[0]',
137137
giin: 'topmostSubform[0].Page2[0].Line9a_ReadOrder[0].f2_2[0]',
138138
usOwners: 'topmostSubform[0].Page8[0].Table_Part29[0].BodyRow1[0].f8_3[0]',
139+
certifyStatus: {
140+
type: 'multi',
141+
if: (hasCertified: boolean) => hasCertified,
142+
fields: [
143+
// [A-NFFE] I certify that the entity is a foreign (non-US) entity...
144+
{
145+
formPath: 'topmostSubform[0].Page7[0].c7_5[0]',
146+
if: (v, values: W8BenETaxFormValues) => values.nffeStatus === NFFEStatus.ActiveNFFE,
147+
},
148+
// [P-NFFE] I certify that the entity is a foreign entity...
149+
{
150+
formPath: 'topmostSubform[0].Page7[0].c7_6[0]',
151+
if: (v, values: W8BenETaxFormValues) => values.nffeStatus === NFFEStatus.PassiveNFFE,
152+
},
153+
// I certify that the entity is a nonprofit organization
154+
{
155+
formPath: 'topmostSubform[0].Page7[0].c7_2[0]',
156+
if: (v, values: W8BenETaxFormValues) => values.nffeStatus === NFFEStatus.NonProfitOrganization,
157+
},
158+
],
159+
},
160+
// @ts-expect-error TODO: fix this
161+
entityHasNoUSOwners: 'topmostSubform[0].Page7[0].c7_7[0]',
162+
hasCapacityToSign: 'topmostSubform[0].Page8[0].c8_3[0]',
139163
signer: {
140164
formPath: 'topmostSubform[0].Page8[0].f8_31[0]',
141165
transform: getFullName,

0 commit comments

Comments
 (0)