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;
|
||||
Description: string;
|
||||
Condition: {
|
||||
Period: {
|
||||
Period?: {
|
||||
From: string;
|
||||
To: string;
|
||||
};
|
||||
User: string;
|
||||
UserType: string;
|
||||
UserType?: string;
|
||||
Coupon: string;
|
||||
PurchasesAmount: string;
|
||||
CartPurchasesAmount: string;
|
||||
Product: string;
|
||||
Term: string;
|
||||
Usage: string;
|
||||
PriceFrom: string;
|
||||
Group: string;
|
||||
PurchasesAmount?: string;
|
||||
CartPurchasesAmount?: string;
|
||||
Product?: string;
|
||||
Term?: string;
|
||||
Usage?: string;
|
||||
PriceFrom?: string;
|
||||
Group?: string;
|
||||
};
|
||||
Target: {
|
||||
Products: {
|
||||
|
@ -10,13 +10,10 @@ export function findPrivilegeDiscount(
|
||||
const applicableDiscounts = discounts.filter(discount => {
|
||||
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 (
|
||||
discount.Layer === 1 &&
|
||||
privilegeId === discount.Condition.Product &&
|
||||
privilegePrice >= conditionMinPrice
|
||||
privilegePrice >= Number(discount.Condition.Term)
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@frontend/kitui",
|
||||
"version": "1.0.69",
|
||||
"version": "1.0.70",
|
||||
"description": "test",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
|
Loading…
Reference in New Issue
Block a user