From d80acc122df40a234781e42d6c0b6419433c0497 Mon Sep 17 00:00:00 2001 From: fproldan Date: Tue, 8 Oct 2024 14:39:28 +0000 Subject: [PATCH] feat: validate overlap --- .../doctype/sales_commission/sales_commission.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/erpnext/payroll/doctype/sales_commission/sales_commission.py b/erpnext/payroll/doctype/sales_commission/sales_commission.py index 9bae6bd4fba5..39e8498c5248 100644 --- a/erpnext/payroll/doctype/sales_commission/sales_commission.py +++ b/erpnext/payroll/doctype/sales_commission/sales_commission.py @@ -22,18 +22,17 @@ def validate_from_to_dates(self): return super().validate_from_to_dates("from_date", "to_date") def validate_omit_transaction_duplicates(self): - # TODO chequear por solapamiento de fechas if not self.omit_sales_person_transactions: return previous_contibutions = frappe.get_all( "Sales Commission", - filters={ - "sales_person": self.sales_person, - "docstatus": 1, - "from_date": self.from_date, - "to_date": self.to_date, - }, + filters=[ + ['from_date', '<=', self.to_date], + ['to_date', '>=', self.from_date], + ['sales_person', '=', self.sales_person], + ['docstatus', '=', 1], + ], pluck="name" ) if previous_contibutions: