Skip to content

Commit

Permalink
[Billing] Add tier compoennt
Browse files Browse the repository at this point in the history
  • Loading branch information
that-guy-iain committed Aug 15, 2024
1 parent b499c49 commit 267904b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 18 deletions.
5 changes: 5 additions & 0 deletions src/Entity/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@
namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Parthenon\Billing\Enum\PriceType;

#[ORM\Entity()]
#[ORM\Table('price')]
class Price extends \Parthenon\Billing\Entity\Price
{
public function __construct()
{
$this->type = PriceType::RECURRING;
}
}
63 changes: 47 additions & 16 deletions src/Parthenon/Billing/Entity/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,37 @@

class Price implements CrudEntityInterface, DeletableInterface, PriceInterface
{
protected ?string $paymentProviderDetailsUrl = null;
private $id;
protected $id;

protected int $amount;

private int $amount;
protected string $currency;

private string $currency;
protected bool $recurring;

private bool $recurring;
protected ?string $schedule = null;

private ?string $schedule = null;
protected ?string $externalReference = null;

private ?string $externalReference = null;
protected bool $includingTax = true;

private bool $includingTax = true;
protected Product $product;

private Product $product;
protected ?bool $public = true;

private ?bool $public = true;
protected ?bool $isDeleted = false;

private ?bool $isDeleted = false;
protected \DateTimeInterface $createdAt;

private \DateTimeInterface $createdAt;
protected ?\DateTimeInterface $deletedAt = null;

private ?\DateTimeInterface $deletedAt = null;
protected ?string $paymentProviderDetailsUrl = null;

private array|Collection $tierComponents = [];
protected array|Collection $tierComponents = [];

private PriceType $type;
protected PriceType $type;

private ?UsageType $usageType = null;
protected ?UsageType $usageType = null;

public function getId()
{
Expand Down Expand Up @@ -228,4 +229,34 @@ public function setCreatedAt(\DateTimeInterface $createdAt): void
{
$this->createdAt = $createdAt;
}

public function getTierComponents(): Collection|array
{
return $this->tierComponents;
}

public function setTierComponents(Collection|array $tierComponents): void
{
$this->tierComponents = $tierComponents;
}

public function getType(): PriceType
{
return $this->type;
}

public function setType(PriceType $type): void
{
$this->type = $type;
}

public function getUsageType(): ?UsageType
{
return $this->usageType;
}

public function setUsageType(?UsageType $usageType): void
{
$this->usageType = $usageType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<field name="externalReference" column="external_reference" type="string" nullable="true" />
<field name="paymentProviderDetailsUrl" column="payment_provider_details_url" type="string" nullable="true" />
<many-to-one field="product" target-entity="Parthenon\Billing\Entity\ProductInterface" />
<one-to-many field="tierComponent" target-entity="Parthenon\Billing\Entity\TierComponentInterface" mapped-by="price" />
<one-to-many field="tierComponents" target-entity="Parthenon\Billing\Entity\TierComponentInterface" mapped-by="price" />
<field name="createdAt" column="created_at" type="datetime" nullable="false" />
<field name="deletedAt" column="deleted_at" type="datetime" nullable="true" />
</mapped-superclass>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
<field name="unitPrice" column="unit_price" type="integer" nullable="false" />
<field name="flatFee" column="flat_fee" type="integer" nullable="false" />

<many-to-one field="price" target-entity="Parthenon\Billing\Entity\PriceInterface" />
<many-to-one field="price" target-entity="Parthenon\Billing\Entity\PriceInterface" inversed-by="price" />
</mapped-superclass>
</doctrine-mapping>

0 comments on commit 267904b

Please sign in to comment.