fix(invoices): localize payment method (wallet/gateway/mixed) to Persian

The payment method was rendered as the raw enum ("wallet") in the PDF and in the
invoice detail/list views. Map it through the existing methodWallet/methodGateway/
methodMixed dictionary keys everywhere.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
keyhan
2026-06-20 00:51:23 +03:30
parent 7438b44120
commit b232129ee2
3 changed files with 17 additions and 4 deletions
+10 -1
View File
@@ -39,6 +39,15 @@ export function buildInvoicePdfData(
const trDesc = (desc?: string) => (isFa ? translateInvoiceDescription(desc) : desc ?? '');
const trReason = (reason?: string) => (isFa ? translateInvoiceReason(reason) : reason ?? '-');
const methodLabel = (m?: string) => {
const map: Record<string, string> = {
wallet: inv.methodWallet,
gateway: inv.methodGateway,
mixed: inv.methodMixed,
};
return m ? map[m] ?? m : '-';
};
const cust = customer ?? invoice.user ?? undefined;
const fullName = [cust?.firstName, cust?.lastName].filter(Boolean).join(' ').trim();
const phone = cust?.phone || undefined;
@@ -50,7 +59,7 @@ export function buildInvoicePdfData(
meta.push(
{ label: pdf.application, value: invoice.application?.name || trReason(invoice.reason) },
{ label: pdf.createdAt, value: formatDate(invoice.createdAt) },
{ label: inv.method, value: invoice.paymentMethod || '-' },
{ label: inv.method, value: methodLabel(invoice.paymentMethod) },
);
if (invoice.paidAt) meta.push({ label: pdf.paidAt, value: formatDate(invoice.paidAt) });
if (invoice.gatewayTrackingCode) meta.push({ label: inv.tracking, value: invoice.gatewayTrackingCode });