Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Add aggregated amounts to stock info
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelvriend committed Jul 20, 2022
1 parent 97f57c3 commit 78a9594
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pygrocy/data_models/product.py
Expand Up @@ -70,6 +70,10 @@ def _init_empty(self):
self._is_partly_in_stock = None

self._available_amount = None
self._amount_aggregated = None
self._amount_opened = None
self._amount_opened_aggregated = None
self._is_aggregated_amount = None
self._best_before_date = None

self._default_quantity_unit_purchase = None
Expand All @@ -81,6 +85,10 @@ def _init_empty(self):
def _init_from_CurrentStockResponse(self, response: CurrentStockResponse):
self._id = response.product_id
self._available_amount = response.amount
self._amount_aggregated = response.amount_aggregated
self._amount_opened = response.amount_opened
self._amount_opened_aggregated = response.amount_opened_aggregated
self._is_aggregated_amount = response.is_aggregated_amount
self._best_before_date = response.best_before_date

if response.product:
Expand Down Expand Up @@ -136,6 +144,22 @@ def product_group_id(self) -> int:
def available_amount(self) -> float:
return self._available_amount

@property
def amount_aggregated(self) -> float:
return self._amount_aggregated

@property
def amount_opened(self) -> float:
return self._amount_opened

@property
def amount_opened_aggregated(self) -> float:
return self._amount_opened_aggregated

@property
def is_aggregated_amount(self) -> bool:
return self._is_aggregated_amount

@property
def best_before_date(self) -> datetime.date:
return self._best_before_date
Expand Down
3 changes: 3 additions & 0 deletions pygrocy/grocy_api_client.py
Expand Up @@ -140,6 +140,9 @@ class CurrentStockResponse(BaseModel):
amount: float
best_before_date: date
amount_opened: float
amount_aggregated: float
amount_opened_aggregated: float
is_aggregated_amount: bool
product: ProductData


Expand Down

0 comments on commit 78a9594

Please sign in to comment.