asv-hlps 1.3.64 → 1.3.65
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import User from "../users/models/User";
|
|
2
2
|
import Product from "./models/Product";
|
|
3
3
|
export declare const unitPriceByClientCat: (product: Product, client: User, speUnitPrice?: number, addDiscount?: boolean) => number;
|
|
4
|
+
export declare const unitPriceByClientCatInPhcy: (product: Product, client: User, speUnitPrice?: number, addDiscount?: boolean) => number;
|
|
4
5
|
export declare const productCatCode: (product: Product, catCodes: string[]) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.productCatCode = exports.unitPriceByClientCat = void 0;
|
|
3
|
+
exports.productCatCode = exports.unitPriceByClientCatInPhcy = exports.unitPriceByClientCat = void 0;
|
|
4
4
|
const user_1 = require("../users/user");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const unitPriceByClientCat = (product, client, speUnitPrice = 0, addDiscount = false) => {
|
|
@@ -17,6 +17,20 @@ const unitPriceByClientCat = (product, client, speUnitPrice = 0, addDiscount = f
|
|
|
17
17
|
: Math.ceil(product.stores[0].salePrice * clientCoef);
|
|
18
18
|
};
|
|
19
19
|
exports.unitPriceByClientCat = unitPriceByClientCat;
|
|
20
|
+
const unitPriceByClientCatInPhcy = (product, client, speUnitPrice = 0, addDiscount = false) => {
|
|
21
|
+
if (speUnitPrice > 0) {
|
|
22
|
+
return speUnitPrice;
|
|
23
|
+
}
|
|
24
|
+
// const store = await getCustomRepository(ProductStoreRepository).getOneStoreByParams({storeName: 'cpa', productId: product.id})
|
|
25
|
+
if (product.store.discountRate && addDiscount) {
|
|
26
|
+
return Math.ceil(product.store.publicPrice) - Math.ceil((0, utils_1.calculPercent)(product.store.publicPrice, product.store.discountRate));
|
|
27
|
+
}
|
|
28
|
+
const clientCoef = !client ? 1 : (0, user_1.userCoef)(client);
|
|
29
|
+
return (0, exports.productCatCode)(product, ["spe", "para"])
|
|
30
|
+
? Math.ceil(product.store.publicPrice)
|
|
31
|
+
: Math.ceil(product.store.publicPrice * clientCoef);
|
|
32
|
+
};
|
|
33
|
+
exports.unitPriceByClientCatInPhcy = unitPriceByClientCatInPhcy;
|
|
20
34
|
const productCatCode = (product, catCodes) => {
|
|
21
35
|
return catCodes.includes(product.cat.code && product.cat.code.toLowerCase());
|
|
22
36
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import User from "../users/models/User";
|
|
2
2
|
import Product from "./models/Product";
|
|
3
3
|
export declare const unitPriceByClientCat: (product: Product, client: User, speUnitPrice?: number, addDiscount?: boolean) => number;
|
|
4
|
+
export declare const unitPriceByClientCatInPhcy: (product: Product, client: User, speUnitPrice?: number, addDiscount?: boolean) => number;
|
|
4
5
|
export declare const productCatCode: (product: Product, catCodes: string[]) => boolean;
|
|
@@ -13,6 +13,19 @@ export const unitPriceByClientCat = (product, client, speUnitPrice = 0, addDisco
|
|
|
13
13
|
? Math.ceil(product.stores[0].salePrice)
|
|
14
14
|
: Math.ceil(product.stores[0].salePrice * clientCoef);
|
|
15
15
|
};
|
|
16
|
+
export const unitPriceByClientCatInPhcy = (product, client, speUnitPrice = 0, addDiscount = false) => {
|
|
17
|
+
if (speUnitPrice > 0) {
|
|
18
|
+
return speUnitPrice;
|
|
19
|
+
}
|
|
20
|
+
// const store = await getCustomRepository(ProductStoreRepository).getOneStoreByParams({storeName: 'cpa', productId: product.id})
|
|
21
|
+
if (product.store.discountRate && addDiscount) {
|
|
22
|
+
return Math.ceil(product.store.publicPrice) - Math.ceil(calculPercent(product.store.publicPrice, product.store.discountRate));
|
|
23
|
+
}
|
|
24
|
+
const clientCoef = !client ? 1 : userCoef(client);
|
|
25
|
+
return productCatCode(product, ["spe", "para"])
|
|
26
|
+
? Math.ceil(product.store.publicPrice)
|
|
27
|
+
: Math.ceil(product.store.publicPrice * clientCoef);
|
|
28
|
+
};
|
|
16
29
|
export const productCatCode = (product, catCodes) => {
|
|
17
30
|
return catCodes.includes(product.cat.code && product.cat.code.toLowerCase());
|
|
18
31
|
};
|