From bc6df5c71b861c6f83d5381e0642c25e6f31fe99 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Dec 2013 16:42:23 +0530 Subject: [PATCH 1/2] [patch] [minor] deleted old stock ledger and stock ageing page --- patches/patch_list.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/patches/patch_list.py b/patches/patch_list.py index 437f3227a7..1a9e75f39b 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -256,4 +256,6 @@ patch_list = [ "patches.1311.p06_fix_report_columns", "execute:webnotes.delete_doc('DocType', 'Documentation Tool')", "execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29", + "execute:webnotes.delete_doc('Page', 'stock-ledger') #2013-12-04", + "execute:webnotes.delete_doc('Page', 'stock-ageing') #2013-12-04", ] \ No newline at end of file From 9b0a6d426c646af1bdc27ecf938b9d6d647e827f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Dec 2013 17:18:05 +0530 Subject: [PATCH 2/2] [patch] [minor] deleted old stock ledger and stock ageing page --- patches/1312/__init__.py | 0 patches/1312/p01_delete_old_stock_reports.py | 11 + patches/patch_list.py | 3 +- stock/page/stock_ageing/README.md | 1 - stock/page/stock_ageing/__init__.py | 1 - stock/page/stock_ageing/stock_ageing.js | 183 -------------- stock/page/stock_ageing/stock_ageing.txt | 37 --- stock/page/stock_ledger/README.md | 1 - stock/page/stock_ledger/__init__.py | 1 - stock/page/stock_ledger/stock_ledger.js | 247 ------------------- stock/page/stock_ledger/stock_ledger.txt | 41 --- 11 files changed, 12 insertions(+), 514 deletions(-) create mode 100644 patches/1312/__init__.py create mode 100644 patches/1312/p01_delete_old_stock_reports.py delete mode 100644 stock/page/stock_ageing/README.md delete mode 100644 stock/page/stock_ageing/__init__.py delete mode 100644 stock/page/stock_ageing/stock_ageing.js delete mode 100644 stock/page/stock_ageing/stock_ageing.txt delete mode 100644 stock/page/stock_ledger/README.md delete mode 100644 stock/page/stock_ledger/__init__.py delete mode 100644 stock/page/stock_ledger/stock_ledger.js delete mode 100644 stock/page/stock_ledger/stock_ledger.txt diff --git a/patches/1312/__init__.py b/patches/1312/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/patches/1312/p01_delete_old_stock_reports.py b/patches/1312/p01_delete_old_stock_reports.py new file mode 100644 index 0000000000..ffa783fc1e --- /dev/null +++ b/patches/1312/p01_delete_old_stock_reports.py @@ -0,0 +1,11 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +def execute(): + import webnotes, os + + webnotes.delete_doc('Page', 'stock-ledger') + webnotes.delete_doc('Page', 'stock-ageing') + + os.system("rm -rf app/stock/page/stock_ledger") + os.system("rm -rf app/stock/page/stock_ageing") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 1a9e75f39b..0ebe5e2540 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -256,6 +256,5 @@ patch_list = [ "patches.1311.p06_fix_report_columns", "execute:webnotes.delete_doc('DocType', 'Documentation Tool')", "execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29", - "execute:webnotes.delete_doc('Page', 'stock-ledger') #2013-12-04", - "execute:webnotes.delete_doc('Page', 'stock-ageing') #2013-12-04", + "patches.1312.p01_delete_old_stock_reports", ] \ No newline at end of file diff --git a/stock/page/stock_ageing/README.md b/stock/page/stock_ageing/README.md deleted file mode 100644 index e8597b2194..0000000000 --- a/stock/page/stock_ageing/README.md +++ /dev/null @@ -1 +0,0 @@ -Average "age" of an Item in a particular Warehouse based on First-in-first-out (FIFO). \ No newline at end of file diff --git a/stock/page/stock_ageing/__init__.py b/stock/page/stock_ageing/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/stock/page/stock_ageing/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/stock/page/stock_ageing/stock_ageing.js b/stock/page/stock_ageing/stock_ageing.js deleted file mode 100644 index 6c626e22ed..0000000000 --- a/stock/page/stock_ageing/stock_ageing.js +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - - -wn.pages['stock-ageing'].onload = function(wrapper) { - wn.ui.make_app_page({ - parent: wrapper, - title: wn._('Stock Ageing'), - single_column: true - }); - - new erpnext.StockAgeing(wrapper); - - - wrapper.appframe.add_module_icon("Stock") - -} - -wn.require("app/js/stock_grid_report.js"); - -erpnext.StockAgeing = erpnext.StockGridReport.extend({ - init: function(wrapper) { - this._super({ - title: wn._("Stock Ageing"), - page: wrapper, - parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, - doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Item Group", "Brand", "Serial No"], - }) - }, - setup_columns: function() { - this.columns = [ - {id: "name", name: wn._("Item"), field: "name", width: 300, - link_formatter: { - open_btn: true, - doctype: '"Item"' - }}, - {id: "item_name", name: wn._("Item Name"), field: "item_name", - width: 100, formatter: this.text_formatter}, - {id: "description", name: wn._("Description"), field: "description", - width: 200, formatter: this.text_formatter}, - {id: "brand", name: wn._("Brand"), field: "brand", width: 100}, - {id: "average_age", name: wn._("Average Age"), field: "average_age", - formatter: this.currency_formatter}, - {id: "earliest", name: wn._("Earliest"), field: "earliest", - formatter: this.currency_formatter}, - {id: "latest", name: wn._("Latest"), field: "latest", - formatter: this.currency_formatter}, - {id: "stock_uom", name: "UOM", field: "stock_uom", width: 100}, - ]; - }, - filters: [ - {fieldtype:"Select", label: wn._("Warehouse"), link:"Warehouse", - default_value: "Select Warehouse..."}, - {fieldtype:"Select", label: wn._("Brand"), link:"Brand", - default_value: "Select Brand...", filter: function(val, item, opts) { - return val == opts.default_value || item.brand == val; - }, link_formatter: {filter_input: "brand"}}, - {fieldtype:"Select", label: wn._("Plot By"), - options: ["Average Age", "Earliest", "Latest"]}, - {fieldtype:"Date", label: wn._("To Date")}, - {fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"}, - {fieldtype:"Button", label: wn._("Reset Filters")} - ], - setup_filters: function() { - var me = this; - this._super(); - this.trigger_refresh_on_change(["warehouse", "plot_by", "brand"]); - this.show_zero_check(); - }, - init_filter_values: function() { - this._super(); - this.filter_inputs.to_date.val(dateutil.obj_to_user(new Date())); - }, - prepare_data: function() { - var me = this; - - if(!this.data) { - me._data = wn.report_dump.data["Item"]; - me.item_by_name = me.make_name_map(me._data); - } - - this.data = [].concat(this._data); - - this.serialized_buying_rates = this.get_serialized_buying_rates(); - - $.each(this.data, function(i, d) { - me.reset_item_values(d); - }); - - this.prepare_balances(); - - // filter out brand - this.data = $.map(this.data, function(d) { - return me.apply_filter(d, "brand") ? d : null; - }); - - // filter out rows with zero values - this.data = $.map(this.data, function(d) { - return me.apply_zero_filter(null, d, null, me) ? d : null; - }); - }, - prepare_balances: function() { - var me = this; - var to_date = dateutil.str_to_obj(this.to_date); - var data = wn.report_dump.data["Stock Ledger Entry"]; - - this.item_warehouse = {}; - - for(var i=0, j=data.length; i to_date) - break; - } - } - - $.each(me.data, function(i, item) { - var full_fifo_stack = []; - if(me.is_default("warehouse")) { - $.each(me.item_warehouse[item.name] || {}, function(i, wh) { - full_fifo_stack = full_fifo_stack.concat(wh.fifo_stack || []) - }); - } else { - full_fifo_stack = me.get_item_warehouse(me.warehouse, item.name).fifo_stack || []; - } - - var age_qty = total_qty = 0.0; - var min_age = max_age = null; - - $.each(full_fifo_stack, function(i, batch) { - var batch_age = dateutil.get_diff(me.to_date, batch[2]); - age_qty += batch_age * batch[0]; - total_qty += batch[0]; - max_age = Math.max(max_age, batch_age); - if(min_age===null) min_age=batch_age; - else min_age = Math.min(min_age, batch_age); - }); - - item.average_age = total_qty.toFixed(2)==0.0 ? 0 - : (age_qty / total_qty).toFixed(2); - item.earliest = max_age || 0.0; - item.latest = min_age || 0.0; - }); - - this.data = this.data.sort(function(a, b) { - var sort_by = me.plot_by.replace(" ", "_").toLowerCase(); - return b[sort_by] - a[sort_by]; - }); - }, - get_plot_data: function() { - var data = []; - var me = this; - - data.push({ - label: me.plot_by, - data: $.map(me.data, function(item, idx) { - return [[idx+1, item[me.plot_by.replace(" ", "_").toLowerCase() ]]] - }), - bars: {show: true}, - }); - - return data.length ? data : false; - }, - get_plot_options: function() { - var me = this; - return { - grid: { hoverable: true, clickable: true }, - xaxis: { - ticks: $.map(me.data, function(item, idx) { return [[idx+1, item.name]] }), - max: 15 - }, - series: { downsample: { threshold: 1000 } } - } - } -}); \ No newline at end of file diff --git a/stock/page/stock_ageing/stock_ageing.txt b/stock/page/stock_ageing/stock_ageing.txt deleted file mode 100644 index cd1cfbd1c9..0000000000 --- a/stock/page/stock_ageing/stock_ageing.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2012-09-21 20:15:14", - "docstatus": 0, - "modified": "2013-07-11 14:44:08", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Stock", - "name": "__common__", - "page_name": "stock-ageing", - "standard": "Yes", - "title": "Stock Ageing" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "stock-ageing", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "stock-ageing" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - } -] \ No newline at end of file diff --git a/stock/page/stock_ledger/README.md b/stock/page/stock_ledger/README.md deleted file mode 100644 index 774498b77e..0000000000 --- a/stock/page/stock_ledger/README.md +++ /dev/null @@ -1 +0,0 @@ -Stock movement report based on Stock Ledger Entry. \ No newline at end of file diff --git a/stock/page/stock_ledger/__init__.py b/stock/page/stock_ledger/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/stock/page/stock_ledger/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/stock/page/stock_ledger/stock_ledger.js b/stock/page/stock_ledger/stock_ledger.js deleted file mode 100644 index 08a455e1d3..0000000000 --- a/stock/page/stock_ledger/stock_ledger.js +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - -wn.pages['stock-ledger'].onload = function(wrapper) { - wn.ui.make_app_page({ - parent: wrapper, - title: wn._('Stock Ledger'), - single_column: true - }); - - new erpnext.StockLedger(wrapper); - wrapper.appframe.add_module_icon("Stock") -} - -wn.require("app/js/stock_grid_report.js"); - -erpnext.StockLedger = erpnext.StockGridReport.extend({ - init: function(wrapper) { - this._super({ - title: wn._("Stock Ledger"), - page: wrapper, - parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, - doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", "Serial No"], - }) - }, - - setup_columns: function() { - this.hide_balance = (this.is_default("item_code") || this.voucher_no) ? true : false; - this.columns = [ - {id: "posting_datetime", name: wn._("Posting Date"), field: "posting_datetime", width: 120, - formatter: this.date_formatter}, - {id: "item_code", name: wn._("Item Code"), field: "item_code", width: 160, - link_formatter: { - filter_input: "item_code", - open_btn: true, - doctype: '"Item"', - }}, - {id: "description", name: wn._("Description"), field: "description", width: 200, - formatter: this.text_formatter}, - {id: "warehouse", name: wn._("Warehouse"), field: "warehouse", width: 100, - link_formatter: {filter_input: "warehouse"}}, - {id: "brand", name: wn._("Brand"), field: "brand", width: 100}, - {id: "stock_uom", name: wn._("UOM"), field: "stock_uom", width: 100}, - {id: "qty", name: wn._("Qty"), field: "qty", width: 100, - formatter: this.currency_formatter}, - {id: "balance", name: wn._("Balance Qty"), field: "balance", width: 100, - formatter: this.currency_formatter, - hidden: this.hide_balance}, - {id: "balance_value", name: wn._("Balance Value"), field: "balance_value", width: 100, - formatter: this.currency_formatter, hidden: this.hide_balance}, - {id: "voucher_type", name: wn._("Voucher Type"), field: "voucher_type", width: 120}, - {id: "voucher_no", name: wn._("Voucher No"), field: "voucher_no", width: 160, - link_formatter: { - filter_input: "voucher_no", - open_btn: true, - doctype: "dataContext.voucher_type" - }}, - ]; - - }, - filters: [ - {fieldtype:"Select", label: wn._("Warehouse"), link:"Warehouse", - default_value: "Select Warehouse...", filter: function(val, item, opts) { - return item.warehouse == val || val == opts.default_value; - }}, - {fieldtype:"Link", label: wn._("Item Code"), link:"Item", default_value: "Select Item...", - filter: function(val, item, opts) { - return item.item_code == val || !val; - }}, - {fieldtype:"Select", label: "Brand", link:"Brand", - default_value: "Select Brand...", filter: function(val, item, opts) { - return val == opts.default_value || item.brand == val || item._show; - }, link_formatter: {filter_input: "brand"}}, - {fieldtype:"Data", label: wn._("Voucher No"), - filter: function(val, item, opts) { - if(!val) return true; - return (item.voucher_no && item.voucher_no.indexOf(val)!=-1); - }}, - {fieldtype:"Date", label: wn._("From Date"), filter: function(val, item) { - return dateutil.str_to_obj(val) <= dateutil.str_to_obj(item.posting_date); - }}, - {fieldtype:"Label", label: wn._("To")}, - {fieldtype:"Date", label: wn._("To Date"), filter: function(val, item) { - return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date); - }}, - {fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"}, - {fieldtype:"Button", label: wn._("Reset Filters")} - ], - - setup_filters: function() { - var me = this; - this._super(); - - this.wrapper.bind("apply_filters_from_route", function() { me.toggle_enable_brand(); }); - this.filter_inputs.item_code.change(function() { me.toggle_enable_brand(); }); - - this.trigger_refresh_on_change(["item_code", "warehouse", "brand"]); - }, - - toggle_enable_brand: function() { - if(!this.filter_inputs.item_code.val()) { - this.filter_inputs.brand.prop("disabled", false); - } else { - this.filter_inputs.brand - .val(this.filter_inputs.brand.get(0).opts.default_value) - .prop("disabled", true); - } - }, - - init_filter_values: function() { - this._super(); - this.filter_inputs.warehouse.get(0).selectedIndex = 0; - }, - prepare_data: function() { - var me = this; - if(!this.item_by_name) - this.item_by_name = this.make_name_map(wn.report_dump.data["Item"]); - var data = wn.report_dump.data["Stock Ledger Entry"]; - var out = []; - - var opening = { - item_code: "On " + dateutil.str_to_user(this.from_date), qty: 0.0, balance: 0.0, - id:"_opening", _show: true, _style: "font-weight: bold", balance_value: 0.0 - } - var total_in = { - item_code: "Total In", qty: 0.0, balance: 0.0, balance_value: 0.0, - id:"_total_in", _show: true, _style: "font-weight: bold" - } - var total_out = { - item_code: "Total Out", qty: 0.0, balance: 0.0, balance_value: 0.0, - id:"_total_out", _show: true, _style: "font-weight: bold" - } - - // clear balance - $.each(wn.report_dump.data["Item"], function(i, item) { - item.balance = item.balance_value = 0.0; - }); - - // initialize warehouse-item map - this.item_warehouse = {}; - this.serialized_buying_rates = this.get_serialized_buying_rates(); - var from_datetime = dateutil.str_to_obj(me.from_date + " 00:00:00"); - var to_datetime = dateutil.str_to_obj(me.to_date + " 23:59:59"); - - // - for(var i=0, j=data.length; i 0) { - total_in.qty += sl.qty; - total_in.balance_value += value_diff; - } else { - total_out.qty += (-1 * sl.qty); - total_out.balance_value += value_diff; - } - } - } - - if(!before_end) break; - - // apply filters - if(me.apply_filters(sl)) { - out.push(sl); - } - - // update balance - if((!me.is_default("warehouse") ? me.apply_filter(sl, "warehouse") : true)) { - sl.balance = me.item_by_name[sl.item_code].balance + sl.qty; - me.item_by_name[sl.item_code].balance = sl.balance; - - sl.balance_value = me.item_by_name[sl.item_code].balance_value + value_diff; - me.item_by_name[sl.item_code].balance_value = sl.balance_value; - } - } - - if(me.item_code && !me.voucher_no) { - var closing = { - item_code: "On " + dateutil.str_to_user(this.to_date), - balance: (out.length ? out[out.length-1].balance : 0), qty: 0, - balance_value: (out.length ? out[out.length-1].balance_value : 0), - id:"_closing", _show: true, _style: "font-weight: bold" - }; - total_out.balance_value = -total_out.balance_value; - var out = [opening].concat(out).concat([total_in, total_out, closing]); - } - - this.data = out; - }, - get_plot_data: function() { - var data = []; - var me = this; - if(me.hide_balance) return false; - data.push({ - label: me.item_code, - data: [[dateutil.str_to_obj(me.from_date).getTime(), me.data[0].balance]] - .concat($.map(me.data, function(col, idx) { - if (col.posting_datetime) { - return [[dateutil.str_to_obj(col.posting_datetime).getTime(), col.balance - col.qty], - [dateutil.str_to_obj(col.posting_datetime).getTime(), col.balance]] - } - return null; - })).concat([ - // closing - [dateutil.str_to_obj(me.to_date).getTime(), me.data[me.data.length - 1].balance] - ]), - points: {show: true}, - lines: {show: true, fill: true}, - }); - return data; - }, - get_plot_options: function() { - return { - grid: { hoverable: true, clickable: true }, - xaxis: { mode: "time", - min: dateutil.str_to_obj(this.from_date).getTime(), - max: dateutil.str_to_obj(this.to_date).getTime(), - }, - series: { downsample: { threshold: 1000 } } - } - }, - get_tooltip_text: function(label, x, y) { - var d = new Date(x); - var date = dateutil.obj_to_user(d) + " " + d.getHours() + ":" + d.getMinutes(); - var value = format_number(y); - return value.bold() + " on " + date; - } -}); \ No newline at end of file diff --git a/stock/page/stock_ledger/stock_ledger.txt b/stock/page/stock_ledger/stock_ledger.txt deleted file mode 100644 index 9c2a4b75e5..0000000000 --- a/stock/page/stock_ledger/stock_ledger.txt +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "creation": "2012-09-21 20:15:14", - "docstatus": 0, - "modified": "2013-07-11 14:44:19", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Stock", - "name": "__common__", - "page_name": "stock-ledger", - "standard": "Yes", - "title": "Stock Ledger" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "stock-ledger", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "stock-ledger" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - }, - { - "doctype": "Page Role", - "role": "Material User" - } -] \ No newline at end of file