From 40806668df8ce94c8920ca8a8a78cf8305954b75 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Mon, 22 Mar 2021 18:00:37 +0200 Subject: [PATCH] feat:(customer & vendr) : catch message error. --- client/src/containers/Customers/utils.js | 9 +++++++++ client/src/containers/Vendors/utils.js | 9 +++++++++ client/src/lang/en/index.js | 20 ++++++++++++++++---- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/client/src/containers/Customers/utils.js b/client/src/containers/Customers/utils.js index e766e18a5..38361f58f 100644 --- a/client/src/containers/Customers/utils.js +++ b/client/src/containers/Customers/utils.js @@ -22,4 +22,13 @@ export const transformErrors = (errors) => { intent: Intent.DANGER, }); } + if (errors.find((error) => error.type === 'CUSTOMER_HAS_TRANSACTIONS')) { + AppToaster.show({ + message: formatMessage({ + id: + 'this_customer_cannot_be_deleted_as_it_is_associated_with_transactions', + }), + intent: Intent.DANGER, + }); + } }; diff --git a/client/src/containers/Vendors/utils.js b/client/src/containers/Vendors/utils.js index 4d4d322e8..c95f91654 100644 --- a/client/src/containers/Vendors/utils.js +++ b/client/src/containers/Vendors/utils.js @@ -12,4 +12,13 @@ export const transformErrors = (errors) => { intent: Intent.DANGER, }); } + if (errors.find((error) => error.type === 'VENDOR_HAS_TRANSACTIONS')) { + AppToaster.show({ + message: formatMessage({ + id: + 'this_vendor_cannot_be_deleted_as_it_is_associated_with_transactions', + }), + intent: Intent.DANGER, + }); + } }; diff --git a/client/src/lang/en/index.js b/client/src/lang/en/index.js index 3f6d47ffc..a87f81eba 100644 --- a/client/src/lang/en/index.js +++ b/client/src/lang/en/index.js @@ -821,7 +821,8 @@ export default { average_rate: 'Average rate', the_name_used_before: 'The name is already used.', the_item_has_associated_transactions: 'The item has associated transactions.', - customer_has_sales_invoices: 'Cannot delete customer has associated sales invoices.', + customer_has_sales_invoices: + 'Cannot delete customer has associated sales invoices.', account_name_is_already_used: 'Account name is already used.', vendors: 'Vendors', vendor_email: 'Vendor Email', @@ -1013,12 +1014,23 @@ export default { 'The payment amount bigger than invoice due amount.', accounting_basis_: 'Accounting Basis', deposit_customer_account: 'Deposit customer account', - withdrawal_customer_account: 'Withdrawal customer account', - vendor_advance_deposit: 'Vendor advance deposit', + withdrawal_vendor_account: 'Withdrawal vendor account', + customer_advance_deposit: 'Customer advance deposit', cannot_delete_bill_that_has_payment_transactions: 'Cannot delete bill that has associated payment transactions.', cannot_change_item_type_to_inventory_with_item_has_associated_transactions: 'Cannot change item type to inventory with item has associated transactions.', work_phone: 'Work Phone', - cannot_delete_vendor_that_has_associated_purchase_bills:'Cannot delete vendor that has associated purchase bills.' + cannot_delete_vendor_that_has_associated_purchase_bills: + 'Cannot delete vendor that has associated purchase bills.', + the_accountant_preferences_has_been_saved: + 'The accountant preferences has been saved.', + the_items_preferences_has_been_saved: 'The items preferences has been saved.', + preferred_sell_account: 'Preferred sell account', + preferred_cost_account: 'Preferred cost account', + preferred_inventory_account: 'Preferred inventory account', + this_customer_cannot_be_deleted_as_it_is_associated_with_transactions: + 'This customer cannot be deleted as it is associated with transactions.', + this_vendor_cannot_be_deleted_as_it_is_associated_with_transactions: + 'This vendor cannot be deleted as it is associated with transactions.', };