asv-hlps-market 1.0.6 → 1.0.9

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 (166) 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/buys/models/BuyProduct.d.ts +3 -0
  6. package/lib/cjs/index.d.ts +12 -2
  7. package/lib/cjs/index.js +14 -2
  8. package/lib/cjs/markets/index.d.ts +1 -0
  9. package/lib/cjs/{shops → markets}/index.js +1 -1
  10. package/lib/cjs/{models → markets/models}/Market.d.ts +2 -1
  11. package/lib/{esm → cjs/markets}/models/UMarket.d.ts +2 -2
  12. package/lib/cjs/models/Gender.d.ts +6 -0
  13. package/lib/cjs/models/Gender.js +2 -0
  14. package/lib/cjs/models/Sale.d.ts +34 -0
  15. package/lib/cjs/models/Sale.js +2 -0
  16. package/lib/cjs/models/SaleProduct.d.ts +18 -0
  17. package/lib/cjs/models/SaleProduct.js +6 -0
  18. package/lib/cjs/models/Ste.d.ts +8 -0
  19. package/lib/cjs/models/Ste.js +2 -0
  20. package/lib/cjs/models/SteGrp.d.ts +7 -0
  21. package/lib/cjs/models/SteGrp.js +2 -0
  22. package/lib/cjs/models/Titr.d.ts +5 -0
  23. package/lib/cjs/models/Titr.js +2 -0
  24. package/lib/cjs/models/User.d.ts +38 -0
  25. package/lib/cjs/models/User.js +2 -0
  26. package/lib/cjs/models/UserGrp.d.ts +4 -0
  27. package/lib/cjs/models/UserGrp.js +2 -0
  28. package/lib/cjs/models/UserRole.d.ts +5 -0
  29. package/lib/cjs/models/UserRole.js +2 -0
  30. package/lib/cjs/models/shared/NaAc.d.ts +6 -0
  31. package/lib/cjs/models/shared/NaAc.js +2 -0
  32. package/lib/cjs/models/shared/NaCoAc.d.ts +4 -0
  33. package/lib/cjs/models/shared/NaCoAc.js +2 -0
  34. package/lib/cjs/models/shared/NaCoShortAc.d.ts +4 -0
  35. package/lib/cjs/models/shared/NaCoShortAc.js +2 -0
  36. package/lib/cjs/pdfs/invoices/amountInvoice.d.ts +66 -0
  37. package/lib/cjs/pdfs/invoices/amountInvoice.js +144 -0
  38. package/lib/cjs/pdfs/invoices/infoInvoice.d.ts +32 -0
  39. package/lib/cjs/pdfs/invoices/infoInvoice.js +80 -0
  40. package/lib/cjs/pdfs/tools/tools.d.ts +34 -0
  41. package/lib/cjs/pdfs/tools/tools.js +53 -0
  42. package/lib/cjs/products/hlpProduct.d.ts +1 -2
  43. package/lib/cjs/products/hlpProduct.js +7 -16
  44. package/lib/cjs/products/interfaces/Product.d.ts +53 -0
  45. package/lib/cjs/products/interfaces/Product.js +2 -0
  46. package/lib/cjs/products/interfaces/ProductCat.d.ts +6 -0
  47. package/lib/cjs/products/interfaces/ProductCat.js +2 -0
  48. package/lib/cjs/products/interfaces/ProductStore.d.ts +24 -0
  49. package/lib/cjs/products/interfaces/ProductStore.js +2 -0
  50. package/lib/cjs/products/models/Product.d.ts +5 -5
  51. package/lib/cjs/products/product.d.ts +3 -0
  52. package/lib/cjs/products/product.js +22 -0
  53. package/lib/cjs/sales/models/SaleItems.d.ts +2 -2
  54. package/lib/cjs/sales/models/SalePayment.d.ts +2 -1
  55. package/lib/cjs/sales/sale.d.ts +18 -0
  56. package/lib/cjs/sales/sale.js +129 -0
  57. package/lib/cjs/shared/CartItem.js +0 -1
  58. package/lib/cjs/shopping/models/CartItem.d.ts +6 -0
  59. package/lib/cjs/shopping/models/CartItem.js +2 -0
  60. package/lib/cjs/shopping/models/index.d.ts +1 -0
  61. package/lib/cjs/shopping/models/index.js +17 -0
  62. package/lib/cjs/shops/models/CartItem.d.ts +6 -0
  63. package/lib/cjs/shops/models/CartItem.js +2 -0
  64. package/lib/cjs/shops/models/Shop.d.ts +1 -1
  65. package/lib/cjs/shops/models/index.d.ts +1 -0
  66. package/lib/cjs/shops/models/index.js +17 -0
  67. package/lib/cjs/users/index.d.ts +1 -0
  68. package/lib/cjs/users/index.js +17 -0
  69. package/lib/cjs/users/models/User.d.ts +1 -1
  70. package/lib/cjs/users/models/index.d.ts +1 -0
  71. package/lib/cjs/users/models/index.js +17 -0
  72. package/lib/esm/bills/bill.d.ts +19 -0
  73. package/lib/esm/bills/bill.js +58 -0
  74. package/lib/esm/bills/models/Bill.d.ts +21 -0
  75. package/lib/esm/buys/models/Buy.d.ts +3 -2
  76. package/lib/esm/buys/models/BuyProduct.d.ts +3 -0
  77. package/lib/esm/index.d.ts +12 -2
  78. package/lib/esm/index.js +14 -2
  79. package/lib/esm/markets/index.d.ts +1 -0
  80. package/lib/esm/markets/index.js +1 -0
  81. package/lib/esm/{models → markets/models}/Market.d.ts +2 -1
  82. package/lib/{cjs → esm/markets}/models/UMarket.d.ts +2 -2
  83. package/lib/esm/models/Gender.d.ts +6 -0
  84. package/lib/esm/models/Gender.js +1 -0
  85. package/lib/esm/models/Sale.d.ts +34 -0
  86. package/lib/esm/models/Sale.js +1 -0
  87. package/lib/esm/models/SaleProduct.d.ts +18 -0
  88. package/lib/esm/models/SaleProduct.js +2 -0
  89. package/lib/esm/models/Ste.d.ts +8 -0
  90. package/lib/esm/models/Ste.js +1 -0
  91. package/lib/esm/models/SteGrp.d.ts +7 -0
  92. package/lib/esm/models/SteGrp.js +1 -0
  93. package/lib/esm/models/Titr.d.ts +5 -0
  94. package/lib/esm/models/Titr.js +1 -0
  95. package/lib/esm/models/User.d.ts +38 -0
  96. package/lib/esm/models/User.js +1 -0
  97. package/lib/esm/models/UserGrp.d.ts +4 -0
  98. package/lib/esm/models/UserGrp.js +1 -0
  99. package/lib/esm/models/UserRole.d.ts +5 -0
  100. package/lib/esm/models/UserRole.js +1 -0
  101. package/lib/esm/models/shared/NaAc.d.ts +6 -0
  102. package/lib/esm/models/shared/NaAc.js +1 -0
  103. package/lib/esm/models/shared/NaCoAc.d.ts +4 -0
  104. package/lib/esm/models/shared/NaCoAc.js +1 -0
  105. package/lib/esm/models/shared/NaCoShortAc.d.ts +4 -0
  106. package/lib/esm/models/shared/NaCoShortAc.js +1 -0
  107. package/lib/esm/pdfs/invoices/amountInvoice.d.ts +66 -0
  108. package/lib/esm/pdfs/invoices/amountInvoice.js +137 -0
  109. package/lib/esm/pdfs/invoices/infoInvoice.d.ts +26 -0
  110. package/lib/esm/pdfs/invoices/infoInvoice.js +75 -0
  111. package/lib/esm/pdfs/tools/tools.d.ts +34 -0
  112. package/lib/esm/pdfs/tools/tools.js +47 -0
  113. package/lib/esm/products/hlpProduct.d.ts +1 -2
  114. package/lib/esm/products/hlpProduct.js +7 -16
  115. package/lib/esm/products/interfaces/Product.d.ts +53 -0
  116. package/lib/esm/products/interfaces/Product.js +1 -0
  117. package/lib/esm/products/interfaces/ProductCat.d.ts +6 -0
  118. package/lib/esm/products/interfaces/ProductCat.js +1 -0
  119. package/lib/esm/products/interfaces/ProductStore.d.ts +24 -0
  120. package/lib/esm/products/interfaces/ProductStore.js +1 -0
  121. package/lib/esm/products/models/Product.d.ts +5 -5
  122. package/lib/esm/products/product.d.ts +3 -0
  123. package/lib/esm/products/product.js +17 -0
  124. package/lib/esm/sales/models/SaleItems.d.ts +2 -2
  125. package/lib/esm/sales/models/SalePayment.d.ts +2 -1
  126. package/lib/esm/sales/sale.d.ts +18 -0
  127. package/lib/esm/sales/sale.js +109 -0
  128. package/lib/esm/shared/CartItem.js +0 -1
  129. package/lib/esm/shopping/models/CartItem.d.ts +6 -0
  130. package/lib/esm/shopping/models/CartItem.js +1 -0
  131. package/lib/esm/shopping/models/index.d.ts +1 -0
  132. package/lib/esm/shopping/models/index.js +1 -0
  133. package/lib/esm/shops/models/CartItem.d.ts +6 -0
  134. package/lib/esm/shops/models/CartItem.js +1 -0
  135. package/lib/esm/shops/models/Shop.d.ts +1 -1
  136. package/lib/esm/shops/models/index.d.ts +1 -0
  137. package/lib/esm/shops/models/index.js +1 -0
  138. package/lib/esm/users/index.d.ts +1 -0
  139. package/lib/esm/users/index.js +1 -0
  140. package/lib/esm/users/models/User.d.ts +1 -1
  141. package/lib/esm/users/models/index.d.ts +1 -0
  142. package/lib/esm/users/models/index.js +1 -0
  143. package/package.json +4 -4
  144. package/lib/cjs/pos/CartProduct.d.ts +0 -6
  145. package/lib/cjs/pos/hlpShop.d.ts +0 -37
  146. package/lib/cjs/pos/hlpShop.js +0 -216
  147. package/lib/cjs/pos/index.d.ts +0 -1
  148. package/lib/cjs/pos/index.js +0 -8
  149. package/lib/cjs/shops/index.d.ts +0 -1
  150. package/lib/esm/pos/CartProduct.d.ts +0 -6
  151. package/lib/esm/pos/hlpShop.d.ts +0 -37
  152. package/lib/esm/pos/hlpShop.js +0 -210
  153. package/lib/esm/pos/index.d.ts +0 -1
  154. package/lib/esm/pos/index.js +0 -1
  155. package/lib/esm/shops/index.d.ts +0 -1
  156. package/lib/esm/shops/index.js +0 -1
  157. /package/lib/cjs/{models/Market.js → bills/models/Bill.js} +0 -0
  158. /package/lib/cjs/{models/UMarket.js → markets/models/Market.js} +0 -0
  159. /package/lib/cjs/{pos/CartProduct.js → markets/models/UMarket.js} +0 -0
  160. /package/lib/cjs/{models → markets/models}/index.d.ts +0 -0
  161. /package/lib/cjs/{models → markets/models}/index.js +0 -0
  162. /package/lib/esm/{models/Market.js → bills/models/Bill.js} +0 -0
  163. /package/lib/esm/{models/UMarket.js → markets/models/Market.js} +0 -0
  164. /package/lib/esm/{pos/CartProduct.js → markets/models/UMarket.js} +0 -0
  165. /package/lib/esm/{models → markets/models}/index.d.ts +0 -0
  166. /package/lib/esm/{models → markets/models}/index.js +0 -0
