From 98dbccd1d658682f5a796b64e69f6dbd9e2c28be Mon Sep 17 00:00:00 2001 From: Sambhaji Kolate Date: Tue, 10 Mar 2015 15:04:28 +0530 Subject: [PATCH 1/6] added actual_batch_qty at warehouse in DN & SI #1873 --- .../doctype/sales_invoice/sales_invoice.js | 2 +- .../sales_invoice_item/sales_invoice_item.json | 15 ++++++++++++++- erpnext/selling/sales_common.js | 18 ++++++++++++++++++ .../delivery_note_item/delivery_note_item.json | 15 ++++++++++++++- erpnext/stock/get_item_details.py | 15 +++++++++++++++ 5 files changed, 62 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index a50d69e97f..1cb26fde1c 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -244,7 +244,7 @@ cur_frm.cscript.hide_fields = function(doc) { cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal, true); } - item_flds_stock = ['serial_no', 'batch_no', 'actual_qty', 'expense_account', 'warehouse'] + item_flds_stock = ['serial_no', 'batch_no', 'actual_qty', 'actual_batch_qty', 'expense_account', 'warehouse'] cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_stock, (cint(doc.update_stock)==1 ? true : false)); diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json index 2baa06a8a2..d545f37e1c 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json @@ -339,6 +339,19 @@ "fieldtype": "Column Break", "permlevel": 0 }, + { + "allow_on_submit": 1, + "fieldname": "actual_batch_qty", + "fieldtype": "Float", + "label": "Available Batch Qty at Warehouse", + "no_copy": 1, + "permlevel": 0, + "precision": "", + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, { "allow_on_submit": 1, "fieldname": "actual_qty", @@ -439,7 +452,7 @@ ], "idx": 1, "istable": 1, - "modified": "2014-09-09 05:35:36.019576", + "modified": "2015-03-10 14:56:45.641026", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Item", diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 5a7ed08e3e..b2172f3190 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -215,7 +215,10 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }, warehouse: function(doc, cdt, cdn) { + var me = this; + this.batch_no(doc, cdt, cdn); var item = frappe.get_doc(cdt, cdn); + this.batch_no(doc) if(item.item_code && item.warehouse) { return this.frm.call({ method: "erpnext.stock.get_item_details.get_available_qty", @@ -476,6 +479,21 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } }, + batch_no: function(doc, cdt, cdn) { + var me = this; + var item = frappe.get_doc(cdt, cdn); + return this.frm.call({ + method: "erpnext.stock.get_item_details.get_batch_qty", + child: item, + args: { + "batch_no": item.batch_no, + "warehouse": item.warehouse, + "item_code": item.item_code + }, + "fieldname": "actual_batch_qty" + }); + }, + set_dynamic_labels: function() { this._super(); this.set_sales_bom_help(this.frm.doc); diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json index a5fe469d69..e2385f5087 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json @@ -314,6 +314,19 @@ "fieldtype": "Column Break", "permlevel": 0 }, + { + "allow_on_submit": 1, + "fieldname": "actual_batch_qty", + "fieldtype": "Float", + "label": "Available Batch Qty at Warehouse", + "no_copy": 1, + "permlevel": 0, + "precision": "", + "print_hide": 1, + "print_width": "150px", + "read_only": 1, + "width": "150px" + }, { "allow_on_submit": 1, "fieldname": "actual_qty", @@ -426,7 +439,7 @@ ], "idx": 1, "istable": 1, - "modified": "2014-09-09 05:35:37.460939", + "modified": "2015-03-10 12:21:17.028911", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note Item", diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 6f9839d456..9ef1a46a05 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -278,6 +278,15 @@ def get_serial_nos_by_fifo(args, item_doc): "qty": cint(args.qty) })) +def get_actual_batch_qty(batch_no,warehouse,item_code): + actual_batch_qty = 0 + if batch_no: + actual_batch_qty = flt(frappe.db.sql("""select sum(actual_qty) + from `tabStock Ledger Entry` + where warehouse=%s and item_code=%s and batch_no=%s""", + (warehouse, item_code, batch_no))[0][0]) + return actual_batch_qty + @frappe.whitelist() def get_conversion_factor(item_code, uom): return {"conversion_factor": frappe.db.get_value("UOM Conversion Detail", @@ -293,6 +302,12 @@ def get_available_qty(item_code, warehouse): return frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse}, ["projected_qty", "actual_qty"], as_dict=True) or {} +@frappe.whitelist(allow_guest=False) +def get_batch_qty(batch_no,warehouse,item_code): + actual_batch_qty = get_actual_batch_qty(batch_no,warehouse,item_code) + if batch_no: + return {'actual_batch_qty': actual_batch_qty} + @frappe.whitelist() def apply_price_list(args): """ From 845f1c636e19458901e601ccf24293dc9355ffda Mon Sep 17 00:00:00 2001 From: Sambhaji Kolate Date: Tue, 10 Mar 2015 15:19:29 +0530 Subject: [PATCH 2/6] code cleanup --- erpnext/selling/sales_common.js | 1 - erpnext/stock/get_item_details.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index b2172f3190..1c5df6e304 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -218,7 +218,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ var me = this; this.batch_no(doc, cdt, cdn); var item = frappe.get_doc(cdt, cdn); - this.batch_no(doc) if(item.item_code && item.warehouse) { return this.frm.call({ method: "erpnext.stock.get_item_details.get_available_qty", diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 9ef1a46a05..6d01c33644 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -302,7 +302,7 @@ def get_available_qty(item_code, warehouse): return frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse}, ["projected_qty", "actual_qty"], as_dict=True) or {} -@frappe.whitelist(allow_guest=False) +@frappe.whitelist() def get_batch_qty(batch_no,warehouse,item_code): actual_batch_qty = get_actual_batch_qty(batch_no,warehouse,item_code) if batch_no: From d6822ddd7c8b82b7f7053e146710433fabada29a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 13 Mar 2015 18:23:10 +0530 Subject: [PATCH 3/6] manipulate grand total for inclusive tax --- erpnext/controllers/accounts_controller.py | 14 ++++++++++++++ erpnext/public/js/transaction.js | 1 + erpnext/selling/sales_common.js | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index fcc350a3ee..e9c6c84184 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -185,6 +185,7 @@ class AccountsController(TransactionBase): self.calculate_net_total() self.calculate_taxes() + self.manipulate_grand_total_for_inclusive_tax() self.calculate_totals() self._cleanup() @@ -353,6 +354,19 @@ class AccountsController(TransactionBase): self.precision(base_field, item)) item.set(base_field, value_in_company_currency) + def manipulate_grand_total_for_inclusive_tax(self): + # if fully inclusive taxes and diff + if (self.meta.get_field("net_total_export") and self.tax_doclist + and all(cint(t.included_in_print_rate) for t in self.tax_doclist)): + + last_tax = self.tax_doclist[-1] + + diff = self.net_total_export - flt(last_tax.total / self.conversion_rate, + self.precision("grand_total_export")) + + if diff: + last_tax.total = last_tax.total + flt(diff * self.conversion_rate, self.precision("total", last_tax)) + def calculate_total_advance(self, parenttype, advance_parentfield): if self.doctype == parenttype and self.docstatus < 2: sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv)) diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index ebdb136dd4..ba0fa408d8 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -632,6 +632,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ this.determine_exclusive_rate && this.determine_exclusive_rate(); this.calculate_net_total(); this.calculate_taxes(); + this.manipulate_grand_total_for_inclusive_tax && this.manipulate_grand_total_for_inclusive_tax(); this.calculate_totals(); this._cleanup(); diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 1c5df6e304..6fdfeae876 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -458,6 +458,26 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }); }, + manipulate_grand_total_for_inclusive_tax: function() { + // if fully inclusive taxes and diff + if (this.frm.tax_doclist.length) { + var all_inclusive = frappe.utils.all(this.frm.tax_doclist.map(function(d) { + return cint(d.included_in_print_rate); + })); + + if (all_inclusive) { + var last_tax = this.frm.tax_doclist.slice(-1)[0]; + + var diff = this.frm.doc.net_total_export + - flt(last_tax.total / this.frm.doc.conversion_rate, precision("grand_total_export")); + + if (diff) { + last_tax.total += flt(diff * this.frm.doc.conversion_rate, precision("total", last_tax)); + } + } + } + }, + _cleanup: function() { this._super(); this.frm.doc.in_words = this.frm.doc.in_words_export = ""; From ead48094b6a9001a46c38fddbd822354917f4381 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 13 Mar 2015 18:59:01 +0530 Subject: [PATCH 4/6] manipulate diff only if diff <= 0.02 --- erpnext/controllers/accounts_controller.py | 2 +- erpnext/selling/sales_common.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index e9c6c84184..431eab5924 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -364,7 +364,7 @@ class AccountsController(TransactionBase): diff = self.net_total_export - flt(last_tax.total / self.conversion_rate, self.precision("grand_total_export")) - if diff: + if diff and abs(diff) <= (2.0 / 10**(self.precision("total", last_tax))): last_tax.total = last_tax.total + flt(diff * self.conversion_rate, self.precision("total", last_tax)) def calculate_total_advance(self, parenttype, advance_parentfield): diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 6fdfeae876..f440315d91 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -471,7 +471,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ var diff = this.frm.doc.net_total_export - flt(last_tax.total / this.frm.doc.conversion_rate, precision("grand_total_export")); - if (diff) { + if ( diff && Math.abs(diff) <= (2.0 / Math.pow(10, precision("total", last_tax)) ) { last_tax.total += flt(diff * this.frm.doc.conversion_rate, precision("total", last_tax)); } } From f2791f8898730badef5bfdd8d602410e8a3549da Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 16 Mar 2015 17:01:09 +0530 Subject: [PATCH 5/6] manipulate_grand_total_for_inclusive_tax --- erpnext/controllers/accounts_controller.py | 7 +++++-- erpnext/selling/sales_common.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 431eab5924..bb7e8527b9 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -364,8 +364,11 @@ class AccountsController(TransactionBase): diff = self.net_total_export - flt(last_tax.total / self.conversion_rate, self.precision("grand_total_export")) - if diff and abs(diff) <= (2.0 / 10**(self.precision("total", last_tax))): - last_tax.total = last_tax.total + flt(diff * self.conversion_rate, self.precision("total", last_tax)) + if diff and abs(diff) <= (2.0 / 10**(self.precision("tax_amount", last_tax))): + adjustment_amount = flt(diff * self.conversion_rate, self.precision("tax_amount", last_tax)) + last_tax.tax_amount += adjustment_amount + last_tax.tax_amount_after_discount_amount += adjustment_amount + last_tax.total += adjustment_amount def calculate_total_advance(self, parenttype, advance_parentfield): if self.doctype == parenttype and self.docstatus < 2: diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index f440315d91..e905de1470 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -471,8 +471,11 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ var diff = this.frm.doc.net_total_export - flt(last_tax.total / this.frm.doc.conversion_rate, precision("grand_total_export")); - if ( diff && Math.abs(diff) <= (2.0 / Math.pow(10, precision("total", last_tax)) ) { - last_tax.total += flt(diff * this.frm.doc.conversion_rate, precision("total", last_tax)); + if ( diff && Math.abs(diff) <= (2.0 / Math.pow(10, precision("tax_amount", last_tax))) ) { + var adjustment_amount = flt(diff * this.frm.doc.conversion_rate, precision("tax_amount", last_tax)); + last_tax.tax_amount += adjustment_amount; + last_tax.tax_amount_after_discount += adjustment_amount; + last_tax.total += adjustment_amount; } } } From ec25117ab01d537e73873f4778e0e98c3102841b Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 16 Mar 2015 22:08:30 +0600 Subject: [PATCH 6/6] bumped to version 4.24.1 --- erpnext/__version__.py | 2 +- erpnext/hooks.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/__version__.py b/erpnext/__version__.py index f7015524bc..5886dcc961 100644 --- a/erpnext/__version__.py +++ b/erpnext/__version__.py @@ -1,2 +1,2 @@ from __future__ import unicode_literals -__version__ = '4.24.0' +__version__ = '4.24.1' diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 017f80e797..15ed392188 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -5,7 +5,7 @@ app_publisher = "Web Notes Technologies Pvt. Ltd. and Contributors" app_description = "Open Source Enterprise Resource Planning for Small and Midsized Organizations" app_icon = "icon-th" app_color = "#e74c3c" -app_version = "4.24.0" +app_version = "4.24.1" error_report_email = "support@erpnext.com" diff --git a/setup.py b/setup.py index 44bafc910d..622575385f 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages import os -version = "4.24.0" +version = "4.24.1" with open("requirements.txt", "r") as f: install_requires = f.readlines()