asv-hlps-market 1.0.6 → 1.0.8

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 (156) 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/buys/models/Buy.d.ts +3 -2
  5. package/lib/cjs/index.d.ts +12 -2
  6. package/lib/cjs/index.js +14 -2
  7. package/lib/cjs/markets/index.d.ts +1 -0
  8. package/lib/cjs/{shops → markets}/index.js +1 -1
  9. package/lib/cjs/{models → markets/models}/Market.d.ts +2 -1
  10. package/lib/{esm → cjs/markets}/models/UMarket.d.ts +2 -2
  11. package/lib/cjs/models/Gender.d.ts +6 -0
  12. package/lib/cjs/models/Gender.js +2 -0
  13. package/lib/cjs/models/Sale.d.ts +34 -0
  14. package/lib/cjs/models/Sale.js +2 -0
  15. package/lib/cjs/models/SaleProduct.d.ts +18 -0
  16. package/lib/cjs/models/SaleProduct.js +6 -0
  17. package/lib/cjs/models/Ste.d.ts +8 -0
  18. package/lib/cjs/models/Ste.js +2 -0
  19. package/lib/cjs/models/SteGrp.d.ts +7 -0
  20. package/lib/cjs/models/SteGrp.js +2 -0
  21. package/lib/cjs/models/Titr.d.ts +5 -0
  22. package/lib/cjs/models/Titr.js +2 -0
  23. package/lib/cjs/models/User.d.ts +38 -0
  24. package/lib/cjs/models/User.js +2 -0
  25. package/lib/cjs/models/UserGrp.d.ts +4 -0
  26. package/lib/cjs/models/UserGrp.js +2 -0
  27. package/lib/cjs/models/UserRole.d.ts +5 -0
  28. package/lib/cjs/models/UserRole.js +2 -0
  29. package/lib/cjs/models/shared/NaAc.d.ts +6 -0
  30. package/lib/cjs/models/shared/NaAc.js +2 -0
  31. package/lib/cjs/models/shared/NaCoAc.d.ts +4 -0
  32. package/lib/cjs/models/shared/NaCoAc.js +2 -0
  33. package/lib/cjs/models/shared/NaCoShortAc.d.ts +4 -0
  34. package/lib/cjs/models/shared/NaCoShortAc.js +2 -0
  35. package/lib/cjs/pdfs/invoices/amountInvoice.d.ts +66 -0
  36. package/lib/cjs/pdfs/invoices/amountInvoice.js +144 -0
  37. package/lib/cjs/pdfs/invoices/infoInvoice.d.ts +32 -0
  38. package/lib/cjs/pdfs/invoices/infoInvoice.js +80 -0
  39. package/lib/cjs/pdfs/tools/tools.d.ts +34 -0
  40. package/lib/cjs/pdfs/tools/tools.js +53 -0
  41. package/lib/cjs/products/hlpProduct.d.ts +1 -2
  42. package/lib/cjs/products/hlpProduct.js +7 -16
  43. package/lib/cjs/products/interfaces/Product.d.ts +53 -0
  44. package/lib/cjs/products/interfaces/Product.js +2 -0
  45. package/lib/cjs/products/interfaces/ProductCat.d.ts +6 -0
  46. package/lib/cjs/products/interfaces/ProductCat.js +2 -0
  47. package/lib/cjs/products/interfaces/ProductStore.d.ts +24 -0
  48. package/lib/cjs/products/interfaces/ProductStore.js +2 -0
  49. package/lib/cjs/products/models/Product.d.ts +5 -5
  50. package/lib/cjs/products/product.d.ts +3 -0
  51. package/lib/cjs/products/product.js +22 -0
  52. package/lib/cjs/sales/models/SaleItems.d.ts +2 -2
  53. package/lib/cjs/sales/models/SalePayment.d.ts +2 -1
  54. package/lib/cjs/sales/sale.d.ts +18 -0
  55. package/lib/cjs/sales/sale.js +129 -0
  56. package/lib/cjs/shared/CartItem.js +0 -1
  57. package/lib/cjs/shops/models/CartItem.d.ts +6 -0
  58. package/lib/cjs/shops/models/CartItem.js +2 -0
  59. package/lib/cjs/shops/models/Shop.d.ts +1 -1
  60. package/lib/cjs/shops/models/index.d.ts +2 -0
  61. package/lib/cjs/shops/models/index.js +18 -0
  62. package/lib/cjs/users/index.d.ts +1 -0
  63. package/lib/cjs/users/index.js +17 -0
  64. package/lib/cjs/users/models/User.d.ts +1 -1
  65. package/lib/cjs/users/models/index.d.ts +1 -0
  66. package/lib/cjs/users/models/index.js +17 -0
  67. package/lib/esm/bills/bill.d.ts +19 -0
  68. package/lib/esm/bills/bill.js +58 -0
  69. package/lib/esm/bills/models/Bill.d.ts +21 -0
  70. package/lib/esm/buys/models/Buy.d.ts +3 -2
  71. package/lib/esm/index.d.ts +12 -2
  72. package/lib/esm/index.js +14 -2
  73. package/lib/esm/markets/index.d.ts +1 -0
  74. package/lib/esm/markets/index.js +1 -0
  75. package/lib/esm/{models → markets/models}/Market.d.ts +2 -1
  76. package/lib/{cjs → esm/markets}/models/UMarket.d.ts +2 -2
  77. package/lib/esm/models/Gender.d.ts +6 -0
  78. package/lib/esm/models/Gender.js +1 -0
  79. package/lib/esm/models/Sale.d.ts +34 -0
  80. package/lib/esm/models/Sale.js +1 -0
  81. package/lib/esm/models/SaleProduct.d.ts +18 -0
  82. package/lib/esm/models/SaleProduct.js +2 -0
  83. package/lib/esm/models/Ste.d.ts +8 -0
  84. package/lib/esm/models/Ste.js +1 -0
  85. package/lib/esm/models/SteGrp.d.ts +7 -0
  86. package/lib/esm/models/SteGrp.js +1 -0
  87. package/lib/esm/models/Titr.d.ts +5 -0
  88. package/lib/esm/models/Titr.js +1 -0
  89. package/lib/esm/models/User.d.ts +38 -0
  90. package/lib/esm/models/User.js +1 -0
  91. package/lib/esm/models/UserGrp.d.ts +4 -0
  92. package/lib/esm/models/UserGrp.js +1 -0
  93. package/lib/esm/models/UserRole.d.ts +5 -0
  94. package/lib/esm/models/UserRole.js +1 -0
  95. package/lib/esm/models/shared/NaAc.d.ts +6 -0
  96. package/lib/esm/models/shared/NaAc.js +1 -0
  97. package/lib/esm/models/shared/NaCoAc.d.ts +4 -0
  98. package/lib/esm/models/shared/NaCoAc.js +1 -0
  99. package/lib/esm/models/shared/NaCoShortAc.d.ts +4 -0
  100. package/lib/esm/models/shared/NaCoShortAc.js +1 -0
  101. package/lib/esm/pdfs/invoices/amountInvoice.d.ts +66 -0
  102. package/lib/esm/pdfs/invoices/amountInvoice.js +137 -0
  103. package/lib/esm/pdfs/invoices/infoInvoice.d.ts +26 -0
  104. package/lib/esm/pdfs/invoices/infoInvoice.js +75 -0
  105. package/lib/esm/pdfs/tools/tools.d.ts +34 -0
  106. package/lib/esm/pdfs/tools/tools.js +47 -0
  107. package/lib/esm/products/hlpProduct.d.ts +1 -2
  108. package/lib/esm/products/hlpProduct.js +7 -16
  109. package/lib/esm/products/interfaces/Product.d.ts +53 -0
  110. package/lib/esm/products/interfaces/Product.js +1 -0
  111. package/lib/esm/products/interfaces/ProductCat.d.ts +6 -0
  112. package/lib/esm/products/interfaces/ProductCat.js +1 -0
  113. package/lib/esm/products/interfaces/ProductStore.d.ts +24 -0
  114. package/lib/esm/products/interfaces/ProductStore.js +1 -0
  115. package/lib/esm/products/models/Product.d.ts +5 -5
  116. package/lib/esm/products/product.d.ts +3 -0
  117. package/lib/esm/products/product.js +17 -0
  118. package/lib/esm/sales/models/SaleItems.d.ts +2 -2
  119. package/lib/esm/sales/models/SalePayment.d.ts +2 -1
  120. package/lib/esm/sales/sale.d.ts +18 -0
  121. package/lib/esm/sales/sale.js +109 -0
  122. package/lib/esm/shared/CartItem.js +0 -1
  123. package/lib/esm/shops/models/CartItem.d.ts +6 -0
  124. package/lib/esm/shops/models/CartItem.js +1 -0
  125. package/lib/esm/shops/models/Shop.d.ts +1 -1
  126. package/lib/esm/shops/models/index.d.ts +2 -0
  127. package/lib/esm/shops/models/index.js +2 -0
  128. package/lib/esm/users/index.d.ts +1 -0
  129. package/lib/esm/users/index.js +1 -0
  130. package/lib/esm/users/models/User.d.ts +1 -1
  131. package/lib/esm/users/models/index.d.ts +1 -0
  132. package/lib/esm/users/models/index.js +1 -0
  133. package/package.json +4 -4
  134. package/lib/cjs/pos/CartProduct.d.ts +0 -6
  135. package/lib/cjs/pos/hlpShop.d.ts +0 -37
  136. package/lib/cjs/pos/hlpShop.js +0 -216
  137. package/lib/cjs/pos/index.d.ts +0 -1
  138. package/lib/cjs/pos/index.js +0 -8
  139. package/lib/cjs/shops/index.d.ts +0 -1
  140. package/lib/esm/pos/CartProduct.d.ts +0 -6
  141. package/lib/esm/pos/hlpShop.d.ts +0 -37
  142. package/lib/esm/pos/hlpShop.js +0 -210
  143. package/lib/esm/pos/index.d.ts +0 -1
  144. package/lib/esm/pos/index.js +0 -1
  145. package/lib/esm/shops/index.d.ts +0 -1
  146. package/lib/esm/shops/index.js +0 -1
  147. /package/lib/cjs/{models/Market.js → bills/models/Bill.js} +0 -0
  148. /package/lib/cjs/{models/UMarket.js → markets/models/Market.js} +0 -0
  149. /package/lib/cjs/{pos/CartProduct.js → markets/models/UMarket.js} +0 -0
  150. /package/lib/cjs/{models → markets/models}/index.d.ts +0 -0
  151. /package/lib/cjs/{models → markets/models}/index.js +0 -0
  152. /package/lib/esm/{models/Market.js → bills/models/Bill.js} +0 -0
  153. /package/lib/esm/{models/UMarket.js → markets/models/Market.js} +0 -0
  154. /package/lib/esm/{pos/CartProduct.js → markets/models/UMarket.js} +0 -0
  155. /package/lib/esm/{models → markets/models}/index.d.ts +0 -0
  156. /package/lib/esm/{models → markets/models}/index.js +0 -0
