mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-06 12:45:30 +00:00
Some code for #1272
This commit is contained in:
@@ -41,7 +41,6 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ReconcileController.
|
* Class ReconcileController.
|
||||||
@@ -217,6 +216,7 @@ class ReconcileController extends Controller
|
|||||||
$transactionsUri = route('accounts.reconcile.transactions', [$account->id, '%start%', '%end%']);
|
$transactionsUri = route('accounts.reconcile.transactions', [$account->id, '%start%', '%end%']);
|
||||||
$overviewUri = route('accounts.reconcile.overview', [$account->id, '%start%', '%end%']);
|
$overviewUri = route('accounts.reconcile.overview', [$account->id, '%start%', '%end%']);
|
||||||
$indexUri = route('accounts.reconcile', [$account->id, '%start%', '%end%']);
|
$indexUri = route('accounts.reconcile', [$account->id, '%start%', '%end%']);
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'accounts.reconcile.index', compact(
|
'accounts.reconcile.index', compact(
|
||||||
'account', 'currency', 'subTitleIcon', 'start', 'end', 'subTitle', 'startBalance', 'endBalance', 'transactionsUri',
|
'account', 'currency', 'subTitleIcon', 'start', 'end', 'subTitle', 'startBalance', 'endBalance', 'transactionsUri',
|
||||||
@@ -370,7 +370,9 @@ class ReconcileController extends Controller
|
|||||||
$collector->setAccounts(new Collection([$account]))
|
$collector->setAccounts(new Collection([$account]))
|
||||||
->setRange($selectionStart, $selectionEnd)->withBudgetInformation()->withOpposingAccount()->withCategoryInformation();
|
->setRange($selectionStart, $selectionEnd)->withBudgetInformation()->withOpposingAccount()->withCategoryInformation();
|
||||||
$transactions = $collector->getJournals();
|
$transactions = $collector->getJournals();
|
||||||
$html = view('accounts.reconcile.transactions', compact('account', 'transactions','currency', 'start', 'end', 'selectionStart', 'selectionEnd'))->render();
|
$html = view(
|
||||||
|
'accounts.reconcile.transactions', compact('account', 'transactions', 'currency', 'start', 'end', 'selectionStart', 'selectionEnd')
|
||||||
|
)->render();
|
||||||
|
|
||||||
return response()->json(['html' => $html, 'startBalance' => $startBalance, 'endBalance' => $endBalance]);
|
return response()->json(['html' => $html, 'startBalance' => $startBalance, 'endBalance' => $endBalance]);
|
||||||
}
|
}
|
||||||
@@ -441,7 +443,6 @@ class ReconcileController extends Controller
|
|||||||
$this->repository->update($journal, $data);
|
$this->repository->update($journal, $data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
if (1 === (int)$request->get('return_to_edit')) {
|
if (1 === (int)$request->get('return_to_edit')) {
|
||||||
session()->put('reconcile.edit.fromUpdate', true);
|
session()->put('reconcile.edit.fromUpdate', true);
|
||||||
|
@@ -29,7 +29,6 @@ use FireflyIII\Http\Requests\ConfigurationRequest;
|
|||||||
use FireflyIII\Support\Facades\FireflyConfig;
|
use FireflyIII\Support\Facades\FireflyConfig;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Redirect;
|
use Redirect;
|
||||||
use Session;
|
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -28,7 +28,6 @@ use FireflyIII\Http\Middleware\IsDemoUser;
|
|||||||
use FireflyIII\Http\Middleware\IsSandStormUser;
|
use FireflyIII\Http\Middleware\IsSandStormUser;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Log;
|
use Log;
|
||||||
use Session;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class HomeController.
|
* Class HomeController.
|
||||||
|
@@ -32,7 +32,6 @@ use FireflyIII\Services\Github\Object\Release;
|
|||||||
use FireflyIII\Services\Github\Request\UpdateRequest;
|
use FireflyIII\Services\Github\Request\UpdateRequest;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Log;
|
use Log;
|
||||||
use Session;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class HomeController.
|
* Class HomeController.
|
||||||
|
@@ -30,7 +30,6 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
|||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Log;
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -29,7 +29,6 @@ use Illuminate\Auth\Events\Registered;
|
|||||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Session;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
|
@@ -34,7 +34,6 @@ use Illuminate\Foundation\Validation\ValidatesRequests;
|
|||||||
use Illuminate\Routing\Controller as BaseController;
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
use Log;
|
use Log;
|
||||||
use Route;
|
use Route;
|
||||||
use Session;
|
|
||||||
use URL;
|
use URL;
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
|
@@ -22,10 +22,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -28,7 +28,6 @@ use FireflyIII\Models\TransactionCurrency;
|
|||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -35,7 +35,6 @@ use Illuminate\Pagination\LengthAwarePaginator;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
|
@@ -27,7 +27,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -44,7 +44,6 @@ use Laravel\Passport\Passport;
|
|||||||
use Log;
|
use Log;
|
||||||
use phpseclib\Crypt\RSA;
|
use phpseclib\Crypt\RSA;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,7 +36,6 @@ use Illuminate\Http\RedirectResponse;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -45,7 +45,6 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
|
@@ -33,7 +33,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|||||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -32,7 +32,6 @@ use FireflyIII\Support\CacheProperties;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -30,7 +30,6 @@ use FireflyIII\Models\TransactionType;
|
|||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Session;
|
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -30,7 +30,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|||||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use URL;
|
use URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,19 +23,22 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers\Transaction;
|
namespace FireflyIII\Http\Controllers\Transaction;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||||
|
use FireflyIII\Helpers\Filter\NegativeAmountFilter;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Http\Requests\MassDeleteJournalRequest;
|
use FireflyIII\Http\Requests\MassDeleteJournalRequest;
|
||||||
use FireflyIII\Http\Requests\MassEditBulkJournalRequest;
|
use FireflyIII\Http\Requests\MassEditBulkJournalRequest;
|
||||||
use FireflyIII\Http\Requests\MassEditJournalRequest;
|
use FireflyIII\Http\Requests\MassEditJournalRequest;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\TransactionType;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
|
use FireflyIII\Transformers\TransactionTransformer;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,7 +72,7 @@ class MassController extends Controller
|
|||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function delete(Collection $journals)
|
public function delete(Collection $journals): View
|
||||||
{
|
{
|
||||||
$subTitle = trans('firefly.mass_delete_journals');
|
$subTitle = trans('firefly.mass_delete_journals');
|
||||||
|
|
||||||
@@ -88,12 +91,12 @@ class MassController extends Controller
|
|||||||
{
|
{
|
||||||
$ids = $request->get('confirm_mass_delete');
|
$ids = $request->get('confirm_mass_delete');
|
||||||
$set = new Collection;
|
$set = new Collection;
|
||||||
if (is_array($ids)) {
|
if (\is_array($ids)) {
|
||||||
/** @var int $journalId */
|
/** @var string $journalId */
|
||||||
foreach ($ids as $journalId) {
|
foreach ($ids as $journalId) {
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
$journal = $this->repository->find((int)$journalId);
|
$journal = $this->repository->findNull((int)$journalId);
|
||||||
if (null !== $journal->id && (int)$journalId === $journal->id) {
|
if (null !== $journal && (int)$journalId === $journal->id) {
|
||||||
$set->push($journal);
|
$set->push($journal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,75 +135,31 @@ class MassController extends Controller
|
|||||||
$budgetRepository = app(BudgetRepositoryInterface::class);
|
$budgetRepository = app(BudgetRepositoryInterface::class);
|
||||||
$budgets = $budgetRepository->getBudgets();
|
$budgets = $budgetRepository->getBudgets();
|
||||||
|
|
||||||
// skip transactions that have multiple destinations, multiple sources or are an opening balance.
|
|
||||||
$filtered = new Collection;
|
|
||||||
$messages = [];
|
|
||||||
/** @var TransactionJournal $journal */
|
|
||||||
foreach ($journals as $journal) {
|
|
||||||
$sources = $this->repository->getJournalSourceAccounts($journal);
|
|
||||||
$destinations = $this->repository->getJournalDestinationAccounts($journal);
|
|
||||||
if ($sources->count() > 1) {
|
|
||||||
$messages[] = trans('firefly.cannot_edit_multiple_source', ['description' => $journal->description, 'id' => $journal->id]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($destinations->count() > 1) {
|
|
||||||
$messages[] = trans('firefly.cannot_edit_multiple_dest', ['description' => $journal->description, 'id' => $journal->id]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (TransactionType::OPENING_BALANCE === $this->repository->getTransactionType($journal)) {
|
|
||||||
$messages[] = trans('firefly.cannot_edit_opening_balance');
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cannot edit reconciled transactions / journals:
|
|
||||||
if ($this->repository->isJournalReconciled($journal)) {
|
|
||||||
$messages[] = trans('firefly.cannot_edit_reconciled', ['description' => $journal->description, 'id' => $journal->id]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$filtered->push($journal);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($messages) > 0) {
|
|
||||||
session()->flash('info', $messages);
|
|
||||||
}
|
|
||||||
|
|
||||||
// put previous url in session
|
// put previous url in session
|
||||||
$this->rememberPreviousUri('transactions.mass-edit.uri');
|
$this->rememberPreviousUri('transactions.mass-edit.uri');
|
||||||
|
|
||||||
// collect some useful meta data for the mass edit:
|
// use the collector to get them.
|
||||||
$filtered->each(
|
$transformer = new TransactionTransformer(new ParameterBag);
|
||||||
function (TransactionJournal $journal) {
|
/** @var JournalCollectorInterface $collector */
|
||||||
$transaction = $this->repository->getFirstPosTransaction($journal);
|
$collector = app(JournalCollectorInterface::class);
|
||||||
$currency = $transaction->transactionCurrency;
|
$collector->setUser(auth()->user());
|
||||||
$journal->amount = (float)$transaction->amount;
|
$collector->withOpposingAccount()->withCategoryInformation()->withBudgetInformation();
|
||||||
$sources = $this->repository->getJournalSourceAccounts($journal);
|
$collector->setJournals($journals);
|
||||||
$destinations = $this->repository->getJournalDestinationAccounts($journal);
|
$collector->addFilter(NegativeAmountFilter::class);
|
||||||
$journal->transaction_count = $journal->transactions()->count();
|
$transactions = $collector->getJournals();
|
||||||
$journal->currency_symbol = $currency->symbol;
|
|
||||||
$journal->transaction_type_type = $journal->transactionType->type;
|
|
||||||
|
|
||||||
$journal->foreign_amount = (float)$transaction->foreign_amount;
|
// add some filters:
|
||||||
$journal->foreign_currency = $transaction->foreignCurrency;
|
|
||||||
|
|
||||||
if (null !== $sources->first()) {
|
|
||||||
$journal->source_account_id = $sources->first()->id;
|
// transform to array
|
||||||
$journal->source_account_name = $sources->first()->editname;
|
$journals = $transactions->map(
|
||||||
}
|
function (Transaction $transaction) use ($transformer) {
|
||||||
if (null !== $destinations->first()) {
|
$result = $transformer->transform($transaction);
|
||||||
$journal->destination_account_id = $destinations->first()->id;
|
|
||||||
$journal->destination_account_name = $destinations->first()->editname;
|
return $result;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (0 === $filtered->count()) {
|
|
||||||
session()->flash('error', trans('firefly.no_edit_multiple_left'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$journals = $filtered;
|
|
||||||
|
|
||||||
return view('transactions.mass.edit', compact('journals', 'subTitle', 'accounts', 'budgets'));
|
return view('transactions.mass.edit', compact('journals', 'subTitle', 'accounts', 'budgets'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,7 +40,6 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Log;
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -42,7 +42,6 @@ use FireflyIII\Transformers\TransactionTransformer;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
|
||||||
use Steam;
|
use Steam;
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
use View;
|
use View;
|
||||||
|
@@ -132,6 +132,20 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
return $journal;
|
return $journal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a specific journal.
|
||||||
|
*
|
||||||
|
* @param int $journalId
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
|
*
|
||||||
|
* @return TransactionJournal|null
|
||||||
|
*/
|
||||||
|
public function findNull(int $journalId): ?TransactionJournal
|
||||||
|
{
|
||||||
|
return $this->user->transactionJournals()->where('id', $journalId)->first();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Transaction $transaction
|
* @param Transaction $transaction
|
||||||
*
|
*
|
||||||
|
@@ -68,11 +68,22 @@ interface JournalRepositoryInterface
|
|||||||
* Find a specific journal.
|
* Find a specific journal.
|
||||||
*
|
*
|
||||||
* @param int $journalId
|
* @param int $journalId
|
||||||
|
* @deprecated
|
||||||
*
|
*
|
||||||
* @return TransactionJournal
|
* @return TransactionJournal
|
||||||
*/
|
*/
|
||||||
public function find(int $journalId): TransactionJournal;
|
public function find(int $journalId): TransactionJournal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a specific journal.
|
||||||
|
*
|
||||||
|
* @param int $journalId
|
||||||
|
* @deprecated
|
||||||
|
*
|
||||||
|
* @return TransactionJournal|null
|
||||||
|
*/
|
||||||
|
public function findNull(int $journalId): ?TransactionJournal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Transaction $transaction
|
* @param Transaction $transaction
|
||||||
*
|
*
|
||||||
|
@@ -157,16 +157,12 @@ class TransactionTransformer extends TransformerAbstract
|
|||||||
$categoryName = null;
|
$categoryName = null;
|
||||||
$budgetId = null;
|
$budgetId = null;
|
||||||
$budgetName = null;
|
$budgetName = null;
|
||||||
$categoryId = null === $transaction->transaction_category_id ? $transaction->transaction_journal_category_id
|
$categoryId = $transaction->transaction_category_id ?? $transaction->transaction_journal_category_id;
|
||||||
: $transaction->transaction_category_id;
|
$categoryName = $transaction->transaction_category_name ?? $transaction->transaction_journal_category_name;
|
||||||
$categoryName = null === $transaction->transaction_category_name ? $transaction->transaction_journal_category_name
|
|
||||||
: $transaction->transaction_category_name;
|
|
||||||
|
|
||||||
if ($transaction->transaction_type_type === TransactionType::WITHDRAWAL) {
|
if ($transaction->transaction_type_type === TransactionType::WITHDRAWAL) {
|
||||||
$budgetId = null === $transaction->transaction_budget_id ? $transaction->transaction_journal_budget_id
|
$budgetId = $transaction->transaction_budget_id ?? $transaction->transaction_journal_budget_id;
|
||||||
: $transaction->transaction_budget_id;
|
$budgetName = $transaction->transaction_budget_name ?? $transaction->transaction_journal_budget_name;
|
||||||
$budgetName = null === $transaction->transaction_budget_name ? $transaction->transaction_journal_budget_name
|
|
||||||
: $transaction->transaction_budget_name;
|
|
||||||
}
|
}
|
||||||
/** @var Note $dbNote */
|
/** @var Note $dbNote */
|
||||||
$dbNote = $transaction->transactionJournal->notes()->first();
|
$dbNote = $transaction->transactionJournal->notes()->first();
|
||||||
@@ -250,7 +246,7 @@ class TransactionTransformer extends TransformerAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
// expand description.
|
// expand description.
|
||||||
if (strlen((string)$transaction->transaction_description) > 0) {
|
if (\strlen((string)$transaction->transaction_description) > 0) {
|
||||||
$data['description'] = $transaction->transaction_description . ' (' . $transaction->description . ')';
|
$data['description'] = $transaction->transaction_description . ' (' . $transaction->description . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,47 +30,47 @@
|
|||||||
<th class="col-lg-2 col-md-2 col-sm-2">{{ trans('list.budget') }}</th>
|
<th class="col-lg-2 col-md-2 col-sm-2">{{ trans('list.budget') }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for journal in journals %}
|
{% for journal in journals %}
|
||||||
{% if journal.transaction_count == 2 %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{# LINK TO EDIT FORM #}
|
{# LINK TO EDIT FORM #}
|
||||||
<a href="{{ route('transactions.edit', journal.id) }}" class="btn btn-xs btn-default"><i
|
<a href="{{ route('transactions.edit', journal.journal_id) }}" class="btn btn-xs btn-default"><i
|
||||||
class="fa fa-fw fa-pencil"></i></a>
|
class="fa fa-fw fa-pencil"></i></a>
|
||||||
<input type="hidden" name="journals[]" value="{{ journal.id }}"/>
|
<input type="hidden" name="journals[]" value="{{ journal.journal_id }}"/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{# DESCRIPTION #}
|
{# DESCRIPTION #}
|
||||||
<input class="form-control input-sm" autocomplete="off"
|
<input class="form-control input-sm" autocomplete="off"
|
||||||
placeholder="{{ journal.description }}" name="description[{{ journal.id }}]"
|
placeholder="{{ journal.description }}" name="description[{{ journal.journal_id }}]"
|
||||||
type="text" value="{{ journal.description }}">
|
type="text" value="{{ journal.description }}">
|
||||||
</td>
|
</td>
|
||||||
|
{# AMOUNT #}
|
||||||
<td>
|
<td>
|
||||||
<div class="input-group input-group-sm">
|
<div class="input-group input-group-sm">
|
||||||
<span class="input-group-addon">{{ journal.currency_symbol }}</span>
|
<span class="input-group-addon">{{ journal.currency_symbol }}</span>
|
||||||
<input name="amount[{{ journal.id }}]" class="form-control" autocomplete="off"
|
<input name="amount[{{ journal.journal_id }}]" class="form-control" autocomplete="off"
|
||||||
step="any" type="number" value="{{ journal.amount }}">
|
step="any" type="number" value="{{ journal.amount }}">
|
||||||
<input type="hidden" name="transaction_currency_id[{{ journal.id }}]"
|
<input type="hidden" name="transaction_currency_id[{{ journal.journal_id }}]"
|
||||||
value="{{ journal.transaction_currency_id }}">
|
value="{{ journal.currency_id }}">
|
||||||
</div>
|
</div>
|
||||||
{% if journal.foreign_amount %}
|
{% if journal.foreign_amount %}
|
||||||
{# insert foreign data #}
|
{# insert foreign data #}
|
||||||
<div class="input-group input-group-sm">
|
<div class="input-group input-group-sm">
|
||||||
<span class="input-group-addon">{{ journal.foreign_currency.symbol }}</span>
|
<span class="input-group-addon">{{ journal.foreign_currency.symbol }}</span>
|
||||||
<input name="foreign_amount[{{ journal.id }}]" class="form-control" autocomplete="off"
|
<input name="foreign_amount[{{ journal.journal_id }}]" class="form-control" autocomplete="off"
|
||||||
step="any" type="number" value="{{ journal.foreign_amount }}">
|
step="any" type="number" value="{{ journal.foreign_amount }}">
|
||||||
<input type="hidden" name="foreign_currency_id[{{ journal.id }}]" value="{{ journal.foreign_currency.id }}">
|
<input type="hidden" name="foreign_currency_id[{{ journal.journal_id }}]" value="{{ journal.foreign_currency.id }}">
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{# DATE #}
|
{# DATE #}
|
||||||
<input class="form-control input-sm" autocomplete="off"
|
<input class="form-control input-sm" autocomplete="off"
|
||||||
name="date[{{ journal.id }}]" type="date" value="{{ journal.date.format('Y-m-d') }}">
|
name="date[{{ journal.journal_id }}]" type="date" value="{{ journal.date.format('Y-m-d') }}">
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{# SOURCE ACCOUNT ID FOR TRANSFER OR WITHDRAWAL #}
|
{# SOURCE ACCOUNT ID FOR TRANSFER OR WITHDRAWAL #}
|
||||||
{% if journal.transaction_type_type == 'Transfer' or journal.transaction_type_type == 'Withdrawal' %}
|
{% if journal.transaction_type_type == 'Transfer' or journal.transaction_type_type == 'Withdrawal' %}
|
||||||
<select class="form-control input-sm" name="source_account_id[{{ journal.id }}]">
|
<select class="form-control input-sm" name="source_account_id[{{ journal.journal_id }}]">
|
||||||
{% for account in accounts %}
|
{% for account in accounts %}
|
||||||
<option value="{{ account.id }}"{% if account.id==journal.source_account_id %} selected="selected"{% endif %}
|
<option value="{{ account.id }}"{% if account.id==journal.source_account_id %} selected="selected"{% endif %}
|
||||||
label="{{ account.name }}">{{ account.name }}</option>
|
label="{{ account.name }}">{{ account.name }}</option>
|
||||||
@@ -79,13 +79,13 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{# SOURCE ACCOUNT NAME FOR DEPOSIT #}
|
{# SOURCE ACCOUNT NAME FOR DEPOSIT #}
|
||||||
<input class="form-control input-sm" placeholder="{{ journal.source_account_name }}" autocomplete="off"
|
<input class="form-control input-sm" placeholder="{{ journal.source_account_name }}" autocomplete="off"
|
||||||
name="source_account_name[{{ journal.id }}]" type="text" value="{{ journal.source_account_name }}">
|
name="source_account_name[{{ journal.journal_id }}]" type="text" value="{{ journal.source_account_name }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if journal.transaction_type_type == 'Transfer' or journal.transaction_type_type == 'Deposit' %}
|
{% if journal.transaction_type_type == 'Transfer' or journal.transaction_type_type == 'Deposit' %}
|
||||||
{# DESTINATION ACCOUNT NAME FOR TRANSFER AND DEPOSIT #}
|
{# DESTINATION ACCOUNT NAME FOR TRANSFER AND DEPOSIT #}
|
||||||
<select class="form-control input-sm" name="destination_account_id[{{ journal.id }}]">
|
<select class="form-control input-sm" name="destination_account_id[{{ journal.journal_id }}]">
|
||||||
{% for account in accounts %}
|
{% for account in accounts %}
|
||||||
<option value="{{ account.id }}"{% if account.id==journal.destination_account_id %} selected="selected"{% endif %}
|
<option value="{{ account.id }}"{% if account.id==journal.destination_account_id %} selected="selected"{% endif %}
|
||||||
label="{{ account.name }}">{{ account.name }}</option>
|
label="{{ account.name }}">{{ account.name }}</option>
|
||||||
@@ -94,19 +94,19 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{# DESTINATION ACCOUNT NAME FOR EXPENSE #}
|
{# DESTINATION ACCOUNT NAME FOR EXPENSE #}
|
||||||
<input class="form-control input-sm" placeholder="{{ journal.destination_account_name }}"
|
<input class="form-control input-sm" placeholder="{{ journal.destination_account_name }}"
|
||||||
name="destination_account_name[{{ journal.id }}]" type="text" autocomplete="off"
|
name="destination_account_name[{{ journal.journal_id }}]" type="text" autocomplete="off"
|
||||||
value="{{ journal.destination_account_name }}">
|
value="{{ journal.destination_account_name }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{# category #}
|
{# category #}
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control input-sm" placeholder="{{ journal.categories[0].name }}" autocomplete="off"
|
<input class="form-control input-sm" placeholder="{{ journal.categories[0].name }}" autocomplete="off"
|
||||||
name="category[{{ journal.id }}]" type="text" value="{{ journal.categories[0].name }}">
|
name="category[{{ journal.journal_id }}]" type="text" value="{{ journal.categories[0].name }}">
|
||||||
</td>
|
</td>
|
||||||
{# budget #}
|
{# budget #}
|
||||||
<td>
|
<td>
|
||||||
{% if journal.transaction_type_type == 'Withdrawal' %}
|
{% if journal.transaction_type_type == 'Withdrawal' %}
|
||||||
<select class="form-control input-sm" name="budget_id[{{ journal.id }}]">
|
<select class="form-control input-sm" name="budget_id[{{ journal.journal_id }}]">
|
||||||
<option value="0" label="({{ 'no_budget'|_ }})"
|
<option value="0" label="({{ 'no_budget'|_ }})"
|
||||||
{% if journal.budgets.count == 0 %}selected="selected"{% endif %}
|
{% if journal.budgets.count == 0 %}selected="selected"{% endif %}
|
||||||
>({{ 'no_budget'|_ }})
|
>({{ 'no_budget'|_ }})
|
||||||
@@ -119,16 +119,12 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
{% if journals.count > 0 %}
|
|
||||||
<input type="submit" name="submit" value="{{ trans('form.update_all_journals') }}" class="btn btn-success pull-right"/>
|
<input type="submit" name="submit" value="{{ trans('form.update_all_journals') }}" class="btn btn-success pull-right"/>
|
||||||
{% endif %}
|
|
||||||
<a href="{{ route('index') }}" class="btn-default btn">{{ trans('form.cancel') }}</a>
|
<a href="{{ route('index') }}" class="btn-default btn">{{ trans('form.cancel') }}</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -973,18 +973,15 @@ Breadcrumbs::register(
|
|||||||
Breadcrumbs::register(
|
Breadcrumbs::register(
|
||||||
'transactions.mass.edit',
|
'transactions.mass.edit',
|
||||||
function (BreadCrumbsGenerator $breadcrumbs, Collection $journals): void {
|
function (BreadCrumbsGenerator $breadcrumbs, Collection $journals): void {
|
||||||
if ($journals->count() > 0) {
|
if (\count($journals) > 0) {
|
||||||
$journalIds = $journals->pluck('id')->toArray();
|
$journalIds = $journals->pluck('id')->toArray();
|
||||||
$what = strtolower($journals->first()->transactionType->type);
|
$what = strtolower($journals->first()['type']);
|
||||||
$breadcrumbs->parent('transactions.index', $what);
|
$breadcrumbs->parent('transactions.index', $what);
|
||||||
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', $journalIds));
|
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', $journalIds));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$breadcrumbs->parent('index');
|
$breadcrumbs->parent('index');
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -822,7 +822,7 @@ Route::group(
|
|||||||
Route::group(
|
Route::group(
|
||||||
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Transaction', 'prefix' => 'transactions/mass', 'as' => 'transactions.mass.'],
|
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Transaction', 'prefix' => 'transactions/mass', 'as' => 'transactions.mass.'],
|
||||||
function () {
|
function () {
|
||||||
Route::get('edit/{journalList}', ['uses' => 'MassController@edit', 'as' => 'edit']);
|
Route::get('edit/{simpleJournalList}', ['uses' => 'MassController@edit', 'as' => 'edit']);
|
||||||
Route::get('delete/{journalList}', ['uses' => 'MassController@delete', 'as' => 'delete']);
|
Route::get('delete/{journalList}', ['uses' => 'MassController@delete', 'as' => 'delete']);
|
||||||
Route::post('update', ['uses' => 'MassController@update', 'as' => 'update']);
|
Route::post('update', ['uses' => 'MassController@update', 'as' => 'update']);
|
||||||
Route::post('destroy', ['uses' => 'MassController@destroy', 'as' => 'destroy']);
|
Route::post('destroy', ['uses' => 'MassController@destroy', 'as' => 'destroy']);
|
||||||
|
Reference in New Issue
Block a user