net = new Money(0); $this->gross = new Money(0); $this->costs = new Money(0); $this->profit = new Money(0); $this->createdAt = new \DateTimeImmutable(); $this->performanceDate = new \DateTime(); $this->createdBy = new NullAccount(); $this->referral = new NullAccount(); } /** * Get id. * * @return int Model id * * @since 1.0.0 */ public function getId() : int { return $this->id; } /** * Get Bill number. * * @return string * * @since 1.0.0 */ public function getNumber() : string { $number = $this->number; return \str_replace( [ '{y}', '{m}', '{d}', '{id}', '{type}', ], [ $this->createdAt->format('Y'), $this->createdAt->format('m'), $this->createdAt->format('d'), $this->id, \is_int($this->type) ? $this->type : $this->type->getId(), ], $number ); } /** * Get type * * @return int | BillType * * @since 1.0.0 */ public function getType() : int | BillType { return $this->type; } /** * Set type * * @param int|BillType $type Type * * @return void * * @since 1.0.0 */ public function setType(int | BillType $type) : void { $this->type = $type; } /** * Get status * * @return int * * @since 1.0.0 */ public function getStatus() : int { return $this->status; } /** * Set status * * @param int $status Status * * @return void * * @since 1.0.0 */ public function setStatus(int $status) : void { $this->status = $status; } /** * Set currency. * * @param string $currency Currency * * @return void * * @since 1.0.0 */ public function setCurrency(string $currency) : void { $this->currency = $currency; } /** * Get currency. * * @return string * * @since 1.0.0 */ public function getCurrency() : string { return $this->currency; } /** * Get vouchers. * * @return array * * @since 1.0.0 */ public function getVouchers() : array { return $this->vouchers; } /** * Add voucher. * * @param string $voucher Voucher code * * @return void * * @since 1.0.0 */ public function addVoucher(string $voucher) : void { $this->vouchers[] = $voucher; } /** * Get tracking ids for shipment. * * @return array * * @since 1.0.0 */ public function getTrackings() : array { return $this->trackings; } /** * Add tracking id. * * @param string $tracking Tracking id * * @return void * * @since 1.0.0 */ public function addTracking(string $tracking) : void { $this->trackings[] = $tracking; } /** * Get Bill elements. * * @return array * * @since 1.0.0 */ public function getElements() : array { return $this->elements; } /** * Add Bill element. * * @param mixed $element Bill element * * @return void * * @since 1.0.0 */ public function addElement($element) : void { $this->elements[] = $element; } /** * Get all media * * @return Media[] * * @since 1.0.0 */ public function getMedia() : array { return $this->media; } /** * Add media * * @param Media $media Media to add * * @return void * * @since 1.0.0 */ public function addMedia(Media $media) : void { $this->media[] = $media; } /** * Get media file by type * * @param string $type Media type * * @return Media * * @since 1.0.0 */ public function getMediaByType(string $type) : Media { foreach ($this->media as $media) { if ($media->type === $type) { return $media; } } return new NullMedia(); } /** * {@inheritdoc} */ public function jsonSerialize() { return []; } }