Skip to Content

Invoicing

Every milestone in an active project generates an invoice. The invoice workflow tracks the lifecycle of each payment from draft through approval to settlement, with structured paths for disputes and rejections.

Flow

Invoice Creation

An invoice is created automatically when a milestone is marked complete. It inherits its financial values from the parent quote:

FieldCalculationDescription
amountquote.amount × (milestone.percentage / 100)Expert’s share for this milestone
serviceFeequote.serviceFee × (milestone.percentage / 100)Platform fee for this milestone
totalamount + serviceFeeTotal amount associated with this invoice

One invoice is created per milestone — enforced by a unique index on milestone. This means each milestone can only ever have one invoice, preventing duplicate billing.

Invoice Status Workflow

StatusTransition TypeMeaning
invoice_draftInvoice created on milestone completion; awaiting approval
invoice_submittedpositiveRaised by the expert, awaiting manager review
invoice_approvedpositiveManager has approved
invoice_sentpositiveSent to the customer; awaiting payment
invoice_disputednegativeManager has flagged an issue; loops back to submitted or draft after resolution
invoice_paidpositivePayment confirmed; project value released
invoice_rejectednegativeInvoice rejected outright; terminal state

Payment Recording

When an invoice is marked as paid:

  • paid = true is set on the invoice record
  • paidAt is required and must be provided — the model validates that paidAt exists whenever paid is true
  • isApproved = true is set to indicate the full approval and payment cycle is complete

These flags are also surfaced as computed virtuals on the parent milestone (isPaid, isApproved), allowing milestone progress to be derived without joining the invoice collection.

Invoice Fields

FieldTypeDescription
quoteQuote refThe quote this invoice is billed against
milestoneMilestone refThe completed milestone this invoice covers (unique)
leadLead refThe originating lead
expertUser refThe expert being paid
customerUser refThe customer being billed
managerUser refThe CSM managing the invoice
vendorUser refThe vendor account
amountNumberExpert payment for this milestone
serviceFeeNumberPlatform fee for this milestone
totalNumberTotal amount
statusStringCurrent invoice status name
paidBooleanWhether payment has been received
paidAtDateRequired when paid = true
dueDateDateOptional payment due date; falls back to the linked milestone’s due date when unset
pdfStringInvoice document URL

Notifications

Key invoice events trigger platform notifications to the relevant parties:

EventNotification KeyRecipients
Invoice raisedinvoice-raisedManager, Customer
Invoice approvedinvoice-approvedExpert
Invoice disputedinvoice-disputedExpert
Invoice rejectedinvoice-rejectedExpert
Payment confirmedinvoice-paidExpert, Customer
Last updated on