- 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
52 lines
1.3 KiB
Python
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()
|