From ad61f81f85b4a58c4206b289768ead232760315c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 12 Sep 2011 13:24:08 +0530 Subject: [PATCH] Added new report: voucher wise tax details --- .../voucher_wise_tax_details/__init__.py | 0 .../voucher_wise_tax_details.js | 47 +++++++++++++++++++ .../voucher_wise_tax_details.py | 22 +++++++++ .../voucher_wise_tax_details.txt | 34 ++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 accounts/search_criteria/voucher_wise_tax_details/__init__.py create mode 100644 accounts/search_criteria/voucher_wise_tax_details/voucher_wise_tax_details.js create mode 100644 accounts/search_criteria/voucher_wise_tax_details/voucher_wise_tax_details.py create mode 100644 accounts/search_criteria/voucher_wise_tax_details/voucher_wise_tax_details.txt diff --git a/accounts/search_criteria/voucher_wise_tax_details/__init__.py b/accounts/search_criteria/voucher_wise_tax_details/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/accounts/search_criteria/voucher_wise_tax_details/voucher_wise_tax_details.js b/accounts/search_criteria/voucher_wise_tax_details/voucher_wise_tax_details.js new file mode 100644 index 0000000000..a89fa86083 --- /dev/null +++ b/accounts/search_criteria/voucher_wise_tax_details/voucher_wise_tax_details.js @@ -0,0 +1,47 @@ +report.customize_filters = function() { + this.hide_all_filters(); + + //Add filter + this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Sales Order'+NEWLINE+'Delivery Note'+NEWLINE+'Sales Invoice', report_default:'Sales Invoice', ignore : 1,parent:'RV Tax Detail', single_select :1, in_first_page:1}); + + this.add_filter({fieldname:'posting_date', label:'Date', fieldtype:'Date', options:'', ignore : 1,parent:'RV Tax Detail', in_first_page:1}); + + this.add_filter({fieldname:'voucher_id', label:'Voucher Id', fieldtype:'Data', options:'', ignore : 1,parent:'RV Tax Detail', in_first_page:1}); + + this.add_filter({fieldname:'tax_account', label:'Tax Account', fieldtype:'Link', options:'Account', ignore : 1,parent:'RV Tax Detail', in_first_page:1}); +} + + +// hide sections +//-------------------------------------- +this.mytabs.items['More Filters'].hide(); +this.mytabs.items['Select Columns'].hide(); + +// Get query +//-------------------------------------- +report.get_query = function() { + based_on = this.get_filter('RV Tax Detail', 'Based On').get_value(); + from_date = this.get_filter('RV Tax Detail', 'From Date').get_value(); + to_date = this.get_filter('RV Tax Detail', 'To Date').get_value(); + vid = this.get_filter('RV Tax Detail', 'Voucher Id').get_value(); + acc = this.get_filter('RV Tax Detail', 'Tax Account').get_value(); + + date_fld = 'transaction_date'; + if(based_on == 'Sales Invoice') { + based_on = 'Receivable Voucher'; + date_fld = 'voucher_date'; + } + + sp_cond = ''; + if (from_date) sp_cond += repl(' AND t1.%(dt)s >= "%(from_date)s"', {dt:date_fld, from_date:from_date}); + if (to_date) sp_cond += repl(' AND t1.%(dt)s <= "%(to_date)s"', {dt:date_fld, to_date:to_date}); + if (vid) sp_cond += repl(' AND t1.name LIKE "%%(voucher)s%"', {voucher:vid}); + if (acc) sp_cond += repl(' AND t2.account_head = "%(acc)s"', {acc:acc}); + + return repl('SELECT t1.`name`, t1.`%(dt)s`, t1.`customer_name`, t1.net_total, t2.account_head, t2.description, t2.rate, t2.tax_amount \ + FROM `tab%(parent)s` t1, `tabRV Tax Detail` t2 \ + WHERE t1.docstatus=1 AND t2.`parenttype` = "%(parent)s" \ + AND t2.`parent` = t1.`name` \ + %(cond)s ORDER BY t1.`name` DESC, t1.%(dt)s DESC', {parent:based_on, cond:sp_cond, dt:date_fld}); +} + diff --git a/accounts/search_criteria/voucher_wise_tax_details/voucher_wise_tax_details.py b/accounts/search_criteria/voucher_wise_tax_details/voucher_wise_tax_details.py new file mode 100644 index 0000000000..91e90f2fe4 --- /dev/null +++ b/accounts/search_criteria/voucher_wise_tax_details/voucher_wise_tax_details.py @@ -0,0 +1,22 @@ +if filter_values.get('based_on') == 'Sales Invoice': + based_on_dt = 'Receivable Voucher' +else: + based_on_dt = filter_values.get('based_on') + +cols = [ + [filter_values.get('based_on'), 'Link','150px', based_on_dt], + ['Transaction Date', 'Date', '120px', ''], + ['Customer', 'Link','150px','Customer'], + ['Net Total', 'Currency', '80px', ''], + ['Tax Account', 'Link','150px','Account'], + ['Description', 'Text','120px',''], + ['Tax Rate', 'Currency', '80px', ''], + ['Tax Amount', 'Currency', '80px', ''] +] + +for c in cols: + colnames.append(c[0]) + coltypes.append(c[1]) + colwidths.append(c[2]) + coloptions.append(c[3]) + col_idx[c[0]] = len(colnames)-1 diff --git a/accounts/search_criteria/voucher_wise_tax_details/voucher_wise_tax_details.txt b/accounts/search_criteria/voucher_wise_tax_details/voucher_wise_tax_details.txt new file mode 100644 index 0000000000..c152c7905f --- /dev/null +++ b/accounts/search_criteria/voucher_wise_tax_details/voucher_wise_tax_details.txt @@ -0,0 +1,34 @@ +# Search Criteria, voucher_wise_tax_details +[ + + # These values are common in all dictionaries + { + 'creation': '2011-09-06 15:36:58', + 'docstatus': 0, + 'modified': '2011-09-06 15:50:28', + 'modified_by': 'Administrator', + 'owner': 'Administrator' + }, + + # These values are common for all Search Criteria + { + 'columns': 'RV Tax Detail\x01Type,RV Tax Detail\x01Account Head,RV Tax Detail\x01Cost Center,RV Tax Detail\x01Description,RV Tax Detail\x01Rate,RV Tax Detail\x01Amount*,RV Tax Detail\x01Total*', + 'criteria_name': 'Voucher wise tax details', + 'doc_type': 'RV Tax Detail', + 'doctype': 'Search Criteria', + 'filters': "{'Delivery Note\x01Submitted':1,'Delivery Note\x01Status':'','Delivery Note\x01Fiscal Year':''}", + 'module': 'Accounts', + 'name': '__common__', + 'page_len': 50, + 'parent_doc_type': 'Delivery Note', + 'sort_by': '`tabRV Tax Detail`.`parent`', + 'sort_order': 'DESC', + 'standard': 'Yes' + }, + + # Search Criteria, voucher_wise_tax_details + { + 'doctype': 'Search Criteria', + 'name': 'voucher_wise_tax_details' + } +] \ No newline at end of file