CompanyVirtualProductOrders


Columns

Column Type Size Nulls Auto Default Children Parents Comments
id bigserial 19 √ nextval('employer_purchases."CompanyVirtualProductOrders_id_seq"'::regclass)
orderNumber varchar 64 null
CompanyPurchaseSubscriptions.orderNumber CompanyPurchaseSubscriptions_orderNumber_fkey R
productId uuid 2147483647 √ null
skuId uuid 2147483647 null
PaidProducts.skuId CompanyVirtualProductOrders_skuId_fkey R
companyId uuid 2147483647 null
Companies.id CompanyVirtualProductOrders_companyId_fkey R
userId uuid 2147483647 null
Users.id CompanyVirtualProductOrders_userId_fkey R
paymentType "employer_purchases"."enum_CompanyVirtualProductOrders_paymentType" 2147483647 null

Defines how the order is paid. CREDITS: paid entirely using credits. EXTERNAL: paid via an external payment provider (Xendit or 2C2P). COMBINED: paid using a combination of credits and an external payment provider. Defaults to EXTERNAL.

status "employer_purchases"."enum_CompanyVirtualProductOrders_status" 2147483647 null

Lifecycle status of the order. PENDING_PAYMENT: initial status for EXTERNAL payment orders, awaiting provider settlement. PARTIALLY_PAID: initial status for COMBINED payment orders — credits have been deducted but external payment is still pending. PROCESSING: payment received but product not yet delivered; handles asynchronous fulfillment delays (e.g. “Opening VIP for you, please wait…”). COMPLETED: product successfully delivered (e.g. VIP activated, credits received). FAILED: payment succeeded but product delivery failed; requires manual intervention or automatic retry. CLOSED: cancelled due to payment timeout, or closed after a delivery failure upon refund request. REFUNDED: full refund completed.

purchaseType "employer_purchases"."enum_CompanyVirtualProductOrders_purchaseType" 2147483647 null

Categorises the purchase intent. ONE_TIME: a single, non-recurring purchase. SUBSCRIPTION: the initial purchase that creates and activates a new subscription.

subscriptionId uuid 2147483647 √ null
CompanyPurchaseSubscriptions.id CompanyVirtualProductOrders_subscriptionId_fkey R

References the subscription this order belongs to. Null by default for ONE_TIME purchases. Must be populated when purchaseType is SUBSCRIPTION.

expiryTime timestamptz 35,6 √ null
countryCode varchar 8 null
Countries.code CompanyVirtualProductOrders_countryCode_fkey R
currency varchar 8 √ null
Currencies.code CompanyVirtualProductOrders_currency_fkey R

ISO 4217 currency code for this order. Should always reflect the product’s default currency, even when the order is paid entirely using credits.

sellingAmount numeric 15,2 0
paidAmount numeric 15,2 0
paidCredits int8 19 0
productSnapshot jsonb 2147483647 √ null

Immutable snapshot of the product SKU at the time the order was placed, including product name, SKU specifications, original price, and selling price. Captured once at order creation and must not change when product information is later updated.

promotionSnapshot jsonb 2147483647 √ null

Immutable snapshot of the promotion applied at the time the order was placed, including promotion name, discount type, and discount amount. Null if no promotion was applied.

bizContext jsonb 2147483647 √ null
tax jsonb 2147483647 null
createdAt timestamptz 35,6 now()
updatedAt timestamptz 35,6 now()
referenceId varchar 255 null
orderSource "employer_purchases"."enum_CompanyVirtualProductOrders_orderSource" 2147483647 null

Indexes

Constraint Name Type Sort Column(s)
CompanyVirtualProductOrders_pkey Primary key Asc id
CompanyVirtualProductOrders_companyId_idx Performance Asc companyId
CompanyVirtualProductOrders_countryCode_idx Performance Asc countryCode
CompanyVirtualProductOrders_createdAt_idx Performance Asc createdAt
CompanyVirtualProductOrders_expiryTime_idx Performance Asc expiryTime
CompanyVirtualProductOrders_orderNumber_key Must be unique Asc orderNumber
CompanyVirtualProductOrders_paymentType_idx Performance Asc paymentType
CompanyVirtualProductOrders_purchaseType_idx Performance Asc purchaseType
CompanyVirtualProductOrders_referenceId_key Must be unique Asc referenceId
CompanyVirtualProductOrders_skuId_idx Performance Asc skuId
CompanyVirtualProductOrders_status_idx Performance Asc status
CompanyVirtualProductOrders_subscriptionId_idx Performance Asc subscriptionId
CompanyVirtualProductOrders_userId_idx Performance Asc userId

Relationships