fix: Exception naming

This commit is contained in:
Deepesh Garg 2020-12-02 12:34:59 +05:30
parent ab5053ef9c
commit 59820004b8
3 changed files with 9 additions and 9 deletions

View File

@ -7,7 +7,7 @@ import frappe
import unittest
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import create_dimension, disable_dimension
from erpnext.exceptions import InvalidAccountDimension, MandatoryDimension
from erpnext.exceptions import InvalidAccountDimensionError, MandatoryAccountDimensionError
class TestAccountingDimensionFilter(unittest.TestCase):
def setUp(self):
@ -20,7 +20,7 @@ class TestAccountingDimensionFilter(unittest.TestCase):
si.location = 'Block 1'
si.save()
self.assertRaises(InvalidAccountDimension, si.submit)
self.assertRaises(InvalidAccountDimensionError, si.submit)
def test_mandatory_dimension_validation(self):
si = create_sales_invoice(do_not_save=1)
@ -31,7 +31,7 @@ class TestAccountingDimensionFilter(unittest.TestCase):
si.items[0].cost_center = '_Test Cost Center 2 - _TC'
si.save()
self.assertRaises(MandatoryDimension, si.submit)
self.assertRaises(MandatoryAccountDimensionError, si.submit)
def tearDown(self):
disable_dimension_filter()

View File

@ -11,7 +11,7 @@ from frappe.model.meta import get_field_precision
from erpnext.accounts.party import validate_party_gle_currency, validate_party_frozen_disabled
from erpnext.accounts.utils import get_account_currency
from erpnext.accounts.utils import get_fiscal_year
from erpnext.exceptions import InvalidAccountCurrency, InvalidAccountDimension, MandatoryDimension
from erpnext.exceptions import InvalidAccountCurrency, InvalidAccountDimensionError, MandatoryAccountDimensionError
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_checks_for_pl_and_bs_accounts
from erpnext.accounts.doctype.accounting_dimension_filter.accounting_dimension_filter import get_dimension_filter_map
from six import iteritems
@ -101,16 +101,16 @@ class GLEntry(Document):
if self.account == account:
if value['is_mandatory'] and not self.get(dimension):
frappe.throw(_("{0} is mandatory for account {1}").format(
frappe.bold(frappe.unscrub(dimension)), frappe.bold(self.account)), MandatoryDimension)
frappe.bold(frappe.unscrub(dimension)), frappe.bold(self.account)), MandatoryAccountDimensionError)
if value['allow_or_restrict'] == 'Allow':
if self.get(dimension) and self.get(dimension) not in value['allowed_dimensions']:
frappe.throw(_("Invalid value {0} for account {1}").format(
frappe.bold(self.get(dimension)), frappe.bold(self.account)), InvalidAccountDimension)
frappe.bold(self.get(dimension)), frappe.bold(self.account)), InvalidAccountDimensionError)
else:
if self.get(dimension) and self.get(dimension) in value['allowed_dimensions']:
frappe.throw(_("Invalid value {0} for account {1}").format(
frappe.bold(self.get(dimension)), frappe.bold(self.account)), InvalidAccountDimension)
frappe.bold(self.get(dimension)), frappe.bold(self.account)), InvalidAccountDimensionError)
def check_pl_account(self):
if self.is_opening=='Yes' and \

View File

@ -6,5 +6,5 @@ class PartyFrozen(frappe.ValidationError): pass
class InvalidAccountCurrency(frappe.ValidationError): pass
class InvalidCurrency(frappe.ValidationError): pass
class PartyDisabled(frappe.ValidationError):pass
class InvalidAccountDimension(frappe.ValidationError): pass
class MandatoryDimension(frappe.ValidationError): pass
class InvalidAccountDimensionError(frappe.ValidationError): pass
class MandatoryAccountDimensionError(frappe.ValidationError): pass