Skip to content

Commit

Permalink
fix: only carry-forward balances till today's period
Browse files Browse the repository at this point in the history
Showing data in future doesn't make sense. Only carry-forward till last
bucket that contains today's day.
  • Loading branch information
ankush committed May 10, 2022
1 parent 891b1e1 commit 3322165
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions erpnext/stock/report/stock_analytics/stock_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ def get_data(filters):
periodic_data = get_periodic_data(sle, filters)
ranges = get_period_date_ranges(filters)

today = getdate()

for dummy, item_data in item_details.items():
row = {
"name": item_data.name,
Expand All @@ -242,13 +244,13 @@ def get_data(filters):
"brand": item_data.brand,
}
previous_period_value = 0.0
for _start_date, end_date in ranges:
for start_date, end_date in ranges:
period = get_period(end_date, filters)
period_data = periodic_data.get(item_data.name, {}).get(period)
if period_data:
row[scrub(period)] = previous_period_value = sum(period_data.values())
else:
row[scrub(period)] = previous_period_value
row[scrub(period)] = previous_period_value if today >= start_date else None

data.append(row)

Expand Down

0 comments on commit 3322165

Please sign in to comment.