Skip to main content

Design Plan: a Careers job consumes placement credits

TL;DR​

  • Posting a Careers::Job buys a Careers::JobPosting, paid with placement credits from the company's own account.
    • The first prices are 1 month for 50 credits and 3 months for 100 credits.
    • Sales changes the prices in the Team Portal, with no deploy.
  • The Careers::Job stays posted until the latest Careers::JobPosting.ends_at of the Careers::Job, and then the system closes it.
    • The employer can close, hide and open the Careers::Job again for free during the period.
    • The employer renews the Careers::Job to buy a new period, before or after it ends.
  • The consume is direct, with no reserve, and it recognises the whole cost on the day the company pays.
  • The price and the Careers::JobPosting live in the Careers domain, in the new tables careers_job_posting_prices and careers_job_postings.
    • Careers reads the end of a Careers::Job from its latest Careers::JobPosting.ends_at, so careers_jobs gets no new column.
  • Careers pays through the Billing interface: Billing::SpendValidator to check, and Billing::SpendService.consume_now to pay.
  • An existing Careers::Job, created before Billing Phase 3.2 ships, has no Careers::JobPosting, so it stays open with no end date.
    • Its HQ manager can hide it and open it again for free.
    • It never gets a renew, and closed is its end state.
  • When credits are too low, the form asks the employer to chat with us on WhatsApp to top up.
  • Closing a Careers::Job early gives no credits back.

The diagram shows the life of one Careers::Job that pays for Careers::JobPosting rows.

Legend:

  • The orange node is the new Careers::JobPosting, the subject of this page.
  • Lavender nodes belong to the Careers domain.
  • Grey nodes are Sales and the Billing interface.
  • The red node is the case with too few credits.
  • The dashed box is one database transaction.

Words used on this page​

WordMeaning
The model Careers::JobOne job that an Org::Company posts on Careers, in the table careers_jobs
The model Careers::JobPostingPriceOne price for a Careers::JobPosting, with its number of days and its credit cost, in the new table careers_job_posting_prices
The model Careers::JobPostingOne paid period of one Careers::Job, from starts_at to ends_at, in the new table careers_job_postings
Existing Careers::JobA Careers::Job created before Billing Phase 3.2 ships, which has no Careers::JobPosting
RenewA new Careers::JobPosting that a Careers::Job buys after it is posted
Direct consumeA consume ledger entry that takes units from available credits, with no reserve before it
The class Billing::SpendServiceThe public Billing class that writes a spend, which Careers calls with consume_now
The class Billing::SpendValidatorThe public Billing class that checks a spend before the transaction
Own accountThe Billing::Account whose billing_accounts.org_company_id is the company of the Careers::Job
HQ managerA person with an Org::Membership on the company who posts and edits Careers jobs in the Employer Dashboard

Problem​

Careers is the product where paying customers are today, but Billing cannot take credits for it.

  • Sales invoices Careers job posts by hand, for example SGD 99 per post, and those invoices live only in Xero.
  • A company gets 1 month free after its first job, and then Sales unblocks it by hand.
  • Finance cannot see Careers revenue next to Ads revenue, because it never reaches the ledger.
  • A Careers::Job stays open for as long as the employer wants, so one payment can cover it for years.
  • The goal is that placement credits pay for each Careers::JobPosting of each Careers::Job.

Worked example: Acme today​

  1. Acme Pte Ltd signs up and posts a Barista job on 1 March.
  2. The trial starts, and Acme posts 4 more jobs during the month for free.
  3. On 1 April the trial ends, and Acme cannot post or see applicant details.
  4. Sales sends a manual invoice for SGD 99 per job and unblocks Acme by hand.
  5. The Barista job is still open a year later, with no new payment.
  6. Nothing in the system records that Acme paid for these jobs.

Context​

The entitlement engine holds each company's placement credits as lots, and every movement writes a ledger entry.

A product domain spends credits only through the Billing interface.

Each company spends only its own account.

  • Phase 3.1 makes a child company spend its own credits, never its parent's.
  • A parent HQ manager can post a job for a child company, and the child's account pays.

Careers is the only product that sells a job post.

  • The table listings_jobs holds the public copy of each job for the marketplace, and it gets no new column.
  • Gig pays wages and a fee per shift through gig credits, not a price per job post.
  • So the price and the Careers::JobPosting belong to Careers, next to careers_jobs.

The Ads domain already has a price list that Sales edits in the Team Portal.

  • Each Ads placement has prices with a name, a number of days and a credit cost.
  • A booking copies the credit cost, so a later price change does not change it.

The careers trial gate decides if a company can post jobs and see applicant details.

  • A new company starts in trial, and the trial ends 1 month after its first job.
  • After the trial, the company is blocked until Sales sets it to allowed.
  • Employers Careers Trial holds the full rule.
  • The next phase replaces this trial with trial credits, so this phase keeps the gate as it is.
  • Both phases merge into the Phase 3 feature branch, so they reach production together.

Alvin and marketing decided the first prices, with 1 credit = SGD 1.

PriceDaysCredits
1 Month3050
3 Months90100

Alvin compared them with other Singapore job boards.

Job boardPrice
FastJobsSGD 120 per post per month
JobStreetAbout SGD 100 to SGD 500 per month
IndeedPay per view, per click or per application
MyCareersFutureFree, owned by the government