@@ -1,210 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import hlpProduct from "../products/hlpProduct";
11
- class SaleItems {
12
- }
13
- export default class HlpShop {
14
- constructor(httpService) {
15
- this.addToCart = (cartProducts, product, qtity) => __awaiter(this, void 0, void 0, function* () {
16
- let nCartProducts = [];
17
- this.createCart(product.shop.id);
18
- const nItem = cartProducts.find((item) => this.isProductInCart(item, product));
19
- if (!nItem) {
20
- nCartProducts = [...cartProducts, { product, qtityOdr: 1 }];
21
- }
22
- else {
23
- nCartProducts = yield this.updateCartQtity(cartProducts, product, qtity);
24
- }
25
- sessionStorage.setItem("basket", JSON.stringify(nCartProducts));
26
- return nCartProducts;
27
- });
28
- this.removeItem = (cartProducts, product) => {
29
- cartProducts.find((item, index) => {
30
- if (item.product.id === product.id) {
31
- const item = cartProducts[index];
32
- this.removeFromCart(cartProducts, item);
33
- }
34
- return false;
35
- });
36
- };
37
- // ------ Removed in cart ------
38
- this.removeFromCart = (cartProducts, item) => {
39
- const index = cartProducts.indexOf(item);
40
- cartProducts.splice(index, 1);
41
- sessionStorage.setItem("basket", JSON.stringify(cartProducts));
42
- };
43
- // --------------------
44
- this.getTotalAmount = (cartProducts, client) => {
45
- return cartProducts.reduce((prev, curr) => {
46
- return Math.ceil(prev /* (this.publicPriceBy(curr.product, client, curr.speUnitPrice, curr.addDiscount) * curr.product.tva) / 100) * curr.qtityOdr + */ +
47
- this.getPublicPrice(curr.product, client, curr.specialPrice, curr.addDiscount) * curr.qtityOdr);
48
- }, 0);
49
- };
50
- // ------ getTotalAmountAllIncluded ------
51
- this.getTotalAmountAllIncluded = (cartProducts, client, shippingFee = 0, otherFee = 0, discount = 0) => {
52
- return Math.ceil(this.getTotalAmount(cartProducts, client) + shippingFee + otherFee + -this.getTotalAmountDiscount(cartProducts, client, discount));
53
- };
54
- this.getTotalAmountDiscount = (cartProducts, client, discountRate) => {
55
- return Math.ceil((+this.getTotalAmount(cartProducts, client) * discountRate) / 100);
56
- };
57
- // ------ total quantity free------
58
- this.getTotalQtityFree = (cartProducts) => {
59
- return cartProducts.reduce((prev, curr) => {
60
- return prev + (+curr.qtityFree || 0);
61
- }, 0);
62
- };
63
- // ------ total quantity ------
64
- this.getTotalQtityReal = (cartProducts) => {
65
- return cartProducts.reduce((prev, curr) => {
66
- return prev + (curr.qtityOdr + (curr.qtityFree || 0));
67
- }, 0);
68
- };
69
- // ------ Total sub amount ------
70
- this.getTotalAmountWithoutTva = (cartProducts, client) => {
71
- return cartProducts.reduce((prev, curr) => {
72
- return Math.ceil(prev + this.getPublicPrice(curr.product, client, curr.specialPrice, curr.addDiscount) * curr.qtityOdr);
73
- }, 0);
74
- };
75
- // ------ Total tva ------
76
- this.getTotalTva = (cartProducts, client) => {
77
- return 0;
78
- /* return cartProducts.reduce((prev: number, curr: CartProduct) => {
79
- return Math.ceil(
80
- prev +
81
- this.unitPriceByClientCatInPhcy(curr.product, client, curr.speUnitPrice, curr.addDiscount) *
82
- (+curr.product.tva / 100) *
83
- curr.qtityOdr
84
- );
85
- }, 0); */
86
- };
87
- // ------ Update Cart Value ------
88
- this.updateCartQtity = (cartProducts, product, qtity) => __awaiter(this, void 0, void 0, function* () {
89
- const index = cartProducts.findIndex((item) => this.isProductInCart(item, product));
90
- cartProducts[index].qtityOdr = qtity;
91
- const qtyInCart = +cartProducts[index].qtityOdr;
92
- const stock = this.calculateStockOrQtityLimitCounts(cartProducts[index]);
93
- // --------------------
94
- if (qtyInCart > 0 && stock) {
95
- cartProducts[index].qtityOdr = qtyInCart;
96
- }
97
- sessionStorage.setItem("basket", JSON.stringify(cartProducts));
98
- return cartProducts;
99
- });
100
- this.getProductPrice = (item) => {
101
- var _a;
102
- if ((item === null || item === void 0 ? void 0 : item.specialPrice) >= 0) {
103
- return item.specialPrice;
104
- }
105
- return +((_a = item === null || item === void 0 ? void 0 : item.product) === null || _a === void 0 ? void 0 : _a.publicPrice);
106
- };
107
- this.createCart = (shopId) => __awaiter(this, void 0, void 0, function* () {
108
- if (!sessionStorage.getItem("sale")) {
109
- try {
110
- const { data: sale } = yield this.httpService.postBody({ shopId }, "shops/sale");
111
- if (sale) {
112
- sessionStorage.setItem("sale", JSON.stringify(sale));
113
- }
114
- }
115
- catch (error) {
116
- // Toastify.error();
117
- }
118
- }
119
- });
120
- // ------ Calculate Product stock Counts ------
121
- // calculateStockOrQtityLimitCounts = (item: CartProduct, qtity: number): CartProduct | boolean => {
122
- this.calculateStockOrQtityLimitCounts = (item) => {
123
- // const qty = +item.qtityOdr + +qtity;
124
- const qty = +item.qtityOdr;
125
- const stockSalable = +hlpProduct.getStockSalable(item.product);
126
- if (stockSalable < qty) {
127
- item.qtityOdr = stockSalable;
128
- return false;
129
- }
130
- return true;
131
- };
132
- // --------------------
133
- this.getPublicPrice = (product, client, specialPrice = 0, addDiscount = false) => {
134
- if (specialPrice > 0) {
135
- return specialPrice;
136
- }
137
- // const store = await getCustomRepository(ProductStoreRepository).getOneStoreByParams({storeName: 'cpa', productId: product.id})
138
- // if (product.discountRate && addDiscount) {
139
- // return Math.ceil(product.publicPrice) - Math.ceil(calculPercent(product.publicPrice, product.discountRate));
140
- // }
141
- return Math.ceil(product.price);
142
- };
143
- this.httpService = httpService;
144
- }
145
- isProductInCart(item, product) {
146
- return item.product.id === product.id || null;
147
- }
148
- addDiscount(cartProducts, item) {
149
- item.addDiscount = !item.addDiscount;
150
- sessionStorage.setItem("basket", JSON.stringify(cartProducts));
151
- }
152
- convertToSale(cartProducts, sale) {
153
- const items = sale.saleProducts;
154
- const client = sale.client;
155
- for (const item of items) {
156
- // this.updateCartQtity(cartProducts, item.product, item.qtityOdr);
157
- }
158
- sessionStorage.setItem("client", JSON.stringify(client));
159
- // sale = deepClone(sale);
160
- delete sale.saleProducts;
161
- delete sale.client;
162
- // --------------------
163
- if (sale.isProforma) {
164
- sale.proformaToSale = true;
165
- sale.isValided = true;
166
- sale.isProforma = false;
167
- }
168
- else if (sale.isWaiting) {
169
- sale.waitingToSale = true;
170
- sale.isWaiting = false;
171
- sale.isValided = true;
172
- }
173
- // --------------------
174
- sessionStorage.setItem("sale", JSON.stringify(sale));
175
- // --------------------
176
- }
177
- // removeAllFromCart(cartProducts: CartProduct[]) {
178
- removeAllFromCart(cartProducts) {
179
- cartProducts.splice(0, cartProducts.length);
180
- sessionStorage.removeItem("basket");
181
- sessionStorage.removeItem("client");
182
- sessionStorage.removeItem("sale");
183
- }
184
- checkout(cartProducts, inCredit) {
185
- return __awaiter(this, void 0, void 0, function* () {
186
- const saleItems = this.getSaleItems();
187
- try {
188
- if (inCredit) {
189
- saleItems.inCredit = true;
190
- }
191
- // const { data } = await httpService.create(saleItems, "checkout");
192
- // if (data) {
193
- // this.removeAllFromCart(cartProducts);
194
- // queryClient.invalidateQueries({ queryKey: ["pos_products"] });
195
- // Toastify.success("commande bien enégistrée");
196
- // return data;
197
- return this.httpService.create(saleItems, "checkout");
198
- // }
199
- }
200
- catch (error) { }
201
- });
202
- }
203
- getSaleItems() {
204
- let saleItems = new SaleItems();
205
- saleItems.sale = JSON.parse(sessionStorage.getItem("sale"));
206
- saleItems.items = JSON.parse(sessionStorage.getItem("basket"));
207
- saleItems.clientId = sessionStorage.getItem("client") ? JSON.parse(sessionStorage.getItem("client")).id : null;
208
- return saleItems;
209
- }
210
- }
@@ -1 +0,0 @@
1
- export { default as HlpShop } from "./hlpShop";
@@ -1 +0,0 @@
1
- export { default as HlpShop } from "./hlpShop";
@@ -1 +0,0 @@
1
- export * from "./models/Shop";
@@ -1 +0,0 @@
1
- export * from "./models/Shop";
File without changes
File without changes
File without changes
File without changes