Add an append-only ledger of entitlement set rule changes with per-pool effect rows, a preview-and-commit rule change flow, and an automatic drain that settles deferred recomputations. Rules gain a tier reduction policy, resource keys declare over-limit behavior, and the materializer now lowers limits when a rule stops applying. Add entitlement set rule change ledger and preview flow Add an append-only ledger of entitlement set rule changes with a preview-and-commit operator flow. Rule writes now go through an enclosed `core.commit_rule_change` function that files an act row and one obligation per carrying pool, with a drain workflow settling deferred recomputations. The preview dry-runs the materializer with a rule overlay and renders per-pool buckets, reduction-policy disclosures, and provider over-limit consequences. Materializing transactions take a shared advisory rendezvous that rule changes hold exclusively, enforced by a possession assertion. Add History and Entitlement changes surfaces, a rule-less warning on five product-selection surfaces, and a `tier_reduction_policy` column that gates FedWiki parking.
201 lines
8.4 KiB
Go
201 lines
8.4 KiB
Go
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
|
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
|
|
package billing
|
|
|
|
import (
|
|
"database/sql"
|
|
"encoding/json"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/sqlc-dev/pqtype"
|
|
)
|
|
|
|
type Account struct {
|
|
BillingAccountID string `json:"billing_account_id"`
|
|
OrgID string `json:"org_id"`
|
|
Name string `json:"name"`
|
|
Status string `json:"status"`
|
|
Metadata json.RawMessage `json:"metadata"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
NextInvoiceNumber int32 `json:"next_invoice_number"`
|
|
}
|
|
|
|
type CoreProductShape struct {
|
|
ProductID string `json:"product_id"`
|
|
LifecycleStatus string `json:"lifecycle_status"`
|
|
IsPublic bool `json:"is_public"`
|
|
SetPresent interface{} `json:"set_present"`
|
|
LadderCount int64 `json:"ladder_count"`
|
|
BillingShape string `json:"billing_shape"`
|
|
ConsumptionShape string `json:"consumption_shape"`
|
|
ActiveRuleCount int64 `json:"active_rule_count"`
|
|
PerUnitRuleCount int64 `json:"per_unit_rule_count"`
|
|
}
|
|
|
|
type Invoice struct {
|
|
InvoiceID string `json:"invoice_id"`
|
|
BillingAccountID string `json:"billing_account_id"`
|
|
SubscriptionID uuid.NullUUID `json:"subscription_id"`
|
|
Status string `json:"status"`
|
|
AmountDue int32 `json:"amount_due"`
|
|
AmountPaid int32 `json:"amount_paid"`
|
|
Currency string `json:"currency"`
|
|
PeriodStart sql.NullTime `json:"period_start"`
|
|
PeriodEnd sql.NullTime `json:"period_end"`
|
|
DueDate sql.NullTime `json:"due_date"`
|
|
PaidAt sql.NullTime `json:"paid_at"`
|
|
VoidedAt sql.NullTime `json:"voided_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
InvoiceNumber sql.NullString `json:"invoice_number"`
|
|
}
|
|
|
|
type InvoiceLineItem struct {
|
|
LineItemID string `json:"line_item_id"`
|
|
InvoiceID string `json:"invoice_id"`
|
|
SubscriptionItemID uuid.NullUUID `json:"subscription_item_id"`
|
|
PriceID string `json:"price_id"`
|
|
Amount int32 `json:"amount"`
|
|
Currency string `json:"currency"`
|
|
Description sql.NullString `json:"description"`
|
|
Quantity int32 `json:"quantity"`
|
|
PeriodStart sql.NullTime `json:"period_start"`
|
|
PeriodEnd sql.NullTime `json:"period_end"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type Payment struct {
|
|
PaymentID string `json:"payment_id"`
|
|
InvoiceID string `json:"invoice_id"`
|
|
BillingAccountID string `json:"billing_account_id"`
|
|
PaymentMethodID uuid.NullUUID `json:"payment_method_id"`
|
|
Amount int32 `json:"amount"`
|
|
Currency string `json:"currency"`
|
|
Status string `json:"status"`
|
|
FailedAt sql.NullTime `json:"failed_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type PaymentMethod struct {
|
|
PaymentMethodID string `json:"payment_method_id"`
|
|
BillingAccountID string `json:"billing_account_id"`
|
|
PmType string `json:"pm_type"`
|
|
CardBrand sql.NullString `json:"card_brand"`
|
|
CardLast4 sql.NullString `json:"card_last4"`
|
|
CardExpMonth sql.NullInt32 `json:"card_exp_month"`
|
|
CardExpYear sql.NullInt32 `json:"card_exp_year"`
|
|
Funding sql.NullString `json:"funding"`
|
|
IsDefault bool `json:"is_default"`
|
|
DetachedAt sql.NullTime `json:"detached_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type PlanLadder struct {
|
|
PlanLadderID string `json:"plan_ladder_id"`
|
|
Key sql.NullString `json:"key"`
|
|
Name string `json:"name"`
|
|
Description sql.NullString `json:"description"`
|
|
IsActive bool `json:"is_active"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
SortOrder int32 `json:"sort_order"`
|
|
}
|
|
|
|
type PlanLadderTier struct {
|
|
PlanLadderID string `json:"plan_ladder_id"`
|
|
ProductID string `json:"product_id"`
|
|
Rank int32 `json:"rank"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type Price struct {
|
|
PriceID string `json:"price_id"`
|
|
ProductID string `json:"product_id"`
|
|
Currency string `json:"currency"`
|
|
UnitAmount int32 `json:"unit_amount"`
|
|
RecurringInterval sql.NullString `json:"recurring_interval"`
|
|
TrialPeriodDays sql.NullInt32 `json:"trial_period_days"`
|
|
IsActive bool `json:"is_active"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
IsDefault bool `json:"is_default"`
|
|
UsageType sql.NullString `json:"usage_type"`
|
|
Key sql.NullString `json:"key"`
|
|
}
|
|
|
|
type Product struct {
|
|
ProductID string `json:"product_id"`
|
|
Name string `json:"name"`
|
|
Description sql.NullString `json:"description"`
|
|
// Presentation-layer grouping only (Doc 41 Decision 136): storefront sections and operator filters. No code may branch on this value for behavior — structural facts live in plan_ladder_tiers and per-price columns.
|
|
DisplayCategory sql.NullString `json:"display_category"`
|
|
Metadata pqtype.NullRawMessage `json:"metadata"`
|
|
IsActive bool `json:"is_active"`
|
|
IsPublic bool `json:"is_public"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
EntitlementSetID uuid.NullUUID `json:"entitlement_set_id"`
|
|
LifecycleStatus string `json:"lifecycle_status"`
|
|
Key sql.NullString `json:"key"`
|
|
}
|
|
|
|
type Subscription struct {
|
|
SubscriptionID string `json:"subscription_id"`
|
|
BillingAccountID string `json:"billing_account_id"`
|
|
Status string `json:"status"`
|
|
CurrentPeriodStart sql.NullTime `json:"current_period_start"`
|
|
CurrentPeriodEnd sql.NullTime `json:"current_period_end"`
|
|
CancelAtPeriodEnd bool `json:"cancel_at_period_end"`
|
|
CanceledAt sql.NullTime `json:"canceled_at"`
|
|
EndedAt sql.NullTime `json:"ended_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
CommitmentEnd sql.NullTime `json:"commitment_end"`
|
|
CommitmentRenewal sql.NullString `json:"commitment_renewal"`
|
|
EarlyTerminationPolicy sql.NullString `json:"early_termination_policy"`
|
|
}
|
|
|
|
type SubscriptionChange struct {
|
|
ChangeID string `json:"change_id"`
|
|
SubscriptionID string `json:"subscription_id"`
|
|
PreviousStatus sql.NullString `json:"previous_status"`
|
|
NewStatus string `json:"new_status"`
|
|
StripeEventID string `json:"stripe_event_id"`
|
|
ChangedAt time.Time `json:"changed_at"`
|
|
}
|
|
|
|
type SubscriptionItem struct {
|
|
SubscriptionItemID string `json:"subscription_item_id"`
|
|
SubscriptionID string `json:"subscription_id"`
|
|
ProductID string `json:"product_id"`
|
|
PriceID string `json:"price_id"`
|
|
Quantity int32 `json:"quantity"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type SubscriptionScheduledChange struct {
|
|
ScheduledChangeID string `json:"scheduled_change_id"`
|
|
SubscriptionID string `json:"subscription_id"`
|
|
ChangeType string `json:"change_type"`
|
|
TargetPriceID uuid.NullUUID `json:"target_price_id"`
|
|
TargetQuantity sql.NullInt32 `json:"target_quantity"`
|
|
EffectiveAt time.Time `json:"effective_at"`
|
|
EffectiveTrigger string `json:"effective_trigger"`
|
|
CreditDisposition sql.NullString `json:"credit_disposition"`
|
|
Status string `json:"status"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|