Skip to content

Commit

Permalink
Allow receipt_quantity for GDPR proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Oct 18, 2024
1 parent 8af22ba commit 0e00b8a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions open_prices/prices/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,15 @@ def clean(self, *args, **kwargs):
"proof",
f"Proof {PROOF_FIELD} ({proof_field_value}) does not match the price {PROOF_FIELD} ({price_field_value})",
)
if proof.type == proof_constants.TYPE_RECEIPT:
if proof.type in proof_constants.TYPE_SHOPPING_SESSION_LIST:
if not self.receipt_quantity:
self.receipt_quantity = 1
else:
if self.receipt_quantity is not None:
validation_errors = utils.add_validation_error(
validation_errors,
"receipt_quantity",
"Can only be set if proof type RECEIPT",
f"Can only be set if proof type in {proof_constants.TYPE_SHOPPING_SESSION_LIST}",
)
# return
if bool(validation_errors):
Expand Down
1 change: 1 addition & 0 deletions open_prices/proofs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

# 1 proof = 1 shop + 1 date
TYPE_SINGLE_SHOP_LIST = [TYPE_PRICE_TAG, TYPE_RECEIPT, TYPE_SHOP_IMPORT]
TYPE_SHOPPING_SESSION_LIST = [TYPE_RECEIPT, TYPE_GDPR_REQUEST]
TYPE_MULTIPLE_SHOP_LIST = [TYPE_GDPR_REQUEST]
3 changes: 3 additions & 0 deletions open_prices/proofs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def has_type_shop_import(self):
def has_type_single_shop(self):
return self.filter(type__in=proof_constants.TYPE_SINGLE_SHOP_LIST)

def has_type_shopping_session(self):
return self.filter(type=proof_constants.TYPE_SHOPPING_SESSION_LIST)

def has_prices(self):
return self.filter(price_count__gt=0)

Expand Down

0 comments on commit 0e00b8a

Please sign in to comment.