diff --git a/apps/web/process/subsidy-import-program/reactions.ts b/apps/web/process/subsidy-import-program/reactions.ts index 1a7b202..3d9096f 100644 --- a/apps/web/process/subsidy-import-program/reactions.ts +++ b/apps/web/process/subsidy-import-program/reactions.ts @@ -23,8 +23,20 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex importProgram: importProgramId, dealer: dealerId, }) => { + const { + data: { transactioncurrencies }, + } = await apolloClient.query({ + query: CRMTypes.GetTransactionCurrenciesDocument, + }); + + const transactioncurrency_rub = transactioncurrencies?.find( + (x) => x?.isocurrencycode === 'RUB' + ); + + const transactioncurrency_rub_id = transactioncurrency_rub?.transactioncurrencyid || null; + if (!productId) { - $calculation.element('selectSupplierCurrency').resetValue().block(); + $calculation.element('selectSupplierCurrency').setValue(transactioncurrency_rub_id).block(); return; } @@ -39,7 +51,7 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex }); if (subsidyId || importProgramId || evo_baseproduct?.evo_sale_without_nds) { - $calculation.element('selectSupplierCurrency').resetValue().block(); + $calculation.element('selectSupplierCurrency').setValue(transactioncurrency_rub_id).block(); } else if (dealerId) { const { data: { dealer }, @@ -50,7 +62,10 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex }, }); if (dealer?.evo_return_leasing_dealer === true) { - $calculation.element('selectSupplierCurrency').resetValue().block(); + $calculation + .element('selectSupplierCurrency') + .setValue(transactioncurrency_rub_id) + .block(); } else { $calculation.element('selectSupplierCurrency').unblock(); } diff --git a/apps/web/stores/calculation/values/index.ts b/apps/web/stores/calculation/values/index.ts index 1dd85c5..038427d 100644 --- a/apps/web/stores/calculation/values/index.ts +++ b/apps/web/stores/calculation/values/index.ts @@ -7,7 +7,6 @@ import { pick } from 'radash'; export default class ValuesStore { private root: RootStore; public values = defaultValues; - private defaultValues = defaultValues; constructor(rootStore: RootStore) { makeAutoObservable(this); @@ -16,7 +15,6 @@ export default class ValuesStore { public hydrate = (initialValues: CalculationValues) => { this.values = { ...defaultValues, ...initialValues }; - this.defaultValues = { ...defaultValues, ...initialValues }; }; public getValues = (keys: K[]) => pick(this.values, keys); @@ -34,6 +32,6 @@ export default class ValuesStore { }; public resetValue = (valueName: Values) => { - this.setValue(valueName, this.defaultValues[valueName]); + this.setValue(valueName, defaultValues[valueName]); }; }