mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 04:59:18 +00:00
fix in get_value_diff of stock grid report: case for serialized items
This commit is contained in:
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user