feat: change the claim amount in expenses to amount
This commit is contained in:
parent
ac9a4fe03c
commit
444313bdfc
@ -97,7 +97,7 @@ def get_expenses():
|
|||||||
"expense_date": frappe.flags.current_date,
|
"expense_date": frappe.flags.current_date,
|
||||||
"expense_type": expense_type.name,
|
"expense_type": expense_type.name,
|
||||||
"default_account": expense_type.default_account or "Miscellaneous Expenses - WPL",
|
"default_account": expense_type.default_account or "Miscellaneous Expenses - WPL",
|
||||||
"claim_amount": claim_amount,
|
"amount": claim_amount,
|
||||||
"sanctioned_amount": claim_amount
|
"sanctioned_amount": claim_amount
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ def update_sanctioned_amount(expense_claim):
|
|||||||
for expense in expense_claim.expenses:
|
for expense in expense_claim.expenses:
|
||||||
sanctioned_amount = random.randint(1,20)*10
|
sanctioned_amount = random.randint(1,20)*10
|
||||||
|
|
||||||
if sanctioned_amount < expense.claim_amount:
|
if sanctioned_amount < expense.amount:
|
||||||
expense.sanctioned_amount = sanctioned_amount
|
expense.sanctioned_amount = sanctioned_amount
|
||||||
|
|
||||||
def get_timesheet_based_salary_slip_employee():
|
def get_timesheet_based_salary_slip_employee():
|
||||||
|
|||||||
@ -109,7 +109,7 @@ cur_frm.cscript.calculate_total = function(doc){
|
|||||||
doc.total_claimed_amount = 0;
|
doc.total_claimed_amount = 0;
|
||||||
doc.total_sanctioned_amount = 0;
|
doc.total_sanctioned_amount = 0;
|
||||||
$.each((doc.expenses || []), function(i, d) {
|
$.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;
|
doc.total_sanctioned_amount += d.sanctioned_amount;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -308,10 +308,10 @@ frappe.ui.form.on("Expense Claim", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on("Expense Claim Detail", {
|
frappe.ui.form.on("Expense Claim Detail", {
|
||||||
claim_amount: function(frm, cdt, cdn) {
|
amount: function(frm, cdt, cdn) {
|
||||||
var child = locals[cdt][cdn];
|
var child = locals[cdt][cdn];
|
||||||
var doc = frm.doc;
|
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);
|
cur_frm.cscript.calculate_total(doc,cdt,cdn);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -13,20 +13,21 @@
|
|||||||
"column_break_5",
|
"column_break_5",
|
||||||
"expense_approver",
|
"expense_approver",
|
||||||
"approval_status",
|
"approval_status",
|
||||||
"total_claimed_amount",
|
|
||||||
"total_sanctioned_amount",
|
|
||||||
"is_paid",
|
"is_paid",
|
||||||
"expense_details",
|
"expense_details",
|
||||||
"expenses",
|
"expenses",
|
||||||
"sb1",
|
"sb1",
|
||||||
"taxes",
|
"taxes",
|
||||||
"net_total",
|
"transactions_section",
|
||||||
|
"total_tax_amount",
|
||||||
|
"total_amount_reimbursed",
|
||||||
|
"total_sanctioned_amount",
|
||||||
|
"total_claimed_amount",
|
||||||
"section_break_16",
|
"section_break_16",
|
||||||
"posting_date",
|
"posting_date",
|
||||||
"vehicle_log",
|
"vehicle_log",
|
||||||
"task",
|
"task",
|
||||||
"cb1",
|
"cb1",
|
||||||
"total_amount_reimbursed",
|
|
||||||
"remark",
|
"remark",
|
||||||
"title",
|
"title",
|
||||||
"email_id",
|
"email_id",
|
||||||
@ -331,16 +332,22 @@
|
|||||||
"fieldtype": "Section Break"
|
"fieldtype": "Section Break"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "net_total",
|
"fieldname": "transactions_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Transactions"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_tax_amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Net Total",
|
"label": "Total Tax Amount",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-money",
|
"icon": "fa fa-money",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2019-06-11 13:21:42.386420",
|
"modified": "2019-06-12 12:32:13.775009",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Expense Claim",
|
"name": "Expense Claim",
|
||||||
|
|||||||
@ -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
|
return gl_entry
|
||||||
|
|
||||||
def make_tax_gl_entries(self, gl_entries):
|
def add_tax_gl_entries(self, gl_entries):
|
||||||
# tax table gl entries
|
# tax table gl entries
|
||||||
for tax in self.get("taxes"):
|
for tax in self.get("taxes"):
|
||||||
account_currency = get_account_currency(tax.account_head)
|
account_currency = get_account_currency(tax.account_head)
|
||||||
@ -190,7 +190,6 @@ class ExpenseClaim(AccountsController):
|
|||||||
"against_voucher": self.name
|
"against_voucher": self.name
|
||||||
}, account_currency)
|
}, account_currency)
|
||||||
)
|
)
|
||||||
return gl_entries
|
|
||||||
|
|
||||||
def validate_account_details(self):
|
def validate_account_details(self):
|
||||||
if not self.cost_center:
|
if not self.cost_center:
|
||||||
@ -210,7 +209,7 @@ class ExpenseClaim(AccountsController):
|
|||||||
if self.approval_status == 'Rejected':
|
if self.approval_status == 'Rejected':
|
||||||
d.sanctioned_amount = 0.0
|
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)
|
self.total_sanctioned_amount += flt(d.sanctioned_amount)
|
||||||
|
|
||||||
def calculate_taxes(self):
|
def calculate_taxes(self):
|
||||||
@ -253,7 +252,7 @@ class ExpenseClaim(AccountsController):
|
|||||||
|
|
||||||
def validate_sanctioned_amount(self):
|
def validate_sanctioned_amount(self):
|
||||||
for d in self.get('expenses'):
|
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))
|
frappe.throw(_("Sanctioned Amount cannot be greater than Claim Amount in Row {0}.").format(d.idx))
|
||||||
|
|
||||||
def set_expense_account(self, validate=False):
|
def set_expense_account(self, validate=False):
|
||||||
|
|||||||
@ -17,7 +17,7 @@ QUnit.test("Test: Expense Claim [HR]", function (assert) {
|
|||||||
d.expense_date = '2017-08-01',
|
d.expense_date = '2017-08-01',
|
||||||
d.expense_type = 'Test Expense Type 1',
|
d.expense_type = 'Test Expense Type 1',
|
||||||
d.description = 'This is just to test Expense Claim',
|
d.description = 'This is just to test Expense Claim',
|
||||||
d.claim_amount = 2000,
|
d.amount = 2000,
|
||||||
d.sanctioned_amount=2000,
|
d.sanctioned_amount=2000,
|
||||||
refresh_field('expenses');
|
refresh_field('expenses');
|
||||||
},
|
},
|
||||||
|
|||||||
@ -89,7 +89,7 @@ class TestExpenseClaim(unittest.TestCase):
|
|||||||
"payable_account": payable_account,
|
"payable_account": payable_account,
|
||||||
"approval_status": "Rejected",
|
"approval_status": "Rejected",
|
||||||
"expenses":
|
"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()
|
expense_claim.submit()
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ class TestExpenseClaim(unittest.TestCase):
|
|||||||
def get_payable_account(company):
|
def get_payable_account(company):
|
||||||
return frappe.get_cached_value('Company', company, 'default_payable_account')
|
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({
|
expense_claim = frappe.get_doc({
|
||||||
"doctype": "Expense Claim",
|
"doctype": "Expense Claim",
|
||||||
"employee": "_T-Employee-00001",
|
"employee": "_T-Employee-00001",
|
||||||
@ -110,7 +110,7 @@ def make_expense_claim(payable_account,claim_amount, sanctioned_amount, company,
|
|||||||
"approval_status": "Approved",
|
"approval_status": "Approved",
|
||||||
"company": company,
|
"company": company,
|
||||||
"expenses":
|
"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:
|
if project:
|
||||||
expense_claim.project = project
|
expense_claim.project = project
|
||||||
|
|||||||
@ -253,7 +253,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "claim_amount",
|
"fieldname": "amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@ -262,7 +262,7 @@
|
|||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Claim Amount",
|
"label": "Amount",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"oldfieldname": "claim_amount",
|
"oldfieldname": "claim_amount",
|
||||||
@ -360,7 +360,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2019-02-24 08:41:36.122565",
|
"modified": "2019-06-10 08:41:36.122565",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Expense Claim Detail",
|
"name": "Expense Claim Detail",
|
||||||
|
|||||||
@ -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 (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):
|
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"))
|
frappe.throw(_("Service Item,Type,frequency and expense amount are required"))
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
frappe.db.sql("update `tabVehicle` set last_odometer=%s where license_plate=%s",
|
frappe.db.sql("update `tabVehicle` set last_odometer=%s where license_plate=%s",
|
||||||
(self.odometer, self.license_plate))
|
(self.odometer, self.license_plate))
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_make_model(license_plate):
|
def get_make_model(license_plate):
|
||||||
vehicle=frappe.get_doc("Vehicle",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:
|
for serdetail in vehicle_log.service_detail:
|
||||||
total_exp_amt = total_exp_amt + serdetail.expense_amount
|
total_exp_amt = total_exp_amt + serdetail.expense_amount
|
||||||
return total_exp_amt
|
return total_exp_amt
|
||||||
|
|
||||||
vehicle_log = frappe.get_doc("Vehicle Log", docname)
|
vehicle_log = frappe.get_doc("Vehicle Log", docname)
|
||||||
exp_claim = frappe.new_doc("Expense Claim")
|
exp_claim = frappe.new_doc("Expense Claim")
|
||||||
exp_claim.employee=vehicle_log.employee
|
exp_claim.employee=vehicle_log.employee
|
||||||
@ -52,6 +52,6 @@ def make_expense_claim(docname):
|
|||||||
exp_claim.append("expenses",{
|
exp_claim.append("expenses",{
|
||||||
"expense_date":vehicle_log.date,
|
"expense_date":vehicle_log.date,
|
||||||
"description":_("Vehicle Expenses"),
|
"description":_("Vehicle Expenses"),
|
||||||
"claim_amount":total_claim_amt
|
"amount":total_claim_amt
|
||||||
})
|
})
|
||||||
return exp_claim.as_dict()
|
return exp_claim.as_dict()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user