AI agent that generates retail price tags with pricing rules, discount calculations, and barcode formatting.
import json, math
products = [
{"name":"Kemeja Cotton","price":49.90,"discount":0},
{"name":"Kasut Sukan","price":159.00,"discount":"20%"},
{"name":"Jam Tangan","price":89.00,"discount":"15%"},
{"name":"Set PROMO","price":199.00,"discount":"Bundle 30%"}
]
def calc_discount(price, disc):
if disc == 0 or disc == "0": return price
pct = float(str(disc).replace("Bundle ","").replace("%",""))
return round(price * (1 - pct/100), 2)
def gen_barcode(prefix, idx):
raw = prefix + str(idx).zfill(3)
chk = sum(int(d)*3 if i%2 else int(d) for i,d in enumerate(raw))%10
chk = (10-chk)%10
return raw + str(chk)
def format_tag(p, idx):
final = calc_discount(p["price"], p["discount"])
barcode = gen_barcode("955100", idx+1)
return {"product": p["name"], "price": p["price"],
"final": final, "barcode": barcode}
tags = [format_tag(p,i) for i,p in enumerate(products)]
print(json.dumps(tags, indent=2))
Basic Package
Special SME traction programme by AINNA.
Limited starter website offer. AI usage, hosting, maintenance and custom integrations depend on the confirmed scope.
View SME Offer โ
Ask about AINNA pages, services and articles.
AINNA website sources only ยท answers up to 5 lines
No section data available yet.
Sites with documented sections will appear here.
We value your privacy
We use browser storage to remember your choice. Optional analytics runs only after you allow it; your choice is recorded with an anonymous ID. Privacy Policy