Only Jod staff can top up credits today, from the Team Portal.

  • So an employer with too few credits chats with us on WhatsApp, as on the Ads campaign page.

User stories​

The user stories are on the Overview.

Rules​

RuleApplies toExample
Posting a Careers::Job pays the picked price from the own account of its companyUS-1Acme posts a Barista job for 1 month and pays 50 credits
Each Careers::JobPosting lasts the price's number of daysUS-1A Careers::JobPosting bought on 14 Oct for 1 month ends on 13 Nov
A Careers::Job consumes directly from available credits and reserves nothingalwaysThe ledger has one consume entry and no reserve entry for the Careers::JobPosting
The consume recognises the whole cost on the day the company paysalwaysAcme pays 50 paid credits on 14 Oct, and SGD 50 is recognised on 14 Oct
A renew recognises its whole cost on the renew day, also when its period starts laterUS-6Acme renews on 10 Nov for a period from 13 Nov, and the whole cost is recognised on 10 Nov
The consume takes the soonest-expiring lot first and skips expired lotsalwaysA trial lot that expires on 20 March is spent before a paid lot that expires next year
The Careers::JobPosting copies the price's days and credit cost when it is createdUS-3Sales changes "1 Month" to 60 credits, and Acme's Careers::JobPosting still says 50
The Careers::JobPosting stores who created italwaysAcme's Careers::JobPosting has created_by_type: 'Org::Membership' and the id of the HQ manager's membership
A Careers::Job with a Careers::JobPosting can be open or hidden only while its latest Careers::JobPosting.ends_at is in the futurealwaysAcme opens the Barista job on 1 Nov and pays nothing
The employer can close, hide or open a Careers::Job again for free during its periodUS-2Acme hides the Barista job on 20 Oct and opens it again on 25 Oct
Hiding or closing a Careers::Job does not pause its periodalwaysAcme hides the Barista job from 20 Oct to 30 Oct, and the period still ends on 13 Nov, not 23 Nov
The system closes an open or hidden Careers::Job when its period endsalwaysOn 13 Nov Careers::Jobs::CloseJob sets the Barista job to status: :closed
A renew of a running Careers::Job starts at its latest Careers::JobPosting.ends_atUS-6Acme renews on 10 Nov for 3 months, and the Barista job is posted until 11 Feb
An existing Careers::Job has no Careers::JobPosting.ends_at, and the system never closes italwaysAcme's Cashier job, an existing Careers::Job, is still open a year after Billing Phase 3.2 ships
The employer can hide and open an existing Careers::Job for free, any number of timesUS-2Acme hides its Cashier job, an existing Careers::Job, and opens it again, and pays nothing
An existing Careers::Job never gets a renewUS-6Acme's renew of its Cashier job, an existing Careers::Job, fails with "This job cannot be renewed. Post a new job to hire again."
A renew of an ended Careers::Job starts now and opens the Careers::JobUS-6Acme renews the Barista job on 1 Dec for 1 month, and it is open until 31 Dec
Opening a Careers::Job whose period has ended fails and asks for a renewUS-6"This job's posting has ended. Renew it to open it again."
closed is the end state of an existing Careers::Job: it cannot open or hide againUS-2Acme closes its Cashier job, an existing Careers::Job, and opening it again fails with "This job is closed. Post a new job to hire again."
The employer cannot post or renew when no price is activeUS-3"Posting a job is not available right now. Please contact Jod support."
The form lists every active price, and the employer picks oneUS-1The form shows "1 Month, 50 credits" and "3 Months, 100 credits"
A price always costs more than 0 creditsalwayscareers_job_posting_prices.unit_cost has the CHECK unit_cost > 0, because a spend of 0 units raises a 500
A company without enough available credits cannot post or renewUS-5Acme has 20 credits and 1 month costs 50, so the post fails
The form shows a WhatsApp button to top up when credits are too lowUS-5"Chat with us to top up credits" opens WhatsApp with the cost and the balance
A company with careers_access_status: :blocked cannot post or renewalways"Company trial period has ended, please contact sales for assistance"
A company with careers_access_status: :trial or :allowed pays creditsalwaysA new company in trial pays its first Careers::JobPosting with trial credits
Closing a Careers::Job gives no credits backalwaysAcme closes the Barista job on 20 Oct, and the 50 credits stay consumed
A Careers::Job never changes companyalwaysAcme cannot move its Barista job, or its existing Cashier job, to a child company
A parent HQ manager who posts for a child company spends the child's own accountalwaysFairPrice HQ posts a job for FairPrice North, and North's account pays
Each Careers::JobPosting is one row in careers_job_postings and one consume ledger entryUS-4Acme's post and renew are 2 Careers::JobPosting rows and 2 entries
A seed file creates "1 Month" and "3 Months" before any company postsalwaysOn the day Billing Phase 3.2 ships, the job form already shows both prices
Every company with careers_access_status: :trial or :allowed gets free credits for one Careers::JobPostingalwaysAcme gets 50 placement credits from a Billing::CreditAction of the System admin
One Careers::JobPosting is never paid twicealwaysA second consume_now for Careers::JobPosting 88 raises a 500, and the transaction rolls back
One submit of the job form creates one Careers::Job at mostUS-1A second request with the same idempotency key gets the first Careers::Job back, and pays nothing
The idempotency key is unique per companyalwaysAcme and Bistro send the same key, and each gets its own Careers::Job
A post with no idempotency key failsUS-1A request with no key gets a 422, and creates nothing
One renew dialog buys one period at mostUS-6Two HQ managers renew at the same moment, and the second one gets "This job is already renewed until 13 Dec"
Every Careers::JobPosting has a pricealwayscareers_job_postings.careers_job_posting_price_id is NOT NULL

