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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user