1.0.70 change discount type: most fields are optional
This commit is contained in:
parent
5f17e1c730
commit
3a8b8b1b42
@ -4,20 +4,20 @@ export interface Discount {
|
|||||||
Layer: number;
|
Layer: number;
|
||||||
Description: string;
|
Description: string;
|
||||||
Condition: {
|
Condition: {
|
||||||
Period: {
|
Period?: {
|
||||||
From: string;
|
From: string;
|
||||||
To: string;
|
To: string;
|
||||||
};
|
};
|
||||||
User: string;
|
User: string;
|
||||||
UserType: string;
|
UserType?: string;
|
||||||
Coupon: string;
|
Coupon: string;
|
||||||
PurchasesAmount: string;
|
PurchasesAmount?: string;
|
||||||
CartPurchasesAmount: string;
|
CartPurchasesAmount?: string;
|
||||||
Product: string;
|
Product?: string;
|
||||||
Term: string;
|
Term?: string;
|
||||||
Usage: string;
|
Usage?: string;
|
||||||
PriceFrom: string;
|
PriceFrom?: string;
|
||||||
Group: string;
|
Group?: string;
|
||||||
};
|
};
|
||||||
Target: {
|
Target: {
|
||||||
Products: {
|
Products: {
|
||||||
|
@ -10,13 +10,10 @@ export function findPrivilegeDiscount(
|
|||||||
const applicableDiscounts = discounts.filter(discount => {
|
const applicableDiscounts = discounts.filter(discount => {
|
||||||
if (discount.Condition.User !== "" && discount.Condition.User === userId) return true;
|
if (discount.Condition.User !== "" && discount.Condition.User === userId) return true;
|
||||||
|
|
||||||
const conditionMinPrice = parseFloat(discount.Condition.Term);
|
|
||||||
if (!isFinite(conditionMinPrice)) throw new Error(`Couldn't parse Discount.Condition.Term: ${discount.Condition.Term}`);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
discount.Layer === 1 &&
|
discount.Layer === 1 &&
|
||||||
privilegeId === discount.Condition.Product &&
|
privilegeId === discount.Condition.Product &&
|
||||||
privilegePrice >= conditionMinPrice
|
privilegePrice >= Number(discount.Condition.Term)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@frontend/kitui",
|
"name": "@frontend/kitui",
|
||||||
"version": "1.0.69",
|
"version": "1.0.70",
|
||||||
"description": "test",
|
"description": "test",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.js",
|
"module": "./dist/index.js",
|
||||||
|
Loading…
Reference in New Issue
Block a user