Files
dinggadingga-backend/src/utils/price.ts
MastersGame db699822f9 feat(sync): add converters from Hiboutik DTOs to Prisma inputs
Includes helpers for Hiboutik dates ("0000-00-00" is ignored) and optional prices ("0.00" means no value).
2026-11-05 23:00:48 +01:00

11 lines
400 B
TypeScript

/**
* Parses an optional Hiboutik price (discount price, size price override).
* Hiboutik sends "0.00" when the value is not set: returns null for empty, zero or invalid values.
*/
export function parseOptionalHiboutikPrice(value: string | null | undefined): string | null {
if (!value) return null;
const price = Number(value);
return Number.isFinite(price) && price > 0 ? value : null;
}