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:
@@ -65,6 +65,8 @@ export default function AdminInvoicesPage() {
|
|||||||
const lineLabel = (label?: string) => (isFa ? translateInvoiceLabel(label) : (label ?? '-'));
|
const lineLabel = (label?: string) => (isFa ? translateInvoiceLabel(label) : (label ?? '-'));
|
||||||
const lineDesc = (desc?: string) => (isFa ? translateInvoiceDescription(desc) : (desc ?? ''));
|
const lineDesc = (desc?: string) => (isFa ? translateInvoiceDescription(desc) : (desc ?? ''));
|
||||||
const reasonLabel = (reason?: string) => (isFa ? translateInvoiceReason(reason) : (reason ?? '-'));
|
const reasonLabel = (reason?: string) => (isFa ? translateInvoiceReason(reason) : (reason ?? '-'));
|
||||||
|
const methodLabel = (m?: string) =>
|
||||||
|
m ? ({ wallet: inv.methodWallet, gateway: inv.methodGateway, mixed: inv.methodMixed } as Record<string, string>)[m] ?? m : '-';
|
||||||
|
|
||||||
const downloadPdfMutation = useMutation({
|
const downloadPdfMutation = useMutation({
|
||||||
mutationFn: (invoice: Invoice) =>
|
mutationFn: (invoice: Invoice) =>
|
||||||
@@ -168,7 +170,7 @@ export default function AdminInvoicesPage() {
|
|||||||
<td className="px-4 py-3">
|
<td className="px-4 py-3">
|
||||||
<span className={statusClasses[invoice.status]}>{statusLabel(invoice.status)}</span>
|
<span className={statusClasses[invoice.status]}>{statusLabel(invoice.status)}</span>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-4 py-3 text-sm text-gray-600">{invoice.paymentMethod || '-'}</td>
|
<td className="px-4 py-3 text-sm text-gray-600">{methodLabel(invoice.paymentMethod)}</td>
|
||||||
<td className="px-4 py-3 text-right rtl:text-left">
|
<td className="px-4 py-3 text-right rtl:text-left">
|
||||||
<p className="text-sm font-bold text-gray-900">{formatPrice(invoice.dueAmount)} {t.common.currencyShort}</p>
|
<p className="text-sm font-bold text-gray-900">{formatPrice(invoice.dueAmount)} {t.common.currencyShort}</p>
|
||||||
<p className="text-xs text-gray-400">{inv.total} {formatPrice(invoice.total)} {t.common.currencyShort}</p>
|
<p className="text-xs text-gray-400">{inv.total} {formatPrice(invoice.total)} {t.common.currencyShort}</p>
|
||||||
@@ -229,7 +231,7 @@ export default function AdminInvoicesPage() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2 text-gray-700">
|
<div className="flex items-center gap-2 text-gray-700">
|
||||||
<Wallet className="w-4 h-4 text-gray-400" />
|
<Wallet className="w-4 h-4 text-gray-400" />
|
||||||
{inv.method}: {selectedInvoice.paymentMethod || '-'}
|
{inv.method}: {methodLabel(selectedInvoice.paymentMethod)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ export default function InvoicesPage() {
|
|||||||
const lineLabel = (label?: string) => (isFa ? translateInvoiceLabel(label) : (label ?? '-'));
|
const lineLabel = (label?: string) => (isFa ? translateInvoiceLabel(label) : (label ?? '-'));
|
||||||
const lineDesc = (desc?: string) => (isFa ? translateInvoiceDescription(desc) : (desc ?? ''));
|
const lineDesc = (desc?: string) => (isFa ? translateInvoiceDescription(desc) : (desc ?? ''));
|
||||||
const reasonLabel = (reason?: string) => (isFa ? translateInvoiceReason(reason) : (reason ?? '-'));
|
const reasonLabel = (reason?: string) => (isFa ? translateInvoiceReason(reason) : (reason ?? '-'));
|
||||||
|
const methodLabel = (m?: string) =>
|
||||||
|
m ? ({ wallet: inv.methodWallet, gateway: inv.methodGateway, mixed: inv.methodMixed } as Record<string, string>)[m] ?? m : '-';
|
||||||
const authUser = useAuthStore((s) => s.user);
|
const authUser = useAuthStore((s) => s.user);
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
@@ -234,7 +236,7 @@ export default function InvoicesPage() {
|
|||||||
<div className="flex justify-between"><span className="text-gray-500">{inv.total}</span><span className="font-semibold">{formatPrice(selectedInvoice.total)} {inv.toman}</span></div>
|
<div className="flex justify-between"><span className="text-gray-500">{inv.total}</span><span className="font-semibold">{formatPrice(selectedInvoice.total)} {inv.toman}</span></div>
|
||||||
<div className="flex justify-between"><span className="text-gray-500">{inv.paidLabel}</span><span className="font-semibold text-green-600">{formatPrice(selectedInvoice.paidAmount)} {inv.toman}</span></div>
|
<div className="flex justify-between"><span className="text-gray-500">{inv.paidLabel}</span><span className="font-semibold text-green-600">{formatPrice(selectedInvoice.paidAmount)} {inv.toman}</span></div>
|
||||||
<div className="flex justify-between"><span className="text-gray-500">{inv.due}</span><span className="font-semibold text-primary-700">{formatPrice(selectedInvoice.dueAmount)} {inv.toman}</span></div>
|
<div className="flex justify-between"><span className="text-gray-500">{inv.due}</span><span className="font-semibold text-primary-700">{formatPrice(selectedInvoice.dueAmount)} {inv.toman}</span></div>
|
||||||
<div className="flex justify-between"><span className="text-gray-500">{inv.method}</span><span>{selectedInvoice.paymentMethod || '-'}</span></div>
|
<div className="flex justify-between"><span className="text-gray-500">{inv.method}</span><span>{methodLabel(selectedInvoice.paymentMethod)}</span></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -39,6 +39,15 @@ export function buildInvoicePdfData(
|
|||||||
const trDesc = (desc?: string) => (isFa ? translateInvoiceDescription(desc) : desc ?? '');
|
const trDesc = (desc?: string) => (isFa ? translateInvoiceDescription(desc) : desc ?? '');
|
||||||
const trReason = (reason?: string) => (isFa ? translateInvoiceReason(reason) : reason ?? '-');
|
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 cust = customer ?? invoice.user ?? undefined;
|
||||||
const fullName = [cust?.firstName, cust?.lastName].filter(Boolean).join(' ').trim();
|
const fullName = [cust?.firstName, cust?.lastName].filter(Boolean).join(' ').trim();
|
||||||
const phone = cust?.phone || undefined;
|
const phone = cust?.phone || undefined;
|
||||||
@@ -50,7 +59,7 @@ export function buildInvoicePdfData(
|
|||||||
meta.push(
|
meta.push(
|
||||||
{ label: pdf.application, value: invoice.application?.name || trReason(invoice.reason) },
|
{ label: pdf.application, value: invoice.application?.name || trReason(invoice.reason) },
|
||||||
{ label: pdf.createdAt, value: formatDate(invoice.createdAt) },
|
{ 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.paidAt) meta.push({ label: pdf.paidAt, value: formatDate(invoice.paidAt) });
|
||||||
if (invoice.gatewayTrackingCode) meta.push({ label: inv.tracking, value: invoice.gatewayTrackingCode });
|
if (invoice.gatewayTrackingCode) meta.push({ label: inv.tracking, value: invoice.gatewayTrackingCode });
|
||||||
|
|||||||
Reference in New Issue
Block a user