Normalize RUC formatting to base-checkdigit across booking and admin views.
Accept dashed or digits-only RUC input on the backend, store a canonical dashed form, and display it consistently in booking and admin UIs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -166,6 +166,18 @@ export function formatCurrency(amount: number, currency: string = 'PYG'): string
|
||||
return formatPrice(amount, currency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a Paraguayan RUC for display as "base-checkdigit" (e.g. 1234567-9).
|
||||
* Legacy records stored digits only; insert the dash before the check digit.
|
||||
*/
|
||||
export function formatRucDisplay(ruc: string | null | undefined): string {
|
||||
if (!ruc) return '';
|
||||
if (ruc.includes('-')) return ruc;
|
||||
const digits = ruc.replace(/\D/g, '');
|
||||
if (digits.length < 2) return ruc;
|
||||
return `${digits.slice(0, -1)}-${digits.slice(-1)}`;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Payment helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user