asv-hlps-market 1.0.1 → 1.0.3
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/index.d.ts +2 -0
- package/lib/cjs/index.js +17 -0
- package/lib/cjs/models/Market.d.ts +8 -0
- package/lib/cjs/models/Market.js +2 -0
- package/lib/cjs/models/UMarket.d.ts +11 -0
- package/lib/cjs/models/UMarket.js +2 -0
- package/lib/cjs/models/index.d.ts +2 -0
- package/lib/cjs/models/index.js +18 -0
- package/lib/cjs/pos/CartProduct.d.ts +6 -0
- package/lib/cjs/pos/CartProduct.js +2 -0
- package/lib/cjs/pos/hlpShop.d.ts +36 -0
- package/lib/cjs/pos/hlpShop.js +210 -0
- package/lib/cjs/pos/index.d.ts +1 -0
- package/lib/cjs/pos/index.js +8 -0
- package/lib/cjs/products/hlpProduct.d.ts +13 -0
- package/lib/cjs/products/hlpProduct.js +49 -0
- package/lib/cjs/products/index.d.ts +2 -0
- package/lib/cjs/products/index.js +23 -0
- package/lib/cjs/products/models/Product.d.ts +40 -0
- package/lib/cjs/products/models/Product.js +2 -0
- package/lib/cjs/products/models/ProductAsset.d.ts +8 -0
- package/lib/cjs/products/models/ProductAsset.js +2 -0
- package/lib/cjs/products/models/ProductCat.d.ts +3 -0
- package/lib/cjs/products/models/ProductCat.js +2 -0
- package/lib/cjs/products/models/ProductCollection.d.ts +3 -0
- package/lib/cjs/products/models/ProductCollection.js +2 -0
- package/lib/cjs/products/models/ProductDepot.d.ts +11 -0
- package/lib/cjs/products/models/ProductDepot.js +2 -0
- package/lib/cjs/products/models/ProductElt.d.ts +3 -0
- package/lib/cjs/products/models/ProductElt.js +2 -0
- package/lib/cjs/products/models/ProductGrp.d.ts +3 -0
- package/lib/cjs/products/models/ProductGrp.js +2 -0
- package/lib/cjs/products/models/ProductImage.d.ts +5 -0
- package/lib/cjs/products/models/ProductImage.js +2 -0
- package/lib/cjs/products/models/ProductIn.d.ts +42 -0
- package/lib/cjs/products/models/ProductIn.js +2 -0
- package/lib/cjs/products/models/ProductState.d.ts +3 -0
- package/lib/cjs/products/models/ProductState.js +2 -0
- package/lib/cjs/products/models/ProductStock.d.ts +6 -0
- package/lib/cjs/products/models/ProductStock.js +2 -0
- package/lib/cjs/products/models/ProductTag.d.ts +3 -0
- package/lib/cjs/products/models/ProductTag.js +2 -0
- package/lib/cjs/products/models/ProductVariant.d.ts +6 -0
- package/lib/cjs/products/models/ProductVariant.js +2 -0
- package/lib/cjs/products/models/index.d.ts +13 -0
- package/lib/cjs/products/models/index.js +29 -0
- package/lib/cjs/sales/index.d.ts +1 -0
- package/lib/cjs/sales/index.js +17 -0
- package/lib/cjs/sales/models/Sale.d.ts +8 -0
- package/lib/cjs/sales/models/Sale.js +2 -0
- package/lib/cjs/sales/models/SalePayment.d.ts +21 -0
- package/lib/cjs/sales/models/SalePayment.js +2 -0
- package/lib/cjs/sales/models/SaleProduct.d.ts +8 -0
- package/lib/cjs/sales/models/SaleProduct.js +2 -0
- package/lib/cjs/sales/models/index.d.ts +3 -0
- package/lib/cjs/sales/models/index.js +19 -0
- package/lib/cjs/shared/CartItem.d.ts +7 -0
- package/lib/cjs/shared/CartItem.js +6 -0
- package/lib/cjs/shared/index.d.ts +1 -0
- package/lib/cjs/shared/index.js +17 -0
- package/lib/cjs/shops/index.d.ts +1 -0
- package/lib/cjs/shops/index.js +17 -0
- package/lib/cjs/shops/models/Shop.d.ts +13 -0
- package/lib/cjs/shops/models/Shop.js +2 -0
- package/lib/cjs/users/models/User.d.ts +7 -0
- package/lib/cjs/users/models/User.js +2 -0
- package/lib/esm/index.d.ts +2 -0
- package/lib/esm/index.js +2 -1
- package/lib/esm/models/Market.d.ts +8 -0
- package/lib/esm/models/Market.js +1 -0
- package/lib/esm/models/UMarket.d.ts +11 -0
- package/lib/esm/models/UMarket.js +1 -0
- package/lib/esm/models/index.d.ts +2 -0
- package/lib/esm/models/index.js +2 -0
- package/lib/esm/pos/CartProduct.d.ts +6 -0
- package/lib/esm/pos/CartProduct.js +1 -0
- package/lib/esm/pos/hlpShop.d.ts +36 -0
- package/lib/esm/pos/hlpShop.js +204 -0
- package/lib/esm/pos/index.d.ts +1 -0
- package/lib/esm/pos/index.js +1 -0
- package/lib/esm/products/hlpProduct.d.ts +13 -0
- package/lib/esm/products/hlpProduct.js +47 -0
- package/lib/esm/products/index.d.ts +2 -0
- package/lib/esm/products/index.js +2 -0
- package/lib/esm/products/models/Product.d.ts +40 -0
- package/lib/esm/products/models/Product.js +1 -0
- package/lib/esm/products/models/ProductAsset.d.ts +8 -0
- package/lib/esm/products/models/ProductAsset.js +1 -0
- package/lib/esm/products/models/ProductCat.d.ts +3 -0
- package/lib/esm/products/models/ProductCat.js +1 -0
- package/lib/esm/products/models/ProductCollection.d.ts +3 -0
- package/lib/esm/products/models/ProductCollection.js +1 -0
- package/lib/esm/products/models/ProductDepot.d.ts +11 -0
- package/lib/esm/products/models/ProductDepot.js +1 -0
- package/lib/esm/products/models/ProductElt.d.ts +3 -0
- package/lib/esm/products/models/ProductElt.js +1 -0
- package/lib/esm/products/models/ProductGrp.d.ts +3 -0
- package/lib/esm/products/models/ProductGrp.js +1 -0
- package/lib/esm/products/models/ProductImage.d.ts +5 -0
- package/lib/esm/products/models/ProductImage.js +1 -0
- package/lib/esm/products/models/ProductIn.d.ts +42 -0
- package/lib/esm/products/models/ProductIn.js +1 -0
- package/lib/esm/products/models/ProductState.d.ts +3 -0
- package/lib/esm/products/models/ProductState.js +1 -0
- package/lib/esm/products/models/ProductStock.d.ts +6 -0
- package/lib/esm/products/models/ProductStock.js +1 -0
- package/lib/esm/products/models/ProductTag.d.ts +3 -0
- package/lib/esm/products/models/ProductTag.js +1 -0
- package/lib/esm/products/models/ProductVariant.d.ts +6 -0
- package/lib/esm/products/models/ProductVariant.js +1 -0
- package/lib/esm/products/models/index.d.ts +13 -0
- package/lib/esm/products/models/index.js +13 -0
- package/lib/esm/sales/index.d.ts +1 -0
- package/lib/esm/sales/index.js +1 -0
- package/lib/esm/sales/models/Sale.d.ts +8 -0
- package/lib/esm/sales/models/Sale.js +1 -0
- package/lib/esm/sales/models/SalePayment.d.ts +21 -0
- package/lib/esm/sales/models/SalePayment.js +1 -0
- package/lib/esm/sales/models/SaleProduct.d.ts +8 -0
- package/lib/esm/sales/models/SaleProduct.js +1 -0
- package/lib/esm/sales/models/index.d.ts +3 -0
- package/lib/esm/sales/models/index.js +3 -0
- package/lib/esm/shared/CartItem.d.ts +7 -0
- package/lib/esm/shared/CartItem.js +3 -0
- package/lib/esm/shared/index.d.ts +1 -0
- package/lib/esm/shared/index.js +1 -0
- package/lib/esm/shops/index.d.ts +1 -0
- package/lib/esm/shops/index.js +1 -0
- package/lib/esm/shops/models/Shop.d.ts +13 -0
- package/lib/esm/shops/models/Shop.js +1 -0
- package/lib/esm/users/models/User.d.ts +7 -0
- package/lib/esm/users/models/User.js +1 -0
- package/package.json +2 -2
package/lib/cjs/index.d.ts
CHANGED
package/lib/cjs/index.js
CHANGED
@@ -1 +1,18 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./models"), exports);
|
18
|
+
__exportStar(require("./products/models"), exports);
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./Market"), exports);
|
18
|
+
__exportStar(require("./UMarket"), exports);
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import Sale from "../sales/models/Sale";
|
2
|
+
import Product from "../products/models/Product";
|
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
|
+
convertToSale(cartProducts: CartProduct[], sale: Sale): void;
|
29
|
+
removeAllFromCart(cartProducts: CartProduct[]): void;
|
30
|
+
checkout(cartProducts: CartProduct[], inCredit?: boolean): Promise<any>;
|
31
|
+
getSaleItems(): SaleItems;
|
32
|
+
private createCart;
|
33
|
+
calculateStockOrQtityLimitCounts: (item: CartProduct) => CartProduct | boolean;
|
34
|
+
getPublicPrice: (product: Product, client: User, specialPrice?: number, addDiscount?: boolean) => number;
|
35
|
+
}
|
36
|
+
export {};
|
@@ -0,0 +1,210 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const hlpProduct_1 = __importDefault(require("../products/hlpProduct"));
|
16
|
+
class SaleItems {
|
17
|
+
}
|
18
|
+
class HlpShop {
|
19
|
+
constructor(httpService) {
|
20
|
+
this.addToCart = (cartProducts, product, qtity) => __awaiter(this, void 0, void 0, function* () {
|
21
|
+
let nCartProducts = [];
|
22
|
+
this.createCart(product.shop.id);
|
23
|
+
const nItem = cartProducts.find((item) => this.isProductInCart(item, product));
|
24
|
+
if (!nItem) {
|
25
|
+
//@ts-ignore
|
26
|
+
nCartProducts = [...cartProducts, { product, qtityOdr: 1 }];
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
nCartProducts = yield this.updateCartQtity(cartProducts, product, qtity);
|
30
|
+
}
|
31
|
+
sessionStorage.setItem("basket", JSON.stringify(nCartProducts));
|
32
|
+
return nCartProducts;
|
33
|
+
});
|
34
|
+
this.removeItem = (cartProducts, product) => {
|
35
|
+
cartProducts.find((item, index) => {
|
36
|
+
if (item.product.id === product.id) {
|
37
|
+
const item = cartProducts[index];
|
38
|
+
this.removeFromCart(cartProducts, item);
|
39
|
+
}
|
40
|
+
return false;
|
41
|
+
});
|
42
|
+
};
|
43
|
+
// ------ Removed in cart ------
|
44
|
+
this.removeFromCart = (cartProducts, item) => {
|
45
|
+
const index = cartProducts.indexOf(item);
|
46
|
+
cartProducts.splice(index, 1);
|
47
|
+
sessionStorage.setItem("basket", JSON.stringify(cartProducts));
|
48
|
+
};
|
49
|
+
// --------------------
|
50
|
+
this.getTotalAmount = (cartProducts, client) => {
|
51
|
+
return cartProducts.reduce((prev, curr) => {
|
52
|
+
return Math.ceil(prev /* (this.publicPriceBy(curr.product, client, curr.speUnitPrice, curr.addDiscount) * curr.product.tva) / 100) * curr.qtityOdr + */ +
|
53
|
+
this.getPublicPrice(curr.product, client, curr.specialPrice, curr.addDiscount) * curr.qtityOdr);
|
54
|
+
}, 0);
|
55
|
+
};
|
56
|
+
// ------ getTotalAmountAllIncluded ------
|
57
|
+
this.getTotalAmountAllIncluded = (cartProducts, client, shippingFee = 0, otherFee = 0, discount = 0) => {
|
58
|
+
return Math.ceil(this.getTotalAmount(cartProducts, client) + shippingFee + otherFee + -this.getTotalAmountDiscount(cartProducts, client, discount));
|
59
|
+
};
|
60
|
+
this.getTotalAmountDiscount = (cartProducts, client, discountRate) => {
|
61
|
+
return Math.ceil((+this.getTotalAmount(cartProducts, client) * discountRate) / 100);
|
62
|
+
};
|
63
|
+
// ------ total quantity free------
|
64
|
+
this.getTotalQtityFree = (cartProducts) => {
|
65
|
+
return cartProducts.reduce((prev, curr) => {
|
66
|
+
return prev + (+curr.qtityFree || 0);
|
67
|
+
}, 0);
|
68
|
+
};
|
69
|
+
// ------ total quantity ------
|
70
|
+
this.getTotalQtityReal = (cartProducts) => {
|
71
|
+
return cartProducts.reduce((prev, curr) => {
|
72
|
+
return prev + (curr.qtityOdr + (curr.qtityFree || 0));
|
73
|
+
}, 0);
|
74
|
+
};
|
75
|
+
// ------ Total sub amount ------
|
76
|
+
this.getTotalAmountWithoutTva = (cartProducts, client) => {
|
77
|
+
return cartProducts.reduce((prev, curr) => {
|
78
|
+
return Math.ceil(prev + this.getPublicPrice(curr.product, client, curr.specialPrice, curr.addDiscount) * curr.qtityOdr);
|
79
|
+
}, 0);
|
80
|
+
};
|
81
|
+
// ------ Total tva ------
|
82
|
+
this.getTotalTva = (cartProducts, client) => {
|
83
|
+
return 0;
|
84
|
+
/* return cartProducts.reduce((prev: number, curr: CartProduct) => {
|
85
|
+
return Math.ceil(
|
86
|
+
prev +
|
87
|
+
this.unitPriceByClientCatInPhcy(curr.product, client, curr.speUnitPrice, curr.addDiscount) *
|
88
|
+
(+curr.product.tva / 100) *
|
89
|
+
curr.qtityOdr
|
90
|
+
);
|
91
|
+
}, 0); */
|
92
|
+
};
|
93
|
+
// ------ Update Cart Value ------
|
94
|
+
this.updateCartQtity = (cartProducts, product, qtity) => __awaiter(this, void 0, void 0, function* () {
|
95
|
+
const index = cartProducts.findIndex((item) => this.isProductInCart(item, product));
|
96
|
+
cartProducts[index].qtityOdr = qtity;
|
97
|
+
const qtyInCart = +cartProducts[index].qtityOdr;
|
98
|
+
const stock = this.calculateStockOrQtityLimitCounts(cartProducts[index]);
|
99
|
+
// --------------------
|
100
|
+
if (qtyInCart > 0 && stock) {
|
101
|
+
cartProducts[index].qtityOdr = qtyInCart;
|
102
|
+
}
|
103
|
+
sessionStorage.setItem("basket", JSON.stringify(cartProducts));
|
104
|
+
return cartProducts;
|
105
|
+
});
|
106
|
+
this.createCart = (shopId) => __awaiter(this, void 0, void 0, function* () {
|
107
|
+
if (!sessionStorage.getItem("sale")) {
|
108
|
+
try {
|
109
|
+
const { data: sale } = yield this.httpService.postBody({ shopId }, "shops/sale");
|
110
|
+
if (sale) {
|
111
|
+
sessionStorage.setItem("sale", JSON.stringify(sale));
|
112
|
+
}
|
113
|
+
}
|
114
|
+
catch (error) {
|
115
|
+
// Toastify.error();
|
116
|
+
}
|
117
|
+
}
|
118
|
+
});
|
119
|
+
// ------ Calculate Product stock Counts ------
|
120
|
+
// calculateStockOrQtityLimitCounts = (item: CartProduct, qtity: number): CartProduct | boolean => {
|
121
|
+
this.calculateStockOrQtityLimitCounts = (item) => {
|
122
|
+
// const qty = +item.qtityOdr + +qtity;
|
123
|
+
const qty = +item.qtityOdr;
|
124
|
+
const stockSalable = +hlpProduct_1.default.getStockSalable(item.product);
|
125
|
+
if (stockSalable < qty) {
|
126
|
+
item.qtityOdr = stockSalable;
|
127
|
+
return false;
|
128
|
+
}
|
129
|
+
return true;
|
130
|
+
};
|
131
|
+
// --------------------
|
132
|
+
this.getPublicPrice = (product, client, specialPrice = 0, addDiscount = false) => {
|
133
|
+
if (specialPrice > 0) {
|
134
|
+
return specialPrice;
|
135
|
+
}
|
136
|
+
// const store = await getCustomRepository(ProductStoreRepository).getOneStoreByParams({storeName: 'cpa', productId: product.id})
|
137
|
+
// if (product.discountRate && addDiscount) {
|
138
|
+
// return Math.ceil(product.publicPrice) - Math.ceil(calculPercent(product.publicPrice, product.discountRate));
|
139
|
+
// }
|
140
|
+
return Math.ceil(product.price);
|
141
|
+
};
|
142
|
+
this.httpService = httpService;
|
143
|
+
}
|
144
|
+
isProductInCart(item, product) {
|
145
|
+
return item.product.id === product.id || null;
|
146
|
+
}
|
147
|
+
addDiscount(cartProducts, item) {
|
148
|
+
item.addDiscount = !item.addDiscount;
|
149
|
+
sessionStorage.setItem("basket", JSON.stringify(cartProducts));
|
150
|
+
}
|
151
|
+
convertToSale(cartProducts, sale) {
|
152
|
+
const items = sale.saleProducts;
|
153
|
+
const client = sale.client;
|
154
|
+
for (const item of items) {
|
155
|
+
// this.updateCartQtity(cartProducts, item.product, item.qtityOdr);
|
156
|
+
}
|
157
|
+
sessionStorage.setItem("client", JSON.stringify(client));
|
158
|
+
// sale = deepClone(sale);
|
159
|
+
delete sale.saleProducts;
|
160
|
+
delete sale.client;
|
161
|
+
// --------------------
|
162
|
+
if (sale.isProforma) {
|
163
|
+
sale.proformaToSale = true;
|
164
|
+
sale.isValided = true;
|
165
|
+
sale.isProforma = false;
|
166
|
+
}
|
167
|
+
else if (sale.isWaiting) {
|
168
|
+
sale.waitingToSale = true;
|
169
|
+
sale.isWaiting = false;
|
170
|
+
sale.isValided = true;
|
171
|
+
}
|
172
|
+
// --------------------
|
173
|
+
sessionStorage.setItem("sale", JSON.stringify(sale));
|
174
|
+
// --------------------
|
175
|
+
}
|
176
|
+
// removeAllFromCart(cartProducts: CartProduct[]) {
|
177
|
+
removeAllFromCart(cartProducts) {
|
178
|
+
cartProducts.splice(0, cartProducts.length);
|
179
|
+
sessionStorage.removeItem("basket");
|
180
|
+
sessionStorage.removeItem("client");
|
181
|
+
sessionStorage.removeItem("sale");
|
182
|
+
}
|
183
|
+
checkout(cartProducts, inCredit) {
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
185
|
+
const saleItems = this.getSaleItems();
|
186
|
+
try {
|
187
|
+
if (inCredit) {
|
188
|
+
saleItems.inCredit = true;
|
189
|
+
}
|
190
|
+
// const { data } = await httpService.create(saleItems, "checkout");
|
191
|
+
// if (data) {
|
192
|
+
// this.removeAllFromCart(cartProducts);
|
193
|
+
// queryClient.invalidateQueries({ queryKey: ["pos_products"] });
|
194
|
+
// Toastify.success("commande bien enégistrée");
|
195
|
+
// return data;
|
196
|
+
return this.httpService.create(saleItems, "checkout");
|
197
|
+
// }
|
198
|
+
}
|
199
|
+
catch (error) { }
|
200
|
+
});
|
201
|
+
}
|
202
|
+
getSaleItems() {
|
203
|
+
let saleItems = new SaleItems();
|
204
|
+
saleItems.sale = JSON.parse(sessionStorage.getItem("sale"));
|
205
|
+
saleItems.items = JSON.parse(sessionStorage.getItem("basket"));
|
206
|
+
saleItems.clientId = sessionStorage.getItem("client") ? JSON.parse(sessionStorage.getItem("client")).id : null;
|
207
|
+
return saleItems;
|
208
|
+
}
|
209
|
+
}
|
210
|
+
exports.default = HlpShop;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default as HlpShop } from "./hlpShop";
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.HlpShop = void 0;
|
7
|
+
var hlpShop_1 = require("./hlpShop");
|
8
|
+
Object.defineProperty(exports, "HlpShop", { enumerable: true, get: function () { return __importDefault(hlpShop_1).default; } });
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import Product from "./models/Product";
|
2
|
+
import ProductStock from "./models/ProductStock";
|
3
|
+
declare class HlpProduct {
|
4
|
+
qtityInAllDepots(stock: ProductStock, prms?: {
|
5
|
+
exceptDepots?: string[];
|
6
|
+
main?: "master" | "slave";
|
7
|
+
}): number;
|
8
|
+
getStockSalable(product: Product): number;
|
9
|
+
stock: (product: Product, param: "salable" | "packs" | "units") => number;
|
10
|
+
extraFiilters: (row: Product) => string;
|
11
|
+
}
|
12
|
+
declare const _default: HlpProduct;
|
13
|
+
export default _default;
|
@@ -0,0 +1,49 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
class HlpProduct {
|
4
|
+
constructor() {
|
5
|
+
this.stock = (product, param) => {
|
6
|
+
const salable = (+product.stock.sumIns || 0) - (+product.stock.sumOuts || 0);
|
7
|
+
const packs = Math.trunc(salable / product.stock.qtityPerPackaging || 0);
|
8
|
+
const units = salable % product.stock.qtityPerPackaging || 0;
|
9
|
+
switch (param) {
|
10
|
+
case "salable":
|
11
|
+
return salable;
|
12
|
+
case "packs":
|
13
|
+
return packs;
|
14
|
+
case "units":
|
15
|
+
return units;
|
16
|
+
default:
|
17
|
+
return salable;
|
18
|
+
}
|
19
|
+
};
|
20
|
+
this.extraFiilters = (row) => row.designation; /* +
|
21
|
+
row.codeCompta +
|
22
|
+
(row.tva > 0 ? "@tva" : "") +
|
23
|
+
(row.isAvailable ? "@dispo" : "") +
|
24
|
+
(!row.isAvailable ? "@indispo" : "") +
|
25
|
+
(row.isActive ? "@actif" : "") +
|
26
|
+
(!row.isActive ? "@inactif" : "") +
|
27
|
+
(row.isPrivate ? "@private" : "") +
|
28
|
+
(!row.isPrivate ? "@noprivate" : ""); */
|
29
|
+
}
|
30
|
+
qtityInAllDepots(stock, prms) {
|
31
|
+
const ins = stock.sumIns - stock.sumOuts;
|
32
|
+
return ins <= 0 ? 0 : ins;
|
33
|
+
}
|
34
|
+
getStockSalable(product) {
|
35
|
+
const stockAllSalable = +this.qtityInAllDepots(product.stock);
|
36
|
+
const stockProduct = Math.trunc(stockAllSalable / product.qtityUnit);
|
37
|
+
/* let stockSalable: number = 0;
|
38
|
+
|
39
|
+
if (stockAllSalable <= stockStore) {
|
40
|
+
stockSalable = stockAllSalable;
|
41
|
+
}
|
42
|
+
if (stockAllSalable > stockStore) {
|
43
|
+
stockSalable = stockStore;
|
44
|
+
} */
|
45
|
+
// return stockSalable || 0;
|
46
|
+
return stockProduct || 0;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
exports.default = new HlpProduct();
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
18
|
+
};
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
20
|
+
exports.HlpProduct = void 0;
|
21
|
+
var hlpProduct_1 = require("./hlpProduct");
|
22
|
+
Object.defineProperty(exports, "HlpProduct", { enumerable: true, get: function () { return __importDefault(hlpProduct_1).default; } });
|
23
|
+
__exportStar(require("./models"), exports);
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { Market } from "../../models/Market";
|
2
|
+
import { Shop } from "../../shops/models/Shop";
|
3
|
+
import ProductCat from "./ProductCat";
|
4
|
+
import ProductImage from "./ProductImage";
|
5
|
+
import ProductIn from "./ProductIn";
|
6
|
+
interface Stock {
|
7
|
+
sumIns: number;
|
8
|
+
sumOuts: number;
|
9
|
+
qtityPerPackaging: number;
|
10
|
+
}
|
11
|
+
export default interface Product {
|
12
|
+
capacity: string;
|
13
|
+
cat: ProductCat;
|
14
|
+
createdAt: Date;
|
15
|
+
description: string;
|
16
|
+
designation: string;
|
17
|
+
disabled?: boolean;
|
18
|
+
iconName: string;
|
19
|
+
iconPack: string;
|
20
|
+
id: number;
|
21
|
+
images: ProductImage[];
|
22
|
+
ins: ProductIn[];
|
23
|
+
isActive: boolean;
|
24
|
+
isAvailable?: boolean;
|
25
|
+
isBulk: boolean;
|
26
|
+
market: Market;
|
27
|
+
price: number;
|
28
|
+
publicPrice: number;
|
29
|
+
qtityLimit: number;
|
30
|
+
qtityUnit: number;
|
31
|
+
stock: Stock;
|
32
|
+
qtityPerBox: number;
|
33
|
+
qtityPerPackaging: number;
|
34
|
+
ref: string;
|
35
|
+
salePrice: number;
|
36
|
+
shop: Shop;
|
37
|
+
updatedAt: Date;
|
38
|
+
specialPrice?: number;
|
39
|
+
}
|
40
|
+
export {};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import EInOutMotive from "asv-hlps/lib/cjs/shared/models/EInOutMotive";
|
2
|
+
import Product from "./Product";
|
3
|
+
import ProductDepot from "./ProductDepot";
|
4
|
+
export default interface ProductIn {
|
5
|
+
id: number;
|
6
|
+
createdAt: Date;
|
7
|
+
lot: string;
|
8
|
+
qtity: number;
|
9
|
+
comment: string;
|
10
|
+
isEdit: boolean;
|
11
|
+
motive: EInOutMotive;
|
12
|
+
authorId: number;
|
13
|
+
qtityPerPackaging: number;
|
14
|
+
/**
|
15
|
+
* remaining qtity
|
16
|
+
*/
|
17
|
+
qtityIn: number;
|
18
|
+
isOutDate: boolean;
|
19
|
+
/**
|
20
|
+
* expired
|
21
|
+
*/
|
22
|
+
isOut: boolean;
|
23
|
+
/**
|
24
|
+
* if true the productIn is created from transfering qtity from another productin
|
25
|
+
*/
|
26
|
+
fromTransfert: boolean;
|
27
|
+
/**
|
28
|
+
* indique the qtity waiting to transfert after transfert validation
|
29
|
+
*/
|
30
|
+
qtityInTransfert: number;
|
31
|
+
/**
|
32
|
+
* is true if the transfert not validate
|
33
|
+
*/
|
34
|
+
inTransfert: boolean;
|
35
|
+
depotId: number;
|
36
|
+
productId: number;
|
37
|
+
designation: string;
|
38
|
+
salePrice: number;
|
39
|
+
publicPrice: number;
|
40
|
+
product: Product;
|
41
|
+
depot: ProductDepot;
|
42
|
+
}
|