From 126a02e2084cd7c5e9d3035d38692a068e2ff8f8 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 2 Jul 2019 15:28:57 +0530 Subject: [PATCH 01/16] fix: set invoice status considering invoice discounting --- .../discounted_invoice.json | 147 +--- .../invoice_discounting.json | 674 ++---------------- .../invoice_discounting.py | 33 +- .../doctype/journal_entry/journal_entry.py | 18 +- .../doctype/sales_invoice/sales_invoice.js | 13 +- .../doctype/sales_invoice/sales_invoice.json | 13 +- .../doctype/sales_invoice/sales_invoice.py | 66 +- .../sales_invoice/sales_invoice_list.js | 23 +- .../doctype/purchase_order/purchase_order.py | 1 - erpnext/controllers/status_updater.py | 2 + 10 files changed, 206 insertions(+), 784 deletions(-) diff --git a/erpnext/accounts/doctype/discounted_invoice/discounted_invoice.json b/erpnext/accounts/doctype/discounted_invoice/discounted_invoice.json index 0d04b19fd1..8d7ed74eb9 100644 --- a/erpnext/accounts/doctype/discounted_invoice/discounted_invoice.json +++ b/erpnext/accounts/doctype/discounted_invoice/discounted_invoice.json @@ -1,177 +1,64 @@ { - "allow_copy": 0, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, - "beta": 0, "creation": "2019-03-07 12:07:09.416101", - "custom": 0, - "docstatus": 0, "doctype": "DocType", - "document_type": "", "editable_grid": 1, "engine": "InnoDB", + "field_order": [ + "sales_invoice", + "customer", + "column_break_3", + "posting_date", + "outstanding_amount" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "sales_invoice", "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": "Invoice", - "length": 0, - "no_copy": 0, "options": "Sales Invoice", - "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 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fetch_from": "sales_invoice.customer", "fieldname": "customer", "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": "Customer", - "length": 0, - "no_copy": 0, "options": "Customer", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "read_only": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fetch_from": "sales_invoice.posting_date", "fieldname": "posting_date", "fieldtype": "Date", - "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": "Date", - "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": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "read_only": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fetch_from": "sales_invoice.grand_total", "fieldname": "outstanding_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": "Outstanding Amount", - "length": 0, - "no_copy": 0, "options": "Company:company:default_currency", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "read_only": 1 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break" } ], - "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-03-07 16:38:03.622666", + "modified": "2019-05-30 19:27:29.436153", "modified_by": "Administrator", "module": "Accounts", "name": "Discounted Invoice", - "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 + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.json b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.json index 8927ca708d..3bfe259432 100644 --- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.json +++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.json @@ -1,744 +1,177 @@ { - "allow_copy": 0, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, "allow_import": 1, - "allow_rename": 0, "autoname": "ACC-INV-DISC-.YYYY.-.#####", - "beta": 0, "creation": "2019-03-07 12:01:56.296952", - "custom": 0, - "docstatus": 0, "doctype": "DocType", - "document_type": "", "editable_grid": 1, "engine": "InnoDB", + "field_order": [ + "posting_date", + "loan_start_date", + "loan_period", + "loan_end_date", + "column_break_3", + "status", + "company", + "section_break_5", + "invoices", + "section_break_7", + "total_amount", + "column_break_9", + "bank_charges", + "section_break_6", + "short_term_loan", + "bank_account", + "bank_charges_account", + "column_break_15", + "accounts_receivable_credit", + "accounts_receivable_discounted", + "accounts_receivable_unpaid", + "amended_from" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, + "default": "Today", "fieldname": "posting_date", "fieldtype": "Date", - "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": "Posting Date", - "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 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "loan_start_date", "fieldtype": "Date", - "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": "Loan Start Date", - "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 + "label": "Loan Start Date" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "loan_period", "fieldtype": "Int", - "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": "Loan Period", - "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 + "label": "Loan Period (Days)" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "loan_end_date", "fieldtype": "Date", - "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": "Loan End Date", - "length": 0, "no_copy": 1, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "read_only": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "column_break_3", - "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 + "fieldtype": "Column Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "status", "fieldtype": "Select", - "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": "Status", - "length": 0, "no_copy": 1, "options": "Draft\nSanctioned\nDisbursed\nSettled\nCancelled", - "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 + "read_only": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "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": 0, "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": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "section_break_5", - "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 + "fieldtype": "Section Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "invoices", "fieldtype": "Table", - "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": "Invoices", - "length": 0, - "no_copy": 0, "options": "Discounted Invoice", - "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 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "section_break_7", - "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 + "fieldtype": "Section Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "total_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": "Total Amount", - "length": 0, - "no_copy": 0, "options": "Company:company:default_currency", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "read_only": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "column_break_9", - "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 + "fieldtype": "Column Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "bank_charges", "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": "Bank Charges", - "length": 0, - "no_copy": 0, - "options": "Company:company:default_currency", - "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 + "options": "Company:company:default_currency" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "section_break_6", - "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 + "fieldtype": "Section Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "short_term_loan", "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": "Short Term Loan 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 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "bank_account", "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 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 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "bank_charges_account", "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 Charges 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 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "column_break_15", - "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 + "fieldtype": "Column Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "accounts_receivable_credit", "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": "Accounts Receivable Credit 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 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "accounts_receivable_discounted", "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": "Accounts Receivable Discounted 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 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "accounts_receivable_unpaid", "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": "Accounts Receivable Unpaid 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 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "amended_from", "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": "Amended From", - "length": 0, "no_copy": 1, "options": "Invoice Discounting", - "permlevel": 0, "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "read_only": 1 } ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, "is_submittable": 1, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2019-03-08 14:24:31.222027", + "modified": "2019-05-30 19:08:21.199759", "modified_by": "Administrator", "module": "Accounts", "name": "Invoice Discounting", - "name_case": "", "owner": "Administrator", "permissions": [ { @@ -748,26 +181,17 @@ "delete": 1, "email": 1, "export": 1, - "if_owner": 0, "import": 1, - "permlevel": 0, "print": 1, "read": 1, "report": 1, "role": "System Manager", - "set_user_permissions": 0, "share": 1, "submit": 1, "write": 1 } ], - "quick_entry": 0, - "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 + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py index c8756af7d7..29475d5644 100644 --- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py +++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py @@ -28,18 +28,39 @@ class InvoiceDiscounting(AccountsController): self.total_amount = sum([flt(d.outstanding_amount) for d in self.invoices]) def on_submit(self): + self.update_sales_invoice() self.make_gl_entries() def on_cancel(self): self.set_status() + self.update_sales_invoice() self.make_gl_entries() - def set_status(self): - self.status = "Draft" - if self.docstatus == 1: - self.status = "Sanctioned" - elif self.docstatus == 2: - self.status = "Cancelled" + def set_status(self, status=None): + if status: + self.status = status + self.db_set("status", status) + for d in self.invoices: + frappe.get_doc("Sales Invoice", d.sales_invoice).set_status(update=True, update_modified=False) + else: + self.status = "Draft" + if self.docstatus == 1: + self.status = "Sanctioned" + elif self.docstatus == 2: + self.status = "Cancelled" + + def update_sales_invoice(self): + for d in self.invoices: + if self.docstatus == 1: + is_discounted = 1 + else: + discounted_invoice = frappe.db.exists({ + "doctype": "Discounted Invoice", + "sales_invoice": d.sales_invoice, + "docstatus": 1 + }) + is_discounted = 1 if discounted_invoice else 0 + frappe.db.set_value("Sales Invoice", d.sales_invoice, "is_discounted", is_discounted) def make_gl_entries(self): company_currency = frappe.get_cached_value('Company', self.company, "default_currency") diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index d082b60211..a9929c379d 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -105,24 +105,28 @@ class JournalEntry(AccountsController): invoice_discounting_list = list(set([d.reference_name for d in self.accounts if d.reference_type=="Invoice Discounting"])) for inv_disc in invoice_discounting_list: - short_term_loan_account, id_status = frappe.db.get_value("Invoice Discounting", inv_disc, ["short_term_loan", "status"]) + inv_disc_doc = frappe.get_doc("Invoice Discounting", inv_disc) + status = None for d in self.accounts: - if d.account == short_term_loan_account and d.reference_name == inv_disc: + if d.account == inv_disc_doc.short_term_loan and d.reference_name == inv_disc: if self.docstatus == 1: if d.credit > 0: - _validate_invoice_discounting_status(inv_disc, id_status, "Sanctioned", d.idx) + _validate_invoice_discounting_status(inv_disc, inv_disc_doc.status, "Sanctioned", d.idx) status = "Disbursed" elif d.debit > 0: - _validate_invoice_discounting_status(inv_disc, id_status, "Disbursed", d.idx) + _validate_invoice_discounting_status(inv_disc, inv_disc_doc.status, "Disbursed", d.idx) status = "Settled" else: if d.credit > 0: - _validate_invoice_discounting_status(inv_disc, id_status, "Disbursed", d.idx) + _validate_invoice_discounting_status(inv_disc, inv_disc_doc.status, "Disbursed", d.idx) status = "Sanctioned" elif d.debit > 0: - _validate_invoice_discounting_status(inv_disc, id_status, "Settled", d.idx) + _validate_invoice_discounting_status(inv_disc, inv_disc_doc.status, "Settled", d.idx) status = "Disbursed" - frappe.db.set_value("Invoice Discounting", inv_disc, "status", status) + break + if status: + inv_disc_doc.set_status(status=status) + def unlink_advance_entry_reference(self): for d in self.get("accounts"): diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 07494a27d6..eaf59d3bf5 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -83,10 +83,14 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } } - if (doc.outstanding_amount>0 && !cint(doc.is_return)) { + if (doc.outstanding_amount>0) { cur_frm.add_custom_button(__('Payment Request'), function() { me.make_payment_request(); }, __('Create')); + + cur_frm.add_custom_button(__('Invoice Discounting'), function() { + cur_frm.events.create_invoice_discounting(cur_frm); + }, __('Create')); } if (doc.docstatus === 1) { @@ -804,6 +808,13 @@ frappe.ui.form.on('Sales Invoice', { frm.set_df_property("patient_name", "hidden", 1); frm.set_df_property("ref_practitioner", "hidden", 1); } + }, + + create_invoice_discounting: function(frm) { + frappe.model.open_mapped_doc({ + method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_invoice_discounting", + frm: frm + }); } }) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index 292d95d7b6..c0a1abd785 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -155,6 +155,7 @@ "inter_company_invoice_reference", "customer_group", "campaign", + "is_discounted", "col_break23", "status", "source", @@ -1336,7 +1337,7 @@ "in_standard_filter": 1, "label": "Status", "no_copy": 1, - "options": "\nDraft\nReturn\nCredit Note Issued\nSubmitted\nPaid\nUnpaid\nOverdue\nCancelled", + "options": "\nDraft\nReturn\nCredit Note Issued\nSubmitted\nPaid\nUnpaid\nUnpaid and Discounted\nOverdue and Discounted\nOverdue\nOverdue\nCancelled", "print_hide": 1, "read_only": 1 }, @@ -1553,12 +1554,20 @@ { "fieldname": "dimension_col_break", "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "is_discounted", + "fieldtype": "Check", + "label": "Is Discounted", + "no_copy": 1, + "read_only": 1 } ], "icon": "fa fa-file-text", "idx": 181, "is_submittable": 1, - "modified": "2019-05-25 22:05:03.474745", + "modified": "2019-07-02 15:21:40.257028", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index d6cf5d8b90..54e127d2f4 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1174,6 +1174,56 @@ class SalesInvoice(SellingController): self.set_missing_values(for_validate = True) + def get_discounting_status(self): + status = None + if self.is_discounted: + invoice_discounting_list = frappe.db.sql(""" + select status + from `tabInvoice Discounting` id, `tabDiscounted Invoice` d + where + id.name = d.parent + and d.sales_invoice=%s + and id.docstatus=1 + and status in ('Disbursed', 'Settled') + """, self.name) + for d in invoice_discounting_list: + status = d[0] + if status == "Disbursed": + break + return status + + def set_status(self, update=False, status=None, update_modified=True): + if self.is_new(): + if self.get('amended_from'): + self.status = 'Draft' + return + + if not status: + if self.docstatus == 2: + status = "Cancelled" + elif self.docstatus == 1: + if flt(self.outstanding_amount) > 0 and getdate(self.due_date) < getdate(nowdate()) and self.is_discounted and self.get_discounting_status()=='Disbursed': + self.status = "Overdue and Discounted" + elif self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()): + self.status = "Overdue" + elif self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.is_discounted and self.get_discounting_status()=='Disbursed': + self.status = "Unpaid and Discounted" + elif self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()): + self.status = "Unpaid" + elif self.outstanding_amount < 0 and self.is_return==0 and get_value('Sales Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1}): + self.status = "Credit Note Issued" + elif self.outstanding_amount<=0 and self.is_return==0: + self.status = "Paid" + elif self.is_return == 1: + self.status = "Return" + else: + self.status = "Submitted" + else: + self.status = "Draft" + + if update: + self.db_set('status', self.status, update_modified = update_modified) + def validate_inter_company_party(doctype, party, company, inter_company_reference): if not party: return @@ -1428,4 +1478,18 @@ def get_loyalty_programs(customer): frappe.db.set(customer, 'loyalty_program', lp_details[0]) return [] else: - return lp_details \ No newline at end of file + return lp_details + +@frappe.whitelist() +def create_invoice_discounting(source_name, target_doc=None): + invoice = frappe.get_doc("Sales Invoice", source_name) + invoice_discounting = frappe.new_doc("Invoice Discounting") + invoice_discounting.company = invoice.company + invoice_discounting.append("invoices", { + "sales_invoice": source_name, + "customer": invoice.customer, + "posting_date": invoice.posting_date, + "outstanding_amount": invoice.outstanding_amount + }) + + return invoice_discounting \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js index 3c9c4b428d..05d49df711 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js @@ -6,17 +6,18 @@ frappe.listview_settings['Sales Invoice'] = { add_fields: ["customer", "customer_name", "base_grand_total", "outstanding_amount", "due_date", "company", "currency", "is_return"], get_indicator: function(doc) { - if(cint(doc.is_return)==1) { - return [__("Return"), "darkgrey", "is_return,=,Yes"]; - } else if(flt(doc.outstanding_amount)==0) { - return [__("Paid"), "green", "outstanding_amount,=,0"] - } else if(flt(doc.outstanding_amount) < 0) { - return [__("Credit Note Issued"), "darkgrey", "outstanding_amount,<,0"] - }else if (flt(doc.outstanding_amount) > 0 && doc.due_date >= frappe.datetime.get_today()) { - return [__("Unpaid"), "orange", "outstanding_amount,>,0|due_date,>,Today"] - } else if (flt(doc.outstanding_amount) > 0 && doc.due_date < frappe.datetime.get_today()) { - return [__("Overdue"), "red", "outstanding_amount,>,0|due_date,<=,Today"] - } + var status_color = { + "Draft": "grey", + "Unpaid": "orange", + "Paid": "green", + "Return": "darkgrey", + "Credit Note Issued": "darkgrey", + "Unpaid and Discounted": "orange", + "Overdue and Discounted": "red", + "Overdue": "red" + + }; + return [__(doc.status), status_color[doc.status], "status,=,"+doc.status]; }, right_column: "grand_total" }; diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index a9a2094f08..8117d9d514 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -510,4 +510,3 @@ def update_status(status, name): def make_inter_company_sales_order(source_name, target_doc=None): from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_inter_company_transaction return make_inter_company_transaction("Purchase Order", source_name, target_doc) - diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 42e0a43e6e..c7542a8951 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -50,7 +50,9 @@ status_map = { ["Paid", "eval:self.outstanding_amount<=0 and self.docstatus==1 and self.is_return==0"], ["Credit Note Issued", "eval:self.outstanding_amount < 0 and self.docstatus==1 and self.is_return==0 and get_value('Sales Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1})"], ["Unpaid", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1"], + ["Unpaid and Discounted", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1 and self.is_discounted and self.discounting_status=='Disbursed'"], ["Overdue", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1"], + ["Overdue and Discounted", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1 and self.is_discounted and self.discounting_status=='Disbursed'"], ["Cancelled", "eval:self.docstatus==2"], ], "Purchase Invoice": [ From 3bbcd491e4e1ccabddef3051796beae93834c16c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 2 Jul 2019 15:31:24 +0530 Subject: [PATCH 02/16] fix: set invoice status considering invoice discounting --- erpnext/controllers/status_updater.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index c7542a8951..db6460f00c 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -43,18 +43,6 @@ status_map = { ["Closed", "eval:self.status=='Closed'"], ["On Hold", "eval:self.status=='On Hold'"], ], - "Sales Invoice": [ - ["Draft", None], - ["Submitted", "eval:self.docstatus==1"], - ["Return", "eval:self.is_return==1 and self.docstatus==1"], - ["Paid", "eval:self.outstanding_amount<=0 and self.docstatus==1 and self.is_return==0"], - ["Credit Note Issued", "eval:self.outstanding_amount < 0 and self.docstatus==1 and self.is_return==0 and get_value('Sales Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1})"], - ["Unpaid", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1"], - ["Unpaid and Discounted", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1 and self.is_discounted and self.discounting_status=='Disbursed'"], - ["Overdue", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1"], - ["Overdue and Discounted", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1 and self.is_discounted and self.discounting_status=='Disbursed'"], - ["Cancelled", "eval:self.docstatus==2"], - ], "Purchase Invoice": [ ["Draft", None], ["Submitted", "eval:self.docstatus==1"], From 05fee62314957890b0772c2d2fa3f4f8266303a5 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 2 Jul 2019 17:55:26 +0530 Subject: [PATCH 03/16] fix: inv status --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 54e127d2f4..43bbfab130 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1210,7 +1210,7 @@ class SalesInvoice(SellingController): self.status = "Unpaid and Discounted" elif self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()): self.status = "Unpaid" - elif self.outstanding_amount < 0 and self.is_return==0 and get_value('Sales Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1}): + elif self.outstanding_amount < 0 and self.is_return==0 and frappe.db.get_value('Sales Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1}): self.status = "Credit Note Issued" elif self.outstanding_amount<=0 and self.is_return==0: self.status = "Paid" From d5fcab5f8197325c775eebd3a24ead49713f8a25 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 15 Jul 2019 12:44:11 +0530 Subject: [PATCH 04/16] fix: Set taxes fix for lead --- erpnext/public/js/utils/party.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/utils/party.js b/erpnext/public/js/utils/party.js index 35185c90b6..a8d3888ba0 100644 --- a/erpnext/public/js/utils/party.js +++ b/erpnext/public/js/utils/party.js @@ -145,7 +145,7 @@ erpnext.utils.set_taxes_from_address = function(frm, triggered_from_field, billi erpnext.utils.set_taxes = function(frm, triggered_from_field) { if(frappe.meta.get_docfield(frm.doc.doctype, "taxes")) { if(!erpnext.utils.validate_mandatory(frm, "Lead/Customer/Supplier", - frm.doc.customer || frm.doc.supplier || frm.doc.lead, triggered_from_field)) { + frm.doc.customer || frm.doc.supplier || frm.doc.lead || frm.doc.party_name, triggered_from_field)) { return; } From eac54612296dc3cd02dc5711dc24fa1bfb11bcce Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 15 Jul 2019 13:55:08 +0530 Subject: [PATCH 05/16] fix: Address filtering fix in opportunity --- erpnext/crm/doctype/opportunity/opportunity.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js index 9dcd0c493a..90a12b7dbd 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -19,6 +19,10 @@ frappe.ui.form.on("Opportunity", { } } }); + + if (frm.doc.opportunity_from && frm.doc.party_name){ + frm.trigger('set_contact_link'); + } }, onload_post_render: function(frm) { From 5435b7e9eb0326ffa9f866567e95fc3f0726ab3a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 15 Jul 2019 13:56:09 +0530 Subject: [PATCH 06/16] fix: Null issue --- .../accounts/doctype/sales_invoice/sales_invoice.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index b686c67fee..7d2861b230 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1203,17 +1203,17 @@ class SalesInvoice(SellingController): elif self.docstatus == 1: if flt(self.outstanding_amount) > 0 and getdate(self.due_date) < getdate(nowdate()) and self.is_discounted and self.get_discounting_status()=='Disbursed': self.status = "Overdue and Discounted" - elif self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()): + elif flt(self.outstanding_amount) > 0 and getdate(self.due_date) < getdate(nowdate()): self.status = "Overdue" - elif self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.is_discounted and self.get_discounting_status()=='Disbursed': + elif flt(self.outstanding_amount) > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.is_discounted and self.get_discounting_status()=='Disbursed': self.status = "Unpaid and Discounted" - elif self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()): + elif flt(self.outstanding_amount) > 0 and getdate(self.due_date) >= getdate(nowdate()): self.status = "Unpaid" - elif self.outstanding_amount < 0 and self.is_return==0 and frappe.db.get_value('Sales Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1}): + elif flt(self.outstanding_amount) < 0 and self.is_return==0 and frappe.db.get_value('Sales Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1}): self.status = "Credit Note Issued" elif self.is_return == 1: self.status = "Return" - elif self.outstanding_amount<=0: + elif flt(self.outstanding_amount)<=0: self.status = "Paid" else: self.status = "Submitted" From ec810a4a55eb9b3036f04716f805584e081fe07f Mon Sep 17 00:00:00 2001 From: sahil28297 <37302950+sahil28297@users.noreply.github.com> Date: Mon, 15 Jul 2019 16:54:41 +0530 Subject: [PATCH 07/16] fix(product_page): compare type as well and provide base class for parseInt (#18332) --- erpnext/templates/includes/product_page.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/erpnext/templates/includes/product_page.js b/erpnext/templates/includes/product_page.js index af98fc7987..65949bb18c 100644 --- a/erpnext/templates/includes/product_page.js +++ b/erpnext/templates/includes/product_page.js @@ -29,10 +29,10 @@ frappe.ready(function() { .html(r.message.product_info.price.formatted_price_sales_uom + "
\ (" + r.message.product_info.price.formatted_price + " / " + r.message.product_info.uom + ")
"); - if(r.message.product_info.in_stock==0) { + if(r.message.product_info.in_stock===0) { $(".item-stock").html("
{{ _("Not in stock") }}
"); } - else if(r.message.product_info.in_stock==1) { + else if(r.message.product_info.in_stock===1) { var qty_display = "{{ _("In stock") }}"; if (r.message.product_info.show_stock_qty) { qty_display += " ("+r.message.product_info.stock_qty+")"; @@ -75,13 +75,13 @@ frappe.ready(function() { newVal = 0; if (btn.attr('data-dir') == 'up') { - newVal = parseInt(oldValue) + 1; + newVal = Number.parseInt(oldValue) + 1; } else if (btn.attr('data-dir') == 'dwn') { - if (parseInt(oldValue) > 1) { - newVal = parseInt(oldValue) - 1; + if (Number.parseInt(oldValue) > 1) { + newVal = Number.parseInt(oldValue) - 1; } else { - newVal = parseInt(oldValue); + newVal = Number.parseInt(oldValue); } } input.val(newVal); From 7697066cc2b0d493138fb8cfae1d6a70f80f1371 Mon Sep 17 00:00:00 2001 From: sahil28297 <37302950+sahil28297@users.noreply.github.com> Date: Mon, 15 Jul 2019 16:55:06 +0530 Subject: [PATCH 08/16] fix(sales_order_list): compare type as well (#18331) * fix(sales_order_list): compare type as well * fix(sales_order_list): compare type as well --- erpnext/selling/doctype/sales_order/sales_order_list.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order_list.js b/erpnext/selling/doctype/sales_order/sales_order_list.js index 15c9eb550f..301ecde638 100644 --- a/erpnext/selling/doctype/sales_order/sales_order_list.js +++ b/erpnext/selling/doctype/sales_order/sales_order_list.js @@ -34,7 +34,7 @@ frappe.listview_settings['Sales Order'] = { "per_delivered,<,100|per_billed,=,100|status,!=,Closed"]; } - } else if ((flt(doc.per_delivered, 6) == 100) + } else if ((flt(doc.per_delivered, 6) === 100) && flt(doc.grand_total) !== 0 && flt(doc.per_billed, 6) < 100 && doc.status !== "Closed") { // to bill @@ -48,7 +48,7 @@ frappe.listview_settings['Sales Order'] = { if(flt(doc.per_billed, 6) < 100 ){ return [__("To Deliver and Bill"), "orange", "per_delivered,=,100|per_billed,<,100|status,!=,Closed"]; - }else if(flt(doc.per_billed, 6) == 100){ + }else if(flt(doc.per_billed, 6) === 100){ return [__("To Deliver"), "orange", "per_delivered,=,100|per_billed,=,100|status,!=,Closed"]; } } From 39c3cfa25dbb0a5e93c08baf5902799849092839 Mon Sep 17 00:00:00 2001 From: sahil28297 <37302950+sahil28297@users.noreply.github.com> Date: Mon, 15 Jul 2019 16:55:26 +0530 Subject: [PATCH 09/16] fix(hr_setting): fix translation method call (#18328) --- erpnext/hr/doctype/hr_settings/hr_settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.js b/erpnext/hr/doctype/hr_settings/hr_settings.js index 9e5effe6a3..4004c1cc2d 100644 --- a/erpnext/hr/doctype/hr_settings/hr_settings.js +++ b/erpnext/hr/doctype/hr_settings/hr_settings.js @@ -15,7 +15,7 @@ frappe.ui.form.on('HR Settings', { let policy = frm.doc.password_policy; if (policy) { if (policy.includes(' ') || policy.includes('--')) { - frappe.msgprint(_("Password policy cannot contain spaces or simultaneous hyphens. The format will be restructured automatically")); + frappe.msgprint(__("Password policy cannot contain spaces or simultaneous hyphens. The format will be restructured automatically")); } frm.set_value('password_policy', policy.split(new RegExp(" |-", 'g')).filter((token) => token).join('-')); } From 868766ddf082f176f8ee1d4b8cf6c55e5a81d35f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 15 Jul 2019 18:02:58 +0530 Subject: [PATCH 10/16] refactor: Refactored over delivery/receipt/billing fields (#17788) * refact: Refactored over delivery/receipt/billing fields * fix: test case --- .../accounts_settings/accounts_settings.json | 11 ++- .../purchase_order/test_purchase_order.py | 14 +++- erpnext/controllers/accounts_controller.py | 59 +++++++------- erpnext/controllers/status_updater.py | 79 ++++++++++++------- erpnext/patches.txt | 1 + .../patches/v12_0/rename_tolerance_fields.py | 15 ++++ erpnext/public/js/queries.js | 2 +- .../doctype/sales_order/test_sales_order.py | 13 +-- .../doctype/delivery_note/delivery_note.py | 2 +- erpnext/stock/doctype/item/item.json | 33 +++++--- .../stock_settings/stock_settings.json | 6 +- 11 files changed, 152 insertions(+), 83 deletions(-) create mode 100644 erpnext/patches/v12_0/rename_tolerance_fields.py diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index c2372bd111..4ff4212920 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -10,6 +10,7 @@ "acc_frozen_upto", "frozen_accounts_modifier", "determine_address_tax_category_from", + "over_billing_allowance", "column_break_4", "credit_controller", "check_supplier_invoice_uniqueness", @@ -168,12 +169,18 @@ "fieldname": "automatically_fetch_payment_terms", "fieldtype": "Check", "label": "Automatically Fetch Payment Terms" + }, + { + "description": "Percentage you are allowed to bill more against the amount ordered. For example: If the order value is $100 for an item and tolerance is set as 10% then you are allowed to bill for $110.", + "fieldname": "over_billing_allowance", + "fieldtype": "Currency", + "label": "Over Billing Allowance (%)" } ], "icon": "icon-cog", "idx": 1, "issingle": 1, - "modified": "2019-04-28 18:20:55.789946", + "modified": "2019-07-04 18:20:55.789946", "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", @@ -200,4 +207,4 @@ "quick_entry": 1, "sort_order": "ASC", "track_changes": 1 - } \ No newline at end of file + } diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py index be68594d29..ff0b65b7be 100644 --- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import unittest import frappe +import json import frappe.defaults from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry from frappe.utils import flt, add_days, nowdate, getdate @@ -15,7 +16,7 @@ from erpnext.stock.doctype.material_request.test_material_request import make_ma from erpnext.stock.doctype.material_request.material_request import make_purchase_order from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry from erpnext.controllers.accounts_controller import update_child_qty_rate -import json +from erpnext.controllers.status_updater import OverAllowanceError class TestPurchaseOrder(unittest.TestCase): def test_make_purchase_receipt(self): @@ -41,7 +42,7 @@ class TestPurchaseOrder(unittest.TestCase): po.load_from_db() self.assertEqual(po.get("items")[0].received_qty, 4) - frappe.db.set_value('Item', '_Test Item', 'tolerance', 50) + frappe.db.set_value('Item', '_Test Item', 'over_delivery_receipt_allowance', 50) pr = create_pr_against_po(po.name, received_qty=8) self.assertEqual(get_ordered_qty(), existing_ordered_qty) @@ -57,12 +58,12 @@ class TestPurchaseOrder(unittest.TestCase): def test_ordered_qty_against_pi_with_update_stock(self): existing_ordered_qty = get_ordered_qty() - po = create_purchase_order() self.assertEqual(get_ordered_qty(), existing_ordered_qty + 10) - frappe.db.set_value('Item', '_Test Item', 'tolerance', 50) + frappe.db.set_value('Item', '_Test Item', 'over_delivery_receipt_allowance', 50) + frappe.db.set_value('Item', '_Test Item', 'over_billing_allowance', 20) pi = make_pi_from_po(po.name) pi.update_stock = 1 @@ -81,6 +82,11 @@ class TestPurchaseOrder(unittest.TestCase): po.load_from_db() self.assertEqual(po.get("items")[0].received_qty, 0) + frappe.db.set_value('Item', '_Test Item', 'over_delivery_receipt_allowance', 0) + frappe.db.set_value('Item', '_Test Item', 'over_billing_allowance', 0) + frappe.db.set_value("Accounts Settings", None, "over_billing_allowance", 0) + + def test_update_child_qty_rate(self): mr = make_material_request(qty=10) po = make_purchase_order(mr.name) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index f5ecaeb286..47f56cbfb1 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -475,21 +475,20 @@ class AccountsController(TransactionBase): order_doctype = "Purchase Order" order_list = list(set([d.get(order_field) - for d in self.get("items") if d.get(order_field)])) + for d in self.get("items") if d.get(order_field)])) journal_entries = get_advance_journal_entries(party_type, party, party_account, - amount_field, order_doctype, order_list, include_unallocated) + amount_field, order_doctype, order_list, include_unallocated) payment_entries = get_advance_payment_entries(party_type, party, party_account, - order_doctype, order_list, include_unallocated) + order_doctype, order_list, include_unallocated) res = journal_entries + payment_entries return res def is_inclusive_tax(self): - is_inclusive = cint(frappe.db.get_single_value("Accounts Settings", - "show_inclusive_tax_in_print")) + is_inclusive = cint(frappe.db.get_single_value("Accounts Settings", "show_inclusive_tax_in_print")) if is_inclusive: is_inclusive = 0 @@ -501,7 +500,7 @@ class AccountsController(TransactionBase): def validate_advance_entries(self): order_field = "sales_order" if self.doctype == "Sales Invoice" else "purchase_order" order_list = list(set([d.get(order_field) - for d in self.get("items") if d.get(order_field)])) + for d in self.get("items") if d.get(order_field)])) if not order_list: return @@ -513,7 +512,7 @@ class AccountsController(TransactionBase): if not advance_entries_against_si or d.reference_name not in advance_entries_against_si: frappe.msgprint(_( "Payment Entry {0} is linked against Order {1}, check if it should be pulled as advance in this invoice.") - .format(d.reference_name, d.against_order)) + .format(d.reference_name, d.against_order)) def update_against_document_in_jv(self): """ @@ -551,9 +550,9 @@ class AccountsController(TransactionBase): 'unadjusted_amount': flt(d.advance_amount), 'allocated_amount': flt(d.allocated_amount), 'exchange_rate': (self.conversion_rate - if self.party_account_currency != self.company_currency else 1), + if self.party_account_currency != self.company_currency else 1), 'grand_total': (self.base_grand_total - if self.party_account_currency == self.company_currency else self.grand_total), + if self.party_account_currency == self.company_currency else self.grand_total), 'outstanding_amount': self.outstanding_amount }) lst.append(args) @@ -576,36 +575,37 @@ class AccountsController(TransactionBase): unlink_ref_doc_from_payment_entries(self) def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield): - from erpnext.controllers.status_updater import get_tolerance_for - item_tolerance = {} - global_tolerance = None + from erpnext.controllers.status_updater import get_allowance_for + item_allowance = {} + global_qty_allowance, global_amount_allowance = None, None for item in self.get("items"): if item.get(item_ref_dn): ref_amt = flt(frappe.db.get_value(ref_dt + " Item", - item.get(item_ref_dn), based_on), self.precision(based_on, item)) + item.get(item_ref_dn), based_on), self.precision(based_on, item)) if not ref_amt: frappe.msgprint( - _("Warning: System will not check overbilling since amount for Item {0} in {1} is zero").format( - item.item_code, ref_dt)) + _("Warning: System will not check overbilling since amount for Item {0} in {1} is zero") + .format(item.item_code, ref_dt)) else: - already_billed = frappe.db.sql("""select sum(%s) from `tab%s` - where %s=%s and docstatus=1 and parent != %s""" % - (based_on, self.doctype + " Item", item_ref_dn, '%s', '%s'), - (item.get(item_ref_dn), self.name))[0][0] + already_billed = frappe.db.sql(""" + select sum(%s) + from `tab%s` + where %s=%s and docstatus=1 and parent != %s + """ % (based_on, self.doctype + " Item", item_ref_dn, '%s', '%s'), + (item.get(item_ref_dn), self.name))[0][0] total_billed_amt = flt(flt(already_billed) + flt(item.get(based_on)), - self.precision(based_on, item)) + self.precision(based_on, item)) - tolerance, item_tolerance, global_tolerance = get_tolerance_for(item.item_code, - item_tolerance, global_tolerance) + allowance, item_allowance, global_qty_allowance, global_amount_allowance = \ + get_allowance_for(item.item_code, item_allowance, global_qty_allowance, global_amount_allowance, "amount") - max_allowed_amt = flt(ref_amt * (100 + tolerance) / 100) + max_allowed_amt = flt(ref_amt * (100 + allowance) / 100) if total_billed_amt - max_allowed_amt > 0.01: - frappe.throw(_( - "Cannot overbill for Item {0} in row {1} more than {2}. To allow over-billing, please set in Stock Settings").format( - item.item_code, item.idx, max_allowed_amt)) + frappe.throw(_("Cannot overbill for Item {0} in row {1} more than {2}. To allow over-billing, please set in Stock Settings") + .format(item.item_code, item.idx, max_allowed_amt)) def get_company_default(self, fieldname): from erpnext.accounts.utils import get_company_default @@ -615,9 +615,10 @@ class AccountsController(TransactionBase): stock_items = [] item_codes = list(set(item.item_code for item in self.get("items"))) if item_codes: - stock_items = [r[0] for r in frappe.db.sql("""select name - from `tabItem` where name in (%s) and is_stock_item=1""" % \ - (", ".join((["%s"] * len(item_codes))),), item_codes)] + stock_items = [r[0] for r in frappe.db.sql(""" + select name from `tabItem` + where name in (%s) and is_stock_item=1 + """ % (", ".join((["%s"] * len(item_codes))),), item_codes)] return stock_items diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index b193ac2b6d..a7ec73ad9d 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -7,6 +7,8 @@ from frappe.utils import flt, comma_or, nowdate, getdate from frappe import _ from frappe.model.document import Document +class OverAllowanceError(frappe.ValidationError): pass + def validate_status(status, options): if status not in options: frappe.throw(_("Status must be one of {0}").format(comma_or(options))) @@ -154,8 +156,9 @@ class StatusUpdater(Document): def validate_qty(self): """Validates qty at row level""" - self.tolerance = {} - self.global_tolerance = None + self.item_allowance = {} + self.global_qty_allowance = None + self.global_amount_allowance = None for args in self.status_updater: if "target_ref_field" not in args: @@ -186,32 +189,41 @@ class StatusUpdater(Document): # if not item[args['target_ref_field']]: # msgprint(_("Note: System will not check over-delivery and over-booking for Item {0} as quantity or amount is 0").format(item.item_code)) - if args.get('no_tolerance'): + if args.get('no_allowance'): item['reduce_by'] = item[args['target_field']] - item[args['target_ref_field']] if item['reduce_by'] > .01: self.limits_crossed_error(args, item) elif item[args['target_ref_field']]: - self.check_overflow_with_tolerance(item, args) + self.check_overflow_with_allowance(item, args) - def check_overflow_with_tolerance(self, item, args): + def check_overflow_with_allowance(self, item, args): """ - Checks if there is overflow condering a relaxation tolerance + Checks if there is overflow condering a relaxation allowance """ - # check if overflow is within tolerance - tolerance, self.tolerance, self.global_tolerance = get_tolerance_for(item['item_code'], - self.tolerance, self.global_tolerance) + qty_or_amount = "qty" if "qty" in args['target_ref_field'] else "amount" + + # check if overflow is within allowance + allowance, self.item_allowance, self.global_qty_allowance, self.global_amount_allowance = \ + get_allowance_for(item['item_code'], self.item_allowance, + self.global_qty_allowance, self.global_amount_allowance, qty_or_amount) + overflow_percent = ((item[args['target_field']] - item[args['target_ref_field']]) / item[args['target_ref_field']]) * 100 - if overflow_percent - tolerance > 0.01: - item['max_allowed'] = flt(item[args['target_ref_field']] * (100+tolerance)/100) + if overflow_percent - allowance > 0.01: + item['max_allowed'] = flt(item[args['target_ref_field']] * (100+allowance)/100) item['reduce_by'] = item[args['target_field']] - item['max_allowed'] - self.limits_crossed_error(args, item) + self.limits_crossed_error(args, item, qty_or_amount) - def limits_crossed_error(self, args, item): + def limits_crossed_error(self, args, item, qty_or_amount): '''Raise exception for limits crossed''' + if qty_or_amount == "qty": + action_msg = _('To allow over receipt / delivery, update "Over Receipt/Delivery Allowance" in Stock Settings or the Item.') + else: + action_msg = _('To allow over billing, update "Over Billing Allowance" in Accounts Settings or the Item.') + frappe.throw(_('This document is over limit by {0} {1} for item {4}. Are you making another {3} against the same {2}?') .format( frappe.bold(_(item["target_ref_field"].title())), @@ -219,9 +231,7 @@ class StatusUpdater(Document): frappe.bold(_(args.get('target_dt'))), frappe.bold(_(self.doctype)), frappe.bold(item.get('item_code')) - ) + '

