mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-14 23:18:40 +00:00
fix(journal entry): validate opening entry against pcv on save
This commit is contained in:
@@ -19,6 +19,7 @@ from erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger
|
|||||||
validate_docs_for_voucher_types,
|
validate_docs_for_voucher_types,
|
||||||
)
|
)
|
||||||
from erpnext.accounts.doctype.tax_withholding_entry.tax_withholding_entry import JournalTaxWithholding
|
from erpnext.accounts.doctype.tax_withholding_entry.tax_withholding_entry import JournalTaxWithholding
|
||||||
|
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,
|
||||||
@@ -131,6 +132,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()
|
||||||
|
|||||||
@@ -821,13 +821,24 @@ def check_freezing_date(posting_date, company, 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)
|
||||||
|
|
||||||
last_pcv_date = frappe.db.get_value(
|
last_pcv_date = frappe.db.get_value(
|
||||||
"Period Closing Voucher", {"docstatus": 1, "company": company}, [{"MAX": "period_end_date"}]
|
"Period Closing Voucher", {"docstatus": 1, "company": company}, [{"MAX": "period_end_date"}]
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user