Direction​

Posting a Careers::Job creates one Careers::JobPosting for the picked price, and Careers pays for it with Billing::SpendService.consume_now.

  • The employer picks a period and sees the cost, the end date and the company's balance before posting.
  • During the period, the Careers::Job works as it does today.
  • When the period ends, the system closes the Careers::Job.
  • The employer renews the Careers::Job to buy a new period.

Worked example: Acme, after the change​

  1. A seed file creates the prices "1 Month" for 50 credits and "3 Months" for 100 credits.
  2. Acme has 170 placement credits.
  3. On 14 Oct, Acme's HQ manager opens the job form.
    • The form shows "1 Month, 50 credits" and "3 Months, 100 credits".
    • The HQ manager picks "1 Month".
    • The form shows "Posted until 13 Nov" and "Your balance: 170 placement credits".
  4. The HQ manager posts the Barista job and confirms the cost.
    • The system creates the Careers::Job with status: :open.
    • The system creates Careers::JobPosting #1 with starts_at: 14 Oct and ends_at: 13 Nov.
    • Billing writes one consume ledger entry of 50 credits, with the text "Job post: Barista, 1 Month".
    • Acme has 120 credits left.
  5. Acme hides the Barista job on 20 Oct and opens it again on 25 Oct.
    • Acme pays nothing, because the period runs until 13 Nov.
  6. On 10 Nov, Acme renews the Barista job for 3 months.
    • Careers::JobPosting #2 starts on 13 Nov and ends on 11 Feb.
    • The Barista job stays open, and its latest Careers::JobPosting.ends_at becomes 11 Feb.
    • Acme has 20 credits left.
  7. On 11 Feb, Careers::Jobs::CloseJob sets the Barista job to status: :closed.
  8. On 20 Feb, Acme tries to open the Barista job.
    • It fails with "This job's posting has ended. Renew it to open it again."
  9. Acme opens the renew dialog.
    • The dialog shows the "Insufficient Placement Credits" alert, because 20 credits is less than 50.
    • The alert has the button "Chat with us to top up credits", which opens WhatsApp.

Legend: lavender = the post succeeds, grey = the post fails with a message.

When a Careers::Job pays​

A Careers::Job pays only on a post and on a renew.

RequestState of the Careers::Job before the requestNew Careers::JobPostingPeriod
PostNew Careers::JobYesFrom now
RenewLatest Careers::JobPosting.ends_at in the futureYesFrom that ends_at
RenewLatest Careers::JobPosting.ends_at in the pastYes, and the Careers::Job opensFrom now
RenewAn existing Careers::Job, with no Careers::JobPostingFails, an existing Careers::Job never renewsNo period
Close, hide or openLatest Careers::JobPosting.ends_at in the futureNoneNo change
OpenLatest Careers::JobPosting.ends_at in the pastFails, the employer must renewNo change
Hide or openAn existing Careers::Job that is open or hiddenNone, any number of timesNo period
Hide or openAn existing Careers::Job that is closedFails, closed is its end stateNo period
Edit fieldsAnyNoneNo change
  • careers_jobs.status has three values: open, hidden and closed.
  • A Careers::Job update never pays, so only the post and the renew endpoints call Careers::JobPostings::Shared::CreateService.

When a Careers::Job is closed​

The hourly Sidekiq job Careers::Jobs::CloseJob closes every Careers::Job whose period has ended.

  • It finds Careers::Job rows with status open or hidden whose latest Careers::JobPosting has ends_at in the past.
    • An existing Careers::Job has no Careers::JobPosting, so the query never selects it.
  • For each Careers::Job, it locks the careers_jobs row and reads the latest Careers::JobPosting.ends_at again.
    • It closes the Careers::Job only when that ends_at is still in the past.
    • So a renew that commits after the query never sees its Careers::Job closed.
  • It sets each Careers::Job to status: :closed.
  • It syncs each Careers::Job to Listings with Careers::Jobs::SyncService, so an open Careers::Job leaves the job search.
  • A Careers::Job can stay posted up to 1 hour after its latest Careers::JobPosting.ends_at.
    • The Careers::Job is free for that hour, which is small enough to accept.

Which domain owns what​

Careers owns the price, the Careers::JobPosting, when a Careers::Job pays and when it closes, and Billing owns the credits.

DomainOwns
CareersThe price table, the Careers::JobPosting table, when a Careers::Job pays, when it closes, the ledger entry description, the trial gate, the company lock, and the status of the Careers::Job
BillingThe own account, the credit check, the direct consume, the lots and the ledger entry
ListingsNothing new, it keeps the public copy of the Careers::Job
  • The Careers job create and renew managers call Careers::JobPostings::Shared::CreateService.
    • No code creates a Careers::JobPosting row without it.
    • A row with no consume would be a period nobody paid.
  • Only Careers changes careers_jobs.status, so the close step lives in Careers.

Database​

The table careers_job_posting_prices is new, and it follows the table ads_placement_prices.

