diff --git a/src/definitions/finance.ts b/src/definitions/finance.ts index c82ac6e85ba..8755edccbb8 100644 --- a/src/definitions/finance.ts +++ b/src/definitions/finance.ts @@ -26,4 +26,9 @@ export type FinanceDefinition = LocaleEntry<{ * Types of transactions (e.g. `deposit`). */ transaction_type: string[]; + + /** + * The pattern used to generate transaction descriptions. + */ + transaction_description_pattern: string[]; }>; diff --git a/src/locales/en/finance/index.ts b/src/locales/en/finance/index.ts index 2428aa2873b..04e3fd05280 100644 --- a/src/locales/en/finance/index.ts +++ b/src/locales/en/finance/index.ts @@ -6,12 +6,14 @@ import type { FinanceDefinition } from '../../..'; import account_type from './account_type'; import credit_card from './credit_card'; import currency from './currency'; +import transaction_description_pattern from './transaction_description_pattern'; import transaction_type from './transaction_type'; const finance: FinanceDefinition = { account_type, credit_card, currency, + transaction_description_pattern, transaction_type, }; diff --git a/src/locales/en/finance/transaction_description_pattern.ts b/src/locales/en/finance/transaction_description_pattern.ts new file mode 100644 index 00000000000..b6854b19c46 --- /dev/null +++ b/src/locales/en/finance/transaction_description_pattern.ts @@ -0,0 +1,13 @@ +export default [ + 'A {{finance.transactionType}} for {{finance.currencyCode}} {{finance.amount}} was made at {{company.name}} via card ending ****{{string.numeric(4)}} on account ***{{string.numeric(4)}}.', + 'A {{finance.transactionType}} of {{finance.currencyCode}} {{finance.amount}} occurred at {{company.name}} using a card ending in ****{{string.numeric(4)}} for account ***{{string.numeric(4)}}.', + 'Payment of {{finance.currencyCode}} {{finance.amount}} for {{finance.transactionType}} at {{company.name}}, processed with card ending ****{{string.numeric(4)}} linked to account ***{{string.numeric(4)}}.', + 'Transaction alert: {{finance.transactionType}} at {{company.name}} using card ending ****{{string.numeric(4)}} for an amount of {{finance.currencyCode}} {{finance.amount}} on account ***{{string.numeric(4)}}.', + 'You made a {{finance.transactionType}} of {{finance.currencyCode}} {{finance.amount}} at {{company.name}} using card ending in ****{{string.numeric(4)}} from account ***{{string.numeric(4)}}.', + 'Your {{finance.transactionType}} of {{finance.currencyCode}} {{finance.amount}} at {{company.name}} was successful. Charged via card ****{{string.numeric(4)}} to account ***{{string.numeric(4)}}.', + '{{finance.transactionType}} at {{company.name}} with a card ending in ****{{string.numeric(4)}} for {{finance.currencyCode}} {{finance.amount}} from account ***{{string.numeric(4)}}.', + '{{finance.transactionType}} confirmed at {{company.name}} for {{finance.currencyCode}} {{finance.amount}}, card ending in ****{{string.numeric(4)}} associated with account ***{{string.numeric(4)}}.', + '{{finance.transactionType}} of {{finance.currencyCode}} {{finance.amount}} at {{company.name}} charged to account ending in {{string.numeric(4)}} using card ending in ****{{string.numeric(4)}}.', + '{{finance.transactionType}} processed at {{company.name}} for {{finance.currencyCode}} {{finance.amount}}, using card ending ****{{string.numeric(4)}}. Account: ***{{string.numeric(4)}}.', + '{{finance.transactionType}} transaction at {{company.name}} using card ending with ****{{string.numeric(4)}} for {{finance.currencyCode}} {{finance.amount}} in account ***{{string.numeric(4)}}.', +]; diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts index 656872b784a..cc4068089e1 100644 --- a/src/modules/finance/index.ts +++ b/src/modules/finance/index.ts @@ -969,18 +969,13 @@ export class FinanceModule extends ModuleBase { * * @example * faker.finance.transactionDescription() - * // 'invoice transaction at Kilback - Durgan using card ending with ************4316 for UAH 783.82 in account ***16168663' + * // 'payment transaction at Emard LLC using card ending with ****9187 for HNL 506.57 in account ***2584.' * * @since 5.1.0 */ transactionDescription(): string { - const amount = this.amount(); - const company = this.faker.company.name(); - const transactionType = this.transactionType(); - const account = this.accountNumber(); - const card = this.creditCardNumber().replaceAll(/.(?=.{4})/g, '*'); - const currency = this.currencyCode(); - - return `${transactionType} transaction at ${company} using card ending with ${card} for ${currency} ${amount} in account ***${account}`; + return this.faker.helpers.fake( + this.faker.definitions.finance.transaction_description_pattern + ); } } diff --git a/test/modules/__snapshots__/finance.spec.ts.snap b/test/modules/__snapshots__/finance.spec.ts.snap index 5ac691cf462..7d1a1f4cb2b 100644 --- a/test/modules/__snapshots__/finance.spec.ts.snap +++ b/test/modules/__snapshots__/finance.spec.ts.snap @@ -84,7 +84,7 @@ exports[`finance > 42 > pin > with length option 1`] = `"3975110867"`; exports[`finance > 42 > routingNumber 1`] = `"397511082"`; -exports[`finance > 42 > transactionDescription 1`] = `"deposit transaction at Reynolds, Miller and Crist using card ending with ************4719 for LYD 374.54 in account ***08670982"`; +exports[`finance > 42 > transactionDescription 1`] = `"You made a withdrawal of SAR 598.66 at Crist - Beer using card ending in ****8670 from account ***9821."`; exports[`finance > 42 > transactionType 1`] = `"invoice"`; @@ -172,7 +172,7 @@ exports[`finance > 1211 > pin > with length option 1`] = `"9829667368"`; exports[`finance > 1211 > routingNumber 1`] = `"982966738"`; -exports[`finance > 1211 > transactionDescription 1`] = `"payment transaction at Fahey, Zieme and Osinski using card ending with ***************2758 for HNL 928.52 in account ***73687684"`; +exports[`finance > 1211 > transactionDescription 1`] = `"withdrawal transaction at Zieme - Osinski using card ending with ****6736 for SZL 768.50 in account ***6848."`; exports[`finance > 1211 > transactionType 1`] = `"withdrawal"`; @@ -260,6 +260,6 @@ exports[`finance > 1337 > pin > with length option 1`] = `"2124352971"`; exports[`finance > 1337 > routingNumber 1`] = `"212435298"`; -exports[`finance > 1337 > transactionDescription 1`] = `"invoice transaction at Gottlieb - Koelpin using card ending with *********6413 for JMD 262.02 in account ***52971361"`; +exports[`finance > 1337 > transactionDescription 1`] = `"Payment of CAD 278.12 for invoice at Leannon - Gibson, processed with card ending ****9713 linked to account ***6194."`; exports[`finance > 1337 > transactionType 1`] = `"invoice"`;