fix check price when non rub currency

This commit is contained in:
Chika 2020-12-16 19:58:52 +03:00
parent 036a3ac085
commit 0fb0abde5d

View File

@ -1,6 +1,7 @@
import { openNotification } from 'client/Elements/Notification';
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
import { Process } from 'core/types/Calculation/Store/process';
import { convertPrice } from '../../lib/tools';
import { calculatePerc, calculateRub } from './calculate';
export default [
@ -239,11 +240,23 @@ export default [
},
effect: supplierDiscountRub => {
const { leaseObjectPrice } = calculationStore.values;
if (
leaseObjectPrice &&
leaseObjectPrice > 0 &&
supplierDiscountRub >= leaseObjectPrice
) {
const { supplierCurrency: supplierCurrencyId } = calculationStore.values;
const supplierCurrency = calculationStore
.getOptions('selectSupplierCurrency')
.find(x => x.transactioncurrencyid === supplierCurrencyId);
const evo_currencychange = calculationStore
.getStaticData('evo_currencychange')
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
const evo_currencychangeValue =
(evo_currencychange && evo_currencychange.evo_currencychange) || 0;
let price = convertPrice(
supplierCurrency?.isocurrencycode,
leaseObjectPrice,
evo_currencychangeValue,
);
if (price && price > 0 && supplierDiscountRub >= price) {
calculationStore.setValidation('tbxSupplierDiscountRub', false);
openNotification({
type: 'error',
@ -264,11 +277,22 @@ export default [
},
effect: firstPaymentRub => {
const { leaseObjectPrice } = calculationStore.values;
if (
leaseObjectPrice &&
leaseObjectPrice > 0 &&
firstPaymentRub >= leaseObjectPrice
) {
const { supplierCurrency: supplierCurrencyId } = calculationStore.values;
const supplierCurrency = calculationStore
.getOptions('selectSupplierCurrency')
.find(x => x.transactioncurrencyid === supplierCurrencyId);
const evo_currencychange = calculationStore
.getStaticData('evo_currencychange')
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
const evo_currencychangeValue =
(evo_currencychange && evo_currencychange.evo_currencychange) || 0;
let price = convertPrice(
supplierCurrency?.isocurrencycode,
leaseObjectPrice,
evo_currencychangeValue,
);
if (price && price > 0 && firstPaymentRub >= price) {
calculationStore.setValidation('tbxFirstPaymentRub', false);
openNotification({
type: 'error',