Skip to main content

BillingSubscription

A tenant's verified subscription: at most one row per tenant (V167's unique index on tenant_id), written only by provider webhooks.

Tablebilling_subscription
Tenant-scopedNo — global table
Columns26
Relationships0
Sourcebackend/src/main/java/com/motorph/payroll/model/BillingSubscription.java
Not tenant-scoped

This entity does not extend TenantOwned, so its rows are shared across every tenant. TenantCoverageTest allows that only for tables deliberately declared global.

Columns​

FieldTypeColumnNullNotes
billingSubscriptionIdIntegerbilling_subscription_id—primary key, generated
tenantIdIntegertenant_id—Set explicitly on insert -- the column has no default since V167, so forgetting it fails.
providerStringprovider——
providerSubscriptionIdStringprovider_subscription_idYes—
providerCustomerIdStringprovider_customer_idYes—
planCodeStringplan_codeYes—
statusSubscriptionStatusstatus—converted by SubscriptionStatusConverter
amountBigDecimalamountYes—
currencyStringcurrencyYes—
currentPeriodEndLocalDateTimecurrent_period_endYes—
cancelAtPeriodEndbooleancancel_at_period_end——
seatsIntegerseatsYesSeats (active employees) the current period bills for; null on a flat, pre-seat plan.
pendingSeatsIntegerpending_seatsYesA lower seat count already scheduled to take effect at renewal; null when none is.
pendingPlanCodeStringpending_plan_codeYesA plan scheduled to take over at renewal (a downgrade); null when none is.
pendingChangeAtLocalDateTimepending_change_atYesWhen #pendingPlanCode takes over (Manila time).
seatsSyncedAtLocalDateTimeseats_synced_atYes—
seatSyncFailureSeatSyncFailureseat_sync_failureYesenum; Why the last seat change was refused; null when the last sync worked.
seatSyncFailedSinceLocalDateTimeseat_sync_failed_sinceYes—
seatSyncFailedSeatsIntegerseat_sync_failed_seatsYes—
seatSyncNotifiedAtLocalDateTimeseat_sync_notified_atYes—
seatSyncRemindedAtLocalDateTimeseat_sync_reminded_atYes—
seatsReportedAtLocalDateTimeseats_reported_atYes—
createdByStringcreated_byYes—
createdDateLocalDateTimecreated_date——
lastModifiedByStringlast_modified_byYes—
lastModifiedDateLocalDateTimelast_modified_dateYes—

Repository​

BillingSubscriptionRepository​

Every lookup names the tenant: the entity is not tenant-filtered (see BillingSubscription), so an unqualified query would read across companies whenever RLS is not in force.

Declared over BillingSubscription with id type Integer. Source: backend/src/main/java/com/motorph/payroll/repository/BillingSubscriptionRepository.java

MethodReturnsNotes
findByTenantId(Integer tenantId)Optional<BillingSubscription>derived
findByProviderAndProviderSubscriptionId(String provider, String providerSubscriptionId)Optional<BillingSubscription>derived
findByTenantIdForUpdate(@Param("tenantId") Integer tenantId)Optional<BillingSubscription>explicit @Query

Reached by​

These controllers hold — directly or through a service they depend on — a repository over BillingSubscription.

ControllerBase pathEndpointsModule
BillingController/api/billing6Billing & Platform
BillingWebhookController/api/webhooks1Billing & Platform
PublicBillingController/api/public/billing1Billing & Platform
SubscriptionStatusController/api/billing1Billing & Platform

Generated page

This page is rebuilt from the source on every docs build by docs-site/scripts/gen-code-wiki.mjs. Editing it has no effect — change the code, or, if what you want to say is prose, write it in docs/.