added index patch and updated general_ledger
diff --git a/erpnext/accounts/page/general_ledger/general_ledger.js b/erpnext/accounts/page/general_ledger/general_ledger.js
index 7fdf57c..c74b8c5 100644
--- a/erpnext/accounts/page/general_ledger/general_ledger.js
+++ b/erpnext/accounts/page/general_ledger/general_ledger.js
@@ -41,11 +41,11 @@
filters: [
{fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company...",
filter: function(val, item, opts) {
- return item.company == val || val == opts.default_value || item._show;
+ return item.company == val || val == opts.default_value;
}},
{fieldtype:"Select", label: "Account", link:"Account", default_value: "Select Account...",
filter: function(val, item, opts, me) {
- if(val == opts.default_value || item._show) {
+ if(val == opts.default_value) {
return true;
} else {
// true if GL Entry belongs to selected
@@ -56,14 +56,14 @@
{fieldtype:"Data", label: "Voucher No",
filter: function(val, item, opts) {
if(!val) return true;
- return (item.voucher_no && item.voucher_no.indexOf(val)!=-1) || item._show;
+ return (item.voucher_no && item.voucher_no.indexOf(val)!=-1);
}},
{fieldtype:"Date", label: "From Date", filter: function(val, item) {
- return item._show || dateutil.user_to_obj(val) <= dateutil.str_to_obj(item.posting_date);
+ return dateutil.str_to_obj(val) <= dateutil.str_to_obj(item.posting_date);
}},
{fieldtype:"Label", label: "To"},
{fieldtype:"Date", label: "To Date", filter: function(val, item) {
- return item._show || dateutil.user_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
+ return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
}},
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: "Reset Filters"}
@@ -85,14 +85,15 @@
// add Opening, Closing, Totals rows
// if filtered by account and / or voucher
var data = wn.report_dump.data["GL Entry"];
- this.make_account_by_name();
+ var out = [];
+
+ if(!this.account_by_name)
+ this.account_by_name = this.make_name_map(wn.report_dump.data["Account"]);
+
var me = this;
- var account = this.filter_inputs.account.val();
- var from_date = dateutil.user_to_obj(this.filter_inputs.from_date.val());
- var to_date = dateutil.user_to_obj(this.filter_inputs.to_date.val());
- var voucher_no = this.filter_inputs.voucher_no.val();
- var default_account = this.filter_inputs.account.get(0).opts.default_value;
+ var from_date = dateutil.str_to_obj(this.from_date);
+ var to_date = dateutil.str_to_obj(this.to_date);
if(to_date < from_date) {
msgprint("From Date must be before To Date");
@@ -109,8 +110,8 @@
}
$.each(data, function(i, item) {
- if((account!=default_account ? me.is_child_account(account, item.account) : true) &&
- (voucher_no ? item.voucher_no==voucher_no : true)) {
+ if((!me.is_default("account") ? me.is_child_account(me.account, item.account) : true) &&
+ (me.voucher_no ? item.voucher_no==me.voucher_no : true)) {
var date = dateutil.str_to_obj(item.posting_date);
@@ -121,6 +122,10 @@
totals.debit += item.debit;
totals.credit += item.credit;
}
+
+ if(me.apply_filters(item)) {
+ out.push(item);
+ }
}
})
@@ -131,21 +136,14 @@
}
- if(account != default_account) {
- var out = [opening].concat(data).concat([totals, closing]);
+ if(!me.is_default("account")) {
+ var out = [opening].concat(out).concat([totals, closing]);
} else {
- var out = data.concat([totals]);
+ var out = out.concat([totals]);
}
this.prepare_data_view(out);
},
- make_account_by_name: function() {
- this.account_by_name = {};
- var me = this;
- $.each(wn.report_dump.data['Account'], function(i, v) {
- me.account_by_name[v.name] = v;
- })
- }
});
}
diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py
index 5a38c5b..dbd4b8c 100644
--- a/erpnext/patches/patch_list.py
+++ b/erpnext/patches/patch_list.py
@@ -580,4 +580,8 @@
'patch_module': 'patches.september_2012',
'patch_file': 'customer_permission_patch',
},
+ {
+ 'patch_module': 'patches.september_2012',
+ 'patch_file': 'add_stock_ledger_entry_index',
+ },
]
diff --git a/erpnext/patches/september_2012/add_stock_ledger_entry_index.py b/erpnext/patches/september_2012/add_stock_ledger_entry_index.py
new file mode 100644
index 0000000..bac9a08
--- /dev/null
+++ b/erpnext/patches/september_2012/add_stock_ledger_entry_index.py
@@ -0,0 +1,10 @@
+import webnotes
+
+def execute():
+ webnotes.conn.commit()
+ try:
+ webnotes.conn.sql("""alter table `tabStock Ledger Entry` add index posting_sort_index(posting_date, posting_time, name)""")webnotes.conn.commit()
+ except Exception, e:
+ if e.args[0]!=1061: raise e
+ webnotes.conn.begin()
+
\ No newline at end of file
diff --git a/erpnext/startup/report_data_map.py b/erpnext/startup/report_data_map.py
index 8e6761a..b132180 100644
--- a/erpnext/startup/report_data_map.py
+++ b/erpnext/startup/report_data_map.py
@@ -15,6 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
+
+# mappings for table dumps
+# "remember to add indexes!"
+
data_map = {
"Account": {
"columns": ["name", "parent_account", "lft", "rgt", "debit_or_credit", "is_pl_account",
@@ -30,7 +34,11 @@
"columns": ["account", "posting_date", "cost_center", "debit", "credit", "is_opening",
"company", "voucher_type", "voucher_no", "remarks"],
"conditions": ["ifnull(is_cancelled, 'No')='No'"],
- "order_by": "posting_date, account"
+ "order_by": "posting_date, account",
+ "links": {
+ "account": ["Account", "name"],
+ "company": ["Company", "name"]
+ }
},
"Company": {
"columns": ["name"],
@@ -43,12 +51,13 @@
"Stock Ledger Entry": {
"columns": ["posting_date", "posting_time", "item_code", "warehouse", "actual_qty as qty",
"voucher_type", "voucher_no"],
- "condition": ["ifnull(is_cancelled, 'No')='No'"],
+ "conditions": ["ifnull(is_cancelled, 'No')='No'"],
"order_by": "posting_date, posting_time, name",
"links": {
"item_code": ["Item", "name"],
"warehouse": ["Warehouse", "name"]
- }
+ },
+ "force_index": "posting_sort_index"
},
"Item": {
"columns": ["name", "if(item_name=name, '', item_name) as item_name",
diff --git a/erpnext/stock/page/stock_ledger/stock_ledger.js b/erpnext/stock/page/stock_ledger/stock_ledger.js
index 87be0c6..ee97868 100644
--- a/erpnext/stock/page/stock_ledger/stock_ledger.js
+++ b/erpnext/stock/page/stock_ledger/stock_ledger.js
@@ -99,7 +99,6 @@
$.each(wn.report_dump.data["Item"], function(i, item) { item.balance = 0.0; });
//
- var t = new Date();
for(var i=0, j=data.length; i<j; i++) {
var sl = data[i];
sl.description = me.item_by_name[sl.item_code].description;
@@ -121,7 +120,7 @@
if(!before_end) break;
// apply filters
- if(me.dataview_filter(sl)) {
+ if(me.apply_filters(sl)) {
out.push(sl);
}
@@ -131,9 +130,7 @@
me.item_by_name[sl.item_code].balance = sl.balance;
}
}
-
- console.log(new Date() - t);
-
+
if(me.item_code != me.item_code_default && !me.voucher_no) {
var closing = {
item_code: "On " + dateutil.str_to_user(this.to_date),
diff --git a/public/js/all-app.js b/public/js/all-app.js
index 4f5eaab..6c56404 100644
--- a/public/js/all-app.js
+++ b/public/js/all-app.js
@@ -392,7 +392,8 @@
if(r.server_messages){r.server_messages=JSON.parse(r.server_messages)
msgprint(r.server_messages);}
if(r.exc){r.exc=JSON.parse(r.exc);if(r.exc instanceof Array){$.each(r.exc,function(i,v){if(v)console.log(v);})}else{console.log(r.exc);}};if(r['403']){wn.container.change_to('403');}
-if(r.docs){LocalDB.sync(r.docs);}}
+if(r.docs){LocalDB.sync(r.docs);}
+wn.last_response=r;}
wn.request.call=function(opts){wn.request.prepare(opts);var ajax_args={url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success&&opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus)
opts.error&&opts.error(xhr)}};if(opts.progress_bar){var interval=null;$.extend(ajax_args,{xhr:function(){var xhr=jQuery.ajaxSettings.xhr();interval=setInterval(function(){if(xhr.readyState>2){var total=parseInt(xhr.getResponseHeader('Original-Length')||0)||parseInt(xhr.getResponseHeader('Content-Length'));var completed=parseInt(xhr.responseText.length);var percent=(100.0/total*completed).toFixed(2);opts.progress_bar.css('width',(percent<10?10:percent)+'%');}},50);wn.last_xhr=xhr;return xhr;},complete:function(){opts.progress_bar.css('width','100%');clearInterval(interval);}})}
$.ajax(ajax_args);}
@@ -1098,7 +1099,7 @@
else{$("#"+me.tooltip_id).remove();me.previousPoint=null;}});},get_view_data:function(){var res=[];var col_map=$.map(this.columns,function(v){return v.field;});for(var i=0,len=this.dataView.getLength();i<len;i++){var d=this.dataView.getItem(i);var row=[];$.each(col_map,function(i,col){var val=d[col];if(val===null||val===undefined){val=""}
row.push(val);})
res.push(row);}
-return res;},options:{editable:false,enableColumnReorder:false},dataview_filter:function(item){var filters=this.filter_inputs;if(item._show)return true;for(i in filters){if(!this.apply_filter(item,i))return false;}
+return res;},options:{editable:false,enableColumnReorder:false},apply_filters:function(item){var filters=this.filter_inputs;if(item._show)return true;for(i in filters){if(!this.apply_filter(item,i))return false;}
if(this.custom_dataview_filter){return this.custom_dataview_filter(item);}
return true;},apply_filter:function(item,fieldname){var filter=this.filter_inputs[fieldname].get(0);if(filter.opts.filter){if(!filter.opts.filter(this[filter.opts.fieldname],item,filter.opts,this)){return false;}}
return true;},is_default:function(fieldname){return this[fieldname]==this[fieldname+"_default"];},date_formatter:function(row,cell,value,columnDef,dataContext){return dateutil.str_to_user(value);},currency_formatter:function(row,cell,value,columnDef,dataContext){return repl('<div style="text-align: right; %(_style)s">%(value)s</div>',{_style:dataContext._style||"",value:fmt_money(value)});},text_formatter:function(row,cell,value,columnDef,dataContext){return repl('<span style="%(_style)s" title="%(esc_value)s">%(value)s</span>',{_style:dataContext._style||"",esc_value:cstr(value).replace(/"/g,'\"'),value:cstr(value)});},check_formatter:function(row,cell,value,columnDef,dataContext){return repl("<input type='checkbox' data-id='%(id)s' \
diff --git a/public/js/all-web.js b/public/js/all-web.js
index 535762f..c8bab89 100644
--- a/public/js/all-web.js
+++ b/public/js/all-web.js
@@ -279,7 +279,8 @@
if(r.server_messages){r.server_messages=JSON.parse(r.server_messages)
msgprint(r.server_messages);}
if(r.exc){r.exc=JSON.parse(r.exc);if(r.exc instanceof Array){$.each(r.exc,function(i,v){if(v)console.log(v);})}else{console.log(r.exc);}};if(r['403']){wn.container.change_to('403');}
-if(r.docs){LocalDB.sync(r.docs);}}
+if(r.docs){LocalDB.sync(r.docs);}
+wn.last_response=r;}
wn.request.call=function(opts){wn.request.prepare(opts);var ajax_args={url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success&&opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus)
opts.error&&opts.error(xhr)}};if(opts.progress_bar){var interval=null;$.extend(ajax_args,{xhr:function(){var xhr=jQuery.ajaxSettings.xhr();interval=setInterval(function(){if(xhr.readyState>2){var total=parseInt(xhr.getResponseHeader('Original-Length')||0)||parseInt(xhr.getResponseHeader('Content-Length'));var completed=parseInt(xhr.responseText.length);var percent=(100.0/total*completed).toFixed(2);opts.progress_bar.css('width',(percent<10?10:percent)+'%');}},50);wn.last_xhr=xhr;return xhr;},complete:function(){opts.progress_bar.css('width','100%');clearInterval(interval);}})}
$.ajax(ajax_args);}