From e35d73eab5f2fe005c5161fcad6141ee17c00b10 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Sun, 28 Jan 2018 12:08:44 +0100 Subject: [PATCH] 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 --- README.md | 13 +++++--- src/Entity/InvoiceTemplate.php | 2 +- src/Invoice/ShortInvoiceCalculator.php | 1 + src/Twig/Extensions.php | 2 +- templates/admin/customer.html.twig | 4 +-- templates/admin/project.html.twig | 2 -- templates/navbar/active-entries.html.twig | 38 +++++++++++++---------- 7 files changed, 35 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 9c952149..e2af403d 100644 --- a/README.md +++ b/README.md @@ -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. 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. -A first example on how to extend Kimai 2 can be found in this [GitHub repository](https://github.com/kevinpapst/kimai2-invoice). +As Kimai 2 was built on top of Symfony, it can be extended like every other Symfony application. +We call these extensions bundles, but you might also know them as add-ons, extensions or plugins. + +All available Kimai 2 bundles can be found at the repository [Kimai recipes](https://github.com/kimai/recipes). -There are more options, for example events to hook your own pages into the navigation tree. -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 diff --git a/src/Entity/InvoiceTemplate.php b/src/Entity/InvoiceTemplate.php index c577d221..669f5adf 100644 --- a/src/Entity/InvoiceTemplate.php +++ b/src/Entity/InvoiceTemplate.php @@ -175,7 +175,7 @@ class InvoiceTemplate * @param string $address * @return InvoiceTemplate */ - public function setAddress(string $address) + public function setAddress($address) { $this->address = $address; return $this; diff --git a/src/Invoice/ShortInvoiceCalculator.php b/src/Invoice/ShortInvoiceCalculator.php index 151bdadf..22c56fc0 100644 --- a/src/Invoice/ShortInvoiceCalculator.php +++ b/src/Invoice/ShortInvoiceCalculator.php @@ -30,6 +30,7 @@ class ShortInvoiceCalculator extends DefaultCalculator $timesheet = new Timesheet(); foreach ($this->model->getEntries() as $entry) { + $timesheet->setRate($timesheet->getRate() + $entry->getRate()); $timesheet->setDuration($timesheet->getDuration() + $entry->getDuration()); if ($timesheet->getActivity() === null) { $timesheet->setActivity($entry->getActivity()); diff --git a/src/Twig/Extensions.php b/src/Twig/Extensions.php index ec6bc37c..a3485d45 100644 --- a/src/Twig/Extensions.php +++ b/src/Twig/Extensions.php @@ -121,7 +121,7 @@ class Extensions extends \Twig_Extension */ public function money($amount, $currency = null) { - $result = round($amount, 2); + $result = number_format(round($amount, 2), 2); if ($currency !== null) { $result .= ' ' . Intl::getCurrencyBundle()->getCurrencySymbol($currency); } diff --git a/templates/admin/customer.html.twig b/templates/admin/customer.html.twig index 0020aa2a..8175ee41 100644 --- a/templates/admin/customer.html.twig +++ b/templates/admin/customer.html.twig @@ -13,10 +13,10 @@ {{ tables.data_table_header({ 'label.name': '', - 'label.customer_number': 'hidden-xs', 'label.project': '', 'label.comment': 'hidden-xs', 'label.country': 'hidden-xs', + 'label.customer_number': 'hidden-xs', 'label.currency': 'hidden-xs', 'label.visible': '', 'label.actions': '', @@ -25,7 +25,6 @@ {% for entry in entries %} {{ entry.name }} {% if entry.company is not empty %}({{ entry.company }}){% endif %} - {{ entry.number }} {% for project in entry.projects %} {{ widgets.label_project(project) }} @@ -33,6 +32,7 @@ {{ entry.comment }} {{ entry.country|country }} + {{ entry.number }} {{ entry.currency }} {{ entry.currency|currency }} {{ widgets.label_visible(entry.visible) }} diff --git a/templates/admin/project.html.twig b/templates/admin/project.html.twig index ad2e424c..21b38fcf 100644 --- a/templates/admin/project.html.twig +++ b/templates/admin/project.html.twig @@ -12,7 +12,6 @@ {% endif %} {{ tables.data_table_header({ - 'label.id': 'hidden-xs', 'label.name': '', 'label.customer': '', 'label.comment': 'hidden-xs hidden-sm', @@ -23,7 +22,6 @@ {% for entry in entries %} - {{ entry.id }} {{ entry.name }} {{ widgets.label_customer(entry.customer) }} diff --git a/templates/navbar/active-entries.html.twig b/templates/navbar/active-entries.html.twig index e087f1a0..b2246209 100644 --- a/templates/navbar/active-entries.html.twig +++ b/templates/navbar/active-entries.html.twig @@ -9,22 +9,28 @@ {{ 'active.entries'|transchoice(entries|length) }}
  • - + {% if entries is not empty %} + + {% else %} +
    + +
    + {% endif %}