@@ -0,0 +1,75 @@
1
+ import { convertEnDateToFr } from 'asv-hlps';
2
+ import { getNbFreezeOnBill, getNbPackagesOnBill, getNbProductsOnBill, getTotalQtityOnBill } from '../../bills/bill';
3
+ import { getNbProductsOnSale, getTotalQtityOnSale } from '../../sales/sale';
4
+ export const infoSale = (tob) => {
5
+ const totalQtity = getTotalQtityOnSale(tob);
6
+ const nbProducts = getNbProductsOnSale(tob);
7
+ const nbColis = tob.nbPackages;
8
+ const nbFreeze = tob.nbFreeze;
9
+ // const oWidth = [ '*', '*', 75, 75, 75, 75];
10
+ const tabTop = {
11
+ width: '50%',
12
+ table: {
13
+ headerRows: 1,
14
+ widths: ['*', '*', 75, 75, 75, 75],
15
+ heights: [6],
16
+ body: [
17
+ [
18
+ { text: 'FACTURE N°', style: 'headerText' },
19
+ { text: 'DATE', style: 'headerText' },
20
+ { text: 'NBRE DE PDTS', style: 'headerText' },
21
+ { text: 'QUANTITE TOTALE', style: 'headerText' },
22
+ { text: 'NBRE COLIS', style: 'headerText' },
23
+ { text: 'NBRE FROID', style: 'headerText' }
24
+ ],
25
+ [
26
+ { text: tob.ref, style: 'rowText' },
27
+ // { text: moment(tob.createdAt ).format('DD/MM/YYYY'), style: 'rowText'},
28
+ { text: convertEnDateToFr(tob.createdAt, '/'), style: 'rowText' },
29
+ { text: nbProducts, style: 'rowText' },
30
+ { text: totalQtity, style: 'rowText' },
31
+ { text: nbColis, style: 'rowText' },
32
+ { text: nbFreeze, style: 'rowText' },
33
+ ]
34
+ ]
35
+ }
36
+ };
37
+ return tabTop;
38
+ };
39
+ export const infoBill = (tob) => {
40
+ const totalQtity = getTotalQtityOnBill(tob.sales);
41
+ const nbProducts = getNbProductsOnBill(tob.sales);
42
+ const nbColis = getNbPackagesOnBill(tob.sales);
43
+ const nbFreeze = getNbFreezeOnBill(tob.sales);
44
+ const oWidth = ['*', '*', 75, 75, 75, 75];
45
+ const tabTop = {
46
+ width: '50%',
47
+ table: {
48
+ headerRows: 1,
49
+ // widths: [ 125, 125, 125, '*' ],
50
+ widths: oWidth,
51
+ heights: [6],
52
+ // widths: [ '16%', '16%', '16%', '16%' ],
53
+ body: [
54
+ [
55
+ { text: 'FACTURE N°', style: 'headerText' },
56
+ { text: 'DATE', style: 'headerText' },
57
+ { text: 'NBRE DE PDTS', style: 'headerText' },
58
+ { text: 'QUANTITE TOTALE', style: 'headerText' },
59
+ { text: 'NBRE COLIS', style: 'headerText' },
60
+ { text: 'NBRE FROID', style: 'headerText' }
61
+ ],
62
+ [
63
+ { text: tob.ref, style: 'rowText' },
64
+ // { text: moment(tob.createdAt ).format('DD/MM/YYYY'), style: 'rowText'},
65
+ { text: convertEnDateToFr(tob.createdAt, '/'), style: 'rowText' },
66
+ { text: nbProducts, style: 'rowText' },
67
+ { text: totalQtity, style: 'rowText' },
68
+ { text: nbColis, style: 'rowText' },
69
+ { text: nbFreeze, style: 'rowText' },
70
+ ]
71
+ ]
72
+ }
73
+ };
74
+ return tabTop;
75
+ };
@@ -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,47 @@
1
+ import { convertEnDateToFr, formatDateYmdHypen, getSteShortname } from "asv-hlps";
2
+ export const displayPdfDate = (label, fromDate, toDate) => {
3
+ fromDate = (!fromDate) ? formatDateYmdHypen(new Date()) : fromDate;
4
+ toDate = (!toDate) ? fromDate : toDate;
5
+ return label + ' du ' + convertEnDateToFr(fromDate) + ' au ' + convertEnDateToFr(toDate);
6
+ };
7
+ export const displayTitle = (title) => {
8
+ return {
9
+ width: '100%',
10
+ alignment: 'center',
11
+ text: title,
12
+ bold: true,
13
+ margin: [0, 10, 0, 10],
14
+ fontSize: 15,
15
+ };
16
+ };
17
+ export const displayClient = (user) => {
18
+ // const clientSte = user.ste ? HlpUser.getSteShortname(user.ste) : '';
19
+ const clientSte = user.ste ? getSteShortname(user.ste, ['pharmacie', 'clinique', 'hopital']) : '';
20
+ /* const clientLastname = (user.lastname) ? user.lastname : '';
21
+ const clientFirstname = (user.firstname) ? user.firstname : '';
22
+ const clientGender = (user.gender) ? user.gender.abr : ''; */
23
+ const clientName = user.ste ? clientSte : user.fullname;
24
+ const cp = user.cp ? user.cp : '';
25
+ const city = user.city ? user.city : '';
26
+ const nif = user.ste.nif ? user.ste.nif : '';
27
+ const address = user.address ? user.address : '';
28
+ const client = {
29
+ absolutePosition: { x: 310, y: 30 },
30
+ text: [
31
+ { text: 'CLIENT: ', fontSize: 8 },
32
+ { text: user.username + '\n', bold: true, fontSize: 10 },
33
+ { text: clientName + '\n' },
34
+ { text: address + ' ' },
35
+ { text: cp + '\n' },
36
+ { text: city + '\n' },
37
+ // {text: nif + '\n'}
38
+ ],
39
+ color: '#000',
40
+ width: 'auto',
41
+ fontSize: 12,
42
+ bold: true,
43
+ alignment: 'left',
44
+ // margin: [100, 0, 0, 0],
45
+ };
46
+ return client;
47
+ };
@@ -1,13 +1,12 @@
1
1
  import Product from "./models/Product";
