From 1d55c72d8b75021624dd334eb2780c9c385b050d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 7 Jan 2013 12:54:10 +0530 Subject: [PATCH 1/3] added .py~ to gitignore --- .gitignore | 1 + .../valuation_control/valuation_control.py~ | 87 ------------------- 2 files changed, 1 insertion(+), 87 deletions(-) delete mode 100644 stock/doctype/valuation_control/valuation_control.py~ diff --git a/.gitignore b/.gitignore index 99a0c8a95a..dc2ad3df1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc +*.py~ *.comp.js .DS_Store patch.log diff --git a/stock/doctype/valuation_control/valuation_control.py~ b/stock/doctype/valuation_control/valuation_control.py~ deleted file mode 100644 index 88ce63e29e..0000000000 --- a/stock/doctype/valuation_control/valuation_control.py~ +++ /dev/null @@ -1,87 +0,0 @@ -# Please edit this list and import only required elements -import webnotes - -from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add -from webnotes.model import db_exists -from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType -from webnotes.model.doclist import getlist, copy_doclist -from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax -from webnotes import session, form, is_testing, msgprint, errprint - -set = webnotes.conn.set -sql = webnotes.conn.sql -get_value = webnotes.conn.get_value -in_transaction = webnotes.conn.in_transaction -convert_to_lists = webnotes.conn.convert_to_lists - -# ----------------------------------------------------------------------------------------- - - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - - # Get FIFO Rate from Stack - # ------------------------- - def get_fifo_rate(self, fcfs_stack, qty): - fcfs_val = 0 - withdraw = flt(qty) - while withdraw: - batch = fcfs_stack[0] - if batch[0] <= withdraw: - # not enough or exactly same qty in current batch, clear batch - withdraw -= batch[0] - fcfs_val += (flt(batch[0]) * flt(batch[1])) - fcfs_stack.pop(0) - else: - # all from current batch - fcfs_val += (flt(withdraw) * flt(batch[1])) - batch[0] -= withdraw - withdraw = 0 - fcfs_rate = flt(fcfs_val) / flt(qty) - return fcfs_rate - - # -------------------------------- - # get serializable inventory rate - # -------------------------------- - def get_serializable_inventory_rate(self, serial_no): - sr_nos = get_obj("Stock Ledger").get_sr_no_list(serial_no) - tot = 0 - for s in sr_nos: - serial_no = s.strip() - tot += flt(webnotes.conn.get_value('Serial No', serial_no, 'purchase_rate')) - return tot / len(sr_nos) - - - # --------------------- - # get valuation method - # --------------------- - def get_valuation_method(self, item_code): - val_method = webnotes.conn.get_value('Item', item_code, 'valuation_method') - if not val_method: - val_method = get_defaults().get('valuation_method', 'FIFO') - return val_method - - - # Get Incoming Rate based on valuation method - # -------------------------------------------- - def get_incoming_rate(self, posting_date, posting_time, item, warehouse, qty = 0, serial_no = ''): - msgprint(1) - in_rate = 0 - val_method = self.get_valuation_method(item) - bin_obj = get_obj('Warehouse',warehouse).get_bin(item) - if serial_no: - in_rate = self.get_serializable_inventory_rate(serial_no) - elif val_method == 'FIFO': - in_rate = 0 - if qty: - prev_sle = bin_obj.get_prev_sle(posting_date, posting_time) - msgprint(prev_sle) - fcfs_stack = eval(prev_sle.get('fcfs_stack', '[]') or '[]') - msgprint(fcfs_stack) - in_rate = fcfs_stack and self.get_fifo_rate(fcfs_stack, qty) or 0 - msgprint(in_rate) - elif val_method == 'Moving Average': - prev_sle = bin_obj.get_prev_sle(posting_date, posting_time) - in_rate = prev_sle and prev_sle.get('valuation_rate', 0) or 0 - return in_rate From e80b9c6ee9011dd2cfc77fbb5e78711951748f76 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 7 Jan 2013 13:28:40 +0530 Subject: [PATCH 2/3] closing = opening + diff for stock balance report --- stock/page/stock_balance/stock_balance.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stock/page/stock_balance/stock_balance.js b/stock/page/stock_balance/stock_balance.js index da6b831d93..90c7943e29 100644 --- a/stock/page/stock_balance/stock_balance.js +++ b/stock/page/stock_balance/stock_balance.js @@ -130,6 +130,12 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({ } } } + + // opening + diff = closing + // adding opening, since diff already added to closing + $.each(me.item_by_name, function(key, item) { + item.closing += item.opening; + }); }, update_groups: function() { From 8bacc3443e238de7148fb337898d188f447d3a27 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 7 Jan 2013 14:59:07 +0530 Subject: [PATCH 3/3] added columns and moved serial no related reports to stock module --- .../__init__.py | 0 .../serial_no_service_contract_expiry.txt | 0 .../serial_no_warranty_expiry}/__init__.py | 0 .../serial_no_warranty_expiry.txt | 19 +++++++++++++++++++ .../serial_no_warranty_expiry/__init__.py | 0 .../serial_no_warranty_expiry.txt | 19 ------------------- 6 files changed, 19 insertions(+), 19 deletions(-) rename {support/report => stock/report/serial_no_service_contract_expiry}/__init__.py (100%) rename {support => stock}/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.txt (100%) rename {support/report/serial_no_service_contract_expiry => stock/report/serial_no_warranty_expiry}/__init__.py (100%) create mode 100644 stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt delete mode 100644 support/report/serial_no_warranty_expiry/__init__.py delete mode 100644 support/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt diff --git a/support/report/__init__.py b/stock/report/serial_no_service_contract_expiry/__init__.py similarity index 100% rename from support/report/__init__.py rename to stock/report/serial_no_service_contract_expiry/__init__.py diff --git a/support/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.txt b/stock/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.txt similarity index 100% rename from support/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.txt rename to stock/report/serial_no_service_contract_expiry/serial_no_service_contract_expiry.txt diff --git a/support/report/serial_no_service_contract_expiry/__init__.py b/stock/report/serial_no_warranty_expiry/__init__.py similarity index 100% rename from support/report/serial_no_service_contract_expiry/__init__.py rename to stock/report/serial_no_warranty_expiry/__init__.py diff --git a/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt b/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt new file mode 100644 index 0000000000..603e9883f3 --- /dev/null +++ b/stock/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt @@ -0,0 +1,19 @@ +[ + { + "owner": "Administrator", + "docstatus": 0, + "creation": "2013-01-04 13:57:25", + "modified_by": "Administrator", + "modified": "2013-01-07 13:22:26" + }, + { + "name": "__common__", + "ref_doctype": "Serial No", + "doctype": "Report", + "json": "{\"filters\":[[\"Serial No\",\"status\",\"=\",\"Delivered\"]],\"columns\":[[\"name\",\"Serial No\"],[\"item_code\",\"Serial No\"],[\"warranty_expiry_date\",\"Serial No\"],[\"warranty_period\",\"Serial No\"],[\"maintenance_status\",\"Serial No\"],[\"purchase_document_no\",\"Serial No\"],[\"purchase_date\",\"Serial No\"],[\"supplier\",\"Serial No\"],[\"supplier_name\",\"Serial No\"],[\"delivery_document_no\",\"Serial No\"],[\"delivery_date\",\"Serial No\"],[\"customer\",\"Serial No\"],[\"customer_name\",\"Serial No\"],[\"item_name\",\"Serial No\"],[\"description\",\"Serial No\"],[\"item_group\",\"Serial No\"],[\"brand\",\"Serial No\"]],\"sort_by\":\"Serial No.warranty_expiry_date\",\"sort_order\":\"asc\",\"sort_by_next\":\"\",\"sort_order_next\":\"asc\"}" + }, + { + "name": "Serial No Warranty Expiry", + "doctype": "Report" + } +] \ No newline at end of file diff --git a/support/report/serial_no_warranty_expiry/__init__.py b/support/report/serial_no_warranty_expiry/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/support/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt b/support/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt deleted file mode 100644 index 4b6c4be175..0000000000 --- a/support/report/serial_no_warranty_expiry/serial_no_warranty_expiry.txt +++ /dev/null @@ -1,19 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2013-01-03 17:24:01", - "modified_by": "Administrator", - "modified": "2013-01-03 17:35:42" - }, - { - "name": "__common__", - "ref_doctype": "Serial No", - "doctype": "Report", - "json": "{\"filters\":[[\"Serial No\",\"status\",\"=\",\"Delivered\"]],\"columns\":[[\"name\",\"Serial No\"],[\"item_code\",\"Serial No\"],[\"warranty_expiry_date\",\"Serial No\"],[\"maintenance_status\",\"Serial No\"],[\"delivery_document_no\",\"Serial No\"],[\"customer\",\"Serial No\"],[\"customer_name\",\"Serial No\"],[\"item_name\",\"Serial No\"],[\"description\",\"Serial No\"],[\"item_group\",\"Serial No\"],[\"brand\",\"Serial No\"]],\"sort_by\":\"Serial No.warranty_expiry_date\",\"sort_order\":\"asc\",\"sort_by_next\":\"\",\"sort_order_next\":\"asc\"}" - }, - { - "name": "Serial No Warranty Expiry", - "doctype": "Report" - } -] \ No newline at end of file