mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-13 01:22:26 -06:00
Repository and test clean up.
This commit is contained in:
parent
54ba18975a
commit
5b8adbfd0c
@ -50,8 +50,9 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
/** @var \Illuminate\Contracts\Filesystem\Filesystem */
|
||||
protected $uploadDisk;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* AttachmentHelper constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -79,6 +79,9 @@ class MetaPieChart implements MetaPieChartInterface
|
||||
/** @var User */
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* MetaPieChart constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->accounts = new Collection;
|
||||
|
@ -77,7 +77,6 @@ class SplitJournalFormRequest extends Request
|
||||
break;
|
||||
}
|
||||
$foreignAmount = $transaction['foreign_amount'] ?? null;
|
||||
$foreignCurrency = isset($transaction['foreign_currency_id']) ? intval($transaction['foreign_currency_id']) : null;
|
||||
$set = [
|
||||
'source_id' => $sourceId,
|
||||
'source_name' => $sourceName,
|
||||
@ -129,39 +128,4 @@ class SplitJournalFormRequest extends Request
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getTransactionData(): array
|
||||
{
|
||||
$descriptions = $this->getArray('description', 'string');
|
||||
$categories = $this->getArray('category', 'string');
|
||||
$amounts = $this->getArray('amount', 'float');
|
||||
$budgets = $this->getArray('amount', 'integer');
|
||||
$srcAccountIds = $this->getArray('source_account_id', 'integer');
|
||||
$srcAccountNames = $this->getArray('source_account_name', 'string');
|
||||
$dstAccountIds = $this->getArray('destination_account_id', 'integer');
|
||||
$dstAccountNames = $this->getArray('destination_account_name', 'string');
|
||||
$piggyBankIds = $this->getArray('piggy_bank_id', 'integer');
|
||||
|
||||
$return = [];
|
||||
// description is leading because it is one of the mandatory fields.
|
||||
foreach ($descriptions as $index => $description) {
|
||||
$category = $categories[$index] ?? '';
|
||||
$transaction = [
|
||||
'description' => $description,
|
||||
'amount' => Steam::positive($amounts[$index]),
|
||||
'budget_id' => $budgets[$index] ?? 0,
|
||||
'category' => $category,
|
||||
'source_account_id' => $srcAccountIds[$index] ?? $this->get('journal_source_account_id'),
|
||||
'source_account_name' => $srcAccountNames[$index] ?? '',
|
||||
'piggy_bank_id' => $piggyBankIds[$index] ?? 0,
|
||||
'destination_account_id' => $dstAccountIds[$index] ?? $this->get('journal_destination_account_id'),
|
||||
'destination_account_name' => $dstAccountNames[$index] ?? '',
|
||||
];
|
||||
$return[] = $transaction;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class PiggyBank extends Model
|
||||
|
||||
/**
|
||||
* Grabs the PiggyBankRepetition that's currently relevant / active.
|
||||
*
|
||||
* @deprecated
|
||||
* @returns PiggyBankRepetition
|
||||
*/
|
||||
public function currentRelevantRep(): PiggyBankRepetition
|
||||
@ -126,6 +126,7 @@ class PiggyBank extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
public function getSuggestedMonthlyAmount(): string
|
||||
@ -152,7 +153,7 @@ class PiggyBank extends Model
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
public function leftOnAccount(Carbon $date): string
|
||||
|
@ -111,6 +111,8 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
/**
|
||||
* Returns the amount of the opening balance for this account.
|
||||
*
|
||||
* @param Account $account
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOpeningBalanceAmount(Account $account): ?string
|
||||
|
@ -410,7 +410,6 @@ class BillRepository implements BillRepositoryInterface
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return \Carbon\Carbon
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function nextDateMatch(Bill $bill, Carbon $date): Carbon
|
||||
{
|
||||
@ -575,6 +574,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
/**
|
||||
* TODO refactor
|
||||
*
|
||||
* @param float $amount
|
||||
* @param float $min
|
||||
* @param float $max
|
||||
@ -592,6 +592,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
/**
|
||||
* TODO refactor
|
||||
*
|
||||
* @param array $matches
|
||||
* @param $description
|
||||
*
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Repositories\Budget;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\AvailableBudget;
|
||||
|
@ -39,6 +39,13 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* CurrencyRepository constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
|
@ -133,7 +133,7 @@ interface ImportJobRepositoryInterface
|
||||
* @param ImportJob $job
|
||||
* @param array $array
|
||||
*
|
||||
* @return void
|
||||
* @return ImportJob
|
||||
*/
|
||||
public function setExtendedStatus(ImportJob $job, array $array): ImportJob;
|
||||
|
||||
@ -147,7 +147,7 @@ interface ImportJobRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
* @param int $count
|
||||
* @param int $steps
|
||||
*
|
||||
* @return ImportJob
|
||||
*/
|
||||
|
@ -197,18 +197,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get account of transaction that is more than zero. Only works with unsplit journals.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function getDestinationAccount(TransactionJournal $journal): Account
|
||||
{
|
||||
return $journal->transactions()->where('amount', '<', 0)->first()->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first positive transaction for the journal. Useful when editing journals.
|
||||
*
|
||||
@ -438,18 +426,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $note->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get account of transaction that is less than zero. Only works with unsplit journals.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function getSourceAccount(TransactionJournal $journal): Account
|
||||
{
|
||||
return $journal->transactions()->where('amount', '>', 0)->first()->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all tags as strings in an array.
|
||||
*
|
||||
@ -542,6 +518,22 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $transactionId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function reconcileById(int $transactionId): bool
|
||||
{
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $this->user->transactions()->find($transactionId);
|
||||
if (!is_null($transaction)) {
|
||||
return $this->reconcile($transaction);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param int $order
|
||||
|
@ -99,15 +99,6 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
public function getAssetTransaction(TransactionJournal $journal): ?Transaction;
|
||||
|
||||
/**
|
||||
* Get account of transaction that is more than zero. Only works with unsplit journals.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function getDestinationAccount(TransactionJournal $journal): Account;
|
||||
|
||||
/**
|
||||
* Returns the first positive transaction for the journal. Useful when editing journals.
|
||||
*
|
||||
@ -199,15 +190,6 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
public function getNoteText(TransactionJournal $journal): string;
|
||||
|
||||
/**
|
||||
* Get account of transaction that is less than zero. Only works with unsplit journals.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function getSourceAccount(TransactionJournal $journal): Account;
|
||||
|
||||
/**
|
||||
* Return all tags as strings in an array.
|
||||
*
|
||||
@ -254,6 +236,13 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
public function reconcile(Transaction $transaction): bool;
|
||||
|
||||
/**
|
||||
* @param int $transactionId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function reconcileById(int $transactionId): bool;
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param int $order
|
||||
|
@ -42,6 +42,8 @@ class JournalTasker implements JournalTaskerInterface
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Collection
|
||||
@ -64,6 +66,7 @@ class JournalTasker implements JournalTaskerInterface
|
||||
* that shows a transaction (transaction/show/xx).
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @return array
|
||||
@ -187,6 +190,8 @@ class JournalTasker implements JournalTaskerInterface
|
||||
* the order of transactions within the journal. So the query is pretty complex:.
|
||||
*
|
||||
* @param int $transactionId
|
||||
*
|
||||
* @deprecated
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
|
@ -52,6 +52,8 @@ interface RuleGroupRepositoryInterface
|
||||
public function find(int $ruleGroupId): RuleGroup;
|
||||
|
||||
/**
|
||||
* Get all rule groups.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function get(): Collection;
|
||||
|
@ -22,6 +22,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\TransactionType;
|
||||
|
||||
use FireflyIII\Models\TransactionType;
|
||||
|
||||
/**
|
||||
@ -29,7 +30,6 @@ use FireflyIII\Models\TransactionType;
|
||||
*/
|
||||
class TransactionTypeRepository implements TransactionTypeRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Find a transaction type or return NULL.
|
||||
*
|
||||
|
@ -58,7 +58,7 @@ class BelongsUser implements Rule
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* TODO use repositories?
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
*
|
||||
|
@ -25,6 +25,7 @@ namespace FireflyIII\Support\Binder;
|
||||
use FireflyIII\Models\Account;
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
@ -49,6 +50,7 @@ class AccountList implements BinderInterface
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (count($list) === 0) {
|
||||
Log::error('Account list is empty.');
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
@ -67,6 +69,7 @@ class AccountList implements BinderInterface
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
Log::error('User is not logged in.');
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
@ -49,6 +50,7 @@ class TagList implements BinderInterface
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (count($list) === 0) {
|
||||
Log::error('Tag list is empty.');
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
/** @var TagRepositoryInterface $repository */
|
||||
@ -66,6 +68,7 @@ class TagList implements BinderInterface
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
Log::error('TagList: user is not logged in.');
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ trait TransactionJournalTrait
|
||||
abstract public function categories(): BelongsToMany;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return Collection
|
||||
*/
|
||||
public function destinationAccountList(): Collection
|
||||
@ -98,6 +99,7 @@ trait TransactionJournalTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return Collection
|
||||
*/
|
||||
public function destinationTransactionList(): Collection
|
||||
@ -116,6 +118,7 @@ trait TransactionJournalTrait
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
@ -148,6 +151,7 @@ trait TransactionJournalTrait
|
||||
abstract public function piggyBankEvents(): HasMany;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return int
|
||||
*/
|
||||
public function piggyBankId(): int
|
||||
@ -160,6 +164,7 @@ trait TransactionJournalTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return Transaction
|
||||
*/
|
||||
public function positiveTransaction(): Transaction
|
||||
@ -185,6 +190,7 @@ trait TransactionJournalTrait
|
||||
abstract public function setMeta(string $name, $value): TransactionJournalMeta;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return Collection
|
||||
*/
|
||||
public function sourceAccountList(): Collection
|
||||
@ -209,6 +215,7 @@ trait TransactionJournalTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return Collection
|
||||
*/
|
||||
public function sourceTransactionList(): Collection
|
||||
@ -227,6 +234,7 @@ trait TransactionJournalTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
public function transactionTypeStr(): string
|
||||
|
@ -258,7 +258,6 @@ class SplitControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController::update
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController::arrayFromInput
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController::getTransactionDataFromRequest
|
||||
*/
|
||||
public function testUpdate()
|
||||
|
Loading…
Reference in New Issue
Block a user