На изменение значения поля "Частичный НДС" cbxPartialVAT необходимо перенести все реакции и зависимости от поля "Продажа без НДС" в Продукте selectProduct (ищем по evo_sale_without_nds):
см. в ЗНР ___Реакции по процессам _ в таблице по "DYN-3854"
This commit is contained in:
parent
d0b4641300
commit
330d68f2a9
@ -348,21 +348,15 @@ export async function makeEltKaskoRequest(
|
||||
const leaseObjectUsed = $calculation.element('cbxLeaseObjectUsed').getValue();
|
||||
|
||||
const productId = $calculation.element('selectProduct').getValue();
|
||||
let evo_baseproduct: CRMTypes.GetProductQuery['evo_baseproduct'] = null;
|
||||
if (productId) {
|
||||
const { data } = await apolloClient.query({
|
||||
query: CRMTypes.GetProductDocument,
|
||||
variables: { productId },
|
||||
});
|
||||
({ evo_baseproduct } = data);
|
||||
}
|
||||
const partialVAT = $calculation.element('cbxPartialVAT').getValue();
|
||||
|
||||
const leaseObjectYear = $calculation.element('tbxLeaseObjectYear').getValue();
|
||||
let isNew = true;
|
||||
if (
|
||||
leaseObjectUsed === true ||
|
||||
(leaseObjectUsed === false &&
|
||||
evo_baseproduct?.evo_sale_without_nds === true &&
|
||||
productId &&
|
||||
partialVAT &&
|
||||
leaseObjectYear < currentDate.getFullYear() - 1)
|
||||
) {
|
||||
isNew = false;
|
||||
@ -373,7 +367,8 @@ export async function makeEltKaskoRequest(
|
||||
if (
|
||||
leaseObjectUsed === true ||
|
||||
(leaseObjectUsed === false &&
|
||||
evo_baseproduct?.evo_sale_without_nds === true &&
|
||||
productId &&
|
||||
partialVAT &&
|
||||
leaseObjectYear < currentDate.getFullYear() - 1)
|
||||
) {
|
||||
vehicleDate = new Date(`${vehicleYear}-01-01`);
|
||||
@ -496,7 +491,8 @@ export async function makeEltKaskoRequest(
|
||||
|
||||
if (
|
||||
leaseObjectUsed === false &&
|
||||
evo_baseproduct?.evo_sale_without_nds === true &&
|
||||
productId &&
|
||||
partialVAT &&
|
||||
leaseObjectYear < currentDate.getFullYear() - 1
|
||||
) {
|
||||
mileage = 0;
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { VAT } from '@/constants/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import { reaction } from 'mobx';
|
||||
import { round } from 'tools';
|
||||
|
||||
export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
export default function reactions({ store }: ProcessContext) {
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
reaction(
|
||||
@ -71,25 +70,15 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
);
|
||||
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['product', 'leaseObjectPrice', 'VATInLeaseObjectPrice']),
|
||||
async ({ product: productId, leaseObjectPrice, VATInLeaseObjectPrice }) => {
|
||||
let evo_sale_without_nds = false;
|
||||
|
||||
if (productId) {
|
||||
const {
|
||||
data: { evo_baseproduct },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetProductDocument,
|
||||
variables: {
|
||||
productId,
|
||||
},
|
||||
});
|
||||
if (evo_baseproduct?.evo_sale_without_nds) {
|
||||
evo_sale_without_nds = evo_baseproduct.evo_sale_without_nds;
|
||||
}
|
||||
}
|
||||
|
||||
if (evo_sale_without_nds) {
|
||||
() =>
|
||||
$calculation.$values.getValues([
|
||||
'product',
|
||||
'leaseObjectPrice',
|
||||
'VATInLeaseObjectPrice',
|
||||
'partialVAT',
|
||||
]),
|
||||
async ({ product: productId, leaseObjectPrice, VATInLeaseObjectPrice, partialVAT }) => {
|
||||
if (productId && partialVAT) {
|
||||
$calculation
|
||||
.element('tbxLeaseObjectPriceWthtVAT')
|
||||
.setValue(leaseObjectPrice - VATInLeaseObjectPrice);
|
||||
|
||||
@ -1,17 +1,16 @@
|
||||
import type { ValidationContext } from '../types';
|
||||
import ValuesSchema from '@/config/schema/values';
|
||||
import { VAT } from '@/constants/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { round } from 'tools';
|
||||
import { z } from 'zod';
|
||||
|
||||
export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
export function createValidationSchema() {
|
||||
return ValuesSchema.pick({
|
||||
VATInLeaseObjectPrice: true,
|
||||
balanceHolder: true,
|
||||
firstPaymentRub: true,
|
||||
lastPaymentPerc: true,
|
||||
leaseObjectPriceWthtVAT: true,
|
||||
partialVAT: true,
|
||||
plPriceRub: true,
|
||||
product: true,
|
||||
subsidySum: true,
|
||||
@ -28,30 +27,21 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
subsidySum,
|
||||
balanceHolder,
|
||||
lastPaymentPerc,
|
||||
partialVAT,
|
||||
},
|
||||
ctx
|
||||
) => {
|
||||
if (productId) {
|
||||
const {
|
||||
data: { evo_baseproduct },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetProductDocument,
|
||||
variables: {
|
||||
productId,
|
||||
},
|
||||
if (
|
||||
productId &&
|
||||
partialVAT &&
|
||||
round(VATInLeaseObjectPrice / leaseObjectPriceWthtVAT, 2) >= VAT
|
||||
) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message:
|
||||
'При продаже ПЛ после ФЛ размер НДС в стоимости ПЛ не может составлять 20% и более от стоимости с НДС. Проверьте корректность НДС, либо измените Продукт',
|
||||
path: ['tbxVATInLeaseObjectPrice'],
|
||||
});
|
||||
|
||||
if (
|
||||
evo_baseproduct?.evo_sale_without_nds &&
|
||||
round(VATInLeaseObjectPrice / leaseObjectPriceWthtVAT, 2) >= VAT
|
||||
) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message:
|
||||
'При продаже ПЛ после ФЛ размер НДС в стоимости ПЛ не может составлять 20% и более от стоимости с НДС. Проверьте корректность НДС, либо измените Продукт',
|
||||
path: ['tbxVATInLeaseObjectPrice'],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (supplierDiscountRub >= plPriceRub) {
|
||||
|
||||
@ -21,6 +21,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
leaseObjectUsed: true,
|
||||
leaseObjectYear: true,
|
||||
maxMass: true,
|
||||
partialVAT: true,
|
||||
plPriceRub: true,
|
||||
product: true,
|
||||
quote: true,
|
||||
@ -45,6 +46,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
leaseObjectYear,
|
||||
lastPaymentPerc,
|
||||
leaseObjectCategory,
|
||||
partialVAT,
|
||||
},
|
||||
ctx
|
||||
) => {
|
||||
@ -75,18 +77,11 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
variables: { quoteId },
|
||||
});
|
||||
|
||||
const {
|
||||
data: { evo_baseproduct },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetProductDocument,
|
||||
variables: { productId },
|
||||
});
|
||||
|
||||
const maxCondition1 =
|
||||
leaseObjectUsed === false &&
|
||||
dealerPerson?.evo_supplier_type !== 100_000_001 &&
|
||||
quote?.evo_max_price_change &&
|
||||
!evo_baseproduct?.evo_sale_without_nds &&
|
||||
!partialVAT &&
|
||||
plPriceRub - discountRub + addEquipmentPrice - importProgramSum >
|
||||
quote.evo_max_price_change;
|
||||
|
||||
@ -94,7 +89,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
leaseObjectUsed === false &&
|
||||
dealerPerson?.evo_supplier_type !== 100_000_001 &&
|
||||
quote?.evo_max_price_change &&
|
||||
evo_baseproduct?.evo_sale_without_nds &&
|
||||
partialVAT &&
|
||||
leaseObjectPriceWthtVAT >
|
||||
quote.evo_max_price_change - (quote.evo_nds_in_price_supplier_currency || 0);
|
||||
|
||||
@ -108,13 +103,13 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
(quote.evo_program_import_subsidy_sum || 0);
|
||||
|
||||
const minCondition1 =
|
||||
!evo_baseproduct?.evo_sale_without_nds &&
|
||||
!partialVAT &&
|
||||
quote?.evo_min_change_price &&
|
||||
plPriceRub - discountRub + addEquipmentPrice - importProgramSum <
|
||||
quote.evo_min_change_price;
|
||||
|
||||
const minCondition2 =
|
||||
evo_baseproduct?.evo_sale_without_nds &&
|
||||
partialVAT &&
|
||||
quote?.evo_min_change_price &&
|
||||
leaseObjectPriceWthtVAT <
|
||||
quote.evo_min_change_price - (quote.evo_nds_in_price_supplier_currency || 0);
|
||||
|
||||
@ -16,12 +16,20 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
* иначе selectSupplierCurrency открыто для редактирования
|
||||
*/
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['product', 'subsidy', 'importProgram', 'dealer']),
|
||||
() =>
|
||||
$calculation.$values.getValues([
|
||||
'product',
|
||||
'subsidy',
|
||||
'importProgram',
|
||||
'dealer',
|
||||
'partialVAT',
|
||||
]),
|
||||
async ({
|
||||
product: productId,
|
||||
subsidy: subsidyId,
|
||||
importProgram: importProgramId,
|
||||
dealer: dealerId,
|
||||
partialVAT,
|
||||
}) => {
|
||||
const {
|
||||
data: { transactioncurrencies },
|
||||
@ -41,16 +49,7 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_baseproduct },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetProductDocument,
|
||||
variables: {
|
||||
productId,
|
||||
},
|
||||
});
|
||||
|
||||
if (subsidyId || importProgramId || evo_baseproduct?.evo_sale_without_nds) {
|
||||
if (subsidyId || importProgramId || (productId && partialVAT)) {
|
||||
$calculation.element('selectSupplierCurrency').setValue(transactioncurrency_rub_id).block();
|
||||
} else if (dealerId) {
|
||||
const {
|
||||
|
||||
@ -38,8 +38,8 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
* поле НДС в стоимости предмета лизинга xxx закрыть для редактирования
|
||||
*/
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['product', 'recalcWithRevision']),
|
||||
async ({ product: productId }) => {
|
||||
() => $calculation.$values.getValues(['product', 'recalcWithRevision', 'partialVAT']),
|
||||
async ({ product: productId, partialVAT }) => {
|
||||
if (!productId) {
|
||||
$calculation.element('tbxSupplierDiscountRub').block();
|
||||
$calculation.element('tbxSupplierDiscountPerc').block();
|
||||
@ -50,16 +50,7 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_baseproduct },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetProductDocument,
|
||||
variables: {
|
||||
productId,
|
||||
},
|
||||
});
|
||||
|
||||
if (evo_baseproduct?.evo_sale_without_nds) {
|
||||
if (productId && partialVAT) {
|
||||
$calculation.element('tbxSupplierDiscountRub').block();
|
||||
$calculation.element('tbxSupplierDiscountPerc').block();
|
||||
$calculation.element('tbxLeaseObjectPrice').unblock();
|
||||
@ -80,8 +71,8 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
|
||||
disposableReaction(
|
||||
() => $process.has('LoadKP'),
|
||||
() => $calculation.$values.getValues(['product']),
|
||||
async ({ product: productId }) => {
|
||||
() => $calculation.$values.getValues(['product', 'partialVAT']),
|
||||
async ({ product: productId, partialVAT }) => {
|
||||
if (!productId) {
|
||||
$calculation.element('tbxSupplierDiscountRub').resetValue();
|
||||
$calculation.element('tbxSupplierDiscountPerc').resetValue();
|
||||
@ -93,23 +84,15 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_baseproduct },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetProductDocument,
|
||||
variables: {
|
||||
productId,
|
||||
},
|
||||
});
|
||||
|
||||
if (evo_baseproduct?.evo_sale_without_nds) {
|
||||
if (productId && partialVAT) {
|
||||
$calculation.element('tbxSupplierDiscountRub').resetValue();
|
||||
$calculation.element('tbxSupplierDiscountPerc').resetValue();
|
||||
$calculation.element('selectImportProgram').resetValue();
|
||||
}
|
||||
|
||||
if (
|
||||
evo_baseproduct?.evo_sale_without_nds &&
|
||||
productId &&
|
||||
partialVAT &&
|
||||
$calculation.element('cbxRecalcWithRevision').getValue() === false
|
||||
) {
|
||||
$calculation.element('cbxLeaseObjectUsed').setValue(true);
|
||||
@ -127,8 +110,8 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
* иначе открыты для редактирования
|
||||
*/
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['recalcWithRevision', 'product']),
|
||||
async ({ recalcWithRevision, product: productId }) => {
|
||||
() => $calculation.$values.getValues(['recalcWithRevision', 'product', 'partialVAT']),
|
||||
async ({ recalcWithRevision, product: productId, partialVAT }) => {
|
||||
if (!productId) {
|
||||
$calculation.element('tbxFirstPaymentPerc').unblock();
|
||||
$calculation.element('tbxFirstPaymentRub').unblock();
|
||||
@ -136,16 +119,7 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_baseproduct },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetProductDocument,
|
||||
variables: {
|
||||
productId,
|
||||
},
|
||||
});
|
||||
|
||||
if (evo_baseproduct?.evo_sale_without_nds && recalcWithRevision) {
|
||||
if (productId && partialVAT && recalcWithRevision) {
|
||||
$calculation.element('tbxFirstPaymentPerc').block();
|
||||
$calculation.element('tbxFirstPaymentRub').block();
|
||||
} else {
|
||||
@ -227,6 +201,7 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
'product',
|
||||
'dealer',
|
||||
'supplierFinancing',
|
||||
'partialVAT',
|
||||
]),
|
||||
async ({
|
||||
leaseObjectUsed,
|
||||
@ -234,20 +209,11 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
product: productId,
|
||||
dealer: dealerId,
|
||||
supplierFinancing,
|
||||
partialVAT,
|
||||
}) => {
|
||||
let evo_baseproduct: CRMTypes.GetProductQuery['evo_baseproduct'] = null;
|
||||
let dealer: CRMTypes.GetDealerQuery['dealer'] = null;
|
||||
let evo_subsidy: CRMTypes.GetSubsidyQuery['evo_subsidy'] = null;
|
||||
|
||||
if (productId) {
|
||||
const { data } = await apolloClient.query({
|
||||
query: CRMTypes.GetProductDocument,
|
||||
variables: { productId },
|
||||
});
|
||||
|
||||
({ evo_baseproduct } = data);
|
||||
}
|
||||
|
||||
if (dealerId) {
|
||||
const { data } = await apolloClient.query({
|
||||
query: CRMTypes.GetDealerDocument,
|
||||
@ -270,7 +236,7 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
leaseObjectUsed ||
|
||||
(evo_subsidy_evo_delivery_time?.length === 1 &&
|
||||
evo_subsidy_evo_delivery_time.includes(100_000_000)) ||
|
||||
evo_baseproduct?.evo_sale_without_nds ||
|
||||
(productId && partialVAT) ||
|
||||
dealer?.evo_return_leasing_dealer
|
||||
) {
|
||||
$calculation.element('radioDeliveryTime').setValue(100_000_000).block();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user