Skip to content
Code-Schnipsel Gruppen Projekte
Commit a6ebf3f4 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix: pricefactors calculated

Übergeordneter 33a4381c
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -45,23 +45,23 @@
</td>
</tr>
{if count($priceFactors)}
<tr>
<td colspan="2"><br/></td>
</tr>
{/if}
{foreach $priceFactors as $priceFactor}
<tr>
<td class="articles-sum-row-firstCell">
{$priceFactor.title}
{$priceFactor.title} ({$priceFactor.valueText})
</td>
<td class="articles-sum-row-sndCell">
{$priceFactor.valueText}
{$priceFactor.sum}
</td>
</tr>
{/foreach}
{if count($priceFactors)}
<tr>
<td colspan="2"><br/></td>
</tr>
{/if}
{foreach $vatArray as $vat}
<tr>
<td>
......@@ -73,12 +73,6 @@
</tr>
{/foreach}
{*if count($data.attributes)}
<tr>
<td colspan="2"><br/></td>
</tr>
{/if*}
<tr class="articles-sum-row-sum">
<td class="articles-sum-row-firstCell">
<span class="articles-sum-row-sum-text">
......
......@@ -218,7 +218,7 @@ public function toArray()
$result['attributes'][] = [
'title' => $Factor->getTitle(),
'value' => $Factor->getNettoSumFormatted(),
'value' => $Factor->getSumFormatted(),
'valueText' => $Factor->getValueText(),
];
}
......
......@@ -256,7 +256,11 @@ public function calcArticleList(ArticleList $List, $callback = false)
$vatSum = $PriceFactor->getNettoSum() * ($Vat->getValue() / 100);
$vat = $Vat->getValue();
$PriceFactor->setBruttoSum($vatSum + $PriceFactor->getNettoSum());
if ($isNetto) {
$PriceFactor->setSum($PriceFactor->getNettoSum());
} else {
$PriceFactor->setSum($vatSum + $PriceFactor->getNettoSum());
}
if (!isset($vatArray[$vat])) {
$vatArray[$vat] = [
......@@ -285,6 +289,30 @@ public function calcArticleList(ArticleList $List, $callback = false)
$vatText[$vat] = self::getVatText($vat, $this->getUser());
}
// gegenrechnung, wegen rundungsfehler
if ($isNetto === false) {
$priceFactorBruttoSums = 0;
foreach ($priceFactors as $Factor) {
/* @var $Factor QUI\ERP\Products\Utils\PriceFactor */
$priceFactorBruttoSums = $priceFactorBruttoSums + round($Factor->getSum(), 2);
}
$priceFactorBruttoSum = $subSum + $priceFactorBruttoSums;
if ($priceFactorBruttoSum !== round($bruttoSum, 2)) {
$diff = $priceFactorBruttoSum - round($bruttoSum, 2);
// if we have a diff, we change the first vat price factor
foreach ($priceFactors as $Factor) {
if ($Factor instanceof QUI\ERP\Products\Interfaces\PriceFactorWithVatInterface) {
$Factor->setSum(round($Factor->getSum() - $diff, 2));
break;
}
}
}
}
$callback([
'sum' => $bruttoSum,
'subSum' => $subSum,
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren