Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix audit log entries and fix #7677
James Cole1278f92355ae
diff --git a/app/Handlers/Events/AuditEventHandler.php b/app/Handlers/Events/AuditEventHandler.phpindex b5a0471aff..a0edd222bd 100644--- a/app/Handlers/Events/AuditEventHandler.php+++ b/app/Handlers/Events/AuditEventHandler.php@@ -24,16 +24,21 @@ declare(strict_types=1);namespace FireflyIII\Handlers\Events;+use Carbon\Carbon;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Repositories\AuditLogEntry\ALERepositoryInterface;+/**+ * Class AuditEventHandler+ */class AuditEventHandler{/**- * @param TriggeredAuditLog $event+ * @param TriggeredAuditLog $event+ ** @return void*/- public function storeAuditEvent(TriggeredAuditLog $event)+ public function storeAuditEvent(TriggeredAuditLog $event): void{$array = ['auditable' => $event->auditable,@@ -42,6 +47,24 @@ class AuditEventHandler'before' => $event->before,'after' => $event->after,];++ if ($event->before === $event->after) {+ app('log')->debug('Will not store event log because before and after are the same.');++ return;+ }+ if ($event->before instanceof Carbon && $event->after instanceof Carbon && $event->before->eq($event->after)) {+ app('log')->debug('Will not store event log because before and after Carbon values are the same.');++ return;+ }+ if ($event->before instanceof Carbon && $event->after instanceof Carbon) {+ $array['before'] = $event->before->toIso8601String();+ $array['after'] = $event->after->toIso8601String();+ app('log')->debug(sprintf('Converted "before" to "%s".', $event->before));+ app('log')->debug(sprintf('Converted "after" to "%s".', $event->after));+ }+/** @var ALERepositoryInterface $repository */$repository = app(ALERepositoryInterface::class);$repository->store($array);diff --git a/app/Http/Controllers/Transaction/ShowController.php b/app/Http/Controllers/Transaction/ShowController.phpindex bb182c7d10..870d871347 100644--- a/app/Http/Controllers/Transaction/ShowController.php+++ b/app/Http/Controllers/Transaction/ShowController.php@@ -66,7 +66,7 @@ class ShowController extends Controller}/**- * @param TransactionGroup $transactionGroup+ * @param TransactionGroup $transactionGroup** @return JsonResponse*/@@ -76,8 +76,8 @@ class ShowController extends Controller}/**- * @param Request $request- * @param TransactionGroup $transactionGroup+ * @param Request $request+ * @param TransactionGroup $transactionGroup** @return Factory|View* @throws FireflyException@@ -106,11 +106,14 @@ class ShowController extends Controller$accounts = $this->getAccounts($groupArray);foreach ($groupArray['transactions'] as $index => $transaction) {- $groupArray['transactions'][$index]['tags'] = $this->repository->getTagObjects($groupArray['transactions'][$index]['transaction_journal_id']);+ $groupArray['transactions'][$index]['tags'] = $this->repository->getTagObjects(+ $groupArray['transactions'][$index]['transaction_journal_id']+ );}// get audit log entries:- $logEntries = [];+ $groupLogEntries = $this->aleRepository->getForObject($transactionGroup);+ $logEntries = [];foreach ($transactionGroup->transactionJournals as $journal) {$logEntries[$journal->id] = $this->aleRepository->getForObject($journal);}@@ -128,6 +131,7 @@ class ShowController extends Controller'first','type','logEntries',+ 'groupLogEntries','subTitle','splits','groupArray',@@ -140,37 +144,7 @@ class ShowController extends Controller}/**- * @param array $group- *- * @return array- */- private function getAccounts(array $group): array- {- $accounts = [];-- foreach ($group['transactions'] as $transaction) {- $accounts['source'][] = [- 'type' => $transaction['source_type'],- 'id' => $transaction['source_id'],- 'name' => $transaction['source_name'],- 'iban' => $transaction['source_iban'],- ];- $accounts['destination'][] = [- 'type' => $transaction['destination_type'],- 'id' => $transaction['destination_id'],- 'name' => $transaction['destination_name'],- 'iban' => $transaction['destination_iban'],- ];- }-- $accounts['source'] = array_unique($accounts['source'], SORT_REGULAR);- $accounts['destination'] = array_unique($accounts['destination'], SORT_REGULAR);-- return $accounts;- }-- /**- * @param array $group+ * @param array $group** @return array*/@@ -187,7 +161,11 @@ class ShowController extends Controller];}$amounts[$symbol]['amount'] = bcadd($amounts[$symbol]['amount'], $transaction['amount']);- if (null !== $transaction['foreign_amount'] && '' !== $transaction['foreign_amount'] && bccomp('0', $transaction['foreign_amount']) !== 0) {+ if (null !== $transaction['foreign_amount'] && '' !== $transaction['foreign_amount']+ && bccomp(+ '0',+ $transaction['foreign_amount']+ ) !== 0) {// same for foreign currency:$foreignSymbol = $transaction['foreign_currency_symbol'];if (!array_key_exists($foreignSymbol, $amounts)) {@@ -197,10 +175,43 @@ class ShowController extends Controller'decimal_places' => $transaction['foreign_currency_decimal_places'],];}- $amounts[$foreignSymbol]['amount'] = bcadd($amounts[$foreignSymbol]['amount'], $transaction['foreign_amount']);+ $amounts[$foreignSymbol]['amount'] = bcadd(+ $amounts[$foreignSymbol]['amount'],+ $transaction['foreign_amount']+ );}}return $amounts;}++ /**+ * @param array $group+ *+ * @return array+ */+ private function getAccounts(array $group): array+ {+ $accounts = [];++ foreach ($group['transactions'] as $transaction) {+ $accounts['source'][] = [+ 'type' => $transaction['source_type'],+ 'id' => $transaction['source_id'],+ 'name' => $transaction['source_name'],+ 'iban' => $transaction['source_iban'],+ ];+ $accounts['destination'][] = [+ 'type' => $transaction['destination_type'],+ 'id' => $transaction['destination_id'],+ 'name' => $transaction['destination_name'],+ 'iban' => $transaction['destination_iban'],+ ];+ }++ $accounts['source'] = array_unique($accounts['source'], SORT_REGULAR);+ $accounts['destination'] = array_unique($accounts['destination'], SORT_REGULAR);++ return $accounts;+ }}diff --git a/app/Services/Internal/Update/GroupUpdateService.php b/app/Services/Internal/Update/GroupUpdateService.phpindex ea3c4d9657..acbcba9d09 100644--- a/app/Services/Internal/Update/GroupUpdateService.php+++ b/app/Services/Internal/Update/GroupUpdateService.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Services\Internal\Update;+use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Exceptions\DuplicateTransactionException;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Factory\TransactionJournalFactory;@@ -40,8 +41,8 @@ class GroupUpdateService/*** Update a transaction group.*- * @param TransactionGroup $transactionGroup- * @param array $data+ * @param TransactionGroup $transactionGroup+ * @param array $data** @return TransactionGroup* @throws DuplicateTransactionException@@ -56,8 +57,18 @@ class GroupUpdateService// update group name.if (array_key_exists('group_title', $data)) {Log::debug(sprintf('Update transaction group #%d title.', $transactionGroup->id));+ $oldTitle = $transactionGroup->title;$transactionGroup->title = $data['group_title'];$transactionGroup->save();+ event(+ new TriggeredAuditLog(+ $transactionGroup->user,+ $transactionGroup,+ 'update_group_title',+ $oldTitle,+ $data['group_title']+ )+ );}@@ -70,7 +81,9 @@ class GroupUpdateServiceif (1 === count($transactions) && 1 === $transactionGroup->transactionJournals()->count()) {/** @var TransactionJournal $first */$first = $transactionGroup->transactionJournals()->first();- Log::debug(sprintf('Will now update journal #%d (only journal in group #%d)', $first->id, $transactionGroup->id));+ Log::debug(+ sprintf('Will now update journal #%d (only journal in group #%d)', $first->id, $transactionGroup->id)+ );$this->updateTransactionJournal($transactionGroup, $first, reset($transactions));$transactionGroup->refresh();app('preferences')->mark();@@ -88,6 +101,7 @@ class GroupUpdateServiceLog::error('There were no transactions updated or created. Will not delete anything.');$transactionGroup->refresh();app('preferences')->mark();+return $transactionGroup;}@@ -111,8 +125,8 @@ class GroupUpdateService}/**- * @param TransactionGroup $transactionGroup- * @param array $data+ * @param TransactionGroup $transactionGroup+ * @param array $data** @return TransactionJournal|null*@@ -135,7 +149,11 @@ class GroupUpdateService} catch (FireflyException $e) {Log::error($e->getMessage());Log::error($e->getTraceAsString());- throw new FireflyException(sprintf('Could not create new transaction journal: %s', $e->getMessage()), 0, $e);+ throw new FireflyException(+ sprintf('Could not create new transaction journal: %s', $e->getMessage()),+ 0,+ $e+ );}$collection->each(function (TransactionJournal $journal) use ($transactionGroup) {@@ -152,12 +170,15 @@ class GroupUpdateService/*** Update single journal.*- * @param TransactionGroup $transactionGroup- * @param TransactionJournal $journal- * @param array $data+ * @param TransactionGroup $transactionGroup+ * @param TransactionJournal $journal+ * @param array $data*/- private function updateTransactionJournal(TransactionGroup $transactionGroup, TransactionJournal $journal, array $data): void- {+ private function updateTransactionJournal(+ TransactionGroup $transactionGroup,+ TransactionJournal $journal,+ array $data+ ): void {Log::debug(sprintf('Now in %s', __METHOD__));if (0 === count($data)) {return;@@ -174,8 +195,8 @@ class GroupUpdateService}/**- * @param TransactionGroup $transactionGroup- * @param array $transactions+ * @param TransactionGroup $transactionGroup+ * @param array $transactions** @return array* @throws DuplicateTransactionException@@ -188,7 +209,7 @@ class GroupUpdateService// updated or created transaction journals:$updated = [];/**- * @var int $index+ * @var int $index* @var array $transaction*/foreach ($transactions as $index => $transaction) {@@ -203,7 +224,9 @@ class GroupUpdateServiceif (!array_key_exists('type', $transaction)) {Log::debug('No transaction type is indicated.');/** @var TransactionJournal|null $randomJournal */- $randomJournal = $transactionGroup->transactionJournals()->inRandomOrder()->with(['transactionType'])->first();+ $randomJournal = $transactionGroup->transactionJournals()->inRandomOrder()->with(+ ['transactionType']+ )->first();if (null !== $randomJournal) {$transaction['type'] = $randomJournal->transactionType->type;Log::debug(sprintf('Transaction type set to %s.', $transaction['type']));diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.phpindex 4203783627..90c37cf052 100644--- a/app/Services/Internal/Update/JournalUpdateService.php+++ b/app/Services/Internal/Update/JournalUpdateService.php@@ -25,6 +25,7 @@ namespace FireflyIII\Services\Internal\Update;use Carbon\Carbon;use Carbon\Exceptions\InvalidDateException;+use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Factory\TagFactory;use FireflyIII\Factory\TransactionJournalMetaFactory;@@ -97,11 +98,12 @@ class JournalUpdateService'external_id','external_url',];- $this->metaDate = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date',];+ $this->metaDate = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date',+ 'invoice_date',];}/**- * @param array $data+ * @param array $data*/public function setData(array $data): void{@@ -109,7 +111,7 @@ class JournalUpdateService}/**- * @param TransactionGroup $transactionGroup+ * @param TransactionGroup $transactionGroup*/public function setTransactionGroup(TransactionGroup $transactionGroup): void{@@ -126,7 +128,7 @@ class JournalUpdateService}/**- * @param TransactionJournal $transactionJournal+ * @param TransactionJournal $transactionJournal*/public function setTransactionJournal(TransactionJournal $transactionJournal): void{@@ -181,76 +183,49 @@ class JournalUpdateService}/**- * @return bool+ * Get destination transaction.+ *+ * @return Transaction*/- private function removeReconciliation(): bool+ private function getDestinationTransaction(): Transaction{- if (count($this->data) > 1) {- return true;- }- if (1 === count($this->data) && true === array_key_exists('transaction_journal_id', $this->data)) {- return true;+ if (null === $this->destinationTransaction) {+ $this->destinationTransaction = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();}- return false;- }-- /**- * @return bool- */- private function hasValidAccounts(): bool- {- return $this->hasValidSourceAccount() && $this->hasValidDestinationAccount();+ return $this->destinationTransaction;}/**- * @return bool+ * This method returns the current or expected type of the journal (in case of a change) based on the data in the+ * array.+ *+ * If the array contains key 'type' and the value is correct, this is returned. Otherwise, the original type is+ * returned.+ *+ * @return string*/- private function hasValidSourceAccount(): bool+ private function getExpectedType(): string{- Log::debug('Now in hasValidSourceAccount().');- $sourceId = $this->data['source_id'] ?? null;- $sourceName = $this->data['source_name'] ?? null;-- if (!$this->hasFields(['source_id', 'source_name'])) {- $origSourceAccount = $this->getOriginalSourceAccount();- $sourceId = $origSourceAccount->id;- $sourceName = $origSourceAccount->name;+ Log::debug('Now in getExpectedType()');+ if ($this->hasFields(['type'])) {+ return ucfirst('opening-balance' === $this->data['type'] ? 'opening balance' : $this->data['type']);}- // make new account validator.- $expectedType = $this->getExpectedType();- Log::debug(sprintf('Expected type (new or unchanged) is %s', $expectedType));-- // make a new validator.- /** @var AccountValidator $validator */- $validator = app(AccountValidator::class);- $validator->setTransactionType($expectedType);- $validator->setUser($this->transactionJournal->user);-- $result = $validator->validateSource(['id' => $sourceId]);- Log::debug(sprintf('hasValidSourceAccount(%d, "%s") will return %s', $sourceId, $sourceName, var_export($result, true)));-- // TODO typeoverrule the account validator may have a different opinion on the transaction type.-- // validate submitted info:- return $result;+ return $this->transactionJournal->transactionType->type;}/**- * @param array $fields- *- * @return bool+ * @return Account*/- private function hasFields(array $fields): bool+ private function getOriginalDestinationAccount(): Account{- foreach ($fields as $field) {- if (array_key_exists($field, $this->data)) {- return true;- }+ if (null === $this->destinationAccount) {+ $destination = $this->getDestinationTransaction();+ $this->destinationAccount = $destination->account;}- return false;+ return $this->destinationAccount;}/**@@ -272,7 +247,11 @@ class JournalUpdateServiceprivate function getSourceTransaction(): Transaction{if (null === $this->sourceTransaction) {- $this->sourceTransaction = $this->transactionJournal->transactions()->with(['account'])->where('amount', '<', 0)->first();+ $this->sourceTransaction = $this->transactionJournal->transactions()->with(['account'])->where(+ 'amount',+ '<',+ 0+ )->first();}Log::debug(sprintf('getSourceTransaction: %s', $this->sourceTransaction->amount));@@ -280,20 +259,96 @@ class JournalUpdateService}/**- * This method returns the current or expected type of the journal (in case of a change) based on the data in the array.+ * Does a validation and returns the destination account. This method will break if the dest isn't really valid.*- * If the array contains key 'type' and the value is correct, this is returned. Otherwise, the original type is returned.+ * @return Account+ */+ private function getValidDestinationAccount(): Account+ {+ Log::debug('Now in getValidDestinationAccount().');++ if (!$this->hasFields(['destination_id', 'destination_name'])) {+ return $this->getOriginalDestinationAccount();+ }++ $destInfo = [+ 'id' => (int)($this->data['destination_id'] ?? null),+ 'name' => $this->data['destination_name'] ?? null,+ 'iban' => $this->data['destination_iban'] ?? null,+ 'number' => $this->data['destination_number'] ?? null,+ 'bic' => $this->data['destination_bic'] ?? null,+ ];++ // make new account validator.+ $expectedType = $this->getExpectedType();+ Log::debug(sprintf('Expected type (new or unchanged) is %s', $expectedType));+ try {+ $result = $this->getAccount($expectedType, 'destination', $destInfo);+ } catch (FireflyException $e) {+ Log::error(sprintf('getValidDestinationAccount() threw unexpected error: %s', $e->getMessage()));+ $result = $this->getOriginalDestinationAccount();+ }++ return $result;+ }++ /**+ * Does a validation and returns the source account. This method will break if the source isn't really valid.*- * @return string+ * @return Account*/- private function getExpectedType(): string+ private function getValidSourceAccount(): Account{- Log::debug('Now in getExpectedType()');- if ($this->hasFields(['type'])) {- return ucfirst('opening-balance' === $this->data['type'] ? 'opening balance' : $this->data['type']);+ Log::debug('Now in getValidSourceAccount().');++ if (!$this->hasFields(['source_id', 'source_name'])) {+ return $this->getOriginalSourceAccount();}- return $this->transactionJournal->transactionType->type;+ $sourceInfo = [+ 'id' => (int)($this->data['source_id'] ?? null),+ 'name' => $this->data['source_name'] ?? null,+ 'iban' => $this->data['source_iban'] ?? null,+ 'number' => $this->data['source_number'] ?? null,+ 'bic' => $this->data['source_bic'] ?? null,+ ];++ $expectedType = $this->getExpectedType();+ try {+ $result = $this->getAccount($expectedType, 'source', $sourceInfo);+ } catch (FireflyException $e) {+ Log::error(sprintf('Cant get the valid source account: %s', $e->getMessage()));++ $result = $this->getOriginalSourceAccount();+ }++ Log::debug(sprintf('getValidSourceAccount() will return #%d ("%s")', $result->id, $result->name));++ return $result;+ }++ /**+ * @param array $fields+ *+ * @return bool+ */+ private function hasFields(array $fields): bool+ {+ foreach ($fields as $field) {+ if (array_key_exists($field, $this->data)) {+ return true;+ }+ }++ return false;+ }++ /**+ * @return bool+ */+ private function hasValidAccounts(): bool+ {+ return $this->hasValidSourceAccount() && $this->hasValidDestinationAccount();}/**@@ -323,7 +378,14 @@ class JournalUpdateService$validator->setUser($this->transactionJournal->user);$validator->source = $this->getValidSourceAccount();$result = $validator->validateDestination(['id' => $destId, 'name' => $destName]);- Log::debug(sprintf('hasValidDestinationAccount(%d, "%s") will return %s', $destId, $destName, var_export($result, true)));+ Log::debug(+ sprintf(+ 'hasValidDestinationAccount(%d, "%s") will return %s',+ $destId,+ $destName,+ var_export($result, true)+ )+ );// TODO typeOverrule: the account validator may have another opinion on the transaction type.@@ -332,65 +394,54 @@ class JournalUpdateService}/**- * @return Account+ * @return bool*/- private function getOriginalDestinationAccount(): Account+ private function hasValidSourceAccount(): bool{- if (null === $this->destinationAccount) {- $destination = $this->getDestinationTransaction();- $this->destinationAccount = $destination->account;+ Log::debug('Now in hasValidSourceAccount().');+ $sourceId = $this->data['source_id'] ?? null;+ $sourceName = $this->data['source_name'] ?? null;++ if (!$this->hasFields(['source_id', 'source_name'])) {+ $origSourceAccount = $this->getOriginalSourceAccount();+ $sourceId = $origSourceAccount->id;+ $sourceName = $origSourceAccount->name;}- return $this->destinationAccount;- }+ // make new account validator.+ $expectedType = $this->getExpectedType();+ Log::debug(sprintf('Expected type (new or unchanged) is %s', $expectedType));- /**- * Get destination transaction.- *- * @return Transaction- */- private function getDestinationTransaction(): Transaction- {- if (null === $this->destinationTransaction) {- $this->destinationTransaction = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();- }+ // make a new validator.+ /** @var AccountValidator $validator */+ $validator = app(AccountValidator::class);+ $validator->setTransactionType($expectedType);+ $validator->setUser($this->transactionJournal->user);- return $this->destinationTransaction;+ $result = $validator->validateSource(['id' => $sourceId]);+ Log::debug(+ sprintf('hasValidSourceAccount(%d, "%s") will return %s', $sourceId, $sourceName, var_export($result, true))+ );++ // TODO typeoverrule the account validator may have a different opinion on the transaction type.++ // validate submitted info:+ return $result;}/**- * Does a validation and returns the source account. This method will break if the source isn't really valid.- *- * @return Account+ * @return bool*/- private function getValidSourceAccount(): Account+ private function removeReconciliation(): bool{- Log::debug('Now in getValidSourceAccount().');-- if (!$this->hasFields(['source_id', 'source_name'])) {- return $this->getOriginalSourceAccount();+ if (count($this->data) > 1) {+ return true;}-- $sourceInfo = [- 'id' => (int)($this->data['source_id'] ?? null),- 'name' => $this->data['source_name'] ?? null,- 'iban' => $this->data['source_iban'] ?? null,- 'number' => $this->data['source_number'] ?? null,- 'bic' => $this->data['source_bic'] ?? null,- ];-- $expectedType = $this->getExpectedType();- try {- $result = $this->getAccount($expectedType, 'source', $sourceInfo);- } catch (FireflyException $e) {- Log::error(sprintf('Cant get the valid source account: %s', $e->getMessage()));-- $result = $this->getOriginalSourceAccount();+ if (1 === count($this->data) && true === array_key_exists('transaction_journal_id', $this->data)) {+ return true;}- Log::debug(sprintf('getValidSourceAccount() will return #%d ("%s")', $result->id, $result->name));-- return $result;+ return false;}/**@@ -424,70 +475,34 @@ class JournalUpdateService}/**- * Does a validation and returns the destination account. This method will break if the dest isn't really valid.*- * @return Account*/- private function getValidDestinationAccount(): Account+ private function updateAmount(): void{- Log::debug('Now in getValidDestinationAccount().');-- if (!$this->hasFields(['destination_id', 'destination_name'])) {- return $this->getOriginalDestinationAccount();+ Log::debug(sprintf('Now in %s', __METHOD__));+ if (!$this->hasFields(['amount'])) {+ return;}- $destInfo = [- 'id' => (int)($this->data['destination_id'] ?? null),- 'name' => $this->data['destination_name'] ?? null,- 'iban' => $this->data['destination_iban'] ?? null,- 'number' => $this->data['destination_number'] ?? null,- 'bic' => $this->data['destination_bic'] ?? null,- ];-- // make new account validator.- $expectedType = $this->getExpectedType();- Log::debug(sprintf('Expected type (new or unchanged) is %s', $expectedType));+ $value = $this->data['amount'] ?? '';+ Log::debug(sprintf('Amount is now "%s"', $value));try {- $result = $this->getAccount($expectedType, 'destination', $destInfo);+ $amount = $this->getAmount($value);} catch (FireflyException $e) {- Log::error(sprintf('getValidDestinationAccount() threw unexpected error: %s', $e->getMessage()));- $result = $this->getOriginalDestinationAccount();- }-- return $result;- }-- /**- * Updates journal transaction type.- */- private function updateType(): void- {- Log::debug('Now in updateType()');- if ($this->hasFields(['type'])) {- $type = 'opening-balance' === $this->data['type'] ? 'opening balance' : $this->data['type'];- Log::debug(- sprintf(- 'Trying to change journal #%d from a %s to a %s.',- $this->transactionJournal->id,- $this->transactionJournal->transactionType->type,- $type- )- );-- /** @var TransactionTypeFactory $typeFactory */- $typeFactory = app(TransactionTypeFactory::class);- $result = $typeFactory->find($this->data['type']);- if (null !== $result) {- Log::debug('Changed transaction type!');- $this->transactionJournal->transaction_type_id = $result->id;- $this->transactionJournal->save();-- return;- }+ Log::debug(sprintf('getAmount("%s") returns error: %s', $value, $e->getMessage()));return;}- Log::debug('No type field present.');+ $origSourceTransaction = $this->getSourceTransaction();+ $origSourceTransaction->amount = app('steam')->negative($amount);+ $origSourceTransaction->save();+ $destTransaction = $this->getDestinationTransaction();+ $destTransaction->amount = app('steam')->positive($amount);+ $destTransaction->save();+ // refresh transactions.+ $this->sourceTransaction->refresh();+ $this->destinationTransaction->refresh();+ Log::debug(sprintf('Updated amount to "%s"', $amount));}/**@@ -511,28 +526,18 @@ class JournalUpdateService}/**- * Update journal generic field. Cannot be set to NULL.*- * @param string $fieldName*/- private function updateField(string $fieldName): void+ private function updateBudget(): void{- if (array_key_exists($fieldName, $this->data) && '' !== (string)$this->data[$fieldName]) {- $value = $this->data[$fieldName];-- if ('date' === $fieldName) {- if ($value instanceof Carbon) {- // update timezone.- $value->setTimezone(config('app.timezone'));- }- if (!($value instanceof Carbon)) {- $value = new Carbon($value);- }- // do some parsing.- Log::debug(sprintf('Create date value from string "%s".', $value));- }- $this->transactionJournal->$fieldName = $value;- Log::debug(sprintf('Updated %s', $fieldName));+ // update budget+ if ($this->hasFields(['budget_id', 'budget_name'])) {+ Log::debug('Will update budget.');+ $this->storeBudget($this->transactionJournal, new NullArrayObject($this->data));+ }+ // is transfer? remove budget+ if (TransactionType::TRANSFER === $this->transactionJournal->transactionType->type) {+ $this->transactionJournal->budgets()->sync([]);}}@@ -552,51 +557,139 @@ class JournalUpdateService/****/- private function updateBudget(): void+ private function updateCurrency(): void{- // update budget- if ($this->hasFields(['budget_id', 'budget_name'])) {- Log::debug('Will update budget.');- $this->storeBudget($this->transactionJournal, new NullArrayObject($this->data));+ // update transactions.+ if (!$this->hasFields(['currency_id', 'currency_code'])) {+ return;}- // is transfer? remove budget- if (TransactionType::TRANSFER === $this->transactionJournal->transactionType->type) {- $this->transactionJournal->budgets()->sync([]);+ $currencyId = $this->data['currency_id'] ?? null;+ $currencyCode = $this->data['currency_code'] ?? null;+ $currency = $this->currencyRepository->findCurrency($currencyId, $currencyCode);+ if (null !== $currency) {+ // update currency everywhere.+ $this->transactionJournal->transaction_currency_id = $currency->id;+ $this->transactionJournal->save();++ $source = $this->getSourceTransaction();+ $source->transaction_currency_id = $currency->id;+ $source->save();++ $dest = $this->getDestinationTransaction();+ $dest->transaction_currency_id = $currency->id;+ $dest->save();++ // refresh transactions.+ $this->sourceTransaction->refresh();+ $this->destinationTransaction->refresh();+ Log::debug(sprintf('Updated currency to #%d (%s)', $currency->id, $currency->code));}}/**+ * Update journal generic field. Cannot be set to NULL.*+ * @param string $fieldName*/- private function updateTags(): void+ private function updateField(string $fieldName): void{- if ($this->hasFields(['tags'])) {- Log::debug('Will update tags.');- $tags = $this->data['tags'] ?? null;- $this->storeTags($this->transactionJournal, $tags);+ if (array_key_exists($fieldName, $this->data) && '' !== (string)$this->data[$fieldName]) {+ $value = $this->data[$fieldName];++ if ('date' === $fieldName) {+ if ($value instanceof Carbon) {+ // update timezone.+ $value->setTimezone(config('app.timezone'));+ }+ if (!($value instanceof Carbon)) {+ $value = new Carbon($value);+ }+ // do some parsing.+ Log::debug(sprintf('Create date value from string "%s".', $value));+ }+ event(+ new TriggeredAuditLog(+ $this->transactionJournal->user,+ $this->transactionJournal,+ sprintf('update_%s', $fieldName),+ $this->transactionJournal->$fieldName,+ $value+ )+ );++ $this->transactionJournal->$fieldName = $value;+ Log::debug(sprintf('Updated %s', $fieldName));}}/****/- private function updateReconciled(): void+ private function updateForeignAmount(): void{- if (array_key_exists('reconciled', $this->data) && is_bool($this->data['reconciled'])) {- $this->transactionJournal->transactions()->update(['reconciled' => $this->data['reconciled']]);+ // amount, foreign currency.+ if (!$this->hasFields(['foreign_currency_id', 'foreign_currency_code', 'foreign_amount'])) {+ return;}- }- /**- *- */- private function updateNotes(): void- {- // update notes.- if ($this->hasFields(['notes'])) {- $notes = '' === (string)$this->data['notes'] ? null : $this->data['notes'];- $this->storeNotes($this->transactionJournal, $notes);+ $amount = $this->data['foreign_amount'] ?? null;+ $foreignAmount = $this->getForeignAmount($amount);+ $source = $this->getSourceTransaction();+ $dest = $this->getDestinationTransaction();+ $foreignCurrency = $source->foreignCurrency;++ // find currency in data array+ $newForeignId = $this->data['foreign_currency_id'] ?? null;+ $newForeignCode = $this->data['foreign_currency_code'] ?? null;+ $foreignCurrency = $this->currencyRepository->findCurrencyNull($newForeignId, $newForeignCode) ??+ $foreignCurrency;++ // not the same as normal currency+ if (null !== $foreignCurrency && $foreignCurrency->id === $this->transactionJournal->transaction_currency_id) {+ Log::error(sprintf('Foreign currency is equal to normal currency (%s)', $foreignCurrency->code));++ return;+ }++ // add foreign currency info to source and destination if possible.+ if (null !== $foreignCurrency && null !== $foreignAmount) {+ $source->foreign_currency_id = $foreignCurrency->id;+ $source->foreign_amount = app('steam')->negative($foreignAmount);+ $source->save();+ $dest->foreign_currency_id = $foreignCurrency->id;+ $dest->foreign_amount = app('steam')->positive($foreignAmount);+ $dest->save();++ Log::debug(+ sprintf(+ 'Update foreign info to %s (#%d) %s',+ $foreignCurrency->code,+ $foreignCurrency->id,+ $foreignAmount+ )+ );++ // refresh transactions.+ $this->sourceTransaction->refresh();+ $this->destinationTransaction->refresh();++ return;}+ if ('0' === $amount) {+ $source->foreign_currency_id = null;+ $source->foreign_amount = null;+ $source->save();++ $dest->foreign_currency_id = null;+ $dest->foreign_amount = null;+ $dest->save();+ Log::debug(sprintf('Foreign amount is "%s" so remove foreign amount info.', $amount));+ }+ Log::info('Not enough info to update foreign currency info.');++ // refresh transactions.+ $this->sourceTransaction->refresh();+ $this->destinationTransaction->refresh();}/**@@ -621,14 +714,20 @@ class JournalUpdateService/****/- private function updateMetaFields(): void+ private function updateMetaDateFields(): void{/** @var TransactionJournalMetaFactory $factory */$factory = app(TransactionJournalMetaFactory::class);- foreach ($this->metaString as $field) {+ foreach ($this->metaDate as $field) {if ($this->hasFields([$field])) {- $value = '' === $this->data[$field] ? null : $this->data[$field];+ try {+ $value = '' === (string)$this->data[$field] ? null : new Carbon($this->data[$field]);+ } catch (InvalidDateException $e) {+ Log::debug(sprintf('%s is not a valid date value: %s', $this->data[$field], $e->getMessage()));++ return;+ }Log::debug(sprintf('Field "%s" is present ("%s"), try to update it.', $field, $value));$set = ['journal' => $this->transactionJournal,@@ -643,19 +742,14 @@ class JournalUpdateService/****/- private function updateMetaDateFields(): void+ private function updateMetaFields(): void{/** @var TransactionJournalMetaFactory $factory */$factory = app(TransactionJournalMetaFactory::class);- foreach ($this->metaDate as $field) {+ foreach ($this->metaString as $field) {if ($this->hasFields([$field])) {- try {- $value = '' === (string)$this->data[$field] ? null : new Carbon($this->data[$field]);- } catch (InvalidDateException $e) {- Log::debug(sprintf('%s is not a valid date value: %s', $this->data[$field], $e->getMessage()));- return;- }+ $value = '' === $this->data[$field] ? null : $this->data[$field];Log::debug(sprintf('Field "%s" is present ("%s"), try to update it.', $field, $value));$set = ['journal' => $this->transactionJournal,@@ -670,125 +764,67 @@ class JournalUpdateService/****/- private function updateCurrency(): void+ private function updateNotes(): void{- // update transactions.- if (!$this->hasFields(['currency_id', 'currency_code'])) {- return;- }- $currencyId = $this->data['currency_id'] ?? null;- $currencyCode = $this->data['currency_code'] ?? null;- $currency = $this->currencyRepository->findCurrency($currencyId, $currencyCode);- if (null !== $currency) {- // update currency everywhere.- $this->transactionJournal->transaction_currency_id = $currency->id;- $this->transactionJournal->save();-- $source = $this->getSourceTransaction();- $source->transaction_currency_id = $currency->id;- $source->save();-- $dest = $this->getDestinationTransaction();- $dest->transaction_currency_id = $currency->id;- $dest->save();-- // refresh transactions.- $this->sourceTransaction->refresh();- $this->destinationTransaction->refresh();- Log::debug(sprintf('Updated currency to #%d (%s)', $currency->id, $currency->code));+ // update notes.+ if ($this->hasFields(['notes'])) {+ $notes = '' === (string)$this->data['notes'] ? null : $this->data['notes'];+ $this->storeNotes($this->transactionJournal, $notes);}}/****/- private function updateAmount(): void+ private function updateReconciled(): void{- Log::debug(sprintf('Now in %s', __METHOD__));- if (!$this->hasFields(['amount'])) {- return;- }-- $value = $this->data['amount'] ?? '';- Log::debug(sprintf('Amount is now "%s"', $value));- try {- $amount = $this->getAmount($value);- } catch (FireflyException $e) {- Log::debug(sprintf('getAmount("%s") returns error: %s', $value, $e->getMessage()));-- return;+ if (array_key_exists('reconciled', $this->data) && is_bool($this->data['reconciled'])) {+ $this->transactionJournal->transactions()->update(['reconciled' => $this->data['reconciled']]);}- $origSourceTransaction = $this->getSourceTransaction();- $origSourceTransaction->amount = app('steam')->negative($amount);- $origSourceTransaction->save();- $destTransaction = $this->getDestinationTransaction();- $destTransaction->amount = app('steam')->positive($amount);- $destTransaction->save();- // refresh transactions.- $this->sourceTransaction->refresh();- $this->destinationTransaction->refresh();- Log::debug(sprintf('Updated amount to "%s"', $amount));}/****/- private function updateForeignAmount(): void+ private function updateTags(): void{- // amount, foreign currency.- if (!$this->hasFields(['foreign_currency_id', 'foreign_currency_code', 'foreign_amount'])) {- return;- }-- $amount = $this->data['foreign_amount'] ?? null;- $foreignAmount = $this->getForeignAmount($amount);- $source = $this->getSourceTransaction();- $dest = $this->getDestinationTransaction();- $foreignCurrency = $source->foreignCurrency;-- // find currency in data array- $newForeignId = $this->data['foreign_currency_id'] ?? null;- $newForeignCode = $this->data['foreign_currency_code'] ?? null;- $foreignCurrency = $this->currencyRepository->findCurrencyNull($newForeignId, $newForeignCode) ?? $foreignCurrency;-- // not the same as normal currency- if (null !== $foreignCurrency && $foreignCurrency->id === $this->transactionJournal->transaction_currency_id) {- Log::error(sprintf('Foreign currency is equal to normal currency (%s)', $foreignCurrency->code));-- return;+ if ($this->hasFields(['tags'])) {+ Log::debug('Will update tags.');+ $tags = $this->data['tags'] ?? null;+ $this->storeTags($this->transactionJournal, $tags);}+ }- // add foreign currency info to source and destination if possible.- if (null !== $foreignCurrency && null !== $foreignAmount) {- $source->foreign_currency_id = $foreignCurrency->id;- $source->foreign_amount = app('steam')->negative($foreignAmount);- $source->save();- $dest->foreign_currency_id = $foreignCurrency->id;- $dest->foreign_amount = app('steam')->positive($foreignAmount);- $dest->save();+ /**+ * Updates journal transaction type.+ */+ private function updateType(): void+ {+ Log::debug('Now in updateType()');+ if ($this->hasFields(['type'])) {+ $type = 'opening-balance' === $this->data['type'] ? 'opening balance' : $this->data['type'];+ Log::debug(+ sprintf(+ 'Trying to change journal #%d from a %s to a %s.',+ $this->transactionJournal->id,+ $this->transactionJournal->transactionType->type,+ $type+ )+ );- Log::debug(sprintf('Update foreign info to %s (#%d) %s', $foreignCurrency->code, $foreignCurrency->id, $foreignAmount));+ /** @var TransactionTypeFactory $typeFactory */+ $typeFactory = app(TransactionTypeFactory::class);+ $result = $typeFactory->find($this->data['type']);+ if (null !== $result) {+ Log::debug('Changed transaction type!');+ $this->transactionJournal->transaction_type_id = $result->id;+ $this->transactionJournal->save();- // refresh transactions.- $this->sourceTransaction->refresh();- $this->destinationTransaction->refresh();+ return;+ }return;}- if ('0' === $amount) {- $source->foreign_currency_id = null;- $source->foreign_amount = null;- $source->save();-- $dest->foreign_currency_id = null;- $dest->foreign_amount = null;- $dest->save();- Log::debug(sprintf('Foreign amount is "%s" so remove foreign amount info.', $amount));- }- Log::info('Not enough info to update foreign currency info.');-- // refresh transactions.- $this->sourceTransaction->refresh();- $this->destinationTransaction->refresh();+ Log::debug('No type field present.');}}diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.phpindex d01c1c5a8c..61b00204dd 100644--- a/app/Support/Twig/General.php+++ b/app/Support/Twig/General.php@@ -109,7 +109,11 @@ class General extends AbstractExtension[, $route, $objectType] = func_get_args();$activeObjectType = $context['objectType'] ?? false;- if ($objectType === $activeObjectType && false !== stripos(Route::getCurrentRoute()->getName(), $route)) {+ if ($objectType === $activeObjectType+ && false !== stripos(+ Route::getCurrentRoute()->getName(),+ $route+ )) {return 'active';}@@ -171,7 +175,7 @@ class General extends AbstractExtensionreturn new TwigFunction('carbonize',static function (string $date): Carbon {- return new Carbon($date);+ return new Carbon($date, config('app.timezone'));});}@@ -205,15 +209,15 @@ class General extends AbstractExtensionstatic function (int $size): string {// less than one GB, more than one MBif ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {- return round($size / (1024 * 1024), 2).' MB';+ return round($size / (1024 * 1024), 2) . ' MB';}// less than one MBif ($size < (1024 * 1024)) {- return round($size / 1024, 2).' KB';+ return round($size / 1024, 2) . ' KB';}- return $size.' bytes';+ return $size . ' bytes';});}@@ -245,6 +249,7 @@ class General extends AbstractExtension'getRootSearchOperator',static function (string $operator): string {$result = OperatorQuerySearch::getRootOperator($operator);+return str_replace('-', 'not_', $result);});diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex d52d72a367..6c838d1dd1 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -2595,6 +2595,9 @@ return ['ale_action_log_add' => 'Added :amount to piggy bank ":name"','ale_action_log_remove' => 'Removed :amount from piggy bank ":name"','ale_action_clear_budget' => 'Removed from budget',+ 'ale_action_update_group_title' => 'Updated transaction group title',+ 'ale_action_update_date' => 'Updated transaction date',+ 'ale_action_update_order' => 'Updated transaction order','ale_action_clear_category' => 'Removed from category','ale_action_clear_notes' => 'Removed notes','ale_action_clear_tag' => 'Cleared tag',diff --git a/resources/views/list/ale.twig b/resources/views/list/ale.twigindex 12263e95e7..3632ec3bd1 100644--- a/resources/views/list/ale.twig+++ b/resources/views/list/ale.twig@@ -4,13 +4,16 @@<th style="width:20%;" scope="row">{# link to object: #}{% if 'FireflyIII\\Models\\Rule' == logEntry.changer_type %}- <a href="{{ route('rules.edit', [logEntry.changer_id] ) }}">- {% endif %}- {{ logEntry.changer_type|replace({"FireflyIII\\Models\\": ""}) }}- #{{ logEntry.changer_id }}+ <a href="{{ route('rules.edit', [logEntry.changer_id] ) }}">+ {% endif %}+ {% if 'FireflyIII\\User' == logEntry.changer_type %}+ <a href="{{ route('profile.index') }}">+ {% endif %}+ {{ logEntry.changer_type|replace({"FireflyIII\\Models\\": ""})|replace({"FireflyIII\\": ""}) }}+ #{{ logEntry.changer_id }}</a></th>- <td style="width:30%;">+ <td style="width:30%;" title="{{ logEntry.created_at.isoFormat(dateTimeFormat) }}">{{ trans('firefly.ale_action_'~logEntry.action) }}</td><td>@@ -18,8 +21,11 @@{% if 'add_tag' == logEntry.action %}<code>{{ logEntry.after }}</code>{% endif %}- {% if 'clear_budget' == logEntry.action %}++ {% if 'update_group_title' == logEntry.action %}<code><s>{{ logEntry.before }}</s></code>+ →+ <code>{{ logEntry.after }}</code>{% endif %}{% if 'clear_category' == logEntry.action %}<code><s>{{ logEntry.before }}</s></code>@@ -51,6 +57,11 @@{% if 'set_destination' == logEntry.action %}<code>{{ logEntry.after }}</code>{% endif %}+ {% if 'update_date' == logEntry.action %}+ <code><s>{{ carbonize(logEntry.before).isoFormat(dateTimeFormat) }}</s></code>+ →+ <code>{{ carbonize(logEntry.after).isoFormat(dateTimeFormat) }}</code>+ {% endif %}{% if 'update_transaction_type' == logEntry.action %}{{ trans('firefly.'~logEntry.before) }} → {{ trans('firefly.'~logEntry.after) }}{% endif %}diff --git a/resources/views/transactions/show.twig b/resources/views/transactions/show.twigindex 645de8ea1d..c72cdd4731 100644--- a/resources/views/transactions/show.twig+++ b/resources/views/transactions/show.twig@@ -11,32 +11,42 @@<div class="box-header with-border"><h3 class="box-title">{{ 'transaction_journal_information'|_ }}</h3><div class="btn-group btn-group-xs pull-right">- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">- {{ 'actions'|_}} <span class="caret"></span>+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"+ aria-haspopup="true" aria-expanded="false">+ {{ 'actions'|_ }} <span class="caret"></span></button><ul class="dropdown-menu">{# edit + delete #}- <li><a href="{{ route('transactions.edit', [transactionGroup.id]) }}"><span class="fa fa-pencil"></span> {{ 'edit'|_ }}</a></li>- <li><a href="{{ route('transactions.delete', [transactionGroup.id]) }}"><span class="fa fa-trash"></span> {{ 'delete'|_ }}</a></li>+ <li><a href="{{ route('transactions.edit', [transactionGroup.id]) }}"><span+ class="fa fa-pencil"></span> {{ 'edit'|_ }}</a></li>+ <li><a href="{{ route('transactions.delete', [transactionGroup.id]) }}"><span+ class="fa fa-trash"></span> {{ 'delete'|_ }}</a></li><li role="separator" class="divider"></li>{# convert to different type #}{% if groupArray.transactions[0].type != 'withdrawal' %}- <li><a href="{{ route('transactions.convert.index', ['withdrawal', transactionGroup.id]) }}"><span class="fa fa-exchange"></span> {{ 'convert_to_withdrawal'|_ }}</a></li>+ <li>+ <a href="{{ route('transactions.convert.index', ['withdrawal', transactionGroup.id]) }}"><span+ class="fa fa-exchange"></span> {{ 'convert_to_withdrawal'|_ }}</a></li>{% endif %}{% if groupArray.transactions[0].type != 'deposit' %}- <li><a href="{{ route('transactions.convert.index', ['deposit', transactionGroup.id]) }}"><span class="fa fa-exchange"></span> {{ 'convert_to_deposit'|_ }}</a></li>+ <li>+ <a href="{{ route('transactions.convert.index', ['deposit', transactionGroup.id]) }}"><span+ class="fa fa-exchange"></span> {{ 'convert_to_deposit'|_ }}</a></li>{% endif %}{% if groupArray.transactions[0].type != 'transfer' %}- <li><a href="{{ route('transactions.convert.index', ['transfer', transactionGroup.id]) }}"><span class="fa fa-exchange"></span> {{ 'convert_to_transfer'|_ }}</a></li>+ <li>+ <a href="{{ route('transactions.convert.index', ['transfer', transactionGroup.id]) }}"><span+ class="fa fa-exchange"></span> {{ 'convert_to_transfer'|_ }}</a></li>{% endif %}{# clone #}{% if groupArray.transactions[0].type != 'opening balance' and groupArray.transactions[0].type != 'reconciliation' %}<li role="separator" class="divider"></li>- <li><a href="#" class="clone-transaction" data-id="{{ transactionGroup.id }}"><span class="fa fa-copy"></span> {{ 'clone'|_ }}</a></li>+ <li><a href="#" class="clone-transaction" data-id="{{ transactionGroup.id }}"><span+ class="fa fa-copy"></span> {{ 'clone'|_ }}</a></li>{% endif %}</ul>@@ -69,6 +79,19 @@</table></div></div>+ {% if groupLogEntries|length > 0 %}+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">+ {{ 'audit_log_entries'|_ }}+ </h3>+ </div>+ <div class="box-body no-padding">+ {% include 'list.ale' with {logEntries: groupLogEntries} %}+ </div>+ </div>+ {% endif %}+</div><div class="col-lg-6"><div class="box box-primary">@@ -183,38 +206,58 @@<div class="btn-group btn-group-xs pull-right">- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">- {{ 'actions'|_}} <span class="caret"></span>+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"+ aria-haspopup="true" aria-expanded="false">+ {{ 'actions'|_ }} <span class="caret"></span></button><ul class="dropdown-menu">{# edit + delete #}- <li><a href="{{ route('transactions.edit', [transactionGroup.id]) }}"><span class="fa fa-pencil"></span> {{ 'edit'|_ }}</a></li>- <li><a href="{{ route('transactions.delete', [transactionGroup.id]) }}"><span class="fa fa-trash"></span> {{ 'delete'|_ }}</a></li>+ <li><a href="{{ route('transactions.edit', [transactionGroup.id]) }}"><span+ class="fa fa-pencil"></span> {{ 'edit'|_ }}</a></li>+ <li><a href="{{ route('transactions.delete', [transactionGroup.id]) }}"><span+ class="fa fa-trash"></span> {{ 'delete'|_ }}</a></li><li role="separator" class="divider"></li>{# convert to different type #}{% if groupArray.transactions[0].type != 'withdrawal' %}- <li><a href="{{ route('transactions.convert.index', ['withdrawal', transactionGroup.id]) }}"><span class="fa fa-exchange"></span> {{ 'convert_to_withdrawal'|_ }}</a></li>+ <li>+ <a href="{{ route('transactions.convert.index', ['withdrawal', transactionGroup.id]) }}"><span+ class="fa fa-exchange"></span> {{ 'convert_to_withdrawal'|_ }}</a>+ </li>{% endif %}{% if groupArray.transactions[0].type != 'deposit' %}- <li><a href="{{ route('transactions.convert.index', ['deposit', transactionGroup.id]) }}"><span class="fa fa-exchange"></span> {{ 'convert_to_deposit'|_ }}</a></li>+ <li>+ <a href="{{ route('transactions.convert.index', ['deposit', transactionGroup.id]) }}"><span+ class="fa fa-exchange"></span> {{ 'convert_to_deposit'|_ }}</a></li>{% endif %}{% if groupArray.transactions[0].type != 'transfer' %}- <li><a href="{{ route('transactions.convert.index', ['transfer', transactionGroup.id]) }}"><span class="fa fa-exchange"></span> {{ 'convert_to_transfer'|_ }}</a></li>+ <li>+ <a href="{{ route('transactions.convert.index', ['transfer', transactionGroup.id]) }}"><span+ class="fa fa-exchange"></span> {{ 'convert_to_transfer'|_ }}</a>+ </li>{% endif %}{# clone #}{% if groupArray.transactions[0].type != 'opening balance' and groupArray.transactions[0].type != 'reconciliation' %}<li role="separator" class="divider"></li>- <li><a href="#" data-id="{{ transactionGroup.id }}" class="clone-transaction"><span class="fa fa-copy"></span> {{ 'clone'|_ }}</a></li>+ <li><a href="#" data-id="{{ transactionGroup.id }}" class="clone-transaction"><span+ class="fa fa-copy"></span> {{ 'clone'|_ }}</a></li>{% endif %}- <li><a href="#" class="link-modal" data-journal="{{ journal.transaction_journal_id }}"><span class="fa fa-fw fa-link"></span>{{ 'link_transaction'|_ }}</a></li>+ <li><a href="#" class="link-modal"+ data-journal="{{ journal.transaction_journal_id }}"><span+ class="fa fa-fw fa-link"></span>{{ 'link_transaction'|_ }}</a></li><li role="separator" class="divider"></li>- <li><a href="{{ route('rules.create-from-journal', [journal.transaction_journal_id]) }}"><span class="fa fa-fw fa-random"></span>{{ 'create_rule_from_transaction'|_ }}</a></li>- <li><a href="{{ route('recurring.create-from-journal', [journal.transaction_journal_id]) }}"><span class="fa fa-fw fa-paint-brush"></span>{{ 'create_recurring_from_transaction'|_ }}</a></li>+ <li>+ <a href="{{ route('rules.create-from-journal', [journal.transaction_journal_id]) }}"><span+ class="fa fa-fw fa-random"></span>{{ 'create_rule_from_transaction'|_ }}+ </a></li>+ <li>+ <a href="{{ route('recurring.create-from-journal', [journal.transaction_journal_id]) }}"><span+ class="fa fa-fw fa-paint-brush"></span>{{ 'create_recurring_from_transaction'|_ }}+ </a></li></ul></div></div>@@ -222,6 +265,7 @@<table class="table"><tr><td colspan="2">+<!-- type is: "{{ first.transactiontype.type }}" -->{% if 'Cash account' == journal.source_type %}<span class="text-success">({{ 'cash'|_ }})</span>@@ -230,8 +274,10 @@title="{{ journal.source_iban|default(journal.source_name) }}">{{ journal.source_name }}</a> →{% endif %}- {% if first.transactiontype.type == 'Withdrawal' or first.transactiontype.type == 'Deposit' %}+ {% if first.transactiontype.type == 'Withdrawal' %}{{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}+ {% elseif first.transactiontype.type == 'Deposit' %}+ {{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places) }}{% elseif first.transactiontype.type == 'Transfer' or first.transactiontype.type == 'Opening balance' %}<span class="text-info money-transfer">{{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places, false) }}@@ -265,19 +311,25 @@{% if null != journal.category_id %}<tr><td style="width:30%;">{{ 'category'|_ }}</td>- <td><a href="{{ route('categories.show', [journal.category_id]) }}">{{ journal.category_name }}</a></td>+ <td>+ <a href="{{ route('categories.show', [journal.category_id]) }}">{{ journal.category_name }}</a>+ </td></tr>{% endif %}{% if null != journal.budget_id and first.transactiontype.type == 'Withdrawal' %}<tr><td style="width:40%;">{{ 'budget'|_ }}</td>- <td><a href="{{ route('budgets.show', [journal.budget_id]) }}">{{ journal.budget_name }}</a></td>+ <td>+ <a href="{{ route('budgets.show', [journal.budget_id]) }}">{{ journal.budget_name }}</a>+ </td></tr>{% endif %}{% if null != journal.bill_id and first.transactiontype.type == 'Withdrawal' %}<tr><td style="width:40%;">{{ 'bill'|_ }}</td>- <td><a href="{{ route('bills.show', [journal.bill_id]) }}">{{ journal.bill_name }}</a></td>+ <td>+ <a href="{{ route('bills.show', [journal.bill_id]) }}">{{ journal.bill_name }}</a>+ </td></tr>{% endif %}<!-- other fields -->@@ -294,7 +346,7 @@<tr><td>{{ trans('list.'~metaField) }}</td><td style="width:40%;">- {% if 'external_url' == metaField %}+ {% if 'external_url' == metaField %}{% set url = journalGetMetaField(journal.transaction_journal_id, metaField) %}<a href="{{ url }}" rel="noopener noreferrer nofollow" target="_blank">{% if url|length > 60 %}@@ -304,7 +356,7 @@{% endif %}</a>{% endif %}- {% if 'external_url' != metaField %}+ {% if 'external_url' != metaField %}{{ journalGetMetaField(journal.transaction_journal_id, metaField) }}{% endif %}</td>@@ -317,7 +369,7 @@<td class="markdown">{{ journal.notes|default('')|markdown }}</td></tr>{% endif %}- {% if journalHasMeta(journal.transaction_journal_id, 'recurring_total') and journalHasMeta(journal.transaction_journal_id, 'recurring_count') %}+ {% if journalHasMeta(journal.transaction_journal_id, 'recurring_total') and journalHasMeta(journal.transaction_journal_id, 'recurring_count') %}{% set recurringTotal = journalGetMetaField(journal.transaction_journal_id, 'recurring_total') %}{% if 0 == recurringTotal %}{% set recurringTotal = '∞' %}@@ -332,7 +384,8 @@<td style="width:40%;">{{ 'tags'|_ }}</td><td>{% for tag in journal.tags %}- <h4 style="display: inline;"><a class="label label-success" href="{{ route('tags.show', tag.id) }}">+ <h4 style="display: inline;"><a class="label label-success"+ href="{{ route('tags.show', tag.id) }}"><span class="fa fa-fw fa-tag"></span>{{ tag.tag }}</a></h4>{% endfor %}@@ -359,17 +412,18 @@<div class="btn-group btn-group-xs"><a href="#" class="btn btn-default switch-link" data-id="{{ link.id }}"><spanclass="fa fa-fw fa-arrows-h"></span></a>- <a href="{{ route('transactions.link.delete', [link.id]) }}" class="btn btn-danger"><span class="fa fa-trash"></span></a>+ <a href="{{ route('transactions.link.delete', [link.id]) }}"+ class="btn btn-danger"><span class="fa fa-trash"></span></a></div></td><td>{% if link.editable %}- {{ link.link }}+ {{ link.link }}{% else %}{{ trans('firefly.'~link.link) }}- {% endif %}+ {% endif %}"<a href="{{ route('transactions.show', link.group) }}"- title="{{ link.description }}">{{ link.description }}</a>"+ title="{{ link.description }}">{{ link.description }}</a>"({{ link.amount|raw }}){% if '' != link.foreign_amount %}@@ -408,7 +462,8 @@<tr><td style="width:30%;">{{ event.amount|raw }}</td><td>- <a href="{{ route('piggy-banks.show', [event.piggy_id]) }}">{{ event.piggy }}</a></td>+ <a href="{{ route('piggy-banks.show', [event.piggy_id]) }}">{{ event.piggy }}</a>+ </td></tr>{% endfor %}@@ -417,16 +472,16 @@</div>{% endif %}{% if logEntries[journal.transaction_journal_id]|length > 0 %}- <div class="box">- <div class="box-header with-border">- <h3 class="box-title">- {{ 'audit_log_entries'|_ }}- </h3>- </div>- <div class="box-body no-padding">- {% include 'list.ale' with {logEntries: logEntries[journal.transaction_journal_id]} %}+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">+ {{ 'audit_log_entries'|_ }}+ </h3>+ </div>+ <div class="box-body no-padding">+ {% include 'list.ale' with {logEntries: logEntries[journal.transaction_journal_id]} %}+ </div></div>- </div>{% endif %}</div>{% endfor %}@@ -444,6 +499,7 @@$('.switch-link').on('click', switchLink);var switchLinkUrl = '{{ route('transactions.link.switch') }}';+function switchLink(e) {e.preventDefault();var obj = $(e.currentTarget);@@ -461,7 +517,9 @@return false}</script>- <script type="text/javascript" src="v1/js/lib/typeahead/typeahead.bundle.min.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>- <script type="text/javascript" src="v1/js/ff/transactions/show.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>+ <script type="text/javascript" src="v1/js/lib/typeahead/typeahead.bundle.min.js?v={{ FF_VERSION }}"+ nonce="{{ JS_NONCE }}"></script>+ <script type="text/javascript" src="v1/js/ff/transactions/show.js?v={{ FF_VERSION }}"+ nonce="{{ JS_NONCE }}"></script>{% endblock %}