diff --git a/src/bill/Bill.php b/src/bill/Bill.php index 6ecf2ea1..ab207272 100755 --- a/src/bill/Bill.php +++ b/src/bill/Bill.php @@ -64,6 +64,15 @@ class Bill implements BillInterface /** @var UsageInterval */ protected $usageInterval; + /** @var BillSource|null */ + protected $source; + + /** @var BillTxn|null */ + protected $txn; + + /** @var BillReversesId|null */ + protected $reversesId; + /** * @param int|string $id */ @@ -77,7 +86,10 @@ public function __construct( ?TargetInterface $target = null, ?PlanInterface $plan = null, array $charges = [], - ?BillState $state = null + ?BillState $state = null, + ?BillSource $source = null, + ?BillTxn $txn = null, + ?BillReversesId $reversesId = null, ) { $this->type = $type; $this->time = $time; @@ -88,6 +100,9 @@ public function __construct( $this->plan = $plan; $this->charges = $charges; $this->state = $state; + $this->source = $source; + $this->txn = $txn; + $this->reversesId = $reversesId; } /** @@ -241,6 +256,16 @@ public function getComment() return $this->comment; } + public function getSource(): ?BillSource + { + return $this->source; + } + + public function getTxn(): ?BillTxn + { + return $this->txn; + } + public function setComment(string $comment) { $this->comment = $comment; @@ -255,4 +280,18 @@ public function setUsageInterval(UsageInterval $usageInterval): void { $this->usageInterval = $usageInterval; } + + public function getReversesId(): ?BillReversesId + { + return $this->reversesId; + } + + /** + * @param BillReversesId|null $reversesId + * @return void + */ + public function setReversesId($reversesId): void + { + $this->reversesId = $reversesId; + } } diff --git a/src/bill/BillInterface.php b/src/bill/BillInterface.php index 2c06d54e..ade18f90 100644 --- a/src/bill/BillInterface.php +++ b/src/bill/BillInterface.php @@ -57,4 +57,10 @@ public function getCharges(); public function getUsageInterval(): UsageInterval; public function setUsageInterval(UsageInterval $usageInterval): void; + + public function getSource(): ?BillSource; + + public function getTxn(): ?BillTxn; + + public function getReversesId(): ?BillReversesId; } diff --git a/src/bill/BillReversesId.php b/src/bill/BillReversesId.php new file mode 100644 index 00000000..fccf7754 --- /dev/null +++ b/src/bill/BillReversesId.php @@ -0,0 +1,22 @@ +value; + } + + public static function fromInt(int $id): self + { + return new self($id); + } +} diff --git a/src/bill/BillSource.php b/src/bill/BillSource.php new file mode 100644 index 00000000..08366f2c --- /dev/null +++ b/src/bill/BillSource.php @@ -0,0 +1,29 @@ +id = $id; + $this->name = $name; + } + + public function getId() + { + return $this->id; + } + + public function getName(): ?string + { + return $this->name; + } +} diff --git a/src/bill/BillTxn.php b/src/bill/BillTxn.php new file mode 100644 index 00000000..1b2de795 --- /dev/null +++ b/src/bill/BillTxn.php @@ -0,0 +1,49 @@ +value = $txn; + } + + public function getValue() + { + return $this->value; + } + + public static function fromString(string $txn): self + { + return new self($txn); + } +} diff --git a/src/charge/modifiers/Installment.php b/src/charge/modifiers/Installment.php index b97817a5..6900f416 100644 --- a/src/charge/modifiers/Installment.php +++ b/src/charge/modifiers/Installment.php @@ -41,7 +41,7 @@ public function buildPrice(Money $sum) $target = $this->getTarget(); $prepaid = Quantity::create('items', 0); - return new SinglePrice(null, $type, $target, null, $prepaid, $sum); + return new SinglePrice(null, $type, $target, $prepaid, $sum); } public function getType() diff --git a/src/price/PriceFactory.php b/src/price/PriceFactory.php index 37572f6e..53b85e19 100644 --- a/src/price/PriceFactory.php +++ b/src/price/PriceFactory.php @@ -91,7 +91,7 @@ public function createRatePrice(PriceCreationDto $dto) public function createSinglePrice(PriceCreationDto $dto) { - return new SinglePrice($dto->id, $dto->type, $dto->target, $dto->plan, $dto->prepaid, $dto->price); + return new SinglePrice($dto->id, $dto->type, $dto->target, $dto->prepaid, $dto->price, $dto->plan); } public function createProgressivePrice(PriceCreationDto $dto): ProgressivePrice diff --git a/src/price/SinglePrice.php b/src/price/SinglePrice.php index 0b667aac..316c3259 100644 --- a/src/price/SinglePrice.php +++ b/src/price/SinglePrice.php @@ -36,9 +36,9 @@ public function __construct( $id, TypeInterface $type, TargetInterface $target, - ?PlanInterface $plan = null, ?QuantityInterface $prepaid = null, - ?Money $price = null + ?Money $price = null, + ?PlanInterface $plan = null, ) { parent::__construct($id, $type, $target, $plan); $this->prepaid = $prepaid; diff --git a/tests/behat/bootstrap/FeatureContext.php b/tests/behat/bootstrap/FeatureContext.php index 7d4b592c..b20f850b 100644 --- a/tests/behat/bootstrap/FeatureContext.php +++ b/tests/behat/bootstrap/FeatureContext.php @@ -97,7 +97,7 @@ public function priceIs($target, $type, $sum, $currency, $unit, $quantity = 0) $target = new Target(Target::ANY, $target); $quantity = Quantity::create($unit, $quantity); $sum = $this->moneyParser->parse($sum, new Currency($currency)); - $this->setPrice(new SinglePrice(null, $type, $target, null, $quantity, $sum)); + $this->setPrice(new SinglePrice(null, $type, $target, $quantity, $sum)); } protected array $progressivePrice = []; diff --git a/tests/unit/action/ActionTest.php b/tests/unit/action/ActionTest.php index e0ad2f9d..da5baaf2 100644 --- a/tests/unit/action/ActionTest.php +++ b/tests/unit/action/ActionTest.php @@ -87,7 +87,7 @@ protected function setUp(): void $this->target = new Target(2, 'server'); $this->prepaid = Quantity::gigabyte(1); $this->money = Money::USD(10000); - $this->price = new SinglePrice(5, $this->type, $this->target, null, $this->prepaid, $this->money); + $this->price = new SinglePrice(5, $this->type, $this->target, $this->prepaid, $this->money); $this->customer = new Customer(2, 'client'); $this->time = new DateTimeImmutable('now'); $this->generalizer = new Generalizer(); diff --git a/tests/unit/charge/modifiers/InstallmentTest.php b/tests/unit/charge/modifiers/InstallmentTest.php index 5bb72642..cb6eb1e2 100644 --- a/tests/unit/charge/modifiers/InstallmentTest.php +++ b/tests/unit/charge/modifiers/InstallmentTest.php @@ -30,7 +30,7 @@ protected function setUp(): void { parent::setUp(); $this->type = Type::anyId('monthly,installment'); - $this->price = new SinglePrice(5, $this->type, $this->target, null, $this->prepaid, $this->money); + $this->price = new SinglePrice(5, $this->type, $this->target, $this->prepaid, $this->money); } protected function buildInstallment($term) diff --git a/tests/unit/charge/modifiers/OnceTest.php b/tests/unit/charge/modifiers/OnceTest.php index 12963805..f3ada8c6 100644 --- a/tests/unit/charge/modifiers/OnceTest.php +++ b/tests/unit/charge/modifiers/OnceTest.php @@ -37,7 +37,7 @@ private function createType(string $name): TypeInterface private function createPrice(TypeInterface $type): PriceInterface { - return new SinglePrice(5, $type, $this->target, null, $this->prepaid, $this->money); + return new SinglePrice(5, $type, $this->target, $this->prepaid, $this->money); } #[\PHPUnit\Framework\Attributes\DataProvider('periodCreationProvider')] diff --git a/tests/unit/price/SinglePriceTest.php b/tests/unit/price/SinglePriceTest.php index 92829f97..483698b9 100644 --- a/tests/unit/price/SinglePriceTest.php +++ b/tests/unit/price/SinglePriceTest.php @@ -40,7 +40,7 @@ protected function setUp(): void $this->type = new Type(null, 'server_traf'); $this->quantity = Quantity::gigabyte(10); $this->money = Money::USD(15); - $this->price = new SinglePrice(null, $this->type, $this->target, null, $this->quantity, $this->money); + $this->price = new SinglePrice(null, $this->type, $this->target, $this->quantity, $this->money); } protected function tearDown(): void