fix: при подгрузке КП отрабатывает реакция на изменение продукта и есть продукт с частичным НДС то БУ ставится автоматом Да

This commit is contained in:
vchikalkin 2023-06-05 10:09:58 +03:00
parent 159fb85e63
commit 2090056b81

View File

@ -2,10 +2,11 @@ import type { ProcessContext } from '../types';
import { createValidationSchema } from './validation';
import * as CRMTypes from '@/graphql/crm.types';
import { createValidationReaction } from '@/process/tools';
import { disposableReaction } from '@/utils/mobx';
import { reaction } from 'mobx';
export function common({ store, apolloClient }: ProcessContext) {
const { $calculation } = store;
const { $calculation, $process } = store;
/**
* Создаем реакцию на выбор Продукта selectProduct:
@ -40,11 +41,11 @@ export function common({ store, apolloClient }: ProcessContext) {
() => $calculation.$values.getValues(['product', 'recalcWithRevision']),
async ({ product: productId }) => {
if (!productId) {
$calculation.element('tbxSupplierDiscountRub').block().resetValue();
$calculation.element('tbxSupplierDiscountPerc').block().resetValue();
$calculation.element('tbxLeaseObjectPrice').block().resetValue();
$calculation.element('tbxVATInLeaseObjectPrice').block().resetValue();
$calculation.element('selectImportProgram').unblock().resetValue();
$calculation.element('tbxSupplierDiscountRub').block();
$calculation.element('tbxSupplierDiscountPerc').block();
$calculation.element('tbxLeaseObjectPrice').block();
$calculation.element('tbxVATInLeaseObjectPrice').block();
$calculation.element('selectImportProgram').unblock();
return;
}
@ -59,12 +60,11 @@ export function common({ store, apolloClient }: ProcessContext) {
});
if (evo_baseproduct?.evo_sale_without_nds) {
$calculation.element('tbxSupplierDiscountRub').block().resetValue();
$calculation.element('tbxSupplierDiscountPerc').block().resetValue();
$calculation.element('tbxSupplierDiscountRub').block();
$calculation.element('tbxSupplierDiscountPerc').block();
$calculation.element('tbxLeaseObjectPrice').unblock();
$calculation.element('tbxVATInLeaseObjectPrice').unblock();
$calculation.element('selectImportProgram').block().resetValue();
$calculation.element('cbxLeaseObjectUsed').setValue(true);
$calculation.element('selectImportProgram').block();
} else {
$calculation.element('tbxSupplierDiscountRub').unblock();
$calculation.element('tbxSupplierDiscountPerc').unblock();
@ -78,6 +78,39 @@ export function common({ store, apolloClient }: ProcessContext) {
}
);
disposableReaction(
() => $process.has('LoadKP'),
() => $calculation.$values.getValues(['product']),
async ({ product: productId }) => {
if (!productId) {
$calculation.element('tbxSupplierDiscountRub').resetValue();
$calculation.element('tbxSupplierDiscountPerc').resetValue();
$calculation.element('tbxLeaseObjectPrice').resetValue();
$calculation.element('tbxLeaseObjectPriceWthtVAT').resetValue();
$calculation.element('tbxVATInLeaseObjectPrice').resetValue();
$calculation.element('selectImportProgram').resetValue();
return;
}
const {
data: { evo_baseproduct },
} = await apolloClient.query({
query: CRMTypes.GetProductDocument,
variables: {
productId,
},
});
if (evo_baseproduct?.evo_sale_without_nds) {
$calculation.element('cbxLeaseObjectUsed').setValue(true);
$calculation.element('tbxSupplierDiscountRub').resetValue();
$calculation.element('tbxSupplierDiscountPerc').resetValue();
$calculation.element('selectImportProgram').resetValue();
}
}
);
/**
* Добавить реакцию на изменение поля Пересчет без пересмотра cbxRecalcWithRevision и загрузку КП:
* ЕСЛИ в поле Продукт selectProduct выбрана запись и поле БУбезНДС evo_sale_without_nds = True