Skip to content

Instantly share code, notes, and snippets.

@matheusmoreira
Last active October 6, 2024 04:07
Show Gist options
  • Save matheusmoreira/db7c3196bb15dbf55b86598378ec9282 to your computer and use it in GitHub Desktop.
Save matheusmoreira/db7c3196bb15dbf55b86598378ec9282 to your computer and use it in GitHub Desktop.
Embedded Python script to validate product price and quantity metadata against posting amount
python
def price_and_quantity(price, quantity, amount):
if not quantity:
quantity = 1
if not price:
price = amount / quantity
return amount == price * quantity
account Market
assert price_and_quantity(tag('Price'), tag('Units'), amount)
2024-10-06 Buying drinks
Market $12.00 ; Product: Water
; Price:: $1.00
; Units:: 12
Card:Credit $12.00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment