скидки - на продукт
This commit is contained in:
parent
ddbff8cb37
commit
8d7c1b5ca7
@ -216,6 +216,13 @@ const DataGridElement: React.FC<MWProps> = ({ openModal }) => {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const discountProduct = ( days:string, generations:string ) => {
|
||||||
|
if( parseInt(days) > 30 && parseInt(generations) > 100 ) { return 0.02; }
|
||||||
|
if( parseInt(days) > 60 && parseInt(generations) > 300 ) { return 0.03; }
|
||||||
|
if( parseInt(days) > 90 && parseInt(generations) > 600 ) { return 0.04; }
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box style={{ width: "100%" }}>
|
<Box style={{ width: "100%" }}>
|
||||||
@ -537,7 +544,22 @@ const DataGridElement: React.FC<MWProps> = ({ openModal }) => {
|
|||||||
if( item.tariffs ) {
|
if( item.tariffs ) {
|
||||||
item.tariffs.forEach( (t) => {
|
item.tariffs.forEach( (t) => {
|
||||||
if( t.time ) { percents = percents + discountTime( t.time ); }
|
if( t.time ) { percents = percents + discountTime( t.time ); }
|
||||||
if( t.time ) { percents = percents + discountCapacity( t.time ); }
|
if( t.points ) { percents = percents + discountCapacity( t.time ); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// применяем активные скидки на продукт
|
||||||
|
if( discountsActiveArray.length >= 0 && checkboxStates == 1 && selectedPromocode < 0 ) {
|
||||||
|
discountsActiveArray.forEach( (activeDiscount) => {
|
||||||
|
discountsArray.forEach( (discount, i) => {
|
||||||
|
if( item.tariffs ) {
|
||||||
|
item.tariffs.forEach( (t) => {
|
||||||
|
if( t.time && t.points ) {
|
||||||
|
percents = percents + discountProduct( t.time, t.points );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -616,11 +638,24 @@ const DataGridElement: React.FC<MWProps> = ({ openModal }) => {
|
|||||||
discountsActiveArray.forEach( (activeDiscount) => {
|
discountsActiveArray.forEach( (activeDiscount) => {
|
||||||
discountsArray.forEach( (discount, i) => {
|
discountsArray.forEach( (discount, i) => {
|
||||||
if( item.time ) { percents = percents + discountTime( item.time ); }
|
if( item.time ) { percents = percents + discountTime( item.time ); }
|
||||||
if( item.time ) { percents = percents + discountCapacity( item.time ); }
|
if( item.points ) { percents = percents + discountCapacity( item.time ); }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// применяем активные скидки на продукт
|
||||||
|
if( discountsActiveArray.length >= 0 && checkboxStates == 1 && selectedPromocode < 0 ) {
|
||||||
|
discountsActiveArray.forEach( (activeDiscount) => {
|
||||||
|
discountsArray.forEach( (discount, i) => {
|
||||||
|
if( item.time && item.points ) {
|
||||||
|
percents = percents + discountProduct( item.time, item.points );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
percents = Number( percents.toFixed(2) );
|
||||||
|
|
||||||
price = price - (price * percents);
|
price = price - (price * percents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user