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

feat: order -> addPriceFactors added

Übergeordneter f5af5ad6
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -94,8 +94,6 @@ public function clear()
try {
$Order = $this->getOrder();
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeDebugException($Exception);
try {
$Order = $this->createNewOrder();
} catch (QUi\Exception $Exception) {
......
......@@ -284,7 +284,8 @@ public function getOrder()
*/
public function updateOrder()
{
$this->Order->save();
$Order = $this->Order;
$Order->save();
}
//endregion
......
......@@ -160,6 +160,60 @@ public function update($PermissionUser = null)
);
}
/**
* Add price factors to the order
*
* @param array $priceFactors
* @throws QUI\Exception
*/
public function addPriceFactors($priceFactors = [])
{
$Basket = new QUI\ERP\Order\Basket\BasketOrder(
$this->getHash(),
$this->getCustomer()
);
$Products = $Basket->getProducts();
$ArticleList = new QUI\ERP\Accounting\ArticleList();
$ArticleList->setUser($this->getCustomer());
$ProductCalc = QUI\ERP\Products\Utils\Calc::getInstance();
$ProductCalc->setUser($this->getCustomer());
$Products->calc($ProductCalc);
$products = $Products->getProducts();
foreach ($products as $Product) {
try {
/* @var QUI\ERP\Order\Basket\Product $Product */
$ArticleList->addArticle($Product->toArticle(null, false));
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeDebugException($Exception);
}
}
foreach ($priceFactors as $PriceFactor) {
if (!($PriceFactor instanceof QUI\ERP\Products\Interfaces\PriceFactorInterface)) {
continue;
}
$Products->getPriceFactors()->addToEnd($PriceFactor);
}
$Products->recalculation();
// recalculate price factors
$ArticleList->importPriceFactors(
$Products->getPriceFactors()->toErpPriceFactorList()
);
$ArticleList->calc();
$this->Articles = $ArticleList;
$this->update();
}
/**
* Calculates the payment for the order
*
......
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