tink/ts/helpers/tinkmath.ts

23 lines
452 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 {
2022-10-29 17:15:30 +00:00
value: parseInt(scaledArg.value.unscaledValue) * Math.pow(10, -(parseInt(scaledArg.value.scale))),
2022-10-29 14:18:29 +00:00
currency: 'EUR'
};
};