Skip to content

Checkout Application Documentation

CouponCode

Represents coupon codes that provide discounts.

Field Name Data Type Attributes Description
id AutoField Primary Key Unique identifier for the record.
code CharField unique=True The coupon code (automatically uppercased).
description TextField null=True, blank=True Optional description of the coupon.
discount_percent DecimalField max_digits=5, decimal_places=2 Discount percentage for the coupon.
money_value_off DecimalField max_digits=10, decimal_places=2 Fixed money value discount amount.
total_issues PositiveIntegerField default=0 Total number of coupons issued.
coupon_limit_per_customer PositiveIntegerField default=1 Maximum coupons a customer can use.
used_count PositiveIntegerField default=0 Number of times the coupon has been used.
total_used PositiveIntegerField default=0 Total number of coupons used across customers.
start_at DateTimeField null=True, blank=True Start date/time of coupon validity.
end_at DateTimeField null=True, blank=True End date/time of coupon validity.
min_purchase DecimalField max_digits=10, decimal_places=2 Minimum purchase required for the coupon.
is_active BooleanField default=True Whether the coupon is active or not.
shop ForeignKey (Shop) null=True, blank=True, on_delete=CASCADE The shop associated with the coupon (if not global).
is_global BooleanField default=False Whether the coupon is applicable globally.
created_at DateTimeField auto_now_add=True Auto-generated field for record creation time.
updated_at DateTimeField auto_now=True Auto-updated field for the last modification.

CouponClaim

Tracks claims of a coupon by a user.

Field Name Data Type Attributes Description
id AutoField Primary Key Unique identifier for the record.
code ForeignKey to=CouponCode Coupon associated with the claim.
user ForeignKey to=User User claiming the coupon.
is_claimed BooleanField Default False Whether the coupon has been claimed.
claimed_at DateTimeField auto_now_add=True Auto-generated field for claim time.

ApplyCoupon

Represents an applied coupon in a transaction.

Field Name Data Type Attributes Description
id AutoField Primary Key Unique identifier for the record.
applied_coupon ForeignKey to=CouponClaim, on_delete=CASCADE Claimed coupon being applied.
shop ForeignKey to=Shop, on_delete=CASCADE, null=True, blank=True The shop associated with the applied coupon.
user ForeignKey to=User, on_delete=CASCADE, null=True The user applying the coupon.
total_purchased DecimalField max_digits=10, decimal_places=2 Total amount of the purchase.
discounted_amount DecimalField max_digits=10, decimal_places=2 Discount amount provided by the coupon.
grand_total DecimalField max_digits=10, decimal_places=2 Final amount after applying discount.
has_applied BooleanField default=False Whether the coupon has been applied.
applied_at DateTimeField auto_now_add=True Time when the coupon was applied.

ProductPurchased

Tracks purchased products with coupon applications.

Field Name Data Type Attributes Description
id AutoField Primary Key Unique identifier for the record.
user ForeignKey to=User User who made the purchase.
applied_coupon ForeignKey to=ApplyCoupon Coupon applied to the purchase.
total_purchased DecimalField max_digits=10, decimal_places=2 Total amount before discount.
discounted_amount DecimalField max_digits=10, decimal_places=2 Total discount applied.
grand_total DecimalField max_digits=10, decimal_places=2 Final amount paid.
has_purchased_succeed BooleanField Default False Whether the purchase was successful.
purchased_at DateTimeField auto_now_add=True Time when the purchase occurred.

PurchasedCartItem

Tracks individual cart items in a completed purchase.

Field Name Data Type Attributes Description
id AutoField Primary Key Unique identifier for the record.
purchased_product ForeignKey to=ProductPurchased Associated product purchase.
cart_item ForeignKey to=CartItem Original cart item.
status BooleanField Default False Status of the purchased item.
created_at DateTimeField auto_now_add=True Time when the item was purchased.
updated_at DateTimeField auto_now=True Time of the last modification.
order_id CharField Unique, Auto-generated Unique order identifier prefixed with "KS".

Relationships

  • User: Associated with CouponClaim, ProductPurchased, and CartItem.
  • CouponCode: Claimed by CouponClaim.
  • CouponClaim: Applied through ApplyCoupon.
  • ApplyCoupon: Used in ProductPurchased.
  • ProductPurchased: Contains multiple PurchasedCartItem.