asv-hlps-market 1.0.0
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/bills/bill.d.ts +19 -0
- package/lib/cjs/bills/bill.js +79 -0
- package/lib/cjs/bills/models/Bill.d.ts +21 -0
- package/lib/cjs/bills/models/Bill.js +2 -0
- package/lib/cjs/index.d.ts +0 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/models/Gender.d.ts +6 -0
- package/lib/cjs/models/Gender.js +2 -0
- package/lib/cjs/models/Sale.d.ts +34 -0
- package/lib/cjs/models/Sale.js +2 -0
- package/lib/cjs/models/SaleProduct.d.ts +18 -0
- package/lib/cjs/models/SaleProduct.js +6 -0
- package/lib/cjs/models/Ste.d.ts +8 -0
- package/lib/cjs/models/Ste.js +2 -0
- package/lib/cjs/models/SteGrp.d.ts +7 -0
- package/lib/cjs/models/SteGrp.js +2 -0
- package/lib/cjs/models/Titr.d.ts +5 -0
- package/lib/cjs/models/Titr.js +2 -0
- package/lib/cjs/models/User.d.ts +38 -0
- package/lib/cjs/models/User.js +2 -0
- package/lib/cjs/models/UserGrp.d.ts +4 -0
- package/lib/cjs/models/UserGrp.js +2 -0
- package/lib/cjs/models/UserRole.d.ts +5 -0
- package/lib/cjs/models/UserRole.js +2 -0
- package/lib/cjs/models/shared/NaAc.d.ts +6 -0
- package/lib/cjs/models/shared/NaAc.js +2 -0
- package/lib/cjs/models/shared/NaCoAc.d.ts +4 -0
- package/lib/cjs/models/shared/NaCoAc.js +2 -0
- package/lib/cjs/models/shared/NaCoShortAc.d.ts +4 -0
- package/lib/cjs/models/shared/NaCoShortAc.js +2 -0
- package/lib/cjs/pdfs/invoices/amountInvoice.d.ts +66 -0
- package/lib/cjs/pdfs/invoices/amountInvoice.js +144 -0
- package/lib/cjs/pdfs/invoices/infoInvoice.d.ts +32 -0
- package/lib/cjs/pdfs/invoices/infoInvoice.js +80 -0
- package/lib/cjs/pdfs/tools/tools.d.ts +34 -0
- package/lib/cjs/pdfs/tools/tools.js +53 -0
- package/lib/cjs/products/interfaces/Product.d.ts +53 -0
- package/lib/cjs/products/interfaces/Product.js +2 -0
- package/lib/cjs/products/interfaces/ProductCat.d.ts +6 -0
- package/lib/cjs/products/interfaces/ProductCat.js +2 -0
- package/lib/cjs/products/interfaces/ProductStore.d.ts +24 -0
- package/lib/cjs/products/interfaces/ProductStore.js +2 -0
- package/lib/cjs/products/product.d.ts +3 -0
- package/lib/cjs/products/product.js +22 -0
- package/lib/cjs/sales/sale.d.ts +18 -0
- package/lib/cjs/sales/sale.js +129 -0
- package/lib/esm/bills/bill.d.ts +19 -0
- package/lib/esm/bills/bill.js +58 -0
- package/lib/esm/bills/models/Bill.d.ts +21 -0
- package/lib/esm/bills/models/Bill.js +1 -0
- package/lib/esm/index.d.ts +0 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/models/Gender.d.ts +6 -0
- package/lib/esm/models/Gender.js +1 -0
- package/lib/esm/models/Sale.d.ts +34 -0
- package/lib/esm/models/Sale.js +1 -0
- package/lib/esm/models/SaleProduct.d.ts +18 -0
- package/lib/esm/models/SaleProduct.js +2 -0
- package/lib/esm/models/Ste.d.ts +8 -0
- package/lib/esm/models/Ste.js +1 -0
- package/lib/esm/models/SteGrp.d.ts +7 -0
- package/lib/esm/models/SteGrp.js +1 -0
- package/lib/esm/models/Titr.d.ts +5 -0
- package/lib/esm/models/Titr.js +1 -0
- package/lib/esm/models/User.d.ts +38 -0
- package/lib/esm/models/User.js +1 -0
- package/lib/esm/models/UserGrp.d.ts +4 -0
- package/lib/esm/models/UserGrp.js +1 -0
- package/lib/esm/models/UserRole.d.ts +5 -0
- package/lib/esm/models/UserRole.js +1 -0
- package/lib/esm/models/shared/NaAc.d.ts +6 -0
- package/lib/esm/models/shared/NaAc.js +1 -0
- package/lib/esm/models/shared/NaCoAc.d.ts +4 -0
- package/lib/esm/models/shared/NaCoAc.js +1 -0
- package/lib/esm/models/shared/NaCoShortAc.d.ts +4 -0
- package/lib/esm/models/shared/NaCoShortAc.js +1 -0
- package/lib/esm/pdfs/invoices/amountInvoice.d.ts +66 -0
- package/lib/esm/pdfs/invoices/amountInvoice.js +137 -0
- package/lib/esm/pdfs/invoices/infoInvoice.d.ts +26 -0
- package/lib/esm/pdfs/invoices/infoInvoice.js +75 -0
- package/lib/esm/pdfs/tools/tools.d.ts +34 -0
- package/lib/esm/pdfs/tools/tools.js +47 -0
- package/lib/esm/products/interfaces/Product.d.ts +53 -0
- package/lib/esm/products/interfaces/Product.js +1 -0
- package/lib/esm/products/interfaces/ProductCat.d.ts +6 -0
- package/lib/esm/products/interfaces/ProductCat.js +1 -0
- package/lib/esm/products/interfaces/ProductStore.d.ts +24 -0
- package/lib/esm/products/interfaces/ProductStore.js +1 -0
- package/lib/esm/products/product.d.ts +3 -0
- package/lib/esm/products/product.js +17 -0
- package/lib/esm/sales/sale.d.ts +19 -0
- package/lib/esm/sales/sale.js +112 -0
- package/package.json +24 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
import { convertEnDateToFr, formatToStringCfa, labelSteName, removeBackSlashOccurences } from "asv-hlps";
|
2
|
+
import { unitPriceByClientCat } from "../products/product";
|
3
|
+
export const getNbProductsOnSale = (sale) => {
|
4
|
+
return sale.saleProducts.length || 0;
|
5
|
+
};
|
6
|
+
export const getTotalTvaOnSale = (sale, dlvr = false) => {
|
7
|
+
return sale.saleProducts.reduce((prev, curr) => {
|
8
|
+
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
9
|
+
return !dlvr
|
10
|
+
? Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityOdr)
|
11
|
+
: Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityDlvr);
|
12
|
+
}, 0);
|
13
|
+
};
|
14
|
+
export const getSubTotalAmountOnSale = (sale, dlvr = false) => {
|
15
|
+
return sale.saleProducts.reduce((prev, curr) => {
|
16
|
+
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
17
|
+
return !dlvr ? Math.ceil(prev + unitPrice * +curr.qtityOdr) : Math.ceil(prev + unitPrice * +curr.qtityDlvr);
|
18
|
+
}, 0);
|
19
|
+
};
|
20
|
+
export const getSubTotalAmountBackOnSale = (sale) => {
|
21
|
+
return sale.saleProducts.reduce((prev, curr) => {
|
22
|
+
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
23
|
+
return Math.ceil(prev + unitPrice * +curr.qtityBack);
|
24
|
+
}, 0);
|
25
|
+
};
|
26
|
+
export const getTotalAmountWithoutTvaOnSale = (sale, dlvr = false) => {
|
27
|
+
return sale.saleProducts.reduce((prev, curr) => {
|
28
|
+
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
29
|
+
return !dlvr ? Math.ceil(prev + unitPrice * +curr.qtityOdr) : Math.ceil(prev + unitPrice * +curr.qtityDlvr);
|
30
|
+
}, 0);
|
31
|
+
};
|
32
|
+
export const getTotalAmountWithoutTvaBackOnSale = (sale) => {
|
33
|
+
return sale.saleProducts.reduce((prev, curr) => {
|
34
|
+
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
35
|
+
return Math.ceil(prev + unitPrice * +curr.qtityBack);
|
36
|
+
}, 0);
|
37
|
+
};
|
38
|
+
export const getTotalTvaOnSaleOnSale = (sale, dlvr = false) => {
|
39
|
+
return sale.saleProducts.reduce((prev, curr) => {
|
40
|
+
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
41
|
+
return !dlvr
|
42
|
+
? Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityOdr)
|
43
|
+
: Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityDlvr);
|
44
|
+
}, 0);
|
45
|
+
};
|
46
|
+
export const getTotalTvaBackOnSale = (sale) => {
|
47
|
+
return sale.saleProducts.reduce((prev, curr) => {
|
48
|
+
const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
|
49
|
+
return Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityBack);
|
50
|
+
}, 0);
|
51
|
+
};
|
52
|
+
export const getTotalAmountOnSale = (sale, dlvr = false) => {
|
53
|
+
return getTotalAmountWithoutTvaOnSale(sale, dlvr) + getTotalTvaOnSale(sale, dlvr);
|
54
|
+
};
|
55
|
+
export const getTotalAmountBackOnSale = (sale) => {
|
56
|
+
return getTotalAmountWithoutTvaBackOnSale(sale) + getTotalTvaBackOnSale(sale);
|
57
|
+
};
|
58
|
+
export const getTotalAmountAllIncludedOnSale = (sale, dlvr = false) => {
|
59
|
+
return getTotalAmountOnSale(sale, dlvr) + getTotalShippingOnSale(sale) - getTotalAmountDiscountOnSale(sale, dlvr) || 0;
|
60
|
+
};
|
61
|
+
// export const getTotalShippingOnSale = (shippingFee: number , otherFee: number = 0) => {
|
62
|
+
export const getTotalShippingOnSale = (sale) => {
|
63
|
+
return (+sale.shippingFee || 0) + (+sale.otherFee || 0);
|
64
|
+
};
|
65
|
+
export const getTotalAmountDiscountOnSale = (sale, dlvr = false) => {
|
66
|
+
return getTotalAmountOnSale(sale, dlvr) * (+sale.discountRate / 100 || 0);
|
67
|
+
};
|
68
|
+
export const getTotalQtityOnSale = (sale, dlvr = false) => {
|
69
|
+
return sale.saleProducts.reduce((prev, curr) => {
|
70
|
+
return !dlvr
|
71
|
+
? Math.ceil(prev + (+curr.qtityOdr + (+curr.qtityFree || 0)))
|
72
|
+
: Math.ceil(prev + (+curr.qtityDlvr + (+curr.qtityFree || 0)));
|
73
|
+
}, 0);
|
74
|
+
};
|
75
|
+
export const getTotalQtityFreeOnSale = (sale) => {
|
76
|
+
return sale.saleProducts.reduce((prev, curr) => {
|
77
|
+
return Math.ceil(prev + (+curr.qtityFree || 0));
|
78
|
+
}, 0);
|
79
|
+
};
|
80
|
+
export const getTotalQtityOdrOrDlvrOnSale = (sale, dlvr = false) => {
|
81
|
+
return sale.saleProducts.reduce((prev, curr) => {
|
82
|
+
return !dlvr ? Math.ceil(prev + (+curr.qtityOdr || 0)) : Math.ceil(prev + (+curr.qtityDlvr || 0));
|
83
|
+
}, 0);
|
84
|
+
};
|
85
|
+
export const tabLabel = (sale) => {
|
86
|
+
const labels = [];
|
87
|
+
for (const sp of sale.saleProducts) {
|
88
|
+
for (let j = 0; j < (+sp.qtityDlvr + +sp.qtityFree); j++) {
|
89
|
+
const name = labelSteName(sale.client.ste);
|
90
|
+
const product = sp.product.designation;
|
91
|
+
const pp = formatToStringCfa(Math.ceil(sp.publicPrice));
|
92
|
+
const saleDate = convertEnDateToFr(sale.saleDate, '/');
|
93
|
+
// const saleDate = formatDateYmd(sale.saleDate, '/');
|
94
|
+
// const saleDate = moment(sale.saleDate ).format('DD/MM/YYYY');
|
95
|
+
labels.push({ name, product, pp, saleDate });
|
96
|
+
}
|
97
|
+
}
|
98
|
+
const tabLen = labels.length;
|
99
|
+
const modulo = tabLen % 5;
|
100
|
+
if (modulo !== 0) {
|
101
|
+
for (let i = 0; i < (5 - +modulo); i++) {
|
102
|
+
labels.push({ name: 'L\' OEIL DE DIEU', product: 'est votre meilleur ami', pp: ' ', saleDate: ' ' });
|
103
|
+
}
|
104
|
+
}
|
105
|
+
return labels;
|
106
|
+
};
|
107
|
+
export const refSaleGenerator = () => {
|
108
|
+
let date = new Date();
|
109
|
+
const nDate = 'C' + date.toLocaleDateString().split('-').join('') + date.toLocaleTimeString().split(':').join('');
|
110
|
+
return removeBackSlashOccurences(nDate, '').toLocaleUpperCase();
|
111
|
+
// return randomatic('A', 4) + date.toLocaleDateString().split('-').join('') + date.toLocaleTimeString().split(':').join('')
|
112
|
+
};
|
package/package.json
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"name": "asv-hlps-market",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "helpers for markets app",
|
5
|
+
"main": "./lib/cjs/index.js",
|
6
|
+
"module": "./lib/esm/index.js",
|
7
|
+
"files": [
|
8
|
+
"lib/"
|
9
|
+
],
|
10
|
+
"scripts": {
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
12
|
+
"tsc": "npx tsc -p tsconfig.json && npx tsc -p tsconfig-cjs.json",
|
13
|
+
"prepublishOnly": "npm run tsc"
|
14
|
+
},
|
15
|
+
"keywords": [],
|
16
|
+
"author": "Aril Vignon",
|
17
|
+
"license": "ISC",
|
18
|
+
"devDependencies": {
|
19
|
+
"typescript": "^5.7.3"
|
20
|
+
},
|
21
|
+
"dependencies": {
|
22
|
+
"asv-hlps": "^1.4.8"
|
23
|
+
}
|
24
|
+
}
|