migrate to gtea from bistbucket

This commit is contained in:
2026-03-15 17:08:23 +07:00
commit 129ca2260c
3716 changed files with 566316 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
<?php
namespace Modules\Business\App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Party;
use App\Models\Sale;
use App\Services\PdfService;
use Maatwebsite\Excel\Facades\Excel;
use Modules\Business\App\Exports\ExportPartyLossProfit;
class AcnooPartyLossProfitController extends Controller
{
public function index(Request $request)
{
$sale = Sale::where('business_id', auth()->user()->business_id)->whereNotNull('party_id')->get();
$totalAmount = $sale->sum('totalAmount');
$totalProfit = $sale->where('lossProfit', '>', 0)->sum('lossProfit') ?? 0;
$totalLoss = $sale->where('lossProfit', '<', 0)->sum('lossProfit') ?? 0;
$parties = Party::with('sales')
->where('business_id', auth()->user()->business_id)
->where('type', '!=', 'Supplier')
->when($request->search, function ($query) use ($request) {
$query->where(function ($q) use ($request) {
$q->where('name', 'like', '%' . $request->search . '%');
});
})
->latest()
->paginate($request->per_page ?? 20)
->appends($request->query());
if ($request->ajax()) {
return response()->json([
'data' => view('business::party-reports.loss-profit.datas', compact('parties'))->render()
]);
}
return view('business::party-reports.loss-profit.index', compact('parties', 'totalAmount', 'totalProfit', 'totalLoss'));
}
public function exportExcel()
{
return Excel::download(new ExportPartyLossProfit, 'party-loss-profit.xlsx');
}
public function exportCsv()
{
return Excel::download(new ExportPartyLossProfit, 'party-loss-profit.csv');
}
public function exportPdf()
{
$parties = Party::with('sales')
->where('business_id', auth()->user()->business_id)
->where('type', '!=', 'Supplier')
->latest()
->get();
return PdfService::render('business::party-reports.loss-profit.pdf', compact('parties'),'party-loss-profit-report.pdf');
}
public function view($id)
{
$party = Party::with('sales.details', 'sales.details.product')
->where('id', $id)
->where('business_id', auth()->user()->business_id)
->firstOrFail();
return response()->json([
'sales' => $party->sales
]);
}
}