From 5402451b35068a791ef9c97067757838d221ca30 Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Fri, 29 Mar 2019 19:25:11 +0530 Subject: [PATCH 01/19] feat: Loan repayment report Co-authored-by: crescent28 --- erpnext/hr/report/loan_repayment/__init__.py | 0 .../report/loan_repayment/loan_repayment.js | 9 ++ .../report/loan_repayment/loan_repayment.json | 28 ++++++ .../report/loan_repayment/loan_repayment.py | 95 +++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 erpnext/hr/report/loan_repayment/__init__.py create mode 100644 erpnext/hr/report/loan_repayment/loan_repayment.js create mode 100644 erpnext/hr/report/loan_repayment/loan_repayment.json create mode 100644 erpnext/hr/report/loan_repayment/loan_repayment.py diff --git a/erpnext/hr/report/loan_repayment/__init__.py b/erpnext/hr/report/loan_repayment/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/hr/report/loan_repayment/loan_repayment.js b/erpnext/hr/report/loan_repayment/loan_repayment.js new file mode 100644 index 0000000000..21aa206160 --- /dev/null +++ b/erpnext/hr/report/loan_repayment/loan_repayment.js @@ -0,0 +1,9 @@ +// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt +/* eslint-disable */ + +frappe.query_reports["Loan Repayment"] = { + "filters": [ + + ] +} diff --git a/erpnext/hr/report/loan_repayment/loan_repayment.json b/erpnext/hr/report/loan_repayment/loan_repayment.json new file mode 100644 index 0000000000..23b6977db8 --- /dev/null +++ b/erpnext/hr/report/loan_repayment/loan_repayment.json @@ -0,0 +1,28 @@ +{ + "add_total_row": 0, + "creation": "2019-03-29 18:58:00.166032", + "disable_prepared_report": 0, + "disabled": 0, + "docstatus": 0, + "doctype": "Report", + "idx": 0, + "is_standard": "Yes", + "letter_head": "Gadgets International", + "modified": "2019-03-29 18:58:00.166032", + "modified_by": "Administrator", + "module": "HR", + "name": "Loan Repayment", + "owner": "Administrator", + "prepared_report": 0, + "ref_doctype": "Loan", + "report_name": "Loan Repayment", + "report_type": "Script Report", + "roles": [ + { + "role": "HR Manager" + }, + { + "role": "Employee" + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/report/loan_repayment/loan_repayment.py b/erpnext/hr/report/loan_repayment/loan_repayment.py new file mode 100644 index 0000000000..9e310de48c --- /dev/null +++ b/erpnext/hr/report/loan_repayment/loan_repayment.py @@ -0,0 +1,95 @@ +# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe import _ + +def execute(filters=None): + + columns = create_columns() + data = get_record() + return columns, data + +def create_columns(): + return [ + { + "label": _("Employee"), + "fieldtype": "Data", + "fieldname": "employee", + "options": "Employee", + "width": 200 + }, + { + "label": _("Loan"), + "fieldtype": "Link", + "fieldname": "loan_name", + "options": "Loan", + "width": 200 + }, + { + "label": _("Loan Amount"), + "fieldtype": "Currency", + "fieldname": "loan_amount", + "options": "currency", + "width": 100 + }, + { + "label": _("Interest"), + "fieldtype": "Data", + "fieldname": "interest", + "width": 100 + }, + { + "label": _("Payable Amount"), + "fieldtype": "Currency", + "fieldname": "payable_amount", + "options": "currency", + "width": 100 + }, + { + "label": _("EMI"), + "fieldtype": "Currency", + "fieldname": "emi", + "options": "currency", + "width": 100 + }, + { + "label": _("Paid Amount"), + "fieldtype": "Currency", + "fieldname": "paid_amount", + "options": "currency", + "width": 100 + }, + { + "label": _("Outstanding Amount"), + "fieldtype": "Currency", + "fieldname": "out_amt", + "options": "currency", + "width": 100 + }, + ] + +def get_record(): + data = [] + loans = frappe.get_all("Loan", + filters=[("status", "=", "Fully Disbursed")], + fields=["applicant", "applicant_name", "name", "loan_amount", "rate_of_interest", + "total_payment", "monthly_repayment_amount", "total_amount_paid"] + ) + + for loan in loans: + row = { + "employee": loan.applicant + ": " + loan.applicant_name, + "loan_name": loan.name, + "loan_amount": loan.loan_amount, + "interest": str(loan.rate_of_interest) + "%", + "payable_amount": loan.total_payment, + "emi": loan.monthly_repayment_amount, + "paid_amount": loan.total_amount_paid, + "out_amt": loan.total_payment - loan.total_amount_paid + } + + data.append(row) + + return data From 593242fa5ca2cb18dfb1cf0155a6297f8d85053a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 5 Apr 2019 19:35:02 +0530 Subject: [PATCH 02/19] fix: Calculate rate based on discount on server side only if not rate or pricing rule applied --- erpnext/controllers/taxes_and_totals.py | 23 +++++++++++--------- erpnext/public/js/controllers/buying.js | 2 ++ erpnext/public/js/controllers/transaction.js | 1 + erpnext/selling/sales_common.js | 2 ++ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index b3880be2c6..fe12cf2316 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -59,19 +59,22 @@ class calculate_taxes_and_totals(object): if item.discount_percentage == 100: item.rate = 0.0 - elif (not item.rate or item.discount_percentage > 0) and item.price_list_rate: - item.rate = flt(item.price_list_rate * - (1.0 - (item.discount_percentage / 100.0)), item.precision("rate")) - item.discount_amount = item.price_list_rate * (item.discount_percentage / 100.0) - elif item.discount_amount and item.price_list_rate: - item.rate = item.price_list_rate - item.discount_amount + elif item.price_list_rate: + if not item.rate or (item.pricing_rules and item.discount_percentage > 0): + item.rate = flt(item.price_list_rate * + (1.0 - (item.discount_percentage / 100.0)), item.precision("rate")) + item.discount_amount = item.price_list_rate * (item.discount_percentage / 100.0) + elif item.discount_amount and item.pricing_rules: + item.rate = item.price_list_rate - item.discount_amount if item.doctype in ['Quotation Item', 'Sales Order Item', 'Delivery Note Item', 'Sales Invoice Item']: item.rate_with_margin, item.base_rate_with_margin = self.calculate_margin(item) - - if flt(item.rate_with_margin) > 0: - item.rate = flt(item.rate_with_margin * (1.0 - (item.discount_percentage / 100.0)), item.precision("rate")) - item.discount_amount = item.rate_with_margin - item.rate + if item.discount_percentage: + if flt(item.rate_with_margin) > 0: + item.rate = flt(item.rate_with_margin * (1.0 - (item.discount_percentage / 100.0)), item.precision("rate")) + item.discount_amount = item.rate_with_margin - item.rate + elif flt(item.price_list_rate) > 0: + item.discount_amount = item.price_list_rate - item.rate elif flt(item.price_list_rate) > 0 and not item.discount_amount: item.discount_amount = item.price_list_rate - item.rate diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js index 3ec27fcc7f..f2fe3fe72b 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -147,6 +147,8 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ }, discount_amount: function(doc, cdt, cdn) { + var item = frappe.get_doc(cdt, cdn); + item.discount_percentage = 0.0; this.price_list_rate(doc, cdt, cdn); }, diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 5291d4ff6f..cb01c525d5 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -23,6 +23,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } else { item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0, precision("discount_percentage", item)); + item.discount_amount = flt(item.price_list_rate) - flt(item.rate); item.margin_type = ''; item.margin_rate_or_amount = 0; item.rate_with_margin = 0; diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 965d2b0219..23dcaa152d 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -145,6 +145,8 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }, discount_amount: function(doc, cdt, cdn) { + var item = frappe.get_doc(cdt, cdn); + item.discount_percentage = 0.0; this.apply_discount_on_item(doc, cdt, cdn, 'discount_amount'); }, From 64bfdd95967e2682752bad5546fbf0e9e078c143 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 23 Apr 2019 13:37:19 +0530 Subject: [PATCH 03/19] fix: test cases --- erpnext/controllers/taxes_and_totals.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index fe12cf2316..b75b8b825c 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -69,12 +69,11 @@ class calculate_taxes_and_totals(object): if item.doctype in ['Quotation Item', 'Sales Order Item', 'Delivery Note Item', 'Sales Invoice Item']: item.rate_with_margin, item.base_rate_with_margin = self.calculate_margin(item) - if item.discount_percentage: - if flt(item.rate_with_margin) > 0: - item.rate = flt(item.rate_with_margin * (1.0 - (item.discount_percentage / 100.0)), item.precision("rate")) - item.discount_amount = item.rate_with_margin - item.rate - elif flt(item.price_list_rate) > 0: - item.discount_amount = item.price_list_rate - item.rate + if flt(item.rate_with_margin) > 0: + item.rate = flt(item.rate_with_margin * (1.0 - (item.discount_percentage / 100.0)), item.precision("rate")) + item.discount_amount = item.rate_with_margin - item.rate + elif flt(item.price_list_rate) > 0: + item.discount_amount = item.price_list_rate - item.rate elif flt(item.price_list_rate) > 0 and not item.discount_amount: item.discount_amount = item.price_list_rate - item.rate From 467609b19316ee8c1444aea4b19ca552397beaef Mon Sep 17 00:00:00 2001 From: ashish-greycube Date: Fri, 26 Apr 2019 11:35:04 +0530 Subject: [PATCH 04/19] show only party_type doctypes in Party Type field of bank account --- erpnext/accounts/doctype/bank_account/bank_account.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/accounts/doctype/bank_account/bank_account.js b/erpnext/accounts/doctype/bank_account/bank_account.js index 5ac41e4452..a3f16e4b03 100644 --- a/erpnext/accounts/doctype/bank_account/bank_account.js +++ b/erpnext/accounts/doctype/bank_account/bank_account.js @@ -12,6 +12,11 @@ frappe.ui.form.on('Bank Account', { } }; }); + frm.set_query("party_type", function() { + return { + query: "erpnext.setup.doctype.party_type.party_type.get_party_type", + } + }); }, refresh: function(frm) { frappe.dynamic_link = { doc: frm.doc, fieldname: 'name', doctype: 'Bank Account' } From 0ed9ec9a035e825b71fb50f4349dee22639f7cbc Mon Sep 17 00:00:00 2001 From: ashish-greycube Date: Fri, 26 Apr 2019 12:42:14 +0530 Subject: [PATCH 05/19] fix : allow_import_of_bank_account_by_account_manager --- .../doctype/bank_account/bank_account.json | 856 ++++-------------- 1 file changed, 158 insertions(+), 698 deletions(-) diff --git a/erpnext/accounts/doctype/bank_account/bank_account.json b/erpnext/accounts/doctype/bank_account/bank_account.json index 84a8e6857c..10db0d77a0 100644 --- a/erpnext/accounts/doctype/bank_account/bank_account.json +++ b/erpnext/accounts/doctype/bank_account/bank_account.json @@ -1,729 +1,189 @@ { - "allow_copy": 0, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 1, - "autoname": "field:account_name", - "beta": 0, - "creation": "2017-05-29 21:35:13.136357", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "Setup", - "editable_grid": 0, - "engine": "InnoDB", + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:account_name", + "creation": "2017-05-29 21:35:13.136357", + "doctype": "DocType", + "document_type": "Setup", + "engine": "InnoDB", + "field_order": [ + "account_name", + "account", + "bank", + "is_company_account", + "company", + "column_break_7", + "is_default", + "bank_account_no", + "iban", + "branch_code", + "swift_number", + "section_break_11", + "party_type", + "column_break_14", + "party", + "address_and_contact", + "address_html", + "website", + "column_break_12", + "contact_html" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "account_name", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 1, - "in_list_view": 1, - "in_standard_filter": 1, - "label": "Account Name", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, + "fieldname": "account_name", + "fieldtype": "Data", + "in_global_search": 1, + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Account Name", + "reqd": 1, "unique": 1 - }, + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "account", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Account", - "length": 0, - "no_copy": 0, - "options": "Account", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "account", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Account", + "options": "Account", + "reqd": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "bank", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Bank", - "length": 0, - "no_copy": 0, - "options": "Bank", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "bank", + "fieldtype": "Link", + "label": "Bank", + "options": "Bank", + "reqd": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "is_company_account", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Is Company Account", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "is_company_account", + "fieldtype": "Check", + "label": "Is Company Account" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "is_company_account", - "fieldname": "company", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 1, - "label": "Company", - "length": 0, - "no_copy": 0, - "options": "Company", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "depends_on": "is_company_account", + "fieldname": "company", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Company", + "options": "Company" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "column_break_7", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 1, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "column_break_7", + "fieldtype": "Column Break", + "search_index": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "is_default", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Is Default", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "is_default", + "fieldtype": "Check", + "label": "Is Default" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "bank_account_no", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Bank Account No", - "length": 30, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "bank_account_no", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Bank Account No", + "length": 30 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "iban", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "IBAN", - "length": 30, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "iban", + "fieldtype": "Data", + "in_list_view": 1, + "label": "IBAN", + "length": 30 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "branch_code", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Branch Code", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "branch_code", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Branch Code" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "swift_number", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "SWIFT number", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "swift_number", + "fieldtype": "Data", + "label": "SWIFT number" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:!doc.is_company_account", - "fieldname": "section_break_11", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "depends_on": "eval:!doc.is_company_account", + "fieldname": "section_break_11", + "fieldtype": "Section Break" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "party_type", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Party Type", - "length": 0, - "no_copy": 0, - "options": "DocType", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "party_type", + "fieldtype": "Link", + "label": "Party Type", + "options": "DocType" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "column_break_14", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "column_break_14", + "fieldtype": "Column Break" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "party", - "fieldtype": "Dynamic Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Party", - "length": 0, - "no_copy": 0, - "options": "party_type", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "party", + "fieldtype": "Dynamic Link", + "label": "Party", + "options": "party_type" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "address_and_contact", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Address and Contact", - "length": 0, - "no_copy": 0, - "options": "fa fa-map-marker", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "address_and_contact", + "fieldtype": "Section Break", + "label": "Address and Contact", + "options": "fa fa-map-marker" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "address_html", - "fieldtype": "HTML", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Address HTML", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "address_html", + "fieldtype": "HTML", + "label": "Address HTML" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "website", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Website", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "website", + "fieldtype": "Data", + "label": "Website" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "column_break_12", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "column_break_12", + "fieldtype": "Column Break" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "contact_html", - "fieldtype": "HTML", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Contact HTML", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "fieldname": "contact_html", + "fieldtype": "HTML", + "label": "Contact HTML" } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2019-03-05 17:56:05.103238", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Bank Account", - "name_case": "", - "owner": "Administrator", + ], + "modified": "2019-04-25 22:10:07.951351", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Bank Account", + "owner": "Administrator", "permissions": [ { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Accounts Manager", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "import": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts Manager", + "share": 1, "write": 1 - }, + }, { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Accounts User", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "share": 1, "write": 1 } - ], - "quick_entry": 0, - "read_only": 0, - "read_only_onload": 0, - "search_fields": "bank,account", - "show_name_in_global_search": 0, - "sort_field": "modified", - "sort_order": "DESC", - "track_changes": 1, - "track_seen": 0, - "track_views": 0 + ], + "search_fields": "bank,account", + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 } \ No newline at end of file From e4e8197f463e489464715473e76407adb83cdafa Mon Sep 17 00:00:00 2001 From: ashish-greycube Date: Fri, 26 Apr 2019 14:06:21 +0530 Subject: [PATCH 06/19] codacy review --- erpnext/accounts/doctype/bank_account/bank_account.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/bank_account/bank_account.js b/erpnext/accounts/doctype/bank_account/bank_account.js index a3f16e4b03..a7b5891cff 100644 --- a/erpnext/accounts/doctype/bank_account/bank_account.js +++ b/erpnext/accounts/doctype/bank_account/bank_account.js @@ -15,7 +15,7 @@ frappe.ui.form.on('Bank Account', { frm.set_query("party_type", function() { return { query: "erpnext.setup.doctype.party_type.party_type.get_party_type", - } + }; }); }, refresh: function(frm) { From 513e3f97e50c8259e7eacba7ec26012fb165745e Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Mon, 29 Apr 2019 12:17:49 +0530 Subject: [PATCH 07/19] fix(salary-register): track doj for non active employee --- erpnext/hr/report/salary_register/salary_register.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/erpnext/hr/report/salary_register/salary_register.py b/erpnext/hr/report/salary_register/salary_register.py index 586ca67273..869ca23139 100644 --- a/erpnext/hr/report/salary_register/salary_register.py +++ b/erpnext/hr/report/salary_register/salary_register.py @@ -99,8 +99,6 @@ def get_employee_doj_map(): employee, date_of_joining FROM `tabEmployee` - WHERE - `status`='Active' """)) def get_ss_earning_map(salary_slips): From 61b4afc3c54d7851f8775104ffbe3be332f9a9a9 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 29 Apr 2019 22:41:24 +0530 Subject: [PATCH 08/19] perf: Order by name instead of parent (#17404) Changing the order by column reduced the query time from 60s to 12s --- erpnext/portal/product_configurator/item_variants_cache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/portal/product_configurator/item_variants_cache.py b/erpnext/portal/product_configurator/item_variants_cache.py index 458c229e2f..f17639c1e7 100644 --- a/erpnext/portal/product_configurator/item_variants_cache.py +++ b/erpnext/portal/product_configurator/item_variants_cache.py @@ -62,7 +62,7 @@ class ItemVariantsCacheManager: item_variants_data = frappe.db.get_all('Item Variant Attribute', {'variant_of': parent_item_code}, ['parent', 'attribute', 'attribute_value'], - order_by='parent', + order_by='name', as_list=1 ) From 4b21225cf418bb4eef78fec607ad5e8cb82d523b Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 29 Apr 2019 22:41:48 +0530 Subject: [PATCH 09/19] fix: Map item_code to title (#17403) When making Project from Sales Order, description was mapped with Task title which can exceed 140 characters easily. Description should be mapped with description as it is html field. --- erpnext/selling/doctype/sales_order/sales_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index fc11e11092..fb7a335302 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -551,7 +551,7 @@ def make_project(source_name, target_doc=None): "Sales Order Item": { "doctype": "Project Task", "field_map": { - "description": "title", + "item_code": "title", }, } }, target_doc, postprocess) From c87b47a5755774387730a887a4a186b23bed009e Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 29 Apr 2019 23:18:47 +0530 Subject: [PATCH 10/19] fix: Price list conversion for other UOM from stock UOM item price (#17386) * fix: Price list for UOM other than stock UOM -Fixes conversion from default UOM item price to other UOMs * fix: Typo --- erpnext/public/js/controllers/transaction.js | 1 + erpnext/stock/get_item_details.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 5291d4ff6f..343e65ef60 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1199,6 +1199,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ "qty": d.qty, "stock_qty": d.stock_qty, "uom": d.uom, + "stock_uom": d.stock_uom, "parenttype": d.parenttype, "parent": d.parent, "pricing_rules": d.pricing_rules, diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 4d8022c24f..30a45dd457 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -492,7 +492,7 @@ def insert_item_price(args): def get_item_price(args, item_code, ignore_party=False): """ Get name, price_list_rate from Item Price based on conditions - Check if the Derised qty is within the increment of the packing list. + Check if the desired qty is within the increment of the packing list. :param args: dict (or frappe._dict) with mandatory fields price_list, uom optional fields min_qty, transaction_date, customer, supplier :param item_code: str, Item Doctype field item_code @@ -530,11 +530,11 @@ def get_price_list_rate_for(args, item_code): for min_qty 9 and min_qty 20. It returns Item Price Rate for qty 9 as the best fit in the range of avaliable min_qtyies - :param customer: link to Customer DocType - :param supplier: link to Supplier DocType + :param customer: link to Customer DocType + :param supplier: link to Supplier DocType :param price_list: str (Standard Buying or Standard Selling) :param item_code: str, Item Doctype field item_code - :param qty: Derised Qty + :param qty: Desired Qty :param transaction_date: Date of the price """ item_price_args = { @@ -559,7 +559,7 @@ def get_price_list_rate_for(args, item_code): general_price_list_rate = get_item_price(item_price_args, item_code, ignore_party=args.get("ignore_party")) if not general_price_list_rate and args.get("uom") != args.get("stock_uom"): - item_price_args["args"] = args.get("stock_uom") + item_price_args["uom"] = args.get("stock_uom") general_price_list_rate = get_item_price(item_price_args, item_code, ignore_party=args.get("ignore_party")) if general_price_list_rate: @@ -575,11 +575,11 @@ def get_price_list_rate_for(args, item_code): def check_packing_list(price_list_rate_name, desired_qty, item_code): """ - Check if the Derised qty is within the increment of the packing list. + Check if the desired qty is within the increment of the packing list. :param price_list_rate_name: Name of Item Price - :param desired_qty: Derised Qt + :param desired_qty: Desired Qt :param item_code: str, Item Doctype field item_code - :param qty: Derised Qt + :param qty: Desired Qt """ flag = True From 1e55c2e7137da166cd76539f5ea05cf5c4135a73 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 30 Apr 2019 10:18:09 +0530 Subject: [PATCH 11/19] Remove old style custom scripts (#17077) * fix: Move Newsletter script from frappe to erpnext * fix: Remove old style client scripts * C-Form * fix: Cost Center * fix: Fiscal Year * fix: Monthly Distribution * fix: Payment Gateway Account * fix: Pricing Rule * fix: Missing semicolon --- erpnext/accounts/doctype/c_form/c_form.js | 46 ++++--- .../doctype/cost_center/cost_center.js | 112 +++++++++--------- .../doctype/fiscal_year/fiscal_year.js | 40 +++---- .../monthly_distribution.js | 20 ++-- .../payment_gateway_account.js | 14 ++- .../doctype/pricing_rule/pricing_rule.js | 105 +--------------- erpnext/hooks.py | 3 +- erpnext/public/js/newsletter.js | 8 ++ 8 files changed, 132 insertions(+), 216 deletions(-) create mode 100644 erpnext/public/js/newsletter.js diff --git a/erpnext/accounts/doctype/c_form/c_form.js b/erpnext/accounts/doctype/c_form/c_form.js index 92cdb635da..3d0fc0a42c 100644 --- a/erpnext/accounts/doctype/c_form/c_form.js +++ b/erpnext/accounts/doctype/c_form/c_form.js @@ -4,24 +4,38 @@ //c-form js file // ----------------------------- +frappe.ui.form.on('C-Form', { + setup(frm) { + frm.fields_dict.invoices.grid.get_field("invoice_no").get_query = function(doc) { + return { + filters: { + "docstatus": 1, + "customer": doc.customer, + "company": doc.company, + "c_form_applicable": 'Yes', + "c_form_no": '' + } + }; + } -cur_frm.fields_dict.invoices.grid.get_field("invoice_no").get_query = function(doc) { - return { - filters: { - "docstatus": 1, - "customer": doc.customer, - "company": doc.company, - "c_form_applicable": 'Yes', - "c_form_no": '' + frm.fields_dict.state.get_query = function() { + return { + filters: { + country: "India" + } + }; } } -} +}); -cur_frm.fields_dict.state.get_query = function(doc) { - return {filters: { country: "India"}} -} +frappe.ui.form.on('C-Form Invoice Detail', { + invoice_no(frm, cdt, cdn) { + let d = frappe.get_doc(cdt, cdn); -cur_frm.cscript.invoice_no = function(doc, cdt, cdn) { - var d = locals[cdt][cdn]; - return get_server_fields('get_invoice_details', d.invoice_no, 'invoices', doc, cdt, cdn, 1); -} \ No newline at end of file + frm.call('get_invoice_details', { + invoice_no: d.invoice_no + }).then(r => { + frappe.model.set_value(cdt, cdn, r.message); + }); + } +}); diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js index 3df4da52ef..96ec57dcb0 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.js +++ b/erpnext/accounts/doctype/cost_center/cost_center.js @@ -22,6 +22,28 @@ frappe.ui.form.on('Cost Center', { frm.trigger("update_cost_center_number"); }); } + + let intro_txt = ''; + let doc = frm.doc; + frm.toggle_display('cost_center_name', doc.__islocal); + frm.toggle_enable(['is_group', 'company'], doc.__islocal); + + if(!doc.__islocal && doc.is_group==1) { + intro_txt += __('Note: This Cost Center is a Group. Cannot make accounting entries against groups.'); + } + + frm.events.hide_unhide_group_ledger(frm); + + frm.toggle_display('sb1', doc.is_group==0); + frm.set_intro(intro_txt); + + if(!frm.doc.__islocal) { + frm.add_custom_button(__('Chart of Cost Centers'), + function() { frappe.set_route("Tree", "Cost Center"); }); + + frm.add_custom_button(__('Budget'), + function() { frappe.set_route("List", "Budget", {'cost_center': frm.doc.name}); }); + } }, update_cost_center_number: function(frm) { var d = new frappe.ui.Dialog({ @@ -64,62 +86,38 @@ frappe.ui.form.on('Cost Center', { primary_action_label: __('Update') }); d.show(); + }, + + parent_cost_center(frm) { + if(!frm.doc.company) { + frappe.msgprint(__('Please enter company name first')); + } + }, + + hide_unhide_group_ledger(frm) { + let doc = frm.doc; + if (doc.is_group == 1) { + frm.add_custom_button(__('Convert to Non-Group'), + () => frm.events.convert_to_ledger(frm)); + } else if (doc.is_group == 0) { + frm.add_custom_button(__('Convert to Group'), + () => frm.events.convert_to_group(frm)); + } + }, + + convert_to_group(frm) { + frm.call('convert_ledger_to_group').then(r => { + if(r.message === 1) { + frm.refresh(); + } + }); + }, + + convert_to_ledger(frm) { + frm.call('convert_group_to_ledger').then(r => { + if(r.message === 1) { + frm.refresh(); + } + }); } }); - -cur_frm.cscript.refresh = function(doc, cdt, cdn) { - var intro_txt = ''; - cur_frm.toggle_display('cost_center_name', doc.__islocal); - cur_frm.toggle_enable(['is_group', 'company'], doc.__islocal); - - if(!doc.__islocal && doc.is_group==1) { - intro_txt += __('Note: This Cost Center is a Group. Cannot make accounting entries against groups.'); - } - - cur_frm.cscript.hide_unhide_group_ledger(doc); - - cur_frm.toggle_display('sb1', doc.is_group==0) - cur_frm.set_intro(intro_txt); - - if(!cur_frm.doc.__islocal) { - cur_frm.add_custom_button(__('Chart of Cost Centers'), - function() { frappe.set_route("Tree", "Cost Center"); }); - - cur_frm.add_custom_button(__('Budget'), - function() { frappe.set_route("List", "Budget", {'cost_center': cur_frm.doc.name}); }); - } -} - -cur_frm.cscript.parent_cost_center = function(doc, cdt, cdn) { - if(!doc.company){ - frappe.msgprint(__('Please enter company name first')); - } -} - -cur_frm.cscript.hide_unhide_group_ledger = function(doc) { - if (doc.is_group == 1) { - cur_frm.add_custom_button(__('Convert to Non-Group'), - function() { cur_frm.cscript.convert_to_ledger(); }, "fa fa-retweet", - "btn-default") - } else if (doc.is_group == 0) { - cur_frm.add_custom_button(__('Convert to Group'), - function() { cur_frm.cscript.convert_to_group(); }, "fa fa-retweet", - "btn-default") - } -} - -cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { - return $c_obj(cur_frm.doc,'convert_group_to_ledger','',function(r,rt) { - if(r.message == 1) { - cur_frm.refresh(); - } - }); -} - -cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) { - return $c_obj(cur_frm.doc,'convert_ledger_to_group','',function(r,rt) { - if(r.message == 1) { - cur_frm.refresh(); - } - }); -} diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.js b/erpnext/accounts/doctype/fiscal_year/fiscal_year.js index 4dc64338ae..152e17dbc8 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.js +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.js @@ -1,37 +1,31 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -$.extend(cur_frm.cscript, { - onload: function() { - if(cur_frm.doc.__islocal) { - cur_frm.set_value("year_start_date", +frappe.ui.form.on('Fiscal Year', { + onload: function(frm) { + if(frm.doc.__islocal) { + frm.set_value("year_start_date", frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)); } }, - refresh: function (doc, dt, dn) { - var me = this; - this.frm.toggle_enable('year_start_date', doc.__islocal) - this.frm.toggle_enable('year_end_date', doc.__islocal) + refresh: function (frm) { + let doc = frm.doc; + frm.toggle_enable('year_start_date', doc.__islocal); + frm.toggle_enable('year_end_date', doc.__islocal); if (!doc.__islocal && (doc.name != frappe.sys_defaults.fiscal_year)) { - this.frm.add_custom_button(__("Default"), - this.frm.cscript.set_as_default, "fa fa-star"); - this.frm.set_intro(__("To set this Fiscal Year as Default, click on 'Set as Default'")); + frm.add_custom_button(__("Set as Default"), () => frm.events.set_as_default(frm)); + frm.set_intro(__("To set this Fiscal Year as Default, click on 'Set as Default'")); } else { - this.frm.set_intro(""); + frm.set_intro(""); } }, - set_as_default: function() { - return frappe.call({ - doc: cur_frm.doc, - method: "set_as_default" - }); + set_as_default: function(frm) { + return frm.call('set_as_default'); }, - year_start_date: function(doc, dt, dn) { - var me = this; - - var year_end_date = - frappe.datetime.add_days(frappe.datetime.add_months(this.frm.doc.year_start_date, 12), -1); - this.frm.set_value("year_end_date", year_end_date); + year_start_date: function(frm) { + let year_end_date = + frappe.datetime.add_days(frappe.datetime.add_months(frm.doc.year_start_date, 12), -1); + frm.set_value("year_end_date", year_end_date); }, }); diff --git a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.js b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.js index 7b489de0a3..569f0084c6 100644 --- a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.js +++ b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.js @@ -1,16 +1,16 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.cscript.onload = function(doc,cdt,cdn){ - if(doc.__islocal){ - var callback1 = function(r,rt){ - refresh_field('percentages'); +frappe.ui.form.on('Monthly Distribution', { + onload(frm) { + if(frm.doc.__islocal) { + return frm.call('get_months').then(() => { + frm.refresh_field('percentages'); + }); } + }, - return $c('runserverobj', {'method':'get_months', 'docs':doc}, callback1); + refresh(frm) { + frm.toggle_display('distribution_id', frm.doc.__islocal); } -} - -cur_frm.cscript.refresh = function(doc,cdt,cdn){ - cur_frm.toggle_display('distribution_id', doc.__islocal); -} +}); diff --git a/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.js b/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.js index e1fe5a16a3..8f09bc3691 100644 --- a/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.js +++ b/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.js @@ -1,6 +1,10 @@ -cur_frm.cscript.refresh = function(doc, dt, dn){ - if(!doc.__islocal){ - var df = frappe.meta.get_docfield(doc.doctype, "payment_gateway", doc.name); - df.read_only = 1; +// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors +// License: GNU General Public License v3. See license.txt + +frappe.ui.form.on('Payment Gateway Account', { + refresh(frm) { + if(!frm.doc.__islocal) { + frm.set_df_property('payment_gateway', 'read_only', 1); + } } -} \ No newline at end of file +}); diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js index e5b6336755..c92b58b580 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js @@ -1,108 +1,6 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -frappe.ui.form.on("Pricing Rule", "refresh", function(frm) { - var help_content = - ` - - -
-

