Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

akaunting/akaunting

9348 stars
4 code files
View akaunting/akaunting on GitHub

composer.json

Open in GitHub
{
//
"require": {
"php": "^7.3.0",
"ext-bcmath": "*",
//
"maatwebsite/excel": "3.1.*"
},
//
}

app/Exports/Sales/Revenues.php

Open in GitHub
use App\Abstracts\Export;
use App\Models\Banking\Transaction as Model;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
 
class Revenues extends Export implements WithColumnFormatting
{
public function collection()
{
return Model::with('account', 'category', 'contact', 'invoice')->income()->collectForExport($this->ids, ['paid_at' => 'desc']);
}
 
public function map($model): array
{
$model->account_name = $model->account->name;
$model->invoice_number = $model->invoice->document_number ?? 0;
$model->contact_email = $model->contact->email;
$model->category_name = $model->category->name;
 
return parent::map($model);
}
 
public function fields(): array
{
return [
'paid_at',
'amount',
'currency_code',
'currency_rate',
'account_name',
'invoice_number',
'contact_email',
'category_name',
'description',
'payment_method',
'reference',
'reconciled',
];
}
 
public function columnFormats(): array
{
return [
'A' => NumberFormat::FORMAT_DATE_YYYYMMDD,
];
}
}

app/Http/Controllers/Sales/Revenues.php

Open in GitHub
use App\Exports\Sales\Revenues as Export;
 
class Revenues extends Controller
{
//
public function export()
{
return $this->exportExcel(new Export, trans_choice('general.revenues', 2));
}
//
}

routes/admin.php

Open in GitHub
use Illuminate\Support\Facades\Route;
 
//
Route::group(['prefix' => 'sales'], function () {
//
Route::get('revenues/export', 'Sales\Revenues@export')->name('revenues.export');
//
});
//

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.