diff --git a/app/Services/Report/ProfitLoss.php b/app/Services/Report/ProfitLoss.php index 0f7e2ca97b..7b33edb3b7 100644 --- a/app/Services/Report/ProfitLoss.php +++ b/app/Services/Report/ProfitLoss.php @@ -284,22 +284,23 @@ class ProfitLoss if ($pivot->paymentable_type == 'invoices') { $invoice = Invoice::query()->withTrashed()->find($pivot->paymentable_id); - $amount_payment_paid += $pivot->amount - $pivot->refunded; - $amount_payment_paid_converted += $amount_payment_paid / ($payment->exchange_rate ?: 1); + $pivot_diff = $pivot->amount - $pivot->refunded; + $amount_payment_paid += $pivot_diff; + $amount_payment_paid_converted += $pivot_diff / ($payment->exchange_rate ?: 1); if ($invoice->amount > 0) { - $tax_amount += ($amount_payment_paid / $invoice->amount) * $invoice->total_taxes; - $tax_amount_converted += (($amount_payment_paid / $invoice->amount) * $invoice->total_taxes) / $payment->exchange_rate; + $tax_amount += ($pivot_diff / $invoice->amount) * $invoice->total_taxes; + $tax_amount_converted += (($pivot_diff / $invoice->amount) * $invoice->total_taxes) / $payment->exchange_rate; } } if ($pivot->paymentable_type == 'credits') { $amount_credit_paid += $pivot->amount - $pivot->refunded; - $amount_credit_paid_converted += $amount_payment_paid / ($payment->exchange_rate ?: 1); + $amount_credit_paid_converted += $pivot_diff / ($payment->exchange_rate ?: 1); - $tax_amount_credit += ($amount_payment_paid / $invoice->amount) * $invoice->total_taxes; - $tax_amount_credit_converted += (($amount_payment_paid / $invoice->amount) * $invoice->total_taxes) / $payment->exchange_rate; + $tax_amount_credit += ($pivot_diff / $invoice->amount) * $invoice->total_taxes; + $tax_amount_credit_converted += (($pivot_diff / $invoice->amount) * $invoice->total_taxes) / $payment->exchange_rate; } } diff --git a/composer.lock b/composer.lock index 45db5adaa6..2a9fb8e951 100644 --- a/composer.lock +++ b/composer.lock @@ -1036,16 +1036,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.295.0", + "version": "3.295.4", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "326eb6c26e2be9d896c4aeb025e20980c06779af" + "reference": "2372661db989fe4229abd95f4434b37252076d58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/326eb6c26e2be9d896c4aeb025e20980c06779af", - "reference": "326eb6c26e2be9d896c4aeb025e20980c06779af", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/2372661db989fe4229abd95f4434b37252076d58", + "reference": "2372661db989fe4229abd95f4434b37252076d58", "shasum": "" }, "require": { @@ -1125,9 +1125,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.295.0" + "source": "https://github.com/aws/aws-sdk-php/tree/3.295.4" }, - "time": "2023-12-22T19:07:47+00:00" + "time": "2023-12-29T19:07:49+00:00" }, { "name": "bacon/bacon-qr-code", @@ -4917,16 +4917,16 @@ }, { "name": "laravel/framework", - "version": "v10.38.2", + "version": "v10.39.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "43da808391da3540d44a8dfeb4e46da4ad8f5723" + "reference": "114926b07bfb5fbf2545c03aa2ce5c8c37be650c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/43da808391da3540d44a8dfeb4e46da4ad8f5723", - "reference": "43da808391da3540d44a8dfeb4e46da4ad8f5723", + "url": "https://api.github.com/repos/laravel/framework/zipball/114926b07bfb5fbf2545c03aa2ce5c8c37be650c", + "reference": "114926b07bfb5fbf2545c03aa2ce5c8c37be650c", "shasum": "" }, "require": { @@ -5029,7 +5029,7 @@ "league/flysystem-sftp-v3": "^3.0", "mockery/mockery": "^1.5.1", "nyholm/psr7": "^1.2", - "orchestra/testbench-core": "^8.15.1", + "orchestra/testbench-core": "^8.18", "pda/pheanstalk": "^4.0", "phpstan/phpstan": "^1.4.7", "phpunit/phpunit": "^10.0.7", @@ -5118,20 +5118,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-12-22T14:39:10+00:00" + "time": "2023-12-27T14:26:28+00:00" }, { "name": "laravel/prompts", - "version": "v0.1.13", + "version": "v0.1.14", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "e1379d8ead15edd6cc4369c22274345982edc95a" + "reference": "2219fa9c4b944add1e825c3bdb8ecae8bc503bc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/e1379d8ead15edd6cc4369c22274345982edc95a", - "reference": "e1379d8ead15edd6cc4369c22274345982edc95a", + "url": "https://api.github.com/repos/laravel/prompts/zipball/2219fa9c4b944add1e825c3bdb8ecae8bc503bc6", + "reference": "2219fa9c4b944add1e825c3bdb8ecae8bc503bc6", "shasum": "" }, "require": { @@ -5147,7 +5147,7 @@ "require-dev": { "mockery/mockery": "^1.5", "pestphp/pest": "^2.3", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^1.11", "phpstan/phpstan-mockery": "^1.1" }, "suggest": { @@ -5173,9 +5173,9 @@ ], "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.1.13" + "source": "https://github.com/laravel/prompts/tree/v0.1.14" }, - "time": "2023-10-27T13:53:59+00:00" + "time": "2023-12-27T04:18:09+00:00" }, { "name": "laravel/serializable-closure", @@ -5827,16 +5827,16 @@ }, { "name": "league/csv", - "version": "9.13.0", + "version": "9.14.0", "source": { "type": "git", "url": "https://github.com/thephpleague/csv.git", - "reference": "3690cc71bfe8dc3b6daeef356939fac95348f0a8" + "reference": "34bf0df7340b60824b9449b5c526fcc3325070d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/csv/zipball/3690cc71bfe8dc3b6daeef356939fac95348f0a8", - "reference": "3690cc71bfe8dc3b6daeef356939fac95348f0a8", + "url": "https://api.github.com/repos/thephpleague/csv/zipball/34bf0df7340b60824b9449b5c526fcc3325070d5", + "reference": "34bf0df7340b60824b9449b5c526fcc3325070d5", "shasum": "" }, "require": { @@ -5912,7 +5912,7 @@ "type": "github" } ], - "time": "2023-12-16T11:03:20+00:00" + "time": "2023-12-29T07:34:53+00:00" }, { "name": "league/flysystem", @@ -8946,16 +8946,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "3.0.34", + "version": "3.0.35", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "56c79f16a6ae17e42089c06a2144467acc35348a" + "reference": "4b1827beabce71953ca479485c0ae9c51287f2fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/56c79f16a6ae17e42089c06a2144467acc35348a", - "reference": "56c79f16a6ae17e42089c06a2144467acc35348a", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/4b1827beabce71953ca479485c0ae9c51287f2fe", + "reference": "4b1827beabce71953ca479485c0ae9c51287f2fe", "shasum": "" }, "require": { @@ -9036,7 +9036,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.34" + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.35" }, "funding": [ { @@ -9052,7 +9052,7 @@ "type": "tidelift" } ], - "time": "2023-11-27T11:13:31+00:00" + "time": "2023-12-29T01:59:53+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -13865,21 +13865,21 @@ }, { "name": "symfony/service-contracts", - "version": "v3.4.0", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838" + "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/b3313c2dbffaf71c8de2934e2ea56ed2291a3838", - "reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/fe07cbc8d837f60caf7018068e350cc5163681a0", + "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0", "shasum": "" }, "require": { "php": ">=8.1", - "psr/container": "^2.0" + "psr/container": "^1.1|^2.0" }, "conflict": { "ext-psr": "<1.1|>=2" @@ -13927,7 +13927,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.4.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.4.1" }, "funding": [ { @@ -13943,7 +13943,7 @@ "type": "tidelift" } ], - "time": "2023-07-30T20:28:31+00:00" + "time": "2023-12-26T14:02:43+00:00" }, { "name": "symfony/string", @@ -14128,16 +14128,16 @@ }, { "name": "symfony/translation-contracts", - "version": "v3.4.0", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "dee0c6e5b4c07ce851b462530088e64b255ac9c5" + "reference": "06450585bf65e978026bda220cdebca3f867fde7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/dee0c6e5b4c07ce851b462530088e64b255ac9c5", - "reference": "dee0c6e5b4c07ce851b462530088e64b255ac9c5", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/06450585bf65e978026bda220cdebca3f867fde7", + "reference": "06450585bf65e978026bda220cdebca3f867fde7", "shasum": "" }, "require": { @@ -14186,7 +14186,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v3.4.0" + "source": "https://github.com/symfony/translation-contracts/tree/v3.4.1" }, "funding": [ { @@ -14202,7 +14202,7 @@ "type": "tidelift" } ], - "time": "2023-07-25T15:08:44+00:00" + "time": "2023-12-26T14:02:43+00:00" }, { "name": "symfony/uid", @@ -15955,16 +15955,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.42.0", + "version": "v3.44.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "632ef1be3447a9b890bef06147475facee535d0f" + "reference": "5445834057a744c1a434ed60fcac566b4de3a0f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/632ef1be3447a9b890bef06147475facee535d0f", - "reference": "632ef1be3447a9b890bef06147475facee535d0f", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/5445834057a744c1a434ed60fcac566b4de3a0f2", + "reference": "5445834057a744c1a434ed60fcac566b4de3a0f2", "shasum": "" }, "require": { @@ -15994,7 +15994,7 @@ "php-cs-fixer/accessible-object": "^1.1", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^9.6 || ^10.5.5", "symfony/yaml": "^5.4 || ^6.0 || ^7.0" }, "suggest": { @@ -16033,7 +16033,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.42.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.44.0" }, "funding": [ { @@ -16041,7 +16041,7 @@ "type": "github" } ], - "time": "2023-12-24T14:38:51+00:00" + "time": "2023-12-29T20:21:16+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -17141,16 +17141,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.3", + "version": "10.5.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "6fce887c71076a73f32fd3e0774a6833fc5c7f19" + "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6fce887c71076a73f32fd3e0774a6833fc5c7f19", - "reference": "6fce887c71076a73f32fd3e0774a6833fc5c7f19", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ed21115d505b4b4f7dc7b5651464e19a2c7f7856", + "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856", "shasum": "" }, "require": { @@ -17222,7 +17222,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.3" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.5" }, "funding": [ { @@ -17238,7 +17238,7 @@ "type": "tidelift" } ], - "time": "2023-12-13T07:25:23+00:00" + "time": "2023-12-27T15:13:52+00:00" }, { "name": "sebastian/cli-parser",