From f838597b5faec9994155edd191a8d16482cdee63 Mon Sep 17 00:00:00 2001 From: Rohan Bansal Date: Tue, 20 Nov 2018 13:12:13 +0530 Subject: [PATCH 01/19] fix(task): Fix error when trying to convert a task into a group even if no child tasks exist --- erpnext/projects/doctype/task/task.js | 10 +++++----- erpnext/projects/doctype/task/task.py | 15 ++++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/erpnext/projects/doctype/task/task.js b/erpnext/projects/doctype/task/task.js index b8f324a85f..c1a9c448b4 100644 --- a/erpnext/projects/doctype/task/task.js +++ b/erpnext/projects/doctype/task/task.js @@ -80,15 +80,15 @@ frappe.ui.form.on("Task", { } }, - is_group: function(frm) { + is_group: function (frm) { frappe.call({ - method:"erpnext.projects.doctype.task.task.check_if_child_exists", + method: "erpnext.projects.doctype.task.task.check_if_child_exists", args: { name: frm.doc.name }, - callback: function(r){ - if(r.message){ - frappe.msgprint(__('Cannot convert it to non-group. Child Tasks exist.')); + callback: function (r) { + if (r.message.length > 0) { + frappe.msgprint(__(`Cannot convert it to non-group. The following child Tasks exist: ${r.message.join(", ")}.`)); frm.reload_doc(); } } diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py index 3dc52d4ebe..649d73a63f 100755 --- a/erpnext/projects/doctype/task/task.py +++ b/erpnext/projects/doctype/task/task.py @@ -2,12 +2,15 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, json -from frappe.utils import getdate, date_diff, add_days, cstr +import json + +import frappe from frappe import _, throw +from frappe.utils import add_days, cstr, date_diff, get_link_to_form, getdate from frappe.utils.nestedset import NestedSet + class CircularReferenceError(frappe.ValidationError): pass class Task(NestedSet): @@ -157,8 +160,10 @@ class Task(NestedSet): @frappe.whitelist() def check_if_child_exists(name): - return frappe.db.sql("""select name from `tabTask` - where parent_task = %s""", name) + child_tasks = frappe.get_all("Task", filters={"parent_task": name}) + child_tasks = [get_link_to_form("Task", task.name) for task in child_tasks] + return child_tasks + def get_project(doctype, txt, searchfield, start, page_len, filters): from erpnext.controllers.queries import get_match_cond @@ -237,4 +242,4 @@ def add_multiple_tasks(data, parent): new_task.insert() def on_doctype_update(): - frappe.db.add_index("Task", ["lft", "rgt"]) \ No newline at end of file + frappe.db.add_index("Task", ["lft", "rgt"]) From bc4574b59d7f13f6ecb1d797d37fe5aa647751b5 Mon Sep 17 00:00:00 2001 From: Anurag mishra Date: Thu, 22 Nov 2018 18:12:45 +0530 Subject: [PATCH 02/19] Delivery Note fixes --- erpnext/stock/doctype/delivery_note/delivery_note.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index ab624d17db..e4cfb474ff 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -119,6 +119,12 @@ class DeliveryNote(SellingController): self.update_current_stock() if not self.installation_status: self.installation_status = 'Not Installed' + + def validate_qty(self): + data = frappe.get_all("Delivery Note Item", filters={"parent" : self.name}, fields=["qty"]) + for quant in data: + if quant.qty == 0: + frappe.throw("Item quantity can not be zero") def validate_with_previous_doc(self): super(DeliveryNote, self).validate_with_previous_doc({ @@ -202,6 +208,7 @@ class DeliveryNote(SellingController): def on_submit(self): self.validate_packed_qty() + self.validate_qty() # Check for Approving Authority frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.base_grand_total, self) From 66bd5810c5317eb8611ebdb94916770c2c9f3bfc Mon Sep 17 00:00:00 2001 From: Anurag mishra Date: Mon, 26 Nov 2018 11:28:22 +0530 Subject: [PATCH 03/19] fix(validate): Qty is mandatory in delivery note --- erpnext/stock/doctype/delivery_note/delivery_note.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index e4cfb474ff..ea1808b215 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -98,6 +98,7 @@ class DeliveryNote(SellingController): frappe.throw(_("Sales Order required for Item {0}").format(d.item_code)) def validate(self): + self.validate_qty() self.validate_posting_time() super(DeliveryNote, self).validate() self.set_status() @@ -121,9 +122,8 @@ class DeliveryNote(SellingController): if not self.installation_status: self.installation_status = 'Not Installed' def validate_qty(self): - data = frappe.get_all("Delivery Note Item", filters={"parent" : self.name}, fields=["qty"]) - for quant in data: - if quant.qty == 0: + for item in self.items: + if not item.qty: frappe.throw("Item quantity can not be zero") def validate_with_previous_doc(self): From 533066eb878e0d8a8a699fd28850a2b1fb48bc99 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 26 Nov 2018 15:04:21 +0530 Subject: [PATCH 04/19] Salary slip bug fix --- erpnext/hr/doctype/salary_slip/salary_slip.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.js b/erpnext/hr/doctype/salary_slip/salary_slip.js index affbb552f7..4fa3f96891 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.js +++ b/erpnext/hr/doctype/salary_slip/salary_slip.js @@ -178,7 +178,7 @@ var calculate_earning_total = function(doc, dt, dn, reset_amount) { tbl[i].amount = Math.round(tbl[i].default_amount)*(flt(doc.payment_days) / cint(doc.total_working_days)*100)/100; } else if(reset_amount) { - tbl[i].amount = tbl[i].default_amount; + tbl[i].amount = tbl[i].amount; } if(!tbl[i].do_not_include_in_total) { total_earn += flt(tbl[i].amount); @@ -199,7 +199,7 @@ var calculate_ded_total = function(doc, dt, dn, reset_amount) { if(cint(tbl[i].depends_on_lwp) == 1) { tbl[i].amount = Math.round(tbl[i].default_amount)*(flt(doc.payment_days)/cint(doc.total_working_days)*100)/100; } else if(reset_amount) { - tbl[i].amount = tbl[i].default_amount; + tbl[i].amount = tbl[i].amount; } if(!tbl[i].do_not_include_in_total) { total_ded += flt(tbl[i].amount); From 42d3af3bbb1bd876eb2702442c616f359c463090 Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Mon, 26 Nov 2018 15:19:17 +0530 Subject: [PATCH 05/19] making validation generic for sales order,sales invoice,purchase order etc. --- erpnext/controllers/accounts_controller.py | 7 +++++++ erpnext/selling/doctype/sales_order/sales_order.py | 1 - erpnext/stock/doctype/delivery_note/delivery_note.py | 7 ------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 51747f67ae..403adb35a4 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -57,6 +57,8 @@ class AccountsController(TransactionBase): _('{0} is blocked so this transaction cannot proceed'.format(supplier_name)), raise_exception=1) def validate(self): + + self.validate_qty_is_not_zero() if self.get("_action") and self._action != "update_after_submit": self.set_missing_values(for_validate=True) @@ -359,6 +361,11 @@ class AccountsController(TransactionBase): return gl_dict + def validate_qty_is_not_zero(self): + for item in self.items: + if not item.qty: + frappe.throw("Item quantity can not be zero") + def validate_account_currency(self, account, account_currency=None): valid_currency = [self.company_currency] if self.get("currency") and self.currency != self.company_currency: diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 5f435ced74..f6ee48ef45 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -32,7 +32,6 @@ class SalesOrder(SellingController): def validate(self): super(SalesOrder, self).validate() - self.validate_order_type() self.validate_delivery_date() self.validate_proj_cust() diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index ea1808b215..ab624d17db 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -98,7 +98,6 @@ class DeliveryNote(SellingController): frappe.throw(_("Sales Order required for Item {0}").format(d.item_code)) def validate(self): - self.validate_qty() self.validate_posting_time() super(DeliveryNote, self).validate() self.set_status() @@ -120,11 +119,6 @@ class DeliveryNote(SellingController): self.update_current_stock() if not self.installation_status: self.installation_status = 'Not Installed' - - def validate_qty(self): - for item in self.items: - if not item.qty: - frappe.throw("Item quantity can not be zero") def validate_with_previous_doc(self): super(DeliveryNote, self).validate_with_previous_doc({ @@ -208,7 +202,6 @@ class DeliveryNote(SellingController): def on_submit(self): self.validate_packed_qty() - self.validate_qty() # Check for Approving Authority frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.base_grand_total, self) From 7b2c445707e1f716c586cac8c1c49b151d8158c7 Mon Sep 17 00:00:00 2001 From: Anurag mishra Date: Thu, 22 Nov 2018 18:12:45 +0530 Subject: [PATCH 06/19] Delivery Note fixes --- erpnext/stock/doctype/delivery_note/delivery_note.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index ab624d17db..e4cfb474ff 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -119,6 +119,12 @@ class DeliveryNote(SellingController): self.update_current_stock() if not self.installation_status: self.installation_status = 'Not Installed' + + def validate_qty(self): + data = frappe.get_all("Delivery Note Item", filters={"parent" : self.name}, fields=["qty"]) + for quant in data: + if quant.qty == 0: + frappe.throw("Item quantity can not be zero") def validate_with_previous_doc(self): super(DeliveryNote, self).validate_with_previous_doc({ @@ -202,6 +208,7 @@ class DeliveryNote(SellingController): def on_submit(self): self.validate_packed_qty() + self.validate_qty() # Check for Approving Authority frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.base_grand_total, self) From 6ddb15b3dfeb148af8ec36d701bebe3b3a6f18df Mon Sep 17 00:00:00 2001 From: Anurag mishra Date: Mon, 26 Nov 2018 11:28:22 +0530 Subject: [PATCH 07/19] fix(validate): Qty is mandatory in delivery note --- erpnext/stock/doctype/delivery_note/delivery_note.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index e4cfb474ff..ea1808b215 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -98,6 +98,7 @@ class DeliveryNote(SellingController): frappe.throw(_("Sales Order required for Item {0}").format(d.item_code)) def validate(self): + self.validate_qty() self.validate_posting_time() super(DeliveryNote, self).validate() self.set_status() @@ -121,9 +122,8 @@ class DeliveryNote(SellingController): if not self.installation_status: self.installation_status = 'Not Installed' def validate_qty(self): - data = frappe.get_all("Delivery Note Item", filters={"parent" : self.name}, fields=["qty"]) - for quant in data: - if quant.qty == 0: + for item in self.items: + if not item.qty: frappe.throw("Item quantity can not be zero") def validate_with_previous_doc(self): From e657fe84b87b7af39d9c972469cb6bb46dcf1361 Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Mon, 26 Nov 2018 15:19:17 +0530 Subject: [PATCH 08/19] making validation generic for sales order,sales invoice,purchase order etc. --- erpnext/controllers/accounts_controller.py | 7 +++++++ erpnext/selling/doctype/sales_order/sales_order.py | 1 - erpnext/stock/doctype/delivery_note/delivery_note.py | 7 ------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 51747f67ae..403adb35a4 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -57,6 +57,8 @@ class AccountsController(TransactionBase): _('{0} is blocked so this transaction cannot proceed'.format(supplier_name)), raise_exception=1) def validate(self): + + self.validate_qty_is_not_zero() if self.get("_action") and self._action != "update_after_submit": self.set_missing_values(for_validate=True) @@ -359,6 +361,11 @@ class AccountsController(TransactionBase): return gl_dict + def validate_qty_is_not_zero(self): + for item in self.items: + if not item.qty: + frappe.throw("Item quantity can not be zero") + def validate_account_currency(self, account, account_currency=None): valid_currency = [self.company_currency] if self.get("currency") and self.currency != self.company_currency: diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 5f435ced74..f6ee48ef45 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -32,7 +32,6 @@ class SalesOrder(SellingController): def validate(self): super(SalesOrder, self).validate() - self.validate_order_type() self.validate_delivery_date() self.validate_proj_cust() diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index ea1808b215..ab624d17db 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -98,7 +98,6 @@ class DeliveryNote(SellingController): frappe.throw(_("Sales Order required for Item {0}").format(d.item_code)) def validate(self): - self.validate_qty() self.validate_posting_time() super(DeliveryNote, self).validate() self.set_status() @@ -120,11 +119,6 @@ class DeliveryNote(SellingController): self.update_current_stock() if not self.installation_status: self.installation_status = 'Not Installed' - - def validate_qty(self): - for item in self.items: - if not item.qty: - frappe.throw("Item quantity can not be zero") def validate_with_previous_doc(self): super(DeliveryNote, self).validate_with_previous_doc({ @@ -208,7 +202,6 @@ class DeliveryNote(SellingController): def on_submit(self): self.validate_packed_qty() - self.validate_qty() # Check for Approving Authority frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.base_grand_total, self) From bd87903b56f6f3b06debf95287fba55a6348e6a3 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 26 Nov 2018 17:13:59 +0530 Subject: [PATCH 09/19] Added condition for default amount --- erpnext/hr/doctype/salary_slip/salary_slip.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.js b/erpnext/hr/doctype/salary_slip/salary_slip.js index 4fa3f96891..86c50d08ba 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.js +++ b/erpnext/hr/doctype/salary_slip/salary_slip.js @@ -177,8 +177,8 @@ var calculate_earning_total = function(doc, dt, dn, reset_amount) { if(cint(tbl[i].depends_on_lwp) == 1) { tbl[i].amount = Math.round(tbl[i].default_amount)*(flt(doc.payment_days) / cint(doc.total_working_days)*100)/100; - } else if(reset_amount) { - tbl[i].amount = tbl[i].amount; + } else if(reset_amount && tbl[i].default_amount) { + tbl[i].amount = tbl[i].default_amount; } if(!tbl[i].do_not_include_in_total) { total_earn += flt(tbl[i].amount); @@ -198,8 +198,8 @@ var calculate_ded_total = function(doc, dt, dn, reset_amount) { for(var i = 0; i < tbl.length; i++){ if(cint(tbl[i].depends_on_lwp) == 1) { tbl[i].amount = Math.round(tbl[i].default_amount)*(flt(doc.payment_days)/cint(doc.total_working_days)*100)/100; - } else if(reset_amount) { - tbl[i].amount = tbl[i].amount; + } else if(reset_amount && tbl[i].default_amount) { + tbl[i].amount = tbl[i].default_amount; } if(!tbl[i].do_not_include_in_total) { total_ded += flt(tbl[i].amount); From 5b6dd58b3e8718f752e858a12412b3662113ba1c Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Mon, 26 Nov 2018 17:22:50 +0530 Subject: [PATCH 10/19] fixed ZeroDivisionError in sales_order.py --- erpnext/selling/doctype/sales_order/sales_order.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index f6ee48ef45..9a35aedb72 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -341,9 +341,11 @@ class SalesOrder(SellingController): delivered_qty += item.delivered_qty tot_qty += item.qty - - self.db_set("per_delivered", flt(delivered_qty/tot_qty) * 100, - update_modified=False) + + if tot_qty != 0: + self.db_set("per_delivered", flt(delivered_qty/tot_qty) * 100, + update_modified=False) + def set_indicator(self): """Set indicator for portal""" From 15ed7a635158282251469159f58568a9e8fa58c8 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 26 Nov 2018 17:31:18 +0530 Subject: [PATCH 11/19] [Fix] No permission for Manufacturing Settings --- .../manufacturing_settings/manufacturing_settings.py | 8 ++++++++ erpnext/stock/doctype/stock_entry/stock_entry.js | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.py b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.py index b80b0beba3..e88164f917 100644 --- a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.py +++ b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.py @@ -13,3 +13,11 @@ class ManufacturingSettings(Document): def get_mins_between_operations(): return relativedelta(minutes=cint(frappe.db.get_single_value("Manufacturing Settings", "mins_between_operations")) or 10) + +@frappe.whitelist() +def is_material_consumption_enabled(): + if not hasattr(frappe.local, 'material_consumption'): + frappe.local.material_consumption = cint(frappe.db.get_single_value('Manufacturing Settings', + 'material_consumption')) + + return frappe.local.material_consumption \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index a26992a5ae..ccd5f363a4 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -199,12 +199,15 @@ frappe.ui.form.on('Stock Entry', { }, validate_purpose_consumption: function(frm) { - frappe.model.get_value('Manufacturing Settings', {'name': 'Manufacturing Settings'}, 'material_consumption', function(d) { - if (d.material_consumption==0 && frm.doc.purpose=="Material Consumption for Manufacture") { + frappe.call({ + method: "erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings.is_material_consumption_enabled", + }).then(r => { + if (cint(r.message) == 0 + && frm.doc.purpose=="Material Consumption for Manufacture") { frm.set_value("purpose", 'Manufacture'); frappe.throw(__('Material Consumption is not set in Manufacturing Settings.')); } - }) + }); }, company: function(frm) { From d1a85a3637b3224ff37e49267903a890959ebd4e Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 26 Nov 2018 18:42:29 +0530 Subject: [PATCH 12/19] [Fix] Due date can not be greter than posting date validation should consider supplier invoice date for purchase invoice --- erpnext/accounts/party.py | 2 +- erpnext/controllers/accounts_controller.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index f19aaf833b..8c7f3d881f 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -335,7 +335,7 @@ def get_due_date_from_template(template_name, posting_date, bill_date): def validate_due_date(posting_date, due_date, party_type, party, company=None, bill_date=None, template_name=None): if getdate(due_date) < getdate(posting_date): - frappe.throw(_("Due Date cannot be before Posting Date")) + frappe.throw(_("Due Date cannot be before Posting / Supplier Invoice Date")) else: if not template_name: return diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 51747f67ae..18a769d0f7 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -179,7 +179,7 @@ class AccountsController(TransactionBase): validate_due_date(self.posting_date, self.due_date, "Customer", self.customer, self.company, self.payment_terms_template) elif self.doctype == "Purchase Invoice": - validate_due_date(self.posting_date, self.due_date, + validate_due_date(self.bill_date or self.posting_date, self.due_date, "Supplier", self.supplier, self.company, self.bill_date, self.payment_terms_template) def set_price_list_currency(self, buying_or_selling): From 5fdbc68ca34a1c22afcdadf59644eb33ff3b945c Mon Sep 17 00:00:00 2001 From: Saif Ur Rehman Date: Mon, 26 Nov 2018 19:32:16 +0500 Subject: [PATCH 13/19] Set Gross Profit on server-side validation of Sales Order --- erpnext/controllers/selling_controller.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index 719f4c732a..7739592ced 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -41,6 +41,7 @@ class SellingController(StockController): self.validate_selling_price() self.set_qty_as_per_stock_uom() self.set_po_nos() + self.set_gross_profit() set_default_income_account_for_item(self) def set_missing_values(self, for_validate=False): @@ -348,6 +349,12 @@ class SellingController(StockController): if po_nos and po_nos[0].get('po_no'): self.po_no = ', '.join(list(set([d.po_no for d in po_nos if d.po_no]))) + def set_gross_profit(self): + if self.doctype == "Sales Order": + for item in self.items: + item.gross_profit = flt(((item.base_rate - item.valuation_rate) * item.stock_qty), self.precision("amount", item)) + + def validate_items(self): # validate items to see if they have is_sales_item enabled from erpnext.controllers.buying_controller import validate_item_type From 05c298969859f977be4b6e51224d6feb58c8c0f5 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 26 Nov 2018 16:52:15 +0530 Subject: [PATCH 14/19] removed total from graph --- .../selling/report/sales_analytics/sales_analytics.js | 9 +++++---- .../selling/report/sales_analytics/sales_analytics.py | 9 +++++---- erpnext/stock/report/stock_analytics/stock_analytics.js | 9 ++++----- erpnext/stock/report/stock_analytics/stock_analytics.py | 6 ++---- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.js b/erpnext/selling/report/sales_analytics/sales_analytics.js index 718f29c611..7dc7c754bc 100644 --- a/erpnext/selling/report/sales_analytics/sales_analytics.js +++ b/erpnext/selling/report/sales_analytics/sales_analytics.js @@ -73,7 +73,8 @@ frappe.query_reports["Sales Analytics"] = { events: { onCheckRow: function(data) { row_name = data[2].content; - row_values = data.slice(4).map(function (column) { + length = data.length + row_values = data.slice(4,length-1).map(function (column) { return column.content; }) entry = { @@ -102,12 +103,12 @@ frappe.query_reports["Sales Analytics"] = { labels: raw_data.labels, datasets: new_datasets } - + setTimeout(() => { frappe.query_report.chart.update(new_data) },200) - - + + setTimeout(() => { frappe.query_report.chart.draw(true); }, 800) diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.py b/erpnext/selling/report/sales_analytics/sales_analytics.py index 2cc2f70401..8d99a9b789 100644 --- a/erpnext/selling/report/sales_analytics/sales_analytics.py +++ b/erpnext/selling/report/sales_analytics/sales_analytics.py @@ -166,7 +166,7 @@ class Analytics(object): for entity, period_data in iteritems(self.entity_periodic_data): row = { "entity": entity, - "entity_name": self.entity_names.get(entity) + "entity_name": self.entity_names.get(entity) } total = 0 for dummy, end_date in self.periodic_daterange: @@ -177,7 +177,7 @@ class Analytics(object): row["total"] = total self.data.append(row) - + def get_rows_by_group(self): self.get_periodic_data() out = [] @@ -185,7 +185,7 @@ class Analytics(object): for d in reversed(self.group_entries): row = { "entity": d.name, - "indent": self.depth_map.get(d.name) + "indent": self.depth_map.get(d.name) } total = 0 for dummy, end_date in self.periodic_daterange: @@ -275,7 +275,8 @@ class Analytics(object): self.parent_child_map = frappe._dict(frappe.db.sql(""" select name, supplier_group from `tabSupplier`""")) def get_chart_data(self): - labels = [d.get("label") for d in self.columns[2:]] + length = len(self.columns) + labels = [d.get("label") for d in self.columns[2:length-1]] self.chart = { "data": { 'labels': labels, diff --git a/erpnext/stock/report/stock_analytics/stock_analytics.js b/erpnext/stock/report/stock_analytics/stock_analytics.js index 6010ea9ee2..bebc84e057 100644 --- a/erpnext/stock/report/stock_analytics/stock_analytics.js +++ b/erpnext/stock/report/stock_analytics/stock_analytics.js @@ -88,10 +88,9 @@ frappe.query_reports["Stock Analytics"] = { events: { onCheckRow: function(data) { row_name = data[2].content; - row_values = data.slice(6).map(function (column) { + row_values = data.slice(7).map(function (column) { return column.content; }) - entry = { 'name':row_name, 'values':row_values @@ -118,12 +117,12 @@ frappe.query_reports["Stock Analytics"] = { labels: raw_data.labels, datasets: new_datasets } - + setTimeout(() => { frappe.query_report.chart.update(new_data) },200) - - + + setTimeout(() => { frappe.query_report.chart.draw(true); }, 800) diff --git a/erpnext/stock/report/stock_analytics/stock_analytics.py b/erpnext/stock/report/stock_analytics/stock_analytics.py index 5a8a672b63..dad8be1b8c 100644 --- a/erpnext/stock/report/stock_analytics/stock_analytics.py +++ b/erpnext/stock/report/stock_analytics/stock_analytics.py @@ -167,13 +167,11 @@ def get_data(filters): return data def get_chart_data(columns): - labels = [d.get("label") for d in columns[4:]] + labels = [d.get("label") for d in columns[5:]] chart = { "data": { 'labels': labels, - 'datasets':[ - { "values": ['0' for d in columns[4:]] } - ] + 'datasets':[] } } chart["type"] = "line" From 6a9d9d76eff53a368559c79db416e7522e0ae90f Mon Sep 17 00:00:00 2001 From: Saif Date: Mon, 26 Nov 2018 19:56:13 +0500 Subject: [PATCH 15/19] Company rename abbr to consider more DocTypes --- erpnext/setup/doctype/company/company.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 0c58fb2679..40bbc2c15f 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -363,7 +363,8 @@ def replace_abbr(company, old, new): for d in doc: _rename_record(d) - for dt in ["Warehouse", "Account", "Cost Center"]: + for dt in ["Warehouse", "Account", "Cost Center", "Department", "Location", + "Sales Taxes and Charges Template", "Purchase Taxes and Charges Template"]: _rename_records(dt) frappe.db.commit() From a9525de0da6844ead7fc6fb2b2faf6bbd92b8c7f Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 26 Nov 2018 20:34:32 +0530 Subject: [PATCH 16/19] paid amount fix in fees --- erpnext/education/doctype/fees/fees.py | 5 ++++- erpnext/templates/includes/fee/fee_row.html | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/erpnext/education/doctype/fees/fees.py b/erpnext/education/doctype/fees/fees.py index bfe6af4bdb..aa616e6206 100644 --- a/erpnext/education/doctype/fees/fees.py +++ b/erpnext/education/doctype/fees/fees.py @@ -112,7 +112,10 @@ def get_fee_list(doctype, txt, filters, limit_start, limit_page_length=20, order user = frappe.session.user student = frappe.db.sql("select name from `tabStudent` where student_email_id= %s", user) if student: - return frappe. db.sql('''select name, program, due_date, paid_amount, outstanding_amount, grand_total from `tabFees` + return frappe. db.sql(''' + select name, program, due_date, grand_total - outstanding_amount as paid_amount, + outstanding_amount, grand_total, currency + from `tabFees` where student= %s and docstatus=1 order by due_date asc limit {0} , {1}''' .format(limit_start, limit_page_length), student, as_dict = True) diff --git a/erpnext/templates/includes/fee/fee_row.html b/erpnext/templates/includes/fee/fee_row.html index ac2b1006ad..d5fd682236 100644 --- a/erpnext/templates/includes/fee/fee_row.html +++ b/erpnext/templates/includes/fee/fee_row.html @@ -5,13 +5,13 @@ {{ doc.program }}
- {{ doc.get_formatted("total_amount") }} + {{ frappe.utils.fmt_money(doc.grand_total, currency=doc.currency) }}
- {{ doc.get_formatted("paid_amount") }} + {{ frappe.utils.fmt_money(doc.paid_amount, currency=doc.currency) }}
- {{ doc.get_formatted("outstanding_amount") }} + {{ frappe.utils.fmt_money(doc.outstanding_amount, currency=doc.currency) }}
From bc513a88285a407bba5225030d408ac51c4058ed Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 26 Nov 2018 20:43:39 +0530 Subject: [PATCH 17/19] Removed paid amount form Fees doctype --- erpnext/education/doctype/fees/fees.json | 36 ++---------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/erpnext/education/doctype/fees/fees.json b/erpnext/education/doctype/fees/fees.json index ac32717721..2413967442 100644 --- a/erpnext/education/doctype/fees/fees.json +++ b/erpnext/education/doctype/fees/fees.json @@ -1,5 +1,6 @@ { "allow_copy": 0, + "allow_events_in_timeline": 0, "allow_guest_to_view": 0, "allow_import": 1, "allow_rename": 0, @@ -991,39 +992,6 @@ "translatable": 0, "unique": 0 }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "0", - "fieldname": "paid_amount", - "fieldtype": "Currency", - "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Paid Amount", - "length": 0, - "no_copy": 1, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, { "allow_bulk_edit": 0, "allow_in_quick_entry": 0, @@ -1360,7 +1328,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2018-08-21 14:44:48.968839", + "modified": "2018-11-26 20:42:14.467284", "modified_by": "Administrator", "module": "Education", "name": "Fees", From 2d0b78810550e4444797478c025de5f3b80e6119 Mon Sep 17 00:00:00 2001 From: Kanchan Chauhan Date: Tue, 27 Nov 2018 10:37:23 +0530 Subject: [PATCH 18/19] [Minor] Indicators in Leave Application --- .../doctype/leave_application/leave_application_list.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/leave_application/leave_application_list.js b/erpnext/hr/doctype/leave_application/leave_application_list.js index d7588da4dd..f69b182737 100644 --- a/erpnext/hr/doctype/leave_application/leave_application_list.js +++ b/erpnext/hr/doctype/leave_application/leave_application_list.js @@ -1,3 +1,10 @@ frappe.listview_settings['Leave Application'] = { - add_fields: ["leave_type", "employee", "employee_name", "total_leave_days", "from_date", "to_date"] + add_fields: ["leave_type", "employee", "employee_name", "total_leave_days", "from_date", "to_date"], + get_indicator: function (doc) { + if (doc.status === "Approved") { + return [__("Approved"), "green", "status,=,Approved"]; + } else if (doc.status === "Rejected") { + return [__("Rejected"), "red", "status,=,Rejected"]; + } + } }; From 6cc2f52fa4bef717a81574ef07f999b28656ae4b Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 27 Nov 2018 12:07:03 +0530 Subject: [PATCH 19/19] [Fix] System allocated grand total amount instead of non zero rounded total for advanced entry in the sales invoice --- erpnext/controllers/accounts_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 51747f67ae..3646d87036 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -405,7 +405,8 @@ class AccountsController(TransactionBase): if d.against_order: allocated_amount = flt(d.amount) else: - allocated_amount = min(self.grand_total - advance_allocated, d.amount) + amount = self.rounded_total or self.grand_total + allocated_amount = min(amount - advance_allocated, d.amount) advance_allocated += flt(allocated_amount) self.append("advances", {