add helper functions for tanstack form and cent conversions

This commit is contained in:
Gregor Vostrak
2026-08-31 15:30:39 +02:00
parent c12789376d
commit efc6b55628
2 changed files with 22 additions and 0 deletions

View File

@@ -43,6 +43,13 @@ export function formatCents(
return formatMoney(amount / 100, currency, format, currencySymbol, numberFormat);
}
/*
* Converts a major-unit amount (e.g. 19.99) to integer hundredths (i.e. cents)
*/
export function toCents(value: number | undefined | null): number {
return Math.round((value || 0) * 100);
}
export function getOrganizationCurrencySymbol(currency: string) {
return (0)
.toLocaleString('de-DE', {