@swan-io/shared-business 2.7.17 → 2.7.19

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.17",
3
+ "version": "2.7.19",
4
4
  "engines": {
5
5
  "node": ">=18.0.0",
6
6
  "yarn": "^1.22.0"
@@ -9,6 +9,7 @@ type Props = {
9
9
  accountCountry: AccountCountry;
10
10
  isCompany: boolean;
11
11
  required?: boolean;
12
+ label?: string;
12
13
  };
13
- export declare const TaxIdentificationNumberInput: ({ value, error, valid, disabled, onChange, onBlur, accountCountry, isCompany, required, }: Props) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const TaxIdentificationNumberInput: ({ value, error, valid, disabled, onChange, onBlur, accountCountry, isCompany, required, label, }: Props) => import("react/jsx-runtime").JSX.Element;
14
15
  export {};
@@ -6,8 +6,9 @@ import { LakeTooltip } from "@swan-io/lake/src/components/LakeTooltip";
6
6
  import { colors } from "@swan-io/lake/src/constants/design";
7
7
  import { t } from "../utils/i18n";
8
8
  import { getCompanyTaxNumberHelp, getCompanyTaxNumberPlaceholder, getIndividualTaxNumberHelp, getIndividualTaxNumberPlaceholder, getTaxNumberTooltip, } from "../utils/templateTranslations";
9
- export const TaxIdentificationNumberInput = ({ value, error, valid, disabled, onChange, onBlur, accountCountry, isCompany, required, }) => {
10
- return (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.taxIdentificationNumber"), optionalLabel: required === true ? undefined : t("common.optional"), help: _jsx(LakeTooltip, { content: getTaxNumberTooltip(accountCountry), placement: "top", width: accountCountry === "DEU" ? 800 : undefined, children: _jsx(Icon, { name: "question-circle-regular", size: 16, color: colors.gray[600] }) }), render: id => (_jsx(LakeTextInput, { id: id, placeholder: isCompany
9
+ export const TaxIdentificationNumberInput = ({ value, error, valid, disabled, onChange, onBlur, accountCountry, isCompany, required, label = t("beneficiaryForm.beneficiary.taxIdentificationNumber"), }) => {
10
+ const tooltipContents = getTaxNumberTooltip(accountCountry);
11
+ return (_jsx(LakeLabel, { label: label, optionalLabel: required === true ? undefined : t("common.optional"), help: tooltipContents != null ? (_jsx(LakeTooltip, { content: tooltipContents, placement: "top", width: accountCountry === "DEU" ? 800 : undefined, children: _jsx(Icon, { name: "question-circle-regular", size: 16, color: colors.gray[600] }) })) : null, render: id => (_jsx(LakeTextInput, { id: id, placeholder: isCompany
11
12
  ? getCompanyTaxNumberPlaceholder(accountCountry)
12
13
  : getIndividualTaxNumberPlaceholder(accountCountry), help: isCompany
13
14
  ? getCompanyTaxNumberHelp(accountCountry)
@@ -3,5 +3,6 @@ import { validateIndividualTaxNumber } from "../validation";
3
3
  test("validateIndividualTaxNumber", () => {
4
4
  expect(validateIndividualTaxNumber("NLD")("923456788")).toBe(undefined);
5
5
  expect(validateIndividualTaxNumber("NLD")("999999999")).not.toBe(undefined);
6
+ expect(validateIndividualTaxNumber("NLD")("99999999")).not.toBe(undefined);
6
7
  expect(validateIndividualTaxNumber("NLD")("123456789")).not.toBe(undefined);
7
8
  });
@@ -1,6 +1,6 @@
1
1
  export type AccountCountry = "DEU" | "ESP" | "FRA" | "NLD";
2
2
  export declare const getIndividualTaxNumberPlaceholder: (accountCountry: AccountCountry) => string;
3
3
  export declare const getCompanyTaxNumberPlaceholder: (accountCountry: AccountCountry) => string;
4
- export declare const getTaxNumberTooltip: (accountCountry: AccountCountry) => string;
4
+ export declare const getTaxNumberTooltip: (accountCountry: AccountCountry) => string | undefined;
5
5
  export declare const getCompanyTaxNumberHelp: (accountCountry: AccountCountry) => string;
6
6
  export declare const getIndividualTaxNumberHelp: (accountCountry: AccountCountry) => string;
@@ -11,7 +11,7 @@ export const getCompanyTaxNumberPlaceholder = (accountCountry) => match(accountC
11
11
  export const getTaxNumberTooltip = (accountCountry) => match(accountCountry)
12
12
  .with("DEU", () => t("common.form.taxIdentificationNumber.tooltip.deu"))
13
13
  .with("ESP", () => "Número de Identificación Fiscal") // no need to translate
14
- .otherwise(() => "");
14
+ .otherwise(() => undefined);
15
15
  export const getCompanyTaxNumberHelp = (accountCountry) => match(accountCountry)
16
16
  .with("DEU", () => t("common.form.help.nbDigits", { nbDigits: "10-11" }))
17
17
  .with("ESP", () => t("common.form.help.nbCharacters", { nbCharacters: "9" }))
@@ -65,9 +65,10 @@ export const validateIndividualTaxNumber = (accountCountry) => value => {
65
65
  }
66
66
  })
67
67
  .with("NLD", () => {
68
- if (/^[0-9]{9}$/.test(value.padStart(9, "0"))) {
68
+ const paddedValue = value.padStart(9, "0");
69
+ if (/^[0-9]{9}$/.test(paddedValue)) {
69
70
  // https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/Netherlands-TIN.pdf
70
- const [n1, n2, n3, n4, n5, n6, n7, n8, n9] = value.split("").map(x => Number(x));
71
+ const [n1, n2, n3, n4, n5, n6, n7, n8, n9] = paddedValue.split("").map(x => Number(x));
71
72
  const remainder = ((n1 ?? 0) * 9 +
72
73
  (n2 ?? 0) * 8 +
73
74
  (n3 ?? 0) * 7 +