Skip to content

Expose company_id on subscription responses for per-company VAT display #216

Description

@v0l

Problem

The customer subscription responses (GET /api/v1/subscriptions, GET /api/v1/subscriptions/{id}) don't carry a seller company_id. ApiSubscription and ApiSubscriptionLineItem both omit it, even though the underlying Subscription row already has company_id (lnvps_db/src/model.rs).

Why it matters

VAT rates are per seller company: account.tax[] is keyed by company_id, and elsewhere clients match it against a company id to pick the right rate (e.g. VmHostRegion.company_id is documented as "match against account.tax[].company_id for the applicable VAT rate").

The web app just added an "incl. tax" price toggle. For VMs it resolves the correct rate via region.company_id, but subscriptions (IP ranges, DNS, …) expose no company id, so the UI has to fall back to the primary (first) tax entry. That's correct for single-company deployments but wrong once a customer holds subscriptions across multiple companies with different VAT rates.

Proposal

Expose the seller company_id on the subscription response so clients can gross-up prices with the right rate. Either (or both):

interface SubscriptionLineItem {
  // ...
  company_id: number; // seller company for this line item's VAT rate
}

or, since a subscription is billed by a single company and the value already lives on the Subscription row, the simpler:

interface Subscription {
  // ...
  company_id: number;
}

Read-only, additive — no breaking change. The subscription-level field is the least duplication; the line-item field mirrors how VM pricing already carries company context. Either lets the client match account.tax[].company_id and drop the primary-rate fallback.

Related: the host CPU arch exposure (#210) followed the same "surface the id the client needs to resolve a per-account value" pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions