feat: sale invoice model tax attributes

This commit is contained in:
Ahmed Bouhuolia
2023-09-06 14:01:40 +02:00
parent ac072d29fc
commit 983ceb5cc6
14 changed files with 346 additions and 161 deletions

View File

@@ -471,6 +471,15 @@ const castCommaListEnvVarToArray = (envVar: string): Array<string> => {
return envVar ? envVar?.split(',')?.map(_.trim) : [];
};
export const sortObjectKeysAlphabetically = (object) => {
return Object.keys(object)
.sort()
.reduce((objEntries, key) => {
objEntries[key] = object[key];
return objEntries;
}, {});
};
export {
templateRender,
accumSum,
@@ -503,5 +512,5 @@ export {
mergeObjectsBykey,
nestedArrayToFlatten,
assocDepthLevelToObjectTree,
castCommaListEnvVarToArray
castCommaListEnvVarToArray,
};

View File

@@ -0,0 +1,19 @@
/**
* Get inclusive tax amount.
* @param {number} amount
* @param {number} taxRate
* @returns {number}
*/
export const getInclusiveTaxAmount = (amount: number, taxRate: number) => {
return (amount * taxRate) / (100 + taxRate);
};
/**
* Get exclusive tax amount.
* @param {number} amount
* @param {number} taxRate
* @returns {number}
*/
export const getExlusiveTaxAmount = (amount: number, taxRate: number) => {
return (amount * taxRate) / 100;
};