class Invoice extends AbstractModel

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 ()

Return Value

Invoice

static boot ()

string getViewInvoiceUrl (array|null $additionalQueryStringParams = null)

Get view invoice url.

Parameters

array|null $additionalQueryStringParams

Return Value

string

string getEditInvoiceUrl (array|null $additionalQueryStringParams = null)

Get Edit Invoice URL.

Parameters

array|null $additionalQueryStringParams

Return Value

string

protected string buildInvoiceUrl (string $baseUrl, array|null $additionalQueryStringParams)

Build full invoice URL with additional query parameters.

Parameters

string $baseUrl
array|null $additionalQueryStringParams

Return Value

string

getInvoiceNumber ()

array getCurrency ()

Get currency object for the invoice.

Return Value

array

string getCurrencyCodeAttribute ()

Get currency code.

Return Value

string

Currency|null getCurrencyModel ()

Return Value

Currency|null

BelongsTo client ()

Each invoice belongs to one client.

Return Value

BelongsTo

hasMany transactions ()

Each invoice can have many transactions.

Return Value

hasMany

HasMany items ()

Each invoice can have many line items.

Return Value

HasMany

hasOne snapshot ()

Each invoice can have one set of invoice snapshot data.

Return Value

hasOne

BelongsTo order ()

An invoice can belong to a single order.

Return Value

BelongsTo

BelongsToMany servicesProduct ()

Return Value

BelongsToMany

BelongsToMany servicesAddon ()

Return Value

BelongsToMany

BelongsToMany servicesDomain ()

Return Value

BelongsToMany

Builder scopeUnpaid (Builder $query)

Where status is unpaid.

Parameters

Builder $query

Return Value

Builder

Builder scopeOverdue (Builder $query)

Where status is overdue.

Parameters

Builder $query

Return Value

Builder

Builder scopePaid (Builder $query)

Where status is paid.

Parameters

Builder $query

Return Value

Builder

Builder scopeCancelled (Builder $query)

Where status is cancelled.

Parameters

Builder $query

Return Value

Builder

Builder scopeRefunded (Builder $query)

Where status is refunded.

Parameters

Builder $query

Return Value

Builder

Builder scopeCollections (Builder $query)

Where status is collections.

Parameters

Builder $query

Return Value

Builder

Builder scopePaymentPending (Builder $query)

Where status is payment-pending.

Parameters

Builder $query

Return Value

Builder

Builder scopeUnpaidOrPaymentPending (Builder $query)

Where status is unpaid or payment-pending.

Parameters

Builder $query

Return Value

Builder

Builder scopeMassPay (Builder $query, bool $isMassPay = true)

Where the invoice does not contain a line item that is of type "Invoice".

Parameters

Builder $query
bool $isMassPay True if you want to find only Mass Pay invoices, false only non Mass Pay

Return Value

Builder

Builder scopeWithLastCaptureAttempt (Builder $query, Carbon $date)

Where the last capture date is on a specific date

Parameters

Builder $query
Carbon $date The carbon object for the date to obtain data for

Return Value

Builder

float getBalanceAttribute ()

Calculate balance remaining for the invoice.

Return Value

float

float getInvoiceAmountAttribute ()

Return Value

float

string getPaymentGatewayNameAttribute ()

Return Value

string

float getAmountPaidAttribute ()

Return Value

float

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.

Return Value

bool

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.

Parameters

float $amount
string $transactionId
float $fees
string $gateway
bool $suppressEmail
Carbon $date

Return Value

bool

Exceptions

NotServicable Invalid argument for amount
NotServicable Attempting payment on an invoice in the Cancelled or Draft status
InvalidArgumentException if gateway is not provided and invoice. does not have one assigned to fall back to.

__construct (bool $suppressEmail)

Parameters

bool $suppressEmail

void observe (InvoicePayment $event)

Parameters

InvoicePayment $event

Return Value

void