Improve tests, models and views.

This commit is contained in:
James Cole 2019-04-16 16:20:46 +02:00
parent 5ac39dbdef
commit 66c55b7bbe
44 changed files with 13710 additions and 5067 deletions

View File

@ -291,7 +291,7 @@ class TransactionController extends Controller
$selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
throw new NotFoundHttpException();
throw new NotFoundHttpException(); // @codeCoverageIgnore
}
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
@ -335,7 +335,7 @@ class TransactionController extends Controller
$selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
throw new NotFoundHttpException();
throw new NotFoundHttpException(); // @codeCoverageIgnore
}
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);

View File

@ -182,7 +182,7 @@ class TransactionStoreRequest extends Request
// the group must have a description if > 1 journal.
$this->validateGroupDescription($validator);
// TODO validate that the currency fits the source and/or destination account.
// TODO the currency info must match the accounts involved.
}
);
@ -217,8 +217,8 @@ class TransactionStoreRequest extends Request
'foreign_currency_code' => $this->stringFromValue($object['foreign_currency_code']),
// amount and foreign amount. Cannot be 0.
'amount' => $this->stringFromValue($object['amount']),
'foreign_amount' => $this->stringFromValue($object['foreign_amount']),
'amount' => $this->stringFromValue((string)$object['amount']),
'foreign_amount' => $this->stringFromValue((string)$object['foreign_amount']),
// description.
'description' => $this->stringFromValue($object['description']),

View File

@ -237,13 +237,12 @@ class TransactionUpdateRequest extends Request
// all transaction types must be equal:
$this->validateTransactionTypesForUpdate($validator);
// if type is set, source + destination info is mandatory.
$this->validateAccountPresence($validator);
// validate source/destination is equal, depending on the transaction journal type.
$this->validateEqualAccountsForUpdate($validator, $transactionGroup);
// TODO if type is set, source + destination info is mandatory.
// TODO validate that the currency fits the source and/or destination account.
// TODO the currency info must match the accounts involved.
// all journals must have a description
//$this->validateDescriptions($validator);
@ -308,7 +307,7 @@ class TransactionUpdateRequest extends Request
foreach ($this->arrayFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->arrayFromValue((string)$transaction[$fieldName]);
$current[$fieldName] = $this->arrayFromValue($transaction[$fieldName]);
}
}
$return[] = $current;

View File

@ -83,12 +83,13 @@ class TransactionIdentifier extends Command
->where('t_count', '>', 2)
->select(['id', 't_count']);
$journalIds = array_unique($result->pluck('id')->toArray());
$count= 0;
foreach ($journalIds as $journalId) {
$this->updateJournalidentifiers((int)$journalId);
$count++;
}
$end = round(microtime(true) - $start, 2);
$this->info(sprintf('Verified and fixed transaction identifiers in %s seconds.', $end));
$this->info(sprintf('Verified and fixed %d transaction identifiers in %s seconds.', $count, $end));
$this->markAsExecuted();
return 0;

View File

@ -124,6 +124,8 @@ class TransactionFactory
$sourceAccount = $this->getAccount($type, 'source', (int)$data['source_id'], $data['source_name']);
$destinationAccount = $this->getAccount($type, 'destination', (int)$data['destination_id'], $data['destination_name']);
// at this point we know the
$amount = $this->getAmount($data['amount']);
$foreignAmount = $this->getForeignAmount($data['foreign_amount']);
$one = $this->create($sourceAccount, $currency, app('steam')->negative($amount));

View File

@ -1,6 +1,6 @@
<?php
/**
* ShowController.php
* ViewController.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
@ -28,6 +28,8 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
use FireflyIII\Transformers\TransactionGroupTransformer;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class ShowController
@ -35,21 +37,22 @@ use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface
class ShowController extends Controller
{
/** @var TransactionGroupRepositoryInterface */
private $groupRepository;
private $repository;
/**
* SingleController constructor.
* ConvertController constructor.
*/
public function __construct()
{
parent::__construct();
// some useful repositories:
$this->middleware(
function ($request, $next) {
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->repository = app(TransactionGroupRepositoryInterface::class);
app('view')->share('title', (string)trans('firefly.transactions'));
app('view')->share('mainTitleIcon', 'fa-repeat');
app('view')->share('mainTitleIcon', 'fa-exchange');
return $next($request);
}
@ -64,16 +67,58 @@ class ShowController extends Controller
public function show(TransactionGroup $transactionGroup)
{
/** @var TransactionJournal $first */
$first = $transactionGroup->transactionJournals->first();
$groupType = $first->transactionType->type;
$description = $transactionGroup->title;
if ($transactionGroup->transactionJournals()->count() > 1) {
$description = $first->description;
$first = $transactionGroup->transactionJournals->first();
$splits = $transactionGroup->transactionJournals->count();
$type = (string)trans(sprintf('firefly.%s', strtolower($first->transactionType->type)));
$title = 1 === $splits ? $first->description : $transactionGroup->title;
$subTitle = sprintf('%s: "%s"', $type, $title);
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters(new ParameterBag);
$groupArray = $transformer->transformObject($transactionGroup);
// do some amount calculations:
$amounts = [];
foreach ($groupArray['transactions'] as $transaction) {
$symbol = $transaction['currency_symbol'];
if (!isset($amounts[$symbol])) {
$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']) {
// same for foreign currency:
$foreignSymbol = $transaction['foreign_currency_symbol'];
if (!isset($amounts[$foreignSymbol])) {
$amounts[$foreignSymbol] = [
'amount' => '0',
'symbol' => $foreignSymbol,
'decimal_places' => $transaction['foreign_currency_decimal_places'],
];
}
$amounts[$symbol]['amount'] = bcadd($amounts[$symbol]['amount'], $transaction['foreign_amount']);
}
}
$subTitle = sprintf('%s: "%s"', $groupType, $description);
$events = $this->repository->getPiggyEvents($transactionGroup);
$attachments = $this->repository->getAttachments($transactionGroup);
$links = $this->repository->getLinks($transactionGroup);
return view('transactions.show', compact('transactionGroup', 'subTitle'));
// TODO links to other journals, use the API
// TODO links to attachments, use the API.
// TODO links to piggy bank events.
return view(
'transactions.show', compact(
'transactionGroup', 'amounts', 'first', 'type', 'subTitle', 'splits', 'groupArray',
'events', 'attachments', 'links'
)
);
}
}

View File

@ -212,61 +212,6 @@ class TransactionController extends Controller
return response()->json([true]);
}
/**
* Show a transaction.
*
* @param TransactionJournal $journal
* @param LinkTypeRepositoryInterface $linkTypeRepository
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
* @throws FireflyException
*/
public function show(TransactionJournal $journal, LinkTypeRepositoryInterface $linkTypeRepository)
{
if ($this->isOpeningBalance($journal)) {
return $this->redirectToAccount($journal);
}
$transactionType = $journal->transactionType->type;
if (TransactionType::RECONCILIATION === $transactionType) {
return redirect(route('accounts.reconcile.show', [$journal->id])); // @codeCoverageIgnore
}
$linkTypes = $linkTypeRepository->get();
$links = $linkTypeRepository->getLinks($journal);
// get attachments:
$attachments = $this->repository->getAttachments($journal);
$attachments = $attachments->each(
function (Attachment $attachment) {
$attachment->file_exists = $this->attachmentRepository->exists($attachment);
return $attachment;
}
);
// get transactions using the collector:
$collector = app(TransactionCollectorInterface::class);
$collector->setUser(auth()->user());
$collector->withOpposingAccount()->withCategoryInformation()->withBudgetInformation();
// filter on specific journals.
$collector->setJournals(new Collection([$journal]));
$set = $collector->getTransactions();
$transactions = [];
/** @var TransactionTransformer $transformer */
$transformer = app(TransactionTransformer::class);
$transformer->setParameters(new ParameterBag);
/** @var Transaction $transaction */
foreach ($set as $transaction) {
$transactions[] = $transformer->transform($transaction);
}
$events = $this->repository->getPiggyBankEvents($journal);
$what = strtolower($transactionType);
$subTitle = trans('firefly.' . $what) . ' "' . $journal->description . '"';
return view('transactions.show', compact('journal', 'attachments', 'events', 'subTitle', 'what', 'transactions', 'linkTypes', 'links'));
}
}

View File

@ -98,7 +98,9 @@ class TransactionGroup extends Model
/** @var User $user */
$user = auth()->user();
/** @var TransactionGroup $group */
$group = $user->transactionGroups()->where('transaction_groups.id', $groupId)->first(['transaction_groups.*']);
$group = $user->transactionGroups()
->with(['transactionJournals','transactionJournals.transactions'])
->where('transaction_groups.id', $groupId)->first(['transaction_groups.*']);
if (null !== $group) {
return $group;
}

View File

@ -368,7 +368,7 @@ class TransactionJournal extends Model
* @codeCoverageIgnore
* @return BelongsTo
*/
public function transactionGroup(): BelongsToMany
public function transactionGroup(): BelongsTo
{
return $this->belongsTo(TransactionGroup::class);
}

View File

@ -63,13 +63,7 @@ use FireflyIII\Support\Steam;
use FireflyIII\Support\Twig\AmountFormat;
use FireflyIII\Support\Twig\Extension\TransactionGroupTwig;
use FireflyIII\Support\Twig\General;
use FireflyIII\Support\Twig\Journal;
use FireflyIII\Support\Twig\Loader\AccountLoader;
use FireflyIII\Support\Twig\Loader\TransactionGroupLoader;
use FireflyIII\Support\Twig\Loader\TransactionJournalLoader;
use FireflyIII\Support\Twig\Loader\TransactionLoader;
use FireflyIII\Support\Twig\Rule;
use FireflyIII\Support\Twig\Transaction;
use FireflyIII\Support\Twig\Translation;
use FireflyIII\Validation\FireflyValidator;
use Illuminate\Foundation\Application;
@ -101,14 +95,9 @@ class FireflyServiceProvider extends ServiceProvider
);
$config = app('config');
Twig::addExtension(new Functions($config));
Twig::addRuntimeLoader(new TransactionLoader);
Twig::addRuntimeLoader(new AccountLoader);
Twig::addRuntimeLoader(new TransactionJournalLoader);
Twig::addExtension(new General);
Twig::addExtension(new TransactionGroupTwig);
Twig::addExtension(new Journal);
Twig::addExtension(new Translation);
Twig::addExtension(new Transaction);
Twig::addExtension(new Rule);
Twig::addExtension(new AmountFormat);
Twig::addExtension(new Twig_Extension_Debug);

View File

