This repository has been archived on 2025-05-09. You can view files and clone it, but cannot push or open issues or pull requests.
2020-10-06 11:14:51 +03:00

78 lines
2.0 KiB
JavaScript

const LEASE_OBJECT_RISK = {
100000000: 'Низкий',
100000001: 'Средний',
100000002: 'Высокий',
};
const computedEffects = {
leadName() {
const leadId = this.values.lead;
if (this.options.selectLead && this.options.selectLead.length) {
const lead = this.options.selectLead?.find(x => x.leadid === leadId);
if (lead) {
return lead.name;
}
}
},
opportunityName() {
const opportunityId = this.values.opportunity;
if (
this.options.selectOpportunity &&
this.options.selectOpportunity.length > 0
) {
const opportunity = this.options.selectOpportunity?.find(
x => x.opportunityid === opportunityId,
);
if (opportunity) {
return opportunity.name;
}
}
},
leaseObjectRiskName() {
const configurationId = this.values.configuration;
if (configurationId) {
const configuration = this.options.selectConfiguration?.find(
x => x.evo_equipmentid === configurationId,
);
if (configuration) {
if (configuration.evo_leasingobject_risk) {
const res = LEASE_OBJECT_RISK[configuration.evo_leasingobject_risk];
return res;
}
}
}
const modelId = this.values.model;
if (modelId) {
const model = this.options.selectModel?.find(
x => x.evo_modelid === modelId,
);
if (model) {
const evo_leasingobject_risk = model.evo_leasingobject_risk;
return LEASE_OBJECT_RISK[evo_leasingobject_risk];
}
}
},
insKaskoPriceLeasePeriod() {
const { leasingPeriod } = this.values;
const { rows } = this.tables.tableInsurance;
const kaskoRow = rows[1];
const dgoRow = rows[2];
const nsRow = rows[3];
if (
leasingPeriod &&
leasingPeriod > 15 &&
kaskoRow.insTerm.value === 100000001
) {
return (
(leasingPeriod / 12) *
(kaskoRow.insCost.value + dgoRow.insCost.value + nsRow.insCost.value)
).toFixed(2);
}
return 0;
},
};
export default computedEffects;