Merge branch 'master' of https://github.com/vchikalkin/EvoCalculator
This commit is contained in:
commit
efd68ad079
@ -1,3 +1,4 @@
|
||||
import { openNotification } from 'client/Elements/Notification';
|
||||
import valuesConstants from 'core/constants/values';
|
||||
import { shiftRight } from 'core/tools/array';
|
||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||
@ -36,6 +37,40 @@ function validateInsuranceTable(this: ICalculationStore) {
|
||||
validation: !isNil(kaskoRow.insured),
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* если в СК ОСАГО поле evo_osago_with_kasko=True И СК ОСАГО != СК КАСКО,
|
||||
* то вывести и ошибку: "Невозможно страхование ОСАГО отдельно от КАСКО -
|
||||
* страховая компания должна быть одна!", иначе все ок
|
||||
*/
|
||||
const osagoInsuranceCompanyOption =
|
||||
this.tables?.tableInsurance?.options?.insuranceCompany?.find(
|
||||
x => x.accountid === osagoRow.insuranceCompany,
|
||||
);
|
||||
const invalid =
|
||||
osagoInsuranceCompanyOption?.evo_osago_with_kasko &&
|
||||
osagoRow.insuranceCompany !== kaskoRow.insuranceCompany;
|
||||
if (invalid)
|
||||
openNotification({
|
||||
type: 'error',
|
||||
message: 'Ошибка',
|
||||
description:
|
||||
'Невозможно страхование ОСАГО отдельно от КАСКО - страховая компания должна быть одна!',
|
||||
});
|
||||
this.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x?.key === 'osago'),
|
||||
)({
|
||||
insuranceCompany: {
|
||||
validation: !invalid,
|
||||
},
|
||||
});
|
||||
this.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x?.key === 'kasko'),
|
||||
)({
|
||||
insuranceCompany: {
|
||||
validation: !invalid,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function validatePaymentsTable(this: ICalculationStore) {
|
||||
|
||||
@ -3,7 +3,7 @@ import { resetIns } from 'client/Containers/Calculation/Components/ELT/lib/reset
|
||||
import { numberElementsProps } from 'client/Containers/Calculation/Elements/props/common';
|
||||
import {
|
||||
getTitle,
|
||||
getValueName,
|
||||
getValueName
|
||||
} from 'client/Containers/Calculation/Elements/tools';
|
||||
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
|
||||
import { openNotification } from 'client/Elements/Notification';
|
||||
@ -13,7 +13,7 @@ import {
|
||||
mainOptionsForQuoteQuery,
|
||||
quoteQuery,
|
||||
secondaryOptionsForQuoteQuery,
|
||||
singleOptionsForQuoteQuery,
|
||||
singleOptionsForQuoteQuery
|
||||
} from 'core/services/CrmService/graphql/query/quote';
|
||||
import { TOptionizedEntity } from 'core/services/CrmService/types/common';
|
||||
import {
|
||||
@ -21,7 +21,7 @@ import {
|
||||
IAccount,
|
||||
IEvoGraph,
|
||||
IEvoTown,
|
||||
IQuote,
|
||||
IQuote
|
||||
} from 'core/services/CrmService/types/entities';
|
||||
import { currentISODate } from 'core/tools/date';
|
||||
import { NIL } from 'core/tools/uuid';
|
||||
@ -40,10 +40,12 @@ const map_add_product_types_to_values = {
|
||||
fuelCard: 100000005,
|
||||
};
|
||||
|
||||
const tablePaymentsStatuses = (graphType, leasingPeriod) => {
|
||||
const tablePaymentsStatuses = (graphType, seasonType, leasingPeriod) => {
|
||||
switch (graphType) {
|
||||
case 100000001: {
|
||||
return Array.from({ length: leasingPeriod - 3 }, (_, i) => i + 2);
|
||||
if (seasonType === 100_000_007)
|
||||
return Array.from({ length: leasingPeriod - 3 }, (_, i) => i + 2);
|
||||
break;
|
||||
}
|
||||
case 100000003: {
|
||||
return Array.from({ length: 12 }, (_, i) => i + 1);
|
||||
@ -248,16 +250,18 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
||||
(a, b) => b.createdon - a.createdon,
|
||||
)[0];
|
||||
if (evo_graph.evo_planpayments) {
|
||||
const statuses = tablePaymentsStatuses(
|
||||
quote.evo_graph_type,
|
||||
quote.evo_seasons_type,
|
||||
quote.evo_period,
|
||||
);
|
||||
const payments = evo_graph.evo_planpayments
|
||||
.slice(1, evo_graph.evo_planpayments.length - 1)
|
||||
.map((evo_planpayment, i) => ({
|
||||
paymentRelation: {
|
||||
validation: undefined,
|
||||
value: evo_planpayment.evo_payment_ratio,
|
||||
status: tablePaymentsStatuses(
|
||||
quote.evo_graph_type,
|
||||
quote.evo_period,
|
||||
)?.includes(i + 1)
|
||||
status: statuses?.includes(i + 1)
|
||||
? ElementStatus.Default
|
||||
: ElementStatus.Disabled,
|
||||
},
|
||||
|
||||
@ -8,7 +8,6 @@ import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { ValuesNames } from 'core/types/Calculation/Store/values';
|
||||
import { ElementStatus } from 'types/elements';
|
||||
import { convertPrice } from '../lib/tools';
|
||||
import { getPrice } from './priceReactions/calculate';
|
||||
|
||||
const reactionEffects: IReactionEffect[] = [
|
||||
@ -91,21 +90,23 @@ const reactionEffects: IReactionEffect[] = [
|
||||
expression: () => {
|
||||
const {
|
||||
supplierDiscountRub,
|
||||
leaseObjectPrice,
|
||||
supplierCurrency,
|
||||
leaseObjectPriceWthtVAT,
|
||||
recalcWithRevision,
|
||||
} = calculationStore.values;
|
||||
|
||||
//@ts-ignore
|
||||
const price = calculationStore.plPriceRub();
|
||||
return [
|
||||
supplierDiscountRub,
|
||||
leaseObjectPrice,
|
||||
supplierCurrency,
|
||||
price,
|
||||
leaseObjectPriceWthtVAT,
|
||||
recalcWithRevision,
|
||||
];
|
||||
},
|
||||
effect: ([
|
||||
supplierDiscountRub,
|
||||
leaseObjectPrice,
|
||||
supplierCurrencyId,
|
||||
price,
|
||||
leaseObjectPriceWthtVAT,
|
||||
recalcWithRevision,
|
||||
]) => {
|
||||
if (!recalcWithRevision) {
|
||||
@ -113,43 +114,50 @@ const reactionEffects: IReactionEffect[] = [
|
||||
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,
|
||||
leaseObjectPrice,
|
||||
evo_currencychangeValue,
|
||||
);
|
||||
const product = calculationStore.getOption('selectProduct');
|
||||
|
||||
const quote = calculationStore.getOption('selectQuote');
|
||||
if (
|
||||
|
||||
const maxCondition1 =
|
||||
quote?.evo_max_price_change &&
|
||||
price - supplierDiscountRub > quote.evo_max_price_change
|
||||
) {
|
||||
!product?.evo_sale_without_nds &&
|
||||
price - supplierDiscountRub > quote.evo_max_price_change;
|
||||
|
||||
const maxCondition2 =
|
||||
quote?.evo_max_price_change &&
|
||||
product?.evo_sale_without_nds &&
|
||||
leaseObjectPriceWthtVAT >
|
||||
quote.evo_max_price_change -
|
||||
(quote.evo_nds_in_price_supplier_currency || 0);
|
||||
|
||||
const minCondition1 =
|
||||
quote?.evo_min_change_price &&
|
||||
!product?.evo_sale_without_nds &&
|
||||
price - supplierDiscountRub < quote.evo_min_change_price;
|
||||
|
||||
const minCondition2 =
|
||||
quote?.evo_min_change_price &&
|
||||
product?.evo_sale_without_nds &&
|
||||
leaseObjectPriceWthtVAT <
|
||||
quote.evo_min_change_price -
|
||||
(quote.evo_nds_in_price_supplier_currency || 0);
|
||||
|
||||
if (maxCondition1 || maxCondition2) {
|
||||
calculationStore.setValidation('tbxLeaseObjectPrice', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
message: 'Ошибка',
|
||||
description:
|
||||
'Указанная стоимость предмета лизинга больше возмножного изменения стоимости предмета лизинга при пересчете без пересмотра. ' +
|
||||
'Указанная стоимость предмета лизинга больше возможного изменения стоимости предмета лизинга при пересчете без пересмотра. ' +
|
||||
'Уменьшите стоимость предмета лизинга',
|
||||
});
|
||||
} else if (
|
||||
quote?.evo_min_change_price &&
|
||||
price - supplierDiscountRub < quote.evo_min_change_price
|
||||
) {
|
||||
} else if (minCondition1 || minCondition2) {
|
||||
calculationStore.setValidation('tbxLeaseObjectPrice', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
message: 'Ошибка',
|
||||
description:
|
||||
'Указанная стоимость предмета лизинга меньше возмножного изменения стоимости предмета лизинга при пересчете без пересмотра. ' +
|
||||
'Указанная стоимость предмета лизинга меньше возможного изменения стоимости предмета лизинга при пересчете без пересмотра. ' +
|
||||
'Увеличьте стоимость предмета лизинга',
|
||||
});
|
||||
} else {
|
||||
|
||||
@ -11,5 +11,6 @@ query GetInsuranceOptions($evo_account_type: [Int!], $statecode: Int) {
|
||||
evo_id_elt_osago
|
||||
evo_legal_region_calc
|
||||
evo_inn
|
||||
evo_osago_with_kasko
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,6 +60,7 @@ export interface IAccount extends BaseEntity {
|
||||
evo_id_elt?: string;
|
||||
evo_id_elt_osago?: string;
|
||||
evo_legal_region_calc?: boolean;
|
||||
evo_osago_with_kasko?: boolean;
|
||||
}
|
||||
|
||||
export interface ISalonProvider extends IAccount {
|
||||
@ -102,6 +103,7 @@ export interface IOpportunity extends BaseEntity {
|
||||
}
|
||||
|
||||
export interface IQuote extends BaseEntity {
|
||||
evo_seasons_type?: number;
|
||||
evo_engine_hours?: number;
|
||||
evo_client_riskid?: string;
|
||||
evo_addproduct_types?: IEvoAddproductType[];
|
||||
@ -140,6 +142,7 @@ export interface IQuote extends BaseEntity {
|
||||
evo_last_payment_perc?: number;
|
||||
evo_min_change_price?: number;
|
||||
evo_max_price_change?: number;
|
||||
evo_nds_in_price_supplier_currency?: number;
|
||||
evo_max_mass?: number;
|
||||
evo_seats?: number;
|
||||
evo_year?: number;
|
||||
|
||||
Reference in New Issue
Block a user