Rename Money/Url to Currency/Link and remove snake_case from composite fields (#2536)

* Rename Money/Url to Currency/Link

* regenerate front types

* renaming money/url field types

* fix double text

* fix tests

* fix server tests

* fix generate-target-column-map

* fix currency convert

* fix: tests

---------

Co-authored-by: Jérémy Magrin <jeremy.magrin@gmail.com>
This commit is contained in:
Weiko
2023-11-17 10:31:17 +01:00
committed by GitHub
parent 31e439681c
commit bc579d64a6
56 changed files with 579 additions and 512 deletions

View File

@ -0,0 +1,30 @@
export const convertCurrencyToCurrencyMicros = (
currencyAmount: number | undefined,
) => {
if (!currencyAmount) {
return undefined;
}
const currencyAmountAsNumber = +currencyAmount;
if (isNaN(currencyAmountAsNumber)) {
throw new Error(`Cannot convert ${currencyAmount} to micros`);
}
const currencyAmountAsMicros = currencyAmountAsNumber * 1000000;
if (currencyAmountAsMicros % 1 !== 0) {
throw new Error(`Cannot convert ${currencyAmount} to micros`);
}
return currencyAmountAsMicros;
};
export const convertCurrencyMicrosToCurrency = (
currencyAmountMicros: number | undefined,
) => {
if (!currencyAmountMicros) {
return undefined;
}
const currencyAmountMicrosAsNumber = +currencyAmountMicros;
if (isNaN(currencyAmountMicrosAsNumber)) {
throw new Error(`Cannot convert ${currencyAmountMicros} to currency`);
}
const currencyAmount = currencyAmountMicrosAsNumber / 1000000;
return currencyAmount;
};