mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 13:33:57 +00:00
Merge branch 'dillon/90-e-invoice-f-2' into vapor/development
This commit is contained in:
@@ -43,6 +43,49 @@ class ListBookingsSalesInvoiceLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
// $this->canListBookings->passes(); //cief todo: 90 - apipub
|
||||
$filters = $request->input('filters');
|
||||
|
||||
// Decode JSON if sent as string
|
||||
if (is_string($filters)) {
|
||||
$filters = json_decode($filters, true);
|
||||
}
|
||||
|
||||
if (!is_array($filters)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Invalid filters format. Expected JSON object.'
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Only these filters are allowed
|
||||
$allowedKeys = ['per_page', 'status', 'order_by', 'date_range', 'date_range_no_data'];
|
||||
|
||||
$extra = array_diff(array_keys($filters), $allowedKeys);
|
||||
if (!empty($extra)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Invalid filter(s) provided: ' . implode(', ', $extra),
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Required filters that must always exist
|
||||
$alwaysRequired = ['per_page', 'status'];
|
||||
|
||||
$missing = array_diff($alwaysRequired, array_keys($filters));
|
||||
if (!empty($missing)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Missing required filter(s): ' . implode(', ', $missing),
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Required at least one of: date_range or date_range_no_data
|
||||
if (!isset($filters['date_range']) && !isset($filters['date_range_no_data'])) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Either "date_range" or "date_range_no_data" filter is required.',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$query = $this->listsBookings->execute($this->listsBookings->deserializeFilters($request->input('filters')));
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Bookings\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject;
|
||||
|
||||
|
||||
class CanListBookingsSalesInvoice extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BookingObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BookingObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user