diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/tables.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/tables.ts index 3255687..182458b 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/tables.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/tables.ts @@ -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) { diff --git a/src/core/services/CrmService/graphql/query/options/insurance_options.graphql b/src/core/services/CrmService/graphql/query/options/insurance_options.graphql index a671cff..7058f20 100644 --- a/src/core/services/CrmService/graphql/query/options/insurance_options.graphql +++ b/src/core/services/CrmService/graphql/query/options/insurance_options.graphql @@ -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 } } diff --git a/src/core/services/CrmService/types/entities.ts b/src/core/services/CrmService/types/entities.ts index cf8ebcc..0088a43 100644 --- a/src/core/services/CrmService/types/entities.ts +++ b/src/core/services/CrmService/types/entities.ts @@ -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 {