Files
oficial/app/src/Model/Venta/Promotion.php

50 lines
1.3 KiB
PHP
Raw Normal View History

2025-02-18 16:02:10 -03:00
<?php
namespace Incoviba\Model\Venta;
use DateTimeInterface;
use Incoviba\Common;
use Incoviba\Model\Proyecto\Broker;
2025-02-18 16:02:10 -03:00
class Promotion extends Common\Ideal\Model
{
public float $amount;
public DateTimeInterface $startDate;
public DateTimeInterface $endDate;
public DateTimeInterface $validUntil;
public int $state;
protected array $contracts;
public function contracts(): array
{
if (empty($this->contracts)) {
$this->contracts = $this->runFactory('contracts');
}
return $this->contracts;
}
protected array $units;
public function units(): array
{
if (empty($this->units)) {
$this->units = $this->runFactory('units');
}
return $this->units;
}
2025-02-18 16:02:10 -03:00
protected function jsonComplement(): array
{
return [
'amount' => $this->amount,
'start_date' => $this->startDate->format('Y-m-d'),
'end_date' => $this->endDate->format('Y-m-d'),
'valid_until' => $this->validUntil->format('Y-m-d'),
'state' => [
'id' => $this->state,
'description' => Promotion\State::name($this->state)
],
'contracts' => $this->contracts() ?? [],
'units' => $this->units() ?? []
2025-02-18 16:02:10 -03:00
];
}
}