Table careers_job_posting_prices {
Note: 'The job postings a Careers job can buy. Sales edits them in the Team Portal. A job posting copies duration_days and unit_cost onto its careers_job_postings row, so a price change never changes a past job posting.'

id bigint [pk, increment]
uuid string [not null, unique, note: 'The public id. The employer endpoints name a price by it. The Team endpoints and the Team Portal page addresses use id.']

instrument string [not null, default: 'placement', note: 'The kind of credit that pays for this price. One value of billing_entitlements.instrument, with no foreign key. Careers passes it to Billing::SpendValidator and Billing::SpendService.consume_now. rails_enum(:placement)']

name string [not null, unique, note: 'e.g. "1 Month".']

duration_days integer [not null, note: 'The days one job posting lists the job. Greater than 0. e.g. 30.']
unit_cost integer [not null, note: 'The units of instrument one job posting consumes: credits for placement. Greater than 0.']

is_active boolean [not null, default: true, note: 'Only active prices show on the job form and the renew dialog.']

created_at timestamptz [not null]
updated_at timestamptz [not null]

indexes {
is_active
}
}

The table careers_job_postings is new, and each row is one paid period of one Careers::Job.

Table careers_job_postings {
Note: 'One job posting of one Careers job. A post creates the first row, and each renew creates one more. Each row is the deliverable of the consume ledger entry that pays for it (billing_ledger_entries.source_type = Careers::JobPosting). Rows are never updated or deleted.'

id bigint [pk, increment]
uuid string [not null, unique, note: 'The public id of the job posting.']
idempotency_key string [null, note: 'The key that the job form sends with a post, so one submit creates one job. Unique per company. Null for a renew.']

careers_job_id bigint [not null, ref: > careers_jobs.id]
org_company_id bigint [not null, ref: > org_companies.id, note: 'Copied from careers_jobs.org_company_id when the job posting is created. Cannot change, because the company of a paid job cannot change. It scopes idempotency_key to one company.']
careers_job_posting_price_id bigint [not null, ref: > careers_job_posting_prices.id, note: 'The price the company paid.']

created_by_type string [not null, note: 'Who created the job posting. Org::Membership for an HQ manager who posts or renews. Identities::Admin when a later phase lets an admin post or renew for a company. Polymorphic, like ads_campaigns.created_by_type.']
created_by_id bigint [not null]

duration_days_snapshot integer [not null, note: 'Copied from careers_job_posting_prices.duration_days when the job posting is created. Cannot change.']
unit_cost_snapshot integer [not null, note: 'Copied from careers_job_posting_prices.unit_cost when the job posting is created. Greater than 0. Cannot change.']

starts_at timestamptz [not null, note: 'The start of the period. Now for a post or the renew of an ended job. The latest ends_at of the job postings of the job, for the renew of a running job.']
ends_at timestamptz [not null, note: 'starts_at plus duration_days_snapshot days.']

created_at timestamptz [not null, note: 'When the job posting was created, which is when the job paid.']
updated_at timestamptz [not null]

indexes {
(careers_job_id, starts_at) [unique, note: 'Two periods of one job never start at the same moment.']
(org_company_id, idempotency_key) [unique, note: 'One submit of the job form creates one job per company. Renew rows have a null key, and PostgreSQL lets many rows share a null key.']
(careers_job_id, ends_at) [note: 'Finds the posting end of a job, for the open check, the renew and the hourly close job.']
careers_job_posting_price_id
(created_by_type, created_by_id)
}
}

The table careers_jobs gets no new column.

  • careers_jobs.status loses the value draft, and its default changes from 'draft' to 'open'.
  • Careers reads the end of a Careers::Job from its latest Careers::JobPosting.ends_at.
  • An existing Careers::Job has no Careers::JobPosting and no end, so no period rule applies to it.

All changes go in the file jodapp-api/docs/db/careers.dbml.

  • The model specs Careers::JobPostingPrice and Careers::JobPosting describe each new table.
  • The file adds no stub table for a Billing table, because no Careers column points into Billing.
  • Each ref: column gets a foreign key in the database, with the default delete rule.
    • None of the new columns needs a NO FOREIGN KEY: note, because each id comes from a row the app reads first.
    • created_by_type and created_by_id are polymorphic, so they have no ref: and no foreign key.
  • bin/dbml_check must report no difference for the new tables.
  • CHECK constraints: duration_days > 0 and unit_cost > 0 on the prices.
  • CHECK constraints on careers_job_postings:
    • ends_at > starts_at;
    • unit_cost_snapshot > 0.
  • careers_job_postings has a unique index on (org_company_id, idempotency_key), and idempotency_key is null for a renew.
    • The client makes the key, so the index is unique per company, not across all companies.
    • careers_job_postings.org_company_id is copied from careers_jobs.org_company_id, and it cannot change.
  • The index on careers_job_postings (careers_job_id, ends_at) serves Careers::Jobs::CloseJob.
  • The file jodapp-api/docs/db/billing.dbml names Careers::JobPosting in the note of billing_ledger_entries.source_type.
  • No column changes on listings_jobs or any Billing table.
  • careers_job_postings has no billing_account_id, because the consume ledger entry records the account that paid.

Backend​

Billing​

