23 lines
443 B
TypeScript
23 lines
443 B
TypeScript
|
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'
|
||
|
};
|
||
|
};
|