@ -29,11 +29,14 @@ use DB;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\TransactionGroupFactory;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Note;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalLink;
use FireflyIII\Services\Internal\Update\GroupUpdateService;
use FireflyIII\Support\NullArrayObject;
use Illuminate\Database\Eloquent\Builder;
/**
* Class TransactionGroupRepository
@ -52,6 +55,80 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
}
}
/**
* Return all attachments for all journals in the group.
*
* @param TransactionGroup $group
*
* @return array
*/
public function getAttachments(TransactionGroup $group): array
{
$journals = $group->transactionJournals->pluck('id')->toArray();
$set = Attachment::whereIn('attachable_id', $journals)
->where('attachable_type', TransactionJournal::class)
->whereNull('deleted_at')->get();
$result = [];
/** @var Attachment $attachment */
foreach ($set as $attachment) {
$current = $attachment->toArray();
$current['file_exists'] = true;
$current['journal_title'] = $attachment->attachable->description;
$result[] = $current;
}
//$result = $set->toArray();
return $result;
}
/**
* Return all journal links for all journals in the group.
*
* @param TransactionGroup $group
*
* @return array
*/
public function getLinks(TransactionGroup $group): array
{
$return = [];
$journals = $group->transactionJournals->pluck('id')->toArray();
$set = TransactionJournalLink
::where(
static function (Builder $q) use ($journals) {
$q->whereIn('source_id', $journals);
$q->orWhereIn('destination_id', $journals);
}
)
->with(['source', 'destination'])
->leftJoin('link_types', 'link_types.id', '=', 'journal_links.link_type_id')
->get(['journal_links.*', 'link_types.inward', 'link_types.outward']);
/** @var TransactionJournalLink $entry */
foreach ($set as $entry) {
$journalId = in_array($entry->source_id, $journals, true) ? $entry->source_id : $entry->destination_id;
$return[$journalId] = $return[$journalId] ?? [];
if ($journalId === $entry->source_id) {
$return[$journalId][] = [
'link' => $entry->outward,
'group' => $entry->destination->transaction_group_id,
'description' => $entry->destination->description,
];
}
if ($journalId === $entry->destination_id) {
$return[$journalId][] = [
'link' => $entry->inward,
'group' => $entry->source->transaction_group_id,
'description' => $entry->source->description,
];
}
}
return $return;
}
/**
* Return object with all found meta field things as Carbon objects.
*
@ -124,6 +201,18 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
return $note->text;
}
/**
* Return all piggy bank events for all journals in the group.
*
* @param TransactionGroup $group
*
* @return array
*/
public function getPiggyEvents(TransactionGroup $group): array
{
return [];
}
/**
* Get the tags for a journal (by ID).
*

View File

@ -33,6 +33,25 @@ use FireflyIII\User;
*/
interface TransactionGroupRepositoryInterface
{
/**
* Return all attachments for all journals in the group.
*
* @param TransactionGroup $group
*
* @return array
*/
public function getAttachments(TransactionGroup $group): array;
/**
* Return all journal links for all journals in the group.
*
* @param TransactionGroup $group
*
* @return array
*/
public function getLinks(TransactionGroup $group): array;
/**
* Return object with all found meta field things as Carbon objects.
*
@ -62,6 +81,15 @@ interface TransactionGroupRepositoryInterface
*/
public function getNoteText(int $journalId): ?string;
/**
* Return all piggy bank events for all journals in the group.
*
* @param TransactionGroup $group
*
* @return array
*/
public function getPiggyEvents(TransactionGroup $group): array;
/**
* Get the tags for a journal (by ID).
*

View File

@ -28,6 +28,7 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Jobs\CreateRecurringTransactions;
use FireflyIII\Models\Configuration;
use Log;
use Preferences;
/**
* Class RecurringCronjob
@ -67,6 +68,7 @@ class RecurringCronjob extends AbstractCronjob
Log::error($e->getTraceAsString());
throw new FireflyException(sprintf('Could not run recurring transaction cron job: %s', $e->getMessage()));
}
Preferences::mark();
return true;
}

View File

@ -1,51 +0,0 @@
<?php
/**
* Account.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Support\Twig\Extension;
use FireflyIII\Models\Account as AccountModel;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Twig_Extension;
/**
* Class Account.
*/
class Account extends Twig_Extension
{
/**
* @param AccountModel $account
* @param string $field
*
* @return string
*/
public function getMetaField(AccountModel $account, string $field): string
{
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$result = $repository->getMetaValue($account, $field);
if (null === $result) {
return '';
}
return $result;
}
}

View File

@ -1,426 +0,0 @@
<?php
/**
* Transaction.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Support\Twig\Extension;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Transaction as TransactionModel;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use Lang;
use Log;
use Twig_Extension;
/**
* Class Transaction.
*/
class Transaction extends Twig_Extension
{
/**
* Can show the amount of a transaction, if that transaction has been collected by the journal collector.
*
* @param TransactionModel $transaction
*
* @return string
*/
public function amount(TransactionModel $transaction): string
{
// at this point amount is always negative.
$amount = bcmul(app('steam')->positive((string)$transaction->transaction_amount), '-1');
$format = '%s';
$coloured = true;
if (TransactionType::RECONCILIATION === $transaction->transaction_type_type && 1 === bccomp((string)$transaction->transaction_amount, '0')) {
$amount = bcmul($amount, '-1');
}
if (TransactionType::DEPOSIT === $transaction->transaction_type_type) {
$amount = bcmul($amount, '-1');
}
if (TransactionType::TRANSFER === $transaction->transaction_type_type) {
$amount = app('steam')->positive($amount);
$coloured = false;
$format = '<span class="text-info">%s</span>';
}
if (TransactionType::OPENING_BALANCE === $transaction->transaction_type_type) {
$amount = (string)$transaction->transaction_amount;
}
$currency = new TransactionCurrency;
$currency->symbol = $transaction->transaction_currency_symbol;
$currency->decimal_places = $transaction->transaction_currency_dp;
$str = sprintf($format, app('amount')->formatAnything($currency, $amount, $coloured));
if (null !== $transaction->transaction_foreign_amount) {
$amount = bcmul(app('steam')->positive((string)$transaction->transaction_foreign_amount), '-1');
if (TransactionType::DEPOSIT === $transaction->transaction_type_type) {
$amount = bcmul($amount, '-1');
}
if (TransactionType::TRANSFER === $transaction->transaction_type_type) {
$amount = app('steam')->positive($amount);
$coloured = false;
$format = '<span class="text-info">%s</span>';
}
$currency = new TransactionCurrency;
$currency->symbol = $transaction->foreign_currency_symbol;
$currency->decimal_places = $transaction->foreign_currency_dp;
$str .= ' (' . sprintf($format, app('amount')->formatAnything($currency, $amount, $coloured)) . ')';
}
return $str;
}
/**
* @param array $transaction
*
* @return string
*/
public function amountArray(array $transaction): string
{
// first display amount:
$amount = (string)$transaction['amount'];
$fakeCurrency = new TransactionCurrency;
$fakeCurrency->decimal_places = $transaction['currency_decimal_places'];
$fakeCurrency->symbol = $transaction['currency_symbol'];
$string = app('amount')->formatAnything($fakeCurrency, $amount, true);
// then display (if present) the foreign amount:
if (null !== $transaction['foreign_amount']) {
$amount = (string)$transaction['foreign_amount'];
$fakeCurrency = new TransactionCurrency;
$fakeCurrency->decimal_places = $transaction['foreign_currency_decimal_places'];
$fakeCurrency->symbol = $transaction['foreign_currency_symbol'];
$string .= ' (' . app('amount')->formatAnything($fakeCurrency, $amount, true) . ')';
}
return $string;
}
/**
*
* @param TransactionModel $transaction
*
* @return string
*/
public function budgets(TransactionModel $transaction): string
{
$txt = '';
// journal has a budget:
if (null !== $transaction->transaction_journal_budget_id) {
$name = $transaction->transaction_journal_budget_name;
$txt = sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$transaction->transaction_journal_budget_id]), $name, $name);
}
// transaction has a budget
if (null !== $transaction->transaction_budget_id && '' === $txt) {
$name = $transaction->transaction_budget_name;
$txt = sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$transaction->transaction_budget_id]), $name, $name);
}
if ('' === $txt) {
// see if the transaction has a budget:
$budgets = $transaction->budgets()->get();
if (0 === $budgets->count()) {
$budgets = $transaction->transactionJournal()->first()->budgets()->get();
}
if ($budgets->count() > 0) {
$str = [];
foreach ($budgets as $budget) {
$str[] = sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$budget->id]), $budget->name, $budget->name);
}
$txt = implode(', ', $str);
}
}
return $txt;
}
/**
* @param TransactionModel $transaction
*
* @return string
*/
public function categories(TransactionModel $transaction): string
{
$txt = '';
// journal has a category:
if (null !== $transaction->transaction_journal_category_id) {
$name = $transaction->transaction_journal_category_name;
$txt = sprintf('<a href="%s" title="%s">%s</a>', route('categories.show', [$transaction->transaction_journal_category_id]), $name, $name);
}
// transaction has a category:
if (null !== $transaction->transaction_category_id && '' === $txt) {
$name = $transaction->transaction_category_name;
$txt = sprintf('<a href="%s" title="%s">%s</a>', route('categories.show', [$transaction->transaction_category_id]), $name, $name);
}
if ('' === $txt) {
// see if the transaction has a category:
$categories = $transaction->categories()->get();
if (0 === $categories->count()) {
$categories = $transaction->transactionJournal()->first()->categories()->get();
}
if ($categories->count() > 0) {
$str = [];
foreach ($categories as $category) {
$str[] = sprintf('<a href="%s" title="%s">%s</a>', route('categories.show', [$category->id]), $category->name, $category->name);
}
$txt = implode(', ', $str);
}
}
return $txt;
}
/**
* @param TransactionModel $transaction
*
* @return string
*/
public function description(TransactionModel $transaction): string
{
$description = $transaction->description;
if ('' !== (string)$transaction->transaction_description) {
$description = $transaction->transaction_description . ' (' . $transaction->description . ')';
}
return $description;
}
/**
* @param TransactionModel $transaction
*
* @return string
*/
public function destinationAccount(TransactionModel $transaction): string
{
if (TransactionType::RECONCILIATION === $transaction->transaction_type_type) {
return '&mdash;';
}
$name = $transaction->account_name;
$iban = $transaction->account_iban;
$transactionId = (int)$transaction->account_id;
$type = $transaction->account_type;
// name is present in object, use that one:
if (null !== $transaction->opposing_account_id && bccomp($transaction->transaction_amount, '0') === -1) {
$name = $transaction->opposing_account_name;
$transactionId = (int)$transaction->opposing_account_id;
$type = $transaction->opposing_account_type;
$iban = $transaction->opposing_account_iban;
}
// Find the opposing account and use that one:
if (null === $transaction->opposing_account_id && bccomp($transaction->transaction_amount, '0') === -1) {
// if the amount is negative, find the opposing account and use that one:
$journalId = $transaction->journal_id;
/** @var TransactionModel $other */
$other = TransactionModel
::where('transaction_journal_id', $journalId)
->where('transactions.id', '!=', $transaction->id)
->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))
->where('identifier', $transaction->identifier)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']);
if (null === $other) {
Log::error(sprintf('Cannot find other transaction for journal #%d', $journalId));
return '';
}
$name = $other->name;
$transactionId = $other->account_id;
$type = $other->type;
}
if (AccountType::CASH === $type) {
$txt = '<span class="text-success">(' . trans('firefly.cash') . ')</span>';
return $txt;
}
$txt = sprintf('<a title="%3$s" href="%2$s">%1$s</a>', e($name), route('accounts.show', [$transactionId]), $iban);
return $txt;
}
/**
* @param TransactionModel $transaction
*
* @return string
*/
public function hasAttachments(TransactionModel $transaction): string
{
$res = '';
if (\is_int($transaction->attachmentCount) && $transaction->attachmentCount > 0) {
$res = sprintf(
'<i class="fa fa-paperclip" title="%s"></i>', Lang::choice(
'firefly.nr_of_attachments',
$transaction->attachmentCount, ['count' => $transaction->attachmentCount]
)
);
}
if (null === $transaction->attachmentCount) {
$journalId = (int)$transaction->journal_id;
$count = Attachment::whereNull('deleted_at')
->where('attachable_type', TransactionJournal::class)
->where('attachable_id', $journalId)
->count();
if ($count > 0) {
$res = sprintf('<i class="fa fa-paperclip" title="%s"></i>', Lang::choice('firefly.nr_of_attachments', $count, ['count' => $count]));
}
}
return $res;
}
/**
* @param TransactionModel $transaction
*
* @return string
*/
public function icon(TransactionModel $transaction): string
{
switch ($transaction->transaction_type_type) {
case TransactionType::WITHDRAWAL:
$txt = sprintf('<i class="fa fa-long-arrow-left fa-fw" title="%s"></i>', (string)trans('firefly.withdrawal'));
break;
case TransactionType::DEPOSIT:
$txt = sprintf('<i class="fa fa-long-arrow-right fa-fw" title="%s"></i>', (string)trans('firefly.deposit'));
break;
case TransactionType::TRANSFER:
$txt = sprintf('<i class="fa fa-fw fa-exchange" title="%s"></i>', (string)trans('firefly.transfer'));
break;
case TransactionType::OPENING_BALANCE:
$txt = sprintf('<i class="fa-fw fa fa-star-o" title="%s"></i>', (string)trans('firefly.opening_balance'));
break;
case TransactionType::RECONCILIATION:
$txt = sprintf('<i class="fa-fw fa fa-calculator" title="%s"></i>', (string)trans('firefly.reconciliation_transaction'));
break;
default:
$txt = '';
break;
}
return $txt;
}
/**
* @param TransactionModel $transaction
*
* @return string
*/
public function isReconciled(TransactionModel $transaction): string
{
$icon = '';
if (1 === (int)$transaction->reconciled) {
$icon = '<i class="fa fa-check"></i>';
}
return $icon;
}
/**
* Returns an icon when the transaction is a split transaction.
*
* @param TransactionModel $transaction
*
* @return string
*/
public function isSplit(TransactionModel $transaction): string
{
$res = '';
if (true === $transaction->is_split) {
$res = '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>';
}
if (null === $transaction->is_split) {
$journalId = (int)$transaction->journal_id;
$count = TransactionModel::where('transaction_journal_id', $journalId)->whereNull('deleted_at')->count();
if ($count > 2) {
$res = '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>';
}
}
return $res;
}
/**
* @param TransactionModel $transaction
*
* @return string
*/
public function sourceAccount(TransactionModel $transaction): string
{
if (TransactionType::RECONCILIATION === $transaction->transaction_type_type) {
return '&mdash;';
}
// if the amount is negative, assume that the current account (the one in $transaction) is indeed the source account.
$name = $transaction->account_name;
$transactionId = (int)$transaction->account_id;
$type = $transaction->account_type;
$iban = $transaction->account_iban;
// name is present in object, use that one:
if (null !== $transaction->opposing_account_id && 1 === bccomp($transaction->transaction_amount, '0')) {
$name = $transaction->opposing_account_name;
$transactionId = (int)$transaction->opposing_account_id;
$type = $transaction->opposing_account_type;
$iban = $transaction->opposing_account_iban;
}
// Find the opposing account and use that one:
if (null === $transaction->opposing_account_id && 1 === bccomp($transaction->transaction_amount, '0')) {
$journalId = $transaction->journal_id;
/** @var TransactionModel $other */
$other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)
->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where(
'identifier',
$transaction->identifier
)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']);
$name = $other->name;
$transactionId = $other->account_id;
$type = $other->type;
}
if (AccountType::CASH === $type) {
$txt = '<span class="text-success">(' . trans('firefly.cash') . ')</span>';
return $txt;
}
$txt = sprintf('<a title="%3$s" href="%2$s">%1$s</a>', e($name), route('accounts.show', [$transactionId]), $iban);
return $txt;
}
}

View File

@ -1,178 +0,0 @@
<?php
/**
* TransactionJournal.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Support\Twig\Extension;
use Carbon\Carbon;
use FireflyIII\Models\Transaction as TransactionModel;
use FireflyIII\Models\TransactionJournal as JournalModel;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Twig_Extension;
/**
* Class TransactionJournal
*/
class TransactionJournal extends Twig_Extension
{
/**
* @param JournalModel $journal
* @param string $field
*
* @return null|Carbon
*/
public function getMetaDate(JournalModel $journal, string $field): ?Carbon
{
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
return $repository->getMetaDate($journal, $field);
}
/**
* @param JournalModel $journal
* @param string $field
*
* @return string
*/
public function getMetaField(JournalModel $journal, string $field): string
{
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
$result = $repository->getMetaField($journal, $field);
if (null === $result) {
return '';
}
return $result;
}
/**
* Return if journal HAS field.
*
* @param JournalModel $journal
* @param string $field
*
* @return bool
*/
public function hasMetaField(JournalModel $journal, string $field): bool
{
// HIER BEN JE
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
$result = $repository->getMetaField($journal, $field);
if (null === $result) {
return false;
}
if ('' === (string)$result) {
return false;
}
return true;
}
/**
* @param JournalModel $journal
*
* @return string
*/
public function totalAmount(JournalModel $journal): string
{
$type = $journal->transactionType->type;
$totals = $this->getTotalAmount($journal);
$array = [];
foreach ($totals as $total) {
if (TransactionType::WITHDRAWAL === $type) {
$total['amount'] = bcmul($total['amount'], '-1');
}
if (null !== $total['currency']) {
$array[] = app('amount')->formatAnything($total['currency'], $total['amount']);
}
}
return implode(' / ', $array);
}
/**
* @param JournalModel $journal
*
* @return string
*/
public function totalAmountPlain(JournalModel $journal): string
{
$type = $journal->transactionType->type;
$totals = $this->getTotalAmount($journal);
$array = [];
foreach ($totals as $total) {
if (TransactionType::WITHDRAWAL === $type) {
$total['amount'] = bcmul($total['amount'], '-1');
}
$array[] = app('amount')->formatAnything($total['currency'], $total['amount'], false);
}
return implode(' / ', $array);
}
/**
* @param JournalModel $journal
*
* @return array
*/
private function getTotalAmount(JournalModel $journal): array
{
$transactions = $journal->transactions()->where('amount', '>', 0)->get();
$totals = [];
/** @var TransactionModel $transaction */
foreach ($transactions as $transaction) {
$currencyId = $transaction->transaction_currency_id;
$currency = $transaction->transactionCurrency;
if (!isset($totals[$currencyId])) {
$totals[$currencyId] = [
'amount' => '0',
'currency' => $currency,
];
}
$totals[$currencyId]['amount'] = bcadd($transaction->amount, $totals[$currencyId]['amount']);
if (null !== $transaction->foreign_currency_id) {
$foreignAmount = $transaction->foreign_amount ?? '0';
$foreignId = $transaction->foreign_currency_id;
$foreign = $transaction->foreignCurrency;
if (!isset($totals[$foreignId])) {
$totals[$foreignId] = [
'amount' => '0',
'currency' => $foreign,
];
}
$totals[$foreignId]['amount'] = bcadd(
$foreignAmount,
$totals[$foreignId]['amount']
);
}
}
return $totals;
}
}

View File

