@swan-io/shared-business 13.2.2 → 13.2.3

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": "13.2.2",
3
+ "version": "13.2.3",
4
4
  "engines": {
5
5
  "node": "^22.12.0"
6
6
  },
@@ -25,7 +25,7 @@
25
25
  ],
26
26
  "license": "MIT",
27
27
  "peerDependencies": {
28
- "@swan-io/lake": "13.2.2"
28
+ "@swan-io/lake": "13.2.3"
29
29
  },
30
30
  "dependencies": {
31
31
  "@formatjs/intl": "^3.1.6",
@@ -50,6 +50,6 @@
50
50
  "@types/react-dom": "^19.1.7",
51
51
  "@types/react-native": "^0.72.8",
52
52
  "type-fest": "^4.41.0",
53
- "@swan-io/lake": "13.2.2"
53
+ "@swan-io/lake": "13.2.3"
54
54
  }
55
55
  }
@@ -110,7 +110,7 @@ const logoStyle = {
110
110
  export const AccountStatementV1 = ({ partnerLogoUrl, style, accountHolderType, accountHolderName, accountHolderAddress, iban, bic, openingDate, closingDate, openingBalance, transactions, feesDebit, feesCredit, totalsCredit, totalsDebit, closingBalance, }) => {
111
111
  return (_jsxs(Box, { style: [styles.container, style], direction: "column", justifyContent: "spaceBetween", children: [_jsxs(Box, { children: [_jsx(Box, { direction: "row", justifyContent: "spaceBetween", children: _jsxs(Box, { direction: "row", alignItems: "center", children: [isNotNullishOrEmpty(partnerLogoUrl) ? (_jsx("img", { src: partnerLogoUrl, style: logoStyle })) : (_jsx(SwanLogo, { style: styles.defaultLogo })), _jsx(Separator, { horizontal: true, space: 8 }), _jsx(Text, { style: styles.partnershipText, children: t("accountStatement.partnership") }), _jsx(Space, { width: 4 }), _jsx(SwanLogo, { color: colors.gray[900], style: styles.swanLogo })] }) }), _jsx(Space, { height: 24 }), _jsx(Text, { style: styles.pageTitle, children: t("accountStatement.titleDocument") }), _jsx(Space, { height: 8 }), _jsx(Text, { style: styles.text, children: accountHolderType === "Company"
112
112
  ? t("accountStatement.titleDocument.companyDescription")
113
- : t("accountStatement.titleDocument.individualDescription") }), _jsx(Space, { height: 24 }), _jsxs(Box, { direction: "row", justifyContent: "spaceBetween", children: [_jsxs(Box, { direction: "column", children: [_jsx(Text, { style: styles.sectionTitle, children: accountHolderName.toUpperCase() }), _jsx(Text, { style: styles.text, children: accountHolderAddress.street }), _jsx(Text, { style: styles.text, children: accountHolderAddress.city }), isNotNullish(accountHolderAddress.country) && (_jsx(Text, { style: styles.text, children: getCountryName(accountHolderAddress.country) }))] }), _jsxs(Box, { direction: "column", alignItems: "end", children: [_jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.contactSupport") }), _jsx(Text, { style: styles.text, children: "support@swan.io" })] })] }), _jsx(Space, { height: 24 }), _jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.iban") }), _jsx(Text, { style: styles.text, children: iban }), _jsx(Space, { height: 12 }), _jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.bic") }), _jsx(Text, { style: styles.text, children: bic }), _jsx(Space, { height: 48 }), _jsxs(Box, { direction: "row", justifyContent: "spaceBetween", children: [_jsx(Box, { direction: "column", children: _jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.date", { openingDate, closingDate }) }) }), _jsxs(Box, { direction: "column", children: [_jsx(Text, { style: styles.openingBalanceText, children: t("accountStatement.openingBalance") }), _jsx(Text, { style: styles.totalAmount, children: formatCurrencyIso(Number(openingBalance.value), openingBalance.currency) })] })] }), _jsx(Space, { height: 24 }), _jsxs(_Fragment, { children: [_jsxs(Box, { direction: "row", style: { backgroundColor: colors.gray[50] }, children: [_jsx(Text, { style: [styles.titleColumn, { width: "15%" }], children: t("accountStatement.column.date") }), _jsx(Text, { style: [styles.titleColumn, { width: "22%" }], children: t("accountStatement.column.type") }), _jsx(Text, { style: [styles.titleColumn, { width: "33%" }], children: t("accountStatement.column.description") }), _jsx(Text, { style: [styles.titleColumn, { width: "15%", textAlign: "right" }], children: t("accountStatement.column.credit") }), _jsx(Text, { style: [styles.titleColumn, { width: "15%", textAlign: "right" }], children: t("accountStatement.column.debit") })] }), _jsx(Box, { direction: "column", children: transactions.map(transaction => (_jsxs(Box, { direction: "row", children: [_jsx(Text, { style: [styles.textColumn, { width: "15%" }], children: transaction.date }), _jsx(Text, { style: [styles.textColumn, { width: "22%" }], children: translateTransaction(transaction.type) }), _jsx(Text, { style: [styles.textColumn, { width: "33%" }], children: transaction.label }), _jsx(Text, { style: [styles.textColumn, { width: "15%", textAlign: "right" }], children: transaction.credit ? transaction.credit.value : "" }), _jsx(Text, { style: [styles.textColumn, { width: "15%", textAlign: "right" }], children: transaction.debit ? transaction.debit.value : "" })] }, transaction.id))) })] }), _jsxs(Box, { direction: "column", children: [_jsxs(Box, { direction: "row", justifyContent: "end", children: [_jsx(Text, { style: styles.row, children: t("accountStatement.column.fees") }), _jsx(Text, { style: styles.row, children: feesCredit.value }), _jsx(Text, { style: styles.row, children: feesDebit.value })] }), _jsxs(Box, { direction: "row", justifyContent: "end", children: [_jsx(Text, { style: styles.row, children: t("accountStatement.column.totals") }), _jsx(Text, { style: styles.row, children: totalsCredit.value }), _jsx(Text, { style: styles.row, children: totalsDebit.value })] })] }), _jsx(Box, { direction: "row", justifyContent: "end", children: _jsxs(Box, { direction: "row", alignItems: "center", style: styles.closingBalanceRow, justifyContent: "spaceBetween", children: [_jsx(Title, { text: t("accountStatement.closingBalance") }), _jsx(Title, { text: formatCurrencyIso(Number(closingBalance.value), closingBalance.currency), style: styles.totalAmount, align: "right" })] }) })] }), _jsxs(Box, { children: [_jsx(Separator, { space: 24 }), _jsx(Text, { style: styles.footer, children: t("transactionStatement.footer") })] })] }));
113
+ : t("accountStatement.titleDocument.individualDescription") }), _jsx(Space, { height: 24 }), _jsxs(Box, { direction: "row", justifyContent: "spaceBetween", children: [_jsxs(Box, { direction: "column", children: [_jsx(Text, { style: styles.sectionTitle, children: accountHolderName.toUpperCase() }), _jsx(Text, { style: styles.text, children: accountHolderAddress.street }), _jsx(Text, { style: styles.text, children: accountHolderAddress.city }), isNotNullish(accountHolderAddress.country) && (_jsx(Text, { style: styles.text, children: getCountryName(accountHolderAddress.country) }))] }), _jsxs(Box, { direction: "column", alignItems: "end", children: [_jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.contactSupport") }), _jsx(Text, { style: styles.text, children: "support.swan.io" })] })] }), _jsx(Space, { height: 24 }), _jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.iban") }), _jsx(Text, { style: styles.text, children: iban }), _jsx(Space, { height: 12 }), _jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.bic") }), _jsx(Text, { style: styles.text, children: bic }), _jsx(Space, { height: 48 }), _jsxs(Box, { direction: "row", justifyContent: "spaceBetween", children: [_jsx(Box, { direction: "column", children: _jsx(Text, { style: styles.sectionTitle, children: t("accountStatement.date", { openingDate, closingDate }) }) }), _jsxs(Box, { direction: "column", children: [_jsx(Text, { style: styles.openingBalanceText, children: t("accountStatement.openingBalance") }), _jsx(Text, { style: styles.totalAmount, children: formatCurrencyIso(Number(openingBalance.value), openingBalance.currency) })] })] }), _jsx(Space, { height: 24 }), _jsxs(_Fragment, { children: [_jsxs(Box, { direction: "row", style: { backgroundColor: colors.gray[50] }, children: [_jsx(Text, { style: [styles.titleColumn, { width: "15%" }], children: t("accountStatement.column.date") }), _jsx(Text, { style: [styles.titleColumn, { width: "22%" }], children: t("accountStatement.column.type") }), _jsx(Text, { style: [styles.titleColumn, { width: "33%" }], children: t("accountStatement.column.description") }), _jsx(Text, { style: [styles.titleColumn, { width: "15%", textAlign: "right" }], children: t("accountStatement.column.credit") }), _jsx(Text, { style: [styles.titleColumn, { width: "15%", textAlign: "right" }], children: t("accountStatement.column.debit") })] }), _jsx(Box, { direction: "column", children: transactions.map(transaction => (_jsxs(Box, { direction: "row", children: [_jsx(Text, { style: [styles.textColumn, { width: "15%" }], children: transaction.date }), _jsx(Text, { style: [styles.textColumn, { width: "22%" }], children: translateTransaction(transaction.type) }), _jsx(Text, { style: [styles.textColumn, { width: "33%" }], children: transaction.label }), _jsx(Text, { style: [styles.textColumn, { width: "15%", textAlign: "right" }], children: transaction.credit ? transaction.credit.value : "" }), _jsx(Text, { style: [styles.textColumn, { width: "15%", textAlign: "right" }], children: transaction.debit ? transaction.debit.value : "" })] }, transaction.id))) })] }), _jsxs(Box, { direction: "column", children: [_jsxs(Box, { direction: "row", justifyContent: "end", children: [_jsx(Text, { style: styles.row, children: t("accountStatement.column.fees") }), _jsx(Text, { style: styles.row, children: feesCredit.value }), _jsx(Text, { style: styles.row, children: feesDebit.value })] }), _jsxs(Box, { direction: "row", justifyContent: "end", children: [_jsx(Text, { style: styles.row, children: t("accountStatement.column.totals") }), _jsx(Text, { style: styles.row, children: totalsCredit.value }), _jsx(Text, { style: styles.row, children: totalsDebit.value })] })] }), _jsx(Box, { direction: "row", justifyContent: "end", children: _jsxs(Box, { direction: "row", alignItems: "center", style: styles.closingBalanceRow, justifyContent: "spaceBetween", children: [_jsx(Title, { text: t("accountStatement.closingBalance") }), _jsx(Title, { text: formatCurrencyIso(Number(closingBalance.value), closingBalance.currency), style: styles.totalAmount, align: "right" })] }) })] }), _jsxs(Box, { children: [_jsx(Separator, { space: 24 }), _jsx(Text, { style: styles.footer, children: t("transactionStatement.footer") })] })] }));
114
114
  };
115
115
  export const AccountStatement = (props) => match(props)
116
116
  .with({ version: "v1" }, props => _jsx(AccountStatementV1, { ...props }))
@@ -5,7 +5,7 @@ import { LakeTextInput } from "@swan-io/lake/src/components/LakeTextInput";
5
5
  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
- import { getCompanyTaxNumberHelp, getCompanyTaxNumberPlaceholder, getIndividualTaxNumberHelp, getIndividualTaxNumberPlaceholder, getTaxNumberTooltip, } from "../utils/templateTranslations";
8
+ import { getCompanyTaxNumberHelp, getCompanyTaxNumberPlaceholder, getIndividualTaxNumberHelp, getIndividualTaxNumberPlaceholder, getTaxNumberTooltip, } from "../utils/validation";
9
9
  export const TaxIdentificationNumberInput = ({ ref, value, error, valid, disabled, onChange, onBlur, country, isCompany, required, label = t("taxIdentificationNumber.label"), placeholder = isCompany
10
10
  ? getCompanyTaxNumberPlaceholder(country)
11
11
  : getIndividualTaxNumberPlaceholder(country), }) => {
@@ -1506,6 +1506,14 @@ export declare const individualCountries: ("BEL" | "CZE" | "DNK" | "DEU" | "EST"
1506
1506
  export type IndividualCountryCCA3 = (typeof individualCountries)[number];
1507
1507
  export declare const companyCountries: ("BEL" | "CZE" | "DNK" | "DEU" | "EST" | "IRL" | "ESP" | "FRA" | "HRV" | "ISL" | "ITA" | "LVA" | "LIE" | "LTU" | "LUX" | "HUN" | "MLT" | "NLD" | "NOR" | "AUT" | "POL" | "PRT" | "ROU" | "SVN" | "SVK" | "FIN" | "SWE" | "GRC" | "CYP" | "BGR")[];
1508
1508
  export type CompanyCountryCCA3 = (typeof companyCountries)[number];
1509
+ type TaxNumberValidationRule = {
1510
+ pattern: RegExp;
1511
+ message: string;
1512
+ };
1513
+ export type TaxNumberValidation = {
1514
+ individual: Partial<Record<IndividualCountryCCA3, TaxNumberValidationRule>>;
1515
+ company: Partial<Record<CompanyCountryCCA3, TaxNumberValidationRule>>;
1516
+ };
1509
1517
  export declare const countriesWithMultipleCCA3: Partial<Record<CountryCCA3, CountryCCA3[]>>;
1510
1518
  export declare const isCountryCCA3: (value: unknown) => value is CountryCCA3;
1511
1519
  export declare const isCountryCCA2: (value: unknown) => value is CountryCCA2;
@@ -384,7 +384,7 @@
384
384
  "transactionStatement.debtor.bankIdentifier": "Bankleitzahl des Schuldners",
385
385
  "transactionStatement.debtor.bankName": "Name der Bank des Schuldners",
386
386
  "transactionStatement.debtor.name": "Name des Schuldners",
387
- "transactionStatement.footer": "SWAN ist eine vereinfachte Aktiengesellschaft (SAS), eingetragen im Handelsregister von Bobigny unter der Nummer 853 827 103, mit einem Kapital von 16.999,66 Euro, USt-IdNr. FR90853827103 und Firmensitz in 95 Avenue du Président Wilson, 93100 Montreuil, FRANKREICH.\nAls E-Geld-Institut, das Zahlungsdienstleistungen gemäß französischem Recht anbietet und von der ACPR genehmigt wurde, ist SWAN unter der Nummer 17328 bei dieser registriert.",
387
+ "transactionStatement.footer": "SWAN ist eine vereinfachte Aktiengesellschaft (SAS), eingetragen im Handelsregister von Bobigny unter der Nummer 853 827 103, mit einem Kapital von 16.999,66 Euro, USt-IdNr. FR90853827103 und Firmensitz in 91 rue du Faubourg Saint-Honoré, 75008 Paris, FRANKREICH.\nAls E-Geld-Institut, das Zahlungsdienstleistungen gemäß französischem Recht anbietet und von der ACPR genehmigt wurde, ist SWAN unter der Nummer 17328 bei dieser registriert.",
388
388
  "transactionStatement.generationDate": "Generiert am: {date}",
389
389
  "transactionStatement.generationInfos": "Dieses Dokument bestätigt Ihren Transaktionsantrag. Es stellt keinen Nachweis der Transaktionsausführung dar. Ihre Transaktion wird nach Bestehen eines obligatorischen Verifizierungsprozesses ausgeführt.",
390
390
  "transactionStatement.information.amount": "Betrag",
@@ -384,7 +384,7 @@
384
384
  "transactionStatement.debtor.bankIdentifier": "Debtor's bank identifier",
385
385
  "transactionStatement.debtor.bankName": "Debtor’s bank name",
386
386
  "transactionStatement.debtor.name": "Debtor’s name",
387
- "transactionStatement.footer": "SWAN is a simplified joint-stock company (SAS) registered with the Bobigny Trade and Companies Register under number 853 827 103, with a capital of 16,999.66 Euros, VAT number FR90853827103 and whose registered office is located at 95 Avenue du Président Wilson, 93100 Montreuil, FRANCE.\nIn its capacity as an Electronic Money institution offering payment services under French law approved by the ACPR, SWAN is registered with the latter under number 17328.",
387
+ "transactionStatement.footer": "SWAN is a simplified joint-stock company (SAS) registered with the Bobigny Trade and Companies Register under number 853 827 103, with a capital of 16,999.66 Euros, VAT number FR90853827103 and whose registered office is located at 91 rue du Faubourg Saint-Honoré, 75008 Paris, FRANCE.\nIn its capacity as an Electronic Money institution offering payment services under French law approved by the ACPR, SWAN is registered with the latter under number 17328.",
388
388
  "transactionStatement.generationDate": "Generated on: {date}",
389
389
  "transactionStatement.generationInfos": "This document is confirmation of your transaction request. It doesn't constitute proof of transaction execution. Your transaction will be executed after passing a mandatory verification process.",
390
390
  "transactionStatement.information.amount": "Amount",
@@ -384,7 +384,7 @@
384
384
  "transactionStatement.debtor.bankIdentifier": "Identificador bancario del deudor",
385
385
  "transactionStatement.debtor.bankName": "Nombre del banco del deudor",
386
386
  "transactionStatement.debtor.name": "Nombre del deudor",
387
- "transactionStatement.footer": "SWAN es una sociedad anónima simplificada (SAS) registrada en el Registro Mercantil de Bobigny con el número 853 827 103, con un capital de 16.999,66 euros, número de IVA FR90853827103 y con domicilio social en 95 Avenue du Président Wilson, 93100 Montreuil, FRANCIA.\nEn su calidad de institución de dinero electrónico que ofrece servicios de pago conforme a la ley francesa aprobada por la ACPR, SWAN está registrada bajo el número 17328.",
387
+ "transactionStatement.footer": "SWAN es una sociedad anónima simplificada (SAS) registrada en el Registro Mercantil de Bobigny con el número 853 827 103, con un capital de 16.999,66 euros, número de IVA FR90853827103 y con domicilio social en 91 rue du Faubourg Saint-Honoré, 75008 Paris, FRANCIA.\nEn su calidad de institución de dinero electrónico que ofrece servicios de pago conforme a la ley francesa aprobada por la ACPR, SWAN está registrada bajo el número 17328.",
388
388
  "transactionStatement.generationDate": "Generado el: {date}",
389
389
  "transactionStatement.generationInfos": "Este documento es la confirmación de tu solicitud de transacción. No constituye una prueba de la ejecución de la transacción. La transacción se ejecutará tras pasar un proceso de verificación obligatorio.",
390
390
  "transactionStatement.information.amount": "Importe",
@@ -384,7 +384,7 @@
384
384
  "transactionStatement.debtor.bankIdentifier": "Velallisen pankkitunnus",
385
385
  "transactionStatement.debtor.bankName": "Velallisen pankin nimi",
386
386
  "transactionStatement.debtor.name": "Velallisen nimi",
387
- "transactionStatement.footer": "SWAN on ranskalainen osakeyhtiö (SAS), joka on rekisteröity Bobigny:n kaupparekisteriin numerolla 853 827 103, pääomanaan 16 999,66 euroa, ALV-numero FR90853827103 ja kotipaikkanaan 95 Avenue du Président Wilson, 93100 Montreuil, RANSKA.\nSWAN toimii elektronisen rahan liikkeellelaskijana, tarjoten maksupalveluita Ranskan lain mukaisesti, ja on hyväksytty ACPR:n toimesta rekisteröitynä numerolla 17328.",
387
+ "transactionStatement.footer": "SWAN on ranskalainen osakeyhtiö (SAS), joka on rekisteröity Bobigny:n kaupparekisteriin numerolla 853 827 103, pääomanaan 16 999,66 euroa, ALV-numero FR90853827103 ja kotipaikkanaan 91 rue du Faubourg Saint-Honoré, 75008 Paris, RANSKA.\nSWAN toimii elektronisen rahan liikkeellelaskijana, tarjoten maksupalveluita Ranskan lain mukaisesti, ja on hyväksytty ACPR:n toimesta rekisteröitynä numerolla 17328.",
388
388
  "transactionStatement.generationDate": "Luotu: {date}",
389
389
  "transactionStatement.generationInfos": "Tämä asiakirja on vahvistus maksupyynnöstänne. Se ei ole kuitti tehdystä maksusuorituksesta. Maksusuoritus toteutetaan pakollisen vahvistusprosessin jälkeen.",
390
390
  "transactionStatement.information.amount": "Summa",
@@ -384,7 +384,7 @@
384
384
  "transactionStatement.debtor.bankIdentifier": "Identifiant bancaire du débiteur",
385
385
  "transactionStatement.debtor.bankName": "Nom de la banque du débiteur",
386
386
  "transactionStatement.debtor.name": "Nom du débiteur",
387
- "transactionStatement.footer": "SWAN est une société par actions simplifiée (SAS) immatriculée au Registre du Commerce et des Sociétés de Bobigny sous le numéro 853 827 103, avec un capital de 16 999,66 euros, numéro de TVA FR90853827103 et dont le siège social est situé au 95 Avenue du Président Wilson, 93100 Montreuil, FRANCE.\nEn tant qu'établissement de monnaie électronique offrant des services de paiement en vertu du droit français approuvé par l'ACPR, SWAN est inscrite auprès de ce dernier sous le numéro 17328.",
387
+ "transactionStatement.footer": "SWAN est une société par actions simplifiée (SAS) immatriculée au Registre du Commerce et des Sociétés de Bobigny sous le numéro 853 827 103, avec un capital de 16 999,66 euros, numéro de TVA FR90853827103 et dont le siège social est situé au 91 rue du Faubourg Saint-Honoré, 75008 Paris, FRANCE.\nEn tant qu'établissement de monnaie électronique offrant des services de paiement en vertu du droit français approuvé par l'ACPR, SWAN est inscrite auprès de ce dernier sous le numéro 17328.",
388
388
  "transactionStatement.generationDate": "Généré le : {date}",
389
389
  "transactionStatement.generationInfos": "Ce document atteste de votre demande de transaction. En aucun cas il ne constitue une preuve de son exécution. Votre transaction sera exécutée après un processus de vérification obligatoire.",
390
390
  "transactionStatement.information.amount": "Montant",
@@ -384,7 +384,7 @@
384
384
  "transactionStatement.debtor.bankIdentifier": "Identificativo bancario del debitore",
385
385
  "transactionStatement.debtor.bankName": "Nome della banca del debitore",
386
386
  "transactionStatement.debtor.name": "Nome del debitore",
387
- "transactionStatement.footer": "SWAN è una società per azioni semplificata (SAS) registrata presso il Registro delle imprese di Bobigny con il numero 853 827 103, con un capitale di 16.999,66 euro, partita IVA FR90853827103 e sede legale in 95 Avenue du Président Wilson, 93100 Montreuil, FRANCIA.\nIn qualità di istituto di moneta elettronica che offre servizi di pagamento ai sensi della legge francese approvata dall'ACPR, SWAN è registrata presso quest'ultima con il numero 17328.",
387
+ "transactionStatement.footer": "SWAN è una società per azioni semplificata (SAS) registrata presso il Registro delle imprese di Bobigny con il numero 853 827 103, con un capitale di 16.999,66 euro, partita IVA FR90853827103 e sede legale in 91 rue du Faubourg Saint-Honoré, 75008 Paris, FRANCIA.\nIn qualità di istituto di moneta elettronica che offre servizi di pagamento ai sensi della legge francese approvata dall'ACPR, SWAN è registrata presso quest'ultima con il numero 17328.",
388
388
  "transactionStatement.generationDate": "Generato il: {date}",
389
389
  "transactionStatement.generationInfos": "Questo documento è la conferma della tua richiesta di transazione. Non costituisce prova dell'esecuzione della transazione. La tua transazione verrà eseguita dopo aver superato un obbligatorio processo di verifica.",
390
390
  "transactionStatement.information.amount": "Importo",
@@ -384,7 +384,7 @@
384
384
  "transactionStatement.debtor.bankIdentifier": "Bank-ID van de debiteur",
385
385
  "transactionStatement.debtor.bankName": "Banknaam van de debiteur",
386
386
  "transactionStatement.debtor.name": "Naam van de debiteur",
387
- "transactionStatement.footer": "SWAN is een vereenvoudigde naamloze vennootschap (SAS) geregistreerd bij de Kamer van Koophandel van Bobigny onder nummer 853 827 103, met een kapitaal van 16.999,66 euro, btw-nummer FR90853827103 en met maatschappelijke zetel gevestigd aan 95 Avenue du Président Wilson, 93100 Montreuil, FRANKRIJK.\nIn zijn hoedanigheid van een elektronisch geldinstelling die betalingsdiensten aanbiedt onder Frans recht goedgekeurd door de ACPR, is SWAN geregistreerd bij laatstgenoemde onder nummer 17328.",
387
+ "transactionStatement.footer": "SWAN is een vereenvoudigde naamloze vennootschap (SAS) geregistreerd bij de Kamer van Koophandel van Bobigny onder nummer 853 827 103, met een kapitaal van 16.999,66 euro, btw-nummer FR90853827103 en met maatschappelijke zetel gevestigd aan 91 rue du Faubourg Saint-Honoré, 75008 Paris, FRANKRIJK.\nIn zijn hoedanigheid van een elektronisch geldinstelling die betalingsdiensten aanbiedt onder Frans recht goedgekeurd door de ACPR, is SWAN geregistreerd bij laatstgenoemde onder nummer 17328.",
388
388
  "transactionStatement.generationDate": "Gegenereerd op: {date}",
389
389
  "transactionStatement.generationInfos": "Dit document bevestigt je transactieverzoek. Het vormt geen bewijs van transactie-uitvoering. Je transactie zal worden uitgevoerd na het doorlopen van een verplicht verificatieproces.",
390
390
  "transactionStatement.information.amount": "Bedrag",
@@ -384,7 +384,7 @@
384
384
  "transactionStatement.debtor.bankIdentifier": "Identificador bancário do devedor",
385
385
  "transactionStatement.debtor.bankName": "Nome do banco do devedor",
386
386
  "transactionStatement.debtor.name": "Nome do devedor",
387
- "transactionStatement.footer": "A SWAN é uma sociedade anônima simplificada (SAS) registrada no Registro de Comércio e Empresas de Bobigny sob o número 853 827 103, com capital de 16.999,66 euros, número de IVA FR90853827103 e cuja sede está localizada em 95 Avenue du Président Wilson, 93100 Montreuil, FRANÇA.\nNa qualidade de instituição de dinheiro eletrônico que oferece serviços de pagamento ao abrigo da lei francesa aprovada pela ACPR, a SWAN está registrada junto deste sob o número 17328.",
387
+ "transactionStatement.footer": "A SWAN é uma sociedade anônima simplificada (SAS) registrada no Registro de Comércio e Empresas de Bobigny sob o número 853 827 103, com capital de 16.999,66 euros, número de IVA FR90853827103 e cuja sede está localizada em 91 rue du Faubourg Saint-Honoré, 75008 Paris, FRANÇA.\nNa qualidade de instituição de dinheiro eletrônico que oferece serviços de pagamento ao abrigo da lei francesa aprovada pela ACPR, a SWAN está registrada junto deste sob o número 17328.",
388
388
  "transactionStatement.generationDate": "Gerado em:{date}",
389
389
  "transactionStatement.generationInfos": "Este documento é a confirmação do seu pedido de transação. Não constitui prova da execução da transação. A sua transação será executada ao completar o processo de verificação obrigatório.",
390
390
  "transactionStatement.information.amount": "Valor",
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,291 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { getCompanyTaxNumberHelp, getCompanyTaxNumberPlaceholder, getIndividualTaxNumberHelp, getIndividualTaxNumberPlaceholder, getTaxNumberTooltip, isValidEmail, validateBooleanRequired, validateCompanyTaxNumber, validateIndividualTaxNumber, validateNullableRequired, validateRequired, } from "../validation";
3
+ describe("isValidEmail", () => {
4
+ test("validates correct email addresses", () => {
5
+ expect(isValidEmail("test@example.com")).toBe(true);
6
+ expect(isValidEmail("user.name+tag@example.co.uk")).toBe(true);
7
+ expect(isValidEmail("test_email@domain.io")).toBe(true);
8
+ expect(isValidEmail("TEST@EXAMPLE.COM")).toBe(true);
9
+ expect(isValidEmail("test@proton.me")).toBe(true);
10
+ });
11
+ test("rejects invalid email addresses", () => {
12
+ expect(isValidEmail("invalid")).toBe(false);
13
+ expect(isValidEmail("@example.com")).toBe(false);
14
+ expect(isValidEmail("test@")).toBe(false);
15
+ expect(isValidEmail("test@.com")).toBe(false);
16
+ expect(isValidEmail("")).toBe(false);
17
+ });
18
+ });
19
+ describe("validateRequired", () => {
20
+ test("returns error for empty strings", () => {
21
+ expect(validateRequired("")).toBeDefined();
22
+ });
23
+ test("returns undefined for non-empty strings", () => {
24
+ expect(validateRequired("value")).toBeUndefined();
25
+ });
26
+ });
27
+ describe("validateNullableRequired", () => {
28
+ test("returns error for undefined or empty values", () => {
29
+ expect(validateNullableRequired(undefined)).toBeDefined();
30
+ expect(validateNullableRequired("")).toBeDefined();
31
+ });
32
+ test("returns undefined for non-empty strings", () => {
33
+ expect(validateNullableRequired("value")).toBeUndefined();
34
+ });
35
+ });
36
+ describe("validateBooleanRequired", () => {
37
+ test("returns error for undefined or false", () => {
38
+ expect(validateBooleanRequired(undefined)).toBeDefined();
39
+ expect(validateBooleanRequired(false)).toBeDefined();
40
+ });
41
+ test("returns undefined for true", () => {
42
+ expect(validateBooleanRequired(true)).toBeUndefined();
43
+ });
44
+ });
45
+ describe("validateIndividualTaxNumber", () => {
46
+ describe("BEL (Belgium)", () => {
47
+ const validator = validateIndividualTaxNumber("BEL");
48
+ test("accepts valid 10-digit tax numbers", () => {
49
+ expect(validator("1234567890")).toBeUndefined();
50
+ });
51
+ test("rejects invalid formats", () => {
52
+ expect(validator("123456789")).toBeDefined(); // 9 digits
53
+ expect(validator("12345678901")).toBeDefined(); // 11 digits
54
+ expect(validator("123456789A")).toBeDefined(); // contains letter
55
+ });
56
+ test("allows undefined or empty values", () => {
57
+ expect(validator(undefined)).toBeUndefined();
58
+ expect(validator("")).toBeUndefined();
59
+ });
60
+ });
61
+ describe("DEU (Germany)", () => {
62
+ const validator = validateIndividualTaxNumber("DEU");
63
+ test("accepts valid 11-digit tax numbers", () => {
64
+ expect(validator("12345678901")).toBeUndefined();
65
+ });
66
+ test("rejects invalid formats", () => {
67
+ expect(validator("1234567890")).toBeDefined(); // 10 digits
68
+ expect(validator("123456789012")).toBeDefined(); // 12 digits
69
+ });
70
+ });
71
+ describe("ESP (Spain)", () => {
72
+ const validator = validateIndividualTaxNumber("ESP");
73
+ test("accepts valid 9-character tax numbers", () => {
74
+ expect(validator("123456789")).toBeUndefined();
75
+ expect(validator("A1234567B")).toBeUndefined();
76
+ });
77
+ test("rejects invalid formats", () => {
78
+ expect(validator("12345678")).toBeDefined(); // 8 characters
79
+ expect(validator("1234567890")).toBeDefined(); // 10 characters
80
+ });
81
+ });
82
+ describe("FIN (Finland)", () => {
83
+ const validator = validateIndividualTaxNumber("FIN");
84
+ test("accepts valid 11-character tax numbers", () => {
85
+ expect(validator("12345678901")).toBeUndefined();
86
+ expect(validator("A234567890B")).toBeUndefined();
87
+ });
88
+ test("rejects invalid formats", () => {
89
+ expect(validator("1234567890")).toBeDefined(); // 10 characters
90
+ expect(validator("123456789012")).toBeDefined(); // 12 characters
91
+ });
92
+ });
93
+ describe("FRA (France)", () => {
94
+ const validator = validateIndividualTaxNumber("FRA");
95
+ test("accepts valid 13-digit tax numbers", () => {
96
+ expect(validator("1234567890123")).toBeUndefined();
97
+ });
98
+ test("rejects invalid formats", () => {
99
+ expect(validator("123456789012")).toBeDefined(); // 12 digits
100
+ expect(validator("12345678901234")).toBeDefined(); // 14 digits
101
+ expect(validator("123456789012A")).toBeDefined(); // contains letter
102
+ });
103
+ });
104
+ describe("ITA (Italy)", () => {
105
+ const validator = validateIndividualTaxNumber("ITA");
106
+ test("accepts valid 16-character tax numbers", () => {
107
+ expect(validator("1234567890123456")).toBeUndefined();
108
+ expect(validator("ABCDEF12G34H567I")).toBeUndefined();
109
+ });
110
+ test("rejects invalid formats", () => {
111
+ expect(validator("123456789012345")).toBeDefined(); // 15 characters
112
+ expect(validator("12345678901234567")).toBeDefined(); // 17 characters
113
+ });
114
+ });
115
+ describe("NLD (Netherlands)", () => {
116
+ const validator = validateIndividualTaxNumber("NLD");
117
+ test("accepts valid 9-digit tax numbers", () => {
118
+ expect(validator("123456789")).toBeUndefined();
119
+ });
120
+ test("rejects invalid formats", () => {
121
+ expect(validator("12345678")).toBeDefined(); // 8 digits
122
+ expect(validator("1234567890")).toBeDefined(); // 10 digits
123
+ expect(validator("12345678A")).toBeDefined(); // contains letter
124
+ });
125
+ });
126
+ describe("PRT (Portugal)", () => {
127
+ const validator = validateIndividualTaxNumber("PRT");
128
+ test("accepts valid 9-digit tax numbers", () => {
129
+ expect(validator("123456789")).toBeUndefined();
130
+ });
131
+ test("rejects invalid formats", () => {
132
+ expect(validator("12345678")).toBeDefined(); // 8 digits
133
+ expect(validator("1234567890")).toBeDefined(); // 10 digits
134
+ });
135
+ });
136
+ });
137
+ describe("validateCompanyTaxNumber", () => {
138
+ describe("BEL (Belgium)", () => {
139
+ const validator = validateCompanyTaxNumber("BEL");
140
+ test("accepts valid 10-12 digit tax numbers", () => {
141
+ expect(validator("1234567890")).toBeUndefined(); // 10 digits
142
+ expect(validator("12345678901")).toBeUndefined(); // 11 digits
143
+ expect(validator("123456789012")).toBeUndefined(); // 12 digits
144
+ });
145
+ test("rejects invalid formats", () => {
146
+ expect(validator("123456789")).toBeDefined(); // 9 digits
147
+ expect(validator("1234567890123")).toBeDefined(); // 13 digits
148
+ expect(validator("123456789A")).toBeDefined(); // contains letter
149
+ });
150
+ test("allows undefined or empty values", () => {
151
+ expect(validator(undefined)).toBeUndefined();
152
+ expect(validator("")).toBeUndefined();
153
+ });
154
+ });
155
+ describe("DEU (Germany)", () => {
156
+ const validator = validateCompanyTaxNumber("DEU");
157
+ test("accepts valid 10-13 digit tax numbers", () => {
158
+ expect(validator("1234567890")).toBeUndefined(); // 10 digits
159
+ expect(validator("12345678901")).toBeUndefined(); // 11 digits
160
+ expect(validator("123456789012")).toBeUndefined(); // 12 digits
161
+ expect(validator("1234567890123")).toBeUndefined(); // 13 digits
162
+ });
163
+ test("rejects invalid formats", () => {
164
+ expect(validator("123456789")).toBeDefined(); // 9 digits
165
+ expect(validator("12345678901234")).toBeDefined(); // 14 digits
166
+ });
167
+ });
168
+ describe("ESP (Spain)", () => {
169
+ const validator = validateCompanyTaxNumber("ESP");
170
+ test("accepts valid 9-character tax numbers", () => {
171
+ expect(validator("123456789")).toBeUndefined();
172
+ expect(validator("A1234567B")).toBeUndefined();
173
+ });
174
+ test("rejects invalid formats", () => {
175
+ expect(validator("12345678")).toBeDefined(); // 8 characters
176
+ expect(validator("1234567890")).toBeDefined(); // 10 characters
177
+ });
178
+ });
179
+ describe("FIN (Finland)", () => {
180
+ const validator = validateCompanyTaxNumber("FIN");
181
+ test("accepts valid 8-9 character tax numbers", () => {
182
+ expect(validator("12345678")).toBeUndefined(); // 8 characters
183
+ expect(validator("123456789")).toBeUndefined(); // 9 characters
184
+ expect(validator("A2345678")).toBeUndefined();
185
+ });
186
+ test("rejects invalid formats", () => {
187
+ expect(validator("1234567")).toBeDefined(); // 7 characters
188
+ expect(validator("1234567890")).toBeDefined(); // 10 characters
189
+ });
190
+ });
191
+ describe("FRA (France)", () => {
192
+ const validator = validateCompanyTaxNumber("FRA");
193
+ test("accepts valid 9-digit tax numbers", () => {
194
+ expect(validator("123456789")).toBeUndefined();
195
+ });
196
+ test("rejects invalid formats", () => {
197
+ expect(validator("12345678")).toBeDefined(); // 8 digits
198
+ expect(validator("1234567890")).toBeDefined(); // 10 digits
199
+ expect(validator("12345678A")).toBeDefined(); // contains letter
200
+ });
201
+ });
202
+ describe("ITA (Italy)", () => {
203
+ const validator = validateCompanyTaxNumber("ITA");
204
+ test("accepts valid 11-digit tax numbers", () => {
205
+ expect(validator("12345678901")).toBeUndefined();
206
+ });
207
+ test("rejects invalid formats", () => {
208
+ expect(validator("1234567890")).toBeDefined(); // 10 digits
209
+ expect(validator("123456789012")).toBeDefined(); // 12 digits
210
+ expect(validator("1234567890A")).toBeDefined(); // contains letter
211
+ });
212
+ });
213
+ describe("NLD (Netherlands)", () => {
214
+ const validator = validateCompanyTaxNumber("NLD");
215
+ test("accepts valid 9-digit tax numbers", () => {
216
+ expect(validator("123456789")).toBeUndefined();
217
+ });
218
+ test("rejects invalid formats", () => {
219
+ expect(validator("12345678")).toBeDefined(); // 8 digits
220
+ expect(validator("1234567890")).toBeDefined(); // 10 digits
221
+ });
222
+ });
223
+ describe("PRT (Portugal)", () => {
224
+ const validator = validateCompanyTaxNumber("PRT");
225
+ test("accepts valid 9-digit tax numbers", () => {
226
+ expect(validator("123456789")).toBeUndefined();
227
+ });
228
+ test("rejects invalid formats", () => {
229
+ expect(validator("12345678")).toBeDefined(); // 8 digits
230
+ expect(validator("1234567890")).toBeDefined(); // 10 digits
231
+ });
232
+ });
233
+ });
234
+ describe("Tax number helper functions", () => {
235
+ describe("getIndividualTaxNumberPlaceholder", () => {
236
+ test("returns country-specific placeholders", () => {
237
+ expect(getIndividualTaxNumberPlaceholder("DEU")).toContain("Steueridentifikationsnummer");
238
+ expect(getIndividualTaxNumberPlaceholder("ESP")).toContain("Número de Identificación Fiscal");
239
+ expect(getIndividualTaxNumberPlaceholder("ITA")).toContain("Codice fiscale");
240
+ });
241
+ test("returns generic placeholder for other countries", () => {
242
+ const placeholder = getIndividualTaxNumberPlaceholder("FRA");
243
+ expect(placeholder).toBeTypeOf("string");
244
+ });
245
+ });
246
+ describe("getCompanyTaxNumberPlaceholder", () => {
247
+ test("returns country-specific placeholders", () => {
248
+ expect(getCompanyTaxNumberPlaceholder("DEU")).toContain("Steuer-Nummer");
249
+ expect(getCompanyTaxNumberPlaceholder("ESP")).toContain("Número de Identificación Fiscal");
250
+ expect(getCompanyTaxNumberPlaceholder("ITA")).toContain("Codice fiscale");
251
+ });
252
+ test("returns generic placeholder for other countries", () => {
253
+ const placeholder = getCompanyTaxNumberPlaceholder("FRA");
254
+ expect(placeholder).toBeTypeOf("string");
255
+ });
256
+ });
257
+ describe("getTaxNumberTooltip", () => {
258
+ test("returns tooltips for specific countries", () => {
259
+ expect(getTaxNumberTooltip("DEU")).toBeTypeOf("string");
260
+ expect(getTaxNumberTooltip("ESP")).toBe("Número de Identificación Fiscal");
261
+ expect(getTaxNumberTooltip("ITA")).toBeTypeOf("string");
262
+ });
263
+ test("returns undefined for countries without specific tooltips", () => {
264
+ expect(getTaxNumberTooltip("FRA")).toBeUndefined();
265
+ });
266
+ });
267
+ describe("getIndividualTaxNumberHelp", () => {
268
+ test("returns correct help text for all countries", () => {
269
+ expect(getIndividualTaxNumberHelp("BEL")).toBeTypeOf("string");
270
+ expect(getIndividualTaxNumberHelp("DEU")).toBeTypeOf("string");
271
+ expect(getIndividualTaxNumberHelp("ESP")).toBeTypeOf("string");
272
+ expect(getIndividualTaxNumberHelp("FIN")).toBeTypeOf("string");
273
+ expect(getIndividualTaxNumberHelp("FRA")).toBeTypeOf("string");
274
+ expect(getIndividualTaxNumberHelp("ITA")).toBeTypeOf("string");
275
+ expect(getIndividualTaxNumberHelp("NLD")).toBeTypeOf("string");
276
+ expect(getIndividualTaxNumberHelp("PRT")).toBeTypeOf("string");
277
+ });
278
+ });
279
+ describe("getCompanyTaxNumberHelp", () => {
280
+ test("returns correct help text for all countries", () => {
281
+ expect(getCompanyTaxNumberHelp("BEL")).toBeTypeOf("string");
282
+ expect(getCompanyTaxNumberHelp("DEU")).toBeTypeOf("string");
283
+ expect(getCompanyTaxNumberHelp("ESP")).toBeTypeOf("string");
284
+ expect(getCompanyTaxNumberHelp("FIN")).toBeTypeOf("string");
285
+ expect(getCompanyTaxNumberHelp("FRA")).toBeTypeOf("string");
286
+ expect(getCompanyTaxNumberHelp("ITA")).toBeTypeOf("string");
287
+ expect(getCompanyTaxNumberHelp("NLD")).toBeTypeOf("string");
288
+ expect(getCompanyTaxNumberHelp("PRT")).toBeTypeOf("string");
289
+ });
290
+ });
291
+ });
@@ -12,3 +12,8 @@ export { printFormat as printIbanFormat } from "iban";
12
12
  export declare const validateIban: (iban: string) => string | undefined;
13
13
  export declare const validateDate: (value: ExtractedDate | undefined) => string | undefined;
14
14
  export declare const validateBirthdate: (value: ExtractedDate | undefined) => string | undefined;
15
+ export declare const getIndividualTaxNumberPlaceholder: (country: IndividualCountryCCA3 | CompanyCountryCCA3) => string;
16
+ export declare const getCompanyTaxNumberPlaceholder: (country: IndividualCountryCCA3 | CompanyCountryCCA3) => string;
17
+ export declare const getTaxNumberTooltip: (country: IndividualCountryCCA3 | CompanyCountryCCA3) => string | undefined;
18
+ export declare const getCompanyTaxNumberHelp: (country: CompanyCountryCCA3) => string;
19
+ export declare const getIndividualTaxNumberHelp: (country: IndividualCountryCCA3) => string;
@@ -1,4 +1,3 @@
1
- import { noop } from "@swan-io/lake/src/utils/function";
2
1
  import { isNullish } from "@swan-io/lake/src/utils/nullish";
3
2
  import dayjs from "dayjs";
4
3
  import { isValid as isValidIban } from "iban";
@@ -34,6 +33,76 @@ const VAT_NUMBER_REGEX = /^((AT)?U[0-9]{8}|(BE)?0[0-9]{9}|(BG)?[0-9]{9,10}|(CY)?
34
33
  // (SE)?[0-9]{12} | # Sweden
35
34
  // (SI)?[0-9]{8} | # Slovenia
36
35
  // (SK)?[0-9]{10} # Slovakia
36
+ const TAX_NUMBER_REGEX = {
37
+ individual: {
38
+ BEL: {
39
+ pattern: /^\d{10}$/,
40
+ message: t("common.form.help.nbDigits", { nbDigits: "10" }),
41
+ },
42
+ DEU: {
43
+ pattern: /^\d{11}$/,
44
+ message: t("common.form.help.nbDigits", { nbDigits: "11" }),
45
+ },
46
+ ESP: {
47
+ pattern: /^[a-zA-Z0-9]{9}$/,
48
+ message: t("common.form.help.nbCharacters", { nbCharacters: "9" }),
49
+ },
50
+ FIN: {
51
+ pattern: /^[a-zA-Z0-9]{11}$/,
52
+ message: t("common.form.help.nbCharacters", { nbCharacters: "11" }),
53
+ },
54
+ FRA: {
55
+ pattern: /^\d{13}$/,
56
+ message: t("common.form.help.nbDigits", { nbDigits: "13" }),
57
+ },
58
+ ITA: {
59
+ pattern: /^[a-zA-Z0-9]{16}$/,
60
+ message: t("common.form.help.nbCharacters", { nbCharacters: "16" }),
61
+ },
62
+ NLD: {
63
+ pattern: /^\d{9}$/,
64
+ message: t("common.form.help.nbDigits", { nbDigits: "9" }),
65
+ },
66
+ PRT: {
67
+ pattern: /^\d{9}$/,
68
+ message: t("common.form.help.nbDigits", { nbDigits: "9" }),
69
+ },
70
+ },
71
+ company: {
72
+ BEL: {
73
+ pattern: /^\d{10,12}$/,
74
+ message: t("common.form.help.nbDigits", { nbDigits: "10-12" }),
75
+ },
76
+ DEU: {
77
+ pattern: /^\d{10,13}$/,
78
+ message: t("common.form.help.nbDigits", { nbDigits: "10-13" }),
79
+ },
80
+ ESP: {
81
+ pattern: /^[a-zA-Z0-9]{9}$/,
82
+ message: t("common.form.help.nbCharacters", { nbCharacters: "9" }),
83
+ },
84
+ FIN: {
85
+ pattern: /^[a-zA-Z0-9]{8,9}$/,
86
+ message: t("common.form.help.nbCharacters", { nbCharacters: "8-9" }),
87
+ },
88
+ FRA: {
89
+ pattern: /^\d{9}$/,
90
+ message: t("common.form.help.nbDigits", { nbDigits: "9" }),
91
+ },
92
+ ITA: {
93
+ pattern: /^\d{11}$/,
94
+ message: t("common.form.help.nbDigits", { nbDigits: "11" }),
95
+ },
96
+ NLD: {
97
+ pattern: /^\d{9}$/,
98
+ message: t("common.form.help.nbDigits", { nbDigits: "9" }),
99
+ },
100
+ PRT: {
101
+ pattern: /^\d{9}$/,
102
+ message: t("common.form.help.nbDigits", { nbDigits: "9" }),
103
+ },
104
+ },
105
+ };
37
106
  export const isValidVatNumber = (maybeVat) => {
38
107
  return VAT_NUMBER_REGEX.test(maybeVat);
39
108
  };
@@ -59,111 +128,19 @@ export const validateIndividualTaxNumber = (country) => value => {
59
128
  if (value == null || !value) {
60
129
  return;
61
130
  }
62
- return match(country)
63
- .with("BEL", () => {
64
- // accept 10 digits
65
- if (!/^\d{10}$/.test(value)) {
66
- return t("common.form.invalidTaxIdentificationNumber");
67
- }
68
- })
69
- .with("DEU", () => {
70
- // accept 11 digits
71
- if (!/^\d{11}$/.test(value)) {
72
- return t("common.form.invalidTaxIdentificationNumber");
73
- }
74
- })
75
- .with("ESP", () => {
76
- // accept 9 characters
77
- if (!/^[a-zA-Z0-9]{9}$/.test(value)) {
78
- return t("common.form.invalidTaxIdentificationNumber");
79
- }
80
- })
81
- .with("FIN", () => {
82
- // accept 11 characters
83
- if (!/^[a-zA-Z0-9]{11}$/.test(value)) {
84
- return t("common.form.invalidTaxIdentificationNumber");
85
- }
86
- })
87
- .with("FRA", () => {
88
- // accept 13 digits
89
- if (!/^\d{13}$/.test(value)) {
90
- return t("common.form.invalidTaxIdentificationNumber");
91
- }
92
- })
93
- .with("ITA", () => {
94
- // accept 16 characters
95
- if (!/^[a-zA-Z0-9]{16}$/.test(value)) {
96
- return t("common.form.invalidTaxIdentificationNumber");
97
- }
98
- })
99
- .with("NLD", () => {
100
- // accept 9 digits
101
- if (!/^\d{9}$/.test(value)) {
102
- return t("common.form.invalidTaxIdentificationNumber");
103
- }
104
- })
105
- .with("PRT", () => {
106
- // accept 9 digits
107
- if (!/^\d{9}$/.test(value)) {
108
- return t("common.form.invalidTaxIdentificationNumber");
109
- }
110
- })
111
- .otherwise(noop);
131
+ const rule = TAX_NUMBER_REGEX.individual[country];
132
+ if (rule && !rule.pattern.test(value)) {
133
+ return t("common.form.invalidTaxIdentificationNumber");
134
+ }
112
135
  };
113
136
  export const validateCompanyTaxNumber = (country) => value => {
114
137
  if (value == null || !value) {
115
138
  return;
116
139
  }
117
- return match(country)
118
- .with("BEL", () => {
119
- // accept 10 to 12 digits
120
- if (!/^\d{10,12}$/.test(value)) {
121
- return t("common.form.invalidTaxIdentificationNumber");
122
- }
123
- })
124
- .with("DEU", () => {
125
- // accept 10 to 13 digits
126
- if (!/^\d{10,13}$/.test(value)) {
127
- return t("common.form.invalidTaxIdentificationNumber");
128
- }
129
- })
130
- .with("ESP", () => {
131
- // accept 9 characters
132
- if (!/^[a-zA-Z0-9]{9}$/.test(value)) {
133
- return t("common.form.invalidTaxIdentificationNumber");
134
- }
135
- })
136
- .with("FIN", () => {
137
- // accept 8 to 9 characters
138
- if (!/^[a-zA-Z0-9]{8,9}$/.test(value)) {
139
- return t("common.form.invalidTaxIdentificationNumber");
140
- }
141
- })
142
- .with("FRA", () => {
143
- // accept 9 digits
144
- if (!/^\d{9}$/.test(value)) {
145
- return t("common.form.invalidTaxIdentificationNumber");
146
- }
147
- })
148
- .with("ITA", () => {
149
- // accept 11 digits
150
- if (!/^\d{11}$/.test(value)) {
151
- return t("common.form.invalidTaxIdentificationNumber");
152
- }
153
- })
154
- .with("NLD", () => {
155
- // accept 9 digits
156
- if (!/^\d{9}$/.test(value)) {
157
- return t("common.form.invalidTaxIdentificationNumber");
158
- }
159
- })
160
- .with("PRT", () => {
161
- // accept 9 digits
162
- if (!/^\d{9}$/.test(value)) {
163
- return t("common.form.invalidTaxIdentificationNumber");
164
- }
165
- })
166
- .otherwise(noop);
140
+ const rule = TAX_NUMBER_REGEX.company[country];
141
+ if (rule && !rule.pattern.test(value)) {
142
+ return t("common.form.invalidTaxIdentificationNumber");
143
+ }
167
144
  };
168
145
  export { printFormat as printIbanFormat } from "iban";
169
146
  export const validateIban = (iban) => {
@@ -194,3 +171,23 @@ export const validateBirthdate = (value) => {
194
171
  return t("validation.birthdateCannotBeFuture");
195
172
  }
196
173
  };
174
+ /*
175
+ * Translation helpers for tax validation
176
+ */
177
+ export const getIndividualTaxNumberPlaceholder = (country) => match(country)
178
+ .with("DEU", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Steueridentifikationsnummer)`)
179
+ .with("ESP", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Número de Identificación Fiscal)`)
180
+ .with("ITA", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Codice fiscale)`)
181
+ .otherwise(() => t("common.form.taxIdentificationNumber.placeholder"));
182
+ export const getCompanyTaxNumberPlaceholder = (country) => match(country)
183
+ .with("DEU", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Steuer-Nummer)`)
184
+ .with("ESP", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Número de Identificación Fiscal)`)
185
+ .with("ITA", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Codice fiscale)`)
186
+ .otherwise(() => t("common.form.taxIdentificationNumber.placeholder"));
187
+ export const getTaxNumberTooltip = (country) => match(country)
188
+ .with("DEU", () => t("common.form.taxIdentificationNumber.tooltip.deu"))
189
+ .with("ESP", () => "Número de Identificación Fiscal") // no need to translate
190
+ .with("ITA", () => t("common.form.taxIdentificationNumber.tooltip.ita"))
191
+ .otherwise(() => undefined);
192
+ export const getCompanyTaxNumberHelp = (country) => { var _a, _b; return (_b = (_a = TAX_NUMBER_REGEX.company[country]) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : ""; };
193
+ export const getIndividualTaxNumberHelp = (country) => { var _a, _b; return (_b = (_a = TAX_NUMBER_REGEX.individual[country]) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : ""; };
@@ -1,7 +0,0 @@
1
- import { CompanyCountryCCA3, IndividualCountryCCA3 } from "../constants/countries";
2
- export type AccountCountry = "DEU" | "ESP" | "FRA" | "NLD" | "ITA" | "BEL";
3
- export declare const getIndividualTaxNumberPlaceholder: (country: IndividualCountryCCA3 | CompanyCountryCCA3) => string;
4
- export declare const getCompanyTaxNumberPlaceholder: (country: IndividualCountryCCA3 | CompanyCountryCCA3) => string;
5
- export declare const getTaxNumberTooltip: (country: IndividualCountryCCA3 | CompanyCountryCCA3) => string | undefined;
6
- export declare const getCompanyTaxNumberHelp: (country: IndividualCountryCCA3 | CompanyCountryCCA3) => string;
7
- export declare const getIndividualTaxNumberHelp: (country: IndividualCountryCCA3 | CompanyCountryCCA3) => string;
@@ -1,37 +0,0 @@
1
- import { match } from "ts-pattern";
2
- import { t } from "./i18n";
3
- export const getIndividualTaxNumberPlaceholder = (country) => match(country)
4
- .with("DEU", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Steueridentifikationsnummer)`)
5
- .with("ESP", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Número de Identificación Fiscal)`)
6
- .with("ITA", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Codice fiscale)`)
7
- .otherwise(() => t("common.form.taxIdentificationNumber.placeholder"));
8
- export const getCompanyTaxNumberPlaceholder = (country) => match(country)
9
- .with("DEU", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Steuer-Nummer)`)
10
- .with("ESP", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Número de Identificación Fiscal)`)
11
- .with("ITA", () => `${t("common.form.taxIdentificationNumber.placeholder")} (Codice fiscale)`)
12
- .otherwise(() => t("common.form.taxIdentificationNumber.placeholder"));
13
- export const getTaxNumberTooltip = (country) => match(country)
14
- .with("DEU", () => t("common.form.taxIdentificationNumber.tooltip.deu"))
15
- .with("ESP", () => "Número de Identificación Fiscal") // no need to translate
16
- .with("ITA", () => t("common.form.taxIdentificationNumber.tooltip.ita"))
17
- .otherwise(() => undefined);
18
- export const getCompanyTaxNumberHelp = (country) => match(country)
19
- .with("BEL", () => t("common.form.help.nbDigits", { nbDigits: "10-12" }))
20
- .with("DEU", () => t("common.form.help.nbDigits", { nbDigits: "10-13" }))
21
- .with("FIN", () => t("common.form.help.nbCharacters", { nbCharacters: "8-9" }))
22
- .with("FRA", () => t("common.form.help.nbDigits", { nbDigits: "9" }))
23
- .with("ESP", () => t("common.form.help.nbCharacters", { nbCharacters: "9" }))
24
- .with("ITA", () => t("common.form.help.nbDigits", { nbDigits: "11" }))
25
- .with("NLD", () => t("common.form.help.nbDigits", { nbDigits: "9" }))
26
- .with("PRT", () => t("common.form.help.nbDigits", { nbDigits: "9" }))
27
- .otherwise(() => "");
28
- export const getIndividualTaxNumberHelp = (country) => match(country)
29
- .with("BEL", () => t("common.form.help.nbDigits", { nbDigits: "10" }))
30
- .with("DEU", () => t("common.form.help.nbDigits", { nbDigits: "11" }))
31
- .with("ESP", () => t("common.form.help.nbCharacters", { nbCharacters: "9" }))
32
- .with("FIN", () => t("common.form.help.nbCharacters", { nbCharacters: "11" }))
33
- .with("FRA", () => t("common.form.help.nbDigits", { nbDigits: "13" }))
34
- .with("ITA", () => t("common.form.help.nbCharacters", { nbCharacters: "16" }))
35
- .with("NLD", () => t("common.form.help.nbDigits", { nbDigits: "9" }))
36
- .with("PRT", () => t("common.form.help.nbDigits", { nbDigits: "9" }))
37
- .otherwise(() => "");