Service
extends BaseBill
in package
Uses
Images
Implement service object
This class provides general interfaces to handle and store service data.
Tags
Table of Contents
- $ : string|null
- $ : string|null
- $ : string|null
- $ : string|null
- $ : string|null
- $company : Company|null
- The linked company object
- $prices : array<string|int, mixed>|null
- Buffer prices
- $project : Project|null
- In project context
- $relation : Relation|null
- $root : string
- The root storage folder starting at %DATA%/folder/
- $_number : string|null
- The formatted bill number
- $cancel_bill : null|Service
- $customer : Customer|null
- $last_bill_date : int|null|bool
- Last bill anchor
- $mail_map : array<string|int, mixed>
- $tasks : array<string|int, mixed>|null
- Cache tasks
- $template : Template|null
- A local instance of the assigned template
- $template_map : array<string|int, mixed>
- __construct() : mixed
- Service constructor.
- AddEventEntry() : Result
- Add new event
- AddPriceRow() : Result
- AllBillsPayed() : bool
- Are all the bills paid?
- AllocateArticleMovements() : Result
- AssignImage() : Result
- Assign an image from instance
- Bill() : array<string|int, mixed>|null
- Get a certain bill link attribute
- BillPreview() : Result
- Get preview for certain bill or in general
- Bills() : array<string|int, mixed>
- Get the bills
- CancelsBill() : Service|null
- This is a bill cancellation with full refund
- Copy() : mixed
- CopyOf() : Service|null
- CreateBill() : Result
- Create a bill
- CreateMissingBills() : Result
- Create the missing bill entries
- Currency() : string
- Get the currency of the basket
- DateFormatted() : string
- Get the formatted date range
- DateToFormatted() : DateTime|string|null
- Get date as object or formatted
- Deadline() : object|null
- Get the deadline
- DeliveryAddress() : Address|null
- DeliveryNotePreview() : Result
- Create delivery note
- FormattedBillNumber() : string|null
- Get bill number
- FormattedOfferNumber() : string
- Get a formatted offer number
- FullPrice() : float|string
- Get price Get the full gross price of this project
- FullPriceNet() : float|string
- Get price Get the full net price of this project (without tax)
- FullTax() : float|string
- Get tax price Get the full taxes of this project
- GeneralSearchFields() : array<string|int, mixed>
- Get the general search fields for index
- GetBillPdfs() : Result
- Get all bill pdf files for a certain time frame in a project context
- GetCompany() : string|null
- Get company id Get the company id from content
- GetCompanyExtra() : string|null
- Get the assignment extra
- GetCompanyObject() : Company|null
- Get company
- GetCustomerExtra() : mixed
- GetCustomerObject() : Customer|null
- Get customer
- GetLastKnownEvent() : Event|null
- Get most recent event of certain type
- GetPrimaryPicture() : Asset|null
- Get the primary picture
- GetTemplate() : Template|null
- Load template
- Images() : array<string|int, mixed>|array<string|int, Asset>
- List images
- IsRecurring() : bool
- Has recurring
- LastPayedDate() : int
- Get the last paid timestamp
- MainImage() : Asset|null
- Get main image
- MainProject() : Project|null
- Resolve the main project of this service/bill
- MainRelation() : Relation|null
- Get / Set the main relation
- Name() : string
- Get the name and include the external reference as well
- NextBillDate() : string|null
- Get the next billing date based on existing bills in format "FAA_DATE_SHORT"
- OfferPreview() : Result
- Create offer preview
- PaymentType() : null|string|PaymentMethod
- The payment type used
- PriceGroups() : array<string|int, mixed>|null
- Get price groups of this entity
- PriceList() : array<string|int, RowPrice>
- Price list Resolve the prices list to row price objects. This method is cached.
- PriceListWithGroups() : array<string|int, mixed>|null
- Refunds() : array<string|int, mixed>|null
- Get the refunds
- RefundsSum() : float
- Refund sum
- RegisterBillNumber() : Result
- Register a new billing number to the service on demand
- RegisterOfferNumber() : Result
- Save() : Result
- Save service in file system and git repository
- SearchFields() : array<string|int, mixed>
- Return search indexer fields
- SendBillToCustomer() : Result
- Send the bill to the customer
- SendOfferToCustomer() : Result
- Send offer mail
- SendServiceDeliveryNote() : Result
- Send delivery note by mail
- Serialize() : array<string|int, mixed>
- Serialize the service for export purposes
- ServiceToBill() : Result
- Get the bill pdf
- ServiceToDeliveryNote() : Result
- Get the delivery note pdf
- ServiceToOffer() : Result
- Get the offer pdf
- SetAllBillsPayed() : Result
- Set all bills to paid
- Skonto() : array<string|int, mixed>|null
- Status() : Result
- Status transition and getter
- Task() : Task|null
- Fetch a single related task if it is linked to the service
- Tasks() : array<string|int, Task>|null
- Get a list of tasks from search
- TaxRateMap() : array<string|int, mixed>
- Get the groups of included taxes
- ToPlainObject() : mixed
- ToPlainReducedObject() : stdClass
- Convert to reduced plain data set
- UniqueTaxType() : string
- Get the unique tax type identification
- preview() : Result
- Render preview for bill or, offer
- endDate() : string|null
- The ending date for this service
- getBill() : array<string|int, mixed>|null
- Gt a single bill by number
- sendBillOfferToCustomer() : Result
- Send bill or offer email
- toPdf() : Result
Properties
$
public
string|null
$
interval
$
public
string|null
$
number
$
public
string|null
$
description
$
public
string|null
$
offer_number
$
public
string|null
$
status
$company
The linked company object
protected
Company|null
$company
= null
$prices
Buffer prices
protected
array<string|int, mixed>|null
$prices
= null
Storage for row prices as resolved object list.
A list of row prices
$project
In project context
protected
Project|null
$project
= null
A reference to another overlaying project
A project object
$relation
protected
Relation|null
$relation
= null
$root
The root storage folder starting at %DATA%/folder/
protected
string
$root
= 'media/projects/'
$_number
The formatted bill number
private
string|null
$_number
= null
$cancel_bill
private
null|Service
$cancel_bill
$customer
private
Customer|null
$customer
= null
$last_bill_date
Last bill anchor
private
int|null|bool
$last_bill_date
= null
$mail_map
private
array<string|int, mixed>
$mail_map
= ['delivery_note' => 'email_setup_customer_delivery_note', 'offer' => 'email_setup_customer_offer', 'bill' => 'email_setup_customer']
$tasks
Cache tasks
private
array<string|int, mixed>|null
$tasks
= null
$template
A local instance of the assigned template
private
Template|null
$template
= null
The instance
$template_map
private
array<string|int, mixed>
$template_map
= ['delivery_note' => 'delivery_note_pdf', 'offer' => 'offer_pdf', 'refunds' => 'template_refund', 'bill' => 'template']
Methods
__construct()
Service constructor.
public
__construct([string|null $id = null ][, string|null $language = null ][, string|null $subtype = null ]) : mixed
Construct a new service object
Parameters
- $id : string|null = null
-
The service id
- $language : string|null = null
-
The language to load with
- $subtype : string|null = null
-
The subtype name
Return values
mixed —AddEventEntry()
Add new event
public
AddEventEntry(array<string|int, mixed> $event) : Result
Parameters
- $event : array<string|int, mixed>
Return values
Result —AddPriceRow()
public
AddPriceRow(array<string|int, mixed> $row) : Result
Parameters
- $row : array<string|int, mixed>
Return values
Result —AllBillsPayed()
Are all the bills paid?
public
AllBillsPayed() : bool
Return values
bool —AllocateArticleMovements()
public
AllocateArticleMovements() : Result
Return values
Result —AssignImage()
Assign an image from instance
public
AssignImage(Asset $asset) : Result
Parameters
- $asset : Asset
-
An asset instance
Return values
Result —The result object
Bill()
Get a certain bill link attribute
public
Bill(int $number) : array<string|int, mixed>|null
Parameters
- $number : int
-
The bill number
Return values
array<string|int, mixed>|null —The found bill
BillPreview()
Get preview for certain bill or in general
public
BillPreview([Project|null $project = null ][, Array|string $number = null ][, string $template = 'template' ]) : Result
Parameters
- $project : Project|null = null
-
The parent project
- $number : Array|string = null
-
The bill number or null
- $template : string = 'template'
Return values
Result —The preview build result
Bills()
Get the bills
public
Bills([null $date_from = null ][, null $date_to = null ]) : array<string|int, mixed>
Parameters
- $date_from : null = null
-
Filter date from
- $date_to : null = null
-
Filter date to
Return values
array<string|int, mixed> —The list of bills
CancelsBill()
This is a bill cancellation with full refund
public
CancelsBill([bool $no_revision = true ]) : Service|null
Parameters
- $no_revision : bool = true
Return values
Service|null —Copy()
public
Copy([mixed $target = null ]) : mixed
Parameters
- $target : mixed = null
Tags
Return values
mixed —CopyOf()
public
CopyOf() : Service|null
Return values
Service|null —CreateBill()
Create a bill
public
CreateBill([Project|null $project = null ][, string|null $version = null ][, int|null $number = null ][, string $template = 'template' ]) : Result
Create a pdf bill and return the download path. When a version is given this will cause an implicit operation to a newly loaded version of this service.
Parameters
- $project : Project|null = null
-
A project object
- $version : string|null = null
-
A certain version to generate the bill for
- $number : int|null = null
-
A certain number in the bill list (requires resolve of version)
- $template : string = 'template'
Return values
Result —A default system result object
CreateMissingBills()
Create the missing bill entries
public
CreateMissingBills([bool $force = false ]) : Result
Build the pdfs of all bills that are not available locally
Parameters
- $force : bool = false
-
Force rendering of bill
Return values
Result —The render result
Currency()
Get the currency of the basket
public
Currency([bool $symbol = true ]) : string
This is hard coded at the moment but may become dynamic in the future
Parameters
- $symbol : bool = true
-
As symbol like €
Return values
string —The currency
DateFormatted()
Get the formatted date range
public
DateFormatted([null|string $time_zone = FAA_TIMEZONE ][, string|null $format = 'd.m.Y H:i' ]) : string
Parameters
- $time_zone : null|string = FAA_TIMEZONE
- $format : string|null = 'd.m.Y H:i'
Return values
string —DateToFormatted()
Get date as object or formatted
public
DateToFormatted([string|null $time_zone = FAA_TIMEZONE ][, string|null $format = 'd.m.Y H:i' ][, int $offset = 30 ]) : DateTime|string|null
Parameters
- $time_zone : string|null = FAA_TIMEZONE
-
Time zone to render in
- $format : string|null = 'd.m.Y H:i'
-
If set return formatted otherwise as string
- $offset : int = 30
-
Additional offset in days
Return values
DateTime|string|null —Deadline()
Get the deadline
public
Deadline() : object|null
Return values
object|null —DeliveryAddress()
public
DeliveryAddress() : Address|null
Return values
Address|null —DeliveryNotePreview()
Create delivery note
public
DeliveryNotePreview([Project|null $project = null ]) : Result
Parameters
- $project : Project|null = null
Return values
Result —FormattedBillNumber()
Get bill number
public
FormattedBillNumber([null|string|int $number = null ]) : string|null
Get the formatted bill number with pad left and prefix This method is cached
Parameters
- $number : null|string|int = null
Return values
string|null —The formatted bill number
FormattedOfferNumber()
Get a formatted offer number
public
FormattedOfferNumber() : string
Return values
string —FullPrice()
Get price Get the full gross price of this project
public
FullPrice([bool $format = false ][, bool $include_refund = true ]) : float|string
Parameters
- $format : bool = false
-
When true as formatted string
- $include_refund : bool = true
Return values
float|string —Either a formatted output or, the raw value
FullPriceNet()
Get price Get the full net price of this project (without tax)
public
FullPriceNet([bool $format = false ]) : float|string
Parameters
- $format : bool = false
-
When true as formatted string
Return values
float|string —Either a formatted output or, the raw value
FullTax()
Get tax price Get the full taxes of this project
public
FullTax([bool $format = false ]) : float|string
Parameters
- $format : bool = false
-
When true as formatted string
Return values
float|string —Either a formatted output or, the raw value
GeneralSearchFields()
Get the general search fields for index
public
GeneralSearchFields() : array<string|int, mixed>
Return values
array<string|int, mixed> —GetBillPdfs()
Get all bill pdf files for a certain time frame in a project context
public
GetBillPdfs(Project $project[, null $date_from = null ][, null $date_to = null ]) : Result
Parameters
- $project : Project
-
The parent project
- $date_from : null = null
-
Filter date from
- $date_to : null = null
-
Filter date to
Return values
Result —The fetch result
GetCompany()
Get company id Get the company id from content
public
GetCompany() : string|null
Return values
string|null —The content id
GetCompanyExtra()
Get the assignment extra
public
GetCompanyExtra() : string|null
Return values
string|null —GetCompanyObject()
Get company
public
GetCompanyObject() : Company|null
Get the main company from content
Return values
Company|null —A company object or null when list is empty
GetCustomerExtra()
public
GetCustomerExtra(string $key) : mixed
Parameters
- $key : string
Return values
mixed —GetCustomerObject()
Get customer
public
GetCustomerObject([bool $no_revision = false ]) : Customer|null
Get the sub customer from content. This method is cached
Parameters
- $no_revision : bool = false
-
If true, no revision will be used to resolve the customer
Return values
Customer|null —A customer object or null when list is empty
GetLastKnownEvent()
Get most recent event of certain type
public
GetLastKnownEvent( $type) : Event|null
Iterate of elements list and return the newest entry
Parameters
Return values
Event|null —GetPrimaryPicture()
Get the primary picture
public
GetPrimaryPicture() : Asset|null
Return values
Asset|null —GetTemplate()
Load template
public
GetTemplate([string $name = 'template' ]) : Template|null
Helper method to load the assigned template and return as object. This one is cached locally.
Parameters
- $name : string = 'template'
-
Type of template to fetch
Return values
Template|null —A system template object covered in a result object
Images()
List images
public
Images([bool $resolved = false ]) : array<string|int, mixed>|array<string|int, Asset>
Get the content of the images attribute relation Will generate and return an empty array hen attribute is not filled
Parameters
- $resolved : bool = false
Return values
array<string|int, mixed>|array<string|int, Asset> —IsRecurring()
Has recurring
public
IsRecurring() : bool
Check if this service has a interval
Return values
bool —Indicate if this service has recurring entries
LastPayedDate()
Get the last paid timestamp
public
LastPayedDate() : int
Return values
int —MainImage()
Get main image
public
MainImage() : Asset|null
Return values
Asset|null —MainProject()
Resolve the main project of this service/bill
public
MainProject([Project|null $project = null ]) : Project|null
Parameters
- $project : Project|null = null
Return values
Project|null —MainRelation()
Get / Set the main relation
public
MainRelation([Relation|null $rel = null ]) : Relation|null
Parameters
- $rel : Relation|null = null
Return values
Relation|null —Name()
Get the name and include the external reference as well
public
Name() : string
Return values
string —NextBillDate()
Get the next billing date based on existing bills in format "FAA_DATE_SHORT"
public
NextBillDate() : string|null
Return values
string|null —OfferPreview()
Create offer preview
public
OfferPreview([Project|null $project = null ]) : Result
Parameters
- $project : Project|null = null
Return values
Result —PaymentType()
The payment type used
public
PaymentType([string $mode = 'raw' ]) : null|string|PaymentMethod
Parameters
- $mode : string = 'raw'
Return values
null|string|PaymentMethod —PriceGroups()
Get price groups of this entity
public
PriceGroups() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —PriceList()
Price list Resolve the prices list to row price objects. This method is cached.
public
PriceList() : array<string|int, RowPrice>
Return values
array<string|int, RowPrice> —A list of row price objects
PriceListWithGroups()
public
PriceListWithGroups() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —Refunds()
Get the refunds
public
Refunds() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —RefundsSum()
Refund sum
public
RefundsSum() : float
Return values
float —RegisterBillNumber()
Register a new billing number to the service on demand
public
RegisterBillNumber([Project|null $project = null ][, string|null $basket_id = null ][, bool|null $reset = false ]) : Result
Checks if the service has bills and adds new ones when not and not recurring. When it has not and recurring property flag is set, it will either reuse the locked number of the bill item or, create a new bill item with new number. The date will be set either to the date from or the next bill date.
This method saves the service on demand and therefore commits at least one file to the database.
Parameters
- $project : Project|null = null
-
The parent project object
- $basket_id : string|null = null
- $reset : bool|null = false
Return values
Result —A system result object
RegisterOfferNumber()
public
RegisterOfferNumber([Project|null $project = null ]) : Result
Parameters
- $project : Project|null = null
Return values
Result —Save()
Save service in file system and git repository
public
Save([bool $force_new_id = false ]) : Result
Will call the parent method to save the changes first. Then it checks if all bills have a version and if not, they will get the version of the previously commited service
Parameters
- $force_new_id : bool = false
-
Indicate force new id on demand (local id empty)
Return values
Result —A default system result set
SearchFields()
Return search indexer fields
public
SearchFields() : array<string|int, mixed>
Convert instance to search indexer values
Return values
array<string|int, mixed> —The search indexer fields
SendBillToCustomer()
Send the bill to the customer
public
SendBillToCustomer(string $language[, array<string|int, mixed>|null $payload = null ]) : Result
Creates the mail object based on the configuration and send it to the customer
Parameters
- $language : string
-
The template language
- $payload : array<string|int, mixed>|null = null
Return values
Result —The send result
SendOfferToCustomer()
Send offer mail
public
SendOfferToCustomer([string|null $language = null ][, array<string|int, mixed>|null $payload = null ]) : Result
Send the offer email to the defined email address of the assigned customer
Parameters
- $language : string|null = null
-
A language key
- $payload : array<string|int, mixed>|null = null
Return values
Result —A system result object
SendServiceDeliveryNote()
Send delivery note by mail
public
SendServiceDeliveryNote(string $language, array<string|int, mixed> $payload) : Result
Send the email to the defined email address passed by the data in payload
Parameters
- $language : string
-
A language key
- $payload : array<string|int, mixed>
Return values
Result —A system result object
Serialize()
Serialize the service for export purposes
public
Serialize([string $timezone = FAA_TIMEZONE ]) : array<string|int, mixed>
Parameters
- $timezone : string = FAA_TIMEZONE
Return values
array<string|int, mixed> —ServiceToBill()
Get the bill pdf
public
ServiceToBill([string|null $language = null ][, Project|null $project = null ][, object|null $mail = null ]) : Result
Generates the bill pdf file based on the defined template nd the given language
Parameters
- $language : string|null = null
-
The target language
- $project : Project|null = null
-
The parent project
- $mail : object|null = null
-
The email data when given
Return values
Result —The result
ServiceToDeliveryNote()
Get the delivery note pdf
public
ServiceToDeliveryNote([string|null $language = null ][, Project|null $project = null ][, object|null $mail = null ]) : Result
Generates the delivery note pdf file based on the defined template nd the given language
Parameters
- $language : string|null = null
-
The target language
- $project : Project|null = null
-
The parent project
- $mail : object|null = null
-
The email request body
Return values
Result —The result
ServiceToOffer()
Get the offer pdf
public
ServiceToOffer([string|null $language = null ][, Project|null $project = null ][, object|null $mail = null ]) : Result
Generates the offer pdf file based on the defined template nd the given language
Parameters
- $language : string|null = null
-
The target language
- $project : Project|null = null
-
The parent project
- $mail : object|null = null
-
The email request body
Return values
Result —The result
SetAllBillsPayed()
Set all bills to paid
public
SetAllBillsPayed() : Result
Return values
Result —Skonto()
public
Skonto() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —Status()
Status transition and getter
public
Status([string|null $status = null ]) : Result
Parameters
- $status : string|null = null
-
The new status or null for read only
Return values
Result —Task()
Fetch a single related task if it is linked to the service
public
Task(string $id) : Task|null
Parameters
- $id : string
-
The related task id
Return values
Task|null —Tasks()
Get a list of tasks from search
public
Tasks([array<string|int, mixed>|null $filter = null ]) : array<string|int, Task>|null
This method is cached upon save operation
Parameters
- $filter : array<string|int, mixed>|null = null
Return values
array<string|int, Task>|null —TaxRateMap()
Get the groups of included taxes
public
TaxRateMap([bool $format = false ]) : array<string|int, mixed>
Parameters
- $format : bool = false
-
When true as formatted string
Return values
array<string|int, mixed> —ToPlainObject()
public
ToPlainObject([mixed $language = null ][, mixed $with_parent = true ]) : mixed
Parameters
- $language : mixed = null
- $with_parent : mixed = true
Tags
Return values
mixed —ToPlainReducedObject()
Convert to reduced plain data set
public
ToPlainReducedObject(array<string|int, mixed> $fields[, string|null $language = null ]) : stdClass
Translate and expose the current data attribute as plain resolved object with filtered attributes
Parameters
- $fields : array<string|int, mixed>
-
List of attributes to show
- $language : string|null = null
-
A system language code or empty for raw setup
Return values
stdClass —A simple attribute based php object
UniqueTaxType()
Get the unique tax type identification
public
UniqueTaxType() : string
Return values
string —preview()
Render preview for bill or, offer
protected
preview(string $type[, array<string|int, mixed>|null $bill = null ][, object|null $mail = null ]) : Result
Parameters
- $type : string
-
The type of template to fetch
- $bill : array<string|int, mixed>|null = null
-
Bill data
- $mail : object|null = null
-
Email data of related wrapper mail
Return values
Result —The preview result
endDate()
The ending date for this service
private
endDate() : string|null
Return values
string|null —getBill()
Gt a single bill by number
private
getBill(int|string|null $number) : array<string|int, mixed>|null
Parameters
- $number : int|string|null
-
Certain bill number or if not set the last one
Return values
array<string|int, mixed>|null —sendBillOfferToCustomer()
Send bill or offer email
private
sendBillOfferToCustomer(string $mode[, null|string $language = null ][, null|array<string|int, mixed> $payload = null ]) : Result
Parameters
- $mode : string
-
The mode, either bill or, offer
- $language : null|string = null
-
The target language of the message
- $payload : null|array<string|int, mixed> = null
-
The additional payload
Return values
Result —toPdf()
private
toPdf(string $template, string $prefix[, string|null $language = null ][, Project|null $project = null ][, object|null $mail = null ]) : Result
Parameters
- $template : string
- $prefix : string
- $language : string|null = null
- $project : Project|null = null
- $mail : object|null = null