@ -24,8 +24,8 @@ namespace FireflyIII\Support\Twig;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Support\Twig\Extension\Account as AccountExtension;
use League\CommonMark\CommonMarkConverter;
use Route;
use Twig_Extension;
@ -56,14 +56,12 @@ class General extends Twig_Extension
public function getFunctions(): array
{
return [
$this->getCurrencyCode(),
$this->getCurrencySymbol(),
$this->phpdate(),
$this->activeRouteStrict(),
$this->activeRoutePartial(),
$this->activeRoutePartialWhat(),
$this->formatDate(),
new Twig_SimpleFunction('accountGetMetaField', [AccountExtension::class, 'getMetaField']),
$this->getMetaField(),
$this->hasRole(),
];
}
@ -102,7 +100,7 @@ class General extends Twig_Extension
return new Twig_SimpleFunction(
'activeRoutePartialWhat',
function ($context): string {
[, $route, $what] = \func_get_args();
[, $route, $what] = func_get_args();
$activeWhat = $context['what'] ?? false;
if ($what === $activeWhat && !(false === stripos(Route::getCurrentRoute()->getName(), $route))) {
@ -139,6 +137,8 @@ class General extends Twig_Extension
}
/**
* Show account balance. Only used on the front page of Firefly III.
*
* @return Twig_SimpleFilter
*/
protected function balance(): Twig_SimpleFilter
@ -158,6 +158,8 @@ class General extends Twig_Extension
}
/**
* Formats a string as a thing by converting it to a Carbon first.
*
* @return Twig_SimpleFunction
*/
protected function formatDate(): Twig_SimpleFunction
@ -173,6 +175,8 @@ class General extends Twig_Extension
}
/**
* Used to convert 1024 to 1kb etc.
*
* @return Twig_SimpleFilter
*/
protected function formatFilesize(): Twig_SimpleFilter
@ -198,25 +202,19 @@ class General extends Twig_Extension
/**
* @return Twig_SimpleFunction
*/
protected function getCurrencyCode(): Twig_SimpleFunction
protected function getMetaField(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'getCurrencyCode',
function (): string {
return app('amount')->getCurrencyCode();
}
);
}
'accountGetMetaField',
static function (Account $account, string $field): string {
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$result = $repository->getMetaValue($account, $field);
if (null === $result) {
return '';
}
/**
* @return Twig_SimpleFunction
*/
protected function getCurrencySymbol(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'getCurrencySymbol',
function (): string {
return app('amount')->getCurrencySymbol();
return $result;
}
);
}
@ -257,6 +255,8 @@ class General extends Twig_Extension
}
/**
* Show icon with attachment.
*
* @return Twig_SimpleFilter
*/
protected function mimeIcon(): Twig_SimpleFilter
@ -334,6 +334,8 @@ class General extends Twig_Extension
}
/**
* Basic example thing for some views.
*
* @return Twig_SimpleFunction
*/
protected function phpdate(): Twig_SimpleFunction

View File

@ -1,223 +0,0 @@
<?php
/**
* Journal.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Support\Twig;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Category;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use FireflyIII\Support\Twig\Extension\TransactionJournal as TransactionJournalExtension;
use Twig_Extension;
use Twig_SimpleFilter;
use Twig_SimpleFunction;
/**
* Class Journal.
*/
class Journal extends Twig_Extension
{
/**
* @return Twig_SimpleFunction
*/
public function getDestinationAccount(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'destinationAccount',
function (TransactionJournal $journal) {
$cache = new CacheProperties;
$cache->addProperty($journal->id);
$cache->addProperty('transaction-journal');
$cache->addProperty('destination-account-string');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
$list = $repository->getJournalDestinationAccounts($journal);
$array = [];
/** @var Account $entry */
foreach ($list as $entry) {
if (AccountType::CASH === $entry->accountType->type) {
$array[] = '<span class="text-success">(cash)</span>';
continue;
}
$array[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($entry->name), route('accounts.show', $entry->id));
}
$array = array_unique($array);
$result = implode(', ', $array);
$cache->store($result);
return $result;
}
);
}
/**
* @return array
*/
public function getFilters(): array
{
$filters = [
new Twig_SimpleFilter('journalTotalAmount', [TransactionJournalExtension::class, 'totalAmount'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('journalTotalAmountPlain', [TransactionJournalExtension::class, 'totalAmountPlain'], ['is_safe' => ['html']]),
];
return $filters;
}
/**
* @return array
*/
public function getFunctions(): array
{
$functions = [
$this->getSourceAccount(),
$this->getDestinationAccount(),
$this->journalBudgets(),
$this->journalCategories(),
new Twig_SimpleFunction('journalGetMetaField', [TransactionJournalExtension::class, 'getMetaField']),
new Twig_SimpleFunction('journalHasMeta', [TransactionJournalExtension::class, 'hasMetaField']),
new Twig_SimpleFunction('journalGetMetaDate', [TransactionJournalExtension::class, 'getMetaDate']),
];
return $functions;
}
/**
* @return Twig_SimpleFunction
*/
public function getSourceAccount(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'sourceAccount',
function (TransactionJournal $journal): string {
$cache = new CacheProperties;
$cache->addProperty($journal->id);
$cache->addProperty('transaction-journal');
$cache->addProperty('source-account-string');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
$list = $repository->getJournalSourceAccounts($journal);
$array = [];
/** @var Account $entry */
foreach ($list as $entry) {
if (AccountType::CASH === $entry->accountType->type) {
$array[] = '<span class="text-success">(cash)</span>';
continue;
}
$array[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($entry->name), route('accounts.show', $entry->id));
}
$array = array_unique($array);
$result = implode(', ', $array);
$cache->store($result);
return $result;
}
);
}
/**
* @return Twig_SimpleFunction
*/
public function journalBudgets(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'journalBudgets',
function (TransactionJournal $journal): string {
$cache = new CacheProperties;
$cache->addProperty($journal->id);
$cache->addProperty('transaction-journal');
$cache->addProperty('budget-string');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$budgets = [];
// get all budgets:
foreach ($journal->budgets as $budget) {
$budgets[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($budget->name), route('budgets.show', $budget->id));
}
// and more!
foreach ($journal->transactions as $transaction) {
foreach ($transaction->budgets as $budget) {
$budgets[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($budget->name), route('budgets.show', $budget->id));
}
}
$string = implode(', ', array_unique($budgets));
$cache->store($string);
return $string;
}
);
}
/**
* @return Twig_SimpleFunction
*/
public function journalCategories(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'journalCategories',
function (TransactionJournal $journal): string {
$cache = new CacheProperties;
$cache->addProperty($journal->id);
$cache->addProperty('transaction-journal');
$cache->addProperty('category-string');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$categories = [];
// get all categories for the journal itself (easy):
foreach ($journal->categories as $category) {
$categories[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($category->name), route('categories.show', $category->id));
}
if (0 === \count($categories)) {
$set = Category::distinct()->leftJoin('category_transaction', 'categories.id', '=', 'category_transaction.category_id')
->leftJoin('transactions', 'category_transaction.transaction_id', '=', 'transactions.id')
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('categories.user_id', $journal->user_id)
->where('transaction_journals.id', $journal->id)
->whereNull('transactions.deleted_at')
->get(['categories.*']);
/** @var Category $category */
foreach ($set as $category) {
$categories[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($category->name), route('categories.show', $category->id));
}
}
$string = implode(', ', array_unique($categories));
$cache->store($string);
return $string;
}
);
}
}

View File

@ -1,52 +0,0 @@
<?php
/**
* AccountLoader.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Support\Twig\Loader;
use FireflyIII\Support\Twig\Extension\Account;
use Twig_RuntimeLoaderInterface;
/**
* Class AccountLoader.
*/
class AccountLoader implements Twig_RuntimeLoaderInterface
{
/**
* Creates the runtime implementation of a Twig element (filter/function/test).
*
* @param string $class A runtime class
*
* @return object|null The runtime instance or null if the loader does not know how to create the runtime for this class
*/
public function load($class)
{
// implement the logic to create an instance of $class
// and inject its dependencies
// most of the time, it means using your dependency injection container
if (Account::class === $class) {
return app(Account::class);
}
return null;
}
}

View File

@ -1,52 +0,0 @@
<?php
/**
* TransactionJournalLoader.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Support\Twig\Loader;
use FireflyIII\Support\Twig\Extension\TransactionJournal;
use Twig_RuntimeLoaderInterface;
/**
* Class TransactionJournalLoader.
*/
class TransactionJournalLoader implements Twig_RuntimeLoaderInterface
{
/**
* Creates the runtime implementation of a Twig element (filter/function/test).
*
* @param string $class A runtime class
*
* @return object|null The runtime instance or null if the loader does not know how to create the runtime for this class
*/
public function load($class)
{
// implement the logic to create an instance of $class
// and inject its dependencies
// most of the time, it means using your dependency injection container
if (TransactionJournal::class === $class) {
return app(TransactionJournal::class);
}
return null;
}
}

View File

@ -1,52 +0,0 @@
<?php
/**
* TransactionLoader.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Support\Twig\Loader;
use FireflyIII\Support\Twig\Extension\Transaction;
use Twig_RuntimeLoaderInterface;
/**
* Class TransactionLoader.
*/
class TransactionLoader implements Twig_RuntimeLoaderInterface
{
/**
* Creates the runtime implementation of a Twig element (filter/function/test).
*
* @param string $class A runtime class
*
* @return object|null The runtime instance or null if the loader does not know how to create the runtime for this class
*/
public function load($class)
{
// implement the logic to create an instance of $class
// and inject its dependencies
// most of the time, it means using your dependency injection container
if (Transaction::class === $class) {
return app(Transaction::class);
}
return null;
}
}

View File

