diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts index 638f547..9afd094 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts @@ -82,8 +82,14 @@ export default ({ firstPaymentNdsAbs: 0, firstPaymentWithNdsAbs: 0, modelId: NIL, - paymentDateNew: new Date(), + paymentDateNew: currentDate, plTypeId: NIL, + tlmCostPaymentSum: preparedPaymentsRows + .map(x => x.tlmCostPayment || 0) + .reduce((a, b) => a + b, 0), + gpsCostPaymentSum: preparedPaymentsRows + .map(x => x.gpsCostPayment || 0) + .reduce((a, b) => a + b, 0), }; preparedValues.calcDate = currentDate; @@ -160,17 +166,14 @@ export default ({ ? insuranceOSAGORow?.insCost?.value : 0; - preparedValues.insurance = - (preparedValues.insuranceOsago || 0) + (preparedValues.insuranceKasko || 0); - preparedValues.insuranceKaskoNmper = (preparedValues.nmperInsurance || 0) >= 16 ? ((preparedValues.insuranceKasko || 0) * (preparedValues.nmperInsurance || 0)) / 12 : preparedValues.insuranceKasko; - - preparedValues.insuranceContract = + + preparedValues.insuranceContract = (preparedValues.insuranceKaskoNmper || 0) + (preparedValues.insuranceOsago || 0); @@ -443,12 +446,8 @@ export default ({ (preparedValues.trackerCost || 0) + (preparedValues.tLMCost || 0) + preparedValues.transportTaxGr + - preparedPaymentsRows - .map(x => x.tlmCostPayment || 0) - .reduce((a, b) => a + b, 0) + - preparedPaymentsRows - .map(x => x.gpsCostPayment || 0) - .reduce((a, b) => a + b, 0)) * + (preparedValues.tlmCostPaymentSum || 0) + + (preparedValues.gpsCostPaymentSum || 0)) * preparedValues.leasing0K - preparedValues.firstPaymentSum - (values.product === 'LEASING0' ? 0 : preparedValues.discount || 0)) * @@ -643,90 +642,6 @@ export default ({ } } - const { - plPrice = 0, - insurance, - rats = 0, - registration = 0, - trackerCost = 0, - tLMCost = 0, - transportTaxGr, - leasing0K, - nsibBrutto = 0, - insuranceContract, - comissionRub, - discount = 0, - baseRegistration = 0, - nsibNetto = 0, - nmper = 0, - firstPaymentSum, - } = preparedValues; - - preparedValues.calculationCost = - plPrice + - (insurance + rats + registration + trackerCost + tLMCost + transportTaxGr) * - leasing0K; - - preparedValues.priceUpTotal = - plPrice + - trackerCost + - tLMCost + - preparedPaymentsRows - .map(x => x.tlmCostPayment || 0) - .reduce((a, b) => a + b, 0) + - preparedPaymentsRows - .map(x => x.gpsCostPayment || 0) - .reduce((a, b) => a + b, 0) + - registration + - insuranceContract + - rats + - nsibBrutto + - transportTaxGr; - - preparedValues.acquisitionExpenses = - plPrice + - insurance - - comissionRub - - discount + - trackerCost + - tLMCost + - baseRegistration + - rats; - - preparedValues.npvBase = - plPrice + - ((nsibNetto * 12) / nmper + - insurance + - baseRegistration + - trackerCost + - tLMCost + - rats - - discount - - comissionRub - - firstPaymentSum); - - preparedValues.niAtInception = - preparedValues.acquisitionExpenses - firstPaymentSum; - - preparedValues.dogCredit = - plPrice + - (insurance + rats + registration + trackerCost + tLMCost + transportTaxGr) * - leasing0K - - firstPaymentSum + - (nsibNetto * 12) / nmper - - (values.product === 'LEASING0' ? 0 : discount); - - preparedValues.dogCreditLeasing = - plPrice + - insurance + - registration + - trackerCost + - tLMCost + - rats - - discount - - comissionRub - - firstPaymentSum; - return { preparedPayments: { rows: preparedPaymentsRows }, preparedValues, diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/validate.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/validate.ts index 5e96134..8ee1148 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate.ts @@ -88,7 +88,6 @@ const validateTables = () => { }; export default () => { - const v = toJS(CalculationStore.values); validateElements(); validateTables(); }; diff --git a/src/core/types/Calculation/Prepare.ts b/src/core/types/Calculation/Prepare.ts index c20ce0d..26f878a 100644 --- a/src/core/types/Calculation/Prepare.ts +++ b/src/core/types/Calculation/Prepare.ts @@ -89,6 +89,8 @@ export interface PreparedValues { directorBonus?: number; dogCredit?: number; dogCreditLeasing?: number; + tlmCostPaymentSum?: number; + gpsCostPaymentSum?: number; } export interface PaymentRow {