ifixkart-admin/Backend/test_warranty_db.py
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +05:30

52 lines
1.3 KiB
Python

import sys
import os
sys.path.insert(0, os.path.abspath('/mnt/fam/SERVER/IfixKartEcommerce/Backend'))
import app.models.db_base
from app.core.database.db_session import SessionLocal
from app.models.OrderModel import Order, OrderItem
from app.models.WarrantyModel import Warranty
from app.services.WarrantyService import WarrantyService
import ulid
from datetime import datetime
db = SessionLocal()
# Create dummy order
order_id = str(ulid.ULID())
order = Order(
order_id=order_id,
order_no="TEST-ORD-" + str(ulid.ULID())[-4:],
customer_id=None,
total_amount=1000.0,
final_amount=1000.0,
status="DELIVERED",
payment_status="PAID"
)
db.add(order)
item = OrderItem(
item_id=str(ulid.ULID()),
order_id=order_id,
product_id=str(ulid.ULID()),
variant_id=str(ulid.ULID()),
product_name="Test Product",
sku="TEST-SKU",
quantity=1,
unit_price=1000.0,
total_price=1000.0
)
db.add(item)
db.commit()
print(f"Created Test Order: {order_id}")
# Trigger Warranty Service
count = WarrantyService.generate_warranty_for_order(db, order_id)
print(f"Warranties generated: {count}")
warranties = db.query(Warranty).filter(Warranty.reference_id == order_id).all()
for w in warranties:
print(f"Warranty ID: {w.warranty_id}, Status: {w.status}, End Date: {w.end_date}")
db.close()