fix: import resource imporements

This commit is contained in:
Ahmed Bouhuolia
2024-03-27 04:01:01 +02:00
parent 973d1832bd
commit ad4e51d81d
59 changed files with 1508 additions and 211 deletions

View File

@@ -15,6 +15,7 @@ export default {
unique: true,
required: true,
importable: true,
exportable: true,
order: 1,
},
description: {
@@ -22,6 +23,7 @@ export default {
column: 'description',
fieldType: 'text',
importable: true,
exportable: true,
},
slug: {
name: 'account.field.slug',
@@ -35,6 +37,7 @@ export default {
name: 'account.field.code',
column: 'code',
fieldType: 'text',
exportable: true,
importable: true,
minLength: 3,
maxLength: 6,
@@ -75,6 +78,7 @@ export default {
})),
required: true,
importable: true,
exportable: true,
order: 2,
},
active: {
@@ -82,6 +86,7 @@ export default {
column: 'active',
fieldType: 'boolean',
filterable: false,
exportable: true,
importable: true,
},
balance: {
@@ -96,6 +101,7 @@ export default {
fieldType: 'text',
filterable: false,
importable: true,
exportable: true,
},
parentAccount: {
name: 'account.field.parent_account',
@@ -109,6 +115,7 @@ export default {
column: 'created_at',
fieldType: 'date',
importable: false,
exportable: true,
},
},
};

View File

@@ -1,70 +1,89 @@
export default {
importable: true,
defaultFilterField: 'displayName',
defaultSort: {
sortOrder: 'DESC',
sortField: 'createdAt',
},
fields: {
first_name: {
firstName: {
name: 'customer.field.first_name',
column: 'first_name',
fieldType: 'text',
importable: true,
},
last_name: {
lastName: {
name: 'customer.field.last_name',
column: 'last_name',
fieldType: 'text',
importable: true,
},
display_name: {
displayName: {
name: 'customer.field.display_name',
column: 'display_name',
fieldType: 'text',
required: true,
importable: true,
},
email: {
name: 'customer.field.email',
column: 'email',
fieldType: 'text',
importable: true,
},
work_phone: {
workPhone: {
name: 'customer.field.work_phone',
column: 'work_phone',
fieldType: 'text',
importable: true,
},
personal_phone: {
personalPhone: {
name: 'customer.field.personal_phone',
column: 'personal_phone',
fieldType: 'text',
importable: true,
},
company_name: {
companyName: {
name: 'customer.field.company_name',
column: 'company_name',
fieldType: 'text',
importable: true,
},
website: {
name: 'customer.field.website',
column: 'website',
fieldType: 'text',
},
created_at: {
name: 'customer.field.created_at',
column: 'created_at',
fieldType: 'date',
importable: true,
},
balance: {
name: 'customer.field.balance',
column: 'balance',
fieldType: 'number',
},
opening_balance: {
openingBalance: {
name: 'customer.field.opening_balance',
column: 'opening_balance',
fieldType: 'number',
importable: true,
},
opening_balance_at: {
openingBalanceAt: {
name: 'customer.field.opening_balance_at',
column: 'opening_balance_at',
filterable: false,
fieldType: 'date',
importable: true,
},
currency_code: {
openingBalanceExchangeRate: {
name: 'Opening Balance Ex. Rate',
column: 'opening_balance_exchange_rate',
fieldType: 'number',
importable: true,
},
currencyCode: {
name: 'customer.field.currency',
column: 'currency_code',
fieldType: 'text',
importable: true,
},
status: {
name: 'customer.field.status',
@@ -76,6 +95,99 @@ export default {
{ key: 'unpaid', label: 'customer.field.status.unpaid' },
],
filterCustomQuery: statusFieldFilterQuery,
importable: true,
},
// Billing Address
billingAddress1: {
name: 'Billing Address 1',
column: 'billing_address1',
fieldType: 'text',
importable: true,
},
billingAddress2: {
name: 'Billing Address 2',
column: 'billing_address2',
fieldType: 'text',
importable: true,
},
billingAddressCity: {
name: 'Billing Address City',
column: 'billing_address_city',
fieldType: 'text',
importable: true,
},
billingAddressCountry: {
name: 'Billing Address Country',
column: 'billing_address_country',
fieldType: 'text',
importable: true,
},
billingAddressPostcode: {
name: 'Billing Address Postcode',
column: 'billing_address_postcode',
fieldType: 'text',
importable: true,
},
billingAddressState: {
name: 'Billing Address State',
column: 'billing_address_state',
fieldType: 'text',
importable: true,
},
billingAddressPhone: {
name: 'Billing Address Phone',
column: 'billing_address_phone',
fieldType: 'text',
importable: true,
},
// Shipping Address
shippingAddress1: {
name: 'Shipping Address 1',
column: 'shipping_address1',
fieldType: 'text',
importable: true,
},
shippingAddress2: {
name: 'Shipping Address 2',
column: 'shipping_address2',
fieldType: 'text',
importable: true,
},
shippingAddressCity: {
name: 'Shipping Address City',
column: 'shipping_address_city',
fieldType: 'text',
importable: true,
},
shippingAddressCountry: {
name: 'Shipping Address Country',
column: 'shipping_address_country',
fieldType: 'text',
importable: true,
},
shippingAddressPostcode: {
name: 'Shipping Address Postcode',
column: 'shipping_address_postcode',
fieldType: 'text',
importable: true,
},
shippingAddressPhone: {
name: 'Shipping Address Phone',
column: 'shipping_address_phone',
fieldType: 'text',
importable: true,
},
shippingAddressState: {
name: 'Shipping Address State',
column: 'shipping_address_state',
fieldType: 'text',
importable: true,
},
//
createdAt: {
name: 'customer.field.created_at',
column: 'created_at',
fieldType: 'date',
},
},
};

View File

@@ -1,8 +1,10 @@
import TenantModel from 'models/TenantModel';
export default class Import extends TenantModel {
resource!: string;
mapping!: string;
columns!: string;
params!: Record<string, any>;
/**
* Table name.
@@ -49,6 +51,14 @@ export default class Import extends TenantModel {
}
public get paramsParsed() {
try {
return JSON.parse(this.params);
} catch {
return [];
}
}
public get mappingParsed() {
try {
return JSON.parse(this.mapping);

View File

@@ -0,0 +1,54 @@
export default {
defaultFilterField: 'createdAt',
defaultSort: {
sortOrder: 'DESC',
sortField: 'createdAt',
},
importable: true,
fields: {
date: {
name: 'Date',
column: 'date',
fieldType: 'date',
importable: true,
required: true,
},
payee: {
name: 'Payee',
column: 'payee',
fieldType: 'text',
importable: true,
},
description: {
name: 'Description',
column: 'description',
fieldType: 'text',
importable: true,
},
referenceNo: {
name: 'Reference No.',
column: 'reference_no',
fieldType: 'text',
importable: true,
},
amount: {
name: 'Amount',
column: 'Amount',
fieldType: 'numeric',
required: true,
importable: true,
},
account: {
name: 'Account',
column: 'account_id',
fieldType: 'relation',
to: { model: 'Account', to: 'id' },
},
createdAt: {
name: 'Created At',
column: 'createdAt',
fieldType: 'date',
importable: false,
},
},
};

View File

@@ -1,9 +1,15 @@
/* eslint-disable global-require */
import * as R from 'ramda';
import { Model, ModelOptions, QueryContext, mixin } from 'objection';
import TenantModel from 'models/TenantModel';
import { Model, ModelOptions, QueryContext } from 'objection';
import ModelSettings from './ModelSetting';
import Account from './Account';
import UncategorizedCashflowTransactionMeta from './UncategorizedCashflowTransaction.meta';
export default class UncategorizedCashflowTransaction extends TenantModel {
export default class UncategorizedCashflowTransaction extends mixin(
TenantModel,
[ModelSettings]
) {
id!: number;
amount!: number;
categorized!: boolean;
@@ -35,6 +41,10 @@ export default class UncategorizedCashflowTransaction extends TenantModel {
];
}
static get meta() {
return UncategorizedCashflowTransactionMeta;
}
/**
* Retrieves the withdrawal amount.
* @returns {number}

View File

@@ -1,74 +1,88 @@
export default {
defaultFilterField: 'display_name',
defaultFilterField: 'displayName',
defaultSort: {
sortOrder: 'DESC',
sortField: 'created_at',
sortField: 'createdAt',
},
importable: true,
fields: {
first_name: {
firstName: {
name: 'vendor.field.first_name',
column: 'first_name',
fieldType: 'text',
importable: true,
},
last_name: {
lastName: {
name: 'vendor.field.last_name',
column: 'last_name',
fieldType: 'text',
importable: true,
},
display_name: {
displayName: {
name: 'vendor.field.display_name',
column: 'display_name',
fieldType: 'text',
required: true,
importable: true,
},
email: {
name: 'vendor.field.email',
column: 'email',
fieldType: 'text',
importable: true,
},
work_phone: {
workPhone: {
name: 'vendor.field.work_phone',
column: 'work_phone',
fieldType: 'text',
importable: true,
},
personal_phone: {
personalPhone: {
name: 'vendor.field.personal_pone',
column: 'personal_phone',
fieldType: 'text',
importable: true,
},
company_name: {
companyName: {
name: 'vendor.field.company_name',
column: 'company_name',
fieldType: 'text',
importable: true,
},
website: {
name: 'vendor.field.website',
column: 'website',
fieldType: 'text',
},
created_at: {
name: 'vendor.field.created_at',
column: 'created_at',
fieldType: 'date',
importable: true,
},
balance: {
name: 'vendor.field.balance',
column: 'balance',
fieldType: 'number',
},
opening_balance: {
openingBalance: {
name: 'vendor.field.opening_balance',
column: 'opening_balance',
fieldType: 'number',
importable: true,
},
opening_balance_at: {
openingBalanceAt: {
name: 'vendor.field.opening_balance_at',
column: 'opening_balance_at',
fieldType: 'date',
importable: true,
},
currency_code: {
openingBalanceExchangeRate: {
name: 'Opening Balance Ex. Rate',
column: 'opening_balance_exchange_rate',
fieldType: 'number',
importable: true,
},
currencyCode: {
name: 'vendor.field.currency',
column: 'currency_code',
fieldType: 'text',
importable: true,
},
status: {
name: 'vendor.field.status',
@@ -87,6 +101,98 @@ export default {
break;
}
},
importable: true,
},
// Billing Address
billingAddress1: {
name: 'Billing Address 1',
column: 'billing_address1',
fieldType: 'text',
importable: true,
},
billingAddress2: {
name: 'Billing Address 2',
column: 'billing_address2',
fieldType: 'text',
importable: true,
},
billingAddressCity: {
name: 'Billing Address City',
column: 'billing_address_city',
fieldType: 'text',
importable: true,
},
billingAddressCountry: {
name: 'Billing Address Country',
column: 'billing_address_country',
fieldType: 'text',
importable: true,
},
billingAddressPostcode: {
name: 'Billing Address Postcode',
column: 'billing_address_postcode',
fieldType: 'text',
importable: true,
},
billingAddressState: {
name: 'Billing Address State',
column: 'billing_address_state',
fieldType: 'text',
importable: true,
},
billingAddressPhone: {
name: 'Billing Address Phone',
column: 'billing_address_phone',
fieldType: 'text',
importable: true,
},
// Shipping Address
shippingAddress1: {
name: 'Shipping Address 1',
column: 'shipping_address1',
fieldType: 'text',
importable: true,
},
shippingAddress2: {
name: 'Shipping Address 2',
column: 'shipping_address2',
fieldType: 'text',
importable: true,
},
shippingAddressCity: {
name: 'Shipping Address City',
column: 'shipping_address_city',
fieldType: 'text',
importable: true,
},
shippingAddressCountry: {
name: 'Shipping Address Country',
column: 'shipping_address_country',
fieldType: 'text',
importable: true,
},
shippingAddressPostcode: {
name: 'Shipping Address Postcode',
column: 'shipping_address_postcode',
fieldType: 'text',
importable: true,
},
shippingAddressState: {
name: 'Shipping Address State',
column: 'shipping_address_state',
fieldType: 'text',
importable: true,
},
shippingAddressPhone: {
name: 'Shipping Address Phone',
column: 'shipping_address_phone',
fieldType: 'text',
importable: true,
},
createdAt: {
name: 'vendor.field.created_at',
column: 'created_at',
fieldType: 'date',
},
},
};