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  boot() -
string getViewInvoiceUrl(array|null $additionalQueryStringParams = null) Get view invoice url.
getInvoiceNumber() -
array getCurrency() Get currency object for the invoice.
string getCurrencyCodeAttribute() Get currency code.
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 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.
string getPaymentGatewayNameAttribute() -
float getAmountPaidAttribute() -
bool addPayment(float $amount, string $transactionId = '', float $fees = 0.0, string $gateway = '', bool $noEmail = false, Carbon $date = null) -
bool addPaymentIfNotExists(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.
Invoice setStatusPending() Set invoice status to payment pending.
Invoice setStatusRefunded() Set invoice status to refunded.
Invoice setStatusCancelled() Set invoice status to cancelled.
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) -
Cart cart() Build a cart object based on the current invoice.
Invoice runCreationHooks(string $source) Run invoice creation hooks.
Collection getSubscriptionIds(array|null $paymentMethods = null) Get subscription IDs from items that belong to this invoice.
Invoice saveSubscriptionId(string $subscriptionId) Save subscription ID.
Builder scopeSubscriptionId(Builder $query, string $subscriptionId) Where the invoices contain items that have a given subscription ID.
getLink() -
$this setPaymentMethod(string $gatewayName) Set the invoice Payment Method.
$this setPayMethodId(int $payMethodId) Set the Pay Method ID for the invoice.
$this clearPayMethodId() Clear the associated Pay Method
getTaxrateAttribute() -
getTaxrate2Attribute() -
getGatewayInterface() -

Details

static boot ()

string getViewInvoiceUrl (array|null $additionalQueryStringParams = null)

Get view invoice url.

Parameters

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

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

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

bool addPaymentIfNotExists (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

Invoice setStatusPending ()

Set invoice status to payment pending.

Return Value

Invoice

Invoice setStatusRefunded ()

Set invoice status to refunded.

Return Value

Invoice

Invoice setStatusCancelled ()

Set invoice status to cancelled.

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

Cart cart ()

Build a cart object based on the current invoice.

Return Value

Cart

Invoice runCreationHooks (string $source)

Run invoice creation hooks.

Parameters

string $source One of 'adminarea', 'api', 'autogen' or 'clientarea'

Return Value

Invoice

Collection getSubscriptionIds (array|null $paymentMethods = null)

Get subscription IDs from items that belong to this invoice.

Parameters

array|null $paymentMethods

Return Value

Collection

Invoice saveSubscriptionId (string $subscriptionId)

Save subscription ID.

Parameters

string $subscriptionId

Return Value

Invoice

Builder scopeSubscriptionId (Builder $query, string $subscriptionId)

Where the invoices contain items that have a given subscription ID.

Parameters

Builder $query
string $subscriptionId

Return Value

Builder

$this setPaymentMethod (string $gatewayName)

Set the invoice Payment Method.

Parameters

string $gatewayName The name of the gateway. (e.g. 'paypal')

Return Value

$this

Exceptions

BillingException if gateway is not active.

$this setPayMethodId (int $payMethodId)

Set the Pay Method ID for the invoice.

Parameters

int $payMethodId The ID of the clients Pay Method to associate.

Return Value

$this

Exceptions

BillingException if Pay Method is not valid for the invoice gateway.
BillingException if Pay Method does not belong to the client that the invoice does.

$this clearPayMethodId ()

Clear the associated Pay Method

Return Value

$this

getTaxrateAttribute ()

getTaxrate2Attribute ()

getGatewayInterface ()