Invoicing

Invoicing turns the b3s__Pay_Bill_Staging__c lines produced by the pay and bill engine into numbered invoices. It produces two kinds of document from the same staging ledger:

Worker pay (Pay lines) is never invoiced. Before the rate sheet engine, self-bills were built from Pay lines carrying a payee account; such legacy lines are no longer picked up, and re-pricing an invoiced shift reverses them and writes Supplier lines (see the pay and bill engine).

Invoice numbering is configured on the SBU. Other settings are configured per client on an Invoice Configuration record: how lines split into separate invoices, how they group into invoice lines, which values copy onto invoice fields, how changes to already-issued work are corrected, the tax plugin, and the PDF templates. Once an invoice is issued, the staging lines on it are locked and become a ledger: later changes never rewrite them, they append correcting lines instead.

The package ships no jurisdiction-specific legal wording. Statements such as "The VAT shown is your output tax due to HMRC" (UK self-billing) or "The recipient and supplier have agreed this is an RCTI" (Australia) belong in your own PDF template (see PDF templates).

How it fits together

Shift__c ──< Pay_Bill_Staging__c  (Type Pay | Supplier | Bill, Pay_Code__c, Payee_Account__c, Invoice_Line__c, Correction_Of__c, Is_Manual__c)
                    │ 1:1
                    ▼
Invoice__c ──< Invoice_Line__c     (Kind Client | Self-Bill, Document_Type Invoice | Credit Note)
    │
    └── Invoice_Configuration__c   (per client, or the global default)
         └── Invoice_Template__mdt (Visualforce page rendered as PDF)
  1. The pay and bill engine interprets shifts into staging lines.
  2. A finance user (or a bulk run) generates invoices for a client and a period. Generation deletes any previous un-numbered drafts for that client (except credit notes of a specific invoice, which stay until undone), then groups every eligible staging line into draft invoices (status New).
  3. The user reviews the drafts and either undoes them (deletes them, releasing their lines) or issues them. Issuing numbers each invoice, sets issue and due dates, locks its staging lines and queues the PDF.
  4. Clients and vendors see issued invoices and download the PDF in their portal.
  5. When work on an issued invoice changes later, the pay and bill engine appends reversal lines, and the next generate corrects the invoice according to the configuration's correction mode.

Data model

Invoice_Configuration__c

One or more records per client account that needs its own rules (e.g. one for WFM shifts and one for VMS shifts, split by their eligibility rules), plus global defaults. Edit the settings on the standard record detail, and the templates plus split, group and mapping rules with the Invoice Configurator on the record page's Invoice Rules tab (see Native components).

Field Type Meaning
Name Text Configuration name.
b3s__Account__c Lookup(Account) The client this configuration applies to. Blank means a global configuration.
b3s__Is_Default__c Checkbox A global configuration used when an account has none of its own. Account must be blank.
b3s__Active__c Checkbox (default true) Inactive configurations are ignored by resolution.
b3s__Eligibility_Rules__c Long text (JSON) Which interpreted lines may be invoiced: [{fieldPath, operator, values}], all ANDed. Blank = inherit the global default (see Global default rules). See Eligibility.
b3s__Interpretation_Rules__c Long text (JSON) Which of the account's shifts a pay/bill run interprets: same format, paths start at b3s__Shift__c. Blank = inherit the global default. See Interpretation rules.
b3s__Pay_Bill_Setting__c Text(40) Developer name of the Pay/Bill Setting a blank rule field inherits from. Blank = the only setting that defines that rule; if several do, rule saves and generation fail with ... both define ... — choose a Pay/Bill Setting. Picked in the configurator.
b3s__Split_Rules__c Long text (JSON) Field paths whose distinct values each become a separate invoice.
b3s__Group_Rules__c Long text (JSON) Field paths whose distinct values each become one invoice line.
b3s__Field_Mapping__c Long text (JSON) Copy staging values onto invoice or invoice line fields.
b3s__Processing__c Picklist Internal (default): invoices are generated here. External: an integration writes invoices back (see External processing).
b3s__Correction_Mode__c Picklist Credit and Reissue (default), Amend Existing or Delta as New.
b3s__Allow_Amend_Issued__c Checkbox Required for Amend Existing; without it Credit and Reissue is used.
b3s__Amend_Client_Only__c Checkbox (default true) Self-bills always use Credit and Reissue, even when Amend Existing is configured.
b3s__Self_Billing_Enabled__c Checkbox Also generate self-bills from sub-vendor Supplier lines.
b3s__VMS_Fee_Percent__c Percent (default 2) VMS access fee deducted from sub-vendor self-bills: the pay and bill engine adds a negative VMS_Fee Supplier line worth this share of the vendor's supplier total. The vendor's own VMS_Fee_Percent__c wins. Blank or 0 = no fee. Only self-billing configurations are read. See VMS access fee.
b3s__Require_Self_Bill_Agreement__c Checkbox Self-bills can be issued only while the vendor has a current self-billing agreement and a tax registration number.
b3s__Tax_Plugin__c Text(255) Apex class implementing b3s.InvoiceTaxPlugin. Blank means the shipped default plugin.
b3s__Client_Tax_Rate__c Percent Rate the default plugin applies to client invoice lines.
b3s__Self_Bill_Tax_Rate__c Percent Rate the default plugin applies to self-bill lines when the vendor is tax registered.
b3s__Expense_Tax_Rate__c Percent Rate the default plugin applies to Expenses documents (client and self-bill). Blank means 0 %, the usual treatment of recharged expenses.
b3s__Client_Template__c Text(40) Invoice_Template__mdt developer name for client invoices. Blank means Default.
b3s__Supplier_Template__c Text(40) Invoice_Template__mdt developer name for self-bills. Blank means Default.
b3s__Invoice_Prefix__c Text(20) Optional per-configuration prefix of client invoice and credit note numbers, used only while the invoice's SBU has no Invoice_Prefix__c (see Issuing and numbering).
b3s__Last_Invoice_Number__c Number Last sequence number issued from this configuration, incremented only while the SBU client prefix is blank.
b3s__Payment_Terms_Days__c Number (default 30) Due date is the issue date plus this many days. Blank = the SBU's Payment_Terms_Days__c.
b3s__SBU__c Lookup(SBU) Optional business unit scope (see Resolution).
b3s__Backing_Sheet__c Long text (JSON) Shift-level backing sheet appended to the PDF and saved as a CSV file. Blank = none. See Backing sheets.

Invoice__c

Sharing model: Private. The record name is an auto number (INV-DRAFT-000001); the real document number lives in b3s__Invoice_Number__c once issued.

