tink/ts/helpers/tinkmath.ts

23 lines
443 B
TypeScript
Raw Normal View History

2022-10-29 14:18:29 +00:00
export interface ITinkScaledAmount {
value: {
unscaledValue: string;
scale: string;
};
currencyCode: string;
}
/**
* returns a normalized amount
* @param scaledArg
* @returns
*/
export const getNormalizedAmount = (scaledArg?: ITinkScaledAmount) => {
if (!scaledArg) {
return null;
}
return {
amount: parseInt(scaledArg.value.unscaledValue) / (10 ^ parseInt(scaledArg.value.scale)),
currency: 'EUR'
};
};