From f31221d0d33cf186e7a7015ccb7de9ae66947067 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 9 Jul 2014 09:13:00 +0530 Subject: [PATCH 01/49] Changed `raise Exception` to `frappe.throw` --- .../accounts/doctype/sales_invoice/sales_invoice.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 834865bcd6..5e29487b50 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -339,8 +339,8 @@ class SalesInvoice(SellingController): def validate_pos(self): if not self.cash_bank_account and flt(self.paid_amount): - msgprint(_("Cash or Bank Account is mandatory for making payment entry")) - raise Exception + frappe.throw(_("Cash or Bank Account is mandatory for making payment entry")) + if flt(self.paid_amount) + flt(self.write_off_amount) \ - flt(self.grand_total) > 1/(10**(self.precision("grand_total") + 1)): frappe.throw(_("""Paid amount + Write Off Amount can not be greater than Grand Total""")) @@ -431,9 +431,8 @@ class SalesInvoice(SellingController): submitted = frappe.db.sql("""select name from `tabSales Order` where docstatus = 1 and name = %s""", d.sales_order) if not submitted: - msgprint(_("Sales Order {0} is not submitted").format(d.sales_order)) - raise Exception - + frappe.throw(_("Sales Order {0} is not submitted").format(d.sales_order)) + if d.delivery_note: submitted = frappe.db.sql("""select name from `tabDelivery Note` where docstatus = 1 and name = %s""", d.delivery_note) @@ -682,7 +681,7 @@ def manage_recurring_invoices(next_date=None, commit=True): if exception_list: exception_message = "\n\n".join([cstr(d) for d in exception_list]) - raise Exception, exception_message + frappe.throw(exception_message) def make_new_invoice(ref_wrapper, posting_date): from erpnext.accounts.utils import get_fiscal_year From 3f606b6c640c6c5195660572252a6439e44d6867 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 9 Jul 2014 09:27:02 +0530 Subject: [PATCH 02/49] Update project.py --- erpnext/projects/doctype/project/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index bce9c52688..4a14c55c3a 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -55,7 +55,7 @@ class Project(Document): "event_type": "Private", "ref_type": self.doctype, "ref_name": self.name - }).insert() + }).insert(ignore_permissions=True) def on_trash(self): delete_events(self.doctype, self.name) From 8adb21121691a1d8d772c7e150b7539025487f5b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 9 Jul 2014 11:09:33 +0530 Subject: [PATCH 03/49] Fixed patch: erpnext/patches/v4_1/fix_delivery_and_billing_status.py --- erpnext/patches.txt | 2 +- ...for_draft_so.py => fix_delivery_and_billing_status.py} | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) rename erpnext/patches/v4_1/{fix_delivery_and_billing_status_for_draft_so.py => fix_delivery_and_billing_status.py} (80%) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 1c2112d7b8..b7fc5e7768 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -67,4 +67,4 @@ erpnext.patches.v4_0.set_naming_series_property_setter erpnext.patches.v4_1.set_outgoing_email_footer erpnext.patches.v4_1.fix_jv_remarks erpnext.patches.v4_1.fix_sales_order_delivered_status -erpnext.patches.v4_1.fix_delivery_and_billing_status_for_draft_so \ No newline at end of file +erpnext.patches.v4_1.fix_delivery_and_billing_status diff --git a/erpnext/patches/v4_1/fix_delivery_and_billing_status_for_draft_so.py b/erpnext/patches/v4_1/fix_delivery_and_billing_status.py similarity index 80% rename from erpnext/patches/v4_1/fix_delivery_and_billing_status_for_draft_so.py rename to erpnext/patches/v4_1/fix_delivery_and_billing_status.py index 8d38338e04..2dbc825085 100644 --- a/erpnext/patches/v4_1/fix_delivery_and_billing_status_for_draft_so.py +++ b/erpnext/patches/v4_1/fix_delivery_and_billing_status.py @@ -5,8 +5,8 @@ from __future__ import unicode_literals import frappe def execute(): - frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered' - where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0 and docstatus = 0""") + frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered' + where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0 and ifnull(docstatus, 0) in (0, 1)""") - frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed' - where billing_status = 'Billed' and ifnull(per_billed, 0) = 0 and docstatus = 0""") \ No newline at end of file + frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed' + where billing_status = 'Billed' and ifnull(per_billed, 0) = 0 and ifnull(docstatus, 0) in (0, 1)""") From 5e0de79c0db47aacb0fb374abc6550cb8f5e66c8 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Wed, 9 Jul 2014 11:08:59 +0530 Subject: [PATCH 04/49] Account validated in general ledger report. Fixed #1912 --- erpnext/accounts/report/general_ledger/general_ledger.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index 0fa7e446fe..dd8052835e 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -63,6 +63,8 @@ def get_gl_entries(filters): def get_conditions(filters): conditions = [] if filters.get("account"): + if not frappe.db.exists("Account", filters["account"]): + frappe.throw(_("Account {0} is not valid").format(filters["account"])) lft, rgt = frappe.db.get_value("Account", filters["account"], ["lft", "rgt"]) conditions.append("""account in (select name from tabAccount where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt)) From fcfa42d9927343c31a62d3b9f8c2620b9ad48fe1 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Wed, 9 Jul 2014 11:31:11 +0530 Subject: [PATCH 05/49] Minor fixes #1917 --- erpnext/accounts/doctype/pricing_rule/pricing_rule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 9141697a77..9a3b3121f4 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -183,7 +183,7 @@ def get_pricing_rules(args): group_condition = _get_tree_conditions(parenttype) if group_condition: conditions += " and " + group_condition - + if not args.price_list: args.price_list = None conditions += " and ifnull(for_price_list, '') in (%(price_list)s, '')" if args.get("transaction_date"): From 8e4fcca2169078931db6fede3d3265d10e5865ea Mon Sep 17 00:00:00 2001 From: nabinhait Date: Wed, 9 Jul 2014 12:50:50 +0530 Subject: [PATCH 06/49] Get query fixes in address in contact listing. Fixes #1911 --- erpnext/buying/doctype/supplier/supplier.js | 6 ++++-- erpnext/selling/doctype/customer/customer.js | 6 ++++-- erpnext/setup/doctype/sales_partner/sales_partner.js | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index 99d0e4e9f5..c2b29a4a17 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -69,7 +69,8 @@ cur_frm.cscript.make_address = function() { page_length: 5, new_doctype: "Address", get_query: function() { - return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where supplier='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_address desc" + return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where supplier='" + + cur_frm.doc.name.replace("'", "\\'") + "' and docstatus != 2 order by is_primary_address desc" }, as_dict: 1, no_results_message: __('No addresses created'), @@ -87,7 +88,8 @@ cur_frm.cscript.make_contact = function() { page_length: 5, new_doctype: "Contact", get_query: function() { - return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where supplier='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc" + return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where supplier='" + + cur_frm.doc.name.replace("'", "\\'") + "' and docstatus != 2 order by is_primary_contact desc" }, as_dict: 1, no_results_message: __('No contacts created'), diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index e8407581d1..9a4a356d17 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -86,7 +86,8 @@ cur_frm.cscript.make_address = function() { page_length: 5, new_doctype: "Address", get_query: function() { - return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where customer='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_address desc" + return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where customer='" + + cur_frm.doc.name.replace("'", "\\'") + "' and docstatus != 2 order by is_primary_address desc" }, as_dict: 1, no_results_message: __('No addresses created'), @@ -104,7 +105,8 @@ cur_frm.cscript.make_contact = function() { page_length: 5, new_doctype: "Contact", get_query: function() { - return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where customer='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc" + return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where customer='" + + cur_frm.doc.name.replace("'", "\\'") + "' and docstatus != 2 order by is_primary_contact desc" }, as_dict: 1, no_results_message: __('No contacts created'), diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.js b/erpnext/setup/doctype/sales_partner/sales_partner.js index 02af9f7276..64c4e2106c 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.js +++ b/erpnext/setup/doctype/sales_partner/sales_partner.js @@ -41,7 +41,8 @@ cur_frm.cscript.make_address = function() { frappe.set_route("Form", "Address", address.name); }, get_query: function() { - return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where sales_partner='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_address desc" + return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where sales_partner='" + + cur_frm.doc.name.replace("'", "\\'") + "' and docstatus != 2 order by is_primary_address desc" }, as_dict: 1, no_results_message: __('No addresses created'), @@ -64,7 +65,8 @@ cur_frm.cscript.make_contact = function() { frappe.set_route("Form", "Contact", contact.name); }, get_query: function() { - return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where sales_partner='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc" + return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where sales_partner='" + + cur_frm.doc.name.replace("'", "\\'") + "' and docstatus != 2 order by is_primary_contact desc" }, as_dict: 1, no_results_message: __('No contacts created'), From 7e848b19240f472535884b79d0d6a373f388533c Mon Sep 17 00:00:00 2001 From: nabinhait Date: Wed, 9 Jul 2014 12:54:56 +0530 Subject: [PATCH 07/49] Title mandatory in Note. Fixes #1913 --- erpnext/utilities/doctype/note/note.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/utilities/doctype/note/note.json b/erpnext/utilities/doctype/note/note.json index 2ee6d9ad4f..6cf756c3aa 100644 --- a/erpnext/utilities/doctype/note/note.json +++ b/erpnext/utilities/doctype/note/note.json @@ -12,7 +12,8 @@ "in_list_view": 1, "label": "Title", "permlevel": 0, - "print_hide": 1 + "print_hide": 1, + "reqd": 1 }, { "description": "Help: To link to another record in the system, use \"#Form/Note/[Note Name]\" as the Link URL. (don't use \"http://\")", @@ -48,7 +49,7 @@ ], "icon": "icon-file-text", "idx": 1, - "modified": "2014-05-27 03:49:13.934698", + "modified": "2014-07-09 12:54:11.897597", "modified_by": "Administrator", "module": "Utilities", "name": "Note", From 0c3bb75fd9dbe38ca687bbf71000fcbc326b9411 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 9 Jul 2014 12:59:56 +0530 Subject: [PATCH 08/49] Added error_report_email in hooks --- erpnext/hooks.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 1dde6386d2..df15916f7a 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -7,6 +7,8 @@ app_icon = "icon-th" app_color = "#e74c3c" app_version = __version__ +error_report_email = "support@erpnext.com" + app_include_js = "assets/js/erpnext.min.js" app_include_css = "assets/css/erpnext.css" web_include_js = "assets/js/erpnext-web.min.js" From 48d3b54e02ccdaf0fe18736a9cd1de4c577e8fb5 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 9 Jul 2014 13:15:03 +0530 Subject: [PATCH 09/49] Fixes in queries --- erpnext/controllers/queries.py | 100 ++++++++++++++++++++------------- 1 file changed, 62 insertions(+), 38 deletions(-) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 16d27d47fc..2650c66ac2 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -32,34 +32,46 @@ def employee_query(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select name, employee_name from `tabEmployee` where status = 'Active' and docstatus < 2 - and (%(key)s like "%(txt)s" - or employee_name like "%(txt)s") - %(mcond)s + and ({key} like %(txt)s + or employee_name like %(txt)s) + {mcond} order by - if(locate("%(_txt)s", name), locate("%(_txt)s", name), 99999), - if(locate("%(_txt)s", employee_name), locate("%(_txt)s", employee_name), 99999), + if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999), + if(locate(%(_txt)s, employee_name), locate(%(_txt)s, employee_name), 99999), name, employee_name - limit %(start)s, %(page_len)s""" % {'key': searchfield, 'txt': "%%%s%%" % txt, - '_txt': txt.replace("%", ""), - 'mcond':get_match_cond(doctype), 'start': start, 'page_len': page_len}) + limit %(start)s, %(page_len)s""".format(**{ + 'key': searchfield, + 'mcond': get_match_cond(doctype) + }), { + 'txt': "%%%s%%" % txt, + '_txt': txt.replace("%", ""), + 'start': start, + 'page_len': page_len + }) # searches for leads which are not converted def lead_query(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select name, lead_name, company_name from `tabLead` where docstatus < 2 and ifnull(status, '') != 'Converted' - and (%(key)s like "%(txt)s" - or lead_name like "%(txt)s" - or company_name like "%(txt)s") - %(mcond)s + and ({key} like %(txt)s + or lead_name like %(txt)s + or company_name like %(txt)s) + {mcond} order by - if(locate("%(_txt)s", name), locate("%(_txt)s", name), 99999), - if(locate("%(_txt)s", lead_name), locate("%(_txt)s", lead_name), 99999), - if(locate("%(_txt)s", company_name), locate("%(_txt)s", company_name), 99999), + if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999), + if(locate(%(_txt)s, lead_name), locate(%(_txt)s, lead_name), 99999), + if(locate(%(_txt)s, company_name), locate(%(_txt)s, company_name), 99999), name, lead_name - limit %(start)s, %(page_len)s""" % {'key': searchfield, 'txt': "%%%s%%" % txt, - '_txt': txt.replace("%", ""), - 'mcond':get_match_cond(doctype), 'start': start, 'page_len': page_len}) + limit %(start)s, %(page_len)s""".format(**{ + 'key': searchfield, + 'mcond':get_match_cond(doctype) + }), { + 'txt': "%%%s%%" % txt, + '_txt': txt.replace("%", ""), + 'start': start, + 'page_len': page_len + }) # searches for customer def customer_query(doctype, txt, searchfield, start, page_len, filters): @@ -72,19 +84,25 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters): fields = ", ".join(fields) - return frappe.db.sql("""select %(field)s from `tabCustomer` + return frappe.db.sql("""select {fields} from `tabCustomer` where docstatus < 2 - and (%(key)s like "%(txt)s" - or customer_name like "%(txt)s") - %(mcond)s + and ({key} like %(txt)s + or customer_name like %(txt)s) + {mcond} order by - if(locate("%(_txt)s", name), locate("%(_txt)s", name), 99999), - if(locate("%(_txt)s", customer_name), locate("%(_txt)s", customer_name), 99999), + if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999), + if(locate(%(_txt)s, customer_name), locate(%(_txt)s, customer_name), 99999), name, customer_name - limit %(start)s, %(page_len)s""" % {'field': fields,'key': searchfield, - 'txt': "%%%s%%" % txt, '_txt': txt.replace("%", ""), - 'mcond':get_match_cond(doctype), - 'start': start, 'page_len': page_len}) + limit %(start)s, %(page_len)s""".format(**{ + "fields": fields, + "key": searchfield, + "mcond": get_match_cond(doctype) + }), { + 'txt': "%%%s%%" % txt, + '_txt': txt.replace("%", ""), + 'start': start, + 'page_len': page_len + }) # searches for supplier def supplier_query(doctype, txt, searchfield, start, page_len, filters): @@ -95,19 +113,25 @@ def supplier_query(doctype, txt, searchfield, start, page_len, filters): fields = ["name", "supplier_name", "supplier_type"] fields = ", ".join(fields) - return frappe.db.sql("""select %(field)s from `tabSupplier` + return frappe.db.sql("""select {field} from `tabSupplier` where docstatus < 2 - and (%(key)s like "%(txt)s" - or supplier_name like "%(txt)s") - %(mcond)s + and ({key} like %(txt)s + or supplier_name like %(txt)s) + {mcond} order by - if(locate("%(_txt)s", name), locate("%(_txt)s", name), 99999), - if(locate("%(_txt)s", supplier_name), locate("%(_txt)s", supplier_name), 99999), + if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999), + if(locate(%(_txt)s, supplier_name), locate(%(_txt)s, supplier_name), 99999), name, supplier_name - limit %(start)s, %(page_len)s """ % {'field': fields,'key': searchfield, - 'txt': "%%%s%%" % txt, '_txt': txt.replace("%", ""), - 'mcond':get_match_cond(doctype), 'start': start, - 'page_len': page_len}) + limit %(start)s, %(page_len)s """.format(**{ + 'field': fields, + 'key': searchfield, + 'mcond':get_match_cond(doctype) + }), { + 'txt': "%%%s%%" % txt, + '_txt': txt.replace("%", ""), + 'start': start, + 'page_len': page_len + }) def tax_account_query(doctype, txt, searchfield, start, page_len, filters): tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount From a96cf5b96b691e7d4efa325e3014375b42f6e1b5 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 10 Jul 2014 12:16:39 +0530 Subject: [PATCH 10/49] Print Hide other charges calculation --- erpnext/selling/doctype/sales_order/sales_order.json | 4 ++-- erpnext/stock/doctype/delivery_note/delivery_note.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json index ebe1d84eda..bb5211312c 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -420,7 +420,7 @@ "label": "Taxes and Charges Calculation", "oldfieldtype": "HTML", "permlevel": 0, - "print_hide": 0 + "print_hide": 1 }, { "fieldname": "section_break_43", @@ -883,7 +883,7 @@ "idx": 1, "is_submittable": 1, "issingle": 0, - "modified": "2014-07-07 17:47:40.089520", + "modified": "2014-07-10 02:43:45.504009", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order", diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json index f1dc5a390e..9b43a71934 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.json +++ b/erpnext/stock/doctype/delivery_note/delivery_note.json @@ -427,6 +427,7 @@ "label": "Taxes and Charges Calculation", "oldfieldtype": "HTML", "permlevel": 0, + "print_hide": 1, "read_only": 0 }, { @@ -1008,7 +1009,7 @@ "idx": 1, "in_create": 0, "is_submittable": 1, - "modified": "2014-06-23 07:55:47.859869", + "modified": "2014-07-10 02:45:47.673011", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note", From d5fb5d91e99a510770908db87b6c868e17858b36 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Wed, 9 Jul 2014 17:36:38 +0530 Subject: [PATCH 11/49] overflow validation fixed --- .../doctype/purchase_invoice/purchase_invoice.py | 1 + .../doctype/sales_invoice/sales_invoice.py | 6 ++++-- .../doctype/purchase_order/purchase_order.py | 1 + erpnext/controllers/status_updater.py | 15 +++++++++------ .../installation_note/installation_note.py | 3 ++- .../stock/doctype/delivery_note/delivery_note.py | 3 ++- .../doctype/purchase_receipt/purchase_receipt.py | 1 + 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 80aa73a197..74a9628209 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -30,6 +30,7 @@ class PurchaseInvoice(BuyingController): 'target_ref_field': 'amount', 'source_field': 'amount', 'percent_join_field': 'purchase_order', + 'overflow_type': 'billing' }] def validate(self): diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 5e29487b50..0f6737cc87 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -36,7 +36,8 @@ class SalesInvoice(SellingController): 'join_field': 'so_detail', 'percent_join_field': 'sales_order', 'status_field': 'billing_status', - 'keyword': 'Billed' + 'keyword': 'Billed', + 'overflow_type': 'billing' }] def validate(self): @@ -134,7 +135,8 @@ class SalesInvoice(SellingController): 'keyword':'Delivered', 'second_source_dt': 'Delivery Note Item', 'second_source_field': 'qty', - 'second_join_field': 'prevdoc_detail_docname' + 'second_join_field': 'prevdoc_detail_docname', + 'overflow_type': 'delivery' }) def on_update_after_submit(self): diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index 2109d72aa2..f9f5103726 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -24,6 +24,7 @@ class PurchaseOrder(BuyingController): 'target_ref_field': 'qty', 'source_field': 'qty', 'percent_join_field': 'prevdoc_docname', + 'overflow_type': 'order' }] def validate(self): diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 90eacd9820..3c6355488f 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -132,11 +132,12 @@ 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)) elif args.get('no_tolerance'): - item['reduce_by'] = item[args['target_field']] - \ - item[args['target_ref_field']] + item['reduce_by'] = item[args['target_field']] - item[args['target_ref_field']] if item['reduce_by'] > .01: - msgprint(_("Allowance for over-delivery / over-billing crossed for Item {0}").format(item.item_code)) - throw(_("{0} must be less than or equal to {1}").format(_(item.target_ref_field), item[args["target_ref_field"]])) + msgprint(_("Allowance for over-{0} crossed for Item {1}") + .format(args["overflow_type"], item.item_code)) + throw(_("{0} must be reduced by {1} or you should increase overflow tolerance") + .format(_(item.target_ref_field.title()), item["reduce_by"])) else: self.check_overflow_with_tolerance(item, args) @@ -156,8 +157,10 @@ class StatusUpdater(Document): item['max_allowed'] = flt(item[args['target_ref_field']] * (100+tolerance)/100) item['reduce_by'] = item[args['target_field']] - item['max_allowed'] - msgprint(_("Allowance for over-delivery / over-billing crossed for Item {0}.").format(item["item_code"])) - throw(_("{0} must be less than or equal to {1}").format(item["target_ref_field"].title(), item["max_allowed"])) + msgprint(_("Allowance for over-{0} crossed for Item {1}.") + .format(args["overflow_type"], item["item_code"])) + throw(_("{0} must be reduced by {1} or you should increase overflow tolerance") + .format(_(item["target_ref_field"].title()), item["reduce_by"])) def update_qty(self, change_modified=True): """ diff --git a/erpnext/selling/doctype/installation_note/installation_note.py b/erpnext/selling/doctype/installation_note/installation_note.py index 7d2d3d0663..0477abc265 100644 --- a/erpnext/selling/doctype/installation_note/installation_note.py +++ b/erpnext/selling/doctype/installation_note/installation_note.py @@ -28,7 +28,8 @@ class InstallationNote(TransactionBase): 'source_field': 'qty', 'percent_join_field': 'prevdoc_docname', 'status_field': 'installation_status', - 'keyword': 'Installed' + 'keyword': 'Installed', + 'overflow_type': 'installation' }] def validate(self): diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index c1ddf63a44..13da9078b0 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -29,7 +29,8 @@ class DeliveryNote(SellingController): 'source_field': 'qty', 'percent_join_field': 'against_sales_order', 'status_field': 'delivery_status', - 'keyword': 'Delivered' + 'keyword': 'Delivered', + 'overflow_type': 'delivery' }] def onload(self): diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 71c07eba02..74f1198752 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -27,6 +27,7 @@ class PurchaseReceipt(BuyingController): 'target_ref_field': 'qty', 'source_field': 'qty', 'percent_join_field': 'prevdoc_docname', + 'overflow_type': 'receipt' }] def onload(self): From ee8b6f28b897b8fbbef2a4c30539afa8c1da476e Mon Sep 17 00:00:00 2001 From: nabinhait Date: Thu, 10 Jul 2014 15:27:00 +0530 Subject: [PATCH 12/49] minor fix --- erpnext/accounts/doctype/c_form/c_form.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/c_form/c_form.py b/erpnext/accounts/doctype/c_form/c_form.py index e0f008f8ad..88ced9a813 100644 --- a/erpnext/accounts/doctype/c_form/c_form.py +++ b/erpnext/accounts/doctype/c_form/c_form.py @@ -55,12 +55,12 @@ class CForm(Document): def get_invoice_details(self, invoice_no): """ Pull details from invoices for referrence """ - - inv = frappe.db.get_value("Sales Invoice", invoice_no, - ["posting_date", "territory", "net_total", "grand_total"], as_dict=True) - return { - 'invoice_date' : inv.posting_date, - 'territory' : inv.territory, - 'net_total' : inv.net_total, - 'grand_total' : inv.grand_total - } + if invoice_no: + inv = frappe.db.get_value("Sales Invoice", invoice_no, + ["posting_date", "territory", "net_total", "grand_total"], as_dict=True) + return { + 'invoice_date' : inv.posting_date, + 'territory' : inv.territory, + 'net_total' : inv.net_total, + 'grand_total' : inv.grand_total + } From 28c4bee0b1d434cead996080668213ef1d54c917 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 10 Jul 2014 16:43:16 +0530 Subject: [PATCH 13/49] Production Planning Tool - Fixed bom get query --- .../production_planning_tool/production_planning_tool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js index 0415c911e1..d57f639f7f 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js @@ -37,8 +37,8 @@ cur_frm.fields_dict['pp_details'].grid.get_field('item_code').get_query = functi }); } -cur_frm.fields_dict['pp_details'].grid.get_field('bom_no').get_query = function(doc) { - var d = locals[this.doctype][this.docname]; +cur_frm.fields_dict['pp_details'].grid.get_field('bom_no').get_query = function(doc, cdt, cdn) { + var d = locals[cdt][cdn]; if (d.item_code) { return { query: "erpnext.controllers.queries.bom", From 9b7b9b2e9313bb3d9db95aaa3e5b5f92ef30915e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 10 Jul 2014 18:44:41 +0530 Subject: [PATCH 14/49] Bank Reconciliation Statement Print Format --- .../bank_reconciliation_statement.html | 46 +++++++++++++++++++ .../bank_reconciliation_statement.py | 19 ++++---- 2 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html new file mode 100644 index 0000000000..91e07ab7da --- /dev/null +++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html @@ -0,0 +1,46 @@ +

{%= __("Bank Reconciliation Statement") %}

+

{%= filters.account %}

+
+ + + + + + + + + + + + {% for(var i=0, l=data.length; i + + + + + + + {% } else { %} + + + + + + + + {% } %} + {% } %} + +
{%= __("Posting Date") %}{%= __("Journal Voucher") %}{%= __("Reference") %}{%= __("Debit") %}{%= __("Credit") %}
{%= dateutil.str_to_user(data[i].posting_date) %}{%= data[i].journal_voucher %}{%= __("Against") %}: {%= data[i].against_account %} + {% if (data[i].reference) { %} +
{%= __("Reference") %}: {%= data[i].reference %} + {% if (data[i].ref_date) { %} +
{%= __("Reference Date") %}: {%= dateutil.str_to_user(data[i].ref_date) %} + {% } %} + {% } %} + {% if (data[i].clearance_date) { %} +
{%= __("Clearance Date") %}: {%= dateutil.str_to_user(data[i].clearance_date) %} + {% } %} +
{%= format_currency(data[i].debit) %}{%= format_currency(data[i].credit) %}
{%= data[i].journal_voucher %}{%= format_currency(data[i].debit) %}{%= format_currency(data[i].credit) %}
+

Printed On {%= dateutil.str_to_user(dateutil.get_datetime_as_string()) %}

diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py index e87fbd3226..119de09e41 100644 --- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py +++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py @@ -19,28 +19,29 @@ def execute(filters=None): total_debit, total_credit = 0,0 for d in data: - total_debit += flt(d[4]) - total_credit += flt(d[5]) + total_debit += flt(d[2]) + total_credit += flt(d[3]) bank_bal = flt(balance_as_per_company) - flt(total_debit) + flt(total_credit) data += [ get_balance_row("Balance as per company books", balance_as_per_company), - ["", "", "", "Amounts not reflected in bank", total_debit, total_credit], + ["", "Amounts not reflected in bank", total_debit, total_credit, "", "", "", ""], get_balance_row("Balance as per bank", bank_bal) ] return columns, data def get_columns(): - return ["Journal Voucher:Link/Journal Voucher:140", "Posting Date:Date:100", - "Clearance Date:Date:110", "Against Account:Link/Account:200", - "Debit:Currency:120", "Credit:Currency:120" + return ["Posting Date:Date:100", "Journal Voucher:Link/Journal Voucher:200", + "Debit:Currency:120", "Credit:Currency:120", + "Against Account:Link/Account:200", "Reference::100", "Ref Date:Date:110", "Clearance Date:Date:110" ] def get_entries(filters): entries = frappe.db.sql("""select - jv.name, jv.posting_date, jv.clearance_date, jvd.against_account, jvd.debit, jvd.credit + jv.posting_date, jv.name, jvd.debit, jvd.credit, + jvd.against_account, jv.cheque_no, jv.cheque_date, jv.clearance_date from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv where jvd.parent = jv.name and jv.docstatus=1 @@ -52,6 +53,6 @@ def get_entries(filters): def get_balance_row(label, amount): if amount > 0: - return ["", "", "", label, amount, 0] + return ["", label, amount, 0, "", "", "", ""] else: - return ["", "", "", label, 0, amount] + return ["", label, 0, amount, "", "", "", ""] From 059922cef1036278ead50f391267cbc2b14e265c Mon Sep 17 00:00:00 2001 From: webnotes Date: Fri, 11 Jul 2014 11:20:44 +0530 Subject: [PATCH 15/49] Add Payment Reconciliation Feature/Tool --- .../payment_reconciliation/__init__.py | 0 .../payment_reconciliation.js | 25 +++ .../payment_reconciliation.json | 152 ++++++++++++++++++ .../payment_reconciliation.py | 14 ++ .../__init__.py | 0 .../payment_reconciliation_invoice.json | 59 +++++++ .../payment_reconciliation_invoice.py | 9 ++ .../__init__.py | 0 .../payment_reconciliation_payment.json | 71 ++++++++ .../payment_reconciliation_payment.py | 9 ++ 10 files changed, 339 insertions(+) create mode 100644 erpnext/accounts/doctype/payment_reconciliation/__init__.py create mode 100644 erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js create mode 100644 erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json create mode 100644 erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py create mode 100644 erpnext/accounts/doctype/payment_reconciliation_invoice/__init__.py create mode 100644 erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json create mode 100644 erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.py create mode 100644 erpnext/accounts/doctype/payment_reconciliation_payment/__init__.py create mode 100644 erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json create mode 100644 erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.py diff --git a/erpnext/accounts/doctype/payment_reconciliation/__init__.py b/erpnext/accounts/doctype/payment_reconciliation/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js new file mode 100644 index 0000000000..f0706db896 --- /dev/null +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -0,0 +1,25 @@ +// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +// For license information, please see license.txt + +frappe.provide("erpnext.accounts"); + +erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.extend({ + + onload: function() { + var me = this + this.frm.set_query ("party_account", function() { + return{ + filters:[ + ["Account", "company", "=", me.frm.doc.company], + ["Account", "group_or_ledger", "=", "Ledger"], + ["Account", "master_type", "in", ["Customer", "Supplier"]] + ] + }; + }); + } + +}); + +$.extend(cur_frm.cscript, new erpnext.accounts.PaymentReconciliationController({frm: cur_frm})); + +cur_frm.add_fetch("party_account", "master_type", "party_type") \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json new file mode 100644 index 0000000000..7c53b739e6 --- /dev/null +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json @@ -0,0 +1,152 @@ +{ + "creation": "2014-07-09 12:04:51.681583", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "fields": [ + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "permlevel": 0, + "reqd": 1 + }, + { + "depends_on": "", + "fieldname": "party_account", + "fieldtype": "Link", + "in_list_view": 0, + "label": "Party Account", + "options": "Account", + "permlevel": 0, + "reqd": 1, + "search_index": 0 + }, + { + "fieldname": "party_type", + "fieldtype": "Select", + "hidden": 0, + "in_list_view": 1, + "label": "Party Type", + "options": "Customer\nSupplier", + "permlevel": 0, + "reqd": 0 + }, + { + "fieldname": "bank_cash_account", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Bank / Cash Account", + "options": "Account", + "permlevel": 0, + "reqd": 0, + "search_index": 0 + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "label": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "from_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "From Date", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "to_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "To Date", + "permlevel": 0, + "search_index": 1 + }, + { + "fieldname": "minimum_amount", + "fieldtype": "Currency", + "label": "Minimum Amount", + "permlevel": 0 + }, + { + "fieldname": "maximum_amount", + "fieldtype": "Currency", + "label": "Maximum Amount", + "permlevel": 0 + }, + { + "fieldname": "get_unreconciled_entries_btn", + "fieldtype": "Button", + "label": "Get Unreconciled Entries", + "permlevel": 0 + }, + { + "fieldname": "sec_break1", + "fieldtype": "Section Break", + "label": "Unreconciled Payment Details", + "permlevel": 0 + }, + { + "fieldname": "payment_reconciliation_payments", + "fieldtype": "Table", + "label": "Payment Reconciliation Payments", + "options": "Payment Reconciliation Payment", + "permlevel": 0 + }, + { + "fieldname": "reconcile_btn", + "fieldtype": "Button", + "label": "Reconcile", + "permlevel": 0 + }, + { + "fieldname": "sec_break2", + "fieldtype": "Section Break", + "label": "Invoice/JV Details", + "permlevel": 0 + }, + { + "fieldname": "payment_reconciliation_invoices", + "fieldtype": "Table", + "label": "Payment Reconciliation Invoices", + "options": "Payment Reconciliation Invoice", + "permlevel": 0, + "read_only": 1 + } + ], + "issingle": 1, + "modified": "2014-07-10 18:04:50.893833", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Payment Reconciliation", + "name_case": "", + "owner": "Administrator", + "permissions": [ + { + "cancel": 0, + "create": 1, + "delete": 1, + "permlevel": 0, + "read": 1, + "role": "Accounts Manager", + "submit": 0, + "write": 1 + }, + { + "cancel": 0, + "create": 1, + "delete": 1, + "permlevel": 0, + "read": 1, + "role": "Accounts User", + "submit": 0, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py new file mode 100644 index 0000000000..8fb331714b --- /dev/null +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -0,0 +1,14 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe + +from frappe.utils import flt + +from frappe import msgprint, _ + +from frappe.model.document import Document + +class PaymentReconciliation(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_reconciliation_invoice/__init__.py b/erpnext/accounts/doctype/payment_reconciliation_invoice/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json new file mode 100644 index 0000000000..008b3265d8 --- /dev/null +++ b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json @@ -0,0 +1,59 @@ +{ + "creation": "2014-07-09 16:14:23.672922", + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "fields": [ + { + "fieldname": "invoice_type", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Invoice Type", + "options": "Sales Invoice\nPurchase Invoice\nJournal Voucher", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "invoice_number", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Invoice Number", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "invoice_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Invoice Date", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "outstanding_amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Outstanding Amount", + "permlevel": 0, + "read_only": 1 + } + ], + "istable": 1, + "modified": "2014-07-09 17:15:00.069551", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Payment Reconciliation Invoice", + "name_case": "", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.py b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.py new file mode 100644 index 0000000000..e136881514 --- /dev/null +++ b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.py @@ -0,0 +1,9 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class PaymentReconciliationInvoice(Document): + pass \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_reconciliation_payment/__init__.py b/erpnext/accounts/doctype/payment_reconciliation_payment/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json new file mode 100644 index 0000000000..cbff5b1e20 --- /dev/null +++ b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json @@ -0,0 +1,71 @@ +{ + "creation": "2014-07-09 16:13:35.452759", + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "fields": [ + { + "fieldname": "journal_voucher", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Journal Voucher", + "options": "Journal Voucher", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "posting_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Posting Date", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount", + "permlevel": 0, + "read_only": 1 + }, + { + "default": "Sales Invoice", + "fieldname": "invoice_type", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Invoice Type", + "options": "Sales Invoice\nPurchase Invoice\nJournal Voucher", + "permlevel": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "invoice_number", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Invoice Number", + "permlevel": 0, + "reqd": 1 + }, + { + "fieldname": "remark", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Remark", + "permlevel": 0, + "read_only": 1 + } + ], + "istable": 1, + "modified": "2014-07-09 17:00:18.705385", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Payment Reconciliation Payment", + "name_case": "", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.py b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.py new file mode 100644 index 0000000000..9082ef9bcf --- /dev/null +++ b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.py @@ -0,0 +1,9 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class PaymentReconciliationPayment(Document): + pass \ No newline at end of file From 90b79fcd1fda8166413e9af8e7a0a3f2636dee01 Mon Sep 17 00:00:00 2001 From: ankitjavalkarwork Date: Fri, 11 Jul 2014 15:23:26 +0530 Subject: [PATCH 16/49] Add Payment Reconciliation Feature/Tool - minor changes --- .../payment_reconciliation/payment_reconciliation.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json index 7c53b739e6..12253d0043 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json @@ -79,7 +79,7 @@ "permlevel": 0 }, { - "fieldname": "get_unreconciled_entries_btn", + "fieldname": "get_unreconciled_entries", "fieldtype": "Button", "label": "Get Unreconciled Entries", "permlevel": 0 @@ -98,7 +98,7 @@ "permlevel": 0 }, { - "fieldname": "reconcile_btn", + "fieldname": "reconcile", "fieldtype": "Button", "label": "Reconcile", "permlevel": 0 @@ -119,7 +119,7 @@ } ], "issingle": 1, - "modified": "2014-07-10 18:04:50.893833", + "modified": "2014-07-11 15:01:47.133918", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation", From 0e57b971ad2c9d3bb7f828ef5ca9fd1ffc1c7c27 Mon Sep 17 00:00:00 2001 From: ankitjavalkarwork Date: Fri, 11 Jul 2014 16:08:55 +0530 Subject: [PATCH 17/49] Add Payment Reconciliation Feature/Tool - minor changes --- .../payment_reconciliation.js | 17 ++++++++++++----- .../payment_reconciliation.py | 6 +++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index f0706db896..b40691d053 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -7,19 +7,26 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext onload: function() { var me = this - this.frm.set_query ("party_account", function() { + this.frm.set_query ('party_account', function() { return{ filters:[ - ["Account", "company", "=", me.frm.doc.company], - ["Account", "group_or_ledger", "=", "Ledger"], - ["Account", "master_type", "in", ["Customer", "Supplier"]] + ['Account', 'company', '=', me.frm.doc.company], + ['Account', 'group_or_ledger', '=', 'Ledger'], + ['Account', 'master_type', 'in', ['Customer', 'Supplier']] ] }; }); + }, + + get_unreconciled_entries: function() { + return this.frm.call({ + doc: me.frm.doc, + method: 'get_unreconciled_entries' + }); } }); $.extend(cur_frm.cscript, new erpnext.accounts.PaymentReconciliationController({frm: cur_frm})); -cur_frm.add_fetch("party_account", "master_type", "party_type") \ No newline at end of file +cur_frm.add_fetch('party_account', 'master_type', 'party_type') \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index 8fb331714b..2eb188b0a9 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -11,4 +11,8 @@ from frappe import msgprint, _ from frappe.model.document import Document class PaymentReconciliation(Document): - pass \ No newline at end of file + def get_unreconciled_entries(self): + self.set('payment_reconciliation_payment', []) + jve = self.get_jv_entries() + self.create_payment_reconciliation_payment(jve) + From e6cee7b41f1c45563dfdf67d09fee6fc1d7c9b82 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Thu, 10 Jul 2014 19:06:39 +0530 Subject: [PATCH 18/49] Expense account can be liability account for stock reconciliation --- erpnext/controllers/stock_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index bb3ab69ca1..27437a396a 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -240,7 +240,7 @@ class StockController(AccountsController): else: is_expense_account = frappe.db.get_value("Account", item.get("expense_account"), "report_type")=="Profit and Loss" - if self.doctype != "Purchase Receipt" and not is_expense_account: + if self.doctype not in ("Purchase Receipt", "Stock Reconciliation") and not is_expense_account: frappe.throw(_("Expense / Difference account ({0}) must be a 'Profit or Loss' account") .format(item.get("expense_account"))) if is_expense_account and not item.get("cost_center"): From 614fb750b7fb883757f7b5c53ac97ff10ed8cf25 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Mon, 14 Jul 2014 10:47:50 +0530 Subject: [PATCH 19/49] set qty as per stock uom in entire purchase cycle --- erpnext/controllers/buying_controller.py | 8 ++++++++ erpnext/stock/get_item_details.py | 1 + 2 files changed, 9 insertions(+) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index afccdfa0e3..acb00245e6 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -17,6 +17,7 @@ class BuyingController(StockController): self.supplier_name = frappe.db.get_value("Supplier", self.supplier, "supplier_name") self.is_item_table_empty() + self.set_qty_as_per_stock_uom() self.validate_stock_or_nonstock_items() self.validate_warehouse() @@ -317,3 +318,10 @@ class BuyingController(StockController): def is_item_table_empty(self): if not len(self.get(self.fname)): frappe.throw(_("Item table can not be blank")) + + def set_qty_as_per_stock_uom(self): + for d in self.get(self.fname): + if d.meta.get_field("stock_qty") and not d.stock_qty: + if not d.conversion_factor: + frappe.throw(_("Row {0}: Conversion Factor is mandatory")) + d.stock_qty = flt(d.qty) * flt(d.conversion_factor) \ No newline at end of file diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index f9a1d9fa1a..82b396fb39 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -152,6 +152,7 @@ def get_basic_details(args, item_doc): "min_order_qty": flt(item.min_order_qty) if args.parenttype == "Material Request" else "", "conversion_factor": 1.0, "qty": 1.0, + "stock_qty": 1.0, "price_list_rate": 0.0, "base_price_list_rate": 0.0, "rate": 0.0, From 5c38488590d8398ce4bb242473884303b3661113 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Mon, 14 Jul 2014 11:43:00 +0530 Subject: [PATCH 20/49] Utility: reset serial no status and warehouse --- erpnext/utilities/repost_stock.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py index e4028b69f6..1c6782ad36 100644 --- a/erpnext/utilities/repost_stock.py +++ b/erpnext/utilities/repost_stock.py @@ -190,3 +190,18 @@ def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, postin "posting_date": posting_date, "posting_time": posting_time }) + +def reset_serial_no_status_and_warehouse(serial_nos=[]): + if not serial_nos: + serial_nos = frappe.db.sql_list("""select name from `tabSerial No` where status != 'Not in Use' + and docstatus = 0""") + for serial_no in serial_nos: + try: + sr = frappe.get_doc("Serial No", serial_no) + sr.via_stock_ledger = True + sr.save() + except: + pass + + frappe.db.sql("""update `tabSerial No` set warehouse='' where status in ('Delivered', 'Purchase Returned')""") + \ No newline at end of file From b0a8d000b1c1d7551fc37d6df8e95e1b37a5da94 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Mon, 14 Jul 2014 11:56:03 +0530 Subject: [PATCH 21/49] Utility: reset serial no status and warehouse --- erpnext/utilities/repost_stock.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py index 1c6782ad36..4205893893 100644 --- a/erpnext/utilities/repost_stock.py +++ b/erpnext/utilities/repost_stock.py @@ -198,6 +198,10 @@ def reset_serial_no_status_and_warehouse(serial_nos=[]): for serial_no in serial_nos: try: sr = frappe.get_doc("Serial No", serial_no) + last_sle = sr.get_last_sle() + if flt(last_sle.actual_qty) > 0: + sr.warehouse = last_sle.warehouse + sr.via_stock_ledger = True sr.save() except: From d5fd5359095dabe9ee9e4c145d470a926ffc0446 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Mon, 14 Jul 2014 12:39:50 +0530 Subject: [PATCH 22/49] Minor fix, if no default company --- erpnext/public/js/queries.js | 2 +- erpnext/stock/doctype/stock_entry/stock_entry.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/public/js/queries.js b/erpnext/public/js/queries.js index b57b765ad6..4bb3302bd8 100644 --- a/erpnext/public/js/queries.js +++ b/erpnext/public/js/queries.js @@ -71,7 +71,7 @@ $.extend(erpnext.queries, { warehouse: function(doc) { return { - filters: [["Warehouse", "company", "in", ["", doc.company]]] + filters: [["Warehouse", "company", "in", ["", cstr(doc.company)]]] } } }); diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 10241983ad..7274ece1fa 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -92,7 +92,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ set_default_account: function() { var me = this; - if(cint(frappe.defaults.get_default("auto_accounting_for_stock"))) { + if(cint(frappe.defaults.get_default("auto_accounting_for_stock")) && this.frm.doc.company) { var account_for = "stock_adjustment_account"; if (this.frm.doc.purpose == "Purchase Return") From e8c5cb8c9a7487e59b1205f106117c7cc4061f82 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 14 Jul 2014 13:10:24 +0530 Subject: [PATCH 23/49] Fixed Address and Contact report name --- erpnext/config/buying.py | 2 +- erpnext/config/selling.py | 2 +- .../customer_addresses_and_contacts.json | 30 +++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/erpnext/config/buying.py b/erpnext/config/buying.py index bc6251982b..1b9e5a23b0 100644 --- a/erpnext/config/buying.py +++ b/erpnext/config/buying.py @@ -150,7 +150,7 @@ def get_data(): { "type": "report", "is_query_report": True, - "name": "Supplier Addresses And Contacts", + "name": "Supplier Addresses and Contacts", "doctype": "Supplier" }, { diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py index 200ab6d4ba..c95f15aa83 100644 --- a/erpnext/config/selling.py +++ b/erpnext/config/selling.py @@ -206,7 +206,7 @@ def get_data(): { "type": "report", "is_query_report": True, - "name": "Customer Addresses And Contacts", + "name": "Customer Addresses and Contacts", "doctype": "Contact" }, { diff --git a/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json b/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json index 9bde272c61..deb90b71cd 100644 --- a/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json +++ b/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json @@ -1,17 +1,17 @@ { - "apply_user_permissions": 1, - "creation": "2012-10-04 18:45:27", - "docstatus": 0, - "doctype": "Report", - "idx": 1, - "is_standard": "Yes", - "modified": "2014-06-03 07:18:17.006732", - "modified_by": "Administrator", - "module": "Selling", - "name": "Customer Addresses And Contacts", - "owner": "Administrator", - "query": "SELECT\n\t`tabCustomer`.name as customer_id,\n\t`tabCustomer`.customer_name,\n\t`tabCustomer`.customer_group,\n\t`tabAddress`.address_line1,\n\t`tabAddress`.address_line2,\n\t`tabAddress`.city,\n\t`tabAddress`.state,\n\t`tabAddress`.pincode,\n\t`tabAddress`.country,\n\t`tabAddress`.is_primary_address, \n\t`tabContact`.first_name,\n\t`tabContact`.last_name,\n\t`tabContact`.phone,\n\t`tabContact`.mobile_no,\n\t`tabContact`.email_id,\n\t`tabContact`.is_primary_contact\nFROM\n\t`tabCustomer`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.customer=`tabCustomer`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.customer=`tabCustomer`.name\n\t)\nWHERE\n\t`tabCustomer`.docstatus<2\nORDER BY\n\t`tabCustomer`.name asc", - "ref_doctype": "Customer", - "report_name": "Customer Addresses And Contacts", + "apply_user_permissions": 1, + "creation": "2012-10-04 18:45:27", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-07-14 07:18:17.006732", + "modified_by": "Administrator", + "module": "Selling", + "name": "Customer Addresses and Contacts", + "owner": "Administrator", + "query": "SELECT\n\t`tabCustomer`.name as customer_id,\n\t`tabCustomer`.customer_name,\n\t`tabCustomer`.customer_group,\n\t`tabAddress`.address_line1,\n\t`tabAddress`.address_line2,\n\t`tabAddress`.city,\n\t`tabAddress`.state,\n\t`tabAddress`.pincode,\n\t`tabAddress`.country,\n\t`tabAddress`.is_primary_address, \n\t`tabContact`.first_name,\n\t`tabContact`.last_name,\n\t`tabContact`.phone,\n\t`tabContact`.mobile_no,\n\t`tabContact`.email_id,\n\t`tabContact`.is_primary_contact\nFROM\n\t`tabCustomer`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.customer=`tabCustomer`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.customer=`tabCustomer`.name\n\t)\nWHERE\n\t`tabCustomer`.docstatus<2\nORDER BY\n\t`tabCustomer`.name asc", + "ref_doctype": "Customer", + "report_name": "Customer Addresses And Contacts", "report_type": "Query Report" -} \ No newline at end of file +} From 7700c62fa8ec7290ef2aaeaab975bd55cfee3e16 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Mon, 14 Jul 2014 14:21:21 +0530 Subject: [PATCH 24/49] Minor fix --- erpnext/utilities/repost_stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py index 4205893893..159825a495 100644 --- a/erpnext/utilities/repost_stock.py +++ b/erpnext/utilities/repost_stock.py @@ -191,7 +191,7 @@ def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, postin "posting_time": posting_time }) -def reset_serial_no_status_and_warehouse(serial_nos=[]): +def reset_serial_no_status_and_warehouse(serial_nos=None): if not serial_nos: serial_nos = frappe.db.sql_list("""select name from `tabSerial No` where status != 'Not in Use' and docstatus = 0""") From 1829bd84d3d2d388583548a6b73e9cf85959bfe2 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 14 Jul 2014 14:26:28 +0530 Subject: [PATCH 25/49] hotfix: website_image --- erpnext/setup/doctype/item_group/item_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index 745345e58a..c6f49a1546 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -82,7 +82,7 @@ def get_child_groups(item_group_name): def get_item_for_list_in_html(context): # add missing absolute link in files # user may forget it during upload - if context.get("website_image", "").startswith("files/"): + if (context.get("website_image") or "").startswith("files/"): context["website_image"] = "/" + context["website_image"] return frappe.get_template("templates/includes/product_in_grid.html").render(context) From 345753ed195754aaeb30dbf59d858a296bf8bb27 Mon Sep 17 00:00:00 2001 From: ankitjavalkarwork Date: Mon, 14 Jul 2014 16:38:27 +0530 Subject: [PATCH 26/49] Add Payment Reconciliation Feature/Tool - fetch unreconciled entries --- .../payment_reconciliation.js | 17 +++++-- .../payment_reconciliation.py | 45 ++++++++++++++++++- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index b40691d053..277fcf4705 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -19,10 +19,19 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext }, get_unreconciled_entries: function() { - return this.frm.call({ - doc: me.frm.doc, - method: 'get_unreconciled_entries' - }); + var me = this; + if (!this.frm.doc.company) { + msgprint(__("Please enter the Company")); + } + else if (!this.frm.doc.party_account) { + msgprint(__("Please enter the Party Account")); + } + else { + return this.frm.call({ + doc: me.frm.doc, + method: 'get_unreconciled_entries' + }); + } } }); diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index 2eb188b0a9..17dd5e70a5 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -14,5 +14,48 @@ class PaymentReconciliation(Document): def get_unreconciled_entries(self): self.set('payment_reconciliation_payment', []) jve = self.get_jv_entries() - self.create_payment_reconciliation_payment(jve) + self.add_payment_entries(jve) + def get_jv_entries(self): + self.validation() + + dr_or_cr = "credit" if self.party_type == "Customer" else "debit" + + #Add conditions for debit/credit, sorting by date and amount + cond = self.from_date and " and t1.posting_date >= '" + self.from_date + "'" or "" + cond += self.to_date and " and t1.posting_date <= '" + self.to_date + "'" or "" + + if self.minimum_amount: + cond += (" and ifnull(t2.%s), 0) >= %s") % (dr_or_cr, self.minimum_amount) + if self.maximum_amount: + cond += " and ifnull(t2.%s, 0) <= %s" % (dr_or_cr, self.maximum_amount) + + jve = frappe.db.sql(""" + select + t1.name as voucher_no, t1.posting_date, t1.remark, t2.account, + t2.name as voucher_detail_no, t2.%s, t2.is_advance + from + `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 + where + t1.name = t2.parent and t1.docstatus = 1 and t2.account = %s + and t2.%s > 0 and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')='' + and ifnull(t2.against_jv, '')='' %s + group by t1.name, t2.name """ % (dr_or_cr, '%s', dr_or_cr, cond), (self.party_account), + as_dict = True) + + return jve + + def add_payment_entries(self, jve): + self.set('payment_reconciliation_payments', []) + for e in jve: + ent = self.append('payment_reconciliation_payments', {}) + ent.journal_voucher = e.get('voucher_no') + ent.posting_date = e.get('posting_date') + ent.amount = flt(e.get('credit' or 'debit')) + ent.remark = e.get('remark') + + def validation(self): + self.check_mandatory() + + def check_mandatory(self): + pass From ec05d7f8a1eae1b3864eb4dd197527a872d85e35 Mon Sep 17 00:00:00 2001 From: ankitjavalkarwork Date: Mon, 14 Jul 2014 18:19:15 +0530 Subject: [PATCH 27/49] Add Payment Reconciliation Feature/Tool - javascript validation --- .../payment_reconciliation.js | 15 +++++++-------- .../payment_reconciliation.py | 1 + .../payment_reconciliation_payment.json | 11 ++++++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index 277fcf4705..cf62fd3073 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -20,20 +20,19 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext get_unreconciled_entries: function() { var me = this; - if (!this.frm.doc.company) { - msgprint(__("Please enter the Company")); - } - else if (!this.frm.doc.party_account) { - msgprint(__("Please enter the Party Account")); - } - else { + if(!this.frm.doc.company || !this.frm.doc.party_account) { + if(!this.frm.doc.company) { + msgprint(__("Please enter Company")); + } else { + msgprint(__("Please enter Party Account")); + } + } else { return this.frm.call({ doc: me.frm.doc, method: 'get_unreconciled_entries' }); } } - }); $.extend(cur_frm.cscript, new erpnext.accounts.PaymentReconciliationController({frm: cur_frm})); diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index 17dd5e70a5..b0b189e6d0 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -53,6 +53,7 @@ class PaymentReconciliation(Document): ent.posting_date = e.get('posting_date') ent.amount = flt(e.get('credit' or 'debit')) ent.remark = e.get('remark') + ent.voucher_detail_number = e.get('voucher_detail_no') def validation(self): self.check_mandatory() diff --git a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json index cbff5b1e20..231dfae075 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json +++ b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json @@ -56,10 +56,19 @@ "label": "Remark", "permlevel": 0, "read_only": 1 + }, + { + "fieldname": "voucher_detail_number", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Voucher Detail Number", + "permlevel": 0, + "read_only": 1 } ], "istable": 1, - "modified": "2014-07-09 17:00:18.705385", + "modified": "2014-07-14 16:48:45.875052", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Payment", From d934cd105b1597785839f821549d1c0c9e6219f8 Mon Sep 17 00:00:00 2001 From: ankitjavalkarwork Date: Tue, 15 Jul 2014 18:01:36 +0530 Subject: [PATCH 28/49] Add Payment Reconciliation Feature/Tool - invoice entries table population --- .../payment_reconciliation.py | 95 +++++++++++++++---- 1 file changed, 76 insertions(+), 19 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index b0b189e6d0..fc1ff24109 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -12,25 +12,20 @@ from frappe.model.document import Document class PaymentReconciliation(Document): def get_unreconciled_entries(self): - self.set('payment_reconciliation_payment', []) - jve = self.get_jv_entries() - self.add_payment_entries(jve) + jv_entries = self.get_jv_entries() + self.add_payment_entries(jv_entries) + invoice_entries = self.get_invoice_entries() + + self.add_invoice_entries(invoice_entries) def get_jv_entries(self): - self.validation() + self.check_mandatory() dr_or_cr = "credit" if self.party_type == "Customer" else "debit" - - #Add conditions for debit/credit, sorting by date and amount - cond = self.from_date and " and t1.posting_date >= '" + self.from_date + "'" or "" - cond += self.to_date and " and t1.posting_date <= '" + self.to_date + "'" or "" - if self.minimum_amount: - cond += (" and ifnull(t2.%s), 0) >= %s") % (dr_or_cr, self.minimum_amount) - if self.maximum_amount: - cond += " and ifnull(t2.%s, 0) <= %s" % (dr_or_cr, self.maximum_amount) + cond = self.check_condition(dr_or_cr) - jve = frappe.db.sql(""" + jv_entries = frappe.db.sql(""" select t1.name as voucher_no, t1.posting_date, t1.remark, t2.account, t2.name as voucher_detail_no, t2.%s, t2.is_advance @@ -42,21 +37,83 @@ class PaymentReconciliation(Document): and ifnull(t2.against_jv, '')='' %s group by t1.name, t2.name """ % (dr_or_cr, '%s', dr_or_cr, cond), (self.party_account), as_dict = True) + return jv_entries - return jve - - def add_payment_entries(self, jve): + def add_payment_entries(self, jv_entries): self.set('payment_reconciliation_payments', []) - for e in jve: + for e in jv_entries: ent = self.append('payment_reconciliation_payments', {}) ent.journal_voucher = e.get('voucher_no') ent.posting_date = e.get('posting_date') - ent.amount = flt(e.get('credit' or 'debit')) + ent.amount = flt(e.get('credit')) or flt(e.get('debit')) ent.remark = e.get('remark') ent.voucher_detail_number = e.get('voucher_detail_no') - def validation(self): + def get_invoice_entries(self): + #Fetch JVs, Sales and Purchase Invoices for 'payment_reconciliation_invoices' to reconcile against + non_reconciled_invoices = [] self.check_mandatory() + dr_or_cr = "debit" if self.party_type == "Customer" else "credit" + + cond = self.check_condition(dr_or_cr) + + invoice_list = frappe.db.sql(""" + select + voucher_no, voucher_type, posting_date, ifnull(sum(ifnull(%s, 0)), 0) as amount + from + `tabGL Entry` + where + account = %s and ifnull(%s, 0) > 0 %s + group by voucher_no, voucher_type""" % (dr_or_cr, "%s", + dr_or_cr, cond), (self.party_account), as_dict=True) + + for d in invoice_list: + payment_amount = frappe.db.sql(""" + select + ifnull(sum(ifnull(%s, 0)), 0) + from + `tabGL Entry` + where + account = %s and against_voucher_type = %s and ifnull(against_voucher, '') = %s""", + (("credit" if self.party_type == "Customer" else "debit"), self.party_account, + d.voucher_type, d.voucher_no)) + + payment_amount = payment_amount[0][0] if payment_amount else 0 + + if d.amount > payment_amount: + non_reconciled_invoices.append({'voucher_no': d.voucher_no, + 'voucher_type': d.voucher_type, + 'posting_date': d.posting_date, + 'amount': flt(d.amount), + 'outstanding_amount': d.amount - payment_amount}) + + return non_reconciled_invoices + + + def add_invoice_entries(self, non_reconciled_invoices): + #Populate 'payment_reconciliation_invoices' with JVs and Invoices to reconcile against + self.set('payment_reconciliation_invoices', []) + if not non_reconciled_invoices: + return + for e in non_reconciled_invoices: + ent = self.append('payment_reconciliation_invoices', {}) + ent.invoice_type = e.get('voucher_type') + ent.invoice_number = e.get('voucher_no') + ent.invoice_date = e.get('posting_date') + ent.amount = flt(e.get('amount')) + ent.outstanding_amount = e.get('outstanding_amount') + def check_mandatory(self): pass + + def check_condition(self, dr_or_cr): + cond = self.from_date and " and posting_date >= '" + self.from_date + "'" or "" + cond += self.to_date and " and posting_date <= '" + self.to_date + "'" or "" + + if self.minimum_amount: + cond += (" and ifnull(%s), 0) >= %s") % (dr_or_cr, self.minimum_amount) + if self.maximum_amount: + cond += " and ifnull(%s, 0) <= %s" % (dr_or_cr, self.maximum_amount) + + return cond \ No newline at end of file From c70d2d23a8d11c93455e7751cef30fc7f1fbda15 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 16 Jul 2014 11:27:25 +0530 Subject: [PATCH 29/49] Support Ticket: set resolution_date as None if missing --- .../doctype/support_ticket/support_ticket.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/erpnext/support/doctype/support_ticket/support_ticket.py b/erpnext/support/doctype/support_ticket/support_ticket.py index 9517ea48de..4cdc20ac0f 100644 --- a/erpnext/support/doctype/support_ticket/support_ticket.py +++ b/erpnext/support/doctype/support_ticket/support_ticket.py @@ -8,31 +8,31 @@ from erpnext.utilities.transaction_base import TransactionBase from frappe.utils import now, extract_email_id class SupportTicket(TransactionBase): - + def get_sender(self, comm): return frappe.db.get_value('Support Email Settings',None,'support_email') def get_subject(self, comm): return '[' + self.name + '] ' + (comm.subject or 'No Subject Specified') - + def get_content(self, comm): signature = frappe.db.get_value('Support Email Settings',None,'support_signature') content = comm.content if signature: content += '

' + signature + '

' return content - + def get_portal_page(self): return "ticket" - + def validate(self): self.update_status() self.set_lead_contact(self.raised_by) - + if self.status == "Closed": from frappe.widgets.form.assign_to import clear clear(self.doctype, self.name) - + def set_lead_contact(self, email_id): import email.utils email_id = email.utils.parseaddr(email_id) @@ -41,8 +41,8 @@ class SupportTicket(TransactionBase): self.lead = frappe.db.get_value("Lead", {"email_id": email_id}) if not self.contact: self.contact = frappe.db.get_value("Contact", {"email_id": email_id}) - - if not self.company: + + if not self.company: self.company = frappe.db.get_value("Lead", self.lead, "company") or \ frappe.db.get_default("company") @@ -53,15 +53,16 @@ class SupportTicket(TransactionBase): if self.status=="Closed" and status !="Closed": self.resolution_date = now() if self.status=="Open" and status !="Open": - self.resolution_date = "" + # if no date, it should be set as None and not a blank string "", as per mysql strict config + self.resolution_date = None @frappe.whitelist() def set_status(name, status): st = frappe.get_doc("Support Ticket", name) st.status = status st.save() - + def auto_close_tickets(): - frappe.db.sql("""update `tabSupport Ticket` set status = 'Closed' - where status = 'Replied' + frappe.db.sql("""update `tabSupport Ticket` set status = 'Closed' + where status = 'Replied' and date_sub(curdate(),interval 15 Day) > modified""") From e73ed2afaed1279c8ca87ba77c1e7aaf2ea56fc5 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 16 Jul 2014 11:48:34 +0530 Subject: [PATCH 30/49] Setup Wizard: fixed attachment issue #1940 --- .../setup/page/setup_wizard/setup_wizard.py | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py index ca52efb119..343cba56c4 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.py +++ b/erpnext/setup/page/setup_wizard/setup_wizard.py @@ -113,9 +113,11 @@ def update_user_name(args): last_name=%(last_name)s WHERE name=%(name)s""", args) if args.get("attach_user"): - filename, filetype, content = args.get("attach_user").split(",") - fileurl = save_file(filename, content, "User", args.get("name"), decode=True).file_url - frappe.db.set_value("User", args.get("name"), "user_image", fileurl) + attach_user = args.get("attach_user").split(",") + if len(attach_user)==3: + filename, filetype, content = attach_user + fileurl = save_file(filename, content, "User", args.get("name"), decode=True).file_url + frappe.db.set_value("User", args.get("name"), "user_image", fileurl) add_all_roles_to(args.get("name")) @@ -319,9 +321,11 @@ def create_items(args): }).insert() if args.get("item_img_" + str(i)): - filename, filetype, content = args.get("item_img_" + str(i)).split(",") - fileurl = save_file(filename, content, "Item", item, decode=True).file_url - frappe.db.set_value("Item", item, "image", fileurl) + item_image = args.get("item_img_" + str(i)).split(",") + if len(item_image)==3: + filename, filetype, content = item_image + fileurl = save_file(filename, content, "Item", item, decode=True).file_url + frappe.db.set_value("Item", item, "image", fileurl) def create_customers(args): for i in xrange(1,6): @@ -374,17 +378,21 @@ def create_letter_head(args): "is_default": 1 }).insert() - filename, filetype, content = args.get("attach_letterhead").split(",") - fileurl = save_file(filename, content, "Letter Head", _("Standard"), decode=True).file_url - frappe.db.set_value("Letter Head", _("Standard"), "content", "" % fileurl) + attach_letterhead = args.get("attach_letterhead").split(",") + if len(attach_letterhead)==3: + filename, filetype, content = attach_letterhead + fileurl = save_file(filename, content, "Letter Head", _("Standard"), decode=True).file_url + frappe.db.set_value("Letter Head", _("Standard"), "content", "" % fileurl) def create_logo(args): if args.get("attach_logo"): - filename, filetype, content = args.get("attach_logo").split(",") - fileurl = save_file(filename, content, "Website Settings", "Website Settings", - decode=True).file_url - frappe.db.set_value("Website Settings", "Website Settings", "banner_html", - "" % fileurl) + attach_logo = args.get("attach_logo").split(",") + if len(attach_logo)==3: + filename, filetype, content = attach_logo + fileurl = save_file(filename, content, "Website Settings", "Website Settings", + decode=True).file_url + frappe.db.set_value("Website Settings", "Website Settings", "banner_html", + "" % fileurl) def add_all_roles_to(name): user = frappe.get_doc("User", name) From d93fa2f78b5e0444eeadc0b383a06ac93ff659f1 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 16 Jul 2014 15:48:02 +0530 Subject: [PATCH 31/49] Fixes in Stock Entry and test cases --- .../doctype/sales_invoice/test_records.json | 602 +++++++++--------- .../sales_invoice/test_sales_invoice.py | 1 + .../stock/doctype/stock_entry/stock_entry.py | 5 +- 3 files changed, 305 insertions(+), 303 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/test_records.json b/erpnext/accounts/doctype/sales_invoice/test_records.json index b0828f5c7e..eb86672ccd 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_records.json +++ b/erpnext/accounts/doctype/sales_invoice/test_records.json @@ -1,385 +1,385 @@ [ { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "debit_to": "_Test Customer - _TC", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "debit_to": "_Test Customer - _TC", + "doctype": "Sales Invoice", + "due_date": "2013-01-23", "entries": [ { - "amount": 500.0, - "base_amount": 500.0, - "base_rate": 500.0, - "cost_center": "_Test Cost Center - _TC", - "description": "138-CMS Shoe", - "doctype": "Sales Invoice Item", - "income_account": "Sales - _TC", - "item_name": "138-CMS Shoe", - "parentfield": "entries", - "qty": 1.0, + "amount": 500.0, + "base_amount": 500.0, + "base_rate": 500.0, + "cost_center": "_Test Cost Center - _TC", + "description": "138-CMS Shoe", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_name": "138-CMS Shoe", + "parentfield": "entries", + "qty": 1.0, "rate": 500.0 } - ], - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total": 561.8, - "grand_total_export": 561.8, - "is_pos": 0, - "naming_series": "_T-Sales Invoice-", - "net_total": 500.0, + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 561.8, + "grand_total_export": 561.8, + "is_pos": 0, + "naming_series": "_T-Sales Invoice-", + "net_total": 500.0, "other_charges": [ { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 6 - }, + }, { - "account_head": "_Test Account Service Tax - _TC", - "charge_type": "On Net Total", - "description": "Service Tax", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account Service Tax - _TC", + "charge_type": "On Net Total", + "description": "Service Tax", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 6.36 } - ], - "plc_conversion_rate": 1.0, - "posting_date": "2013-01-23", - "price_list_currency": "INR", + ], + "plc_conversion_rate": 1.0, + "posting_date": "2013-01-23", + "price_list_currency": "INR", "sales_team": [ { - "allocated_percentage": 65.5, - "doctype": "Sales Team", - "parentfield": "sales_team", + "allocated_percentage": 65.5, + "doctype": "Sales Team", + "parentfield": "sales_team", "sales_person": "_Test Sales Person 1" - }, + }, { - "allocated_percentage": 34.5, - "doctype": "Sales Team", - "parentfield": "sales_team", + "allocated_percentage": 34.5, + "doctype": "Sales Team", + "parentfield": "sales_team", "sales_person": "_Test Sales Person 2" } - ], - "selling_price_list": "_Test Price List", + ], + "selling_price_list": "_Test Price List", "territory": "_Test Territory" - }, + }, { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "debit_to": "_Test Customer - _TC", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "debit_to": "_Test Customer - _TC", + "doctype": "Sales Invoice", + "due_date": "2013-03-07", "entries": [ { - "amount": 500.0, - "base_amount": 500.0, - "base_rate": 500.0, - "cost_center": "_Test Cost Center - _TC", - "description": "_Test Item", - "doctype": "Sales Invoice Item", - "expense_account": "_Test Account Cost for Goods Sold - _TC", - "income_account": "Sales - _TC", - "item_code": "_Test Item", - "item_name": "_Test Item", - "parentfield": "entries", - "price_list_rate": 500.0, + "amount": 500.0, + "base_amount": 500.0, + "base_rate": 500.0, + "cost_center": "_Test Cost Center - _TC", + "description": "_Test Item", + "doctype": "Sales Invoice Item", + "expense_account": "_Test Account Cost for Goods Sold - _TC", + "income_account": "Sales - _TC", + "item_code": "_Test Item", + "item_name": "_Test Item", + "parentfield": "entries", + "price_list_rate": 500.0, "qty": 1.0 } - ], - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total": 630.0, - "grand_total_export": 630.0, - "is_pos": 0, - "naming_series": "_T-Sales Invoice-", - "net_total": 500.0, + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total": 630.0, + "grand_total_export": 630.0, + "is_pos": 0, + "naming_series": "_T-Sales Invoice-", + "net_total": 500.0, "other_charges": [ { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 16 - }, + }, { - "account_head": "_Test Account Service Tax - _TC", - "charge_type": "On Net Total", - "description": "Service Tax", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account Service Tax - _TC", + "charge_type": "On Net Total", + "description": "Service Tax", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 10 } - ], - "plc_conversion_rate": 1.0, - "posting_date": "2013-03-07", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", + ], + "plc_conversion_rate": 1.0, + "posting_date": "2013-03-07", + "price_list_currency": "INR", + "selling_price_list": "_Test Price List", "territory": "_Test Territory" - }, + }, { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "debit_to": "_Test Customer - _TC", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "debit_to": "_Test Customer - _TC", + "doctype": "Sales Invoice", + "due_date": "2013-01-23", "entries": [ { - "cost_center": "_Test Cost Center - _TC", - "doctype": "Sales Invoice Item", - "income_account": "Sales - _TC", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "item_tax_rate": "{\"_Test Account Excise Duty - _TC\": 10}", - "parentfield": "entries", - "price_list_rate": 50, - "qty": 10, - "rate": 50, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_code": "_Test Item Home Desktop 100", + "item_name": "_Test Item Home Desktop 100", + "item_tax_rate": "{\"_Test Account Excise Duty - _TC\": 10}", + "parentfield": "entries", + "price_list_rate": 50, + "qty": 10, + "rate": 50, "stock_uom": "_Test UOM" - }, + }, { - "cost_center": "_Test Cost Center - _TC", - "doctype": "Sales Invoice Item", - "income_account": "Sales - _TC", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "parentfield": "entries", - "price_list_rate": 150, - "qty": 5, - "rate": 150, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_code": "_Test Item Home Desktop 200", + "item_name": "_Test Item Home Desktop 200", + "parentfield": "entries", + "price_list_rate": 150, + "qty": 5, + "rate": 150, "stock_uom": "_Test UOM" } - ], - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total_export": 0, - "is_pos": 0, - "naming_series": "_T-Sales Invoice-", + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total_export": 0, + "is_pos": 0, + "naming_series": "_T-Sales Invoice-", "other_charges": [ { - "account_head": "_Test Account Shipping Charges - _TC", - "charge_type": "Actual", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account Shipping Charges - _TC", + "charge_type": "Actual", + "cost_center": "_Test Cost Center - _TC", + "description": "Shipping Charges", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 100 - }, + }, { - "account_head": "_Test Account Customs Duty - _TC", - "charge_type": "On Net Total", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account Customs Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Customs Duty", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 10 - }, + }, { - "account_head": "_Test Account Excise Duty - _TC", - "charge_type": "On Net Total", - "cost_center": "_Test Cost Center - _TC", - "description": "Excise Duty", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account Excise Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Excise Duty", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 12 - }, + }, { - "account_head": "_Test Account Education Cess - _TC", - "charge_type": "On Previous Row Amount", - "cost_center": "_Test Cost Center - _TC", - "description": "Education Cess", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 2, + "account_head": "_Test Account Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "Education Cess", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 2, "row_id": 3 - }, + }, { - "account_head": "_Test Account S&H Education Cess - _TC", - "charge_type": "On Previous Row Amount", - "cost_center": "_Test Cost Center - _TC", - "description": "S&H Education Cess", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 1, + "account_head": "_Test Account S&H Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "S&H Education Cess", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 1, "row_id": 3 - }, + }, { - "account_head": "_Test Account CST - _TC", - "charge_type": "On Previous Row Total", - "cost_center": "_Test Cost Center - _TC", - "description": "CST", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": 2, + "account_head": "_Test Account CST - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "CST", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": 2, "row_id": 5 - }, + }, { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", "rate": 12.5 - }, + }, { - "account_head": "_Test Account Discount - _TC", - "charge_type": "On Previous Row Total", - "cost_center": "_Test Cost Center - _TC", - "description": "Discount", - "doctype": "Sales Taxes and Charges", - "parentfield": "other_charges", - "rate": -10, + "account_head": "_Test Account Discount - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Discount", + "doctype": "Sales Taxes and Charges", + "parentfield": "other_charges", + "rate": -10, "row_id": 7 } - ], - "plc_conversion_rate": 1.0, - "posting_date": "2013-01-23", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", + ], + "plc_conversion_rate": 1.0, + "posting_date": "2013-01-23", + "price_list_currency": "INR", + "selling_price_list": "_Test Price List", "territory": "_Test Territory" - }, + }, { - "company": "_Test Company", - "conversion_rate": 1.0, - "currency": "INR", - "customer": "_Test Customer", - "customer_name": "_Test Customer", - "debit_to": "_Test Customer - _TC", - "doctype": "Sales Invoice", - "due_date": "2013-01-23", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "customer": "_Test Customer", + "customer_name": "_Test Customer", + "debit_to": "_Test Customer - _TC", + "doctype": "Sales Invoice", + "due_date": "2013-01-23", "entries": [ { - "cost_center": "_Test Cost Center - _TC", - "doctype": "Sales Invoice Item", - "income_account": "Sales - _TC", - "item_code": "_Test Item Home Desktop 100", - "item_name": "_Test Item Home Desktop 100", - "item_tax_rate": "{\"_Test Account Excise Duty - _TC\": 10}", - "parentfield": "entries", - "price_list_rate": 62.5, - "qty": 10, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_code": "_Test Item Home Desktop 100", + "item_name": "_Test Item Home Desktop 100", + "item_tax_rate": "{\"_Test Account Excise Duty - _TC\": 10}", + "parentfield": "entries", + "price_list_rate": 62.5, + "qty": 10, "stock_uom": "_Test UOM" - }, + }, { - "cost_center": "_Test Cost Center - _TC", - "doctype": "Sales Invoice Item", - "income_account": "Sales - _TC", - "item_code": "_Test Item Home Desktop 200", - "item_name": "_Test Item Home Desktop 200", - "parentfield": "entries", - "price_list_rate": 190.66, - "qty": 5, + "cost_center": "_Test Cost Center - _TC", + "doctype": "Sales Invoice Item", + "income_account": "Sales - _TC", + "item_code": "_Test Item Home Desktop 200", + "item_name": "_Test Item Home Desktop 200", + "parentfield": "entries", + "price_list_rate": 190.66, + "qty": 5, "stock_uom": "_Test UOM" } - ], - "fiscal_year": "_Test Fiscal Year 2013", - "grand_total_export": 0, - "is_pos": 0, - "naming_series": "_T-Sales Invoice-", + ], + "fiscal_year": "_Test Fiscal Year 2013", + "grand_total_export": 0, + "is_pos": 0, + "naming_series": "_T-Sales Invoice-", "other_charges": [ { - "account_head": "_Test Account Excise Duty - _TC", - "charge_type": "On Net Total", - "cost_center": "_Test Cost Center - _TC", - "description": "Excise Duty", - "doctype": "Sales Taxes and Charges", - "idx": 1, - "included_in_print_rate": 1, - "parentfield": "other_charges", + "account_head": "_Test Account Excise Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Excise Duty", + "doctype": "Sales Taxes and Charges", + "idx": 1, + "included_in_print_rate": 1, + "parentfield": "other_charges", "rate": 12 - }, + }, { - "account_head": "_Test Account Education Cess - _TC", - "charge_type": "On Previous Row Amount", - "cost_center": "_Test Cost Center - _TC", - "description": "Education Cess", - "doctype": "Sales Taxes and Charges", - "idx": 2, - "included_in_print_rate": 1, - "parentfield": "other_charges", - "rate": 2, + "account_head": "_Test Account Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "Education Cess", + "doctype": "Sales Taxes and Charges", + "idx": 2, + "included_in_print_rate": 1, + "parentfield": "other_charges", + "rate": 2, "row_id": 1 - }, + }, { - "account_head": "_Test Account S&H Education Cess - _TC", - "charge_type": "On Previous Row Amount", - "cost_center": "_Test Cost Center - _TC", - "description": "S&H Education Cess", - "doctype": "Sales Taxes and Charges", - "idx": 3, - "included_in_print_rate": 1, - "parentfield": "other_charges", - "rate": 1, + "account_head": "_Test Account S&H Education Cess - _TC", + "charge_type": "On Previous Row Amount", + "cost_center": "_Test Cost Center - _TC", + "description": "S&H Education Cess", + "doctype": "Sales Taxes and Charges", + "idx": 3, + "included_in_print_rate": 1, + "parentfield": "other_charges", + "rate": 1, "row_id": 1 - }, + }, { - "account_head": "_Test Account CST - _TC", - "charge_type": "On Previous Row Total", - "cost_center": "_Test Cost Center - _TC", - "description": "CST", - "doctype": "Sales Taxes and Charges", - "idx": 4, - "included_in_print_rate": 1, - "parentfield": "other_charges", - "rate": 2, + "account_head": "_Test Account CST - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "CST", + "doctype": "Sales Taxes and Charges", + "idx": 4, + "included_in_print_rate": 1, + "parentfield": "other_charges", + "rate": 2, "row_id": 3 - }, + }, { - "account_head": "_Test Account VAT - _TC", - "charge_type": "On Net Total", - "cost_center": "_Test Cost Center - _TC", - "description": "VAT", - "doctype": "Sales Taxes and Charges", - "idx": 5, - "included_in_print_rate": 1, - "parentfield": "other_charges", + "account_head": "_Test Account VAT - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "VAT", + "doctype": "Sales Taxes and Charges", + "idx": 5, + "included_in_print_rate": 1, + "parentfield": "other_charges", "rate": 12.5 - }, + }, { - "account_head": "_Test Account Customs Duty - _TC", - "charge_type": "On Net Total", - "cost_center": "_Test Cost Center - _TC", - "description": "Customs Duty", - "doctype": "Sales Taxes and Charges", - "idx": 6, - "parentfield": "other_charges", + "account_head": "_Test Account Customs Duty - _TC", + "charge_type": "On Net Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Customs Duty", + "doctype": "Sales Taxes and Charges", + "idx": 6, + "parentfield": "other_charges", "rate": 10 - }, + }, { - "account_head": "_Test Account Shipping Charges - _TC", - "charge_type": "Actual", - "cost_center": "_Test Cost Center - _TC", - "description": "Shipping Charges", - "doctype": "Sales Taxes and Charges", - "idx": 7, - "parentfield": "other_charges", + "account_head": "_Test Account Shipping Charges - _TC", + "charge_type": "Actual", + "cost_center": "_Test Cost Center - _TC", + "description": "Shipping Charges", + "doctype": "Sales Taxes and Charges", + "idx": 7, + "parentfield": "other_charges", "rate": 100 - }, + }, { - "account_head": "_Test Account Discount - _TC", - "charge_type": "On Previous Row Total", - "cost_center": "_Test Cost Center - _TC", - "description": "Discount", - "doctype": "Sales Taxes and Charges", - "idx": 8, - "parentfield": "other_charges", - "rate": -10, + "account_head": "_Test Account Discount - _TC", + "charge_type": "On Previous Row Total", + "cost_center": "_Test Cost Center - _TC", + "description": "Discount", + "doctype": "Sales Taxes and Charges", + "idx": 8, + "parentfield": "other_charges", + "rate": -10, "row_id": 7 } - ], - "plc_conversion_rate": 1.0, - "posting_date": "2013-01-23", - "price_list_currency": "INR", - "selling_price_list": "_Test Price List", + ], + "plc_conversion_rate": 1.0, + "posting_date": "2013-01-23", + "price_list_currency": "INR", + "selling_price_list": "_Test Price List", "territory": "_Test Territory" } -] \ No newline at end of file +] diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 85e57822e2..1d22e0930a 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -674,6 +674,7 @@ class TestSalesInvoice(unittest.TestCase): "notification_email_address": "test@example.com, test1@example.com, test2@example.com", "repeat_on_day_of_month": getdate(today).day, "posting_date": today, + "due_date": None, "fiscal_year": get_fiscal_year(today)[0], "invoice_period_from_date": get_first_day(today), "invoice_period_to_date": get_last_day(today) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 586179de28..2609ff5042 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -204,7 +204,7 @@ class StockEntry(StockController): if not self.posting_date or not self.posting_time: frappe.throw(_("Posting date and posting time is mandatory")) - allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock") + allow_negative_stock = cint(frappe.db.get_default("allow_negative_stock")) for d in self.get('mtn_details'): args = frappe._dict({ @@ -219,7 +219,8 @@ class StockEntry(StockController): # get actual stock at source warehouse d.actual_qty = get_previous_sle(args).get("qty_after_transaction") or 0 - if d.s_warehouse and not allow_negative_stock and d.actual_qty <= d.transfer_qty: + # validate qty during submit + if d.docstatus==1 and d.s_warehouse and not allow_negative_stock and d.actual_qty < d.transfer_qty: frappe.throw(_("""Row {0}: Qty not avalable in warehouse {1} on {2} {3}. Available Qty: {4}, Transfer Qty: {5}""").format(d.idx, d.s_warehouse, self.posting_date, self.posting_time, d.actual_qty, d.transfer_qty)) From f214bfcfc3ab83b351eb48bd13d2352948c446ba Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 16 Jul 2014 17:52:08 +0530 Subject: [PATCH 32/49] Fixes in load defaults of transaction.js --- erpnext/public/js/transaction.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 1790a47252..ae5864d491 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -20,16 +20,13 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ currency: currency, price_list_currency: currency, status: "Draft", - fiscal_year: frappe.defaults.get_user_default("fiscal_year"), is_subcontracted: "No", }, function(fieldname, value) { if(me.frm.fields_dict[fieldname] && !me.frm.doc[fieldname]) me.frm.set_value(fieldname, value); }); - if(!this.frm.doc.company) { - this.frm.set_value("company", frappe.defaults.get_user_default("company")); - } else { + if(this.frm.doc.company) { cur_frm.script_manager.trigger("company"); } } @@ -332,7 +329,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ method: "erpnext.accounts.doctype.pricing_rule.pricing_rule.apply_pricing_rule", args: { args: this._get_args(item) }, callback: function(r) { - if (!r.exc) { + if (!r.exc && r.message) { me._set_values_for_item_list(r.message); if(calculate_taxes_and_totals) me.calculate_taxes_and_totals(); } From 4b5e89a067646648f4827bd586cf12e6669b52e9 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 16 Jul 2014 19:23:58 +0530 Subject: [PATCH 33/49] Fixes in Stock Entry test cases --- .../doctype/stock_entry/test_stock_entry.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 260223d4b8..1fdc016d7d 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -21,7 +21,7 @@ class TestStockEntry(unittest.TestCase): frappe.db.sql("""delete from `tabMaterial Request`""") self._clear_stock_account_balance() - frappe.db.set_value("Stock Settings", None, "auto_indent", True) + frappe.db.set_value("Stock Settings", None, "auto_indent", 1) st1 = frappe.copy_doc(test_records[0]) st1.insert() @@ -664,15 +664,17 @@ class TestStockEntry(unittest.TestCase): def test_serial_no_not_exists(self): self._clear_stock_account_balance() frappe.db.sql("delete from `tabSerial No` where name in ('ABCD', 'EFGH')") + make_serialized_item() se = frappe.copy_doc(test_records[0]) se.purpose = "Material Issue" - se.get("mtn_details")[0].item_code = "_Test Serialized Item" + se.get("mtn_details")[0].item_code = "_Test Serialized Item With Series" se.get("mtn_details")[0].qty = 2 se.get("mtn_details")[0].s_warehouse = "_Test Warehouse 1 - _TC" se.get("mtn_details")[0].t_warehouse = None se.get("mtn_details")[0].serial_no = "ABCD\nEFGH" se.get("mtn_details")[0].transfer_qty = 2 se.insert() + self.assertRaises(SerialNoNotExistsError, se.submit) def test_serial_duplicate(self): @@ -699,8 +701,8 @@ class TestStockEntry(unittest.TestCase): return se, serial_nos def test_serial_item_error(self): - self._clear_stock_account_balance() se, serial_nos = self.test_serial_by_series() + make_serialized_item("_Test Serialized Item", "ABCD\nEFGH") se = frappe.copy_doc(test_records[0]) se.purpose = "Material Transfer" @@ -735,6 +737,8 @@ class TestStockEntry(unittest.TestCase): def test_serial_warehouse_error(self): self._clear_stock_account_balance() + make_serialized_item(target_warehouse="_Test Warehouse 1 - _TC") + t = make_serialized_item() serial_nos = get_serial_nos(t.get("mtn_details")[0].serial_no) @@ -818,11 +822,16 @@ class TestStockEntry(unittest.TestCase): self.assertRaises (StockFreezeError, se.submit) frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 0) -def make_serialized_item(): +def make_serialized_item(item_code=None, serial_no=None, target_warehouse=None): se = frappe.copy_doc(test_records[0]) - se.get("mtn_details")[0].item_code = "_Test Serialized Item With Series" + se.get("mtn_details")[0].item_code = item_code or "_Test Serialized Item With Series" + se.get("mtn_details")[0].serial_no = serial_no se.get("mtn_details")[0].qty = 2 se.get("mtn_details")[0].transfer_qty = 2 + + if target_warehouse: + se.get("mtn_details")[0].t_warehouse = target_warehouse + se.insert() se.submit() return se From b8189d7d2337ecd33a7ee3cbbce78d204acf4e5a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 16 Jul 2014 19:24:53 +0530 Subject: [PATCH 34/49] Auto Re-order Item for default warehouse only, if Warehouse wise re-order not specified --- erpnext/stock/utils.py | 95 ++++++++++++++++++++++++++---------------- 1 file changed, 59 insertions(+), 36 deletions(-) diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py index 340e5511ff..10f5cc2776 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -176,7 +176,6 @@ def get_buying_amount(voucher_type, voucher_no, item_row, stock_ledger_entries): def reorder_item(): """ Reorder item if stock reaches reorder level""" - # if initial setup not completed, return if not frappe.db.sql("select name from `tabFiscal Year` limit 1"): return @@ -185,46 +184,69 @@ def reorder_item(): frappe.local.auto_indent = cint(frappe.db.get_value('Stock Settings', None, 'auto_indent')) if frappe.local.auto_indent: - material_requests = {} - bin_list = frappe.db.sql("""select item_code, warehouse, projected_qty - from tabBin where ifnull(item_code, '') != '' and ifnull(warehouse, '') != '' - and exists (select name from `tabItem` - where `tabItem`.name = `tabBin`.item_code and - is_stock_item='Yes' and (is_purchase_item='Yes' or is_sub_contracted_item='Yes') and - (ifnull(end_of_life, '0000-00-00')='0000-00-00' or end_of_life > curdate()))""", - as_dict=True) + _reorder_item() - for bin in bin_list: - #check if re-order is required - item_reorder = frappe.db.get("Item Reorder", - {"parent": bin.item_code, "warehouse": bin.warehouse}) - if item_reorder: - reorder_level = item_reorder.warehouse_reorder_level - reorder_qty = item_reorder.warehouse_reorder_qty - material_request_type = item_reorder.material_request_type or "Purchase" - else: - reorder_level, reorder_qty = frappe.db.get_value("Item", bin.item_code, - ["re_order_level", "re_order_qty"]) - material_request_type = "Purchase" +def _reorder_item(): + # {"Purchase": {"Company": [{"item_code": "", "warehouse": "", "reorder_qty": 0.0}]}, "Transfer": {...}} + material_requests = {"Purchase": {}, "Transfer": {}} - if flt(reorder_level) and flt(bin.projected_qty) < flt(reorder_level): - if flt(reorder_level) - flt(bin.projected_qty) > flt(reorder_qty): - reorder_qty = flt(reorder_level) - flt(bin.projected_qty) + item_warehouse_projected_qty = get_item_warehouse_projected_qty() + warehouse_company = frappe._dict(frappe.db.sql("""select name, company from `tabWarehouse`""")) + default_company = (frappe.defaults.get_defaults()["company"] or + frappe.db.sql("""select name from tabCompany limit 1""")[0][0]) - company = frappe.db.get_value("Warehouse", bin.warehouse, "company") or \ - frappe.defaults.get_defaults()["company"] or \ - frappe.db.sql("""select name from tabCompany limit 1""")[0][0] + def add_to_material_request(item_code, warehouse, reorder_level, reorder_qty, material_request_type): + if warehouse not in item_warehouse_projected_qty[item_code]: + # likely a disabled warehouse or a warehouse where BIN does not exist + return - material_requests.setdefault(material_request_type, frappe._dict()).setdefault( - company, []).append(frappe._dict({ - "item_code": bin.item_code, - "warehouse": bin.warehouse, - "reorder_qty": reorder_qty - }) - ) + reorder_level = flt(reorder_level) + reorder_qty = flt(reorder_qty) + projected_qty = item_warehouse_projected_qty[item_code][warehouse] - if material_requests: - create_material_request(material_requests) + if reorder_level and projected_qty < reorder_level: + deficiency = reorder_level - projected_qty + if deficiency > reorder_qty: + reorder_qty = deficiency + + company = warehouse_company.get(warehouse) or default_company + + material_requests[material_request_type].setdefault(company, []).append({ + "item_code": item_code, + "warehouse": warehouse, + "reorder_qty": reorder_qty + }) + + for item_code in item_warehouse_projected_qty: + item = frappe.get_doc("Item", item_code) + if item.get("item_reorder"): + for d in item.get("item_reorder"): + add_to_material_request(item_code, d.warehouse, d.warehouse_reorder_level, + d.warehouse_reorder_qty, d.material_request_type) + + else: + # raise for default warehouse + add_to_material_request(item_code, item.default_warehouse, item.re_order_level, item.re_order_qty, "Purchase") + + if material_requests: + create_material_request(material_requests) + +def get_item_warehouse_projected_qty(): + item_warehouse_projected_qty = {} + + for item_code, warehouse, projected_qty in frappe.db.sql("""select item_code, warehouse, projected_qty + from tabBin where ifnull(item_code, '') != '' and ifnull(warehouse, '') != '' + and exists (select name from `tabItem` + where `tabItem`.name = `tabBin`.item_code and + is_stock_item='Yes' and (is_purchase_item='Yes' or is_sub_contracted_item='Yes') and + (ifnull(end_of_life, '0000-00-00')='0000-00-00' or end_of_life > %s)) + and exists (select name from `tabWarehouse` + where `tabWarehouse`.name = `tabBin`.warehouse + and ifnull(disabled, 0)=0)""", nowdate()): + + item_warehouse_projected_qty.setdefault(item_code, {})[warehouse] = flt(projected_qty) + + return item_warehouse_projected_qty def create_material_request(material_requests): """ Create indent on reaching reorder level """ @@ -263,6 +285,7 @@ def create_material_request(material_requests): }) for d in items: + d = frappe._dict(d) item = frappe.get_doc("Item", d.item_code) mr.append("indent_details", { "doctype": "Material Request Item", From 96cb130263cef2192fc2c3f5d81327e015b159e2 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Mon, 14 Jul 2014 14:52:49 +0530 Subject: [PATCH 35/49] Default letter head in general ledger and bank reco statement print --- .../bank_reconciliation_statement.html | 3 +++ erpnext/accounts/report/general_ledger/general_ledger.html | 3 +++ 2 files changed, 6 insertions(+) diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html index 91e07ab7da..1a401f5e68 100644 --- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html +++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html @@ -1,3 +1,6 @@ +
+ {%= frappe.boot.letter_heads[frappe.defaults.get_default("letter_head")] %} +

{%= __("Bank Reconciliation Statement") %}

{%= filters.account %}


diff --git a/erpnext/accounts/report/general_ledger/general_ledger.html b/erpnext/accounts/report/general_ledger/general_ledger.html index 63cd1a19d2..fd5fa5fa54 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.html +++ b/erpnext/accounts/report/general_ledger/general_ledger.html @@ -1,3 +1,6 @@ +
+ {%= frappe.boot.letter_heads[frappe.defaults.get_default("letter_head")] %} +

{%= __("Statement of Account") %}

{%= filters.account || "General Ledger" %}


From 143400d444cf51de9afa09fb8423531e2243ab7e Mon Sep 17 00:00:00 2001 From: nabinhait Date: Thu, 17 Jul 2014 11:00:13 +0530 Subject: [PATCH 36/49] Batch no get query fix --- erpnext/stock/doctype/stock_entry/stock_entry.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 2609ff5042..82a099eef6 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -676,9 +676,9 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters): batch_nos = None args = { - 'item_code': filters['item_code'], - 's_warehouse': filters['s_warehouse'], - 'posting_date': filters['posting_date'], + 'item_code': filters.get("item_code"), + 's_warehouse': filters.get('s_warehouse'), + 'posting_date': filters,get('posting_date'), 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype), "start": start, From d16081c4d93ee0acbf39eacc3dc62b4b8cf8a027 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Thu, 17 Jul 2014 11:08:19 +0530 Subject: [PATCH 37/49] Batch no get query fix --- erpnext/stock/doctype/stock_entry/stock_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 82a099eef6..7629c3cefd 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -678,7 +678,7 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters): args = { 'item_code': filters.get("item_code"), 's_warehouse': filters.get('s_warehouse'), - 'posting_date': filters,get('posting_date'), + 'posting_date': filters.get('posting_date'), 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype), "start": start, From fa1cd5faff541bad9ca99267a3d87cebf6f18dd1 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Thu, 17 Jul 2014 11:52:50 +0530 Subject: [PATCH 38/49] Fixed root type of liability accounts --- erpnext/patches.txt | 1 + erpnext/setup/doctype/company/company.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index b7fc5e7768..1a903de743 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -68,3 +68,4 @@ erpnext.patches.v4_1.set_outgoing_email_footer erpnext.patches.v4_1.fix_jv_remarks erpnext.patches.v4_1.fix_sales_order_delivered_status erpnext.patches.v4_1.fix_delivery_and_billing_status +execute:frappe.db.sql("update `tabAccount` set root_type='Liability' where root_type='Income' and report_type='Balance Sheet'") \ No newline at end of file diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index d24c7e78e2..f8e043a927 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -241,7 +241,7 @@ class Company(Document): [_('Sales'),_('Direct Income'),'Ledger','Income Account','Profit and Loss', None, 'Income'], [_('Service'),_('Direct Income'),'Ledger','Income Account','Profit and Loss', None, 'Income'], [_('Indirect Income'),_('Income'),'Group','Income Account','Profit and Loss', None, 'Income'], - [_('Source of Funds (Liabilities)'), None,'Group', None,'Balance Sheet', None, 'Income'], + [_('Source of Funds (Liabilities)'), None,'Group', None,'Balance Sheet', None, 'Liability'], [_('Capital Account'),_('Source of Funds (Liabilities)'),'Group', None,'Balance Sheet', None, 'Liability'], [_('Reserves and Surplus'),_('Capital Account'),'Ledger', None,'Balance Sheet', None, 'Liability'], [_('Shareholders Funds'),_('Capital Account'),'Ledger', None,'Balance Sheet', None, 'Liability'], From e26204e61d94e39dc759df7c7ec6c6ae81cb06e3 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Thu, 17 Jul 2014 12:22:58 +0530 Subject: [PATCH 39/49] From date and to date in general ledger print format --- erpnext/accounts/report/general_ledger/general_ledger.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/general_ledger/general_ledger.html b/erpnext/accounts/report/general_ledger/general_ledger.html index fd5fa5fa54..a639266819 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.html +++ b/erpnext/accounts/report/general_ledger/general_ledger.html @@ -2,7 +2,12 @@ {%= frappe.boot.letter_heads[frappe.defaults.get_default("letter_head")] %}

{%= __("Statement of Account") %}

-

{%= filters.account || "General Ledger" %}

+

{%= filters.account || "General Ledger" %}

+
+ {%= dateutil.str_to_user(filters.from_date) %} + {%= __(" to ") %} + {%= dateutil.str_to_user(filters.to_date) %} +

From 5f2f9552249394ca47adbc42b8e7c3651bd0a27d Mon Sep 17 00:00:00 2001 From: nabinhait Date: Thu, 17 Jul 2014 12:29:56 +0530 Subject: [PATCH 40/49] From date and to date in general ledger print format --- erpnext/accounts/report/general_ledger/general_ledger.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/general_ledger/general_ledger.html b/erpnext/accounts/report/general_ledger/general_ledger.html index a639266819..190d45555a 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.html +++ b/erpnext/accounts/report/general_ledger/general_ledger.html @@ -5,7 +5,7 @@

{%= filters.account || "General Ledger" %}

{%= dateutil.str_to_user(filters.from_date) %} - {%= __(" to ") %} + {%= __("to") %} {%= dateutil.str_to_user(filters.to_date) %}

From fa0db761da07cb343896d7cf17b6ce91d06e1649 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 17 Jul 2014 12:30:55 +0530 Subject: [PATCH 41/49] Fix in Stock Entry test case --- erpnext/stock/doctype/stock_entry/test_stock_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 1fdc016d7d..0f6a33fb73 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -664,7 +664,7 @@ class TestStockEntry(unittest.TestCase): def test_serial_no_not_exists(self): self._clear_stock_account_balance() frappe.db.sql("delete from `tabSerial No` where name in ('ABCD', 'EFGH')") - make_serialized_item() + make_serialized_item(target_warehouse="_Test Warehouse 1 - _TC") se = frappe.copy_doc(test_records[0]) se.purpose = "Material Issue" se.get("mtn_details")[0].item_code = "_Test Serialized Item With Series" From 87e30f68b93603597bd398896d641cddd83807ff Mon Sep 17 00:00:00 2001 From: ankitjavalkarwork Date: Thu, 17 Jul 2014 19:10:45 +0530 Subject: [PATCH 42/49] Add Payment Reconciliation Feature/Tool - Complete --- .../payment_reconciliation.js | 41 ++++-- .../payment_reconciliation.json | 7 +- .../payment_reconciliation.py | 121 +++++++++++++----- .../payment_reconciliation_invoice.json | 3 +- .../payment_reconciliation_payment.json | 21 ++- 5 files changed, 142 insertions(+), 51 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index cf62fd3073..c2ba1e62b3 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -20,19 +20,38 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext get_unreconciled_entries: function() { var me = this; - if(!this.frm.doc.company || !this.frm.doc.party_account) { - if(!this.frm.doc.company) { - msgprint(__("Please enter Company")); - } else { - msgprint(__("Please enter Party Account")); + return this.frm.call({ + doc: me.frm.doc, + method: 'get_unreconciled_entries', + callback: function(r, rt) { + var invoices = []; + + $.each(me.frm.doc.payment_reconciliation_invoices || [], function(i, row) { + if (row.invoice_number && !inList(invoices, row.invoice_number)) + invoices.push(row.invoice_number); + }); + + frappe.meta.get_docfield("Payment Reconciliation Payment", "invoice_number", + me.frm.doc.name).options = invoices.join("\n"); + + $.each(me.frm.doc.payment_reconciliation_payments || [], function(i, p) { + if(!inList(invoices, cstr(p.invoice_number))) p.invoice_number = null; + }); + + refresh_field("payment_reconciliation_payments"); } - } else { - return this.frm.call({ - doc: me.frm.doc, - method: 'get_unreconciled_entries' - }); - } + }); + + }, + + reconcile: function() { + var me = this; + return this.frm.call({ + doc: me.frm.doc, + method: 'reconcile' + }); } + }); $.extend(cur_frm.cscript, new erpnext.accounts.PaymentReconciliationController({frm: cur_frm})); diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json index 12253d0043..ce0d731786 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json @@ -1,4 +1,5 @@ { + "allow_copy": 1, "creation": "2014-07-09 12:04:51.681583", "custom": 0, "docstatus": 0, @@ -27,11 +28,12 @@ { "fieldname": "party_type", "fieldtype": "Select", - "hidden": 0, + "hidden": 1, "in_list_view": 1, "label": "Party Type", "options": "Customer\nSupplier", "permlevel": 0, + "read_only": 1, "reqd": 0 }, { @@ -118,8 +120,9 @@ "read_only": 1 } ], + "hide_toolbar": 1, "issingle": 1, - "modified": "2014-07-11 15:01:47.133918", + "modified": "2014-07-17 19:07:34.385854", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation", diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index fc1ff24109..be53aca928 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -12,32 +12,42 @@ from frappe.model.document import Document class PaymentReconciliation(Document): def get_unreconciled_entries(self): - jv_entries = self.get_jv_entries() - self.add_payment_entries(jv_entries) - invoice_entries = self.get_invoice_entries() - - self.add_invoice_entries(invoice_entries) + self.get_jv_entries() + self.get_invoice_entries() def get_jv_entries(self): - self.check_mandatory() - - dr_or_cr = "credit" if self.party_type == "Customer" else "debit" - + self.check_mandatory_to_fetch() + dr_or_cr = "credit" if self.party_type == "Customer" else "debit" cond = self.check_condition(dr_or_cr) + bank_account_condition = "t2.against_account like %(bank_cash_account)s" \ + if self.bank_cash_account else "1=1" + jv_entries = frappe.db.sql(""" select t1.name as voucher_no, t1.posting_date, t1.remark, t2.account, - t2.name as voucher_detail_no, t2.%s, t2.is_advance + t2.name as voucher_detail_no, t2.{dr_or_cr}, t2.is_advance from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where - t1.name = t2.parent and t1.docstatus = 1 and t2.account = %s - and t2.%s > 0 and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')='' - and ifnull(t2.against_jv, '')='' %s - group by t1.name, t2.name """ % (dr_or_cr, '%s', dr_or_cr, cond), (self.party_account), - as_dict = True) - return jv_entries + t1.name = t2.parent and t1.docstatus = 1 and t2.account = %(party_account)s + and t2.{dr_or_cr} > 0 and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')='' + and ifnull(t2.against_jv, '')='' {cond} + and (CASE + WHEN t1.voucher_type in ('Debit Note', 'Credit Note') + THEN 1=1 + ELSE {bank_account_condition} + END) + group by t1.name, t2.name """.format(**{ + "dr_or_cr": dr_or_cr, + "cond": cond, + "bank_account_condition": bank_account_condition + }), { + "party_account": self.party_account, + "bank_cash_account": "%%%s%%" % self.bank_cash_account + }, as_dict=1) + + self.add_payment_entries(jv_entries) def add_payment_entries(self, jv_entries): self.set('payment_reconciliation_payments', []) @@ -48,14 +58,12 @@ class PaymentReconciliation(Document): ent.amount = flt(e.get('credit')) or flt(e.get('debit')) ent.remark = e.get('remark') ent.voucher_detail_number = e.get('voucher_detail_no') + ent.is_advance = e.get('is_advance') def get_invoice_entries(self): #Fetch JVs, Sales and Purchase Invoices for 'payment_reconciliation_invoices' to reconcile against non_reconciled_invoices = [] - self.check_mandatory() - dr_or_cr = "debit" if self.party_type == "Customer" else "credit" - cond = self.check_condition(dr_or_cr) invoice_list = frappe.db.sql(""" @@ -65,7 +73,7 @@ class PaymentReconciliation(Document): `tabGL Entry` where account = %s and ifnull(%s, 0) > 0 %s - group by voucher_no, voucher_type""" % (dr_or_cr, "%s", + group by voucher_no, voucher_type""" % (dr_or_cr, '%s', dr_or_cr, cond), (self.party_account), as_dict=True) for d in invoice_list: @@ -75,27 +83,30 @@ class PaymentReconciliation(Document): from `tabGL Entry` where - account = %s and against_voucher_type = %s and ifnull(against_voucher, '') = %s""", - (("credit" if self.party_type == "Customer" else "debit"), self.party_account, - d.voucher_type, d.voucher_no)) - + account = %s and against_voucher_type = %s and ifnull(against_voucher, '') = %s""" % + (("credit" if self.party_type == "Customer" else "debit"), '%s', '%s', '%s'), + (self.party_account, d.voucher_type, d.voucher_no)) + payment_amount = payment_amount[0][0] if payment_amount else 0 if d.amount > payment_amount: - non_reconciled_invoices.append({'voucher_no': d.voucher_no, + non_reconciled_invoices.append({ + 'voucher_no': d.voucher_no, 'voucher_type': d.voucher_type, 'posting_date': d.posting_date, 'amount': flt(d.amount), 'outstanding_amount': d.amount - payment_amount}) - return non_reconciled_invoices + self.add_invoice_entries(non_reconciled_invoices) def add_invoice_entries(self, non_reconciled_invoices): #Populate 'payment_reconciliation_invoices' with JVs and Invoices to reconcile against self.set('payment_reconciliation_invoices', []) if not non_reconciled_invoices: - return + frappe.throw(_("No invoices found to be reconciled")) + + for e in non_reconciled_invoices: ent = self.append('payment_reconciliation_invoices', {}) ent.invoice_type = e.get('voucher_type') @@ -104,16 +115,64 @@ class PaymentReconciliation(Document): ent.amount = flt(e.get('amount')) ent.outstanding_amount = e.get('outstanding_amount') - def check_mandatory(self): - pass + def reconcile(self, args): + self.get_invoice_entries() + self.validate_invoice() + dr_or_cr = "credit" if self.party_type == "Customer" else "debit" + lst = [] + for e in self.get('payment_reconciliation_payments'): + lst.append({ + 'voucher_no' : e.journal_voucher, + 'voucher_detail_no' : e.voucher_detail_number, + 'against_voucher_type' : e.invoice_type, + 'against_voucher' : e.invoice_number, + 'account' : self.party_account, + 'is_advance' : e.is_advance, + 'dr_or_cr' : dr_or_cr, + 'unadjusted_amt' : flt(e.amount), + 'allocated_amt' : flt(e.amount) + }) + + if lst: + from erpnext.accounts.utils import reconcile_against_document + reconcile_against_document(lst) + self.get_unreconciled_entries() + msgprint(_("Successfully Reconciled")) + + + def check_mandatory_to_fetch(self): + for fieldname in ["company", "party_account"]: + if not self.get(fieldname): + frappe.throw(_("Please select {0} first").format(self.meta.get_label(fieldname))) + + + def validate_invoice(self): + unreconciled_invoices = frappe._dict() + for d in self.get("payment_reconciliation_invoices"): + unreconciled_invoices.setdefault(d.invoice_type, {}).setdefault(d.invoice_number, d.outstanding_amount) + + invoices_to_reconcile = [] + for p in self.get("payment_reconciliation_payments"): + if p.invoice_type and p.invoice_number: + invoices_to_reconcile.append(p.invoice_number) + + if p.invoice_number not in unreconciled_invoices.get(p.invoice_type): + frappe.throw(_("{0}: {1} not found in Invoice Details table") + .format(p.invoice_type, p.invoice_number)) + + if p.amount > unreconciled_invoices.get(p.invoice_type).get(p.invoice_number): + frappe.throw(_("Row {0}: Payment amount must be less than or equals to invoice outstanding amount").format(p.idx)) + + if not invoices_to_reconcile: + frappe.throw(_("Please select Invoice Type and Invoice Number in atleast one row")) def check_condition(self, dr_or_cr): cond = self.from_date and " and posting_date >= '" + self.from_date + "'" or "" cond += self.to_date and " and posting_date <= '" + self.to_date + "'" or "" if self.minimum_amount: - cond += (" and ifnull(%s), 0) >= %s") % (dr_or_cr, self.minimum_amount) + cond += " and ifnull(%s, 0) >= %s" % (dr_or_cr, self.minimum_amount) if self.maximum_amount: cond += " and ifnull(%s, 0) <= %s" % (dr_or_cr, self.maximum_amount) - return cond \ No newline at end of file + return cond \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json index 008b3265d8..fba5f4e422 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json +++ b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json @@ -18,6 +18,7 @@ "fieldtype": "Data", "in_list_view": 1, "label": "Invoice Number", + "options": "", "permlevel": 0, "read_only": 1 }, @@ -47,7 +48,7 @@ } ], "istable": 1, - "modified": "2014-07-09 17:15:00.069551", + "modified": "2014-07-17 15:52:28.820965", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Invoice", diff --git a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json index 231dfae075..e939b02e1e 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json +++ b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json @@ -43,17 +43,18 @@ }, { "fieldname": "invoice_number", - "fieldtype": "Data", + "fieldtype": "Select", "in_list_view": 1, "label": "Invoice Number", + "options": "", "permlevel": 0, "reqd": 1 }, { - "fieldname": "remark", - "fieldtype": "Text", - "in_list_view": 1, - "label": "Remark", + "fieldname": "is_advance", + "fieldtype": "Data", + "hidden": 1, + "label": "Is Advance", "permlevel": 0, "read_only": 1 }, @@ -65,10 +66,18 @@ "label": "Voucher Detail Number", "permlevel": 0, "read_only": 1 + }, + { + "fieldname": "remark", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "Remark", + "permlevel": 0, + "read_only": 1 } ], "istable": 1, - "modified": "2014-07-14 16:48:45.875052", + "modified": "2014-07-17 18:32:25.230146", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Payment", From d4e080be291b59288645667592006c9479ad81e6 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Thu, 17 Jul 2014 19:31:57 +0530 Subject: [PATCH 43/49] Country mandatory in company master --- erpnext/setup/doctype/company/company.json | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index 51a1ac5ede..4209e7d770 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -53,6 +53,15 @@ "permlevel": 0, "reqd": 0 }, + { + "fieldname": "country", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Country", + "options": "Country", + "permlevel": 0, + "reqd": 1 + }, { "fieldname": "charts_section", "fieldtype": "Section Break", @@ -60,18 +69,10 @@ "label": "Chart of Accounts", "permlevel": 0 }, - { - "fieldname": "country", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Country", - "options": "Country", - "permlevel": 0, - "reqd": 0 - }, { "fieldname": "chart_of_accounts", "fieldtype": "Link", + "hidden": 0, "ignore_user_permissions": 1, "label": "Chart of Accounts", "options": "Chart of Accounts", @@ -348,7 +349,7 @@ ], "icon": "icon-building", "idx": 1, - "modified": "2014-05-27 03:49:08.597191", + "modified": "2014-07-17 19:30:24.487672", "modified_by": "Administrator", "module": "Setup", "name": "Company", From d141cf729366a8de14b6b910de4b426b1d090b63 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 18 Jul 2014 10:31:34 +0530 Subject: [PATCH 44/49] Minor fix in reorder item --- erpnext/stock/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py index 10f5cc2776..100d338fd6 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -192,7 +192,7 @@ def _reorder_item(): item_warehouse_projected_qty = get_item_warehouse_projected_qty() warehouse_company = frappe._dict(frappe.db.sql("""select name, company from `tabWarehouse`""")) - default_company = (frappe.defaults.get_defaults()["company"] or + default_company = (frappe.defaults.get_defaults().get("company") or frappe.db.sql("""select name from tabCompany limit 1""")[0][0]) def add_to_material_request(item_code, warehouse, reorder_level, reorder_qty, material_request_type): From 5283e5a7d8adfc9829f91336e5e329ace5b98e5d Mon Sep 17 00:00:00 2001 From: ankitjavalkarwork Date: Fri, 18 Jul 2014 15:42:45 +0530 Subject: [PATCH 45/49] Add Payment Reconciliation Feature/Tool - JS changes1 --- .../payment_reconciliation.js | 5 ++ .../payment_reconciliation.json | 11 +++- .../payment_reconciliation_invoice.json | 8 ++- .../payment_reconciliation_invoice.py | 4 +- .../payment_reconciliation_payment.json | 50 +++++++++++++------ .../payment_reconciliation_payment.py | 4 +- 6 files changed, 59 insertions(+), 23 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index c2ba1e62b3..14520c2a05 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -16,8 +16,13 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext ] }; }); + + var help_content = [' Note:', + '
    If you are unable to match the exact amount, then amend your Journal Voucher and split rows such that your amounts match the invoice you are trying to reconcile.
'].join("\n"); + this.frm.set_value("reconcile_help", help_content); }, + get_unreconciled_entries: function() { var me = this; return this.frm.call({ diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json index ce0d731786..40b5706260 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.json @@ -108,7 +108,7 @@ { "fieldname": "sec_break2", "fieldtype": "Section Break", - "label": "Invoice/JV Details", + "label": "Invoice/Journal Voucher Details", "permlevel": 0 }, { @@ -118,11 +118,18 @@ "options": "Payment Reconciliation Invoice", "permlevel": 0, "read_only": 1 + }, + { + "fieldname": "reconcile_help", + "fieldtype": "Small Text", + "label": "", + "permlevel": 0, + "read_only": 1 } ], "hide_toolbar": 1, "issingle": 1, - "modified": "2014-07-17 19:07:34.385854", + "modified": "2014-07-18 15:53:20.638456", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation", diff --git a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json index fba5f4e422..4e4ee1ae95 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json +++ b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.json @@ -30,6 +30,12 @@ "permlevel": 0, "read_only": 1 }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "label": "Column Break", + "permlevel": 0 + }, { "fieldname": "amount", "fieldtype": "Currency", @@ -48,7 +54,7 @@ } ], "istable": 1, - "modified": "2014-07-17 15:52:28.820965", + "modified": "2014-07-18 12:20:51.269974", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Invoice", diff --git a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.py b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.py index e136881514..3094a173f0 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.py +++ b/erpnext/accounts/doctype/payment_reconciliation_invoice/payment_reconciliation_invoice.py @@ -1,4 +1,4 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors and contributors # For license information, please see license.txt from __future__ import unicode_literals @@ -6,4 +6,4 @@ import frappe from frappe.model.document import Document class PaymentReconciliationInvoice(Document): - pass \ No newline at end of file + pass diff --git a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json index e939b02e1e..3dd36fc465 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json +++ b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.json @@ -30,6 +30,29 @@ "permlevel": 0, "read_only": 1 }, + { + "fieldname": "is_advance", + "fieldtype": "Data", + "hidden": 1, + "label": "Is Advance", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "voucher_detail_number", + "fieldtype": "Data", + "hidden": 1, + "in_list_view": 0, + "label": "Voucher Detail Number", + "permlevel": 0, + "read_only": 1 + }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "label": "Column Break", + "permlevel": 0 + }, { "default": "Sales Invoice", "fieldname": "invoice_type", @@ -51,21 +74,10 @@ "reqd": 1 }, { - "fieldname": "is_advance", - "fieldtype": "Data", - "hidden": 1, - "label": "Is Advance", - "permlevel": 0, - "read_only": 1 - }, - { - "fieldname": "voucher_detail_number", - "fieldtype": "Data", - "hidden": 1, - "in_list_view": 0, - "label": "Voucher Detail Number", - "permlevel": 0, - "read_only": 1 + "fieldname": "sec_break1", + "fieldtype": "Section Break", + "label": "", + "permlevel": 0 }, { "fieldname": "remark", @@ -74,10 +86,16 @@ "label": "Remark", "permlevel": 0, "read_only": 1 + }, + { + "fieldname": "col_break2", + "fieldtype": "Column Break", + "label": "Column Break", + "permlevel": 0 } ], "istable": 1, - "modified": "2014-07-17 18:32:25.230146", + "modified": "2014-07-18 15:53:15.589501", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Reconciliation Payment", diff --git a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.py b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.py index 9082ef9bcf..21e19bdd71 100644 --- a/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.py +++ b/erpnext/accounts/doctype/payment_reconciliation_payment/payment_reconciliation_payment.py @@ -1,4 +1,4 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors and contributors # For license information, please see license.txt from __future__ import unicode_literals @@ -6,4 +6,4 @@ import frappe from frappe.model.document import Document class PaymentReconciliationPayment(Document): - pass \ No newline at end of file + pass From b1c5738a677fc982bbc700d2464b02e3a75aa55c Mon Sep 17 00:00:00 2001 From: nabinhait Date: Sat, 19 Jul 2014 16:53:45 +0530 Subject: [PATCH 46/49] Fixes overflow tolerance --- erpnext/controllers/status_updater.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 3c6355488f..7a4a30004b 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -152,7 +152,7 @@ class StatusUpdater(Document): overflow_percent = ((item[args['target_field']] - item[args['target_ref_field']]) / item[args['target_ref_field']]) * 100 - + print overflow_percent - tolerance if overflow_percent - tolerance > 0.01: item['max_allowed'] = flt(item[args['target_ref_field']] * (100+tolerance)/100) item['reduce_by'] = item[args['target_field']] - item['max_allowed'] @@ -266,8 +266,7 @@ def get_tolerance_for(item_code, item_tolerance={}, global_tolerance=None): if not tolerance: if global_tolerance == None: - global_tolerance = flt(frappe.db.get_value('Global Defaults', None, - 'tolerance')) + global_tolerance = flt(frappe.db.get_value('Stock Settings', None, 'tolerance')) tolerance = global_tolerance item_tolerance[item_code] = tolerance From 711e8bec3df43c2893fb2ba4f88d621ea2475fb1 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Sat, 19 Jul 2014 17:00:15 +0530 Subject: [PATCH 47/49] Fixes overflow tolerance --- erpnext/controllers/status_updater.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 7a4a30004b..6a2dce00fc 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -152,7 +152,7 @@ class StatusUpdater(Document): overflow_percent = ((item[args['target_field']] - item[args['target_ref_field']]) / item[args['target_ref_field']]) * 100 - print overflow_percent - tolerance + if overflow_percent - tolerance > 0.01: item['max_allowed'] = flt(item[args['target_ref_field']] * (100+tolerance)/100) item['reduce_by'] = item[args['target_field']] - item['max_allowed'] From b1e7bf16bab7811fd82e718c28f2ff371e880986 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Sat, 19 Jul 2014 17:56:43 +0530 Subject: [PATCH 48/49] Translate while creating India specific accounts --- .../company/fixtures/india/__init__.py | 72 ++++++++++--------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/erpnext/setup/doctype/company/fixtures/india/__init__.py b/erpnext/setup/doctype/company/fixtures/india/__init__.py index fa45ab0364..d52b30402e 100644 --- a/erpnext/setup/doctype/company/fixtures/india/__init__.py +++ b/erpnext/setup/doctype/company/fixtures/india/__init__.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ def install(company): docs = [ @@ -27,44 +28,45 @@ def install(company): 'group_or_ledger': 2, 'account_type': 3, 'report_type': 4, - 'tax_rate': 5 + 'tax_rate': 5, + 'root_type': 6 } acc_list_india = [ - ['CENVAT Capital Goods','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['CENVAT','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['CENVAT Service Tax','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['CENVAT Service Tax Cess 1','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['CENVAT Service Tax Cess 2','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['CENVAT Edu Cess','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['CENVAT SHE Cess','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['Excise Duty 4','Tax Assets','Ledger','Tax','Balance Sheet','4.00'], - ['Excise Duty 8','Tax Assets','Ledger','Tax','Balance Sheet','8.00'], - ['Excise Duty 10','Tax Assets','Ledger','Tax','Balance Sheet','10.00'], - ['Excise Duty 14','Tax Assets','Ledger','Tax','Balance Sheet','14.00'], - ['Excise Duty Edu Cess 2','Tax Assets','Ledger','Tax','Balance Sheet','2.00'], - ['Excise Duty SHE Cess 1','Tax Assets','Ledger','Tax','Balance Sheet','1.00'], - ['P L A','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['P L A - Cess Portion','Tax Assets','Ledger','Chargeable','Balance Sheet', None], - ['Edu. Cess on Excise','Duties and Taxes','Ledger','Tax','Balance Sheet','2.00'], - ['Edu. Cess on Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet','2.00'], - ['Edu. Cess on TDS','Duties and Taxes','Ledger','Tax','Balance Sheet','2.00'], - ['Excise Duty @ 4','Duties and Taxes','Ledger','Tax','Balance Sheet','4.00'], - ['Excise Duty @ 8','Duties and Taxes','Ledger','Tax','Balance Sheet','8.00'], - ['Excise Duty @ 10','Duties and Taxes','Ledger','Tax','Balance Sheet','10.00'], - ['Excise Duty @ 14','Duties and Taxes','Ledger','Tax','Balance Sheet','14.00'], - ['Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet','10.3'], - ['SHE Cess on Excise','Duties and Taxes','Ledger','Tax','Balance Sheet','1.00'], - ['SHE Cess on Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet','1.00'], - ['SHE Cess on TDS','Duties and Taxes','Ledger','Tax','Balance Sheet','1.00'], - ['Professional Tax','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['VAT','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['TDS (Advertisement)','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['TDS (Commission)','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['TDS (Contractor)','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['TDS (Interest)','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['TDS (Rent)','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None], - ['TDS (Salary)','Duties and Taxes','Ledger','Chargeable','Balance Sheet', None] + [_('CENVAT Capital Goods'),_(_('Tax Assets')),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('CENVAT'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('CENVAT Service Tax'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('CENVAT Service Tax Cess 1'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('CENVAT Service Tax Cess 2'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('CENVAT Edu Cess'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('CENVAT SHE Cess'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('Excise Duty 4'),_('Tax Assets'),'Ledger','Tax','Balance Sheet','4.00', 'Asset'], + [_('Excise Duty 8'),_('Tax Assets'),'Ledger','Tax','Balance Sheet','8.00', 'Asset'], + [_('Excise Duty 10'),_('Tax Assets'),'Ledger','Tax','Balance Sheet','10.00', 'Asset'], + [_('Excise Duty 14'),_('Tax Assets'),'Ledger','Tax','Balance Sheet','14.00', 'Asset'], + [_('Excise Duty Edu Cess 2'),_('Tax Assets'),'Ledger','Tax','Balance Sheet','2.00', 'Asset'], + [_('Excise Duty SHE Cess 1'),_('Tax Assets'),'Ledger','Tax','Balance Sheet','1.00', 'Asset'], + [_('P L A'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('P L A - Cess Portion'),_('Tax Assets'),'Ledger','Chargeable','Balance Sheet', None, 'Asset'], + [_('Edu. Cess on Excise'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','2.00', 'Liability'], + [_('Edu. Cess on Service Tax'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','2.00', 'Liability'], + [_('Edu. Cess on TDS'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','2.00', 'Liability'], + [_('Excise Duty @ 4'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','4.00', 'Liability'], + [_('Excise Duty @ 8'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','8.00', 'Liability'], + [_('Excise Duty @ 10'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','10.00', 'Liability'], + [_('Excise Duty @ 14'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','14.00', 'Liability'], + [_('Service Tax'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','10.3', 'Liability'], + [_('SHE Cess on Excise'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','1.00', 'Liability'], + [_('SHE Cess on Service Tax'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','1.00', 'Liability'], + [_('SHE Cess on TDS'),_('Duties and Taxes'),'Ledger','Tax','Balance Sheet','1.00', 'Liability'], + [_('Professional Tax'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('VAT'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('TDS (Advertisement)'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('TDS (Commission)'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('TDS (Contractor)'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('TDS (Interest)'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('TDS (Rent)'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'], + [_('TDS (Salary)'),_('Duties and Taxes'),'Ledger','Chargeable','Balance Sheet', None, 'Liability'] ] for lst in acc_list_india: From 1c6313679b32adb03a71e4bb9eae2563ef1a7034 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 21 Jul 2014 13:08:49 +0530 Subject: [PATCH 49/49] Update material_request.js --- erpnext/stock/doctype/material_request/material_request.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index e53a92aad7..7a47765a2c 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -11,8 +11,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten this._super(); this.frm.set_query("item_code", this.frm.cscript.fname, function() { return { - query: "erpnext.controllers.queries.item_query", - filters: {'is_stock_item': 'Yes'} + query: "erpnext.controllers.queries.item_query" } }); },