patch: create entries for only missing transactions
This commit is contained in:
parent
45197965d7
commit
24248f687b
@ -7,7 +7,7 @@ import frappe
|
|||||||
def execute():
|
def execute():
|
||||||
""" Generates leave ledger entries for leave allocation/application/encashment
|
""" Generates leave ledger entries for leave allocation/application/encashment
|
||||||
for last allocation """
|
for last allocation """
|
||||||
if frappe.db.exists("DocType","Leave Ledger Entry"):
|
if frappe.db.a_row_exists("Leave Ledger Entry"):
|
||||||
return
|
return
|
||||||
|
|
||||||
allocation_list = get_allocation_records()
|
allocation_list = get_allocation_records()
|
||||||
@ -20,7 +20,9 @@ def generate_allocation_ledger_entries(allocation_list):
|
|||||||
from erpnext.hr.doctype.leave_allocation.leave_allocation import LeaveAllocation
|
from erpnext.hr.doctype.leave_allocation.leave_allocation import LeaveAllocation
|
||||||
|
|
||||||
for allocation in allocation_list:
|
for allocation in allocation_list:
|
||||||
LeaveAllocation.create_leave_ledger_entry(allocation)
|
if not frappe.db.exists("Leave Ledger Entry", {'transaction_type': 'Leave Allocation',
|
||||||
|
'transaction_name': allocation.name}):
|
||||||
|
LeaveAllocation.create_leave_ledger_entry(allocation)
|
||||||
|
|
||||||
def generate_application_leave_ledger_entries(allocation_list):
|
def generate_application_leave_ledger_entries(allocation_list):
|
||||||
''' fix ledger entries for missing leave application transaction '''
|
''' fix ledger entries for missing leave application transaction '''
|
||||||
@ -29,7 +31,9 @@ def generate_application_leave_ledger_entries(allocation_list):
|
|||||||
leave_applications = get_leaves_application_records(allocation_list)
|
leave_applications = get_leaves_application_records(allocation_list)
|
||||||
|
|
||||||
for record in leave_applications:
|
for record in leave_applications:
|
||||||
LeaveApplication.create_leave_ledger_entry(record)
|
if not frappe.db.exists("Leave Ledger Entry", {'transaction_type': 'Leave Application',
|
||||||
|
'transaction_name': record.name}):
|
||||||
|
LeaveApplication.create_leave_ledger_entry(record)
|
||||||
|
|
||||||
def generate_encashment_leave_ledger_entries(allocation_list):
|
def generate_encashment_leave_ledger_entries(allocation_list):
|
||||||
''' fix ledger entries for missing leave encashment transaction '''
|
''' fix ledger entries for missing leave encashment transaction '''
|
||||||
@ -38,7 +42,9 @@ def generate_encashment_leave_ledger_entries(allocation_list):
|
|||||||
leave_encashments = get_leave_encashment_records(allocation_list)
|
leave_encashments = get_leave_encashment_records(allocation_list)
|
||||||
|
|
||||||
for record in leave_encashments:
|
for record in leave_encashments:
|
||||||
LeaveEncashment.create_leave_ledger_entry(record)
|
if not frappe.db.exists("Leave Ledger Entry", {'transaction_type': 'Leave Encashment',
|
||||||
|
'transaction_name': record.name}):
|
||||||
|
LeaveEncashment.create_leave_ledger_entry(record)
|
||||||
|
|
||||||
def get_allocation_records():
|
def get_allocation_records():
|
||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
@ -62,7 +68,7 @@ def get_leaves_application_records(allocation_list):
|
|||||||
for allocation in allocation_list:
|
for allocation in allocation_list:
|
||||||
leave_applications.append(frappe.db.sql("""
|
leave_applications.append(frappe.db.sql("""
|
||||||
SELECT
|
SELECT
|
||||||
name,
|
DISTINCT name,
|
||||||
employee,
|
employee,
|
||||||
leave_type,
|
leave_type,
|
||||||
total_leave_days,
|
total_leave_days,
|
||||||
|
Loading…
Reference in New Issue
Block a user