refactor: convert raw sql to orm

This commit is contained in:
Mangesh-Khairnar
2019-08-08 17:43:23 +05:30
parent 9bc4232af6
commit bafc89f439
9 changed files with 23 additions and 50 deletions

View File

@@ -69,45 +69,18 @@ def generate_expiry_allocation_ledger_entries():
expire_allocation(allocation_obj)
def get_allocation_records():
return frappe.db.sql("""
SELECT
name,
employee,
leave_type,
new_leaves_allocated,
unused_leaves,
from_date,
to_date,
carry_forward
FROM `tabLeave Allocation`
WHERE
docstatus=1
ORDER BY to_date ASC
""", as_dict=1)
return frappe.get_all("Leave Allocation", filters={
"docstatus": 1
}, fields=['name', 'employee', 'leave_type', 'new_leaves_allocated',
'unused_leaves', 'from_date', 'to_date', 'carry_forward'
], order_by='to_date ASC')
def get_leaves_application_records():
return frappe.db.sql("""
SELECT
name,
employee,
leave_type,
total_leave_days,
from_date,
to_date
FROM `tabLeave Application`
WHERE
docstatus=1
""", as_dict=1)
return frappe.get_all("Leave Application", filters={
"docstatus": 1
}, fields=['name', 'employee', 'leave_type', 'total_leave_days', 'from_date', 'to_date'])
def get_leave_encashment_records():
return frappe.db.sql("""
SELECT
name,
employee,
leave_type,
encashable_days,
encashment_date
FROM `tabLeave Encashment`
WHERE
docstatus=1
""", as_dict=1)
return frappe.get_all("Leave Encashment", filters={
"docstatus": 1
}, fields=['name', 'employee', 'leave_type', 'encashable_days', 'encashment_date'])