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.
Files changed (93) hide show
  1. package/lib/cjs/bills/bill.d.ts +19 -0
  2. package/lib/cjs/bills/bill.js +79 -0
  3. package/lib/cjs/bills/models/Bill.d.ts +21 -0
  4. package/lib/cjs/bills/models/Bill.js +2 -0
  5. package/lib/cjs/index.d.ts +0 -0
  6. package/lib/cjs/index.js +1 -0
  7. package/lib/cjs/models/Gender.d.ts +6 -0
  8. package/lib/cjs/models/Gender.js +2 -0
  9. package/lib/cjs/models/Sale.d.ts +34 -0
  10. package/lib/cjs/models/Sale.js +2 -0
  11. package/lib/cjs/models/SaleProduct.d.ts +18 -0
  12. package/lib/cjs/models/SaleProduct.js +6 -0
  13. package/lib/cjs/models/Ste.d.ts +8 -0
  14. package/lib/cjs/models/Ste.js +2 -0
  15. package/lib/cjs/models/SteGrp.d.ts +7 -0
  16. package/lib/cjs/models/SteGrp.js +2 -0
  17. package/lib/cjs/models/Titr.d.ts +5 -0
  18. package/lib/cjs/models/Titr.js +2 -0
  19. package/lib/cjs/models/User.d.ts +38 -0
  20. package/lib/cjs/models/User.js +2 -0
  21. package/lib/cjs/models/UserGrp.d.ts +4 -0
  22. package/lib/cjs/models/UserGrp.js +2 -0
  23. package/lib/cjs/models/UserRole.d.ts +5 -0
  24. package/lib/cjs/models/UserRole.js +2 -0
  25. package/lib/cjs/models/shared/NaAc.d.ts +6 -0
  26. package/lib/cjs/models/shared/NaAc.js +2 -0
  27. package/lib/cjs/models/shared/NaCoAc.d.ts +4 -0
  28. package/lib/cjs/models/shared/NaCoAc.js +2 -0
  29. package/lib/cjs/models/shared/NaCoShortAc.d.ts +4 -0
  30. package/lib/cjs/models/shared/NaCoShortAc.js +2 -0
  31. package/lib/cjs/pdfs/invoices/amountInvoice.d.ts +66 -0
  32. package/lib/cjs/pdfs/invoices/amountInvoice.js +144 -0
  33. package/lib/cjs/pdfs/invoices/infoInvoice.d.ts +32 -0
  34. package/lib/cjs/pdfs/invoices/infoInvoice.js +80 -0
  35. package/lib/cjs/pdfs/tools/tools.d.ts +34 -0
  36. package/lib/cjs/pdfs/tools/tools.js +53 -0
  37. package/lib/cjs/products/interfaces/Product.d.ts +53 -0
  38. package/lib/cjs/products/interfaces/Product.js +2 -0
  39. package/lib/cjs/products/interfaces/ProductCat.d.ts +6 -0
  40. package/lib/cjs/products/interfaces/ProductCat.js +2 -0
  41. package/lib/cjs/products/interfaces/ProductStore.d.ts +24 -0
  42. package/lib/cjs/products/interfaces/ProductStore.js +2 -0
  43. package/lib/cjs/products/product.d.ts +3 -0
  44. package/lib/cjs/products/product.js +22 -0
  45. package/lib/cjs/sales/sale.d.ts +18 -0
  46. package/lib/cjs/sales/sale.js +129 -0
  47. package/lib/esm/bills/bill.d.ts +19 -0
  48. package/lib/esm/bills/bill.js +58 -0
  49. package/lib/esm/bills/models/Bill.d.ts +21 -0
  50. package/lib/esm/bills/models/Bill.js +1 -0
  51. package/lib/esm/index.d.ts +0 -0
  52. package/lib/esm/index.js +1 -0
  53. package/lib/esm/models/Gender.d.ts +6 -0
  54. package/lib/esm/models/Gender.js +1 -0
  55. package/lib/esm/models/Sale.d.ts +34 -0
  56. package/lib/esm/models/Sale.js +1 -0
  57. package/lib/esm/models/SaleProduct.d.ts +18 -0
  58. package/lib/esm/models/SaleProduct.js +2 -0
  59. package/lib/esm/models/Ste.d.ts +8 -0
  60. package/lib/esm/models/Ste.js +1 -0
  61. package/lib/esm/models/SteGrp.d.ts +7 -0
  62. package/lib/esm/models/SteGrp.js +1 -0
  63. package/lib/esm/models/Titr.d.ts +5 -0
  64. package/lib/esm/models/Titr.js +1 -0
  65. package/lib/esm/models/User.d.ts +38 -0
  66. package/lib/esm/models/User.js +1 -0
  67. package/lib/esm/models/UserGrp.d.ts +4 -0
  68. package/lib/esm/models/UserGrp.js +1 -0
  69. package/lib/esm/models/UserRole.d.ts +5 -0
  70. package/lib/esm/models/UserRole.js +1 -0
  71. package/lib/esm/models/shared/NaAc.d.ts +6 -0
  72. package/lib/esm/models/shared/NaAc.js +1 -0
  73. package/lib/esm/models/shared/NaCoAc.d.ts +4 -0
  74. package/lib/esm/models/shared/NaCoAc.js +1 -0
  75. package/lib/esm/models/shared/NaCoShortAc.d.ts +4 -0
  76. package/lib/esm/models/shared/NaCoShortAc.js +1 -0
  77. package/lib/esm/pdfs/invoices/amountInvoice.d.ts +66 -0
  78. package/lib/esm/pdfs/invoices/amountInvoice.js +137 -0
  79. package/lib/esm/pdfs/invoices/infoInvoice.d.ts +26 -0
  80. package/lib/esm/pdfs/invoices/infoInvoice.js +75 -0
  81. package/lib/esm/pdfs/tools/tools.d.ts +34 -0
  82. package/lib/esm/pdfs/tools/tools.js +47 -0
  83. package/lib/esm/products/interfaces/Product.d.ts +53 -0
  84. package/lib/esm/products/interfaces/Product.js +1 -0
  85. package/lib/esm/products/interfaces/ProductCat.d.ts +6 -0
  86. package/lib/esm/products/interfaces/ProductCat.js +1 -0
  87. package/lib/esm/products/interfaces/ProductStore.d.ts +24 -0
  88. package/lib/esm/products/interfaces/ProductStore.js +1 -0
  89. package/lib/esm/products/product.d.ts +3 -0
  90. package/lib/esm/products/product.js +17 -0
  91. package/lib/esm/sales/sale.d.ts +19 -0
  92. package/lib/esm/sales/sale.js +112 -0
  93. package/package.json +24 -0
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.infoBill = exports.infoSale = void 0;
4
+ const asv_hlps_1 = require("asv-hlps");
5
+ const bill_1 = require("../../bills/bill");
6
+ const sale_1 = require("../../sales/sale");
7
+ const infoSale = (tob) => {
8
+ const totalQtity = (0, sale_1.getTotalQtityOnSale)(tob);
9
+ const nbProducts = (0, sale_1.getNbProductsOnSale)(tob);
10
+ const nbColis = tob.nbPackages;
11
+ const nbFreeze = tob.nbFreeze;
12
+ // const oWidth = [ '*', '*', 75, 75, 75, 75];
13
+ const tabTop = {
14
+ width: '50%',
15
+ table: {
16
+ headerRows: 1,
17
+ widths: ['*', '*', 75, 75, 75, 75],
18
+ heights: [6],
19
+ body: [
20
+ [
21
+ { text: 'FACTURE N°', style: 'headerText' },
22
+ { text: 'DATE', style: 'headerText' },
23
+ { text: 'NBRE DE PDTS', style: 'headerText' },
24
+ { text: 'QUANTITE TOTALE', style: 'headerText' },
25
+ { text: 'NBRE COLIS', style: 'headerText' },
26
+ { text: 'NBRE FROID', style: 'headerText' }
27
+ ],
28
+ [
29
+ { text: tob.ref, style: 'rowText' },
30
+ // { text: moment(tob.createdAt ).format('DD/MM/YYYY'), style: 'rowText'},
31
+ { text: (0, asv_hlps_1.convertEnDateToFr)(tob.createdAt, '/'), style: 'rowText' },
32
+ { text: nbProducts, style: 'rowText' },
33
+ { text: totalQtity, style: 'rowText' },
34
+ { text: nbColis, style: 'rowText' },
35
+ { text: nbFreeze, style: 'rowText' },
36
+ ]
37
+ ]
38
+ }
39
+ };
40
+ return tabTop;
41
+ };
42
+ exports.infoSale = infoSale;
43
+ const infoBill = (tob) => {
44
+ const totalQtity = (0, bill_1.getTotalQtityOnBill)(tob.sales);
45
+ const nbProducts = (0, bill_1.getNbProductsOnBill)(tob.sales);
46
+ const nbColis = (0, bill_1.getNbPackagesOnBill)(tob.sales);
47
+ const nbFreeze = (0, bill_1.getNbFreezeOnBill)(tob.sales);
48
+ const oWidth = ['*', '*', 75, 75, 75, 75];
49
+ const tabTop = {
50
+ width: '50%',
51
+ table: {
52
+ headerRows: 1,
53
+ // widths: [ 125, 125, 125, '*' ],
54
+ widths: oWidth,
55
+ heights: [6],
56
+ // widths: [ '16%', '16%', '16%', '16%' ],
57
+ body: [
58
+ [
59
+ { text: 'FACTURE N°', style: 'headerText' },
60
+ { text: 'DATE', style: 'headerText' },
61
+ { text: 'NBRE DE PDTS', style: 'headerText' },
62
+ { text: 'QUANTITE TOTALE', style: 'headerText' },
63
+ { text: 'NBRE COLIS', style: 'headerText' },
64
+ { text: 'NBRE FROID', style: 'headerText' }
65
+ ],
66
+ [
67
+ { text: tob.ref, style: 'rowText' },
68
+ // { text: moment(tob.createdAt ).format('DD/MM/YYYY'), style: 'rowText'},
69
+ { text: (0, asv_hlps_1.convertEnDateToFr)(tob.createdAt, '/'), style: 'rowText' },
70
+ { text: nbProducts, style: 'rowText' },
71
+ { text: totalQtity, style: 'rowText' },
72
+ { text: nbColis, style: 'rowText' },
73
+ { text: nbFreeze, style: 'rowText' },
74
+ ]
75
+ ]
76
+ }
77
+ };
78
+ return tabTop;
79
+ };
80
+ exports.infoBill = infoBill;
@@ -0,0 +1,34 @@
1
+ import { User } from 'asv-hlps-models';
2
+ export declare const displayPdfDate: (label: string, fromDate: string, toDate: string) => string;
3
+ export declare const displayTitle: (title: string) => {
4
+ width: string;
5
+ alignment: string;
6
+ text: string;
7
+ bold: boolean;
8
+ margin: number[];
9
+ fontSize: number;
10
+ };
11
+ export declare const displayClient: (user: User) => {
12
+ absolutePosition: {
13
+ x: number;
14
+ y: number;
15
+ };
16
+ text: ({
17
+ text: string;
18
+ fontSize: number;
19
+ bold?: undefined;
20
+ } | {
21
+ text: string;
22
+ bold: boolean;
23
+ fontSize: number;
24
+ } | {
25
+ text: string;
26
+ fontSize?: undefined;
27
+ bold?: undefined;
28
+ })[];
29
+ color: string;
30
+ width: string;
31
+ fontSize: number;
32
+ bold: boolean;
33
+ alignment: string;
34
+ };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.displayClient = exports.displayTitle = exports.displayPdfDate = void 0;
4
+ const asv_hlps_1 = require("asv-hlps");
5
+ const displayPdfDate = (label, fromDate, toDate) => {
6
+ fromDate = (!fromDate) ? (0, asv_hlps_1.formatDateYmdHypen)(new Date()) : fromDate;
7
+ toDate = (!toDate) ? fromDate : toDate;
8
+ return label + ' du ' + (0, asv_hlps_1.convertEnDateToFr)(fromDate) + ' au ' + (0, asv_hlps_1.convertEnDateToFr)(toDate);
9
+ };
10
+ exports.displayPdfDate = displayPdfDate;
11
+ const displayTitle = (title) => {
12
+ return {
13
+ width: '100%',
14
+ alignment: 'center',
15
+ text: title,
16
+ bold: true,
17
+ margin: [0, 10, 0, 10],
18
+ fontSize: 15,
19
+ };
20
+ };
21
+ exports.displayTitle = displayTitle;
22
+ const displayClient = (user) => {
23
+ // const clientSte = user.ste ? HlpUser.getSteShortname(user.ste) : '';
24
+ const clientSte = user.ste ? (0, asv_hlps_1.getSteShortname)(user.ste, ['pharmacie', 'clinique', 'hopital']) : '';
25
+ /* const clientLastname = (user.lastname) ? user.lastname : '';
26
+ const clientFirstname = (user.firstname) ? user.firstname : '';
27
+ const clientGender = (user.gender) ? user.gender.abr : ''; */
28
+ const clientName = user.ste ? clientSte : user.fullname;
29
+ const cp = user.cp ? user.cp : '';
30
+ const city = user.city ? user.city : '';
31
+ const nif = user.ste.nif ? user.ste.nif : '';
32
+ const address = user.address ? user.address : '';
33
+ const client = {
34
+ absolutePosition: { x: 310, y: 30 },
35
+ text: [
36
+ { text: 'CLIENT: ', fontSize: 8 },
37
+ { text: user.username + '\n', bold: true, fontSize: 10 },
38
+ { text: clientName + '\n' },
39
+ { text: address + ' ' },
40
+ { text: cp + '\n' },
41
+ { text: city + '\n' },
42
+ // {text: nif + '\n'}
43
+ ],
44
+ color: '#000',
45
+ width: 'auto',
46
+ fontSize: 12,
47
+ bold: true,
48
+ alignment: 'left',
49
+ // margin: [100, 0, 0, 0],
50
+ };
51
+ return client;
52
+ };
53
+ exports.displayClient = displayClient;
@@ -0,0 +1,53 @@
1
+ import { ProductCat } from "./ProductCat";
2
+ import { ProductStore } from "./ProductStore";
3
+ export interface Product {
4
+ id: number;
5
+ ref?: string;
6
+ designation?: string;
7
+ unitPrice?: number;
8
+ salePrice?: number;
9
+ pght?: number;
10
+ pghtPrice?: number;
11
+ codeHs?: string;
12
+ codeCip?: string;
13
+ codeCip7?: string;
14
+ codeEan?: string;
15
+ condeInam?: string;
16
+ codeCompta?: number;
17
+ codeAmm?: string;
18
+ codeAmmStart?: Date | string;
19
+ codeAmmEnd?: Date | string;
20
+ pvdPrice?: number;
21
+ fees?: number;
22
+ profit?: number;
23
+ profitPhcie?: number;
24
+ publicPrice?: number;
25
+ qtityLimit?: number;
26
+ stockLimit?: number;
27
+ stockMax?: number;
28
+ stockReap?: number;
29
+ stock?: number;
30
+ stockReserved?: number;
31
+ stockSalable?: number;
32
+ qtityPerPackaging?: number;
33
+ qtityPerBox?: number;
34
+ promo?: number;
35
+ isInOrder?: boolean;
36
+ coef?: number;
37
+ promoPerQtity?: number;
38
+ promoEndAt?: Date;
39
+ image?: string;
40
+ description?: string;
41
+ isActive?: boolean;
42
+ tva?: number;
43
+ discountRate?: number;
44
+ createdAt?: Date;
45
+ updatedAt?: Date;
46
+ hasPromo?: boolean;
47
+ inEqeer?: boolean;
48
+ qtityWarning?: boolean;
49
+ isPublished?: boolean;
50
+ isAvailable?: boolean;
51
+ cat?: ProductCat;
52
+ stores?: ProductStore[];
53
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export interface ProductCat {
2
+ id: number;
3
+ name: string;
4
+ code: string;
5
+ isActive: boolean;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,24 @@
1
+ export interface ProductStore {
2
+ id?: number;
3
+ name?: string;
4
+ qtityLimit?: number;
5
+ stockLimit?: number;
6
+ stockMax?: number;
7
+ stock?: number;
8
+ stockReap?: number;
9
+ stockReserved?: number;
10
+ stockSalable?: number;
11
+ fees?: number;
12
+ pght?: number;
13
+ pvdPrice?: number;
14
+ pghtPrice?: number;
15
+ costPrice?: number;
16
+ salePrice?: number;
17
+ profitPhcie?: number;
18
+ publicPrice?: number;
19
+ isActive?: boolean;
20
+ isAvailable?: boolean;
21
+ isPublished?: boolean;
22
+ hasPromo?: boolean;
23
+ discountRate?: number;
24
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { Product, User } from "asv-hlps-models";
2
+ export declare const unitPriceByClientCat: (product: Product, client: User, speUnitPrice?: number, addDiscount?: boolean) => number;
3
+ export declare const productCatCode: (product: Product, catCodes: string[]) => boolean;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.productCatCode = exports.unitPriceByClientCat = void 0;
4
+ const asv_hlps_1 = require("asv-hlps");
5
+ const unitPriceByClientCat = (product, client, speUnitPrice = 0, addDiscount = false) => {
6
+ if (speUnitPrice > 0) {
7
+ return speUnitPrice;
8
+ }
9
+ // const store = await getCustomRepository(ProductStoreRepository).getOneStoreByParams({storeName: 'cpa', productId: product.id})
10
+ if (product.stores[0].discountRate && addDiscount) {
11
+ return Math.ceil(product.stores[0].salePrice) - Math.ceil((0, asv_hlps_1.calculPercent)(product.stores[0].salePrice, product.stores[0].discountRate));
12
+ }
13
+ const clientCoef = (!client) ? 1 : (0, asv_hlps_1.userCoef)(client);
14
+ return ((0, exports.productCatCode)(product, ['spe', 'para'])) ?
15
+ Math.ceil(product.stores[0].salePrice) :
16
+ Math.ceil(product.stores[0].salePrice * clientCoef);
17
+ };
18
+ exports.unitPriceByClientCat = unitPriceByClientCat;
19
+ const productCatCode = (product, catCodes) => {
20
+ return catCodes.includes(product.cat.code && product.cat.code.toLowerCase());
21
+ };
22
+ exports.productCatCode = productCatCode;
@@ -0,0 +1,18 @@
1
+ import { Sale } from "asv-hlps-models";
2
+ export declare const getNbProductsOnSale: (sale: Sale) => number;
3
+ export declare const getTotalTvaOnSale: (sale: Sale, dlvr?: boolean) => number;
4
+ export declare const getSubTotalAmountOnSale: (sale: Sale, dlvr?: boolean) => number;
5
+ export declare const getSubTotalAmountBackOnSale: (sale: Sale) => number;
6
+ export declare const getTotalAmountWithoutTvaOnSale: (sale: Sale, dlvr?: boolean) => number;
7
+ export declare const getTotalAmountWithoutTvaBackOnSale: (sale: Sale) => number;
8
+ export declare const getTotalTvaOnSaleOnSale: (sale: Sale, dlvr?: boolean) => number;
9
+ export declare const getTotalTvaBackOnSale: (sale: Sale) => number;
10
+ export declare const getTotalAmountOnSale: (sale: Sale, dlvr?: boolean) => number;
11
+ export declare const getTotalAmountBackOnSale: (sale: Sale) => number;
12
+ export declare const getTotalAmountAllIncludedOnSale: (sale: Sale, dlvr?: boolean) => number;
13
+ export declare const getTotalShippingOnSale: (sale: Sale) => number;
14
+ export declare const getTotalAmountDiscountOnSale: (sale: Sale, dlvr?: boolean) => number;
15
+ export declare const getTotalQtityOnSale: (sale: Sale, dlvr?: boolean) => number;
16
+ export declare const getTotalQtityFreeOnSale: (sale: Sale) => number;
17
+ export declare const getTotalQtityOdrOrDlvrOnSale: (sale: Sale, dlvr?: boolean) => number;
18
+ export declare const tabLabel: (sale: Sale) => any[];
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tabLabel = exports.getTotalQtityOdrOrDlvrOnSale = exports.getTotalQtityFreeOnSale = exports.getTotalQtityOnSale = exports.getTotalAmountDiscountOnSale = exports.getTotalShippingOnSale = exports.getTotalAmountAllIncludedOnSale = exports.getTotalAmountBackOnSale = exports.getTotalAmountOnSale = exports.getTotalTvaBackOnSale = exports.getTotalTvaOnSaleOnSale = exports.getTotalAmountWithoutTvaBackOnSale = exports.getTotalAmountWithoutTvaOnSale = exports.getSubTotalAmountBackOnSale = exports.getSubTotalAmountOnSale = exports.getTotalTvaOnSale = exports.getNbProductsOnSale = void 0;
4
+ const asv_hlps_1 = require("asv-hlps");
5
+ const product_1 = require("../products/product");
6
+ const getNbProductsOnSale = (sale) => {
7
+ return sale.saleProducts.length || 0;
8
+ };
9
+ exports.getNbProductsOnSale = getNbProductsOnSale;
10
+ const getTotalTvaOnSale = (sale, dlvr = false) => {
11
+ return sale.saleProducts.reduce((prev, curr) => {
12
+ console.log('------ cuurr ------');
13
+ console.log(curr);
14
+ console.log('------ cuurr ------');
15
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
16
+ return !dlvr
17
+ ? Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityOdr)
18
+ : Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityDlvr);
19
+ }, 0);
20
+ };
21
+ exports.getTotalTvaOnSale = getTotalTvaOnSale;
22
+ const getSubTotalAmountOnSale = (sale, dlvr = false) => {
23
+ return sale.saleProducts.reduce((prev, curr) => {
24
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
25
+ return !dlvr ? Math.ceil(prev + unitPrice * +curr.qtityOdr) : Math.ceil(prev + unitPrice * +curr.qtityDlvr);
26
+ }, 0);
27
+ };
28
+ exports.getSubTotalAmountOnSale = getSubTotalAmountOnSale;
29
+ const getSubTotalAmountBackOnSale = (sale) => {
30
+ return sale.saleProducts.reduce((prev, curr) => {
31
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
32
+ return Math.ceil(prev + unitPrice * +curr.qtityBack);
33
+ }, 0);
34
+ };
35
+ exports.getSubTotalAmountBackOnSale = getSubTotalAmountBackOnSale;
36
+ const getTotalAmountWithoutTvaOnSale = (sale, dlvr = false) => {
37
+ return sale.saleProducts.reduce((prev, curr) => {
38
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
39
+ return !dlvr ? Math.ceil(prev + unitPrice * +curr.qtityOdr) : Math.ceil(prev + unitPrice * +curr.qtityDlvr);
40
+ }, 0);
41
+ };
42
+ exports.getTotalAmountWithoutTvaOnSale = getTotalAmountWithoutTvaOnSale;
43
+ const getTotalAmountWithoutTvaBackOnSale = (sale) => {
44
+ return sale.saleProducts.reduce((prev, curr) => {
45
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
46
+ return Math.ceil(prev + unitPrice * +curr.qtityBack);
47
+ }, 0);
48
+ };
49
+ exports.getTotalAmountWithoutTvaBackOnSale = getTotalAmountWithoutTvaBackOnSale;
50
+ const getTotalTvaOnSaleOnSale = (sale, dlvr = false) => {
51
+ return sale.saleProducts.reduce((prev, curr) => {
52
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
53
+ return !dlvr
54
+ ? Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityOdr)
55
+ : Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityDlvr);
56
+ }, 0);
57
+ };
58
+ exports.getTotalTvaOnSaleOnSale = getTotalTvaOnSaleOnSale;
59
+ const getTotalTvaBackOnSale = (sale) => {
60
+ return sale.saleProducts.reduce((prev, curr) => {
61
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : (0, product_1.unitPriceByClientCat)(curr.product, sale.client, curr.speUnitPrice);
62
+ return Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityBack);
63
+ }, 0);
64
+ };
65
+ exports.getTotalTvaBackOnSale = getTotalTvaBackOnSale;
66
+ const getTotalAmountOnSale = (sale, dlvr = false) => {
67
+ return (0, exports.getTotalAmountWithoutTvaOnSale)(sale, dlvr) + (0, exports.getTotalTvaOnSale)(sale, dlvr);
68
+ };
69
+ exports.getTotalAmountOnSale = getTotalAmountOnSale;
70
+ const getTotalAmountBackOnSale = (sale) => {
71
+ return (0, exports.getTotalAmountWithoutTvaBackOnSale)(sale) + (0, exports.getTotalTvaBackOnSale)(sale);
72
+ };
73
+ exports.getTotalAmountBackOnSale = getTotalAmountBackOnSale;
74
+ const getTotalAmountAllIncludedOnSale = (sale, dlvr = false) => {
75
+ return (0, exports.getTotalAmountOnSale)(sale, dlvr) + (0, exports.getTotalShippingOnSale)(sale) - (0, exports.getTotalAmountDiscountOnSale)(sale, dlvr) || 0;
76
+ };
77
+ exports.getTotalAmountAllIncludedOnSale = getTotalAmountAllIncludedOnSale;
78
+ // export const getTotalShippingOnSale = (shippingFee: number , otherFee: number = 0) => {
79
+ const getTotalShippingOnSale = (sale) => {
80
+ return (+sale.shippingFee || 0) + (+sale.otherFee || 0);
81
+ };
82
+ exports.getTotalShippingOnSale = getTotalShippingOnSale;
83
+ const getTotalAmountDiscountOnSale = (sale, dlvr = false) => {
84
+ return (0, exports.getTotalAmountOnSale)(sale, dlvr) * (+sale.discountRate / 100 || 0);
85
+ };
86
+ exports.getTotalAmountDiscountOnSale = getTotalAmountDiscountOnSale;
87
+ const getTotalQtityOnSale = (sale, dlvr = false) => {
88
+ return sale.saleProducts.reduce((prev, curr) => {
89
+ return !dlvr
90
+ ? Math.ceil(prev + (+curr.qtityOdr + (+curr.qtityFree || 0)))
91
+ : Math.ceil(prev + (+curr.qtityDlvr + (+curr.qtityFree || 0)));
92
+ }, 0);
93
+ };
94
+ exports.getTotalQtityOnSale = getTotalQtityOnSale;
95
+ const getTotalQtityFreeOnSale = (sale) => {
96
+ return sale.saleProducts.reduce((prev, curr) => {
97
+ return Math.ceil(prev + (+curr.qtityFree || 0));
98
+ }, 0);
99
+ };
100
+ exports.getTotalQtityFreeOnSale = getTotalQtityFreeOnSale;
101
+ const getTotalQtityOdrOrDlvrOnSale = (sale, dlvr = false) => {
102
+ return sale.saleProducts.reduce((prev, curr) => {
103
+ return !dlvr ? Math.ceil(prev + (+curr.qtityOdr || 0)) : Math.ceil(prev + (+curr.qtityDlvr || 0));
104
+ }, 0);
105
+ };
106
+ exports.getTotalQtityOdrOrDlvrOnSale = getTotalQtityOdrOrDlvrOnSale;
107
+ const tabLabel = (sale) => {
108
+ const labels = [];
109
+ for (const sp of sale.saleProducts) {
110
+ for (let j = 0; j < (+sp.qtityDlvr + +sp.qtityFree); j++) {
111
+ const name = (0, asv_hlps_1.labelSteName)(sale.client.ste);
112
+ const product = sp.product.designation;
113
+ const pp = (0, asv_hlps_1.formatToStringCfa)(Math.ceil(sp.publicPrice));
114
+ const saleDate = (0, asv_hlps_1.convertEnDateToFr)(sale.saleDate, '/');
115
+ // const saleDate = formatDateYmd(sale.saleDate, '/');
116
+ // const saleDate = moment(sale.saleDate ).format('DD/MM/YYYY');
117
+ labels.push({ name, product, pp, saleDate });
118
+ }
119
+ }
120
+ const tabLen = labels.length;
121
+ const modulo = tabLen % 5;
122
+ if (modulo !== 0) {
123
+ for (let i = 0; i < (5 - +modulo); i++) {
124
+ labels.push({ name: 'L\' OEIL DE DIEU', product: 'est votre meilleur ami', pp: ' ', saleDate: ' ' });
125
+ }
126
+ }
127
+ return labels;
128
+ };
129
+ exports.tabLabel = tabLabel;
@@ -0,0 +1,19 @@
1
+ import { Bill, Sale } from "asv-hlps-models";
2
+ export declare const getNbProductsOnBill: (sales: Sale[]) => Sale;
3
+ export declare const getNbPackagesOnBill: (sales: Sale[]) => Sale;
4
+ export declare const getNbFreezeOnBill: (sales: Sale[]) => Sale;
5
+ export declare const getTotalTvaOnBill: (sales: Sale[]) => any;
6
+ export declare const getTotalAmountOnBill: (sales: Sale[]) => Sale;
7
+ export declare const getTotalAmountBackOnBill: (sales: Sale[]) => Sale;
8
+ export declare const getTotalTvaBackOnBill: (sales: Sale[]) => Sale;
9
+ export declare const getTotalQtityOnBill: (sales: Sale[]) => Sale;
10
+ export declare const getTotalQtityFreeOnBill: (sales: Sale[]) => Sale;
11
+ export declare const getTotalAmountWithoutTvaOnBill: (sales: Sale[]) => Sale;
12
+ export declare const getTotalAmountWithoutTvaBackOnBill: (sales: Sale[]) => Sale;
13
+ export declare const getTotalAmountAllIncludedOnBill: (sales: Sale[]) => Sale;
14
+ export declare const getTotalAmountTvaOnBill: (sales: Sale[]) => Sale;
15
+ export declare const getTotalAmountTvaBackOnBill: (sales: Sale[]) => Sale;
16
+ export declare const getTotalAmountOnListBill: (bills: Bill[]) => Bill;
17
+ export declare const getTotalAmountTvaOnListBill: (bills: Bill[]) => Bill;
18
+ export declare const getTotalAmountWithoutTvaOnListBill: (bills: Bill[]) => Bill;
19
+ export declare const getTotalDueAmountOnListBill: (bills: Bill[]) => Bill;
@@ -0,0 +1,58 @@
1
+ import { getNbProductsOnSale, getTotalAmountAllIncludedOnSale, getTotalAmountBackOnSale, getTotalAmountOnSale, getTotalAmountWithoutTvaBackOnSale, getTotalAmountWithoutTvaOnSale, getTotalQtityFreeOnSale, getTotalQtityOnSale, getTotalTvaBackOnSale, getTotalTvaOnSale } from "../sales/sale";
2
+ export const getNbProductsOnBill = (sales) => {
3
+ return sales.reduce((prev, sale) => prev + (+getNbProductsOnSale(sale)), 0);
4
+ };
5
+ export const getNbPackagesOnBill = (sales) => {
6
+ return sales.reduce((prev, sale) => prev + (+sale.nbPackages), 0);
7
+ };
8
+ export const getNbFreezeOnBill = (sales) => {
9
+ return sales.reduce((prev, sale) => prev + (+sale.nbFreeze), 0);
10
+ };
11
+ export const getTotalTvaOnBill = (sales) => {
12
+ if (!sales.length) {
13
+ return 0;
14
+ }
15
+ return sales.reduce((prev, sale) => prev + (getTotalTvaOnSale(sale, true)), 0);
16
+ };
17
+ export const getTotalAmountOnBill = (sales) => {
18
+ return sales.reduce((prev, sale) => prev + (getTotalAmountOnSale(sale, true)), 0);
19
+ };
20
+ export const getTotalAmountBackOnBill = (sales) => {
21
+ return sales.reduce((prev, sale) => prev + (getTotalAmountBackOnSale(sale)), 0);
22
+ };
23
+ export const getTotalTvaBackOnBill = (sales) => {
24
+ return sales.reduce((prev, sale) => prev + (getTotalTvaBackOnSale(sale)), 0);
25
+ };
26
+ export const getTotalQtityOnBill = (sales) => {
27
+ return sales.reduce((prev, sale) => prev + (getTotalQtityOnSale(sale, true)), 0);
28
+ };
29
+ export const getTotalQtityFreeOnBill = (sales) => {
30
+ return sales.reduce((prev, sale) => prev + (getTotalQtityFreeOnSale(sale)), 0);
31
+ };
32
+ export const getTotalAmountWithoutTvaOnBill = (sales) => {
33
+ return sales.reduce((prev, sale) => prev + (+getTotalAmountWithoutTvaOnSale(sale, true)), 0);
34
+ };
35
+ export const getTotalAmountWithoutTvaBackOnBill = (sales) => {
36
+ return sales.reduce((prev, sale) => prev + (+getTotalAmountWithoutTvaBackOnSale(sale)), 0);
37
+ };
38
+ export const getTotalAmountAllIncludedOnBill = (sales) => {
39
+ return sales.reduce((prev, sale) => prev + (+getTotalAmountAllIncludedOnSale(sale, true)), 0);
40
+ };
41
+ export const getTotalAmountTvaOnBill = (sales) => {
42
+ return sales.reduce((prev, sale) => prev + (+getTotalTvaOnSale(sale, true)), 0);
43
+ };
44
+ export const getTotalAmountTvaBackOnBill = (sales) => {
45
+ return sales.reduce((prev, sale) => prev + (+getTotalTvaBackOnSale(sale)), 0);
46
+ };
47
+ export const getTotalAmountOnListBill = (bills) => {
48
+ return bills.reduce((prev, curr) => prev + (+curr.totalAmount), 0);
49
+ };
50
+ export const getTotalAmountTvaOnListBill = (bills) => {
51
+ return bills.reduce((prev, curr) => prev + (+getTotalAmountTvaOnBill(curr.sales)), 0);
52
+ };
53
+ export const getTotalAmountWithoutTvaOnListBill = (bills) => {
54
+ return bills.reduce((prev, curr) => prev + (+getTotalAmountWithoutTvaOnBill(curr.sales)), 0);
55
+ };
56
+ export const getTotalDueAmountOnListBill = (bills) => {
57
+ return bills.reduce((prev, curr) => prev + (+curr.dueAmount), 0);
58
+ };
@@ -0,0 +1,21 @@
1
+ import { Sale } from "../../models/Sale";
2
+ export interface Bill {
3
+ id?: number;
4
+ createdAt?: Date;
5
+ ref?: string;
6
+ totalAmount?: number;
7
+ isPaid?: boolean;
8
+ isPartialPaid?: boolean;
9
+ paidDate?: Date;
10
+ dueAmount?: number;
11
+ escompteAmount?: number;
12
+ totalAmountAllIncluded?: number;
13
+ hasTva?: boolean;
14
+ isBack?: boolean;
15
+ fromCron?: boolean;
16
+ nbPrint?: number;
17
+ type?: 'sale' | 'avoir';
18
+ store?: string;
19
+ sales?: Sale[];
20
+ nbrePayment?: number;
21
+ }
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,6 @@
1
+ export interface Gender {
2
+ id: number;
3
+ name: string;
4
+ avatar: string;
5
+ abr: string;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ import { SaleProduct } from "./SaleProduct";
2
+ import { User } from "./User";
3
+ export interface Sale {
4
+ id: number;
5
+ ref?: string;
6
+ createdAt?: any;
7
+ saleDate?: any;
8
+ deliveryDate?: Date;
9
+ shippingDate?: Date;
10
+ shippingFee?: number;
11
+ otherFee?: number;
12
+ nbPrint?: number;
13
+ discountRate?: number;
14
+ status?: number;
15
+ isValided?: boolean;
16
+ isProforma?: boolean;
17
+ proformaToSale?: boolean;
18
+ hasBack?: boolean;
19
+ isBack?: boolean;
20
+ isWaiting?: boolean;
21
+ waitingToSale?: boolean;
22
+ backChoice?: string;
23
+ nbPackages?: number;
24
+ nbFreeze?: number;
25
+ isProcessing?: boolean;
26
+ isProcessed?: boolean;
27
+ isOnProcessed?: boolean;
28
+ isDelivering?: boolean;
29
+ isPicking?: boolean;
30
+ isDelivered?: boolean;
31
+ rejectedReason?: string;
32
+ saleProducts?: SaleProduct[];
33
+ client?: User;
34
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { Product } from '../products/interfaces/Product';
2
+ export declare class SaleProduct {
3
+ id: number;
4
+ qtityFund?: number;
5
+ qtityOdr?: number;
6
+ qtityDlvr?: number;
7
+ qtityFree?: number;
8
+ qtityBack?: number;
9
+ publicPrice?: number;
10
+ unitPrice?: number;
11
+ speUnitPrice?: number;
12
+ pghtPrice?: number;
13
+ promo?: number;
14
+ tva?: number;
15
+ isBack?: boolean;
16
+ hasBack?: boolean;
17
+ product?: Product;
18
+ }
@@ -0,0 +1,2 @@
1
+ export class SaleProduct {
2
+ }
@@ -0,0 +1,8 @@
1
+ import { SteGrp } from './SteGrp';
2
+ export interface Ste {
3
+ id: number;
4
+ name: string;
5
+ isValided?: boolean;
6
+ isActive?: boolean;
7
+ grp?: SteGrp;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export interface SteGrp {
2
+ id: number;
3
+ name: string;
4
+ code?: string;
5
+ shortname: string;
6
+ coef?: number;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export interface Titr {
2
+ id: number;
3
+ name: string;
4
+ shortname: string;
5
+ }