finishing to dev
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m41s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 42s
Build, Push and Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-05-14 22:50:44 +07:00
parent 2fabdf8fc9
commit 8307b9e66d
212 changed files with 2451 additions and 4493 deletions

View File

@@ -8,6 +8,7 @@
use App\Services\PdfService;
use App\Traits\DateFilterTrait;
use App\Traits\DateRangeTrait;
use Illuminate\Support\Carbon;
use Maatwebsite\Excel\Facades\Excel;
use Modules\Business\App\Exports\ExportTransaction;
@@ -23,6 +24,15 @@ public function __construct()
public function index(Request $request)
{
$businessId = auth()->user()->business_id;
$today = Carbon::today()->format('Y-m-d');
$total_due = DueCollect::where('business_id', $businessId)
->whereDate('paymentDate', $today)
->sum('totalDue');
$total_paid = DueCollect::where('business_id', $businessId)
->whereDate('paymentDate', $today)
->sum('payDueAmount');
$transactionsQuery = DueCollect::with('party:id,name,type', 'payment_type:id,name', 'transactions')->where('business_id', $businessId);
@@ -83,44 +93,12 @@ public function exportCsv()
return Excel::download(new ExportTransaction, 'transaction-history.csv');
}
public function exportPdf(Request $request)
public function exportPdf()
{
$businessId = auth()->user()->business_id;
$transactions = DueCollect::with('party:id,name,type', 'payment_type:id,name', 'transactions')->where('business_id', auth()->user()->business_id)
->latest()
->get();
$transactionsQuery = DueCollect::with('party:id,name,type', 'payment_type:id,name', 'transactions')->where('business_id', $businessId);
// Date Filter
$duration = $request->custom_days ?: 'today';
[$filter_from_date, $filter_to_date] = $this->applyDateRange($duration, $request->from_date, $request->to_date);
$this->applyDateFilter($transactionsQuery, $duration, 'paymentDate', $request->from_date, $request->to_date);
// Search Filter
if ($request->filled('search')) {
$transactionsQuery->where(function ($query) use ($request) {
$query->where('paymentType', 'like', '%' . $request->search . '%')
->orWhere('totalDue', 'like', '%' . $request->search . '%')
->orWhere('invoiceNumber', 'like', '%' . $request->search . '%')
->orWhere('payDueAmount', 'like', '%' . $request->search . '%')
->orWhereHas('party', function ($q) use ($request) {
$q->where('name', 'like', '%' . $request->search . '%');
})
->orWhereHas('payment_type', function ($q) use ($request) {
$q->where('name', 'like', '%' . $request->search . '%');
});
});
}
if ($request->filled('type')) {
$transactionsQuery->whereHas('party', function ($q) use ($request) {
$q->where(function ($q) use ($request) {
$q->where('type', $request->type);
});
});
}
$transactions = $transactionsQuery->latest()->limit($request->per_page)->get();
return PdfService::render('business::reports.transaction-history.pdf', compact('transactions', 'duration', 'filter_from_date', 'filter_to_date'),'due-transactions-report.pdf');
return PdfService::render('business::reports.transaction-history.pdf', compact('transactions'),'due-transactions-report.pdf');
}
}