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

refactor: addPriceFactor method -> #78

Übergeordneter 802f402e
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -11,6 +11,8 @@
use function count;
use function is_null;
use function key;
use function round;
/**
* Class ArticleList
......@@ -477,6 +479,42 @@ public function importPriceFactors(QUI\ERP\Accounting\PriceFactors\FactorList $P
$this->PriceFactors = $PriceFactors;
}
/**
* @param \QUI\ERP\Accounting\PriceFactors\Factor|QUI\ERP\Products\Utils\PriceFactor $PriceFactor
* @return void
*
* @throws \QUI\ERP\Exception
*/
public function addPriceFactor($PriceFactor)
{
if ($PriceFactor instanceof QUI\ERP\Products\Utils\PriceFactor) {
$isNetto = $this->isNetto;
$vat = 0;
$netto = $PriceFactor->getNettoSum();
$precision = $this->getCurrency()->getPrecision();
if (count($this->vatArray)) {
$vat = key($this->vatArray);
}
$PriceFactor->setVat($vat);
$brutto = $netto * ((100 + $vat) / 100);
$brutto = round($brutto, $precision);
if ($isNetto) {
$PriceFactor->setSum($netto);
} else {
$PriceFactor->setSum($brutto);
}
$PriceFactor = new QUI\ERP\Accounting\PriceFactors\Factor($PriceFactor->toArray());
}
$this->PriceFactors->addFactor($PriceFactor);
$this->recalculate();
}
//endregion
//region order
......
......@@ -90,6 +90,15 @@ public function toJSON(): string
return json_encode($this->toArray());
}
/**
* @param \QUI\ERP\Accounting\PriceFactors\Factor $Factor
* @return void
*/
public function addFactor(Factor $Factor)
{
$this->list[] = $Factor;
}
//region iterator
/**
......
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