class Invoice extends AbstractModel

Constants

STATUS_DRAFT

STATUS_UNPAID

STATUS_PAID

Properties summary

Type Property Description
protected $table
protected $dates
protected $columnMap
$timestamps
protected $appends

Methods summary

Return Type Method Name Description
static  boot() -
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.
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 collections.
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.
string getPaymentGatewayNameAttribute() -
float getAmountPaidAttribute() -
bool addPayment(float $amount, string $transactionId = '', float $fees = 0.0, string $gateway = '', bool $noEmail = false, Carbon $date = null) -
array getBillingValues() -
bool shouldRenewRun(integer $relatedId, string $registrationDate, string $type = 'Hosting') Checks if the module renewal should run for a provided related id, registration date and type of item.
Vat vat() -
static Invoice newInvoice(integer $clientId, string $gateway = null, float $taxRate1 = null, float $taxRate2 = null) Create a new invoice in Draft and return the instance to be updated and saved.
Invoice setStatusUnpaid() Set invoice status to unpaid.
hasOne data() Each invoice can have one set of invoice data.
HasMany|History[] transactionHistory() -
BelongsTo|Model payMethod() -
string getPayMethodRemoteToken() -
setPayMethodRemoteToken($remoteToken) -
deletePayMethod() -
convertLocalCardToRemote($remoteToken) -
convertLocalBankAccountToRemote($remoteToken) -
saveRemoteCard($cardLastFour, $cardType, $expiryDate, $remoteToken) -
saveRemoteBankAccount($bankName, $remoteToken) -

Details

static boot ()

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

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 collections.

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

string getPaymentGatewayNameAttribute ()

Return Value

string

float getAmountPaidAttribute ()

Return Value

float

bool addPayment (float $amount, string $transactionId = '', float $fees = 0.0, string $gateway = '', bool $noEmail = false, Carbon $date = null)

Parameters

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

Return Value

bool

Exceptions

NotServicable
Fatal

array getBillingValues ()

Return Value

array

bool shouldRenewRun (integer $relatedId, string $registrationDate, string $type = 'Hosting')

Checks if the module renewal should run for a provided related id, registration date and type of item.

Parameters

integer $relatedId The id of the item for the invoice being paid. tblhosting.id or tblhostingaddons.id
string $registrationDate in mysql date format
string $type Either one of Hosting or Addon. Exception will be thrown for other item types.

Return Value

bool

Exceptions

NotServicable

Vat vat ()

Return Value

Vat

static Invoice newInvoice (integer $clientId, string $gateway = null, float $taxRate1 = null, float $taxRate2 = null)

Create a new invoice in Draft and return the instance to be updated and saved.

Parameters

integer $clientId
string $gateway
float $taxRate1
float $taxRate2

Return Value

Invoice

Invoice setStatusUnpaid ()

Set invoice status to unpaid.

Return Value

Invoice

hasOne data ()

Each invoice can have one set of invoice data.

Return Value

hasOne

HasMany|History[] transactionHistory ()

Return Value

HasMany|History[]

BelongsTo|Model payMethod ()

Return Value

BelongsTo|Model

string getPayMethodRemoteToken ()

Return Value

string

setPayMethodRemoteToken ($remoteToken)

Parameters

$remoteToken

deletePayMethod ()

convertLocalCardToRemote ($remoteToken)

Parameters

$remoteToken

convertLocalBankAccountToRemote ($remoteToken)

Parameters

$remoteToken

saveRemoteCard ($cardLastFour, $cardType, $expiryDate, $remoteToken)

Parameters

$cardLastFour
$cardType
$expiryDate
$remoteToken

saveRemoteBankAccount ($bankName, $remoteToken)

Parameters

$bankName
$remoteToken