From 9c9c6b9fbd817aa4fcd381821fb219dfe99da785 Mon Sep 17 00:00:00 2001 From: dros Date: Tue, 30 Jul 2024 13:39:46 +0200 Subject: [PATCH 1/7] Clarifications, links added, Links fixed Signed-off-by: dros --- README.md | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ccbcfb4e4826..f9a267b7af1c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- Sublime's custom image +Sublime's custom image

![v5-develop phpunit](https://github.com/invoiceninja/invoiceninja/workflows/phpunit/badge.svg?branch=v5-develop) @@ -8,25 +8,29 @@ # Invoice Ninja 5 -## [Hosted](https://www.invoiceninja.com) | [Self-Hosted](https://www.invoiceninja.org) +Invoice Ninja Version 5 is here! We've taken the best parts of version 4 and added the most requested features to create an invoicing application like no other. Check the [Invoice Ninja YouTube Channel](https://www.youtube.com/@appinvoiceninja) to get up to speed. -Join us on [Slack](http://slack.invoiceninja.com), [Discord](https://discord.gg/ZwEdtfCwXA), [Support Forum](https://forum.invoiceninja.com) +**Choose your setup** -## Introduction +- [Hosted](https://www.invoiceninja.com): Our hosted version is a Software as a Service (SaaS) solution. You're up and running in under 5 minutes, with no need to worry about hosting or server infrastructure. +- [Self-Hosted](https://www.invoiceninja.org): For those who prefer to manage their own hosting and server infrastructure. This version gives you full control and flexibility. -Version 5 of Invoice Ninja is here! -We took the best parts of version 4 and add the most requested features -to produce a invoicing application like no other. +All Pro and Enterprise features from the hosted app are included in the open-source code. We offer a $30 per year white-label license to remove the Invoice Ninja branding from client-facing parts of the app. -All Pro and Enterprise features from the hosted app are included in the open code. -We offer a $30 per year white-label license to remove the Invoice Ninja branding from client facing parts of the app. +#### Get social with us -* [Videos](https://www.youtube.com/@appinvoiceninja) -* [API Documentation](https://api-docs.invoicing.co/) -* [APP Documentation](https://invoiceninja.github.io/) * [Support Forum](https://forum.invoiceninja.com) +* [Slack](http://slack.invoiceninja.com) +* [Discord](https://discord.gg/ZwEdtfCwXA) -## Setup +#### Documentation + +* [Invoice Ninja - API](https://api-docs.invoicing.co/) +* [Invoice Ninja - Developer Guide](https://invoiceninja.github.io/en/developer-guide/) +* [Invoice Ninja - User Guide](https://invoiceninja.github.io/en/user-guide/) +* [Invoice Ninja - Self-Hosted Installation Guide](https://invoiceninja.github.io/en/self-host-installation/) + +## Installation Options and Clients ### Mobile Apps * [iPhone](https://apps.apple.com/app/id1503970375?platform=iphone) @@ -39,16 +43,21 @@ We offer a $30 per year white-label license to remove the Invoice Ninja branding * [Linux - Snap](https://snapcraft.io/invoiceninja) * [Linux - Flatpak](https://flathub.org/apps/com.invoiceninja.InvoiceNinja) -### Installation Options +### Self-Hosted Server Installation +**Note:** The self-hosted options do support the desktop and mobile apps. + +* [Server or VM](https://invoiceninja.github.io/en/self-host-installation/) * [Docker File](https://hub.docker.com/r/invoiceninja/invoiceninja/) -* [Cloudron](https://cloudron.io/store/com.invoiceninja.cloudronapp.html) +* [Cloudron](https://www.cloudron.io/store/com.invoiceninja.cloudronapp2.html) * [Softaculous](https://www.softaculous.com/apps/ecommerce/Invoice_Ninja) ### Recommended Providers * [Stripe](https://stripe.com/) * [Postmark](https://postmarkapp.com/) -## Quick Hosting Setup +## [Advanced] Quick Hosting Setup + +In addition to the official [Invoice Ninja - Self-Hosted Installation Guide](https://invoiceninja.github.io/en/self-host-installation/) we have a few commands for you. ```sh git clone --single-branch --branch v5-stable https://github.com/invoiceninja/invoiceninja.git @@ -84,6 +93,7 @@ pass: password ``` ## Developers Guide +In addition to the official [Invoice Ninja - Developer Guide](https://invoiceninja.github.io/en/developer-guide/) we've got your back with some insights. ### App Design From 1c723bca85686537f0d00f15e7ecfe87425959f9 Mon Sep 17 00:00:00 2001 From: dros Date: Tue, 30 Jul 2024 14:23:16 +0200 Subject: [PATCH 2/7] Demo added, insta added Signed-off-by: dros --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f9a267b7af1c..190b5eddab4e 100644 --- a/README.md +++ b/README.md @@ -8,20 +8,21 @@ # Invoice Ninja 5 -Invoice Ninja Version 5 is here! We've taken the best parts of version 4 and added the most requested features to create an invoicing application like no other. Check the [Invoice Ninja YouTube Channel](https://www.youtube.com/@appinvoiceninja) to get up to speed. +Invoice Ninja Version 5 is here! We've taken the best parts of version 4 and added the most requested features to create an invoicing application like no other. Check the [Invoice Ninja YouTube Channel](https://www.youtube.com/@appinvoiceninja) to get up to speed, or try the [Demo](https://react.invoicing.co/demo) now. **Choose your setup** - [Hosted](https://www.invoiceninja.com): Our hosted version is a Software as a Service (SaaS) solution. You're up and running in under 5 minutes, with no need to worry about hosting or server infrastructure. - [Self-Hosted](https://www.invoiceninja.org): For those who prefer to manage their own hosting and server infrastructure. This version gives you full control and flexibility. -All Pro and Enterprise features from the hosted app are included in the open-source code. We offer a $30 per year white-label license to remove the Invoice Ninja branding from client-facing parts of the app. +All Pro and Enterprise features from the hosted app are included in the open-source code. We offer a $30 per year white-label license to remove the Invoice Ninja branding from client-facing parts of the app. #### Get social with us * [Support Forum](https://forum.invoiceninja.com) * [Slack](http://slack.invoiceninja.com) * [Discord](https://discord.gg/ZwEdtfCwXA) +* [Instagram](https://www.instagram.com/appinvoiceninja) #### Documentation From a03c1eb3e22a556fecfaa933608a8baef03a46d5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 1 Aug 2024 09:02:25 +1000 Subject: [PATCH 3/7] Fixes for number formatting --- app/Helpers/Invoice/InvoiceItemSum.php | 13 +++--- .../Invoice/InvoiceItemSumInclusive.php | 9 ++-- app/Helpers/Invoice/InvoiceSum.php | 6 +-- app/Helpers/Invoice/InvoiceSumInclusive.php | 7 +-- app/Services/Pdf/PdfBuilder.php | 8 ++-- composer.lock | 46 +++++++++---------- 6 files changed, 46 insertions(+), 43 deletions(-) diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 76ba72ca5e4f..9f913c42a8bc 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -11,16 +11,17 @@ namespace App\Helpers\Invoice; -use App\DataMapper\BaseSettings; -use App\DataMapper\InvoiceItem; -use App\DataMapper\Tax\RuleInterface; +use App\Models\Quote; +use App\Utils\Number; use App\Models\Client; use App\Models\Credit; use App\Models\Invoice; use App\Models\PurchaseOrder; -use App\Models\Quote; -use App\Models\RecurringInvoice; use App\Models\RecurringQuote; +use App\DataMapper\InvoiceItem; +use App\DataMapper\BaseSettings; +use App\Models\RecurringInvoice; +use App\DataMapper\Tax\RuleInterface; use App\Utils\Traits\NumberFormatter; class InvoiceItemSum @@ -313,7 +314,7 @@ class InvoiceItemSum $key = str_replace(' ', '', $tax_name.$tax_rate); - $group_tax = ['key' => $key, 'total' => $tax_total, 'tax_name' => $tax_name.' '.floatval($tax_rate).'%']; + $group_tax = ['key' => $key, 'total' => $tax_total, 'tax_name' => $tax_name.' '.Number::formatValueNoTrailingZeroes(floatval($tax_rate), $this->client).'%']; $this->tax_collection->push(collect($group_tax)); } diff --git a/app/Helpers/Invoice/InvoiceItemSumInclusive.php b/app/Helpers/Invoice/InvoiceItemSumInclusive.php index da4c3e1f3aa4..8bcf87fc25a3 100644 --- a/app/Helpers/Invoice/InvoiceItemSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceItemSumInclusive.php @@ -11,14 +11,15 @@ namespace App\Helpers\Invoice; -use App\DataMapper\Tax\RuleInterface; +use App\Models\Quote; +use App\Utils\Number; use App\Models\Client; use App\Models\Credit; use App\Models\Invoice; use App\Models\PurchaseOrder; -use App\Models\Quote; -use App\Models\RecurringInvoice; use App\Models\RecurringQuote; +use App\Models\RecurringInvoice; +use App\DataMapper\Tax\RuleInterface; use App\Utils\Traits\NumberFormatter; class InvoiceItemSumInclusive @@ -265,7 +266,7 @@ class InvoiceItemSumInclusive $key = str_replace(' ', '', $tax_name.$tax_rate); - $group_tax = ['key' => $key, 'total' => $tax_total, 'tax_name' => $tax_name.' '.$tax_rate.'%']; + $group_tax = ['key' => $key, 'total' => $tax_total, 'tax_name' => $tax_name.' '.Number::formatValueNoTrailingZeroes(floatval($tax_rate), $this->client).'%']; $this->tax_collection->push(collect($group_tax)); } diff --git a/app/Helpers/Invoice/InvoiceSum.php b/app/Helpers/Invoice/InvoiceSum.php index 32a821445d17..c2979f73219e 100644 --- a/app/Helpers/Invoice/InvoiceSum.php +++ b/app/Helpers/Invoice/InvoiceSum.php @@ -131,7 +131,7 @@ class InvoiceSum $tax += $this->getSurchargeTaxTotalForKey($this->invoice->tax_name1, $this->invoice->tax_rate1); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.floatval($this->invoice->tax_rate1).'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate1), $this->invoice->client).'%', 'total' => $tax]; } if (is_string($this->invoice->tax_name2) && strlen($this->invoice->tax_name2) >= 2) { @@ -139,7 +139,7 @@ class InvoiceSum $tax += $this->getSurchargeTaxTotalForKey($this->invoice->tax_name2, $this->invoice->tax_rate2); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.floatval($this->invoice->tax_rate2).'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate2), $this->invoice->client).'%', 'total' => $tax]; } if (is_string($this->invoice->tax_name3) && strlen($this->invoice->tax_name3) >= 2) { @@ -147,7 +147,7 @@ class InvoiceSum $tax += $this->getSurchargeTaxTotalForKey($this->invoice->tax_name3, $this->invoice->tax_rate3); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.floatval($this->invoice->tax_rate3).'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate3), $this->invoice->client).'%', 'total' => $tax]; } return $this; diff --git a/app/Helpers/Invoice/InvoiceSumInclusive.php b/app/Helpers/Invoice/InvoiceSumInclusive.php index 6df714231f04..8b0b6f95cc93 100644 --- a/app/Helpers/Invoice/InvoiceSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceSumInclusive.php @@ -12,6 +12,7 @@ namespace App\Helpers\Invoice; use App\Models\Quote; +use App\Utils\Number; use App\Models\Credit; use App\Models\Invoice; use App\Models\PurchaseOrder; @@ -157,19 +158,19 @@ class InvoiceSumInclusive $tax = $this->calcInclusiveLineTax($this->invoice->tax_rate1, $amount); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.floatval($this->invoice->tax_rate1).'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate1), $this->invoice->client).'%', 'total' => $tax]; } if (is_string($this->invoice->tax_name2) && strlen($this->invoice->tax_name2) > 1) { $tax = $this->calcInclusiveLineTax($this->invoice->tax_rate2, $amount); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.floatval($this->invoice->tax_rate2).'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate2), $this->invoice->client).'%', 'total' => $tax]; } if (is_string($this->invoice->tax_name3) && strlen($this->invoice->tax_name3) > 1) { $tax = $this->calcInclusiveLineTax($this->invoice->tax_rate3, $amount); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.floatval($this->invoice->tax_rate3).'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate3), $this->invoice->client).'%', 'total' => $tax]; } return $this; diff --git a/app/Services/Pdf/PdfBuilder.php b/app/Services/Pdf/PdfBuilder.php index fe27b6979af3..093b8b15774d 100644 --- a/app/Services/Pdf/PdfBuilder.php +++ b/app/Services/Pdf/PdfBuilder.php @@ -739,7 +739,7 @@ class PdfBuilder if ($item->is_amount_discount) { $data[$key][$table_type.'.discount'] = $this->service->config->formatMoney($item->discount); } else { - $data[$key][$table_type.'.discount'] = floatval($item->discount).'%'; + $data[$key][$table_type.'.discount'] = $this->service->config->formatValueNoTrailingZeroes(floatval($item->discount)).'%'; } } else { $data[$key][$table_type.'.discount'] = ''; @@ -749,17 +749,17 @@ class PdfBuilder // but that's no longer necessary. if (isset($item->tax_rate1)) { - $data[$key][$table_type.'.tax_rate1'] = floatval($item->tax_rate1).'%'; + $data[$key][$table_type.'.tax_rate1'] = $this->service->config->formatValueNoTrailingZeroes(floatval($item->tax_rate1)).'%'; $data[$key][$table_type.'.tax1'] = &$data[$key][$table_type.'.tax_rate1']; } if (isset($item->tax_rate2)) { - $data[$key][$table_type.'.tax_rate2'] = floatval($item->tax_rate2).'%'; + $data[$key][$table_type.'.tax_rate2'] = $this->service->config->formatValueNoTrailingZeroes(floatval($item->tax_rate2)).'%'; $data[$key][$table_type.'.tax2'] = &$data[$key][$table_type.'.tax_rate2']; } if (isset($item->tax_rate3)) { - $data[$key][$table_type.'.tax_rate3'] = floatval($item->tax_rate3).'%'; + $data[$key][$table_type.'.tax_rate3'] = $this->service->config->formatValueNoTrailingZeroes(floatval($item->tax_rate3)).'%'; $data[$key][$table_type.'.tax3'] = &$data[$key][$table_type.'.tax_rate3']; } diff --git a/composer.lock b/composer.lock index efa6a8ea7ee1..fa1c4b178c59 100644 --- a/composer.lock +++ b/composer.lock @@ -535,16 +535,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.316.3", + "version": "3.316.10", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "e832e594b3c213760e067e15ef2739f77505e832" + "reference": "eeb8df6ff6caa428e8bcd631ad2a96430900a249" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/e832e594b3c213760e067e15ef2739f77505e832", - "reference": "e832e594b3c213760e067e15ef2739f77505e832", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/eeb8df6ff6caa428e8bcd631ad2a96430900a249", + "reference": "eeb8df6ff6caa428e8bcd631ad2a96430900a249", "shasum": "" }, "require": { @@ -624,9 +624,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.316.3" + "source": "https://github.com/aws/aws-sdk-php/tree/3.316.10" }, - "time": "2024-07-12T18:07:23+00:00" + "time": "2024-07-30T18:10:20+00:00" }, { "name": "bacon/bacon-qr-code", @@ -4552,16 +4552,16 @@ }, { "name": "laravel/framework", - "version": "v11.18.1", + "version": "v11.19.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "b19ba518c56852567e99fbae9321bc436c2cc5a8" + "reference": "5e103d499e9ee5bcfc184412d034c4e516b87085" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/b19ba518c56852567e99fbae9321bc436c2cc5a8", - "reference": "b19ba518c56852567e99fbae9321bc436c2cc5a8", + "url": "https://api.github.com/repos/laravel/framework/zipball/5e103d499e9ee5bcfc184412d034c4e516b87085", + "reference": "5e103d499e9ee5bcfc184412d034c4e516b87085", "shasum": "" }, "require": { @@ -4754,7 +4754,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-07-26T10:39:29+00:00" + "time": "2024-07-30T15:22:41+00:00" }, { "name": "laravel/pint", @@ -16199,16 +16199,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.60.0", + "version": "v3.61.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "e595e4e070d17c5d42ed8c4206f630fcc5f401a4" + "reference": "94a87189f55814e6cabca2d9a33b06de384a2ab8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/e595e4e070d17c5d42ed8c4206f630fcc5f401a4", - "reference": "e595e4e070d17c5d42ed8c4206f630fcc5f401a4", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/94a87189f55814e6cabca2d9a33b06de384a2ab8", + "reference": "94a87189f55814e6cabca2d9a33b06de384a2ab8", "shasum": "" }, "require": { @@ -16290,7 +16290,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.60.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.61.1" }, "funding": [ { @@ -16298,7 +16298,7 @@ "type": "github" } ], - "time": "2024-07-25T09:26:51+00:00" + "time": "2024-07-31T14:33:15+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -17347,16 +17347,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.28", + "version": "10.5.29", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ff7fb85cdf88131b83e721fb2a327b664dbed275" + "reference": "8e9e80872b4e8064401788ee8a32d40b4455318f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ff7fb85cdf88131b83e721fb2a327b664dbed275", - "reference": "ff7fb85cdf88131b83e721fb2a327b664dbed275", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8e9e80872b4e8064401788ee8a32d40b4455318f", + "reference": "8e9e80872b4e8064401788ee8a32d40b4455318f", "shasum": "" }, "require": { @@ -17428,7 +17428,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.28" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.29" }, "funding": [ { @@ -17444,7 +17444,7 @@ "type": "tidelift" } ], - "time": "2024-07-18T14:54:16+00:00" + "time": "2024-07-30T11:08:00+00:00" }, { "name": "react/cache", From 2c0e67a5687805b575714147703c407019ae0924 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 1 Aug 2024 10:57:10 +1000 Subject: [PATCH 4/7] Fixes for bank transaction filters --- app/Filters/BankTransactionFilters.php | 6 ++++-- app/PaymentDrivers/Stripe/BrowserPay.php | 2 +- app/PaymentDrivers/Stripe/CreditCard.php | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Filters/BankTransactionFilters.php b/app/Filters/BankTransactionFilters.php index faaeaa7ade4a..f786f49e78ed 100644 --- a/app/Filters/BankTransactionFilters.php +++ b/app/Filters/BankTransactionFilters.php @@ -155,11 +155,13 @@ class BankTransactionFilters extends QueryFilters $dir = ($sort_col[1] == 'asc') ? 'asc' : 'desc'; if ($sort_col[0] == 'deposit') { - return $this->builder->where('base_type', 'CREDIT')->orderBy('amount', $dir); + return $this->builder->orderByRaw("(CASE WHEN base_type = 'CREDIT' THEN amount END) $dir")->orderBy('amount', $dir); + // return $this->builder->where('base_type', 'CREDIT')->orderBy('amount', $dir); } if ($sort_col[0] == 'withdrawal') { - return $this->builder->where('base_type', 'DEBIT')->orderBy('amount', $dir); + return $this->builder->orderByRaw("(CASE WHEN base_type = 'DEBIT' THEN amount END) $dir")->orderBy('amount', $dir); + // return $this->builder->where('base_type', 'DEBIT')->orderBy('amount', $dir); } if ($sort_col[0] == 'status') { diff --git a/app/PaymentDrivers/Stripe/BrowserPay.php b/app/PaymentDrivers/Stripe/BrowserPay.php index 9af3eb90d579..09d71fcdb17c 100644 --- a/app/PaymentDrivers/Stripe/BrowserPay.php +++ b/app/PaymentDrivers/Stripe/BrowserPay.php @@ -153,7 +153,7 @@ class BrowserPay implements MethodInterface $this->stripe->client->company, ); - return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id)]); + return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); } /** diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php index 8b2266c3c2a5..eab1a98c3262 100644 --- a/app/PaymentDrivers/Stripe/CreditCard.php +++ b/app/PaymentDrivers/Stripe/CreditCard.php @@ -160,7 +160,7 @@ class CreditCard } } - return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id)]); + return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]); } public function processUnsuccessfulPayment($server_response) From afb8065dfef4007fe4efa4082612152831a54d87 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 1 Aug 2024 11:15:02 +1000 Subject: [PATCH 5/7] Fixes for task export date ranges --- app/Export/CSV/BaseExport.php | 5 ++++- app/Export/CSV/TaskExport.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Export/CSV/BaseExport.php b/app/Export/CSV/BaseExport.php index 605abff1e234..a3bac0bb1204 100644 --- a/app/Export/CSV/BaseExport.php +++ b/app/Export/CSV/BaseExport.php @@ -1258,7 +1258,7 @@ class BaseExport $date_range = $this->input['date_range']; - if (array_key_exists('date_key', $this->input) && strlen($this->input['date_key']) > 1 && ($table_name && $this->columnExists($table_name, $this->input['date_key']))) { + if (array_key_exists('date_key', $this->input) && strlen($this->input['date_key'] ?? '') > 1 && ($table_name && $this->columnExists($table_name, $this->input['date_key']))) { $this->date_key = $this->input['date_key']; } @@ -1270,6 +1270,9 @@ class BaseExport $custom_end_date = now(); } + nlog($custom_start_date->format('Y-m-d')); + nlog($custom_end_date->format('Y-m-d')); + switch ($date_range) { case 'all': $this->start_date = 'All available data'; diff --git a/app/Export/CSV/TaskExport.php b/app/Export/CSV/TaskExport.php index bc357d61a96f..155d61a88f48 100644 --- a/app/Export/CSV/TaskExport.php +++ b/app/Export/CSV/TaskExport.php @@ -29,7 +29,7 @@ class TaskExport extends BaseExport { private $entity_transformer; - public string $date_key = 'created_at'; + public string $date_key = 'calculated_start_date'; private string $date_format = 'Y-m-d'; From 19ba732adf99d90de871e6bb80d2907ec560141f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 1 Aug 2024 11:25:11 +1000 Subject: [PATCH 6/7] Add client model to invoice calculators --- app/Export/CSV/BaseExport.php | 3 --- app/Helpers/Invoice/InvoiceItemSum.php | 5 +++-- .../Invoice/InvoiceItemSumInclusive.php | 5 +++-- app/Helpers/Invoice/InvoiceSum.php | 17 +++++++------- app/Helpers/Invoice/InvoiceSumInclusive.php | 22 +++++++++---------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/app/Export/CSV/BaseExport.php b/app/Export/CSV/BaseExport.php index a3bac0bb1204..4ea22fe974ee 100644 --- a/app/Export/CSV/BaseExport.php +++ b/app/Export/CSV/BaseExport.php @@ -1269,9 +1269,6 @@ class BaseExport $custom_start_date = now()->startOfYear(); $custom_end_date = now(); } - - nlog($custom_start_date->format('Y-m-d')); - nlog($custom_end_date->format('Y-m-d')); switch ($date_range) { case 'all': diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 9f913c42a8bc..d1d7dd56cff0 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -15,6 +15,7 @@ use App\Models\Quote; use App\Utils\Number; use App\Models\Client; use App\Models\Credit; +use App\Models\Vendor; use App\Models\Invoice; use App\Models\PurchaseOrder; use App\Models\RecurringQuote; @@ -121,7 +122,7 @@ class InvoiceItemSum private $tax_collection; - private ?Client $client; + private Client | Vendor $client; private bool $calc_tax = false; @@ -132,10 +133,10 @@ class InvoiceItemSum $this->tax_collection = collect([]); $this->invoice = $invoice; + $this->client = $invoice->client ?? $invoice->vendor; if ($this->invoice->client) { $this->currency = $this->invoice->client->currency(); - $this->client = $this->invoice->client; $this->shouldCalculateTax(); } else { $this->currency = $this->invoice->vendor->currency(); diff --git a/app/Helpers/Invoice/InvoiceItemSumInclusive.php b/app/Helpers/Invoice/InvoiceItemSumInclusive.php index 8bcf87fc25a3..df9a897abefa 100644 --- a/app/Helpers/Invoice/InvoiceItemSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceItemSumInclusive.php @@ -15,6 +15,7 @@ use App\Models\Quote; use App\Utils\Number; use App\Models\Client; use App\Models\Credit; +use App\Models\Vendor; use App\Models\Invoice; use App\Models\PurchaseOrder; use App\Models\RecurringQuote; @@ -110,7 +111,7 @@ class InvoiceItemSumInclusive private bool $calc_tax = false; - private ?Client $client; + private Client | Vendor $client; private RuleInterface $rule; @@ -119,10 +120,10 @@ class InvoiceItemSumInclusive $this->tax_collection = collect([]); $this->invoice = $invoice; + $this->client = $invoice->client ?? $invoice->vendor; if ($this->invoice->client) { $this->currency = $this->invoice->client->currency(); - $this->client = $this->invoice->client; $this->shouldCalculateTax(); } else { $this->currency = $this->invoice->vendor->currency(); diff --git a/app/Helpers/Invoice/InvoiceSum.php b/app/Helpers/Invoice/InvoiceSum.php index c2979f73219e..12cb3a1b16de 100644 --- a/app/Helpers/Invoice/InvoiceSum.php +++ b/app/Helpers/Invoice/InvoiceSum.php @@ -11,12 +11,14 @@ namespace App\Helpers\Invoice; +use App\Models\Client; use App\Models\Credit; use App\Models\Invoice; use App\Models\PurchaseOrder; use App\Models\Quote; use App\Models\RecurringInvoice; use App\Models\RecurringQuote; +use App\Models\Vendor; use App\Utils\Number; use App\Utils\Traits\NumberFormatter; use Illuminate\Support\Collection; @@ -50,6 +52,8 @@ class InvoiceSum private $precision; + private Client | Vendor $client; + public InvoiceItemSum $invoice_items; private $rappen_rounding = false; @@ -60,18 +64,15 @@ class InvoiceSum */ public function __construct($invoice) { + $this->invoice = $invoice; + $this->client = $invoice->client ?? $invoice->vendor; - if ($this->invoice->client) { - $this->precision = $this->invoice->client->currency()->precision; - $this->rappen_rounding = $this->invoice->client->getSetting('enable_rappen_rounding'); - } else { - $this->precision = $this->invoice->vendor->currency()->precision; - $this->rappen_rounding = $this->invoice->vendor->getSetting('enable_rappen_rounding'); - - } + $this->precision = $this->client->currency()->precision; + $this->rappen_rounding = $this->client->getSetting('enable_rappen_rounding'); $this->tax_map = new Collection(); + } public function build() diff --git a/app/Helpers/Invoice/InvoiceSumInclusive.php b/app/Helpers/Invoice/InvoiceSumInclusive.php index 8b0b6f95cc93..07fdf3e86894 100644 --- a/app/Helpers/Invoice/InvoiceSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceSumInclusive.php @@ -13,7 +13,9 @@ namespace App\Helpers\Invoice; use App\Models\Quote; use App\Utils\Number; +use App\Models\Client; use App\Models\Credit; +use App\Models\Vendor; use App\Models\Invoice; use App\Models\PurchaseOrder; use App\Models\RecurringQuote; @@ -50,6 +52,8 @@ class InvoiceSumInclusive private $rappen_rounding = false; + private Client | Vendor $client; + public InvoiceItemSumInclusive $invoice_items; /** * Constructs the object with Invoice and Settings object. @@ -59,14 +63,10 @@ class InvoiceSumInclusive public function __construct($invoice) { $this->invoice = $invoice; - - if ($this->invoice->client) { - $this->precision = $this->invoice->client->currency()->precision; - $this->rappen_rounding = $this->invoice->client->getSetting('enable_rappen_rounding'); - } else { - $this->precision = $this->invoice->vendor->currency()->precision; - $this->rappen_rounding = $this->invoice->vendor->getSetting('enable_rappen_rounding'); - } + $this->client = $invoice->client ?? $invoice->vendor; + + $this->precision = $this->client->currency()->precision; + $this->rappen_rounding = $this->client->getSetting('enable_rappen_rounding'); $this->tax_map = new Collection(); } @@ -158,19 +158,19 @@ class InvoiceSumInclusive $tax = $this->calcInclusiveLineTax($this->invoice->tax_rate1, $amount); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate1), $this->invoice->client).'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate1), $this->client).'%', 'total' => $tax]; } if (is_string($this->invoice->tax_name2) && strlen($this->invoice->tax_name2) > 1) { $tax = $this->calcInclusiveLineTax($this->invoice->tax_rate2, $amount); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate2), $this->invoice->client).'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate2), $this->client).'%', 'total' => $tax]; } if (is_string($this->invoice->tax_name3) && strlen($this->invoice->tax_name3) > 1) { $tax = $this->calcInclusiveLineTax($this->invoice->tax_rate3, $amount); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate3), $this->invoice->client).'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate3), $this->client).'%', 'total' => $tax]; } return $this; From f4075d88ee2e53be9c7ea7aa923f14bdb93d5f29 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 1 Aug 2024 11:32:03 +1000 Subject: [PATCH 7/7] Fixes for invoice calcs --- app/Helpers/Invoice/InvoiceSum.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Helpers/Invoice/InvoiceSum.php b/app/Helpers/Invoice/InvoiceSum.php index 12cb3a1b16de..e69cf394a6ca 100644 --- a/app/Helpers/Invoice/InvoiceSum.php +++ b/app/Helpers/Invoice/InvoiceSum.php @@ -132,7 +132,7 @@ class InvoiceSum $tax += $this->getSurchargeTaxTotalForKey($this->invoice->tax_name1, $this->invoice->tax_rate1); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate1), $this->invoice->client).'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate1), $this->client).'%', 'total' => $tax]; } if (is_string($this->invoice->tax_name2) && strlen($this->invoice->tax_name2) >= 2) { @@ -140,7 +140,7 @@ class InvoiceSum $tax += $this->getSurchargeTaxTotalForKey($this->invoice->tax_name2, $this->invoice->tax_rate2); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate2), $this->invoice->client).'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate2), $this->client).'%', 'total' => $tax]; } if (is_string($this->invoice->tax_name3) && strlen($this->invoice->tax_name3) >= 2) { @@ -148,7 +148,7 @@ class InvoiceSum $tax += $this->getSurchargeTaxTotalForKey($this->invoice->tax_name3, $this->invoice->tax_rate3); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate3), $this->invoice->client).'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate3), $this->client).'%', 'total' => $tax]; } return $this;