Last active
October 6, 2024 04:07
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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