loadKP: статусы графика с гибкой дегрессией

This commit is contained in:
Chika 2022-04-21 11:49:45 +03:00
parent 8af5e5460e
commit f725d48fb9
2 changed files with 14 additions and 9 deletions

View File

@ -3,7 +3,7 @@ import { resetIns } from 'client/Containers/Calculation/Components/ELT/lib/reset
import { numberElementsProps } from 'client/Containers/Calculation/Elements/props/common';
import {
getTitle,
getValueName,
getValueName
} from 'client/Containers/Calculation/Elements/tools';
import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { openNotification } from 'client/Elements/Notification';
@ -13,7 +13,7 @@ import {
mainOptionsForQuoteQuery,
quoteQuery,
secondaryOptionsForQuoteQuery,
singleOptionsForQuoteQuery,
singleOptionsForQuoteQuery
} from 'core/services/CrmService/graphql/query/quote';
import { TOptionizedEntity } from 'core/services/CrmService/types/common';
import {
@ -21,7 +21,7 @@ import {
IAccount,
IEvoGraph,
IEvoTown,
IQuote,
IQuote
} from 'core/services/CrmService/types/entities';
import { currentISODate } from 'core/tools/date';
import { NIL } from 'core/tools/uuid';
@ -40,10 +40,12 @@ const map_add_product_types_to_values = {
fuelCard: 100000005,
};
const tablePaymentsStatuses = (graphType, leasingPeriod) => {
const tablePaymentsStatuses = (graphType, seasonType, leasingPeriod) => {
switch (graphType) {
case 100000001: {
return Array.from({ length: leasingPeriod - 3 }, (_, i) => i + 2);
if (seasonType === 100_000_007)
return Array.from({ length: leasingPeriod - 3 }, (_, i) => i + 2);
break;
}
case 100000003: {
return Array.from({ length: 12 }, (_, i) => i + 1);
@ -248,16 +250,18 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
(a, b) => b.createdon - a.createdon,
)[0];
if (evo_graph.evo_planpayments) {
const statuses = tablePaymentsStatuses(
quote.evo_graph_type,
quote.evo_seasons_type,
quote.evo_period,
);
const payments = evo_graph.evo_planpayments
.slice(1, evo_graph.evo_planpayments.length - 1)
.map((evo_planpayment, i) => ({
paymentRelation: {
validation: undefined,
value: evo_planpayment.evo_payment_ratio,
status: tablePaymentsStatuses(
quote.evo_graph_type,
quote.evo_period,
)?.includes(i + 1)
status: statuses?.includes(i + 1)
? ElementStatus.Default
: ElementStatus.Disabled,
},

View File

@ -102,6 +102,7 @@ export interface IOpportunity extends BaseEntity {
}
export interface IQuote extends BaseEntity {
evo_seasons_type?: number;
evo_engine_hours?: number;
evo_client_riskid?: string;
evo_addproduct_types?: IEvoAddproductType[];