Skip to content

Instantly share code, notes, and snippets.

@TheB1ackSheep
Created July 16, 2015 13:54
Show Gist options
  • Save TheB1ackSheep/84b95c8573b10b128b16 to your computer and use it in GitHub Desktop.
Save TheB1ackSheep/84b95c8573b10b128b16 to your computer and use it in GitHub Desktop.
Checkout Model 0.1
from django.db import models
from django.utils.translation import ugettext_lazy as _
# Create your models here.
class ShipmentMethod(models.Model):
name = models.CharField(_('วิธีจัดส่ง'), max_length=100)
cost = models.FloatField(_('ค่าจัดส่ง'))
"""
Order Status:
0 - incomplete order
1 - unpaid
2 - paid
3 - shipped
4 - cancel (by user or expired)
"""
class OrderStatus(models.Model):
name = models.CharField(_('สถานะ'), max_length=100)
class Order(models.Model):
user = models.ForeignKey('account.Customer', blank=True, null=True)
qty = models.IntegerField(_('จำนวนรวม'))
grand_total = models.FloatField(_('ราคาทั้งหมด'))
shipment_method = models.ForeignKey('checkout.ShipmentMethod')
# Shipment Address
shipment_name = models.CharField(_('ชื่อ-นามกุล/บริษัท'), max_length=50)
shipment_address_1 = models.CharField(_('ที่อยู่ 1'), max_length=50)
shipment_address_2 = models.CharField(_('ที่อยู่ 2'), max_length=50, blank=True, null=True)
shipment_tumbon = models.ForeignKey('address.Tumbon', related_name='shipment_tumbon')
shipment_phone = models.CharField(_('เบอร์ติดต่อ'), max_length=10)
shipment_phone_ext = models.CharField(_('ต่อ'), max_length=5, blank=True, null=True)
# Invoice Address (Personal/Juristic Address)
invoice_name = models.CharField(_('ชื่อ-นามกุล/บริษัท'), max_length=50)
invoice_tax_id = models.CharField(_('เลขประจำตัวผู้เสียภาษี'), max_length=20)
invoice_address_1 = models.CharField(_('ที่อยู่ 1'), max_length=50)
invoice_address_2 = models.CharField(_('ที่อยู่ 2'), max_length=50)
invoice_tumbon = models.ForeignKey('address.Tumbon', related_name='invoice_tumbon')
invoice_phone = models.CharField(_('เบอร์ติดต่อ'), max_length=10)
invoice_phone_ext = models.CharField(_('ต่อ'), max_length=5, blank=True, null=True)
invoice_fax = models.CharField(_('แฟกซ์'), max_length=10, blank=True, null=True)
class OrderItem(models.Model):
order = models.ForeignKey('checkout.Order')
product = models.ForeignKey('shop.Product')
qty = models.IntegerField()
subtotal = models.FloatField()
"""
Order Tracking
used to follow status of order time by time when status change
"""
class OrderTracking(models.Model):
order = models.ForeignKey('checkout.Order')
status = models.ForeignKey('checkout.OrderStatus')
datetime = models.DateTimeField(auto_now_add=True)
note = models.CharField(max_length=400)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment