@swan-io/shared-business 2.7.21 → 2.7.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-io/shared-business",
3
- "version": "2.7.21",
3
+ "version": "2.7.23",
4
4
  "engines": {
5
5
  "node": ">=18.0.0",
6
6
  "yarn": "^1.22.0"
@@ -50,13 +50,12 @@ const validateCca3CountryCode = value => {
50
50
  };
51
51
  export const validateUbo = (editorState, accountCountry) => {
52
52
  const isAddressRequired = match(accountCountry)
53
- .with("DEU", "ESP", "NLD", () => true)
53
+ .with("DEU", "ESP", () => true)
54
54
  .otherwise(() => false);
55
55
  const isBirthInfoRequired = match(accountCountry)
56
56
  .with("ESP", "FRA", "NLD", () => true)
57
57
  .otherwise(() => false);
58
- const isTaxIdentificationNumberRequired = (accountCountry === "DEU" && editorState.residencyAddressCountry === "DEU") ||
59
- accountCountry === "NLD";
58
+ const isTaxIdentificationNumberRequired = accountCountry === "DEU" && editorState.residencyAddressCountry === "DEU";
60
59
  const validateTaxNumber = isTaxIdentificationNumberRequired
61
60
  ? combineValidators(validateNullableRequired, validateIndividualTaxNumber(accountCountry))
62
61
  : validateIndividualTaxNumber(accountCountry);
@@ -158,7 +157,7 @@ const requiredStepFields = [
158
157
  export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step, googleMapApiKey, onStepChange, onClose, onSave, onCityLoadError, }, ref) => {
159
158
  const [reference] = useState(() => initialState?.reference ?? uuid());
160
159
  const isAddressRequired = match(accountCountry)
161
- .with("DEU", "ESP", "NLD", () => true)
160
+ .with("DEU", "ESP", () => true)
162
161
  .otherwise(() => false);
163
162
  const isBirthInfoRequired = match(accountCountry)
164
163
  .with("ESP", "FRA", "NLD", () => true)
@@ -246,7 +245,7 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
246
245
  initialValue: initialState?.taxIdentificationNumber,
247
246
  validate: (value, { getFieldState }) => {
248
247
  const uboCountry = getFieldState("country").value;
249
- if ((accountCountry === "DEU" && uboCountry === "DEU") || accountCountry === "NLD") {
248
+ if (accountCountry === "DEU" && uboCountry === "DEU") {
250
249
  return combineValidators(validateNullableRequired, validateIndividualTaxNumber(accountCountry))(value);
251
250
  }
252
251
  return validateIndividualTaxNumber(accountCountry)(value);
@@ -339,10 +338,8 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
339
338
  ? t("beneficiaryForm.beneficiary.fillBirthCountry")
340
339
  : t("beneficiaryForm.beneficiary.birthPostalCodePlaceholder"), id: id, disabled: birthCountryCode.value === undefined, value: value, onChangeText: onChange })) })) })] })) }) }), _jsx(Field, { name: "type", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.type"), type: "radioGroup", render: () => (_jsx(RadioGroup, { direction: "row", value: value, onValueChange: onChange, items: beneficiaryTypes })) })) }), _jsx(FieldsListener, { names: ["type"], children: ({ type }) => type.value === "HasCapital" ? (_jsxs(_Fragment, { children: [_jsx(Field, { name: "totalCapitalPercentage", children: ({ value, onChange, error }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.totalCapitalPercentage"), render: id => (_jsx(LakeTextInput, { error: error, unit: "%", inputMode: "decimal", "aria-valuemin": 0, "aria-valuemax": 100, id: id, value: value, onChangeText: onChange })) })) }), _jsx(Space, { height: 12 }), _jsx(Field, { name: "capitalType", children: ({ value, error, onChange }) => (_jsx(CapitalTypeCheckboxes, { value: value ?? "none", error: error, onChange: onChange })) })] })) : null })] })))
