Refactor invoice handling and add total net amount calculation
Introduce logic for validating booked and draft invoices in E-conomic. Add methods to calculate the total net amount for invoice collections and improve error handling for specific invoice states. Updated related workflows to ensure consistent validation and data integrity.
This commit is contained in:
@@ -446,4 +446,22 @@ class orders_o extends db
|
||||
$result = $db->query($sql);
|
||||
return $db->fetch_all($result);
|
||||
}
|
||||
|
||||
public function getNetAmount(): float
|
||||
{
|
||||
self::requireSelected();
|
||||
$net = 0;
|
||||
// Get the order items object
|
||||
$order_items = new order_items_o();
|
||||
// Get the price, quantity of the order items
|
||||
$items = $order_items->getAllItemsAsArray($this->id);
|
||||
// Loop through the items and get the net amount
|
||||
foreach ( $items as $item ) {
|
||||
$tmp_price = (int)$item['price'];
|
||||
$tmp_quantity = (int)$item['quantity'];
|
||||
// Add the price to the net amount
|
||||
$net += $tmp_price * $tmp_quantity;
|
||||
}
|
||||
return $net;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user