mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
fix: Fixed expense claim payment status
This commit is contained in:
@@ -108,7 +108,7 @@ def build_forest(data):
|
|||||||
error_messages = []
|
error_messages = []
|
||||||
|
|
||||||
for i in data:
|
for i in data:
|
||||||
account_name, _, account_number, is_group, account_type, root_type = i
|
account_name, __, account_number, is_group, account_type, root_type = i
|
||||||
|
|
||||||
if not account_name:
|
if not account_name:
|
||||||
error_messages.append("Row {0}: Please enter Account Name".format(line_no))
|
error_messages.append("Row {0}: Please enter Account Name".format(line_no))
|
||||||
|
|||||||
@@ -146,10 +146,14 @@ class PurchaseInvoice(BuyingController):
|
|||||||
["account_type", "report_type", "account_currency"], as_dict=True)
|
["account_type", "report_type", "account_currency"], as_dict=True)
|
||||||
|
|
||||||
if account.report_type != "Balance Sheet":
|
if account.report_type != "Balance Sheet":
|
||||||
frappe.throw(_("Credit To account must be a Balance Sheet account"))
|
frappe.throw(_("Please ensure {} account is a Balance Sheet account. \
|
||||||
|
You can change the parent account to a Balance Sheet account or select a different account.")
|
||||||
|
.format(frappe.bold("Credit To")), title=_("Invalid Account"))
|
||||||
|
|
||||||
if self.supplier and account.account_type != "Payable":
|
if self.supplier and account.account_type != "Payable":
|
||||||
frappe.throw(_("Credit To account must be a Payable account"))
|
frappe.throw(_("Please ensure {} account is a Payable account. \
|
||||||
|
Change the account type to Payable or select a different account.")
|
||||||
|
.format(frappe.bold("Credit To")), title=_("Invalid Account"))
|
||||||
|
|
||||||
self.party_account_currency = account.account_currency
|
self.party_account_currency = account.account_currency
|
||||||
|
|
||||||
|
|||||||
@@ -470,13 +470,17 @@ class SalesInvoice(SellingController):
|
|||||||
["account_type", "report_type", "account_currency"], as_dict=True)
|
["account_type", "report_type", "account_currency"], as_dict=True)
|
||||||
|
|
||||||
if not account:
|
if not account:
|
||||||
frappe.throw(_("Debit To is required"))
|
frappe.throw(_("Debit To is required"), title=_("Account Missing"))
|
||||||
|
|
||||||
if account.report_type != "Balance Sheet":
|
if account.report_type != "Balance Sheet":
|
||||||
frappe.throw(_("Debit To account must be a Balance Sheet account"))
|
frappe.throw(_("Please ensure {} account is a Balance Sheet account. \
|
||||||
|
You can change the parent account to a Balance Sheet account or select a different account.")
|
||||||
|
.format(frappe.bold("Debit To")), title=_("Invalid Account"))
|
||||||
|
|
||||||
if self.customer and account.account_type != "Receivable":
|
if self.customer and account.account_type != "Receivable":
|
||||||
frappe.throw(_("Debit To account must be a Receivable account"))
|
frappe.throw(_("Please ensure {} account is a Receivable account. \
|
||||||
|
Change the account type to Receivable or select a different account.")
|
||||||
|
.format(frappe.bold("Debit To")), title=_("Invalid Account"))
|
||||||
|
|
||||||
self.party_account_currency = account.account_currency
|
self.party_account_currency = account.account_currency
|
||||||
|
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ class ExpenseClaim(AccountsController):
|
|||||||
paid_amount = flt(self.total_amount_reimbursed) + flt(self.total_advance_amount)
|
paid_amount = flt(self.total_amount_reimbursed) + flt(self.total_advance_amount)
|
||||||
precision = self.precision("grand_total")
|
precision = self.precision("grand_total")
|
||||||
if (self.is_paid or (flt(self.total_sanctioned_amount) > 0
|
if (self.is_paid or (flt(self.total_sanctioned_amount) > 0
|
||||||
and flt(self.total_sanctioned_amount, precision) == flt(paid_amount, precision))) \
|
and flt(flt(self.total_sanctioned_amount) + flt(self.total_taxes_and_charges), precision) == flt(paid_amount, precision))) \
|
||||||
and self.docstatus == 1 and self.approval_status == 'Approved':
|
and self.docstatus == 1 and self.approval_status == 'Approved':
|
||||||
self.status = "Paid"
|
self.status = "Paid"
|
||||||
elif flt(self.total_sanctioned_amount) > 0 and self.docstatus == 1 and self.approval_status == 'Approved':
|
elif flt(self.grand_total) > 0 and self.docstatus == 1 and self.approval_status == 'Approved':
|
||||||
self.status = "Unpaid"
|
self.status = "Unpaid"
|
||||||
elif self.docstatus == 1 and self.approval_status == 'Rejected':
|
elif self.docstatus == 1 and self.approval_status == 'Rejected':
|
||||||
self.status = 'Rejected'
|
self.status = 'Rejected'
|
||||||
|
|||||||
@@ -34,12 +34,14 @@ class TestExpenseClaim(unittest.TestCase):
|
|||||||
task_name = task.name
|
task_name = task.name
|
||||||
payable_account = get_payable_account(company_name)
|
payable_account = get_payable_account(company_name)
|
||||||
|
|
||||||
make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4", "_Test Project 1", task_name)
|
make_expense_claim(payable_account, 300, 200, company_name,
|
||||||
|
"Travel Expenses - _TC4", "_Test Project 1", task_name, cost_center="Main - _TC4")
|
||||||
|
|
||||||
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 200)
|
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 200)
|
||||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 200)
|
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 200)
|
||||||
|
|
||||||
expense_claim2 = make_expense_claim(payable_account, 600, 500, company_name, "Travel Expenses - _TC4","_Test Project 1", task_name)
|
expense_claim2 = make_expense_claim(payable_account, 600, 500, company_name,
|
||||||
|
"Travel Expenses - _TC4","_Test Project 1", task_name, cost_center="Main - _TC4")
|
||||||
|
|
||||||
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 700)
|
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 700)
|
||||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 700)
|
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 700)
|
||||||
@@ -51,7 +53,8 @@ class TestExpenseClaim(unittest.TestCase):
|
|||||||
|
|
||||||
def test_expense_claim_status(self):
|
def test_expense_claim_status(self):
|
||||||
payable_account = get_payable_account(company_name)
|
payable_account = get_payable_account(company_name)
|
||||||
expense_claim = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4")
|
expense_claim = make_expense_claim(payable_account, 300, 200, company_name,
|
||||||
|
"Travel Expenses - _TC4", cost_center="Main - _TC4")
|
||||||
|
|
||||||
je_dict = make_bank_entry("Expense Claim", expense_claim.name)
|
je_dict = make_bank_entry("Expense Claim", expense_claim.name)
|
||||||
je = frappe.get_doc(je_dict)
|
je = frappe.get_doc(je_dict)
|
||||||
@@ -70,7 +73,8 @@ class TestExpenseClaim(unittest.TestCase):
|
|||||||
def test_expense_claim_gl_entry(self):
|
def test_expense_claim_gl_entry(self):
|
||||||
payable_account = get_payable_account(company_name)
|
payable_account = get_payable_account(company_name)
|
||||||
taxes = generate_taxes()
|
taxes = generate_taxes()
|
||||||
expense_claim = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4", do_not_submit=True, taxes=taxes)
|
expense_claim = make_expense_claim(payable_account, 300, 200, company_name,
|
||||||
|
"Travel Expenses - _TC4", do_not_submit=True, taxes=taxes, cost_center="Main - _TC4")
|
||||||
expense_claim.submit()
|
expense_claim.submit()
|
||||||
|
|
||||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||||
@@ -124,9 +128,10 @@ def generate_taxes():
|
|||||||
"total": 210
|
"total": 210
|
||||||
}]}
|
}]}
|
||||||
|
|
||||||
def make_expense_claim(payable_account, amount, sanctioned_amount, company, account, project=None, task_name=None, do_not_submit=False, taxes=None):
|
def make_expense_claim(payable_account, amount, sanctioned_amount, company, account,
|
||||||
|
project=None, task_name=None, do_not_submit=False, taxes=None, cost_center=None):
|
||||||
employee = frappe.db.get_value("Employee", {"status": "Active"})
|
employee = frappe.db.get_value("Employee", {"status": "Active"})
|
||||||
currency = frappe.db.get_value('Company', company, 'default_currency')
|
currency, company_cost_center = frappe.db.get_value('Company', company, ['default_currency', 'cost_center'])
|
||||||
expense_claim = {
|
expense_claim = {
|
||||||
"doctype": "Expense Claim",
|
"doctype": "Expense Claim",
|
||||||
"employee": employee,
|
"employee": employee,
|
||||||
@@ -134,12 +139,15 @@ def make_expense_claim(payable_account, amount, sanctioned_amount, company, acco
|
|||||||
"approval_status": "Approved",
|
"approval_status": "Approved",
|
||||||
"company": company,
|
"company": company,
|
||||||
'currency': currency,
|
'currency': currency,
|
||||||
"expenses":
|
"expenses": [{
|
||||||
[{"expense_type": "Travel",
|
"expense_type": "Travel",
|
||||||
"default_account": account,
|
"default_account": account,
|
||||||
'currency': currency,
|
'currency': currency,
|
||||||
"amount": amount,
|
"amount": amount,
|
||||||
"sanctioned_amount": sanctioned_amount}]}
|
"sanctioned_amount": sanctioned_amount,
|
||||||
|
"cost_center": cost_center or company_cost_center
|
||||||
|
}]
|
||||||
|
}
|
||||||
if taxes:
|
if taxes:
|
||||||
expense_claim.update(taxes)
|
expense_claim.update(taxes)
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ class LeaveApplication(Document):
|
|||||||
if self.status == "Approved":
|
if self.status == "Approved":
|
||||||
for dt in daterange(getdate(self.from_date), getdate(self.to_date)):
|
for dt in daterange(getdate(self.from_date), getdate(self.to_date)):
|
||||||
date = dt.strftime("%Y-%m-%d")
|
date = dt.strftime("%Y-%m-%d")
|
||||||
status = "Half Day" if date == self.half_day_date else "On Leave"
|
status = "Half Day" if getdate(date) == getdate(self.half_day_date) else "On Leave"
|
||||||
|
|
||||||
attendance_name = frappe.db.exists('Attendance', dict(employee = self.employee,
|
attendance_name = frappe.db.exists('Attendance', dict(employee = self.employee,
|
||||||
attendance_date = date, docstatus = ('!=', 2)))
|
attendance_date = date, docstatus = ('!=', 2)))
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ erpnext.patches.v11_0.rename_bom_wo_fields
|
|||||||
erpnext.patches.v12_0.set_default_homepage_type
|
erpnext.patches.v12_0.set_default_homepage_type
|
||||||
erpnext.patches.v11_0.rename_additional_salary_component_additional_salary
|
erpnext.patches.v11_0.rename_additional_salary_component_additional_salary
|
||||||
erpnext.patches.v11_0.renamed_from_to_fields_in_project
|
erpnext.patches.v11_0.renamed_from_to_fields_in_project
|
||||||
erpnext.patches.v11_0.add_permissions_in_gst_settings
|
erpnext.patches.v11_0.add_permissions_in_gst_settings #2020-04-04
|
||||||
erpnext.patches.v11_1.setup_guardian_role
|
erpnext.patches.v11_1.setup_guardian_role
|
||||||
execute:frappe.delete_doc('DocType', 'Notification Control')
|
execute:frappe.delete_doc('DocType', 'Notification Control')
|
||||||
erpnext.patches.v12_0.set_gst_category
|
erpnext.patches.v12_0.set_gst_category
|
||||||
@@ -652,5 +652,5 @@ erpnext.patches.v12_0.add_export_type_field_in_party_master
|
|||||||
erpnext.patches.v12_0.rename_bank_reconciliation_fields # 2020-01-22
|
erpnext.patches.v12_0.rename_bank_reconciliation_fields # 2020-01-22
|
||||||
erpnext.patches.v12_0.create_irs_1099_field_united_states
|
erpnext.patches.v12_0.create_irs_1099_field_united_states
|
||||||
erpnext.patches.v12_0.set_permission_einvoicing
|
erpnext.patches.v12_0.set_permission_einvoicing
|
||||||
erpnext.patches.v12_0.set_received_qty_in_material_request_as_per_stock_uom
|
|
||||||
erpnext.patches.v12_0.set_correct_status_for_expense_claim
|
erpnext.patches.v12_0.set_correct_status_for_expense_claim
|
||||||
|
erpnext.patches.v12_0.set_received_qty_in_material_request_as_per_stock_uom
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.permissions import add_permission, update_permission_property
|
from erpnext.regional.india.setup import add_permissions
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||||
if not company:
|
if not company:
|
||||||
return
|
return
|
||||||
|
|
||||||
for doctype in ('GST HSN Code', 'GST Settings'):
|
add_permissions()
|
||||||
add_permission(doctype, 'Accounts Manager', 0)
|
|
||||||
update_permission_property(doctype, 'Accounts Manager', 0, 'write', 1)
|
|
||||||
update_permission_property(doctype, 'Accounts Manager', 0, 'create', 1)
|
|
||||||
@@ -4,4 +4,8 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
frappe.db.sql("update `tabExpense Claim` set status = 'Paid' where (total_advance_amount + total_amount_reimbursed ) = total_sanctioned_amount")
|
frappe.db.sql("""
|
||||||
|
update `tabExpense Claim`
|
||||||
|
set status = 'Paid'
|
||||||
|
where total_advance_amount + total_amount_reimbursed = total_sanctioned_amount + total_taxes_and_charges
|
||||||
|
""")
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>(a) {{__("Outward taxable supplies(other than zero rated, nil rated and exempted")}}</td>
|
<td>(a) {{__("Outward taxable supplies(other than zero rated, nil rated and exempted)")}}</td>
|
||||||
<td class="right">{{ flt(data.sup_details.osup_det.txval, 2) }}</td>
|
<td class="right">{{ flt(data.sup_details.osup_det.txval, 2) }}</td>
|
||||||
<td class="right">{{ flt(data.sup_details.osup_det.iamt, 2) }}</td>
|
<td class="right">{{ flt(data.sup_details.osup_det.iamt, 2) }}</td>
|
||||||
<td class="right">{{ flt(data.sup_details.osup_det.camt, 2) }}</td>
|
<td class="right">{{ flt(data.sup_details.osup_det.camt, 2) }}</td>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"actions": [],
|
||||||
"autoname": "format:GSTR3B-{month}-{year}-{company_address}",
|
"autoname": "format:GSTR3B-{month}-{year}-{company_address}",
|
||||||
"creation": "2019-02-04 11:35:55.964639",
|
"creation": "2019-02-04 11:35:55.964639",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
@@ -48,25 +49,13 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2019-08-10 22:30:26.727038",
|
"links": [],
|
||||||
|
"modified": "2020-04-04 19:32:30.772908",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Regional",
|
"module": "Regional",
|
||||||
"name": "GSTR 3B Report",
|
"name": "GSTR 3B Report",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [],
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"email": 1,
|
|
||||||
"export": 1,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"report": 1,
|
|
||||||
"role": "System Manager",
|
|
||||||
"share": 1,
|
|
||||||
"write": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
|
|||||||
@@ -77,13 +77,19 @@ def add_custom_roles_for_reports():
|
|||||||
)).insert()
|
)).insert()
|
||||||
|
|
||||||
def add_permissions():
|
def add_permissions():
|
||||||
for doctype in ('GST HSN Code', 'GST Settings'):
|
for doctype in ('GST HSN Code', 'GST Settings', 'GSTR 3B Report'):
|
||||||
add_permission(doctype, 'All', 0)
|
add_permission(doctype, 'All', 0)
|
||||||
for role in ('Accounts Manager', 'System Manager', 'Item Manager', 'Stock Manager'):
|
for role in ('Accounts Manager', 'Accounts User', 'System Manager'):
|
||||||
add_permission(doctype, role, 0)
|
add_permission(doctype, role, 0)
|
||||||
update_permission_property(doctype, role, 0, 'write', 1)
|
update_permission_property(doctype, role, 0, 'write', 1)
|
||||||
update_permission_property(doctype, role, 0, 'create', 1)
|
update_permission_property(doctype, role, 0, 'create', 1)
|
||||||
|
|
||||||
|
if doctype == 'GST HSN Code':
|
||||||
|
for role in ('Item Manager', 'Stock Manager'):
|
||||||
|
add_permission(doctype, role, 0)
|
||||||
|
update_permission_property(doctype, role, 0, 'write', 1)
|
||||||
|
update_permission_property(doctype, role, 0, 'create', 1)
|
||||||
|
|
||||||
def add_print_formats():
|
def add_print_formats():
|
||||||
frappe.reload_doc("regional", "print_format", "gst_tax_invoice")
|
frappe.reload_doc("regional", "print_format", "gst_tax_invoice")
|
||||||
frappe.reload_doc("accounts", "print_format", "gst_pos_invoice")
|
frappe.reload_doc("accounts", "print_format", "gst_pos_invoice")
|
||||||
|
|||||||
Reference in New Issue
Block a user