Skip to main content

Phase 3.1 — Overview

Phase 3.1 makes every company, a child company included, spend only its own credits.

  • Today a child company spends its parent company's credits.
  • After Phase 3.1, a child company spends the credits on its own Billing::Account.
  • So one division can never use credits that another division paid for.

The decision behind this phase is Billing D16 — A company spends only its own billing account, never its parent's.

  • This folder is the work record for building it.

Words this phase uses​

WordMeaning
The model Org::CompanyAn organisation that uses Jod, and it can have a parent company in org_companies.parent_company_id
Root companyAn Org::Company with no parent, for example NTUC FairPrice
Child companyAn Org::Company with a parent, for example NTUC FairPrice Supermarkets (North)
The model Billing::AccountThe record that holds a company's credits, invoices and credit actions
Own accountThe Billing::Account whose billing_accounts.org_company_id is the company

Why we're building this​

Phase 3 gives each company credits it can spend on Ads placements.

  • A later fix made every child company spend its parent's account, so a child's Ads campaign no longer fails.
  • That fix puts all children of one parent into one shared pool of credits.

The shared pool does not match how our largest clients buy credits.

  1. In JodGig, NTUC FairPrice tops up each division on its own.
    • Supermarkets (North) tops up 1,000 credits.
    • Supermarkets (East) tops up 2,000 credits.
  2. With one shared pool, all 3,000 credits sit on the parent's account.
  3. North submits Ads campaigns that cost 1,500 credits, and the submit passes.
  4. North has now spent 500 credits that East paid for, and nothing shows it.

User stories​

  • US-1: As Finance, I want North's invoice to grant credits only to North, so each division's balance is exact.
  • US-2: As FairPrice North's HQ manager, I want to spend only North's credits, so North never uses East's credits.
  • US-3: As FairPrice North's HQ manager, I want to see North's own balance, so I know what North can spend.
  • US-4: As Sales, I want every company synced from JodGig to have an account, so each division can buy credits.
  • US-5: As a Jod engineer, I want one rule for the account a company spends, so every credit path agrees.

Scope​

In this phaseNot in this phase
Every company spends only its own Billing::AccountMoving credits between two accounts, which a later phase plans
The JodGig company sync creates an account for a child company tooOrg::LegalEntity, a later grouping of companies under one registered legal entity
A backfill creates the account for each existing company that has noneA parent HQ manager's combined view of every division's balance
The Team Portal and the Employer Dashboard show the company's own accountOutlet budgets (billing_outlet_budgets), which stay a gig-only design
Careers job credit charge and trial credits on sign-up, which Phase 4 builds

What does not change​

  • Billing::EntitlementLotService does not change.
    • Consume and release already follow the account on the reserve ledger entry.
  • No Billing table changes.
    • Each Billing table already carries billing_account_id.
  • A root company with no children works exactly as it does today.
  • A company created in Jod already gets its own account when it is created.

Pages in this folder​

  1. Design Plan: the rules, the design, the code that changes and the rollout.
  2. Use Cases: every flow step by step, with a FairPrice worked example.
  3. Implementation Plan: the issues for jodapp-api and jodapp-web, in build order, and a manual test plan.