Bill every ShipHero shipment as a draft Xero invoice

Every shipment that leaves your warehouse gets priced against that brand's rate card, drafted as a Xero invoice, and logged to a running billing ledger.

Deterministic Code
ShipHeroXeroGoogle SheetsFinanceOperationsData Sync
PromptCreate

Build me a code workflow that turns every outbound shipment into a billable draft invoice. Use a ShipHero poll trigger on new shipments, so the workflow runs once for each shipment that ships out of the warehouse. Every step here is deterministic and the amounts must be reproducible, so nothing about the pricing should be left to judgement.

For each shipment, call ShipHero Get shipment to read the shipment id, the ship date, the carrier and service used, the package weight, and the shipped line items with their quantities. Then call ShipHero Get order for the order behind that shipment to read the order number and the customer_account_id. On a 3PL account, customer_account_id identifies the brand the shipment belongs to, and it is the key for everything downstream: which rate card applies, whether the brand is billable, and which Xero contact the invoice is raised against.

Keep the rate card in workflow configuration as structured input rather than in code, so someone can change fees without editing logic. For each brand hold: the brand name, the ShipHero customer_account_id, the Xero contact id to invoice, a pick and pack base fee, a per additional item handling fee, how shipping is charged (pass the carrier cost through, or apply a fixed markup percentage), and a flag for whether the brand is on a flat monthly plan.

Skip shipments for brands on a flat monthly plan, since those clients pay a fixed retainer and must not also be billed per shipment. Also skip, and record as skipped, any shipment whose customer_account_id has no rate card entry. Never invent or estimate a fee for a brand you do not have rates for.

Compute the billable lines from the rate card and the shipment data. Add one pick and pack base fee line for the shipment. Add one additional item handling line priced as the total shipped units minus one, multiplied by the per additional item fee, and omit that line entirely when only one unit shipped. Add one shipping line for the carrier and service used, following the brand's shipping charge rule. Round money to two decimals, and give each line a description naming the fee and the order number so the invoice reads clearly to the client.

Create the invoice with Xero Create Invoices as a sales invoice (type ACCREC) against that brand's Xero contact, with status DRAFT. Do not approve, authorise, or send it. Finance reviews and approves drafts before anything reaches a client. Put the shipment id and the order number in the invoice reference so every invoice traces back to the shipment that produced it.

Then append one row to the fulfillment billing ledger spreadsheet using Google Sheets Append Values, with the shipment id, order number, brand, ship date, carrier and service, package weight, invoiced total, and the resulting Xero invoice id. This ledger is what finance reconciles the Xero drafts against at month end, so it should be a complete running record of what was billed.

Make the workflow safe to re-run. Before creating anything, check whether the shipment id already appears in the ledger sheet, and skip the shipment if it does, so a replayed trigger can never double-bill a brand. If Xero rejects the invoice, do not append a ledger row, because the ledger must only contain shipments that were actually invoiced.

What does this prompt do?

  • Picks up every shipment as it leaves your ShipHero warehouse, and reads the order behind it to see which brand it belongs to, what shipped, how much it weighed, and which carrier and service carried it.
  • Prices the shipment against the rate card you set for that brand: a pick and pack base fee, a handling fee for each additional item, and the shipping charge.
  • Creates a draft sales invoice in Xero against that brand's contact, referenced back to the shipment and order number so finance can trace every line.
  • Appends a row to a Google Sheet ledger with the shipment, order number, brand, ship date, carrier, weight and invoiced total, giving you a running record to reconcile against at month end.

What do I need to use this?

  • A ShipHero account with access to your orders and shipments
  • A Xero organisation where you raise sales invoices, with a contact already set up for each brand you bill
  • A Google Sheet to hold the billing ledger
  • Your per-brand rate card: the base pick and pack fee, the fee for each additional item, and how you charge for shipping
  • A list of which brands are on a flat monthly plan, so they can be left out of per-shipment billing

How can I customize it?

  • Edit the fees for any brand, or add a new brand, straight from the workflow settings without touching the billing logic.
  • Mark brands that are on a flat monthly plan so their shipments are skipped instead of invoiced.
  • Choose how shipping is charged: pass the carrier cost through as-is, or add a fixed markup on top.
  • Change which columns land in the ledger sheet to match how your finance team already reconciles.

FAQs

Will invoices be sent to my clients automatically?
No. Every invoice is created in Xero as a draft and left there. Nothing is approved, emailed, or sent to a client until someone on your finance team reviews it and approves it themselves. That is deliberate: billing mistakes are expensive to unwind once a client has seen them.
What happens to brands on a flat monthly plan?
They are skipped. You mark those brands in the rate card settings, and their shipments are recorded as skipped rather than invoiced, so a client on a fixed monthly retainer never gets billed twice for the same fulfillment.
Can each brand have different rates?
Yes, and that is the point. The rate card holds a separate set of fees for every brand you fulfill for, so a high-volume client on discounted pick and pack rates and a smaller client on standard rates are both billed correctly from the same workflow.
How are multi-item orders priced?
The base pick and pack fee covers the shipment itself, and the additional item handling fee is applied to every unit beyond the first. A single-item shipment is billed the base fee only, with no handling line added.
What stops a shipment being invoiced twice?
The ledger sheet is checked before anything is created. If a shipment already appears there, it is skipped, so a repeated run cannot produce a duplicate invoice for work you have already billed.
Do I still need to check the numbers?
The invoice amounts are calculated from your rate card and the actual shipment data, so they are reproducible rather than estimated. The Google Sheet ledger gives you the full run of shipments and totals side by side, which is what you reconcile the Xero invoices against at month end.

Related templates

Weekly Amazon S3 bucket security audit posted to Slack

Every Monday, check every S3 bucket for public exposure, missing encryption and weak backup settings, then get the risks ranked in Slack.

Amazon S3
Slack Bot
Google Sheets
Agentic Task
Turn procurement portal tenders into CRM deals each morning

Every weekday at 7am, sign in to the tender portals you track, filter new notices against your bid criteria, and open a deal for the ones worth chasing.

Anchor Browser
Google Sheets
HubSpot
+1
Agentic Task
Draft polite follow-ups for emails that never got a reply

Every weekday at 4pm, spot the threads that went quiet, stage a ready-to-send nudge in your mailbox, and get a ranked Slack recap.

Aurinko
Google Sheets
Slack Bot
Agentic Task
Flag VIP client emails in Zoho Mail and alert your team

Keep a spreadsheet of your most important senders, and every email from one gets labeled, posted to your team channel, and logged automatically.

Zoho Mail
Google Sheets
Slack Bot
Deterministic Code
Send Yotpo review requests when Shopify orders ship

The moment an order is fulfilled, we register it with Yotpo so the review request is timed off real delivery, and we log every sync so failures never go unnoticed.

Shopify
Yotpo
Google Sheets
Deterministic Code
Reconcile Shopify sales against Zoho Books every night

Every night at 11pm we compare the day's Shopify orders with your Zoho Books invoices and payments, and flag only what does not match.

Zoho Books
Shopify
Google Sheets
+1
Agentic Task

Stop rebuilding your 3PL invoices in a spreadsheet every month.

Let every shipment price itself the moment it leaves the warehouse, and hand finance a clean set of drafts to approve.