Fix audit log entries and fix #7677

This commit is contained in:
James Cole 2023-06-21 05:55:57 +02:00
parent 573f9adb49
commit 1278f92355
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
8 changed files with 627 additions and 457 deletions

View File

@ -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);

View File

@ -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,7 +144,49 @@ class ShowController extends Controller
}
/**
* @param array $group
* @param array $group
*
* @return array
*/
private function getAmounts(array $group): array
{
$amounts = [];
foreach ($group['transactions'] as $transaction) {
$symbol = $transaction['currency_symbol'];
if (!array_key_exists($symbol, $amounts)) {
$amounts[$symbol] = [
'amount' => '0',
'symbol' => $symbol,
'decimal_places' => $transaction['currency_decimal_places'],
];
}
$amounts[$symbol]['amount'] = bcadd($amounts[$symbol]['amount'], $transaction['amount']);
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)) {
$amounts[$foreignSymbol] = [
'amount' => '0',
'symbol' => $foreignSymbol,
'decimal_places' => $transaction['foreign_currency_decimal_places'],
];
}
$amounts[$foreignSymbol]['amount'] = bcadd(
$amounts[$foreignSymbol]['amount'],
$transaction['foreign_amount']
);
}
}
return $amounts;
}
/**
* @param array $group
*
* @return array
*/
@ -168,39 +214,4 @@ class ShowController extends Controller
return $accounts;
}
/**
* @param array $group
*
* @return array
*/
private function getAmounts(array $group): array
{
$amounts = [];
foreach ($group['transactions'] as $transaction) {
$symbol = $transaction['currency_symbol'];
if (!array_key_exists($symbol, $amounts)) {
$amounts[$symbol] = [
'amount' => '0',
'symbol' => $symbol,
'decimal_places' => $transaction['currency_decimal_places'],
];
}
$amounts[$symbol]['amount'] = bcadd($amounts[$symbol]['amount'], $transaction['amount']);
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)) {
$amounts[$foreignSymbol] = [
'amount' => '0',
'symbol' => $foreignSymbol,
'decimal_places' => $transaction['foreign_currency_decimal_places'],
];
}
$amounts[$foreignSymbol]['amount'] = bcadd($amounts[$foreignSymbol]['amount'], $transaction['foreign_amount']);
}
}
return $amounts;
}
}

View File

