mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Merge tax report changes
This commit is contained in:
parent
c1ae4109a9
commit
1b60d2ee8a
@ -13,24 +13,39 @@ class TaskReport extends AbstractReport
|
|||||||
'project',
|
'project',
|
||||||
'description',
|
'description',
|
||||||
'duration',
|
'duration',
|
||||||
|
'amount',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
$startDate = date_create($this->startDate);
|
||||||
|
$endDate = date_create($this->endDate);
|
||||||
|
|
||||||
$tasks = Task::scope()
|
$tasks = Task::scope()
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->with('client.contacts')
|
->with('client.contacts', 'project', 'account')
|
||||||
->withArchived()
|
->withArchived()
|
||||||
->dateRange($this->startDate, $this->endDate);
|
->dateRange($startDate, $endDate);
|
||||||
|
|
||||||
foreach ($tasks->get() as $task) {
|
foreach ($tasks->get() as $task) {
|
||||||
|
$amount = $task->getRate() * ($task->getDuration() / 60 / 60);
|
||||||
|
if ($task->client && $task->client->currency_id) {
|
||||||
|
$currencyId = $task->client->currency_id;
|
||||||
|
} else {
|
||||||
|
$currencyId = auth()->user()->account->getCurrencyId();
|
||||||
|
}
|
||||||
|
|
||||||
$this->data[] = [
|
$this->data[] = [
|
||||||
$task->client ? ($this->isExport ? $task->client->getDisplayName() : $task->client->present()->link) : trans('texts.unassigned'),
|
$task->client ? ($this->isExport ? $task->client->getDisplayName() : $task->client->present()->link) : trans('texts.unassigned'),
|
||||||
$this->isExport ? $task->getStartTime() : link_to($task->present()->url, $task->getStartTime()),
|
$this->isExport ? $task->getStartTime() : link_to($task->present()->url, $task->getStartTime()),
|
||||||
$task->present()->project,
|
$task->present()->project,
|
||||||
$task->description,
|
$task->description,
|
||||||
Utils::formatTime($task->getDuration()),
|
Utils::formatTime($task->getDuration()),
|
||||||
|
Utils::formatMoney($amount, $currencyId),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->addToTotals($currencyId, 'duration', $task->getDuration());
|
||||||
|
$this->addToTotals($currencyId, 'amount', $amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user