Add the expense reimbursements report
The expenses employees paid themselves in a period, by person with kilometres and amounts, printable and as CSV for payroll. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Reports\Infrastructure\Adapters;
|
||||
|
||||
use App\Modules\Expenses\Application\Contracts\ExpenseReportQueries;
|
||||
use App\Modules\Expenses\Application\DTOs\ReimbursableExpense;
|
||||
use App\Modules\Reports\Application\Contracts\ReportExpenses;
|
||||
use App\Modules\Reports\Application\DTOs\ReimbursementEntry;
|
||||
use App\Modules\Reports\Domain\ValueObjects\ReportPeriod;
|
||||
|
||||
/**
|
||||
* Expenses for reports through the Expenses module.
|
||||
*/
|
||||
class ExpensesForReports implements ReportExpenses
|
||||
{
|
||||
public function __construct(private ExpenseReportQueries $queries) {}
|
||||
|
||||
public function employeePaid(ReportPeriod $period): array
|
||||
{
|
||||
return array_map(fn (ReimbursableExpense $expense): ReimbursementEntry => new ReimbursementEntry(
|
||||
$expense->userId,
|
||||
$expense->jobId,
|
||||
$expense->category->value,
|
||||
$expense->spentOn,
|
||||
$expense->description,
|
||||
$expense->destination,
|
||||
$expense->purpose,
|
||||
$expense->kilometerTenths,
|
||||
$expense->costCents,
|
||||
), $this->queries->employeePaidBetween($period->from, $period->to));
|
||||
}
|
||||
|
||||
public function costsByJob(ReportPeriod $period): array
|
||||
{
|
||||
return $this->queries->costsByJobBetween($period->from, $period->to);
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,13 @@ namespace App\Modules\Reports\Infrastructure\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Reports\Application\Contracts\ReportCatalog;
|
||||
use App\Modules\Reports\Application\Contracts\ReportExpenses;
|
||||
use App\Modules\Reports\Application\Contracts\ReportHours;
|
||||
use App\Modules\Reports\Application\Contracts\ReportJobs;
|
||||
use App\Modules\Reports\Application\Contracts\ReportPeople;
|
||||
use App\Modules\Reports\Application\Contracts\ReportSales;
|
||||
use App\Modules\Reports\Infrastructure\Adapters\CatalogForReports;
|
||||
use App\Modules\Reports\Infrastructure\Adapters\ExpensesForReports;
|
||||
use App\Modules\Reports\Infrastructure\Adapters\HoursForReports;
|
||||
use App\Modules\Reports\Infrastructure\Adapters\JobsForReports;
|
||||
use App\Modules\Reports\Infrastructure\Adapters\PeopleForReports;
|
||||
@@ -33,6 +35,7 @@ class ReportsServiceProvider extends ServiceProvider
|
||||
ReportCatalog::class => CatalogForReports::class,
|
||||
ReportPeople::class => PeopleForReports::class,
|
||||
ReportSales::class => SalesForReports::class,
|
||||
ReportExpenses::class => ExpensesForReports::class,
|
||||
];
|
||||
|
||||
public function boot(): void
|
||||
|
||||
Reference in New Issue
Block a user