diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py index 7f51b139de4..00311c4f66d 100644 --- a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py +++ b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py @@ -108,7 +108,7 @@ def build_forest(data): error_messages = [] 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: error_messages.append("Row {0}: Please enter Account Name".format(line_no)) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 698c2ab333d..3933b5b1ee8 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -146,10 +146,14 @@ class PurchaseInvoice(BuyingController): ["account_type", "report_type", "account_currency"], as_dict=True) 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": - 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 diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index eda80246cdb..b6d2affee54 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -470,13 +470,17 @@ class SalesInvoice(SellingController): ["account_type", "report_type", "account_currency"], as_dict=True) if not account: - frappe.throw(_("Debit To is required")) + frappe.throw(_("Debit To is required"), title=_("Account Missing")) 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": - 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 diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py index e9f15cdfb9a..fefec01130a 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/expense_claim.py @@ -45,10 +45,10 @@ class ExpenseClaim(AccountsController): paid_amount = flt(self.total_amount_reimbursed) + flt(self.total_advance_amount) precision = self.precision("grand_total") 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': 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" elif self.docstatus == 1 and self.approval_status == 'Rejected': self.status = 'Rejected' diff --git a/erpnext/hr/doctype/expense_claim/test_expense_claim.py b/erpnext/hr/doctype/expense_claim/test_expense_claim.py index b559dfd81d1..7a7946d8ddd 100644 --- a/erpnext/hr/doctype/expense_claim/test_expense_claim.py +++ b/erpnext/hr/doctype/expense_claim/test_expense_claim.py @@ -34,12 +34,14 @@ class TestExpenseClaim(unittest.TestCase): task_name = task.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("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("Project", "_Test Project 1", "total_expense_claim"), 700) @@ -51,7 +53,8 @@ class TestExpenseClaim(unittest.TestCase): def test_expense_claim_status(self): 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 = frappe.get_doc(je_dict) @@ -70,7 +73,8 @@ class TestExpenseClaim(unittest.TestCase): def test_expense_claim_gl_entry(self): payable_account = get_payable_account(company_name) 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() gl_entries = frappe.db.sql("""select account, debit, credit @@ -124,9 +128,10 @@ def generate_taxes(): "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"}) - 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 = { "doctype": "Expense Claim", "employee": employee, @@ -134,12 +139,15 @@ def make_expense_claim(payable_account, amount, sanctioned_amount, company, acco "approval_status": "Approved", "company": company, 'currency': currency, - "expenses": - [{"expense_type": "Travel", + "expenses": [{ + "expense_type": "Travel", "default_account": account, 'currency': currency, "amount": amount, - "sanctioned_amount": sanctioned_amount}]} + "sanctioned_amount": sanctioned_amount, + "cost_center": cost_center or company_cost_center + }] + } if taxes: expense_claim.update(taxes) diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 39e5e1132ca..a800923a8c2 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -122,7 +122,7 @@ class LeaveApplication(Document): if self.status == "Approved": for dt in daterange(getdate(self.from_date), getdate(self.to_date)): 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_date = date, docstatus = ('!=', 2))) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 75394da0555..02ab7169f7a 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -582,7 +582,7 @@ erpnext.patches.v11_0.rename_bom_wo_fields erpnext.patches.v12_0.set_default_homepage_type erpnext.patches.v11_0.rename_additional_salary_component_additional_salary 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 execute:frappe.delete_doc('DocType', 'Notification Control') 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.create_irs_1099_field_united_states 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_received_qty_in_material_request_as_per_stock_uom diff --git a/erpnext/patches/v11_0/add_permissions_in_gst_settings.py b/erpnext/patches/v11_0/add_permissions_in_gst_settings.py index e8fcf33bede..121a20288c3 100644 --- a/erpnext/patches/v11_0/add_permissions_in_gst_settings.py +++ b/erpnext/patches/v11_0/add_permissions_in_gst_settings.py @@ -1,12 +1,9 @@ import frappe -from frappe.permissions import add_permission, update_permission_property +from erpnext.regional.india.setup import add_permissions def execute(): company = frappe.get_all('Company', filters = {'country': 'India'}) if not company: return - for doctype in ('GST HSN Code', 'GST Settings'): - add_permission(doctype, 'Accounts Manager', 0) - update_permission_property(doctype, 'Accounts Manager', 0, 'write', 1) - update_permission_property(doctype, 'Accounts Manager', 0, 'create', 1) \ No newline at end of file + add_permissions() \ No newline at end of file diff --git a/erpnext/patches/v12_0/set_correct_status_for_expense_claim.py b/erpnext/patches/v12_0/set_correct_status_for_expense_claim.py index 3d3980743e6..1fefc90680e 100644 --- a/erpnext/patches/v12_0/set_correct_status_for_expense_claim.py +++ b/erpnext/patches/v12_0/set_correct_status_for_expense_claim.py @@ -4,4 +4,8 @@ import frappe def execute(): - frappe.db.sql("update `tabExpense Claim` set status = 'Paid' where (total_advance_amount + total_amount_reimbursed ) = total_sanctioned_amount") \ No newline at end of file + frappe.db.sql(""" + update `tabExpense Claim` + set status = 'Paid' + where total_advance_amount + total_amount_reimbursed = total_sanctioned_amount + total_taxes_and_charges + """) \ No newline at end of file diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.html b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.html index 2da79a63648..35f9cf674ce 100644 --- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.html +++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.html @@ -29,7 +29,7 @@