CoolCMS API

OrderVoucher extends BaseEntity
in package
implements IdentifiableInterface uses IdentifiableTrait

AbstractYes

Snapshot of a voucher applied to an order (table `cms_mod_eshop_order_voucher_rel`).

Surrogate PK (a multi-value relation without a PK).

code, percents and price are the voucher values at the time of application. vat is the maximum rate of the order items (VAT of a fixed discount is computed with the highest rate, see OrderCalculator), priceWithVat is the fixed discount raised by that rate. The voucher is a reference only (SET NULL).

Tags
template
Attributes
#[MappedSuperclass]
#[TableAlias]
$alias: 'orderVoucher'

Table of Contents

Interfaces

IdentifiableInterface
Entity with a simple integer primary key. Most entities have one (often via {@see \App\Core\Traits\Shared\Models\Entities\IdentifiableTrait}); texts and links with a composite key do not, which is why `getId()` is not on {@see \App\Core\Base\BaseEntity}. Code that needs the id of a generic entity asks for this interface (parameter type, template bound, `instanceof`).

Properties

$code  : string
$id  : int|null
$order  : TOrder|null
$percents  : int
$price  : string
$priceWithVat  : string
$vat  : string
$voucher  : TVoucher|null

Methods

__construct()  : mixed
callInitMethods()  : void
Calls `init{TraitName}()` for every used trait that defines such a method.
getAllTraits()  : array<string, string>
Returns all traits the class uses, including those used by parent classes and nested traits.
getCode()  : string
getId()  : int|null
getOrder()  : TOrder|null
getPercents()  : int
getPrice()  : string
getPriceWithVat()  : string
getVat()  : string
getVatAsFloat()  : float
getVoucher()  : TVoucher|null
isPersisted()  : bool
setCode()  : $this
setId()  : $this
setOrder()  : $this
setPercents()  : $this
setPrice()  : $this
setPriceWithVat()  : $this
setVat()  : $this
setVoucher()  : $this
getTraitsRecursive()  : array<string, string>
Walks the trait list recursively and collects nested traits too.

Properties

$code

protected string $code = ''
Attributes
#[Column]
$name: 'code'
$type: 'string'
$length: 80

$id

protected int|null $id = null
Attributes
#[Column]
$name: 'order_voucher_id'
$type: 'bigint'
$options: ['unsigned' => true]
#[GeneratedValue]
#[Id]

$percents

protected int $percents = 0
Attributes
#[Column]
$name: 'percents'
$type: 'integer'
$options: ['unsigned' => true]
#[ExternalReadonly]

$price

protected string $price = '0.000'
Attributes
#[Column]
$name: 'price'
$type: 'decimal'
$precision: 10
$scale: 3
#[ExternalReadonly]

$priceWithVat

protected string $priceWithVat = '0.000'
Attributes
#[Column]
$name: 'price_with_vat'
$type: 'decimal'
$precision: 10
$scale: 3
#[ExternalReadonly]

Methods

__construct()

public __construct([int|null $id = null ][, mixed $order = null ][, mixed $voucher = null ][, string $code = '' ][, int $percents = 0 ][, string $price = '0.000' ][, string $priceWithVat = '0.000' ][, string $vat = '0.00' ]) : mixed
Parameters
$id : int|null = null
$order : mixed = null
$voucher : mixed = null
$code : string = ''
$percents : int = 0
$price : string = '0.000'
$priceWithVat : string = '0.000'
$vat : string = '0.00'

callInitMethods()

Calls `init{TraitName}()` for every used trait that defines such a method.

public callInitMethods() : void

getAllTraits()

Returns all traits the class uses, including those used by parent classes and nested traits.

public getAllTraits() : array<string, string>
Return values
array<string, string>

getCode()

public getCode() : string
Return values
string

getOrder()

public getOrder() : TOrder|null
Return values
TOrder|null

getPercents()

public getPercents() : int
Return values
int

getPrice()

public getPrice() : string
Return values
string

getPriceWithVat()

public getPriceWithVat() : string
Return values
string

getVatAsFloat()

public getVatAsFloat() : float
Return values
float

getVoucher()

public getVoucher() : TVoucher|null
Return values
TVoucher|null

setCode()

public setCode(string $code) : $this
Parameters
$code : string
Return values
$this

setId()

public setId(int|null $id) : $this
Parameters
$id : int|null
Return values
$this

setOrder()

public setOrder(TOrder|null $order) : $this
Parameters
$order : TOrder|null
Return values
$this

setPercents()

public setPercents(int $percents) : $this
Parameters
$percents : int
Return values
$this

setPrice()

public setPrice(string $price) : $this
Parameters
$price : string
Return values
$this

setPriceWithVat()

public setPriceWithVat(string $priceWithVat) : $this
Parameters
$priceWithVat : string
Return values
$this

setVat()

public setVat(string $vat) : $this
Parameters
$vat : string
Return values
$this

setVoucher()

public setVoucher(TVoucher|null $voucher) : $this
Parameters
$voucher : TVoucher|null
Return values
$this

getTraitsRecursive()

Walks the trait list recursively and collects nested traits too.

private static getTraitsRecursive(array<string, string> $traits) : array<string, string>
Parameters
$traits : array<string, string>
Return values
array<string, string>
On this page

Search results