2
2
  import ProductStock from "./models/ProductStock";
3
3
  declare class HlpProduct {
4
+ stock: (product: Product, param: "salable" | "packs" | "units") => number;
4
5
  qtityInAllDepots(stock: ProductStock, prms?: {
5
6
  exceptDepots?: string[];
6
7
  main?: "master" | "slave";
7
8
  }): number;
8
9
  getStockSalable(product: Product): number;
9
- stock: (product: Product, param: "salable" | "packs" | "units") => number;
10
- extraFiilters: (row: Product) => string;
11
10
  }
12
11
  declare const _default: HlpProduct;
13
12
  export default _default;
@@ -15,31 +15,22 @@ class HlpProduct {
15
15
  return salable;
16
16
  }
17
17
  };
18
- this.extraFiilters = (row) => row.designation; /* +
19
- row.codeCompta +
20
- (row.tva > 0 ? "@tva" : "") +
21
- (row.isAvailable ? "@dispo" : "") +
22
- (!row.isAvailable ? "@indispo" : "") +
23
- (row.isActive ? "@actif" : "") +
24
- (!row.isActive ? "@inactif" : "") +
25
- (row.isPrivate ? "@private" : "") +
26
- (!row.isPrivate ? "@noprivate" : ""); */
27
18
  }
