Project reports

This commit is contained in:
David Bomba 2025-03-24 13:21:12 +11:00
parent 790d57f7c8
commit 07c30aea66
4 changed files with 147 additions and 131 deletions

View File

@ -63,8 +63,7 @@ class ProjectReport extends BaseExport
$user_name = $user ? $user->present()->name() : ''; $user_name = $user ? $user->present()->name() : '';
$projects = \App\Models\Project::with(['invoices','expenses','tasks'])->where('company_id', $this->company->id)
$projects = \App\Models\Project::where('company_id', $this->company->id)
->whereIn('id', $this->transformKeys($this->input['projects'])) ->whereIn('id', $this->transformKeys($this->input['projects']))
->get(); ->get();
@ -83,6 +82,7 @@ class ProjectReport extends BaseExport
$ts_instance = $ts->setCompany($this->company) $ts_instance = $ts->setCompany($this->company)
->setData($data) ->setData($data)
->setRawTemplate(file_get_contents(resource_path($this->template))) ->setRawTemplate(file_get_contents(resource_path($this->template)))
->setGlobals()
->parseNinjaBlocks() ->parseNinjaBlocks()
->save(); ->save();

View File

@ -1063,6 +1063,7 @@ class TemplateService
'custom_value2' => $expense->custom_value2 ?: '', 'custom_value2' => $expense->custom_value2 ?: '',
'custom_value3' => $expense->custom_value3 ?: '', 'custom_value3' => $expense->custom_value3 ?: '',
'custom_value4' => $expense->custom_value4 ?: '', 'custom_value4' => $expense->custom_value4 ?: '',
'number' => $expense->number ?: '',
'calculate_tax_by_amount' => (bool) $expense->calculate_tax_by_amount, 'calculate_tax_by_amount' => (bool) $expense->calculate_tax_by_amount,
'uses_inclusive_taxes' => (bool) $expense->uses_inclusive_taxes, 'uses_inclusive_taxes' => (bool) $expense->uses_inclusive_taxes,
'client' => $this->getClient($expense), 'client' => $this->getClient($expense),

View File

@ -5569,6 +5569,7 @@ $lang = array(
'plan_selected' => 'Plan Selected', 'plan_selected' => 'Plan Selected',
'invalid_date_create_syntax' => 'Invalid date syntax', 'invalid_date_create_syntax' => 'Invalid date syntax',
'start_and_end_date_required' => 'Start and end date are required', 'start_and_end_date_required' => 'Start and end date are required',
'project_value' => 'Project Value',
); );
return $lang; return $lang;

View File

@ -90,13 +90,17 @@
background: #34495e; background: #34495e;
color: white; color: white;
padding: 6px; padding: 6px;
text-align: center; text-align: left;
} }
td { td {
padding: 6px; padding: 6px;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
text-align: center; text-align: left;
}
td li {
text-align: left;
} }
tr { tr {
@ -140,24 +144,30 @@
background: #e8f5e9; background: #e8f5e9;
color: #2e7d32; color: #2e7d32;
} }
.page-break {
page-break-before: always;
}
</style> </style>
</head> </head>
<body> <body>
<ninja> <ninja>
{% if projects|e %} {% if projects|e %}
{% for project in projects %} {% for project in projects %}
<div class="page-break">
<h1>{{ project.name }}</h1> <h1>{{ project.name }}</h1>
<h3>Due: {{ project.due_date }}</h3> <h3>Due: {{ project.due_date }}</h3>
<h6>{{ project.current_hours }} / {{ project.budgeted_hours }}: (Hours / Budgeted Hours @ {{ project.task_rate }}) - <h6>{{ project.current_hours }} / {{ project.budgeted_hours }}: (Hours / Budgeted Hours @ {{ project.task_rate
}}) -
Report generated on {{ "now"|date('Y-m-d') }}</h6> Report generated on {{ "now"|date('Y-m-d') }}</h6>
<table> <table>
<thead> <thead>
<tr> <tr>
<th>Date</th> <th>{{ t('date') }}</th>
<th>Description</th> <th>{{ t('description') }}</th>
<th>Duration</th> <th>{{ t('duration') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -184,6 +194,9 @@
</table> </table>
{% if project.invoices %} {% if project.invoices %}
<div style="text-align: center;">
<h2>{{ t('invoices') }}</h2>
</div>
<table> <table>
<thead> <thead>
<tr> <tr>
@ -211,14 +224,17 @@
<tr> <tr>
<td></td> <td></td>
<td></td> <td></td>
<td>{{ total_amount }}</td> <td>{{ total_amount|format_currency(currency_code) }}</td>
<td>{{ total_balance }}</td> <td>{{ total_balance|format_currency(currency_code) }}</td>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
{% endif %} {% endif %}
{% if project.expenses %} {% if project.expenses %}
<div style="text-align: center;">
<h2>{{ t('expenses') }}</h2>
</div>
<table> <table>
<thead> <thead>
<tr> <tr>
@ -235,14 +251,14 @@
<td>{{ expense.number }}</td> <td>{{ expense.number }}</td>
<td>{{ expense.amount }}</td> <td>{{ expense.amount }}</td>
</tr> </tr>
{% set total_amount = total_amount + expense.amount_raw %} {% set total_expense_amount = total_expense_amount + expense.amount_raw %}
{% endfor%} {% endfor%}
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<td></td> <td></td>
<td></td> <td></td>
<td>{{ total_expense_amount }}</td> <td>{{ total_expense_amount|format_currency(currency_code) }}</td>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
@ -251,40 +267,38 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th>Summary</th> <th>{{ t('summary') }}</th>
<th></th> <th>{{ t('amount') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<td>{{ t('project_value') }}</td>
<td>{{ (project.budgeted_hours * project.task_rate_raw)|format_currency(currency_code) }}</td>
</tr>
<tr>
<td>{{ t('invoice_task_hours') }}</td>
<td>{{ (project.current_hours * project.task_rate_raw)|format_currency(currency_code) }}</td>
</tr>
<tr>
<td>{{ t('invoiced') }}</td>
<td>{{ total_amount|format_currency(currency_code) }}</td>
</tr>
<tr> <tr>
<td>{{ t('expenses') }}</td> <td>{{ t('expenses') }}</td>
<td>{{ total_expense_amount }}</td> <td>{{ total_expense_amount|format_currency(currency_code) }}</td>
</tr> </tr>
<tr> <tr>
<td>{{ t('invoices') }}</td> <td>{{ t('profit') }}</td>
<td>{{ total_amount }}</td> <td>{{ (total_amount - total_expense_amount)|format_currency(currency_code) }}</td>
</tr>
<tr>
<td>{{ t('budgeted') }}</td>
<td>{{ project.budgeted_hours * project.task_rate_raw }}</td>
</tr>
<tr>
<td>{{ t('budgeted') }}</td>
<td>{{ project.budgeted_hours * project.task_rate_raw }}</td>
</tr>
<tr>
<td>Budget - Expenses</td>
<td>{{ (project.budgeted_hours * project.task_rate_raw) - total_expense_amount }}</td>
</tr>
<tr>
<td>Invoices - Expenses</td>
<td>{{ total_amount - total_expense_amount }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</ninja> </ninja>
</body> </body>
</html> </html>