[Fix] Employee advance issues (#14750)

This commit is contained in:
rohitwaghchaure 2018-07-01 16:48:00 +05:30 committed by Nabin Hait
parent f02bef78f0
commit afe764264d
2 changed files with 11 additions and 2 deletions

View File

@ -19,6 +19,7 @@ frappe.ui.form.on('Employee Advance', {
filters: {
"root_type": "Asset",
"is_group": 0,
"account_type": "Payable",
"company": frm.doc.company
}
};

View File

@ -3,7 +3,7 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
import frappe, erpnext
from frappe import _
from frappe.model.document import Document
from frappe.utils import flt, nowdate
@ -18,6 +18,7 @@ class EmployeeAdvance(Document):
def validate(self):
self.set_status()
self.validate_employee_advance_account()
def on_cancel(self):
self.set_status()
@ -35,6 +36,13 @@ class EmployeeAdvance(Document):
elif self.docstatus == 2:
self.status = "Cancelled"
def validate_employee_advance_account(self):
company_currency = erpnext.get_company_currency(self.company)
if (self.advance_account and
company_currency != frappe.db.get_value('Account', self.advance_account, 'account_currency')):
frappe.throw(_("Advance account currency should be same as company curreny {0}")
.format(company_currency))
def set_total_advance_paid(self):
paid_amount = frappe.db.sql("""
select ifnull(sum(debit_in_account_currency), 0) as paid_amount
@ -61,7 +69,7 @@ class EmployeeAdvance(Document):
where employee_advance = %s and docstatus=1 and allocated_amount > 0
""", self.name)[0][0]
frappe.db.set_value("Employee Advance", self.name, "claimed_ amount", claimed_amount)
frappe.db.set_value("Employee Advance", self.name, "claimed_amount", claimed_amount)
@frappe.whitelist()
def get_due_advance_amount(employee, posting_date):