diff --git a/erpnext/demo/user/hr.py b/erpnext/demo/user/hr.py index 79f3c192878..0211bc8a90a 100644 --- a/erpnext/demo/user/hr.py +++ b/erpnext/demo/user/hr.py @@ -97,7 +97,7 @@ def get_expenses(): "expense_date": frappe.flags.current_date, "expense_type": expense_type.name, "default_account": expense_type.default_account or "Miscellaneous Expenses - WPL", - "claim_amount": claim_amount, + "amount": claim_amount, "sanctioned_amount": claim_amount }) @@ -107,7 +107,7 @@ def update_sanctioned_amount(expense_claim): for expense in expense_claim.expenses: sanctioned_amount = random.randint(1,20)*10 - if sanctioned_amount < expense.claim_amount: + if sanctioned_amount < expense.amount: expense.sanctioned_amount = sanctioned_amount def get_timesheet_based_salary_slip_employee(): diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js index 0ff70cb6805..6425b95d7e7 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim.js @@ -109,7 +109,7 @@ cur_frm.cscript.calculate_total = function(doc){ doc.total_claimed_amount = 0; doc.total_sanctioned_amount = 0; $.each((doc.expenses || []), function(i, d) { - doc.total_claimed_amount += d.claim_amount; + doc.total_claimed_amount += d.amount; doc.total_sanctioned_amount += d.sanctioned_amount; }); @@ -308,10 +308,10 @@ frappe.ui.form.on("Expense Claim", { }); frappe.ui.form.on("Expense Claim Detail", { - claim_amount: function(frm, cdt, cdn) { + amount: function(frm, cdt, cdn) { var child = locals[cdt][cdn]; var doc = frm.doc; - frappe.model.set_value(cdt, cdn, 'sanctioned_amount', child.claim_amount); + frappe.model.set_value(cdt, cdn, 'sanctioned_amount', child.amount); cur_frm.cscript.calculate_total(doc,cdt,cdn); }, diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.json b/erpnext/hr/doctype/expense_claim/expense_claim.json index 007e6468150..409bdc8615a 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.json +++ b/erpnext/hr/doctype/expense_claim/expense_claim.json @@ -13,20 +13,21 @@ "column_break_5", "expense_approver", "approval_status", - "total_claimed_amount", - "total_sanctioned_amount", "is_paid", "expense_details", "expenses", "sb1", "taxes", - "net_total", + "transactions_section", + "total_tax_amount", + "total_amount_reimbursed", + "total_sanctioned_amount", + "total_claimed_amount", "section_break_16", "posting_date", "vehicle_log", "task", "cb1", - "total_amount_reimbursed", "remark", "title", "email_id", @@ -331,16 +332,22 @@ "fieldtype": "Section Break" }, { - "fieldname": "net_total", + "fieldname": "transactions_section", + "fieldtype": "Section Break", + "label": "Transactions" + }, + { + "fieldname": "total_tax_amount", "fieldtype": "Currency", - "label": "Net Total", + "label": "Total Tax Amount", + "options": "Company:company:default_currency", "read_only": 1 } ], "icon": "fa fa-money", "idx": 1, "is_submittable": 1, - "modified": "2019-06-11 13:21:42.386420", + "modified": "2019-06-12 12:32:13.775009", "modified_by": "Administrator", "module": "HR", "name": "Expense Claim", diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py index c5b6ebe56b4..07e711939c9 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/expense_claim.py @@ -172,11 +172,11 @@ class ExpenseClaim(AccountsController): }) ) - gl_entry = self.make_tax_gl_entries(gl_entry) + self.add_tax_gl_entries(gl_entry) return gl_entry - def make_tax_gl_entries(self, gl_entries): + def add_tax_gl_entries(self, gl_entries): # tax table gl entries for tax in self.get("taxes"): account_currency = get_account_currency(tax.account_head) @@ -190,7 +190,6 @@ class ExpenseClaim(AccountsController): "against_voucher": self.name }, account_currency) ) - return gl_entries def validate_account_details(self): if not self.cost_center: @@ -210,7 +209,7 @@ class ExpenseClaim(AccountsController): if self.approval_status == 'Rejected': d.sanctioned_amount = 0.0 - self.total_claimed_amount += flt(d.claim_amount) + self.total_claimed_amount += flt(d.amount) self.total_sanctioned_amount += flt(d.sanctioned_amount) def calculate_taxes(self): @@ -253,7 +252,7 @@ class ExpenseClaim(AccountsController): def validate_sanctioned_amount(self): for d in self.get('expenses'): - if flt(d.sanctioned_amount) > flt(d.claim_amount): + if flt(d.sanctioned_amount) > flt(d.amount): frappe.throw(_("Sanctioned Amount cannot be greater than Claim Amount in Row {0}.").format(d.idx)) def set_expense_account(self, validate=False): diff --git a/erpnext/hr/doctype/expense_claim/test_expense_claim.js b/erpnext/hr/doctype/expense_claim/test_expense_claim.js index 070474e10f4..d0c43d3be47 100644 --- a/erpnext/hr/doctype/expense_claim/test_expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.js @@ -17,7 +17,7 @@ QUnit.test("Test: Expense Claim [HR]", function (assert) { d.expense_date = '2017-08-01', d.expense_type = 'Test Expense Type 1', d.description = 'This is just to test Expense Claim', - d.claim_amount = 2000, + d.amount = 2000, d.sanctioned_amount=2000, refresh_field('expenses'); }, diff --git a/erpnext/hr/doctype/expense_claim/test_expense_claim.py b/erpnext/hr/doctype/expense_claim/test_expense_claim.py index 075bc63345d..6fc2a83ebd8 100644 --- a/erpnext/hr/doctype/expense_claim/test_expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.py @@ -89,7 +89,7 @@ class TestExpenseClaim(unittest.TestCase): "payable_account": payable_account, "approval_status": "Rejected", "expenses": - [{ "expense_type": "Travel", "default_account": "Travel Expenses - WP", "claim_amount": 300, "sanctioned_amount": 200 }] + [{ "expense_type": "Travel", "default_account": "Travel Expenses - WP", "amount": 300, "sanctioned_amount": 200 }] }) expense_claim.submit() @@ -102,7 +102,7 @@ class TestExpenseClaim(unittest.TestCase): def get_payable_account(company): return frappe.get_cached_value('Company', company, 'default_payable_account') -def make_expense_claim(payable_account,claim_amount, sanctioned_amount, company, account, project=None, task_name=None): +def make_expense_claim(payable_account,amount, sanctioned_amount, company, account, project=None, task_name=None): expense_claim = frappe.get_doc({ "doctype": "Expense Claim", "employee": "_T-Employee-00001", @@ -110,7 +110,7 @@ def make_expense_claim(payable_account,claim_amount, sanctioned_amount, company, "approval_status": "Approved", "company": company, "expenses": - [{ "expense_type": "Travel", "default_account": account, "claim_amount": claim_amount, "sanctioned_amount": sanctioned_amount }] + [{ "expense_type": "Travel", "default_account": account, "amount": amount, "sanctioned_amount": sanctioned_amount }] }) if project: expense_claim.project = project diff --git a/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json b/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json index d4e70575e91..b23fb6af0fe 100644 --- a/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json +++ b/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.json @@ -253,7 +253,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "claim_amount", + "fieldname": "amount", "fieldtype": "Currency", "hidden": 0, "ignore_user_permissions": 0, @@ -262,7 +262,7 @@ "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 0, - "label": "Claim Amount", + "label": "Amount", "length": 0, "no_copy": 0, "oldfieldname": "claim_amount", @@ -360,7 +360,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2019-02-24 08:41:36.122565", + "modified": "2019-06-10 08:41:36.122565", "modified_by": "Administrator", "module": "HR", "name": "Expense Claim Detail", diff --git a/erpnext/hr/doctype/vehicle_log/vehicle_log.py b/erpnext/hr/doctype/vehicle_log/vehicle_log.py index ceea4933f36..df633611be8 100644 --- a/erpnext/hr/doctype/vehicle_log/vehicle_log.py +++ b/erpnext/hr/doctype/vehicle_log/vehicle_log.py @@ -18,11 +18,11 @@ class VehicleLog(Document): if (service_detail.service_item or service_detail.type or service_detail.frequency or service_detail.expense_amount): if not (service_detail.service_item and service_detail.type and service_detail.frequency and service_detail.expense_amount): frappe.throw(_("Service Item,Type,frequency and expense amount are required")) - + def on_submit(self): frappe.db.sql("update `tabVehicle` set last_odometer=%s where license_plate=%s", (self.odometer, self.license_plate)) - + @frappe.whitelist() def get_make_model(license_plate): vehicle=frappe.get_doc("Vehicle",license_plate) @@ -41,7 +41,7 @@ def make_expense_claim(docname): for serdetail in vehicle_log.service_detail: total_exp_amt = total_exp_amt + serdetail.expense_amount return total_exp_amt - + vehicle_log = frappe.get_doc("Vehicle Log", docname) exp_claim = frappe.new_doc("Expense Claim") exp_claim.employee=vehicle_log.employee @@ -52,6 +52,6 @@ def make_expense_claim(docname): exp_claim.append("expenses",{ "expense_date":vehicle_log.date, "description":_("Vehicle Expenses"), - "claim_amount":total_claim_amt + "amount":total_claim_amt }) return exp_claim.as_dict()