63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import type { GetQuoteDataInput, GetQuoteDataOutput } from '../load-kp/types';
|
|
import initializeApollo from '@/apollo/client';
|
|
import type * as CRMTypes from '@/graphql/crm.types';
|
|
import { gql } from '@apollo/client';
|
|
|
|
const QUERY_GET_PRICE_DATA_FROM_QUOTE = gql`
|
|
query GetPriceDataFromQuote($quoteId: Uuid!) {
|
|
quote(quoteId: $quoteId) {
|
|
# evo_comission_rub
|
|
evo_comission_perc
|
|
evo_discount_perc
|
|
# 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_supplier_currency_price
|
|
evo_transactioncurrencyid
|
|
}
|
|
}
|
|
`;
|
|
|
|
type QuotePaymentsProcessData = {
|
|
values: Partial<GetQuoteDataOutput['values']>;
|
|
};
|
|
|
|
export default async function getPriceDataFromKP({
|
|
values: { quote: quoteId },
|
|
}: GetQuoteDataInput): Promise<QuotePaymentsProcessData> {
|
|
const apolloClient = initializeApollo();
|
|
|
|
const {
|
|
data: { quote },
|
|
} = await apolloClient.query<
|
|
CRMTypes.GetPriceDataFromQuoteQuery,
|
|
CRMTypes.GetPriceDataFromQuoteQueryVariables
|
|
>({
|
|
query: QUERY_GET_PRICE_DATA_FROM_QUOTE,
|
|
variables: {
|
|
quoteId,
|
|
},
|
|
});
|
|
|
|
return {
|
|
values: {
|
|
VATInLeaseObjectPrice: quote?.evo_nds_in_price_supplier_currency ?? undefined,
|
|
comissionPerc: quote?.evo_comission_perc ?? undefined,
|
|
// comissionRub: quote?.evo_comission_rub ?? undefined,
|
|
firstPaymentPerc: quote?.evo_first_payment_perc ?? undefined,
|
|
// lastPaymentRub: quote?.evo_last_payment_rub ?? undefined,
|
|
lastPaymentPerc: quote?.evo_last_payment_perc ?? undefined,
|
|
lastPaymentRule: quote?.evo_last_payment_calc,
|
|
leaseObjectPrice: quote?.evo_supplier_currency_price ?? undefined,
|
|
// leaseObjectPriceWthtVAT: quote?.evo_price_without_nds_supplier_currency ?? undefined,
|
|
supplierCurrency: quote?.evo_transactioncurrencyid,
|
|
supplierDiscountPerc: quote?.evo_discount_perc ?? undefined,
|
|
// supplierDiscountRub: quote?.evo_discount_supplier_currency ?? undefined,
|
|
},
|
|
};
|
|
}
|