341
340
  .with("address", () => (_jsxs(View, { role: "form", children: [_jsx(Field, { name: "country", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.country"), render: id => (_jsx(CountryPicker, { id: id, value: value, countries: allCountries, onValueChange: onChange })) })) }), _jsx(Space, { height: 12 }), _jsx(FieldsListener, { names: ["country"], children: ({ country }) => (_jsxs(_Fragment, { children: [_jsx(AddressFormPart, { apiKey: googleMapApiKey, initialAddress: initialAddress.current.residencyAddressLine1 ?? "", initialCity: initialAddress.current.residencyAddressCity ?? "", initialPostalCode: initialAddress.current.residencyAddressPostalCode ?? "", country: country?.value ?? accountCountry, label: t("beneficiaryForm.beneficiary.address"), Field: Field, setFieldValue: setFieldValue, listenFields: listenFields, isLarge: large }), ((accountCountry === "DEU" && country?.value === "DEU") ||
342
- accountCountry === "ESP" ||
343
- accountCountry === "NLD") && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 12 }), _jsx(Field, { name: "taxIdentificationNumber", children: ({ value, error, valid, onChange }) => (_jsx(TaxIdentificationNumberInput, { value: value ?? "", error: error, valid: valid, onChange: onChange, accountCountry: accountCountry, isCompany: false,
341
+ accountCountry === "ESP") && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 12 }), _jsx(Field, { name: "taxIdentificationNumber", children: ({ value, error, valid, onChange }) => (_jsx(TaxIdentificationNumberInput, { value: value ?? "", error: error, valid: valid, onChange: onChange, accountCountry: accountCountry, isCompany: false,
344
342
  // is mandatory for German accounts with UBO living in Germany
345
- required: (accountCountry === "DEU" && country?.value === "DEU") ||
346
- accountCountry === "NLD" })) })] }))] })) })] })))
343
+ required: accountCountry === "DEU" && country?.value === "DEU" })) })] }))] })) })] })))
347
344
  .exhaustive(), isAddressRequired && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 12 }), _jsx(StepDots, { currentStep: step, steps: formSteps })] }))] })) }));
348
345
  });
@@ -63,28 +63,6 @@ export const validateIndividualTaxNumber = (accountCountry) => value => {
63
63
  if (!/^[a-zA-Z0-9]{9}$/.test(value)) {
64
64
  return t("common.form.invalidTaxIdentificationNumber");
65
65
  }
66
- })
67
- .with("NLD", () => {
68
- const paddedValue = value.padStart(9, "0");
69
- if (/^[0-9]{9}$/.test(paddedValue)) {
70
- // https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/Netherlands-TIN.pdf
71
- const [n1, n2, n3, n4, n5, n6, n7, n8, n9] = paddedValue.split("").map(x => Number(x));
72
- const remainder = ((n1 ?? 0) * 9 +
73
- (n2 ?? 0) * 8 +
74
- (n3 ?? 0) * 7 +
75
- (n4 ?? 0) * 6 +
76
- (n5 ?? 0) * 5 +
77
- (n6 ?? 0) * 4 +
78
- (n7 ?? 0) * 3 +
79
- (n8 ?? 0) * 2) %
80
- 11;
81
- if ((n9 ?? 0) !== remainder) {
82
- return t("common.form.invalidTaxIdentificationNumber");
83
- }
84
- }
85
- else {
86
- return t("common.form.invalidTaxIdentificationNumber");
87
- }
88
66
  })
89
67
  .otherwise(noop);
90
68
  };
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import { validateIndividualTaxNumber } from "../validation";
3
- test("validateIndividualTaxNumber", () => {
4
- expect(validateIndividualTaxNumber("NLD")("923456788")).toBe(undefined);
5
- expect(validateIndividualTaxNumber("NLD")("999999999")).not.toBe(undefined);
6
- expect(validateIndividualTaxNumber("NLD")("99999999")).not.toBe(undefined);
7
- expect(validateIndividualTaxNumber("NLD")("123456789")).not.toBe(undefined);
8
- });