feat: Repay advance from salary
This commit is contained in:
parent
6dc335d898
commit
59a0bce3a9
@ -23,6 +23,14 @@ frappe.ui.form.on('Employee Advance', {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query('salary_component', function(doc) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
"type": "Deduction"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
@ -47,19 +55,33 @@ frappe.ui.form.on('Employee Advance', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (frm.doc.docstatus === 1
|
if (frm.doc.docstatus === 1
|
||||||
&& (flt(frm.doc.claimed_amount) + flt(frm.doc.return_amount) < flt(frm.doc.paid_amount))
|
&& (flt(frm.doc.claimed_amount) < flt(frm.doc.paid_amount) && flt(frm.doc.paid_amount) != flt(frm.doc.return_amount))) {
|
||||||
&& frappe.model.can_create("Journal Entry")) {
|
|
||||||
|
|
||||||
|
if (frm.doc.repay_unclaimed_amount_from_salary == 0 && frappe.model.can_create("Journal Entry")){
|
||||||
frm.add_custom_button(__("Return"), function() {
|
frm.add_custom_button(__("Return"), function() {
|
||||||
frm.trigger('make_return_entry');
|
frm.trigger('make_return_entry');
|
||||||
}, __('Create'));
|
}, __('Create'));
|
||||||
|
}else if (frm.doc.repay_unclaimed_amount_from_salary == 1 && frappe.model.can_create("Additional Salary")){
|
||||||
|
frm.add_custom_button(__("Deduction from salary"), function() {
|
||||||
|
frm.events.make_deduction_via_additional_salary(frm)
|
||||||
|
}, __('Create'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
make_deduction_via_additional_salary: function(frm){
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.hr.doctype.employee_advance.employee_advance.create_return_through_additional_salary",
|
||||||
|
args: {
|
||||||
|
doc: frm.doc
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
make_payment_entry: function(frm) {
|
make_payment_entry: function(frm) {
|
||||||
var method = "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry";
|
var method = "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry";
|
||||||
if(frm.doc.__onload && frm.doc.__onload.make_payment_via_journal_entry) {
|
if(frm.doc.__onload && frm.doc.__onload.make_payment_via_journal_entry) {
|
||||||
method = "erpnext.hr.doctype.employee_advance.employee_advance.make_bank_entry"
|
method = "erpnext.hr.doctype.employee_advance.employee_advance.make_bank_entry";
|
||||||
}
|
}
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: method,
|
method: method,
|
||||||
|
@ -10,9 +10,12 @@
|
|||||||
"naming_series",
|
"naming_series",
|
||||||
"employee",
|
"employee",
|
||||||
"employee_name",
|
"employee_name",
|
||||||
|
"department",
|
||||||
"column_break_4",
|
"column_break_4",
|
||||||
"posting_date",
|
"posting_date",
|
||||||
"department",
|
"repay_unclaimed_amount_from_salary",
|
||||||
|
"payroll_date",
|
||||||
|
"salary_component",
|
||||||
"section_break_8",
|
"section_break_8",
|
||||||
"purpose",
|
"purpose",
|
||||||
"column_break_11",
|
"column_break_11",
|
||||||
@ -169,11 +172,30 @@
|
|||||||
"label": "Returned Amount",
|
"label": "Returned Amount",
|
||||||
"options": "Company:company:default_currency",
|
"options": "Company:company:default_currency",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "repay_unclaimed_amount_from_salary",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Repay unclaimed amount from salary"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.repay_unclaimed_amount_from_salary == 1",
|
||||||
|
"fieldname": "payroll_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Payroll date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.repay_unclaimed_amount_from_salary == 1",
|
||||||
|
"fieldname": "salary_component",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Salary Component",
|
||||||
|
"options": "Salary Component"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2019-12-15 19:04:07.044505",
|
"modified": "2020-01-03 13:02:32.094099",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Employee Advance",
|
"name": "Employee Advance",
|
||||||
|
@ -133,8 +133,24 @@ def make_bank_entry(dt, dn):
|
|||||||
return je.as_dict()
|
return je.as_dict()
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_return_entry(employee, company, employee_advance_name,
|
def create_return_through_additional_salary(doc):
|
||||||
return_amount, advance_account, mode_of_payment=None):
|
import json
|
||||||
|
doc = frappe._dict(json.loads(doc))
|
||||||
|
additional_salary = frappe.new_doc('Additional Salary')
|
||||||
|
additional_salary.employee = doc.employee
|
||||||
|
additional_salary.salary_component = doc.salary_component
|
||||||
|
additional_salary.amount = doc.paid_amount - doc.claimed_amount
|
||||||
|
additional_salary.payroll_date = doc.payroll_date
|
||||||
|
additional_salary.company = doc.company
|
||||||
|
|
||||||
|
additional_salary.submit()
|
||||||
|
|
||||||
|
frappe.db.set_value("Employee Advance", doc.name, "return_amount", additional_salary.amount)
|
||||||
|
|
||||||
|
return additional_salary.name
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def make_return_entry(employee_name, company, employee_advance_name, return_amount, mode_of_payment, advance_account):
|
||||||
return_account = get_default_bank_cash_account(company, account_type='Cash', mode_of_payment = mode_of_payment)
|
return_account = get_default_bank_cash_account(company, account_type='Cash', mode_of_payment = mode_of_payment)
|
||||||
je = frappe.new_doc('Journal Entry')
|
je = frappe.new_doc('Journal Entry')
|
||||||
je.posting_date = nowdate()
|
je.posting_date = nowdate()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user