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).
This commit is contained in:
10
src/utils/price.ts
Normal file
10
src/utils/price.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
Reference in New Issue
Block a user