asv-hlps 1.4.61 → 1.4.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/products/product.js +1 -1
- package/lib/cjs/sales/sale.js +21 -0
- package/lib/cjs/utils.d.ts +1 -0
- package/lib/cjs/utils.js +7 -1
- package/lib/esm/products/product.js +1 -1
- package/lib/esm/sales/sale.js +21 -0
- package/lib/esm/utils.d.ts +1 -0
- package/lib/esm/utils.js +5 -0
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ const unitPriceByClientCat = (product, client, speUnitPrice = 0, addDiscount = f
|
|
|
8
8
|
return speUnitPrice;
|
|
9
9
|
}
|
|
10
10
|
// const store = await getCustomRepository(ProductStoreRepository).getOneStoreByParams({storeName: 'cpa', productId: product.id})
|
|
11
|
-
if (product.stores[0].discountRate && addDiscount) {
|
|
11
|
+
if ((product === null || product === void 0 ? void 0 : product.stores[0].discountRate) && addDiscount) {
|
|
12
12
|
return Math.ceil(product.stores[0].salePrice) - Math.ceil((0, utils_1.calculPercent)(product.stores[0].salePrice, product.stores[0].discountRate));
|
|
13
13
|
}
|
|
14
14
|
const clientCoef = !client ? 1 : (0, user_1.userCoef)(client);
|
package/lib/cjs/sales/sale.js
CHANGED
|
@@ -10,6 +10,9 @@ const getNbProductsOnSale = (sale) => {
|
|
|
10
10
|
exports.getNbProductsOnSale = getNbProductsOnSale;
|
|
11
11
|
const getTotalTvaOnSale = (sale, dlvr = false) => {
|
|
12
12
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
13
|
+
if (curr.unitPrice === 0) {
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
13
16
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
|
|
14
17
|
return !dlvr
|
|
15
18
|
? Math.ceil(prev + unitPrice * (+curr.tva / 100) * +curr.qtityOdr)
|
|
@@ -21,6 +24,9 @@ const getTotalTvaOnSale = (sale, dlvr = false) => {
|
|
|
21
24
|
exports.getTotalTvaOnSale = getTotalTvaOnSale;
|
|
22
25
|
const getSubTotalAmountOnSale = (sale, dlvr = false) => {
|
|
23
26
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
27
|
+
if (curr.unitPrice === 0) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
24
30
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
|
|
25
31
|
return !dlvr ? Math.ceil(prev + unitPrice * +curr.qtityOdr) : Math.ceil(prev + unitPrice * +curr.qtityDlvr);
|
|
26
32
|
}, 0);
|
|
@@ -28,6 +34,9 @@ const getSubTotalAmountOnSale = (sale, dlvr = false) => {
|
|
|
28
34
|
exports.getSubTotalAmountOnSale = getSubTotalAmountOnSale;
|
|
29
35
|
const getSubTotalAmountBackOnSale = (sale) => {
|
|
30
36
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
37
|
+
if (curr.unitPrice === 0) {
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
31
40
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
|
|
32
41
|
return Math.ceil(prev + unitPrice * +curr.qtityBack);
|
|
33
42
|
}, 0);
|
|
@@ -35,6 +44,9 @@ const getSubTotalAmountBackOnSale = (sale) => {
|
|
|
35
44
|
exports.getSubTotalAmountBackOnSale = getSubTotalAmountBackOnSale;
|
|
36
45
|
const getTotalAmountWithoutTvaOnSale = (sale, dlvr = false) => {
|
|
37
46
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
47
|
+
if (curr.unitPrice === 0) {
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
38
50
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
|
|
39
51
|
return !dlvr ? Math.ceil(prev + unitPrice * +curr.qtityOdr) : Math.ceil(prev + unitPrice * +curr.qtityDlvr);
|
|
40
52
|
}, 0);
|
|
@@ -42,6 +54,9 @@ const getTotalAmountWithoutTvaOnSale = (sale, dlvr = false) => {
|
|
|
42
54
|
exports.getTotalAmountWithoutTvaOnSale = getTotalAmountWithoutTvaOnSale;
|
|
43
55
|
const getTotalAmountWithoutTvaBackOnSale = (sale) => {
|
|
44
56
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
57
|
+
if (curr.unitPrice === 0) {
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
45
60
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
|
|
46
61
|
return Math.ceil(prev + unitPrice * +curr.qtityBack);
|
|
47
62
|
}, 0);
|
|
@@ -49,6 +64,9 @@ const getTotalAmountWithoutTvaBackOnSale = (sale) => {
|
|
|
49
64
|
exports.getTotalAmountWithoutTvaBackOnSale = getTotalAmountWithoutTvaBackOnSale;
|
|
50
65
|
const getTotalTvaOnSaleOnSale = (sale, dlvr = false) => {
|
|
51
66
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
67
|
+
if (curr.unitPrice === 0) {
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
52
70
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
|
|
53
71
|
return !dlvr
|
|
54
72
|
? Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityOdr)
|
|
@@ -58,6 +76,9 @@ const getTotalTvaOnSaleOnSale = (sale, dlvr = false) => {
|
|
|
58
76
|
exports.getTotalTvaOnSaleOnSale = getTotalTvaOnSaleOnSale;
|
|
59
77
|
const getTotalTvaBackOnSale = (sale) => {
|
|
60
78
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
79
|
+
if (curr.unitPrice === 0) {
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
61
82
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
|
|
62
83
|
return Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityBack);
|
|
63
84
|
}, 0);
|
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -122,3 +122,4 @@ export declare const arraySome: (arr1: any[], arr2: any[]) => boolean;
|
|
|
122
122
|
export declare const checkObjInArray: (objs: any[], checkProp: string | number, prop?: string) => boolean;
|
|
123
123
|
export declare const pathName: (location: any) => any;
|
|
124
124
|
export declare const nthIndexOf: (str: string, charToFind: string, nthPosition?: number) => number;
|
|
125
|
+
export declare const partOfStringBetweenTwoSpeChar: (str: string, position1: number, position2: number, char?: string) => string;
|
package/lib/cjs/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.dateNth = exports.dateNthMonth = exports.dateNthDay = exports.dateNthWeek = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.reformatDates = exports.firstDayOfDate = exports.dateToString = exports.dateDiff = exports.dateFormatter = exports.replaceSpacesWith = exports.replaceAllIn = exports.toPlural = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.removeSpecialCharsAndSpaces = exports.refGenerator = exports.removeAMPM = exports.removeBackSlashOccurences = exports.stringifyFormatter = exports.removeString = exports.diffArraysByProp = exports.diffArraysByFunc = exports.deepClone = exports.findFirstSequenceMissing = exports.fillNumWithZero = exports.findSequencesMissing = exports.removeAccent = exports.sequencesToNumbers = exports.notInSequence = exports.currencyFormatterCfa = exports.currencyFormatter = exports.checkAuth = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.duplicateObjectsGrouped = exports.duplicateObjects = exports.removeDuplicateValues = exports.removeDuplicateObjects = exports.getRandomColor = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.formatDateFirstDayFr = exports.isEmpty = void 0;
|
|
7
|
-
exports.nthIndexOf = exports.pathName = exports.checkObjInArray = exports.arraySome = exports.winMaxHeight = exports.toggleProp = exports.roundLastNDigits = exports.removeParamKeyName = exports.countryIsoToFlag = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceTimes = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.genRandomNumberArray = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = exports.getPeriodDateColor = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = void 0;
|
|
7
|
+
exports.partOfStringBetweenTwoSpeChar = exports.nthIndexOf = exports.pathName = exports.checkObjInArray = exports.arraySome = exports.winMaxHeight = exports.toggleProp = exports.roundLastNDigits = exports.removeParamKeyName = exports.countryIsoToFlag = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceTimes = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.genRandomNumberArray = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = exports.getPeriodDateColor = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = void 0;
|
|
8
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
9
|
const dayOfYear_1 = __importDefault(require("dayjs/plugin/dayOfYear"));
|
|
10
10
|
const isSameOrBefore_1 = __importDefault(require("dayjs/plugin/isSameOrBefore"));
|
|
@@ -864,3 +864,9 @@ const nthIndexOf = (str, charToFind, nthPosition = 1) => {
|
|
|
864
864
|
return str.split(charToFind, nthPosition).join(charToFind).length;
|
|
865
865
|
};
|
|
866
866
|
exports.nthIndexOf = nthIndexOf;
|
|
867
|
+
const partOfStringBetweenTwoSpeChar = (str, position1, position2, char = "/") => {
|
|
868
|
+
const firstSlashPosition = (0, exports.nthIndexOf)(str, char, position1);
|
|
869
|
+
const secondSlashPosition = (0, exports.nthIndexOf)(str, char, position2);
|
|
870
|
+
return str.substring(firstSlashPosition + 1, secondSlashPosition);
|
|
871
|
+
};
|
|
872
|
+
exports.partOfStringBetweenTwoSpeChar = partOfStringBetweenTwoSpeChar;
|
|
@@ -5,7 +5,7 @@ export const unitPriceByClientCat = (product, client, speUnitPrice = 0, addDisco
|
|
|
5
5
|
return speUnitPrice;
|
|
6
6
|
}
|
|
7
7
|
// const store = await getCustomRepository(ProductStoreRepository).getOneStoreByParams({storeName: 'cpa', productId: product.id})
|
|
8
|
-
if (product.stores[0].discountRate && addDiscount) {
|
|
8
|
+
if ((product === null || product === void 0 ? void 0 : product.stores[0].discountRate) && addDiscount) {
|
|
9
9
|
return Math.ceil(product.stores[0].salePrice) - Math.ceil(calculPercent(product.stores[0].salePrice, product.stores[0].discountRate));
|
|
10
10
|
}
|
|
11
11
|
const clientCoef = !client ? 1 : userCoef(client);
|
package/lib/esm/sales/sale.js
CHANGED
|
@@ -6,6 +6,9 @@ export const getNbProductsOnSale = (sale) => {
|
|
|
6
6
|
};
|
|
7
7
|
export const getTotalTvaOnSale = (sale, dlvr = false) => {
|
|
8
8
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
9
|
+
if (curr.unitPrice === 0) {
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
9
12
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
|
10
13
|
return !dlvr
|
|
11
14
|
? Math.ceil(prev + unitPrice * (+curr.tva / 100) * +curr.qtityOdr)
|
|
@@ -16,30 +19,45 @@ export const getTotalTvaOnSale = (sale, dlvr = false) => {
|
|
|
16
19
|
};
|
|
17
20
|
export const getSubTotalAmountOnSale = (sale, dlvr = false) => {
|
|
18
21
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
22
|
+
if (curr.unitPrice === 0) {
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
19
25
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
|
20
26
|
return !dlvr ? Math.ceil(prev + unitPrice * +curr.qtityOdr) : Math.ceil(prev + unitPrice * +curr.qtityDlvr);
|
|
21
27
|
}, 0);
|
|
22
28
|
};
|
|
23
29
|
export const getSubTotalAmountBackOnSale = (sale) => {
|
|
24
30
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
31
|
+
if (curr.unitPrice === 0) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
25
34
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
|
26
35
|
return Math.ceil(prev + unitPrice * +curr.qtityBack);
|
|
27
36
|
}, 0);
|
|
28
37
|
};
|
|
29
38
|
export const getTotalAmountWithoutTvaOnSale = (sale, dlvr = false) => {
|
|
30
39
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
40
|
+
if (curr.unitPrice === 0) {
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
31
43
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
|
32
44
|
return !dlvr ? Math.ceil(prev + unitPrice * +curr.qtityOdr) : Math.ceil(prev + unitPrice * +curr.qtityDlvr);
|
|
33
45
|
}, 0);
|
|
34
46
|
};
|
|
35
47
|
export const getTotalAmountWithoutTvaBackOnSale = (sale) => {
|
|
36
48
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
49
|
+
if (curr.unitPrice === 0) {
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
37
52
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
|
38
53
|
return Math.ceil(prev + unitPrice * +curr.qtityBack);
|
|
39
54
|
}, 0);
|
|
40
55
|
};
|
|
41
56
|
export const getTotalTvaOnSaleOnSale = (sale, dlvr = false) => {
|
|
42
57
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
58
|
+
if (curr.unitPrice === 0) {
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
43
61
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
|
44
62
|
return !dlvr
|
|
45
63
|
? Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityOdr)
|
|
@@ -48,6 +66,9 @@ export const getTotalTvaOnSaleOnSale = (sale, dlvr = false) => {
|
|
|
48
66
|
};
|
|
49
67
|
export const getTotalTvaBackOnSale = (sale) => {
|
|
50
68
|
return sale.saleProducts.reduce((prev, curr) => {
|
|
69
|
+
if (curr.unitPrice === 0) {
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
51
72
|
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
|
52
73
|
return Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityBack);
|
|
53
74
|
}, 0);
|
package/lib/esm/utils.d.ts
CHANGED
|
@@ -122,3 +122,4 @@ export declare const arraySome: (arr1: any[], arr2: any[]) => boolean;
|
|
|
122
122
|
export declare const checkObjInArray: (objs: any[], checkProp: string | number, prop?: string) => boolean;
|
|
123
123
|
export declare const pathName: (location: any) => any;
|
|
124
124
|
export declare const nthIndexOf: (str: string, charToFind: string, nthPosition?: number) => number;
|
|
125
|
+
export declare const partOfStringBetweenTwoSpeChar: (str: string, position1: number, position2: number, char?: string) => string;
|
package/lib/esm/utils.js
CHANGED
|
@@ -765,3 +765,8 @@ export const pathName = (location) => {
|
|
|
765
765
|
export const nthIndexOf = (str, charToFind, nthPosition = 1) => {
|
|
766
766
|
return str.split(charToFind, nthPosition).join(charToFind).length;
|
|
767
767
|
};
|
|
768
|
+
export const partOfStringBetweenTwoSpeChar = (str, position1, position2, char = "/") => {
|
|
769
|
+
const firstSlashPosition = nthIndexOf(str, char, position1);
|
|
770
|
+
const secondSlashPosition = nthIndexOf(str, char, position2);
|
|
771
|
+
return str.substring(firstSlashPosition + 1, secondSlashPosition);
|
|
772
|
+
};
|