For U.S. recordkeeping context, the IRS lists supporting documents that document business transactions. Keep the approved time and rate evidence behind this draft; the example does not establish local invoice or tax compliance.
Define the billing-reconciliation output
The fictional Northstar Studio fixture contains thirteen time entries and four rate rules. Twelve entries are approved and billable; one administrative correction is explicitly non-billable. The negative V1 duplicates 1.5 project-management hours and applies a paid rate to the excluded entry. The corrected workbook and PDF show 33.00 hours and a $2,917.50 subtotal, but remain NOT_SENT.
Billing states used by the reconciliation
| Term | Meaning in this tutorial |
|---|---|
| Approved time | A source entry accepted under the freelancer’s real approval process. |
| Rate rule | The agreed mapping from work code to price and billing increment. |
| Source-entry lineage | The list of time IDs that composes one invoice line. |
| Draft ceiling | READY_FOR_FREELANCER_REVIEW: no client delivery or payment request. |
How a polished invoice can overcharge
| Billing defect | Planted V1 line | Financial effect |
|---|---|---|
| Duplicate source | T-012 appears twice in the PM total | Plausible grouped hours can hide repeated input. |
| Non-billable conversion | T-013 receives the PM rate | A nearby paid code does not override an explicit exclusion. |
| Overstated subtotal | V1 totals $3,047.50 | The error is $130.00 despite individually plausible lines. |
| Premature state | A polished PDF looks send-ready | Appearance does not prove identity, terms, tax, or authorization. |
Step 1: freeze approved time and rate inputs
Source preparation. Export the approved time log and the governing rate sheet separately. Each time row needs a stable entry ID, date, work code, description, hours, and approval state. Each rate needs its billing rule.
Inventory time entries and rates. Return duplicates, missing codes, disallowed increments, non-billable rows, approval gaps, and conflicts. Do not calculate an invoice yet.Evidence retained. The retained source has thirteen unique IDs. T-001 through T-012 are approved billable work; T-013 is a 0.50-hour administrative correction with a $0.00 rule.

Stop condition. Confirm that approval happened outside the AI workflow. A model label such as APPROVED is not evidence that a client or project owner accepted the time.
Step 2: map every billable entry exactly once
Structuring decision. Group rows by the actual work code and retain the composing IDs. Do not group by similar wording, because two descriptions can legitimately use different rates.
Group only APPROVED billable rows by work_code. Return description, summed hours, exact approved rate, amount, and semicolon-separated source entry IDs. List excluded rows separately.Structured result. The corrected lines contain six design IDs, three revision IDs, and three coordination IDs. The twelve billable IDs are unique; T-013 appears only in the exclusion record.

Integrity check. Flatten the source-entry lists and compare them with the billable source inventory. Set equality and uniqueness are stronger checks than matching a total alone.
Step 3: define arithmetic and state rules
Release contract. Specify rounding, currency, approved rates, exclusion behavior, and release state before requesting a formatted invoice. Keep legal identity, tax, payment terms, and purchase-order fields open for human review.
Calculate amount = hours × approved rate using decimal arithmetic. Preserve two decimals. Never infer tax, currency conversion, payment terms, legal names, bank details, or client acceptance. End at READY_FOR_FREELANCER_REVIEW.Contract outcome. The contract treats formatting as the last step and makes external sending an explicit false state.

Boundary check. Use the actual contract and jurisdictional requirements for a real invoice. This tutorial does not supply tax or legal defaults.
Step 4: retain the overstated AI V1
First-pass test. Save the first grouped draft and its total before corrections. A retained failure makes the audit testable and prevents the final PDF from becoming the only record.
Draft grouped invoice lines from the time log and rate sheet. Include hours, rate, amount, and total.Observed failure. V1 correctly grouped design and revision, but coordination contained 5.25 hours instead of 3.75, and a non-billable correction was charged at $65. The subtotal was overstated by $130.00.

Failure check. Do not begin by comparing the grand total with an expectation. Inspect source ID uniqueness, eligibility, hours, rate, line multiplication, then the subtotal.
Step 5: reconcile hours, rates, scope, and amount
Evidence audit. Compare each proposed line with source IDs and the rate table. Recompute with decimal values, remove duplicates, and keep exclusions visible.
Audit V1 for duplicate entry IDs, excluded entries, code-to-rate mismatches, hour sums, line multiplication, and subtotal. Return the minimum correction and a corrected line table.Audit finding. The corrected workbook reports 22.25 design hours at $95, 7.00 revision hours at $80, and 3.75 coordination hours at $65. The subtotal is $2,917.50.

Source check. Reperform the calculation independently. The workbook’s computed amount and line gate should agree with the stored amount, but formula agreement cannot prove the source hours were approved.
Step 6: export a review-only PDF
Corrected deliverable. Populate a visibly fictional invoice layout without bank details. Mark the status NOT_SENT and put the reconciliation summary near the line table. Preserve open reviewer decisions.
Create a one-page invoice draft from the verified lines. Label every party fictional, show source IDs, mark READY_FOR_FREELANCER_REVIEW and NOT_SENT, omit banking details, and include the evidence boundary.Corrected result. The PDF renders the three lines, 33.00 hours, $2,917.50 subtotal, excluded T-013 note, and duplicate correction. It does not request payment.
Artifact check. Replace fictional identity only after verifying the real legal entity, client, currency, tax, terms, invoice number, purchase order, and remittance method.
Step 7: render every sheet and the exported page
Export review. Render all four workbook sheets and the PDF itself. Scan formulas for spreadsheet errors and inspect typography, contrast, clipping, amounts, and status labels.
Render INVOICE REVIEW, TIME LOG, RATE SHEET, and AI V1 AUDIT. Search formulas for #REF!, #DIV/0!, #VALUE!, #NAME?, and #N/A. Render the exported PDF page from disk.Export evidence. All sheets rendered, the formula scan matched zero errors, and the PDF required one visual fix: masthead text was changed from dark-on-navy to white-on-navy before acceptance.

Portability check. Retain the corrected generated file, not only a screenshot. Visual QA is where a mathematically correct but unreadable invoice should fail.
Step 8: run the freelancer-release gate
Release decision. Execute the deterministic invoice checker. It must prove twelve billable IDs appear once, T-013 is excluded, rates match, hours total 33.00, and subtotal equals $2,917.50.
python3 invoice-evidence-gate.pyGate result. All retained checks passed, and duplicate, non-billable rate, overstated total, and sent-state mutations were rejected. Invoice sent and payment requested both remained false.

Owner check. A real freelancer or bookkeeper must approve the final document. Never let an AI system send invoices or initiate payment merely because a reconciliation script passes.
Limits of the fictional billing record
This is a fictional billing fixture, not accounting, tax, legal, collections, or contract advice. The run does not prove client acceptance, work authorization, tax treatment, invoice numbering, identity, payment terms, currency, or banking accuracy. No invoice or payment request was transmitted.
When the invoice draft is ready for freelancer review
- Every billed source entry appears exactly once, uses an approved work code and rate, and reconciles to the line total.
- Excluded administration, overstated V1, correction lineage, XLSX formulas, PDF render, and unsent state remain visible.
- Tax position, payment status, contract interpretation, client acceptance, and legal identity are still unresolved.
- The freelancer or bookkeeper owns every real line and the decision to transmit it.
