Implement vehicle subscription handling and department SMS feature

Added functionality to handle vehicle subscriptions in invoices, including validation and item visibility. Introduced department notification SMS capability with endpoints for creating, retrieving, and deleting SMS records. Enhanced invoice drafting logic to exclude items not flagged for inclusion in invoices.
This commit is contained in:
Jepp9350
2025-04-14 16:03:29 +02:00
parent 6efa414251
commit 7b82be6c57
8 changed files with 514 additions and 11 deletions
+14 -2
View File
@@ -51,6 +51,12 @@ class order_items_o extends db
*/
public object_property $related_item_id;
/**
* The include in invoice property
* @var object_property
*/
public object_property $include_in_invoice;
public function structure(): void
{
$this->setTable('order_items');
@@ -84,9 +90,10 @@ class order_items_o extends db
$this->price = new object_property($this->table, $this->id, 'price', 'int', true);
$this->quantity = new object_property($this->table, $this->id, 'quantity', 'int', true);
$this->related_item_id = new object_property($this->table, $this->id, 'related_item_id', 'int', false);
$this->include_in_invoice = new object_property($this->table, $this->id, 'include_in_invoice', 'bool', false);
}
public function add(int $order_id, int $product_id, string $reference, string $notes, int $cashier_id, int $price, int $quantity): void
public function add(int $order_id, int $product_id, string $reference, string $notes, int $cashier_id, int $price, int $quantity, $related_item_id = null): void
{
global $db, $response;
try {
@@ -102,6 +109,10 @@ class order_items_o extends db
// Set the values of the object properties
$this->getObjectProperties();
// Set the related item id, if it is set
if ($related_item_id) {
$this->related_item_id->set($related_item_id);
}
} catch (\Exception $e) {
$response->error($e->getMessage());
}
@@ -186,7 +197,8 @@ class order_items_o extends db
'quantity' => (int)$this->quantity->value(),
'related_item_id' => (int)$this->related_item_id->value(),
'product' => (array)(new products_o())->getProductById($this->product_id->value())->asArray(),
'cashier' => (array)(new users_o())->getUserById($this->cashier_id->value())->asArray()
'cashier' => (array)(new users_o())->getUserById($this->cashier_id->value())->asArray(),
'include_in_invoice' => (bool)$this->include_in_invoice->value(),
];
}