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

fix: correct price factors calculation for the ERP Factor List

Übergeordneter b88cbb4a
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -51,7 +51,7 @@
{$priceFactor.title} {if !empty($priceFactor.valueText)}({$priceFactor.valueText}){/if}
</td>
<td class="articles-sum-row-sndCell">
{$priceFactor.sum}
{$priceFactor.sumFormatted}
</td>
</tr>
{/foreach}
......
......@@ -7,6 +7,7 @@
namespace QUI\ERP\Accounting;
use QUI;
use QUI\ERP\Accounting\PriceFactors\FactorList as ErpFactorList;
/**
* Class ArticleListUnique
......@@ -72,13 +73,11 @@ public function __construct($attributes = [])
// price factors
$this->PriceFactors = new QUI\ERP\Accounting\PriceFactors\FactorList();
$this->PriceFactors = new ErpFactorList();
if (isset($attributes['priceFactors'])) {
try {
$this->PriceFactors = new QUI\ERP\Accounting\PriceFactors\FactorList(
$attributes['priceFactors']
);
$this->PriceFactors = new ErpFactorList($attributes['priceFactors']);
} catch (QUI\ERP\Exception $Exception) {
QUI\System\Log::writeRecursive(
$attributes['priceFactors'],
......
......@@ -152,7 +152,6 @@ public function calcArticleList(ArticleList $List, $callback = false)
$articles = $List->getArticles();
$isNetto = QUI\ERP\Utils\User::isNettoUser($this->getUser());
$isEuVatUser = QUI\ERP\Tax\Utils::isUserEuVatUser($this->getUser());
$Area = QUI\ERP\Utils\User::getUserArea($this->getUser());
$subSum = 0;
$nettoSum = 0;
......@@ -211,68 +210,25 @@ public function calcArticleList(ArticleList $List, $callback = false)
$nettoSubSum = $nettoSum;
/* @var $PriceFactor QUI\ERP\Accounting\PriceFactors\Factor */
// foreach ($priceFactors as $PriceFactor) {
// switch ($PriceFactor->getCalculation()) {
// // einfache Zahl, Währung --- kein Prozent
// case self::CALCULATION_COMPLEMENT:
// $nettoSum = $nettoSum + $PriceFactor->getValue();
// $priceFactorSum = $priceFactorSum + $PriceFactor->getValue();
//
// $PriceFactor->setNettoSum($PriceFactor->getValue());
// break;
//
// // Prozent Angabe
// case self::CALCULATION_PERCENTAGE:
// switch ($PriceFactor->getCalculationBasis()) {
// default:
// case self::CALCULATION_BASIS_NETTO:
// $percentage = $PriceFactor->getValue() / 100 * $nettoSubSum;
// break;
//
// case self::CALCULATION_BASIS_BRUTTO:
// case self::CALCULATION_BASIS_CURRENTPRICE:
// $percentage = $PriceFactor->getValue() / 100 * $nettoSum;
// break;
// }
//
// $PriceFactor->setNettoSum($percentage);
//
// $nettoSum = $this->round($nettoSum + $percentage);
// $priceFactorSum = $priceFactorSum + $percentage;
// break;
//
// default:
// continue;
// }
//
// // add pricefactor VAT
// if (!($PriceFactor instanceof QUI\ERP\Products\Interfaces\PriceFactorWithVatInterface)) {
// continue;
// }
//
// /* @var $PriceFactor QUI\ERP\Products\Interfaces\PriceFactorWithVatInterface */
// $VatType = $PriceFactor->getVatType();
// $Vat = QUI\ERP\Tax\Utils::getTaxEntry($VatType, $Area);
// $vatSum = $PriceFactor->getNettoSum() * ($Vat->getValue() / 100);
// $vat = $Vat->getValue();
//
// if ($isNetto) {
// $PriceFactor->setSum($PriceFactor->getNettoSum());
// } else {
// $PriceFactor->setSum($vatSum + $PriceFactor->getNettoSum());
// }
//
// if (!isset($vatArray[$vat])) {
// $vatArray[$vat] = [
// 'vat' => $vat,
// 'text' => self::getVatText($Vat->getValue(), $this->getUser())
// ];
//
// $vatArray[$vat]['sum'] = 0;
// }
//
// $vatArray[$vat]['sum'] = $vatArray[$vat]['sum'] + $vatSum;
// }
foreach ($priceFactors as $PriceFactor) {
$nettoSum = $nettoSum + $PriceFactor->getNettoSum();
$priceFactorSum = $priceFactorSum + $PriceFactor->getNettoSum();
$vat = $PriceFactor->getVat();
$vatSum = $PriceFactor->getVatSum();
if (!isset($vatArray[$vat])) {
$vatArray[$vat] = [
'vat' => $vat,
'text' => self::getVatText($vatSum, $this->getUser())
];
$vatArray[$vat]['sum'] = 0;
}
$vatArray[$vat]['sum'] = $vatArray[$vat]['sum'] + $vatSum;
}
// vat text
$vatLists = [];
......
......@@ -8,6 +8,7 @@
use QUI\ERP\Exception;
use QUI\System\Log;
use QUI\Utils\Math;
/**
* Class FactorList
......@@ -136,7 +137,30 @@ public function getSumFormatted()
*/
public function getNettoSum()
{
return $this->sum;
return $this->nettoSum;
}
/**
* Return the sum from the vat
*
* @return float|int|mixed
*/
public function getVatSum()
{
return $this->sum - $this->nettoSum;
}
/**
* Return the vat %
*
* @return int
*/
public function getVat()
{
$vat = abs($this->sum - $this->nettoSum);
$nettoSum = abs($this->nettoSum);
return Math::percent($vat, $nettoSum);
}
/**
......@@ -167,7 +191,7 @@ public function toArray()
return [
'title' => $this->getTitle(),
'description' => $this->getDescription(),
'sum' => $this->getSumFormatted(),
'sum' => $this->getSum(),
'sumFormatted' => $this->getSumFormatted(),
'nettoSum' => $this->getNettoSum(),
'nettoSumFormatted' => $this->getNettoSumFormatted(),
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren