Skip to content

Commit

Permalink
Merge pull request #10 from inventree/build-quantity-fix
Browse files Browse the repository at this point in the history
Bug fix for build order quantity
  • Loading branch information
SchrodingersGat authored Nov 5, 2024
2 parents ff99041 + 6178bb8 commit c7de735
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion order_history/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version information for the Order History plugin."""

PLUGIN_VERSION = "0.3.0"
PLUGIN_VERSION = "0.3.1"
11 changes: 10 additions & 1 deletion order_history/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def generate_build_order_history(self):
completion_date__lte=self.end_date
)

# Exclude builds which have no completed stock
builds = builds.exclude(completed=0)

# Construct a dict of order quantities for each part type
parts = {}
history_items = {}
Expand All @@ -102,7 +105,7 @@ def generate_build_order_history(self):
if date_key not in history_items[part.pk]:
history_items[part.pk][date_key] = 0

history_items[part.pk][date_key] += build.quantity
history_items[part.pk][date_key] += build.completed

return self.format_response(parts, history_items, 'build')

Expand Down Expand Up @@ -145,6 +148,9 @@ def generate_purchase_order_history(self):
# Exclude any lines which do not map to an internal part
lines = lines.exclude(part__part=None)

# Exclude lines which have no received stock
lines = lines.exclude(received=0)

# Construct a dictionary of purchase history data to part ID
history_items = {}
parts = {}
Expand Down Expand Up @@ -199,6 +205,9 @@ def generate_sales_order_history(self):
order__shipment_date__lte=self.end_date
)

# Exclude lines which have no shipped stock
lines = lines.exclude(shipped=0)

# Construct a dictionary of sales history data to part ID
history_items = {}
parts = {}
Expand Down

0 comments on commit c7de735

Please sign in to comment.