- New models: WarrantyModel, WalletModel, SystemConfigModel - New schemas: WarrantySchema, RefundSchema, SystemConfig, CrmTaskCalendar, NotificationTemplate, NotificationGateway, RepairErp, ReviewModeration, InventoryPos, MultiDashboard, BillingFinance - New services: WarrantyService, RefundService, CrmService, CrmTaskCalendarService, DeliveryService, EmailTemplateService, InventoryPosService, MultiDashboardService, NotificationGatewayService, RepairErpService, ReviewModerationService, SystemConfigService, TemplateService, CreditService - Updated routers: AdminOrder, BillingFinance, Cart, Catalog, Checkout, Crm, InventoryPos, NotificationGateway, RolePermission, ServiceJob, Settings, Storefront, UserCreation - Updated models: Inventory, Notification, Order, Product, Service, Setting, SystemConfig, User - Updated core: database init, invoice generator, main app - Added WarrantyRouter with full CRUD and claim flow
71 lines
1.6 KiB
Python
71 lines
1.6 KiB
Python
import requests
|
|
import json
|
|
import time
|
|
import os
|
|
import ulid
|
|
|
|
API_BASE = "http://localhost:8000/api/v1"
|
|
|
|
def print_result(step, res):
|
|
print(f"\n--- {step} ---")
|
|
print(f"Status: {res.status_code}")
|
|
try:
|
|
print(json.dumps(res.json(), indent=2))
|
|
except:
|
|
print(res.text)
|
|
|
|
script = """
|
|
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-100",
|
|
tenant_id="tenant_default",
|
|
customer_id=str(ulid.ULID()),
|
|
final_amount=1000.0,
|
|
status="DELIVERED",
|
|
payment_status="PAID"
|
|
)
|
|
db.add(order)
|
|
|
|
item = OrderItem(
|
|
order_item_id=str(ulid.ULID()),
|
|
order_id=order_id,
|
|
product_id=str(ulid.ULID()),
|
|
variant_id=str(ulid.ULID()),
|
|
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()
|
|
"""
|
|
|
|
with open("test_warranty_db.py", "w") as f:
|
|
f.write(script)
|