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

fix: #44 - sometimes an user got a wron vat

Übergeordneter 51942167
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -10,6 +10,7 @@
use QUI\ERP\Accounting\ArticleList;
use QUI\ERP\Accounting\Payments\Payments;
use QUI\ERP\Money\Price;
use QUI\ERP\Products\Handler\Products;
use QUI\ERP\Accounting\Payments\Transactions\Transaction;
use QUI\ERP\Accounting\Payments\Transactions\Handler as TransactionHandler;
......@@ -306,6 +307,48 @@ public function setSuccessfulStatus()
//region API
/**
* Recalculate all article prices
*/
/**
* @throws Basket\Exception
* @throws QUI\ERP\Exception
* @throws QUI\Exception
*/
public function recalculate()
{
$Basket = new QUI\ERP\Order\Basket\BasketOrder(
$this->getHash(),
$this->getCustomer()
);
$Products = $Basket->getProducts();
$ArticleList = new 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) {
// @todo hinweis an benutzer, das artikel nicht mit aufgenommen werden konnte
}
}
$ArticleList->calc();
$this->Articles = $ArticleList;
$this->update();
}
/**
* Refresh the order data
* fetch the data from the database
......
......@@ -170,6 +170,9 @@ public function import($products = [])
$this->List->addProduct($Product);
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeDebugException($Exception);
// @todo message an benutzer - Product konnte nicht aufgenommen werden
}
}
}
......
......@@ -83,6 +83,8 @@ public function getBody()
$Engine = QUI::getTemplateManager()->getEngine();
$Order = $this->getOrder();
$Order->recalculate();
$Articles = $Order->getArticles()->toUniqueList();
$Articles->hideHeader();
......
......@@ -72,10 +72,8 @@ public function getBody()
}
try {
if ($Address->getId() !== $this->getOrder()->getInvoiceAddress()->getId()) {
$this->getOrder()->setInvoiceAddress($Address);
$this->getOrder()->save();
}
$this->getOrder()->setInvoiceAddress($Address);
$this->getOrder()->save();
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeDebugException($Exception);
}
......
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