fixed short invoice calculator (#114)

* fixed money display and address field for InvoiceTemplate entity
* added quick start button for users without active records
* rearranged columns on project and customer admin page
* improved extensions docu
This commit is contained in:
Kevin Papst
2018-01-28 12:08:44 +01:00
committed by GitHub
parent 9bbaf0ec71
commit e35d73eab5
7 changed files with 35 additions and 27 deletions

View File

@@ -156,13 +156,16 @@ $ bin/console doctrine:schema:drop --force && bin/console doctrine:schema:create
That will drop the configured Kimai v2 database schema and re-create it, before importing the data from the `mysql` database at `127.0.0.1` on port `3306` authenticating the user `kimai` with the password `test` for import. That will drop the configured Kimai v2 database schema and re-create it, before importing the data from the `mysql` database at `127.0.0.1` on port `3306` authenticating the user `kimai` with the password `test` for import.
The connection will use the charset `latin1` and the default table prefix `kimai_` for reading data. Imported users can login with the password `test123` and all customer will have the country `de` assigned. The connection will use the charset `latin1` and the default table prefix `kimai_` for reading data. Imported users can login with the password `test123` and all customer will have the country `de` assigned.
## Extending Kimai 2 with Bundles ## Extensions for Kimai 2
As Kimai 2 was built with extendability in mind, it can be extended like every other Symfony application. As Kimai 2 was built on top of Symfony, it can be extended like every other Symfony application.
A first example on how to extend Kimai 2 can be found in this [GitHub repository](https://github.com/kevinpapst/kimai2-invoice). We call these extensions bundles, but you might also know them as add-ons, extensions or plugins.
There are more options, for example events to hook your own pages into the navigation tree. All available Kimai 2 bundles can be found at the repository [Kimai recipes](https://github.com/kimai/recipes).
As we don't have documentation on this by now, please ask in the issues track or have a look at [this class](https://github.com/kevinpapst/kimai2/blob/master/src/EventSubscriber/MenuSubscriber.php).
An example on how to extend Kimai 2 can be found in this [GitHub repository](https://github.com/kevinpapst/kimai2-invoice).
There are more options, for example events to hook your own links into the navigation tree.
But we don't have documentation on this by now, so please ask in the [issue tracker](https://github.com/kevinpapst/kimai2) or have a look at [this class](https://github.com/kevinpapst/kimai2/blob/master/src/EventSubscriber/MenuSubscriber.php).
## Troubleshooting ## Troubleshooting

View File

@@ -175,7 +175,7 @@ class InvoiceTemplate
* @param string $address * @param string $address
* @return InvoiceTemplate * @return InvoiceTemplate
*/ */
public function setAddress(string $address) public function setAddress($address)
{ {
$this->address = $address; $this->address = $address;
return $this; return $this;

View File

@@ -30,6 +30,7 @@ class ShortInvoiceCalculator extends DefaultCalculator
$timesheet = new Timesheet(); $timesheet = new Timesheet();
foreach ($this->model->getEntries() as $entry) { foreach ($this->model->getEntries() as $entry) {
$timesheet->setRate($timesheet->getRate() + $entry->getRate());
$timesheet->setDuration($timesheet->getDuration() + $entry->getDuration()); $timesheet->setDuration($timesheet->getDuration() + $entry->getDuration());
if ($timesheet->getActivity() === null) { if ($timesheet->getActivity() === null) {
$timesheet->setActivity($entry->getActivity()); $timesheet->setActivity($entry->getActivity());

View File

@@ -121,7 +121,7 @@ class Extensions extends \Twig_Extension
*/ */
public function money($amount, $currency = null) public function money($amount, $currency = null)
{ {
$result = round($amount, 2); $result = number_format(round($amount, 2), 2);
if ($currency !== null) { if ($currency !== null) {
$result .= ' ' . Intl::getCurrencyBundle()->getCurrencySymbol($currency); $result .= ' ' . Intl::getCurrencyBundle()->getCurrencySymbol($currency);
} }

View File

@@ -13,10 +13,10 @@
{{ tables.data_table_header({ {{ tables.data_table_header({
'label.name': '', 'label.name': '',
'label.customer_number': 'hidden-xs',
'label.project': '', 'label.project': '',
'label.comment': 'hidden-xs', 'label.comment': 'hidden-xs',
'label.country': 'hidden-xs', 'label.country': 'hidden-xs',
'label.customer_number': 'hidden-xs',
'label.currency': 'hidden-xs', 'label.currency': 'hidden-xs',
'label.visible': '', 'label.visible': '',
'label.actions': '', 'label.actions': '',
@@ -25,7 +25,6 @@
{% for entry in entries %} {% for entry in entries %}
<tr> <tr>
<td>{{ entry.name }} {% if entry.company is not empty %}({{ entry.company }}){% endif %}</td> <td>{{ entry.name }} {% if entry.company is not empty %}({{ entry.company }}){% endif %}</td>
<td class="hidden-xs">{{ entry.number }}</td>
<td> <td>
{% for project in entry.projects %} {% for project in entry.projects %}
<a href="{{ path('admin_project_edit', {'id' : project.id}) }}">{{ widgets.label_project(project) }}</a> <a href="{{ path('admin_project_edit', {'id' : project.id}) }}">{{ widgets.label_project(project) }}</a>
@@ -33,6 +32,7 @@
</td> </td>
<td class="hidden-xs">{{ entry.comment }}</td> <td class="hidden-xs">{{ entry.comment }}</td>
<td class="hidden-xs">{{ entry.country|country }}</td> <td class="hidden-xs">{{ entry.country|country }}</td>
<td class="hidden-xs">{{ entry.number }}</td>
<td class="hidden-xs">{{ entry.currency }} {{ entry.currency|currency }}</td> <td class="hidden-xs">{{ entry.currency }} {{ entry.currency|currency }}</td>
<td>{{ widgets.label_visible(entry.visible) }}</td> <td>{{ widgets.label_visible(entry.visible) }}</td>
<td> <td>

View File

@@ -12,7 +12,6 @@
{% endif %} {% endif %}
{{ tables.data_table_header({ {{ tables.data_table_header({
'label.id': 'hidden-xs',
'label.name': '', 'label.name': '',
'label.customer': '', 'label.customer': '',
'label.comment': 'hidden-xs hidden-sm', 'label.comment': 'hidden-xs hidden-sm',
@@ -23,7 +22,6 @@
{% for entry in entries %} {% for entry in entries %}
<tr> <tr>
<td class="hidden-xs">{{ entry.id }}</td>
<td>{{ entry.name }}</td> <td>{{ entry.name }}</td>
<td> <td>
<a href="{{ path('admin_customer_edit', {'id' : entry.customer.id}) }}">{{ widgets.label_customer(entry.customer) }}</a> <a href="{{ path('admin_customer_edit', {'id' : entry.customer.id}) }}">{{ widgets.label_customer(entry.customer) }}</a>

View File

@@ -9,6 +9,7 @@
{{ 'active.entries'|transchoice(entries|length) }} {{ 'active.entries'|transchoice(entries|length) }}
</li> </li>
<li> <li>
{% if entries is not empty %}
<ul class="menu"> <ul class="menu">
{% for entry in entries %} {% for entry in entries %}
<li> <li>
@@ -25,6 +26,11 @@
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
{% else %}
<div class="start_record">
<a href="{{ path('timesheet_create') }}"><i class="fa fa-play-circle-o fa-5x"></i></a>
</div>
{% endif %}
</li> </li>
<li class="footer"><a href="{{ path('timesheet_create') }}">{{ 'timesheet.start'|trans }}</a></li> <li class="footer"><a href="{{ path('timesheet_create') }}">{{ 'timesheet.start'|trans }}</a></li>
</ul> </ul>