fix plprice & discount
This commit is contained in:
parent
e544774c6b
commit
fbac09d375
@ -1,10 +1,9 @@
|
||||
import { calcPrice } from 'client/stores/CalculationStore/Effects/lib/tools';
|
||||
import valuesConstants from 'core/constants/values';
|
||||
import { PreparedValues } from 'core/types/Calculation/Prepare';
|
||||
import { PaymentRow, PreparedValues } from 'core/types/Calculation/Prepare';
|
||||
import { IGetCalculationRequest } from 'core/types/Calculation/Requests';
|
||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||
import { DateTime } from 'luxon';
|
||||
import { PaymentRow } from './../../core/types/Calculation/Prepare';
|
||||
|
||||
export const prepareCalculationData = ({
|
||||
calculationStore,
|
||||
@ -225,46 +224,34 @@ export const prepareCalculationData = ({
|
||||
preparedValues.firstPayment = values.firstPaymentPerc / 100;
|
||||
}
|
||||
|
||||
const transactioncurrencyRUB = options.selectSupplierCurrency?.find(
|
||||
x => x.isocurrencycode === 'RUB',
|
||||
//plPrice && discount
|
||||
const supplierCurrency = options.selectSupplierCurrency?.find(
|
||||
x => x.transactioncurrencyid === values.supplierCurrency,
|
||||
);
|
||||
|
||||
if (
|
||||
values.supplierCurrency === transactioncurrencyRUB?.transactioncurrencyid
|
||||
) {
|
||||
preparedValues.plPrice =
|
||||
values.leaseObjectPrice / (1 + valuesConstants.VAT);
|
||||
preparedValues.discount =
|
||||
values.supplierDiscountRub / (1 + valuesConstants.VAT);
|
||||
} else {
|
||||
const evo_currencychanges = calculationStore.getStaticData(
|
||||
'evo_currencychange',
|
||||
);
|
||||
const evo_currencychanges = calculationStore.getStaticData(
|
||||
'evo_currencychange',
|
||||
);
|
||||
const evo_currencychange = evo_currencychanges.find(
|
||||
x => x.evo_ref_transactioncurrency === values.supplierCurrency,
|
||||
);
|
||||
|
||||
if (evo_currencychanges && evo_currencychanges.length > 0) {
|
||||
const evo_currencychange_supplier = evo_currencychanges.find(
|
||||
x => x.transactioncurrencyid === values.supplierCurrency,
|
||||
);
|
||||
preparedValues.plPrice =
|
||||
calcPrice(
|
||||
supplierCurrency?.isocurrencycode,
|
||||
values.leaseObjectPrice,
|
||||
evo_currencychange?.evo_currencychange || 1,
|
||||
) /
|
||||
(1 + valuesConstants.VAT);
|
||||
|
||||
if (evo_currencychange_supplier) {
|
||||
preparedValues.plPrice =
|
||||
calcPrice(
|
||||
evo_currencychange_supplier.isocurrencycode,
|
||||
values.leaseObjectPrice,
|
||||
evo_currencychange_supplier.evo_currencychange || 0,
|
||||
) /
|
||||
(1 + valuesConstants.VAT);
|
||||
|
||||
preparedValues.discount =
|
||||
calcPrice(
|
||||
evo_currencychange_supplier.isocurrencycode,
|
||||
values.supplierDiscountRub,
|
||||
evo_currencychange_supplier.evo_currencychange || 0,
|
||||
) /
|
||||
(1 + valuesConstants.VAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
preparedValues.discount =
|
||||
calcPrice(
|
||||
supplierCurrency?.isocurrencycode,
|
||||
values.supplierDiscountRub,
|
||||
evo_currencychange?.evo_currencychange || 1,
|
||||
) /
|
||||
(1 + valuesConstants.VAT);
|
||||
//
|
||||
|
||||
preparedValues.acceptSum =
|
||||
(preparedValues.plPrice || 0) - (preparedValues.discount || 0);
|
||||
|
||||
Reference in New Issue
Block a user