From 0c1ad970b3c9819ba50761f98355c22428c94111 Mon Sep 17 00:00:00 2001 From: Chika Date: Mon, 18 Apr 2022 13:18:52 +0300 Subject: [PATCH] merge release/dyn-1032_used-without-nds --- .../Components/Results/resultsList.ts | 1 + .../Components/Sections/sectionsList.ts | 204 +++++++--- .../Calculation/Elements/components.ts | 4 + .../Calculation/Elements/props/common.ts | 36 +- .../Calculation/Elements/tables/payments.ts | 2 +- .../Containers/Calculation/Elements/titles.ts | 12 +- .../Containers/Calculation/Elements/values.ts | 4 + .../Calculation/lib/renderSections.js | 5 +- .../Containers/Calculation/types/elements.ts | 6 +- src/client/Elements/Label.jsx | 2 +- src/client/Elements/Radio.jsx | 9 +- .../process/configurator/reactions/filters.ts | 135 +++++++ .../process/configurator/reactions/index.js | 7 + .../configurator/reactions/validation.ts | 36 ++ .../process/configurator/reactions/values.ts | 69 ++++ src/client/process/used-pl/reactions.ts | 285 +++++++++++++ .../Effects/actions/calculate/prepareData.ts | 99 +++-- .../Effects/actions/calculate/results.ts | 7 +- .../actions/calculate/validate/elements.ts | 4 +- .../Effects/reactions/loadKpReaction/index.ts | 13 +- .../reactions/loadKpReaction/mapKpToValues.ts | 2 + .../Effects/reactions/otherReactions.ts | 326 +++------------ .../Effects/reactions/priceReactions/index.ts | 51 +++ .../reactions/recalcWoRevisionReactions.ts | 3 +- .../Effects/reactions/tablesReactions.ts | 98 ++--- .../CalculationStore/config/initialOptions.ts | 6 + .../config/initialStatuses.ts | 2 + .../CalculationStore/config/initialValues.ts | 3 + src/client/stores/CalculationStore/index.ts | 4 + .../CoreService/types/Calculation/prepared.ts | 2 + .../query/options/main_options.graphql | 1 + .../query/quote/fragments/quoteFields.graphql | 3 + .../CrmService/graphql/schema.graphql | 377 ++++++++++++++++-- .../services/CrmService/types/entities.ts | 3 + src/core/types/Calculation/Store/values.ts | 6 +- 35 files changed, 1349 insertions(+), 478 deletions(-) create mode 100644 src/client/process/configurator/reactions/filters.ts create mode 100644 src/client/process/configurator/reactions/index.js create mode 100644 src/client/process/configurator/reactions/validation.ts create mode 100644 src/client/process/configurator/reactions/values.ts create mode 100644 src/client/process/used-pl/reactions.ts diff --git a/src/client/Containers/Calculation/Components/Results/resultsList.ts b/src/client/Containers/Calculation/Components/Results/resultsList.ts index 17ded19..8d02712 100644 --- a/src/client/Containers/Calculation/Components/Results/resultsList.ts +++ b/src/client/Containers/Calculation/Components/Results/resultsList.ts @@ -38,6 +38,7 @@ export const calculationResults: ISection[] = [ 'labelResultDopProdSum', 'labelResultFirstPayment', 'labelResultLastPayment', + 'labelResultFirstPaymentRiskPolicy', 'labelResultTerm', 'labelResultAB_FL', 'labelResultAB_UL', diff --git a/src/client/Containers/Calculation/Components/Sections/sectionsList.ts b/src/client/Containers/Calculation/Components/Sections/sectionsList.ts index 19e9452..4905f72 100644 --- a/src/client/Containers/Calculation/Components/Sections/sectionsList.ts +++ b/src/client/Containers/Calculation/Components/Sections/sectionsList.ts @@ -19,38 +19,58 @@ const sections: ISection[] = [ ], }, { + style: { columnsNumber: 3 }, + blocks: [ + { elements: ['tbxLeaseObjectPrice', 'selectSupplierCurrency'] }, + { + elements: ['tbxVATInLeaseObjectPrice', 'tbxSupplierDiscountRub'], + }, + { + elements: ['tbxLeaseObjectPriceWthtVAT', 'tbxSupplierDiscountPerc'], + }, + ], + }, + { + style: { columnsNumber: 3 }, + blocks: [ + { elements: ['tbxFirstPaymentPerc'] }, + { elements: ['tbxFirstPaymentRub'] }, + ], + }, + + { + style: { columnsNumber: 3 }, blocks: [ { - elements: [ - 'selectSupplierCurrency', - 'tbxLeaseObjectPrice', - 'tbxSupplierDiscountRub', - 'tbxSupplierDiscountPerc', - // 'radioBalanceHolder', - 'tbxRedemptionPaymentSum', - 'tbxSaleBonus', - 'selectSubsidy', - ], + elements: ['tbxLeasingPeriod'], }, { - // title: 'Параметры договора лизинга', - elements: [ - 'tbxFirstPaymentPerc', - 'tbxFirstPaymentRub', - 'radioLastPaymentRule', - 'tbxLastPaymentPerc', - 'tbxLastPaymentRub', - 'tbxLeasingPeriod', - 'labelSubsidySum', - ], + elements: ['tbxSaleBonus'], }, + { + elements: ['tbxRedemptionPaymentSum'], + }, + ], + }, + { + style: { gridTemplateColumns: '2fr 1fr' }, + blocks: [ + { elements: ['selectSubsidy'] }, + { elements: ['labelSubsidySum'] }, + ], + }, + { + style: { columnsNumber: 3 }, + blocks: [ { - // title: 'Параметры расчета', - elements: [ - // 'tbxComissionPerc', - // 'tbxComissionRub', - ], + elements: ['tbxLastPaymentPerc'], + }, + { + elements: ['tbxLastPaymentRub'], + }, + { + elements: ['radioLastPaymentRule'], }, ], }, @@ -84,36 +104,80 @@ const sections: ISection[] = [ }, ], }, + { title: 'ПЛ', groups: [ { + style: { + gridTemplateColumns: '2fr 1fr', + }, blocks: [ { - elements: [ - 'selectLeaseObjectType', - 'selectBrand', - 'selectModel', - 'selectConfiguration', - ], + elements: ['selectLeaseObjectType'], }, { - title: ' ', - elements: [ - 'labelLeaseObjectRisk', - 'labelDepreciationGroup', - 'cbxLeaseObjectUsed', - 'radioDeliveryTime', - ], + elements: ['labelDepreciationGroup'], }, ], }, { + style: { + gridTemplateColumns: '2fr 1fr', + }, + blocks: [ + { + elements: ['selectBrand'], + }, + { + elements: ['cbxLeaseObjectUsed'], + }, + ], + }, + { + style: { + gridTemplateColumns: '2fr 1fr', + }, + blocks: [ + { + elements: ['selectModel'], + }, + { + elements: ['cbxWithTrailer'], + }, + ], + }, + { + style: { + gridTemplateColumns: '2fr 1fr', + }, + blocks: [ + { + elements: ['selectConfiguration'], + }, + { + elements: ['radioDeliveryTime'], + }, + ], + }, + { + style: { + columnsNumber: 1, + }, + blocks: [ + { + elements: ['selectLeaseObjectUseFor'], + }, + ], + }, + { + style: { + columnsNumber: 3, + }, blocks: [ { elements: [ 'tbxLeaseObjectCount', - 'selectLeaseObjectUseFor', 'tbxLeaseObjectYear', 'selectLeaseObjectCategory', ], @@ -123,16 +187,10 @@ const sections: ISection[] = [ 'selectEngineType', 'tbxLeaseObjectMotorPower', 'tbxEngineVolume', - 'tbxMaxMass', ], }, { - elements: [ - 'tbxCountSeats', - 'tbxMaxSpeed', - 'tbxMileage', - 'cbxWithTrailer', - ], + elements: ['tbxMaxSpeed', 'tbxCountSeats', 'tbxMileage'], }, ], }, @@ -271,28 +329,47 @@ const sections: ISection[] = [ }, ], }, + { title: 'Доп. продукты', groups: [ { + style: { + gridTemplateColumns: '2fr 1.5fr 1.5fr', + }, title: 'Регистрация', + blocks: [ + { + elements: ['radioObjectRegistration'], + }, + { + elements: ['radioTypePTS'], + }, + ], + }, + { + style: { + gridTemplateColumns: '2fr 1.5fr 1.5fr', + }, blocks: [ { elements: [ - 'radioObjectRegistration', 'selectRegionRegistration', 'selectTownRegistration', 'selectObjectRegionRegistration', - 'tbxLeaseObjectYear', - 'tbxLeaseObjectMotorPower', ], }, { elements: [ - 'radioTypePTS', + 'tbxLeaseObjectYear', + 'tbxLeaseObjectMotorPower', + 'tbxVehicleTaxInYear', + ], + }, + { + elements: [ 'selectObjectCategoryTax', 'selectObjectTypeTax', - 'tbxVehicleTaxInYear', 'tbxVehicleTaxInLeasingPeriod', ], }, @@ -308,17 +385,24 @@ const sections: ISection[] = [ }, { title: 'Доп. продукты', - style: { columnsNumber: 1 }, + style: { gridTemplateColumns: '2fr 3fr' }, blocks: [ { - elements: [ - 'selectTechnicalCard', - // 'selectFuelCard', - 'selectInsNSIB', - 'radioRequirementTelematic', - 'selectTracker', - 'selectTelematic', - ], + elements: ['selectTechnicalCard'], + }, + { + elements: ['selectInsNSIB'], + }, + ], + }, + { + style: { + gridTemplateColumns: '2fr 3fr', + }, + blocks: [ + { elements: ['radioRequirementTelematic'] }, + { + elements: ['selectTracker', 'selectTelematic'], }, ], }, diff --git a/src/client/Containers/Calculation/Elements/components.ts b/src/client/Containers/Calculation/Elements/components.ts index 863e5f4..b3f5938 100644 --- a/src/client/Containers/Calculation/Elements/components.ts +++ b/src/client/Containers/Calculation/Elements/components.ts @@ -18,6 +18,8 @@ export default { selectClientType: Select, selectSupplierCurrency: Select, tbxLeaseObjectPrice: InputNumber, + tbxLeaseObjectPriceWthtVAT: InputNumber, + tbxVATInLeaseObjectPrice: InputNumber, tbxSupplierDiscountRub: InputNumber, tbxSupplierDiscountPerc: InputNumber, radioBalanceHolder: Radio, @@ -115,6 +117,7 @@ export default { cbxRecalcWithRevision: Checkbox, tbxIRR_Perc: InputNumber, tbxMileage: InputNumber, + tbxEngineHours: InputNumber, radioCalcType: Radio, tbxTotalPayments: InputNumber, radioObjectRegistration: Radio, @@ -155,6 +158,7 @@ export default { labelResultDopMPLLeasing: Label, labelResultBonusDopProd: Label, labelResultBonusSafeFinance: Label, + labelResultFirstPaymentRiskPolicy: Label, /** Button Elements */ btnCreateKP: Button, diff --git a/src/client/Containers/Calculation/Elements/props/common.ts b/src/client/Containers/Calculation/Elements/props/common.ts index bd06674..2443935 100644 --- a/src/client/Containers/Calculation/Elements/props/common.ts +++ b/src/client/Containers/Calculation/Elements/props/common.ts @@ -9,12 +9,32 @@ import { AllElementsNames, ElementsNames } from '../../types/elements'; const elementsProps: Partial> = { tbxLeaseObjectPrice: { - min: '1000.00', + min: '0.00', max: '1000000000.00', step: '10000.00', precision: 2, formatter: formatNumber, }, + tbxLeaseObjectPriceWthtVAT: { + min: '0.00', + max: '1000000000.00', + step: '10000.00', + precision: 2, + formatter: formatNumber, + }, + tbxVATInLeaseObjectPrice: { + min: '0.00', + max: '1000000000.00', + step: '10000.00', + precision: 2, + formatter: formatNumber, + }, + tbxEngineHours: { + min: '0.0', + step: '10.0', + precision: 2, + formatter: formatNumber, + }, tbxSupplierDiscountRub: { min: '0', max: '1000000000', @@ -52,7 +72,7 @@ const elementsProps: Partial> = { formatter: formatNumber, }, radioLastPaymentRule: { - style: 'button', + // style: 'button', }, tbxLastPaymentPerc: { min: '0', @@ -236,7 +256,12 @@ const elementsProps: Partial> = { }, tbxMaxPriceChange: { min: '0', - max: '1000000000', + max: '34999990', + step: '10000.00', + }, + tbxMinPriceChange: { + min: '0', + max: '34999990', step: '10000.00', }, tbxImporterRewardPerc: { @@ -298,10 +323,10 @@ const elementsProps: Partial> = { formatter: formatNumber, }, radioObjectRegistration: { - style: 'button', + // style: 'button', }, radioTypePTS: { - style: 'button', + // style: 'button', }, tbxVehicleTaxInYear: { min: '0', @@ -380,6 +405,7 @@ const numberResultElementsProps = ( 'labelResultIRRGraphPerc', 'labelResultIRRNominalPerc', 'labelResultTerm', + 'labelResultFirstPaymentRiskPolicy', ] as ElementsNames[] ).reduce( (ac, a) => ({ diff --git a/src/client/Containers/Calculation/Elements/tables/payments.ts b/src/client/Containers/Calculation/Elements/tables/payments.ts index 5b1c49d..81a5800 100644 --- a/src/client/Containers/Calculation/Elements/tables/payments.ts +++ b/src/client/Containers/Calculation/Elements/tables/payments.ts @@ -27,7 +27,7 @@ const callbacks: Table['callbacks'] = { const rowLength = calculationStore.tables[tableName].rows.length; const { graphType, seasonType } = calculationStore.values; - if (graphType === 100000001 && !seasonType) { + if (graphType === 100000001 && seasonType === 100_000_007) { if (rowIndex > 1 && rowIndex < rowLength - 1) { if ( calculationStore.tables[tableName].rows[rowIndex].paymentRelation diff --git a/src/client/Containers/Calculation/Elements/titles.ts b/src/client/Containers/Calculation/Elements/titles.ts index 6b9237d..2fa6c00 100644 --- a/src/client/Containers/Calculation/Elements/titles.ts +++ b/src/client/Containers/Calculation/Elements/titles.ts @@ -8,7 +8,7 @@ export const elementsTitles: Partial> = { selectProduct: 'Продукт', selectClientRisk: 'Риск клиента', selectClientType: 'Тип клиента', - tbxLeaseObjectPrice: 'Стоимость предмета лизинга', + tbxLeaseObjectPrice: 'Стоимость ПЛ с НДС', selectSupplierCurrency: 'Валюта поставщика', tbxSupplierDiscountRub: 'Скидка от поставщика', tbxSupplierDiscountPerc: 'Скидка от поставщика, %', @@ -109,9 +109,9 @@ export const elementsTitles: Partial> = { tbxTotalPayments: 'Сумма платежей', radioObjectRegistration: 'На кого регистрируется ТС', selectObjectRegionRegistration: 'Регион регистрации в ГИБДД', - tbxVehicleTaxInYear: 'Транспортный налог, в год', - tbxVehicleTaxInLeasingPeriod: 'Транспортный налог на срок ДЛ', - selectObjectCategoryTax: 'Категория в соответствии с ТР ТС 018/2011', + tbxVehicleTaxInYear: 'Трансп. налог, в год', + tbxVehicleTaxInLeasingPeriod: 'Трансп. налог на срок ДЛ', + selectObjectCategoryTax: 'Кат. по ТР ТС 018/2011', selectObjectTypeTax: 'Тип ТС для ТН', radioTypePTS: 'Тип ПТС', labelRegistrationDescription: 'Описание регистрации', @@ -122,6 +122,9 @@ export const elementsTitles: Partial> = { labelSubsidySum: 'Сумма субсидии с НДС', selectFuelCard: 'Топливная карта', tbxMinPriceChange: 'Мин. возможное изменение стоимости ПЛ', + tbxEngineHours: 'Моточасы', + tbxLeaseObjectPriceWthtVAT: 'Стоимость ПЛ без НДС', + tbxVATInLeaseObjectPrice: 'НДС в стоимости ПЛ', /** Result Elements */ labelResultTotalGraphwithNDS: 'Итого по графику, с НДС', @@ -141,6 +144,7 @@ export const elementsTitles: Partial> = { labelResultDopMPLLeasing: 'Доп.бонус МПЛ за лизинг, без НДФЛ', labelResultBonusDopProd: 'Бонус МПЛ за доп.продукты, без НДФЛ', labelResultBonusSafeFinance: 'Бонус за Safe Finance без НДФЛ', + labelResultFirstPaymentRiskPolicy: 'Первый платеж по риск политике, %', }; export const tablesTitles: Record = { diff --git a/src/client/Containers/Calculation/Elements/values.ts b/src/client/Containers/Calculation/Elements/values.ts index ec85204..59bf090 100644 --- a/src/client/Containers/Calculation/Elements/values.ts +++ b/src/client/Containers/Calculation/Elements/values.ts @@ -20,6 +20,9 @@ const elementsValues: Record = { selectClientRisk: 'clientRisk', selectClientType: 'clientType', tbxLeaseObjectPrice: 'leaseObjectPrice', + tbxLeaseObjectPriceWthtVAT: 'leaseObjectPriceWthtVAT', + tbxVATInLeaseObjectPrice: 'VATInLeaseObjectPrice', + tbxEngineHours: 'engineHours', selectSupplierCurrency: 'supplierCurrency', tbxSupplierDiscountRub: 'supplierDiscountRub', tbxSupplierDiscountPerc: 'supplierDiscountPerc', @@ -148,6 +151,7 @@ const elementsValues: Record = { labelResultDopMPLLeasing: 'resultDopMPLLeasing', labelResultBonusDopProd: 'resultBonusDopProd', labelResultBonusSafeFinance: 'resultBonusSafeFinance', + labelResultFirstPaymentRiskPolicy: 'resultFirstPaymentRiskPolicy', }; const elementsComputedValues: Record< diff --git a/src/client/Containers/Calculation/lib/renderSections.js b/src/client/Containers/Calculation/lib/renderSections.js index 6f8125a..6988696 100644 --- a/src/client/Containers/Calculation/lib/renderSections.js +++ b/src/client/Containers/Calculation/lib/renderSections.js @@ -46,8 +46,9 @@ const ElementsGrid = styled(Box)` grid-template-columns: 1fr; ${mq.laptop` - grid-template-columns: repeat(${props => - props.columnsNumber || props.defaultColumnsNumber}, 1fr); + grid-template-columns:${props => + props.gridTemplateColumns || + `repeat(${props.columnsNumber || props.defaultColumnsNumber},1fr)`} `} `; diff --git a/src/client/Containers/Calculation/types/elements.ts b/src/client/Containers/Calculation/types/elements.ts index 2ed54d7..ee927f3 100644 --- a/src/client/Containers/Calculation/types/elements.ts +++ b/src/client/Containers/Calculation/types/elements.ts @@ -133,7 +133,11 @@ export type ElementsNames = | 'labelResultBonusMPL' | 'labelResultDopMPLLeasing' | 'labelResultBonusDopProd' - | 'labelResultBonusSafeFinance'; + | 'labelResultBonusSafeFinance' + | 'labelResultFirstPaymentRiskPolicy' + | 'tbxLeaseObjectPriceWthtVAT' + | 'tbxVATInLeaseObjectPrice' + | 'tbxEngineHours'; export type ButtonElementsNames = 'btnCreateKP' | 'btnCalculate'; export type LinkElementsNames = 'linkDownloadKp'; diff --git a/src/client/Elements/Label.jsx b/src/client/Elements/Label.jsx index ff8ec2d..9aec46e 100644 --- a/src/client/Elements/Label.jsx +++ b/src/client/Elements/Label.jsx @@ -7,7 +7,7 @@ const Text = styled.span` font-size: 0.85rem; `; -const Label = ({ value, middleware }) => { +const Label = ({ value = '-', middleware }) => { //TODO: Hide if no value return ( diff --git a/src/client/Elements/Radio.jsx b/src/client/Elements/Radio.jsx index 9547ba9..86827bf 100644 --- a/src/client/Elements/Radio.jsx +++ b/src/client/Elements/Radio.jsx @@ -25,13 +25,18 @@ const Radio = ({ {options.map((option, i) => { if (style === 'button') { return ( - + {option.name} ); } return ( - + {option.name} ); diff --git a/src/client/process/configurator/reactions/filters.ts b/src/client/process/configurator/reactions/filters.ts new file mode 100644 index 0000000..922fc4f --- /dev/null +++ b/src/client/process/configurator/reactions/filters.ts @@ -0,0 +1,135 @@ +import CalculationStore from 'client/stores/CalculationStore'; +import { pipe } from 'core/tools/func'; +import { ICalculationStore } from 'core/types/Calculation/Store'; +import { Process } from 'core/types/Calculation/Store/process'; +import { difference } from 'lodash'; +import { reaction } from 'mobx'; + +export default function ($calculation: ICalculationStore) { + reaction( + () => ({ + product: $calculation.getOption('selectProduct'), + subsidy: $calculation.getOption('selectSubsidy'), + }), + ({ product, subsidy }) => { + /** + * + * @description + #1 + * DYN-190 При выборе значения в поле selectSubsidy необходимо добавить + * фильтрацию в полях при условии что selectSubsidy не равно null: + + Тип предмета лизинга selectLeaseObjectType + если с записью Субсидия нет связанных Типов предмета лизинга, + то указываются все записи согласно текущей фильтрации, + иначе указываются те записи, которые связаны с Субсидией, указанной в поле selectSubsidy + + #2 + * На изменение поля Продукт selectProduct добавляем фильтрацию списков: + в поле Тип предмета лизинга selectLeaseObjectType - указываются те, которые связаны с продуктом. + Если с Продуктом нет связанных Типов предмета лизинга, + то указывается весь список. Это надо добавить в текущие условия фильтрации данного поля + */ + $calculation.setFilter('selectLeaseObjectType', types => + types.filter( + pipe( + type => + (!product?.evo_leasingobject_types?.length || + product.evo_leasingobject_types.filter( + x => + x.evo_leasingobject_typeid === + type?.evo_leasingobject_typeid, + )?.length) && + type, + type => + //@ts-ignore + type && + (!subsidy?.evo_leasingobject_types?.length || + subsidy.evo_leasingobject_types.filter( + x => + x.evo_leasingobject_typeid === + type.evo_leasingobject_typeid, + )?.length), + ), + ), + ); + + $calculation.setFilter('selectDealer', dealers => + dealers.filter( + dealer => + !subsidy?.accounts?.length || + subsidy.accounts.filter(x => x.accountid === dealer.accountid) + ?.length, + ), + ); + + $calculation.setFilter('selectDealerPerson', dealerPersons => + dealerPersons.filter( + dealerPerson => + !subsidy?.accounts?.length || + subsidy.accounts.filter(x => x.accountid === dealerPerson.accountid) + ?.length, + ), + ); + }, + ); + + reaction( + () => $calculation.getOption('selectTarif'), + tarif => { + /** + * @description + * На изменение поля Тариф selectTarif добавляем фильрацию в полях: + в поле Вид графика radioGraphType должны закрываться значения для выбора, + которые указаны в массиве поля "Недопустимые виды графиков" evo_graphtype_exception. + Если в массиве пусто, значит допустимы все значения + */ + + const graphTypes = $calculation.getOptions('radioGraphType'); + const filteredGraphTypes = graphTypes?.map(type => ({ + ...type, + disabled: tarif?.evo_graphtype_exception?.includes(type.value), + })); + $calculation.setOptions( + 'radioGraphType', + //@ts-ignore + filteredGraphTypes, + ); + if (!$calculation.stores.calculationProcess.hasProcess(Process.LoadKp)) { + const graphTypeValue = $calculation.getValue('graphType'); + if ( + !filteredGraphTypes + ?.filter(x => !x.disabled) + ?.map(x => x.value) + .includes(graphTypeValue) + ) + CalculationStore.setValue('graphType', null); + } + }, + ); + + /** + * @description + * в поле Тип дегрессии/сезонности selectSeasonType должны отображаться только те значения, + * которых нет в массиве поля "Недопустимые Типы дегрессий/сезонности" evo_seasons_type_exception + * (добавить в текущую фильтрацию поля) + */ + reaction( + () => { + return { + tarif: $calculation.getOption('selectTarif'), + graphType: $calculation.getOption('radioGraphType'), + }; + }, + ({ tarif, graphType }) => { + const exeption = tarif?.evo_seasons_type_exception || []; + const includes = graphType?.seasonTypes; + + const targetValues = difference(includes, exeption); + + $calculation.setFilter('selectSeasonType', options => + options.filter(x => targetValues.includes(x.value)), + ); + }, + ); +} diff --git a/src/client/process/configurator/reactions/index.js b/src/client/process/configurator/reactions/index.js new file mode 100644 index 0000000..6c6ce0c --- /dev/null +++ b/src/client/process/configurator/reactions/index.js @@ -0,0 +1,7 @@ +import filters from './filters'; +import validation from './validation'; +import values from './values'; + +const configuratorReactions = [filters, validation, values]; +export const injectConfiguratorReactions = calculationStore => + configuratorReactions.map(injector => injector(calculationStore)); diff --git a/src/client/process/configurator/reactions/validation.ts b/src/client/process/configurator/reactions/validation.ts new file mode 100644 index 0000000..db55472 --- /dev/null +++ b/src/client/process/configurator/reactions/validation.ts @@ -0,0 +1,36 @@ +import { openNotification } from 'client/Elements/Notification'; +import { ICalculationStore } from 'core/types/Calculation/Store'; +import { reaction } from 'mobx'; + +export default function ($calculation: ICalculationStore) { + /** + * @description + * На изменение поля Процет убывания платежей tbxParmentsDecreasePercent необходимо заложить проверку: + * Если значение поля меньше значения в поле "Минимальный % убывания платежей" evo_min_decreasing_perc из записи, + * указанной в поле ТарифselectTarif , то поле Процет убывания платежей tbxParmentsDecreasePercent должно обводиться красной рамкой + * и выводиться сообщение "Процент убывания не может быть меньше минимального значения по данному тарифу + - <указывается значение из поля "Минимальный % убывания платежей">, иначе красная рамка снимается. + * При красной рамке в данном поле нельзя осуществить расчет графика. + */ + reaction( + () => { + const { parmentsDecreasePercent } = $calculation.values; + return { + parmentsDecreasePercent, + tarif: $calculation.getOption('selectTarif'), + }; + }, + ({ parmentsDecreasePercent, tarif }) => { + if (parmentsDecreasePercent < tarif?.evo_min_decreasing_perc) { + $calculation.setValidation('tbxParmentsDecreasePercent', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: `Процент убывания не может быть меньше минимального значения по данному тарифу - ${tarif?.evo_min_decreasing_perc}`, + }); + } else { + $calculation.setValidation('tbxParmentsDecreasePercent', undefined); + } + }, + ); +} diff --git a/src/client/process/configurator/reactions/values.ts b/src/client/process/configurator/reactions/values.ts new file mode 100644 index 0000000..971f03c --- /dev/null +++ b/src/client/process/configurator/reactions/values.ts @@ -0,0 +1,69 @@ +import { ICalculationStore } from 'core/types/Calculation/Store'; +import { Process } from 'core/types/Calculation/Store/process'; +import { reaction } from 'mobx'; + +export default function ($calculation: ICalculationStore) { + reaction( + () => { + const { + product, + leasingPeriod, + deliveryTime, + firstPaymentPerc, + lastPaymentPerc, + } = $calculation.values; + return { + product_evo_id: product, + leasingPeriod, + deliveryTime, + firstPaymentPerc, + lastPaymentPerc, + }; + }, + ({ + product_evo_id, + leasingPeriod, + deliveryTime, + firstPaymentPerc, + lastPaymentPerc, + }) => { + if (product_evo_id && leasingPeriod && deliveryTime) { + const product = $calculation.getOption('selectProduct', { + evo_id: product_evo_id, + }); + if (product) { + const tarif = $calculation.options.selectTarif?.find( + x => + x.evo_baseproductid === product.evo_baseproductid && + x.evo_min_period <= leasingPeriod && + x.evo_max_period >= leasingPeriod && + x.evo_delivery_time?.includes(deliveryTime) && + x.evo_min_first_payment <= firstPaymentPerc && + x.evo_max_first_payment >= firstPaymentPerc && + x.evo_min_last_payment <= lastPaymentPerc && + x.evo_max_last_payment >= lastPaymentPerc, + ); + $calculation.setValue('tarif', tarif?.evo_tarifid); + } + } else { + $calculation.setValue('tarif', null); + } + }, + ); + + reaction( + () => $calculation.values.tarif, + tarifid => { + const { calculationProcess } = $calculation.stores; + if (calculationProcess.hasProcess(Process.LoadKp)) { + return; + } + + const tarif = $calculation.getOption('selectTarif', { + evo_tarifid: tarifid, + }); + + $calculation.setValue('IRR_Perc', tarif?.evo_irr); + }, + ); +} diff --git a/src/client/process/used-pl/reactions.ts b/src/client/process/used-pl/reactions.ts new file mode 100644 index 0000000..f290fa8 --- /dev/null +++ b/src/client/process/used-pl/reactions.ts @@ -0,0 +1,285 @@ +import { openNotification } from 'client/Elements/Notification'; +import { ICalculationStore } from 'core/types/Calculation/Store'; +import { Process } from 'core/types/Calculation/Store/process'; +import { reaction } from 'mobx'; +import { ElementStatus } from 'types/elements'; + +export default function ($calculation: ICalculationStore) { + /** + * + * @description + * Создаем реакцию на выбор Продукта selectProduct: + +Если в поле Продукт selectProduct значение не выбрано, то + поле Валюта поставщика selectSupplierCurrency закрыть для редактирования и сделать равным RUB + поле Скидка от поставщика tbxSupplierDiscountRub закрыть для редактирования и сделать равным 0 + поле Скидка от поставщика, % tbxSupplierDiscountPerc закрыть для редактирования и сделать равным 0 + поле Стоимость предмета лизинга с НДС tbxLeaseObjectPrice закрыть для редактирования + поле Стоимость предмета лизинга без НДС xxx закрыть для редактирования + поле НДС в стоимости предмета лизинга xxx закрыть для редактирования + +Если в поле Продукт selectProduct выбрана запись, у которой БУбезНДС evo_sale_without_nds = True, то: + поле ПЛ БУ cbxLeaseObjectUsed =True и закрыто для редактирования + поле Валюта поставщика selectSupplierCurrency закрыть для редактирования и сделать равным RUB + поле Скидка от поставщика tbxSupplierDiscountRub закрыть для редактирования и сделать равным 0 + поле Скидка от поставщика, % tbxSupplierDiscountPerc закрыть для редактирования и сделать равным 0 + поле Стоимость предмета лизинга с НДС tbxLeaseObjectPrice закрыть для редактирования + поле Стоимость предмета лизинга без НДС xxx открыть для редактирования + поле НДС в стоимости предмета лизинга xxx открыть для редактирования + +Если в поле Продукт selectProduct выбрана запись, у которой БУбезНДС evo_sale_without_nds != True, то: + поле ПЛ БУ cbxLeaseObjectUsed открыто для редактирования (проверить на другие реакции открывающие/закрывающие это поле) + поле Валюта поставщика selectSupplierCurrency открыто для редактирования + поле Скидка от поставщика tbxSupplierDiscountRub открыто для редактирования + поле Скидка от поставщика, % tbxSupplierDiscountPerc открыто для редактирования + поле Стоимость предмета лизинга с НДС tbxLeaseObjectPrice открыто для редактирования + поле Стоимость предмета лизинга без НДС xxx закрыть для редактирования + поле НДС в стоимости предмета лизинга xxx закрыть для редактирования + */ + reaction( + () => ({ + product: $calculation.getOption('selectProduct'), + recalcWithRevision: $calculation.values.recalcWithRevision, + }), + ({ product }) => { + if (!product) { + $calculation.setStatus( + 'selectSupplierCurrency', + ElementStatus.Disabled, + ); + + $calculation.setStatus( + 'tbxSupplierDiscountRub', + ElementStatus.Disabled, + ); + + $calculation.setStatus( + 'tbxSupplierDiscountPerc', + ElementStatus.Disabled, + ); + + $calculation.setStatus('tbxLeaseObjectPrice', ElementStatus.Disabled); + + $calculation.setStatus( + 'tbxVATInLeaseObjectPrice', + ElementStatus.Disabled, + ); + } else { + const { evo_sale_without_nds } = product; + if (evo_sale_without_nds) { + $calculation.setStatus('cbxLeaseObjectUsed', ElementStatus.Disabled); + + $calculation.setStatus( + 'selectSupplierCurrency', + ElementStatus.Disabled, + ); + + $calculation.setStatus( + 'tbxSupplierDiscountRub', + ElementStatus.Disabled, + ); + + $calculation.setStatus( + 'tbxSupplierDiscountPerc', + ElementStatus.Disabled, + ); + + $calculation.setStatus('tbxLeaseObjectPrice', ElementStatus.Default); + + $calculation.setStatus( + 'tbxVATInLeaseObjectPrice', + ElementStatus.Default, + ); + } else { + $calculation.setStatus('cbxLeaseObjectUsed', ElementStatus.Default); + + $calculation.setStatus( + 'selectSupplierCurrency', + ElementStatus.Default, + ); + + $calculation.setStatus( + 'tbxSupplierDiscountRub', + ElementStatus.Default, + ); + + $calculation.setStatus( + 'tbxSupplierDiscountPerc', + ElementStatus.Default, + ); + + $calculation.setStatus('tbxLeaseObjectPrice', ElementStatus.Default); + + $calculation.setStatus( + 'tbxVATInLeaseObjectPrice', + ElementStatus.Disabled, + ); + } + } + }, + { + fireImmediately: true, + }, + ); + reaction( + () => $calculation.getOption('selectProduct'), + product => { + if ($calculation.stores.calculationProcess.hasProcess(Process.LoadKp)) + return; + if (!product) { + const supplierCurrency = + $calculation.options.selectSupplierCurrency?.find( + x => x.isocurrencycode === 'RUB', + ); + $calculation.setValue( + 'supplierCurrency', + supplierCurrency?.transactioncurrencyid, + ); + + $calculation.setValue('supplierDiscountRub', 0); + + $calculation.setValue('supplierDiscountRub', 0); + + $calculation.setValue('leaseObjectPrice', 0); + + $calculation.setValue('leaseObjectPriceWthtVAT', 0); + + $calculation.setValue('VATInLeaseObjectPrice', 0); + } else { + const { evo_sale_without_nds } = product; + if (evo_sale_without_nds) { + $calculation.setValue('leaseObjectUsed', true); + + const supplierCurrency = + $calculation.options.selectSupplierCurrency?.find( + x => x.isocurrencycode === 'RUB', + ); + $calculation.setValue( + 'supplierCurrency', + supplierCurrency?.transactioncurrencyid, + ); + + $calculation.setValue('supplierDiscountRub', 0); + + $calculation.setValue('supplierDiscountRub', 0); + } + } + }, + { + fireImmediately: true, + }, + ); + + /** + * @description + * Добавить реакцию на изменение поля Пересчет без пересмотра cbxRecalcWithRevision и загрузку КП: + ЕСЛИ в поле Продукт selectProduct выбрана запись и поле БУбезНДС evo_sale_without_nds = True + и Пересчет без пересмотра cbxRecalcWithRevision = True, + + то поля "Первый платеж, руб." tbxFirstPaymentRub + и "Первый платеж %" tbxFirstPaymentPerc закрыты для редактирования, + иначе открыты для редактирования + */ + reaction( + () => $calculation.getValues(['recalcWithRevision', 'quote']), + ({ recalcWithRevision, quote }) => { + const product = $calculation.getOption('selectProduct'); + if (product?.evo_sale_without_nds && recalcWithRevision) { + $calculation.setStatus('tbxFirstPaymentPerc', ElementStatus.Disabled); + $calculation.setStatus('tbxFirstPaymentRub', ElementStatus.Disabled); + } else { + $calculation.setStatus('tbxFirstPaymentPerc', ElementStatus.Default); + $calculation.setStatus('tbxFirstPaymentRub', ElementStatus.Default); + } + }, + ); + + /** + * @description + * Реакция на изменение ПЛ БУ cbxLeaseObjectUsed и Тип ПЛ selectLeaseObjectType + * Если ПЛ БУ cbxLeaseObjectUsed = True и Тип ПЛ selectLeaseObjectType = Спецтехника (id=9) , + * то поле Моточасы tbxEngineHours открыто для редактирования, иначе закрыто и равно 0. + */ + reaction( + () => { + const leaseObjectType = $calculation.getOption('selectLeaseObjectType'); + const { leaseObjectUsed } = $calculation.values; + return { + leaseObjectUsed, + leaseObjectType, + }; + }, + ({ leaseObjectUsed, leaseObjectType }) => { + if (leaseObjectUsed && leaseObjectType?.evo_id === '9') { + $calculation.setStatus('tbxEngineHours', ElementStatus.Default); + } else { + $calculation.setValue('engineHours', 0); + $calculation.setStatus('tbxEngineHours', ElementStatus.Disabled); + } + }, + { + fireImmediately: true, + }, + ); + + /** + * @description + * Добавить реакцию на изменение Типа ПЛ selectLeaseObjectType , ПЛ БУ cbxLeaseObjectUsed и Моточасы tbxEngineHours: + * Если ПЛ БУ cbxLeaseObjectUsed = True и Тип ПЛ selectLeaseObjectType = Спецтехника (id=9) и Моточасы = 0, + * то поле Моточасы tbxEngineHours должно обводиться красной рамкой и выводиться сообщение + * "Укажите Моточасы, иначе красная рамка снимается. + * При красной рамке в данном поле нельзя осуществить расчет графика. + */ + reaction( + () => { + const leaseObjectType = $calculation.getOption('selectLeaseObjectType'); + const { leaseObjectUsed, engineHours } = $calculation.values; + return { leaseObjectUsed, engineHours, leaseObjectType }; + }, + ({ leaseObjectType, leaseObjectUsed, engineHours }) => { + if (leaseObjectUsed && leaseObjectType?.evo_id === '9' && !engineHours) { + $calculation.setValidation('tbxEngineHours', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: 'Укажите Моточасы', + }); + } else { + $calculation.setValidation('tbxEngineHours', undefined); + } + }, + ); + + reaction( + () => $calculation.getValue('leaseObjectUsed'), + leaseObjectUsed => { + if (leaseObjectUsed) { + $calculation.setStatus('tbxMileage', ElementStatus.Default); + } else { + $calculation.setValue('mileage', 0); + $calculation.setStatus('tbxMileage', ElementStatus.Disabled); + } + }, + { + fireImmediately: true, + }, + ); + reaction( + () => { + const { mileage, leaseObjectUsed } = $calculation.values; + return { mileage, leaseObjectUsed }; + }, + ({ mileage, leaseObjectUsed }) => { + if (!mileage && leaseObjectUsed) { + $calculation.setValidation('tbxMileage', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: 'Не указан пробег', + }); + } else { + $calculation.setValidation('tbxMileage', undefined); + } + }, + ); +} diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts index a347581..3833bf6 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts @@ -197,7 +197,48 @@ export default function (this: ICalculationStore): PreparedData { preparedValues.repayment = 0.25; - if (values.firstPaymentPerc < 30) { + //plPrice && discount + const supplierCurrency = options.selectSupplierCurrency?.find( + x => x.transactioncurrencyid === values.supplierCurrency, + ); + + const evo_currencychanges = this.getStaticData('evo_currencychange'); + const evo_currencychange = evo_currencychanges.find( + x => x.evo_ref_transactioncurrency === values.supplierCurrency, + ); + + preparedValues.plPrice = convertPrice( + supplierCurrency?.isocurrencycode, + values.leaseObjectPriceWthtVAT, + evo_currencychange?.evo_currencychange || 1, + ); + + preparedValues.plPriceWithVAT = convertPrice( + supplierCurrency?.isocurrencycode, + values.leaseObjectPrice, + evo_currencychange?.evo_currencychange || 1, + ); + + preparedValues.plPriceVAT = convertPrice( + supplierCurrency?.isocurrencycode, + values.VATInLeaseObjectPrice, + evo_currencychange?.evo_currencychange || 1, + ); + + preparedValues.discount = + convertPrice( + supplierCurrency?.isocurrencycode, + values.supplierDiscountRub, + evo_currencychange?.evo_currencychange || 1, + ) / + (1 + valuesConstants.VAT); + // + + const firstPaymentPercWthtVAT = + values.firstPaymentRub / + (1 + valuesConstants.VAT) / + (preparedValues.plPrice || 0); + if (firstPaymentPercWthtVAT * 100 < 30) { const evo_coefficient_season = this.getStaticData('evo_coefficient').filter( x => x.evo_corfficient_type === 100000000 && @@ -208,17 +249,20 @@ export default function (this: ICalculationStore): PreparedData { ); switch (values.graphType) { case 100000003: - if (evo_coefficient_season && evo_coefficient_season.length > 0) { - const evo_coefficient = evo_coefficient_season.find( - x => - x.evo_season_type === values.seasonType && - x.evo_graph_type === 100000003, - ); - if (evo_coefficient) + if (values.highSeasonStart !== 100_000_000) { + if (evo_coefficient_season && evo_coefficient_season.length > 0) { + const evo_coefficient = evo_coefficient_season.find( + x => + x.evo_season_type === values.seasonType && + x.evo_graph_type === 100000003, + ); preparedValues.firstPayment = - (values.firstPaymentPerc + - evo_coefficient.evo_correction_coefficient) / + (firstPaymentPercWthtVAT * 100 + + (evo_coefficient?.evo_correction_coefficient || 0)) / 100; + } + } else { + preparedValues.firstPayment = firstPaymentPercWthtVAT; } break; @@ -230,48 +274,21 @@ export default function (this: ICalculationStore): PreparedData { ); if (evo_coefficient) preparedValues.firstPayment = - (values.firstPaymentPerc + - evo_coefficient.evo_correction_coefficient) / + (firstPaymentPercWthtVAT * 100 + + (evo_coefficient?.evo_correction_coefficient || 0)) / 100; } break; //TODO: beautify default: - preparedValues.firstPayment = values.firstPaymentPerc / 100; + preparedValues.firstPayment = firstPaymentPercWthtVAT; break; } } else { - preparedValues.firstPayment = values.firstPaymentPerc / 100; + preparedValues.firstPayment = firstPaymentPercWthtVAT; } - //plPrice && discount - const supplierCurrency = options.selectSupplierCurrency?.find( - x => x.transactioncurrencyid === values.supplierCurrency, - ); - - const evo_currencychanges = this.getStaticData('evo_currencychange'); - const evo_currencychange = evo_currencychanges.find( - x => x.evo_ref_transactioncurrency === values.supplierCurrency, - ); - - preparedValues.plPrice = - convertPrice( - supplierCurrency?.isocurrencycode, - values.leaseObjectPrice, - evo_currencychange?.evo_currencychange || 1, - ) / - (1 + valuesConstants.VAT); - - preparedValues.discount = - convertPrice( - supplierCurrency?.isocurrencycode, - values.supplierDiscountRub, - evo_currencychange?.evo_currencychange || 1, - ) / - (1 + valuesConstants.VAT); - // - preparedValues.acceptSum = (preparedValues.plPrice || 0) - (preparedValues.discount || 0); diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts index 4ae4566..67a26f4 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts @@ -56,8 +56,7 @@ export default { ); this.setValue( 'resultPlPrice', - (preparedData?.preparedValues?.acceptSum || 0) * - (1 + valuesConstants.VAT), + preparedData?.preparedValues?.plPriceWithVAT || 0, ); this.setValue( 'resultPriceUpPr', @@ -149,6 +148,10 @@ export default { (preparedData?.preparedValues?.bonusFinGAP || 0) * (1 - valuesConstants.NDFL), ); + this.setValue( + 'resultFirstPaymentRiskPolicy', + (preparedData?.preparedValues?.firstPayment || 0) * 100, + ); }, setResValues: function ( this: ICalculationStore, diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts index 2a54268..a51b9cb 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts @@ -8,7 +8,7 @@ import { getValue, showValidationMessages, validate, - ValidationCondition + ValidationCondition, } from 'core/validation/validate'; import { isNil } from 'lodash'; @@ -151,6 +151,8 @@ const elementsValidations: Partial< // selectRate: VALIDATIONS.IS_NULL, selectRegistration: CONDITIONS.IS_NULL, // tbxLeaseObjectPrice: CONDITIONS.LESS_OR_EQUALS_ZERO, + tbxLeaseObjectPriceWthtVAT: CONDITIONS.LESS_OR_EQUALS_ZERO, + tbxVATInLeaseObjectPrice: CONDITIONS.LESS_OR_EQUALS_ZERO, // tbxLastPaymentPerc: VALIDATIONS.IS_NULL, // tbxLastPaymentRub: VALIDATIONS.IS_NULL, // tbxFirstPaymentPerc: VALIDATIONS.IS_NULL, diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts index 97461e0..b833910 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts @@ -195,14 +195,14 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ value: quote?.evo_osago_accountid, }, insured: { value: quote.evo_osago_payer }, - insCost: { value: quote.evo_osago_price }, + insCost: { value: quote.evo_osago_price || 0 }, }, { insuranceCompany: { value: quote.evo_kasko_accountid, }, insured: { value: quote.evo_kasko_payer }, - insCost: { value: quote.evo_kasko_price }, + insCost: { value: quote.evo_kasko_price || 0 }, insTerm: { value: quote.evo_insurance_period }, }, { @@ -210,7 +210,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ value: quote.evo_kasko_accountid, }, insured: { value: quote.evo_kasko_payer }, - insCost: { value: quote.evo_dgo_price }, + insCost: { value: quote.evo_dgo_price || 0 }, insTerm: { value: quote.evo_insurance_period }, }, { @@ -218,7 +218,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ value: quote.evo_kasko_accountid, }, insured: { value: quote.evo_kasko_payer }, - insCost: { value: quote.evo_ns_price }, + insCost: { value: quote.evo_ns_price || 0 }, insTerm: { value: quote.evo_insurance_period }, }, { @@ -540,6 +540,10 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ initialValues.redemptionPaymentSum; // redemptionPayment + // engineHours + const engineHours = quote?.evo_engine_hours || 0; + // engineHours + const finalValues = { ...initialValues, ...newValues, @@ -569,6 +573,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ balanceHolder, redemptionPaymentSum, ...agentsValues, + engineHours, }; // check min max number values diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts index ee54acf..fccd961 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts @@ -5,6 +5,8 @@ const mapKPtoValues: Partial> = { evo_baseproductid: 'product', evo_client_typeid: 'clientType', evo_supplier_currency_price: 'leaseObjectPrice', + evo_price_without_nds_supplier_currency: 'leaseObjectPriceWthtVAT', + evo_nds_in_price_supplier_currency: 'VATInLeaseObjectPrice', evo_transactioncurrencyid: 'supplierCurrency', evo_discount_supplier_currency: 'supplierDiscountRub', evo_discount_perc: 'supplierDiscountPerc', diff --git a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts index 16e8399..fa54293 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts @@ -505,102 +505,74 @@ const reactionEffects: IReactionEffect[] = [ }), (calculationStore, calculationProcess) => ({ - expression: () => { - const { graphType } = calculationStore.values; - return graphType; - }, + expression: () => calculationStore.values.graphType, effect: graphType => { - if (graphType) { - if (!calculationProcess.hasProcess(Process.LoadKp)) { - calculationStore.setValue('seasonType', null); - calculationStore.setValue('highSeasonStart', null); - calculationStore.setValue('parmentsDecreasePercent', 96); + if (!calculationProcess.hasProcess(Process.LoadKp)) { + calculationStore.setValue('seasonType', null); + calculationStore.setValue('highSeasonStart', null); + calculationStore.setValue('parmentsDecreasePercent', 96); + } + + switch (graphType) { + case 100000001: { + calculationStore.setStatus('selectSeasonType', ElementStatus.Default); + + calculationStore.setStatus( + 'tbxParmentsDecreasePercent', + ElementStatus.Disabled, + ); + calculationStore.setStatus( + 'selectHighSeasonStart', + ElementStatus.Disabled, + ); + break; } - switch (graphType) { - case 100000001: { - calculationStore.setStatus( - 'selectSeasonType', - ElementStatus.Default, - ); - calculationStore.setFilter('selectSeasonType', options => - options.filter( - x => - x.value && - typeof x.value === 'number' && - [100000003, 100000004, 100000005, 100000006].includes( - x.value, - ), - ), - ); + case 100000002: { + calculationStore.setStatus( + 'selectSeasonType', + ElementStatus.Disabled, + ); + calculationStore.setStatus( + 'tbxParmentsDecreasePercent', + ElementStatus.Default, + ); + calculationStore.setStatus( + 'selectHighSeasonStart', + ElementStatus.Disabled, + ); + break; + } - calculationStore.setStatus( - 'tbxParmentsDecreasePercent', - ElementStatus.Disabled, - ); - calculationStore.setStatus( - 'selectHighSeasonStart', - ElementStatus.Disabled, - ); - break; - } + case 100000003: { + calculationStore.setStatus('selectSeasonType', ElementStatus.Default); - case 100000002: { - calculationStore.setStatus( - 'selectSeasonType', - ElementStatus.Disabled, - ); - calculationStore.setStatus( - 'tbxParmentsDecreasePercent', - ElementStatus.Default, - ); - calculationStore.setStatus( - 'selectHighSeasonStart', - ElementStatus.Disabled, - ); - break; - } + calculationStore.setStatus( + 'tbxParmentsDecreasePercent', + ElementStatus.Disabled, + ); + calculationStore.setStatus( + 'selectHighSeasonStart', + ElementStatus.Default, + ); + break; + } - case 100000003: { - calculationStore.setStatus( - 'selectSeasonType', - ElementStatus.Default, - ); - calculationStore.setFilter('selectSeasonType', options => - options.filter( - x => - x.value && - typeof x.value === 'number' && - [100000000, 100000001, 100000002].includes(x.value), - ), - ); - - calculationStore.setStatus( - 'tbxParmentsDecreasePercent', - ElementStatus.Disabled, - ); - calculationStore.setStatus( - 'selectHighSeasonStart', - ElementStatus.Default, - ); - break; - } - - default: { - calculationStore.setStatus( - 'selectSeasonType', - ElementStatus.Disabled, - ); - calculationStore.setStatus( - 'tbxParmentsDecreasePercent', - ElementStatus.Disabled, - ); - calculationStore.setStatus( - 'selectHighSeasonStart', - ElementStatus.Disabled, - ); - break; - } + case null: + default: { + calculationStore.setStatus( + 'selectSeasonType', + ElementStatus.Disabled, + ); + calculationStore.setStatus( + 'tbxParmentsDecreasePercent', + ElementStatus.Disabled, + ); + calculationStore.setStatus( + 'selectHighSeasonStart', + ElementStatus.Disabled, + ); + break; } } }, @@ -1140,74 +1112,6 @@ const reactionEffects: IReactionEffect[] = [ // }, // }), - calculationStore => ({ - expression: () => { - const { - product, - leasingPeriod, - deliveryTime, - firstPaymentPerc, - lastPaymentPerc, - } = calculationStore.values; - return { - product_evo_id: product, - leasingPeriod, - deliveryTime, - firstPaymentPerc, - lastPaymentPerc, - }; - }, - effect: ({ - product_evo_id, - leasingPeriod, - deliveryTime, - firstPaymentPerc, - lastPaymentPerc, - }) => { - if (product_evo_id && leasingPeriod && deliveryTime) { - const product = calculationStore.getOption('selectProduct', { - evo_id: product_evo_id, - }); - if (product) { - const tarif = calculationStore.options.selectTarif?.find( - x => - x.evo_baseproductid === product.evo_baseproductid && - x.evo_min_period <= leasingPeriod && - x.evo_max_period >= leasingPeriod && - x.evo_delivery_time?.includes(deliveryTime) && - x.evo_min_first_payment <= firstPaymentPerc && - x.evo_max_first_payment >= firstPaymentPerc && - x.evo_min_last_payment <= lastPaymentPerc && - x.evo_max_last_payment >= lastPaymentPerc, - ); - calculationStore.setValue('tarif', tarif?.evo_tarifid); - } - } else { - calculationStore.setValue('tarif', null); - } - }, - }), - - (calculationStore, calculationProcess) => ({ - expression: () => { - const { tarif } = calculationStore.values; - return tarif; - }, - effect: tarif_evo_id => { - if (calculationProcess.hasProcess(Process.LoadKp)) { - return; - } - - const tarif = calculationStore.getOption('selectTarif', { - evo_tarifid: tarif_evo_id, - }); - - if (tarif) { - calculationStore.setValue('IRR_Perc', tarif.evo_irr); - } - }, - }), - calculationStore => ({ expression: () => { const { leasingPeriod, leaseObjectType } = calculationStore.values; @@ -1405,41 +1309,6 @@ const reactionEffects: IReactionEffect[] = [ }, }), - calculationStore => ({ - expression: () => { - const { leaseObjectUsed } = calculationStore.values; - return leaseObjectUsed; - }, - effect: leaseObjectUsed => { - if (leaseObjectUsed) { - calculationStore.setStatus('tbxMileage', ElementStatus.Default); - } else { - calculationStore.setValue('mileage', 0); - calculationStore.setStatus('tbxMileage', ElementStatus.Disabled); - } - }, - options: { fireImmediately: true }, - }), - - calculationStore => ({ - expression: () => { - const { mileage, leaseObjectUsed } = calculationStore.values; - return { mileage, leaseObjectUsed }; - }, - effect: ({ mileage, leaseObjectUsed }) => { - if (!mileage && leaseObjectUsed) { - calculationStore.setValidation('tbxMileage', false); - openNotification({ - type: 'error', - message: 'Ошибка', - description: 'Не указан пробег', - }); - } else { - calculationStore.setValidation('tbxMileage', undefined); - } - }, - }), - calculationStore => ({ expression: () => { const { calcType } = calculationStore.values; @@ -1477,7 +1346,7 @@ const reactionEffects: IReactionEffect[] = [ effect: ([graphType, seasonType]) => { calculationStore.setValidation( 'selectSeasonType', - !(graphType === 100000003 && seasonType === null), + !([100000001, 100000003].includes(graphType) && seasonType === null), ); }, }), @@ -1582,75 +1451,6 @@ const reactionEffects: IReactionEffect[] = [ }, }), - /** - * - * @description - #1 - * DYN-190 При выборе значения в поле selectSubsidy необходимо добавить - * фильтрацию в полях при условии что selectSubsidy не равно null: - -Тип предмета лизинга selectLeaseObjectType -если с записью Субсидия нет связанных Типов предмета лизинга, -то указываются все записи согласно текущей фильтрации, -иначе указываются те записи, которые связаны с Субсидией, указанной в поле selectSubsidy - - #2 - * На изменение поля Продукт selectProduct добавляем фильтрацию списков: -в поле Тип предмета лизинга selectLeaseObjectType - указываются те, которые связаны с продуктом. -Если с Продуктом нет связанных Типов предмета лизинга, -то указывается весь список. Это надо добавить в текущие условия фильтрации данного поля - */ - calculationStore => ({ - expression: () => { - return { - product: calculationStore.getOption('selectProduct'), - subsidy: calculationStore.getOption('selectSubsidy'), - }; - }, - effect: ({ product, subsidy }) => { - calculationStore.setFilter('selectLeaseObjectType', types => - types.filter( - pipe( - type => - (!product?.evo_leasingobject_types?.length || - product.evo_leasingobject_types.filter( - x => - x.evo_leasingobject_typeid === - type?.evo_leasingobject_typeid, - )?.length) && - type, - type => - type && - (!subsidy?.evo_leasingobject_types?.length || - subsidy.evo_leasingobject_types.filter( - x => - x.evo_leasingobject_typeid === - type.evo_leasingobject_typeid, - )?.length), - ), - ), - ); - - calculationStore.setFilter('selectDealer', dealers => - dealers.filter( - dealer => - !subsidy?.accounts?.length || - subsidy.accounts.filter(x => x.accountid === dealer.accountid) - ?.length, - ), - ); - - calculationStore.setFilter('selectDealerPerson', dealerPersons => - dealerPersons.filter( - dealerPerson => - !subsidy?.accounts?.length || - subsidy.accounts.filter(x => x.accountid === dealerPerson.accountid) - ?.length, - ), - ); - }, - }), - calculationStore => ({ expression: () => { return { diff --git a/src/client/stores/CalculationStore/Effects/reactions/priceReactions/index.ts b/src/client/stores/CalculationStore/Effects/reactions/priceReactions/index.ts index 7cf10f5..b6bf488 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/priceReactions/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/priceReactions/index.ts @@ -1,6 +1,8 @@ import { openNotification } from 'client/Elements/Notification'; +import valuesConstants from 'core/constants/values'; import { IReactionEffect } from 'core/types/Calculation/Store/effect'; import { Process } from 'core/types/Calculation/Store/process'; +import { round } from 'lodash'; import { convertPrice } from '../../lib/tools'; import { calculatePerc, calculateRub, getPrice } from './calculate'; @@ -289,4 +291,53 @@ export default [ } }, }), + + calculationStore => ({ + expression: () => { + const product = calculationStore.getOption('selectProduct'); + const { leaseObjectPrice, VATInLeaseObjectPrice } = + calculationStore.values; + return { + product, + leaseObjectPrice, + VATInLeaseObjectPrice, + }; + }, + effect: ({ product, leaseObjectPrice, VATInLeaseObjectPrice }) => { + calculationStore.setValidation('tbxVATInLeaseObjectPrice', undefined); + const { VAT } = valuesConstants; + + if (!product?.evo_sale_without_nds) { + const leaseObjectPriceWthtVATValue = leaseObjectPrice / (1 + VAT); + calculationStore.setValue( + 'leaseObjectPriceWthtVAT', + leaseObjectPriceWthtVATValue, + ); + calculationStore.setValue( + 'VATInLeaseObjectPrice', + leaseObjectPrice - leaseObjectPriceWthtVATValue, + ); + } else { + const leaseObjectPriceWthtVAT = + leaseObjectPrice - VATInLeaseObjectPrice; + calculationStore.setValue( + 'leaseObjectPriceWthtVAT', + leaseObjectPriceWthtVAT, + ); + + if (round(VATInLeaseObjectPrice / leaseObjectPriceWthtVAT, 2) >= VAT) { + calculationStore.setValidation('tbxVATInLeaseObjectPrice', false); + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'При продаже ПЛ после ФЛ размер НДС в стоимости ПЛ не может составлять 20% и более от стоимости с НДС. Проверьте корректность НДС либо измените Продукт', + }); + } + } + }, + options: { + delay: 10, + }, + }), ] as IReactionEffect[]; diff --git a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts index 5adbdea..ed38c34 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts @@ -572,7 +572,7 @@ const elementsToDisable: (InteractionElementsNames | TableNames)[] = [ 'tablePayments', 'selectLead', 'selectOpportunity', - // 'selectProduct', + 'selectProduct', 'selectClientRisk', 'selectClientType', 'tbxLeasingPeriod', @@ -605,6 +605,7 @@ const elementsToDisable: (InteractionElementsNames | TableNames)[] = [ 'selectTracker', 'tbxMileage', 'selectSubsidy', + 'tbxEngineHours', ]; // Для recalc = true и первого платежа = 0 diff --git a/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts index 9cd8fc6..9096344 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts @@ -458,59 +458,67 @@ export default [ } case 100000001: { - if (seasonType) { - const paymentsInStep = Math.ceil((leasingPeriod - 2) / 3); - const targetSeasonType = calculationStore.getOption( - 'selectSeasonType', - { - value: seasonType, - }, - ); - const stepsValues: number[] = - targetSeasonType && targetSeasonType.stepsValues; + switch (seasonType) { + default: { + const paymentsInStep = Math.ceil((leasingPeriod - 2) / 3); + const targetSeasonType = calculationStore.getOption( + 'selectSeasonType', + { + value: seasonType, + }, + ); + const stepsValues: number[] = + targetSeasonType && targetSeasonType.stepsValues; - const middleRows = Array.from( - { length: leasingPeriod - 2 }, - (_v, i) => { - let value = stepsValues[2]; + const middleRows = Array.from( + { length: leasingPeriod - 2 }, + (_v, i) => { + let value = stepsValues[2]; - if (i <= paymentsInStep * 2 - 1) { - value = stepsValues[1]; - } + if (i <= paymentsInStep * 2 - 1) { + value = stepsValues[1]; + } - if (i <= paymentsInStep - 1) { - value = stepsValues[0]; - } + if (i <= paymentsInStep - 1) { + value = stepsValues[0]; + } - return { + return { + paymentRelation: { + value, + status: ElementStatus.Disabled, + }, + }; + }, + ); + payments = [...payments, ...middleRows]; + break; + } + case 100_000_007: { + const middleRows = Array.from( + { length: leasingPeriod - 3 }, + () => ({ paymentRelation: { - value, + value: 100, + status: ElementStatus.Default, + }, + }), + ); + payments = [ + ...payments, + { + paymentRelation: { + value: 100, status: ElementStatus.Disabled, }, - }; - }, - ); - payments = [...payments, ...middleRows]; - } else { - const middleRows = Array.from( - { length: leasingPeriod - 3 }, - () => ({ - paymentRelation: { - value: 100, - status: ElementStatus.Default, }, - }), - ); - payments = [ - ...payments, - { - paymentRelation: { - value: 100, - status: ElementStatus.Disabled, - }, - }, - ...middleRows, - ]; + ...middleRows, + ]; + break; + } + case null: { + break; + } } break; diff --git a/src/client/stores/CalculationStore/config/initialOptions.ts b/src/client/stores/CalculationStore/config/initialOptions.ts index e1189ef..eb75aee 100644 --- a/src/client/stores/CalculationStore/config/initialOptions.ts +++ b/src/client/stores/CalculationStore/config/initialOptions.ts @@ -37,6 +37,7 @@ const initialOptions: Partial> = { { name: 'дегрессия (ступенчатая)', value: 100000001, + seasonTypes: [100000003, 100000004, 100000005, 100000006, 100000007], }, { name: 'равноубывающий', @@ -45,6 +46,7 @@ const initialOptions: Partial> = { { name: 'сезонный', value: 100000003, + seasonTypes: [100000000, 100000001, 100000002], }, { name: 'легкий старт', @@ -77,6 +79,10 @@ const initialOptions: Partial> = { stepsValues: [100, 75, 50], forbiddenHighSeasonStart: ['11'], }, + { + name: 'Гибкая дегрессия', + value: 100000007, + }, { name: '100.50.25', value: 100000003, diff --git a/src/client/stores/CalculationStore/config/initialStatuses.ts b/src/client/stores/CalculationStore/config/initialStatuses.ts index 33e2543..c36d2ce 100644 --- a/src/client/stores/CalculationStore/config/initialStatuses.ts +++ b/src/client/stores/CalculationStore/config/initialStatuses.ts @@ -26,6 +26,8 @@ const initialStatuses: Partial< radioInfuranceOPF: ElementStatus.Disabled, tbxRedemptionPaymentSum: ElementStatus.Disabled, + + tbxLeaseObjectPriceWthtVAT: ElementStatus.Disabled, }; export default initialStatuses; diff --git a/src/client/stores/CalculationStore/config/initialValues.ts b/src/client/stores/CalculationStore/config/initialValues.ts index cbb0488..60a006b 100644 --- a/src/client/stores/CalculationStore/config/initialValues.ts +++ b/src/client/stores/CalculationStore/config/initialValues.ts @@ -8,6 +8,9 @@ const initialValues: Partial> = { quote: null, recalcWithRevision: false, leaseObjectPrice: 1000000, + VATInLeaseObjectPrice: 0, + leaseObjectPriceWthtVAT: 0, + engineHours: 0, supplierCurrency: 'RUB', supplierDiscountRub: 0, supplierDiscountPerc: 0, diff --git a/src/client/stores/CalculationStore/index.ts b/src/client/stores/CalculationStore/index.ts index 6643467..edd62a4 100644 --- a/src/client/stores/CalculationStore/index.ts +++ b/src/client/stores/CalculationStore/index.ts @@ -1,4 +1,6 @@ +import { injectConfiguratorReactions } from 'client/process/configurator/reactions'; import { injectFinGapReactions } from 'client/process/fingap/reactions'; +import injectUsedWhthVATReactions from 'client/process/used-pl/reactions'; import { ICalculationStore } from 'core/types/Calculation/Store'; import { isEqual } from 'lodash'; import { autorun, makeAutoObservable, reaction, when } from 'mobx'; @@ -35,6 +37,8 @@ reactionEffects.map(reactionEffectBuilder => { }); }); injectFinGapReactions(CalculationStore); +injectUsedWhthVATReactions(CalculationStore); +injectConfiguratorReactions(CalculationStore); whenEffects.map(whenEffectBuilder => { const whenEffect = whenEffectBuilder(CalculationStore); diff --git a/src/core/services/CoreService/types/Calculation/prepared.ts b/src/core/services/CoreService/types/Calculation/prepared.ts index 7709447..3ac6cc1 100644 --- a/src/core/services/CoreService/types/Calculation/prepared.ts +++ b/src/core/services/CoreService/types/Calculation/prepared.ts @@ -23,6 +23,8 @@ export interface PreparedValues { scheduleOfPayments?: number; comissionRub?: number; plPrice?: number; + plPriceVAT?: number; + plPriceWithVAT?: number; discount?: number; acceptSum?: number; plTypeId?: string; diff --git a/src/core/services/CrmService/graphql/query/options/main_options.graphql b/src/core/services/CrmService/graphql/query/options/main_options.graphql index e902441..2724bae 100644 --- a/src/core/services/CrmService/graphql/query/options/main_options.graphql +++ b/src/core/services/CrmService/graphql/query/options/main_options.graphql @@ -75,6 +75,7 @@ query GetMainOptions( systemusers { systemuserid } + evo_sale_without_nds } selectRegistration: evo_addproduct_types( statecode: $statecode diff --git a/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql index 253d802..e1536a7 100644 --- a/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql +++ b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql @@ -133,4 +133,7 @@ fragment quoteFields on quote { evo_product_risks { evo_addproduct_typeid } + evo_price_without_nds_supplier_currency + evo_nds_in_price_supplier_currency + evo_engine_hours } diff --git a/src/core/services/CrmService/graphql/schema.graphql b/src/core/services/CrmService/graphql/schema.graphql index af0eac3..f43d6b4 100644 --- a/src/core/services/CrmService/graphql/schema.graphql +++ b/src/core/services/CrmService/graphql/schema.graphql @@ -1,9 +1,15 @@ -"""The cost directives is used to express the complexity of a field.""" +""" +The cost directives is used to express the complexity of a field. +""" directive @cost( - """Defines the complexity of the field.""" + """ + Defines the complexity of the field. + """ complexity: Int! = 1 - """Defines field arguments that act as complexity multipliers.""" + """ + Defines field arguments that act as complexity multipliers. + """ multipliers: [MultiplierPath!] ) on FIELD_DEFINITION @@ -23,7 +29,9 @@ Export this locally resolved field as a variable to be used in the remainder of https://www.apollographql.com/docs/react/essentials/local-state/#using-client-fields-as-variables """ directive @export( - """The variable name to export this field as.""" + """ + The variable name to export this field as. + """ as: String! ) on FIELD @@ -32,7 +40,9 @@ Specify a custom store key for this result. See https://www.apollographql.com/docs/react/advanced/caching/#the-connection-directive """ directive @connection( - """Specify the store key.""" + """ + Specify the store key. + """ key: String! """ @@ -49,76 +59,202 @@ scalar MultiplierPath type Query { account(accountid: Uuid!): account - """Контрагенты. statecode по умолчанию 0""" - accounts(evo_accnumber: String, evo_account_type: [Int!], evo_broker_accountid: Uuid, evo_fin_department_accountid: Uuid, evo_id_elt: String, evo_inn: String, evo_kpp: String, evo_legal_form: Int, evo_type_ins_policy: [Int!], ownerid: Uuid, owner_domainname: String, statecode: Int): [account] + """ + Контрагенты. statecode по умолчанию 0 + """ + accounts( + evo_accnumber: String + evo_account_type: [Int!] + evo_broker_accountid: Uuid + evo_fin_department_accountid: Uuid + evo_id_elt: String + evo_inn: String + evo_kpp: String + evo_legal_form: Int + evo_type_ins_policy: [Int!] + ownerid: Uuid + owner_domainname: String + statecode: Int + ): [account] - """Брокер. statecode по умолчанию 0""" + """ + Брокер. statecode по умолчанию 0 + """ broker_agents(ownnerid: Uuid!, statecode: Int): [account] contacts(parentcustomerid: Uuid, statecode: Int): [contact] email(activityid: Uuid!): email evo_addcontract(evo_addcontractid: Uuid!): evo_addcontract evo_addproduct(evo_addproductid: Uuid!): evo_addproduct evo_addproduct_type(evo_addproduct_typeid: Uuid!): evo_addproduct_type - evo_addproduct_types(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_max_period_param: DecimalParamInput, evo_min_period_param: DecimalParamInput, evo_product_type: Int, statecode: Int): [evo_addproduct_type] + evo_addproduct_types( + evo_datefrom_param: DateParamInput + evo_dateto_param: DateParamInput + evo_max_period_param: DecimalParamInput + evo_min_period_param: DecimalParamInput + evo_product_type: Int + statecode: Int + ): [evo_addproduct_type] evo_address(evo_addressid: Uuid!): evo_address - evo_addresses(evo_address_name: String, evo_fias: Boolean, statecode: Int): [evo_address] + evo_addresses( + evo_address_name: String + evo_fias: Boolean + statecode: Int + ): [evo_address] evo_agency_agreement(evo_agency_agreementid: Uuid!): evo_agency_agreement - evo_bank_detailses(evo_accountid: Uuid, orderby: OrderByInput, statecode: Int = 0): [evo_bank_details] + evo_bank_detailses( + evo_accountid: Uuid + orderby: OrderByInput + statecode: Int = 0 + ): [evo_bank_details] evo_baseproduct(evo_baseproductid: Uuid!): evo_baseproduct - evo_baseproducts(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_relation: [Int!], statecode: Int): [evo_baseproduct] + evo_baseproducts( + evo_datefrom_param: DateParamInput + evo_dateto_param: DateParamInput + evo_relation: [Int!] + statecode: Int + ): [evo_baseproduct] evo_brands(evo_vehicle_type: [Int!], statecode: Int): [evo_brand] evo_businessunits(statecode: Int): [evo_businessunit] evo_client_risks(statecode: Int): [evo_client_risk] evo_client_types(statecode: Int): [evo_client_type] - evo_coefficients(evo_client_riskid: Uuid, evo_client_typeid: Uuid, evo_corfficient_type: Int, evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_job_titleid: Uuid, evo_max_period_param: DecimalParamInput, evo_min_period_param: DecimalParamInput, statecode: Int): [evo_coefficient] + evo_coefficients( + evo_client_riskid: Uuid + evo_client_typeid: Uuid + evo_corfficient_type: Int + evo_datefrom_param: DateParamInput + evo_dateto_param: DateParamInput + evo_job_titleid: Uuid + evo_max_period_param: DecimalParamInput + evo_min_period_param: DecimalParamInput + statecode: Int + ): [evo_coefficient] evo_contract(evo_contractid: Uuid!): evo_contract evo_contracts(evo_name: String, statecode: Int): [evo_contract] evo_countries(evo_code_numeric: String): [evo_countryGraphQL] evo_country(evo_countryid: Uuid!): evo_countryGraphQL - evo_currencychanges(evo_coursedate_param: DateParamInput, evo_ref_transactioncurrency: Uuid, statecode: Int): [evo_currencychange] + evo_currencychanges( + evo_coursedate_param: DateParamInput + evo_ref_transactioncurrency: Uuid + statecode: Int + ): [evo_currencychange] evo_equipments(evo_modelid: Uuid, statecode: Int): [evo_equipment] - evo_external_supplier_codes(evo_id: String, statecode: Int): [evo_external_supplier_code] - evo_external_system_request(evo_external_system_requestid: Uuid!): evo_external_system_request - evo_external_system_requests(evo_integration_status: Int, evo_name: String, evo_system: Int, statecode: Int): [evo_external_system_request] + evo_external_supplier_codes( + evo_id: String + statecode: Int + ): [evo_external_supplier_code] + evo_external_system_request( + evo_external_system_requestid: Uuid! + ): evo_external_system_request + evo_external_system_requests( + evo_integration_status: Int + evo_name: String + evo_system: Int + statecode: Int + ): [evo_external_system_request] evo_finegibdd(evo_finegibddid: Uuid!): evo_finegibdd evo_gps_brands(statecode: Int): [evo_gps_brand] evo_gps_models(evo_gps_brandid: Uuid, statecode: Int): [evo_gps_model] evo_graphs(evo_contractid: Uuid, statecode: Int): [evo_graph] - evo_identity_documents(evo_employee_systemuserid: Uuid!): [evo_identity_document] + evo_identity_documents( + evo_employee_systemuserid: Uuid! + ): [evo_identity_document] evo_impairment_groups(statecode: Int): [evo_impairment_group] - evo_insurance_periods(evo_contractid: Uuid, statecode: Int): [evo_insurance_period] + evo_insurance_periods( + evo_contractid: Uuid + statecode: Int + ): [evo_insurance_period] evo_job_titles(statecode: Int): [evo_job_title] evo_leasingobject(evo_leasingobjectid: Uuid!): evo_leasingobject - evo_leasingobject_type(evo_leasingobject_typeid: Uuid!): evo_leasingobject_type + evo_leasingobject_type( + evo_leasingobject_typeid: Uuid! + ): evo_leasingobject_type evo_leasingobject_types(statecode: Int): [evo_leasingobject_type] evo_model(evo_modelid: Uuid!): evo_model - evo_models(evo_brandid: Uuid, evo_vehicle_type: Int, statecode: Int): [evo_model] + evo_models( + evo_brandid: Uuid + evo_vehicle_type: Int + statecode: Int + ): [evo_model] evo_orglegalform(evo_orglegalformid: Uuid!): evo_orglegalform evo_orglegalforms(statecode: Int = 0): [evo_orglegalform] - evo_paymentorders(evo_dds_1c: String, evo_name: String, evo_paydate_param: DateParamInput, evo_payment_number_1c: String, evo_paysum: Decimal, statecode: Int, statuscode: Int): [evo_paymentorder] - evo_planpayments(evo_addproduct_typeid: Uuid, statecode: Int): [evo_planpayment] + evo_paymentorders( + evo_dds_1c: String + evo_name: String + evo_paydate_param: DateParamInput + evo_payment_number_1c: String + evo_paysum: Decimal + statecode: Int + statuscode: Int + ): [evo_paymentorder] + evo_planpayments( + evo_addproduct_typeid: Uuid + statecode: Int + ): [evo_planpayment] evo_product_risk(evo_product_riskid: Uuid!): evo_product_risk evo_product_risks(statecode: Int): [evo_product_risk] evo_rate(evo_rateid: Uuid!): evo_rate - evo_rates(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, statecode: Int): [evo_rate] + evo_rates( + evo_datefrom_param: DateParamInput + evo_dateto_param: DateParamInput + statecode: Int + ): [evo_rate] - """Регион. statecode по умолчанию 0""" - evo_regions(evo_businessunit_evolution: Boolean, evo_creditregistry_id: Int, statecode: Int): [evo_region] + """ + Регион. statecode по умолчанию 0 + """ + evo_regions( + evo_businessunit_evolution: Boolean + evo_creditregistry_id: Int + statecode: Int + ): [evo_region] evo_request_payment(evo_request_paymentid: Uuid!): evo_request_payment - evo_request_payments(evo_id: String, evo_name: String, statecode: Int): [evo_request_payment] + evo_request_payments( + evo_id: String + evo_name: String + statecode: Int + ): [evo_request_payment] evo_reward_condition(evo_reward_conditionid: Uuid!): evo_reward_condition - evo_reward_conditions(evo_agency_agreementid_param: GuidParamInput, evo_agent_accountid: Uuid, evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, statecode: Int): [evo_reward_condition] + evo_reward_conditions( + evo_agency_agreementid_param: GuidParamInput + evo_agent_accountid: Uuid + evo_datefrom_param: DateParamInput + evo_dateto_param: DateParamInput + statecode: Int + ): [evo_reward_condition] evo_sot_coefficient_types(statecode: Int): [evo_sot_coefficient_type] evo_statuscode(evo_id: String, evo_statuscodeid: Uuid): evo_statuscode evo_statuscodes(statecode: Int): [evo_statuscode] - evo_subsidies(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, statecode: Int): [evo_subsidy] + evo_subsidies( + evo_datefrom_param: DateParamInput + evo_dateto_param: DateParamInput + statecode: Int + ): [evo_subsidy] evo_tarif(evo_tarifid: Uuid!): evo_tarif - evo_tarifs(evo_balance_holder: [Int!], evo_baseproductid: Uuid, evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_graphtype_exception: [Int!], evo_ins_type: [Int!], evo_max_first_payment_param: DecimalParamInput, evo_max_last_payment_param: DecimalParamInput, evo_max_period_param: DecimalParamInput, evo_min_first_payment_param: DecimalParamInput, evo_min_last_payment_param: DecimalParamInput, evo_min_period_param: DecimalParamInput, evo_used: Boolean, statecode: Int): [evo_tarif] + evo_tarifs( + evo_balance_holder: [Int!] + evo_baseproductid: Uuid + evo_datefrom_param: DateParamInput + evo_dateto_param: DateParamInput + evo_graphtype_exception: [Int!] + evo_ins_type: [Int!] + evo_max_first_payment_param: DecimalParamInput + evo_max_last_payment_param: DecimalParamInput + evo_max_period_param: DecimalParamInput + evo_min_first_payment_param: DecimalParamInput + evo_min_last_payment_param: DecimalParamInput + evo_min_period_param: DecimalParamInput + evo_used: Boolean + statecode: Int + ): [evo_tarif] evo_town(evo_fias_id: String, evo_townid: Uuid): evo_town - """Города. statecode по умолчанию 0""" + """ + Города. statecode по умолчанию 0 + """ evo_towns(evo_regionid: Uuid, statecode: Int): [evo_town] - evo_vehicle_body_type(evo_vehicle_body_typeid: Uuid!): evo_vehicle_body_typeGraphQL + evo_vehicle_body_type( + evo_vehicle_body_typeid: Uuid! + ): evo_vehicle_body_typeGraphQL """ Лизинговые сделки. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName @@ -128,8 +264,18 @@ type Query { """ Интересы. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName """ - leads(evo_opportunityid: Uuid, ownerid: Uuid, owner_domainname: String, statecode: Int): [lead] - opportunities(evo_leadid: Uuid, ownerid: Uuid, owner_domainname: String, statecode: Int): [opportunity] + leads( + evo_opportunityid: Uuid + ownerid: Uuid + owner_domainname: String + statecode: Int + ): [lead] + opportunities( + evo_leadid: Uuid + ownerid: Uuid + owner_domainname: String + statecode: Int + ): [opportunity] opportunity(opportunityid: Uuid!): opportunity queue(emailaddress: String): queue quote(quoteId: Uuid!): quote @@ -137,18 +283,33 @@ type Query { """ Предложения. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName """ - quotes(condition: ConditionInput, evo_leadid: Uuid, ownerid: Uuid, owner_domainname: String, statecode: Int): [quote] + quotes( + condition: ConditionInput + evo_leadid: Uuid + ownerid: Uuid + owner_domainname: String + statecode: Int + ): [quote] - """Агенты салона. statecode по умолчанию 0""" + """ + Агенты салона. statecode по умолчанию 0 + """ salon_agents(salonaccountid: Uuid!, statecode: Int): [account] - """Поставщики ЮЛ салона. statecode по умолчанию 0""" + """ + Поставщики ЮЛ салона. statecode по умолчанию 0 + """ salon_providers(salonaccountid: Uuid!, statecode: Int): [account] systemuser(domainname: String, systemuserid: Uuid): systemuser - systemusers(evo_employee_id: String, isdisabled: Boolean = false): [systemuser] + systemusers( + evo_employee_id: String + isdisabled: Boolean = false + ): [systemuser] templates(description: String): [template] - """Валюта. statecode по умолчанию 0""" + """ + Валюта. statecode по умолчанию 0 + """ transactioncurrencies(statecode: Int): [transactioncurrency] transactioncurrency(transactioncurrencyid: Uuid!): transactioncurrency } @@ -179,12 +340,14 @@ type account { evo_citizenship_countryid: Uuid evo_client_riskid: Uuid evo_consent_date: DateTime + evo_contracts: [evo_contract] evo_dadata_dateupdate: DateTime evo_dadatdalog: String evo_dealer_responsible_systemuserid: Uuid evo_div_12month: Boolean evo_economic_security_systemuserid: Uuid evo_employee_count: Int + evo_fingap_number_rules: Int evo_fin_department_accountid: Uuid evo_fin_department_accountidData: account evo_fuel_card_code: String @@ -199,6 +362,7 @@ type account { evo_ifns_code_branch: String evo_ifns_name: String evo_inn: String + evo_insurance_agent_accountid: Uuid evo_invoice_number_fix: String evo_invoice_number_rules: Int evo_kpp: String @@ -217,6 +381,7 @@ type account { evo_okved: String evo_orglegalformid: Uuid evo_orglegalformidData: evo_orglegalform + evo_osago_with_kasko: Boolean evo_smb_category: Int evo_smb_issue_date: DateTime evo_state_actuality_date: DateTime @@ -269,7 +434,9 @@ input GuidParamInput { has: Boolean } -"""The built-in `Decimal` scalar type.""" +""" +The built-in `Decimal` scalar type. +""" scalar Decimal input OrderByInput { @@ -299,7 +466,9 @@ type contact { firstname: String fullname: String gendercode: Int + jobtitle: String lastname: String + link: String middlename: String mobilephone: String modifiedon: DateTime @@ -311,6 +480,7 @@ type contact { parentcustomerid_account: Uuid parentcustomerid_contact: Uuid statecode: Int + telephone1: String toObjectString: String } @@ -360,6 +530,7 @@ type evo_addproduct_type { evo_prime_cost: Decimal evo_product_type: Int evo_pts_type: [Int!] + evo_quote_name: String evo_retro_bonus: Decimal evo_retro_bonus_withoutnds: Decimal evo_towtruck: Boolean @@ -382,6 +553,7 @@ type evo_baseproduct { evo_leasingobject_types(statecode: Int): [evo_leasingobject_type] evo_name: String evo_relation: [Int!] + evo_sale_without_nds: Boolean modifiedon: DateTime statecode: Int systemusers(statecode: Int): [systemuser] @@ -398,6 +570,7 @@ type evo_graph { evo_cost_price_telematics_withoutnds_sum: Decimal evo_cost_telematics_sum: Decimal evo_cost_telematics_withoutnds_sum: Decimal + evo_graf_date_approve: DateTime evo_graphid: Uuid evo_name: String evo_nds: Decimal @@ -472,6 +645,7 @@ type evo_insurance_period { evo_storage: String evo_supplier_accountid: Uuid evo_territory_price: Decimal + evo_under_payment_compensation: Decimal evo_unlimit_drivers: Boolean modifiedon: DateTime ownerid_systemuser: Uuid @@ -847,6 +1021,8 @@ type quote { evo_double_agent_reward_summ: Decimal evo_double_agent_reward_total: Decimal evo_economic: Decimal + evo_economic_with_nds: Decimal + evo_engine_hours: Decimal evo_engine_type: Int evo_engine_volume: Decimal evo_equipmentid: Uuid @@ -857,6 +1033,7 @@ type quote { evo_fingap_payer: Int evo_fingap_period: Int evo_fingap_price: Decimal + evo_fingap_quote: Boolean evo_fin_department_accountid: Uuid evo_fin_department_reward_conditionid: Uuid evo_fin_department_reward_summ: Decimal @@ -929,6 +1106,7 @@ type quote { evo_leasing_bonus_summ: Decimal evo_legal_regionid: Uuid evo_legal_townid: Uuid + evo_lessor_bank_detailsid: Uuid evo_loan_appraisalid: Uuid evo_logid: Uuid evo_max_mass: Decimal @@ -938,6 +1116,8 @@ type quote { evo_min_change_price: Decimal evo_modelid: Uuid evo_msfo_irr: Decimal + evo_nds_in_price_supplier_currency: Decimal + evo_nds_perc: Decimal evo_net_irr: Decimal evo_niatinception_msfo: Decimal evo_ni_at_inception: Decimal @@ -996,6 +1176,7 @@ type quote { evo_risk_programsolution: Uuid evo_rub_price: Decimal evo_sale_bonus: Decimal + evo_sale_without_nds: Boolean evo_seasons_type: Int evo_seats: Int evo_statuscodeid: Uuid @@ -1041,7 +1222,12 @@ type quote { type evo_brand { createdon: DateTime - evo_baseproducts(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_relation: [Int!], statecode: Int): [evo_baseproduct] + evo_baseproducts( + evo_datefrom_param: DateParamInput + evo_dateto_param: DateParamInput + evo_relation: [Int!] + statecode: Int + ): [evo_baseproduct] evo_brandid: Uuid evo_brand_owner: Int evo_id: String @@ -1057,7 +1243,12 @@ type evo_brand { type evo_model { createdon: DateTime - evo_baseproducts(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_relation: [Int!], statecode: Int): [evo_baseproduct] + evo_baseproducts( + evo_datefrom_param: DateParamInput + evo_dateto_param: DateParamInput + evo_relation: [Int!] + statecode: Int + ): [evo_baseproduct] evo_brandid: Uuid evo_gps: Boolean evo_high_risk_vehicle: Boolean @@ -1083,7 +1274,12 @@ type evo_model { type evo_equipment { createdon: DateTime - evo_baseproducts(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_relation: [Int!], statecode: Int): [evo_baseproduct] + evo_baseproducts( + evo_datefrom_param: DateParamInput + evo_dateto_param: DateParamInput + evo_relation: [Int!] + statecode: Int + ): [evo_baseproduct] evo_equipmentid: Uuid evo_id: String evo_impairment_groupid: Uuid @@ -1237,6 +1433,7 @@ type evo_request_payment { evo_agency_agreementidData: evo_agency_agreement evo_agent_report_date: DateTime evo_agent_report_summ: Decimal + evo_bank_accountid: Uuid evo_bank_code: String evo_bank_detailsid: Uuid evo_bank_detailsidData: evo_bank_details @@ -1246,14 +1443,18 @@ type evo_request_payment { evo_contract_paysum: Decimal evo_contract_paysum_currency: Decimal evo_contract_paysum_fact: Decimal + evo_corresponding_account: String evo_director_decision: Int evo_director_systemuserid: Uuid evo_final_accept: Int evo_finegibddid: Uuid evo_finegibddidData: evo_finegibdd evo_id: String + evo_inn: String + evo_insurance_periodid: Uuid evo_insurance_policyid: Uuid evo_insurance_policyidData: evo_insurance_policy + evo_kpp: String evo_leasingobjectid: Uuid evo_name: String evo_number_dkp: String @@ -1339,6 +1540,7 @@ type evo_contract { evo_dealer_person_reward_conditionid: Uuid evo_dealer_person_reward_summ: Decimal evo_debtwork_contractid: Uuid + evo_debtwork_contracts: [evo_debtwork_contract] evo_debt_leasing: Decimal evo_debt_penalty_fee: Decimal evo_debt_total: Decimal @@ -1397,6 +1599,7 @@ type evo_contract { evo_leasingobjectidData: evo_leasingobject evo_leasing_bonus_summ: Decimal evo_leasing_pledge_agreementid: Uuid + evo_lessor_bank_detailsid: Uuid evo_log_activdate_1c: String evo_msfo_irr: Decimal evo_msfo_irr_actual: Decimal @@ -1622,6 +1825,7 @@ type evo_tarif { evo_max_irr: Decimal evo_max_last_payment: Decimal evo_max_period: Decimal + evo_min_decreasing_perc: Decimal evo_min_first_payment: Decimal evo_min_irr: Decimal evo_min_last_payment: Decimal @@ -1632,6 +1836,7 @@ type evo_tarif { evo_name: String evo_pay_supplier_without_addcontract: Boolean evo_rates(statecode: Int): [evo_rate] + evo_seasons_type_exception: [Int!] evo_tarifid: Uuid evo_transactioncurrencyid: Uuid evo_used: Boolean @@ -1763,7 +1968,9 @@ type systemuser { middlename: String mobilephone: String modifiedon: DateTime + roles: [role] systemuserid: Uuid + tisa_phonecallprocessings(statecode: Int = 0): [tisa_phonecallprocessing] toObjectString: String } @@ -2212,7 +2419,9 @@ type team { toObjectString: String } -"""The `DateTime` scalar represents an ISO-8601 compliant date time type.""" +""" +The `DateTime` scalar represents an ISO-8601 compliant date time type. +""" scalar DateTime input FilterInput { @@ -2236,6 +2445,7 @@ enum SortingType { type evo_insurance_policy { createdon: DateTime evo_accountid: Uuid + evo_addproductnumberid: Uuid evo_contractid: Uuid evo_create_contract_elt: Boolean evo_create_period_status: Int @@ -2306,6 +2516,85 @@ type evo_approvallog { toObjectString: String } +type evo_debtwork_contract { + createdon: DateTime + evo_accountid: Uuid + evo_contractid: Uuid + evo_date_change_statuscode: DateTime + evo_db_region_com: String + evo_debtwork_contractid: Uuid + evo_debt_restruct_description: String + evo_economic_security_com: String + evo_erroneous_pay_contractname: String + evo_inspection_done: Boolean + evo_inspection_impossible: Boolean + evo_inspection_impossible_reason: String + evo_inspection_link_report: String + evo_inspection_systemuserid: Uuid + evo_insurance_case_dateend: DateTime + evo_leasingobjectid: Uuid + evo_non_payment_count: Decimal + evo_opportunityid: Uuid + evo_plan_date_transfer_pay: DateTime + evo_redemption_com: String + evo_redemption_type: [Int!] + evo_result_debt_restruct: Boolean + evo_result_error_payment: Boolean + evo_result_inspection: Boolean + evo_result_insurance_case: Boolean + evo_result_redemption: Boolean + evo_result_termination: Boolean + evo_result_wait_payment: Boolean + evo_result_withdrawal: Boolean + evo_statuscodeid: Uuid + evo_statuscodeidData: evo_statuscode + evo_statuscode_reason: String + evo_storage: String + evo_termination_add_registry: Int + evo_termination_com: String + evo_termination_com_lawyer: String + evo_termination_lawyer_systemuserid: Uuid + evo_termination_reason_terms: Int + evo_termination_reason_terms_doc: String + evo_termination_reason_terms_text: String + evo_termination_send_notice: Boolean + evo_termination_send_notice_date: DateTime + evo_termination_send_notice_repeat: Boolean + evo_termination_solution: Int + evo_termination_status_work: Int + evo_termination_suspended_until: DateTime + evo_termination_unique_notice: Boolean + evo_withdrawal_businessunitid: Uuid + evo_withdrawal_done: Boolean + evo_withdrawal_impossible: Boolean + evo_withdrawal_impossible_reason: String + evo_withdrawal_issue_agreed: Int + evo_withdrawal_issue_done: Int + evo_withdrawal_parking_addressid: Uuid + evo_withdrawal_plan_date: DateTime + evo_withdrawal_systemuserid: Uuid + modifiedon: DateTime + ownerid: Uuid + toObjectString: String +} + +type tisa_phonecallprocessing { + createdon: DateTime + modifiedon: DateTime + tisa_emploeeid: Uuid + tisa_extension: String + tisa_phonecallprocessingid: Uuid + toObjectString: String +} + +type role { + createdon: DateTime + modifiedon: DateTime + name: String + roleid: Uuid + toObjectString: String +} + type activityparty { addressused: String createdon: DateTime diff --git a/src/core/services/CrmService/types/entities.ts b/src/core/services/CrmService/types/entities.ts index ac6e4bb..1296bda 100644 --- a/src/core/services/CrmService/types/entities.ts +++ b/src/core/services/CrmService/types/entities.ts @@ -102,6 +102,7 @@ export interface IOpportunity extends BaseEntity { } export interface IQuote extends BaseEntity { + evo_engine_hours?: number; evo_client_riskid?: string; evo_addproduct_types?: IEvoAddproductType[]; evo_gps_brandid?: string; @@ -203,6 +204,7 @@ export interface IEvoBaseproduct extends BaseEntity { evo_leasingobject_types?: IEvoLeasingObjectType[]; evo_brands?: IEvoBrand[]; systemusers?: ISystemUser[]; + evo_sale_without_nds?: boolean; } export interface IEvoLeasingObjectType extends BaseEntity { @@ -397,6 +399,7 @@ export interface IEvoTarif extends BaseEntity { evo_min_irr?: number; evo_datefrom?: Date; evo_graphtype_exception?: number[]; + evo_seasons_type_exception?: number[]; evo_dateto?: Date; evo_irr_plan?: number; evo_used?: boolean; diff --git a/src/core/types/Calculation/Store/values.ts b/src/core/types/Calculation/Store/values.ts index 6854a65..c370459 100644 --- a/src/core/types/Calculation/Store/values.ts +++ b/src/core/types/Calculation/Store/values.ts @@ -134,7 +134,11 @@ export type ValuesNames = | 'resultBonusMPL' | 'resultDopMPLLeasing' | 'resultBonusDopProd' - | 'resultBonusSafeFinance'; + | 'resultBonusSafeFinance' + | 'resultFirstPaymentRiskPolicy' + | 'leaseObjectPriceWthtVAT' + | 'VATInLeaseObjectPrice' + | 'engineHours'; export type ComputedValuesNames = | 'leaseObjectRiskName'