remove cloned code
This commit is contained in:
parent
d85e751ec2
commit
cca03a0f4a
@ -1,9 +1,9 @@
|
||||
import { convertPrice } from '../../lib/tools';
|
||||
|
||||
export const calculatePerc = calculationStore => (
|
||||
export const getPrice = (
|
||||
supplierCurrencyId,
|
||||
leaseObjectPrice,
|
||||
rubSum,
|
||||
calculationStore,
|
||||
) => {
|
||||
const supplierCurrency = calculationStore
|
||||
.getOptions('selectSupplierCurrency')
|
||||
@ -18,6 +18,19 @@ export const calculatePerc = calculationStore => (
|
||||
parseFloat(leaseObjectPrice),
|
||||
evo_currencychangeValue,
|
||||
);
|
||||
return price;
|
||||
};
|
||||
|
||||
export const calculatePerc = calculationStore => (
|
||||
supplierCurrencyId,
|
||||
leaseObjectPrice,
|
||||
rubSum,
|
||||
) => {
|
||||
const price = getPrice(
|
||||
supplierCurrencyId,
|
||||
leaseObjectPrice,
|
||||
calculationStore,
|
||||
);
|
||||
return (rubSum / price) * 100;
|
||||
};
|
||||
|
||||
@ -26,18 +39,10 @@ export const calculateRub = calculationStore => (
|
||||
leaseObjectPrice,
|
||||
perc,
|
||||
) => {
|
||||
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 = convertPrice(
|
||||
supplierCurrency.isocurrencycode,
|
||||
parseFloat(leaseObjectPrice),
|
||||
evo_currencychangeValue,
|
||||
const price = getPrice(
|
||||
supplierCurrencyId,
|
||||
leaseObjectPrice,
|
||||
calculationStore,
|
||||
);
|
||||
return (perc * price) / 100;
|
||||
};
|
||||
|
||||
@ -2,7 +2,7 @@ import { openNotification } from 'client/Elements/Notification';
|
||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { convertPrice } from '../../lib/tools';
|
||||
import { calculatePerc, calculateRub } from './calculate';
|
||||
import { calculatePerc, calculateRub, getPrice } from './calculate';
|
||||
|
||||
export default [
|
||||
(calculationStore, calculationProcess) => ({
|
||||
@ -242,18 +242,10 @@ export default [
|
||||
const { leaseObjectPrice } = calculationStore.values;
|
||||
|
||||
const { supplierCurrency: supplierCurrencyId } = calculationStore.values;
|
||||
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;
|
||||
const price = convertPrice(
|
||||
supplierCurrency?.isocurrencycode,
|
||||
const price = getPrice(
|
||||
supplierCurrencyId,
|
||||
leaseObjectPrice,
|
||||
evo_currencychangeValue,
|
||||
calculationStore,
|
||||
);
|
||||
|
||||
if (price && price > 0 && supplierDiscountRub >= price) {
|
||||
|
||||
@ -5,6 +5,7 @@ import { ElementsNames } from 'core/types/Calculation/Store/elements';
|
||||
import { TableNames } from 'core/types/Calculation/Store/tables';
|
||||
import { ElementStatus } from 'core/types/statuses';
|
||||
import { convertPrice } from '../lib/tools';
|
||||
import { getPrice } from './priceReactions/calculate';
|
||||
|
||||
const reactionEffects: IReactionEffect[] = [
|
||||
calculationStore => ({
|
||||
@ -34,18 +35,10 @@ const reactionEffects: IReactionEffect[] = [
|
||||
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;
|
||||
const price = convertPrice(
|
||||
supplierCurrency?.isocurrencycode,
|
||||
const price = getPrice(
|
||||
supplierCurrencyId,
|
||||
leaseObjectPrice,
|
||||
evo_currencychangeValue,
|
||||
calculationStore,
|
||||
);
|
||||
|
||||
const maxPriceChange =
|
||||
|
||||
@ -113,48 +113,6 @@ export default [
|
||||
},
|
||||
}),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
const kaskoRow = tableRows[kaskoRowIndex];
|
||||
const { leasingPeriod } = calculationStore.values;
|
||||
|
||||
return {
|
||||
insTerm: kaskoRow.insTerm?.value,
|
||||
leasingPeriod,
|
||||
};
|
||||
},
|
||||
effect: ({ insTerm, leasingPeriod }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
if (insTerm === 100000001 && leasingPeriod > 15 && kaskoRowIndex) {
|
||||
if (kaskoRowIndex >= 0)
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insured: { value: 100000001, status: ElementStatus.Disabled },
|
||||
});
|
||||
} else {
|
||||
if (kaskoRowIndex >= 0)
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { leasingPeriod } = calculationStore.values;
|
||||
|
||||
Reference in New Issue
Block a user