28
19
  qtityInAllDepots(stock, prms) {
29
20
  const ins = stock.sumIns - stock.sumOuts;
30
21
  return ins <= 0 ? 0 : ins;
31
22
  }
32
23
  getStockSalable(product) {
33
- const stockAllSalable = +this.qtityInAllDepots(product.stock);
24
+ const stockAllSalable = this.qtityInAllDepots(product.stock);
34
25
  const stockProduct = Math.trunc(stockAllSalable / product.qtityUnit);
35
26
  /* let stockSalable: number = 0;
36
27
 
37
- if (stockAllSalable <= stockStore) {
38
- stockSalable = stockAllSalable;
39
- }
40
- if (stockAllSalable > stockStore) {
41
- stockSalable = stockStore;
42
- } */
28
+ if (stockAllSalable <= stockStore) {
29
+ stockSalable = stockAllSalable;
30
+ }
31
+ if (stockAllSalable > stockStore) {
32
+ stockSalable = stockStore;
33
+ } */
43
34
  // return stockSalable || 0;
44
35
  return stockProduct || 0;
45
36
  }
@@ -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 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export interface ProductCat {
2
+ id: number;
3
+ name: string;
4
+ code: string;
5
+ isActive: boolean;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -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 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { Market } from "../../models/Market";
1
+ import Market from "../../markets/models/Market";
2
2
  import { Shop } from "../../shops/models/Shop";
3
3
  import ProductCat from "./ProductCat";
4
4
  import ProductImage from "./ProductImage";
@@ -9,6 +9,7 @@ interface Stock {
9
9
  qtityPerPackaging: number;
10
10
  }
11
11
  export default interface Product {
12
+ id: number;
12
13
  capacity: string;
13
14
  cat: ProductCat;
14
15
  createdAt: Date;
@@ -17,7 +18,6 @@ export default interface Product {
17
18
  disabled?: boolean;
18
19
  iconName: string;
19
20
  iconPack: string;
20
- id: number;
21
21
  images: ProductImage[];
22
22
  ins: ProductIn[];
23
23
  isActive: boolean;
@@ -27,14 +27,14 @@ export default interface Product {
27
27
  price: number;
28
28
  publicPrice: number;
29
29
  qtityLimit: number;
30
- qtityUnit: number;
31
- stock: Stock;
32
30
  qtityPerBox: number;
33
31
  qtityPerPackaging: number;
32
+ qtityUnit: number;
34
33
  ref: string;
35
34
  salePrice: number;
36
35
  shop: Shop;
37
- updatedAt: Date;
38
36
  specialPrice?: number;
37
+ stock: Stock;
38
+ updatedAt: Date;
39
39
  }
40
40
  export {};
@@ -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,17 @@
1
+ import { calculPercent, userCoef } from "asv-hlps";
2
+ export const unitPriceByClientCat = (product, client, speUnitPrice = 0, addDiscount = false) => {
3
+ if (speUnitPrice > 0) {
4
+ return speUnitPrice;
5
+ }
6
+ // const store = await getCustomRepository(ProductStoreRepository).getOneStoreByParams({storeName: 'cpa', productId: product.id})
7
+ if (product.stores[0].discountRate && addDiscount) {
8
+ return Math.ceil(product.stores[0].salePrice) - Math.ceil(calculPercent(product.stores[0].salePrice, product.stores[0].discountRate));
9
+ }
10
+ const clientCoef = (!client) ? 1 : userCoef(client);
11
+ return (productCatCode(product, ['spe', 'para'])) ?
12
+ Math.ceil(product.stores[0].salePrice) :
13
+ Math.ceil(product.stores[0].salePrice * clientCoef);
14
+ };
15
+ export const productCatCode = (product, catCodes) => {
16
+ return catCodes.includes(product.cat.code && product.cat.code.toLowerCase());
17
+ };
@@ -1,8 +1,8 @@
1
- import CartProduct from "../../pos/CartProduct";
1
+ import CartItem from "../../shops/models/CartItem";
2
2
  import Sale from "./Sale";
3
3
  export default interface SaleItems {
4
4
  sale?: Sale;
5
- items?: CartProduct[];
5
+ items?: CartItem[];
6
6
  clientId?: number;
7
7
  fromMobile?: boolean;
8
8
  isWaiting?: boolean;
@@ -1,4 +1,5 @@
1
- import { Bank, BankAccount, PaymentMode } from "asv-hlps/lib/cjs/cashs";
1
+ import { Bank, BankAccount } from "asv-hlps/lib/cjs/cashs";
2
+ import PaymentMode from "asv-hlps/lib/cjs/cashs/models/PaymentMode";
2
3
  import User from "../../users/models/User";
3
4
  import Sale from "./Sale";
4
5
  export default interface SalePayment {
@@ -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,109 @@
1
+ import { convertEnDateToFr, formatToStringCfa, labelSteName } 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
+ console.log('------ cuurr ------');
9
+ console.log(curr);
10
+ console.log('------ cuurr ------');
11
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
12
+ return !dlvr
13
+ ? Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityOdr)
14
+ : Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityDlvr);
15
+ }, 0);
16
+ };
17
+ export const getSubTotalAmountOnSale = (sale, dlvr = false) => {
18
+ return sale.saleProducts.reduce((prev, curr) => {
19
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
20
+ return !dlvr ? Math.ceil(prev + unitPrice * +curr.qtityOdr) : Math.ceil(prev + unitPrice * +curr.qtityDlvr);
21
+ }, 0);
22
+ };
23
+ export const getSubTotalAmountBackOnSale = (sale) => {
24
+ return sale.saleProducts.reduce((prev, curr) => {
25
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
26
+ return Math.ceil(prev + unitPrice * +curr.qtityBack);
27
+ }, 0);
28
+ };
29
+ export const getTotalAmountWithoutTvaOnSale = (sale, dlvr = false) => {
30
+ return sale.saleProducts.reduce((prev, curr) => {
31
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
32
+ return !dlvr ? Math.ceil(prev + unitPrice * +curr.qtityOdr) : Math.ceil(prev + unitPrice * +curr.qtityDlvr);
33
+ }, 0);
34
+ };
35
+ export const getTotalAmountWithoutTvaBackOnSale = (sale) => {
36
+ return sale.saleProducts.reduce((prev, curr) => {
37
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
38
+ return Math.ceil(prev + unitPrice * +curr.qtityBack);
39
+ }, 0);
40
+ };
41
+ export const getTotalTvaOnSaleOnSale = (sale, dlvr = false) => {
42
+ return sale.saleProducts.reduce((prev, curr) => {
43
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
44
+ return !dlvr
45
+ ? Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityOdr)
46
+ : Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityDlvr);
47
+ }, 0);
48
+ };
49
+ export const getTotalTvaBackOnSale = (sale) => {
50
+ return sale.saleProducts.reduce((prev, curr) => {
51
+ const unitPrice = curr.unitPrice > 0 ? curr.unitPrice : unitPriceByClientCat(curr.product, sale.client, curr.speUnitPrice);
52
+ return Math.ceil(prev + unitPrice * (+curr.product.tva / 100) * +curr.qtityBack);
53
+ }, 0);
54
+ };
55
+ export const getTotalAmountOnSale = (sale, dlvr = false) => {
56
+ return getTotalAmountWithoutTvaOnSale(sale, dlvr) + getTotalTvaOnSale(sale, dlvr);
57
+ };
58
+ export const getTotalAmountBackOnSale = (sale) => {
59
+ return getTotalAmountWithoutTvaBackOnSale(sale) + getTotalTvaBackOnSale(sale);
60
+ };
61
+ export const getTotalAmountAllIncludedOnSale = (sale, dlvr = false) => {
62
+ return getTotalAmountOnSale(sale, dlvr) + getTotalShippingOnSale(sale) - getTotalAmountDiscountOnSale(sale, dlvr) || 0;
63
+ };
64
+ // export const getTotalShippingOnSale = (shippingFee: number , otherFee: number = 0) => {
65
+ export const getTotalShippingOnSale = (sale) => {
66
+ return (+sale.shippingFee || 0) + (+sale.otherFee || 0);
67
+ };
68
+ export const getTotalAmountDiscountOnSale = (sale, dlvr = false) => {
69
+ return getTotalAmountOnSale(sale, dlvr) * (+sale.discountRate / 100 || 0);
70
+ };
71
+ export const getTotalQtityOnSale = (sale, dlvr = false) => {
72
+ return sale.saleProducts.reduce((prev, curr) => {
73
+ return !dlvr
74
+ ? Math.ceil(prev + (+curr.qtityOdr + (+curr.qtityFree || 0)))
75
+ : Math.ceil(prev + (+curr.qtityDlvr + (+curr.qtityFree || 0)));
76
+ }, 0);
77
+ };
78
+ export const getTotalQtityFreeOnSale = (sale) => {
79
+ return sale.saleProducts.reduce((prev, curr) => {
80
+ return Math.ceil(prev + (+curr.qtityFree || 0));
81
+ }, 0);
82
+ };
83
+ export const getTotalQtityOdrOrDlvrOnSale = (sale, dlvr = false) => {
84
+ return sale.saleProducts.reduce((prev, curr) => {
85
+ return !dlvr ? Math.ceil(prev + (+curr.qtityOdr || 0)) : Math.ceil(prev + (+curr.qtityDlvr || 0));
86
+ }, 0);
87
+ };
88
+ export const tabLabel = (sale) => {
89
+ const labels = [];
90
+ for (const sp of sale.saleProducts) {
91
+ for (let j = 0; j < (+sp.qtityDlvr + +sp.qtityFree); j++) {
92
+ const name = labelSteName(sale.client.ste);
93
+ const product = sp.product.designation;
94
+ const pp = formatToStringCfa(Math.ceil(sp.publicPrice));
95
+ const saleDate = convertEnDateToFr(sale.saleDate, '/');
96
+ // const saleDate = formatDateYmd(sale.saleDate, '/');
97
+ // const saleDate = moment(sale.saleDate ).format('DD/MM/YYYY');
98
+ labels.push({ name, product, pp, saleDate });
99
+ }
100
+ }
101
+ const tabLen = labels.length;
102
+ const modulo = tabLen % 5;
103
+ if (modulo !== 0) {
104
+ for (let i = 0; i < (5 - +modulo); i++) {
105
+ labels.push({ name: 'L\' OEIL DE DIEU', product: 'est votre meilleur ami', pp: ' ', saleDate: ' ' });
106
+ }
107
+ }
108
+ return labels;
109
+ };
@@ -1,3 +1,2 @@
1
- // export default interface CartItem {
2
1
  export default class CartItem {
3
2
  }