Careers calls two public Billing classes, and Billing gets no new method.

  • Billing::SpendValidator checks the credits before the transaction.
  • Billing::SpendService.consume_now pays for the Careers::JobPosting inside the transaction.
  • Billing interface for product domains states every rule of both classes.

consume_now takes the company and the deliverable, never an account or a source type.

# app/domains/careers/job_postings/shared/create_service.rb
::Billing::SpendService.consume_now(
org_company: careers_job.org_company,
instrument: careers_job_posting_price.instrument.to_sym,
units: careers_job_posting.unit_cost_snapshot,
deliverable: careers_job_posting,
description: format(
::Careers::JobPosting::BILLING_LEDGER_ENTRY_DESCRIPTIONS.fetch(:post),
job_title: careers_job.title,
price_name: careers_job_posting_price.name
)
)

These rules of consume_now shape the Careers code.

  • It finds the own account from org_company:.
  • It writes deliverable.class.name as the source type, so Careers adds nothing to Billing::LedgerEntry.
  • It holds the lock on the account's Billing::EntitlementBalance row.
  • It counts only the lots that are not past expires_at, soonest expires_at first.
  • It raises Billing::InsufficientCreditsError when those lots hold fewer than units, and the request ends with a 422.
  • It raises Errors::InternalServerError when units is 0 or less, so a price always costs more than 0.
  • It raises Errors::InternalServerError when no database transaction is open, so the caller opens it.
  • It raises Errors::InternalServerError for a second call with the same Careers::JobPosting, so one Careers::JobPosting is never paid twice.
    • Its idempotency key is consume_now_Careers::JobPosting_<id>.
  • It recognises revenue per lot, so a trial lot recognises SGD 0.
  • It copies description: into billing_ledger_entries.description, the line on the statement of account.

The model Careers::JobPosting holds the ledger entry text as a template constant.

# app/domains/careers/job_posting.rb
BILLING_LEDGER_ENTRY_DESCRIPTIONS = {
post: 'Job post: %{job_title}, %{price_name}',
renew: 'Job renew: %{job_title}, %{price_name}'
}.freeze
  • The post code and the renew code each pass their own key.
    • A careers_job_postings row does not say if it is a post or a renew.

The Careers job create and renew validators run Billing::SpendValidator and merge its errors.

# app/domains/careers/jobs/employers_create_validator.rb
def enough_placement_credits
billing_spend_validator = ::Billing::SpendValidator.new(
org_company: org_company,
instrument: careers_job_posting_price.instrument.to_sym,
units: careers_job_posting_price.unit_cost
)
errors.merge!(billing_spend_validator.errors) if billing_spend_validator.invalid?
end
  • Billing writes the error message under the key placement_credits, and Careers writes no message of its own.
  • The check runs before the transaction and takes no lock, so consume_now checks again under the lock.

The Careers::JobPosting create service​

The new service Careers::JobPostings::Shared::CreateService is the only way to create a Careers::JobPosting.

  • It takes careers_job:, careers_job_posting_price:, created_by:, description_key: and idempotency_key:.
    • description_key: is :post or :renew.
    • idempotency_key: is the key of the job form for a post, and nil for a renew.
  • It does not wrap its own transaction, so it joins the caller's transaction.

It runs these steps in order:

  1. It locks the careers_jobs row, so two calls for one Careers::Job run one after the other.
  2. It sets starts_at to the latest Careers::JobPosting.ends_at of the Careers::Job when that is in the future, and to now otherwise.
  3. It sets ends_at to starts_at plus duration_days days.
  4. It creates the Careers::JobPosting with created_by, both snapshots, starts_at and ends_at.
  5. It calls Billing::SpendService.consume_now with the company, the price's instrument, the snapshot cost, the Careers::JobPosting and the description.

Careers job managers​

Today the Careers job create saves the Careers::Job, syncs it and starts the trial in one transaction.

# app/domains/careers/jobs/employers_create_manager.rb:79-86 (feature/backend-billing-phase-3)
ActiveRecord::Base.transaction do
job.save!
::Careers::Jobs::SyncService.execute(careers_job: job)
::Org::Companies::TrialService.start_trial(
org_company: org_company,
careers_job: job
)
end

Today the Careers job update lets the employer set any status and any company.