@ -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 GroupUpdateService
if (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 GroupUpdateService
Log::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 GroupUpdateService
if (!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']));

View File

@ -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
*/
private function removeReconciliation(): bool
{
if (count($this->data) > 1) {
return true;
}
if (1 === count($this->data) && true === array_key_exists('transaction_journal_id', $this->data)) {
return true;
}
return false;
}
/**
* @return bool
*/
private function hasValidAccounts(): bool
{
return $this->hasValidSourceAccount() && $this->hasValidDestinationAccount();
}
/**
* @return bool
*/
private function hasValidSourceAccount(): bool
{
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;
}
// 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;
}
/**
* @param array $fields
* Get destination transaction.
*
* @return bool
* @return Transaction
*/
private function hasFields(array $fields): bool
private function getDestinationTransaction(): Transaction
{
foreach ($fields as $field) {
if (array_key_exists($field, $this->data)) {
return true;
}
if (null === $this->destinationTransaction) {
$this->destinationTransaction = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();
}
return false;
return $this->destinationTransaction;
}
/**
* 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 getExpectedType(): string
{
Log::debug('Now in getExpectedType()');
if ($this->hasFields(['type'])) {
return ucfirst('opening-balance' === $this->data['type'] ? 'opening balance' : $this->data['type']);
}
return $this->transactionJournal->transactionType->type;
}
/**
* @return Account
*/
private function getOriginalDestinationAccount(): Account
{
if (null === $this->destinationAccount) {
$destination = $this->getDestinationTransaction();
$this->destinationAccount = $destination->account;
}
return $this->destinationAccount;
}
/**
@ -272,7 +247,11 @@ class JournalUpdateService
private 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,84 +259,39 @@ 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 string
* @return Account
*/
private function getExpectedType(): string
private function getValidDestinationAccount(): Account
{
Log::debug('Now in getExpectedType()');
if ($this->hasFields(['type'])) {
return ucfirst('opening-balance' === $this->data['type'] ? 'opening balance' : $this->data['type']);
}
return $this->transactionJournal->transactionType->type;
}
/**
* @return bool
*/
private function hasValidDestinationAccount(): bool
{
Log::debug('Now in hasValidDestinationAccount().');
$destId = $this->data['destination_id'] ?? null;
$destName = $this->data['destination_name'] ?? null;
Log::debug('Now in getValidDestinationAccount().');
if (!$this->hasFields(['destination_id', 'destination_name'])) {
Log::debug('No destination info submitted, grab the original data.');
$destination = $this->getOriginalDestinationAccount();
$destId = $destination->id;
$destName = $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();
}
// make a new validator.
/** @var AccountValidator $validator */
$validator = app(AccountValidator::class);
$validator->setTransactionType($expectedType);
$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)));
// TODO typeOverrule: the account validator may have another opinion on the transaction type.
// validate submitted info:
return $result;
}
/**
* @return Account
*/
private function getOriginalDestinationAccount(): Account
{
if (null === $this->destinationAccount) {
$destination = $this->getDestinationTransaction();
$this->destinationAccount = $destination->account;
}
return $this->destinationAccount;
}
/**
* Get destination transaction.
*
* @return Transaction
*/
private function getDestinationTransaction(): Transaction
{
if (null === $this->destinationTransaction) {
$this->destinationTransaction = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();
}
return $this->destinationTransaction;
}
/**
* Does a validation and returns the source account. This method will break if the source isn't really valid.
*
@ -393,6 +327,123 @@ class JournalUpdateService
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();
}
/**
* @return bool
*/
private function hasValidDestinationAccount(): bool
{
Log::debug('Now in hasValidDestinationAccount().');
$destId = $this->data['destination_id'] ?? null;
$destName = $this->data['destination_name'] ?? null;
if (!$this->hasFields(['destination_id', 'destination_name'])) {
Log::debug('No destination info submitted, grab the original data.');
$destination = $this->getOriginalDestinationAccount();
$destId = $destination->id;
$destName = $destination->name;
}
// 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);
$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)
)
);
// TODO typeOverrule: the account validator may have another opinion on the transaction type.
// validate submitted info:
return $result;
}
/**
* @return bool
*/
private function hasValidSourceAccount(): bool
{
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;
}
// 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 bool
*/
private function removeReconciliation(): bool
{
if (count($this->data) > 1) {
return true;
}
if (1 === count($this->data) && true === array_key_exists('transaction_journal_id', $this->data)) {
return true;
}
return false;
}
/**
* Will update the source and destination accounts of this journal. Assumes they are valid.
*/
@ -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));
}
/**
@ -510,45 +525,6 @@ class JournalUpdateService
}
}
/**
* Update journal generic field. Cannot be set to NULL.
*
* @param string $fieldName
*/
private function updateField(string $fieldName): 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));
}
}
/**
*
*/
private function updateCategory(): void
{
// update category
if ($this->hasFields(['category_id', 'category_name'])) {
Log::debug('Will update category.');
$this->storeCategory($this->transactionJournal, new NullArrayObject($this->data));
}
}
/**
*
*/
@ -568,102 +544,13 @@ class JournalUpdateService
/**
*
*/
private function updateTags(): void
private function updateCategory(): void
{
if ($this->hasFields(['tags'])) {
Log::debug('Will update tags.');
$tags = $this->data['tags'] ?? null;
$this->storeTags($this->transactionJournal, $tags);
}
}
// update category
if ($this->hasFields(['category_id', 'category_name'])) {
Log::debug('Will update category.');
/**
*
*/
private function updateReconciled(): void
{
if (array_key_exists('reconciled', $this->data) && is_bool($this->data['reconciled'])) {
$this->transactionJournal->transactions()->update(['reconciled' => $this->data['reconciled']]);
}
}
/**
*
*/
private function updateNotes(): void
{
// update notes.
if ($this->hasFields(['notes'])) {
$notes = '' === (string)$this->data['notes'] ? null : $this->data['notes'];
$this->storeNotes($this->transactionJournal, $notes);
}
}
/**
*
*/
private function updateMeta(): void
{
// update meta fields.
// first string
if ($this->hasFields($this->metaString)) {
Log::debug('Meta string fields are present.');
$this->updateMetaFields();
}
// then date fields.
if ($this->hasFields($this->metaDate)) {
Log::debug('Meta date fields are present.');
$this->updateMetaDateFields();
}
}
/**
*
*/
private function updateMetaFields(): void
{
/** @var TransactionJournalMetaFactory $factory */
$factory = app(TransactionJournalMetaFactory::class);
foreach ($this->metaString as $field) {
if ($this->hasFields([$field])) {
$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,
'name' => $field,
'data' => $value,
];
$factory->updateOrCreate($set);
}
}
}
/**
*
*/
private function updateMetaDateFields(): void
{
/** @var TransactionJournalMetaFactory $factory */
$factory = app(TransactionJournalMetaFactory::class);
foreach ($this->metaDate 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;
}
Log::debug(sprintf('Field "%s" is present ("%s"), try to update it.', $field, $value));
$set = [
'journal' => $this->transactionJournal,
'name' => $field,
'data' => $value,
];
$factory->updateOrCreate($set);
}
$this->storeCategory($this->transactionJournal, new NullArrayObject($this->data));
}
}
@ -700,34 +587,39 @@ class JournalUpdateService
}
/**
* Update journal generic field. Cannot be set to NULL.
*
* @param string $fieldName
*/
private function updateAmount(): void
private function updateField(string $fieldName): void
{
Log::debug(sprintf('Now in %s', __METHOD__));
if (!$this->hasFields(['amount'])) {
return;
}
if (array_key_exists($fieldName, $this->data) && '' !== (string)$this->data[$fieldName]) {
$value = $this->data[$fieldName];
$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()));
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
)
);
return;
$this->transactionJournal->$fieldName = $value;
Log::debug(sprintf('Updated %s', $fieldName));
}
$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));
}
/**
@ -749,7 +641,8 @@ class JournalUpdateService
// 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;
$foreignCurrency = $this->currencyRepository->findCurrencyNull($newForeignId, $newForeignCode) ??
$foreignCurrency;
// not the same as normal currency
if (null !== $foreignCurrency && $foreignCurrency->id === $this->transactionJournal->transaction_currency_id) {
@ -767,7 +660,14 @@ class JournalUpdateService
$dest->foreign_amount = app('steam')->positive($foreignAmount);
$dest->save();
Log::debug(sprintf('Update foreign info to %s (#%d) %s', $foreignCurrency->code, $foreignCurrency->id, $foreignAmount));
Log::debug(
sprintf(
'Update foreign info to %s (#%d) %s',
$foreignCurrency->code,
$foreignCurrency->id,
$foreignAmount
)
);
// refresh transactions.
$this->sourceTransaction->refresh();
@ -791,4 +691,140 @@ class JournalUpdateService
$this->sourceTransaction->refresh();
$this->destinationTransaction->refresh();
}
/**
*
*/
private function updateMeta(): void
{
// update meta fields.
// first string
if ($this->hasFields($this->metaString)) {
Log::debug('Meta string fields are present.');
$this->updateMetaFields();
}
// then date fields.
if ($this->hasFields($this->metaDate)) {
Log::debug('Meta date fields are present.');
$this->updateMetaDateFields();
}
}
/**
*
*/
private function updateMetaDateFields(): void
{
/** @var TransactionJournalMetaFactory $factory */
$factory = app(TransactionJournalMetaFactory::class);
foreach ($this->metaDate 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;
}
Log::debug(sprintf('Field "%s" is present ("%s"), try to update it.', $field, $value));
$set = [
'journal' => $this->transactionJournal,
'name' => $field,
'data' => $value,
];
$factory->updateOrCreate($set);
}
}
}
/**
*
*/
private function updateMetaFields(): void
{
/** @var TransactionJournalMetaFactory $factory */
$factory = app(TransactionJournalMetaFactory::class);
foreach ($this->metaString as $field) {
if ($this->hasFields([$field])) {
$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,
'name' => $field,
'data' => $value,
];
$factory->updateOrCreate($set);
}
}
}
/**
*
*/
private function updateNotes(): void
{
// update notes.
if ($this->hasFields(['notes'])) {
$notes = '' === (string)$this->data['notes'] ? null : $this->data['notes'];
$this->storeNotes($this->transactionJournal, $notes);
}
}
/**
*
*/
private function updateReconciled(): void
{
if (array_key_exists('reconciled', $this->data) && is_bool($this->data['reconciled'])) {
$this->transactionJournal->transactions()->update(['reconciled' => $this->data['reconciled']]);
}
}
/**
*
*/
private function updateTags(): void
{
if ($this->hasFields(['tags'])) {
Log::debug('Will update tags.');
$tags = $this->data['tags'] ?? null;
$this->storeTags($this->transactionJournal, $tags);
}
}
/**
* 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;
}
return;
}
Log::debug('No type field present.');
}
}

View File

@ -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 AbstractExtension
return 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 AbstractExtension
static function (int $size): string {
// less than one GB, more than one MB
if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
return round($size / (1024 * 1024), 2).' MB';
return round($size / (1024 * 1024), 2) . ' MB';
}
// less than one MB
if ($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);
}
);

View File

@ -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',

View File

@ -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>
&rarr;
<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>
&rarr;
<code>{{ carbonize(logEntry.after).isoFormat(dateTimeFormat) }}</code>
{% endif %}
{% if 'update_transaction_type' == logEntry.action %}
{{ trans('firefly.'~logEntry.before) }} &rarr; {{ trans('firefly.'~logEntry.after) }}
{% endif %}

View File

@ -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> &rarr;
{% 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 }}"><span
class="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 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 class="box-body no-padding">
{% include 'list.ale' with {logEntries: logEntries[journal.transaction_journal_id]} %}
</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 %}