Skip to content

Commit

Permalink
Merge pull request #186 from horstoeko/Issue_185
Browse files Browse the repository at this point in the history
#185 Fixed duplicated VAT Breakdown in QuickDescriptor
  • Loading branch information
horstoeko authored Nov 26, 2024
2 parents 1ce5509 + 3a7aeec commit def6f29
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/quick/ZugferdQuickDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ class ZugferdQuickDescriptor extends ZugferdDocumentBuilder
*/
protected $totalPrepaidAmount = 0.0;

/**
* Internal flag to see if the totals are alread calculated
*
* @var boolean
*/
protected $totalsAreCalculated = false;

/**
* Returns the profile of the descriptor
*
Expand Down Expand Up @@ -1035,6 +1042,10 @@ public function doSetPrepaidAmount(float $totalPrepaidAmount = 0.0): ZugferdQuic
*/
protected function doCalcTotals(): ZugferdQuickDescriptor
{
if ($this->totalsAreCalculated !== false) {
return $this;
}

$this->writeVatBreakDown();
$this->setDocumentSummation(
$this->summarizeVatTableElement(self::VT_BASISAMOUNT) + $this->summarizeVatTableElement(self::VT_CALCULATEDAMOUNT),
Expand All @@ -1047,6 +1058,9 @@ protected function doCalcTotals(): ZugferdQuickDescriptor
0.0,
$this->totalPrepaidAmount
);

$this->totalsAreCalculated = true;

return $this;
}

Expand Down

0 comments on commit def6f29

Please sign in to comment.