Merge branch 'develop' into 5.8-dev

This commit is contained in:
James Cole
2022-07-26 20:28:32 +02:00
4 changed files with 21 additions and 18 deletions

View File

@@ -32,9 +32,11 @@ use FireflyIII\Transformers\TransactionGroupTransformer;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\View\View; use Illuminate\View\View;
use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\ParameterBag;
/** /**
* Class ShowController * Class ShowController
*/ */
@@ -146,7 +148,7 @@ class ShowController extends Controller
]; ];
} }
$amounts[$symbol]['amount'] = bcadd($amounts[$symbol]['amount'], $transaction['amount']); $amounts[$symbol]['amount'] = bcadd($amounts[$symbol]['amount'], $transaction['amount']);
if (null !== $transaction['foreign_amount']) { if (null !== $transaction['foreign_amount'] && '' !== $transaction['foreign_amount'] && bccomp('0', $transaction['foreign_amount']) !== 0) {
// same for foreign currency: // same for foreign currency:
$foreignSymbol = $transaction['foreign_currency_symbol']; $foreignSymbol = $transaction['foreign_currency_symbol'];
if (!array_key_exists($foreignSymbol, $amounts)) { if (!array_key_exists($foreignSymbol, $amounts)) {

View File

@@ -277,7 +277,10 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
{ {
/** @var Transaction $transaction */ /** @var Transaction $transaction */
$transaction = $journal->transactions->first(); $transaction = $journal->transactions->first();
if (null === $transaction->foreign_amount) { if (null === $transaction->foreign_amount || '' === $transaction->foreign_amount) {
return '';
}
if (0 === bccomp('0', $transaction->foreign_amount)) {
return ''; return '';
} }
$currency = $transaction->foreignCurrency; $currency = $transaction->foreignCurrency;

View File

@@ -118,7 +118,7 @@ class TransactionGroupTransformer extends AbstractTransformer
// amount: // amount:
$amount = app('steam')->positive((string) ($row['amount'] ?? '0')); $amount = app('steam')->positive((string) ($row['amount'] ?? '0'));
$foreignAmount = null; $foreignAmount = null;
if (null !== $row['foreign_amount']) { if (null !== $row['foreign_amount'] && '' !== $row['foreign_amount'] && bccomp('0', $row['foreign_amount']) !== 0) {
$foreignAmount = app('steam')->positive($row['foreign_amount']); $foreignAmount = app('steam')->positive($row['foreign_amount']);
} }
@@ -517,7 +517,7 @@ class TransactionGroupTransformer extends AbstractTransformer
private function getForeignAmount(string $type, ?string $foreignAmount): ?string private function getForeignAmount(string $type, ?string $foreignAmount): ?string
{ {
$result = null; $result = null;
if (null !== $foreignAmount) { if (null !== $foreignAmount && '' !== $foreignAmount && bccomp('0', $foreignAmount) !== 0) {
$result = TransactionType::WITHDRAWAL !== $type ? app('steam')->negative($foreignAmount) : app('steam')->positive($foreignAmount); $result = TransactionType::WITHDRAWAL !== $type ? app('steam')->negative($foreignAmount) : app('steam')->positive($foreignAmount);
} }

26
composer.lock generated
View File

@@ -1854,16 +1854,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v9.21.4", "version": "v9.21.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "7707d6a16c70da1561bf80964e89b1b94ca78a48" "reference": "569d7a2e361895f90e66bb4e02db89c27691a0e7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/7707d6a16c70da1561bf80964e89b1b94ca78a48", "url": "https://api.github.com/repos/laravel/framework/zipball/569d7a2e361895f90e66bb4e02db89c27691a0e7",
"reference": "7707d6a16c70da1561bf80964e89b1b94ca78a48", "reference": "569d7a2e361895f90e66bb4e02db89c27691a0e7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2030,7 +2030,7 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2022-07-21T13:30:12+00:00" "time": "2022-07-22T14:16:44+00:00"
}, },
{ {
"name": "laravel/passport", "name": "laravel/passport",
@@ -3303,16 +3303,16 @@
}, },
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
"version": "2.7.0", "version": "2.8.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Seldaek/monolog.git", "url": "https://github.com/Seldaek/monolog.git",
"reference": "5579edf28aee1190a798bfa5be8bc16c563bd524" "reference": "720488632c590286b88b80e62aa3d3d551ad4a50"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/5579edf28aee1190a798bfa5be8bc16c563bd524", "url": "https://api.github.com/repos/Seldaek/monolog/zipball/720488632c590286b88b80e62aa3d3d551ad4a50",
"reference": "5579edf28aee1190a798bfa5be8bc16c563bd524", "reference": "720488632c590286b88b80e62aa3d3d551ad4a50",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -3332,11 +3332,10 @@
"guzzlehttp/psr7": "^2.2", "guzzlehttp/psr7": "^2.2",
"mongodb/mongodb": "^1.8", "mongodb/mongodb": "^1.8",
"php-amqplib/php-amqplib": "~2.4 || ^3", "php-amqplib/php-amqplib": "~2.4 || ^3",
"php-console/php-console": "^3.1.3",
"phpspec/prophecy": "^1.15", "phpspec/prophecy": "^1.15",
"phpstan/phpstan": "^0.12.91", "phpstan/phpstan": "^0.12.91",
"phpunit/phpunit": "^8.5.14", "phpunit/phpunit": "^8.5.14",
"predis/predis": "^1.1", "predis/predis": "^1.1 || ^2.0",
"rollbar/rollbar": "^1.3 || ^2 || ^3", "rollbar/rollbar": "^1.3 || ^2 || ^3",
"ruflin/elastica": "^7", "ruflin/elastica": "^7",
"swiftmailer/swiftmailer": "^5.3|^6.0", "swiftmailer/swiftmailer": "^5.3|^6.0",
@@ -3356,7 +3355,6 @@
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar", "rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server" "ruflin/elastica": "Allow sending log messages to an Elastic Search server"
}, },
@@ -3391,7 +3389,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/Seldaek/monolog/issues", "issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/2.7.0" "source": "https://github.com/Seldaek/monolog/tree/2.8.0"
}, },
"funding": [ "funding": [
{ {
@@ -3403,7 +3401,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-06-09T08:59:12+00:00" "time": "2022-07-24T11:55:47+00:00"
}, },
{ {
"name": "nesbot/carbon", "name": "nesbot/carbon",