Owns invoices, quotes and payment lists for the current organisation: looks them up, counts them and starts new ones via builders. Registered with the application manager as the JS service "invoiceManager", so app developers reach it as invoiceManager from server-side JS.
Group: Managers
Methods
invoiceBuilder(Date now, Profile createdBy) · findInvoiceStatus(String status) · findQuoteStatus(String status) · findInvoices(Date startDate, Date endDate) · findInvoices(String status, Date startDate, Date endDate) · countInvoices(String status, Date startDate, Date endDate) · countQuotes(String status, Date startDate, Date endDate) · quoteBuilder(Date now, Profile createdBy) · findInvoiceByNumber(String invoiceNumber) · findPaymentListByNumber(String num) · nextInvoiceNumber()
invoiceBuilder(Date now, Profile createdBy)
Returns: InvoiceBuilder
Starts a builder for a new invoice, ready to have its fields set before being persisted.
| Parameter | Description |
|---|---|
now | the date and time the invoice is being created |
createdBy | the profile creating the invoice |
findInvoiceStatus(String status)
Returns: InvoiceStatus
Parses a free-text value into the matching invoice status.
| Parameter | Description |
|---|---|
status | the text to parse, such as "draft", "sent", "overdue" or "paid" |
findQuoteStatus(String status)
Returns: QuoteStatus
Parses a free-text value into the matching quote status.
| Parameter | Description |
|---|---|
status | the text to parse, matched case-insensitively against the quote status names |
findInvoices(Date startDate, Date endDate)
Returns: List<Invoice>
Looks up all invoices for the current organisation issued within a date range, regardless of status.
| Parameter | Description |
|---|---|
startDate | the earliest issue date to include |
endDate | the latest issue date to include |
findInvoices(String status, Date startDate, Date endDate)
Returns: List<Invoice>
Looks up invoices for the current organisation, optionally filtered by status, issued within a date range.
| Parameter | Description |
|---|---|
status | the invoice status to filter by, or null to include all statuses |
startDate | the earliest issue date to include |
endDate | the latest issue date to include |
countInvoices(String status, Date startDate, Date endDate)
Returns: long
Counts invoices for the current organisation, optionally filtered by status, issued within a date range.
| Parameter | Description |
|---|---|
status | the invoice status to filter by, or null to include all statuses |
startDate | the earliest issue date to include |
endDate | the latest issue date to include |
countQuotes(String status, Date startDate, Date endDate)
Returns: Long
Counts quotes for the current organisation, optionally filtered by status, issued within a date range.
| Parameter | Description |
|---|---|
status | the quote status to filter by (parsed with findQuoteStatus), or null to include all statuses |
startDate | the earliest issue date to include |
endDate | the latest issue date to include |
quoteBuilder(Date now, Profile createdBy)
Returns: QuoteBuilder
Starts a builder for a new quote, ready to have its fields set before being persisted.
| Parameter | Description |
|---|---|
now | the date and time the quote is being created |
createdBy | the profile creating the quote |
findInvoiceByNumber(String invoiceNumber)
Returns: Invoice
Looks up a single invoice for the current organisation by its invoice number.
| Parameter | Description |
|---|---|
invoiceNumber | the invoice number to search for |
findPaymentListByNumber(String num)
Returns: PaymentItemList
Looks up a payment item list (invoice, quote or purchase order) for the current organisation by its number.
| Parameter | Description |
|---|---|
num | the payment list number to search for |
nextInvoiceNumber()
Returns: String
Generates the next available invoice number for the current organisation, for use on a new invoice.