Add custom routes, subscription features, and refactor orders
Introduced a new POST route for collected vehicle subscription invoices and enhanced responses with wash subscription transactions. Refactored order handling by adding department-based pricing logic and simplifying reusable methods. Various minor improvements include exception handling, input validation, and updated permissions.
This commit is contained in:
@@ -34,6 +34,14 @@ class ordersRoute
|
||||
// Create economic_module_orders object
|
||||
$economic_module_orders = new economic_module_orders();
|
||||
$orders = new orders_o();
|
||||
$department_ids = $user->getGroup()->getDepartments();
|
||||
if (self::isParametersSet(['show_wash_subscription'])) {
|
||||
// Check if the boolean is true
|
||||
if (self::getParameter('show_wash_subscription') === 'true') {
|
||||
// add the '10' to the department_ids
|
||||
$department_ids[] = '10';
|
||||
}
|
||||
}
|
||||
// Return the list of departments
|
||||
$orders->setView('orders_with_invoice_collections');
|
||||
$response->success(
|
||||
@@ -65,7 +73,7 @@ class ordersRoute
|
||||
$orders->forceRestrictFilters(
|
||||
[
|
||||
// This makes sure that the user can only see orders from the departments they explicitly have access to
|
||||
'department_id' => $user->getGroup()->getDepartments(),
|
||||
'department_id' => $department_ids,
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -429,7 +437,7 @@ class ordersRoute
|
||||
$this->delete('/orders/module/stripe/payment_intent', function () {
|
||||
// Require the user to be logged in
|
||||
global $response;
|
||||
$this->requirePermission('delete_payment_intent');
|
||||
$this->requirePermission('charge_order');
|
||||
// Get the user object
|
||||
$user = (new authentication())->get_user();
|
||||
// Check if the request was successful
|
||||
@@ -466,7 +474,11 @@ class ordersRoute
|
||||
// Return an error
|
||||
$response->error('Invalid session', 400);
|
||||
}
|
||||
});
|
||||
},
|
||||
[
|
||||
'charge_order' => 'Delete a payment intent'
|
||||
]
|
||||
);
|
||||
|
||||
$this->post('/orders/module/stripe/payment_intent/capture', function () {
|
||||
// Require the user to be logged in
|
||||
|
||||
Reference in New Issue
Block a user