mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 20:29:09 +00:00
Merge branch 'version-12-hotfix' of https://github.com/frappe/erpnext into v12-pre-release
This commit is contained in:
@@ -113,13 +113,13 @@ frappe.ui.form.on('Employee Advance', {
|
||||
employee: function (frm) {
|
||||
if (frm.doc.employee) {
|
||||
return frappe.call({
|
||||
method: "erpnext.hr.doctype.employee_advance.employee_advance.get_due_advance_amount",
|
||||
method: "erpnext.hr.doctype.employee_advance.employee_advance.get_pending_amount",
|
||||
args: {
|
||||
"employee": frm.doc.employee,
|
||||
"posting_date": frm.doc.posting_date
|
||||
},
|
||||
callback: function(r) {
|
||||
frm.set_value("due_advance_amount",r.message);
|
||||
frm.set_value("pending_amount",r.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"column_break_11",
|
||||
"advance_amount",
|
||||
"paid_amount",
|
||||
"due_advance_amount",
|
||||
"pending_amount",
|
||||
"claimed_amount",
|
||||
"return_amount",
|
||||
"section_break_7",
|
||||
@@ -101,14 +101,6 @@
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:cur_frm.doc.employee",
|
||||
"fieldname": "due_advance_amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Due Advance Amount",
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "claimed_amount",
|
||||
"fieldtype": "Currency",
|
||||
@@ -169,11 +161,25 @@
|
||||
"label": "Returned Amount",
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "repay_unclaimed_amount_from_salary",
|
||||
"fieldtype": "Check",
|
||||
"label": "Repay unclaimed amount from salary"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:cur_frm.doc.employee",
|
||||
"fieldname": "pending_amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Pending Amount",
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2019-12-15 19:04:07.044505",
|
||||
"modified": "2020-06-12 12:42:39.833818",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee Advance",
|
||||
|
||||
@@ -95,7 +95,7 @@ class EmployeeAdvance(Document):
|
||||
frappe.db.set_value("Employee Advance", self.name, "status", self.status)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_due_advance_amount(employee, posting_date):
|
||||
def get_pending_amount(employee, posting_date):
|
||||
employee_due_amount = frappe.get_all("Employee Advance", \
|
||||
filters = {"employee":employee, "docstatus":1, "posting_date":("<=", posting_date)}, \
|
||||
fields = ["advance_amount", "paid_amount"])
|
||||
|
||||
@@ -154,6 +154,14 @@ frappe.ui.form.on("Expense Claim", {
|
||||
}
|
||||
};
|
||||
});
|
||||
frm.set_query("cost_center", "expenses", function() {
|
||||
return {
|
||||
filters: {
|
||||
"company": frm.doc.company,
|
||||
"is_group": 0
|
||||
}
|
||||
};
|
||||
});
|
||||
frm.set_query("account_head", "taxes", function(doc) {
|
||||
return {
|
||||
filters: [
|
||||
|
||||
@@ -428,14 +428,23 @@ def get_leave_details(employee, date):
|
||||
leave_allocation = {}
|
||||
for d in allocation_records:
|
||||
allocation = allocation_records.get(d, frappe._dict())
|
||||
|
||||
total_allocated_leaves = frappe.db.get_value('Leave Allocation', {
|
||||
'from_date': ('<=', date),
|
||||
'to_date': ('>=', date),
|
||||
'leave_type': allocation.leave_type,
|
||||
}, 'SUM(total_leaves_allocated)') or 0
|
||||
|
||||
remaining_leaves = get_leave_balance_on(employee, d, date, to_date = allocation.to_date,
|
||||
consider_all_leaves_in_the_allocation_period=True)
|
||||
|
||||
end_date = allocation.to_date
|
||||
leaves_taken = get_leaves_for_period(employee, d, allocation.from_date, end_date) * -1
|
||||
leaves_pending = get_pending_leaves_for_period(employee, d, allocation.from_date, end_date)
|
||||
|
||||
leave_allocation[d] = {
|
||||
"total_leaves": allocation.total_leaves_allocated,
|
||||
"total_leaves": total_allocated_leaves,
|
||||
"expired_leaves": total_allocated_leaves - (remaining_leaves + leaves_taken),
|
||||
"leaves_taken": leaves_taken,
|
||||
"pending_leaves": leaves_pending,
|
||||
"remaining_leaves": remaining_leaves}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
<table class="table table-bordered small">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 20%">{{ __("Leave Type") }}</th>
|
||||
<th style="width: 20%" class="text-right">{{ __("Total Allocated Leaves") }}</th>
|
||||
<th style="width: 20%" class="text-right">{{ __("Used Leaves") }}</th>
|
||||
<th style="width: 20%" class="text-right">{{ __("Pending Leaves") }}</th>
|
||||
<th style="width: 20%" class="text-right">{{ __("Available Leaves") }}</th>
|
||||
<th style="width: 16%">{{ __("Leave Type") }}</th>
|
||||
<th style="width: 16%" class="text-right">{{ __("Total Allocated Leaves") }}</th>
|
||||
<th style="width: 16%" class="text-right">{{ __("Expired Leaves") }}</th>
|
||||
<th style="width: 16%" class="text-right">{{ __("Used Leaves") }}</th>
|
||||
<th style="width: 16%" class="text-right">{{ __("Pending Leaves") }}</th>
|
||||
<th style="width: 16%" class="text-right">{{ __("Available Leaves") }}</th>
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
@@ -17,6 +18,7 @@
|
||||
<tr>
|
||||
<td> {%= key %} </td>
|
||||
<td class="text-right"> {%= value["total_leaves"] %} </td>
|
||||
<td class="text-right"> {%= value["expired_leaves"] %} </td>
|
||||
<td class="text-right"> {%= value["leaves_taken"] %} </td>
|
||||
<td class="text-right"> {%= value["pending_leaves"] %} </td>
|
||||
<td class="text-right"> {%= value["remaining_leaves"] %} </td>
|
||||
|
||||
@@ -20,6 +20,9 @@ def get_template():
|
||||
|
||||
args = frappe.local.form_dict
|
||||
|
||||
if getdate(args.from_date) > getdate(args.to_date):
|
||||
frappe.throw(_("To Date should be greater than From Date"))
|
||||
|
||||
w = UnicodeWriter()
|
||||
w = add_header(w)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import flt
|
||||
from frappe.utils import flt, add_days
|
||||
from erpnext.hr.doctype.leave_application.leave_application \
|
||||
import get_leave_balance_on, get_leaves_for_period
|
||||
|
||||
@@ -26,8 +26,8 @@ def get_columns(leave_types):
|
||||
for leave_type in leave_types:
|
||||
columns.append(_(leave_type) + " " + _("Opening") + ":Float:160")
|
||||
columns.append(_(leave_type) + " " + _("Allocated") + ":Float:160")
|
||||
columns.append(_(leave_type) + " " + _("Expired") + ":Float:160")
|
||||
columns.append(_(leave_type) + " " + _("Taken") + ":Float:160")
|
||||
columns.append(_(leave_type) + " " + _("Expired") + ":Float:160")
|
||||
columns.append(_(leave_type) + " " + _("Balance") + ":Float:160")
|
||||
|
||||
return columns
|
||||
@@ -84,7 +84,7 @@ def calculate_leaves_details(filters, leave_type, employee):
|
||||
# removing expired leaves
|
||||
leaves_taken = leaves_deducted - remove_expired_leave(ledger_entries)
|
||||
|
||||
opening = get_leave_balance_on(employee.name, leave_type, filters.from_date)
|
||||
opening = get_leave_balance_on(employee.name, leave_type, add_days(filters.from_date, -1))
|
||||
|
||||
new_allocation , expired_allocation = get_allocated_and_expired_leaves(ledger_entries, filters.from_date, filters.to_date)
|
||||
|
||||
@@ -94,7 +94,7 @@ def calculate_leaves_details(filters, leave_type, employee):
|
||||
#Formula for calculating closing balance
|
||||
closing = max(opening + new_allocation - (leaves_taken + expired_leaves), 0)
|
||||
|
||||
return [opening, new_allocation, expired_leaves, leaves_taken, closing]
|
||||
return [opening, new_allocation, leaves_taken, expired_leaves, closing]
|
||||
|
||||
|
||||
def remove_expired_leave(records):
|
||||
@@ -113,7 +113,7 @@ def get_allocated_and_expired_leaves(records, from_date, to_date):
|
||||
expired_leaves = 0
|
||||
|
||||
for record in records:
|
||||
if record.to_date <= getdate(to_date) and record.leaves>0:
|
||||
if record.to_date < getdate(to_date) and record.leaves>0:
|
||||
expired_leaves += record.leaves
|
||||
|
||||
if record.from_date >= getdate(from_date) and record.leaves>0:
|
||||
|
||||
@@ -45,16 +45,16 @@ def get_columns():
|
||||
'fieldtype': 'Float',
|
||||
'fieldname': 'new_allocation',
|
||||
'width': 120,
|
||||
}, {
|
||||
'label': _('Expired Leaves'),
|
||||
'fieldtype': 'Float',
|
||||
'fieldname': 'expired_leaves',
|
||||
'width': 120,
|
||||
}, {
|
||||
'label': _('Leaves Taken'),
|
||||
'fieldtype': 'float',
|
||||
'fieldname': 'leaves_taken',
|
||||
'width': 120,
|
||||
}, {
|
||||
'label': _('Expired Leaves'),
|
||||
'fieldtype': 'Float',
|
||||
'fieldname': 'expired_leaves',
|
||||
'width': 120,
|
||||
}, {
|
||||
'label': _('Closing Balance'),
|
||||
'fieldtype': 'float',
|
||||
@@ -96,8 +96,8 @@ def get_data(filters):
|
||||
leave_details = calculate_leaves_details(filters, leave_type, employee)
|
||||
row.opening_balance = flt(leave_details[0])
|
||||
row.new_allocation = flt(leave_details[1])
|
||||
row.expired_leaves = flt(leave_details[2])
|
||||
row.leaves_taken = flt(leave_details[3])
|
||||
row.leaves_taken = flt(leave_details[2])
|
||||
row.expired_leaves = flt(leave_details[3])
|
||||
row.closing_balance = flt(leave_details[4])
|
||||
|
||||
data.append(row)
|
||||
|
||||
Reference in New Issue
Block a user