@@ -0,0 +1,6 @@
1
+ import Product from "../../products/models/Product";
2
+ import BaseCartItem from "../../shared/CartItem";
3
+ export default interface CartItem extends BaseCartItem {
4
+ product: Product;
5
+ specialPrice?: number;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import UMarket from "../../models/UMarket";
1
+ import UMarket from "../../markets/models/UMarket";
2
2
  import Product from "../../products/models/Product";
3
3
  export interface Shop {
4
4
  id: number;
@@ -0,0 +1,2 @@
1
+ export * from "./Shop";
2
+ export * from "./CartItem";
@@ -0,0 +1,2 @@
1
+ export * from "./Shop";
2
+ export * from "./CartItem";
@@ -0,0 +1 @@
1
+ export * from "./models";
@@ -0,0 +1 @@
1
+ export * from "./models";
@@ -1,5 +1,5 @@
1
1
  import UserBase from "asv-hlps/lib/cjs/users/models/UserBase";
2
- import UMarket from "../../models/UMarket";
2
+ import UMarket from "../../markets/models/UMarket";
3
3
  export default interface User extends UserBase {
4
4
  markets?: UMarket[];
5
5
  wallets?: any;
@@ -0,0 +1 @@
1
+ export * from "./User";
@@ -0,0 +1 @@
1
+ export * from "./User";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "asv-hlps-market",
3
- "version": "1.0.6",
4
- "description": "helpers for markets app",
3
+ "version": "1.0.8",
4
+ "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
7
7
  "files": [
@@ -16,9 +16,9 @@
16
16
  "author": "Aril Vignon",
17
17
  "license": "ISC",
18
18
  "devDependencies": {
19
- "typescript": "^5.7.3"
19
+ "typescript": "^4.6.3"
20
20
  },
21
21
  "dependencies": {
22
- "asv-hlps": "^1.4.9"
22
+ "asv-hlps": "^1.4.11"
23
23
  }
24
24
  }
@@ -1,6 +0,0 @@
1
- import Product from "../products/models/Product";
2
- import CartItem from "../shared/CartItem";
3
- export default interface CartProduct extends CartItem {
4
- product: Product;
5
- specialPrice?: number;
6
- }
@@ -1,37 +0,0 @@
1
- import Product from "../products/models/Product";
2
- import Sale from "../sales/models/Sale";
3
- import User from "../users/models/User";
4
- import CartProduct from "./CartProduct";
5
- declare class SaleItems {
6
- sale?: Sale;
7
- items?: CartProduct[];
8
- clientId?: number;
9
- isWaiting?: boolean;
10
- inCredit?: boolean;
11
- }
12
- export default class HlpShop {
13
- private httpService;
14
- constructor(httpService: any);
15
- isProductInCart(item: CartProduct, product: Product): true;
16
- addToCart: (cartProducts: CartProduct[], product: Product, qtity: number) => Promise<CartProduct[]>;
17
- removeItem: (cartProducts: CartProduct[], product: Product) => void;
18
- removeFromCart: (cartProducts: CartProduct[], item: CartProduct) => void;
19
- getTotalAmount: (cartProducts: CartProduct[], client: User) => number;
20
- getTotalAmountAllIncluded: (cartProducts: CartProduct[], client: User, shippingFee?: number, otherFee?: number, discount?: number) => number;
21
- getTotalAmountDiscount: (cartProducts: CartProduct[], client: User, discountRate: number) => number;
22
- getTotalQtityFree: (cartProducts: CartProduct[]) => number;
23
- getTotalQtityReal: (cartProducts: CartProduct[]) => number;
24
- getTotalAmountWithoutTva: (cartProducts: CartProduct[], client: User) => number;
25
- getTotalTva: (cartProducts: CartProduct[], client: User) => number;
26
- updateCartQtity: (cartProducts: CartProduct[], product: Product, qtity: number) => Promise<CartProduct[]>;
27
- addDiscount(cartProducts: CartProduct[], item: CartProduct): void;
28
- getProductPrice: (item: CartProduct) => number;
29
- convertToSale(cartProducts: CartProduct[], sale: Sale): void;
30
- removeAllFromCart(cartProducts: CartProduct[]): void;
31
- checkout(cartProducts: CartProduct[], inCredit?: boolean): Promise<any>;
32
- getSaleItems(): SaleItems;
33
- private createCart;
34
- calculateStockOrQtityLimitCounts: (item: CartProduct) => CartProduct | boolean;
35
- getPublicPrice: (product: Product, client: User, specialPrice?: number, addDiscount?: boolean) => number;
36
- }
37
- export {};