mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Improve test coverage.
This commit is contained in:
parent
4bd8e1b11e
commit
fc70afa3ea
@ -82,17 +82,12 @@ class TagFactory
|
|||||||
public function findOrCreate(string $tag): ?Tag
|
public function findOrCreate(string $tag): ?Tag
|
||||||
{
|
{
|
||||||
$tag = trim($tag);
|
$tag = trim($tag);
|
||||||
if (null === $this->tags) {
|
|
||||||
$this->tags = $this->user->tags()->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var Tag $object */
|
/** @var Tag $dbTag */
|
||||||
foreach ($this->tags as $object) {
|
$dbTag = $this->user->tags()->where('tag', $tag)->first();
|
||||||
if (strtolower($object->tag) === strtolower($tag)) {
|
if (null !== $tag) {
|
||||||
return $object;
|
return $dbTag;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$newTag = $this->create(
|
$newTag = $this->create(
|
||||||
[
|
[
|
||||||
'tag' => $tag,
|
'tag' => $tag,
|
||||||
@ -103,7 +98,6 @@ class TagFactory
|
|||||||
'zoom_level' => null,
|
'zoom_level' => null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->tags->push($newTag);
|
|
||||||
|
|
||||||
return $newTag;
|
return $newTag;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ class Category
|
|||||||
public function getCategories(): Collection
|
public function getCategories(): Collection
|
||||||
{
|
{
|
||||||
$set = $this->categories->sortBy(
|
$set = $this->categories->sortBy(
|
||||||
function (CategoryModel $category) {
|
static function (CategoryModel $category) {
|
||||||
return $category->spent;
|
return $category->spent;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -387,6 +387,10 @@ class CurrencyController extends Controller
|
|||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$data = $request->getCurrencyData();
|
$data = $request->getCurrencyData();
|
||||||
|
|
||||||
|
if (false === $data['enabled'] && $this->repository->currencyInUse($currency)) {
|
||||||
|
$data['enabled'] = true;
|
||||||
|
}
|
||||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
$request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => config('firefly.site_owner')]));
|
$request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => config('firefly.site_owner')]));
|
||||||
|
@ -68,7 +68,7 @@ class AutoCompleteController extends Controller
|
|||||||
$filteredAccountTypes[] = $type;
|
$filteredAccountTypes[] = $type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log::debug('Now in accounts(). Filtering results.', $filteredAccountTypes);
|
Log::debug(sprintf('Now in accounts("%s"). Filtering results.', $search), $filteredAccountTypes);
|
||||||
|
|
||||||
$return = [];
|
$return = [];
|
||||||
$result = $repository->searchAccount((string)$search, $filteredAccountTypes);
|
$result = $repository->searchAccount((string)$search, $filteredAccountTypes);
|
||||||
@ -107,7 +107,7 @@ class AutoCompleteController extends Controller
|
|||||||
|
|
||||||
// filter the account types:
|
// filter the account types:
|
||||||
$allowedAccountTypes = [AccountType::REVENUE];
|
$allowedAccountTypes = [AccountType::REVENUE];
|
||||||
Log::debug('Now in accounts(). Filtering results.', $allowedAccountTypes);
|
Log::debug('Now in revenueAccounts(). Filtering results.', $allowedAccountTypes);
|
||||||
|
|
||||||
$return = [];
|
$return = [];
|
||||||
$result = $repository->searchAccount((string)$search, $allowedAccountTypes);
|
$result = $repository->searchAccount((string)$search, $allowedAccountTypes);
|
||||||
@ -138,7 +138,7 @@ class AutoCompleteController extends Controller
|
|||||||
|
|
||||||
// filter the account types:
|
// filter the account types:
|
||||||
$allowedAccountTypes = [AccountType::EXPENSE];
|
$allowedAccountTypes = [AccountType::EXPENSE];
|
||||||
Log::debug('Now in accounts(). Filtering results.', $allowedAccountTypes);
|
Log::debug(sprintf('Now in expenseAccounts(%s). Filtering results.', $search), $allowedAccountTypes);
|
||||||
|
|
||||||
$return = [];
|
$return = [];
|
||||||
$result = $repository->searchAccount((string)$search, $allowedAccountTypes);
|
$result = $repository->searchAccount((string)$search, $allowedAccountTypes);
|
||||||
|
@ -83,7 +83,7 @@ class SearchController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function search(Request $request, SearchInterface $searcher): JsonResponse
|
public function search(Request $request, SearchInterface $searcher): JsonResponse
|
||||||
{
|
{
|
||||||
$fullQuery = (string)$request->get('query');
|
$fullQuery = (string)$request->get('search');
|
||||||
|
|
||||||
$searcher->parseQuery($fullQuery);
|
$searcher->parseQuery($fullQuery);
|
||||||
$searcher->setLimit((int)config('firefly.search_result_limit'));
|
$searcher->setLimit((int)config('firefly.search_result_limit'));
|
||||||
|
@ -34,6 +34,7 @@ use FireflyIII\Models\ImportJob;
|
|||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
use FireflyIII\Models\Rule;
|
use FireflyIII\Models\Rule;
|
||||||
use FireflyIII\Models\TransactionGroup;
|
use FireflyIII\Models\TransactionGroup;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
@ -568,8 +569,15 @@ class ImportArrayStorage
|
|||||||
$tag = $repository->store($data);
|
$tag = $repository->store($data);
|
||||||
|
|
||||||
Log::debug(sprintf('Created tag #%d ("%s")', $tag->id, $tag->tag));
|
Log::debug(sprintf('Created tag #%d ("%s")', $tag->id, $tag->tag));
|
||||||
Log::debug('Looping journals...');
|
Log::debug('Looping groups...');
|
||||||
$journalIds = $collection->pluck('id')->toArray();
|
|
||||||
|
// TODO double loop.
|
||||||
|
|
||||||
|
/** @var TransactionGroup $group */
|
||||||
|
foreach ($collection as $group) {
|
||||||
|
Log::debug(sprintf('Looping journals in group #%d', $group->id));
|
||||||
|
/** @var TransactionJournal $journal */
|
||||||
|
$journalIds = $group->transactionJournals->pluck('id')->toArray();
|
||||||
$tagId = $tag->id;
|
$tagId = $tag->id;
|
||||||
foreach ($journalIds as $journalId) {
|
foreach ($journalIds as $journalId) {
|
||||||
Log::debug(sprintf('Linking journal #%d to tag #%d...', $journalId, $tagId));
|
Log::debug(sprintf('Linking journal #%d to tag #%d...', $journalId, $tagId));
|
||||||
@ -583,7 +591,7 @@ class ImportArrayStorage
|
|||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
}
|
}
|
||||||
Log::info(sprintf('Linked %d journals to tag #%d ("%s")', $collection->count(), $tag->id, $tag->tag));
|
Log::info(sprintf('Linked %d journals to tag #%d ("%s")', $collection->count(), $tag->id, $tag->tag));
|
||||||
|
}
|
||||||
$this->repository->setTag($this->importJob, $tag);
|
$this->repository->setTag($this->importJob, $tag);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -503,6 +503,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
public function getBudgetPeriodReport(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array
|
public function getBudgetPeriodReport(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array
|
||||||
{
|
{
|
||||||
$carbonFormat = Navigation::preferredCarbonFormat($start, $end);
|
$carbonFormat = Navigation::preferredCarbonFormat($start, $end);
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
// prep data array:
|
// prep data array:
|
||||||
/** @var Budget $budget */
|
/** @var Budget $budget */
|
||||||
@ -517,7 +518,6 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
// get all transactions:
|
// get all transactions:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
|
||||||
$collector->setAccounts($accounts)->setRange($start, $end);
|
$collector->setAccounts($accounts)->setRange($start, $end);
|
||||||
$collector->setBudgets($budgets);
|
$collector->setBudgets($budgets);
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
@ -529,7 +529,6 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
$date = $journal['date']->format($carbonFormat);
|
$date = $journal['date']->format($carbonFormat);
|
||||||
$data[$budgetId]['entries'][$date] = bcadd($data[$budgetId]['entries'][$date] ?? '0', $journal['amount']);
|
$data[$budgetId]['entries'][$date] = bcadd($data[$budgetId]['entries'][$date] ?? '0', $journal['amount']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,9 +25,12 @@ namespace FireflyIII\Repositories\Currency;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Factory\TransactionCurrencyFactory;
|
use FireflyIII\Factory\TransactionCurrencyFactory;
|
||||||
use FireflyIII\Models\AccountMeta;
|
use FireflyIII\Models\AccountMeta;
|
||||||
|
use FireflyIII\Models\AvailableBudget;
|
||||||
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Models\BudgetLimit;
|
use FireflyIII\Models\BudgetLimit;
|
||||||
use FireflyIII\Models\CurrencyExchangeRate;
|
use FireflyIII\Models\CurrencyExchangeRate;
|
||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
|
use FireflyIII\Models\RecurrenceTransaction;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use FireflyIII\Services\Internal\Destroy\CurrencyDestroyService;
|
use FireflyIII\Services\Internal\Destroy\CurrencyDestroyService;
|
||||||
@ -62,7 +65,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function countJournals(TransactionCurrency $currency): int
|
public function countJournals(TransactionCurrency $currency): int
|
||||||
{
|
{
|
||||||
return $currency->transactions()->count();
|
return $currency->transactions()->count() + $currency->transactionJournals()->count();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,14 +79,14 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
Log::debug(sprintf('Now in currencyInUse() for #%d ("%s")', $currency->id, $currency->code));
|
Log::debug(sprintf('Now in currencyInUse() for #%d ("%s")', $currency->id, $currency->code));
|
||||||
$countJournals = $this->countJournals($currency);
|
$countJournals = $this->countJournals($currency);
|
||||||
if ($countJournals > 0) {
|
if ($countJournals > 0) {
|
||||||
Log::debug(sprintf('Count journals is %d, return true.', $countJournals));
|
Log::info(sprintf('Count journals is %d, return true.', $countJournals));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// is the only currency left
|
// is the only currency left
|
||||||
if (1 === $this->getAll()->count()) {
|
if (1 === $this->getAll()->count()) {
|
||||||
Log::debug('Is the last currency in the system, return true. ', $countJournals);
|
Log::info('Is the last currency in the system, return true. ');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -90,7 +94,41 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
// is being used in accounts:
|
// is being used in accounts:
|
||||||
$meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((string)$currency->id))->count();
|
$meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((string)$currency->id))->count();
|
||||||
if ($meta > 0) {
|
if ($meta > 0) {
|
||||||
Log::debug(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
|
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is being used in bills:
|
||||||
|
$bills = Bill::where('transaction_currency_id', $currency->id)->count();
|
||||||
|
if ($bills > 0) {
|
||||||
|
Log::info(sprintf('Used in %d bills as currency, return true. ', $bills));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is being used in recurring transactions
|
||||||
|
$recurringAmount = RecurrenceTransaction::where('transaction_currency_id', $currency->id)->count();
|
||||||
|
$recurringForeign = RecurrenceTransaction::where('foreign_currency_id', $currency->id)->count();
|
||||||
|
|
||||||
|
if ($recurringAmount > 0 || $recurringForeign > 0) {
|
||||||
|
Log::info(sprintf('Used in %d recurring transactions as (foreign) currency id, return true. ', $recurringAmount + $recurringForeign));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is being used in accounts (as integer)
|
||||||
|
$meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((int)$currency->id))->count();
|
||||||
|
if ($meta > 0) {
|
||||||
|
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is being used in available budgets
|
||||||
|
$availableBudgets = AvailableBudget::where('transaction_currency_id', $currency->id)->count();
|
||||||
|
if ($availableBudgets > 0) {
|
||||||
|
Log::info(sprintf('Used in %d available budgets as currency, return true. ', $availableBudgets));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -98,7 +136,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
// is being used in budget limits
|
// is being used in budget limits
|
||||||
$budgetLimit = BudgetLimit::where('transaction_currency_id', $currency->id)->count();
|
$budgetLimit = BudgetLimit::where('transaction_currency_id', $currency->id)->count();
|
||||||
if ($budgetLimit > 0) {
|
if ($budgetLimit > 0) {
|
||||||
Log::debug(sprintf('Used in %d budget limits as currency, return true. ', $budgetLimit));
|
Log::info(sprintf('Used in %d budget limits as currency, return true. ', $budgetLimit));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -106,19 +144,19 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
// is the default currency for the user or the system
|
// is the default currency for the user or the system
|
||||||
$defaultCode = app('preferences')->getForUser($this->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data;
|
$defaultCode = app('preferences')->getForUser($this->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data;
|
||||||
if ($currency->code === $defaultCode) {
|
if ($currency->code === $defaultCode) {
|
||||||
Log::debug('Is the default currency of the user, return true.');
|
Log::info('Is the default currency of the user, return true.');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// is the default currency for the system
|
// is the default currency for the system
|
||||||
$defaultSystemCode = config('firefly.default_currency', 'EUR');
|
// $defaultSystemCode = config('firefly.default_currency', 'EUR');
|
||||||
$result = $currency->code === $defaultSystemCode;
|
// $result = $currency->code === $defaultSystemCode;
|
||||||
if (true === $result) {
|
// if (true === $result) {
|
||||||
Log::debug('Is the default currency of the SYSTEM, return true.');
|
// Log::info('Is the default currency of the SYSTEM, return true.');
|
||||||
|
//
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
Log::debug('Currency is not used, return false.');
|
Log::debug('Currency is not used, return false.');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -73,7 +73,7 @@ class ListLoginsRequest extends SpectreRequest
|
|||||||
}
|
}
|
||||||
// sort logins by date created:
|
// sort logins by date created:
|
||||||
$sorted = $collection->sortByDesc(
|
$sorted = $collection->sortByDesc(
|
||||||
function (Login $login) {
|
static function (Login $login) {
|
||||||
return $login->getUpdatedAt()->timestamp;
|
return $login->getUpdatedAt()->timestamp;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -53,7 +53,6 @@ trait BasicDataSupport
|
|||||||
unset($data[$entryId]);
|
unset($data[$entryId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ use Log;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AssetAccountMapper
|
* Class AssetAccountMapper
|
||||||
|
* Can also handle liability accounts.
|
||||||
*/
|
*/
|
||||||
class AssetAccountMapper
|
class AssetAccountMapper
|
||||||
{
|
{
|
||||||
@ -41,6 +42,17 @@ class AssetAccountMapper
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
private $types;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AssetAccountMapper constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Based upon data in the importable, try to find or create the asset account account.
|
* Based upon data in the importable, try to find or create the asset account account.
|
||||||
*
|
*
|
||||||
@ -56,12 +68,12 @@ class AssetAccountMapper
|
|||||||
if ((int)$accountId > 0) {
|
if ((int)$accountId > 0) {
|
||||||
// find asset account with this ID:
|
// find asset account with this ID:
|
||||||
$result = $this->repository->findNull($accountId);
|
$result = $this->repository->findNull($accountId);
|
||||||
if (null !== $result && $result->accountType->type === AccountType::ASSET) {
|
if (null !== $result && in_array($result->accountType->type, $this->types, true)) {
|
||||||
Log::debug(sprintf('Found asset account "%s" based on given ID %d', $result->name, $accountId));
|
Log::debug(sprintf('Found %s "%s" based on given ID %d', $result->accountType->type, $result->name, $accountId));
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
if (null !== $result && $result->accountType->type !== AccountType::ASSET) {
|
if (null !== $result && in_array($result->accountType->type, $this->types, true)) {
|
||||||
Log::warning(
|
Log::warning(
|
||||||
sprintf('Found account "%s" based on given ID %d but its a %s, return nothing.', $result->name, $accountId, $result->accountType->type)
|
sprintf('Found account "%s" based on given ID %d but its a %s, return nothing.', $result->name, $accountId, $result->accountType->type)
|
||||||
);
|
);
|
||||||
@ -76,8 +88,8 @@ class AssetAccountMapper
|
|||||||
Log::debug(sprintf('Array does not contain a value for %s. Continue', $field));
|
Log::debug(sprintf('Array does not contain a value for %s. Continue', $field));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$result = $this->repository->$function($value, [AccountType::ASSET]);
|
$result = $this->repository->$function($value, $this->types);
|
||||||
Log::debug(sprintf('Going to run %s() with argument "%s" (asset account)', $function, $value));
|
Log::debug(sprintf('Going to run %s() with argument "%s" (asset account or liability)', $function, $value));
|
||||||
if (null !== $result) {
|
if (null !== $result) {
|
||||||
Log::debug(sprintf('Found asset account "%s". Return it!', $result->name));
|
Log::debug(sprintf('Found asset account "%s". Return it!', $result->name));
|
||||||
|
|
||||||
|
@ -228,19 +228,12 @@ class ImportableConverter
|
|||||||
{
|
{
|
||||||
$type = 'unknown';
|
$type = 'unknown';
|
||||||
|
|
||||||
if ($source === AccountType::ASSET && $destination === AccountType::ASSET) {
|
$newType = config(sprintf('firefly.account_to_transaction.%s.%s', $source, $destination));
|
||||||
Log::debug('Source and destination are asset accounts. This is a transfer.');
|
if (null !== $newType) {
|
||||||
$type = 'transfer';
|
Log::debug(sprintf('Source is %s, destination is %s, so this is a %s.', $source, $destination, $newType));
|
||||||
}
|
|
||||||
if ($source === AccountType::REVENUE) {
|
|
||||||
Log::debug('Source is a revenue account. This is a deposit.');
|
|
||||||
$type = 'deposit';
|
|
||||||
}
|
|
||||||
if ($destination === AccountType::EXPENSE) {
|
|
||||||
Log::debug('Destination is an expense account. This is a withdrawal.');
|
|
||||||
$type = 'withdrawal';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return (string)$newType;
|
||||||
|
}
|
||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,15 +60,19 @@ class OpposingAccountMapper
|
|||||||
Log::debug(sprintf('Because amount is %s, will instead search for accounts of type %s', $amount, $expectedType));
|
Log::debug(sprintf('Because amount is %s, will instead search for accounts of type %s', $amount, $expectedType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// append expected types with liability types:
|
||||||
|
$expectedTypes = [$expectedType, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
|
||||||
|
|
||||||
|
|
||||||
if ((int)$accountId > 0) {
|
if ((int)$accountId > 0) {
|
||||||
// find any account with this ID:
|
// find any account with this ID:
|
||||||
$result = $this->repository->findNull($accountId);
|
$result = $this->repository->findNull($accountId);
|
||||||
if (null !== $result && ($result->accountType->type === $expectedType || $result->accountType->type === AccountType::ASSET)) {
|
if (null !== $result && (in_array($result->accountType->type, $expectedTypes, true) || $result->accountType->type === AccountType::ASSET)) {
|
||||||
Log::debug(sprintf('Found account "%s" (%s) based on given ID %d. Return it!', $result->name, $result->accountType->type, $accountId));
|
Log::debug(sprintf('Found account "%s" (%s) based on given ID %d. Return it!', $result->name, $result->accountType->type, $accountId));
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
if (null !== $result && $result->accountType->type !== $expectedType) {
|
if (null !== $result && !in_array($result->accountType->type, $expectedTypes, true)) {
|
||||||
Log::warning(
|
Log::warning(
|
||||||
sprintf(
|
sprintf(
|
||||||
'Found account "%s" (%s) based on given ID %d, but need a %s. Return nothing.', $result->name, $result->accountType->type, $accountId,
|
'Found account "%s" (%s) based on given ID %d, but need a %s. Return nothing.', $result->name, $result->accountType->type, $accountId,
|
||||||
@ -90,7 +94,7 @@ class OpposingAccountMapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// first search for $expectedType, then find asset:
|
// first search for $expectedType, then find asset:
|
||||||
$searchTypes = [$expectedType, AccountType::ASSET];
|
$searchTypes = [$expectedType, AccountType::ASSET, AccountType::DEBT, AccountType::MORTGAGE, AccountType::LOAN];
|
||||||
foreach ($searchTypes as $type) {
|
foreach ($searchTypes as $type) {
|
||||||
// find by (respectively):
|
// find by (respectively):
|
||||||
// IBAN, accountNumber, name,
|
// IBAN, accountNumber, name,
|
||||||
|
@ -174,7 +174,9 @@ class StageImportDataHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
$entry = [
|
$entry = [
|
||||||
'type' => $type,
|
// transaction data:
|
||||||
|
'transactions' => [
|
||||||
|
[
|
||||||
'date' => $transaction->getMadeOn()->format('Y-m-d'),
|
'date' => $transaction->getMadeOn()->format('Y-m-d'),
|
||||||
'tags' => $tags,
|
'tags' => $tags,
|
||||||
'user' => $this->importJob->user_id,
|
'user' => $this->importJob->user_id,
|
||||||
@ -190,13 +192,9 @@ class StageImportDataHandler
|
|||||||
'bill_id' => null,
|
'bill_id' => null,
|
||||||
'bill_name' => null,
|
'bill_name' => null,
|
||||||
'original-source' => sprintf('spectre-v%s', config('firefly.version')),
|
'original-source' => sprintf('spectre-v%s', config('firefly.version')),
|
||||||
|
'type' => $type,
|
||||||
// transaction data:
|
|
||||||
'transactions' => [
|
|
||||||
[
|
|
||||||
'currency_id' => null,
|
'currency_id' => null,
|
||||||
'currency_code' => $currencyCode,
|
'currency_code' => $currencyCode,
|
||||||
'description' => null,
|
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
'budget_id' => null,
|
'budget_id' => null,
|
||||||
'budget_name' => null,
|
'budget_name' => null,
|
||||||
|
@ -25,7 +25,6 @@ namespace FireflyIII\Support;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Navigation.
|
* Class Navigation.
|
||||||
@ -307,16 +306,15 @@ class Navigation
|
|||||||
$displayFormat = (string)trans('config.year');
|
$displayFormat = (string)trans('config.year');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$begin = clone $start;
|
$begin = clone $start;
|
||||||
$entries = [];
|
$entries = [];
|
||||||
while ($begin < $end) {
|
while ($begin < $end) {
|
||||||
$formatted = $begin->format($format);
|
$formatted = $begin->format($format);
|
||||||
$displayed = $begin->formatLocalized($displayFormat);
|
$displayed = $begin->formatLocalized($displayFormat);
|
||||||
$entries[$formatted] = $displayed;
|
$entries[$formatted] = $displayed;
|
||||||
|
|
||||||
$begin->$increment();
|
$begin->$increment();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entries;
|
return $entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
57796
public/v1/js/app.js
vendored
57796
public/v1/js/app.js
vendored
File diff suppressed because one or more lines are too long
@ -94,7 +94,7 @@
|
|||||||
this.target = this.$refs.input;
|
this.target = this.$refs.input;
|
||||||
let types = this.allowedTypes.join(',');
|
let types = this.allowedTypes.join(',');
|
||||||
this.name = this.accountName;
|
this.name = this.accountName;
|
||||||
this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&query=";
|
this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&search=";
|
||||||
this.triggerTransactionType();
|
this.triggerTransactionType();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -104,7 +104,7 @@
|
|||||||
},
|
},
|
||||||
accountTypeFilters() {
|
accountTypeFilters() {
|
||||||
let types = this.accountTypeFilters.join(',');
|
let types = this.accountTypeFilters.join(',');
|
||||||
this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&query=";
|
this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&search=";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods:
|
methods:
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.target = this.$refs.input;
|
this.target = this.$refs.input;
|
||||||
this.categoryAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/categories?query=";
|
this.categoryAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/categories?search=";
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
hasError: function () {
|
hasError: function () {
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
if (this.tag.length < 2) {
|
if (this.tag.length < 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const url = document.getElementsByTagName('base')[0].href + `json/tags?query=${this.tag}`;
|
const url = document.getElementsByTagName('base')[0].href + `json/tags?search=${this.tag}`;
|
||||||
|
|
||||||
clearTimeout(this.debounce);
|
clearTimeout(this.debounce);
|
||||||
this.debounce = setTimeout(() => {
|
this.debounce = setTimeout(() => {
|
||||||
|
@ -849,6 +849,7 @@ return [
|
|||||||
'bulk_edit' => 'Edit selected in bulk',
|
'bulk_edit' => 'Edit selected in bulk',
|
||||||
'mass_delete' => 'Delete selected',
|
'mass_delete' => 'Delete selected',
|
||||||
'cannot_edit_other_fields' => 'You cannot mass-edit other fields than the ones here, because there is no room to show them. Please follow the link and edit them by one-by-one, if you need to edit these fields.',
|
'cannot_edit_other_fields' => 'You cannot mass-edit other fields than the ones here, because there is no room to show them. Please follow the link and edit them by one-by-one, if you need to edit these fields.',
|
||||||
|
'cannot_change_amount_reconciled' => 'You can\'t change the amount of reconciled transactions.',
|
||||||
'no_budget' => '(no budget)',
|
'no_budget' => '(no budget)',
|
||||||
'no_budget_squared' => '(no budget)',
|
'no_budget_squared' => '(no budget)',
|
||||||
'perm-delete-many' => 'Deleting many items in one go can be very disruptive. Please be cautious. You can delete part of a split transaction from this page, so take care.',
|
'perm-delete-many' => 'Deleting many items in one go can be very disruptive. Please be cautious. You can delete part of a split transaction from this page, so take care.',
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="query" class="col-sm-1 control-label">{{ 'search_query'|_ }}</label>
|
<label for="query" class="col-sm-1 control-label">{{ 'search_query'|_ }}</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input autocomplete="off" type="text" name="q" id="query" value="{{ fullQuery }}" class="form-control"
|
<input autocomplete="off" type="text" name="search" id="query" value="{{ fullQuery }}" class="form-control"
|
||||||
placeholder="{{ fullQuery }}">
|
placeholder="{{ fullQuery }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -99,6 +99,7 @@
|
|||||||
|
|
||||||
{# TWO: WITHDRAWAL TO TRANSFER #}
|
{# TWO: WITHDRAWAL TO TRANSFER #}
|
||||||
{% if sourceType.type == 'Withdrawal' and destinationType.type == 'Transfer' %}
|
{% if sourceType.type == 'Withdrawal' and destinationType.type == 'Transfer' %}
|
||||||
|
|
||||||
<a href="{{ route('accounts.show', [transaction.source_id]) }}"
|
<a href="{{ route('accounts.show', [transaction.source_id]) }}"
|
||||||
title="{{ transaction.source_iban|default(transaction.source_name) }}">{{ transaction.source_name }}</a>
|
title="{{ transaction.source_iban|default(transaction.source_name) }}">{{ transaction.source_name }}</a>
|
||||||
{# hide source in hidden input #}
|
{# hide source in hidden input #}
|
||||||
|
@ -17,7 +17,9 @@
|
|||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<p>
|
<p>
|
||||||
{{ 'cannot_edit_other_fields'|_ }}
|
{{ 'cannot_edit_other_fields'|_ }}
|
||||||
|
<span class="text-danger">{{ 'cannot_change_amount_reconciled'|_ }}</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table class="table table-striped table-condensed">
|
<table class="table table-striped table-condensed">
|
||||||
<tr>
|
<tr>
|
||||||
<th class=""> </th>
|
<th class=""> </th>
|
||||||
@ -45,9 +47,8 @@
|
|||||||
</td>
|
</td>
|
||||||
{# AMOUNT #}
|
{# AMOUNT #}
|
||||||
<td>
|
<td>
|
||||||
|
{% if journal.reconciled == false %}
|
||||||
<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.transaction_journal_id }}]" class="form-control" autocomplete="off"
|
<input name="amount[{{ journal.transaction_journal_id }}]" class="form-control" autocomplete="off"
|
||||||
step="any" type="number" value="{{ journal.amount }}">
|
step="any" type="number" value="{{ journal.amount }}">
|
||||||
@ -64,6 +65,29 @@
|
|||||||
value="{{ journal.foreign_currency_id }}">
|
value="{{ journal.foreign_currency_id }}">
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
<span class="text-sm">
|
||||||
|
{% if journal.reconciled != false %}
|
||||||
|
{% if journal.transaction_type_type == 'Deposit' %}
|
||||||
|
{{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_symbol_decimal_places) }}
|
||||||
|
{% if null != journal.foreign_amount %}
|
||||||
|
({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
|
{% elseif journal.transaction_type_type == 'Transfer' %}
|
||||||
|
<span class="text-info">
|
||||||
|
{{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_symbol_decimal_places, false) }}
|
||||||
|
{% if null != journal.foreign_amount %}
|
||||||
|
({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places, false) }})
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
{% else %}
|
||||||
|
{{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_symbol_decimal_places) }}
|
||||||
|
{% if null != journal.foreign_amount %}
|
||||||
|
({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_symbol_decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{# DATE #}
|
{# DATE #}
|
||||||
|
Loading…
Reference in New Issue
Block a user