Merge branch 'master' into edge

This commit is contained in:
Anand Doshi 2013-01-02 16:24:41 +05:30
commit 55bf3a3357
5 changed files with 53 additions and 54 deletions

View File

@ -243,13 +243,9 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
out = this.group_data_by_ledger(grouped_ledgers);
}
if(me.account_by_name[me.account].debit_or_credit == "Debit") {
opening.debit -= opening.credit; opening.credit = 0;
closing.debit -= closing.credit; closing.credit = 0;
} else {
opening.credit -= opening.debit; opening.debit = 0;
closing.credit -= closing.debit; closing.debit = 0;
}
opening = me.get_balance(me.account_by_name[me.account].debit_or_credit, opening)
closing = me.get_balance(me.account_by_name[me.account].debit_or_credit, closing)
out = [opening].concat(out).concat([totals, closing]);
} else {
me.appframe.set_title("General Ledger");
@ -260,6 +256,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
},
group_data_by_ledger: function(grouped_ledgers) {
var me = this;
var out = []
$.each(Object.keys(grouped_ledgers).sort(), function(i, account) {
if(grouped_ledgers[account].entries.length) {
@ -270,7 +267,14 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
grouped_ledgers[account].closing.credit =
grouped_ledgers[account].opening.credit
+ grouped_ledgers[account].totals.credit;
grouped_ledgers[account].opening =
me.get_balance(me.account_by_name[me.account].debit_or_credit,
grouped_ledgers[account].opening)
grouped_ledgers[account].closing =
me.get_balance(me.account_by_name[me.account].debit_or_credit,
grouped_ledgers[account].closing)
out = out.concat([grouped_ledgers[account].opening])
.concat(grouped_ledgers[account].entries)
.concat([grouped_ledgers[account].totals,
@ -280,6 +284,15 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
});
return [{id: "_blank_first", _no_format: true, debit: "", credit: ""}].concat(out);
},
get_balance: function(debit_or_credit, balance) {
if(debit_or_credit == "Debit") {
balance.debit -= balance.credit; balance.credit = 0;
} else {
balance.credit -= balance.debit; balance.debit = 0;
}
return balance
},
make_summary_row: function(label, item_account) {
return {

View File

@ -1,4 +0,0 @@
def execute():
import webnotes
from webnotes.modules import reload_doc
reload_doc("stock", "search_criteria", "stock_ledger")

View File

@ -346,10 +346,6 @@ patch_list = [
'patch_module': 'patches.september_2012',
'patch_file': 'communication_delete_permission',
},
{
'patch_module': 'patches.september_2012',
'patch_file': 'reload_criteria_stock_ledger',
},
{
'patch_module': 'patches.september_2012',
'patch_file': 'all_permissions_patch',
@ -430,10 +426,6 @@ patch_list = [
'patch_module': 'patches.november_2012',
'patch_file': 'custom_field_insert_after',
},
{
'patch_module': 'patches.november_2012',
'patch_file': 'reload_stock_ledger_report',
},
{
'patch_module': 'patches.november_2012',
'patch_file': 'delete_item_sales_register1',

View File

@ -1,8 +0,0 @@
from __future__ import unicode_literals
def execute():
import webnotes
from webnotes.modules import reload_doc
reload_doc('stock', 'Search Criteria', 'Stock Ledger')
from webnotes.model import delete_doc
delete_doc("Report", "Stock Ledger")

View File

@ -143,32 +143,9 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
if(!this._data) {
this._data = [];
this.item_warehouse_map = [];
this.item_warehouse_map = {};
this.item_by_name = this.make_name_map(wn.report_dump.data["Item"]);
var sorted_item_list = Object.keys(this.item_by_name).sort();
$.each(sorted_item_list, function(i, item_code) {
var item = me.item_by_name[item_code];
$.each(wn.report_dump.data["Warehouse"], function(i, warehouse) {
// a list of item warehouse combination objects
var row = {
item_code: item_code,
warehouse: warehouse.name,
brand: item.brand,
item_name: item.item_name || item.name,
uom: item.stock_uom,
id: item_code + ":" + warehouse.name,
}
me.reset_item_values(row);
me._data.push(row);
me.item_warehouse_map[row.id] = row;
});
});
this.calculate_quantities();
// filter out rows with zero values
this._data = $.map(this._data, function(d) {
return me.apply_zero_filter(null, d, null, me) ? d : null;
});
}
this.data = [].concat(this._data);
@ -189,16 +166,45 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
["Sales Order Item", "reserved_qty"]],
function(i, v) {
$.each(wn.report_dump.data[v[0]], function(i, item) {
var row = me.item_warehouse_map[item.item_code + ":" + item.warehouse];
var row = me.get_row(item.item_code, item.warehouse);
row[v[1]] += flt(item.qty);
});
}
);
// sort by item, warehouse
this._data = $.map(Object.keys(this.item_warehouse_map).sort(), function(key) {
return me.item_warehouse_map[key];
});
// calculate projected qty
$.each(this._data, function(i, row) {
row.projected_qty = row.actual_qty + row.planned_qty + row.requested_qty
+ row.ordered_qty - row.reserved_qty;
});
// filter out rows with zero values
this._data = $.map(this._data, function(d) {
return me.apply_zero_filter(null, d, null, me) ? d : null;
});
},
get_row: function(item_code, warehouse) {
var key = item_code + ":" + warehouse;
if(!this.item_warehouse_map[key]) {
var item = this.item_by_name[item_code];
var row = {
item_code: item_code,
warehouse: warehouse,
brand: item.brand,
item_name: item.item_name || item.name,
uom: item.stock_uom,
id: key,
}
this.reset_item_values(row);
this.item_warehouse_map[key] = row;
}
return this.item_warehouse_map[key];
},
calculate_total: function() {