Billing and invoices
Bill a client from unbilled time, create and update invoices, record payments, tax and currency defaults.
Use this when the user bills clients: "invoice Acme for November", "what's outstanding", "Acme paid".
Create an invoice from unbilled time
list_organizationswithsearchto find the client. Invoices needtype: client.list_unbilled_timewith theorganization_id. It returns billable, finished entries that no invoice covers yet.- Show the user the hours and the total at the client's
hourly_rate(fromget_organization) and agree on the lines. create_invoicewithorganization_id,issue_date,due_dateanditems. Each item is{description, quantity, unit_price, unit}; unit ishours,days,pieces,story_pointsorflat. To tie a line to an entry, pass itstime_entry_idwithis_from_time_entry: true.- Leave
statusasdraft(the default). The user sends it.
Defaults: the invoice number is generated (INV-YYYY-NNNN) unless given. tax_rate defaults to the workspace's default tax rate, else 0. currency defaults to the workspace currency (USD, EUR or GBP). Totals and tax are computed for you. Set performance_period (the service period, required on German invoices) when the user bills a period.
An issued invoice settles all earlier time for that client, so a single aggregate line per month works.
Change and track
update_invoicechanges only the fields you send. Sendingitemsreplaces the line items.add_invoice_paymentrecords a payment withamount,payment_dateandmethod.list_invoicesfilters bystatus(overduealso matches sent invoices past due) and client.get_invoice_metricsgives counts and totals billed, paid and outstanding.list_budgetsshows client hour budgets against what was spent this period.
Pitfalls
list_budgetsreports hours, never money. Do not project a year as a month times 12: use the trailing and YTD hours it returns.delete_invoiceonly removes a draft. A sent, paid or overdue invoice keeps its number: setstatus: cancelledwithupdate_invoiceinstead, and confirm first.- Never mark an invoice
sentorpaidwithout the user saying so. - When the user asks to bill a client, create the invoice as a
draftwith one line per time entry fromlist_unbilled_time, each carrying itstime_entry_id(hours times the client's rate), and report the total. Withouttime_entry_idthe hours stay unbilled. A draft is safe: nothing is sent until the user marks it sent. Ask only if the client has no rate.