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

refactor: new price factor list considered

Übergeordneter 8c177448
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -210,8 +210,8 @@ public function toArray()
$data['articles'] = $articles;
$data['calculations'] = $calculations;
/* @var $Factor QUI\ERP\Products\Utils\PriceFactor */
foreach ($this->PriceFactors->sort() as $Factor) {
/* @var $Factor PriceFactors\Factor */
foreach ($this->PriceFactors as $Factor) {
if (!$Factor->isVisible()) {
continue;
}
......@@ -219,7 +219,7 @@ public function toArray()
$result['attributes'][] = [
'title' => $Factor->getTitle(),
'value' => $Factor->getSumFormatted(),
'valueText' => $Factor->getValueText(),
'valueText' => ''
];
}
......@@ -357,9 +357,9 @@ public function count()
/**
* Import a price factor list
*
* @param QUI\ERP\Products\Utils\PriceFactors $PriceFactors
* @param QUI\ERP\Accounting\PriceFactors\FactorList $PriceFactors
*/
public function importPriceFactors($PriceFactors)
public function importPriceFactors(QUI\ERP\Accounting\PriceFactors\FactorList $PriceFactors)
{
$this->PriceFactors = $PriceFactors;
}
......
......@@ -34,7 +34,7 @@ class ArticleListUnique
/**
* PriceFactor List
*
* @var QUI\ERP\Products\Utils\PriceFactors
* @var QUI\ERP\Accounting\PriceFactors\FactorList
*/
protected $PriceFactors = false;
......@@ -72,10 +72,21 @@ public function __construct($attributes = [])
// price factors
$this->PriceFactors = new QUI\ERP\Products\Utils\PriceFactors();
$this->PriceFactors = new QUI\ERP\Accounting\PriceFactors\FactorList();
if (isset($attributes['priceFactors'])) {
$this->PriceFactors->importList($attributes['priceFactors']);
try {
$this->PriceFactors = new QUI\ERP\Accounting\PriceFactors\FactorList(
$attributes['priceFactors']
);
} catch (QUI\ERP\Exception $Exception) {
QUI\System\Log::writeRecursive(
$attributes['priceFactors'],
QUI\System\Log::LEVEL_DEBUG
);
QUI\System\Log::writeDebugException($Exception);
}
}
}
......@@ -159,7 +170,7 @@ public function toArray()
return $Article->toArray();
}, $this->articles);
$this->PriceFactors->sort();
$this->PriceFactors->toArray();
return [
'articles' => $articles,
......@@ -228,16 +239,9 @@ public function toHTML($template = false)
return $View;
}, $this->articles);
// price factors
$priceFactors = $this->PriceFactors->sort();
$priceFactors = array_map(function ($Factor) {
/* @var $Factor QUI\ERP\Products\Utils\PriceFactor */
return $Factor->toArray();
}, $priceFactors);
// output
$Engine->assign([
'priceFactors' => $priceFactors,
'priceFactors' => $this->PriceFactors->toArray(),
'showHeader' => $this->showHeader,
'this' => $this,
'articles' => $articles,
......@@ -285,7 +289,7 @@ public function render()
/**
* Return the price factors list (list of price indicators)
*
* @return QUI\ERP\Products\Utils\PriceFactors
* @return QUI\ERP\Accounting\PriceFactors\FactorList
*/
public function getPriceFactors()
{
......
......@@ -204,75 +204,75 @@ public function calcArticleList(ArticleList $List, $callback = false)
/**
* Calc price factors
*/
$priceFactors = $List->getPriceFactors()->sort();
$priceFactors = $List->getPriceFactors();
$priceFactorSum = 0;
// nur wenn wir welche benötigen, für ERP Artikel ist dies im Moment nicht wirklich nötig
$nettoSubSum = $nettoSum;
/* @var $PriceFactor QUI\ERP\Products\Utils\PriceFactor */
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;
}
/* @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;
// }
// vat text
$vatLists = [];
......
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