<?php
namespace JanusHercules\IntegratedExternalPartnerCustomers\Domain\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\Table(name: 'weclapp_contract_items')]
class WeclappContractItem
{
public function __construct(
string $id,
WeclappContract $weclappContract,
string $title,
float $unitPrice,
int $discountPercentage,
?int $numberOfJobs = null
) {
$this->id = $id;
$this->weclappContract = $weclappContract;
$this->title = $title;
$this->unitPrice = $unitPrice;
$this->discountPercentage = $discountPercentage;
$this->numberOfJobs = $numberOfJobs;
}
#[ORM\Id]
#[ORM\Column(
type: Types::STRING
)]
private string $id; // yes, all weclapp IDs are seemingly numeric, but the API defines them as type string
public function getId(): string
{
return $this->id;
}
#[ORM\ManyToOne(
targetEntity: WeclappContract::class,
cascade : ['persist']
)]
#[ORM\JoinColumn(
name : 'weclapp_contracts_id',
referencedColumnName: 'id',
onDelete : 'CASCADE'
)]
private WeclappContract $weclappContract;
public function getWeclappContract(): WeclappContract
{
return $this->weclappContract;
}
public function setWeclappContract(WeclappContract $weclappContract): void
{
$this->weclappContract = $weclappContract;
}
public function setDiscountPercentage(int $discountPercentage): void
{
$this->discountPercentage = $discountPercentage;
}
#[ORM\Column(
type: Types::STRING
)]
private string $title;
public function getTitle(): string
{
return $this->title;
}
public function setTitle(string $title): void
{
$this->title = $title;
}
#[ORM\Column(
type: Types::FLOAT
)]
private float $unitPrice;
public function getUnitPrice(): float
{
return $this->unitPrice;
}
public function setUnitPrice(float $unitPrice): void
{
$this->unitPrice = $unitPrice;
}
#[ORM\Column(
type: Types::INTEGER
)]
private int $discountPercentage;
public function getDiscountPercentage(): int
{
return $this->discountPercentage;
}
#[ORM\Column(
type : Types::INTEGER,
nullable: true
)]
private ?int $numberOfJobs;
public function getNumberOfJobs(): ?int
{
return $this->numberOfJobs;
}
public function setNumberOfJobs(?int $numberOfJobs): void
{
$this->numberOfJobs = $numberOfJobs;
}
}