E-Invoice - Project 27: Import Tax Entity, Customers Data Report

This commit is contained in:
Dillon Ngo
2025-07-20 18:58:53 +08:00
parent 494efd7c6d
commit 2bdc0e1828
8 changed files with 6190 additions and 45 deletions
@@ -8,11 +8,35 @@ use Illuminate\Http\Request;
use Maatwebsite\Excel\Excel;
use Illuminate\Support\Facades\Storage;
use App\Classes\General\AWSS3Helper;
use App\Classes\Modules\Exports\Services\ExportsCompanies;
use Carbon\Carbon;
class ExportController
{
public function salesInvoices(Request $request){
$exportsTransactions = new ExportsSalesInvoiceReport($request);
$validated = $request->validate([
'startDate' => 'nullable|date_format:d-m-Y',
'endDate' => 'nullable|date_format:d-m-Y|after_or_equal:startDate',
]);
$startDate = null;
$endDate = null;
if (isset($validated['startDate']) && $validated['startDate']) {
$startDate = Carbon::createFromFormat('d-m-Y', $validated['startDate'])->startOfDay();
} else {
$startDate = Carbon::now()->subMonths(1)->startOfDay();
}
if (isset($validated['endDate']) && $validated['endDate']) {
$endDate = Carbon::createFromFormat('d-m-Y', $validated['endDate'])->endOfDay();
} else {
$endDate = Carbon::now()->endOfDay();
}
$exportsTransactions = new ExportsSalesInvoiceReport($startDate, $endDate);
$exportFileName = 'Exchange - Sales Invoice Report.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
@@ -24,4 +48,39 @@ class ExportController
}
return $response;
}
public function companies(Request $request){
$validated = $request->validate([
'startDate' => 'nullable|date_format:d-m-Y',
'endDate' => 'nullable|date_format:d-m-Y|after_or_equal:startDate',
]);
$startDate = null;
$endDate = null;
if (isset($validated['startDate']) && $validated['startDate']) {
$startDate = Carbon::createFromFormat('d-m-Y', $validated['startDate'])->startOfDay();
} else {
$startDate = Carbon::now()->subMonths(1)->startOfDay();
}
if (isset($validated['endDate']) && $validated['endDate']) {
$endDate = Carbon::createFromFormat('d-m-Y', $validated['endDate'])->endOfDay();
} else {
$endDate = Carbon::now()->endOfDay();
}
$exportsCompanies = new ExportsCompanies($startDate, $endDate);
$exportFileName = 'Exchange - Customers Data Report.xls';
$filesystemDriver = Storage::getDefaultDriver();
if($filesystemDriver === 's3'){
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsCompanies) ]);
}
else{
$response = $exportsCompanies->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
ob_end_clean();
}
return $response;
}
}