Skip to content

Commit

Permalink
HP-1751 fixed the case when we pass two sql for one type in AbstractL…
Browse files Browse the repository at this point in the history
…ineDescription
  • Loading branch information
VadymHrechukha committed Dec 10, 2024
1 parent 75b747c commit f01cc94
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
13 changes: 11 additions & 2 deletions src/product/PriceTypeDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace hiqdev\php\billing\product;

use hiqdev\billing\registry\invoice\InvoiceRepresentationCollection;
use hiqdev\billing\registry\product\GType;
use hiqdev\billing\registry\product\PriceType;
use hiqdev\php\units\Unit;

Expand All @@ -16,8 +17,11 @@ class PriceTypeDefinition

private InvoiceRepresentationCollection $invoiceCollection;

public function __construct(private readonly PriceTypesCollection $parent, private readonly PriceType $type)
{
public function __construct(
private readonly PriceTypesCollection $parent,
private readonly PriceType $type,
private readonly GType $gType,
) {
$this->invoiceCollection = new InvoiceRepresentationCollection($this);
}

Expand Down Expand Up @@ -62,4 +66,9 @@ public function type(): PriceType
{
return $this->type;
}

public function gType(): GType
{
return $this->gType;
}
}
9 changes: 5 additions & 4 deletions src/product/PriceTypesCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace hiqdev\php\billing\product;

use hiqdev\billing\registry\product\GType;
use hiqdev\billing\registry\product\PriceType;

class PriceTypesCollection implements \IteratorAggregate
Expand Down Expand Up @@ -34,7 +35,7 @@ private function getAllPrices(): array

public function monthly(PriceType $type): PriceTypeDefinition
{
$priceType = $this->createPriceTypeDefinition($type);
$priceType = $this->createPriceTypeDefinition(GType::monthly, $type);

$this->addPriceTypeDefinition($type, $priceType);

Expand All @@ -46,14 +47,14 @@ private function addPriceTypeDefinition(PriceType $type, PriceTypeDefinition $pr
$this->pricesGroupedByPriceType[$type->name][] = $priceTypeDefinition;
}

private function createPriceTypeDefinition(PriceType $type): PriceTypeDefinition
private function createPriceTypeDefinition(GType $gType, PriceType $type): PriceTypeDefinition
{
return new PriceTypeDefinition($this, $type);
return new PriceTypeDefinition($this, $type, $gType);
}

public function overuse(PriceType $type): PriceTypeDefinition
{
$priceType = $this->createPriceTypeDefinition($type);
$priceType = $this->createPriceTypeDefinition(GType::overuse, $type);

$this->addPriceTypeDefinition($type, $priceType);

Expand Down

0 comments on commit f01cc94

Please # to comment.