fix: disallow posting date of purchase receipt and invoice before PO transaction date

This commit is contained in:
Mihir Kandoi
2025-06-19 13:15:36 +05:30
parent c8c1c96298
commit 77e82f4a80
3 changed files with 17 additions and 0 deletions

View File

@@ -259,6 +259,7 @@ class PurchaseInvoice(BuyingController):
self.is_opening = "No" self.is_opening = "No"
self.validate_posting_time() self.validate_posting_time()
self.validate_posting_date_with_po()
super().validate() super().validate()

View File

@@ -80,6 +80,21 @@ class BuyingController(SubcontractingController):
), ),
) )
def validate_posting_date_with_po(self):
po_list = []
for item in self.items:
if item.purchase_order and item.purchase_order not in po_list:
po_list.append(item.purchase_order)
for po in po_list:
po_posting_date = frappe.get_value("Purchase Order", po, "transaction_date")
if getdate(po_posting_date) > getdate(self.posting_date):
frappe.throw(
_("Posting Date {0} cannot be before Purchase Order Posting Date {1}").format(
frappe.bold(self.posting_date), frappe.bold(po_posting_date)
)
)
def create_package_for_transfer(self) -> None: def create_package_for_transfer(self) -> None:
"""Create serial and batch package for Sourece Warehouse in case of inter transfer.""" """Create serial and batch package for Sourece Warehouse in case of inter transfer."""

View File

@@ -235,6 +235,7 @@ class PurchaseReceipt(BuyingController):
def validate(self): def validate(self):
self.validate_posting_time() self.validate_posting_time()
self.validate_posting_date_with_po()
super().validate() super().validate()
if self._action != "submit": if self._action != "submit":