diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index 188c0ee..0f55ef8 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -397,7 +397,7 @@ export type GetPriceDataFromQuoteQueryVariables = Exact<{ }>; -export type GetPriceDataFromQuoteQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_comission_perc: number | null, evo_discount_perc: number | null, evo_discount_supplier_currency: number | null, evo_first_payment_perc: number | null, evo_last_payment_calc: number | null, evo_last_payment_perc: number | null, evo_nds_in_price_supplier_currency: number | null, evo_price_without_nds_supplier_currency: number | null, evo_sale_bonus: number | null, evo_supplier_currency_price: number | null, evo_transactioncurrencyid: string | null } | null }; +export type GetPriceDataFromQuoteQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_comission_perc: number | null, evo_discount_perc: number | null, evo_first_payment_perc: number | null, evo_last_payment_calc: number | null, evo_last_payment_perc: number | null, evo_nds_in_price_supplier_currency: number | null, evo_sale_bonus: number | null, evo_transactioncurrencyid: string | null } | null }; export type GetRewardRulesQueryVariables = Exact<{ conditionId: Scalars['Uuid']; @@ -455,6 +455,6 @@ export const GetQuoteUrlDocument = {"kind":"Document","definitions":[{"kind":"Op export const GetLeasingObjectDataFromQuoteDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeasingObjectDataFromQuote"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_equipmentid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}}]}}]} as unknown as DocumentNode; export const GetLeasingWithoutKaskoOptionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeasingWithoutKaskoOptions"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000007"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_addproduct_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_visible_calc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetPaymentsDataFromQuoteDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetPaymentsDataFromQuote"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_accept_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graph_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_payments_decrease_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_seasons_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_high_season"}},{"kind":"Field","name":{"kind":"Name","value":"evo_graphs"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createdon"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sumpay_withnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_planpayments"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_payment_ratio"}}]}}]}}]}}]}}]} as unknown as DocumentNode; -export const GetPriceDataFromQuoteDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetPriceDataFromQuote"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_comission_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_discount_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_discount_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_calc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_nds_in_price_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_price_without_nds_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sale_bonus"}},{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_currency_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_transactioncurrencyid"}}]}}]}}]} as unknown as DocumentNode; +export const GetPriceDataFromQuoteDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetPriceDataFromQuote"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_comission_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_discount_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_calc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_nds_in_price_supplier_currency"}},{"kind":"Field","name":{"kind":"Name","value":"evo_sale_bonus"}},{"kind":"Field","name":{"kind":"Name","value":"evo_transactioncurrencyid"}}]}}]}}]} as unknown as DocumentNode; export const GetRewardRulesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRewardRules"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"conditionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_reward_condition"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_reward_conditionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"conditionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_calc_reward_rules"}}]}}]}}]} as unknown as DocumentNode; export const GetAgentsDataFromQuoteDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAgentsDataFromQuote"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_supplier_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_person_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_reward_total"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_broker_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_broker_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_broker_reward_total"}},{"kind":"Field","name":{"kind":"Name","value":"evo_dealer_broker_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_agent_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_agent_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_agent_reward_total"}},{"kind":"Field","name":{"kind":"Name","value":"evo_agent_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_double_agent_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_double_agent_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_double_agent_reward_total"}},{"kind":"Field","name":{"kind":"Name","value":"evo_double_agent_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_reward_total"}},{"kind":"Field","name":{"kind":"Name","value":"evo_broker_reward_summ"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fin_department_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fin_department_reward_conditionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fin_department_reward_total"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fin_department_reward_summ"}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/apps/web/process/price/get-kp-data.ts b/apps/web/process/price/get-kp-data.ts index 8bc1f18..34ac5c1 100644 --- a/apps/web/process/price/get-kp-data.ts +++ b/apps/web/process/price/get-kp-data.ts @@ -9,15 +9,15 @@ const QUERY_GET_PRICE_DATA_FROM_QUOTE = gql` # evo_comission_rub evo_comission_perc evo_discount_perc - evo_discount_supplier_currency + # evo_discount_supplier_currency evo_first_payment_perc evo_last_payment_calc evo_last_payment_perc # evo_last_payment_rub evo_nds_in_price_supplier_currency - evo_price_without_nds_supplier_currency + # evo_price_without_nds_supplier_currency evo_sale_bonus - evo_supplier_currency_price + # evo_supplier_currency_price evo_transactioncurrencyid } } @@ -53,12 +53,12 @@ export default async function getPriceDataFromKP({ // lastPaymentRub: quote?.evo_last_payment_rub || 0, lastPaymentPerc: quote?.evo_last_payment_perc || 0, lastPaymentRule: quote?.evo_last_payment_calc, - leaseObjectPrice: quote?.evo_supplier_currency_price || 0, - leaseObjectPriceWthtVAT: quote?.evo_price_without_nds_supplier_currency || 0, + // leaseObjectPrice: quote?.evo_supplier_currency_price || 0, + // leaseObjectPriceWthtVAT: quote?.evo_price_without_nds_supplier_currency || 0, saleBonus: quote?.evo_sale_bonus || 0, supplierCurrency: quote?.evo_transactioncurrencyid, supplierDiscountPerc: quote?.evo_discount_perc || 0, - supplierDiscountRub: quote?.evo_discount_supplier_currency || 0, + // supplierDiscountRub: quote?.evo_discount_supplier_currency || 0, }, }; } diff --git a/apps/web/process/price/reactions/common.ts b/apps/web/process/price/reactions/common.ts index a0a367e..cacd4c6 100644 --- a/apps/web/process/price/reactions/common.ts +++ b/apps/web/process/price/reactions/common.ts @@ -37,13 +37,17 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex /** * Расчет размера скидки поставщика в валюте */ - autorun(() => { - const { leaseObjectPrice, supplierDiscountRub } = $calculation.$values.values; + makeDisposable( + () => + autorun(() => { + const { leaseObjectPrice, supplierDiscountRub } = $calculation.$values.values; - $calculation - .element('tbxSupplierDiscountPerc') - .setValue((supplierDiscountRub / leaseObjectPrice) * 100); - }); + $calculation + .element('tbxSupplierDiscountPerc') + .setValue((supplierDiscountRub / leaseObjectPrice) * 100); + }), + () => $process.has('LoadKP') + ); /** * Расчет суммы скидки поставщика в валюте @@ -56,40 +60,38 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex .setValue((supplierDiscountPerc * leaseObjectPrice) / 100); }); - autorun(async () => { - const { - product: productId, - leaseObjectPrice, - VATInLeaseObjectPrice, - } = $calculation.$values.values; + reaction( + () => + pick($calculation.$values.values, ['product', 'leaseObjectPrice', 'VATInLeaseObjectPrice']), + async ({ product: productId, leaseObjectPrice, VATInLeaseObjectPrice }) => { + let evo_sale_without_nds = false; - 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 (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 + .element('tbxLeaseObjectPriceWthtVAT') + .setValue(leaseObjectPrice - VATInLeaseObjectPrice); + } else { + const priceWithVAT = leaseObjectPrice / (1 + VAT); + const priceVAT = leaseObjectPrice - priceWithVAT; + $calculation.element('tbxLeaseObjectPriceWthtVAT').setValue(priceWithVAT); + $calculation.element('tbxVATInLeaseObjectPrice').setValue(priceVAT); } } - - if (evo_sale_without_nds) { - $calculation - .element('tbxLeaseObjectPriceWthtVAT') - .setValue(leaseObjectPrice - VATInLeaseObjectPrice); - } else { - const priceWithVAT = leaseObjectPrice / (1 + VAT); - const priceVAT = leaseObjectPrice - priceWithVAT; - $calculation.element('tbxLeaseObjectPriceWthtVAT').setValue(priceWithVAT); - $calculation.element('tbxVATInLeaseObjectPrice').setValue(priceVAT); - } - }); + ); reaction( () =>