diff --git a/VERSION.txt b/VERSION.txt index cf38f27aeab7..17799edf2630 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.3.75 \ No newline at end of file +5.3.76 \ No newline at end of file diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index aa310479d812..b6440543eeb6 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -28,8 +28,6 @@ class ClientService public function updateBalance(float $amount) { - // $this->client->balance += $amount; - $this->client->increment('balance', $amount); return $this; @@ -37,8 +35,6 @@ class ClientService public function updatePaidToDate(float $amount) { - // $this->client->paid_to_date += $amount; - $this->client->increment('paid_to_date', $amount); return $this; @@ -46,8 +42,6 @@ class ClientService public function adjustCreditBalance(float $amount) { - // $this->client->credit_balance += $amount; - $this->client->increment('credit_balance', $amount); return $this; diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 5b91c111a66b..59366cb5d86a 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -146,11 +146,8 @@ class InvoiceService return $this; } - // $this->invoice->balance += $balance_adjustment; + $this->invoice->balance += $balance_adjustment; - $this->invoice->increment('balance', $balance_adjustment); - - if (round($this->invoice->balance,2) == 0 && !$is_draft) { $this->invoice->status_id = Invoice::STATUS_PAID; } @@ -164,10 +161,7 @@ class InvoiceService public function updatePaidToDate($adjustment) { - // $this->invoice->paid_to_date += $adjustment; - - $this->invoice->increment('paid_to_date', $adjustment); - + $this->invoice->paid_to_date += $adjustment; return $this; } diff --git a/app/Services/Payment/RefundPayment.php b/app/Services/Payment/RefundPayment.php index ac1d0fdf420a..4d02bfecf927 100644 --- a/app/Services/Payment/RefundPayment.php +++ b/app/Services/Payment/RefundPayment.php @@ -263,11 +263,15 @@ class RefundPayment foreach ($this->refund_data['invoices'] as $refunded_invoice) { $invoice = Invoice::withTrashed()->find($refunded_invoice['invoice_id']); - $invoice->restore(); + if($invoice->trashed()) + $invoice->restore(); + + $invoice->service() + ->updateBalance($refunded_invoice['amount']) + ->updatePaidToDate($refunded_invoice['amount'] * -1) + ->save(); - $invoice->service()->updateBalance($refunded_invoice['amount'])->save(); $invoice->ledger()->updateInvoiceBalance($refunded_invoice['amount'], "Refund of payment # {$this->payment->number}")->save(); - $invoice->paid_to_date -= $refunded_invoice['amount']; if ($invoice->amount == $invoice->balance) { $invoice->service()->setStatus(Invoice::STATUS_SENT); @@ -278,7 +282,6 @@ class RefundPayment $invoice->saveQuietly(); $client = $invoice->client; - $adjustment_amount += $refunded_invoice['amount']; $client->balance += $refunded_invoice['amount']; $client->save(); @@ -300,8 +303,11 @@ class RefundPayment } $client = $this->payment->client->fresh(); - $client->service()->updatePaidToDate(-1 * $refunded_invoice['amount'])->save(); + if($client->trashed()) + $client->restore(); + + $client->service()->updatePaidToDate(-1 * $refunded_invoice['amount'])->save(); $transaction = [ 'invoice' => [], @@ -318,6 +324,10 @@ class RefundPayment //if we are refunding and no payments have been tagged, then we need to decrement the client->paid_to_date by the total refund amount. $client = $this->payment->client->fresh(); + + if($client->trashed()) + $client->restore(); + $client->service()->updatePaidToDate(-1 * $this->total_refund)->save(); $transaction = [ diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index 3a34b2e80310..5054c9b87a3e 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -43,12 +43,19 @@ class UpdateInvoicePayment collect($paid_invoices)->each(function ($paid_invoice) use ($invoices) { - $client = $this->payment->client->fresh(); + $client = $this->payment->client; + + if($client->trashed()) + $client->restore(); $invoice = $invoices->first(function ($inv) use ($paid_invoice) { return $paid_invoice->invoice_id == $inv->hashed_id; }); + + if($invoice->trashed()) + $invoice->restore(); + if ($invoice->id == $this->payment_hash->fee_invoice_id) { $paid_amount = $paid_invoice->amount + $this->payment_hash->fee_total; } else { @@ -116,7 +123,6 @@ class UpdateInvoicePayment $invoices->each(function ($invoice) { - $invoice = $invoice->fresh(); event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); }); diff --git a/composer.json b/composer.json index 9ba53b9158d1..1dc05e2364e5 100644 --- a/composer.json +++ b/composer.json @@ -148,4 +148,4 @@ }, "minimum-stability": "dev", "prefer-stable": true -} +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index 71d17b274537..eda820989f3f 100644 --- a/composer.lock +++ b/composer.lock @@ -110,16 +110,16 @@ }, { "name": "apimatic/unirest-php", - "version": "2.2.1", + "version": "2.2.2", "source": { "type": "git", "url": "https://github.com/apimatic/unirest-php.git", - "reference": "847149c56d850081c07d5677e9647fa0c15e595f" + "reference": "a45c4c71a1ea3659b118042a67cc1b6486bcf03a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/apimatic/unirest-php/zipball/847149c56d850081c07d5677e9647fa0c15e595f", - "reference": "847149c56d850081c07d5677e9647fa0c15e595f", + "url": "https://api.github.com/repos/apimatic/unirest-php/zipball/a45c4c71a1ea3659b118042a67cc1b6486bcf03a", + "reference": "a45c4c71a1ea3659b118042a67cc1b6486bcf03a", "shasum": "" }, "require": { @@ -168,9 +168,9 @@ "support": { "email": "opensource@apimatic.io", "issues": "https://github.com/apimatic/unirest-php/issues", - "source": "https://github.com/apimatic/unirest-php/tree/2.2.1" + "source": "https://github.com/apimatic/unirest-php/tree/2.2.2" }, - "time": "2022-03-12T08:37:06+00:00" + "time": "2022-03-24T08:19:20+00:00" }, { "name": "asm/php-ansible", @@ -434,16 +434,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.215.0", + "version": "3.216.2", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "79c4ffdf93cdcc7be9196ae2e22f0d0323cb2557" + "reference": "9e09386c3a5b313eeb324490beff4eb843ed339d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/79c4ffdf93cdcc7be9196ae2e22f0d0323cb2557", - "reference": "79c4ffdf93cdcc7be9196ae2e22f0d0323cb2557", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/9e09386c3a5b313eeb324490beff4eb843ed339d", + "reference": "9e09386c3a5b313eeb324490beff4eb843ed339d", "shasum": "" }, "require": { @@ -519,9 +519,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.215.0" + "source": "https://github.com/aws/aws-sdk-php/tree/3.216.2" }, - "time": "2022-03-18T18:16:01+00:00" + "time": "2022-03-25T18:17:03+00:00" }, { "name": "bacon/bacon-qr-code", @@ -1300,16 +1300,16 @@ }, { "name": "doctrine/dbal", - "version": "3.3.3", + "version": "3.3.4", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "82331b861727c15b1f457ef05a8729e508e7ead5" + "reference": "83f779beaea1893c0bece093ab2104c6d15a7f26" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/82331b861727c15b1f457ef05a8729e508e7ead5", - "reference": "82331b861727c15b1f457ef05a8729e508e7ead5", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/83f779beaea1893c0bece093ab2104c6d15a7f26", + "reference": "83f779beaea1893c0bece093ab2104c6d15a7f26", "shasum": "" }, "require": { @@ -1391,7 +1391,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.3.3" + "source": "https://github.com/doctrine/dbal/tree/3.3.4" }, "funding": [ { @@ -1407,7 +1407,7 @@ "type": "tidelift" } ], - "time": "2022-03-09T15:39:50+00:00" + "time": "2022-03-20T18:37:29+00:00" }, { "name": "doctrine/deprecations", @@ -2287,16 +2287,16 @@ }, { "name": "google/apiclient-services", - "version": "v0.239.0", + "version": "v0.240.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "ce8e34d618bdef9e824fd1728d505a468818712c" + "reference": "c6d39cda24d7ada02ecf8c464a1c8adb02607ba7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/ce8e34d618bdef9e824fd1728d505a468818712c", - "reference": "ce8e34d618bdef9e824fd1728d505a468818712c", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/c6d39cda24d7ada02ecf8c464a1c8adb02607ba7", + "reference": "c6d39cda24d7ada02ecf8c464a1c8adb02607ba7", "shasum": "" }, "require": { @@ -2325,29 +2325,29 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.239.0" + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.240.0" }, - "time": "2022-03-13T01:20:35+00:00" + "time": "2022-03-21T01:20:11+00:00" }, { "name": "google/auth", - "version": "v1.18.0", + "version": "v1.19.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-auth-library-php.git", - "reference": "21dd478e77b0634ed9e3a68613f74ed250ca9347" + "reference": "31e5d24d5fa0eaf6adc7e596292dc4732f4b60c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/21dd478e77b0634ed9e3a68613f74ed250ca9347", - "reference": "21dd478e77b0634ed9e3a68613f74ed250ca9347", + "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/31e5d24d5fa0eaf6adc7e596292dc4732f4b60c5", + "reference": "31e5d24d5fa0eaf6adc7e596292dc4732f4b60c5", "shasum": "" }, "require": { - "firebase/php-jwt": "~2.0|~3.0|~4.0|~5.0", - "guzzlehttp/guzzle": "^5.3.1|^6.2.1|^7.0", + "firebase/php-jwt": "~5.0", + "guzzlehttp/guzzle": "^6.2.1|^7.0", "guzzlehttp/psr7": "^1.7|^2.0", - "php": ">=5.4", + "php": ">=5.6", "psr/cache": "^1.0|^2.0", "psr/http-message": "^1.0" }, @@ -2355,8 +2355,10 @@ "guzzlehttp/promises": "0.1.1|^1.3", "kelvinmo/simplejwt": "^0.2.5|^0.5.1", "phpseclib/phpseclib": "^2.0.31", - "phpunit/phpunit": "^4.8.36|^5.7", - "sebastian/comparator": ">=1.2.3" + "phpspec/prophecy-phpunit": "^1.1", + "phpunit/phpunit": "^5.7||^8.5.13", + "sebastian/comparator": ">=1.2.3", + "squizlabs/php_codesniffer": "^3.5" }, "suggest": { "phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2." @@ -2379,11 +2381,11 @@ "oauth2" ], "support": { - "docs": "https://googleapis.github.io/google-auth-library-php/master/", + "docs": "https://googleapis.github.io/google-auth-library-php/main/", "issues": "https://github.com/googleapis/google-auth-library-php/issues", - "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.18.0" + "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.19.0" }, - "time": "2021-08-24T18:03:18+00:00" + "time": "2022-03-24T21:22:45+00:00" }, { "name": "graham-campbell/result-type", @@ -2507,16 +2509,16 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.4.1", + "version": "7.4.2", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79" + "reference": "ac1ec1cd9b5624694c3a40be801d94137afb12b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ee0a041b1760e6a53d2a39c8c34115adc2af2c79", - "reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ac1ec1cd9b5624694c3a40be801d94137afb12b4", + "reference": "ac1ec1cd9b5624694c3a40be801d94137afb12b4", "shasum": "" }, "require": { @@ -2611,7 +2613,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.4.1" + "source": "https://github.com/guzzle/guzzle/tree/7.4.2" }, "funding": [ { @@ -2627,7 +2629,7 @@ "type": "tidelift" } ], - "time": "2021-12-06T18:43:05+00:00" + "time": "2022-03-20T14:16:28+00:00" }, { "name": "guzzlehttp/promises", @@ -2715,16 +2717,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "2.1.0", + "version": "2.2.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72" + "reference": "c94a94f120803a18554c1805ef2e539f8285f9a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/089edd38f5b8abba6cb01567c2a8aaa47cec4c72", - "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/c94a94f120803a18554c1805ef2e539f8285f9a2", + "reference": "c94a94f120803a18554c1805ef2e539f8285f9a2", "shasum": "" }, "require": { @@ -2748,7 +2750,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, "autoload": { @@ -2810,7 +2812,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.1.0" + "source": "https://github.com/guzzle/psr7/tree/2.2.1" }, "funding": [ { @@ -2826,7 +2828,7 @@ "type": "tidelift" } ], - "time": "2021-10-06T17:43:30+00:00" + "time": "2022-03-20T21:55:58+00:00" }, { "name": "halaxa/json-machine", @@ -4616,16 +4618,16 @@ }, { "name": "mollie/mollie-api-php", - "version": "v2.40.2", + "version": "v2.41.0", "source": { "type": "git", "url": "https://github.com/mollie/mollie-api-php.git", - "reference": "ac3e079bbc86e95dc77d4f33965a62e9e6b95ed8" + "reference": "26010bd6999af4466c31c92733df87dc04d95772" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/ac3e079bbc86e95dc77d4f33965a62e9e6b95ed8", - "reference": "ac3e079bbc86e95dc77d4f33965a62e9e6b95ed8", + "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/26010bd6999af4466c31c92733df87dc04d95772", + "reference": "26010bd6999af4466c31c92733df87dc04d95772", "shasum": "" }, "require": { @@ -4636,9 +4638,10 @@ "php": ">=5.6" }, "require-dev": { - "eloquent/liberator": "^2.0", + "eloquent/liberator": "^2.0|^3.0", "friendsofphp/php-cs-fixer": "^3.0", "guzzlehttp/guzzle": "^6.3 || ^7.0", + "phpstan/phpstan": "^1.4", "phpunit/phpunit": "^5.7 || ^6.5 || ^7.1 || ^8.5 || ^9.5" }, "suggest": { @@ -4701,9 +4704,9 @@ ], "support": { "issues": "https://github.com/mollie/mollie-api-php/issues", - "source": "https://github.com/mollie/mollie-api-php/tree/v2.40.2" + "source": "https://github.com/mollie/mollie-api-php/tree/v2.41.0" }, - "time": "2022-02-08T08:53:18+00:00" + "time": "2022-03-24T15:06:33+00:00" }, { "name": "moneyphp/money", @@ -7887,16 +7890,16 @@ }, { "name": "stripe/stripe-php", - "version": "v7.117.0", + "version": "v7.119.0", "source": { "type": "git", "url": "https://github.com/stripe/stripe-php.git", - "reference": "c9d40524c63f3c5042d704f88a60f49a349b1221" + "reference": "a454dde82f5698cc4bcc5016c5328f533f516690" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/stripe/stripe-php/zipball/c9d40524c63f3c5042d704f88a60f49a349b1221", - "reference": "c9d40524c63f3c5042d704f88a60f49a349b1221", + "url": "https://api.github.com/repos/stripe/stripe-php/zipball/a454dde82f5698cc4bcc5016c5328f533f516690", + "reference": "a454dde82f5698cc4bcc5016c5328f533f516690", "shasum": "" }, "require": { @@ -7941,9 +7944,9 @@ ], "support": { "issues": "https://github.com/stripe/stripe-php/issues", - "source": "https://github.com/stripe/stripe-php/tree/v7.117.0" + "source": "https://github.com/stripe/stripe-php/tree/v7.119.0" }, - "time": "2022-03-18T18:16:15+00:00" + "time": "2022-03-25T20:09:27+00:00" }, { "name": "swiftmailer/swiftmailer", @@ -14615,16 +14618,16 @@ }, { "name": "swagger-api/swagger-ui", - "version": "v4.6.2", + "version": "v4.9.1", "source": { "type": "git", "url": "https://github.com/swagger-api/swagger-ui.git", - "reference": "d191c1ca18443a77273e9912ac2603ce1f7dc216" + "reference": "56fe8a1c279be6b55cd9aef7ce5e06e0ec364880" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swagger-api/swagger-ui/zipball/d191c1ca18443a77273e9912ac2603ce1f7dc216", - "reference": "d191c1ca18443a77273e9912ac2603ce1f7dc216", + "url": "https://api.github.com/repos/swagger-api/swagger-ui/zipball/56fe8a1c279be6b55cd9aef7ce5e06e0ec364880", + "reference": "56fe8a1c279be6b55cd9aef7ce5e06e0ec364880", "shasum": "" }, "type": "library", @@ -14670,9 +14673,9 @@ ], "support": { "issues": "https://github.com/swagger-api/swagger-ui/issues", - "source": "https://github.com/swagger-api/swagger-ui/tree/v4.6.2" + "source": "https://github.com/swagger-api/swagger-ui/tree/v4.9.1" }, - "time": "2022-03-10T11:36:38+00:00" + "time": "2022-03-25T18:33:52+00:00" }, { "name": "symfony/debug", @@ -14999,16 +15002,16 @@ }, { "name": "zircote/swagger-php", - "version": "4.2.12", + "version": "4.2.13", "source": { "type": "git", "url": "https://github.com/zircote/swagger-php.git", - "reference": "4ad0dc2245b6b603d732630fbea251ac92c630f2" + "reference": "8888655d7dc21eda6ec71e521f71a757605f48fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zircote/swagger-php/zipball/4ad0dc2245b6b603d732630fbea251ac92c630f2", - "reference": "4ad0dc2245b6b603d732630fbea251ac92c630f2", + "url": "https://api.github.com/repos/zircote/swagger-php/zipball/8888655d7dc21eda6ec71e521f71a757605f48fe", + "reference": "8888655d7dc21eda6ec71e521f71a757605f48fe", "shasum": "" }, "require": { @@ -15068,9 +15071,9 @@ ], "support": { "issues": "https://github.com/zircote/swagger-php/issues", - "source": "https://github.com/zircote/swagger-php/tree/4.2.12" + "source": "https://github.com/zircote/swagger-php/tree/4.2.13" }, - "time": "2022-03-15T20:43:30+00:00" + "time": "2022-03-23T08:54:27+00:00" } ], "aliases": [], @@ -15090,5 +15093,5 @@ "platform-dev": { "php": "^7.4|^8.0" }, - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.0.0" } diff --git a/config/ninja.php b/config/ninja.php index 07c4b8eafc9a..4fcab1bfcbef 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.3.75', - 'app_tag' => '5.3.75', + 'app_version' => '5.3.76', + 'app_tag' => '5.3.76', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),