Skip to content

Commit

Permalink
added option priceWithTax to order
Browse files Browse the repository at this point in the history
  • Loading branch information
MartkCz committed Aug 24, 2017
1 parent b9878d3 commit a356e7d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/Data/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,36 @@ class Order {
/** @var Item[] */
private $items = [];

/** @var bool */
private $hasPriceWithTax = FALSE;

/**
* @param string|int $number
* @param \DateTime $dueDate
* @param Account $account
* @param PaymentInformation $payment
* @param \DateTime|NULL $created
* @param bool $hasPriceWithTax
*/
public function __construct($number, ?\DateTime $dueDate, ?Account $account, PaymentInformation $payment,
\DateTime $created = NULL) {
\DateTime $created = NULL, bool $hasPriceWithTax = FALSE) {
$this->number = $number;
$this->dueDate = $dueDate;
$this->account = $account;
$this->payment = $payment;
$this->created = $created ? : new \DateTime();
$this->hasPriceWithTax = $hasPriceWithTax;

$this->validate();
}

/**
* @return bool
*/
public function hasPriceWithTax(): bool {
return $this->hasPriceWithTax;
}

/**
* @param string $name
* @param int|float $price
Expand Down
2 changes: 1 addition & 1 deletion src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ protected function totalPrice($plus) {
*/
private function getTotalPrice($useTax = FALSE) {
$total = 0;
if ($useTax && $this->company->hasTax() && $this->order->getPayment()->getTax() !== NULL) {
if ($useTax && $this->company->hasTax() && $this->order->getPayment()->getTax() !== NULL && !$this->order->hasPriceWithTax()) {
$tax = $this->order->getPayment()->getTax() + 1;
} else {
$tax = 1;
Expand Down

0 comments on commit a356e7d

Please sign in to comment.