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:
Michilis
2026-07-13 03:47:35 +00:00
co-authored by Cursor
parent 75e317d73e
commit 0d47156071
9 changed files with 55 additions and 50 deletions
+12
View File
@@ -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
// ---------------------------------------------------------------------------