Design Plan: a Careers job consumes placement credits
TL;DR
- Posting a
Careers::Jobbuys aCareers::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::Jobstays posted until the latestCareers::JobPosting.ends_atof theCareers::Job, and then the system closes it.- The employer can close, hide and open the
Careers::Jobagain for free during the period. - The employer renews the
Careers::Jobto buy a new period, before or after it ends.
- The employer can close, hide and open the
- The consume is direct, with no reserve, and it recognises the whole cost on the day the company pays.
- The price and the
Careers::JobPostinglive in the Careers domain, in the new tablescareers_job_posting_pricesandcareers_job_postings.- Careers reads the end of a
Careers::Jobfrom its latestCareers::JobPosting.ends_at, socareers_jobsgets no new column.
- Careers reads the end of a
- Careers pays through the Billing interface:
Billing::SpendValidatorto check, andBilling::SpendService.consume_nowto pay. - An existing
Careers::Job, created before Billing Phase 3.2 ships, has noCareers::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
closedis 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::Jobearly 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
| Word | Meaning |
|---|---|
The model Careers::Job | One job that an Org::Company posts on Careers, in the table careers_jobs |
The model Careers::JobPostingPrice | One 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::JobPosting | One paid period of one Careers::Job, from starts_at to ends_at, in the new table careers_job_postings |
Existing Careers::Job | A Careers::Job created before Billing Phase 3.2 ships, which has no Careers::JobPosting |
| Renew | A new Careers::JobPosting that a Careers::Job buys after it is posted |
| Direct consume | A consume ledger entry that takes units from available credits, with no reserve before it |
The class Billing::SpendService | The public Billing class that writes a spend, which Careers calls with consume_now |
The class Billing::SpendValidator | The public Billing class that checks a spend before the transaction |
| Own account | The Billing::Account whose billing_accounts.org_company_id is the company of the Careers::Job |
| HQ manager | A 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::Jobstays 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::JobPostingof eachCareers::Job.
Worked example: Acme today
- Acme Pte Ltd signs up and posts a Barista job on 1 March.
- The trial starts, and Acme posts 4 more jobs during the month for free.
- On 1 April the trial ends, and Acme cannot post or see applicant details.
- Sales sends a manual invoice for SGD 99 per job and unblocks Acme by hand.
- The Barista job is still open a year later, with no new payment.
- 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.
- Phase 3 built grant, reserve, consume, release and expire.
- An Ads campaign reserves credits on submit and consumes them day by day.
- Billing D5 — Spending mechanics: instant delivery consumes directly says a Careers post consumes directly, with no reserve.
- Billing D12 — A running service cannot be cancelled says a Careers post gives no credits back.
A product domain spends credits only through the Billing interface.
- Billing D18 — Product domains spend credits only through SpendService holds the rules.
- Billing interface for product domains shows the Careers call.
- Careers names only two Billing classes:
Billing::SpendServiceandBilling::SpendValidator.
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_jobsholds 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::JobPostingbelong to Careers, next tocareers_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.
| Price | Days | Credits |
|---|---|---|
| 1 Month | 30 | 50 |
| 3 Months | 90 | 100 |
Alvin compared them with other Singapore job boards.
| Job board | Price |
|---|---|
| FastJobs | SGD 120 per post per month |
| JobStreet | About SGD 100 to SGD 500 per month |
| Indeed | Pay per view, per click or per application |
| MyCareersFuture | Free, 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
| Rule | Applies to | Example |
|---|---|---|
Posting a Careers::Job pays the picked price from the own account of its company | US-1 | Acme posts a Barista job for 1 month and pays 50 credits |
Each Careers::JobPosting lasts the price's number of days | US-1 | A Careers::JobPosting bought on 14 Oct for 1 month ends on 13 Nov |
A Careers::Job consumes directly from available credits and reserves nothing | always | The ledger has one consume entry and no reserve entry for the Careers::JobPosting |
| The consume recognises the whole cost on the day the company pays | always | Acme 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 later | US-6 | Acme 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 lots | always | A 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 created | US-3 | Sales changes "1 Month" to 60 credits, and Acme's Careers::JobPosting still says 50 |
The Careers::JobPosting stores who created it | always | Acme'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 future | always | Acme 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 period | US-2 | Acme hides the Barista job on 20 Oct and opens it again on 25 Oct |
Hiding or closing a Careers::Job does not pause its period | always | Acme 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 ends | always | On 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_at | US-6 | Acme 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 it | always | Acme'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 times | US-2 | Acme hides its Cashier job, an existing Careers::Job, and opens it again, and pays nothing |
An existing Careers::Job never gets a renew | US-6 | Acme'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::Job | US-6 | Acme 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 renew | US-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 again | US-2 | Acme 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 active | US-3 | "Posting a job is not available right now. Please contact Jod support." |
| The form lists every active price, and the employer picks one | US-1 | The form shows "1 Month, 50 credits" and "3 Months, 100 credits" |
| A price always costs more than 0 credits | always | careers_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 renew | US-5 | Acme 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 low | US-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 renew | always | "Company trial period has ended, please contact sales for assistance" |
A company with careers_access_status: :trial or :allowed pays credits | always | A new company in trial pays its first Careers::JobPosting with trial credits |
Closing a Careers::Job gives no credits back | always | Acme closes the Barista job on 20 Oct, and the 50 credits stay consumed |
A Careers::Job never changes company | always | Acme 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 account | always | FairPrice 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 entry | US-4 | Acme's post and renew are 2 Careers::JobPosting rows and 2 entries |
| A seed file creates "1 Month" and "3 Months" before any company posts | always | On 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::JobPosting | always | Acme gets 50 placement credits from a Billing::CreditAction of the System admin |
One Careers::JobPosting is never paid twice | always | A 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 most | US-1 | A second request with the same idempotency key gets the first Careers::Job back, and pays nothing |
| The idempotency key is unique per company | always | Acme and Bistro send the same key, and each gets its own Careers::Job |
| A post with no idempotency key fails | US-1 | A request with no key gets a 422, and creates nothing |
| One renew dialog buys one period at most | US-6 | Two 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 price | always | careers_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::Jobworks as it does today. - When the period ends, the system closes the
Careers::Job. - The employer renews the
Careers::Jobto buy a new period.
Worked example: Acme, after the change
- A seed file creates the prices "1 Month" for 50 credits and "3 Months" for 100 credits.
- Acme has 170 placement credits.
- 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".
- The HQ manager posts the Barista job and confirms the cost.
- The system creates the
Careers::Jobwithstatus: :open. - The system creates
Careers::JobPosting#1 withstarts_at: 14 Octandends_at: 13 Nov. - Billing writes one
consumeledger entry of 50 credits, with the text "Job post: Barista, 1 Month". - Acme has 120 credits left.
- The system creates the
- 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.
- 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_atbecomes 11 Feb. - Acme has 20 credits left.
- On 11 Feb,
Careers::Jobs::CloseJobsets the Barista job tostatus: :closed. - 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."
- 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.
| Request | State of the Careers::Job before the request | New Careers::JobPosting | Period |
|---|---|---|---|
| Post | New Careers::Job | Yes | From now |
| Renew | Latest Careers::JobPosting.ends_at in the future | Yes | From that ends_at |
| Renew | Latest Careers::JobPosting.ends_at in the past | Yes, and the Careers::Job opens | From now |
| Renew | An existing Careers::Job, with no Careers::JobPosting | Fails, an existing Careers::Job never renews | No period |
| Close, hide or open | Latest Careers::JobPosting.ends_at in the future | None | No change |
| Open | Latest Careers::JobPosting.ends_at in the past | Fails, the employer must renew | No change |
| Hide or open | An existing Careers::Job that is open or hidden | None, any number of times | No period |
| Hide or open | An existing Careers::Job that is closed | Fails, closed is its end state | No period |
| Edit fields | Any | None | No change |
careers_jobs.statushas three values:open,hiddenandclosed.- A
Careers::Jobupdate never pays, so only the post and the renew endpoints callCareers::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::Jobrows withstatusopenorhiddenwhose latestCareers::JobPostinghasends_atin the past.- An existing
Careers::Jobhas noCareers::JobPosting, so the query never selects it.
- An existing
- For each
Careers::Job, it locks thecareers_jobsrow and reads the latestCareers::JobPosting.ends_atagain.- It closes the
Careers::Jobonly when thatends_atis still in the past. - So a renew that commits after the query never sees its
Careers::Jobclosed.
- It closes the
- It sets each
Careers::Jobtostatus: :closed. - It syncs each
Careers::Jobto Listings withCareers::Jobs::SyncService, so anopenCareers::Jobleaves the job search. - A
Careers::Jobcan stay posted up to 1 hour after its latestCareers::JobPosting.ends_at.- The
Careers::Jobis free for that hour, which is small enough to accept.
- The
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.
| Domain | Owns |
|---|---|
| Careers | The 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 |
| Billing | The own account, the credit check, the direct consume, the lots and the ledger entry |
| Listings | Nothing 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::JobPostingrow without it. - A row with no consume would be a period nobody paid.
- No code creates a
- 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.statusloses the valuedraft, and its default changes from'draft'to'open'.- Careers reads the end of a
Careers::Jobfrom its latestCareers::JobPosting.ends_at. - An existing
Careers::Jobhas noCareers::JobPostingand 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::JobPostingPriceandCareers::JobPostingdescribe each new table. - The file adds no stub table for a Billing table, because no Careers column points into Billing.
careers_job_posting_prices.instrumentnames the Billing credit as a string, as Billing D18 — Product domains spend credits only through SpendService asks.
- 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_typeandcreated_by_idare polymorphic, so they have noref:and no foreign key.
- None of the new columns needs a
bin/dbml_checkmust report no difference for the new tables.- CHECK constraints:
duration_days > 0andunit_cost > 0on the prices. - CHECK constraints on
careers_job_postings:ends_at > starts_at;unit_cost_snapshot > 0.
careers_job_postingshas a unique index on(org_company_id, idempotency_key), andidempotency_keyis 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_idis copied fromcareers_jobs.org_company_id, and it cannot change.
- The index on
careers_job_postings (careers_job_id, ends_at)servesCareers::Jobs::CloseJob. - The file
jodapp-api/docs/db/billing.dbmlnamesCareers::JobPostingin the note ofbilling_ledger_entries.source_type. - No column changes on
listings_jobsor any Billing table. careers_job_postingshas nobilling_account_id, because theconsumeledger entry records the account that paid.
Backend
Billing
Careers calls two public Billing classes, and Billing gets no new method.
Billing::SpendValidatorchecks the credits before the transaction.Billing::SpendService.consume_nowpays for theCareers::JobPostinginside 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.nameas the source type, so Careers adds nothing toBilling::LedgerEntry. - It holds the lock on the account's
Billing::EntitlementBalancerow. - It counts only the lots that are not past
expires_at, soonestexpires_atfirst. - It raises
Billing::InsufficientCreditsErrorwhen those lots hold fewer thanunits, and the request ends with a 422. - It raises
Errors::InternalServerErrorwhenunitsis 0 or less, so a price always costs more than 0. - It raises
Errors::InternalServerErrorwhen no database transaction is open, so the caller opens it. - It raises
Errors::InternalServerErrorfor a second call with the sameCareers::JobPosting, so oneCareers::JobPostingis never paid twice.- Its idempotency key is
consume_now_Careers::JobPosting_<id>.
- Its idempotency key is
- It recognises revenue per lot, so a trial lot recognises SGD 0.
- It copies
description:intobilling_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_postingsrow does not say if it is a post or a renew.
- A
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_nowchecks 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:andidempotency_key:.description_key:is:postor:renew.idempotency_key:is the key of the job form for a post, andnilfor a renew.
- It does not wrap its own transaction, so it joins the caller's transaction.
It runs these steps in order:
- It locks the
careers_jobsrow, so two calls for oneCareers::Jobrun one after the other. - It sets
starts_atto the latestCareers::JobPosting.ends_atof theCareers::Jobwhen that is in the future, and to now otherwise. - It sets
ends_attostarts_atplusduration_daysdays. - It creates the
Careers::JobPostingwithcreated_by, both snapshots,starts_atandends_at. - It calls
Billing::SpendService.consume_nowwith the company, the price'sinstrument, the snapshot cost, theCareers::JobPostingand 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,
| Path | File | Change |
|---|---|---|
| Price model | New app/domains/careers/job_posting_price.rb | Careers::JobPostingPrice |
Careers::JobPosting model | New app/domains/careers/job_posting.rb | Careers::JobPosting, with BILLING_LEDGER_ENTRY_DESCRIPTIONS |
Careers::JobPosting create | New app/domains/careers/job_postings/shared/create_service.rb | Works out the period, creates the Careers::JobPosting and calls Billing::SpendService.consume_now |
| Prices for Sales | New app/domains/careers/job_posting_prices/team_* | Create, show, update, activate, deactivate and index |
| Prices for employers | New app/domains/careers/job_posting_prices/employers_index_* | Lists the active prices |
Careers::Job model | app/domains/careers/job.rb | has_many :job_postings, with class_name: 'Careers::JobPosting' and foreign_key: :careers_job_id, and no draft in the status enum |
| Job create request | app/domains/careers/jobs/employers_create_request.rb | Accepts careers_job_posting_price_uuid, and requires idempotency_key |
| Job create validator | app/domains/careers/jobs/employers_create_validator.rb | Checks the price is active, and runs Billing::SpendValidator |
| Job create manager | app/domains/careers/jobs/employers_create_manager.rb | Answers 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 validator | app/domains/careers/jobs/employers_update_validator.rb | Blocks status: open or hidden when the period has ended or an existing Careers::Job is closed, and blocks every company change |
| Job renew | New 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 seed | New db/seeds/singles/<timestamp>_seed_careers_job_posting_prices.rb | Creates "1 Month" and "3 Months" when they are missing, and never changes a price that exists |
| Free credits | A new Billing service, a rake task and the sign-up path | Grants free placement credits for one Careers::JobPosting, as Free credits for each company says |
| Close ended Careers jobs | New app/domains/careers/jobs/close_job.rb | Hourly in sidekiq-scheduler, locks each Careers::Job, checks its latest Careers::JobPosting.ends_at again, closes it and syncs it to Listings |
| Job serializers | app/domains/careers/employers_job_detail_serializer.rb, employers_job_list_serializer.rb | Add posting_ends_at and the count of Careers::JobPosting rows, which the manager loads, so the serializer runs no query |
Team Careers::JobPosting show | New app/domains/careers/job_postings/team_show_* | Returns one Careers::JobPosting with the slug of its Careers::Job |
| Team Careers job show | New 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::JobPostingPricewith 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_daysandunit_cost. - A Team price response holds
id,name,duration_days,unit_cost,instrumentandis_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::JobPostingrows.
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 iscareers_jobs.slug, such asacme/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.
| Part | Fields |
|---|---|
The Careers::Job | Title, company, status, latest Careers::JobPosting.ends_at |
One row per Careers::JobPosting | starts_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 theCareers::JobPostingid fromsource_id. - That route reads the
Careers::JobPosting, and redirects to the page of itsCareers::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.
| Route | Purpose |
|---|---|
GET /team/careers/job_posting_prices | List every Careers price |
POST /team/careers/job_posting_prices | Create a Careers price |
GET /team/careers/job_posting_prices/:id | Show one price |
PATCH /team/careers/job_posting_prices/:id | Edit one price |
PATCH /team/careers/job_posting_prices/:id/activate | Show the price on the job form |
PATCH /team/careers/job_posting_prices/:id/deactivate | Remove the price from the job form |
GET /team/careers/job_postings/:id | Show one Careers::JobPosting with the slug of its Careers::Job, for the deliverable route |
GET /team/careers/jobs/*slug | Show 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_keywhen 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
WhatsappButtonsays "Chat with us to top up credits". - The WhatsApp message names the cost of the
Careers::JobPostingand the balance.
The job list and the job page show the period.
- Each
Careers::Jobshows "Posted until" withposting_ends_at, or "Posting ended" when it is in the past.- An existing
Careers::Jobhasposting_ends_at: null, and it shows neither text.
- An existing
- Each
Careers::Jobwith aCareers::JobPostinghas a "Renew" button, which opens the renew dialog. - An existing
Careers::Jobshows the renew button as disabled, with the text "Cannot renew".- The web reads
posting_ends_at: nullfor this, so the API adds no field for it.
- The web reads
- The job edit form and the job filter no longer offer "Draft", because
careers_jobs.statushas nodraftvalue.CAREERS_JOB_STATUSinapp/domains/careers-job/careers-job-constant.jsloses itsdraftentry.
- The job edit form shows the company of the
Careers::Jobas read-only, because aCareers::Jobnever 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::JobPostingrows 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.
| Route | Purpose |
|---|---|
POST /employers/careers/jobs/*slug/renew | Buy 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.
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::JobPostingof 1 month, which costs 50 credits. - A company with
careers_access_status: :blockedgets none, because it already used its trial. - A rake task creates one
Billing::CreditActionwith 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::CreditActionwith the same credits when it signs up. - Each
Billing::CreditActionhas these values:action_type: :trial_grant;admin_created_by_id: theIdentities::AdminnamedSystem;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::Jobopen for years. - An employer could also edit a
Careers::Jobthat was paid once into a different job, and never pay again. - Marketing decided prices per period, so the period is part of the product.
- It lost, because one payment could keep a
- 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.
- It lost for this phase, because it needs a reserve and a daily consume per
- A column
careers_jobs.listing_ends_atthat copies the latestCareers::JobPosting.ends_atonto theCareers::Job.- It lost, because Ali ruled on 2026-11-16 to drop it.
- A copy on the
Careers::Jobcan disagree with itsCareers::JobPostingrows. - An existing
Careers::Jobhas no end date, so the column has nothing to hold.
- A free
Careers::JobPostingfor each existingCareers::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::JobPostingwith no price, and a second way to create aCareers::JobPosting.
- Goodwill credits for each company, then a paid
Careers::JobPostingfor each existingCareers::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::Jobrows, on the day Billing Phase 3.2 ships or some days after it.- It lost for now, because the existing
Careers::Jobrows are all the jobs that a candidate can find today. - Ali sets the end date later.
- It lost for now, because the existing
- A renew only after the period ends.
- It lost, because the
Careers::Jobwould close between the end and the renew. - Applicants could not see the job during that gap.
- It lost, because the
- Generic tables in the Listings domain,
listings_job_posting_pricesandlistings_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::JobPostingrows 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::Productwould hold theCareers::JobPostingPrice.- It lost, because a product is what Jod sells for money.
- A
Careers::JobPostingPriceis what a company spends in credits.
- A payment each time the
Careers::Jobopens.- It lost, because hiding a job and showing it again would cost credits.
- Each Careers job manager creates the
Careers::JobPostingrow by itself.- It lost, because a
Careers::JobPostingrow and its consume must be written together. - The create and the renew managers would both repeat those steps.
- It lost, because a
- Two renews at the same moment both pay.
- It lost, because a double click would buy a second period, and closing a
Careers::Jobgives no credits back.
- It lost, because a double click would buy a second period, and closing a
- An idempotency key for the renew.
- It lost, because two HQ managers send two keys, and the count of
Careers::JobPostingrows stops both cases.
- It lost, because two HQ managers send two keys, and the count of
- A unique index on
careers_job_postings.idempotency_keyacross 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 firstCareers::JobPostingstarts now.- It lost, because the ledger would show a "Job renew" entry with no "Job post" entry before it.
- An existing
Careers::Jobthen stays fully outside Billing.
- A renew that opens a closed existing
Careers::Jobagain.- It lost, because
closedis the end state of an existingCareers::Job. - A new hire goes through the paid post.
- It lost, because
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::Jobrows.- 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.
- Alvin suggested new prices per day, per week and per month, in Ads Domain Overview — Prices that Marketing suggested.
- Sales enters them in the Team Portal, so they need no code change.
- 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::Jobcloses.- Billing D12 — A running service cannot be cancelled still applies to Careers jobs.
- A price per company.
- A later phase can read a
Billing::AgreementTermwithterm_key: :unit_pricefor the placement entitlement.
- A later phase can read a
- 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
| Record | What the rollout does |
|---|---|
A Careers::Job with status: :open or :hidden on the day Billing Phase 3.2 ships | Nothing, 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 ships | Nothing, 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 ships | None exists, so the migration only changes the default of careers_jobs.status to 'open' |
A company with careers_access_status: :blocked | Nothing, it still cannot post or renew, and it gets no free credits |
A company with careers_access_status: :trial or :allowed | A 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::Jobhas noCareers::JobPosting, andCareers::Jobs::CloseJobselects only aCareers::Jobthat has one. - So shipping Billing Phase 3.2 needs no task and no backfill for existing
Careers::Jobrows. - An existing
Careers::Jobstays open with no end date, until its HQ manager closes it. - Some existing
Careers::Jobrows 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::Jobrows.- 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::Jobrow. - 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::Jobthat was open or hidden is still open or hidden, unless its HQ manager closed it. Careers::Jobs::CloseJobhas closed noCareers::Jobthat has noCareers::JobPosting.- Every
Careers::Jobposted after Billing Phase 3.2 ships has oneCareers::JobPostingand oneconsumeledger entry per period.
Open questions
- The end date for existing
Careers::Jobrows. When do existingCareers::Jobrows close? (Ali)- Ali sets the date later.
- 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
Systemadmin, the reason text, and that a blocked company gets none.