BillableManager
in package
Uses
ActivityLogger
Table of Contents
- DAYS_PER_MONTH = 28
- HOURS_PER_DAY = 24
- MINUTES_PER_HOUR = 60
- SECONDS_PER_MINUTE = 60
- $errorLogName : string
- $warningLogName : string
- $jobsLogName : string
- The name of the log in which we are going to log actions performed by jobs
- $currency : string
- buildDescription() : string
- buildDescriptionFromComposition() : string
- calculateHourly() : array<string|int, mixed>
- calculateMonthly() : array<string|int, mixed>
- calculateMonthlyPrevisionForProject() : string
- calculateOneTime() : array<string|int, mixed>
- calculatePerUsage() : array<string|int, mixed>
- cloneCosts() : void
- This function will clone costs from another Billable entity It is used, inside this trait, to clone costs from the priceList
- closeBillingEntries() : void
- closeBillingEntry() : bool
- createBillingEntry() : void
- Creates a new price list entry for a specific model - that implements the IsBillable Trait
- customersWithBillingToInvoice() : CustomerResourceCollection
- Fetch all customers with invoice to be generated
- fetchBillingEntrySummaryForAllProjects() : array<string|int, mixed>
- Get all billing enetries for all user projects
- fetchBillingEntrySummaryForProject() : array<string|int, mixed>
- Fetch a summary of payed invoices
- getPartialBillingSummaryForBillingEntry() : array<string|int, mixed>
- Calculate the price of the billing entry at $billableTo date
- getPriceComposition() : array<string|int, mixed>
- hasBillingToInvoiceByProject() : bool
- Checks if the project has billing entry to invoice
- logEntry() : Activity
- logEntryWithoutModel() : Activity
- logError() : Activity
- logWarning() : Activity
- setPriceList() : void
- This function will handle the priceList for a billable model.
- updateBillingEntries() : void
- Updated the price list entry data, based on a specific model - that impements the IsBillable Trait
- updatePartialBillingEntries() : void
- Update all not closed billing entry with the partial price until $billableTo
- log() : array<string|int, Activity>
Constants
DAYS_PER_MONTH
protected
mixed
DAYS_PER_MONTH
= 28
HOURS_PER_DAY
protected
mixed
HOURS_PER_DAY
= 24
MINUTES_PER_HOUR
protected
mixed
MINUTES_PER_HOUR
= 60
SECONDS_PER_MINUTE
protected
mixed
SECONDS_PER_MINUTE
= 60
Properties
$errorLogName
public
static string
$errorLogName
= "error"
$warningLogName
public
static string
$warningLogName
= "warning"
$jobsLogName
The name of the log in which we are going to log actions performed by jobs
protected
string
$jobsLogName
= "jobs"
$currency
private
static string
$currency
= "€"
Methods
buildDescription()
public
static buildDescription(BillingEntry $billingEntry, IsBillableAbstractClass $model, array<string|int, mixed> $pricingComposition[, array<string|int, mixed> $modelChanges = [] ]) : string
Parameters
- $billingEntry : BillingEntry
- $model : IsBillableAbstractClass
- $pricingComposition : array<string|int, mixed>
- $modelChanges : array<string|int, mixed> = []
Return values
string —buildDescriptionFromComposition()
public
static buildDescriptionFromComposition(array<string|int, mixed> $priceComposition) : string
Parameters
- $priceComposition : array<string|int, mixed>
Return values
string —calculateHourly()
public
static calculateHourly(BillingEntry $billingEntry, IsBillableAbstractClass $model, Carbon $billable_to_ts) : array<string|int, mixed>
Parameters
- $billingEntry : BillingEntry
- $model : IsBillableAbstractClass
- $billable_to_ts : Carbon
Tags
Return values
array<string|int, mixed> —calculateMonthly()
public
static calculateMonthly(BillingEntry $billingEntry, IsBillableAbstractClass $model, Carbon $billable_to_ts) : array<string|int, mixed>
Parameters
- $billingEntry : BillingEntry
- $model : IsBillableAbstractClass
- $billable_to_ts : Carbon
Tags
Return values
array<string|int, mixed> —calculateMonthlyPrevisionForProject()
public
calculateMonthlyPrevisionForProject(Project $project) : string
Parameters
- $project : Project
Return values
string —decimal total
calculateOneTime()
public
static calculateOneTime(IsBillableAbstractClass $model) : array<string|int, mixed>
Parameters
- $model : IsBillableAbstractClass
Tags
Return values
array<string|int, mixed> —calculatePerUsage()
public
static calculatePerUsage(IsBillableAbstractClass $model) : array<string|int, mixed>
Parameters
- $model : IsBillableAbstractClass
Tags
Return values
array<string|int, mixed> —cloneCosts()
This function will clone costs from another Billable entity It is used, inside this trait, to clone costs from the priceList
public
cloneCosts(PriceList|IsBillableAbstractClass $billable, PriceList|IsBillableAbstractClass $origin[, bool $setFlags = true ]) : void
Parameters
- $billable : PriceList|IsBillableAbstractClass
- $origin : PriceList|IsBillableAbstractClass
- $setFlags : bool = true
Return values
void —closeBillingEntries()
public
closeBillingEntries(IsBillableAbstractClass $model[, bool $recreate = false ][, Carbon|null $billableTo = null ][, array<string|int, mixed> $modelChanges = [] ]) : void
Parameters
- $model : IsBillableAbstractClass
- $recreate : bool = false
- $billableTo : Carbon|null = null
- $modelChanges : array<string|int, mixed> = []
Tags
Return values
void —closeBillingEntry()
public
closeBillingEntry(BillingEntry $billingEntry[, IsBillableAbstractClass|null $model = null ][, bool $recreate = false ][, Carbon|null $billableTo = null ][, Carbon|null $nextBillableFrom = null ][, array<string|int, mixed> $modelChanges = [] ]) : bool
Parameters
- $billingEntry : BillingEntry
- $model : IsBillableAbstractClass|null = null
- $recreate : bool = false
- $billableTo : Carbon|null = null
- $nextBillableFrom : Carbon|null = null
- $modelChanges : array<string|int, mixed> = []
Tags
Return values
bool —createBillingEntry()
Creates a new price list entry for a specific model - that implements the IsBillable Trait
public
createBillingEntry(IsBillableAbstractClass $model[, Carbon|Carbon|null $fromTsDate = null ]) : void
Parameters
- $model : IsBillableAbstractClass
- $fromTsDate : Carbon|Carbon|null = null
Tags
Return values
void —customersWithBillingToInvoice()
Fetch all customers with invoice to be generated
public
static customersWithBillingToInvoice() : CustomerResourceCollection
Return values
CustomerResourceCollection —Customer eloquent collection
fetchBillingEntrySummaryForAllProjects()
Get all billing enetries for all user projects
public
static fetchBillingEntrySummaryForAllProjects(Collection $projects) : array<string|int, mixed>
Parameters
- $projects : Collection
Tags
Return values
array<string|int, mixed> —fetchBillingEntrySummaryForProject()
Fetch a summary of payed invoices
public
static fetchBillingEntrySummaryForProject(Project $project) : array<string|int, mixed>
Parameters
- $project : Project
Return values
array<string|int, mixed> —getPartialBillingSummaryForBillingEntry()
Calculate the price of the billing entry at $billableTo date
public
getPartialBillingSummaryForBillingEntry(BillingEntry $billingEntry[, Carbon|null $billableTo = null ]) : array<string|int, mixed>
Parameters
- $billingEntry : BillingEntry
- $billableTo : Carbon|null = null
Return values
array<string|int, mixed> —getPriceComposition()
public
static getPriceComposition(BillingEntry $billingEntry, IsBillableAbstractClass $model[, Carbon|null $billable_to = null ]) : array<string|int, mixed>
Parameters
- $billingEntry : BillingEntry
- $model : IsBillableAbstractClass
- $billable_to : Carbon|null = null
Return values
array<string|int, mixed> —hasBillingToInvoiceByProject()
Checks if the project has billing entry to invoice
public
static hasBillingToInvoiceByProject(Project $project) : bool
Parameters
- $project : Project
Return values
bool —logEntry()
public
static logEntry(Model $model, array<string|int, mixed> $properties, string $description, string $event, string $logName) : Activity
Parameters
- $model : Model
- $properties : array<string|int, mixed>
- $description : string
- $event : string
- $logName : string
Return values
Activity —logEntryWithoutModel()
public
static logEntryWithoutModel(array<string|int, mixed> $properties, string $description, string $event, string $logName) : Activity
Parameters
- $properties : array<string|int, mixed>
- $description : string
- $event : string
- $logName : string
Return values
Activity —logError()
public
static logError(Model $model, array<string|int, mixed> $properties, string $description, string $event) : Activity
Parameters
- $model : Model
- $properties : array<string|int, mixed>
- $description : string
- $event : string
Return values
Activity —logWarning()
public
static logWarning(Model $model, array<string|int, mixed> $properties, string $description, string $event) : Activity
Parameters
- $model : Model
- $properties : array<string|int, mixed>
- $description : string
- $event : string
Return values
Activity —setPriceList()
This function will handle the priceList for a billable model.
public
setPriceList(IsBillableAbstractClass $model) : void
It's used in creating and updating event to check if a priceList is a promo or is billable upon a specific relation of the model.
Parameters
- $model : IsBillableAbstractClass
Tags
Return values
void —updateBillingEntries()
Updated the price list entry data, based on a specific model - that impements the IsBillable Trait
public
updateBillingEntries(IsBillableAbstractClass $model) : void
Parameters
- $model : IsBillableAbstractClass
Return values
void —updatePartialBillingEntries()
Update all not closed billing entry with the partial price until $billableTo
public
updatePartialBillingEntries([Carbon|null $billableTo = null ]) : void
Parameters
- $billableTo : Carbon|null = null
Return values
void —log()
protected
log(Model|array<string|int, mixed> $models, array<string|int, mixed> $properties, string $description[, null $logName = null ]) : array<string|int, Activity>
Parameters
- $models : Model|array<string|int, mixed>
- $properties : array<string|int, mixed>
- $description : string
- $logName : null = null