mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-16 13:32:13 +00:00
* fix: validate party on non receivable / payable account (cherry picked from commitc6a2d86ba6) * test: add unit test to validate on non receivable / payable account (cherry picked from commita10a15b2c3) * fix: Set account type payable for advance account (cherry picked from commit8abbece7c4) --------- Co-authored-by: Karuppasamy923 <karuppasamylivak@gmail.com>
This commit is contained in:
@@ -13,7 +13,11 @@ import erpnext
|
|||||||
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
||||||
get_checks_for_pl_and_bs_accounts,
|
get_checks_for_pl_and_bs_accounts,
|
||||||
)
|
)
|
||||||
from erpnext.accounts.party import validate_party_frozen_disabled, validate_party_gle_currency
|
from erpnext.accounts.party import (
|
||||||
|
validate_account_party_type,
|
||||||
|
validate_party_frozen_disabled,
|
||||||
|
validate_party_gle_currency,
|
||||||
|
)
|
||||||
from erpnext.accounts.utils import get_account_currency, get_fiscal_year
|
from erpnext.accounts.utils import get_account_currency, get_fiscal_year
|
||||||
from erpnext.exceptions import InvalidAccountCurrency
|
from erpnext.exceptions import InvalidAccountCurrency
|
||||||
|
|
||||||
@@ -268,6 +272,7 @@ class GLEntry(Document):
|
|||||||
|
|
||||||
def validate_party(self):
|
def validate_party(self):
|
||||||
validate_party_frozen_disabled(self.party_type, self.party)
|
validate_party_frozen_disabled(self.party_type, self.party)
|
||||||
|
validate_account_party_type(self)
|
||||||
|
|
||||||
def validate_currency(self):
|
def validate_currency(self):
|
||||||
company_currency = erpnext.get_company_currency(self.company)
|
company_currency = erpnext.get_company_currency(self.company)
|
||||||
|
|||||||
@@ -79,3 +79,48 @@ class TestGLEntry(unittest.TestCase):
|
|||||||
"SELECT current from tabSeries where name = %s", naming_series
|
"SELECT current from tabSeries where name = %s", naming_series
|
||||||
)[0][0]
|
)[0][0]
|
||||||
self.assertEqual(old_naming_series_current_value + 2, new_naming_series_current_value)
|
self.assertEqual(old_naming_series_current_value + 2, new_naming_series_current_value)
|
||||||
|
|
||||||
|
def test_validate_account_party_type(self):
|
||||||
|
jv = make_journal_entry(
|
||||||
|
"_Test Account Cost for Goods Sold - _TC",
|
||||||
|
"_Test Bank - _TC",
|
||||||
|
100,
|
||||||
|
"_Test Cost Center - _TC",
|
||||||
|
save=False,
|
||||||
|
submit=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in jv.accounts:
|
||||||
|
row.party_type = "Supplier"
|
||||||
|
break
|
||||||
|
|
||||||
|
jv.save()
|
||||||
|
try:
|
||||||
|
jv.submit()
|
||||||
|
except Exception as e:
|
||||||
|
self.assertEqual(
|
||||||
|
str(e),
|
||||||
|
"Party Type and Party can only be set for Receivable / Payable account_Test Account Cost for Goods Sold - _TC",
|
||||||
|
)
|
||||||
|
|
||||||
|
jv1 = make_journal_entry(
|
||||||
|
"_Test Account Cost for Goods Sold - _TC",
|
||||||
|
"_Test Bank - _TC",
|
||||||
|
100,
|
||||||
|
"_Test Cost Center - _TC",
|
||||||
|
save=False,
|
||||||
|
submit=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in jv.accounts:
|
||||||
|
row.party_type = "Customer"
|
||||||
|
break
|
||||||
|
|
||||||
|
jv1.save()
|
||||||
|
try:
|
||||||
|
jv1.submit()
|
||||||
|
except Exception as e:
|
||||||
|
self.assertEqual(
|
||||||
|
str(e),
|
||||||
|
"Party Type and Party can only be set for Receivable / Payable account_Test Account Cost for Goods Sold - _TC",
|
||||||
|
)
|
||||||
|
|||||||
@@ -1479,7 +1479,7 @@ class TestPaymentEntry(FrappeTestCase):
|
|||||||
parent_account="Current Liabilities - _TC",
|
parent_account="Current Liabilities - _TC",
|
||||||
account_name="Advances Paid",
|
account_name="Advances Paid",
|
||||||
company=company,
|
company=company,
|
||||||
account_type="Liability",
|
account_type="Payable",
|
||||||
)
|
)
|
||||||
|
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
|
|||||||
@@ -759,6 +759,17 @@ def validate_party_frozen_disabled(party_type, party_name):
|
|||||||
frappe.msgprint(_("{0} {1} is not active").format(party_type, party_name), alert=True)
|
frappe.msgprint(_("{0} {1} is not active").format(party_type, party_name), alert=True)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_account_party_type(self):
|
||||||
|
if self.party_type and self.party:
|
||||||
|
account_type = frappe.get_cached_value("Account", self.account, "account_type")
|
||||||
|
if account_type and (account_type not in ["Receivable", "Payable"]):
|
||||||
|
frappe.throw(
|
||||||
|
_(
|
||||||
|
"Party Type and Party can only be set for Receivable / Payable account<br><br>" "{0}"
|
||||||
|
).format(self.account)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_dashboard_info(party_type, party, loyalty_program=None):
|
def get_dashboard_info(party_type, party, loyalty_program=None):
|
||||||
current_fiscal_year = get_fiscal_year(nowdate(), as_dict=True)
|
current_fiscal_year = get_fiscal_year(nowdate(), as_dict=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user