Compare commits

...

4 Commits

Author SHA1 Message Date
ruthra kumar
c7f0e04124 chore: resolve conflicts 2024-12-30 14:01:01 +05:30
Karuppasamy923
43f7e037a1 fix: Set account type payable for advance account
(cherry picked from commit 8abbece7c4)

# Conflicts:
#	erpnext/accounts/doctype/payment_entry/test_payment_entry.py
2024-12-30 08:04:09 +00:00
Karuppasamy923
d553a3e015 test: add unit test to validate on non receivable / payable account
(cherry picked from commit a10a15b2c3)
2024-12-30 08:04:09 +00:00
Karuppasamy923
53dac5909d fix: validate party on non receivable / payable account
(cherry picked from commit c6a2d86ba6)

# Conflicts:
#	erpnext/accounts/party.py
2024-12-30 08:04:09 +00:00
3 changed files with 62 additions and 1 deletions

View File

@@ -13,7 +13,11 @@ import erpnext
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
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.exceptions import InvalidAccountCurrency
@@ -226,6 +230,7 @@ class GLEntry(Document):
def validate_party(self):
validate_party_frozen_disabled(self.party_type, self.party)
validate_account_party_type(self)
def validate_currency(self):
company_currency = erpnext.get_company_currency(self.company)

View File

@@ -79,3 +79,48 @@ class TestGLEntry(unittest.TestCase):
"SELECT current from tabSeries where name = %s", naming_series
)[0][0]
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",
)

View File

@@ -786,6 +786,17 @@ def get_timeline_data(doctype, name):
return out
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):
current_fiscal_year = get_fiscal_year(nowdate(), as_dict=True)