fix: reset result values after create-kp with recalc
This commit is contained in:
parent
554a702e6c
commit
aaa8cadc02
@ -41,7 +41,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
);
|
||||
|
||||
disposableReaction(
|
||||
() => $process.has('Calculate'),
|
||||
() => $process.has('Calculate') || $process.has('CreateKP'),
|
||||
() => {
|
||||
const values = $calculation.$values.getValues();
|
||||
|
||||
@ -63,6 +63,18 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
'tarif',
|
||||
'rate',
|
||||
'creditRate',
|
||||
'recalcWithRevision',
|
||||
'quote',
|
||||
'depreciationGroup',
|
||||
'registrationDescription',
|
||||
'leaseObjectCount',
|
||||
'kpUrl',
|
||||
'leadUrl',
|
||||
'quoteUrl',
|
||||
'opportunityUrl',
|
||||
'subsidySum',
|
||||
'insKaskoPriceLeasePeriod',
|
||||
'leaseObjectRiskName',
|
||||
]),
|
||||
};
|
||||
},
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { updateSelectQuote } from '../lead-opportunity/reactions/common';
|
||||
import type { ProcessContext } from '../types';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import { toJS } from 'mobx';
|
||||
import { notification } from 'ui/elements';
|
||||
|
||||
@ -50,14 +51,31 @@ export function action({ store, trpcClient, apolloClient }: ProcessContext) {
|
||||
} else {
|
||||
$results.setPayments(res.data.resultPayments);
|
||||
$results.setValues(res.data.resultValues);
|
||||
$calculation.$values.setValues(res.data.values);
|
||||
$calculation.$values.setValues({ ...res.data.values, recalcWithRevision: false });
|
||||
|
||||
notification.success({
|
||||
key,
|
||||
message: successMessage,
|
||||
});
|
||||
|
||||
await updateSelectQuote({ apolloClient, store });
|
||||
const leadid = $calculation.element('selectLead').getValue();
|
||||
|
||||
if (leadid) {
|
||||
const {
|
||||
data: { quotes },
|
||||
} = await apolloClient.query({
|
||||
fetchPolicy: 'network-only',
|
||||
query: CRMTypes.GetQuotesDocument,
|
||||
variables: {
|
||||
leadid,
|
||||
},
|
||||
});
|
||||
|
||||
$calculation
|
||||
.element('selectQuote')
|
||||
.setOptions(normalizeOptions(quotes))
|
||||
.setValue(values.quote);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@ -89,44 +89,33 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['recalcWithRevision', 'lead']),
|
||||
async () => {
|
||||
await updateSelectQuote({ apolloClient, store });
|
||||
async ({ lead: leadid, recalcWithRevision }) => {
|
||||
if (leadid) {
|
||||
const {
|
||||
data: { quotes },
|
||||
} = await apolloClient.query({
|
||||
fetchPolicy: 'network-only',
|
||||
query: CRMTypes.GetQuotesDocument,
|
||||
variables: {
|
||||
leadid,
|
||||
},
|
||||
});
|
||||
|
||||
if (recalcWithRevision) {
|
||||
const filteredQuotes = quotes?.filter(
|
||||
(quote) =>
|
||||
quote?.evo_recalc_limit &&
|
||||
quote.evo_recalc_limit > 0 &&
|
||||
quote.evo_statuscodeidData?.evo_id === '2.3' &&
|
||||
!quote.evo_purchases_participation
|
||||
);
|
||||
$calculation.element('selectQuote').setOptions(normalizeOptions(filteredQuotes));
|
||||
} else {
|
||||
$calculation.element('selectQuote').setOptions(normalizeOptions(quotes));
|
||||
}
|
||||
} else {
|
||||
$calculation.element('selectQuote').reset();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateSelectQuote({
|
||||
store,
|
||||
apolloClient,
|
||||
}: Pick<ProcessContext, 'apolloClient' | 'store'>) {
|
||||
const { $calculation } = store;
|
||||
const leadid = $calculation.element('selectLead').getValue();
|
||||
const recalcWithRevision = $calculation.element('cbxRecalcWithRevision').getValue();
|
||||
|
||||
if (leadid) {
|
||||
const {
|
||||
data: { quotes },
|
||||
} = await apolloClient.query({
|
||||
fetchPolicy: 'network-only',
|
||||
query: CRMTypes.GetQuotesDocument,
|
||||
variables: {
|
||||
leadid,
|
||||
},
|
||||
});
|
||||
|
||||
if (recalcWithRevision) {
|
||||
const filteredQuotes = quotes?.filter(
|
||||
(quote) =>
|
||||
quote?.evo_recalc_limit &&
|
||||
quote.evo_recalc_limit > 0 &&
|
||||
quote.evo_statuscodeidData?.evo_id === '2.3' &&
|
||||
!quote.evo_purchases_participation
|
||||
);
|
||||
$calculation.element('selectQuote').setOptions(normalizeOptions(filteredQuotes));
|
||||
} else {
|
||||
$calculation.element('selectQuote').setOptions(normalizeOptions(quotes));
|
||||
}
|
||||
} else {
|
||||
$calculation.element('selectQuote').reset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,8 @@ export function common({ store, trpcClient, apolloClient }: ProcessContext) {
|
||||
() => {
|
||||
const quote = $calculation.element('selectQuote').getOption();
|
||||
|
||||
if (!quote || $process.has('LoadKP')) return;
|
||||
if (!quote || $process.has('LoadKP') || $process.has('Calculate') || $process.has('CreateKP'))
|
||||
return;
|
||||
|
||||
$process.add('LoadKP');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user