Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Rushabh Mehta 2013-03-08 13:19:32 +05:30
commit bffd370dec
5 changed files with 39 additions and 4 deletions

View File

@ -134,6 +134,7 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
var data = wn.report_dump.data["Stock Ledger Entry"];
this.item_warehouse = {};
this.serialized_buying_rates = this.get_serialized_buying_rates();
for(var i=0, j=data.length; i<j; i++) {
var sl = data[i];

View File

@ -44,8 +44,9 @@ erpnext.StockGridReport = wn.views.TreeGridReport.extend({
wh.fifo_stack.push([add_qty, sl.incoming_rate, sl.posting_date]);
} else {
// outgoing
if(is_fifo) {
if(sl.serial_no) {
var value_diff = -1 * this.get_serialized_value_diff(sl);
} else if(is_fifo) {
var value_diff = this.get_fifo_value_diff(wh, sl);
} else {
// average rate for weighted average
@ -102,4 +103,34 @@ erpnext.StockGridReport = wn.views.TreeGridReport.extend({
wh.fifo_stack = fifo_stack.reverse();
return -fifo_value_diff;
},
get_serialized_value_diff: function(sl) {
var me = this;
var value_diff = 0.0;
$.each(sl.serial_no.trim().split("\n"), function(i, serial_no) {
if(serial_no) {
value_diff += flt(me.serialized_buying_rates[serial_no]);
}
});
return value_diff;
},
get_serialized_buying_rates: function() {
var serialized_buying_rates = {};
$.each(wn.report_dump.data["Stock Ledger Entry"], function(i, sle) {
if(sle.qty > 0 && sle.serial_no) {
$.each(sle.serial_no.trim().split("\n"), function(i, sr) {
if(sr && sle.incoming_rate !== undefined) {
serialized_buying_rates[sr] = flt(sle.incoming_rate);
}
});
}
});
return serialized_buying_rates;
},
});

View File

@ -86,8 +86,9 @@ data_map = {
"order_by": "name"
},
"Stock Ledger Entry": {
"columns": ["name", "posting_date", "posting_time", "item_code", "warehouse", "actual_qty as qty",
"voucher_type", "voucher_no", "ifnull(incoming_rate,0) as incoming_rate", "stock_uom"],
"columns": ["name", "posting_date", "posting_time", "item_code", "warehouse",
"actual_qty as qty", "voucher_type", "voucher_no",
"ifnull(incoming_rate,0) as incoming_rate", "stock_uom", "serial_no"],
"conditions": ["ifnull(is_cancelled, 'No')='No'"],
"order_by": "posting_date, posting_time, name",
"links": {

View File

@ -99,6 +99,7 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({
var data = wn.report_dump.data["Stock Ledger Entry"];
this.item_warehouse = {};
this.serialized_buying_rates = this.get_serialized_buying_rates();
for(var i=0, j=data.length; i<j; i++) {
var sl = data[i];

View File

@ -155,6 +155,7 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
// initialize warehouse-item map
this.item_warehouse = {};
this.serialized_buying_rates = this.get_serialized_buying_rates();
var from_datetime = dateutil.str_to_obj(me.from_date + " 00:00:00");
var to_datetime = dateutil.str_to_obj(me.to_date + " 23:59:59");