Skip to content

Commit

Permalink
fix: check for latest transaction of the same company only (#38)
Browse files Browse the repository at this point in the history
Co-authored-by: Raffael Meyer <[email protected]>
  • Loading branch information
Mutantpenguin and barredterra authored Jul 24, 2024
1 parent 14bec40 commit e62962d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions erpnext_germany/custom/sales.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def on_trash(doc: SellingController, event: str = None) -> None:
if doc.flags.ignore_validate:
return

if is_not_latest(doc.doctype, doc.name, doc.creation):
if is_not_latest(doc.doctype, doc.name, doc.creation, doc.company):
frappe.throw(
msg=_(
"Only the most recent {0} can be deleted in order to avoid gaps in numbering."
Expand All @@ -16,11 +16,12 @@ def on_trash(doc: SellingController, event: str = None) -> None:
)


def is_not_latest(doctype, name, creation):
def is_not_latest(doctype, name, creation, company):
return frappe.db.exists(
doctype,
{
"creation": (">", creation),
"name": ("!=", name),
"company": company,
},
)

0 comments on commit e62962d

Please sign in to comment.