From 72bf3096bbaa88dfcb3c38c9418b83dea72a2e15 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Wed, 2 Dec 2020 18:24:14 +0200 Subject: [PATCH 1/2] fix: full amount bold expenses transactions. fix: bulk delete expenses transactions. fix: issue delete account node in tree. --- client/src/containers/Expenses/ExpenseForm.js | 2 +- client/src/store/accounts/accounts.selectors.js | 1 + client/src/style/pages/expense-form.scss | 15 +++++++++++++++ client/src/utils.js | 5 +++-- server/src/api/controllers/Expenses.ts | 2 +- server/src/repositories/ExpenseRepository.ts | 4 ++-- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/client/src/containers/Expenses/ExpenseForm.js b/client/src/containers/Expenses/ExpenseForm.js index c86d8b26f..aef026c18 100644 --- a/client/src/containers/Expenses/ExpenseForm.js +++ b/client/src/containers/Expenses/ExpenseForm.js @@ -143,7 +143,7 @@ function ExpenseForm({ const form = { ...values, - is_published: submitPayload.publish, + publish: submitPayload.publish, categories, }; // Handle request success. diff --git a/client/src/store/accounts/accounts.selectors.js b/client/src/store/accounts/accounts.selectors.js index 7a35e9bd6..0b5e61475 100644 --- a/client/src/store/accounts/accounts.selectors.js +++ b/client/src/store/accounts/accounts.selectors.js @@ -35,6 +35,7 @@ export const getAccountsListFactory = () => return treeToList(accountsTree, { idFieldKey: 'id', childrenFieldKey: 'children', + nodeFilter: (node, depth) => accountsItems[node.id], nodeMapper: (node, depth) => { const account = accountsItems[node.id]; const spaceChar = String.fromCharCode(160); diff --git a/client/src/style/pages/expense-form.scss b/client/src/style/pages/expense-form.scss index da15f4a93..4def95174 100644 --- a/client/src/style/pages/expense-form.scss +++ b/client/src/style/pages/expense-form.scss @@ -1,6 +1,21 @@ .dashboard__insider--expense-form{ background-color: #fff; } +.dashboard__insider--expenses{ + + + .bigcapital-datatable{ + + .tbody{ + .tr .td.total_amount{ + span{ + font-weight: 600; + } + } + } + } +} + .page-form--expense{ $self: '.page-form'; diff --git a/client/src/utils.js b/client/src/utils.js index 6da8b9c3b..aa1bfe0d2 100644 --- a/client/src/utils.js +++ b/client/src/utils.js @@ -329,15 +329,16 @@ export function treeToList( idFieldKey = 'id', childrenFieldKey = 'children', nodeMapper = (node, depth) => node, + nodeFilter = (node, depth) => true, }, ) { let depth = 0; const walker = (tree) => { - return tree.reduce(function (acc, o) { + return tree.reduce((acc, o) => { depth += 1; - if (o[idFieldKey]) { + if (o[idFieldKey] && nodeFilter(o, depth)) { acc.push(nodeMapper(o, depth)); } if (o[childrenFieldKey]) { diff --git a/server/src/api/controllers/Expenses.ts b/server/src/api/controllers/Expenses.ts index 253cd06c7..46c343cb2 100644 --- a/server/src/api/controllers/Expenses.ts +++ b/server/src/api/controllers/Expenses.ts @@ -251,7 +251,7 @@ export default class ExpensesController extends BaseController { */ async bulkDeleteExpenses(req: Request, res: Response, next: NextFunction) { const { tenantId, user } = req; - const { ids: expensesIds } = req.params; + const { ids: expensesIds } = req.query; try { await this.expensesService.deleteBulkExpenses( diff --git a/server/src/repositories/ExpenseRepository.ts b/server/src/repositories/ExpenseRepository.ts index a25c308e0..f10ebbcdd 100644 --- a/server/src/repositories/ExpenseRepository.ts +++ b/server/src/repositories/ExpenseRepository.ts @@ -85,9 +85,9 @@ export default class ExpenseRepository extends TenantRepository { * @param {number[]} expensesIds */ async bulkDelete(expensesIds: number[]): Promise { - const { Expense } = this.models; + const { Expense, ExpenseCategory } = this.models; - await Expense.query().whereIn('expense_id', expensesIds).delete(); + await ExpenseCategory.query().whereIn('expense_id', expensesIds).delete(); await Expense.query().whereIn('id', expensesIds).delete(); this.flushCache(); From c2a87f5ec1410d632f49a31b043b5f79207b68fb Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Wed, 2 Dec 2020 18:44:23 +0200 Subject: [PATCH 2/2] fix: bulk delete item categories issue. --- client/src/containers/Items/ItemCategoriesList.js | 4 ++-- client/src/lang/en/index.js | 5 +++-- client/src/store/dashboard/dashboard.reducer.js | 3 ++- client/src/store/itemCategories/itemsCategory.actions.js | 2 +- server/src/api/controllers/ItemCategories.ts | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/client/src/containers/Items/ItemCategoriesList.js b/client/src/containers/Items/ItemCategoriesList.js index e15049fa0..55b43bbd2 100644 --- a/client/src/containers/Items/ItemCategoriesList.js +++ b/client/src/containers/Items/ItemCategoriesList.js @@ -106,7 +106,7 @@ const ItemCategoryList = ({ setDeleteCategory(false); AppToaster.show({ message: formatMessage({ - id: 'the_item_category_has_been_successfully_deleted', + id: 'the_item_category_has_been_deleted_successfully', }), intent: Intent.SUCCESS, }); @@ -135,7 +135,7 @@ const ItemCategoryList = ({ setBulkDelete(false); AppToaster.show({ message: formatMessage({ - id: 'the_item_categories_has_been_successfully_deleted', + id: 'the_item_categories_has_been_deleted_successfully', }), intent: Intent.SUCCESS, }); diff --git a/client/src/lang/en/index.js b/client/src/lang/en/index.js index f141cf36c..a36eb76e5 100644 --- a/client/src/lang/en/index.js +++ b/client/src/lang/en/index.js @@ -221,8 +221,8 @@ export default { 'The item category has been successfully created.', the_item_category_has_been_successfully_edited: 'The item category has been successfully edited.', - the_item_category_has_been_successfully_deleted: - 'The item category has been successfully deleted', + the_item_category_has_been_deleted_successfully: + 'The item category has been deleted successfully.', once_delete_these_item_categories_you_will_not_able_restore_them: "Once you delete these categories, you won't be able to retrieve them later. Are you sure you want to delete them?", once_delete_these_views_you_will_not_able_restore_them: @@ -855,4 +855,5 @@ export default { posting_date: 'Posting date', customer: 'Customer', email_is_already_used: 'The email is already used.', + the_item_categories_has_been_deleted_successfully: 'The item categories has been deleted successfully .', }; diff --git a/client/src/store/dashboard/dashboard.reducer.js b/client/src/store/dashboard/dashboard.reducer.js index 1336f48f7..f4565a424 100644 --- a/client/src/store/dashboard/dashboard.reducer.js +++ b/client/src/store/dashboard/dashboard.reducer.js @@ -97,7 +97,8 @@ export default persistReducer({ 'pageSubtitle', 'pageHint', 'preferencesPageTitle', - 'topbarEditViewId' + 'topbarEditViewId', + 'backLink' ], storage, }, reducerInstance); diff --git a/client/src/store/itemCategories/itemsCategory.actions.js b/client/src/store/itemCategories/itemsCategory.actions.js index 4de3b2bce..0c471e6b8 100644 --- a/client/src/store/itemCategories/itemsCategory.actions.js +++ b/client/src/store/itemCategories/itemsCategory.actions.js @@ -78,7 +78,7 @@ export const deleteItemCategory = (id) => { export const deleteBulkItemCategories = ({ ids }) => { return (dispatch) => new Promise((resolve, reject) => { - ApiService.delete(`item_categories/bulk`, { params: { ids } }) + ApiService.delete(`item_categories`, { params: { ids } }) .then((response) => { dispatch({ type: t.ITEM_CATEGORIES_BULK_DELETE, diff --git a/server/src/api/controllers/ItemCategories.ts b/server/src/api/controllers/ItemCategories.ts index 6bdd272e9..064e1e16a 100644 --- a/server/src/api/controllers/ItemCategories.ts +++ b/server/src/api/controllers/ItemCategories.ts @@ -110,7 +110,7 @@ export default class ItemsCategoriesController extends BaseController { */ get categoriesBulkValidationSchema() { return [ - query('ids').isArray({ min: 2 }), + query('ids').isArray({ min: 1 }), query('ids.*').isNumeric().toInt(), ]; }