load initial options from crm
This commit is contained in:
parent
60f9f7b59e
commit
cd8f7f7447
@ -24,28 +24,31 @@ const Calculation = () => {
|
||||
CalculationService.getEntities({
|
||||
queries: staticEntitiesList,
|
||||
}),
|
||||
// CalculationService.getEntities({
|
||||
// queries: [
|
||||
// {
|
||||
// entityName: 'accounts',
|
||||
// where: { evo_account_type: 100000002, statecode: 0 },
|
||||
// },
|
||||
// ],
|
||||
// toOptions: true,
|
||||
// }),
|
||||
CalculationService.getEntities({
|
||||
queries: [
|
||||
{
|
||||
alias: 'insuranceCompany',
|
||||
entityName: 'account',
|
||||
where: { evo_account_type: 100000002, statecode: 0 },
|
||||
fields: ['accountid', 'name', 'evo_type_ins_policy'],
|
||||
many: true,
|
||||
},
|
||||
],
|
||||
toOptions: true,
|
||||
}),
|
||||
])
|
||||
.then(
|
||||
([
|
||||
{ entities: initialOptions },
|
||||
{ entities: staticEntities },
|
||||
// { entities: insuranceCompanies },
|
||||
{ entities: insuranceCompanies },
|
||||
]) => {
|
||||
console.log(initialOptions);
|
||||
console.log(insuranceCompanies);
|
||||
calculationStore.applyOptions(initialOptions);
|
||||
calculationStore.applyStaticData(staticEntities);
|
||||
// calculationStore.setTableColumns('tableInsurance')({
|
||||
// options: { insuranceCompany: insuranceCompanies },
|
||||
// });
|
||||
calculationStore.setTableColumns('tableInsurance')({
|
||||
options: { ...insuranceCompanies },
|
||||
});
|
||||
setStatus(LoadingStatus.ready);
|
||||
},
|
||||
)
|
||||
|
||||
@ -1,19 +1,29 @@
|
||||
import { TEntityQuery } from 'core/types/Entities/query';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
const currentDate = DateTime.local().toUTC().toJSDate();
|
||||
|
||||
const initialOptions: TEntityQuery[] = [
|
||||
{
|
||||
alias: 'selectLead',
|
||||
entityName: 'lead',
|
||||
fields: ['leadid', 'fullname'],
|
||||
fields: ['leadid', 'fullname', 'evo_opportunityid'],
|
||||
where: { statecode: 0 },
|
||||
many: true,
|
||||
},
|
||||
{
|
||||
alias: 'selectOpportunity',
|
||||
entityName: 'opportunity',
|
||||
fields: [
|
||||
'opportunityid',
|
||||
'name',
|
||||
'accountid',
|
||||
'evo_leadid',
|
||||
'evo_client_riskid',
|
||||
],
|
||||
where: { statecode: 0 },
|
||||
many: true,
|
||||
},
|
||||
// {
|
||||
// alias: 'selectOpportunity',
|
||||
// entityName: 'opportunities',
|
||||
// fields: ['opportunityid', 'name'],
|
||||
// where: { statecode: 0 },
|
||||
// },
|
||||
{
|
||||
alias: 'selectSupplier',
|
||||
entityName: 'account',
|
||||
@ -25,71 +35,153 @@ const initialOptions: TEntityQuery[] = [
|
||||
fields: ['accountid', 'name'],
|
||||
many: true,
|
||||
},
|
||||
// {
|
||||
// alias: 'selectSupplierCurrency',
|
||||
// entityName: 'transactioncurrency',
|
||||
// where: {
|
||||
// statecode: 0,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// alias: 'selectClientRisk',
|
||||
// entityName: 'evo_client_risk',
|
||||
// where: {
|
||||
// statecode: 0,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// alias: 'selectClientType',
|
||||
// entityName: 'evo_client_type',
|
||||
// where: {
|
||||
// statecode: 0,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// alias: 'selectDealer',
|
||||
// entityName: 'account',
|
||||
// where: {
|
||||
// evo_account_type: 100000001,
|
||||
// statecode: 0,
|
||||
// },
|
||||
// whereIn: {
|
||||
// evo_supplier_type: 100000000,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// alias: 'selectGPSBrand',
|
||||
// entityName: 'evo_gps_brand',
|
||||
// where: {
|
||||
// statecode: 0,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// alias: 'selectRegionRegistration',
|
||||
// entityName: 'evo_region',
|
||||
// where: {
|
||||
// statecode: 0,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// alias: 'selectTownRegistration',
|
||||
// entityName: 'evo_town',
|
||||
// where: {
|
||||
// statecode: 0,
|
||||
// },
|
||||
// },
|
||||
// // TODO: remove on prod
|
||||
// {
|
||||
// alias: 'selectAccount',
|
||||
// entityName: 'account',
|
||||
// },
|
||||
// {
|
||||
// alias: 'selectBrand',
|
||||
// entityName: 'evo_brand',
|
||||
// where: {
|
||||
// statecode: 0,
|
||||
// },
|
||||
// },
|
||||
{
|
||||
alias: 'selectSupplierCurrency',
|
||||
entityName: 'transactioncurrency',
|
||||
where: {
|
||||
statecode: 0,
|
||||
},
|
||||
fields: ['transactioncurrencyid', 'isocurrencycode'],
|
||||
many: true,
|
||||
},
|
||||
{
|
||||
alias: 'selectClientRisk',
|
||||
entityName: 'evo_client_risk',
|
||||
where: {
|
||||
statecode: 0,
|
||||
},
|
||||
fields: ['statecode', 'evo_name', 'evo_client_riskid'],
|
||||
many: true,
|
||||
},
|
||||
{
|
||||
alias: 'selectClientType',
|
||||
entityName: 'evo_client_type',
|
||||
where: {
|
||||
statecode: 0,
|
||||
},
|
||||
fields: ['evo_name', 'evo_client_typeid'],
|
||||
many: true,
|
||||
},
|
||||
{
|
||||
alias: 'selectDealer',
|
||||
entityName: 'account',
|
||||
where: {
|
||||
evo_account_type: 100000001,
|
||||
statecode: 0,
|
||||
evo_legal_form: 100000001,
|
||||
},
|
||||
fields: ['accountid', 'name'],
|
||||
many: true,
|
||||
},
|
||||
{
|
||||
alias: 'selectGPSBrand',
|
||||
entityName: 'evo_gps_brand',
|
||||
where: {
|
||||
statecode: 0,
|
||||
},
|
||||
fields: ['evo_gps_brandid', 'evo_name'],
|
||||
many: true,
|
||||
},
|
||||
{
|
||||
alias: 'selectRegionRegistration',
|
||||
entityName: 'evo_region',
|
||||
where: {
|
||||
statecode: 0,
|
||||
},
|
||||
fields: ['evo_name', 'evo_regionid'],
|
||||
many: true,
|
||||
},
|
||||
|
||||
{
|
||||
alias: 'selectAccount',
|
||||
entityName: 'account',
|
||||
where: {
|
||||
evo_account_type: 100000000,
|
||||
statecode: 0,
|
||||
},
|
||||
fields: ['accountid', 'name', 'evo_client_riskid'],
|
||||
many: true,
|
||||
},
|
||||
{
|
||||
alias: 'selectBrand',
|
||||
entityName: 'evo_brand',
|
||||
where: {
|
||||
statecode: 0,
|
||||
},
|
||||
fields: [
|
||||
'evo_name',
|
||||
'evo_brandid',
|
||||
'evo_importer_reward_perc',
|
||||
'evo_importer_reward_rub',
|
||||
],
|
||||
many: true,
|
||||
},
|
||||
{
|
||||
alias: 'selectProduct',
|
||||
entityName: 'evo_baseproduct',
|
||||
where: {
|
||||
evo_relation: 100000000,
|
||||
statecode: 0,
|
||||
},
|
||||
whereCmp: {
|
||||
evo_datefrom_param: {
|
||||
lte: currentDate,
|
||||
},
|
||||
evo_dateto_param: {
|
||||
gte: currentDate,
|
||||
},
|
||||
},
|
||||
fields: ['evo_name', 'evo_baseproductid', 'evo_id'],
|
||||
relatedEntities: [
|
||||
{
|
||||
entityName: 'evo_leasingobject_type',
|
||||
fields: ['evo_name', 'evo_leasingobject_typeid', 'evo_id'],
|
||||
many: true,
|
||||
},
|
||||
{
|
||||
entityName: 'evo_brand',
|
||||
fields: ['evo_brandid', 'evo_name'],
|
||||
many: true,
|
||||
},
|
||||
],
|
||||
many: true,
|
||||
},
|
||||
{
|
||||
alias: 'selectRegistration',
|
||||
entityName: 'evo_addproduct_type',
|
||||
where: {
|
||||
statecode: 0,
|
||||
evo_product_type: 100000001,
|
||||
},
|
||||
whereCmp: {
|
||||
evo_datefrom_param: {
|
||||
lte: currentDate,
|
||||
},
|
||||
evo_dateto_param: {
|
||||
gte: currentDate,
|
||||
},
|
||||
},
|
||||
fields: ['evo_addproduct_typeid', 'evo_name'],
|
||||
many: true,
|
||||
},
|
||||
{
|
||||
alias: 'selectInsNSIB',
|
||||
entityName: 'evo_addproduct_type',
|
||||
where: {
|
||||
statecode: 0,
|
||||
evo_product_type: 100000002,
|
||||
},
|
||||
whereCmp: {
|
||||
evo_datefrom_param: {
|
||||
lte: currentDate,
|
||||
},
|
||||
evo_dateto_param: {
|
||||
gte: currentDate,
|
||||
},
|
||||
},
|
||||
fields: ['evo_addproduct_typeid', 'evo_name'],
|
||||
many: true,
|
||||
},
|
||||
];
|
||||
|
||||
export default initialOptions;
|
||||
|
||||
@ -10,6 +10,12 @@ const tableInsurance: ITable = {
|
||||
},
|
||||
insuranceCompany: {
|
||||
value: null,
|
||||
filter: options =>
|
||||
options.filter(
|
||||
x =>
|
||||
x.evo_type_ins_policy &&
|
||||
x.evo_type_ins_policy.includes(100000001),
|
||||
),
|
||||
},
|
||||
insured: {
|
||||
value: null,
|
||||
@ -28,6 +34,12 @@ const tableInsurance: ITable = {
|
||||
},
|
||||
insuranceCompany: {
|
||||
value: null,
|
||||
filter: options =>
|
||||
options.filter(
|
||||
x =>
|
||||
x.evo_type_ins_policy &&
|
||||
x.evo_type_ins_policy.includes(100000000),
|
||||
),
|
||||
},
|
||||
insured: {
|
||||
value: null,
|
||||
@ -47,6 +59,12 @@ const tableInsurance: ITable = {
|
||||
insuranceCompany: {
|
||||
value: null,
|
||||
status: Status.Disabled,
|
||||
filter: options =>
|
||||
options.filter(
|
||||
x =>
|
||||
x.evo_type_ins_policy &&
|
||||
x.evo_type_ins_policy.includes(100000000),
|
||||
),
|
||||
},
|
||||
insured: {
|
||||
value: null,
|
||||
@ -67,6 +85,12 @@ const tableInsurance: ITable = {
|
||||
insuranceCompany: {
|
||||
value: null,
|
||||
status: Status.Disabled,
|
||||
filter: options =>
|
||||
options.filter(
|
||||
x =>
|
||||
x.evo_type_ins_policy &&
|
||||
x.evo_type_ins_policy.includes(100000000),
|
||||
),
|
||||
},
|
||||
insured: {
|
||||
value: null,
|
||||
|
||||
@ -43,7 +43,8 @@ const convert = {
|
||||
};
|
||||
|
||||
function convertNestedEntity(query: TBaseEntityQuery) {
|
||||
let entityQuery: string = `${query.entityName}{
|
||||
let entityQuery: string = `${
|
||||
query.many ? plural(query.entityName) : query.entityName}{
|
||||
${convert.fields(query.fields)}
|
||||
${convert.relatedEntities(query.relatedEntities)}
|
||||
}`;
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { CRMEntityNames } from "./crmEntityNames";
|
||||
import { CRMEntityNames } from './crmEntityNames';
|
||||
|
||||
interface AccountData {}
|
||||
|
||||
export interface IAccount {
|
||||
name?: string;
|
||||
@ -12,6 +14,8 @@ export interface IAccount {
|
||||
ownerid?: string;
|
||||
evo_broker_accountid?: string;
|
||||
evo_client_riskid?: string;
|
||||
accountidData?: AccountData;
|
||||
evo_type_ins_policy?: number[];
|
||||
}
|
||||
|
||||
export interface ILead {
|
||||
@ -25,7 +29,7 @@ export interface ILead {
|
||||
|
||||
export interface IOpportunity {
|
||||
opportunityid?: string;
|
||||
evo_accountid?: string;
|
||||
accountid?: string;
|
||||
evo_leadid?: string;
|
||||
evo_client_riskid?: string;
|
||||
ownerid?: string;
|
||||
@ -67,7 +71,8 @@ export interface IEvoBaseproduct {
|
||||
evo_id?: string;
|
||||
evo_relation?: number;
|
||||
evo_datefrom?: Date;
|
||||
evo_dateto?: Date;
|
||||
evo_datefrom_param?: Date;
|
||||
evo_dateto_param?: Date;
|
||||
evo_leaseobject_types?: IEvoLeasingObjectType[];
|
||||
evo_brands?: IEvoBrand[];
|
||||
}
|
||||
|
||||
@ -23,30 +23,26 @@ class CalculationController {
|
||||
next: NextFunction,
|
||||
): Promise<any> => {
|
||||
const { queries, toOptions } = req.body as IGetEntitiesRequest;
|
||||
// console.log('CalculationController -> queries', queries);
|
||||
try {
|
||||
let resEntities = await getEntities(queries);
|
||||
if (toOptions) {
|
||||
let entitiesWithOptions: TEntities<TCRMEntity & IBaseOption> = {};
|
||||
Object.keys(resEntities).forEach(name => {
|
||||
const targetEntities: TCRMEntity[] = resEntities[name];
|
||||
let resEntities = await getEntities(queries);
|
||||
if (toOptions) {
|
||||
let entitiesWithOptions: TEntities<TCRMEntity & IBaseOption> = {};
|
||||
Object.keys(resEntities).forEach(name => {
|
||||
const targetEntities: TCRMEntity[] = resEntities[name];
|
||||
|
||||
let optionatedOptions = [];
|
||||
for (let entity of targetEntities) {
|
||||
optionatedOptions.push(
|
||||
//@ts-ignore
|
||||
//TODO
|
||||
convertEntityToOption(entity, entity.__typename),
|
||||
);
|
||||
}
|
||||
entitiesWithOptions[name] = optionatedOptions;
|
||||
});
|
||||
res.send({ entities: entitiesWithOptions });
|
||||
}
|
||||
res.send({ entities: resEntities });
|
||||
} catch (error) {
|
||||
throw error;
|
||||
let optionatedOptions = [];
|
||||
for (let entity of targetEntities) {
|
||||
optionatedOptions.push(
|
||||
//@ts-ignore
|
||||
//TODO
|
||||
convertEntityToOption(entity, entity.__typename),
|
||||
);
|
||||
}
|
||||
entitiesWithOptions[name] = optionatedOptions;
|
||||
});
|
||||
res.send({ entities: entitiesWithOptions });
|
||||
return;
|
||||
}
|
||||
res.send({ entities: resEntities });
|
||||
};
|
||||
|
||||
static calculate = async (
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user