From 6054ae2becfcaccdb14f785d7d30a730ae727345 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 26 Feb 2013 10:51:24 +0530 Subject: [PATCH] delete gross profit based on search criteria --- patches/patch_list.py | 1 + .../search_criteria/gross_profit/__init__.py | 1 - .../gross_profit/gross_profit.js | 38 ------- .../gross_profit/gross_profit.py | 104 ------------------ .../gross_profit/gross_profit.sql | 15 --- .../gross_profit/gross_profit.txt | 28 ----- 6 files changed, 1 insertion(+), 186 deletions(-) delete mode 100644 selling/search_criteria/gross_profit/__init__.py delete mode 100644 selling/search_criteria/gross_profit/gross_profit.js delete mode 100644 selling/search_criteria/gross_profit/gross_profit.py delete mode 100644 selling/search_criteria/gross_profit/gross_profit.sql delete mode 100644 selling/search_criteria/gross_profit/gross_profit.txt diff --git a/patches/patch_list.py b/patches/patch_list.py index 1e30b7ecba..d262da2b08 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -195,4 +195,5 @@ patch_list = [ "execute:webnotes.conn.sql(\"update `tabReport` set report_type=if(ifnull(query, '')='', 'Report Builder', 'Query Report') where is_standard='No'\")", "execute:webnotes.conn.sql(\"update `tabReport` set report_name=name where ifnull(report_name,'')='' and is_standard='No'\")", "patches.february_2013.p08_todo_query_report", + "execute:webnotes.delete_doc('Search Criteria', 'gross_profit') # 2013-02-26" ] \ No newline at end of file diff --git a/selling/search_criteria/gross_profit/__init__.py b/selling/search_criteria/gross_profit/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/selling/search_criteria/gross_profit/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/selling/search_criteria/gross_profit/gross_profit.js b/selling/search_criteria/gross_profit/gross_profit.js deleted file mode 100644 index 29c7e72ccf..0000000000 --- a/selling/search_criteria/gross_profit/gross_profit.js +++ /dev/null @@ -1,38 +0,0 @@ -// ERPNext - web based ERP (http://erpnext.com) -// Copyright (C) 2012 Web Notes Technologies Pvt Ltd -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -report.customize_filters = function() { - this.mytabs.items['Select Columns'].hide(); - this.mytabs.tabs['More Filters'].hide(); - this.hide_all_filters(); - this.filter_fields_dict['Delivery Note'+FILTER_SEP +'ID'].df.filter_hide = 0; - this.filter_fields_dict['Delivery Note'+FILTER_SEP +'From Posting Date'].df.filter_hide = 0; - this.filter_fields_dict['Delivery Note'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0; - this.filter_fields_dict['Delivery Note Item'+FILTER_SEP +'Item Code'].df.filter_hide = 0; - this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Project Name'].df.filter_hide = 0; - - this.filter_fields_dict['Delivery Note'+FILTER_SEP +'ID'].df.in_first_page = 1; - this.filter_fields_dict['Delivery Note'+FILTER_SEP +'From Posting Date'].df.in_first_page = 1; - this.filter_fields_dict['Delivery Note'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1; - this.filter_fields_dict['Delivery Note Item'+FILTER_SEP +'Item Code'].df.in_first_page = 1; - this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Project Name'].df.in_first_page = 1; - - this.filter_fields_dict['Delivery Note' + FILTER_SEP + - 'From Posting Date'].df['report_default'] = sys_defaults["year_start_date"] - this.filter_fields_dict['Delivery Note' + FILTER_SEP + - 'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date()); - -} \ No newline at end of file diff --git a/selling/search_criteria/gross_profit/gross_profit.py b/selling/search_criteria/gross_profit/gross_profit.py deleted file mode 100644 index 34719226e3..0000000000 --- a/selling/search_criteria/gross_profit/gross_profit.py +++ /dev/null @@ -1,104 +0,0 @@ -# ERPNext - web based ERP (http://erpnext.com) -# Copyright (C) 2012 Web Notes Technologies Pvt Ltd -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from __future__ import unicode_literals -from webnotes.utils import flt - -if not (filter_values.get('posting_date') or filter_values.get('posting_date1')): - msgprint("Please select From and To Posting Date", raise_exception=1) - -columns = [ - ['Delivery Note', 'Link', '120px', 'Delivery Note'], - ['Posting Date', 'Date', '120px', ''], - ['Posting Time', 'Data', '120px', ''], - ['Item Code', 'Link', '120px', 'Item'], - ['Item Name', 'Data', '120px', ''], - ['Description', 'Data', '120px', ''], - ['Warehouse', 'Link', '120px', 'Warehouse'], - ['Project Name', 'Link', '120px', 'Project'], - ['Quantity', 'Currency', '120px', ''], - ['Rate', 'Currency', '120px', ''], - ['Amount', 'Currency', '120px', ''], - #['DN Item Row Id', 'Data', '120px', ''], - ['Purchase Cost', 'Currency', '150px', ''], - ['Gross Profit', 'Currency', '150px', ''], - ['Gross Profit (%)', 'Currrency', '150px', ''] -] - -for c in columns: - colnames.append(c[0]) - coltypes.append(c[1]) - colwidths.append(c[2]) - coloptions.append(c[3]) - col_idx[c[0]] = len(colnames)-1 - -sle = sql(""" - select - actual_qty, incoming_rate, voucher_no, item_code, warehouse, voucher_detail_no - from - `tabStock Ledger Entry` - where - voucher_type = 'Delivery Note' - and ifnull(is_cancelled, 'No') = 'No' - order by posting_date desc, posting_time desc, name desc -""", as_dict=1) - -def get_purchase_cost(dn, item, wh, qty, dn_item_row_id): - from webnotes.utils import flt - global sle - purchase_cost = 0 - packing_items = sql("select item_code, qty from `tabSales BOM Item` where parent = %s", item) - if packing_items: - packing_items = [[t[0], flt(t[1])*qty] for t in packing_items] - else: - packing_items = [[item, qty]] - for d in sle: - if packing_items: - if d['voucher_no'] == dn \ - and [d['item_code'], flt(abs(d['actual_qty']))] in packing_items \ - and (not d['voucher_detail_no'] or d['voucher_detail_no'] == dn_item_row_id): - purchase_cost += flt(d['incoming_rate'])*flt(abs(d['actual_qty'])) - packing_items.remove([d['item_code'], flt(abs(d['actual_qty']))]) - else: - break - - return purchase_cost - -out, tot_amount, tot_pur_cost = [], 0, 0 -for r in res: - purchase_cost = get_purchase_cost(r[col_idx['Delivery Note']], r[col_idx['Item Code']], \ - r[col_idx['Warehouse']], r[col_idx['Quantity']], r[-1]) - r.pop(-1) - r.append(purchase_cost) - - gp = flt(r[col_idx['Amount']]) - flt(purchase_cost) - gp_percent = r[col_idx['Amount']] and purchase_cost and \ - round((gp*100/flt(r[col_idx['Amount']])), 2) or 0 - r.append(fmt_money(gp)) - r.append(fmt_money(gp_percent)) - out.append(r) - - tot_amount += flt(r[col_idx['Amount']]) - tot_pur_cost += flt(purchase_cost) -# Add Total Row -l_row = ['' for i in range(len(colnames))] -l_row[col_idx['Project Name']] = 'TOTALS' -l_row[col_idx['Amount']] = fmt_money(tot_amount) -l_row[col_idx['Purchase Cost']] = fmt_money(tot_pur_cost) -l_row[col_idx['Gross Profit']] = fmt_money(flt(tot_amount) - flt(tot_pur_cost)) -l_row[col_idx['Gross Profit (%)']] = tot_amount and \ - round((flt(tot_amount) - flt(tot_pur_cost))*100 / flt(tot_amount), 2) -out.append(l_row) \ No newline at end of file diff --git a/selling/search_criteria/gross_profit/gross_profit.sql b/selling/search_criteria/gross_profit/gross_profit.sql deleted file mode 100644 index ce176c2ca9..0000000000 --- a/selling/search_criteria/gross_profit/gross_profit.sql +++ /dev/null @@ -1,15 +0,0 @@ -SELECT - dn.name, dn.posting_date, dn.posting_time, dn_item.item_code, - dn_item.item_name, dn_item.description, dn_item.warehouse, - dn.project_name, dn_item.qty, dn_item.basic_rate, dn_item.amount, dn_item.name -FROM - `tabDelivery Note Item` dn_item, `tabDelivery Note` dn -WHERE - dn_item.parent = dn.name - AND dn.docstatus = 1 - AND dn.name like '%(name)s%%' - AND ifnull(dn_item.item_code, '') like '%(item_code)s%%' - AND ifnull(dn.project_name, '') like '%(project_name)s%%' - AND dn.posting_date >= '%(posting_date)s' - AND dn.posting_date <= '%(posting_date1)s' -ORDER BY dn.name DESC \ No newline at end of file diff --git a/selling/search_criteria/gross_profit/gross_profit.txt b/selling/search_criteria/gross_profit/gross_profit.txt deleted file mode 100644 index f726faab95..0000000000 --- a/selling/search_criteria/gross_profit/gross_profit.txt +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2012-05-14 18:22:18", - "modified_by": "Administrator", - "modified": "2012-09-24 14:11:39" - }, - { - "description": "Invoice wise", - "parent_doc_type": "Delivery Note", - "module": "Selling", - "standard": "Yes", - "sort_order": "DESC", - "filters": "{\"Delivery Note\\u0001Submitted\":1,\"Delivery Note\\u0001Status\":[],\"Delivery Note\\u0001Fiscal Year\":[]}", - "doc_type": "Delivery Note Item", - "name": "__common__", - "doctype": "Search Criteria", - "sort_by": "`tabDelivery Note`.`name`", - "page_len": 50, - "criteria_name": "Gross Profit", - "columns": "Delivery Note\u0001ID,Delivery Note\u0001Posting Date,Delivery Note\u0001Posting Time,Delivery Note Item\u0001Item Code,Delivery Note Item\u0001Item Name,Delivery Note Item\u0001Description,Delivery Note Item\u0001Warehouse,Delivery Note\u0001Project Name,Delivery Note Item\u0001Quantity,Delivery Note Item\u0001Rate*,Delivery Note Item\u0001Amount*" - }, - { - "name": "gross_profit", - "doctype": "Search Criteria" - } -] \ No newline at end of file