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

feat: extends main comments object -> import and sort methods; the main erp...

feat: extends main comments object -> import and sort methods; the main erp process can return the complete history of all erp objects
Übergeordneter 736ae33d
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -12,6 +12,7 @@
* Class Comments
* - Invoice comments
* - order comments
* - transaction comments
*
* Helper class to manage comment arrays
*
......@@ -115,4 +116,34 @@ public function clear()
{
$this->comments = [];
}
/**
* Sort all comments via its time
*/
public function sort()
{
usort($this->comments, function ($commentA, $commentB) {
if ($commentA['time'] == $commentB['time']) {
return 0;
}
return ($commentA['time'] < $commentB['time']) ? -1 : 1;
});
}
/**
* Import another Comments object into this Comments Object
*
* @param Comments $Comments
*/
public function import(Comments $Comments)
{
$comments = $Comments->toArray();
foreach ($comments as $comment) {
$this->addComment($comment['message'], $comment['time']);
}
$this->sort();
}
}
......@@ -71,7 +71,10 @@ public function addHistory($message, $time = false)
}
/**
* Return the invoice history
* Return the history of the process
* This history only contains the process history
*
* If you want the complete history of all process objects, use getCompleteHistory()
*
* @return QUI\ERP\Comments
*/
......@@ -98,6 +101,30 @@ public function getHistory()
return $this->History;
}
/**
* Return a complete history of all process objects
* invoices invoices and orders
*
* @return Comments
*/
public function getCompleteHistory()
{
$History = $this->getHistory();
$invoices = $this->getInvoices();
$orders = $this->getOrders();
foreach ($invoices as $Invoice) {
$History->import($Invoice->getHistory());
}
foreach ($orders as $Order) {
$History->import($Order->getHistory());
}
return $History;
}
//endregion
//region invoice
......@@ -139,9 +166,7 @@ public function hasTemporaryInvoice()
}
/**
* Return all invoices from the process
*
* @return array
* @return Accounting\Invoice\Invoice[]|Accounting\Invoice\InvoiceTemporary[]
*/
public function getInvoices()
{
......@@ -164,7 +189,7 @@ public function hasOrder()
}
/**
* Return the order, if the process has an order
* Return the first order of the process
*
* @return null|Order\Order|Order\OrderInProcess|Order\Order|Order\Order
*/
......@@ -193,6 +218,22 @@ public function getOrder()
return null;
}
/**
* Return all orders from the process
*
* @return array|Order\Order|Order\Order[]|Order\OrderInProcess
*/
public function getOrders()
{
try {
QUI::getPackage('quiqqer/order');
} catch (QUI\Exception $Exception) {
return [];
}
return QUI\ERP\Order\Handler::getInstance()->getOrdersByGlobalProcessId($this->processId);
}
//endregion
//region transactions
......
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