' + - _('To allow over-billing or over-ordering, update "Allowance" in Stock Settings or the Item.'), - title = _('Limit Crossed')) + ) + '

' + action_msg, OverAllowanceError, title = _('Limit Crossed')) def update_qty(self, update_modified=True): """Updates qty or amount at row level @@ -358,19 +368,34 @@ class StatusUpdater(Document): ref_doc.db_set("per_billed", per_billed) ref_doc.set_status(update=True) -def get_tolerance_for(item_code, item_tolerance={}, global_tolerance=None): +def get_allowance_for(item_code, item_allowance={}, global_qty_allowance=None, global_amount_allowance=None, qty_or_amount="qty"): """ - Returns the tolerance for the item, if not set, returns global tolerance + Returns the allowance for the item, if not set, returns global allowance """ - if item_tolerance.get(item_code): - return item_tolerance[item_code], item_tolerance, global_tolerance + if qty_or_amount == "qty": + if item_allowance.get(item_code, frappe._dict()).get("qty"): + return item_allowance[item_code].qty, item_allowance, global_qty_allowance, global_amount_allowance + else: + if item_allowance.get(item_code, frappe._dict()).get("amount"): + return item_allowance[item_code].amount, item_allowance, global_qty_allowance, global_amount_allowance - tolerance = flt(frappe.db.get_value('Item',item_code,'tolerance') or 0) + qty_allowance, over_billing_allowance = \ + frappe.db.get_value('Item', item_code, ['over_delivery_receipt_allowance', 'over_billing_allowance']) - if not tolerance: - if global_tolerance == None: - global_tolerance = flt(frappe.db.get_value('Stock Settings', None, 'tolerance')) - tolerance = global_tolerance + if qty_or_amount == "qty" and not qty_allowance: + if global_qty_allowance == None: + global_qty_allowance = flt(frappe.db.get_single_value('Stock Settings', 'over_delivery_receipt_allowance')) + qty_allowance = global_qty_allowance + elif qty_or_amount == "amount" and not over_billing_allowance: + if global_amount_allowance == None: + global_amount_allowance = flt(frappe.db.get_single_value('Accounts Settings', 'over_billing_allowance')) + over_billing_allowance = global_amount_allowance - item_tolerance[item_code] = tolerance - return tolerance, item_tolerance, global_tolerance + if qty_or_amount == "qty": + allowance = qty_allowance + item_allowance.setdefault(item_code, frappe._dict()).setdefault("qty", qty_allowance) + else: + allowance = over_billing_allowance + item_allowance.setdefault(item_code, frappe._dict()).setdefault("amount", over_billing_allowance) + + return allowance, item_allowance, global_qty_allowance, global_amount_allowance diff --git a/erpnext/patches.txt b/erpnext/patches.txt index f5666dfc60..e5975443cc 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -603,6 +603,7 @@ erpnext.patches.v11_1.set_salary_details_submittable erpnext.patches.v11_1.rename_depends_on_lwp execute:frappe.delete_doc("Report", "Inactive Items") erpnext.patches.v11_1.delete_scheduling_tool +erpnext.patches.v12_0.rename_tolerance_fields erpnext.patches.v12_0.make_custom_fields_for_bank_remittance #14-06-2019 execute:frappe.delete_doc_if_exists("Page", "support-analytics") erpnext.patches.v12_0.make_item_manufacturer diff --git a/erpnext/patches/v12_0/rename_tolerance_fields.py b/erpnext/patches/v12_0/rename_tolerance_fields.py new file mode 100644 index 0000000000..aa2fff4ca7 --- /dev/null +++ b/erpnext/patches/v12_0/rename_tolerance_fields.py @@ -0,0 +1,15 @@ +import frappe +from frappe.model.utils.rename_field import rename_field + +def execute(): + frappe.reload_doc("stock", "doctype", "item") + frappe.reload_doc("stock", "doctype", "stock_settings") + frappe.reload_doc("accounts", "doctype", "accounts_settings") + + rename_field('Stock Settings', "tolerance", "over_delivery_receipt_allowance") + rename_field('Item', "tolerance", "over_delivery_receipt_allowance") + + qty_allowance = frappe.db.get_single_value("Stock Settings", "over_delivery_receipt_allowance") + frappe.db.set_value("Accounts Settings", None, "over_delivery_receipt_allowance", qty_allowance) + + frappe.db.sql("update tabItem set over_billing_allowance=over_delivery_receipt_allowance") \ No newline at end of file diff --git a/erpnext/public/js/queries.js b/erpnext/public/js/queries.js index 560a5617da..84d2113c06 100644 --- a/erpnext/public/js/queries.js +++ b/erpnext/public/js/queries.js @@ -65,7 +65,7 @@ $.extend(erpnext.queries, { frappe.throw(__("Please set {0}", [__(frappe.meta.get_label(doc.doctype, frappe.dynamic_link.fieldname, doc.name))])); } - + console.log(frappe.dynamic_link) return { query: 'frappe.contacts.doctype.address.address.address_query', filters: { diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index 569c53f628..bd07841488 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -192,8 +192,8 @@ class TestSalesOrder(unittest.TestCase): def test_reserved_qty_for_over_delivery(self): make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100) - # set over-delivery tolerance - frappe.db.set_value('Item', "_Test Item", 'tolerance', 50) + # set over-delivery allowance + frappe.db.set_value('Item', "_Test Item", 'over_delivery_receipt_allowance', 50) existing_reserved_qty = get_reserved_qty() @@ -209,8 +209,9 @@ class TestSalesOrder(unittest.TestCase): def test_reserved_qty_for_over_delivery_via_sales_invoice(self): make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100) - # set over-delivery tolerance - frappe.db.set_value('Item', "_Test Item", 'tolerance', 50) + # set over-delivery allowance + frappe.db.set_value('Item', "_Test Item", 'over_delivery_receipt_allowance', 50) + frappe.db.set_value('Item', "_Test Item", 'over_billing_allowance', 20) existing_reserved_qty = get_reserved_qty() @@ -291,8 +292,8 @@ class TestSalesOrder(unittest.TestCase): make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100) make_stock_entry(item="_Test Item Home Desktop 100", target="_Test Warehouse - _TC", qty=10, rate=100) - # set over-delivery tolerance - frappe.db.set_value('Item', "_Test Product Bundle Item", 'tolerance', 50) + # set over-delivery allowance + frappe.db.set_value('Item', "_Test Product Bundle Item", 'over_delivery_receipt_allowance', 50) existing_reserved_qty_item1 = get_reserved_qty("_Test Item") existing_reserved_qty_item2 = get_reserved_qty("_Test Item Home Desktop 100") diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index ec7df2da6d..2de9b975da 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -51,7 +51,7 @@ class DeliveryNote(SellingController): 'source_field': 'qty', 'percent_join_field': 'against_sales_invoice', 'overflow_type': 'delivery', - 'no_tolerance': 1 + 'no_allowance': 1 }] if cint(self.is_return): self.status_updater.append({ diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index 164ffa443b..a142bb9035 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -29,7 +29,8 @@ "is_fixed_asset", "asset_category", "asset_naming_series", - "tolerance", + "over_delivery_receipt_allowance", + "over_billing_allowance", "image", "section_break_11", "brand", @@ -284,14 +285,6 @@ "fieldtype": "Select", "label": "Asset Naming Series" }, - { - "depends_on": "eval:!doc.__islocal", - "fieldname": "tolerance", - "fieldtype": "Float", - "label": "Allow over delivery or receipt upto this percent", - "oldfieldname": "tolerance", - "oldfieldtype": "Currency" - }, { "fieldname": "image", "fieldtype": "Attach Image", @@ -1021,6 +1014,26 @@ "fieldtype": "Check", "label": "Synced With Hub", "read_only": 1 + }, + { + "fieldname": "manufacturers", + "fieldtype": "Table", + "label": "Manufacturers", + "options": "Item Manufacturer" + }, + { + "depends_on": "eval:!doc.__islocal", + "fieldname": "over_delivery_receipt_allowance", + "fieldtype": "Float", + "label": "Over Delivery/Receipt Allowance (%)", + "oldfieldname": "tolerance", + "oldfieldtype": "Currency" + }, + { + "fieldname": "over_billing_allowance", + "fieldtype": "Float", + "label": "Over Billing Allowance (%)", + "depends_on": "eval:!doc.__islocal" } ], "has_web_view": 1, @@ -1028,7 +1041,7 @@ "idx": 2, "image_field": "image", "max_attachments": 1, - "modified": "2019-07-05 12:18:13.977931", + "modified": "2019-07-12 12:18:13.977931", "modified_by": "Administrator", "module": "Stock", "name": "Item", diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.json b/erpnext/stock/doctype/stock_settings/stock_settings.json index c989907639..f43390f19d 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.json +++ b/erpnext/stock/doctype/stock_settings/stock_settings.json @@ -255,7 +255,7 @@ "columns": 0, "description": "Percentage you are allowed to receive or deliver more against the quantity ordered. For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units.", "fetch_if_empty": 0, - "fieldname": "tolerance", + "fieldname": "over_delivery_receipt_allowance", "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, @@ -264,7 +264,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Limit Percent", + "label": "Over Delivery/Receipt Allowance (%)", "length": 0, "no_copy": 0, "permlevel": 0, @@ -918,7 +918,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2019-06-18 01:19:07.738045", + "modified": "2019-07-04 01:19:07.738045", "modified_by": "Administrator", "module": "Stock", "name": "Stock Settings", From e9f0e88f9bc4bd58a3e278401856e2285140fa48 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Mon, 15 Jul 2019 18:57:25 +0530 Subject: [PATCH 11/16] fix: taxes sequence if shipping rule is set in the sales invoice (#18329) --- erpnext/public/js/controllers/transaction.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 11fdb8b178..844db996a2 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1424,11 +1424,14 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ }, callback: function(r) { if(!r.exc) { - me.frm.set_value("taxes", r.message); + if(me.frm.doc.shipping_rule && me.frm.doc.taxes) { + for (let tax of r.message) { + me.frm.add_child("taxes", tax); + } - if(me.frm.doc.shipping_rule) { - me.frm.script_manager.trigger("shipping_rule"); + refresh_field("taxes"); } else { + me.frm.set_value("taxes", r.message); me.calculate_taxes_and_totals(); } } From 4c0dffe6871521eb39cb8b073b57a660d229ebfe Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 16 Jul 2019 01:52:03 +0530 Subject: [PATCH 12/16] feat: added payment terms filter in the accounts payable summary --- .../accounts/report/accounts_payable/accounts_payable.js | 6 ++++++ .../accounts_payable_summary/accounts_payable_summary.js | 6 ++++++ .../report/accounts_receivable/accounts_receivable.py | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/erpnext/accounts/report/accounts_payable/accounts_payable.js b/erpnext/accounts/report/accounts_payable/accounts_payable.js index f6a561f04f..cfcc575718 100644 --- a/erpnext/accounts/report/accounts_payable/accounts_payable.js +++ b/erpnext/accounts/report/accounts_payable/accounts_payable.js @@ -88,6 +88,12 @@ frappe.query_reports["Accounts Payable"] = { } } }, + { + "fieldname":"payment_terms_template", + "label": __("Payment Terms Template"), + "fieldtype": "Link", + "options": "Payment Terms Template" + }, { "fieldname":"supplier_group", "label": __("Supplier Group"), diff --git a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js index ec4f0c983f..006068a266 100644 --- a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js +++ b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js @@ -77,6 +77,12 @@ frappe.query_reports["Accounts Payable Summary"] = { "fieldtype": "Link", "options": "Supplier" }, + { + "fieldname":"payment_terms_template", + "label": __("Payment Terms Template"), + "fieldtype": "Link", + "options": "Payment Terms Template" + }, { "fieldname":"supplier_group", "label": __("Supplier Group"), diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 0cda2c15dd..ecf149b335 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -541,6 +541,10 @@ class ReceivablePayableReport(object): where supplier_group=%s)""") values.append(self.filters.get("supplier_group")) + if self.filters.get("payment_terms_template"): + conditions.append("party in (select name from tabSupplier where payment_terms=%s)") + values.append(self.filters.get("payment_terms_template")) + if self.filters.get("cost_center"): lft, rgt = frappe.get_cached_value("Cost Center", self.filters.get("cost_center"), ['lft', 'rgt']) From 82770d91523430cfbccaf8f5202b1be4d60ea8ea Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 16 Jul 2019 09:40:09 +0530 Subject: [PATCH 13/16] fix: Project fixes (#18343) * fix: Add fetch from in Full Name * fix: Remove deprecated buttons * fix: Show Project to Administrator --- .../doctype/project_user/project_user.json | 392 ++++-------------- erpnext/projects/doctype/task/task.js | 14 - erpnext/templates/pages/projects.py | 12 +- 3 files changed, 78 insertions(+), 340 deletions(-) diff --git a/erpnext/projects/doctype/project_user/project_user.json b/erpnext/projects/doctype/project_user/project_user.json index 458028ff51..f0a70dd1df 100644 --- a/erpnext/projects/doctype/project_user/project_user.json +++ b/erpnext/projects/doctype/project_user/project_user.json @@ -1,333 +1,85 @@ { - "allow_copy": 0, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, - "allow_import": 0, - "allow_rename": 0, - "beta": 0, - "creation": "2016-03-25 02:52:19.283003", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, + "creation": "2016-03-25 02:52:19.283003", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "user", + "email", + "image", + "column_break_2", + "full_name", + "welcome_email_sent", + "view_attachments", + "section_break_5", + "project_status" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "user", - "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": "User", - "length": 0, - "no_copy": 0, - "options": "User", - "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": 1, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "user", + "fieldtype": "Link", + "in_list_view": 1, + "label": "User", + "options": "User", + "reqd": 1, + "search_index": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_from": "user.email", - "fieldname": "email", - "fieldtype": "Read Only", - "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": "Email", - "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 - }, + "fetch_from": "user.email", + "fieldname": "email", + "fieldtype": "Read Only", + "label": "Email" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fetch_from": "user.user_image", - "fieldname": "image", - "fieldtype": "Read Only", - "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 1, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Image", - "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 - }, + "fetch_from": "user.user_image", + "fieldname": "image", + "fieldtype": "Read Only", + "hidden": 1, + "in_global_search": 1, + "label": "Image" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "column_break_2", - "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_2", + "fieldtype": "Column Break" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "user.full_name", - "fieldname": "full_name", - "fieldtype": "Read Only", - "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": "Full 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": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fetch_from": "user.full_name", + "fieldname": "full_name", + "fieldtype": "Read Only", + "label": "Full Name" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "welcome_email_sent", - "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": "Welcome email sent", - "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 - }, + "default": "0", + "fieldname": "welcome_email_sent", + "fieldtype": "Check", + "label": "Welcome email sent" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 1, - "fieldname": "view_attachments", - "fieldtype": "Check", - "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": "View attachments", - "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 - }, + "columns": 1, + "default": "0", + "fieldname": "view_attachments", + "fieldtype": "Check", + "in_list_view": 1, + "label": "View attachments" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "section_break_5", - "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 - }, + "fieldname": "section_break_5", + "fieldtype": "Section Break" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:parent.doctype == 'Project Update'", - "fieldname": "project_status", - "fieldtype": "Text", - "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": "Project Status", - "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:parent.doctype == 'Project Update'", + "fieldname": "project_status", + "fieldtype": "Text", + "label": "Project Status" } - ], - "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-01-17 17:10:05.339735", - "modified_by": "Administrator", - "module": "Projects", - "name": "Project User", - "name_case": "", - "owner": "Administrator", - "permissions": [], - "quick_entry": 0, - "read_only": 0, - "read_only_onload": 0, - "show_name_in_global_search": 0, - "sort_field": "modified", - "sort_order": "DESC", - "track_changes": 0, - "track_seen": 0, - "track_views": 0 + ], + "istable": 1, + "modified": "2019-07-15 19:37:26.942294", + "modified_by": "Administrator", + "module": "Projects", + "name": "Project User", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC" } \ No newline at end of file diff --git a/erpnext/projects/doctype/task/task.js b/erpnext/projects/doctype/task/task.js index 489c7a3b32..5719276669 100644 --- a/erpnext/projects/doctype/task/task.js +++ b/erpnext/projects/doctype/task/task.js @@ -42,20 +42,6 @@ frappe.ui.form.on("Task", { frappe.set_route("List", "Expense Claim"); }, __("View"), true); } - - if (frm.perm[0].write) { - if (!["Closed", "Cancelled"].includes(frm.doc.status)) { - frm.add_custom_button(__("Close"), () => { - frm.set_value("status", "Closed"); - frm.save(); - }); - } else { - frm.add_custom_button(__("Reopen"), () => { - frm.set_value("status", "Open"); - frm.save(); - }); - } - } } } }, diff --git a/erpnext/templates/pages/projects.py b/erpnext/templates/pages/projects.py index ddca27455e..d23fed9e7d 100644 --- a/erpnext/templates/pages/projects.py +++ b/erpnext/templates/pages/projects.py @@ -7,22 +7,22 @@ import json def get_context(context): project_user = frappe.db.get_value("Project User", {"parent": frappe.form_dict.project, "user": frappe.session.user} , ["user", "view_attachments"], as_dict= True) - if not project_user or frappe.session.user == 'Guest': + if frappe.session.user != 'Administrator' and (not project_user or frappe.session.user == 'Guest'): raise frappe.PermissionError - + context.no_cache = 1 context.show_sidebar = True project = frappe.get_doc('Project', frappe.form_dict.project) project.has_permission('read') - + project.tasks = get_tasks(project.name, start=0, item_status='open', search=frappe.form_dict.get("search")) project.timesheets = get_timesheets(project.name, start=0, search=frappe.form_dict.get("search")) - if project_user.view_attachments: + if project_user and project_user.view_attachments: project.attachments = get_attachments(project.name) context.doc = project @@ -46,7 +46,7 @@ def get_tasks(project, start=0, search=None, item_status=None): task.todo=task.todo[0] task.todo.user_image = frappe.db.get_value('User', task.todo.owner, 'user_image') - + task.comment_count = len(json.loads(task._comments or "[]")) task.css_seen = '' @@ -86,7 +86,7 @@ def get_timesheets(project, start=0, search=None): timesheet.info.css_seen = '' if timesheet.info._seen: if frappe.session.user in json.loads(timesheet.info._seen): - timesheet.info.css_seen = 'seen' + timesheet.info.css_seen = 'seen' return timesheets @frappe.whitelist() From 8c21703959075c464ad9772aa90435e3eaab64a1 Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Tue, 16 Jul 2019 09:41:01 +0530 Subject: [PATCH 14/16] fix: Fixes in get_balance_on function (#18324) --- erpnext/accounts/utils.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index e75dd957db..e41c74cac8 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -104,6 +104,9 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company # get balance of all entries that exist date = nowdate() + if account: + acc = frappe.get_doc("Account", account) + try: year_start_date = get_fiscal_year(date, verbose=0)[1] except FiscalYearError: @@ -118,7 +121,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company allow_cost_center_in_entry_of_bs_account = get_allow_cost_center_in_entry_of_bs_account() - if cost_center and allow_cost_center_in_entry_of_bs_account: + if cost_center and (allow_cost_center_in_entry_of_bs_account or acc.report_type =='Profit and Loss'): cc = frappe.get_doc("Cost Center", cost_center) if cc.is_group: cond.append(""" exists ( @@ -132,20 +135,13 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, company if account: - acc = frappe.get_doc("Account", account) - if not frappe.flags.ignore_account_permission: acc.check_permission("read") - - if not allow_cost_center_in_entry_of_bs_account and acc.report_type == 'Profit and Loss': + if acc.report_type == 'Profit and Loss': # for pl accounts, get balance within a fiscal year cond.append("posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" \ % year_start_date) - elif allow_cost_center_in_entry_of_bs_account: - # for all accounts, get balance within a fiscal year if maintain cost center in balance account is checked - cond.append("posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" \ - % year_start_date) # different filter for group and ledger - improved performance if acc.is_group: cond.append("""exists ( From b560050334b5a63c9fe2c3be506cd766b27472ed Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Tue, 16 Jul 2019 12:11:02 +0530 Subject: [PATCH 15/16] fix(payment-entry):remove unused argument --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 699f04675f..368389807d 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -601,7 +601,7 @@ def get_outstanding_reference_documents(args): condition += " and company = {0}".format(frappe.db.escape(args.get("company"))) outstanding_invoices = get_outstanding_invoices(args.get("party_type"), args.get("party"), - args.get("party_account"), filters=args, condition=condition, limit=100) + args.get("party_account"), filters=args, condition=condition) for d in outstanding_invoices: d["exchange_rate"] = 1 From a4e0532df041f6ace65bb13c7ff65215f56b91c4 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 16 Jul 2019 15:59:37 +0530 Subject: [PATCH 16/16] fix: Project Template should be set only once (#18354) --- erpnext/projects/doctype/project/project.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/projects/doctype/project/project.json b/erpnext/projects/doctype/project/project.json index b4536c085c..dc221bccbc 100644 --- a/erpnext/projects/doctype/project/project.json +++ b/erpnext/projects/doctype/project/project.json @@ -126,7 +126,8 @@ "fieldname": "project_template", "fieldtype": "Link", "label": "From Template", - "options": "Project Template" + "options": "Project Template", + "set_only_once": 1 }, { "fieldname": "expected_start_date", @@ -442,7 +443,7 @@ "icon": "fa fa-puzzle-piece", "idx": 29, "max_attachments": 4, - "modified": "2019-06-25 16:14:43.887151", + "modified": "2019-07-16 11:11:12.343658", "modified_by": "Administrator", "module": "Projects", "name": "Project", @@ -481,6 +482,7 @@ "quick_entry": 1, "search_fields": "customer, status, priority, is_active", "show_name_in_global_search": 1, + "sort_field": "modified", "sort_order": "DESC", "timeline_field": "customer", "track_seen": 1