- - ${__('Notes')} -

-
    -
  • - ${__("Pricing Rule is made to overwrite Price List / define discount percentage, based on some criteria.")} -
  • -
  • - ${__("If selected Pricing Rule is made for 'Rate', it will overwrite Price List. Pricing Rule rate is the final rate, so no further discount should be applied. Hence, in transactions like Sales Order, Purchase Order etc, it will be fetched in 'Rate' field, rather than 'Price List Rate' field.")} -
  • -
  • - ${__('Discount Percentage can be applied either against a Price List or for all Price List.')} -
  • -
  • - ${__('To not apply Pricing Rule in a particular transaction, all applicable Pricing Rules should be disabled.')} -
  • -
-
-

- ${__('How Pricing Rule is applied?')} -

-
    -
  1. - ${__("Pricing Rule is first selected based on 'Apply On' field, which can be Item, Item Group or Brand.")} -
  2. -
  3. - ${__("Then Pricing Rules are filtered out based on Customer, Customer Group, Territory, Supplier, Supplier Group, Campaign, Sales Partner etc.")} -
  4. -
  5. - ${__('Pricing Rules are further filtered based on quantity.')} -
  6. -
  7. - ${__('If two or more Pricing Rules are found based on the above conditions, Priority is applied. Priority is a number between 0 to 20 while default value is zero (blank). Higher number means it will take precedence if there are multiple Pricing Rules with same conditions.')} -
  8. -
  9. - ${__('Even if there are multiple Pricing Rules with highest priority, then following internal priorities are applied:')} -
      -
    • - ${__('Item Code > Item Group > Brand')} -
    • -
    • - ${__('Customer > Customer Group > Territory')} -
    • -
    • - ${__('Supplier > Supplier Group')} -
    • -
    -
  10. -
  11. - ${__('If multiple Pricing Rules continue to prevail, users are asked to set Priority manually to resolve conflict.')} -
  12. -
