loadkp reaction
This commit is contained in:
parent
e169fa9bf7
commit
ade824355f
@ -46,6 +46,7 @@
|
||||
"ts-loader": "^8.0.2",
|
||||
"typescript": "3.9.7",
|
||||
"use-debounce": "^3.4.3",
|
||||
"uuid": "^8.3.1",
|
||||
"validator": "^13.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@ -36,7 +36,7 @@ export const useStoreValue = ({ valueName }) => {
|
||||
};
|
||||
|
||||
export const useTableValue = ({ tableName, rowIndex, propName }) => {
|
||||
const { calculationStore } = useStores();
|
||||
const { calculationStore, calculationProcess } = useStores();
|
||||
const [currentValue, setCurrentValue] = useState(undefined);
|
||||
const [debouncedValue] = useDebounce(currentValue, DEFAULT_DEBOUNCE_DELAY);
|
||||
|
||||
@ -66,7 +66,13 @@ export const useTableValue = ({ tableName, rowIndex, propName }) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (cellCallBack) {
|
||||
cellCallBack(calculationStore, tableName, rowIndex, debouncedValue);
|
||||
cellCallBack(
|
||||
calculationStore,
|
||||
calculationProcess,
|
||||
tableName,
|
||||
rowIndex,
|
||||
debouncedValue,
|
||||
);
|
||||
}
|
||||
}, [debouncedValue, cellCallBack]);
|
||||
|
||||
|
||||
@ -5,6 +5,4 @@ import { CRM_PROXY_URL } from 'core/constants/urls';
|
||||
export default new ApolloClient({
|
||||
uri: getServerUrl('/proxy', CRM_PROXY_URL),
|
||||
cache: new InMemoryCache(),
|
||||
|
||||
|
||||
});
|
||||
|
||||
@ -40,6 +40,7 @@ export default class {
|
||||
resEntities[targetName];
|
||||
|
||||
if (toOptions)
|
||||
//@ts-ignore
|
||||
if (toOptions.includes(targetName)) {
|
||||
if (Array.isArray(targetEnt)) {
|
||||
let optionatedEntities: (TCRMEntity & IBaseOption)[] = [];
|
||||
|
||||
@ -18,6 +18,9 @@ const valuesActions = {
|
||||
setValue(sourceValueName, newValue) {
|
||||
this.values[sourceValueName] = newValue;
|
||||
},
|
||||
setValues(values){
|
||||
this.values = values;
|
||||
},
|
||||
|
||||
getStatus(elementName) {
|
||||
return this.statuses[elementName];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,11 @@
|
||||
import requestReactions from './requestReactions';
|
||||
import otherReactions from './otherReactions';
|
||||
import tablesReactions from './tablesReactions';
|
||||
import loadKpReaction from './loadKpReaction';
|
||||
|
||||
export default [
|
||||
...otherReactions,
|
||||
...requestReactions,
|
||||
...tablesReactions,
|
||||
loadKpReaction,
|
||||
];
|
||||
@ -0,0 +1,359 @@
|
||||
//@ts-nocheck
|
||||
|
||||
import { gql } from '@apollo/client';
|
||||
import { elementsValues } from 'client/Containers/Calculation/lib/elements/values';
|
||||
import CrmService from 'client/services/CrmService';
|
||||
import initialValues from 'client/stores/CalculationStore/config/initialValues';
|
||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||
import { ElementStatus } from 'core/types/statuses';
|
||||
import mapKPtoValues from './mapKpToValues';
|
||||
import { currentDate } from 'client/tools/date';
|
||||
import { NIL } from 'uuid';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { calculationProcess } from 'client/stores/CalculationStore';
|
||||
|
||||
const quoteQuery = gql`
|
||||
query($quoteId: Uuid!) {
|
||||
quote(quoteId: $quoteId) {
|
||||
${Object.values(mapKPtoValues).join(' ')}
|
||||
evo_addproduct_types {
|
||||
evo_product_type
|
||||
evo_addproduct_typeid
|
||||
}
|
||||
evo_osago_accountid
|
||||
evo_kasko_accountid
|
||||
evo_osago_payer
|
||||
evo_kasko_payer
|
||||
evo_osago_price
|
||||
evo_kasko_price
|
||||
evo_dgo_price
|
||||
evo_ns_price
|
||||
evo_insurance_period
|
||||
evo_graphs {
|
||||
createdon
|
||||
evo_planpayments {
|
||||
evo_payment_ratio
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const optionsQuery = gql`
|
||||
query(
|
||||
$statecode: Int
|
||||
$evo_brandid: Uuid
|
||||
$evo_modelid: Uuid
|
||||
$salonaccountid: Uuid!
|
||||
$currentDate: DateTime
|
||||
$dealer_person_accountid: Uuid!
|
||||
$dealer_broker_accountid: Uuid!
|
||||
$ind_agent_accountid: Uuid!
|
||||
$double_agent_accountid: Uuid!
|
||||
$broker_accountid: Uuid!
|
||||
$findepartment_accountid: Uuid!
|
||||
$evo_gps_brandid: Uuid!
|
||||
$evo_regionid: Uuid!
|
||||
) {
|
||||
selectModel: evo_models(statecode: $statecode, evo_brandid: $evo_brandid) {
|
||||
evo_name
|
||||
evo_modelid
|
||||
evo_leasingobject_risk
|
||||
evo_importer_reward_perc
|
||||
evo_importer_reward_rub
|
||||
evo_impairment_groupid
|
||||
}
|
||||
selectConfiguration: evo_equipments(
|
||||
statecode: $statecode
|
||||
evo_modelid: $evo_modelid
|
||||
) {
|
||||
evo_equipmentid
|
||||
evo_name
|
||||
evo_impairment_groupid
|
||||
evo_leasingobject_risk
|
||||
evo_start_production_year
|
||||
}
|
||||
selectDealerPerson: salon_providers(
|
||||
statecode: $statecode
|
||||
salonaccountid: $salonaccountid
|
||||
) {
|
||||
accountid
|
||||
name
|
||||
evo_broker_accountid
|
||||
}
|
||||
selectDealerRewardCondition: evo_reward_conditions(
|
||||
evo_agent_accountid: $dealer_person_accountid
|
||||
evo_datefrom_param: { lte: $currentDate }
|
||||
evo_dateto_param: { gte: $currentDate }
|
||||
statecode: $statecode
|
||||
) {
|
||||
evo_reward_conditionid
|
||||
evo_name
|
||||
evo_reward_summ
|
||||
evo_reduce_reward
|
||||
}
|
||||
selectDealerBroker: account(accountid: $dealer_broker_accountid) {
|
||||
accountid
|
||||
name
|
||||
}
|
||||
selectDealerBrokerRewardCondition: evo_reward_conditions(
|
||||
evo_agent_accountid: $dealer_broker_accountid
|
||||
evo_datefrom_param: { lte: $currentDate }
|
||||
evo_dateto_param: { gte: $currentDate }
|
||||
statecode: $statecode
|
||||
) {
|
||||
evo_reward_conditionid
|
||||
evo_name
|
||||
evo_reward_summ
|
||||
evo_reduce_reward
|
||||
}
|
||||
selectIndAgentRewardCondition: evo_reward_conditions(
|
||||
evo_agent_accountid: $ind_agent_accountid
|
||||
evo_datefrom_param: { lte: $currentDate }
|
||||
evo_dateto_param: { gte: $currentDate }
|
||||
statecode: $statecode
|
||||
) {
|
||||
evo_reward_conditionid
|
||||
evo_name
|
||||
evo_double_agent_accountid
|
||||
evo_reward_summ
|
||||
evo_reduce_reward
|
||||
}
|
||||
calcDoubleAgentRewardCondition: evo_reward_conditions(
|
||||
evo_agent_accountid: $double_agent_accountid
|
||||
evo_datefrom_param: { lte: $currentDate }
|
||||
evo_dateto_param: { gte: $currentDate }
|
||||
statecode: $statecode
|
||||
) {
|
||||
evo_reward_conditionid
|
||||
evo_name
|
||||
evo_reward_summ
|
||||
evo_reduce_reward
|
||||
}
|
||||
calcBrokerRewardCondition: evo_reward_conditions(
|
||||
evo_agent_accountid: $broker_accountid
|
||||
evo_datefrom_param: { lte: $currentDate }
|
||||
evo_dateto_param: { gte: $currentDate }
|
||||
statecode: $statecode
|
||||
) {
|
||||
evo_reward_conditionid
|
||||
evo_name
|
||||
evo_reward_summ
|
||||
evo_reduce_reward
|
||||
}
|
||||
selectFinDepartmentRewardCondtion: evo_reward_conditions(
|
||||
evo_agent_accountid: $findepartment_accountid
|
||||
evo_datefrom_param: { lte: $currentDate }
|
||||
evo_dateto_param: { gte: $currentDate }
|
||||
statecode: $statecode
|
||||
) {
|
||||
evo_reward_conditionid
|
||||
evo_name
|
||||
evo_reward_summ
|
||||
evo_reduce_reward
|
||||
}
|
||||
selectGPSModel: evo_gps_models(
|
||||
statecode: $statecode
|
||||
evo_gps_brandid: $evo_gps_brandid
|
||||
) {
|
||||
evo_name
|
||||
evo_gps_modelid
|
||||
}
|
||||
selectTownRegistration: evo_towns(
|
||||
statecode: $statecode
|
||||
evo_regionid: $evo_regionid
|
||||
) {
|
||||
evo_name
|
||||
evo_townid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const map_add_product_types_to_values = {
|
||||
technicalCard: 100000000,
|
||||
registration: 100000001,
|
||||
insNSIB: 100000002,
|
||||
tracker: 100000003,
|
||||
telematics: 100000004,
|
||||
};
|
||||
|
||||
const loadKpReaction: IReactionEffect = calculationStore => ({
|
||||
expression: () => {
|
||||
const { quote } = calculationStore.values;
|
||||
return quote;
|
||||
},
|
||||
effect: quoteId => {
|
||||
const { lead, quote, opportunity } = calculationStore.values;
|
||||
|
||||
if (!quoteId) {
|
||||
calculationStore.setValues({
|
||||
...initialValues,
|
||||
lead,
|
||||
opportunity,
|
||||
quote,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
calculationStore.setStatus('selectQuote', ElementStatus.Disabled);
|
||||
calculationStore.setStatus('btnCalculate', ElementStatus.Disabled);
|
||||
calculationStore.setStatus('btnCreateKP', ElementStatus.Disabled);
|
||||
|
||||
CrmService.crmgqlquery({
|
||||
query: quoteQuery,
|
||||
variables: {
|
||||
quoteId,
|
||||
},
|
||||
})
|
||||
.then(async ({ entities: { quote } }) => {
|
||||
if (!quote) {
|
||||
throw new Error('No quote!');
|
||||
}
|
||||
calculationProcess.setProcess(Process.LoadKp);
|
||||
if (!Array.isArray(quote)) {
|
||||
const newValues = Object.assign(
|
||||
{},
|
||||
...Object.values(elementsValues).map(valueName => ({
|
||||
[valueName]: quote[mapKPtoValues[valueName]],
|
||||
})),
|
||||
);
|
||||
|
||||
const { entities: options } = await CrmService.crmgqlquery({
|
||||
query: optionsQuery,
|
||||
variables: {
|
||||
statecode: 0,
|
||||
evo_brandid: quote.evo_brandid || NIL,
|
||||
evo_modelid: quote.evo_modelid || NIL,
|
||||
salonaccountid: quote.evo_supplier_accountid || NIL,
|
||||
currentDate,
|
||||
dealer_person_accountid: quote.evo_dealer_person_accountid || NIL,
|
||||
dealer_broker_accountid: quote.evo_dealer_broker_accountid || NIL,
|
||||
ind_agent_accountid: quote.evo_agent_accountid || NIL,
|
||||
double_agent_accountid: quote.evo_double_agent_accountid || NIL,
|
||||
broker_accountid: quote.evo_broker_accountid || NIL,
|
||||
findepartment_accountid:
|
||||
quote.evo_fin_department_accountid || NIL,
|
||||
evo_gps_brandid: quote.evo_gps_brandid || NIL,
|
||||
evo_regionid: quote.evo_regionid || NIL,
|
||||
},
|
||||
toOptions: [
|
||||
'selectModel',
|
||||
'selectConfiguration',
|
||||
'selectDealerPerson',
|
||||
'selectDealerRewardCondition',
|
||||
'selectDealerBroker',
|
||||
'selectDealerBrokerRewardCondition',
|
||||
'selectIndAgentRewardCondition',
|
||||
'selectCalcDoubleAgentRewardCondition',
|
||||
'selectCalcBrokerRewardCondition',
|
||||
'selectFinDepartmentRewardCondtion',
|
||||
'selectGPSModel',
|
||||
'selectTownRegistration',
|
||||
],
|
||||
});
|
||||
|
||||
Object.keys(options).forEach(elementName => {
|
||||
if (Array.isArray(options[elementName])) {
|
||||
calculationStore.setOptions(elementName, options[elementName]);
|
||||
} else {
|
||||
calculationStore.setOptions(elementName, [options[elementName]]);
|
||||
}
|
||||
calculationStore.setStatus(elementName, ElementStatus.Default);
|
||||
});
|
||||
|
||||
let base_product_evo_id;
|
||||
const base_product = calculationStore?.options?.selectProduct?.find(
|
||||
x => x.evo_baseproductid === newValues.product,
|
||||
);
|
||||
if (base_product) {
|
||||
base_product_evo_id = base_product.evo_id;
|
||||
}
|
||||
|
||||
let addProducts = Object.assign(
|
||||
{},
|
||||
...Object.keys(map_add_product_types_to_values).map(elementName => {
|
||||
const target_add_product_type = quote?.evo_addproduct_types?.find(
|
||||
x =>
|
||||
x.evo_product_type ===
|
||||
map_add_product_types_to_values[elementName],
|
||||
);
|
||||
|
||||
return {
|
||||
[elementName]:
|
||||
target_add_product_type &&
|
||||
target_add_product_type.evo_addproduct_typeid,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
const tbxLeaseObjectCount = {
|
||||
leaseObjectCount: calculationStore.values.recalcWithRevision
|
||||
? quote.evo_recalc_limit
|
||||
: quote.evo_object_count,
|
||||
};
|
||||
|
||||
calculationStore.setValues({
|
||||
...initialValues,
|
||||
...newValues,
|
||||
product: base_product_evo_id,
|
||||
...addProducts,
|
||||
...tbxLeaseObjectCount,
|
||||
lead,
|
||||
opportunity,
|
||||
quote: quoteId,
|
||||
});
|
||||
}
|
||||
|
||||
calculationStore.setTableRows(
|
||||
'tableInsurance',
|
||||
0,
|
||||
)([
|
||||
{
|
||||
insuranceCompany: {
|
||||
value: quote?.evo_osago_accountid,
|
||||
},
|
||||
insured: { value: quote.evo_osago_payer },
|
||||
insCost: { value: quote.evo_osago_price },
|
||||
},
|
||||
{
|
||||
insuranceCompany: {
|
||||
value: quote.evo_kasko_accountid,
|
||||
},
|
||||
insured: { value: quote.evo_kasko_payer },
|
||||
insCost: { value: quote.evo_kasko_price },
|
||||
insTerm: { value: quote.evo_insurance_period },
|
||||
},
|
||||
{
|
||||
insured: { value: quote.evo_kasko_payer },
|
||||
insCost: { value: quote.evo_dgo_price },
|
||||
insTerm: { value: quote.evo_insurance_period },
|
||||
},
|
||||
{
|
||||
insured: { value: quote.evo_kasko_payer },
|
||||
insCost: { value: quote.evo_ns_price },
|
||||
insTerm: { value: quote.evo_insurance_period },
|
||||
},
|
||||
]);
|
||||
|
||||
const evo_planpayments = quote.evo_graphs.sort(
|
||||
(a, b) => b.createdon - a.createdon,
|
||||
)[0].evo_planpayments;
|
||||
const payments = evo_planpayments
|
||||
.slice(1, evo_planpayments.length - 1)
|
||||
.map(evo_planpayment => ({
|
||||
paymentRelation: {
|
||||
value: evo_planpayment.evo_payment_ratio,
|
||||
},
|
||||
}));
|
||||
calculationStore.setTableRows('tablePayments', 1)(payments);
|
||||
})
|
||||
.finally(() => {
|
||||
calculationStore.setStatus('selectQuote', ElementStatus.Default);
|
||||
calculationStore.setStatus('btnCalculate', ElementStatus.Default);
|
||||
calculationStore.setStatus('btnCreateKP', ElementStatus.Default);
|
||||
calculationProcess.setProcess(Process.Default);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default loadKpReaction;
|
||||
@ -87,21 +87,6 @@ const mapKPtoValues: TValues<string> = {
|
||||
maxPriceChange: 'evo_max_price_change',
|
||||
importerRewardPerc: 'evo_importer_reward_perc',
|
||||
importerRewardRub: 'evo_importer_reward_rub',
|
||||
// insuranceCompanyOSAGO: 'evo_osago_accountid',
|
||||
// insuranceCompanyKASKO: 'evo_kasko_accountid',
|
||||
// insuranceCompanyDGO: 'evo_kasko_accountid',
|
||||
// insuranceCompanyNS: 'evo_kasko_accountid',
|
||||
// insuredOSAGO: 'evo_osago_payer',
|
||||
// insuredKASKO: 'evo_kasko_payer',
|
||||
// insuredDGO: 'evo_kasko_payer',
|
||||
// insuredNS: 'evo_kasko_payer',
|
||||
// inscostOSAGO: 'evo_osago_price',
|
||||
// inscostKASKO: 'evo_kasko_price',
|
||||
// inscostDGO: 'evo_dgo_price',
|
||||
// inscostNS: 'evo_ns_price',
|
||||
// insTermKASKO: 'evo_first_insurance_period',
|
||||
// insTermDGO: 'evo_first_insurance_period',
|
||||
// insTermNS: 'evo_first_insurance_period',
|
||||
requirementTelematic: 'evo_req_telematic',
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,716 @@
|
||||
import { openNotification } from 'client/Elements/Notification';
|
||||
import { shiftRight, shift } from 'core/tools/array';
|
||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { ITableCell, TableProps } from 'core/types/Calculation/Store/tables';
|
||||
import { ElementStatus } from 'core/types/statuses';
|
||||
import { toJS } from 'mobx';
|
||||
|
||||
export default [
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
|
||||
const kaskoValues = calculationStore.getTableRowValues(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
'value',
|
||||
);
|
||||
|
||||
return {
|
||||
...kaskoValues,
|
||||
};
|
||||
},
|
||||
effect: ({ insuranceCompany, insTerm, insured }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
if (insTerm) {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const dgoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'ДГО',
|
||||
);
|
||||
if (dgoRowIndex && dgoRowIndex >= 0)
|
||||
calculationStore.setTableRows(
|
||||
'tableInsurance',
|
||||
dgoRowIndex,
|
||||
)([
|
||||
{
|
||||
insuranceCompany: {
|
||||
value: insuranceCompany,
|
||||
},
|
||||
insTerm: {
|
||||
value: insTerm,
|
||||
},
|
||||
insured: {
|
||||
value: insured,
|
||||
},
|
||||
},
|
||||
{
|
||||
insuranceCompany: {
|
||||
value: insuranceCompany,
|
||||
},
|
||||
insTerm: {
|
||||
value: insTerm,
|
||||
},
|
||||
insured: {
|
||||
value: insured,
|
||||
},
|
||||
},
|
||||
]);
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
const kaskoRow = tableRows[kaskoRowIndex];
|
||||
const { leasingPeriod } = calculationStore.values;
|
||||
|
||||
return {
|
||||
insTerm: kaskoRow.insTerm?.value,
|
||||
leasingPeriod,
|
||||
};
|
||||
},
|
||||
effect: ({ insTerm, leasingPeriod }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
if (insTerm === 100000001 && leasingPeriod > 15 && kaskoRowIndex) {
|
||||
if (kaskoRowIndex >= 0)
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insured: { value: 100000001, status: ElementStatus.Disabled },
|
||||
});
|
||||
} else {
|
||||
if (kaskoRowIndex >= 0)
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
const kaskoRow = tableRows[kaskoRowIndex];
|
||||
const { leasingPeriod } = calculationStore.values;
|
||||
|
||||
return {
|
||||
insTerm: kaskoRow.insTerm?.value,
|
||||
leasingPeriod,
|
||||
};
|
||||
},
|
||||
effect: ({ insTerm, leasingPeriod }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
if (insTerm === 100000001 && leasingPeriod > 15 && kaskoRowIndex) {
|
||||
if (kaskoRowIndex >= 0)
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insured: { value: 100000001, status: ElementStatus.Disabled },
|
||||
});
|
||||
} else {
|
||||
if (kaskoRowIndex >= 0)
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { leasingPeriod } = calculationStore.values;
|
||||
return leasingPeriod;
|
||||
},
|
||||
effect: leasingPeriod => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
const osagoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'ОСАГО',
|
||||
);
|
||||
|
||||
if (leasingPeriod) {
|
||||
if (leasingPeriod < 12) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insured: { value: 100000000, status: ElementStatus.Disabled },
|
||||
});
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
osagoRowIndex,
|
||||
)({
|
||||
insured: { value: 100000000, status: ElementStatus.Disabled },
|
||||
});
|
||||
} else {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insured: { value: 100000000, status: ElementStatus.Default },
|
||||
});
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
osagoRowIndex,
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
});
|
||||
}
|
||||
|
||||
if (leasingPeriod === 12) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insTerm: { value: 100000000, status: ElementStatus.Disabled },
|
||||
});
|
||||
return;
|
||||
} else if (leasingPeriod > 12 && leasingPeriod < 16) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insTerm: { value: 100000001, status: ElementStatus.Disabled },
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
insTerm: { status: ElementStatus.Default },
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
options: {
|
||||
fireImmediately: true,
|
||||
},
|
||||
}),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
const dgoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'ДГО',
|
||||
);
|
||||
const nsRowIndex = tableRows.findIndex(x => x.policyType?.value === 'НС');
|
||||
|
||||
const kaskoValues = calculationStore.getTableRowValues(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
'value',
|
||||
);
|
||||
const dgoValues = calculationStore.getTableRowValues(
|
||||
'tableInsurance',
|
||||
dgoRowIndex,
|
||||
'value',
|
||||
);
|
||||
const nsValues = calculationStore.getTableRowValues(
|
||||
'tableInsurance',
|
||||
nsRowIndex,
|
||||
'value',
|
||||
);
|
||||
|
||||
return {
|
||||
kaskoRow: kaskoValues,
|
||||
dgoRow: dgoValues,
|
||||
nsRow: nsValues,
|
||||
};
|
||||
},
|
||||
effect: ({ kaskoRow, dgoRow, nsRow }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
|
||||
if (
|
||||
kaskoRow &&
|
||||
kaskoRow.insCost === 0 &&
|
||||
((dgoRow && dgoRow.insCost > 0) || (nsRow && nsRow.insCost > 0))
|
||||
) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
1,
|
||||
)({
|
||||
insCost: {
|
||||
validation: false,
|
||||
},
|
||||
});
|
||||
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка во время расчета графика',
|
||||
description: 'Укажите стоимость КАСКО',
|
||||
})();
|
||||
} else {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insCost: {
|
||||
validation: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
const kaskoValues = calculationStore.getTableRowValues(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
'value',
|
||||
);
|
||||
return {
|
||||
kaskoRow: kaskoValues,
|
||||
};
|
||||
},
|
||||
effect: ({ kaskoRow }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
|
||||
if (
|
||||
kaskoRow &&
|
||||
kaskoRow.insured === 100000001 &&
|
||||
kaskoRow.insCost === 0
|
||||
) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insCost: {
|
||||
validation: false,
|
||||
},
|
||||
});
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка во время расчета графика',
|
||||
description: 'Укажите стоимость КАСКО, включаемую в график',
|
||||
})();
|
||||
} else {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insCost: {
|
||||
validation: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const osagoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'ОСАГО',
|
||||
);
|
||||
const osagoValues = calculationStore.getTableRowValues(
|
||||
'tableInsurance',
|
||||
osagoRowIndex,
|
||||
'value',
|
||||
);
|
||||
return {
|
||||
osagoRow: osagoValues,
|
||||
};
|
||||
},
|
||||
effect: ({ osagoRow }) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const osagoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'ОСАГО',
|
||||
);
|
||||
|
||||
if (
|
||||
osagoRow &&
|
||||
osagoRow.insured === 100000001 &&
|
||||
osagoRow.insCost === 0
|
||||
) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
osagoRowIndex,
|
||||
)({
|
||||
insCost: {
|
||||
validation: false,
|
||||
},
|
||||
});
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка во время расчета графика',
|
||||
description: 'Укажите стоимость ОСАГО, включаемую в график',
|
||||
})();
|
||||
} else {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
osagoRowIndex,
|
||||
)({
|
||||
insCost: {
|
||||
validation: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const {
|
||||
leasingPeriod,
|
||||
graphType,
|
||||
parmentsDecreasePercent,
|
||||
seasonType,
|
||||
highSeasonStart: highSeasonStartId,
|
||||
firstPaymentPerc,
|
||||
lastPaymentPerc,
|
||||
} = calculationStore.values;
|
||||
|
||||
const highSeasonStart = calculationStore.options.selectHighSeasonStart?.find(
|
||||
x => x.value === highSeasonStartId,
|
||||
);
|
||||
|
||||
return {
|
||||
leasingPeriod,
|
||||
graphType,
|
||||
parmentsDecreasePercent,
|
||||
seasonType,
|
||||
highSeasonStart: parseInt(highSeasonStart?.name || '2'),
|
||||
firstPaymentPerc,
|
||||
lastPaymentPerc,
|
||||
};
|
||||
},
|
||||
effect: async (nextParams, prevParams) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
const {
|
||||
leasingPeriod,
|
||||
graphType,
|
||||
parmentsDecreasePercent,
|
||||
seasonType,
|
||||
highSeasonStart,
|
||||
firstPaymentPerc,
|
||||
lastPaymentPerc,
|
||||
} = nextParams;
|
||||
|
||||
const prevValues = toJS(calculationStore.tables.tablePayments.rows).map(
|
||||
x => x.paymentRelation?.value,
|
||||
);
|
||||
let payments: TableProps<ITableCell>[] = [
|
||||
{
|
||||
paymentRelation: {
|
||||
value: firstPaymentPerc,
|
||||
status: ElementStatus.Disabled,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
calculationStore.cleanTable('tablePayments');
|
||||
|
||||
switch (graphType) {
|
||||
case 100000000: {
|
||||
const middleRows = Array.from({ length: leasingPeriod - 2 }, () => ({
|
||||
paymentRelation: {
|
||||
value: 100,
|
||||
status: ElementStatus.Disabled,
|
||||
},
|
||||
}));
|
||||
payments = [...payments, ...middleRows];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 100000001: {
|
||||
const middleRows = Array.from({ length: leasingPeriod - 3 }, () => ({
|
||||
paymentRelation: {
|
||||
value: 100,
|
||||
status: ElementStatus.Default,
|
||||
},
|
||||
}));
|
||||
payments = [
|
||||
...payments,
|
||||
{
|
||||
paymentRelation: {
|
||||
value: 100,
|
||||
status: ElementStatus.Disabled,
|
||||
},
|
||||
},
|
||||
...middleRows,
|
||||
];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 100000002: {
|
||||
const middleRows = Array.from(
|
||||
{ length: leasingPeriod - 3 },
|
||||
(v, i) => ({
|
||||
paymentRelation: {
|
||||
value: 100,
|
||||
status: ElementStatus.Disabled,
|
||||
},
|
||||
}),
|
||||
);
|
||||
for (let i in middleRows) {
|
||||
const currRow = middleRows[parseInt(i)];
|
||||
const prevRow = middleRows[parseInt(i) - 1];
|
||||
currRow.paymentRelation.value = parseFloat(
|
||||
(
|
||||
((prevRow ? prevRow.paymentRelation.value : 100) *
|
||||
parmentsDecreasePercent) /
|
||||
100
|
||||
).toFixed(2),
|
||||
);
|
||||
}
|
||||
payments = [
|
||||
...payments,
|
||||
{
|
||||
paymentRelation: {
|
||||
value: 100,
|
||||
status: ElementStatus.Disabled,
|
||||
},
|
||||
},
|
||||
...middleRows,
|
||||
];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 100000003: {
|
||||
let HIGH = 100,
|
||||
MIDDLE = 75,
|
||||
LOW = 50;
|
||||
|
||||
if (
|
||||
prevParams.graphType === nextParams.graphType
|
||||
// && nextParams.graphType === 100000003
|
||||
) {
|
||||
/**
|
||||
* FIND PREV HIGH, MIDDLE, LOW
|
||||
*/
|
||||
const {
|
||||
leasingPeriod: prevLeasingPeriod,
|
||||
seasonType: prevSeasonType,
|
||||
highSeasonStart: prevHighSeasonStart,
|
||||
} = prevParams;
|
||||
|
||||
const prevPeriodsNumber =
|
||||
prevLeasingPeriod <= 14 ? prevLeasingPeriod - 2 : 12;
|
||||
const prevShiftNumber = prevHighSeasonStart - 2;
|
||||
|
||||
let middleRows = prevValues.slice(1, prevPeriodsNumber + 1);
|
||||
if (middleRows.length < 12) {
|
||||
middleRows = [
|
||||
...middleRows,
|
||||
...Array.from({ length: 12 - middleRows.length }, v => 0),
|
||||
];
|
||||
}
|
||||
if (prevShiftNumber > 0)
|
||||
middleRows = shiftRight(middleRows, prevShiftNumber);
|
||||
|
||||
switch (prevSeasonType) {
|
||||
// 6/6
|
||||
case 100000000: {
|
||||
HIGH = middleRows[0];
|
||||
LOW = middleRows[6];
|
||||
break;
|
||||
}
|
||||
// 8/4
|
||||
case 100000001: {
|
||||
HIGH = middleRows[0];
|
||||
LOW = middleRows[8];
|
||||
|
||||
break;
|
||||
}
|
||||
// 4/4/4
|
||||
case 100000002: {
|
||||
HIGH = middleRows[0];
|
||||
MIDDLE = middleRows[4];
|
||||
LOW = middleRows[8];
|
||||
break;
|
||||
}
|
||||
}
|
||||
/** */
|
||||
}
|
||||
|
||||
/**
|
||||
* GENERATE PERIODS
|
||||
*/
|
||||
|
||||
const {
|
||||
leasingPeriod: nextLeasingPeriod,
|
||||
seasonType: nextSeasonType,
|
||||
highSeasonStart: nextHighSeasonStart,
|
||||
} = nextParams;
|
||||
|
||||
const nextPeriodsNumber =
|
||||
nextLeasingPeriod <= 14 ? nextLeasingPeriod - 2 : 12;
|
||||
const nextShiftNumber = nextHighSeasonStart - 2;
|
||||
|
||||
let nextPeriods: number[] = [];
|
||||
|
||||
switch (nextSeasonType) {
|
||||
// 6/6
|
||||
case 100000000: {
|
||||
nextPeriods = Array.from({ length: 12 }, (v, i) =>
|
||||
i < 6 ? HIGH : LOW,
|
||||
);
|
||||
break;
|
||||
}
|
||||
// 8/4
|
||||
case 100000001: {
|
||||
nextPeriods = Array.from({ length: 12 }, (v, i) =>
|
||||
i < 8 ? HIGH : LOW,
|
||||
);
|
||||
break;
|
||||
}
|
||||
// 4/4/4
|
||||
case 100000002: {
|
||||
nextPeriods = Array.from(
|
||||
{ length: 12 },
|
||||
(v, i) => (i < 4 && HIGH) || (i < 8 && MIDDLE) || LOW,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nextShiftNumber > 0) {
|
||||
nextPeriods = shift(nextPeriods, nextShiftNumber);
|
||||
}
|
||||
nextPeriods.length = nextPeriodsNumber;
|
||||
|
||||
const middleRows = Array.from(
|
||||
{ length: nextLeasingPeriod - 2 },
|
||||
(v, i) => {
|
||||
return {
|
||||
paymentRelation: {
|
||||
value:
|
||||
nextPeriods[
|
||||
i - nextPeriodsNumber * Math.floor(i / nextPeriodsNumber)
|
||||
],
|
||||
status:
|
||||
i < nextPeriodsNumber
|
||||
? ElementStatus.Default
|
||||
: ElementStatus.Disabled,
|
||||
},
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
payments = [...payments, ...middleRows];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 100000004: {
|
||||
const middleRows = Array.from({ length: leasingPeriod - 5 }, () => ({
|
||||
paymentRelation: {
|
||||
value: 100,
|
||||
status: ElementStatus.Disabled,
|
||||
},
|
||||
}));
|
||||
|
||||
payments = [
|
||||
...payments,
|
||||
{
|
||||
paymentRelation: {
|
||||
value: 25,
|
||||
status: ElementStatus.Default,
|
||||
},
|
||||
},
|
||||
{
|
||||
paymentRelation: {
|
||||
value: 50,
|
||||
status: ElementStatus.Default,
|
||||
},
|
||||
},
|
||||
{
|
||||
paymentRelation: {
|
||||
value: 75,
|
||||
status: ElementStatus.Default,
|
||||
},
|
||||
},
|
||||
...middleRows,
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
payments = [
|
||||
...payments,
|
||||
{
|
||||
paymentRelation: {
|
||||
value: lastPaymentPerc,
|
||||
status: ElementStatus.Disabled,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
calculationStore.setTableRows('tablePayments', 0)(payments);
|
||||
},
|
||||
options: {
|
||||
fireImmediately: true,
|
||||
},
|
||||
}),
|
||||
] as IReactionEffect[];
|
||||
@ -1,4 +1,5 @@
|
||||
import { openNotification } from 'client/Elements/Notification';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { ITable } from 'core/types/Calculation/Store/tables';
|
||||
import { ElementStatus } from 'core/types/statuses';
|
||||
|
||||
@ -128,7 +129,10 @@ const tableInsurance: ITable = {
|
||||
],
|
||||
},
|
||||
callbacks: {
|
||||
insCost: (calculationStore, tableName, rowIndex) => {
|
||||
insCost: (calculationStore, calculationProcess, tableName, rowIndex) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value &&
|
||||
calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value >
|
||||
@ -221,7 +225,10 @@ const tableInsurance: ITable = {
|
||||
}
|
||||
},
|
||||
|
||||
insured: (calculationStore, tableName, rowIndex) => {
|
||||
insured: (calculationStore, calculationProcess, tableName, rowIndex) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value &&
|
||||
calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value >
|
||||
@ -253,7 +260,10 @@ const tableInsurance: ITable = {
|
||||
}
|
||||
},
|
||||
|
||||
insTerm: (calculationStore, tableName, rowIndex) => {
|
||||
insTerm: (calculationStore, calculationProcess, tableName, rowIndex) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value &&
|
||||
calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value >
|
||||
@ -284,7 +294,15 @@ const tableInsurance: ITable = {
|
||||
});
|
||||
}
|
||||
},
|
||||
insuranceCompany: (calculationStore, tableName, rowIndex) => {
|
||||
insuranceCompany: (
|
||||
calculationStore,
|
||||
calculationProcess,
|
||||
tableName,
|
||||
rowIndex,
|
||||
) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value &&
|
||||
calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value >
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { ITable } from 'core/types/Calculation/Store/tables';
|
||||
import { toJS } from 'mobx';
|
||||
|
||||
@ -8,7 +9,16 @@ const tablePayments: ITable = {
|
||||
// },
|
||||
],
|
||||
callbacks: {
|
||||
paymentRelation: (calculationStore, tableName, rowIndex, value) => {
|
||||
paymentRelation: (
|
||||
calculationStore,
|
||||
calculationProcess,
|
||||
tableName,
|
||||
rowIndex,
|
||||
value,
|
||||
) => {
|
||||
if (calculationProcess.process === Process.LoadKp) {
|
||||
return;
|
||||
}
|
||||
const { graphType } = calculationStore.values;
|
||||
if (graphType === 100000001) {
|
||||
if (
|
||||
|
||||
@ -3,8 +3,8 @@ import {
|
||||
modalData,
|
||||
} from 'client/stores/CalculationStore/Data/modal';
|
||||
import actionsEffects from 'client/stores/CalculationStore/Effects/action';
|
||||
// import assignProperties from 'client/tools/assignProps';
|
||||
import { ICalculationStore } from 'core/types/Calculation/Store';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { isEqual } from 'lodash';
|
||||
import { autorun, makeAutoObservable, reaction, when } from 'mobx';
|
||||
import {
|
||||
@ -16,14 +16,19 @@ import {
|
||||
import { staticData, staticDataAction } from './Data/staticEntities';
|
||||
import autorunEffects from './Effects/autorun';
|
||||
import computedEffects from './Effects/computed';
|
||||
import reactionEffects from './Effects/reaction';
|
||||
import reactions from './Effects/reactions';
|
||||
import whenEffects from './Effects/when';
|
||||
|
||||
export const calculationProcess = makeAutoObservable({
|
||||
process: Process.Default,
|
||||
setProcess(process) {
|
||||
this.process = process;
|
||||
},
|
||||
});
|
||||
|
||||
const CalculationStore: ICalculationStore = makeAutoObservable(
|
||||
Object.assign(
|
||||
{},
|
||||
// assignProperties(
|
||||
// {},
|
||||
staticData,
|
||||
staticDataAction,
|
||||
valuesData,
|
||||
@ -39,8 +44,11 @@ const CalculationStore: ICalculationStore = makeAutoObservable(
|
||||
|
||||
autorunEffects.map(autorunEffect => autorun(autorunEffect(CalculationStore)));
|
||||
|
||||
reactionEffects.map(reactionEffectBuilder => {
|
||||
const reactionEffect = reactionEffectBuilder(CalculationStore);
|
||||
reactions.map(reactionEffectBuilder => {
|
||||
const reactionEffect = reactionEffectBuilder(
|
||||
CalculationStore,
|
||||
calculationProcess,
|
||||
);
|
||||
return reaction(reactionEffect.expression, reactionEffect.effect, {
|
||||
...reactionEffect.options,
|
||||
equals: (nextParams, prevParams) => {
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import CalculationStore from './CalculationStore';
|
||||
import CalculationStore, { calculationProcess } from './CalculationStore';
|
||||
|
||||
class RootStore {
|
||||
constructor() {
|
||||
this.calculationStore = CalculationStore;
|
||||
this.calculationProcess = calculationProcess;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,16 +1,19 @@
|
||||
import { TCRMEntity } from 'core/types/Entities/crmEntities';
|
||||
import { ColumnsNames, IColumn, PostValues } from 'core/types/Calculation/Core';
|
||||
import {
|
||||
PreparedPayments,
|
||||
PreparedValues,
|
||||
PreparedValues
|
||||
} from 'core/types/Calculation/Prepare';
|
||||
import {
|
||||
ElementsNames
|
||||
} from 'core/types/Calculation/Store/elements';
|
||||
import { TableProps } from 'core/types/Calculation/Store/tables';
|
||||
import { TValues } from 'core/types/Calculation/Store/values';
|
||||
import { TCRMEntity } from 'core/types/Entities/crmEntities';
|
||||
import { CRMEntityNames } from 'core/types/Entities/crmEntityNames';
|
||||
|
||||
export interface IQueryToCRMGQL {
|
||||
query: any;
|
||||
toOptions?: CRMEntityNames[];
|
||||
toOptions?: CRMEntityNames[] | ElementsNames[];
|
||||
variables: {
|
||||
[prop in keyof TCRMEntity]: any;
|
||||
} & { [prop: string]: any };
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { calculationProcess } from 'client/stores/CalculationStore';
|
||||
import { IReactionOptions, IReactionPublic, Lambda } from 'mobx';
|
||||
import { ICalculationStore } from './';
|
||||
|
||||
@ -7,12 +8,17 @@ export type TAction = {
|
||||
[actionName in ActionsNames]?: () => void;
|
||||
};
|
||||
|
||||
export type TCalculationProcess = typeof calculationProcess;
|
||||
|
||||
export interface IAutorunEffect {
|
||||
(CalculationStore: ICalculationStore): () => void;
|
||||
}
|
||||
|
||||
export interface IReactionEffect {
|
||||
(CalculationStore: ICalculationStore): {
|
||||
(
|
||||
CalculationStore: ICalculationStore,
|
||||
calculationProcess: TCalculationProcess,
|
||||
): {
|
||||
expression: (r: IReactionPublic) => any;
|
||||
effect: (arg: any, prev: any, r: IReactionPublic) => void;
|
||||
options?: IReactionOptions;
|
||||
|
||||
@ -42,6 +42,7 @@ interface ICalculationValues {
|
||||
sourceValueName: ValuesNames | ResultValuesNames,
|
||||
newValue: TValue,
|
||||
) => void;
|
||||
setValues: (values: TValues<any>) => void;
|
||||
|
||||
statuses: TElements<ElementStatus>;
|
||||
getStatus: (elementName: ElementsNames) => ElementStatus;
|
||||
|
||||
4
src/core/types/Calculation/Store/process.ts
Normal file
4
src/core/types/Calculation/Store/process.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export enum Process {
|
||||
Default,
|
||||
LoadKp,
|
||||
}
|
||||
@ -3,6 +3,7 @@ import { ElementStatus } from '../../statuses';
|
||||
import { ICalculationStore } from './';
|
||||
import { TElementFilter } from './filters';
|
||||
import { IBaseOption } from './options';
|
||||
import { TCalculationProcess } from './effect';
|
||||
|
||||
export type TableNames = 'tableInsurance' | 'tablePayments' | 'tableResults';
|
||||
export type TableValuesNames =
|
||||
@ -19,6 +20,7 @@ export type TableValuesNames =
|
||||
|
||||
export type TCellCallback = (
|
||||
calculationStore: ICalculationStore,
|
||||
calculationProcess: TCalculationProcess,
|
||||
tableName: TableNames,
|
||||
rowIndex: number,
|
||||
value: any,
|
||||
|
||||
@ -40,6 +40,7 @@ export interface IOpportunity {
|
||||
statecode?: number;
|
||||
accountidData?: IAccount;
|
||||
parentaccountid?: string;
|
||||
evo_addproduct_types?: IEvoAddproductType[];
|
||||
}
|
||||
|
||||
export interface IQuote {
|
||||
@ -54,6 +55,21 @@ export interface IQuote {
|
||||
evo_statuscode?: IEvoStatusCode;
|
||||
evo_quotename?: string;
|
||||
offerprintform?: string;
|
||||
evo_object_count?: number;
|
||||
evo_osago_accountid?: string;
|
||||
evo_kasko_accountid?: string;
|
||||
evo_osago_payer?: number;
|
||||
evo_kasko_payer?: number;
|
||||
evo_osago_price?: number;
|
||||
evo_dgo_price?: number;
|
||||
evo_ns_price?: number;
|
||||
evo_insurance_period?: number;
|
||||
evo_graphs?: IEvoGraph[];
|
||||
}
|
||||
|
||||
interface IEvoGraph {
|
||||
createdon?: Date;
|
||||
evo_planpayment?: IEvoPlanPayment[];
|
||||
}
|
||||
|
||||
export interface ITransactionCurrency {
|
||||
@ -126,6 +142,9 @@ export interface IEvoEquipment {
|
||||
evo_leasingobject_risk?: number;
|
||||
evo_start_production_year?: number;
|
||||
statecode?: number;
|
||||
evo_supplier_accountid?: string;
|
||||
evo_dealer_person_accountid?: string;
|
||||
evo_dealer_broker_accountid?: string;
|
||||
}
|
||||
|
||||
export interface IEvoRewardCondition {
|
||||
@ -307,6 +326,7 @@ export interface IEvoPlanPayment {
|
||||
evo_cost_price_telematics_withoutnds?: number;
|
||||
evo_cost_equipment_withoutnds?: number;
|
||||
evo_addproduct_typeid?: string;
|
||||
evo_payment_ratio?: number;
|
||||
}
|
||||
|
||||
export interface ISystemUser {
|
||||
|
||||
Reference in New Issue
Block a user