mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-01 12:38:27 +00:00
refactor: better query parameters for PO and MR
This commit is contained in:
@@ -174,9 +174,6 @@ class BudgetValidation:
|
|||||||
|
|
||||||
def get_ordered_amount(self, key: tuple | None = None):
|
def get_ordered_amount(self, key: tuple | None = None):
|
||||||
if key:
|
if key:
|
||||||
items = set([x.item_code for x in self.doc.items])
|
|
||||||
exp_accounts = set([x.expense_account for x in self.doc.items])
|
|
||||||
|
|
||||||
po = qb.DocType("Purchase Order")
|
po = qb.DocType("Purchase Order")
|
||||||
poi = qb.DocType("Purchase Order Item")
|
poi = qb.DocType("Purchase Order Item")
|
||||||
|
|
||||||
@@ -186,8 +183,11 @@ class BudgetValidation:
|
|||||||
conditions.append(po.status.ne("Closed"))
|
conditions.append(po.status.ne("Closed"))
|
||||||
conditions.append(po.transaction_date[self.fy_start_date : self.fy_end_date])
|
conditions.append(po.transaction_date[self.fy_start_date : self.fy_end_date])
|
||||||
conditions.append(poi.amount.gt(poi.billed_amt))
|
conditions.append(poi.amount.gt(poi.billed_amt))
|
||||||
conditions.append(poi.expense_account.isin(exp_accounts))
|
conditions.append(poi.expense_account.eq(key[2]))
|
||||||
conditions.append(poi.item_code.isin(items))
|
|
||||||
|
if self.document_type in ["Purchase Order", "Material Request"]:
|
||||||
|
if items := set([x.item_code for x in self.doc.items]):
|
||||||
|
conditions.append(poi.item_code.isin(items))
|
||||||
|
|
||||||
# key structure - (dimension_type, dimension, GL account)
|
# key structure - (dimension_type, dimension, GL account)
|
||||||
conditions.append(poi[key[0]].eq(key[1]))
|
conditions.append(poi[key[0]].eq(key[1]))
|
||||||
@@ -206,9 +206,6 @@ class BudgetValidation:
|
|||||||
|
|
||||||
def get_requested_amount(self, key: tuple | None = None):
|
def get_requested_amount(self, key: tuple | None = None):
|
||||||
if key:
|
if key:
|
||||||
items = set([x.item_code for x in self.doc.items])
|
|
||||||
exp_accounts = set([x.expense_account for x in self.doc.items])
|
|
||||||
|
|
||||||
mr = qb.DocType("Material Request")
|
mr = qb.DocType("Material Request")
|
||||||
mri = qb.DocType("Material Request Item")
|
mri = qb.DocType("Material Request Item")
|
||||||
|
|
||||||
@@ -218,8 +215,11 @@ class BudgetValidation:
|
|||||||
conditions.append(mr.material_request_type.eq("Purchase"))
|
conditions.append(mr.material_request_type.eq("Purchase"))
|
||||||
conditions.append(mr.status.ne("Stopped"))
|
conditions.append(mr.status.ne("Stopped"))
|
||||||
conditions.append(mr.transaction_date[self.fy_start_date : self.fy_end_date])
|
conditions.append(mr.transaction_date[self.fy_start_date : self.fy_end_date])
|
||||||
conditions.append(mri.expense_account.isin(exp_accounts))
|
conditions.append(mri.expense_account.eq(key[2]))
|
||||||
conditions.append(mri.item_code.isin(items))
|
|
||||||
|
if self.document_type in ["Purchase Order", "Material Request"]:
|
||||||
|
if items := set([x.item_code for x in self.doc.items]):
|
||||||
|
conditions.append(mri.item_code.isin(items))
|
||||||
|
|
||||||
# key structure - (dimension_type, dimension, GL account)
|
# key structure - (dimension_type, dimension, GL account)
|
||||||
conditions.append(mri[key[0]].eq(key[1]))
|
conditions.append(mri[key[0]].eq(key[1]))
|
||||||
|
|||||||
Reference in New Issue
Block a user