feat: create leave ledger entry
This commit is contained in:
parent
5e2b067107
commit
1de990b2ac
0
erpnext/hr/doctype/leave_ledger_entry/__init__.py
Normal file
0
erpnext/hr/doctype/leave_ledger_entry/__init__.py
Normal file
@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Leave Ledger Entry', {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
@ -0,0 +1,99 @@
|
||||
{
|
||||
"creation": "2019-05-09 15:47:39.760406",
|
||||
"doctype": "DocType",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"employee",
|
||||
"employee_name",
|
||||
"leave_type",
|
||||
"transaction_type",
|
||||
"transaction_name",
|
||||
"leaves",
|
||||
"from_date",
|
||||
"to_date",
|
||||
"is_carry_forward",
|
||||
"amended_from"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "employee",
|
||||
"fieldtype": "Link",
|
||||
"label": "Employee",
|
||||
"options": "Employee"
|
||||
},
|
||||
{
|
||||
"fieldname": "employee_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Employee Name"
|
||||
},
|
||||
{
|
||||
"fieldname": "leave_type",
|
||||
"fieldtype": "Link",
|
||||
"label": "Leave Type",
|
||||
"options": "Leave Type"
|
||||
},
|
||||
{
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
"label": "Amended From",
|
||||
"no_copy": 1,
|
||||
"options": "Leave Ledger Entry",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "transaction_type",
|
||||
"fieldtype": "Link",
|
||||
"label": "Transaction Type",
|
||||
"options": "DocType"
|
||||
},
|
||||
{
|
||||
"fieldname": "transaction_name",
|
||||
"fieldtype": "Dynamic Link",
|
||||
"label": "Transaction Name",
|
||||
"options": "transaction_type"
|
||||
},
|
||||
{
|
||||
"fieldname": "leaves",
|
||||
"fieldtype": "Int",
|
||||
"label": "Leaves"
|
||||
},
|
||||
{
|
||||
"fieldname": "from_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "From Date"
|
||||
},
|
||||
{
|
||||
"fieldname": "to_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "To Date"
|
||||
},
|
||||
{
|
||||
"fieldname": "is_carry_forward",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Carry Forward"
|
||||
}
|
||||
],
|
||||
"is_submittable": 1,
|
||||
"modified": "2019-05-09 15:54:52.834794",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Leave Ledger Entry",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "ASC"
|
||||
}
|
39
erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.py
Normal file
39
erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.py
Normal file
@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import add_days
|
||||
|
||||
class LeaveLedgerEntry(Document):
|
||||
pass
|
||||
|
||||
def create_leave_ledger_entry(ref_doc, submit=True):
|
||||
ledger = dict(
|
||||
doctype='Leave Ledger Entry',
|
||||
employee=ref_doc.employee,
|
||||
employee_name=ref_doc.employee_name,
|
||||
leave_type=ref_doc.leave_type,
|
||||
from_date=ref_doc.from_date,
|
||||
transaction_document_type=ref_doc.doctype,
|
||||
transaction_document_name=ref_doc.name
|
||||
)
|
||||
|
||||
if ref_doc.carry_forwarded_leaves:
|
||||
expiry_days = frappe.db.get_value("Leave Type", ref_doc.leave_type, "carry_forward_leave_expiry")
|
||||
|
||||
ledger.update(dict(
|
||||
leaves=ref_doc.carry_forwarded_leaves * 1 if submit else -1,
|
||||
to_date=add_days(ref_doc.from_date, expiry_days) if expiry_days else ref_doc.to_date,
|
||||
is_carry_forward=1
|
||||
))
|
||||
frappe.get_doc(ledger).insert()
|
||||
|
||||
ledger.update(dict(
|
||||
leaves=ref_doc.new_leaves_allocated * 1 if submit else -1,
|
||||
to_date=ref_doc.to_date,
|
||||
is_carry_forward=0
|
||||
))
|
||||
frappe.get_doc(ledger).insert()
|
@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# import frappe
|
||||
import unittest
|
||||
|
||||
class TestLeaveLedgerEntry(unittest.TestCase):
|
||||
pass
|
Loading…
Reference in New Issue
Block a user