102 lines
2.9 KiB
TypeScript
102 lines
2.9 KiB
TypeScript
import { ICalculationStore } from 'core/types/Calculation/Store';
|
|
import { ComputedValuesNames } from 'core/types/Calculation/Store/values';
|
|
import { convertPrice } from './lib/tools';
|
|
|
|
const LEASE_OBJECT_RISK = {
|
|
100000000: 'Низкий',
|
|
100000001: 'Средний',
|
|
100000002: 'Высокий',
|
|
};
|
|
|
|
type ComputedEffect = (this: ICalculationStore) => string | number | undefined;
|
|
|
|
export const insKaskoPriceLeasePeriod: ComputedEffect = function () {
|
|
const { leasingPeriod } = this.values;
|
|
const { rows } = this.tables.tableInsurance;
|
|
const kaskoRow = rows[1];
|
|
const dgoRow = rows[2];
|
|
const nsRow = rows[3];
|
|
|
|
let res = 0;
|
|
if (
|
|
leasingPeriod &&
|
|
leasingPeriod > 15 &&
|
|
kaskoRow?.insTerm?.value === 100000001
|
|
) {
|
|
res =
|
|
(leasingPeriod / 12) *
|
|
(kaskoRow?.insCost?.value +
|
|
dgoRow?.insCost?.value +
|
|
nsRow?.insCost?.value);
|
|
}
|
|
|
|
return res;
|
|
};
|
|
|
|
const computedEffects: Record<ComputedValuesNames, ComputedEffect> = {
|
|
leaseObjectRiskName: function () {
|
|
const configuration = this.getOption('selectConfiguration');
|
|
if (configuration) {
|
|
if (configuration.evo_leasingobject_risk) {
|
|
const res = LEASE_OBJECT_RISK[configuration.evo_leasingobject_risk];
|
|
return res;
|
|
}
|
|
}
|
|
|
|
const model = this.getOption('selectModel');
|
|
const evo_leasingobject_risk = model?.evo_leasingobject_risk;
|
|
if (evo_leasingobject_risk)
|
|
return LEASE_OBJECT_RISK[evo_leasingobject_risk];
|
|
},
|
|
insKaskoPriceLeasePeriod,
|
|
irrInfo: function () {
|
|
const tarif = this.getOption('selectTarif');
|
|
if (tarif && tarif.evo_min_irr && tarif.evo_max_irr) {
|
|
return `Min: ${tarif.evo_min_irr}% - Max: ${tarif.evo_max_irr}%`;
|
|
}
|
|
return '-';
|
|
},
|
|
registrationDescription: function () {
|
|
const registration = this.getOption('selectRegistration');
|
|
return registration?.evo_description;
|
|
},
|
|
|
|
plPriceRub: function () {
|
|
const supplierCurrency = this.getOption('selectSupplierCurrency');
|
|
const { leaseObjectPrice } = this.values;
|
|
|
|
const evo_currencychanges = this.getStaticData('evo_currencychange');
|
|
const evo_currencychange = evo_currencychanges.find(
|
|
x =>
|
|
x.evo_ref_transactioncurrency ===
|
|
supplierCurrency?.transactioncurrencyid,
|
|
);
|
|
|
|
return convertPrice(
|
|
supplierCurrency?.isocurrencycode,
|
|
leaseObjectPrice,
|
|
evo_currencychange?.evo_currencychange || 1,
|
|
);
|
|
},
|
|
|
|
discountRub: function () {
|
|
const supplierCurrency = this.getOption('selectSupplierCurrency');
|
|
const { supplierDiscountRub } = this.values;
|
|
|
|
const evo_currencychanges = this.getStaticData('evo_currencychange');
|
|
const evo_currencychange = evo_currencychanges.find(
|
|
x =>
|
|
x.evo_ref_transactioncurrency ===
|
|
supplierCurrency?.transactioncurrencyid,
|
|
);
|
|
|
|
return convertPrice(
|
|
supplierCurrency?.isocurrencycode,
|
|
supplierDiscountRub,
|
|
evo_currencychange?.evo_currencychange || 1,
|
|
);
|
|
},
|
|
};
|
|
|
|
export default computedEffects;
|