The timesheet is approved, but the contract cap is nearly reached and a rate changed halfway through the month. A successful API call would not make the invoice correct. The workflow must preserve the billing rule, the approved time and finance’s decision together.
How can approved timesheets become invoice-ready records?
Import approved time entries and join them to the applicable contract version, rate and billing period. Deterministic checks should validate caps, billable status, currency and milestone conditions before preparing an invoice preview. Finance approves the exact preview revision before a separate service creates a draft in the accounting system. Stable workflow keys and receipt reconciliation prevent retries from creating duplicate drafts. Sending or posting invoices requires the agreed accounting authorization.
billing preflight
An approved timesheet is only the first billing check
Time approval confirms one part of the record. The invoice still depends on effective rates, billable status, caps, milestone conditions and whether an entry was already billed. Finance needs those checks together before authorizing a draft.
□
Time and contract evidence
Freeze the eligible billing inputs
Import time entries with source IDs and an authoritative approval reference. Confirm whether the available Harvest account and API expose sufficient approval evidence; if not, use a controlled approval export or an additional approval step. Store the applicable contract, effective rate dates, currency and milestone sign-off from an agreed source.
□
Billing validation
Validate before requesting approval
Node.js computes line amounts with decimal arithmetic and approved rounding rules. Check non-billable entries, rate gaps, caps, previously billed time and milestone conditions. Temporal persists workflow progress while exceptions are corrected. Finance reviews an immutable preview revision; changed time or rates invalidate that approval.
□
Accounting handoff
Make the accounting write recoverable
Use a stable workflow identity for engagement and billing period and unique line mappings for source time. After finance approval, a scoped activity creates a Xero draft and saves the invoice ID. Activities may retry, so reconcile ambiguous writes using supported idempotency behavior or the external reference before resending. An uncertain match goes to finance, not another blind create call.
The preview is the approval boundary
The approval attaches to a frozen preview. If time, rates or terms change, the previous decision cannot authorize the new payload.
Technical details
Approval and retries must refer to the same invoice
The billing preview, approval and accounting receipt stay linked. A timeout after draft creation triggers receipt reconciliation before another create request.
Harvest APITime entries plus authoritative approval evidence
Retrieve time records; confirm approval evidence separately where needed.
Node.jsEffective rates, caps, currency and rounding checks
Implement rate checks and accounting adapters.
TemporalDurable validation, review waits and recovery
Coordinate durable validation, approval waits and recovery.
01Freeze the previewSource time + contract revision
02Finance authorizesExact payload revision
03Create a draftStable reference + saved receipt
PostgreSQLSnapshots, approvals and source-to-draft mapping
Store billing snapshots, approvals and draft mappings.
→approved payload only
Xero APIAccounting draft and invoice receipt
Create an authorized draft and retrieve its receipt.
Timeout after acceptance?Look up the receipt before repeating the write. Durable retries do not remove the need for idempotent accounting operations.
Simplified implementation architecture. Open a technology to inspect its responsibility.
Payload revisions and accounting recovery
Separate contract editing, finance approval and accounting execution permissions. Retain approval actor, payload hash, rule version and invoice receipt. Monitor failed activities, approval age and unmapped time. Bound retries for transient errors and classify invalid rates as non-retryable until corrected. Define reversal and credit-note handling with finance rather than deleting posted history.
Interrupt the accounting write after acceptance
Test changed time after approval, overlapping billing runs, rate boundaries, rounding, cap breaches and Xero timeouts after creation. Replay Temporal histories when worker code changes. Pilot with previews, then approved drafts in a test organization before any live billing run; retain a manual reconciliation route.
Count corrections and duplicate drafts beside preparation time
A quicker preview is useful when its lines survive finance review and its retries do not create another draft. These checkpoints define a billing-control review; no invoice correction rate or time saving is presented as achieved.
Prepare
Invoice preparation time
Finance minutes from complete approved inputs to a reviewed invoice preview.
Correct
Invoice correction rate
Reviewed drafts needing time, rate or contract corrections divided by reviewed drafts.
Deduplicate
Duplicate draft count
Confirmed duplicate accounting drafts sharing the same approved billing payload or time entries.
Authorize
Approval turnaround
Validated preview creation to finance decision, separating returned-for-correction cases.
Interactive demo
Inspect the invoice before finance authorizes it
An invoice preview keeps approved time, its effective rate and the contract exception visible. Select a billing line to see why it is ready, held or excluded.
That must be verified for the available account and interfaces. The workflow cannot treat imported time as approved without authoritative approval evidence.
Does Temporal guarantee a single invoice?
No. Durable execution does not remove the need for idempotent activities and accounting-side reconciliation after an ambiguous write.
What if a rate changes after finance approves?
The approved preview is immutable. A changed billing payload creates a new revision and requires fresh finance authorization.
Will invoices be sent automatically?
The workflow ends at an authorized draft. Posting and sending remain subject to the organization’s accounting approval controls.
Trace its approved time, contract rate version and accounting draft reference. We can identify where the billing rule became unclear and what must be frozen before approval.