New feature for issue #2419
This commit is contained in:
parent
a94478a618
commit
f13c4f0145
@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cstr, flt, fmt_money, formatdate, getdate
|
||||
from frappe.utils import cstr, flt, fmt_money, formatdate, getdate, cint
|
||||
from frappe import msgprint, _, scrub
|
||||
from erpnext.setup.utils import get_company_currency
|
||||
from erpnext.controllers.accounts_controller import AccountsController
|
||||
@ -37,11 +37,13 @@ class JournalVoucher(AccountsController):
|
||||
self.validate_against_sales_order()
|
||||
self.validate_against_purchase_order()
|
||||
self.check_credit_days()
|
||||
self.validate_expense_claim()
|
||||
|
||||
def on_submit(self):
|
||||
self.check_credit_limit()
|
||||
self.make_gl_entries()
|
||||
self.update_advance_paid()
|
||||
self.update_expense_claim()
|
||||
|
||||
def update_advance_paid(self):
|
||||
advance_paid = frappe._dict()
|
||||
@ -62,6 +64,7 @@ class JournalVoucher(AccountsController):
|
||||
|
||||
self.make_gl_entries(1)
|
||||
self.update_advance_paid()
|
||||
self.update_expense_claim()
|
||||
|
||||
def validate_party(self):
|
||||
for d in self.get("entries"):
|
||||
@ -421,6 +424,22 @@ class JournalVoucher(AccountsController):
|
||||
from `tabPurchase Invoice` where docstatus = 1 and company = %s
|
||||
and outstanding_amount > 0 %s""" % ('%s', cond), self.company, as_dict=True)
|
||||
|
||||
def update_expense_claim(self):
|
||||
for d in self.entries:
|
||||
if d.against_expense_claim:
|
||||
amt = frappe.db.sql("""select sum(debit) as amt from `tabJournal Voucher Detail`
|
||||
where against_expense_claim = %s and docstatus = 1""", d.against_expense_claim ,as_dict=1)[0].amt
|
||||
frappe.db.sql("update `tabExpense Claim` set total_amount_reimbursed = %s where name = %s",(amt, d.against_expense_claim))
|
||||
|
||||
def validate_expense_claim(self):
|
||||
for d in self.entries:
|
||||
if d.against_expense_claim:
|
||||
sanctioned_amount = cint(frappe.db.get_value("Expense Claim", d.against_expense_claim, "total_sanctioned_amount"))
|
||||
reimbursed_amount = cint(frappe.db.get_value("Expense Claim", d.against_expense_claim, "total_amount_reimbursed"))
|
||||
pending_amount = sanctioned_amount - reimbursed_amount
|
||||
if d.debit > pending_amount:
|
||||
frappe.throw("Amount cannot be greater than Expense Claim")
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_default_bank_cash_account(company, voucher_type):
|
||||
account = frappe.db.get_value("Company", company,
|
||||
|
@ -173,6 +173,14 @@
|
||||
"options": "Purchase Order",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "against_expense_claim",
|
||||
"fieldtype": "Link",
|
||||
"label": "Against Expense Claim",
|
||||
"options": "Expense Claim",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "is_advance",
|
||||
"fieldtype": "Select",
|
||||
@ -198,7 +206,7 @@
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"modified": "2014-09-17 13:02:42.012069",
|
||||
"modified": "2014-12-08 19:32:47.996777",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Journal Voucher Detail",
|
||||
|
@ -89,7 +89,7 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
if(doc.docstatus==0 && doc.exp_approver==user && doc.approval_status=="Approved")
|
||||
cur_frm.savesubmit();
|
||||
|
||||
if(doc.docstatus==1 && frappe.model.can_create("Journal Voucher"))
|
||||
if(doc.docstatus==1 && frappe.model.can_create("Journal Voucher") && doc.total_amount_reimbursed < doc.total_sanctioned_amount)
|
||||
cur_frm.add_custom_button(__("Make Bank Voucher"),
|
||||
cur_frm.cscript.make_bank_voucher, frappe.boot.doctype_icons["Journal Voucher"]);
|
||||
}
|
||||
@ -109,6 +109,9 @@ cur_frm.cscript.set_help = function(doc) {
|
||||
} else {
|
||||
if(doc.approval_status=="Approved") {
|
||||
cur_frm.set_intro(__("Expense Claim has been approved."));
|
||||
if(doc.total_amount_reimbursed== doc.total_sanctioned_amount){
|
||||
cur_frm.set_intro(__("Expense Claim has been reimbursed."));
|
||||
}
|
||||
} else if(doc.approval_status=="Rejected") {
|
||||
cur_frm.set_intro(__("Expense Claim has been rejected."));
|
||||
}
|
||||
|
@ -163,6 +163,16 @@
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "total_amount_reimbursed",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Total Amount Reimbursed",
|
||||
"no_copy": 1,
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"fieldname": "remark",
|
||||
@ -202,7 +212,7 @@
|
||||
"icon": "icon-money",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2014-11-24 18:25:53.038826",
|
||||
"modified": "2014-12-09 11:52:32.196383",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Expense Claim",
|
||||
|
@ -14,6 +14,11 @@
|
||||
{%= doc.approval_status %}
|
||||
</span>
|
||||
|
||||
{% if(doc.total_amount_reimbursed== doc.total_sanctioned_amount && doc.docstatus== 1) { %}
|
||||
<span class="label label-success">
|
||||
"Reimbursed"
|
||||
</span>
|
||||
{% } %}
|
||||
</div>
|
||||
</div>
|
||||
<!-- sample graph -->
|
||||
|
@ -1,4 +1,5 @@
|
||||
frappe.listview_settings['Expense Claim'] = {
|
||||
add_fields: ["approval_status", "employee", "employee_name", "total_claimed_amount"],
|
||||
add_fields: ["approval_status", "employee", "employee_name",
|
||||
"total_claimed_amount", "total_amount_reimbursed", "total_sanctioned_amount", "docstatus"],
|
||||
filters:[["approval_status","!=", "Rejected"]]
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user