From b77ee2f3a76c00afbc812c279404602db6763109 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 17 Oct 2012 11:09:13 +0530 Subject: [PATCH] fixes in stock ageing report --- stock/page/stock_ageing/stock_ageing.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stock/page/stock_ageing/stock_ageing.js b/stock/page/stock_ageing/stock_ageing.js index 87fbd58037..3418e7f326 100644 --- a/stock/page/stock_ageing/stock_ageing.js +++ b/stock/page/stock_ageing/stock_ageing.js @@ -129,13 +129,15 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({ $.each(full_fifo_stack, function(i, batch) { var batch_age = dateutil.get_diff(me.to_date, batch[2]); - age_qty += batch_age * batch[1]; - total_qty += batch[1]; + age_qty += batch_age * batch[0]; + total_qty += batch[0]; max_age = Math.max(max_age, batch_age); - if(min_age===null) min_age=batch_age; else min_age = Math.min(min_age, batch_age) + if(min_age===null) min_age=batch_age; + else min_age = Math.min(min_age, batch_age); }); - item.average_age = total_qty.toFixed(2)==0.0 ? 0 : (age_qty / total_qty).toFixed(2); + item.average_age = total_qty.toFixed(2)==0.0 ? 0 + : (age_qty / total_qty).toFixed(2); item.earliest = max_age || 0.0; item.latest = min_age || 0.0; });