Invoice
Constants
STATUS_CANCELLED |
|
STATUS_COLLECTIONS |
|
STATUS_DRAFT |
|
STATUS_PAID |
|
STATUS_PAYMENT_PENDING |
|
STATUS_REFUNDED |
|
STATUS_UNPAID |
|
PAYMENT_CONFIRMATION_EMAIL |
|
CC_CONFIRMATION_EMAIL |
|
CC_FAILED_EMAIL |
|
CC_PENDING_EMAIL |
|
DD_CONFIRMATION_EMAIL |
|
DD_FAILED_EMAIL |
|
DD_PENDING_EMAIL |
|
INVOICE_PAYMENT_EMAILS |
|
PAYMENT_CONFIRMATION_EMAILS |
|
PAYMENT_FAILED_EMAILS |
|
PAYMENT_PENDING_EMAILS |
|
Properties summary
Type | Property | Description | |
---|---|---|---|
protected | $table | ||
protected | $dates | ||
protected | $columnMap | ||
protected | $appends |
Methods summary
Return Type | Method Name | Description | |
---|---|---|---|
static Invoice | factoryWithoutStatusIndex() | - | |
static | boot() | - | |
string | getViewInvoiceUrl(array|null $additionalQueryStringParams = null) | Get view invoice url. | |
string | getEditInvoiceUrl(array|null $additionalQueryStringParams = null) | Get Edit Invoice URL. | |
string | buildInvoiceUrl(string $baseUrl, array|null $additionalQueryStringParams) | Build full invoice URL with additional query parameters. | |
getInvoiceNumber() | - | ||
array | getCurrency() | Get currency object for the invoice. | |
string | getCurrencyCodeAttribute() | Get currency code. | |
Currency|null | getCurrencyModel() | - | |
BelongsTo | client() | Each invoice belongs to one client. | |
hasMany | transactions() | Each invoice can have many transactions. | |
HasMany | items() | Each invoice can have many line items. | |
hasOne | snapshot() | Each invoice can have one set of invoice snapshot data. | |
BelongsTo | order() | An invoice can belong to a single order. | |
BelongsToMany | servicesProduct() | - | |
BelongsToMany | servicesAddon() | - | |
BelongsToMany | servicesDomain() | - | |
Builder | scopeUnpaid(Builder $query) | Where status is unpaid. | |
Builder | scopeOverdue(Builder $query) | Where status is overdue. | |
Builder | scopePaid(Builder $query) | Where status is paid. | |
Builder | scopeCancelled(Builder $query) | Where status is cancelled. | |
Builder | scopeRefunded(Builder $query) | Where status is refunded. | |
Builder | scopeCollections(Builder $query) | Where status is collections. | |
Builder | scopePaymentPending(Builder $query) | Where status is payment-pending. | |
Builder | scopeUnpaidOrPaymentPending(Builder $query) | Where status is unpaid or payment-pending. | |
Builder | scopeMassPay(Builder $query, bool $isMassPay = true) | Where the invoice does not contain a line item that is of type "Invoice". | |
Builder | scopeWithLastCaptureAttempt(Builder $query, Carbon $date) | Where the last capture date is on a specific date | |
float | getBalanceAttribute() | Calculate balance remaining for the invoice. | |
float | getInvoiceAmountAttribute() | - | |
string | getPaymentGatewayNameAttribute() | - | |
float | getAmountPaidAttribute() | - | |
bool | hasRemainingBalanceDue() | Remaining balance is the invoice total minus the sum of all transactions towards the invoice, with consideration of the currency's decimal/no-decimal format. | |
bool | addPayment(float $amount, string $transactionId = '', float $fees = 0.0, string $gateway = '', bool $suppressEmail = false, Carbon $date = null) | "add a payment" means to record a transaction for an invoice, and per this method, also means updating the invoice status, managing overpayments, updating services referenced in the invoice, and other invoice-adjacent observable events. | |
__construct(bool $suppressEmail) | - | ||
void | observe(InvoicePayment $event) | - |
Details
static Invoice
factoryWithoutStatusIndex ()
static
boot ()
string
getViewInvoiceUrl (array|null $additionalQueryStringParams = null)
Get view invoice url.
string
getEditInvoiceUrl (array|null $additionalQueryStringParams = null)
Get Edit Invoice URL.
protected string
buildInvoiceUrl (string $baseUrl, array|null $additionalQueryStringParams)
Build full invoice URL with additional query parameters.
getInvoiceNumber ()
array
getCurrency ()
Get currency object for the invoice.
string
getCurrencyCodeAttribute ()
Get currency code.
Currency|null
getCurrencyModel ()
BelongsTo
client ()
Each invoice belongs to one client.
hasMany
transactions ()
Each invoice can have many transactions.
HasMany
items ()
Each invoice can have many line items.
hasOne
snapshot ()
Each invoice can have one set of invoice snapshot data.
BelongsTo
order ()
An invoice can belong to a single order.
BelongsToMany
servicesProduct ()
BelongsToMany
servicesAddon ()
BelongsToMany
servicesDomain ()
Builder
scopeUnpaid (Builder $query)
Where status is unpaid.
Builder
scopeOverdue (Builder $query)
Where status is overdue.
Builder
scopePaid (Builder $query)
Where status is paid.
Builder
scopeCancelled (Builder $query)
Where status is cancelled.
Builder
scopeRefunded (Builder $query)
Where status is refunded.
Builder
scopeCollections (Builder $query)
Where status is collections.
Builder
scopePaymentPending (Builder $query)
Where status is payment-pending.
Builder
scopeUnpaidOrPaymentPending (Builder $query)
Where status is unpaid or payment-pending.
Builder
scopeMassPay (Builder $query, bool $isMassPay = true)
Where the invoice does not contain a line item that is of type "Invoice".
Builder
scopeWithLastCaptureAttempt (Builder $query, Carbon $date)
Where the last capture date is on a specific date
float
getBalanceAttribute ()
Calculate balance remaining for the invoice.
float
getInvoiceAmountAttribute ()
string
getPaymentGatewayNameAttribute ()
float
getAmountPaidAttribute ()
bool
hasRemainingBalanceDue ()
Remaining balance is the invoice total minus the sum of all transactions towards the invoice, with consideration of the currency's decimal/no-decimal format.
Ex. if the invoice total was set to 666.66, and the payment history was in Japanese Yen (JPY), once there is enough transactions totalling
= 666.50, this method would return FALSE. If the payment history was in USD, the target sum would be >= 666.66 for this method to return FALSE.
bool
addPayment (float $amount, string $transactionId = '', float $fees = 0.0, string $gateway = '', bool $suppressEmail = false, Carbon $date = null)
"add a payment" means to record a transaction for an invoice, and per this method, also means updating the invoice status, managing overpayments, updating services referenced in the invoice, and other invoice-adjacent observable events.