mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-14 07:01:56 +00:00
fix(journal entry): validate opening entry against pcv on save
(cherry picked from commit f8aa4c730c)
# Conflicts:
# erpnext/accounts/doctype/journal_entry/journal_entry.py
# erpnext/accounts/general_ledger.py
This commit is contained in:
@@ -21,6 +21,7 @@ from erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger
|
|||||||
from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import (
|
from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import (
|
||||||
get_party_tax_withholding_details,
|
get_party_tax_withholding_details,
|
||||||
)
|
)
|
||||||
|
from erpnext.accounts.general_ledger import validate_opening_entry_against_pcv
|
||||||
from erpnext.accounts.party import get_party_account
|
from erpnext.accounts.party import get_party_account
|
||||||
from erpnext.accounts.utils import (
|
from erpnext.accounts.utils import (
|
||||||
cancel_exchange_gain_loss_journal,
|
cancel_exchange_gain_loss_journal,
|
||||||
@@ -123,6 +124,9 @@ class JournalEntry(AccountsController):
|
|||||||
if not self.is_opening:
|
if not self.is_opening:
|
||||||
self.is_opening = "No"
|
self.is_opening = "No"
|
||||||
|
|
||||||
|
if self.is_opening == "Yes":
|
||||||
|
validate_opening_entry_against_pcv(self.company)
|
||||||
|
|
||||||
self.clearance_date = None
|
self.clearance_date = None
|
||||||
|
|
||||||
self.validate_party()
|
self.validate_party()
|
||||||
|
|||||||
@@ -802,13 +802,24 @@ def check_freezing_date(posting_date, adv_adj=False):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def validate_against_pcv(is_opening, posting_date, company):
|
def validate_opening_entry_against_pcv(company):
|
||||||
if is_opening and frappe.db.exists("Period Closing Voucher", {"docstatus": 1, "company": company}):
|
if frappe.db.exists("Period Closing Voucher", {"docstatus": 1, "company": company}):
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("Opening Entry can not be created after Period Closing Voucher is created."),
|
_(
|
||||||
|
"A Period Closing Voucher is already submitted and an Opening Entry can no longer be created. {0} to learn more."
|
||||||
|
).format(
|
||||||
|
'<a href="https://docs.frappe.io/erpnext/period-closing-voucher#14-pcv-and-opening-entries" target="_blank" rel="noopener">'
|
||||||
|
+ _("Read the docs")
|
||||||
|
+ "</a>"
|
||||||
|
),
|
||||||
title=_("Invalid Opening Entry"),
|
title=_("Invalid Opening Entry"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_against_pcv(is_opening, posting_date, company):
|
||||||
|
if is_opening:
|
||||||
|
validate_opening_entry_against_pcv(company)
|
||||||
|
|
||||||
# Local import so you don't have to touch file-level imports
|
# Local import so you don't have to touch file-level imports
|
||||||
from frappe.query_builder.functions import Max
|
from frappe.query_builder.functions import Max
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user