fix: Expense claim paid through employee advance getting fetched as outstanding in Payment Entry (#19427)

* fix: Expense claim paid through employee advance getting fetched as outstanding in Payment Entry

* fix: Codacy

* fix: Minor UX fixes

* fix: Also credit payable amount in case of advance payment

* fix: Against voucher in GL enrty
This commit is contained in:
Deepesh Garg
2019-11-12 14:32:50 +05:30
committed by Nabin Hait
parent 2689acfc8e
commit 3cc3b57926
4 changed files with 464 additions and 439 deletions

View File

@@ -554,7 +554,7 @@ frappe.ui.form.on('Payment Entry', {
frappe.flags.allocate_payment_amount = true; frappe.flags.allocate_payment_amount = true;
frm.events.validate_filters_data(frm, filters); frm.events.validate_filters_data(frm, filters);
frm.events.get_outstanding_documents(frm, filters); frm.events.get_outstanding_documents(frm, filters);
}, __("Filters"), __("Get Outstanding Invoices")); }, __("Filters"), __("Get Outstanding Documents"));
}, },
validate_filters_data: function(frm, filters) { validate_filters_data: function(frm, filters) {

View File

@@ -21,7 +21,7 @@ def get_data():
}, },
{ {
'label': _('Expense'), 'label': _('Expense'),
'items': ['Expense Claim', 'Travel Request'] 'items': ['Expense Claim', 'Travel Request', 'Employee Advance']
}, },
{ {
'label': _('Benefit'), 'label': _('Benefit'),

View File

@@ -262,7 +262,8 @@
"fieldname": "payable_account", "fieldname": "payable_account",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Payable Account", "label": "Payable Account",
"options": "Account" "options": "Account",
"reqd": 1
}, },
{ {
"fieldname": "cost_center", "fieldname": "cost_center",
@@ -365,7 +366,7 @@
"icon": "fa fa-money", "icon": "fa fa-money",
"idx": 1, "idx": 1,
"is_submittable": 1, "is_submittable": 1,
"modified": "2019-06-26 18:05:52.530462", "modified": "2019-11-08 14:13:08.964547",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Expense Claim", "name": "Expense Claim",
@@ -432,4 +433,4 @@
"sort_order": "DESC", "sort_order": "DESC",
"timeline_field": "employee", "timeline_field": "employee",
"title_field": "title" "title_field": "title"
} }

View File

@@ -144,6 +144,33 @@ class ExpenseClaim(AccountsController):
"against_voucher": self.name "against_voucher": self.name
}) })
) )
gl_entry.append(
self.get_gl_dict({
"account": data.advance_account,
"debit": data.allocated_amount,
"debit_in_account_currency": data.allocated_amount,
"against": self.payable_account,
"party_type": "Employee",
"party": self.employee,
"against_voucher_type": self.doctype,
"against_voucher": self.name
})
)
gl_entry.append(
self.get_gl_dict({
"account": self.payable_account,
"credit": data.allocated_amount,
"credit_in_account_currency": data.allocated_amount,
"against": data.advance_account,
"party_type": "Employee",
"party": self.employee,
"against_voucher_type": "Employee Advance",
"against_voucher": data.employee_advance
})
)
self.add_tax_gl_entries(gl_entry) self.add_tax_gl_entries(gl_entry)
if self.is_paid and self.grand_total: if self.is_paid and self.grand_total:
@@ -192,9 +219,6 @@ class ExpenseClaim(AccountsController):
if not self.cost_center: if not self.cost_center:
frappe.throw(_("Cost center is required to book an expense claim")) frappe.throw(_("Cost center is required to book an expense claim"))
if not self.payable_account:
frappe.throw(_("Please set default payable account for the company {0}").format(getlink("Company",self.company)))
if self.is_paid: if self.is_paid:
if not self.mode_of_payment: if not self.mode_of_payment:
frappe.throw(_("Mode of payment is required to make a payment").format(self.employee)) frappe.throw(_("Mode of payment is required to make a payment").format(self.employee))