effect: recalcWithRevision
This commit is contained in:
parent
4222d0565c
commit
231331a5bd
@ -1,4 +1,4 @@
|
||||
export function calcSupplierPrice(
|
||||
export function calcPrice(
|
||||
isocurrencycode,
|
||||
leaseObjectPrice,
|
||||
evo_currencychange,
|
||||
@ -26,7 +26,7 @@ export const calculatePerc = calculationStore => (
|
||||
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
|
||||
const evo_currencychangeValue =
|
||||
(evo_currencychange && evo_currencychange.evo_currencychange) || 0;
|
||||
let price = calcSupplierPrice(
|
||||
let price = calcPrice(
|
||||
supplierCurrency?.isocurrencycode,
|
||||
parseFloat(leaseObjectPrice),
|
||||
evo_currencychangeValue,
|
||||
@ -50,7 +50,7 @@ export const calculateRub = calculationStore => (
|
||||
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
|
||||
const evo_currencychangeValue =
|
||||
(evo_currencychange && evo_currencychange.evo_currencychange) || 0;
|
||||
let price = calcSupplierPrice(
|
||||
let price = calcPrice(
|
||||
supplierCurrency?.isocurrencycode,
|
||||
parseFloat(leaseObjectPrice),
|
||||
evo_currencychangeValue,
|
||||
|
||||
@ -2,7 +2,7 @@ import { openNotification } from 'client/Elements/Notification';
|
||||
import CalculationService from 'client/services/CalculationService';
|
||||
import { IReactionEffect } from 'core/types/effect';
|
||||
import { Status } from 'core/types/statuses';
|
||||
import { calculatePerc, calculateRub } from './lib/tools';
|
||||
import { calcPrice, calculatePerc, calculateRub } from './lib/tools';
|
||||
|
||||
const reactionEffects: IReactionEffect[] = [
|
||||
calculationStore => ({
|
||||
@ -1725,6 +1725,56 @@ const reactionEffects: IReactionEffect[] = [
|
||||
);
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const {
|
||||
recalcWithRevision,
|
||||
supplierCurrency,
|
||||
supplierDiscountRub,
|
||||
supplierDiscountPerc,
|
||||
leaseObjectPrice,
|
||||
} = calculationStore.values;
|
||||
return [
|
||||
recalcWithRevision,
|
||||
supplierCurrency,
|
||||
supplierDiscountRub,
|
||||
supplierDiscountPerc,
|
||||
leaseObjectPrice,
|
||||
];
|
||||
},
|
||||
effect: ([
|
||||
recalcWithRevision,
|
||||
supplierCurrencyId,
|
||||
supplierDiscountRub,
|
||||
supplierDiscountPerc,
|
||||
leaseObjectPrice,
|
||||
]) => {
|
||||
if (recalcWithRevision === true) {
|
||||
return;
|
||||
}
|
||||
const supplierCurrency = calculationStore
|
||||
.getOptions('selectSupplierCurrency')
|
||||
.find(x => x.transactioncurrencyid === supplierCurrencyId);
|
||||
const evo_currencychange = calculationStore
|
||||
.getStaticData('evo_currencychange')
|
||||
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
|
||||
const evo_currencychangeValue =
|
||||
(evo_currencychange && evo_currencychange.evo_currencychange) || 0;
|
||||
let price = calcPrice(
|
||||
supplierCurrency?.isocurrencycode,
|
||||
leaseObjectPrice,
|
||||
evo_currencychangeValue,
|
||||
);
|
||||
|
||||
let maxPriceChange =
|
||||
price - supplierDiscountRub < 800000
|
||||
? price - supplierDiscountRub + 50000
|
||||
: (price - supplierDiscountRub) * 1.05;
|
||||
|
||||
calculationStore.setValue('maxPriceChange', maxPriceChange);
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
export default reactionEffects;
|
||||
|
||||
Reference in New Issue
Block a user