Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
bffd370dec
@ -134,6 +134,7 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
|
|||||||
var data = wn.report_dump.data["Stock Ledger Entry"];
|
var data = wn.report_dump.data["Stock Ledger Entry"];
|
||||||
|
|
||||||
this.item_warehouse = {};
|
this.item_warehouse = {};
|
||||||
|
this.serialized_buying_rates = this.get_serialized_buying_rates();
|
||||||
|
|
||||||
for(var i=0, j=data.length; i<j; i++) {
|
for(var i=0, j=data.length; i<j; i++) {
|
||||||
var sl = data[i];
|
var sl = data[i];
|
||||||
|
@ -44,8 +44,9 @@ erpnext.StockGridReport = wn.views.TreeGridReport.extend({
|
|||||||
wh.fifo_stack.push([add_qty, sl.incoming_rate, sl.posting_date]);
|
wh.fifo_stack.push([add_qty, sl.incoming_rate, sl.posting_date]);
|
||||||
} else {
|
} else {
|
||||||
// outgoing
|
// outgoing
|
||||||
|
if(sl.serial_no) {
|
||||||
if(is_fifo) {
|
var value_diff = -1 * this.get_serialized_value_diff(sl);
|
||||||
|
} else if(is_fifo) {
|
||||||
var value_diff = this.get_fifo_value_diff(wh, sl);
|
var value_diff = this.get_fifo_value_diff(wh, sl);
|
||||||
} else {
|
} else {
|
||||||
// average rate for weighted average
|
// average rate for weighted average
|
||||||
@ -102,4 +103,34 @@ erpnext.StockGridReport = wn.views.TreeGridReport.extend({
|
|||||||
wh.fifo_stack = fifo_stack.reverse();
|
wh.fifo_stack = fifo_stack.reverse();
|
||||||
return -fifo_value_diff;
|
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;
|
||||||
|
},
|
||||||
});
|
});
|
@ -86,8 +86,9 @@ data_map = {
|
|||||||
"order_by": "name"
|
"order_by": "name"
|
||||||
},
|
},
|
||||||
"Stock Ledger Entry": {
|
"Stock Ledger Entry": {
|
||||||
"columns": ["name", "posting_date", "posting_time", "item_code", "warehouse", "actual_qty as qty",
|
"columns": ["name", "posting_date", "posting_time", "item_code", "warehouse",
|
||||||
"voucher_type", "voucher_no", "ifnull(incoming_rate,0) as incoming_rate", "stock_uom"],
|
"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'"],
|
"conditions": ["ifnull(is_cancelled, 'No')='No'"],
|
||||||
"order_by": "posting_date, posting_time, name",
|
"order_by": "posting_date, posting_time, name",
|
||||||
"links": {
|
"links": {
|
||||||
|
@ -99,6 +99,7 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({
|
|||||||
var data = wn.report_dump.data["Stock Ledger Entry"];
|
var data = wn.report_dump.data["Stock Ledger Entry"];
|
||||||
|
|
||||||
this.item_warehouse = {};
|
this.item_warehouse = {};
|
||||||
|
this.serialized_buying_rates = this.get_serialized_buying_rates();
|
||||||
|
|
||||||
for(var i=0, j=data.length; i<j; i++) {
|
for(var i=0, j=data.length; i<j; i++) {
|
||||||
var sl = data[i];
|
var sl = data[i];
|
||||||
|
@ -155,6 +155,7 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
|
|||||||
|
|
||||||
// initialize warehouse-item map
|
// initialize warehouse-item map
|
||||||
this.item_warehouse = {};
|
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 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");
|
var to_datetime = dateutil.str_to_obj(me.to_date + " 23:59:59");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user