Automated RMA generation, return authorization, tracking, and refund processing for ecommerce returns.
import json, uuid, datetime
from enum import Enum
class ReturnStatus(Enum):
PENDING = "Pending"
APPROVED = "Approved"
INSPECTION = "Inspection"
REFUNDED = "Refunded"
def generate_rma(product, reason):
return {
"rma": f"RMA-{uuid.uuid4().hex[:6].upper()}",
"product": product,
"reason": reason,
"status": ReturnStatus.PENDING.value,
"created": datetime.date.today().isoformat(),
"refund_amount": 0.0
}
def calculate_refund(rma, price):
if rma["reason"] in ("Defective", "Damaged"):
return round(price * 0.85, 2)
return round(price * 1.0, 2)
def update_inventory(stock, product, qty):
stock[product] = stock.get(product, 0) + qty
return stock
returns = [
generate_rma("Kemeja Cotton", "Wrong size"),
generate_rma("Kasut Sukan", "Defective"),
generate_rma("Jam Tangan", "Changed mind"),
]
for r in returns:
r["refund_amount"] = calculate_refund(r, 80.0)
r["status"] = ReturnStatus.APPROVED.value
print(json.dumps(returns, 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 sources only Β· up to 5 lines Β· 20 questions/hour
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