fix prepared-values
This commit is contained in:
parent
2097b28870
commit
5432536b2e
@ -33,16 +33,44 @@ export async function createRequestData({
|
||||
|
||||
const { RUB } = createCurrencyUtility({ apolloClient });
|
||||
|
||||
let tracker: CRMTypes.GetAddProductTypeQuery['evo_addproduct_type'] = null;
|
||||
|
||||
if (input.values.tracker) {
|
||||
const { data } = await apolloClient.query({
|
||||
query: CRMTypes.GetAddProductTypeDocument,
|
||||
variables: { addproductTypeId: input.values.tracker },
|
||||
});
|
||||
tracker = data.evo_addproduct_type;
|
||||
}
|
||||
|
||||
let telematic: CRMTypes.GetAddProductTypeQuery['evo_addproduct_type'] = null;
|
||||
if (input.values.telematic) {
|
||||
const { data } = await apolloClient.query({
|
||||
query: CRMTypes.GetAddProductTypeDocument,
|
||||
variables: { addproductTypeId: input.values.telematic },
|
||||
});
|
||||
telematic = data.evo_addproduct_type;
|
||||
}
|
||||
|
||||
const preparedPayments: CoreTypes.PreparedPayments = {
|
||||
rows: payments.values.map((value, index) => ({
|
||||
gpsBasePayment: 0,
|
||||
gpsCostPayment: 0,
|
||||
numberPayment: index + 1,
|
||||
percentPayment: index === 0 ? 0 : value,
|
||||
sumPayment: (payments.sums[index] ?? 0) / (1 + VAT),
|
||||
tlmBasePayment: 0,
|
||||
tlmCostPayment: 0,
|
||||
})),
|
||||
rows: payments.values.map((value, index) => {
|
||||
const tracker_evo_planpayments = tracker?.evo_planpayments?.[index];
|
||||
const telematic_evo_planpayments = telematic?.evo_planpayments?.[index];
|
||||
|
||||
return {
|
||||
gpsBasePayment:
|
||||
(tracker_evo_planpayments?.evo_cost_price_telematics_withoutnds || 0) +
|
||||
(tracker_evo_planpayments?.evo_cost_equipment_withoutnds || 0),
|
||||
gpsCostPayment: tracker_evo_planpayments?.evo_cost_telematics_withoutnds || 0,
|
||||
numberPayment: index + 1,
|
||||
percentPayment: index === 0 ? 0 : value,
|
||||
sumPayment: (payments.sums[index] ?? 0) / (1 + VAT),
|
||||
tlmBasePayment:
|
||||
(telematic_evo_planpayments?.evo_cost_price_telematics_withoutnds || 0) +
|
||||
(telematic_evo_planpayments?.evo_cost_equipment_withoutnds || 0),
|
||||
tlmCostPayment: telematic_evo_planpayments?.evo_cost_telematics_withoutnds || 0,
|
||||
};
|
||||
}),
|
||||
};
|
||||
|
||||
const currentDate = dayjs().utc(false);
|
||||
@ -389,7 +417,9 @@ export async function createRequestData({
|
||||
(x) => x?.evo_sot_coefficient_typeidData?.evo_id === 'DIRECTOR_BONUS_NSIB'
|
||||
);
|
||||
|
||||
return evo_coefficient?.evo_sot_coefficient || 0;
|
||||
const nsibBrutto = await this.nsibBrutto();
|
||||
|
||||
return (evo_coefficient?.evo_sot_coefficient || 0) * nsibBrutto;
|
||||
},
|
||||
|
||||
async directorExtraBonus() {
|
||||
@ -832,13 +862,7 @@ export async function createRequestData({
|
||||
},
|
||||
|
||||
async nsBonus() {
|
||||
const evo_coefficient = evo_coefficients?.find(
|
||||
(x) =>
|
||||
x?.evo_job_titleid === systemuser?.evo_job_titleid &&
|
||||
x?.evo_sot_coefficient_typeidData?.evo_id === 'BONUS_NS_PR'
|
||||
);
|
||||
|
||||
return evo_coefficient?.evo_sot_coefficient || 0;
|
||||
return 0;
|
||||
},
|
||||
|
||||
async nsibBase() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user