update marketing
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 5m14s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 17s
Build, Push and Deploy / deploy-staging (push) Successful in 41s
Build, Push and Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-05-14 11:55:22 +07:00
parent f80fcc4c1b
commit 05fd3230b8
448 changed files with 17545 additions and 5128 deletions

View File

@@ -124,13 +124,78 @@ public function exportCsv()
return Excel::download(new ExportTransactionReport, 'bill-wise-profit.csv');
}
public function exportPdf()
public function exportPdf(Request $request)
{
$transactions = Transaction::with('paymentType')
->where('business_id', auth()->user()->business_id)
->latest()
->get();
$businessId = auth()->user()->business_id;
return PdfService::render('business::transactions.pdf', compact('transactions'),'transactions-report.pdf');
$transactionsQuery = Transaction::with('paymentType')
->where('business_id', $businessId);
$duration = $request->custom_days ?: 'today';
[$filter_from_date, $filter_to_date] = $this->applyDateRange($duration, $request->from_date, $request->to_date);
$this->applyDateFilter($transactionsQuery, $duration, 'date', $request->from_date, $request->to_date);
// Search filter
if ($request->filled('search')) {
$transactionsQuery->where(function ($query) use ($request) {
$query->where('amount', 'like', '%' . $request->search . '%')
->orWhere('invoice_no', 'like', '%' . $request->search . '%')
->orWhere('platform', 'like', '%' . $request->search . '%')
->orWhere('type', 'like', '%' . $request->search . '%');
});
}
// Platform filter
if ($request->filled('platform')) {
$transactionsQuery->where('platform', $request->platform);
}
// Party Filter
if ($request->filled('party_id')) {
$transactionsQuery->where(function ($q) use ($request) {
$q->where(function ($saleQ) use ($request) {
$saleQ->where('platform', 'sale')
->whereHas('sale', function ($s) use ($request) {
$s->where('party_id', $request->party_id);
});
});
$q->where(function ($saleRtnQ) use ($request) {
$saleRtnQ->where('platform', 'sale_return')
->whereHas('saleReturn.sale', function ($s) use ($request) {
$s->where('party_id', $request->party_id);
});
});
$q->orWhere(function ($purQ) use ($request) {
$purQ->where('platform', 'purchase')
->whereHas('purchase', function ($p) use ($request) {
$p->where('party_id', $request->party_id);
});
});
$q->orWhere(function ($purRtnQ) use ($request) {
$purRtnQ->where('platform', 'purchase_return')
->whereHas('purchaseReturn.purchase', function ($p) use ($request) {
$p->where('party_id', $request->party_id);
});
});
$q->orWhere(function ($dueQ) use ($request) {
$dueQ->where('platform', 'due_collect')
->whereHas('dueCollect', function ($d) use ($request) {
$d->where('party_id', $request->party_id);
});
});
});
}
$transactions = $transactionsQuery->latest()->limit($request->per_page ?? 20)->get();
return PdfService::render('business::transactions.pdf', compact('transactions', 'duration', 'filter_from_date', 'filter_to_date'),'transactions-report.pdf');
}
}