mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various bugfixes and code clean up.
This commit is contained in:
@@ -63,6 +63,7 @@ class Import extends Command
|
||||
{
|
||||
Log::debug('Start start-import command');
|
||||
$jobKey = (string)$this->argument('key');
|
||||
/** @var ImportJob $job */
|
||||
$job = ImportJob::where('key', $jobKey)->first();
|
||||
if (null === $job) {
|
||||
$this->errorLine(sprintf('No job found with key "%s"', $jobKey));
|
||||
|
@@ -31,6 +31,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Export\Collector\AttachmentCollector;
|
||||
use FireflyIII\Export\Collector\UploadCollector;
|
||||
use FireflyIII\Export\Entry\Entry;
|
||||
use FireflyIII\Export\Exporter\ExporterInterface;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
@@ -220,6 +221,7 @@ class ExpandedProcessor implements ProcessorInterface
|
||||
public function exportJournals(): bool
|
||||
{
|
||||
$exporterClass = config('firefly.export_formats.' . $this->exportFormat);
|
||||
/** @var ExporterInterface $exporter */
|
||||
$exporter = app($exporterClass);
|
||||
$exporter->setJob($this->job);
|
||||
$exporter->setEntries($this->exportEntries);
|
||||
|
@@ -43,7 +43,6 @@ class TransactionCurrencyFactory
|
||||
*/
|
||||
public function create(array $data): ?TransactionCurrency
|
||||
{
|
||||
$result = null;
|
||||
try {
|
||||
/** @var TransactionCurrency $currency */
|
||||
$result = TransactionCurrency::create(
|
||||
@@ -55,6 +54,7 @@ class TransactionCurrencyFactory
|
||||
]
|
||||
);
|
||||
} catch (QueryException $e) {
|
||||
$result = null;
|
||||
Log::error(sprintf('Could not create new currency: %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
|
@@ -81,7 +81,7 @@ class VersionCheckEventHandler
|
||||
|
||||
$latestRelease = $this->getLatestRelease();
|
||||
$versionCheck = $this->versionCheck($latestRelease);
|
||||
$resultString = $this->parseResult($latestRelease, $versionCheck);
|
||||
$resultString = $this->parseResult($versionCheck, $latestRelease);
|
||||
if (0 !== $versionCheck && '' !== $resultString) {
|
||||
// flash info
|
||||
session()->flash('info', $resultString);
|
||||
|
@@ -77,11 +77,12 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
*/
|
||||
public function getAttachmentContent(Attachment $attachment): string
|
||||
{
|
||||
$content = '';
|
||||
|
||||
try {
|
||||
$content = Crypt::decrypt($this->uploadDisk->get(sprintf('at-%d.data', $attachment->id)));
|
||||
} catch (DecryptException|FileNotFoundException $e) {
|
||||
Log::error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
|
||||
$content = '';
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
@@ -76,7 +76,8 @@ class Help implements HelpInterface
|
||||
$statusCode = $res->getStatusCode();
|
||||
$content = trim($res->getBody()->getContents());
|
||||
} catch (GuzzleException|Exception $e) {
|
||||
Log::error($e);
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Status code is %d', $statusCode));
|
||||
|
@@ -66,12 +66,12 @@ trait UpdateTrait
|
||||
/**
|
||||
* Parses the version check result in a human readable sentence.
|
||||
*
|
||||
* @param Release|null $release
|
||||
* @param int $versionCheck
|
||||
* @param Release|null $release
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function parseResult(Release $release = null, int $versionCheck): string
|
||||
public function parseResult(int $versionCheck, Release $release = null): string
|
||||
{
|
||||
$current = (string)config('firefly.version');
|
||||
$return = '';
|
||||
|
@@ -144,10 +144,13 @@ class ReconcileController extends Controller
|
||||
|
||||
// get start and end
|
||||
if (null === $start && null === $end) {
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range));
|
||||
/** @var Carbon $end */
|
||||
$end = clone session('end', app('navigation')->endOfPeriod(new Carbon, $range));
|
||||
}
|
||||
if (null === $end) {
|
||||
/** @var Carbon $end */
|
||||
$end = app('navigation')->endOfPeriod($start, $range);
|
||||
}
|
||||
|
||||
|
@@ -90,7 +90,9 @@ class ShowController extends Controller
|
||||
if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
|
||||
return $this->redirectToOriginalAccount($account);
|
||||
}
|
||||
/** @var Carbon $start */
|
||||
$start = $start ?? session('start');
|
||||
/** @var Carbon $end */
|
||||
$end = $end ?? session('end');
|
||||
if ($end < $start) {
|
||||
throw new FireflyException('End is after start!'); // @codeCoverageIgnore
|
||||
|
@@ -101,7 +101,7 @@ class UpdateController extends Controller
|
||||
{
|
||||
$latestRelease = $this->getLatestRelease();
|
||||
$versionCheck = $this->versionCheck($latestRelease);
|
||||
$resultString = $this->parseResult($latestRelease, $versionCheck);
|
||||
$resultString = $this->parseResult($versionCheck, $latestRelease);
|
||||
|
||||
if (0 !== $versionCheck && '' !== $resultString) {
|
||||
// flash info
|
||||
|
@@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Http\Requests\BillFormRequest;
|
||||
@@ -277,7 +278,9 @@ class BillController extends Controller
|
||||
// add info about rules:
|
||||
$rules = $this->billRepository->getRulesForBill($bill);
|
||||
$subTitle = $bill->name;
|
||||
/** @var Carbon $start */
|
||||
$start = session('start');
|
||||
/** @var Carbon $end */
|
||||
$end = session('end');
|
||||
$year = $start->year;
|
||||
$page = (int)$request->get('page');
|
||||
|
@@ -77,6 +77,7 @@ class IndexController extends Controller
|
||||
*/
|
||||
public function index(Request $request, string $moment = null)
|
||||
{
|
||||
/** @var string $range */
|
||||
$range = app('preferences')->get('viewRange', '1M')->data;
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', new Carbon);
|
||||
|
@@ -195,6 +195,7 @@ class ShowController extends Controller
|
||||
->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();
|
||||
$transactions = $collector->getPaginatedJournals();
|
||||
$transactions->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));
|
||||
/** @var Carbon $start */
|
||||
$start = session('first', Carbon::create()->startOfYear());
|
||||
$end = new Carbon;
|
||||
$limits = $this->getLimits($budget, $start, $end);
|
||||
|
@@ -74,7 +74,9 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function expenseAccounts(AccountRepositoryInterface $repository): JsonResponse
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
|
@@ -276,7 +276,7 @@ class DebugController extends Controller
|
||||
{
|
||||
$packages = [];
|
||||
$file = \dirname(__DIR__, 3) . '/vendor/composer/installed.json';
|
||||
if (!(false === $file) && file_exists($file)) {
|
||||
if (file_exists($file)) {
|
||||
// file exists!
|
||||
$content = file_get_contents($file);
|
||||
$json = json_decode($content, true);
|
||||
|
@@ -59,6 +59,7 @@ class HelpController extends Controller
|
||||
*/
|
||||
public function show(string $route): JsonResponse
|
||||
{
|
||||
/** @var string $language */
|
||||
$language = app('preferences')->get('language', config('firefly.default_language', 'en_US'))->data;
|
||||
$html = $this->getHelpText($route, $language);
|
||||
|
||||
|
@@ -149,8 +149,11 @@ class JavascriptController extends Controller
|
||||
private function getDateRangeConfig(): array
|
||||
{
|
||||
$viewRange = app('preferences')->get('viewRange', '1M')->data;
|
||||
/** @var Carbon $start */
|
||||
$start = session('start');
|
||||
/** @var Carbon $end */
|
||||
$end = session('end');
|
||||
/** @var Carbon $first */
|
||||
$first = session('first');
|
||||
$title = sprintf('%s - %s', $start->formatLocalized($this->monthAndDayFormat), $end->formatLocalized($this->monthAndDayFormat));
|
||||
$isCustom = true === session('is_custom_range', false);
|
||||
|
@@ -54,7 +54,9 @@ class BoxController extends Controller
|
||||
*/
|
||||
public function available(BudgetRepositoryInterface $repository): JsonResponse
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$today = new Carbon;
|
||||
$cache = new CacheProperties;
|
||||
@@ -111,7 +113,9 @@ class BoxController extends Controller
|
||||
public function balance(CurrencyRepositoryInterface $repository): JsonResponse
|
||||
{
|
||||
// Cache result, return cache if present.
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
@@ -195,7 +199,9 @@ class BoxController extends Controller
|
||||
*/
|
||||
public function bills(BillRepositoryInterface $repository): JsonResponse
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
|
||||
$cache = new CacheProperties;
|
||||
|
@@ -161,7 +161,7 @@ class ReconcileController extends Controller
|
||||
|
||||
$currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
|
||||
$currency = $this->currencyRepos->findNull($currencyId);
|
||||
if (0 === $currency) {
|
||||
if (0 === $currencyId) {
|
||||
$currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
@@ -156,10 +156,10 @@ class RecurrenceController extends Controller
|
||||
if ($date > $today || 'true' === (string)$request->get('past')) {
|
||||
$weekly = sprintf('weekly,%s', $date->dayOfWeekIso);
|
||||
$monthly = sprintf('monthly,%s', $date->day);
|
||||
$dayOfWeek = trans(sprintf('config.dow_%s', $date->dayOfWeekIso));
|
||||
$dayOfWeek = (string)trans(sprintf('config.dow_%s', $date->dayOfWeekIso));
|
||||
$ndom = sprintf('ndom,%s,%s', $date->weekOfMonth, $date->dayOfWeekIso);
|
||||
$yearly = sprintf('yearly,%s', $date->format('Y-m-d'));
|
||||
$yearlyDate = $date->formatLocalized(trans('config.month_and_day_no_year'));
|
||||
$yearlyDate = $date->formatLocalized((string)trans('config.month_and_day_no_year'));
|
||||
$result = [
|
||||
'daily' => ['label' => (string)trans('firefly.recurring_daily'), 'selected' => 0 === strpos($preSelected, 'daily')],
|
||||
$weekly => ['label' => (string)trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek]),
|
||||
|
@@ -95,19 +95,16 @@ class IndexController extends Controller
|
||||
/**
|
||||
* Show a single recurring transaction.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Recurrence $recurrence
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function show(Request $request, Recurrence $recurrence)
|
||||
public function show(Recurrence $recurrence)
|
||||
{
|
||||
$transformer = new RecurrenceTransformer(new ParameterBag);
|
||||
$array = $transformer->transform($recurrence);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$transactions = $this->recurring->getTransactions($recurrence, $page, $pageSize);
|
||||
$transactions = $this->recurring->getTransactions($recurrence);
|
||||
|
||||
// transform dates back to Carbon objects:
|
||||
foreach ($array['recurrence_repetitions'] as $index => $repetition) {
|
||||
|
@@ -61,8 +61,6 @@ class Installer
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
// Log::debug(sprintf('URL is %s, will run installer middleware', $url));
|
||||
|
||||
// no tables present?
|
||||
try {
|
||||
DB::table('users')->count();
|
||||
|
@@ -47,6 +47,7 @@ class ExportFormRequest extends Request
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
/** @var Carbon $sessionFirst */
|
||||
$sessionFirst = clone session('first');
|
||||
$first = $sessionFirst->subDay()->format('Y-m-d');
|
||||
$today = Carbon::create()->addDay()->format('Y-m-d');
|
||||
|
@@ -190,7 +190,7 @@ class RecurrenceFormRequest extends Request
|
||||
$rules['repetitions'] = 'required|numeric|between:0,254';
|
||||
}
|
||||
// if foreign amount, currency must be different.
|
||||
if (0.0 !== $this->float('foreign_amount')) {
|
||||
if (null !== $this->float('foreign_amount')) {
|
||||
$rules['foreign_currency_id'] = 'exists:transaction_currencies,id|different:transaction_currency_id';
|
||||
}
|
||||
|
||||
|
@@ -56,11 +56,15 @@ class Request extends FormRequest
|
||||
*
|
||||
* @param string $field
|
||||
*
|
||||
* @return float
|
||||
* @return float|null
|
||||
*/
|
||||
public function float(string $field): float
|
||||
public function float(string $field): ?float
|
||||
{
|
||||
return (float)$this->get($field);
|
||||
$res = $this->get($field);
|
||||
if(null === $res) {
|
||||
return null;
|
||||
}
|
||||
return (float)$res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -50,6 +50,7 @@ class SelectTransactionsRequest extends Request
|
||||
public function rules(): array
|
||||
{
|
||||
// fixed
|
||||
/** @var Carbon $sessionFirst */
|
||||
$sessionFirst = clone session('first');
|
||||
$first = $sessionFirst->subDay()->format('Y-m-d');
|
||||
$today = Carbon::create()->addDay()->format('Y-m-d');
|
||||
|
@@ -113,7 +113,7 @@ class BunqJobConfiguration implements JobConfigurationInterface
|
||||
Log::debug(sprintf('Now in BunqJobConfiguration::getHandler() with stage "%s"', $this->importJob->stage));
|
||||
$handler = null;
|
||||
switch ($this->importJob->stage) {
|
||||
case 'new';
|
||||
case 'new':
|
||||
$handler = app(NewBunqJobHandler::class);
|
||||
$handler->setImportJob($this->importJob);
|
||||
break;
|
||||
|
@@ -101,13 +101,10 @@ class FileJobConfiguration implements JobConfigurationInterface
|
||||
return 'import.file.new';
|
||||
case 'configure-upload':
|
||||
return 'import.file.configure-upload';
|
||||
break;
|
||||
case 'roles':
|
||||
return 'import.file.roles';
|
||||
break;
|
||||
case 'map':
|
||||
return 'import.file.map';
|
||||
break;
|
||||
default:
|
||||
// @codeCoverageIgnoreStart
|
||||
throw new FireflyException(
|
||||
|
@@ -185,7 +185,9 @@ class ImportArrayStorage
|
||||
unset($transaction['importHashV2']);
|
||||
$json = json_encode($transaction);
|
||||
if (false === $json) {
|
||||
throw new FireflyException('Could not encode import array. Please see the logs.', $transaction); // @codeCoverageIgnore
|
||||
/** @noinspection ForgottenDebugOutputInspection */
|
||||
Log::error('Could not encode import array.', print_r($transaction, true));
|
||||
throw new FireflyException('Could not encode import array. Please see the logs.'); // @codeCoverageIgnore
|
||||
}
|
||||
$hash = hash('sha256', $json, false);
|
||||
Log::debug(sprintf('The hash is: %s', $hash));
|
||||
|
@@ -161,7 +161,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
$set = $set->sortBy(
|
||||
function (Bill $bill) {
|
||||
$int = 1 === $bill->active ? 0 : 1;
|
||||
$int = $bill->active ? 0 : 1;
|
||||
|
||||
return $int . strtolower($bill->name);
|
||||
}
|
||||
|
@@ -144,11 +144,12 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
||||
{
|
||||
$disk = Storage::disk('export');
|
||||
$file = $job->key . '.zip';
|
||||
$content = '';
|
||||
|
||||
try {
|
||||
$content = $disk->get($file);
|
||||
} catch (FileNotFoundException $e) {
|
||||
Log::warning(sprintf('File not found: %s', $e->getMessage()));
|
||||
$content = '';
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
@@ -150,12 +150,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
||||
*/
|
||||
public function getConfiguration(ImportJob $job): array
|
||||
{
|
||||
$config = $job->configuration;
|
||||
if (\is_array($config)) {
|
||||
return $config;
|
||||
}
|
||||
|
||||
return [];
|
||||
return $job->configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -477,7 +477,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
|
||||
$value = $entry->data;
|
||||
|
||||
// return when array:
|
||||
if (\is_array($value)) {
|
||||
$return = implode(',', $value);
|
||||
$cache->store($return);
|
||||
|
@@ -379,7 +379,7 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
$repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment);
|
||||
$diffInYears = $today->diffInYears($repDate);
|
||||
$repDate->addYears($diffInYears); // technically not necessary.
|
||||
$string = $repDate->formatLocalized(trans('config.month_and_day_no_year'));
|
||||
$string = $repDate->formatLocalized((string)trans('config.month_and_day_no_year'));
|
||||
|
||||
return (string)trans('firefly.recurring_yearly', ['date' => $string], $language);
|
||||
}
|
||||
|
@@ -67,18 +67,18 @@ class ValidRecurrenceRepetitionValue implements Rule
|
||||
return $this->validateMonthly($value);
|
||||
}
|
||||
|
||||
//ndom,3,7
|
||||
// Value is like: ndom,3,7
|
||||
// nth x-day of the month.
|
||||
if (0 === strpos($value, 'ndom')) {
|
||||
return $this->validateNdom($value);
|
||||
}
|
||||
|
||||
//weekly,7
|
||||
// Value is like: weekly,7
|
||||
if (0 === strpos($value, 'weekly')) {
|
||||
return $this->validateWeekly($value);
|
||||
}
|
||||
|
||||
//yearly,2018-01-01
|
||||
// Value is like: yearly,2018-01-01
|
||||
if (0 === strpos($value, 'yearly')) {
|
||||
return $this->validateYearly($value);
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ use bunq\Util\BunqEnumApiEnvironmentType;
|
||||
use Exception;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Log;
|
||||
use Tests\Object\FakeApiContext;
|
||||
|
||||
/**
|
||||
* Special class to hide away bunq's static initialisation methods.
|
||||
@@ -46,10 +47,10 @@ class ApiContext
|
||||
* @param string|null $proxyUrl
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @return BunqApiContext
|
||||
* @return BunqApiContext|FakeApiContext
|
||||
*/
|
||||
public function create(BunqEnumApiEnvironmentType $environmentType, string $apiKey, string $description, array $permittedIps, string $proxyUrl = null
|
||||
): BunqApiContext {
|
||||
) {
|
||||
$permittedIps = $permittedIps ?? [];
|
||||
try {
|
||||
$context = BunqApiContext::create($environmentType, $apiKey, $description, $permittedIps, $proxyUrl);
|
||||
|
@@ -41,7 +41,6 @@ class IpifyOrg implements IPRetrievalInterface
|
||||
*/
|
||||
public function getIP(): ?string
|
||||
{
|
||||
$result = null;
|
||||
try {
|
||||
$client = new Client;
|
||||
$res = $client->request('GET', 'https://api.ipify.org');
|
||||
|
@@ -28,6 +28,7 @@ use FireflyIII\Factory\BudgetFactory;
|
||||
use FireflyIII\Factory\CategoryFactory;
|
||||
use FireflyIII\Factory\PiggyBankFactory;
|
||||
use FireflyIII\Factory\TransactionCurrencyFactory;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Recurrence;
|
||||
use FireflyIII\Models\RecurrenceMeta;
|
||||
@@ -44,6 +45,15 @@ use Log;
|
||||
*/
|
||||
trait RecurringTransactionTrait
|
||||
{
|
||||
/**
|
||||
* @param null|string $expectedType
|
||||
* @param int|null $accountId
|
||||
* @param null|string $accountName
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract public function findAccount(?string $expectedType, ?int $accountId, ?string $accountName): ?Account;
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
* @param array $repetitions
|
||||
|
@@ -124,7 +124,6 @@ trait TransactionServiceTrait
|
||||
|
||||
// alternatively, return by name. Validator should catch invalid names.
|
||||
return $repository->findByName($accountName, [AccountType::ASSET]);
|
||||
break;
|
||||
case AccountType::EXPENSE:
|
||||
if ($accountId > 0) {
|
||||
// must be able to find it based on ID. Validator should catch invalid ID's.
|
||||
@@ -140,7 +139,6 @@ trait TransactionServiceTrait
|
||||
|
||||
// return cash account:
|
||||
return $repository->getCashAccount();
|
||||
break;
|
||||
case AccountType::REVENUE:
|
||||
if ($accountId > 0) {
|
||||
// must be able to find it based on ID. Validator should catch invalid ID's.
|
||||
|
@@ -250,7 +250,7 @@ abstract class SpectreRequest
|
||||
$client = new Client;
|
||||
$res = $client->request('POST', $fullUri, ['headers' => $headers, 'body' => $body]);
|
||||
} catch (GuzzleException|Exception $e) {
|
||||
throw new FireflyException(sprintf('Request Exception: %s', $e->getMessage()));
|
||||
throw new FireflyException(sprintf('Guzzle Exception: %s', $e->getMessage()));
|
||||
}
|
||||
$body = $res->getBody()->getContents();
|
||||
$statusCode = $res->getStatusCode();
|
||||
|
@@ -66,22 +66,18 @@ class ImportProvider implements BinderInterface
|
||||
$isDemoUser = $repository->hasRole($user, 'demo');
|
||||
$isDebug = (bool)config('app.debug');
|
||||
foreach ($providerNames as $providerName) {
|
||||
//Log::debug(sprintf('Now with provider %s', $providerName));
|
||||
// only consider enabled providers
|
||||
$enabled = (bool)config(sprintf('import.enabled.%s', $providerName));
|
||||
$allowedForDemo = (bool)config(sprintf('import.allowed_for_demo.%s', $providerName));
|
||||
$allowedForUser = (bool)config(sprintf('import.allowed_for_user.%s', $providerName));
|
||||
if (false === $enabled) {
|
||||
//Log::debug('Provider is not enabled. NEXT!');
|
||||
continue;
|
||||
}
|
||||
|
||||
if (true === $isDemoUser && false === $allowedForDemo) {
|
||||
//Log::debug('User is demo and this provider is not allowed for demo user. NEXT!');
|
||||
continue;
|
||||
}
|
||||
if (false === $isDemoUser && false === $allowedForUser && false === $isDebug) {
|
||||
//Log::debug('User is not demo and this provider is not allowed for such users. NEXT!');
|
||||
continue; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
@@ -28,8 +28,11 @@ use Illuminate\Support\Facades\Facade;
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* Class FireflyConfig.
|
||||
* @method ?Configuration get($name, $default = null)
|
||||
* @method null|Configuration get($name, $default = null)
|
||||
* @method Configuration set(string $name, $value)
|
||||
* @method delete(string $name)
|
||||
* @method Configuration|null getFresh(string $name, $default = null)
|
||||
* @method Configuration put(string $name, $value)
|
||||
*/
|
||||
class FireflyConfig extends Facade
|
||||
{
|
||||
|
@@ -34,7 +34,7 @@ use Illuminate\Support\Facades\Facade;
|
||||
* @method Collection beginsWith(User $user, string $search)
|
||||
* @method bool delete(string $name)
|
||||
* @method Collection findByName(string $name)
|
||||
* @method Preference get(string $name, $value)
|
||||
* @method Preference get(string $name, $value = null)
|
||||
* @method array getArrayForUser(User $user, array $list)
|
||||
* @method Preference|null getForUser(User $user, string $name, $default = null)
|
||||
* @method string lastActivity()
|
||||
|
@@ -55,7 +55,7 @@ class FireflyConfig
|
||||
*
|
||||
* @return \FireflyIII\Models\Configuration|null
|
||||
*/
|
||||
public function get(string $name, $default = null): ?Configuration
|
||||
public function get(string $name, $default = null): ?Configuration
|
||||
{
|
||||
$fullName = 'ff-config-' . $name;
|
||||
if (Cache::has($fullName)) {
|
||||
|
@@ -63,7 +63,6 @@ class ConfigureRolesHandler implements FileConfigurationInterface
|
||||
{
|
||||
/** @var array $roles */
|
||||
$roles = $config['column-roles'];
|
||||
$count = $config['column-count'];
|
||||
$assigned = 0;
|
||||
|
||||
// check if data actually contains amount column (foreign amount does not count)
|
||||
|
Reference in New Issue
Block a user