-
`; - - set_field_options("pricing_rule_help", help_content); - - cur_frm.cscript.set_options_for_applicable_for(); -}); - -cur_frm.cscript.set_options_for_applicable_for = function() { - var options = [""]; - var applicable_for = cur_frm.doc.applicable_for; - - if(cur_frm.doc.selling) { - options = $.merge(options, ["Customer", "Customer Group", "Territory", "Sales Partner", "Campaign"]); - } - if(cur_frm.doc.buying) { - $.merge(options, ["Supplier", "Supplier Group"]); - } - - set_field_options("applicable_for", options.join("\n")); - - if(!in_list(options, applicable_for)) applicable_for = null; - cur_frm.set_value("applicable_for", applicable_for) -} - -cur_frm.cscript.selling = function() { - cur_frm.cscript.set_options_for_applicable_for(); -} - -cur_frm.cscript.buying = function() { - cur_frm.cscript.set_options_for_applicable_for(); -} - -//Dynamically change the description based on type of margin -cur_frm.cscript.margin_type = function(doc){ - cur_frm.set_df_property('margin_rate_or_amount', 'description', doc.margin_type=='Percentage'?'In Percentage %':'In Amount') -} - -frappe.ui.form.on('Pricing Rule', 'rate_or_discount', function(frm){ - if(frm.doc.rate_or_discount == 'Rate') { - frm.set_value('for_price_list', "") - } -}) - frappe.ui.form.on('Pricing Rule', { setup: function(frm) { frm.fields_dict["for_price_list"].get_query = function(doc){ @@ -199,7 +97,7 @@ frappe.ui.form.on('Pricing Rule', { `; - set_field_options("pricing_rule_help", help_content); + frm.set_df_property('pricing_rule_help', 'options', help_content); frm.events.set_options_for_applicable_for(frm); frm.trigger("toggle_reqd_apply_on"); }, @@ -256,5 +154,4 @@ frappe.ui.form.on('Pricing Rule', { if(!in_list(options, applicable_for)) applicable_for = null; frm.set_value("applicable_for", applicable_for); } - }); diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 47d205692c..85f2804f27 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -24,7 +24,8 @@ web_include_css = "assets/css/erpnext-web.css" doctype_js = { "Communication": "public/js/communication.js", "Event": "public/js/event.js", - "Website Theme": "public/js/website_theme.js" + "Website Theme": "public/js/website_theme.js", + "Newsletter": "public/js/newsletter.js" } welcome_email = "erpnext.setup.utils.welcome_email" diff --git a/erpnext/public/js/newsletter.js b/erpnext/public/js/newsletter.js new file mode 100644 index 0000000000..3a4dbf8933 --- /dev/null +++ b/erpnext/public/js/newsletter.js @@ -0,0 +1,8 @@ +// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors +// License: GNU General Public License v3. See license.txt + +frappe.ui.form.on('Newsletter', { + refresh() { + erpnext.toggle_naming_series(); + } +}); From 6b77f6edf3e0db1e628267efcb5ce8ba3b4a7564 Mon Sep 17 00:00:00 2001 From: Karthikeyan S Date: Wed, 1 May 2019 09:07:44 +0530 Subject: [PATCH 12/19] fix: woocommerce settings patch (#17422) (cherry picked from commit 7df8c0ef82d72920aba342623dc10c5c14b1d8f8) --- .../patches/v11_1/woocommerce_set_creation_user.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/erpnext/patches/v11_1/woocommerce_set_creation_user.py b/erpnext/patches/v11_1/woocommerce_set_creation_user.py index e50d5ae711..5ccdec6d26 100644 --- a/erpnext/patches/v11_1/woocommerce_set_creation_user.py +++ b/erpnext/patches/v11_1/woocommerce_set_creation_user.py @@ -1,10 +1,11 @@ from __future__ import unicode_literals import frappe +from frappe.utils import cint def execute(): - woocommerce_setting_enable_sync = frappe.db.sql("SELECT t.value FROM tabSingles t WHERE doctype = 'Woocommerce Settings' AND field = 'enable_sync'", as_dict=True) - if len(woocommerce_setting_enable_sync) and woocommerce_setting_enable_sync[0].value == '1': - frappe.db.sql("""UPDATE tabSingles - SET value = (SELECT t.value FROM tabSingles t WHERE doctype = 'Woocommerce Settings' AND field = 'modified_by') - WHERE doctype = 'Woocommerce Settings' - AND field = 'creation_user';""") \ No newline at end of file + frappe.reload_doc("erpnext_integrations", "doctype","woocommerce_settings") + doc = frappe.get_doc("Woocommerce Settings") + + if cint(doc.enable_sync): + doc.creation_user = doc.modified_by + doc.save(ignore_permissions=True) \ No newline at end of file From 71a07bf0227851f2e6418149206fe57d412a274a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 1 May 2019 11:02:35 +0530 Subject: [PATCH 13/19] Update loan_repayment.json --- erpnext/hr/report/loan_repayment/loan_repayment.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/hr/report/loan_repayment/loan_repayment.json b/erpnext/hr/report/loan_repayment/loan_repayment.json index 23b6977db8..b967dfdb38 100644 --- a/erpnext/hr/report/loan_repayment/loan_repayment.json +++ b/erpnext/hr/report/loan_repayment/loan_repayment.json @@ -7,7 +7,7 @@ "doctype": "Report", "idx": 0, "is_standard": "Yes", - "letter_head": "Gadgets International", + "letter_head": "", "modified": "2019-03-29 18:58:00.166032", "modified_by": "Administrator", "module": "HR", @@ -25,4 +25,4 @@ "role": "Employee" } ] -} \ No newline at end of file +} From 97ad454525ea39420222f24857f1d29d1dc5a1e0 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Wed, 1 May 2019 11:50:05 +0530 Subject: [PATCH 14/19] fix(py3): Undefined variable --- .../fichier_des_ecritures_comptables_[fec].py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].py b/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].py index 6b8d3f0139..a257ed2c6e 100644 --- a/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].py +++ b/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].py @@ -69,19 +69,19 @@ def get_gl_entries(filters): gl_entries = frappe.db.sql(""" select - gl.posting_date as GlPostDate, gl.name as GlName, gl.account, gl.transaction_date, + gl.posting_date as GlPostDate, gl.name as GlName, gl.account, gl.transaction_date, sum(gl.debit) as debit, sum(gl.credit) as credit, sum(gl.debit_in_account_currency) as debitCurr, sum(gl.credit_in_account_currency) as creditCurr, - gl.voucher_type, gl.voucher_no, gl.against_voucher_type, - gl.against_voucher, gl.account_currency, gl.against, + gl.voucher_type, gl.voucher_no, gl.against_voucher_type, + gl.against_voucher, gl.account_currency, gl.against, gl.party_type, gl.party, - inv.name as InvName, inv.title as InvTitle, inv.posting_date as InvPostDate, + inv.name as InvName, inv.title as InvTitle, inv.posting_date as InvPostDate, pur.name as PurName, pur.title as PurTitle, pur.posting_date as PurPostDate, jnl.cheque_no as JnlRef, jnl.posting_date as JnlPostDate, jnl.title as JnlTitle, pay.name as PayName, pay.posting_date as PayPostDate, pay.title as PayTitle, cus.customer_name, cus.name as cusName, sup.supplier_name, sup.name as supName - + from `tabGL Entry` gl left join `tabSales Invoice` inv on gl.voucher_no = inv.name left join `tabPurchase Invoice` pur on gl.voucher_no = pur.name @@ -118,7 +118,7 @@ def get_result_as_list(data, filters): if account_number[0] is not None: CompteNum = account_number[0] else: - frappe.throw(_("Account number for account {0} is not available.
Please setup your Chart of Accounts correctly.").format(account.name)) + frappe.throw(_("Account number for account {0} is not available.
Please setup your Chart of Accounts correctly.").format(d.get("account"))) if d.get("party_type") == "Customer": CompAuxNum = d.get("cusName") From 1db334317d16db14edae1c7c67f4ebd61893ad37 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Wed, 1 May 2019 11:51:04 +0530 Subject: [PATCH 15/19] fix(py3): Undefined variable --- .../asset_value_adjustment/asset_value_adjustment.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py index ac3c350702..56425a0dcb 100644 --- a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py +++ b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py @@ -36,7 +36,7 @@ class AssetValueAdjustment(Document): fixed_asset_account, accumulated_depreciation_account, depreciation_expense_account = \ get_depreciation_accounts(asset) - depreciation_cost_center, depreciation_series = frappe.get_cached_value('Company', asset.company, + depreciation_cost_center, depreciation_series = frappe.get_cached_value('Company', asset.company, ["depreciation_cost_center", "series_for_depreciation_entry"]) je = frappe.new_doc("Journal Entry") @@ -75,8 +75,8 @@ class AssetValueAdjustment(Document): rate_per_day = flt(d.value_after_depreciation) / flt(total_days) from_date = self.date else: - no_of_depreciations = len([e.name for e in asset.schedules - if (cint(s.finance_book_id) == d.idx and not e.journal_entry)]) + no_of_depreciations = len([s.name for s in asset.schedules + if (cint(s.finance_book_id) == d.idx and not s.journal_entry)]) value_after_depreciation = d.value_after_depreciation for data in asset.schedules: From a08bf7ef86f2cbddb10749e71f3128ec75772c7c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 30 Apr 2019 00:48:11 +0530 Subject: [PATCH 16/19] fix: a few fixes in payroll --- .../employee_benefit_application.py | 12 +- ...ee_tax_exemption_declaration_category.json | 332 +++++++++--------- .../payroll_period/payroll_period.json | 47 ++- .../salary_component/salary_component.js | 2 - erpnext/hr/doctype/salary_slip/salary_slip.py | 101 ++++-- .../doctype/salary_slip/test_salary_slip.py | 16 +- .../salary_structure/salary_structure.py | 7 +- erpnext/patches.txt | 2 +- 8 files changed, 298 insertions(+), 221 deletions(-) diff --git a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py index c613a13223..701ae2465f 100644 --- a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py +++ b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py @@ -177,9 +177,12 @@ def get_benefit_component_amount(employee, start_date, end_date, struct_row, sal # Considering there is only one application for a year benefit_application_name = frappe.db.sql(""" - select name from `tabEmployee Benefit Application` - where payroll_period=%(payroll_period)s and employee=%(employee)s - and docstatus = 1 + select name + from `tabEmployee Benefit Application` + where + payroll_period=%(payroll_period)s + and employee=%(employee)s + and docstatus = 1 """, { 'employee': employee, 'payroll_period': payroll_period @@ -209,7 +212,8 @@ def get_benefit_pro_rata_ratio_amount(sal_struct, component_max): total_pro_rata_max = 0 benefit_amount = 0 for sal_struct_row in sal_struct.get("earnings"): - pay_against_benefit_claim, max_benefit_amount = frappe.db.get_value("Salary Component", sal_struct_row.salary_component, ["pay_against_benefit_claim", "max_benefit_amount"]) + pay_against_benefit_claim, max_benefit_amount = frappe.db.get_value("Salary Component", + sal_struct_row.salary_component, ["pay_against_benefit_claim", "max_benefit_amount"]) if sal_struct_row.is_flexible_benefit == 1 and pay_against_benefit_claim != 1: total_pro_rata_max += max_benefit_amount if total_pro_rata_max > 0: diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration_category/employee_tax_exemption_declaration_category.json b/erpnext/hr/doctype/employee_tax_exemption_declaration_category/employee_tax_exemption_declaration_category.json index 56556c1030..7b3b8f5caa 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration_category/employee_tax_exemption_declaration_category.json +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration_category/employee_tax_exemption_declaration_category.json @@ -1,179 +1,179 @@ { - "allow_copy": 0, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, - "beta": 0, - "creation": "2018-04-13 16:56:23.333041", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, - "engine": "InnoDB", + "allow_copy": 0, + "allow_events_in_timeline": 0, + "allow_guest_to_view": 0, + "allow_import": 0, + "allow_rename": 0, + "beta": 0, + "creation": "2018-04-13 16:56:23.333041", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "editable_grid": 1, + "engine": "InnoDB", "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "exemption_sub_category", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Exemption Sub Category", - "length": 0, - "no_copy": 0, - "options": "Employee Tax Exemption Sub Category", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, + "fieldname": "exemption_sub_category", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Exemption Sub Category", + "length": 0, + "no_copy": 0, + "options": "Employee Tax Exemption Sub Category", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, "unique": 0 - }, + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_from": "exemption_sub_category.exemption_category", - "fetch_if_empty": 0, - "fieldname": "exemption_category", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Exemption Category", - "length": 0, - "no_copy": 0, - "options": "Employee Tax Exemption Category", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_from": "exemption_sub_category.exemption_category", + "fetch_if_empty": 0, + "fieldname": "exemption_category", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Exemption Category", + "length": 0, + "no_copy": 0, + "options": "Employee Tax Exemption Category", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, "unique": 0 - }, + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_from": "exemption_sub_category.max_amount", - "fetch_if_empty": 0, - "fieldname": "max_amount", - "fieldtype": "Currency", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Maximum Exemption Amount", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_from": "exemption_sub_category.max_amount", + "fetch_if_empty": 0, + "fieldname": "max_amount", + "fieldtype": "Currency", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Maximum Exempted Amount", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, "unique": 0 - }, + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_if_empty": 0, - "fieldname": "amount", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Declared Amount", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, + "fieldname": "amount", + "fieldtype": "Currency", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Declared Amount", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, "unique": 0 } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 1, - "max_attachments": 0, - "modified": "2019-04-25 15:45:11.279158", - "modified_by": "Administrator", - "module": "HR", - "name": "Employee Tax Exemption Declaration Category", - "name_case": "", - "owner": "Administrator", - "permissions": [], - "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, - "sort_field": "modified", - "sort_order": "DESC", - "track_changes": 1, - "track_seen": 0, + ], + "has_web_view": 0, + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_view": 0, + "in_create": 0, + "is_submittable": 0, + "issingle": 0, + "istable": 1, + "max_attachments": 0, + "modified": "2019-04-26 11:28:14.023086", + "modified_by": "Administrator", + "module": "HR", + "name": "Employee Tax Exemption Declaration Category", + "name_case": "", + "owner": "Administrator", + "permissions": [], + "quick_entry": 1, + "read_only": 0, + "read_only_onload": 0, + "show_name_in_global_search": 0, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1, + "track_seen": 0, "track_views": 0 } \ No newline at end of file diff --git a/erpnext/hr/doctype/payroll_period/payroll_period.json b/erpnext/hr/doctype/payroll_period/payroll_period.json index d3a9612d78..c9bac095f9 100644 --- a/erpnext/hr/doctype/payroll_period/payroll_period.json +++ b/erpnext/hr/doctype/payroll_period/payroll_period.json @@ -1,5 +1,6 @@ { "allow_copy": 0, + "allow_events_in_timeline": 0, "allow_guest_to_view": 0, "allow_import": 1, "allow_rename": 0, @@ -20,6 +21,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "company", "fieldtype": "Link", "hidden": 0, @@ -53,6 +55,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "column_break_2", "fieldtype": "Column Break", "hidden": 0, @@ -84,6 +87,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "start_date", "fieldtype": "Date", "hidden": 0, @@ -116,6 +120,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "end_date", "fieldtype": "Date", "hidden": 0, @@ -148,6 +153,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "section_break_5", "fieldtype": "Section Break", "hidden": 1, @@ -180,6 +186,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "periods", "fieldtype": "Table", "hidden": 0, @@ -213,6 +220,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "section_break_7", "fieldtype": "Section Break", "hidden": 0, @@ -245,6 +253,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "taxable_salary_slabs", "fieldtype": "Table", "hidden": 0, @@ -270,6 +279,39 @@ "set_only_once": 0, "translatable": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fetch_if_empty": 0, + "fieldname": "standard_tax_exemption_amount", + "fieldtype": "Currency", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Standard Tax Exemption Amount", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 } ], "has_web_view": 0, @@ -282,7 +324,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-25 12:29:07.207927", + "modified": "2019-04-26 01:45:03.160929", "modified_by": "Administrator", "module": "HR", "name": "Payroll Period", @@ -354,5 +396,6 @@ "sort_field": "modified", "sort_order": "DESC", "track_changes": 1, - "track_seen": 0 + "track_seen": 0, + "track_views": 0 } \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_component/salary_component.js b/erpnext/hr/doctype/salary_component/salary_component.js index 1d398ccd59..f6afd5efeb 100644 --- a/erpnext/hr/doctype/salary_component/salary_component.js +++ b/erpnext/hr/doctype/salary_component/salary_component.js @@ -5,10 +5,8 @@ frappe.ui.form.on('Salary Component', { setup: function(frm) { frm.set_query("default_account", "accounts", function(doc, cdt, cdn) { var d = locals[cdt][cdn]; - var root_types = ["Expense", "Liability"]; return { filters: { - "root_type": ["in", root_types], "is_group": 0, "company": d.company } diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 1b487a6423..cfc06e35e2 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -107,8 +107,8 @@ class SalarySlip(TransactionBase): for d in self.get("earnings"): if d.is_flexible_benefit == 1: current_flexi_amount += d.amount - last_benefits = get_last_payroll_period_benefits(self.employee, self.start_date, self.end_date,\ - current_flexi_amount, payroll_period, self._salary_structure_doc) + last_benefits = get_last_payroll_period_benefits(self.employee, self.start_date, self.end_date, + current_flexi_amount, payroll_period, self._salary_structure_doc) if last_benefits: for last_benefit in last_benefits: last_benefit = frappe._dict(last_benefit) @@ -118,7 +118,7 @@ class SalarySlip(TransactionBase): def add_employee_flexi_benefits(self, struct_row): if frappe.db.get_value("Salary Component", struct_row.salary_component, "pay_against_benefit_claim") != 1: benefit_component_amount = get_benefit_component_amount(self.employee, self.start_date, self.end_date, \ - struct_row, self._salary_structure_doc, self.total_working_days, self.payroll_frequency) + struct_row, self._salary_structure_doc, self.total_working_days, self.payroll_frequency) if benefit_component_amount: self.update_component_row(struct_row, benefit_component_amount, "earnings") else: @@ -418,7 +418,7 @@ class SalarySlip(TransactionBase): for d in self.get(component_type): if (self.salary_structure and - cint(d.depends_on_payment_days) and + cint(d.depends_on_payment_days) and cint(self.total_working_days) and (not self.salary_slip_based_on_timesheet or getdate(self.start_date) < joining_date or @@ -593,7 +593,7 @@ class SalarySlip(TransactionBase): unclaimed_earning = self.calculate_unclaimed_taxable_earning(payroll_period, tax_component) earning_in_period = taxable_earning["taxable_earning"] + unclaimed_earning period_factor = self.get_period_factor(payroll_period.start_date, payroll_period.end_date, - payroll_period.start_date, self.end_date) + payroll_period.start_date, self.end_date) annual_taxable_earning = earning_in_period * period_factor additional_income += self.get_total_additional_income(payroll_period.start_date) else: @@ -607,6 +607,7 @@ class SalarySlip(TransactionBase): {"employee": self.employee, "payroll_period": payroll_period.name, "docstatus": 1}, "total_exemption_amount") annual_taxable_earning = annual_earning - exemption_amount + if self.deduct_tax_for_unclaimed_employee_benefits or self.deduct_tax_for_unsubmitted_tax_exemption_proof: tax_detail = self.get_tax_paid_in_period(payroll_period, tax_component) if tax_detail: @@ -616,11 +617,17 @@ class SalarySlip(TransactionBase): # add any additional income in this slip additional_income += taxable_earning["additional_income"] - args = {"payroll_period": payroll_period.name, "tax_component": tax_component, - "annual_taxable_earning": annual_taxable_earning, "period_factor": period_factor, - "unclaimed_benefit": unclaimed_benefit, "additional_income": additional_income, - "pro_rata_tax_paid": pro_rata_tax_paid, "benefit_tax_paid": benefit_tax_paid, - "additional_tax_paid": additional_tax_paid} + args = { + "payroll_period": payroll_period.name, + "tax_component": tax_component, + "period_factor": period_factor, + "annual_taxable_earning": annual_taxable_earning, + "additional_income": additional_income, + "unclaimed_benefit": unclaimed_benefit, + "pro_rata_tax_paid": pro_rata_tax_paid, + "benefit_tax_paid": benefit_tax_paid, + "additional_tax_paid": additional_tax_paid + } return self.calculate_tax(args) def calculate_unclaimed_taxable_benefit(self, payroll_period): @@ -667,27 +674,49 @@ class SalarySlip(TransactionBase): return total_taxable_earning def get_total_additional_income(self, from_date): - total_additional_pay = 0 - sum_additional_earning = frappe.db.sql("""select sum(sd.amount) from `tabSalary Detail` sd join - `tabSalary Slip` ss on sd.parent=ss.name where sd.parentfield='earnings' - and sd.is_tax_applicable=1 and is_additional_component=1 and is_flexible_benefit=0 - and ss.docstatus=1 and ss.employee='{0}' and ss.start_date between '{1}' and '{2}' - and ss.end_date between '{1}' and '{2}'""".format(self.employee, - from_date, self.start_date)) - if sum_additional_earning and sum_additional_earning[0][0]: - total_additional_pay = sum_additional_earning[0][0] - return total_additional_pay + sum_additional_earning = frappe.db.sql(""" + select sum(sd.amount) + from + `tabSalary Detail` sd join `tabSalary Slip` ss on sd.parent=ss.name + where + sd.parentfield='earnings' + and sd.is_tax_applicable=1 and is_additional_component=1 + and is_flexible_benefit=0 and ss.docstatus=1 + and ss.employee=%(employee)s + and ss.start_date between %(from_date)s and %(to_date)s + and ss.end_date between %(from_date)s and %(to_date)s + """, { + "employee": self.employee, + "from_date": from_date, + "to_date": self.start_date + }) + return sum_additional_earning[0][0] if sum_additional_earning else 0 def get_tax_paid_in_period(self, payroll_period, tax_component, only_total=False): # find total_tax_paid, tax paid for benefit, additional_salary - sum_tax_paid = frappe.db.sql("""select sum(sd.amount), sum(tax_on_flexible_benefit), - sum(tax_on_additional_salary) from `tabSalary Detail` sd join `tabSalary Slip` - ss on sd.parent=ss.name where sd.parentfield='deductions' and sd.salary_component='{3}' - and sd.variable_based_on_taxable_salary=1 and ss.docstatus=1 and ss.employee='{0}' - and ss.start_date between '{1}' and '{2}' and ss.end_date between '{1}' and - '{2}'""".format(self.employee, payroll_period.start_date, self.start_date, tax_component)) + sum_tax_paid = frappe.db.sql(""" + select + sum(sd.amount), sum(tax_on_flexible_benefit), sum(tax_on_additional_salary) + from + `tabSalary Detail` sd join `tabSalary Slip` ss on sd.parent=ss.name + where + sd.parentfield='deductions' and sd.salary_component=%(salary_component)s + and sd.variable_based_on_taxable_salary=1 + and ss.docstatus=1 and ss.employee=%(employee)s + and ss.start_date between %(from_date)s and %(to_date)s + and ss.end_date between %(from_date)s and %(to_date)s + """, { + "salary_component": tax_component, + "employee": self.employee, + "from_date": payroll_period.start_date, + "to_date": self.start_date + }) if sum_tax_paid and sum_tax_paid[0][0]: - return {'total_tax_paid': sum_tax_paid[0][0], 'benefit_tax':sum_tax_paid[0][1], 'additional_tax': sum_tax_paid[0][2]} + return { + 'total_tax_paid': sum_tax_paid[0][0], + 'benefit_tax':sum_tax_paid[0][1], + 'additional_tax': sum_tax_paid[0][2] + } def get_taxable_earnings(self, include_flexi=0, only_flexi=0): taxable_earning = 0 @@ -698,22 +727,22 @@ class SalarySlip(TransactionBase): additional_income += earning.amount continue if only_flexi: - if earning.is_tax_applicable and earning.is_flexible_benefit: + if earning.is_flexible_benefit: taxable_earning += earning.amount continue - if include_flexi: - if earning.is_tax_applicable or (earning.is_tax_applicable and earning.is_flexible_benefit): - taxable_earning += earning.amount - else: - if earning.is_tax_applicable and not earning.is_flexible_benefit: - taxable_earning += earning.amount - return {"taxable_earning": taxable_earning, "additional_income": additional_income} + if include_flexi or not earning.is_flexible_benefit: + taxable_earning += earning.amount + return { + "taxable_earning": taxable_earning, + "additional_income": additional_income + } def calculate_tax(self, args): tax_amount, benefit_tax, additional_tax = 0, 0, 0 annual_taxable_earning = args.get("annual_taxable_earning") benefit_to_tax = args.get("unclaimed_benefit") additional_income = args.get("additional_income") + # Get tax calc by period annual_tax = self.calculate_tax_by_tax_slab(args.get("payroll_period"), annual_taxable_earning) @@ -744,8 +773,10 @@ class SalarySlip(TransactionBase): def calculate_tax_by_tax_slab(self, payroll_period, annual_taxable_earning): payroll_period_obj = frappe.get_doc("Payroll Period", payroll_period) + annual_taxable_earning -= flt(payroll_period_obj.standard_tax_exemption_amount) data = self.get_data_for_eval() data.update({"annual_taxable_earning": annual_taxable_earning}) + taxable_amount = 0 for slab in payroll_period_obj.taxable_salary_slabs: if slab.condition and not self.eval_tax_slab_condition(slab.condition, data): diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py index 746bf8cff1..75c1e420b8 100644 --- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py @@ -159,21 +159,21 @@ class TestSalarySlip(unittest.TestCase): month = "%02d" % getdate(nowdate()).month m = get_month_details(fiscal_year, month) - for payroll_frequncy in ["Monthly", "Bimonthly", "Fortnightly", "Weekly", "Daily"]: - make_employee(payroll_frequncy + "_test_employee@salary.com") - ss = make_employee_salary_slip(payroll_frequncy + "_test_employee@salary.com", payroll_frequncy) - if payroll_frequncy == "Monthly": + for payroll_frequency in ["Monthly", "Bimonthly", "Fortnightly", "Weekly", "Daily"]: + make_employee(payroll_frequency + "_test_employee@salary.com") + ss = make_employee_salary_slip(payroll_frequency + "_test_employee@salary.com", payroll_frequency) + if payroll_frequency == "Monthly": self.assertEqual(ss.end_date, m['month_end_date']) - elif payroll_frequncy == "Bimonthly": + elif payroll_frequency == "Bimonthly": if getdate(ss.start_date).day <= 15: self.assertEqual(ss.end_date, m['month_mid_end_date']) else: self.assertEqual(ss.end_date, m['month_end_date']) - elif payroll_frequncy == "Fortnightly": + elif payroll_frequency == "Fortnightly": self.assertEqual(ss.end_date, add_days(nowdate(),13)) - elif payroll_frequncy == "Weekly": + elif payroll_frequency == "Weekly": self.assertEqual(ss.end_date, add_days(nowdate(),6)) - elif payroll_frequncy == "Daily": + elif payroll_frequency == "Daily": self.assertEqual(ss.end_date, nowdate()) def test_tax_for_payroll_period(self): diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py index 26efd00d47..3431d3d4a8 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/salary_structure.py @@ -57,11 +57,12 @@ class SalaryStructure(Document): have_a_flexi = True max_of_component = frappe.db.get_value("Salary Component", earning_component.salary_component, "max_benefit_amount") flexi_amount += max_of_component + if have_a_flexi and flt(self.max_benefits) == 0: frappe.throw(_("Max benefits should be greater than zero to dispense benefits")) - if have_a_flexi and flt(self.max_benefits) > flexi_amount: - frappe.throw(_("Total flexible benefit component amount {0} should not be less \ - than max benefits {1}").format(flexi_amount, self.max_benefits)) + if have_a_flexi and flexi_amount and flt(self.max_benefits) > flexi_amount: + frappe.throw(_("Total flexible benefit component amount {0} should not be less than max benefits {1}") + .format(flexi_amount, self.max_benefits)) if not have_a_flexi and flt(self.max_benefits) > 0: frappe.throw(_("Salary Structure should have flexible benefit component(s) to dispense benefit amount")) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 6daa85fb85..9787dc8c64 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -568,7 +568,7 @@ execute:frappe.delete_doc_if_exists("Page", "sales-analytics") execute:frappe.delete_doc_if_exists("Page", "purchase-analytics") execute:frappe.delete_doc_if_exists("Page", "stock-analytics") execute:frappe.delete_doc_if_exists("Page", "production-analytics") -erpnext.patches.v11_0.ewaybill_fields_gst_india #2018-11-13 #2019-01-09 #2019-04-01 +erpnext.patches.v11_0.ewaybill_fields_gst_india #2018-11-13 #2019-01-09 #2019-04-01 #2019-04-26 erpnext.patches.v11_0.drop_column_max_days_allowed erpnext.patches.v10_0.update_user_image_in_employee erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items From 5762a5d8b61932578e8d6e3e780815357cfb16d6 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 1 May 2019 10:59:02 +0530 Subject: [PATCH 17/19] fix: Null handling --- erpnext/hr/doctype/salary_slip/salary_slip.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index cfc06e35e2..fbfa3af6cd 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -577,8 +577,8 @@ class SalarySlip(TransactionBase): def calculate_variable_tax(self, tax_component, payroll_period): annual_taxable_earning, period_factor = 0, 0 - pro_rata_tax_paid, additional_tax_paid, benefit_tax_paid = 0, 0, 0 - unclaimed_earning, unclaimed_benefit, additional_income = 0, 0, 0 + pro_rata_tax_paid, additional_tax_paid, benefit_tax_paid = 0.0, 0.0, 0.0 + unclaimed_earning, unclaimed_benefit, additional_income = 0.0, 0.0, 0.0 # get taxable_earning, additional_income in this slip taxable_earning = self.get_taxable_earnings() @@ -690,7 +690,7 @@ class SalarySlip(TransactionBase): "from_date": from_date, "to_date": self.start_date }) - return sum_additional_earning[0][0] if sum_additional_earning else 0 + return flt(sum_additional_earning[0][0]) if sum_additional_earning else 0 def get_tax_paid_in_period(self, payroll_period, tax_component, only_total=False): # find total_tax_paid, tax paid for benefit, additional_salary From b9b2a0684748a47bc66ee8123982d20162630cb3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 1 May 2019 12:49:44 +0530 Subject: [PATCH 18/19] moved deferred accounting monthly job to long job --- erpnext/hooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 85f2804f27..8ae9267b64 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -269,7 +269,7 @@ scheduler_events = { "daily_long": [ "erpnext.manufacturing.doctype.bom_update_tool.bom_update_tool.update_latest_price_in_all_boms" ], - "monthly": [ + "monthly_long": [ "erpnext.accounts.deferred_revenue.convert_deferred_revenue_to_income", "erpnext.accounts.deferred_revenue.convert_deferred_expense_to_expense", "erpnext.hr.utils.allocate_earned_leaves" From 316c3b3f9dc53b6273ceb403e736d19a37e7a648 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 1 May 2019 13:26:24 +0530 Subject: [PATCH 19/19] fix: Fetch exchange rate from invoice on server side --- .../payment_entry_reference.json | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json b/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json index f1553990ea..a752c6f9a1 100644 --- a/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json +++ b/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json @@ -20,6 +20,7 @@ "bold": 0, "collapsible": 0, "columns": 2, + "fetch_if_empty": 0, "fieldname": "reference_doctype", "fieldtype": "Link", "hidden": 0, @@ -53,6 +54,7 @@ "bold": 0, "collapsible": 0, "columns": 2, + "fetch_if_empty": 0, "fieldname": "reference_name", "fieldtype": "Dynamic Link", "hidden": 0, @@ -86,6 +88,8 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_from": "reference_name.due_date", + "fetch_if_empty": 0, "fieldname": "due_date", "fieldtype": "Date", "hidden": 0, @@ -119,6 +123,7 @@ "collapsible": 0, "columns": 0, "depends_on": "", + "fetch_if_empty": 0, "fieldname": "bill_no", "fieldtype": "Data", "hidden": 0, @@ -151,6 +156,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "fetch_if_empty": 0, "fieldname": "column_break_4", "fieldtype": "Column Break", "hidden": 0, @@ -182,6 +188,7 @@ "bold": 0, "collapsible": 0, "columns": 2, + "fetch_if_empty": 0, "fieldname": "total_amount", "fieldtype": "Float", "hidden": 0, @@ -214,6 +221,7 @@ "bold": 0, "collapsible": 0, "columns": 2, + "fetch_if_empty": 0, "fieldname": "outstanding_amount", "fieldtype": "Float", "hidden": 0, @@ -246,6 +254,7 @@ "bold": 0, "collapsible": 0, "columns": 2, + "fetch_if_empty": 0, "fieldname": "allocated_amount", "fieldtype": "Float", "hidden": 0, @@ -279,6 +288,8 @@ "collapsible": 0, "columns": 0, "depends_on": "eval:(doc.reference_doctype=='Purchase Invoice')", + "fetch_from": "reference_name.conversion_rate", + "fetch_if_empty": 0, "fieldname": "exchange_rate", "fieldtype": "Float", "hidden": 0, @@ -315,7 +326,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2019-01-07 16:52:06.884796", + "modified": "2019-05-01 13:24:56.586677", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Entry Reference",