Field Type Meaning
b3s__Account__c Lookup(Account), required Bill-to account: the client, or the vendor for a self-bill.
b3s__Client_Account__c Lookup(Account) The client the work was for (equals Account on client invoices).
b3s__Kind__c Picklist Client or Self-Bill.
b3s__Document_Type__c Picklist Invoice or Credit Note.
b3s__Credited_Invoice__c Lookup(Invoice__c) The invoice a credit note credits.
b3s__Status__c Picklist New, Issued, Reverted.
b3s__Invoice_Number__c Text(40), unique Set when issued.
b3s__Invoice_Configuration__c Lookup The configuration that produced the invoice.
b3s__Category__c Picklist Services (shift lines) or Expenses (expense lines). Set by the engine; expenses are always invoiced on their own document.
b3s__Split_Key__c Text(255) Hash of the invoice's split values (used to match invoices in Amend Existing).
b3s__Split_Values__c Long text Readable JSON of the split values, for example {"Site":"London Bridge"}.
b3s__Currency__c Text(3) Currency of the staging lines. Mirrored onto CurrencyIsoCode in multi-currency orgs.
b3s__Period_Start__c / b3s__Period_End__c Date The generate period.
b3s__Issue_Date__c / b3s__Due_Date__c Date Set on issue.
b3s__Net__c / b3s__Tax__c / b3s__Gross__c Roll-up summary Sums of the lines.
b3s__Revision__c Number (default 0) Incremented each time Amend Existing rebuilds a numbered invoice.
b3s__PO_Number__c Text(80) Client purchase order number, printed in the PDF header. Filled by a header field mapping (see Site invoice data) or by hand on a draft.
b3s__Invoice_Contact__c Lookup(Contact) Person the document is addressed to, printed as "Attn" under the customer. Filled by a header field mapping or by hand on a draft.
b3s__External_Id__c Text(255), External ID, unique Upsert key for integrations.
b3s__Pdf_Document_Id__c Text(18) ContentVersion Id of the latest rendered PDF.
b3s__Backing_Sheet_Document_Id__c Text(18) ContentVersion Id of the backing sheet CSV saved with the latest PDF. Blank when the configuration defines no backing sheet.
b3s__Error__c Long text Generation or PDF error. An invoice with a generation error cannot be issued.
b3s__Invoice_Run__c Lookup(Invoice_Run__c) Latest generation run. Run membership also retains earlier runs when an invoice is amended.
b3s__Generated_By_Run__c Text(18) Apex job Id for bulk generation; run record Id for account generation. Use the Invoice Run relationship for navigation.
b3s__SBU__c Lookup(SBU) Legal entity of the document: issues client invoices, receives the supply on self-bills. Stamped at generate (the lines' unit in SBU mode, else the default SBU); decides the number series and the PDF letterhead. See Strategic business units.

Invoice_Line__c

Master-detail child of Invoice__c.

Field Type Meaning
b3s__Group_Key__c Text(255) The group rule values joined with ·.
b3s__Detail__c Text(255) Line description. Defaults to the non-blank group values joined with · unless mapped. Expense lines have no shift, so when every group value is blank they group and are labelled by <worker> · <expense category> instead. VMS_Fee lines ignore the group rules: every fee of one percentage becomes one line at the end of the self-bill, labelled VMS access fee <n> % (quantity 1, rate = net).
b3s__Section__c Text(255) Section the line prints under: the value of the first group rule when that rule has "section": true. Blank means no sections. See Sections.
b3s__Quantity__c Number(16,4) Sum of the grouped staging quantities. A VMS access fee line has quantity 1.
b3s__Unit__c Text(20) Set when every grouped line has the same unit.
b3s__Rate__c Number(16,4) The rate when every grouped staging line has the same rate. Otherwise the average, Net / Quantity, to 4 decimals (so Quantity x Rate matches Net). Blank when the lines mix units or the quantity is 0.
b3s__Net__c Number(16,2) Sum of the grouped staging totals, half-up to 2 decimals.
b3s__Tax_Rate__c Percent From the tax plugin.
b3s__Tax__c / b3s__Gross__c Number(16,2) Tax = Net x rate / 100, half-up to 2 decimals. Gross = Net + Tax.
b3s__Sort_Order__c Number Line order on the document.
b3s__External_Id__c Text(255), External ID, unique Upsert key for integrations.

Adjustment__c

One record per commercial adjustment event: what was credited or charged, why and by whom (Created By). Written by Adjust invoice and the Adjust Invoice Flow action (see Adjustments); its staging lines are in the Staging Lines related list.

Field Type Meaning
Name Auto number ADJ-0000
b3s__Type__c Picklist: Invoice, Shift Invoice = money-only adjustment of an invoice. Shift is reserved for corrections produced by shift changes.
b3s__Reason__c Picklist (unrestricted): Goodwill, Agreed Discount, Disputed, Pricing Error, Rate Change, Tax Correction, Additional Charge, Other Why. Add your own values.
b3s__Comments__c Long text Free text. Required in the modal.
b3s__Status__c Picklist: Open, Billed Billed once every line of the adjustment sits on a numbered invoice (set when that invoice is issued). Lines can only be added to an Open adjustment.
b3s__Account__c Lookup(Account) The client.
b3s__Invoice__c Lookup(Invoice__c) The issued invoice the adjustment corrects.

Pay_Bill_Staging__c additions

Field Type Meaning
b3s__Invoice_Line__c Lookup(Invoice_Line__c), clear on delete The invoice line this staging line is billed on. Always 1:1. Deleting a draft invoice clears it, releasing the line.
b3s__Correction_Of__c Lookup(Pay_Bill_Staging__c) The original line a reversal or repost corrects.
b3s__Is_Manual__c Checkbox Admin-entered adjustment. Never deleted by the pay and bill engine. Needs a shift, or both a client account and a work date.
b3s__Client_Account__c Lookup(Account) The client the line is invoiced to. Stamped by the pay and bill engine (the shift's job account, else its site account, then that account's Invoice_To_Account__c when set; see Bill-to resolution), copied onto reversals and reposts, and filled from the shift on insert of a line that has a shift and no value. Set it yourself on a manual line without a shift.
b3s__Work_Date__c Date The date the work belongs to (the shift's site-local Site_Scheduled_Start_Date__c). Stamped and copied like Client_Account__c. The period end filters on it.
b3s__Adjustment__c Lookup(Adjustment__c), restrict delete The adjustment that wrote this line (partial credit or manual charge). An adjustment cannot be deleted while it has lines.
b3s__Description__c Text(255) Free text for a manual line. Each manual line with a description gets its own invoice line, and the description is added to that line's Detail.
b3s__Expense__c Lookup(Expense__c) Set on lines interpreted from an expense (they carry no shift). Client_Account__c is the expense's account (or its Invoice_To_Account__c) and Work_Date__c its Date_of_Expense__c. Copied onto reversals and reposts. See Pay and bill engine, Expenses.

On upgrade, a post-install batch stamps Client_Account__c and Work_Date__c on existing lines from their shift, invoiced lines included. Lines without a value are not invoiced, so if the batch could not start (the install log says so), execute Database.executeBatch(new b3s.StagingContextBackfillBatch()); in anonymous Apex before the next generate.

Account additions

Field Type Meaning
b3s__Tax_Registration_Number__c Text(40) VAT, GST, ABN or EIN number printed on invoices and self-bills.
b3s__Tax_Registered__c Checkbox Vendor is registered for tax. The default plugin charges self-bill tax only when set.
b3s__Self_Bill_Agreement_Start__c / b3s__Self_Bill_Agreement_Expiry__c Date The vendor's self-billing agreement. A blank expiry means open ended.
b3s__Self_Bill_Prefix__c Text(20) Per-vendor self-bill prefix. Required only when the receiving SBU has no Self-Bill Prefix.
b3s__Self_Bill_Last_Number__c Number (default 0) Last self-bill sequence number for this vendor, incremented only while the SBU self-bill prefix is blank.
b3s__Is_Master_Vendor__c Checkbox The agency running the VMS. At most one per org. Its own workers produce no Supplier line, and Supplier lines payable to it are never self-billed.
b3s__VMS_Fee_Percent__c Percent This vendor's VMS access fee. Blank uses the invoice configuration's; 0 waives it.
b3s__Backing_Sheet__c Long text (JSON) Vendor override: a backing sheet (same JSON as the configuration's) used on this vendor's self-bills instead of the configuration's. Blank uses the configuration's sheet. Validated on save.
b3s__Invoice_To_Account__c Lookup(Account) Bill-to redirect. Blank means this account is invoiced itself. When set, work whose client resolves to this account is invoiced to the named account instead. One hop only; Salesforce refuses an account naming itself. See Bill-to resolution.

Site additions

Field Type Meaning
b3s__PO_Number__c Text(80) Standing client purchase order number for work at the site. Printed on invoices when mapped.
b3s__Invoice_Contact__c Lookup(Contact) Who invoices for work at the site are addressed to, when mapped.

Invoice_Template__mdt

Field Meaning
Label / DeveloperName Template name. The developer name is what a configuration references.
b3s__Page_Name__c Visualforce page rendered as PDF, for example b3s__InvoicePdf, or a page in your org without namespace.
b3s__Usage__c Client, Supplier or Both.

The package ships one record, Default, pointing at b3s__InvoicePdf with usage Both.

Invoice_Rule_Template__mdt

Reusable starting points for the rule fields of an Invoice Configuration. Not to be confused with Invoice_Template__mdt (PDF pages).

Field Meaning
Label / DeveloperName Template name shown in the Invoice Configurator's Start from template menu.
b3s__Type__c Split Rules, Group Rules, Field Mapping or Backing Sheet: the configuration field the template fills.
b3s__JSON__c Exactly what that configuration field would hold: a JSON array for the three rule types, a JSON object for Backing Sheet (see Rule JSON and Backing sheets).
b3s__Description__c Optional hover text in the menu.
b3s__Active__c Untick to hide the template.
b3s__Sort_Order__c Menu order within its type (lower first, then by label).

Templates are copied, not linked. Applying one replaces that one section in the configurator; the rows then edit like any others (for example apply a global "Split by school" and add a PO split rule for one client), and nothing is stored until Save, which validates as usual. Reset undoes an unsaved apply. Changing or deleting a template later never changes configurations that used it. Each section takes its own template, so a configuration can mix them freely. A template whose JSON does not parse is refused with Invoice Rule Template [Name] is not valid JSON: ... and the section is left as it was.

The package ships no records. Typical templates are Split by site, Split by site and PO, Group by worker, Group by worker and pay code, PO number on the invoice and Shift detail. Create your own in Setup > Custom Metadata Types > Invoice Rule Template > Manage Records; the quickest way to get the JSON is to build the rules in the configurator, save, and copy the field value from the record detail.

Configuration

Resolution

When invoices are generated for an account, its configuration is resolved as follows:

  1. The active configurations whose b3s__Account__c is that account (the candidates, by Name).
  2. Otherwise, the active configurations with b3s__Is_Default__c checked and a blank account.

An account may have several candidates. The Invoicing component shows an Invoice configuration picker when there is more than one (default: the first by Name) and generates with the picked one; drafts are replaced per configuration, so generating one never touches another's drafts. A call without a configuration fails with Account ... has N active invoice configurations — select one. The bulk run generates every non-External candidate of each account in turn. Give each candidate eligibility rules that don't overlap (e.g. b3s__Shift__r.b3s__VMS__c in [true] vs [false]): an interpreted line matching both goes to whichever generates first. Corrections and manual lines skip eligibility, so they go to the first configuration generated. If no candidate exists, generation fails with No active invoice configuration for account ... and no active default configuration.

Per business unit. In SBU mode the bulk run invoices each client one unit at a time and resolves the configuration for that unit: the account's configurations with that b3s__SBU__c, else the account's configurations with no unit, else the defaults with that unit, else the defaults with no unit. See Strategic business units.

Rule JSON

All paths are rooted at b3s__Pay_Bill_Staging__c and can traverse up to 5 relationships, for example b3s__Shift__r.b3s__Work_Site__r.Name. The Invoice Configurator builds these for you with a field path picker, but the JSON is plain and can be edited directly.

Split rules decide which lines go on separate invoices. Each distinct combination of values becomes its own invoice.

[
    {
        "fieldPath": "b3s__Shift__r.b3s__Work_Site__r.Name",
        "order": 1,
        "label": "Site"
    },
    {
        "fieldPath": "b3s__Shift__r.b3s__Cost_Center__r.Name",
        "order": 2,
        "label": "Cost centre"
    }
]

Group rules decide how lines inside one invoice collapse into invoice lines. Each distinct combination of values becomes one invoice line; quantities and totals are summed.

[
    {
        "fieldPath": "b3s__Shift__r.b3s__Work_Job__r.Name",
        "order": 1,
        "label": "Job"
    },
    { "fieldPath": "b3s__Pay_Code__c", "order": 2, "label": "Pay code" }
]

order sorts the rules (blank means position in the array). label names the value in b3s__Split_Values__c (blank means the path). With no group rules, every line of an invoice collapses into one invoice line.

Date buckets. A split or group rule on a date or date/time path can resolve to the week or month the date falls in instead of the exact date, for weekly or monthly invoice lines or one invoice per month:

[
    {
        "fieldPath": "b3s__Work_Date__c",
        "bucket": "week",
        "weekStart": "Monday",
        "label": "Week"
    },
    { "fieldPath": "b3s__Pay_Code__c", "label": "Pay code" }
]
Key Values Meaning
bucket week, month The value becomes the first day of the week or month (2026-11-02), which is also what the invoice line Detail and b3s__Split_Values__c show. Blank = the exact value.
weekStart Monday (default) to Sunday First day of a week bucket. Ignored for month.

The path must end on a Date or Date/Time field (... a week bucket needs a date or date/time field on save). b3s__Work_Date__c is the usual choice: it is the site-local work date of every line, expenses and manual lines included. A Date/Time path is converted to a date in the timezone of the user running the generate. The Invoice Configurator offers Date bucket and Week starts on every split and group rule.

Sections and subtotals

Add "section": true to the first group rule (by order) to print the invoice body in sections: the engine writes that rule's value to each line's b3s__Section__c, and the PDF prints a heading whenever the section changes and a net subtotal after the section's last line. Sections never split the invoice. Lines are already ordered by their group values, so one section's lines stay together. The flag is refused on split rules and on any other group rule. In the Invoice Configurator, tick Section on the first group rule.

[
    {
        "fieldPath": "b3s__Shift__r.b3s__Work_Site__r.Name",
        "order": 1,
        "label": "School",
        "section": true
    },
    { "fieldPath": "b3s__Pay_Code__c", "order": 2, "label": "Pay code" }
]

This is the usual shape for a trust invoiced once for all its schools: one invoice, one section per school, one line per pay code inside it.

Field mapping copies a staging value onto an invoice header field (b3s__Invoice__c.<field>) or invoice line field (b3s__Invoice_Line__c.<field>). Targets can be your own custom fields on those objects.

[
    {
        "source": "b3s__Shift__r.b3s__Work_Job__r.b3s__Purchase_Order__c",
        "target": "b3s__Invoice__c.PO_Number__c"
    },
    {
        "source": "b3s__Pay_Code__c",
        "target": "b3s__Invoice_Line__c.b3s__Detail__c"
    }
]

An entry may name a fallback path, read when the source value is blank on a line. Uniformity is checked on the resulting value.

Mapping rules:

Site invoice data

Map site-level purchase order numbers and contacts onto the invoice header with field mappings. The shift PO (stamped from the placement) wins and the site's standing PO is the fallback; the site's invoice contact becomes the "Attn" line:

[
    {
        "source": "b3s__Shift__r.b3s__PO_Number__c",
        "fallback": "b3s__Shift__r.b3s__Work_Site__r.b3s__PO_Number__c",
        "target": "b3s__Invoice__c.b3s__PO_Number__c"
    },
    {
        "source": "b3s__Shift__r.b3s__Work_Site__r.b3s__Invoice_Contact__c",
        "target": "b3s__Invoice__c.b3s__Invoice_Contact__c"
    }
]

Header mappings must resolve to one value per invoice, so pair them with a site split rule (b3s__Shift__r.b3s__Work_Site__r.Name) when one invoice can span sites with different POs or contacts; otherwise the draft is created with an error and no lines. Expense lines have no shift, so a mapping through the shift resolves blank on them.

Implicit split keys

Three keys always split invoices, ahead of any admin split rule, and need not be configured:

  1. Kind: client invoice or self-bill.
  2. Bill-to account: the client for client invoices, the payee vendor account for self-bills (so each vendor gets its own self-bill).
  3. Currency of the staging line.
  4. Category: expense lines (Expense__c set) go on a separate Expenses document (Category__c = Expenses), for clients and for vendor self-bills alike. Shift lines are Services. Admin split rules apply on top of both.
  5. SBU (SBU mode only): the staging line's b3s__SBU__c, so one document never mixes legal entities. Turning SBU mode on changes the key of new drafts: in Amend Existing, new lines no longer join invoices issued before the switch.

Validation on save

Saving a configuration (through the configurator or any API) validates it and rejects the save with every problem listed:

The configurator's Save also calls validateConfig and shows any problems in a "Configuration problems" panel.

Eligibility

A generate run for a client account and a period picks up every staging line that meets all of these:

Bill-to resolution

The client a line is invoiced to is resolved once, when the line is written, and stamped on b3s__Client_Account__c:

  1. The shift's Work Job account, else its Work Site account. A site account never beats a job account: a trust job at a school site bills the trust.
  2. If that account has Invoice_To_Account__c, the line is stamped with that account instead. One hop: the target's own redirect is not followed.

Expense lines start from the expense's Account__c and follow the same redirect. Manual lines without a shift keep the client you set.

Use the redirect for parent and child trusts whose schools are their own accounts, a head office that pays for its branches, or a factoring partner. Invoicing never walks Parent Account: that hierarchy keeps its meaning for portal memberships, rate cards and user provisioning. When the schools are only sites of one trust account (no own portal users, rate cards or PO numbers per school), no redirect is needed: put the jobs or sites on the trust account. In both shapes the school stays reachable for split, group, section and mapping rules through b3s__Shift__r.b3s__Work_Job__r.b3s__Account__r.Name or b3s__Shift__r.b3s__Work_Site__r.Name.

The redirect applies to lines written after it is set. To move already interpreted, un-invoiced work, re-run the pay and bill interpretation for those shifts (or run b3s.StagingContextBackfillBatch for lines with no client yet). Lines already on an issued invoice are not moved: their corrections are invoiced to the original invoice's client, so a redirect change never splits a credit from the invoice it credits. The bulk run picks up the redirected account automatically, because it reads the stamped client.

The pay and bill engine compares the resolved client with the client a shift's lines were invoiced to. Changing the redirect of an account whose shifts were already invoiced therefore credits the old bill-to and re-bills the new one when those shifts are next re-interpreted. The self-billing VMS fee configuration is also looked up on the resolved client.

Eligibility rules

b3s__Eligibility_Rules__c holds the conditions an interpreted line must meet. It is a JSON array, and every entry must match:

[
    {
        "fieldPath": "b3s__Shift__r.b3s__Approval_Status__c",
        "operator": "in",
        "values": ["Approved"]
    }
]

Examples: invoice submitted or approved shifts with {"fieldPath":"b3s__Shift__r.b3s__Approval_Status__c","values":["Submitted","Approved"]}. Invoice everything except rejected or queried shifts with "operator":"not in","values":["Rejected","Queried"].

The rules are checked when the configuration is saved (bad path, wrong field type, bad operator or no values). The configurator edits them in its Eligibility rules section. The bulk run looks at every account that has uninvoiced interpreted lines. Each account's generate then applies that account's rules, so an account whose lines all fail its rules gets no invoice.

Interpretation rules

b3s__Interpretation_Rules__c, on the same configuration, decides which of the account's shifts a Pay/Bill Runner run interprets. It uses the same format, but paths start at b3s__Shift__c, for example [{"fieldPath":"b3s__Approval_Status__c","values":["Submitted","Approved"]}]. Blank = inherit the global default; [] = every shift of the account in the period. A pay/bill run does not need a configuration record. The runner uses the configuration's own interpretation rules only when the account has exactly one configuration and that field is set. Otherwise it uses a Pay/Bill Setting: the runner shows a Pay/Bill Setting picker when there is more than one (default: the single configuration's b3s__Pay_Bill_Setting__c, else the first setting by label). The runner shows the source (Config: <name> or Pay/Bill Setting: <label>) and its rules in plain words under the shift count. Each run stores the rules it used, so Reverse always matches the original scope. The configurator edits it in its Interpretation rules section. Together with the eligibility rules, this keeps "which shifts get interpreted" and "which lines get invoiced" on one record.

Global default rules

Both rule fields also exist on the Pay/Bill Setting custom metadata (b3s__Pay_Bill_Setting__mdt, subscriber-editable): b3s__Interpretation_Rules__c and b3s__Eligibility_Rules__c. An org can keep several settings (e.g. WFM_Default and VMS_Default). How the rules are chosen:

  1. The configuration's own field, if it isn't blank ([] counts as set and means "no conditions").
  2. Otherwise the field on the configuration's b3s__Pay_Bill_Setting__c setting. If that is blank, the only setting that defines the field is used; several → error, choose one.
  3. Otherwise: interpretation = every shift; eligibility = shift Approved and not on Bill Hold.

Sample settings:

Setting Interpretation Eligibility
WFM_Default Approval Status in Submitted, Approved shift Approved, not on Bill Hold
VMS_Default Approval Status = Approved and b3s__VMS__c = true (client-approved VMS shifts) shift b3s__VMS__c = true, not on Bill Hold, and Pay/Bill Status = Interpreted (the engine already requires Interpreted; it's listed so the preview shows it)

Bill Hold (b3s__Bill_Hold__c on Shift, with b3s__Bill_Hold_Reason__c) approves a shift for pay while holding its bill. The shift is interpreted once as usual and its Pay lines export, but the eligibility condition {"fieldPath":"b3s__Shift__r.b3s__Bill_Hold__c","operator":"in","values":[false]} keeps its Bill and Supplier lines out of every generate until the hold is released; the next generate then bills them. The Shift Management Studio sets it with Hold bill / Release bill. Own eligibility rules on a configuration or setting replace the default, so add the condition there to honour holds. A hold set after the shift is invoiced does not pull lines back: raise a credit instead.

b3s__Hierarchy__c (rate card resolution) is org-wide: the Default record is used, else the first setting that has a value. Picking a setting in the runner does not change it. Rules on a setting are checked every time they're used. A bad global rule makes the pay/bill preview, the run and invoice generation fail with the problem named, and it also blocks saving any configuration that inherits it. The standard New form can create a configuration before a Pay/Bill Setting is selected; authored rules are still validated. Open Invoice Rules after creation to finish setup. If only one metadata setting is available, the configurator selects it and persists it on Save. With several settings, choose the appropriate policy before saving inherited rules. Generation still rejects ambiguous inherited rules. Keep Pay_Bill_Setting__c off the standard layout: the configurator owns its selection. The deprecated Invoice Prefix and Last Invoice Number fields are also excluded from the layout; manage numbering on the SBU. In the configurator, the Pay/Bill Setting (inherited rules) picker sets b3s__Pay_Bill_Setting__c, and each rule section has an Inherit from the Pay/Bill Setting checkbox (ticked when the field is blank). While ticked, it shows that setting's rules read-only; unticking copies them in as a starting point.

Groups whose summed net and quantity are both zero are dropped; their staging lines stay uninvoiced. A draft whose groups are all dropped is not created at all. An invoice whose lines net to a negative amount is created as a Credit Note, in every correction mode (an Amend Existing revision that turns negative becomes a credit note too).

Because a correction line is eligible whatever the eligibility rules say, a shift whose approval is withdrawn after invoicing has its reversal invoiced on the next run, while its new lines wait until the shift is approved again. A shift whose Approval Status becomes Rejected produces no lines at all, so it is reversed exactly like a cancellation.

Statuses and lifecycle

Status Meaning Allowed actions
New without number A disposable draft. Undo (delete), Issue. Regenerating the client deletes and rebuilds it, except a credit note of a specific invoice (Credited_Invoice__c set), which stays until it is undone or issued.
New with number A numbered invoice rebuilt by Amend Existing (revision 1 or later). Issue again (keeps its number).
Issued Numbered and locked. Its staging lines are locked. Regenerate PDF, Credit. Correct through the correction mode.
Reverted Fully credited: credit notes naming it as the credited invoice, with a gross of exactly minus its gross, have been issued. Regenerate PDF.

Integrity rules, enforced for every user and integration:

Posted and unposted. Finance processes speak of "invoiced but not posted" and "posted". In the package, unposted = a New draft without a number, posted = a numbered invoice (Issued, Reverted, or a numbered New revision). There is no separate Posted status. A shift whose lines sit on a draft is Invoiced and needs Edit Invoiced Shifts to change; on a numbered invoice it is Posted and needs Edit Posted Shifts (see Shift management studio).

Issuing and numbering

Issue works on a selection of invoices, all or nothing. Every selected invoice must:

Numbers come from the invoice's SBU (the legal entity; blank = the default SBU, created automatically on install or upgrade). The issue step locks the units involved, so concurrent issues never reuse a number:

Document Sequence Number format
Client invoice or credit note The SBU: Invoice_Prefix__c + next Last_Invoice_Number__c, zero-padded to Number_Padding__c digits INV- + 42, padding 6, gives INV-000042
Self-bill or self-bill credit note The SBU receiving the supply: Self_Bill_Prefix__c + next Self_Bill_Last_Number__c (same padding). Every vendor's self-bills share the unit's series. SB- + 7 gives SB-7

With one SBU this is one global series per document kind; with several, each legal entity has its own. Unit prefixes are unique across every unit and both series.

Optional per-configuration and per-vendor series. These fields remain available for implementations that need separate sequences. When the invoice's SBU has no prefix for the document kind, client documents use the configuration's Invoice_Prefix__c + Last_Invoice_Number__c, and self-bills use the vendor account's Self_Bill_Prefix__c + Self_Bill_Last_Number__c. These fallback numbers are not padded.

To use per-configuration client numbering, leave the SBU's Invoice Prefix blank and set a prefix and last number on each applicable Invoice Configuration. For example, configurations with TEMP- / 41 and PERM- / 7 next issue TEMP-42 and PERM-8 independently. To use per-vendor self-bill numbering, leave the receiving SBU's Self-Bill Prefix blank and configure each vendor's series instead. Client and self-bill choices are independent.

A non-blank SBU prefix always takes precedence for that kind: neither the configuration nor the vendor overrides it. The prefix selects the whole series, including its counter; a blank counter is treated as zero, so the next number is 1. Numbers are allocated on issue. The unused counters are not kept in sync. This choice applies to all documents of that kind for the SBU; one configuration cannot opt out while the SBU prefix is populated. If both the SBU and fallback prefix are blank, issuing a new number is blocked.

When install or upgrade creates the default SBU because no SBU exists, it copies the default configuration's prefix (else another available configuration prefix) and the highest configuration counter. Its self-bill counter is seeded from the highest vendor counter, but its self-bill prefix is left blank. This is initial seeding, not ongoing synchronization. Before switching between series, review the destination prefix and counter against previously issued numbers; changing the prefix selection does not migrate counters or renumber existing invoices.

Fallback prefixes must be unique (ignoring case) across all configurations and all vendor self-bill prefixes:

On issue the invoice gets the number (revised invoices keep theirs), its SBU (the default SBU when it had none), status Issued, issue date today and due date today plus the configuration's Payment_Terms_Days__c, else the SBU's. Issuing a credit note that names a credited invoice marks that invoice Reverted only when it credits it in full (the credit notes issued together for it have a gross of exactly minus the invoice's gross). A partial credit note, such as a Delta as New credit for one shift of a multi-shift invoice, keeps the reference but leaves the invoice Issued.

Issuing a reissued invoice (one carrying reposts of an invoice in Credit and Reissue) automatically adds that invoice's pending credit note to the same issue, so the credit and the replacement are always numbered together. If the credit note is missing (for example it was undone) the issue is refused with re-billed lines of ... need its credit note, which is missing; if it has a generation error, with the credit note ... has a generation error. Regenerate the client to rebuild it. The PDF job is then queued for every issued invoice.

The staging ledger

Once a staging line sits on a numbered invoice, or has been exported to payroll (b3s__Status__c = Processed), it is locked:

Changes to invoiced work append correcting lines instead of editing:

Reversal and repost are told apart by sign: a reversal's quantity (or total, when quantity is zero) has the opposite sign of its original's. A line counts as handled once any line names it in Correction_Of__c.

What the pay and bill engine does with locked lines

When a shift is interpreted again (Interpret Now, a Pay/Bill Runner batch, or the automatic re-interpretation described below):

Drafts react to shift changes. Any change to an interpreted shift's invoice affecting fields (or cancelling, rejecting or unapproving it) re-prices the shift and its affected set automatically (see Automatic re-pricing). A draft invoice holding one of their lines is deleted in the process, so a draft is never issued from stale lines: generate again to rebuild it. Unprocessing a shift (Shift Management Studio) deletes its draft the same way.

Automatic re-interpretation

An Interpreted shift that has locked lines (on an issued invoice, or Pay lines exported to payroll) is re-interpreted automatically (in a queued job) when any of these change: Status to Cancelled, Approval Status away from Approved or to Rejected, or a field in the Pay/Bill Setting's Invoice Affecting Fields (default: scheduled, actual and billable start or end, contact, work job, work site, cost center, rate group, rate basis, supplier account, rate overrides). Such a change is only possible for a user holding Edit Posted Shifts: the shift lock rejects it for everyone else. The job regenerates auto breaks (unless approval locked) and then runs the pay and bill engine, so the next invoice generate picks up the correction. Shifts without invoiced lines are not re-interpreted automatically.

When the edit itself runs in a queued job, batch or future call, the re-interpretation runs straight away in the same transaction instead. A second, different change to the same shift in that transaction (for example times edited, then the shift cancelled) is re-interpreted again; a repeat of the same values is not.

The job runs as the user who edited the shift. If that user cannot see the rate cards or break rules the shift needs, the shift is marked Failed (no reversals, no new lines) and the next pay and bill run by a finance user repairs it.

Manual lines

Admins can insert their own staging lines (an adjustment, a goodwill credit; approved expenses are interpreted automatically, see Pay and bill engine, Expenses) with b3s__Is_Manual__c = true:

For credits and charges against an issued invoice, use Adjustments instead of inserting lines by hand: they validate the amounts, mirror the tax and leave an audit record.

Correction modes

All three modes start the same way: a change to invoiced work leaves a reversal line (and usually new lines) in the ledger. The mode decides what documents the next generate produces.

The worked examples share this setup. Client Acme is invoiced weekly with a group rule on rate type. Invoice ACME-1001 (1 to 7 March) was issued with two Bill lines:

Staging line Shift Quantity Rate Total
L1 S1, 3 March 8 h 30.00 240.00
L2 S2, 4 March 8 h 30.00 240.00

ACME-1001: one line "Standard", 16 h x 30.00 = 480.00 net.

Then S1's actual end is corrected and it is now 6 hours. Re-interpretation appends:

Staging line Correction of Quantity Total
R1 (reversal) L1 -8 h -240.00
N1 (new) 6 h 180.00

The next generate runs for 8 to 14 March, which also has a new shift S3 (8 h, 240.00).

Crediting an issued invoice by hand

Correction modes react to changed work. When the work did not change but the invoice must still be cancelled (the client disputes it, it went to the wrong purchase order, the wrong configuration was used), select it in the Invoice Generator and click Credit. This works in every correction mode.

For each selected invoice:

  1. A credit note (status New, Credited_Invoice__c = the invoice) is created that mirrors the invoice line for line: same details, rates and tax rates, negated quantities and amounts. Its header copies the invoice's fields (account, kind, currency, period, mapped values), so its gross is exactly minus the invoice's gross.
  2. Every staging line on the invoice gets a reversal, stamped on the credit note, and a repost, left uninvoiced.
  3. The next Generate for the client bills the reposts as a fresh invoice, in every mode. In Amend Existing they are never amended back onto the credited invoice.
  4. Issuing the reissue brings the pending credit note into the same issue. Issuing the credit note marks the invoice Reverted.

To fix the reason the invoice was wrong before re-billing (for example a purchase order mapping), change the configuration or source records after crediting and before generating.

Credit is refused (Cannot credit: ...) for drafts, credit notes, Reverted invoices, invoices on External configurations (credit them in the external system), invoices that have a credit note pending (not yet issued), and invoices with outstanding corrections. An issued partial credit note (see Adjustments) does not block a full credit: the full credit note mirrors the whole invoice, the reissue re-bills it in full and the partial credit stays, so the client still nets the original minus the partial credit. For the last case, generate first so the correction mode processes them.

Undoing a credit note (by hand or from the correction modes) deletes the reversal and repost pairs that crediting created, so the invoice is back to plain Issued with nothing left to re-bill. Reversals from re-interpreted work are kept. The undo is refused while a repost already sits on a reissued draft (Undo the reissued invoice(s) first: ...).

Re-interpreting a credited shift before the credit note is issued deletes the unissued credit note, like any draft that carries its lines; credit the invoice again if it is still needed.

Adjustments

Use an adjustment when the work is right but the commercial outcome must differ: goodwill, an agreed discount, a disputed line, a wrong rate the client will not pay, an extra charge such as parking or a call-out fee. Adjustments change only money. They never touch the shift, never re-price it and never change worker pay. To fix the work itself, change the shift and let it be re-interpreted (see the correction modes above).

Select one issued invoice in the Invoice Generator and click Adjust invoice. The modal has two parts:

A Reason and Comments are required. The preview shows the credit net, the credit tax (at each line's own tax rate), the charge net (taxed by the tax plugin when generated) and the net change. Save adjustment writes one Adjustment__c and its staging lines; nothing is invoiced yet:

Operation Staging lines written What the next generate does
Credit lines Per credited invoice line, one manual reversal per underlying staging line, scaled by the credited share (rounded to the cent, the residual on the largest line). Correction_Of__c = the original, Is_Manual__c, Adjustment__c, Description Credit <invoice number>. Credit and Reissue: a credit note for the adjustment only (no reissue of the invoice), Credited_Invoice__c set, tax mirrored. Delta as New: a negative line on the delta invoice ("Corrects "). Amend Existing: the issued invoice is amended with the credit line.
Add charge / allowance One manual Bill line (or Supplier line with the payee) with Client_Account__c, Work_Date__c, Description, quantity, unit, rate, total, currency, Adjustment__c. No shift needed. Billed on the next invoice for the client as its own line labelled with the description.

Then Generate, review and Issue as usual: numbering, PDFs, backing sheets and portal visibility need nothing extra. Issuing a partial credit note never reverts the invoice; only a credit for the full gross does. When the invoice carrying the last line of an adjustment is issued, the adjustment turns Billed. To cancel an adjustment before it is billed, undo the draft it landed on (if any), then delete its staging lines and the adjustment record.

Adjustment credits are not changes of work. They do not cancel the original line in the ledger, so re-interpreting the shift later compares against the full original and only appends real work changes. They also do not count as "handled" for Credit or Credit and Reissue: a later full credit still reverses and reposts the original line.

Adjustments are refused (Cannot adjust: ...) without a reason, for invoices that are not Issued and numbered, credit notes, External configurations, a credit larger than what is left, a credit with both quantity and amount, and charges without a description, a non-zero total, a client, a currency (or in another currency than the invoice).

Flow and Apex. The invocable action Adjust Invoice (category Invoicing) takes one credit (Invoice Line Id + Credit: Quantity or Credit: Amount) and/or one charge (Charge: Description, Total or Quantity and Rate, optional Client Account Id, Work Date, Currency, Type, Payee Account Id, Shift Id) per request, with Reason (required), Comments and an optional Adjustment Id to add to an existing open adjustment. It returns the Adjustment Id. Put your own approval step in the Flow before the action. Apex code can call b3s.InvoiceAdjustmentService from inside the package only; integrations use the Flow action.

Credit and Reissue (default)

The issued invoice is fully credited and its still-valid work is billed again.

  1. For each issued invoice that a correction points at, every line not yet handled gets a reversal and a repost: L2 gets R2 (-240.00) and P2 (+240.00). L1 is already handled by R1. The run's period does not limit this: every reversal and repost of that invoice is billed in the same run, even when the invoice covered a longer period than the run.
  2. A credit note is built from all of the invoice's reversals (R1 + R2 = -480.00), grouped by the same rules, with Credited_Invoice__c = ACME-1001. Its lines copy the tax rate of the original invoice's lines, so the credit note is an exact mirror of what was billed, even if rates or the tax plugin changed since.
  3. Reposts and every other eligible line go through the normal engine: P2 (240.00) + N1 (180.00) + S3 (240.00) = a new invoice of 660.00.
  4. Issuing the new invoice also issues its pending credit note in the same action, and issuing the credit note marks ACME-1001 as Reverted.

Result: ACME-1001 (480.00, Reverted), credit note (-480.00), new invoice (660.00). This is the cleanest audit trail and is always used for self-bills when Amend Client Only is checked, and whenever Amend Existing is selected without Allow Amend Issued.

Amend Existing

The issued invoice is rebuilt in place and keeps its number. Requires Allow Amend Issued.

  1. Reversals join their original's invoice: R1 joins ACME-1001.
  2. Other eligible lines join an open numbered invoice of the same client, configuration and kind only when their split key matches and their shift date falls inside that invoice's period. N1 (3 March) joins ACME-1001. S3 (10 March) does not, so it goes to a new invoice.
  3. Every touched invoice is rebuilt from all of its staging lines: L1 + L2 + R1 + N1 gives "Standard" 14 h, 420.00. Its old invoice lines are replaced, its status returns to New, Revision__c goes up by one, the PDF id is cleared and header field mappings re-apply. The period end extends to the generate period end when that is later.
  4. Issuing it again keeps ACME-1001 and sets a new issue and due date.

Result: ACME-1001 revision 1 (420.00), new invoice for S3 (240.00). If a rebuild hits a mapping error, the issued invoice is left intact with b3s__Error__c set and the joining lines stay uninvoiced. Lines whose original invoice is already Reverted go onto a new invoice instead.

Delta as New

Issued invoices are never touched; only the difference is billed.

  1. Everything goes through the normal engine. Each reversal of an issued line gets an extra group key Corrects <invoice number>, so it lands on its own invoice line.
  2. The new invoice for 8 to 14 March carries "Standard · Corrects ACME-1001" (-8 h, -240.00) and "Standard" (N1 + S3, 14 h, 420.00): net 180.00.
  3. If an invoice's lines net negative it becomes a credit note. When all of its reversals point at one invoice, Credited_Invoice__c is set to it.

Result: ACME-1001 stays Issued (480.00), new invoice (180.00). A Delta credit note keeps Credited_Invoice__c as a reference, but issuing it marks the credited invoice Reverted only when it credits it in full (for example the only shift on ACME-1001 was cancelled). A partial credit, such as cancelling S1 alone (-240.00 against 480.00), leaves ACME-1001 Issued.

Tax

After grouping, the engine makes one bulk call to the configuration's tax plugin with every invoice line it built, except lines whose tax was already decided:

Reposts and new lines are always taxed by the plugin at today's rules. The plugin sets a percentage rate on each request; the engine then computes, per line, Tax = Net x rate / 100 rounded half-up to 2 decimals, and Gross = Net + Tax. A rate left blank counts as 0.

The default plugin

With b3s__Tax_Plugin__c blank, the shipped default applies:

A custom plugin reads the category from request.invoice.b3s__Category__c.

Writing your own tax plugin

Implement the global interface in your org for reverse charge, exempt services, multi-rate GST, or US sales tax lookups:

global interface InvoiceTaxPlugin {
    // Set taxRate (percent, e.g. 20) on each request. Bulk: one call per generate.
    void applyTax(List<InvoiceTaxRequest> requests);
}

global class InvoiceTaxRequest {
    global b3s__Invoice__c invoice;              // header (no Id yet on a fresh generate)
    global b3s__Invoice_Line__c line;            // the line: Net__c, Detail__c, Group_Key__c, mapped fields
    global b3s__Invoice_Configuration__c config; // the resolved configuration
    global Account billTo;                       // Id, Name, b3s__Tax_Registered__c, b3s__Tax_Registration_Number__c, BillingCountry, BillingState
    global b3s__SBU__c sbu;                      // the legal entity: Name, b3s__Legal_Name__c, b3s__Tax_Registration_Number__c, b3s__Country__c, b3s__Province_State__c (null when no SBU exists)
    global Decimal taxRate;                      // OUTPUT: percent
}

Rules: no DML. SOQL is allowed but must be bulk (one query for all requests). On Amend Existing rebuilds the invoice carries its Id; on fresh drafts it does not.

Example: UK client invoices at 20% VAT, except clients outside the UK (zero rated), and self-bills for vendors that are not VAT registered at 0%.

global with sharing class AcmeUkVatPlugin implements b3s.InvoiceTaxPlugin {
    public void applyTax(List<b3s.InvoiceTaxRequest> requests) {
        for (b3s.InvoiceTaxRequest request : requests) {
            Account billTo = request.billTo;
            Boolean selfBill = request.invoice.b3s__Kind__c == 'Self-Bill';
            if (selfBill) {
                request.taxRate = billTo != null && billTo.b3s__Tax_Registered__c == true ? 20 : 0;
            } else if (billTo != null && String.isNotBlank(billTo.BillingCountry)
                    && billTo.BillingCountry != 'United Kingdom') {
                request.taxRate = 0;
            } else {
                request.taxRate = 20;
            }
        }
    }
}

Set b3s__Tax_Plugin__c to AcmeUkVatPlugin (a bare name resolves to your org's namespace, ns.Class works too). The configuration save rejects a class that does not exist or does not implement the interface; a plugin that becomes invalid later fails generation with Tax plugin [...] not found or does not implement b3s.InvoiceTaxPlugin.

PDF templates

After issue, a queued job renders each invoice's PDF:

  1. The template is the configuration's Client_Template__c (client kind) or Supplier_Template__c (self-bill), blank means Default.
  2. The template's Page_Name__c Visualforce page is rendered as PDF with ?id=<Invoice Id>.
  3. The PDF is saved as a file (ContentVersion) attached to the invoice, titled with the invoice number, and its ContentVersion Id is stored in b3s__Pdf_Document_Id__c.
  4. When the invoice has a backing sheet, its CSV is saved the same way as <number>-backing.csv and its ContentVersion Id stored in b3s__Backing_Sheet_Document_Id__c.
  5. On failure, b3s__Error__c reads PDF generation failed: .... It is cleared on the next successful render.

The job renders 10 invoices per execution and chains itself for the rest. Regenerate PDF re-renders numbered invoices (for example after a template change) as a new file; earlier files remain on the invoice.

The page renders as the user who issued (or regenerated), so that user needs access to the Visualforce page and read access to the invoice, its lines and the bill-to account.

The shipped template

b3s__InvoicePdf (A4) prints the title, number, issue date, due date (not on credit notes), credited invoice number, period, currency, PO number (b3s__PO_Number__c, when set), supplier and customer blocks with billing address and tax registration number, an "Attn" line under the customer (b3s__Invoice_Contact__c, when set), the lines (description, quantity, unit, rate, net, tax %, tax, gross) and totals. Lines with a b3s__Section__c print under a section heading, with a net subtotal after each section's last line. Custom templates read the poNumber and attention properties and each row's sectionHeading, sectionTitle and sectionNet.

Kind / type Title Supplier Customer
Client invoice Invoice Your organization: the invoice's SBU legal entity, else Company Information Bill-to account
Client credit note Credit note Your organization Bill-to account
Self-bill Self-billed invoice Vendor account (with its tax registration number) Your organization (the SBU receiving the supply)
Self-bill credit note Self-billed credit note Vendor account Your organization

When the invoice has an SBU, "your organization" prints the unit's legal name, trading name, address, tax and company registration numbers, email and phone; the header shows the unit's logo (Logo_Document_Id__c) and client invoices end with its bank details. Custom templates read the same supplier, customer, logoUrl and bankDetails properties.

Expenses documents say "expenses" in the title: Expenses invoice, Expenses credit note, Self-billed expenses invoice, Self-billed expenses credit note.

Self-billed documents add "This is a self-billed document issued by the customer on behalf of the supplier." Your organization's tax number is printed from the SBU's Tax_Registration_Number__c; without an SBU (Company Information) it is not printed. Add jurisdiction wording in your own template.

Creating a custom template

  1. Create a Visualforce page in your org with renderAs="pdf". It receives one required URL parameter, id, the b3s__Invoice__c Id. The controller behind the shipped template is internal to the package and cannot be used by your pages, so use the standard controller (with its related lists) or your own controller or extension:
<apex:page
    standardController="b3s__Invoice__c"
    renderAs="pdf"
    showHeader="false"
    sidebar="false"
    standardStylesheets="false"
    applyHtmlTag="false"
    applyBodyTag="false"
>
    <html>
        <body style="font-family: Arial, sans-serif; font-size: 10pt;">
            <h1>
                {!IF(b3s__Invoice__c.b3s__Document_Type__c = 'Credit Note',
                'Credit note', 'Tax invoice')}
            </h1>
            <p>
                Number: {!b3s__Invoice__c.b3s__Invoice_Number__c}<br /> Issued:
                <apex:outputField
                    value="{!b3s__Invoice__c.b3s__Issue_Date__c}"
                /><br /> Bill to: {!b3s__Invoice__c.b3s__Account__r.Name}
                ({!b3s__Invoice__c.b3s__Account__r.b3s__Tax_Registration_Number__c})
            </p>
            <table width="100%">
                <apex:repeat
                    value="{!b3s__Invoice__c.b3s__Invoice_Lines__r}"
                    var="line"
                >
                    <tr>
                        <td>{!line.b3s__Detail__c}</td>
                        <td align="right">{!line.b3s__Quantity__c}</td>
                        <td align="right">{!line.b3s__Net__c}</td>
                        <td align="right">{!line.b3s__Tax__c}</td>
                        <td align="right">{!line.b3s__Gross__c}</td>
                    </tr>
                </apex:repeat>
            </table>
            <p>
                Total {!b3s__Invoice__c.b3s__Currency__c}:
                {!b3s__Invoice__c.b3s__Gross__c}
            </p>
            <apex:outputPanel
                rendered="{!b3s__Invoice__c.b3s__Kind__c = 'Self-Bill'}"
            >
                <p>The VAT shown is your output tax due to HMRC.</p>
            </apex:outputPanel>
        </body>
    </html>
</apex:page>

The invoice lines child relationship is b3s__Invoice_Lines__r; order them by b3s__Sort_Order__c in your own controller if you need a guaranteed order. 2. Grant the page to the users who issue invoices (permission set or profile Visualforce page access). 3. In Setup > Custom Metadata Types > Invoice Template > Manage Records, add a record: label UK Self-Bill, Page Name = your page name without namespace (for example UkSelfBillPdf), Usage = Supplier. 4. Pick it as the configuration's self-bill (supplier) template in the Invoice Configurator.

Backing sheets

A backing sheet is a shift-level table attached to an invoice, so a client (or a vendor importing its self-bills) can see exactly which shifts an invoice line covers even when the lines are grouped to "School A · Day rate". It is configured once per invoice configuration and produces two outputs:

Both are built when the PDF is rendered (on issue and on Regenerate PDF), from the staging lines on the invoice. Changing the configuration later changes the next render, not files already saved. Self-bills use the vendor account's b3s__Backing_Sheet__c when set, else the configuration's sheet. Credit notes get a sheet of their reversal lines (negative values).

Configuration JSON

Edit it in the Invoice Configurator's Backing sheet section, or as JSON in b3s__Backing_Sheet__c:

{
    "enabled": true,
    "granularity": "shift",
    "orientation": "landscape",
    "fontSize": 8,
    "timezone": "site",
    "sortBy": [
        "b3s__Shift__r.b3s__Scheduled_Start_Time__c",
        "b3s__Shift__r.b3s__Contact__r.Name"
    ],
    "sectionBy": "b3s__Shift__r.b3s__Work_Site__r.Name",
    "columns": [
        { "fieldPath": "b3s__Shift__r.Name", "label": "Shift" },
        {
            "fieldPath": "b3s__Shift__r.b3s__Site_Scheduled_Start_Date__c",
            "label": "Date",
            "format": "dd/MM/yyyy"
        },
        {
            "fieldPath": "b3s__Shift__r.b3s__Contact__r.Name",
            "label": "Worker"
        },
        { "fieldPath": "b3s__Shift__r.b3s__Work_Job__r.Name", "label": "Role" },
        {
            "fieldPath": "b3s__Shift__r.b3s__Billable_Start_Time__c",
            "label": "Start",
            "format": "HH:mm",
            "fallback": "b3s__Shift__r.b3s__Absolute_Start_Time__c"
        },
        {
            "fieldPath": "b3s__Shift__r.b3s__Billable_End_Time__c",
            "label": "End",
            "format": "HH:mm",
            "fallback": "b3s__Shift__r.b3s__Absolute_End_Time__c"
        },
        { "fieldPath": "b3s__Shift__r.b3s__PO_Number__c", "label": "PO" },
        {
            "fieldPath": "$quantity",
            "label": "Hours",
            "format": "0.00",
            "align": "right",
            "total": true
        },
        {
            "fieldPath": "$net",
            "label": "Net",
            "format": "currency",
            "align": "right",
            "total": true
        }
    ]
}
Key Default Meaning
enabled true false keeps the configuration but produces no sheet. A blank field also means no sheet.
granularity shift shift: one row per shift; the quantities and totals of that shift's lines on this invoice are summed into the $ tokens. Lines without a shift (expenses, manual lines) get a row each. line: one row per staging line, so b3s__Pay_Code__c, b3s__Rate__c and the like make sense as columns.
orientation landscape landscape or portrait pages for the appendix (the invoice itself stays portrait).
fontSize 8 Table font size in points, 6 to 12. Columns size to their content (each is at least as wide as its longest word); with many columns, use landscape or a smaller font so the table fits the page width.
timezone site Date/time values print in the shift's b3s__Site_Timezone__c (site; the org timezone when the line has no shift) or always in the org timezone (org). Date and time-only fields are timezone free.
sortBy none Field paths the rows are sorted by, in order (nulls last). Without it rows follow the invoice line order.
sectionBy none Field path whose value groups the rows under a heading, with a subtotal row of the total columns after each section. Rows are sorted by it first.
columns required 1 to 14 columns.
expenseColumns none 1 to 14 columns (same keys) used instead of columns on Expenses documents (b3s__Category__c = Expenses). Expense staging lines have no shift, so use paths through b3s__Expense__r (for example b3s__Expense__r.Name, b3s__Expense__r.b3s__Contact__r.Name, b3s__Expense__r.b3s__Category__c, b3s__Expense__r.b3s__Date_of_Expense__c). Without it, Expenses documents use columns, whose shift paths are blank unless a column has an expense fallback.

Column keys:

Key Meaning
fieldPath Path from b3s__Pay_Bill_Staging__c, up to 5 relationships (for example b3s__Shift__r.b3s__Work_Site__r.Name), or a token: $quantity, $net, $tax, $gross (summed per row; tax = line total x the invoice line's tax rate, half-up to 2 decimals), $payCodes (distinct pay codes joined with commas), $lineDetail (the invoice line descriptions the row belongs to).
label Header text, required, at most 30 characters.
format Date/time pattern for date, time and date/time fields (dd/MM/yyyy, yyyy-MM-dd, HH:mm, EEE d MMM); for numbers 0, 0.00, #,##0.00 (thousands separators) or currency (same as #,##0.00). Without a format: dates yyyy-MM-dd, date/times yyyy-MM-dd HH:mm, times HH:mm, numbers as stored, checkboxes Yes / No.
fallback Second field path used when the first is blank (billable time, else absolute time).
align left (default), right or center.
total true sums the column per section and for the whole sheet. Number columns only.

Reason and cost codes are shift fields, so they are ordinary columns: b3s__Shift__r.b3s__Reason_Code__c and b3s__Shift__r.b3s__Cost_Center__r.b3s__Code__c (see Reason codes and cost codes).

The configuration is validated when the record is saved (and when the configurator saves): unknown keys, invalid paths, unknown tokens, a format that does not fit the field type, a total on a text column, a missing or long label and more than 14 columns are refused with Backing Sheet ... messages. The vendor override on Account is validated the same way. More than 14 columns do not fit a PDF page; put a wide export in a second configuration or a report.

Custom templates

The sheet is available to Apex as b3s.InvoiceBackingSheetService.build(invoiceId) (global), returning a Sheet with invoiceNumber, orientation, fontSize, columnCount, headers (cells with value and align), sections (each with heading, rows of cells, subtotals), totals, hasSections and hasTotals, or null when no sheet is configured. Call it from your own template controller to render the same table. The shipped page uses the named CSS pages backing-landscape / backing-portrait and -fs-table-paginate: paginate on the table to repeat the header row.

External processing and write-back

Set b3s__Processing__c = External when an accounting or ERP system produces the invoices. Then:

The WFM Invoice Integration permission set

Assign WFM Invoice Integration (WFM_Invoice_Integration) to the integration user. It grants:

Invoice__c and Pay_Bill_Staging__c are Private objects, so also give the integration user record visibility (for example a sharing rule, role, or a View All grant in your own permission set) over the staging lines it reads.

Composite upsert example

Find the configuration Id once (SELECT Id FROM b3s__Invoice_Configuration__c WHERE b3s__Account__c = '001...' AND b3s__Active__c = true), then write the invoice, its lines and the staging stamps in one all-or-none request, issuing in the final step.

Request: POST /services/data/v61.0/composite

{
    "allOrNone": true,
    "compositeRequest": [
        {
            "method": "PATCH",
            "url": "/services/data/v61.0/sobjects/b3s__Invoice__c/b3s__External_Id__c/ERP-INV-20431",
            "referenceId": "invoice",
            "body": {
                "b3s__Account__c": "001Hu00003AcmeAAA",
                "b3s__Client_Account__c": "001Hu00003AcmeAAA",
                "b3s__Kind__c": "Client",
                "b3s__Document_Type__c": "Invoice",
                "b3s__Status__c": "New",
                "b3s__Currency__c": "GBP",
                "b3s__Invoice_Configuration__c": "a2XHu000001ExtAAA",
                "b3s__Period_Start__c": "2026-03-01",
                "b3s__Period_End__c": "2026-03-07"
            }
        },
        {
            "method": "PATCH",
            "url": "/services/data/v61.0/sobjects/b3s__Invoice_Line__c/b3s__External_Id__c/ERP-INV-20431-1",
            "referenceId": "line1",
            "body": {
                "b3s__Invoice__r": { "b3s__External_Id__c": "ERP-INV-20431" },
                "b3s__Detail__c": "Warehouse operative · Standard",
                "b3s__Quantity__c": 16,
                "b3s__Unit__c": "Hours",
                "b3s__Rate__c": 30,
                "b3s__Net__c": 480.0,
                "b3s__Tax_Rate__c": 20,
                "b3s__Tax__c": 96.0,
                "b3s__Gross__c": 576.0,
                "b3s__Sort_Order__c": 1
            }
        },
        {
            "method": "PATCH",
            "url": "/services/data/v61.0/sobjects/b3s__Pay_Bill_Staging__c/a2YHu00000L1aaaAAA",
            "referenceId": "stamp1",
            "body": {
                "b3s__Invoice_Line__r": {
                    "b3s__External_Id__c": "ERP-INV-20431-1"
                }
            }
        },
        {
            "method": "PATCH",
            "url": "/services/data/v61.0/sobjects/b3s__Pay_Bill_Staging__c/a2YHu00000L2aaaAAA",
            "referenceId": "stamp2",
            "body": {
                "b3s__Invoice_Line__r": {
                    "b3s__External_Id__c": "ERP-INV-20431-1"
                }
            }
        },
        {
            "method": "PATCH",
            "url": "/services/data/v61.0/sobjects/b3s__Invoice__c/b3s__External_Id__c/ERP-INV-20431",
            "referenceId": "issue",
            "body": {
                "b3s__Invoice_Number__c": "20431",
                "b3s__Status__c": "Issued",
                "b3s__Issue_Date__c": "2026-03-09",
                "b3s__Due_Date__c": "2026-04-08"
            }
        }
    ]
}

Response (abridged):

{
    "compositeResponse": [
        {
            "referenceId": "invoice",
            "httpStatusCode": 201,
            "body": {
                "id": "a2ZHu000000Inv1AAA",
                "success": true,
                "errors": [],
                "created": true
            }
        },
        {
            "referenceId": "line1",
            "httpStatusCode": 201,
            "body": {
                "id": "a2aHu000000Ln01AAA",
                "success": true,
                "errors": [],
                "created": true
            }
        },
        { "referenceId": "stamp1", "httpStatusCode": 204, "body": null },
        { "referenceId": "stamp2", "httpStatusCode": 204, "body": null },
        {
            "referenceId": "issue",
            "httpStatusCode": 200,
            "body": {
                "id": "a2ZHu000000Inv1AAA",
                "success": true,
                "errors": [],
                "created": false
            }
        }
    ]
}

Re-running the same request is safe: the upserts update the same records (200, "created": false). A failure in any step rolls back the whole request, for example:

{
    "referenceId": "stamp1",
    "httpStatusCode": 400,
    "body": [
        {
            "errorCode": "FIELD_CUSTOM_VALIDATION_EXCEPTION",
            "message": "This staging line is on an issued invoice and cannot be changed (b3s__Invoice_Line__c)"
        }
    ]
}

To find what to bill, query eligible lines the same way the engine does: b3s__Invoice_Line__c = null, the client is the original invoice's client for corrections of invoiced lines and otherwise the shift's Work Job account (or its Work Site account when the job has none), and the shift is Approved and Interpreted (or the line is a correction or manual line). Credits are written as Document_Type__c = 'Credit Note' with negative lines and Credited_Invoice__c set; set the credited invoice's status to Reverted when it is fully credited.

Portal invoice tabs

Issued invoices are visible to the parties in their own portals through a shared, read-only invoice list. It shows summary tiles (net invoiced: the sum of every listed document, credit notes and Reverted invoices included, so a credited invoice and its credit note cancel out; per currency) and the document count, a searchable and filterable list with number, period, issue and due dates, net, tax, gross, status and the credited invoice number, an expandable lines table per invoice, a Download PDF button and, when the invoice has a backing sheet, a Backing sheet (CSV) button. Only Issued and Reverted invoices are shown; drafts never reach a portal. Everything is definition driven: no field path is hard coded.

Portal Tab Shows
Client Shift Manager VMS view, Invoices Client invoices and credit notes billed to the accounts whose profile grants Invoices Tab (ungoverned: the contact's account).
Vendor Portal Invoices Self-bills and self-bill credit notes billed to the vendor's account (profile needs Invoices Tab), with the client name.

The tab appears only when the app definition declares the invoice schedulable. In the Client Shift Manager it sits inside the VMS view, so VMS must be enabled there. Data loads when the tab is opened; re-clicking the tab refreshes it.

Definition samples

Add the two schedulables to the app definition JSON (b3s__JSON__c). The Vendor Portal sample adds clientNameFieldPath; omit it in the Client Shift Manager.

"invoice": {
    "objectType": "b3s__Invoice__c",
    "loaderName": "invoices",
    "numberFieldPath": "b3s__Invoice_Number__c",
    "documentTypeFieldPath": "b3s__Document_Type__c",
    "categoryFieldPath": "b3s__Category__c",
    "statusFieldPath": "b3s__Status__c",
    "creditedNumberFieldPath": "b3s__Credited_Invoice__r.b3s__Invoice_Number__c",
    "clientNameFieldPath": "b3s__Client_Account__r.Name",
    "issueDateFieldPath": "b3s__Issue_Date__c",
    "dueDateFieldPath": "b3s__Due_Date__c",
    "periodStartFieldPath": "b3s__Period_Start__c",
    "periodEndFieldPath": "b3s__Period_End__c",
    "netFieldPath": "b3s__Net__c",
    "taxFieldPath": "b3s__Tax__c",
    "grossFieldPath": "b3s__Gross__c",
    "currencyFieldPath": "b3s__Currency__c",
    "pdfFieldPath": "b3s__Pdf_Document_Id__c",
    "backingSheetFieldPath": "b3s__Backing_Sheet_Document_Id__c",
    "canEdit": false,
    "canDelete": false
},
"invoiceLine": {
    "objectType": "b3s__Invoice_Line__c",
    "loaderName": "invoiceLines",
    "invoiceFieldPath": "b3s__Invoice__c",
    "sortFieldPath": "b3s__Sort_Order__c",
    "detailFieldPath": "b3s__Detail__c",
    "quantityFieldPath": "b3s__Quantity__c",
    "unitFieldPath": "b3s__Unit__c",
    "rateFieldPath": "b3s__Rate__c",
    "netFieldPath": "b3s__Net__c",
    "taxRateFieldPath": "b3s__Tax_Rate__c",
    "taxFieldPath": "b3s__Tax__c",
    "grossFieldPath": "b3s__Gross__c",
    "canEdit": false,
    "canDelete": false
}

Loader samples

Add two loaders to the configuration's b3s__Loaders__c array, named as in loaderName. The filter is what scopes the portal user: always keep the account, kind and status conditions. This is the Vendor Portal pair; for the Client Shift Manager use b3s__Kind__c = 'Client' (and drop b3s__Client_Account__r.Name).

{
    "name": "invoices",
    "objectName": "b3s__Invoice__c",
    "filterRecordsBy": [
        "b3s__Account__c IN :accountIds(b3s__Tab_Invoices__c) AND b3s__Kind__c = 'Self-Bill' AND b3s__Status__c IN ('Issued', 'Reverted')"
    ],
    "groupRecordsBy": "Id",
    "fieldToLoad": [
        "Name", "b3s__Invoice_Number__c", "b3s__Kind__c", "b3s__Document_Type__c", "b3s__Category__c", "b3s__Status__c",
        "b3s__Credited_Invoice__r.b3s__Invoice_Number__c", "b3s__Client_Account__r.Name",
        "b3s__Issue_Date__c", "b3s__Due_Date__c", "b3s__Period_Start__c", "b3s__Period_End__c",
        "b3s__Net__c", "b3s__Tax__c", "b3s__Gross__c", "b3s__Currency__c", "b3s__Pdf_Document_Id__c",
        "b3s__Backing_Sheet_Document_Id__c"
    ]
},
{
    "name": "invoiceLines",
    "objectName": "b3s__Invoice_Line__c",
    "filterRecordsBy": [
        "b3s__Invoice__c = :contextId AND b3s__Invoice__r.b3s__Account__c IN :accountIds(b3s__Tab_Invoices__c) AND b3s__Invoice__r.b3s__Kind__c = 'Self-Bill' AND b3s__Invoice__r.b3s__Status__c IN ('Issued', 'Reverted')"
    ],
    "groupRecordsBy": "Id",
    "fieldToLoad": [
        "b3s__Invoice__c", "b3s__Sort_Order__c", "b3s__Detail__c", "b3s__Quantity__c", "b3s__Unit__c",
        "b3s__Rate__c", "b3s__Net__c", "b3s__Tax_Rate__c", "b3s__Tax__c", "b3s__Gross__c"
    ]
}

The line loader runs per invoice: when a user expands an invoice the list points :contextId at that invoice. PDF downloads go through the access-checked InvoicePortalService.getInvoicePdf endpoint and backing sheet CSVs through getBackingSheet (see Apex and automation API reference), which re-checks on the server, for every download, that:

Internal users testing the pages download with their own access. The PDF must be a file linked to the invoice (the one the PDF job stores in b3s__Pdf_Document_Id__c); the CSV likewise (b3s__Backing_Sheet_Document_Id__c). The CSV button shows only when backingSheetFieldPath is declared and loaded and the invoice has a sheet. Strings come from the shared invoiceList translation keys, including the status and document type labels (statusIssued, statusReverted, typeInvoice, typeCreditNote) and the Expenses badge shown when categoryFieldPath is Expenses (categoryExpenses) (and the invoices tab label in each app), so they can be re-worded with app translations. For the loader grammar see data loaders.

Native components

Component Where What it does
Invoice Generator Account record page Pick a period (defaults to the previous calendar month), Generate that account's drafts (a line under the pickers shows the configuration and eligibility rules that apply), filter the list by status, view lines, Issue, Undo, Credit (full credit note for issued invoices), Adjust invoice (partial credit and charges for one issued invoice, see Adjustments), Regenerate PDF, open the PDF or the record. Generation results and per-invoice errors are shown inline.
Invoice Generator App or Home page The same list across all accounts, and Generate starts a bulk run for every eligible client with live job progress.
Invoice Configurator Invoice Configuration record page, Invoice Rules tab Client and self-bill template pickers, a Start from template menu on the split, group, mapping and backing sheet sections (shown when that type has an active Invoice Rule Template), plus ordered split, group and mapping editors (add, remove, move up and down) with a field path picker, and the Backing sheet editor (rows, orientation, timezone, font size, section and sort paths, up to 14 columns with value, fallback, label, format, alignment and total; Columns for switches between the shift columns and the optional Expenses invoice columns). Every other setting is edited on the standard record detail. Save validates.

The Invoicing, Invoices and Invoice Configurations tabs are in the 3B WFM and 3B VMS apps. Open Invoicing for the global Invoice Generator: select the period, click Run for All Accounts, review the drafts, then Issue. Invoices remains the invoice record list. The WFM Admin permission set makes the global Invoicing tab visible. The WFM_Admin permission set grants the objects, fields, classes and the PDF page. See native Lightning components for placement steps.

Bulk runs

From an App or Home page, the Invoice Generator starts a batch over every client account that has uninvoiced, invoiceable staging lines on or before the period end, by the same rule as a single generate: the line's b3s__Client_Account__c and b3s__Work_Date__c, and the original invoice's client for corrections of invoiced lines, so a client that only has credits pending is included. Each account is processed in its own transaction:

Bulk runs generate drafts only. Review and issue them from the list.

Limits

Limit Value What happens
Eligible staging lines per account per generate 4,000 Generation fails with More than 4000 uninvoiced staging lines for this account. Invoice a shorter period (an earlier period end).
Rows written per generate 10,000 (platform DML rows) Each phase checks the headroom first and fails with Cannot <phase>: N rows needed but only M DML rows left in this transaction, rolling back. A Credit and Reissue correction of a very large invoice writes two rows per line. Invoice a shorter period.
Outstanding corrections scanned to start a bulk run about 50,000 uninvoiced correction lines Generate the largest clients individually first.
Field path depth 5 relationships Rejected on configuration save.
PDFs per job execution 10 The job chains itself for the remainder.
Backing sheet columns 14 Refused on save.
Staging lines read per backing sheet 10,000 Far above the 4,000 lines one generate can put on an invoice.
Invoices listed in the Invoice Generator 1,000 most recent Use status filtering or the Invoices tab list views for older records.
Split values One invoice per distinct combination Many split rules on high-cardinality fields multiply invoice counts.

Bypassing the guards in data scripts

Bypass Ledger Locks (b3s__Scheduler__c.b3s__Bypass_Ledger_Locks__c, a WFM setting checkbox) is an admin-only control for supervised data repairs and demo data. It applies only on a user-level row. While it is on, that user can change or delete locked shifts, expenses, invoices and staging lines that are otherwise protected.

Warning. Turn it on only for the administrator running the fix, and clear it as soon as the fix is done. Changes made while it is on can leave invoices out of step with their staging lines. Never leave it on in production.

Delete demo data on the Demo Data tab uses it to clear invoices and staging lines across the demo org (see UK education demo data).

Troubleshooting

Symptom Cause Fix
No active invoice configuration for account ... No configuration for the account and no active default. Create an account configuration or an active default with a blank account.
Duplicate active invoice configurations ... Two active configurations for one account, or two defaults. Deactivate one.
... uses External processing The resolved configuration is External. Expected: the integration writes those invoices. Switch to Internal to generate here.
Generate creates no invoices No eligible lines: shifts not Approved and Interpreted, already invoiced, scheduled after the period end, not this client's (job account, or site account when the job has none, then that account's Invoice To Account), or Supplier lines without self-billing enabled (Pay lines are never invoiced). Zero groups are dropped. Check the shift's Approval Status and Pay/Bill Status and the staging line's Invoice Line.
A draft has an Error and no lines: Field mapping ...: values differ ... A mapped value is not uniform across the invoice (header) or line group (line). Add the mapped path as a split rule (header) or group rule (line), then regenerate.
Cannot issue: ... has no Invoice Prefix Neither the invoice's SBU nor the configuration has a prefix. Set Invoice Prefix on the SBU.
Cannot issue: vendor ... has no Self-Bill Prefix Neither the invoice's SBU nor the vendor account has a self-bill prefix. Set Self-Bill Prefix on the SBU.
Cannot issue: vendor ... has no current self-billing agreement or ... no tax registration number Require Self-Bill Agreement is on and the vendor's agreement dates or tax number are missing or out of date. Update the vendor's agreement start, expiry and tax registration number.
Cannot issue: ... has a generation error The draft has Error__c. Fix the cause and regenerate.
Invoice prefix "..." is already used by another invoice configuration (on save) or Cannot issue: invoice prefix "..." of ... is also used by another invoice configuration or vendor account Another configuration or vendor already uses that prefix (case is ignored). Choose a prefix unique across configurations and vendors.
Cannot issue: re-billed lines of ... need its credit note, which is missing or the credit note ... has a generation error A Credit and Reissue replacement was selected but its credit note was undone or failed. Regenerate the client, then issue again (the credit note is added automatically).
Invoice status changes only through Issue / Undo / invoice generation Status was edited by hand or by an automation. Use Issue and Undo. Integrations on External configurations may set it.
This line of an issued invoice still carries staging lines and cannot be deleted An External integration deleted a stamped line. Clear b3s__Invoice_Line__c on those staging lines first, or keep the line.
Staging line ... was invoiced by another run meanwhile Two runs for overlapping lines collided. Generate again.
Cannot credit: ... has outstanding corrections Changed work on the invoice is waiting for the next generate. Generate the client first, then credit if still needed.
Cannot credit: ... already has a credit note pending An unissued credit note already names this invoice. Issue or undo that credit note.
Cannot adjust: ... exceeds the ... left on the line Earlier credits or reversals already reduced the line. Credit at most what the modal shows as left.
Cannot adjust: ... only issued invoices can be adjusted The invoice is a draft or Reverted. Adjust the issued invoice, or change the draft's source and regenerate.
Undo the reissued invoice(s) first: ... The credit note's reposts are already on a draft reissue. Undo the reissue, then the credit note.
Only unissued drafts can be undone Undo selected a numbered invoice. Numbered invoices are corrected through the correction mode, not deleted.
This staging line is on an issued invoice and cannot be changed or ... cannot be deleted The line is locked. Change the shift and re-interpret, or add a manual line. Only Status can change.
Lines of an issued invoice cannot be changed Editing lines of an issued, internally processed invoice. Correct through the correction mode.
This shift has been invoiced and cannot be deleted It has lines on an issued invoice. Cancel or reject the shift instead; the next run reverses its invoiced lines.
A manual staging line must reference a shift Manual line without a shift. Set a shift of the client the line is for.
Backing Sheet ... on save The backing sheet JSON (configuration or vendor Account) has an invalid key, path, token or format. Fix the reported column; see Backing sheets.
No Backing sheet (CSV) button in the portal The configuration has no enabled backing sheet, the PDF was rendered before it was added, or the definition lacks backingSheetFieldPath / the loader lacks b3s__Backing_Sheet_Document_Id__c. Add the sheet and Regenerate PDF; compare the definition with the sample.
PDF missing, Error reads PDF generation failed: ... Template not found, page error, or the issuing user cannot access the page or records. Check the template record and page access, then Regenerate PDF.
An invoiced shift changed but nothing was corrected The shift was not Interpreted before the change, the changed field is not one that triggers re-interpretation, the new result is identical and still for the same client, or the editing user could not see the rate cards or break rules (shift now Failed). Run Interpret Now or a Pay/Bill Runner batch as a finance user, then generate.
Portal Invoices tab missing The definition has no invoice schedulable, the contact's profile lacks Invoices Tab, or (Client Shift Manager) VMS is not enabled. Add the schedulables and loaders above.
Portal shows no invoices Nothing Issued or Reverted for that account and kind, or the loader filter differs. Issue invoices; compare the loader filter with the sample.

Preview, search and generation history

Generate drafts for the period, then use an invoice row's Preview PDF or Preview backing sheet before issuing. PDF preview uses the configured client or supplier template. The supplied Default template marks New invoices as DRAFT and shows Not issued until numbering. Custom templates should provide equivalent draft wording. Dates and invoice numbers remain unset until issue; preview does not reserve a number, change status or save a PDF file. Backing sheet preview uses the same columns, sections, subtotals and totals as the issued document, including supplier overrides. If no backing sheet is configured, the console explains this.

Use Client, Supplier (self-bills), SBUs, Status, invoice number/name and period-overlap dates to narrow the invoice list. These filters combine. The list loads 50 invoices at a time, with Previous and Next controls. Selection belongs to the current page and resets when filters change. Date search is based on invoice period overlap, independently of the generation period controls. Selected SBUs apply to both generation and invoice search; none means all units.

Every generation started from the console creates an Invoice Run record with period, account (blank for bulk), status and bulk job ID. Select a recent run to see its invoices, or choose Open selected run. The picker includes the latest 100 runs for the current account scope; older runs remain available through the Invoice Runs object. The run's Run invoices related list links to member invoices. An amended invoice can appear in several runs. Membership is a record association, not a frozen copy of the invoice: opening it shows its current state. Undoing or replacing a draft deletes the invoice, leaving the membership's invoice lookup blank. Existing invoices are not retroactively assigned to runs.

Issue, undo draft, credit and adjust are also available in each invoice row menu. Only actions valid for the invoice's current status are enabled. Existing confirmations and server-side restrictions still apply.

Salesforce page setup

Assign the updated WFM Admin permission set for access to Invoice Runs, run memberships and the invoice run lookup. Add the Invoice Runs tab to the finance navigation as needed. In Lightning App Builder, the existing Invoice Generator component can be placed on Account, Invoice and Invoice Run record pages, as well as App and Home pages. On Invoice and Invoice Run pages, generation controls are hidden and the list is scoped to that record. Add the component to the relevant record page and activate it for the intended finance users. The delivered Invoice Run layout also exposes its details and run invoice links without requiring a custom record page.

Bulk progress is shown while the console remains open. The job ID on the run supports investigation in Apex Jobs, including aborted jobs; a run whose job is aborted before completion may retain its queued status. Per-invoice generation errors remain on the invoices. Runs completed with mapping errors are marked Completed with errors.