mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 17:33:45 +00:00
Various small bug fixes.
This commit is contained in:
@@ -102,7 +102,8 @@ class ReportHelper implements ReportHelperInterface
|
|||||||
$billLine->setHit(true);
|
$billLine->setHit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($billLine->isActive()) {
|
// non active AND non hit? do not add:
|
||||||
|
if ($billLine->isActive() || $billLine->isHit()) {
|
||||||
$collection->addBill($billLine);
|
$collection->addBill($billLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,9 +15,11 @@ namespace FireflyIII\Http\Controllers;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use ExpandedForm;
|
use ExpandedForm;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Http\Requests\AccountFormRequest;
|
use FireflyIII\Http\Requests\AccountFormRequest;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
@@ -200,6 +202,9 @@ class AccountController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(AccountTaskerInterface $tasker, ARI $repository, Account $account)
|
public function show(AccountTaskerInterface $tasker, ARI $repository, Account $account)
|
||||||
{
|
{
|
||||||
|
if ($account->accountType->type === AccountType::INITIAL_BALANCE) {
|
||||||
|
return $this->redirectToOriginalAccount($account);
|
||||||
|
}
|
||||||
// show journals from current period only:
|
// show journals from current period only:
|
||||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
||||||
$subTitle = $account->name;
|
$subTitle = $account->name;
|
||||||
@@ -330,7 +335,7 @@ class AccountController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(AccountFormRequest $request, ARI $repository, Account $account)
|
public function update(AccountFormRequest $request, ARI $repository, Account $account)
|
||||||
{
|
{
|
||||||
$data = $request->getAccountData();
|
$data = $request->getAccountData();
|
||||||
$repository->update($account, $data);
|
$repository->update($account, $data);
|
||||||
|
|
||||||
Session::flash('success', strval(trans('firefly.updated_account', ['name' => $account->name])));
|
Session::flash('success', strval(trans('firefly.updated_account', ['name' => $account->name])));
|
||||||
@@ -363,4 +368,29 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Account $account
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
private function redirectToOriginalAccount(Account $account)
|
||||||
|
{
|
||||||
|
/** @var Transaction $transaction */
|
||||||
|
$transaction = $account->transactions()->first();
|
||||||
|
if (is_null($transaction)) {
|
||||||
|
throw new FireflyException('Expected a transaction. This account has none. BEEP, error.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$journal = $transaction->transactionJournal;
|
||||||
|
/** @var Transaction $opposingTransaction */
|
||||||
|
$opposingTransaction = $journal->transactions()->where('transactions.id', '!=', $transaction->id)->first();
|
||||||
|
|
||||||
|
if (is_null($opposingTransaction)) {
|
||||||
|
throw new FireflyException('Expected an opposing transaction. This account has none. BEEP, error.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect(route('accounts.show', [$opposingTransaction->account_id]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@ use DB;
|
|||||||
use FireflyIII\Helpers\Collection\Account as AccountCollection;
|
use FireflyIII\Helpers\Collection\Account as AccountCollection;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Database\Query\JoinClause;
|
use Illuminate\Database\Query\JoinClause;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@@ -305,6 +306,8 @@ class AccountTasker implements AccountTaskerInterface
|
|||||||
* - Expense accounts (where money is spent) should only return earnings (the account gets money).
|
* - Expense accounts (where money is spent) should only return earnings (the account gets money).
|
||||||
* - Revenue accounts (where money comes from) should only return expenses (they spend money).
|
* - Revenue accounts (where money comes from) should only return expenses (they spend money).
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
* @param array $accounts
|
* @param array $accounts
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
@@ -325,6 +328,7 @@ class AccountTasker implements AccountTaskerInterface
|
|||||||
$join->on('transaction_journals.id', '=', 'other_side.transaction_journal_id')->where('other_side.amount', $joinModifier, 0);
|
$join->on('transaction_journals.id', '=', 'other_side.transaction_journal_id')->where('other_side.amount', $joinModifier, 0);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
||||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
|
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
|
||||||
->where('transaction_journals.user_id', $this->user->id)
|
->where('transaction_journals.user_id', $this->user->id)
|
||||||
@@ -361,6 +365,8 @@ class AccountTasker implements AccountTaskerInterface
|
|||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
* @param bool $incoming
|
* @param bool $incoming
|
||||||
*
|
*
|
||||||
|
* Opening balances are ignored.
|
||||||
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
protected function financialReport(array $accounts, Carbon $start, Carbon $end, bool $incoming): Collection
|
protected function financialReport(array $accounts, Carbon $start, Carbon $end, bool $incoming): Collection
|
||||||
@@ -371,12 +377,14 @@ class AccountTasker implements AccountTaskerInterface
|
|||||||
$query = Transaction
|
$query = Transaction
|
||||||
::distinct()
|
::distinct()
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
|
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
'transactions as other_side', function (JoinClause $join) use ($joinModifier) {
|
'transactions as other_side', function (JoinClause $join) use ($joinModifier) {
|
||||||
$join->on('transaction_journals.id', '=', 'other_side.transaction_journal_id')->where('other_side.amount', $joinModifier, 0);
|
$join->on('transaction_journals.id', '=', 'other_side.transaction_journal_id')->where('other_side.amount', $joinModifier, 0);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->leftJoin('accounts as other_account', 'other_account.id', '=', 'other_side.account_id')
|
->leftJoin('accounts as other_account', 'other_account.id', '=', 'other_side.account_id')
|
||||||
|
->where('transaction_types.type','!=', TransactionType::OPENING_BALANCE)
|
||||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
||||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
|
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
|
||||||
->where('transaction_journals.user_id', $this->user->id)
|
->where('transaction_journals.user_id', $this->user->id)
|
||||||
|
@@ -40,11 +40,10 @@ class ExpandedForm
|
|||||||
*/
|
*/
|
||||||
public function amount(string $name, $value = null, array $options = []): string
|
public function amount(string $name, $value = null, array $options = []): string
|
||||||
{
|
{
|
||||||
$label = $this->label($name, $options);
|
$label = $this->label($name, $options);
|
||||||
$options = $this->expandOptionArray($name, $label, $options);
|
$options = $this->expandOptionArray($name, $label, $options);
|
||||||
$classes = $this->getHolderClasses($name);
|
$classes = $this->getHolderClasses($name);
|
||||||
$value = round($this->fillFieldValue($name, $value), 2);
|
$value = $this->fillFieldValue($name, $value);
|
||||||
var_dump($value);
|
|
||||||
$options['step'] = 'any';
|
$options['step'] = 'any';
|
||||||
$options['min'] = '0.01';
|
$options['min'] = '0.01';
|
||||||
$defaultCurrency = isset($options['currency']) ? $options['currency'] : Amt::getDefaultCurrency();
|
$defaultCurrency = isset($options['currency']) ? $options['currency'] : Amt::getDefaultCurrency();
|
||||||
|
Reference in New Issue
Block a user