Add handling for forced prices, arrays, and improved type checks
Introduced support for forced pricing in `addItemToOrder` and added stricter validation for array inputs in SQL queries. Enhanced JSON handling in type validation and improved code reuse with new objects. Added new endpoint `/modules/xlvask/related-orders` to fetch related orders by wash IDs.
This commit is contained in:
@@ -60,10 +60,13 @@ class ordersRoute
|
||||
$response->success(
|
||||
$orders->listObjectsWithPaginationIfSet(
|
||||
function ($order) {
|
||||
$order_obj = new orders_o();
|
||||
// Get the order object
|
||||
$order_obj->select((int)$order['id']);
|
||||
// Add the invoice status to the order
|
||||
$order['economic_invoice_module'] = (new economic_module_orders())->getByOrderId($order['id'])->asArray();
|
||||
// Add the total amount to the order
|
||||
$order['total_net_amount'] = (new orders_o())->select($order['id'])->getNetAmount();
|
||||
$order['total_net_amount'] = $order_obj->getNetAmount();
|
||||
// Add the stripe status to the order
|
||||
$stripe_module_orders = (new stripe_module_orders_o())->select($order['id']);
|
||||
if ($stripe_module_orders->exists()) {
|
||||
@@ -71,11 +74,13 @@ class ordersRoute
|
||||
}
|
||||
// If the invoice collection is set, add it to the order
|
||||
if (!empty($order['invoice_collection_id'])) {
|
||||
$collected_order_invoices_obj = new collected_order_invoices_o();
|
||||
$collected_order_invoices_obj->select((int)$order['invoice_collection_id']);
|
||||
$order['invoice_collection'] = [
|
||||
'id' => $order['invoice_collection_id'],
|
||||
'closed_at' => (new collected_order_invoices_o())->select($order['invoice_collection_id'])->closed_at->value(),
|
||||
'booked_invoice_id' => (new collected_order_invoices_o())->select($order['invoice_collection_id'])->booked_invoice_id->value() ?? null,
|
||||
'processor' => (int)(new collected_order_invoices_o())->select($order['invoice_collection_id'])->processor->value() ?? null,
|
||||
'closed_at' => $collected_order_invoices_obj->closed_at->value(),
|
||||
'booked_invoice_id' => $collected_order_invoices_obj->booked_invoice_id->value() ?? null,
|
||||
'processor' => (int)$collected_order_invoices_obj->processor->value() ?? null,
|
||||
];
|
||||
}
|
||||
// Get the customer
|
||||
@@ -207,6 +212,10 @@ class ordersRoute
|
||||
if (isset($data['wash_id'])) {
|
||||
$order->wash_id->set($data['wash_id']);
|
||||
}
|
||||
// Check if the created_at is set
|
||||
if (isset($data['created_at'])) {
|
||||
$order->created_at->set($data['created_at']);
|
||||
}
|
||||
// If the department ID is set, validate it
|
||||
// Log the incident
|
||||
(new logs_o())->add('orders', $order->department_id->value(), 1, $user->id, 'EDIT_ORDER', 'Successfully updated an order (ID: ' . $data['id'] . ')');
|
||||
|
||||
Reference in New Issue
Block a user