@ -1,55 +0,0 @@
<?php
/**
* Transaction.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Support\Twig;
use FireflyIII\Support\Twig\Extension\Transaction as TransactionExtension;
use Twig_Extension;
use Twig_SimpleFilter;
/**
* Class Transaction.
*/
class Transaction extends Twig_Extension
{
/**
* @return array
*/
public function getFilters(): array
{
$filters = [
new Twig_SimpleFilter('transactionIcon', [TransactionExtension::class, 'icon'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('transactionDescription', [TransactionExtension::class, 'description']),
new Twig_SimpleFilter('transactionIsSplit', [TransactionExtension::class, 'isSplit'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('transactionReconciled', [TransactionExtension::class, 'isReconciled'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('transactionHasAtt', [TransactionExtension::class, 'hasAttachments'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('transactionAmount', [TransactionExtension::class, 'amount'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('transactionArrayAmount', [TransactionExtension::class, 'amountArray'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('transactionBudgets', [TransactionExtension::class, 'budgets'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('transactionCategories', [TransactionExtension::class, 'categories'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('transactionSourceAccount', [TransactionExtension::class, 'sourceAccount'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('transactionDestinationAccount', [TransactionExtension::class, 'destinationAccount'], ['is_safe' => ['html']]),
];
return $filters;
}
}

View File

@ -23,6 +23,8 @@ declare(strict_types=1);
namespace FireflyIII\Support\Twig\Extension;
use Carbon\Carbon;
use DB;
use FireflyIII\Models\TransactionType;
use Twig_Extension;
use Twig_SimpleFunction;
@ -40,6 +42,9 @@ class TransactionGroupTwig extends Twig_Extension
return [
$this->transactionAmount(),
$this->groupAmount(),
$this->journalHasMeta(),
$this->journalGetMetaDate(),
$this->journalGetMetaField()
];
}
@ -64,6 +69,71 @@ class TransactionGroupTwig extends Twig_Extension
);
}
/**
* @return Twig_SimpleFunction
*/
public function journalGetMetaDate(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'journalGetMetaDate',
static function (int $journalId, string $metaField) {
$entry = DB::table('journal_meta')
->where('name', $metaField)
->where('transaction_journal_id', $journalId)
->whereNull('deleted_at')
->first();
if (null === $entry) {
return new Carbon;
}
return new Carbon(json_decode($entry->data, false));
}
);
}
/**
* @return Twig_SimpleFunction
*/
public function journalGetMetaField(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'journalGetMetaField',
static function (int $journalId, string $metaField) {
$entry = DB::table('journal_meta')
->where('name', $metaField)
->where('transaction_journal_id', $journalId)
->whereNull('deleted_at')
->first();
if (null === $entry) {
return '';
}
return json_decode($entry->data, true);
}
);
}
/**
* @return Twig_SimpleFunction
*/
public function journalHasMeta(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'journalHasMeta',
static function (int $journalId, string $metaField) {
$count = DB::table('journal_meta')
->where('name', $metaField)
->where('transaction_journal_id', $journalId)
->whereNull('deleted_at')
->count();
return 1 === $count;
}
);
}
/**
* @return Twig_SimpleFunction
*/

View File

@ -48,36 +48,4 @@ class Translation extends Twig_Extension
return $filters;
}
/**
* {@inheritdoc}
*/
public function getFunctions(): array
{
return [
$this->journalLinkTranslation(),
];
}
/**
* @return Twig_SimpleFunction
*/
public function journalLinkTranslation(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'journalLinkTranslation',
function (string $direction, string $original) {
$key = sprintf('firefly.%s_%s', $original, $direction);
$translation = trans($key);
if ($key === $translation) {
return $original;
}
return $translation;
},
['is_safe' => ['html']]
);
}
}

View File

@ -23,9 +23,15 @@ declare(strict_types=1);
namespace FireflyIII\Transformers;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
use FireflyIII\Support\NullArrayObject;
use Illuminate\Support\Collection;
/**
* Class TransactionGroupTransformer
@ -88,6 +94,172 @@ class TransactionGroupTransformer extends AbstractTransformer
return $result;
}
/**
* @param TransactionGroup $group
*
* @return array
*/
public function transformObject(TransactionGroup $group): array
{
//$first = $group->transactionJournals->first();
$result = [
'id' => (int)$group->id,
'created_at' => $group->created_at->toAtomString(),
'updated_at' => $group->updated_at->toAtomString(),
'user' => (int)$group->user_id,
'group_title' => $group->title,
'transactions' => $this->transformJournals($group->transactionJournals),
'links' => [
[
'rel' => 'self',
'uri' => '/transactions/' . $group->id,
],
],
];
// do something else.
return $result;
}
/**
* @param TransactionJournal $journal
*
* @return Transaction
*/
private function getDestinationTransaction(TransactionJournal $journal): Transaction
{
return $journal->transactions->first(
static function (Transaction $transaction) {
return (float)$transaction->amount > 0;
}
);
}
/**
* @param TransactionJournal $journal
*
* @return Transaction
*/
private function getSourceTransaction(TransactionJournal $journal): Transaction
{
return $journal->transactions->first(
static function (Transaction $transaction) {
return (float)$transaction->amount < 0;
}
);
}
/**
* @param Collection $transactionJournals
*
* @return array
*/
private function transformJournals(Collection $transactionJournals): array
{
$result = [];
/** @var TransactionJournal $journal */
foreach ($transactionJournals as $journal) {
$source = $this->getSourceTransaction($journal);
$destination = $this->getDestinationTransaction($journal);
$type = $journal->transactionType->type;
// get amount
$amount = app('steam')->positive($source->amount);
if (TransactionType::WITHDRAWAL !== $type) {
$amount = app('steam')->negative($source->amount);
}
// get foreign amount:
$foreignAmount = null;
if (null !== $source->foreign_amount) {
$foreignAmount = TransactionType::WITHDRAWAL !== $type
? app('steam')->positive($source->foreign_amount)
: app('steam')->negative($source->foreign_amount);
}
$metaFieldData = $this->groupRepos->getMetaFields($journal->id, $this->metaFields);
$metaDateData = $this->groupRepos->getMetaDateFields($journal->id, $this->metaDateFields);
/** @var Budget $budget */
$budget = $journal->budgets->first();
/** @var Category $category */
$category = $journal->categories->first();
$currency = $source->transactionCurrency;
$result[] = [
'user' => (int)$journal->user_id,
'transaction_journal_id' => $journal->id,
'type' => strtolower($type),
'date' => $journal->date->toAtomString(),
'order' => $journal->order,
'currency_id' => $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
'foreign_currency_id' => $source->foreignCurrency ? $source->foreignCurrency->id : null,
'foreign_currency_code' => $source->foreignCurrency ? $source->foreignCurrency->code : null,
'foreign_currency_symbol' => $source->foreignCurrency ? $source->foreignCurrency->symbol : null,
'foreign_currency_decimal_places' => $source->foreignCurrency ? $source->foreignCurrency->decimal_places : null,
'amount' => $amount,
'foreign_amount' => $foreignAmount,
'description' => $journal->description,
'source_id' => $source->account_id,
'source_name' => $source->account->name,
'source_iban' => $source->account->iban,
'source_type' => $source->account->accountType->type,
'destination_id' => $destination->account_id,
'destination_name' => $destination->account->name,
'destination_iban' => $destination->account->iban,
'destination_type' => $destination->account->accountType->type,
'budget_id' => $budget ? $budget->id : null,
'budget_name' => $budget ? $budget->name : null,
'category_id' => $category ? $category->id : null,
'category_name' => $category ? $category->name : null,
'bill_id' => $journal->bill_id ?: null,
'bill_name' => $journal->bill_id ? $journal->bill->name : null,
'reconciled' => $source->reconciled,
'notes' => $this->groupRepos->getNoteText($journal->id),
'tags' => $this->groupRepos->getTags($journal->id),
'internal_reference' => $metaFieldData['internal_reference'],
'external_id' => $metaFieldData['external_id'],
'original_source' => $metaFieldData['original_source'],
'recurrence_id' => $metaFieldData['recurrence_id'],
'bunq_payment_id' => $metaFieldData['bunq_payment_id'],
'import_hash_v2' => $metaFieldData['import_hash_v2'],
'sepa_cc' => $metaFieldData['sepa_cc'],
'sepa_ct_op' => $metaFieldData['sepa_ct_op'],
'sepa_ct_id' => $metaFieldData['sepa_ct_id'],
'sepa_db' => $metaFieldData['sepa_ddb'],
'sepa_country' => $metaFieldData['sepa_country'],
'sepa_ep' => $metaFieldData['sepa_ep'],
'sepa_ci' => $metaFieldData['sepa_ci'],
'sepa_batch_id' => $metaFieldData['sepa_batch_id'],
'interest_date' => $metaDateData['interest_date'] ? $metaDateData['interest_date']->toAtomString() : null,
'book_date' => $metaDateData['book_date'] ? $metaDateData['book_date']->toAtomString() : null,
'process_date' => $metaDateData['process_date'] ? $metaDateData['process_date']->toAtomString() : null,
'due_date' => $metaDateData['due_date'] ? $metaDateData['due_date']->toAtomString() : null,
'payment_date' => $metaDateData['payment_date'] ? $metaDateData['payment_date']->toAtomString() : null,
'invoice_date' => $metaDateData['invoice_date'] ? $metaDateData['invoice_date']->toAtomString() : null,
];
}
return $result;
}
/**
* @param NullArrayObject $data
*

View File

@ -68,11 +68,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property bool blocked
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string $password
* @property string|null $remember_token
* @property string|null $reset
* @property bool $blocked
* @property string|null $blocked_code
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Account[] $accounts
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Attachment[] $attachments
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\AvailableBudget[] $availableBudgets
@ -87,7 +84,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBank[] $piggyBanks
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Preference[] $preferences
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Recurrence[] $recurrences
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Role[] $roles
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\RuleGroup[] $ruleGroups
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Rule[] $rules
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Tag[] $tags

View File

@ -65,6 +65,9 @@ class AccountValidator
$this->combinations = config('firefly.source_dests');
/** @var AccountRepositoryInterface accountRepository */
$this->accountRepository = app(AccountRepositoryInterface::class);
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/**

View File

@ -110,15 +110,20 @@ trait TransactionValidation
$data = $validator->getData();
$transactions = $data['transactions'] ?? [];
foreach ($transactions as $index => $transaction) {
// must have currency info.
if (isset($transaction['foreign_amount'])
&& !(isset($transaction['foreign_currency_id'])
|| isset($transaction['foreign_currency_code']))) {
// if foreign amount is present, then the currency must be as well.
if (isset($transaction['foreign_amount']) && !(isset($transaction['foreign_currency_id']) || isset($transaction['foreign_currency_code']))) {
$validator->errors()->add(
'transactions.' . $index . '.foreign_amount',
(string)trans('validation.require_currency_info')
);
}
// if the currency is present, then the amount must be present as well.
if ((isset($transaction['foreign_currency_id']) || isset($transaction['foreign_currency_code'])) && !isset($transaction['foreign_amount'])) {
$validator->errors()->add(
'transactions.' . $index . '.foreign_amount',
(string)trans('validation.require_currency_amount')
);
}
}
}
@ -196,16 +201,6 @@ trait TransactionValidation
}
}
/**
* If type is set, source + destination info is mandatory.
*
* @param Validator $validator
*/
protected function validateAccountPresence(Validator $validator): void
{
// TODO
}
/**
* @param Validator $validator
*/
@ -299,113 +294,12 @@ trait TransactionValidation
return;
}
foreach ($transactions as $index => $transaction) {
$journalId = (int)($transaction['transaction_journal_id'] ?? 0);
$journalId = $transaction['transaction_journal_id'] ?? null;
$journalId = null === $journalId ? null : (int)$journalId;
$count = $transactionGroup->transactionJournals()->where('id', $journalId)->count();
if (0 === $journalId || 0 === $count) {
if (null === $journalId || (null !== $journalId && 0 !== $journalId && 0 === $count)) {
$validator->errors()->add(sprintf('transactions.%d.source_name', $index), (string)trans('validation.need_id_in_edit'));
}
}
}
// /**
// * Throws an error when this asset account is invalid.
// *
// * @noinspection MoreThanThreeArgumentsInspection
// *
// * @param Validator $validator
// * @param int|null $accountId
// * @param null|string $accountName
// * @param string $idField
// * @param string $nameField
// *
// * @return null|Account
// */
// protected function assetAccountExists(Validator $validator, ?int $accountId, ?string $accountName, string $idField, string $nameField): ?Account
// {
// /** @var User $admin */
// $admin = auth()->user();
// $accountId = (int)$accountId;
// $accountName = (string)$accountName;
// // both empty? hard exit.
// if ($accountId < 1 && '' === $accountName) {
// $validator->errors()->add($idField, (string)trans('validation.filled', ['attribute' => $idField]));
//
// return null;
// }
// // ID belongs to user and is asset account:
// /** @var AccountRepositoryInterface $repository */
// $repository = app(AccountRepositoryInterface::class);
// $repository->setUser($admin);
// $set = $repository->getAccountsById([$accountId]);
// Log::debug(sprintf('Count of accounts found by ID %d is: %d', $accountId, $set->count()));
// if (1 === $set->count()) {
// /** @var Account $first */
// $first = $set->first();
// if ($first->accountType->type !== AccountType::ASSET) {
// $validator->errors()->add($idField, (string)trans('validation.belongs_user'));
//
// return null;
// }
//
// // we ignore the account name at this point.
// return $first;
// }
//
// $account = $repository->findByName($accountName, [AccountType::ASSET]);
// if (null === $account) {
// $validator->errors()->add($nameField, (string)trans('validation.belongs_user'));
//
// return null;
// }
//
// return $account;
// }
//
// /**
// * Throws an error when the given opposing account (of type $type) is invalid.
// * Empty data is allowed, system will default to cash.
// *
// * @noinspection MoreThanThreeArgumentsInspection
// *
// * @param Validator $validator
// * @param string $type
// * @param int|null $accountId
// * @param null|string $accountName
// * @param string $idField
// *
// * @return null|Account
// */
// protected function opposingAccountExists(Validator $validator, string $type, ?int $accountId, ?string $accountName, string $idField): ?Account
// {
// /** @var User $admin */
// $admin = auth()->user();
// $accountId = (int)$accountId;
// $accountName = (string)$accountName;
// // both empty? done!
// if ($accountId < 1 && '' === $accountName) {
// return null;
// }
// if (0 !== $accountId) {
// // ID belongs to user and is $type account:
// /** @var AccountRepositoryInterface $repository */
// $repository = app(AccountRepositoryInterface::class);
// $repository->setUser($admin);
// $set = $repository->getAccountsById([$accountId]);
// if (1 === $set->count()) {
// /** @var Account $first */
// $first = $set->first();
// if ($first->accountType->type !== $type) {
// $validator->errors()->add($idField, (string)trans('validation.belongs_user'));
//
// return null;
// }
//
// // we ignore the account name at this point.
// return $first;
// }
// }
//
// // not having an opposing account by this name is NOT a problem.
// return null;
// }
}

242
composer.lock generated
View File

@ -8,32 +8,28 @@
"packages": [
{
"name": "adldap2/adldap2",
"version": "v10.0.6",
"version": "v9.1.6",
"source": {
"type": "git",
"url": "https://github.com/Adldap2/Adldap2.git",
"reference": "efbf25c80861e47a5443d176dfa1a640000e8a20"
"reference": "d50204d3eff587957b4bb9d7382d2eda5009ed16"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Adldap2/Adldap2/zipball/efbf25c80861e47a5443d176dfa1a640000e8a20",
"reference": "efbf25c80861e47a5443d176dfa1a640000e8a20",
"url": "https://api.github.com/repos/Adldap2/Adldap2/zipball/d50204d3eff587957b4bb9d7382d2eda5009ed16",
"reference": "d50204d3eff587957b4bb9d7382d2eda5009ed16",
"shasum": ""
},
"require": {
"ext-ldap": "*",
"illuminate/contracts": "~5.0",
"php": ">=7.0",
"psr/log": "~1.1",
"tightenco/collect": "~5.0"
},
"require-dev": {
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~6.0"
},
"suggest": {
"ext-fileinfo": "fileinfo is required when retrieving user encoded thumbnails"
},
"type": "library",
"autoload": {
"psr-4": {
@ -61,24 +57,24 @@
"ldap",
"windows"
],
"time": "2019-03-22T18:25:32+00:00"
"time": "2019-04-03T19:41:38+00:00"
},
{
"name": "adldap2/adldap2-laravel",
"version": "v5.1.2",
"version": "v5.1.3",
"source": {
"type": "git",
"url": "https://github.com/Adldap2/Adldap2-Laravel.git",
"reference": "31f80dfad6950f80698986e91cb65eb0c441f182"
"reference": "1a8843b07b389ce26f6d122d19f9443224926d82"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Adldap2/Adldap2-Laravel/zipball/31f80dfad6950f80698986e91cb65eb0c441f182",
"reference": "31f80dfad6950f80698986e91cb65eb0c441f182",
"url": "https://api.github.com/repos/Adldap2/Adldap2-Laravel/zipball/1a8843b07b389ce26f6d122d19f9443224926d82",
"reference": "1a8843b07b389ce26f6d122d19f9443224926d82",
"shasum": ""
},
"require": {
"adldap2/adldap2": "^10.0",
"adldap2/adldap2": "^9.0",
"php": ">=7.1"
},
"require-dev": {
@ -114,7 +110,7 @@
"laravel",
"ldap"
],
"time": "2019-02-27T07:09:43+00:00"
"time": "2019-04-02T23:04:08+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -984,16 +980,16 @@
},
{
"name": "erusev/parsedown",
"version": "v1.7.2",
"version": "1.7.3",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown.git",
"reference": "d60bcdc46978357759ecb13cb4b078da783f8faf"
"reference": "6d893938171a817f4e9bc9e86f2da1e370b7bcd7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/d60bcdc46978357759ecb13cb4b078da783f8faf",
"reference": "d60bcdc46978357759ecb13cb4b078da783f8faf",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/6d893938171a817f4e9bc9e86f2da1e370b7bcd7",
"reference": "6d893938171a817f4e9bc9e86f2da1e370b7bcd7",
"shasum": ""
},
"require": {
@ -1026,7 +1022,7 @@
"markdown",
"parser"
],
"time": "2019-03-17T17:19:46+00:00"
"time": "2019-03-17T18:48:37+00:00"
},
{
"name": "fideloper/proxy",
@ -1313,16 +1309,16 @@
},
{
"name": "laravel/framework",
"version": "v5.8.9",
"version": "v5.8.11",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "2455d21938e9072e5a8ecef64ae162a1825d336b"
"reference": "a2cf7a7983329d63edc6fde43142b232bb61aa0a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/2455d21938e9072e5a8ecef64ae162a1825d336b",
"reference": "2455d21938e9072e5a8ecef64ae162a1825d336b",
"url": "https://api.github.com/repos/laravel/framework/zipball/a2cf7a7983329d63edc6fde43142b232bb61aa0a",
"reference": "a2cf7a7983329d63edc6fde43142b232bb61aa0a",
"shasum": ""
},
"require": {
@ -1456,7 +1452,7 @@
"framework",
"laravel"
],
"time": "2019-04-02T14:11:17+00:00"
"time": "2019-04-10T13:05:18+00:00"
},
{
"name": "laravel/passport",
@ -1656,34 +1652,35 @@
},
{
"name": "league/commonmark",
"version": "0.18.5",
"version": "0.19.1",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
"reference": "f94e18d68260f43a7d846279cad88405854b1306"
"reference": "d42b2d4a5d0a8eb2a4514f828ecb6f5db13a7c6f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/f94e18d68260f43a7d846279cad88405854b1306",
"reference": "f94e18d68260f43a7d846279cad88405854b1306",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/d42b2d4a5d0a8eb2a4514f828ecb6f5db13a7c6f",
"reference": "d42b2d4a5d0a8eb2a4514f828ecb6f5db13a7c6f",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": ">=5.6.5"
"php": "^7.1"
},
"replace": {
"colinodell/commonmark-php": "*"
},
"require-dev": {
"cebe/markdown": "~1.0",
"commonmark/commonmark.js": "0.28",
"commonmark/commonmark.js": "0.29.0",
"erusev/parsedown": "~1.0",
"michelf/php-markdown": "~1.4",
"mikehaertl/php-shellcommand": "^1.2",
"phpunit/phpunit": "^5.7.27|^6.5.14",
"scrutinizer/ocular": "^1.1",
"symfony/finder": "^3.0|^4.0"
"mikehaertl/php-shellcommand": "^1.4",
"phpstan/phpstan-shim": "^0.11.5",
"phpunit/phpunit": "^7.5",
"scrutinizer/ocular": "^1.5",
"symfony/finder": "^4.2"
},
"suggest": {
"league/commonmark-extras": "Library of useful extensions including smart punctuation"
@ -1694,12 +1691,12 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.19-dev"
"dev-master": "0.20-dev"
}
},
"autoload": {
"psr-4": {
"League\\CommonMark\\": "src/"
"League\\CommonMark\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -1715,13 +1712,13 @@
}
],
"description": "PHP Markdown parser based on the CommonMark spec",
"homepage": "https://github.com/thephpleague/commonmark",
"homepage": "https://commonmark.thephpleague.com",
"keywords": [
"commonmark",
"markdown",
"parser"
],
"time": "2019-03-28T13:52:31+00:00"
"time": "2019-04-11T04:37:01+00:00"
},
{
"name": "league/csv",
@ -2309,16 +2306,16 @@
},
{
"name": "nesbot/carbon",
"version": "2.16.2",
"version": "2.16.3",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "720a9c36927396efeeb48a972e9d129d44b6dc28"
"reference": "373d9f0d58651af366435148c39beb702c2b7ef4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/720a9c36927396efeeb48a972e9d129d44b6dc28",
"reference": "720a9c36927396efeeb48a972e9d129d44b6dc28",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/373d9f0d58651af366435148c39beb702c2b7ef4",
"reference": "373d9f0d58651af366435148c39beb702c2b7ef4",
"shasum": ""
},
"require": {
@ -2365,7 +2362,7 @@
"datetime",
"time"
],
"time": "2019-03-29T12:23:12+00:00"
"time": "2019-04-06T17:09:23+00:00"
},
{
"name": "opis/closure",
@ -3308,16 +3305,16 @@
},
{
"name": "symfony/console",
"version": "v4.2.4",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "9dc2299a016497f9ee620be94524e6c0af0280a9"
"reference": "24206aff3efe6962593297e57ef697ebb220e384"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/9dc2299a016497f9ee620be94524e6c0af0280a9",
"reference": "9dc2299a016497f9ee620be94524e6c0af0280a9",
"url": "https://api.github.com/repos/symfony/console/zipball/24206aff3efe6962593297e57ef697ebb220e384",
"reference": "24206aff3efe6962593297e57ef697ebb220e384",
"shasum": ""
},
"require": {
@ -3376,7 +3373,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2019-02-23T15:17:42+00:00"
"time": "2019-04-01T07:32:59+00:00"
},
{
"name": "symfony/contracts",
@ -3448,7 +3445,7 @@
},
{
"name": "symfony/css-selector",
"version": "v4.2.4",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
@ -3501,16 +3498,16 @@
},
{
"name": "symfony/debug",
"version": "v4.2.4",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "de73f48977b8eaf7ce22814d66e43a1662cc864f"
"reference": "43ce8ab34c734dcc8a4af576cb86711daab964c5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/de73f48977b8eaf7ce22814d66e43a1662cc864f",
"reference": "de73f48977b8eaf7ce22814d66e43a1662cc864f",
"url": "https://api.github.com/repos/symfony/debug/zipball/43ce8ab34c734dcc8a4af576cb86711daab964c5",
"reference": "43ce8ab34c734dcc8a4af576cb86711daab964c5",
"shasum": ""
},
"require": {
@ -3553,20 +3550,20 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2019-03-03T18:11:24+00:00"
"time": "2019-03-10T17:09:50+00:00"
},
{
"name": "symfony/event-dispatcher",
"version": "v4.2.4",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "3354d2e6af986dd71f68b4e5cf4a933ab58697fb"
"reference": "ca5af306fbc37f3cf597e91bc9cfa0c7d3f33544"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/3354d2e6af986dd71f68b4e5cf4a933ab58697fb",
"reference": "3354d2e6af986dd71f68b4e5cf4a933ab58697fb",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ca5af306fbc37f3cf597e91bc9cfa0c7d3f33544",
"reference": "ca5af306fbc37f3cf597e91bc9cfa0c7d3f33544",
"shasum": ""
},
"require": {
@ -3617,11 +3614,11 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2019-02-23T15:17:42+00:00"
"time": "2019-03-30T15:58:42+00:00"
},
{
"name": "symfony/finder",
"version": "v4.2.4",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
@ -3670,16 +3667,16 @@
},
{
"name": "symfony/http-foundation",
"version": "v4.2.4",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "850a667d6254ccf6c61d853407b16f21c4579c77"
"reference": "5b7ab6beaa5b053b8d3c9b13367ada9b292e12e1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/850a667d6254ccf6c61d853407b16f21c4579c77",
"reference": "850a667d6254ccf6c61d853407b16f21c4579c77",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/5b7ab6beaa5b053b8d3c9b13367ada9b292e12e1",
"reference": "5b7ab6beaa5b053b8d3c9b13367ada9b292e12e1",
"shasum": ""
},
"require": {
@ -3720,20 +3717,20 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2019-02-26T08:03:39+00:00"
"time": "2019-03-30T15:58:42+00:00"
},
{
"name": "symfony/http-kernel",
"version": "v4.2.4",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "895ceccaa8149f9343e6134e607c21da42d73b7a"
"reference": "e8b940bbeebf0f96789b5d17d9d77f8b2613960b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/895ceccaa8149f9343e6134e607c21da42d73b7a",
"reference": "895ceccaa8149f9343e6134e607c21da42d73b7a",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/e8b940bbeebf0f96789b5d17d9d77f8b2613960b",
"reference": "e8b940bbeebf0f96789b5d17d9d77f8b2613960b",
"shasum": ""
},
"require": {
@ -3809,7 +3806,7 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2019-03-03T19:38:09+00:00"
"time": "2019-04-02T19:03:51+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -4214,16 +4211,16 @@
},
{
"name": "symfony/process",
"version": "v4.2.4",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "6c05edb11fbeff9e2b324b4270ecb17911a8b7ad"
"reference": "1e6cbb41dadcaf29e0db034d6ad0d039a9df06e6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/6c05edb11fbeff9e2b324b4270ecb17911a8b7ad",
"reference": "6c05edb11fbeff9e2b324b4270ecb17911a8b7ad",
"url": "https://api.github.com/repos/symfony/process/zipball/1e6cbb41dadcaf29e0db034d6ad0d039a9df06e6",
"reference": "1e6cbb41dadcaf29e0db034d6ad0d039a9df06e6",
"shasum": ""
},
"require": {
@ -4259,7 +4256,7 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2019-01-24T22:05:03+00:00"
"time": "2019-03-10T20:07:02+00:00"
},
{
"name": "symfony/psr-http-message-bridge",
@ -4328,16 +4325,16 @@
},
{
"name": "symfony/routing",
"version": "v4.2.4",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
"reference": "ff03eae644e6b1e26d4a04b2385fe3a1a7f04e42"
"reference": "319f600c1ea0f981f6bdc2f042cfc1690957c0e0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/ff03eae644e6b1e26d4a04b2385fe3a1a7f04e42",
"reference": "ff03eae644e6b1e26d4a04b2385fe3a1a7f04e42",
"url": "https://api.github.com/repos/symfony/routing/zipball/319f600c1ea0f981f6bdc2f042cfc1690957c0e0",
"reference": "319f600c1ea0f981f6bdc2f042cfc1690957c0e0",
"shasum": ""
},
"require": {
@ -4360,7 +4357,6 @@
"suggest": {
"doctrine/annotations": "For using the annotation loader",
"symfony/config": "For using the all-in-one router or any loader",
"symfony/dependency-injection": "For loading routes from a service",
"symfony/expression-language": "For using expression matching",
"symfony/http-foundation": "For using a Symfony Request object",
"symfony/yaml": "For using the YAML loader"
@ -4401,20 +4397,20 @@
"uri",
"url"
],
"time": "2019-02-23T15:17:42+00:00"
"time": "2019-03-30T15:58:42+00:00"
},
{
"name": "symfony/translation",
"version": "v4.2.4",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "748464177a77011f8f4cdd076773862ce4915f8f"
"reference": "e46933cc31b68f51f7fc5470fb55550407520f56"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/748464177a77011f8f4cdd076773862ce4915f8f",
"reference": "748464177a77011f8f4cdd076773862ce4915f8f",
"url": "https://api.github.com/repos/symfony/translation/zipball/e46933cc31b68f51f7fc5470fb55550407520f56",
"reference": "e46933cc31b68f51f7fc5470fb55550407520f56",
"shasum": ""
},
"require": {
@ -4474,11 +4470,11 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2019-02-27T03:31:50+00:00"
"time": "2019-04-01T14:13:08+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v4.2.4",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
@ -4554,16 +4550,16 @@
},
{
"name": "tightenco/collect",
"version": "v5.8.8",
"version": "v5.8.11",
"source": {
"type": "git",
"url": "https://github.com/tightenco/collect.git",
"reference": "96297c72453eaf311dd0ce448ee48168a994ba97"
"reference": "1e4120c90b3536a9ebd080d50ecaae7b75719054"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tightenco/collect/zipball/96297c72453eaf311dd0ce448ee48168a994ba97",
"reference": "96297c72453eaf311dd0ce448ee48168a994ba97",
"url": "https://api.github.com/repos/tightenco/collect/zipball/1e4120c90b3536a9ebd080d50ecaae7b75719054",
"reference": "1e4120c90b3536a9ebd080d50ecaae7b75719054",
"shasum": ""
},
"require": {
@ -4600,7 +4596,7 @@
"collection",
"laravel"
],
"time": "2019-03-20T13:29:24+00:00"
"time": "2019-04-02T20:31:59+00:00"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
@ -5016,16 +5012,16 @@
},
{
"name": "composer/composer",
"version": "1.8.4",
"version": "1.8.5",
"source": {
"type": "git",
"url": "https://github.com/composer/composer.git",
"reference": "bc364c2480c17941e2135cfc568fa41794392534"
"reference": "949b116f9e7d98d8d276594fed74b580d125c0e6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/composer/zipball/bc364c2480c17941e2135cfc568fa41794392534",
"reference": "bc364c2480c17941e2135cfc568fa41794392534",
"url": "https://api.github.com/repos/composer/composer/zipball/949b116f9e7d98d8d276594fed74b580d125c0e6",
"reference": "949b116f9e7d98d8d276594fed74b580d125c0e6",
"shasum": ""
},
"require": {
@ -5092,7 +5088,7 @@
"dependency",
"package"
],
"time": "2019-02-11T09:52:10+00:00"
"time": "2019-04-09T15:46:48+00:00"
},
{
"name": "composer/semver",
@ -5656,16 +5652,16 @@
},
{
"name": "myclabs/deep-copy",
"version": "1.8.1",
"version": "1.9.1",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8"
"reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8",
"reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72",
"reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72",
"shasum": ""
},
"require": {
@ -5700,7 +5696,7 @@
"object",
"object graph"
],
"time": "2018-06-11T23:09:50+00:00"
"time": "2019-04-07T13:18:21+00:00"
},
{
"name": "phar-io/manifest",
@ -6273,16 +6269,16 @@
},
{
"name": "phpunit/phpunit",
"version": "8.0.6",
"version": "8.1.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "925109f8bbe6dae28fbc7bb07446a53abd3b1c25"
"reference": "e7450b51b6f5d29edcd645ff72b355ab0633ca35"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/925109f8bbe6dae28fbc7bb07446a53abd3b1c25",
"reference": "925109f8bbe6dae28fbc7bb07446a53abd3b1c25",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7450b51b6f5d29edcd645ff72b355ab0633ca35",
"reference": "e7450b51b6f5d29edcd645ff72b355ab0633ca35",
"shasum": ""
},
"require": {
@ -6325,7 +6321,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "8.0-dev"
"dev-master": "8.1-dev"
}
},
"autoload": {
@ -6351,7 +6347,7 @@
"testing",
"xunit"
],
"time": "2019-03-26T14:00:24+00:00"
"time": "2019-04-08T16:03:02+00:00"
},
{
"name": "roave/security-advisories",
@ -6359,12 +6355,12 @@
"source": {
"type": "git",
"url": "https://github.com/Roave/SecurityAdvisories.git",
"reference": "0698207bf8a9bed212fdde2d8c7cdc77085660c4"
"reference": "ff41a9a96718245c7160588928e6d217cfb0393c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/0698207bf8a9bed212fdde2d8c7cdc77085660c4",
"reference": "0698207bf8a9bed212fdde2d8c7cdc77085660c4",
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/ff41a9a96718245c7160588928e6d217cfb0393c",
"reference": "ff41a9a96718245c7160588928e6d217cfb0393c",
"shasum": ""
},
"conflict": {
@ -6384,8 +6380,8 @@
"codeigniter/framework": "<=3.0.6",
"composer/composer": "<=1.0.0-alpha11",
"contao-components/mediaelement": ">=2.14.2,<2.21.1",
"contao/core": ">=2,<3.5.35",
"contao/core-bundle": ">=4,<4.4.18|>=4.5,<4.5.8",
"contao/core": ">=2,<3.5.39",
"contao/core-bundle": ">=4,<4.4.37|>=4.5,<4.7.3",
"contao/listing-bundle": ">=4,<4.4.8",
"contao/newsletter-bundle": ">=4,<4.1",
"david-garcia/phpwhois": "<=4.3.1",
@ -6399,9 +6395,9 @@
"doctrine/mongodb-odm-bundle": ">=2,<3.0.1",
"doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1",
"dompdf/dompdf": ">=0.6,<0.6.2",
"drupal/core": ">=7,<7.64|>=8,<8.5.13|>=8.6,<8.6.12",
"drupal/core": ">=7,<7.65|>=8,<8.5.14|>=8.6,<8.6.13",
"drupal/drupal": ">=7,<7.64|>=8,<8.5.13|>=8.6,<8.6.12",
"erusev/parsedown": "<1.7",
"erusev/parsedown": "<1.7.2",
"ezsystems/ezpublish-kernel": ">=5.3,<5.3.12.1|>=5.4,<5.4.13.1|>=6,<6.7.9.1|>=6.8,<6.13.5.1|>=7,<7.2.4.1|>=7.3,<7.3.2.1",
"ezsystems/ezpublish-legacy": ">=5.3,<5.3.12.6|>=5.4,<5.4.12.3|>=2011,<2017.12.4.3|>=2018.6,<2018.6.1.4|>=2018.9,<2018.9.1.3",
"ezsystems/repository-forms": ">=2.3,<2.3.2.1",
@ -6556,7 +6552,7 @@
}
],
"description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it",
"time": "2019-03-28T22:30:08+00:00"
"time": "2019-04-12T16:05:24+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@ -7222,7 +7218,7 @@
},
{
"name": "symfony/filesystem",
"version": "v4.2.4",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
@ -7272,16 +7268,16 @@
},
{
"name": "theseer/tokenizer",
"version": "1.1.0",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/theseer/tokenizer.git",
"reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b"
"reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b",
"reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b",
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/1c42705be2b6c1de5904f8afacef5895cab44bf8",
"reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8",
"shasum": ""
},
"require": {
@ -7308,7 +7304,7 @@
}
],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"time": "2017-04-07T12:08:54+00:00"
"time": "2019-04-04T09:56:43+00:00"
},
{
"name": "webmozart/assert",

View File

@ -22,40 +22,5 @@
$(function () {
"use strict";
var transactions = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
identify: function (obj) {
return obj.id;
},
prefetch: {
url: autoCompleteUri + '?uid=' + uid,
// filter: function (list) {
// return $.map(list, function (name) {
// return {name: name.name};
// });
// }
},
remote: {
url: autoCompleteUri + '?search=%QUERY&uid=' + uid,
wildcard: '%QUERY'
// filter: function (list) {
// return $.map(list, function (name) {
// return {name: name.name};
// });
// }
}
});
transactions.initialize();
var input = $("#link_other");
input.typeahead({hint: true, highlight: true,}, {source: transactions, displayKey: 'name', autoSelect: false});
input.bind('typeahead:select', function (ev, suggestion) {
console.log('Selection: ' + suggestion.name);
if (suggestion.name.toLowerCase() === input.val().toLowerCase()) {
// This means the exact match is found. Use toLowerCase() if you want case insensitive match.
$('input[name="link_journal_id"]').val(suggestion.id);
} else {
$('input[name="link_journal_id"]').val(0);
}
});
});

