The moment it happens
Create PDF invoices from your order form
Each order from your form gets a numbered PDF invoice saved to Drive and a row in your Invoices sheet.
- Runs
- The moment it happens
- Apps
- Google Drive, Google Sheets
- AI
- Not needed
- Access
- Drive write; Sheets read+write
Send this to your assistant
Create a ClickRuntime automation: when my order form posts to the trigger link, create a PDF invoice with the next invoice number, save it to my Drive 'Invoices' folder and add a row to my Invoices sheet.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A small catering business takes orders through a form on its website. After each event, the owner opens a word processor template, types in the customer, items and prices, works out the next invoice number from last month's file, and saves a PDF. Numbers get skipped or repeated, and the list of what has been invoiced lives only in a folder.
Generating the invoice the moment an order comes in gives every customer a proper invoice with a unique number and keeps a running list for your accounts. Caterers, makers and small service businesses use it to invoice without accounting software.
What you get out of it
Invoice numbers are never repeated
Each invoice takes the next number in sequence, which keeps your records tidy and your accountant happy.
Every invoice is filed
PDFs are saved to one Drive folder, so you can find any invoice by customer or number.
A ledger that keeps itself
Each invoice adds a row with date, customer and total, which gives you a running record of sales.
No retyping order details
Customer details and items come from the order form, so prices and names are not copied by hand.
How it works
What happens, step by step
ClickRuntime starts as soon as your order form sends a new order.
It ignores an order it has already invoiced, so a repeated delivery does not create a second invoice.
It creates a PDF invoice with the next invoice number, the customer's details and the items ordered, and saves it to your Drive Invoices folder.
A row with the invoice number, date, customer, total and a link to the PDF is added to your Invoices sheet.
Before it runs live
- Connect Google Drive
- Connect your Google Sheets account and pick the spreadsheets it may use
- Paste your automation's link into the other app's webhook settings
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Act only on the items that match your own rules, and skip the rest
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Google Drive and Google Sheets steps into one automation
Under the hood
The code that runs this automation
import io
from datetime import date
from reportlab.pdfgen import canvas
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from googleapiclient.http import MediaIoBaseUpload
from clickruntime import on_event, credentials, state
FOLDER_ID, SHEET_ID = "your-invoices-folder-id", "your-spreadsheet-id"
@on_event
def handle(event):
if state.get(f"done:{event.event_id}"):
return {"skipped": "duplicate"}
order = event.json
number = (state.get("last_number") or 1000) + 1
total = sum(i["qty"] * i["price"] for i in order["items"])
buf = io.BytesIO(); pdf = canvas.Canvas(buf)
lines = [f"Invoice {number}", f"Date: {date.today()}", f"Bill to: {order['name']}", ""] + [f"{i['qty']} x {i['item']} @ {i['price']:.2f}" for i in order["items"]] + ["", f"Total: {total:.2f}"]
for n, line in enumerate(lines):
pdf.drawString(60, 780 - n * 18, line)
pdf.save()
creds = Credentials(credentials.connection("google", "work"))
f = build("drive", "v3", credentials=creds, cache_discovery=False).files().create(body={"name": f"Invoice {number}.pdf", "parents": [FOLDER_ID]},
media_body=MediaIoBaseUpload(io.BytesIO(buf.getvalue()), mimetype="application/pdf"), fields="webViewLink").execute()
build("sheets", "v4", credentials=creds, cache_discovery=False).spreadsheets().values().append(spreadsheetId=SHEET_ID, range="Invoices!A:E",
valueInputOption="USER_ENTERED", body={"values": [[number, str(date.today()), order["name"], total, f["webViewLink"]]]}).execute()
state.set("last_number", number)
state.set(f"done:{event.event_id}", True)
return {"invoice": number}FAQ
Common questions
What does the invoice include?
How is the invoice number chosen?
Does it email the invoice to the customer?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Save incoming files to Drive and log them in a sheet
Files sent to your trigger link are saved in your Drive 'Inbox' folder and listed in a sheet with name, sender, date and link.
See how it worksLog your arrival and departure times automatically
Your phone records each time you arrive at or leave work in a Google Sheet, and last month's log is saved to Drive on the 1st.
See how it worksCreate a Drive folder for each new hire in your roster
New rows in your Onboarding sheet get their own Drive folder from your template, shared with the new hire, with the link written back.
See how it worksKeep exploring
Set up “Create PDF invoices from your order form” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.