refactoring: migrating to react-query to manage service-side state.

This commit is contained in:
a.bouhuolia
2021-02-07 08:10:21 +02:00
parent e093be0663
commit adac2386bb
284 changed files with 8255 additions and 6610 deletions

View File

@@ -32,6 +32,7 @@ export default class Account extends TenantModel {
return [
'accountTypeLabel',
'accountParentType',
'accountRootType',
'accountNormal',
'isBalanceSheetAccount',
'isPLSheet'
@@ -59,6 +60,13 @@ export default class Account extends TenantModel {
return AccountTypesUtils.getType(this.accountType, 'parentType');
}
/**
* Retrieve account root type.
*/
get accountRootType() {
return AccountTypesUtils.getType(this.accountType, 'rootType');
}
/**
* Retrieve whether the account is balance sheet account.
*/
@@ -236,9 +244,6 @@ export default class Account extends TenantModel {
},
root_type: {
label: 'Root type',
column: 'account_type_id',
relation: 'account_types.id',
relationColumn: 'account_types.root_type',
options: [
{ key: 'asset', label: 'Asset', },
{ key: 'liability', label: 'Liability' },
@@ -246,7 +251,12 @@ export default class Account extends TenantModel {
{ key: 'Income', label: 'Income' },
{ key: 'expense', label: 'Expense' },
],
fieldType: 'options',
query: (query, role) => {
const accountsTypes = AccountTypesUtils.getTypesByRootType(role.value);
const accountsTypesKeys = accountsTypes.map(type => type.key);
query.whereIn('account_type', accountsTypesKeys);
},
},
created_at: {
label: 'Created at',