Store time ranges for index sites.

This commit is contained in:
2025-02-06 11:53:40 +01:00
parent 4c43bf2193
commit 3884a54539
9 changed files with 61 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
use App\Models\Incoming;
use App\Models\Incomingitem;
use App\Models\Incomingtax;
use App\Models\Option;
use App\Models\Supplier;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
@@ -17,6 +18,9 @@ class IncomingController extends Controller
*/
public function index($from = null, $end = null): JsonResponse
{
Option::updateOrCreate(['name' => 'incoming_from'], ['value' => $from]);
Option::updateOrCreate(['name' => 'incoming_end'], ['value' => $end]);
return response()->json(Incoming::whereBetween('issue_date', [$from, $end])->with(['supplier'])->orderBy('issue_date', 'desc')->get());
}

View File

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
use App\Enum\InvoiceTypeCode;
use App\Http\Controllers\Controller;
use App\Models\Invoice;
use App\Models\Option;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
@@ -16,6 +17,9 @@ class InvoiceController extends Controller
*/
public function index($from = null, $end = null): JsonResponse
{
Option::updateOrCreate(['name' => 'invoice_from'], ['value' => $from]);
Option::updateOrCreate(['name' => 'invoice_end'], ['value' => $end]);
$from = $from . ' 00:00:00';
$end = $end . ' 23:59:59';
return response()->json(Invoice::whereBetween('created_at', [$from, $end])->with(['address', 'customer'])->orderBy('created_at', 'desc')->get());

View File

@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Invoice;
use App\Models\Option;
use App\Models\Payment;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -15,6 +16,9 @@ class PaymentController extends Controller
*/
public function indexFilter($from = null, $end = null): JsonResponse
{
Option::updateOrCreate(['name' => 'payment_from'], ['value' => $from]);
Option::updateOrCreate(['name' => 'payment_end'], ['value' => $end]);
return response()->json(Payment::whereBetween('payment_date', [$from, $end])->with(['invoice'])->orderBy('payment_date', 'desc')->get());
}