from django.db import models
from snow_flake.models import *

class SessionPurchaseOrder(models.Model):
    createdDate = models.DateTimeField()
    updatedDate = models.DateTimeField()
    sessionId = models.TextField(null=True,blank=True,default='')
    sessionUrl = models.TextField(null=True,blank=True,default='')
    status = models.TextField(null=True,blank=True,default='')
    paymentMethodId = models.ForeignKey(PaymentMethod, on_delete=models.CASCADE, related_name='paymentmethod_sessionpurchaseorder')
    orderFromId = models.ForeignKey(OrderFrom, on_delete=models.CASCADE, related_name='orderfrom_sessionpurchaseorder')
    couponId = models.ForeignKey(Coupon, on_delete=models.CASCADE,related_name='coupon_sessionpurchaseorder', null=True, blank=True)
    clientId = models.ForeignKey(Client, on_delete=models.CASCADE, related_name='client_sessionpurchaseorder')

class SessionShippingItem(models.Model):
    createdDate = models.DateTimeField()
    updatedDate = models.DateTimeField()
    shippingCostId = models.ForeignKey(ShippingCost, on_delete=models.CASCADE, related_name='shippingcost_sessionhippingitem')
    sessionPurchaseOrderId = models.ForeignKey(SessionPurchaseOrder, on_delete=models.CASCADE, related_name='sessionpurchaseorder_sessionshippingitem')

class SessionShippingAddress(models.Model):
    address1 = models.TextField(default='')
    address2 = models.TextField(default='')
    zipCode = models.TextField(default='')
    createdDate = models.DateTimeField()
    updatedDate = models.DateTimeField()
    countryId = models.ForeignKey(Country, on_delete=models.CASCADE, related_name='country_sessionshippingaddress')
    stateId = models.ForeignKey(State, on_delete=models.CASCADE, related_name='state_sessionshippingaddress',null=True, blank=True)
    cityId = models.ForeignKey(City, on_delete=models.CASCADE, related_name='city_sessionshippingaddress',null=True, blank=True)
    sessionShippingItemId = models.OneToOneField(SessionShippingItem, on_delete=models.CASCADE, primary_key=True, related_name='sessionshippingitem_sessionShippingAddress')
    def __str__(self):
        return str(self.sessionShippingItemId)

class SessionPurchaseShippingItem(models.Model):
    skuPrice = models.FloatField(default=0)
    skuDiscount = models.FloatField(default=0)
    deliveredQuantity = models.FloatField(default=0)
    createdDate = models.DateTimeField()
    updatedDate = models.DateTimeField()
    skuCostId = models.ForeignKey(SKUCost, on_delete=models.CASCADE, related_name='skucost_sessionpurchaseshippingitem')
    skuId = models.ForeignKey(SKU, on_delete=models.CASCADE, related_name='sku_sessionpurchaseshippingitem')
    sessionShippingItemId = models.ForeignKey(SessionShippingItem, on_delete=models.CASCADE, related_name='sessionshppingitem_sessionpurchaseshippingitem')

class TrackOrder(models.Model):
    sessionId = models.ForeignKey(SessionPurchaseOrder,null=True, on_delete=models.CASCADE, related_name='sessionpurchaseorder_trackorder')
    purchaseOrderId = models.ForeignKey(PurchaseOrder,null=True, on_delete=models.CASCADE, related_name='purchaseorder_trackorder')
    createdDate = models.DateTimeField()
    updatedDate = models.DateTimeField()

#Change Here
class SessionRecharge(models.Model):
    subTotal = models.FloatField(default=0)
    service = models.FloatField(default=0)
    sessionId = models.TextField(null=True,blank=True,default='')
    sessionUrl = models.TextField(null=True,blank=True,default='')
    status = models.TextField(null=True,blank=True,default='')
    description = models.TextField(null=True,blank=True,default='')
    rechargeCostId = models.ForeignKey(RechargeCost, on_delete=models.CASCADE, related_name='rechargecost_sessionrecharge',null=True, blank=True)
    paymentMethodId = models.ForeignKey(PaymentMethod, on_delete=models.CASCADE, related_name='paymentmethod_sessionrecharge')
    createdDate = models.DateTimeField()
    updatedDate = models.DateTimeField()