11944
public/v1/js/lib/vue.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -634,6 +634,9 @@ return [
'converted_to_Transfer' => 'The transaction has been converted to a transfer',
'invalid_convert_selection' => 'The account you have selected is already used in this transaction or does not exist.',
'source_or_dest_invalid' => 'Cannot find the correct transaction details. Conversion is not possible.',
'convert_to_withdrawal' => 'Convert to a withdrawal',
'convert_to_deposit' => 'Convert to a deposit',
'convert_to_transfer' => 'Convert to a transfer',
// create new stuff:
'create_new_withdrawal' => 'Create new withdrawal',
@ -1156,6 +1159,8 @@ return [
'transaction_journal_information' => 'Transaction information',
'transaction_journal_meta' => 'Meta information',
'transaction_journal_more' => 'More information',
'att_part_of_journal' => 'Stored under ":journal"',
'total_amount' => 'Total amount',
'number_of_decimals' => 'Number of decimals',

View File

@ -45,6 +45,7 @@ return [
'at_least_one_repetition' => 'Need at least one repetition.',
'require_repeat_until' => 'Require either a number of repetitions, or an end date (repeat_until). Not both.',
'require_currency_info' => 'The content of this field is invalid without currency information.',
'require_currency_amount' => 'The content of this field is invalid without foreign amount information.',
'equal_description' => 'Transaction description should not equal global description.',
'file_invalid_mime' => 'File ":name" is of type ":mime" which is not accepted as a new upload.',
'file_too_large' => 'File ":name" is too large.',

View File

@ -1,141 +1 @@
<table class="table table-striped table-condensed">
<thead>
<tr class="ignore">
<th class="hidden-xs" colspan="2">&nbsp;</th>
<th>{{ trans('list.description') }}</th>
<th style="text-align:right;">{{ trans('list.amount') }}</th>
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.reconcile') }}</th>
<th class="hidden-xs hidden-sm">{{ trans('list.date') }}</th>
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.from') }}</th>
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.to') }}</th>
<th class="hidden-xs"><i class="fa fa-tasks fa-fw" title="{{ trans('list.budget') }}"></i></th>
<th class="hidden-xs"><i class="fa fa-bar-chart fa-fw" title="{{ trans('list.category') }}"></i></th>
</tr>
</thead>
<tbody>
{# data for previous/next markers #}
{% set endSet = false %}
{% set startSet = false %}
{% for transaction in transactions %}
{# start marker #}
{% if transaction.date < start and startSet == false %}
<tr>
<td colspan="5">
&nbsp;
</td>
<td colspan="3">
<span class="label label-default">
{{ trans('firefly.start_of_reconcile_period', {period: start.formatLocalized(monthAndDayFormat) }) }}
</span>
</td>
<td colspan="2">
&nbsp;
</td>
</tr>
{% set startSet = true %}
{% endif %}
{# end marker #}
{% if transaction.date <= end and endSet == false %}
<tr>
<td colspan="5">
&nbsp;
</td>
<td colspan="3">
<span class="label label-default">
{{ trans('firefly.end_of_reconcile_period', {period: end.formatLocalized(monthAndDayFormat) }) }}
</span>
</td>
<td colspan="2">
&nbsp;
</td>
</tr>
{% set endSet = true %}
{% endif %}
<tr data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ transaction.journal_id }}"
data-transaction-id="{{ transaction.id }}">
<td class="hidden-xs">
<div class="btn-group btn-group-xs">
<a href="{{ route('transactions.edit',transaction.journal_id) }}" class="btn btn-xs btn-default"><i
class="fa fa-fw fa-pencil"></i></a>
</div>
</td>
{# icon #}
<td class="hidden-xs">
{{ transaction|transactionIcon }}
</td>
{# description #}
<td>
<a href="{{ route('transactions.show',transaction.journal_id) }}">
{{ transaction|transactionDescription }}
</a>
{# is a split journal #}
{{ transaction|transactionIsSplit }}
{# count attachments #}
{{ transaction|transactionHasAtt }}
</td>
<td style="text-align: right;"><span style="margin-right:5px;">{{ transaction|transactionAmount }}</span></td>
<td>
{% if currency.id == transaction.transaction_currency_id %}
{% set transactionAmount = transaction.transaction_amount %}
{% else %}
{% set transactionAmount = transaction.transaction_foreign_amount %}
{% endif %}
{% if transaction.$array[$direction][$transactionType] %}
{{ transaction|transactionReconciled }}
<input type="hidden" name="cleared[]" data-younger="{% if transaction.date < start %}true{% else %}false{% endif %}"
data-inrange="{% if transaction.date >= start and transaction.date <= end %}true{% else %}false"{% endif %}"
class="cleared" data-id="{{ transaction.id }}" value="{{ transactionAmount }}">
{% else %}
<input type="checkbox" name="reconciled[]"
data-younger="{% if transaction.date < start %}true{% else %}false{% endif %}"
data-inrange="{% if transaction.date >= start and transaction.date <= end %}true{% else %}false"{% endif %}"
value="{{ transactionAmount }}" data-id="{{ transaction.id }}" disabled class="reconcile_checkbox">
{% endif %}
</td>
<td class="hidden-sm hidden-xs">
{{ transaction.date.formatLocalized(monthAndDayFormat) }}
</td>
<td class="hidden-xs hidden-sm hidden-md">
{# all source accounts #}
{{ transaction|transactionSourceAccount }}
</td>
<td class="hidden-xs hidden-sm hidden-md">
{# all destination accounts #}
{{ transaction|transactionDestinationAccount }}
</td>
<td class="hidden-xs">
{{ transaction|transactionBudgets }}
</td>
<td class="hidden-xs">
{{ transaction|transactionCategories }}
</td>
</tr>
{% endfor %}
{# if the start marker has not been generated yet, do it now, at the end of the loop. #}
{% if startSet == false %}
<tr>
<td colspan="5">
&nbsp;
</td>
<td colspan="3">
<span class="label label-default">
{{ trans('firefly.start_of_reconcile_period', {period: start.formatLocalized(monthAndDayFormat) }) }}
</span>
</td>
<td colspan="2">
&nbsp;
</td>
</tr>
{% set startSet = true %}
{% endif %}
</tbody>
</table>
<h1 style="color:red;">REPLACE ME</h1>

View File

@ -35,7 +35,7 @@
<td data-value="{{ link.source.description }}">
<a href="{{ route('transactions.show', [link.source_id]) }}">{{ link.source.description }}</a>
</td>
<td>{{ link.source|journalTotalAmount }}</td>
<td>{{ link.source|journalTXotalAmount }}</td>
<td>{{ journalLinkTranslation('outward', linkType.outward) }}</td>
<td data-value="{{ link.destination.description }}">
<a href="{{ route('transactions.show', [link.destination_id]) }}">{{ link.destination.description }}</a>

View File

@ -1,70 +1 @@
<tr class="drag" data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ transaction.journal_id }}"
data-transaction-id="{{ transaction.id }}"
>
{# input buttons #}
<td class="hidden-xs">
<div class="select_single" style="display:none;">
<input name="select_all_single[]" class="select_all_single" data-transaction="{{ transaction.id }}" value="{{ transaction.journal_id }}"
type="checkbox"/>
</div>
<div class="btn-group btn-group-xs edit_buttons edit_tr_buttons">{% if sorting %}<a href="#" class="handle btn btn-default btn-xs"><i
class="fa fa-fw fa-arrows-v"></i></a>{% endif %}<a href="{{ route('transactions.edit',transaction.journal_id) }}"
class="btn btn-xs btn-default"><i class="fa fa-fw fa-pencil"></i></a><a
href="{{ route('transactions.delete',transaction.journal_id) }}" class="btn btn-xs btn-danger"><i
class="fa fa-fw fa-trash-o"></i></a></div>
</td>
{# icon #}
<td class="hidden-xs">
{{ transaction|transactionIcon }}
</td>
{# description #}
<td>
{# is reconciled? #}
{{ transaction|transaction$array[$direction][$transactionType] }}
<a href="{{ route('transactions.show',transaction.journal_id) }}">
{{ transaction|transactionDescription }}
</a>
{# is a split journal #}
{{ transaction|transactionIsSplit }}
{# count attachments #}
{{ transaction|transactionHasAtt }}
</td>
<td style="text-align: right;"><span style="margin-right:5px;">{{ transaction|transactionAmount }}</span></td>
<td class="hidden-sm hidden-xs">
{{ transaction.date.formatLocalized(monthAndDayFormat) }}
</td>
<td class="hidden-xs hidden-sm hidden-md">
{{ transaction|transactionSourceAccount }}
</td>
<td class="hidden-xs hidden-sm hidden-md">
{{ transaction|transactionDestinationAccount }}
</td>
{% if not hideBudgets %}
<td class="hidden-xs">
{{ transaction|transactionBudgets }}
</td>
{% endif %}
{% if not hideCategories %}
<td class="hidden-xs">
{{ transaction|transactionCategories }}
</td>
{% endif %}
{% if not hideBills %}
<td class="hidden-xs">
{% if transaction.bill_id %}
<a href="{{ route('bills.show',transaction.bill_id) }}">{{ transaction.bill_name }}</a>
{% endif %}
</td>
{% endif %}
</tr>
<h1 style="color:red;">REPLACE ME</h1>

View File

@ -1,91 +1 @@
<tr class="drag" data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ transaction.journal_id }}" data-transaction-id="{{ transaction.id }}">
{# select buttons #}
<td class="hidden-xs select_boxes" style="display: none;">
<div class="select_single" style="display:none;">
<input name="select_all_single[]" class="select_all_single" data-transaction="{{ transaction.id }}" value="{{ transaction.journal_id }}"
type="checkbox"/>
</div>
</td>
{# icon #}
<td class="hidden-xs">
{{ transaction|transactionIcon }}
</td>
{# description #}
<td>
{# is reconciled? #}
{{ transaction|transactionReconciled }}
<a href="{{ route('transactions.show',transaction.journal_id) }}">
{{ transaction|transactionDescription }}
</a>
{# is a split journal #}
{{ transaction|transactionIsSplit }}
{# count attachments #}
{{ transaction|transactionHasAtt }}
</td>
{# amount #}
<td style="text-align: right;"><span style="margin-right:5px;">{{ transaction|transactionAmount }}</span></td>
{# date #}
<td class="hidden-sm hidden-xs">
{{ transaction.date.formatLocalized(monthAndDayFormat) }}
</td>
{# source #}
<td class="hidden-xs hidden-sm hidden-md">
{{ transaction|transactionSourceAccount }}
</td>
{# dest #}
<td class="hidden-xs hidden-sm hidden-md">
{{ transaction|transactionDestinationAccount }}
</td>
{# budget, if opted to show. #}
{% if showBudgets %}
<td class="hidden-xs">
{{ transaction|transactionBudgets }}
</td>
{% endif %}
{# category, if opted to show. #}
{% if showCategories %}
<td class="hidden-xs">
{{ transaction|transactionCategories }}
</td>
{% endif %}
{# bill, if opted to show#}
{% if showBill %}
<td class="hidden-xs">
{% if transaction.bill_id %}
<a href="{{ route('bills.show',transaction.bill_id) }}">{{ transaction.bill_name }}</a>
{% endif %}
</td>
{% endif %}
<td class="hidden-xs">
<div class="btn-group btn-group-xs pull-right">
{% if sorting %}<a href="#" class="handle btn btn-default"><i class="fa fa-fw fa-arrows-v"></i></a>{% endif %}
<div class="btn-group btn-group-xs">
<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 dropdown-menu-right" role="menu">
<li><a href="{{ route('transactions.edit',transaction.journal_id) }}"><i class="fa fa-fw fa-pencil"></i> {{ 'edit'|_ }}</a></li>
<li><a href="{{ route('transactions.delete',transaction.journal_id) }}"><i class="fa fa-fw fa-trash"></i> {{ 'delete'|_ }}</a></li>
<li role="separator" class="divider"></li>
<li><a href="{{ route('transactions.clone',transaction.journal_id) }}"><i class="fa fa-copy fa-fw"></i> {{ 'clone'|_ }}</a></li>
<li><a href="{{ route('transactions.split.edit',transaction.journal_id) }}"><i class="fa fa-unsorted fa-fw"></i> {{ 'split'|_ }}</a></li>
</ul>
</div>
</div>
</td>
</tr>
<h1 style="color:red;">REPLACE ME</h1>

View File

@ -1,87 +1,4 @@
<table class="table table-hover table-condensed">
<thead>
<tr>
<th>&nbsp;</th>
<th>{{ trans('list.description') }}</th>
<th>{{ trans('list.amount') }}</th>
<th class="hidden-sm hidden-xs">{{ trans('list.date') }}</th>
{% if not hideSource %}
<th class="hidden-xs">{{ trans('list.from') }}</th>
{% endif %}
{% if not hideDestination %}
<th class="hidden-xs">{{ trans('list.to') }}</th>
{% endif %}
{# Hide budgets? #}
{% if not hideBudget %}
<th class="hidden-xs"><i class="fa fa-tasks fa-fw" title="{{ trans('list.budget') }}"></i></th>
{% endif %}
{# Hide categories? #}
{% if not hideCategory %}
<th class="hidden-xs"><i class="fa fa-bar-chart fa-fw" title="{{ trans('list.category') }}"></i></th>
{% endif %}
</tr>
</thead>
<tbody>
{# Make sum: #}
{% set sum = 0 %}
{% for transaction in journals %}
{# add to sum #}
{% set sum = (sum + transaction.transaction_amount) %}
<tr class="drag" data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ transaction.journal_id }}">
<td class="hidden-xs">
{{ transaction|transactionIcon }}
</td>
<td>
<a href="{{ route('transactions.show',transaction.journal_id) }}">
{{ transaction|transactionDescription }}
</a>
</td>
<td>
{{ transaction|transactionAmount }}
</td>
<td class="hidden-sm hidden-xs">
{{ transaction.date.formatLocalized(monthAndDayFormat) }}
</td>
{% if not hideSource %}
<td class="hidden-xs">
{{ transaction|transactionSourceAccount }}
</td>
{% endif %}
{% if not hideDestination %}
<td class="hidden-xs">
{{ transaction|transactionDestinationAccount }}
</td>
{% endif %}
{# Do NOT hide the budget? #}
{% if not hideBudget %}
<td class="hidden-xs">
{{ transaction|transactionBudgets }}
</td>
{% endif %}
{# Do NOT hide the category? #}
{% if not hideCategory %}
<td class="hidden-xs">
{{ transaction|transactionCategories }}
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="2" style="text-align: right;"><em>{{ 'sum'|_ }}:</em></td>
<td>
{% if inverseAmount %}
{{ (sum*-1)|formatAmount }}
{% else %}
{{ sum|formatAmount }}
{% endif %}
</td>
</tr>
</tfoot>
</table>
{{ journals.render|raw }}
{#
TODO REPLACE ME
#}
<h1 style="color:red;">REPLACE ME</h1>

View File

@ -1,156 +1 @@
{{ journals.render|raw }}
<table class="table table-hover table-compressed">
<thead>
<tr class="ignore">
<th class="hide-buttons">&nbsp;</th>
<th class="hide-icon">&nbsp;</th>
<th class="hide-description">{{ trans('list.description') }}</th>
<th class="hide-balance_before" style="text-align: right;">{{ trans('list.balance_before') }}</th>
<th class="hide-amount" style="text-align: right;">{{ trans('list.amount') }}</th>
<th class="hide-balance_after" style="text-align: right;">{{ trans('list.balance_after') }}</th>
<th class="hide-date">{{ trans('list.date') }}</th>
<th class="hide-book_date">{{ trans('list.book_date') }}</th>
<th class="hide-process_date">{{ trans('list.process_date') }}</th>
<th class="hide-interest_date">{{ trans('list.interest_date') }}</th>
{# new optional fields (3x) #}
<th class="hide-interest_date">{{ trans('list.due_date') }}</th>
<th class="hide-payment_date">{{ trans('list.payment_date') }}</th>
<th class="hide-invoice_date">{{ trans('list.invoice_date') }}</th>
<th class="hide-from">{{ trans('list.from') }}</th>
<th class="hide-to">{{ trans('list.to') }}</th>
<th class="hide-budget"><i class="fa fa-tasks fa-fw" title="{{ trans('list.budget') }}"></i></th>
<th class="hide-category"><i class="fa fa-bar-chart fa-fw" title="{{ trans('list.category') }}"></i></th>
<th class="hide-bill">{{ trans('list.bill') }}</th>
{# more optional fields (2x) #}
<th class="hide-internal_reference">{{ trans('list.internal_reference') }}</th>
<th class="hide-notes">{{ trans('list.notes') }}</th>
<th class="hide-create_date">{{ trans('list.create_date') }}</th>
<th class="hide-update_date">{{ trans('list.update_date') }}</th>
</tr>
</thead>
<tbody>
{% for transaction in journals %}
<tr data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ journal.id }}">
<td class="hide-buttons">
<div class="btn-group btn-group-xs">
<a href="{{ route('transactions.edit',transaction.journal_id) }}" class="btn btn-xs btn-default"><i class="fa fa-fw fa-pencil"></i></a>
<a href="{{ route('transactions.delete',transaction.journal_id) }}" class="btn btn-xs btn-danger"><i class="fa fa-fw fa-trash-o"></i></a>
</div>
</td>
<td class="hide-icon">{{ transaction|transactionIcon }}</td>
<td class="hide-description">
<a href="{{ route('transactions.show',transaction.journal_id) }}">
{% if transaction.transaction_description|length > 0 %}
{{ transaction.transaction_description }} ({{ transaction.description }})
{% else %}
{{ transaction.description }}
{% endif %}
</a>
</td>
<td class="hide-balance_before" style="text-align: right;">
{{ formatAmountByCurrency(transaction.transactionCurrency, transaction.before) }}</td>
<td class="hide-amount" style="text-align: right;">
{{ transaction|transactionAmount }}
</td>
<td class="hide-balance_after" style="text-align: right;">{{ formatAmountByCurrency(transaction.transactionCurrency, transaction.after) }}</td>
<td class="hide-date">{{ transaction.date.formatLocalized(monthAndDayFormat) }}</td>
<td class="hide-book_date">
{% if transaction.transactionJournal.hasMeta('book_date') %}
{{ journalGetMetaDate(transaction.transactionJournal, 'book_date').formatLocalized(monthAndDayFormat) }}
{% endif %}
</td>
<td class="hide-process_date">
{% if transaction.transactionJournal.hasMeta('process_date') %}
{{ journalGetMetaDate(transaction.transactionJournal, 'process_date').formatLocalized(monthAndDayFormat) }}
{% endif %}
</td>
<td class="hide-interest_date">
{% if transaction.transactionJournal.hasMeta('interest_date') %}
{{ journalGetMetaDate(transaction.transactionJournal, 'interest_date').formatLocalized(monthAndDayFormat) }}
{% endif %}
</td>
{# new optional fields (3x) #}
<td class="hide-due_date">
{% if transaction.transactionJournal.hasMeta('due_date') %}
{{ journalGetMetaDate(transaction.transactionJournal, 'due_date').formatLocalized(monthAndDayFormat) }}
{% endif %}
</td>
<td class="hide-payment_date">
{% if transaction.transactionJournal.hasMeta('payment_date') %}
{{ journalGetMetaDate(transaction.transactionJournal, 'payment_date').formatLocalized(monthAndDayFormat) }}
{% endif %}
</td>
<td class="hide-invoice_date">
{% if transaction.transactionJournal.hasMeta('invoice_date') %}
{{ journalGetMetaDate(transaction.transactionJournal, 'invoice_date').formatLocalized(monthAndDayFormat) }}
{% endif %}
</td>
<td class="hide-from">
{{ transaction|transactionSourceAccount }}
</td>
<td class="hide-to">
{{ transaction|transactionDestinationAccount }}
</td>
<td class="hide-budget">
{{ transaction|transactionBudgets }}
</td>
<td class="hide-category">
{{ transaction|transactionCategories }}
</td>
{% if transaction.bill_id %}
<td class="hide-bill">
<i class="fa fa-fw fa-rotate-right" title="{{ trans('list.bill') }}"></i>&nbsp
<a href="{{ route('bills.show',transaction.bill_id) }}">{{ transaction.bill_name }}</a>
</td>
{% else %}
<td class="hide-bill">&nbsp;</td>
{% endif %}
{# new optional fields (2x) #}
<td class="hide-internal_reference">
{% if transaction.transactionJournal.hasMeta('internal_reference') %}
{{ journalGetMetaField(transaction.transactionJournal,'internal_reference') }}
{% endif %}
</td>
<td class="hide-notes">
{% if transaction.transactionJournal.notes.count == 1 %}
{{ transaction.transactionJournal.notes.first.text }}
{% endif %}
</td>
<td class="hide-create_date">
{{ transaction.transactionJournal.created_at.formatLocalized(dateTimeFormat) }}
</td>
<td class="hide-update_date">
{{ transaction.transactionJournal.updated_at.formatLocalized(dateTimeFormat) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ journals.render|raw }}
<h1 style="color:red;">REPLACE ME</h1>

View File

@ -3,110 +3,5 @@
{{ trans('firefly.search_found_transactions', {count: transactions.count, time: searchTime}) }}
</p>
<table class="table table-hover table-condensed">
<thead>
<tr class="ignore">
{# hidden row for checkboxes #}
<th class="hidden-xs select_boxes" style="display: none;"><input name="select_all" class="select_all" type="checkbox"/></th>
{# header for icon #}
<th class="hidden-xs"></th>
<th>{{ trans('list.description') }}</th>
<th style="text-align:right;">{{ trans('list.amount') }}</th>
<th class="hidden-xs hidden-sm">{{ trans('list.date') }}</th>
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.from') }}</th>
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.to') }}</th>
<th class="hidden-xs"><i class="fa fa-tasks fa-fw" title="{{ trans('list.budget') }}"></i></th>
<th class="hidden-xs"><i class="fa fa-bar-chart fa-fw" title="{{ trans('list.category') }}"></i></th>
<th class="hidden-xs"><i class="fa fa-fw fa-calendar-o" title="{{ trans('list.bill') }}"></i></th>
{# visible row for edit/delete buttons #}
<th class="hidden-xs no_select_boxes">&nbsp;</th>
</tr>
</thead>
<tbody>
{% for transaction in transactions %}
<tr data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ transaction.journal_id }}" data-transaction-id="{{ transaction.id }}">
{# select buttons #}
<td class="hidden-xs select_boxes" style="display: none;">
<div class="select_single" style="display:none;">
<input name="select_all_single[]" class="select_all_single" data-transaction="{{ transaction.id }}" value="{{ transaction.journal_id }}"
type="checkbox"/>
</div>
</td>
{# icon #}
<td class="hidden-xs">
{{ transaction|transactionIcon }}
</td>
{# description #}
<td>
{# is reconciled? #}
{{ transaction|transactionReconciled }}
<a href="{{ route('transactions.show',transaction.journal_id) }}">
{{ transaction|transactionDescription }}
</a>
{# is a split journal #}
{{ transaction|transactionIsSplit }}
{# count attachments #}
{{ transaction|transactionHasAtt }}
</td>
{# amount #}
<td style="text-align: right;"><span style="margin-right:5px;">{{ transaction|transactionAmount }}</span></td>
{# date #}
<td class="hidden-sm hidden-xs">
{{ transaction.date.formatLocalized(monthAndDayFormat) }}
</td>
{# source #}
<td class="hidden-xs hidden-sm hidden-md">
{{ transaction|transactionSourceAccount }}
</td>
{# dest #}
<td class="hidden-xs hidden-sm hidden-md">
{{ transaction|transactionDestinationAccount }}
</td>
{# budget, if opted to show. #}
<td class="hidden-xs">
{{ transaction|transactionBudgets }}
</td>
{# category, if opted to show. #}
<td class="hidden-xs">
{{ transaction|transactionCategories }}
</td>
{# bill, if opted to show#}
<td class="hidden-xs">
{% if transaction.bill_id %}
<a href="{{ route('bills.show',transaction.bill_id) }}">{{ transaction.bill_name }}</a>
{% endif %}
</td>
<td class="hidden-xs">
<div class="btn-group btn-group-xs pull-right">
{% if sorting %}<a href="#" class="handle btn btn-default"><i class="fa fa-fw fa-arrows-v"></i></a>{% endif %}
<div class="btn-group btn-group-xs">
<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 dropdown-menu-right" role="menu">
<li><a href="{{ route('transactions.edit',transaction.journal_id) }}"><i class="fa fa-fw fa-pencil"></i> {{ 'edit'|_ }}</a></li>
<li><a href="{{ route('transactions.delete',transaction.journal_id) }}"><i class="fa fa-fw fa-trash"></i> {{ 'delete'|_ }}</a></li>
<li role="separator" class="divider"></li>
<li><a href="{{ route('transactions.clone',transaction.journal_id) }}"><i class="fa fa-copy fa-fw"></i> {{ 'clone'|_ }}</a></li>
<li><a href="{{ route('transactions.split.edit',transaction.journal_id) }}"><i class="fa fa-unsorted fa-fw"></i> {{ 'split'|_ }}</a>
</li>
</ul>
</div>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{# TODO REPLACE ME#}
<h1 style="color:red;">REPLACE ME</h1>

View File

@ -52,7 +52,7 @@
{{ sourceAccount(journal)|raw }}
</td>
<td>
{{ destinationAccount(journal)|raw }}
{{ destinationXAccount(journal)|raw }}
</td>
</tr>
{% endfor %}

View File

@ -6,158 +6,328 @@
{% block content %}
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="box">
<div class="col-lg-6">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ 'transaction_journal_information'|_ }}</h3>
<div class="box-tools pull-right">
<div class="btn-group">
<button id="transaction_menu" class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown"><i class="fa fa-ellipsis-v"></i>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="edit"><i class="fa fa-pencil fa-fw"></i> {{ 'edit'|_ }}</a></li>
<li><a href="delete"><i class="fa fa-trash fa-fw"></i> {{ 'delete'|_ }}</a></li>
{# convert to withdrawal #}
{% if journal.transactionType.type != "Withdrawal" %}
<li>
<a href="{{ route('transactions.convert.index', ['withdrawal', journal.id]) }}">
<i class="fa fa-exchange fa-fw"></i> {{ ('convert_'~journal.transactionType.type~'_to_withdrawal')|_ }}
</a>
</li>
{% endif %}
{# convert to deposit #}
{% if journal.transactionType.type != "Deposit" %}
<li>
<a href="{{ route('transactions.convert.index', ['deposit', journal.id]) }}">
<i class="fa fa-exchange fa-fw"></i> {{ ('convert_'~journal.transactionType.type~'_to_deposit')|_ }}
</a>
</li>
{% endif %}
{# convert to transfer#}
{% if journal.transactionType.type != "Transfer" %}
<li>
<a href="{{ route('transactions.convert.index', ['transfer', journal.id]) }}">
<i class="fa fa-exchange fa-fw"></i> {{ ('convert_'~journal.transactionType.type~'_to_transfer')|_ }}
</a>
</li>
{% endif %}
{# other options #}
<li>
<a href="{{ route('transactions.clone', [journal.id]) }}">
<i class="fa fa-copy fa-fw"></i> {{ ('clone_'~journal.transactionType.type|lower)|_ }}
</a>
</li>
<li>
<a href="split">
<i class="fa fa-unsorted fa-fw"></i> {{ ('split_this_'~what)|_ }}
</a>
</li>
<li>
<a href="#" data-toggle="modal" data-target="#linkJournalModal"><i
class="fa fa-fw fa-link"></i> {{ 'link_transaction'|_ }}
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="box-body no-padding">
<table class="table table-hover">
<tbody>
<tr>
<td>{{ trans('list.type') }}</td>
<td>{{ journal.transactiontype.type|_ }}</td>
<td>{{ first.transactiontype.type|_ }}</td>
</tr>
<tr>
<td>{{ trans('list.description') }}</td>
<td>
{% if transactions[0].reconciled %}
<i class="fa fa-check"></i>
{% if splits == 1 %}
{{ first.description }}
{% else %}
{{ transactionGroup.title }}
{% endif %}
{{ journal.description }}</td>
</tr>
<tr>
<td>{{ 'source_accounts'|_ }}</td>
<td>sources</td>
</tr>
<tr>
<td>{{ 'destination_accounts'|_ }}</td>
<td>desitnations</td>
</tr>
<tr>
<td>{{ 'total_amount'|_ }}</td>
<td>
total amount and splits
</td>
</tr>
<tr>
<td style="width:30%;">{{ trans('list.date') }}</td>
<td>
date
{{ first.date.formatLocalized(dateTimeFormat) }}
</td>
</tr>
</tbody>
</table>
</div>
<div class="box-footer">
<div class="pull-right">
<div class="btn-group">
<a class="btn btn-default" href="#"><i class="fa fa-pencil fa-fw"></i> {{ 'edit'|_ }}</a>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-cog fa-fw"></i> {{ 'options'|_ }} <span class="caret"></span>
</button>
<ul class="dropdown-menu">
{# convert to withdrawal #}
{% if journal.transactionType.type != "Withdrawal" %}
<li>
<a href="{{ route('transactions.convert.index', ['withdrawal', journal.id]) }}">
<i class="fa fa-exchange fa-fw"></i> {{ ('convert_'~journal.transactionType.type~'_to_withdrawal')|_ }}
</a>
</li>
{% endif %}
{# convert to deposit #}
{% if journal.transactionType.type != "Deposit" %}
<li>
<a href="{{ route('transactions.convert.index', ['deposit', journal.id]) }}">
<i class="fa fa-exchange fa-fw"></i> {{ ('convert_'~journal.transactionType.type~'_to_deposit')|_ }}
</a>
</li>
{% endif %}
{# convert to transfer#}
{% if journal.transactionType.type != "Transfer" %}
<li>
<a href="{{ route('transactions.convert.index', ['transfer', journal.id]) }}">
<i class="fa fa-exchange fa-fw"></i> {{ ('convert_'~journal.transactionType.type~'_to_transfer')|_ }}
</a>
</li>
{% endif %}
{# other options #}
<li>
<a href="{{ route('transactions.clone', [journal.id]) }}">
<i class="fa fa-copy fa-fw"></i> {{ ('clone_'~journal.transactionType.type|lower)|_ }}
</a>
</li>
<li>
<a href="#">
<i class="fa fa-unsorted fa-fw"></i> {{ ('split_this_'~what)|_ }}
</a>
</li>
<li>
<a href="#" data-toggle="modal" data-target="#linkJournalModal"><i
class="fa fa-fw fa-link"></i> {{ 'link_transaction'|_ }}
</a>
</li>
</ul>
<a href="#" class="btn btn-danger"><i class="fa fa-trash fa-fw"></i> {{ 'delete'|_ }}
</a>
</div>
<div class="btn-group btn-group-xs">
<a href="#" class="btn btn-default"><i class="fa fa-pencil"></i> {{ 'edit'|_ }}</a>
{% if type != 'Opening balance' and type != 'Reconciliation' %}
<a href="#" class="btn btn-default"><i class="fa fa-copy"></i> {{ 'clone'|_ }}</a>
{% if type != 'Withdrawal' %}
<a href="#" class="btn btn-default"><i class="fa fa-exchange"></i> {{ 'convert_to_withdrawal'|_ }}</a>
{% endif %}
{% if type != 'Deposit' %}
<a href="#" class="btn btn-default"><i class="fa fa-exchange"></i> {{ 'convert_to_deposit'|_ }}</a>
{% endif %}
{% if type != 'Transfer' %}
<a href="#" class="btn btn-default"><i class="fa fa-exchange"></i> {{ 'convert_to_transfer'|_ }}</a>
{% endif %}
{% endif %}
<a href="#" class="btn btn-danger"><i class="fa fa-trash"></i> {{ 'delete'|_ }}</a>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ 'transaction_journal_meta'|_ }}</h3>
</div>
<div class="box-body no-padding">
<table class="table table-hover">
<tbody>
{% if type != 'Withdrawal' or splits == 1 %}
<tr>
<td>
{{ 'source_accounts'|_ }}
</td>
<td>
{% for journal in groupArray.transactions %}
<a href="{{ route('accounts.show',journal.source_id) }}"
title="{{ journal.source_iban|default(journal.source_name) }}">
{{ journal.source_name }}
</a>
{% if loop.index0 != groupArray.transactions|length -1 %}, {% endif %}
{% endfor %}
</td>
</tr>
{% endif %}
{% if type != 'Deposit' or splits == 1 %}
<tr>
<td>
{{ 'destination_accounts'|_ }}
</td>
<td>
{% for journal in groupArray.transactions %}
<a href="{{ route('accounts.show',journal.source_id) }}"
title="{{ journal.destination_iban|default(journal.destination_name) }}">
{{ journal.destination_name }}
</a>
{% if loop.index0 != groupArray.transactions|length -1 %}, {% endif %}
{% endfor %}
</td>
</tr>
{% endif %}
<tr>
<td style="width:30%;">{{ 'total_amount'|_ }}</td>
<td>
{% for amount in amounts %}
{% if type == 'Withdrawal' %}
{{ formatAmountBySymbol(amount.amount*-1,amount.symbol, amount.decimal_places) }}
{% elseif type == 'Transfer' %}
<span class="text-info">
{{ formatAmountBySymbol(amount.amount,amount.symbol, amount.decimal_places, false) }}
</span>
{% else %}
{{ formatAmountBySymbol(amount.amount,amount.symbol, amount.decimal_places) }}
{% endif %}
{% endfor %}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row">
</div>
{% if splits > 1 %}
<div class="row">
<div class="col-lg-12">
<h3>{{ 'splits'|_ }}</h3>
</div>
</div>
{% endif %}
{% set boxSize=12 %}
{% if(splits == 2) %}
{% set boxSize=6 %}
{% endif %}
{% if (splits > 2) %}
{% set boxSize = 4 %}
{% endif %}
<div class="row">
{% for index,journal in groupArray.transactions %}
<div class="col-lg-{{ boxSize }}">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
{{ journal.description }}
{% if journal.reconciled %}
<i class="fa fa-check"></i>
{% endif %}
{% if splits > 1 %}
<small>
{{ index+1 }} / {{ splits }}
</small>
{% endif %}
</h3>
</div>
<div class="box-body no-padding">
<table class="table">
<tr>
<td colspan="2">
<a href="{{ route('accounts.show', journal.source_id) }}"
title="{{ journal.source_iban|default(journal.source_name) }}">{{ journal.source_name }}</a> &rarr;
{% if type == 'Withdrawal' %}
{{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}
{% elseif type == 'Transfer' %}
<span class="text-info">
{{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places, false) }}
</span>
{% else %}
{{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places) }}
{% endif %}
&rarr;
<a href="{{ route('accounts.show', journal.destination_id) }}"
title="{{ journal.destination_iban|default(journal.destination_name) }}">{{ journal.destination_name }}</a>
</td>
</tr>
{% 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>
</tr>
{% endif %}
{% if null != journal.budget_id and type == 'Withdrawal' %}
<tr>
<td>{{ 'budget'|_ }}</td>
<td><a href="{{ route('budgets.show', [journal.budget_id]) }}">{{ journal.budget_name }}</a></td>
</tr>
{% endif %}
{% if null != journal.bill_id and type == 'Withdrawal' %}
<tr>
<td>{{ 'bill'|_ }}</td>
<td><a href="{{ route('bills.show', [journal.bill_id]) }}">{{ journal.bill_name }}</a></td>
</tr>
{% endif %}
<!-- other fields -->
{% for dateField in ['interest_date','book_date','process_date','due_date','payment_date','invoice_date'] %}
{% if journalHasMeta(journal.transaction_journal_id, dateField) %}
<tr>
<td>{{ trans('list.'~dateField) }}</td>
<td>{{ journalGetMetaDate(journal.transaction_journal_id, dateField).formatLocalized(monthAndDayFormat) }}</td>
</tr>
{% endif %}
{% endfor %}
{% for metaField in ['external_id','bunq_payment_id','internal_reference','sepa_batch_id','sepa_ct_id','sepa_ct_op','sepa_db','sepa_country','sepa_cc','sepa_ep','sepa_ci'] %}
{% if journalHasMeta(journal.transaction_journal_id, metaField) %}
<tr>
<td>{{ trans('list.'~metaField) }}</td>
<td>{{ journalGetMetaField(journal.transaction_journal_id, metaField) }}</td>
</tr>
{% endif %}
{% endfor %}
{% if null != journal.notes and '' != journal.notes %}
<tr>
<td>{{ trans('list.notes') }}</td>
<td class="markdown">{{ journal.notes|markdown }}</td>
</tr>
{% endif %}
{% if journal.tags|length > 0 %}
<tr>
<td>{{ 'tags'|_ }}</td>
<td>
{% for tag in journal.tags %}
<h4 style="display: inline;"><a class="label label-success" href="{{ route('tags.show', tag) }}">
<i class="fa fa-fw fa-tag"></i>
{{ tag }}</a>
</h4>
{% endfor %}
</td>
</tr>
{% endif %}
{% if links[journal.transaction_journal_id]|length > 0 %}
{% for link in links[journal.transaction_journal_id] %}
<tr>
<td colspan="2">{{ link.link }} "<a href="{{ route('transactions.show', link.group) }}" title="{{ link.description }}">{{ link.description }}</a></td>
</tr>
{% endfor %}
{% endif %}
</table>
</div>
</div>
</div>
{% endfor %}
</div>
<div class="row">
<div class="col-lg-12">
<h3>But wait, there's more!</h3>
Transaction links, piggy bank events and attachments.
</div>
</div>
<div class="row">
<!-- attachments -->
{% if attachments|length > 0 %}
<div class="col-lg-6">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'attachments'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
{% for attachment in attachments %}
<tr>
<td>
<div class="btn-group btn-group-xs">
<a href="{{ route('attachments.edit', attachment.id) }}" class="btn btn-default"><i class="fa fa-pencil"></i></a>
<a href="{{ route('attachments.delete', attachment.id) }}" class="btn btn-danger"><i class="fa fa-trash"></i></a>
{% if attachment.file_exists %}
<a href="{{ route('attachments.download', attachment.id) }}" class="btn btn-default"><i
class="fa fa-download"></i></a>
{% endif %}
{% if not attachment.file_exists %}
<a href="#" class="btn btn-danger"><i class="fa fa-exclamation-triangle"></i></a>
{% endif %}
</div>
</td>
<td>
{% if attachment.file_exists %}
<i class="fa {{ attachment.mime|mimeIcon }}"></i>
<a href="{{ route('attachments.view', attachment.id) }}" title="{{ attachment.filename }}">
{% if attachment.title %}
{{ attachment.title }}
{% else %}
{{ attachment.filename }}
{% endif %}
</a>
({{ attachment.size|filesize }})
{% if null != attachment.notes and '' != attachment.notes %}
{{ attachment.notes|markdown }}
{% endif %}
{% endif %}
{% if not attachment.file_exists %}
<i class="fa fa-fw fa-exclamation-triangle"></i>
{% if attachment.title %}
{{ attachment.title }}
{% else %}
{{ attachment.filename }}
{% endif %}
<br>
<span class="text-danger">{{ 'attachment_not_found'|_ }}</span>
{% endif %}
{% if splits > 1 %}
<small><em><br/>{{ trans('firefly.att_part_of_journal',{journal: attachment.journal_title}) }}
</em></small>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
{% endif %}
<!-- link -->
<div class="col-lg-4">
</div>
<!-- events -->
<div class="col-lg-4">
</div>
</div>
{% endblock %}
{% block scripts %}
{% endblock %}
{#
{% if journal.piggyBankEvents|length > 0 %}
<div class="box">
@ -172,71 +342,7 @@
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'transaction_journal_meta'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
<tbody>
<tr>
<td>{{ 'categories'|_ }}</td>
<td>categoris</td>
</tr>
<tr>
<td>{{ 'budgets'|_ }}</td>
<td>budgets</td>
</tr>
{# all date meta values #}
{% for dateField in ['interest_date','book_date','process_date','due_date','payment_date','invoice_date'] %}
{#
{% if journalHasMeta(journal, dateField) %}
<tr>
<td>{{ trans('list.'~dateField) }}</td>
<td>{{ journalGetMetaDate(journal,dateField).formatLocalized(monthAndDayFormat) }}</td>
</tr>
{% endif %}
#}
{% endfor %}
{# all other meta values #}
{% for metaField in ['external_id','bunq_payment_id','internal_reference','sepa_batch_id','sepa_ct_id','sepa_ct_op','sepa_db','sepa_country','sepa_cc','sepa_ep','sepa_ci'] %}
{#
{% if journalHasMeta(journal, metaField) %}
<tr>
<td>{{ trans('list.'~metaField) }}</td>
<td>{{ journalGetMetaField(journal, metaField) }}</td>
</tr>
{% endif %}
#}
{% endfor %}
{% if journal.notes.count == 1 %}
<tr>
<td>{{ trans('list.notes') }}</td>
<td class="markdown">{{ journal.notes.first.text|markdown }}</td>
</tr>
{% endif %}
{% if journal.bill_id %}
<tr>
<td>{{ 'bill'|_ }}</td>
<td><a href="{{ route('bills.show', journal.bill_id) }}">{{ journal.bill.name }}</a></td>
</tr>
{% endif %}
{% if journal.tags|length > 0 %}
<tr>
<td>{{ 'tags'|_ }}</td>
<td>
{% for tag in journal.tags %}
<h4 style="display: inline;"><a class="label label-success" href="{{ route('tags.show',tag) }}">
<i class="fa fa-fw fa-tag"></i>
{{ tag.tag }}</a>
</h4>
{% endfor %}
</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
@ -294,7 +400,6 @@
</div>
</div>
{% endif %}
{# show links: #}
{% if links.count > 0 %}
<div class="box">
<div class="box-header with-border">
@ -364,7 +469,6 @@
{% set maxIdentifier = ((transactions|length) / 2) -1 %}
{% for x in 0..maxIdentifier %}
<tr>
{# loop each transaction in the array.#}
{% for transaction in transactions %}
{% if
((transaction.type == 'Withdrawal') and transaction.identifier == x and transaction.amount < 0)
@ -393,7 +497,7 @@
</td>
<td>
{{ transaction|transactionArrayAmount }}
{{ transaction|transactionXArrayAmount }}
</td>
<td class="hidden-md hidden-xs">
{% if transaction.budget_id %}
@ -419,7 +523,6 @@
</div>
</div>
{# link journal modal:#}
<div class="modal fade" tabindex="-1" role="dialog" id="linkJournalModal">
<form action="{{ route('transactions.link.store', [journal.id]) }}" method="post" class="form-horizontal">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
@ -468,12 +571,4 @@
</div>
</form>
</div>
{% endblock %}
{% block scripts %}
<script type="text/javascript">
var autoCompleteUri = "{{ route('json.journals-with-id',[journal.id]) }}";
</script>
<script type="text/javascript" src="v1/js/lib/typeahead/typeahead.bundle.min.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="v1/js/ff/transactions/show.js?v={{ FF_VERSION }}"></script>
{% endblock %}
#}

File diff suppressed because it is too large Load Diff

View File

@ -27,19 +27,21 @@ use Carbon\Carbon;
use Closure;
use DB;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Transformers\TransactionTransformer;
use FireflyIII\User;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Log;
use Mockery;
use RuntimeException;
/**
* Class TestCase
*
@ -55,7 +57,7 @@ abstract class TestCase extends BaseTestCase
public function changeDateRange(User $user, $range): void
{
$valid = ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'];
if (\in_array($range, $valid)) {
if (in_array($range, $valid, true)) {
try {
Preference::where('user_id', $user->id)->where('name', 'viewRange')->delete();
} catch (Exception $e) {
@ -105,6 +107,8 @@ abstract class TestCase extends BaseTestCase
*/
public function demoUser(): User
{
throw new FireflyException('demoUser()-method is obsolete.');
return User::find(4);
}
@ -113,23 +117,19 @@ abstract class TestCase extends BaseTestCase
*/
public function emptyUser(): User
{
throw new FireflyException('emptyUser()-method is obsolete.');
return User::find(2);
}
/**
* @param int|null $except
*
* @return Account
*/
public function getRandomAsset(): Account
public function getRandomAsset(?int $except = null): Account
{
return $this->getRandomAccount(AccountType::ASSET);
}
/**
* @return Account
*/
public function getRandomLoan(): Account
{
return $this->getRandomAccount(AccountType::LOAN);
return $this->getRandomAccount(AccountType::ASSET, $except);
}
/**
@ -137,7 +137,7 @@ abstract class TestCase extends BaseTestCase
*/
public function getRandomDeposit(): TransactionJournal
{
return $this->getRandomJournal(TransactionType::DEPOSIT);
return $this->getRandomJournal(TransactionType::DEPOSIT, null);
}
/**
@ -145,7 +145,15 @@ abstract class TestCase extends BaseTestCase
*/
public function getRandomExpense(): Account
{
return $this->getRandomAccount(AccountType::EXPENSE);
return $this->getRandomAccount(AccountType::EXPENSE, null);
}
/**
* @return Account
*/
public function getRandomLoan(): Account
{
return $this->getRandomAccount(AccountType::LOAN, null);
}
/**
@ -153,7 +161,7 @@ abstract class TestCase extends BaseTestCase
*/
public function getRandomRevenue(): Account
{
return $this->getRandomAccount(AccountType::REVENUE);
return $this->getRandomAccount(AccountType::REVENUE, null);
}
/**
@ -186,8 +194,8 @@ abstract class TestCase extends BaseTestCase
public function setUp(): void
{
parent::setUp();
$repository = $this->mock(JournalRepositoryInterface::class);
$repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
// $repository = $this->mock(JournalRepositoryInterface::class);
// $repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
}
/**
@ -198,6 +206,14 @@ abstract class TestCase extends BaseTestCase
return User::find(1);
}
/**
* @return TransactionGroup
*/
protected function getRandomWithdrawalGroup(): TransactionGroup
{
return $this->getRandomGroup(TransactionType::WITHDRAWAL);
}
/**
* @param string $class
*
@ -209,9 +225,9 @@ abstract class TestCase extends BaseTestCase
{
$deprecated = [
TransactionTransformer::class,
TransactionCollectorInterface::class
TransactionCollectorInterface::class,
];
if(in_array($class, $deprecated, true)) {
if (in_array($class, $deprecated, true)) {
throw new RuntimeException('Should not be mocking the transaction collector.');
}
Log::debug(sprintf('Will now mock %s', $class));
@ -233,27 +249,55 @@ abstract class TestCase extends BaseTestCase
}
/**
* @param string $type
* @param string $type
*
* @param int|null $except
*
* @return Account
*/
private function getRandomAccount(string $type): Account
private function getRandomAccount(string $type, ?int $except): Account
{
$query = Account::
$query = Account::
leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->whereNull('accounts.deleted_at')
->where('accounts.user_id', $this->user()->id)
->where('account_types.type', $type)
->inRandomOrder()->take(1);
->whereNull('accounts.deleted_at')
->where('accounts.user_id', $this->user()->id)
->where('account_types.type', $type)
->inRandomOrder()->take(1);
if (null !== $except) {
$query->where('accounts.id', '!=', $except);
}
$result = $query->first(['accounts.*']);
return $result;
}
/**
* @param string $type
*
* @return TransactionGroup
*/
private function getRandomGroup(string $type): TransactionGroup
{
$transactionType = TransactionType::where('type', $type)->first();
// make sure it's a single count group
do {
$journal = $this->user()->transactionJournals()
->where('transaction_type_id', $transactionType->id)->inRandomOrder()->first();
/** @var TransactionGroup $group */
$group = $journal->transactionGroup;
$count = $group->transactionJournals()->count();
Log::debug(sprintf('Count is %d', $count));
} while (1 !== $count);
return $journal->transactionGroup;
}
/**
* @param string $type
*
* @return TransactionJournal
* @throws FireflyException
*/
private function getRandomJournal(string $type): TransactionJournal
{