Files
Toiminnanohjaus/app/Modules/Billing/Infrastructure/Providers/BillingServiceProvider.php
T
petriandClaude Opus 5.5 ae7b611126 Add a CSV download of created billing materials
Management downloads a created billing material as a semicolon CSV with
decimal commas and a UTF-8 BOM for Excel: one row per invoice line with
the invoice's customer, billing unit, e-invoice details and reference,
the job, the line and its net, VAT and gross amounts. Consumers' full
personal identity codes are included only for those who may see them,
the response is not cached, and cells Excel would read as formulas are
escaped. The columns follow Fennoa's import format once a sample exists.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 13:32:46 +02:00

58 lines
2.3 KiB
PHP

<?php
namespace App\Modules\Billing\Infrastructure\Providers;
use App\Models\User;
use App\Modules\Billing\Application\Contracts\BillingCustomers;
use App\Modules\Billing\Application\Contracts\BillingExpenses;
use App\Modules\Billing\Application\Contracts\BillingHours;
use App\Modules\Billing\Application\Contracts\BillingJobs;
use App\Modules\Billing\Application\Contracts\BillingPrices;
use App\Modules\Billing\Application\Contracts\BillingQueries;
use App\Modules\Billing\Domain\Contracts\BillingExportRepository;
use App\Modules\Billing\Infrastructure\CustomersForBilling;
use App\Modules\Billing\Infrastructure\ExpensesForBilling;
use App\Modules\Billing\Infrastructure\HoursForBilling;
use App\Modules\Billing\Infrastructure\JobsForBilling;
use App\Modules\Billing\Infrastructure\Persistence\Repositories\EloquentBillingExportRepository;
use App\Modules\Billing\Infrastructure\Persistence\Repositories\EloquentBillingQueries;
use App\Modules\Billing\Infrastructure\PricesForBilling;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;
/**
* Wires the Billing module (billing material for invoicing) into Laravel:
* bindings, routes, the `billing::` Livewire namespace and the
* `billing.manage` ability.
*/
class BillingServiceProvider extends ServiceProvider
{
/**
* @var array<class-string, class-string>
*/
public array $bindings = [
BillingExportRepository::class => EloquentBillingExportRepository::class,
BillingQueries::class => EloquentBillingQueries::class,
BillingJobs::class => JobsForBilling::class,
BillingHours::class => HoursForBilling::class,
BillingExpenses::class => ExpensesForBilling::class,
BillingPrices::class => PricesForBilling::class,
BillingCustomers::class => CustomersForBilling::class,
];
public function boot(): void
{
$presentationPath = dirname(__DIR__, 2).'/Presentation';
Livewire::addNamespace('billing', viewPath: $presentationPath.'/Livewire');
if (! $this->app->routesAreCached()) {
$this->loadRoutesFrom($presentationPath.'/Routes/web.php');
}
// Management forms the billing material once a month (spec 12).
Gate::define('billing.manage', fn (User $user): bool => $user->role->seesAllMoney());
}
}