# app/domains/careers/jobs/employers_update_manager.rb:54-56 (feature/backend-billing-phase-3)
job.assign_attributes(
org_company: org_company,
taxonomy_category: taxonomy_category,
PathFileChange
Price modelNew app/domains/careers/job_posting_price.rbCareers::JobPostingPrice
Careers::JobPosting modelNew app/domains/careers/job_posting.rbCareers::JobPosting, with BILLING_LEDGER_ENTRY_DESCRIPTIONS
Careers::JobPosting createNew app/domains/careers/job_postings/shared/create_service.rbWorks out the period, creates the Careers::JobPosting and calls Billing::SpendService.consume_now
Prices for SalesNew app/domains/careers/job_posting_prices/team_*Create, show, update, activate, deactivate and index
Prices for employersNew app/domains/careers/job_posting_prices/employers_index_*Lists the active prices
Careers::Job modelapp/domains/careers/job.rbhas_many :job_postings, with class_name: 'Careers::JobPosting' and foreign_key: :careers_job_id, and no draft in the status enum
Job create requestapp/domains/careers/jobs/employers_create_request.rbAccepts careers_job_posting_price_uuid, and requires idempotency_key
Job create validatorapp/domains/careers/jobs/employers_create_validator.rbChecks the price is active, and runs Billing::SpendValidator
Job create managerapp/domains/careers/jobs/employers_create_manager.rbAnswers a repeated idempotency_key of the same company with the first job, by (org_company_id, idempotency_key) and before the validator, then calls Careers::JobPostings::Shared::CreateService inside the transaction
Job update validatorapp/domains/careers/jobs/employers_update_validator.rbBlocks status: open or hidden when the period has ended or an existing Careers::Job is closed, and blocks every company change
Job renewNew app/domains/careers/jobs/employers_renew_*Fails first for a Careers::Job with no Careers::JobPosting, then checks the trial gate, the price and the credits, compares the count of Careers::JobPosting rows under the row lock, then calls Careers::JobPostings::Shared::CreateService and opens an ended Careers::Job
Price seedNew db/seeds/singles/<timestamp>_seed_careers_job_posting_prices.rbCreates "1 Month" and "3 Months" when they are missing, and never changes a price that exists
Free creditsA new Billing service, a rake task and the sign-up pathGrants free placement credits for one Careers::JobPosting, as Free credits for each company says
Close ended Careers jobsNew app/domains/careers/jobs/close_job.rbHourly in sidekiq-scheduler, locks each Careers::Job, checks its latest Careers::JobPosting.ends_at again, closes it and syncs it to Listings
Job serializersapp/domains/careers/employers_job_detail_serializer.rb, employers_job_list_serializer.rbAdd posting_ends_at and the count of Careers::JobPosting rows, which the manager loads, so the serializer runs no query
Team Careers::JobPosting showNew app/domains/careers/job_postings/team_show_*Returns one Careers::JobPosting with the slug of its Careers::Job
Team Careers job showNew app/domains/careers/jobs/team_show_*Returns one Careers::Job with its Careers::JobPosting rows and its latest Careers::JobPosting.ends_at

Team Portal​

Sales manages Careers::JobPostingPrice rows on new pages, built like the Team billing product pages.

  • The list page shows every Careers::JobPostingPrice with its name, days, credit cost and active state.
  • The detail page shows one price, with an "Edit" button and an "Activate" or "Deactivate" button.
  • Sales creates and edits a price on a form with name, duration_days and unit_cost.
  • A Team price response holds id, name, duration_days, unit_cost, instrument and is_active.
  • When Sales deactivates every price, the job form shows the message "Posting a job is not available right now. Please contact Jod support."
  • Editing a price changes only future Careers::JobPosting rows.

The routes live under Careers.

The ledger list shows the description of a Careers::JobPosting entry in the source cell, like an Ads placement.

  • The source cell shows the text that Careers passed, such as "Job post: Barista, 1 Month".
  • jod-app/jodapp-web#1535 shows the description for an Ads placement, so this change builds on it.
  • The text links to a new Team Portal page for the Careers job, as Ali ruled on 2026-11-13.

The Careers job page​

Finance and Sales open one Careers job in the Team Portal, with its Careers::JobPosting rows.

  • The page is read-only, and it is the most minimal page that the ledger link needs.
  • Its path is /team/careers/jobs/<slug>, where the slug is careers_jobs.slug, such as acme/hq/barista-weekends-1a2b3c4d.
  • The "Jobs" entry of the Team sidebar stays disabled, because there is no list page.
  • Tools for Sales to post, renew or close a job for a company are outside this phase.

The page shows the Careers::Job and one table of its Careers::JobPosting rows.

PartFields
The Careers::JobTitle, company, status, latest Careers::JobPosting.ends_at
One row per Careers::JobPostingstarts_at, ends_at, price name, unit_cost_snapshot, created_by

The ledger reaches the page through a deliverable route, like an Ads placement.

  • Billing stores which record caused a spend, not which page shows it.
  • So the ledger links to /team/careers/job-postings/<id>, with the Careers::JobPosting id from source_id.
  • That route reads the Careers::JobPosting, and redirects to the page of its Careers::Job.
  • The Ads route /team/ads/campaign-placements/<id> works the same way, and redirects to the Team campaign page.

Legend: grey = a jodapp-web page or route, lavender = a jodapp-api endpoint.

RoutePurpose
GET /team/careers/job_posting_pricesList every Careers price
POST /team/careers/job_posting_pricesCreate a Careers price
GET /team/careers/job_posting_prices/:idShow one price
PATCH /team/careers/job_posting_prices/:idEdit one price
PATCH /team/careers/job_posting_prices/:id/activateShow the price on the job form
PATCH /team/careers/job_posting_prices/:id/deactivateRemove the price from the job form
GET /team/careers/job_postings/:idShow one Careers::JobPosting with the slug of its Careers::Job, for the deliverable route
GET /team/careers/jobs/*slugShow one Careers job with its Careers::JobPosting rows, for the Careers job page

Employer Dashboard​

The job form shows the periods, the cost and the balance before the HQ manager posts.

  • The form reads the active prices from GET /employers/careers/job_posting_prices.
  • The form reads the balance from GET /employers/billing/entitlement-balances, which exists.
  • The HQ manager picks one period, and the form sends careers_job_posting_price_uuid.
  • The form makes one idempotency_key when it opens, and sends it with the post.
  • The form shows the cost, the balance and "Posted until" with the end date.
  • The submit button opens a confirm dialog with the cost and the end date.
  • When the balance is lower than the cost, the form shows the "Insufficient Placement Credits" alert and disables the submit.
    • The alert is the same as on the employer Ads campaign page.
    • Its WhatsappButton says "Chat with us to top up credits".
    • The WhatsApp message names the cost of the Careers::JobPosting and the balance.

The job list and the job page show the period.

  • Each Careers::Job shows "Posted until" with posting_ends_at, or "Posting ended" when it is in the past.
    • An existing Careers::Job has posting_ends_at: null, and it shows neither text.
  • Each Careers::Job with a Careers::JobPosting has a "Renew" button, which opens the renew dialog.
  • An existing Careers::Job shows the renew button as disabled, with the text "Cannot renew".
    • The web reads posting_ends_at: null for this, so the API adds no field for it.
  • The job edit form and the job filter no longer offer "Draft", because careers_jobs.status has no draft value.
    • CAREERS_JOB_STATUS in app/domains/careers-job/careers-job-constant.js loses its draft entry.
  • The job edit form shows the company of the Careers::Job as read-only, because a Careers::Job never changes company.
    • The job create form still lets a parent HQ manager pick a child company.
  • The renew dialog shows the periods, the cost, the balance and the new end date.
  • The renew dialog sends the count of Careers::JobPosting rows that the job detail returned.
  • The renew dialog shows the same alert and WhatsApp button when credits are too low.

The renew endpoint is new.

RoutePurpose
POST /employers/careers/jobs/*slug/renewBuy a new period with careers_job_posting_price_uuid and job_postings_count

The mock-up shows the job form, the confirm dialog and the renew.

Careers job credit cost mock-up

Free credits for each company​

Every company with careers_access_status: :trial or :allowed gets free placement credits for one Careers::JobPosting.

  • The credits pay one Careers::JobPosting of 1 month, which costs 50 credits.
  • A company with careers_access_status: :blocked gets none, because it already used its trial.
  • A rake task creates one Billing::CreditAction with the free credits for each existing company.
    • It runs in the same deploy as Billing Phase 3.2, with a dry run first.
  • A new company gets one Billing::CreditAction with the same credits when it signs up.
  • Each Billing::CreditAction has these values:
    • action_type: :trial_grant;
    • admin_created_by_id: the Identities::Admin named System;
    • reason: "Sign up free credits".
  • Most other job boards give one free post, so the free credits pay for one post.
  • Alvin suggests that the credits last 2 weeks or 1 month, and work on Ads too.
    • Alvin picks 2 weeks or 1 month after he sees how many applicants a job gets in each.
  • Still open for Ali:
    • when the credits expire;
    • whether companies synced from JodGig get them;
    • which paths count as a sign-up.

Rejected options​

  • One payment per Careers::Job, with no end date.
    • It lost, because one payment could keep a Careers::Job open for years.
    • An employer could also edit a Careers::Job that was paid once into a different job, and never pay again.
    • Marketing decided prices per period, so the period is part of the product.
  • Spread the revenue over the period, like an Ads campaign.
    • It lost for this phase, because it needs a reserve and a daily consume per Careers::Job.
    • The direct consume recognises the whole cost on the day the company pays.
    • A renew also recognises its whole cost on the renew day, before its period starts.
  • A column careers_jobs.listing_ends_at that copies the latest Careers::JobPosting.ends_at onto the Careers::Job.
    • It lost, because Ali ruled on 2026-11-16 to drop it.
    • A copy on the Careers::Job can disagree with its Careers::JobPosting rows.
    • An existing Careers::Job has no end date, so the column has nothing to hold.
  • A free Careers::JobPosting for each existing Careers::Job, from a task that runs when Billing Phase 3.2 ships.
    • It lost, because Billing D18 says that no product costs 0 credits.
    • It also needs a Careers::JobPosting with no price, and a second way to create a Careers::JobPosting.
  • Goodwill credits for each company, then a paid Careers::JobPosting for each existing Careers::Job.
    • It lost, because Ali would rather not backfill, unless a backfill is simple and does not affect Billing.
  • An end date for existing Careers::Job rows, on the day Billing Phase 3.2 ships or some days after it.
    • It lost for now, because the existing Careers::Job rows are all the jobs that a candidate can find today.
    • Ali sets the end date later.
  • A renew only after the period ends.
    • It lost, because the Careers::Job would close between the end and the renew.
    • Applicants could not see the job during that gap.
  • Generic tables in the Listings domain, listings_job_posting_prices and listings_job_postings, with a polymorphic job.
    • It lost, because Careers is the only product that sells a job post.
    • Careers owns Careers::Job, so it also owns when and how much a post costs.
    • A polymorphic job has no foreign key to careers_jobs.
  • One generic table for paid periods in the Billing domain.
    • It lost, because each product owns its own price list and deliverable, as Ads does.
    • Billing owns only the ledger.
  • One number in an app setting would hold the price of a Careers::JobPosting.
    • It lost, because Sales cannot change it without an engineer.
    • A price table also keeps the old prices, which past Careers::JobPosting rows point at.
  • A modal that opens on submit when credits are too low.
    • It lost, because the Ads campaign page already shows an inline alert with a WhatsApp button.
  • A Billing::Product would hold the Careers::JobPostingPrice.
    • It lost, because a product is what Jod sells for money.
    • A Careers::JobPostingPrice is what a company spends in credits.
  • A payment each time the Careers::Job opens.
    • It lost, because hiding a job and showing it again would cost credits.
  • Each Careers job manager creates the Careers::JobPosting row by itself.
    • It lost, because a Careers::JobPosting row and its consume must be written together.
    • The create and the renew managers would both repeat those steps.
  • Two renews at the same moment both pay.
    • It lost, because a double click would buy a second period, and closing a Careers::Job gives no credits back.
  • An idempotency key for the renew.
    • It lost, because two HQ managers send two keys, and the count of Careers::JobPosting rows stops both cases.
  • A unique index on careers_job_postings.idempotency_key across all companies.
    • It lost, because the client makes the key, and one company's key could then block a post of another company.
  • A renew for an existing Careers::Job, whose first Careers::JobPosting starts now.
    • It lost, because the ledger would show a "Job renew" entry with no "Job post" entry before it.
    • An existing Careers::Job then stays fully outside Billing.
  • A renew that opens a closed existing Careers::Job again.
    • It lost, because closed is the end state of an existing Careers::Job.
    • A new hire goes through the paid post.

Out of scope​

  • Team Portal tools for Sales to post, renew or close a Careers job for a company.
    • Ali ruled on 2026-11-13 that this is handled outside this phase.
    • This phase adds only the read-only Careers job page that the ledger link needs.
  • A second product that sells a job post, such as Gig.
    • Gig shifts already pay wages and a fee per shift through gig credits, which is not a job post price.
  • Replacing the trial period with trial credits, and removing the trial gate.
    • The next phase does it, after Billing Phase 3.2.
    • Every Phase 3 step merges into the Phase 3 feature branch and goes to production together.
    • The free credits of Free credits for each company are part of this phase.
  • An end date for existing Careers::Job rows.
    • Ali sets it later.
  • A blurred job page with a pop-up of the credit packages and the Sales contact, when credits are too low.
    • Alvin suggests it as a later change to the WhatsApp alert.
    • It needs a design and the package prices first.
  • New prices for Ads placements.
  • A price that changes with the employment type or for a featured listing.
  • A reminder to the employer before the period ends.
  • A credit refund when a Careers::Job closes.
  • A price per company.
    • A later phase can read a Billing::AgreementTerm with term_key: :unit_price for the placement entitlement.
  • Featured or boosted Careers jobs.
  • A Slack alert to Sales before credits expire.
  • The Xero mapping for Careers revenue, which Billing Phase 4 — Xero Integration owns.

Rollout​

Existing records​

RecordWhat the rollout does
A Careers::Job with status: :open or :hidden on the day Billing Phase 3.2 shipsNothing, so it is an existing Careers::Job with no Careers::JobPosting and no end date
A Careers::Job with status: :closed on the day Billing Phase 3.2 shipsNothing, so it is an existing Careers::Job that stays closed: it cannot open, hide or renew
A Careers::Job with status: :draft on the day Billing Phase 3.2 shipsNone exists, so the migration only changes the default of careers_jobs.status to 'open'
A company with careers_access_status: :blockedNothing, it still cannot post or renew, and it gets no free credits
A company with careers_access_status: :trial or :allowedA rake task creates one Billing::CreditAction with free credits for one Careers::JobPosting

Existing Careers::Job rows stay as they are after Billing Phase 3.2 ships.

  • An existing Careers::Job has no Careers::JobPosting, and Careers::Jobs::CloseJob selects only a Careers::Job that has one.
  • So shipping Billing Phase 3.2 needs no task and no backfill for existing Careers::Job rows.
  • An existing Careers::Job stays open with no end date, until its HQ manager closes it.
  • Some existing Careers::Job rows belong to companies that paid Sales by invoice, and they get no backfill either.

At least one active Careers::JobPostingPrice must exist before Billing Phase 3.2 ships.

  • The deploy runs the price seed file in each environment.
    • It creates "1 Month" for 50 credits and "3 Months" for 100 credits.
    • Sales practises entering and editing prices in QA.
  • Otherwise every post fails with "Posting a job is not available right now. Please contact Jod support."

Dry run​

Phase 3.2 changes no existing Careers::Job, and only the rake task of the free credits writes to existing companies.

  • Before Billing Phase 3.2 ships, a person counts the open and the hidden Careers::Job rows.
    • Careers had 133 open jobs and 1 hidden job on 2026-11-17.
  • Just before the deploy, a person checks by hand that production has no draft Careers::Job row.
  • The rake task of the free credits has a dry run, which a person reads before the live run.

After Billing Phase 3.2 ships​

A person reads the same counts on the day after Billing Phase 3.2 ships.

  • Every existing Careers::Job that was open or hidden is still open or hidden, unless its HQ manager closed it.
  • Careers::Jobs::CloseJob has closed no Careers::Job that has no Careers::JobPosting.
  • Every Careers::Job posted after Billing Phase 3.2 ships has one Careers::JobPosting and one consume ledger entry per period.

Open questions​

  1. The end date for existing Careers::Job rows. When do existing Careers::Job rows close? (Ali)
    • Ali sets the date later.
  2. The free credits. When do they expire, and which companies get them on sign-up? (Ali)
    • The open cases are companies synced from JodGig, and the paths that count as a sign-up.
    • Ali ruled the number, the System admin, the reason text, and that a blocked company gets none.