mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-15 06:08:16 +00:00
Code cleanup and realign.
This commit is contained in:
@@ -34,7 +34,6 @@ use Illuminate\Http\JsonResponse;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
use League\Fractal\Manager;
|
use League\Fractal\Manager;
|
||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class ConfigurationController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
|
|
||||||
if (!$this->repository->hasRole($admin, 'owner')) {
|
if (!$this->repository->hasRole($admin, 'owner')) {
|
||||||
|
/** @noinspection ExceptionsAnnotatingAndHandlingInspection */
|
||||||
throw new FireflyException('No access to method.'); // @codeCoverageIgnore
|
throw new FireflyException('No access to method.'); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ class ScanAttachments extends Command
|
|||||||
$attachment->save();
|
$attachment->save();
|
||||||
$this->line(sprintf('Fixed attachment #%d', $attachment->id));
|
$this->line(sprintf('Fixed attachment #%d', $attachment->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class UpgradeFireflyInstructions extends Command
|
|||||||
if ('install' === (string)$this->argument('task')) {
|
if ('install' === (string)$this->argument('task')) {
|
||||||
$this->installInstructions();
|
$this->installInstructions();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ class UseEncryption extends Command
|
|||||||
$this->handleObjects('Category', 'name', 'encrypted');
|
$this->handleObjects('Category', 'name', 'encrypted');
|
||||||
$this->handleObjects('PiggyBank', 'name', 'encrypted');
|
$this->handleObjects('PiggyBank', 'name', 'encrypted');
|
||||||
$this->handleObjects('TransactionJournal', 'description', 'encrypted');
|
$this->handleObjects('TransactionJournal', 'description', 'encrypted');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ class RequestedNewPassword extends Event
|
|||||||
|
|
||||||
/** @var string The users IP address */
|
/** @var string The users IP address */
|
||||||
public $ipAddress;
|
public $ipAddress;
|
||||||
/** @var User The user */
|
|
||||||
public $user;
|
|
||||||
/** @var string The token */
|
/** @var string The token */
|
||||||
public $token;
|
public $token;
|
||||||
|
/** @var User The user */
|
||||||
|
public $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance. This event is triggered when a users tries to reset his or her password.
|
* Create a new event instance. This event is triggered when a users tries to reset his or her password.
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ use Crypt;
|
|||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Storage;
|
use Storage;
|
||||||
@@ -108,7 +107,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
|
|||||||
if ($this->uploadDisk->exists($file)) {
|
if ($this->uploadDisk->exists($file)) {
|
||||||
try {
|
try {
|
||||||
$decrypted = Crypt::decrypt($this->uploadDisk->get($file));
|
$decrypted = Crypt::decrypt($this->uploadDisk->get($file));
|
||||||
} catch (FileNotFoundException|DecryptException $e) {
|
} catch (DecryptException $e) {
|
||||||
Log::error('Catchable error: could not decrypt attachment #' . $attachment->id . ' because: ' . $e->getMessage());
|
Log::error('Catchable error: could not decrypt attachment #' . $attachment->id . ' because: ' . $e->getMessage());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class ExpandedProcessor implements ProcessorInterface
|
|||||||
{
|
{
|
||||||
/** @var Collection All accounts */
|
/** @var Collection All accounts */
|
||||||
public $accounts;
|
public $accounts;
|
||||||
/** @var string The export format*/
|
/** @var string The export format */
|
||||||
public $exportFormat;
|
public $exportFormat;
|
||||||
/** @var bool Should include attachments */
|
/** @var bool Should include attachments */
|
||||||
public $includeAttachments;
|
public $includeAttachments;
|
||||||
@@ -62,7 +62,7 @@ class ExpandedProcessor implements ProcessorInterface
|
|||||||
public $includeOldUploads;
|
public $includeOldUploads;
|
||||||
/** @var ExportJob The export job itself */
|
/** @var ExportJob The export job itself */
|
||||||
public $job;
|
public $job;
|
||||||
/** @var array The settings*/
|
/** @var array The settings */
|
||||||
public $settings;
|
public $settings;
|
||||||
/** @var Collection The entries to export. */
|
/** @var Collection The entries to export. */
|
||||||
private $exportEntries;
|
private $exportEntries;
|
||||||
@@ -260,7 +260,7 @@ class ExpandedProcessor implements ProcessorInterface
|
|||||||
/**
|
/**
|
||||||
* Delete files.
|
* Delete files.
|
||||||
*/
|
*/
|
||||||
private function deleteFiles():void
|
private function deleteFiles(): void
|
||||||
{
|
{
|
||||||
$disk = Storage::disk('export');
|
$disk = Storage::disk('export');
|
||||||
foreach ($this->getFiles() as $file) {
|
foreach ($this->getFiles() as $file) {
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class TransactionJournalFactory
|
|||||||
// store date meta fields (if present):
|
// store date meta fields (if present):
|
||||||
$fields = ['sepa-cc', 'sepa-ct-op', 'sepa-ct-id', 'sepa-db', 'sepa-country', 'sepa-ep', 'sepa-ci', 'interest_date', 'book_date', 'process_date',
|
$fields = ['sepa-cc', 'sepa-ct-op', 'sepa-ct-id', 'sepa-db', 'sepa-country', 'sepa-ep', 'sepa-ci', 'interest_date', 'book_date', 'process_date',
|
||||||
'due_date', 'recurrence_id', 'payment_date', 'invoice_date', 'internal_reference', 'bunq_payment_id', 'importHash', 'importHashV2',
|
'due_date', 'recurrence_id', 'payment_date', 'invoice_date', 'internal_reference', 'bunq_payment_id', 'importHash', 'importHashV2',
|
||||||
'external_id','sepa-batch-id'];
|
'external_id', 'sepa-batch-id'];
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$this->storeMeta($journal, $data, $field);
|
$this->storeMeta($journal, $data, $field);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
|||||||
|
|
||||||
// render!
|
// render!
|
||||||
try {
|
try {
|
||||||
$result= view('reports.budget.month', compact('accountIds', 'budgetIds', 'accountSummary', 'budgetSummary', 'averageExpenses', 'topExpenses'))
|
$result = view('reports.budget.month', compact('accountIds', 'budgetIds', 'accountSummary', 'budgetSummary', 'averageExpenses', 'topExpenses'))
|
||||||
->with('start', $this->start)->with('end', $this->end)
|
->with('start', $this->start)->with('end', $this->end)
|
||||||
->with('budgets', $this->budgets)
|
->with('budgets', $this->budgets)
|
||||||
->with('accounts', $this->accounts)
|
->with('accounts', $this->accounts)
|
||||||
@@ -87,6 +87,7 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
|||||||
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
|
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
|
||||||
$result = 'Could not render report view.';
|
$result = 'Could not render report view.';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
|||||||
try {
|
try {
|
||||||
$result = view(
|
$result = view(
|
||||||
'reports.tag.month', compact(
|
'reports.tag.month', compact(
|
||||||
'accountIds', 'tagTags', 'reportType', 'accountSummary', 'tagSummary', 'averageExpenses', 'averageIncome', 'topIncome', 'topExpenses'
|
'accountIds', 'tagTags', 'reportType', 'accountSummary', 'tagSummary', 'averageExpenses', 'averageIncome', 'topIncome',
|
||||||
|
'topExpenses'
|
||||||
)
|
)
|
||||||
)->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render();
|
)->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
|
|||||||
@@ -27,14 +27,12 @@ namespace FireflyIII\Handlers\Events;
|
|||||||
|
|
||||||
use FireflyConfig;
|
use FireflyConfig;
|
||||||
use FireflyIII\Events\RequestedVersionCheckStatus;
|
use FireflyIII\Events\RequestedVersionCheckStatus;
|
||||||
|
|
||||||
use FireflyIII\Helpers\Update\UpdateTrait;
|
use FireflyIII\Helpers\Update\UpdateTrait;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
|
|
||||||
|
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class VersionCheckEventHandler
|
* Class VersionCheckEventHandler
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ namespace FireflyIII\Helpers\Attachments;
|
|||||||
use Crypt;
|
use Crypt;
|
||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
@@ -80,7 +79,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$content = Crypt::decrypt($this->uploadDisk->get(sprintf('at-%d.data', $attachment->id)));
|
$content = Crypt::decrypt($this->uploadDisk->get(sprintf('at-%d.data', $attachment->id)));
|
||||||
} catch (DecryptException|FileNotFoundException $e) {
|
} catch (DecryptException $e) {
|
||||||
Log::error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
|
Log::error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
|
||||||
$content = '';
|
$content = '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
|||||||
{
|
{
|
||||||
$set = $balance->getBalanceLines();
|
$set = $balance->getBalanceLines();
|
||||||
$newSet = new Collection;
|
$newSet = new Collection;
|
||||||
|
/** @var BalanceLine $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
if (null !== $entry->getBudget()->id) {
|
if (null !== $entry->getBudget()->id) {
|
||||||
$sum = '0';
|
$sum = '0';
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class CreateController extends Controller
|
|||||||
}
|
}
|
||||||
$request->session()->forget('accounts.create.fromStore');
|
$request->session()->forget('accounts.create.fromStore');
|
||||||
|
|
||||||
return view('accounts.create', compact('subTitleIcon', 'what','interestPeriods', 'subTitle', 'roles', 'liabilityTypes'));
|
return view('accounts.create', compact('subTitleIcon', 'what', 'interestPeriods', 'subTitle', 'roles', 'liabilityTypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class LinkController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a new link form.
|
* Make a new link form.
|
||||||
|
*
|
||||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
|||||||
use FireflyIII\Http\Requests\BillFormRequest;
|
use FireflyIII\Http\Requests\BillFormRequest;
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
|
||||||
use FireflyIII\TransactionRules\TransactionMatcher;
|
use FireflyIII\TransactionRules\TransactionMatcher;
|
||||||
use FireflyIII\Transformers\BillTransformer;
|
use FireflyIII\Transformers\BillTransformer;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
@@ -51,8 +50,6 @@ class BillController extends Controller
|
|||||||
private $attachments;
|
private $attachments;
|
||||||
/** @var BillRepositoryInterface Bill repository */
|
/** @var BillRepositoryInterface Bill repository */
|
||||||
private $billRepository;
|
private $billRepository;
|
||||||
/** @var RuleGroupRepositoryInterface Rule group repository */
|
|
||||||
private $ruleGroupRepos;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BillController constructor.
|
* BillController constructor.
|
||||||
@@ -72,7 +69,6 @@ class BillController extends Controller
|
|||||||
app('view')->share('mainTitleIcon', 'fa-calendar-o');
|
app('view')->share('mainTitleIcon', 'fa-calendar-o');
|
||||||
$this->attachments = app(AttachmentHelperInterface::class);
|
$this->attachments = app(AttachmentHelperInterface::class);
|
||||||
$this->billRepository = app(BillRepositoryInterface::class);
|
$this->billRepository = app(BillRepositoryInterface::class);
|
||||||
$this->ruleGroupRepos = app(RuleGroupRepositoryInterface::class);
|
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
|||||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
|
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ class AccountController extends Controller
|
|||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
/** @var JournalCollectorInterface $collector */
|
||||||
$collector = app(JournalCollectorInterface::class);
|
$collector = app(JournalCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withBudgetInformation()->setTypes([TransactionType::WITHDRAWAL]);
|
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withBudgetInformation()->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
$transactions = $collector->getJournals();
|
$transactions = $collector->getJournals();
|
||||||
@@ -192,6 +193,7 @@ class AccountController extends Controller
|
|||||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var JournalCollectorInterface $collector */
|
||||||
$collector = app(JournalCollectorInterface::class);
|
$collector = app(JournalCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::WITHDRAWAL]);
|
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
$transactions = $collector->getJournals();
|
$transactions = $collector->getJournals();
|
||||||
@@ -283,6 +285,7 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// grab all journals:
|
// grab all journals:
|
||||||
|
/** @var JournalCollectorInterface $collector */
|
||||||
$collector = app(JournalCollectorInterface::class);
|
$collector = app(JournalCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::DEPOSIT]);
|
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::DEPOSIT]);
|
||||||
$transactions = $collector->getJournals();
|
$transactions = $collector->getJournals();
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ class BillController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$results = $collector->setAllAssetAccounts()->setBills(new Collection([$bill]))->getJournals();
|
$results = $collector->setAllAssetAccounts()->setBills(new Collection([$bill]))->getJournals();
|
||||||
|
/** @var Collection $results */
|
||||||
$results = $results->sortBy(
|
$results = $results->sortBy(
|
||||||
function (Transaction $transaction) {
|
function (Transaction $transaction) {
|
||||||
return $transaction->date->format('U');
|
return $transaction->date->format('U');
|
||||||
|
|||||||
@@ -325,12 +325,12 @@ class BudgetController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Shows a budget list with spent/left/overspent.
|
* Shows a budget list with spent/left/overspent.
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return JsonResponse
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function frontpage(): \Symfony\Component\HttpFoundation\Response
|
public function frontpage(): JsonResponse
|
||||||
{
|
{
|
||||||
$start = session('start', Carbon::now()->startOfMonth());
|
$start = session('start', Carbon::now()->startOfMonth());
|
||||||
$end = session('end', Carbon::now()->endOfMonth());
|
$end = session('end', Carbon::now()->endOfMonth());
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ class Controller extends BaseController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user's language.
|
* Get user's language.
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getLanguage(): string
|
private function getLanguage(): string
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class ExportController extends Controller
|
|||||||
}
|
}
|
||||||
$content = $repository->getContent($job);
|
$content = $repository->getContent($job);
|
||||||
|
|
||||||
$job->change('export_downloaded');
|
$repository->changeStatus($job, 'export_downloaded');
|
||||||
/** @var LaravelResponse $response */
|
/** @var LaravelResponse $response */
|
||||||
$response = response($content, 200);
|
$response = response($content, 200);
|
||||||
$response
|
$response
|
||||||
|
|||||||
@@ -108,7 +108,9 @@ class HomeController extends Controller
|
|||||||
}
|
}
|
||||||
$subTitle = (string)trans('firefly.welcomeBack');
|
$subTitle = (string)trans('firefly.welcomeBack');
|
||||||
$transactions = [];
|
$transactions = [];
|
||||||
$frontPage = app('preferences')->get('frontPageAccounts', $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray());
|
$frontPage = app('preferences')->get(
|
||||||
|
'frontPageAccounts', $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray()
|
||||||
|
);
|
||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
$start = session('start', Carbon::now()->startOfMonth());
|
$start = session('start', Carbon::now()->startOfMonth());
|
||||||
/** @var Carbon $end */
|
/** @var Carbon $end */
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate popup view.
|
* Generate popup view.
|
||||||
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
|
|||||||
@@ -340,6 +340,7 @@ class ProfileController extends Controller
|
|||||||
|
|
||||||
session()->flash('success', (string)trans('firefly.saved_preferences'));
|
session()->flash('success', (string)trans('firefly.saved_preferences'));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
return redirect(route('profile.index'));
|
return redirect(route('profile.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,6 +372,7 @@ class ProfileController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Regenerate access token.
|
* Regenerate access token.
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function regenerate()
|
public function regenerate()
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ use FireflyIII\Http\Controllers\Controller;
|
|||||||
use FireflyIII\Http\Requests\RuleFormRequest;
|
use FireflyIII\Http\Requests\RuleFormRequest;
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Models\RuleGroup;
|
use FireflyIII\Models\RuleGroup;
|
||||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||||
use FireflyIII\Support\Http\Controllers\RuleManagement;
|
use FireflyIII\Support\Http\Controllers\RuleManagement;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
@@ -42,8 +41,6 @@ use Throwable;
|
|||||||
class CreateController extends Controller
|
class CreateController extends Controller
|
||||||
{
|
{
|
||||||
use RuleManagement;
|
use RuleManagement;
|
||||||
/** @var BillRepositoryInterface Bill repository */
|
|
||||||
private $billRepos;
|
|
||||||
/** @var RuleRepositoryInterface Rule repository */
|
/** @var RuleRepositoryInterface Rule repository */
|
||||||
private $ruleRepos;
|
private $ruleRepos;
|
||||||
|
|
||||||
@@ -59,7 +56,6 @@ class CreateController extends Controller
|
|||||||
app('view')->share('title', (string)trans('firefly.rules'));
|
app('view')->share('title', (string)trans('firefly.rules'));
|
||||||
app('view')->share('mainTitleIcon', 'fa-random');
|
app('view')->share('mainTitleIcon', 'fa-random');
|
||||||
|
|
||||||
$this->billRepos = app(BillRepositoryInterface::class);
|
|
||||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ use phpseclib\Crypt\RSA;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class InstallController
|
* Class InstallController
|
||||||
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
class InstallController extends Controller
|
class InstallController extends Controller
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ class LinkController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch link from A <> B to B <> A.
|
* Switch link from A <> B to B <> A.
|
||||||
|
*
|
||||||
* @param TransactionJournalLink $link
|
* @param TransactionJournalLink $link
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class TrustProxies extends Middleware
|
|||||||
{
|
{
|
||||||
$trustedProxies = (string)env('TRUSTED_PROXIES', null);
|
$trustedProxies = (string)env('TRUSTED_PROXIES', null);
|
||||||
$this->proxies = explode(',', $trustedProxies);
|
$this->proxies = explode(',', $trustedProxies);
|
||||||
if ($trustedProxies === '**') {
|
if ('**' === $trustedProxies) {
|
||||||
$this->proxies = '**';
|
$this->proxies = '**';
|
||||||
}
|
}
|
||||||
parent::__construct($config);
|
parent::__construct($config);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class AccountFormRequest extends Request
|
|||||||
|
|
||||||
// if the account type is "liabilities" there are actually four types of liability
|
// if the account type is "liabilities" there are actually four types of liability
|
||||||
// that could have been selected.
|
// that could have been selected.
|
||||||
if ($data['accountType'] === 'liabilities') {
|
if ('liabilities' === $data['accountType']) {
|
||||||
$data['accountType'] = null;
|
$data['accountType'] = null;
|
||||||
$data['account_type_id'] = $this->integer('liability_type_id');
|
$data['account_type_id'] = $this->integer('liability_type_id');
|
||||||
// also reverse the opening balance:
|
// also reverse the opening balance:
|
||||||
|
|||||||
@@ -61,9 +61,10 @@ class Request extends FormRequest
|
|||||||
public function float(string $field): ?float
|
public function float(string $field): ?float
|
||||||
{
|
{
|
||||||
$res = $this->get($field);
|
$res = $this->get($field);
|
||||||
if(null === $res) {
|
if (null === $res) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (float)$res;
|
return (float)$res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class RuleFormRequest extends Request
|
|||||||
'rule_triggers' => $this->getRuleTriggerData(),
|
'rule_triggers' => $this->getRuleTriggerData(),
|
||||||
'rule_actions' => $this->getRuleActionData(),
|
'rule_actions' => $this->getRuleActionData(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +111,7 @@ class RuleFormRequest extends Request
|
|||||||
private function getRuleActionData(): array
|
private function getRuleActionData(): array
|
||||||
{
|
{
|
||||||
$return = [];
|
$return = [];
|
||||||
$actionData= $this->get('rule_actions');
|
$actionData = $this->get('rule_actions');
|
||||||
if (\is_array($actionData)) {
|
if (\is_array($actionData)) {
|
||||||
foreach ($actionData as $action) {
|
foreach ($actionData as $action) {
|
||||||
$stopProcessing = $action['stop_processing'] ?? '0';
|
$stopProcessing = $action['stop_processing'] ?? '0';
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class OpposingAccountIbans implements MapperInterface
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get map of opposing accounts.
|
* Get map of opposing accounts.
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getMap(): array
|
public function getMap(): array
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Import\Prerequisites;
|
namespace FireflyIII\Import\Prerequisites;
|
||||||
|
|
||||||
use bunq\Exception\BunqException;
|
|
||||||
use bunq\Util\BunqEnumApiEnvironmentType;
|
use bunq\Util\BunqEnumApiEnvironmentType;
|
||||||
|
use Exception;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Services\Bunq\ApiContext;
|
use FireflyIII\Services\Bunq\ApiContext;
|
||||||
use FireflyIII\Services\IP\IPRetrievalInterface;
|
use FireflyIII\Services\IP\IPRetrievalInterface;
|
||||||
@@ -134,7 +134,7 @@ class BunqPrerequisites implements PrerequisitesInterface
|
|||||||
try {
|
try {
|
||||||
$json = $apiContext->toJson();
|
$json = $apiContext->toJson();
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
} catch (BunqException $e) {
|
} catch (Exception $e) {
|
||||||
$messages = new MessageBag();
|
$messages = new MessageBag();
|
||||||
$messages->add('bunq_error', $e->getMessage());
|
$messages->add('bunq_error', $e->getMessage());
|
||||||
|
|
||||||
|
|||||||
@@ -86,17 +86,18 @@ class YnabRoutine implements RoutineInterface
|
|||||||
if (\count($budgets) > 1) {
|
if (\count($budgets) > 1) {
|
||||||
$this->repository->setStage($this->importJob, 'select_budgets');
|
$this->repository->setStage($this->importJob, 'select_budgets');
|
||||||
$this->repository->setStatus($this->importJob, 'need_job_config');
|
$this->repository->setStatus($this->importJob, 'need_job_config');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\count($budgets) === 1) {
|
if (1 === \count($budgets)) {
|
||||||
$this->repository->setStatus($this->importJob, 'ready_to_run');
|
$this->repository->setStatus($this->importJob, 'ready_to_run');
|
||||||
$this->repository->setStage($this->importJob, 'get_accounts');
|
$this->repository->setStage($this->importJob, 'get_accounts');
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if('get_accounts' === $this->importJob->stage) {
|
if ('get_accounts' === $this->importJob->stage) {
|
||||||
$this->repository->setStatus($this->importJob, 'running');
|
$this->repository->setStatus($this->importJob, 'running');
|
||||||
|
|
||||||
/** @var GetAccountsHandler $handler */
|
/** @var GetAccountsHandler $handler */
|
||||||
@@ -106,9 +107,10 @@ class YnabRoutine implements RoutineInterface
|
|||||||
|
|
||||||
$this->repository->setStage($this->importJob, 'select_accounts');
|
$this->repository->setStage($this->importJob, 'select_accounts');
|
||||||
$this->repository->setStatus($this->importJob, 'need_job_config');
|
$this->repository->setStatus($this->importJob, 'need_job_config');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if('go-for-import' === $this->importJob->stage) {
|
if ('go-for-import' === $this->importJob->stage) {
|
||||||
$this->repository->setStatus($this->importJob, 'running');
|
$this->repository->setStatus($this->importJob, 'running');
|
||||||
$this->repository->setStage($this->importJob, 'do_import');
|
$this->repository->setStage($this->importJob, 'do_import');
|
||||||
/** @var ImportDataHandler $handler */
|
/** @var ImportDataHandler $handler */
|
||||||
@@ -117,26 +119,27 @@ class YnabRoutine implements RoutineInterface
|
|||||||
$handler->run();
|
$handler->run();
|
||||||
$this->repository->setStatus($this->importJob, 'provider_finished');
|
$this->repository->setStatus($this->importJob, 'provider_finished');
|
||||||
$this->repository->setStage($this->importJob, 'final');
|
$this->repository->setStage($this->importJob, 'final');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ('match_accounts' === $this->importJob->stage) {
|
// if ('match_accounts' === $this->importJob->stage) {
|
||||||
// // $this->repository->setStatus($this->importJob, 'running');
|
// // $this->repository->setStatus($this->importJob, 'running');
|
||||||
// /** @var StageGetBudgetsHandler $handler */
|
// /** @var StageGetBudgetsHandler $handler */
|
||||||
// $handler = app(StageGetBudgetsHandler::class);
|
// $handler = app(StageGetBudgetsHandler::class);
|
||||||
// $handler->setImportJob($this->importJob);
|
// $handler->setImportJob($this->importJob);
|
||||||
// $handler->run();
|
// $handler->run();
|
||||||
// $this->repository->setStage($this->importJob, 'get_transactions');
|
// $this->repository->setStage($this->importJob, 'get_transactions');
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if ('get_transactions' === $this->importJob->stage) {
|
// if ('get_transactions' === $this->importJob->stage) {
|
||||||
// // $this->repository->setStatus($this->importJob, 'running');
|
// // $this->repository->setStatus($this->importJob, 'running');
|
||||||
// /** @var StageGetBudgetsHandler $handler */
|
// /** @var StageGetBudgetsHandler $handler */
|
||||||
// $handler = app(StageGetBudgetsHandler::class);
|
// $handler = app(StageGetBudgetsHandler::class);
|
||||||
// $handler->setImportJob($this->importJob);
|
// $handler->setImportJob($this->importJob);
|
||||||
// $handler->run();
|
// $handler->run();
|
||||||
// $this->repository->setStage($this->importJob, 'get_transactions');
|
// $this->repository->setStage($this->importJob, 'get_transactions');
|
||||||
// }
|
// }
|
||||||
throw new FireflyException(sprintf('YNAB import routine cannot handle stage "%s"', $this->importJob->stage));
|
throw new FireflyException(sprintf('YNAB import routine cannot handle stage "%s"', $this->importJob->stage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ class CreateRecurringTransactions implements ShouldQueue
|
|||||||
function (Rule $rule) use ($journal) {
|
function (Rule $rule) use ($journal) {
|
||||||
Log::debug(sprintf('Going to apply rule #%d to journal %d.', $rule->id, $journal->id));
|
Log::debug(sprintf('Going to apply rule #%d to journal %d.', $rule->id, $journal->id));
|
||||||
$processor = Processor::make($rule);
|
$processor = Processor::make($rule);
|
||||||
|
/** @noinspection ExceptionsAnnotatingAndHandlingInspection */
|
||||||
$processor->handleTransactionJournal($journal);
|
$processor->handleTransactionJournal($journal);
|
||||||
if ($rule->stop_processing) {
|
if ($rule->stop_processing) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -110,9 +110,9 @@ class Bill extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
* @return MorphMany
|
||||||
*/
|
*/
|
||||||
public function attachments(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
public function attachments(): MorphMany
|
||||||
{
|
{
|
||||||
return $this->morphMany(Attachment::class, 'attachable');
|
return $this->morphMany(Attachment::class, 'attachable');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace FireflyIII\Models;
|
|||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,9 +92,9 @@ class ImportJob extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
* @return MorphMany
|
||||||
*/
|
*/
|
||||||
public function attachments(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
public function attachments(): MorphMany
|
||||||
{
|
{
|
||||||
return $this->morphMany(Attachment::class, 'attachable');
|
return $this->morphMany(Attachment::class, 'attachable');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,6 +237,7 @@ class Transaction extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for transactions BEFORE the specified date.
|
* Check for transactions BEFORE the specified date.
|
||||||
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*
|
*
|
||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
|
|||||||
@@ -150,9 +150,9 @@ class TransactionJournal extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
* @return MorphMany
|
||||||
*/
|
*/
|
||||||
public function attachments(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
public function attachments(): MorphMany
|
||||||
{
|
{
|
||||||
return $this->morphMany(Attachment::class, 'attachable');
|
return $this->morphMany(Attachment::class, 'attachable');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,9 +45,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||||||
*/
|
*/
|
||||||
class TransactionJournalLink extends Model
|
class TransactionJournalLink extends Model
|
||||||
{
|
{
|
||||||
/** @var string The table to store the data in */
|
|
||||||
protected $table = 'journal_links';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that should be casted to native types.
|
* The attributes that should be casted to native types.
|
||||||
*
|
*
|
||||||
@@ -58,6 +55,8 @@ class TransactionJournalLink extends Model
|
|||||||
'created_at' => 'datetime',
|
'created_at' => 'datetime',
|
||||||
'updated_at' => 'datetime',
|
'updated_at' => 'datetime',
|
||||||
];
|
];
|
||||||
|
/** @var string The table to store the data in */
|
||||||
|
protected $table = 'journal_links';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ use Illuminate\Support\Facades\Schema;
|
|||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Laravel\Passport\Passport;
|
use Laravel\Passport\Passport;
|
||||||
use URL;
|
use URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
* Class AppServiceProvider.
|
* Class AppServiceProvider.
|
||||||
@@ -38,7 +39,7 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
Schema::defaultStringLength(191);
|
Schema::defaultStringLength(191);
|
||||||
if('heroku' === env('APP_ENV')) {
|
if ('heroku' === env('APP_ENV')) {
|
||||||
URL::forceScheme('https');
|
URL::forceScheme('https');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
if (null === $note) {
|
if (null === $note) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $note->text;
|
return $note->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,6 +451,9 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return Account
|
* @return Account
|
||||||
|
* @throws \FireflyIII\Exceptions\FireflyException
|
||||||
|
* @throws FireflyException
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function update(Account $account, array $data): Account
|
public function update(Account $account, array $data): Account
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ interface AttachmentRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $attachmentId
|
* @param int $attachmentId
|
||||||
|
*
|
||||||
* @return Attachment|null
|
* @return Attachment|null
|
||||||
*/
|
*/
|
||||||
public function findWithoutUser(int $attachmentId): ?Attachment;
|
public function findWithoutUser(int $attachmentId): ?Attachment;
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
|||||||
public function changeStatus(ExportJob $job, string $status): bool
|
public function changeStatus(ExportJob $job, string $status): bool
|
||||||
{
|
{
|
||||||
Log::debug(sprintf('Change status of job #%d to "%s"', $job->id, $status));
|
Log::debug(sprintf('Change status of job #%d to "%s"', $job->id, $status));
|
||||||
$job->change($status);
|
$job->status = $status;
|
||||||
|
$job->save();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ interface ExportJobRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $key
|
* @param string $key
|
||||||
|
*
|
||||||
* @return ExportJob|null
|
* @return ExportJob|null
|
||||||
*/
|
*/
|
||||||
public function findByKey(string $key): ?ExportJob;
|
public function findByKey(string $key): ?ExportJob;
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
|||||||
$newConfig = array_merge($currentConfig, $configuration);
|
$newConfig = array_merge($currentConfig, $configuration);
|
||||||
$job->configuration = $newConfig;
|
$job->configuration = $newConfig;
|
||||||
$job->save();
|
$job->save();
|
||||||
|
|
||||||
//Log::debug(sprintf('Set config of job "%s" to: ', $job->key), $newConfig);
|
//Log::debug(sprintf('Set config of job "%s" to: ', $job->key), $newConfig);
|
||||||
|
|
||||||
return $job;
|
return $job;
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ interface ImportJobRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $key
|
* @param string $key
|
||||||
|
*
|
||||||
* @return ImportJob|null
|
* @return ImportJob|null
|
||||||
*/
|
*/
|
||||||
public function findByKey(string $key): ?ImportJob;
|
public function findByKey(string $key): ?ImportJob;
|
||||||
|
|||||||
@@ -707,6 +707,8 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return TransactionJournal
|
* @return TransactionJournal
|
||||||
*
|
*
|
||||||
|
* @throws FireflyException
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function update(TransactionJournal $journal, array $data): TransactionJournal
|
public function update(TransactionJournal $journal, array $data): TransactionJournal
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ namespace FireflyIII\Repositories\Journal;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
|
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\TransactionJournalMeta;
|
use FireflyIII\Models\TransactionJournalMeta;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ interface TagRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Tag|null
|
* @return Tag|null
|
||||||
*/
|
*/
|
||||||
public function findByTag(string $tag):?Tag;
|
public function findByTag(string $tag): ?Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $tagId
|
* @param int $tagId
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class UpdateRequest implements GithubRequest
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$releaseXml = new SimpleXMLElement($res->getBody()->getContents(), LIBXML_NOCDATA);
|
$releaseXml = new SimpleXMLElement($res->getBody()->getContents(), LIBXML_NOCDATA);
|
||||||
} catch (RunTimeException $e) {
|
} catch (RuntimeException $e) {
|
||||||
Log::error(sprintf('Could not get body from github updat result: %s', $e->getMessage()));
|
Log::error(sprintf('Could not get body from github updat result: %s', $e->getMessage()));
|
||||||
$releaseXml = new SimpleXMLElement('');
|
$releaseXml = new SimpleXMLElement('');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use Exception;
|
|||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use Log;
|
use Log;
|
||||||
use RunTimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class IpifyOrg
|
* Class IpifyOrg
|
||||||
@@ -58,7 +58,7 @@ class IpifyOrg implements IPRetrievalInterface
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$body = (string)$res->getBody()->getContents();
|
$body = (string)$res->getBody()->getContents();
|
||||||
} catch (RunTimeException $e) {
|
} catch (RuntimeException $e) {
|
||||||
Log::error(sprintf('Could not get body from ipify.org result: %s', $e->getMessage()));
|
Log::error(sprintf('Could not get body from ipify.org result: %s', $e->getMessage()));
|
||||||
$body = null;
|
$body = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ trait AccountServiceTrait
|
|||||||
/** @var array */
|
/** @var array */
|
||||||
public $validCCFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType', 'accountNumber', 'currency_id', 'BIC'];
|
public $validCCFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType', 'accountNumber', 'currency_id', 'BIC'];
|
||||||
/** @var array */
|
/** @var array */
|
||||||
public $validFields = ['accountNumber', 'currency_id', 'BIC','interest','interest_period'];
|
public $validFields = ['accountNumber', 'currency_id', 'BIC', 'interest', 'interest_period'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Services\Internal\Support;
|
namespace FireflyIII\Services\Internal\Support;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Factory\TransactionTypeFactory;
|
use FireflyIII\Factory\TransactionTypeFactory;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class BillUpdateService
|
|||||||
$bill->repeat_freq = $data['repeat_freq'];
|
$bill->repeat_freq = $data['repeat_freq'];
|
||||||
$bill->skip = $data['skip'];
|
$bill->skip = $data['skip'];
|
||||||
$bill->automatch = true;
|
$bill->automatch = true;
|
||||||
$bill->active = $data['active']??true;
|
$bill->active = $data['active'] ?? true;
|
||||||
$bill->save();
|
$bill->save();
|
||||||
|
|
||||||
// update note:
|
// update note:
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ namespace FireflyIII\Services\Internal\Update;
|
|||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\Recurrence;
|
use FireflyIII\Models\Recurrence;
|
||||||
|
|
||||||
use FireflyIII\Services\Internal\Support\RecurringTransactionTrait;
|
use FireflyIII\Services\Internal\Support\RecurringTransactionTrait;
|
||||||
use FireflyIII\Services\Internal\Support\TransactionServiceTrait;
|
use FireflyIII\Services\Internal\Support\TransactionServiceTrait;
|
||||||
use FireflyIII\Services\Internal\Support\TransactionTypeTrait;
|
use FireflyIII\Services\Internal\Support\TransactionTypeTrait;
|
||||||
@@ -65,7 +64,7 @@ class RecurrenceUpdateService
|
|||||||
$recurrence->apply_rules = $data['recurrence']['apply_rules'] ?? $recurrence->apply_rules;
|
$recurrence->apply_rules = $data['recurrence']['apply_rules'] ?? $recurrence->apply_rules;
|
||||||
$recurrence->active = $data['recurrence']['active'] ?? $recurrence->active;
|
$recurrence->active = $data['recurrence']['active'] ?? $recurrence->active;
|
||||||
|
|
||||||
if(isset($data['recurrence']['repetition_end'])) {
|
if (isset($data['recurrence']['repetition_end'])) {
|
||||||
if (\in_array($data['recurrence']['repetition_end'], ['forever ', 'until_date'])) {
|
if (\in_array($data['recurrence']['repetition_end'], ['forever ', 'until_date'])) {
|
||||||
$recurrence->repetitions = 0;
|
$recurrence->repetitions = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class PwndVerifierV2 implements Verifier
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$strpos = stripos($res->getBody()->getContents(), $rest);
|
$strpos = stripos($res->getBody()->getContents(), $rest);
|
||||||
} catch (RunTimeException $e) {
|
} catch (RuntimeException $e) {
|
||||||
Log::error(sprintf('Could not get body from Pwnd result: %s', $e->getMessage()));
|
Log::error(sprintf('Could not get body from Pwnd result: %s', $e->getMessage()));
|
||||||
$strpos = false;
|
$strpos = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ use Carbon\Carbon;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Class Attempt
|
* Class Attempt
|
||||||
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
* @SuppressWarnings(PHPMD.ShortVariable)
|
* @SuppressWarnings(PHPMD.ShortVariable)
|
||||||
* @SuppressWarnings(PHPMD.TooManyFields)
|
* @SuppressWarnings(PHPMD.TooManyFields)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ use Carbon\Carbon;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Login
|
* Class Login
|
||||||
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
* @SuppressWarnings(PHPMD.ShortVariable)
|
* @SuppressWarnings(PHPMD.ShortVariable)
|
||||||
* @SuppressWarnings(PHPMD.TooManyFields)
|
* @SuppressWarnings(PHPMD.TooManyFields)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ use Carbon\Carbon;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Transaction
|
* Class Transaction
|
||||||
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.ShortVariable)
|
* @SuppressWarnings(PHPMD.ShortVariable)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace FireflyIII\Services\Spectre\Request;
|
|||||||
|
|
||||||
use FireflyIII\Services\Spectre\Object\Customer;
|
use FireflyIII\Services\Spectre\Object\Customer;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class NewCustomerRequest
|
* Class NewCustomerRequest
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ abstract class SpectreRequest
|
|||||||
$statusCode = $res->getStatusCode();
|
$statusCode = $res->getStatusCode();
|
||||||
try {
|
try {
|
||||||
$returnBody = $res->getBody()->getContents();
|
$returnBody = $res->getBody()->getContents();
|
||||||
} catch (RunTimeException $e) {
|
} catch (RuntimeException $e) {
|
||||||
Log::error(sprintf('Could not get body from SpectreRequest::GET result: %s', $e->getMessage()));
|
Log::error(sprintf('Could not get body from SpectreRequest::GET result: %s', $e->getMessage()));
|
||||||
$returnBody = '';
|
$returnBody = '';
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ abstract class SpectreRequest
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$body = $res->getBody()->getContents();
|
$body = $res->getBody()->getContents();
|
||||||
} catch (RunTimeException $e) {
|
} catch (RuntimeException $e) {
|
||||||
Log::error(sprintf('Could not get body from SpectreRequest::POST result: %s', $e->getMessage()));
|
Log::error(sprintf('Could not get body from SpectreRequest::POST result: %s', $e->getMessage()));
|
||||||
$body = '';
|
$body = '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class Amount
|
|||||||
$space = ' ';
|
$space = ' ';
|
||||||
|
|
||||||
// require space between symbol and amount?
|
// require space between symbol and amount?
|
||||||
if ($sepBySpace === false) {
|
if (false === $sepBySpace) {
|
||||||
$space = ''; // no
|
$space = ''; // no
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,8 +134,8 @@ class Amount
|
|||||||
// some complicated switches to format the amount correctly:
|
// some complicated switches to format the amount correctly:
|
||||||
$precedes = $amount < 0 ? $info['n_cs_precedes'] : $info['p_cs_precedes'];
|
$precedes = $amount < 0 ? $info['n_cs_precedes'] : $info['p_cs_precedes'];
|
||||||
$separated = $amount < 0 ? $info['n_sep_by_space'] : $info['p_sep_by_space'];
|
$separated = $amount < 0 ? $info['n_sep_by_space'] : $info['p_sep_by_space'];
|
||||||
$space = $separated === true ? ' ' : '';
|
$space = true === $separated ? ' ' : '';
|
||||||
$result = $precedes === false ? $formatted . $space . $format->symbol : $format->symbol . $space . $formatted;
|
$result = false === $precedes ? $formatted . $space . $format->symbol : $format->symbol . $space . $formatted;
|
||||||
|
|
||||||
if (true === $coloured) {
|
if (true === $coloured) {
|
||||||
if ($amount > 0) {
|
if ($amount > 0) {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class SelectBudgetHandler implements YnabJobConfigurationInterface
|
|||||||
Log::debug('Now in SelectBudgetHandler::configComplete');
|
Log::debug('Now in SelectBudgetHandler::configComplete');
|
||||||
$configuration = $this->repository->getConfiguration($this->importJob);
|
$configuration = $this->repository->getConfiguration($this->importJob);
|
||||||
$selectedBudget = $configuration['selected_budget'] ?? '';
|
$selectedBudget = $configuration['selected_budget'] ?? '';
|
||||||
if ($selectedBudget !== '') {
|
if ('' !== $selectedBudget) {
|
||||||
Log::debug(sprintf('Selected budget is %s, config is complete. Return true.', $selectedBudget));
|
Log::debug(sprintf('Selected budget is %s, config is complete. Return true.', $selectedBudget));
|
||||||
$this->repository->setStage($this->importJob, 'get_accounts');
|
$this->repository->setStage($this->importJob, 'get_accounts');
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\JobConfiguration\Ynab;
|
namespace FireflyIII\Support\Import\JobConfiguration\Ynab;
|
||||||
|
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ class ImportableConverter
|
|||||||
Log::error($e->getTraceAsString());
|
Log::error($e->getTraceAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ class ImportDataHandler
|
|||||||
$destination = $this->mapper->map($possibleDestinationId, $amount, $destinationData);
|
$destination = $this->mapper->map($possibleDestinationId, $amount, $destinationData);
|
||||||
if (1 === bccomp($amount, '0')) {
|
if (1 === bccomp($amount, '0')) {
|
||||||
[$source, $destination] = [$destination, $source];
|
[$source, $destination] = [$destination, $source];
|
||||||
$type = $type === 'transfer' ? 'transfer' : 'deposit';
|
$type = 'transfer' === $type ? 'transfer' : 'deposit';
|
||||||
Log::debug(sprintf('Amount is %s, so switch source/dest and make this a %s', $amount, $type));
|
Log::debug(sprintf('Amount is %s, so switch source/dest and make this a %s', $amount, $type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class StageGetAccessHandler
|
|||||||
$statusCode = $res->getStatusCode();
|
$statusCode = $res->getStatusCode();
|
||||||
try {
|
try {
|
||||||
$content = trim($res->getBody()->getContents());
|
$content = trim($res->getBody()->getContents());
|
||||||
} catch(RuntimeException $e) {
|
} catch (RuntimeException $e) {
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
Log::error($e->getTraceAsString());
|
Log::error($e->getTraceAsString());
|
||||||
throw new FireflyException($e->getMessage());
|
throw new FireflyException($e->getMessage());
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class StageGetBudgetsHandler
|
|||||||
$configuration['budgets'] = $request->budgets;
|
$configuration['budgets'] = $request->budgets;
|
||||||
$this->repository->setConfiguration($this->importJob, $configuration);
|
$this->repository->setConfiguration($this->importJob, $configuration);
|
||||||
Log::debug(sprintf('Found %d budgets', \count($request->budgets)));
|
Log::debug(sprintf('Found %d budgets', \count($request->budgets)));
|
||||||
if (\count($request->budgets) === 0) {
|
if (0 === \count($request->budgets)) {
|
||||||
throw new FireflyException('It seems this user has zero budgets or an error prevented Firefly III from reading them.');
|
throw new FireflyException('It seems this user has zero budgets or an error prevented Firefly III from reading them.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,6 +171,7 @@ class Preferences
|
|||||||
if (\is_array($lastActivity)) {
|
if (\is_array($lastActivity)) {
|
||||||
$lastActivity = implode(',', $lastActivity);
|
$lastActivity = implode(',', $lastActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return md5($lastActivity);
|
return md5($lastActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class General extends Twig_Extension
|
|||||||
$this->balance(),
|
$this->balance(),
|
||||||
$this->formatFilesize(),
|
$this->formatFilesize(),
|
||||||
$this->mimeIcon(),
|
$this->mimeIcon(),
|
||||||
$this->markdown()
|
$this->markdown(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,6 +249,7 @@ class General extends Twig_Extension
|
|||||||
if ($repository->hasRole(auth()->user(), $role)) {
|
if ($repository->hasRole(auth()->user(), $role)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ class Translation extends Twig_Extension
|
|||||||
'journalLinkTranslation',
|
'journalLinkTranslation',
|
||||||
function (string $direction, string $original) {
|
function (string $direction, string $original) {
|
||||||
$key = sprintf('firefly.%s_%s', $original, $direction);
|
$key = sprintf('firefly.%s_%s', $original, $direction);
|
||||||
return $key;
|
|
||||||
$translation = trans($key);
|
$translation = trans($key);
|
||||||
|
|
||||||
if ($key === $translation) {
|
if ($key === $translation) {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ final class Processor
|
|||||||
Log::debug(sprintf('Push trigger %d', $trigger->id));
|
Log::debug(sprintf('Push trigger %d', $trigger->id));
|
||||||
$self->triggers->push(TriggerFactory::getTrigger($trigger));
|
$self->triggers->push(TriggerFactory::getTrigger($trigger));
|
||||||
}
|
}
|
||||||
if ($includeActions === true) {
|
if (true === $includeActions) {
|
||||||
$self->actions = $rule->ruleActions()->orderBy('order', 'ASC')->get();
|
$self->actions = $rule->ruleActions()->orderBy('order', 'ASC')->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -195,15 +195,15 @@ class TransactionMatcher
|
|||||||
$allTriggers = $this->rule->ruleTriggers()->whereIn('trigger_type', $valid)->get();
|
$allTriggers = $this->rule->ruleTriggers()->whereIn('trigger_type', $valid)->get();
|
||||||
/** @var RuleTrigger $trigger */
|
/** @var RuleTrigger $trigger */
|
||||||
foreach ($allTriggers as $trigger) {
|
foreach ($allTriggers as $trigger) {
|
||||||
if ($trigger->trigger_type === 'amount_less') {
|
if ('amount_less' === $trigger->trigger_type) {
|
||||||
$this->maxAmount = $trigger->trigger_value;
|
$this->maxAmount = $trigger->trigger_value;
|
||||||
Log::debug(sprintf('Set max amount to be %s', $trigger->trigger_value));
|
Log::debug(sprintf('Set max amount to be %s', $trigger->trigger_value));
|
||||||
}
|
}
|
||||||
if ($trigger->trigger_type === 'amount_more') {
|
if ('amount_more' === $trigger->trigger_type) {
|
||||||
$this->minAmount = $trigger->trigger_value;
|
$this->minAmount = $trigger->trigger_value;
|
||||||
Log::debug(sprintf('Set min amount to be %s', $trigger->trigger_value));
|
Log::debug(sprintf('Set min amount to be %s', $trigger->trigger_value));
|
||||||
}
|
}
|
||||||
if ($trigger->trigger_type === 'amount_exactly') {
|
if ('amount_exactly' === $trigger->trigger_type) {
|
||||||
$this->exactAmount = $trigger->trigger_value;
|
$this->exactAmount = $trigger->trigger_value;
|
||||||
Log::debug(sprintf('Set exact amount to be %s', $trigger->trigger_value));
|
Log::debug(sprintf('Set exact amount to be %s', $trigger->trigger_value));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
|
|
||||||
$type = $account->accountType->type;
|
$type = $account->accountType->type;
|
||||||
$role = $this->repository->getMetaValue($account, 'accountRole');
|
$role = $this->repository->getMetaValue($account, 'accountRole');
|
||||||
if ($type !== AccountType::ASSET || (string)$role === '') {
|
if ($type !== AccountType::ASSET || '' === (string)$role) {
|
||||||
$role = null;
|
$role = null;
|
||||||
}
|
}
|
||||||
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
|
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
|
||||||
@@ -167,13 +167,13 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
$date = $this->parameters->get('date');
|
$date = $this->parameters->get('date');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($currencyId === 0) {
|
if (0 === $currencyId) {
|
||||||
$currencyId = null;
|
$currencyId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$monthlyPaymentDate = null;
|
$monthlyPaymentDate = null;
|
||||||
$creditCardType = null;
|
$creditCardType = null;
|
||||||
if ($role === 'ccAsset' && $type === AccountType::ASSET) {
|
if ('ccAsset' === $role && $type === AccountType::ASSET) {
|
||||||
$creditCardType = $this->repository->getMetaValue($account, 'ccType');
|
$creditCardType = $this->repository->getMetaValue($account, 'ccType');
|
||||||
$monthlyPaymentDate = $this->repository->getMetaValue($account, 'ccMonthlyPaymentDate');
|
$monthlyPaymentDate = $this->repository->getMetaValue($account, 'ccMonthlyPaymentDate');
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,7 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
'updated_at' => $account->updated_at->toAtomString(),
|
'updated_at' => $account->updated_at->toAtomString(),
|
||||||
'created_at' => $account->created_at->toAtomString(),
|
'created_at' => $account->created_at->toAtomString(),
|
||||||
'name' => $account->name,
|
'name' => $account->name,
|
||||||
'active' => (int)$account->active === 1,
|
'active' => 1 === (int)$account->active,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'currency_id' => $currencyId,
|
'currency_id' => $currencyId,
|
||||||
'currency_code' => $currencyCode,
|
'currency_code' => $currencyCode,
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class BudgetTransformer extends TransformerAbstract
|
|||||||
'id' => (int)$budget->id,
|
'id' => (int)$budget->id,
|
||||||
'updated_at' => $budget->updated_at->toAtomString(),
|
'updated_at' => $budget->updated_at->toAtomString(),
|
||||||
'created_at' => $budget->created_at->toAtomString(),
|
'created_at' => $budget->created_at->toAtomString(),
|
||||||
'active' => (int)$budget->active === 1,
|
'active' => 1 === (int)$budget->active,
|
||||||
'name' => $budget->name,
|
'name' => $budget->name,
|
||||||
'links' => [
|
'links' => [
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ use League\Fractal\Resource\Item;
|
|||||||
use League\Fractal\TransformerAbstract;
|
use League\Fractal\TransformerAbstract;
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CurrencyExchangeRateTransformer
|
||||||
|
*/
|
||||||
class CurrencyExchangeRateTransformer extends TransformerAbstract
|
class CurrencyExchangeRateTransformer extends TransformerAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -79,6 +82,11 @@ class CurrencyExchangeRateTransformer extends TransformerAbstract
|
|||||||
return $this->item($rate->toCurrency, new CurrencyTransformer($this->parameters), 'transaction_currencies');
|
return $this->item($rate->toCurrency, new CurrencyTransformer($this->parameters), 'transaction_currencies');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param CurrencyExchangeRate $rate
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function transform(CurrencyExchangeRate $rate): array
|
public function transform(CurrencyExchangeRate $rate): array
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ class PiggyBankEventTransformer extends TransformerAbstract
|
|||||||
$pageSize = (int)app('preferences')->getForUser($journal->user, 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser($journal->user, 'listPageSize', 50)->data;
|
||||||
|
|
||||||
// journals always use collector and limited using URL parameters.
|
// journals always use collector and limited using URL parameters.
|
||||||
|
/** @var JournalCollectorInterface $collector */
|
||||||
$collector = app(JournalCollectorInterface::class);
|
$collector = app(JournalCollectorInterface::class);
|
||||||
$collector->setUser($journal->user);
|
$collector->setUser($journal->user);
|
||||||
$collector->withOpposingAccount()->withCategoryInformation()->withCategoryInformation();
|
$collector->withOpposingAccount()->withCategoryInformation()->withCategoryInformation();
|
||||||
@@ -130,6 +131,7 @@ class PiggyBankEventTransformer extends TransformerAbstract
|
|||||||
$repository = app(CurrencyRepositoryInterface::class);
|
$repository = app(CurrencyRepositoryInterface::class);
|
||||||
$repository->setUser($account->user);
|
$repository->setUser($account->user);
|
||||||
$currency = $repository->findNull($currencyId);
|
$currency = $repository->findNull($currencyId);
|
||||||
|
/** @noinspection NullPointerExceptionInspection */
|
||||||
$decimalPlaces = $currency->decimal_places;
|
$decimalPlaces = $currency->decimal_places;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ class PiggyBankTransformer extends TransformerAbstract
|
|||||||
'start_date' => $startDate,
|
'start_date' => $startDate,
|
||||||
'target_date' => $targetDate,
|
'target_date' => $targetDate,
|
||||||
'order' => (int)$piggyBank->order,
|
'order' => (int)$piggyBank->order,
|
||||||
'active' => (int)$piggyBank->active === 1,
|
'active' => 1 === (int)$piggyBank->active,
|
||||||
'notes' => null,
|
'notes' => null,
|
||||||
'links' => [
|
'links' => [
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ use FireflyIII\Models\Preference;
|
|||||||
use League\Fractal\TransformerAbstract;
|
use League\Fractal\TransformerAbstract;
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PreferenceTransformer
|
||||||
|
*/
|
||||||
class PreferenceTransformer extends TransformerAbstract
|
class PreferenceTransformer extends TransformerAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -45,6 +48,11 @@ class PreferenceTransformer extends TransformerAbstract
|
|||||||
/** @var ParameterBag */
|
/** @var ParameterBag */
|
||||||
protected $parameters;
|
protected $parameters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PreferenceTransformer constructor.
|
||||||
|
*
|
||||||
|
* @param ParameterBag $parameters
|
||||||
|
*/
|
||||||
public function __construct(ParameterBag $parameters)
|
public function __construct(ParameterBag $parameters)
|
||||||
{
|
{
|
||||||
$this->parameters = $parameters;
|
$this->parameters = $parameters;
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class TagTransformer extends TransformerAbstract
|
|||||||
'tag' => $tag->tag,
|
'tag' => $tag->tag,
|
||||||
'tag_mode' => $tag->tagMode,
|
'tag_mode' => $tag->tagMode,
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
'description' => $tag->description === '' ? null : $tag->description,
|
'description' => '' === $tag->description ? null : $tag->description,
|
||||||
'latitude' => (float)$tag->latitude,
|
'latitude' => (float)$tag->latitude,
|
||||||
'longitude' => (float)$tag->longitude,
|
'longitude' => (float)$tag->longitude,
|
||||||
'zoom_level' => (int)$tag->zoomLevel,
|
'zoom_level' => (int)$tag->zoomLevel,
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class UserTransformer extends TransformerAbstract
|
|||||||
'updated_at' => $user->updated_at->toAtomString(),
|
'updated_at' => $user->updated_at->toAtomString(),
|
||||||
'created_at' => $user->created_at->toAtomString(),
|
'created_at' => $user->created_at->toAtomString(),
|
||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
'blocked' => (int)$user->blocked === 1,
|
'blocked' => 1 === (int)$user->blocked,
|
||||||
'blocked_code' => $user->blocked_code,
|
'blocked_code' => $user->blocked_code,
|
||||||
'role' => $role,
|
'role' => $role,
|
||||||
'links' => [
|
'links' => [
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ class User extends Authenticatable
|
|||||||
{
|
{
|
||||||
$bytes = random_bytes(16);
|
$bytes = random_bytes(16);
|
||||||
|
|
||||||
return (string)bin2hex($bytes);
|
return bin2hex($bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -243,7 +243,9 @@ class FireflyValidator extends Validator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $attribute
|
* @param string $attribute
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@@ -338,7 +340,7 @@ class FireflyValidator extends Validator
|
|||||||
$classes = app('config')->get('firefly.rule-triggers');
|
$classes = app('config')->get('firefly.rule-triggers');
|
||||||
/** @var TriggerInterface $class */
|
/** @var TriggerInterface $class */
|
||||||
$class = $classes[$triggerType] ?? false;
|
$class = $classes[$triggerType] ?? false;
|
||||||
if(false === $class) {
|
if (false === $class) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,7 +414,7 @@ class FireflyValidator extends Validator
|
|||||||
public function validateUniqueAccountNumberForUser($attribute, $value, $parameters): bool
|
public function validateUniqueAccountNumberForUser($attribute, $value, $parameters): bool
|
||||||
{
|
{
|
||||||
$accountId = (int)($this->data['id'] ?? 0.0);
|
$accountId = (int)($this->data['id'] ?? 0.0);
|
||||||
if ($accountId === 0) {
|
if (0 === $accountId) {
|
||||||
$accountId = (int)($parameters[0] ?? 0.0);
|
$accountId = (int)($parameters[0] ?? 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,7 +423,7 @@ class FireflyValidator extends Validator
|
|||||||
->where('accounts.user_id', auth()->user()->id)
|
->where('accounts.user_id', auth()->user()->id)
|
||||||
->where('account_meta.name', 'accountNumber');
|
->where('account_meta.name', 'accountNumber');
|
||||||
|
|
||||||
if ((int)$accountId > 0) {
|
if ($accountId > 0) {
|
||||||
// exclude current account from check.
|
// exclude current account from check.
|
||||||
$query->where('account_meta.account_id', '!=', $accountId);
|
$query->where('account_meta.account_id', '!=', $accountId);
|
||||||
}
|
}
|
||||||
@@ -513,66 +515,6 @@ class FireflyValidator extends Validator
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $index
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getRuleActionName(int $index): string
|
|
||||||
{
|
|
||||||
$name = $this->data['rule-action'][$index] ?? 'invalid';
|
|
||||||
if (!isset($this->data['rule-action'][$index])) {
|
|
||||||
$name = $this->data['rule-actions'][$index]['name'] ?? 'invalid';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $index
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getRuleActionValue(int $index): string
|
|
||||||
{
|
|
||||||
$value = $this->data['rule-action-value'][$index] ?? '';
|
|
||||||
if (!isset($this->data['rule-action-value'][$index])) {
|
|
||||||
$value = $this->data['rule-actions'][$index]['value'] ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $index
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getRuleTriggerName(int $index): string
|
|
||||||
{
|
|
||||||
$name = $this->data['rule-trigger'][$index] ?? 'invalid';
|
|
||||||
if (!isset($this->data['rule-trigger'][$index])) {
|
|
||||||
$name = $this->data['rule-triggers'][$index]['name'] ?? 'invalid';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $index
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getRuleTriggerValue(int $index): string
|
|
||||||
{
|
|
||||||
$value = $this->data['rule-trigger-value'][$index] ?? '';
|
|
||||||
if (!isset($this->data['rule-trigger-value'][$index])) {
|
|
||||||
$value = $this->data['rule-triggers'][$index]['value'] ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $value
|
* @param $value
|
||||||
*
|
*
|
||||||
@@ -627,6 +569,7 @@ class FireflyValidator extends Validator
|
|||||||
$ignore = $existingAccount->id;
|
$ignore = $existingAccount->id;
|
||||||
$value = $this->tryDecrypt($value);
|
$value = $this->tryDecrypt($value);
|
||||||
|
|
||||||
|
/** @var Collection $set */
|
||||||
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
|
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
|
||||||
/** @var Account $entry */
|
/** @var Account $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
@@ -650,6 +593,7 @@ class FireflyValidator extends Validator
|
|||||||
$ignore = (int)($parameters[0] ?? 0.0);
|
$ignore = (int)($parameters[0] ?? 0.0);
|
||||||
$value = $this->tryDecrypt($value);
|
$value = $this->tryDecrypt($value);
|
||||||
|
|
||||||
|
/** @var Collection $set */
|
||||||
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
|
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
|
||||||
/** @var Account $entry */
|
/** @var Account $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
|
|||||||
@@ -37,6 +37,39 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
trait RecurrenceValidation
|
trait RecurrenceValidation
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Adds an error to the validator when there are no repetitions in the array of data.
|
||||||
|
*
|
||||||
|
* @param Validator $validator
|
||||||
|
*/
|
||||||
|
public function validateOneRepetition(Validator $validator): void
|
||||||
|
{
|
||||||
|
$data = $validator->getData();
|
||||||
|
$repetitions = $data['repetitions'] ?? [];
|
||||||
|
// need at least one transaction
|
||||||
|
if (0 === \count($repetitions)) {
|
||||||
|
$validator->errors()->add('description', (string)trans('validation.at_least_one_repetition'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates that the recurrence has valid repetition information. It either doesn't stop,
|
||||||
|
* or stops after X times or at X date. Not both of them.,
|
||||||
|
*
|
||||||
|
* @param Validator $validator
|
||||||
|
*/
|
||||||
|
public function validateRecurrenceRepetition(Validator $validator): void
|
||||||
|
{
|
||||||
|
$data = $validator->getData();
|
||||||
|
$repetitions = $data['nr_of_repetitions'] ?? null;
|
||||||
|
$repeatUntil = $data['repeat_until'] ?? null;
|
||||||
|
if (null !== $repetitions && null !== $repeatUntil) {
|
||||||
|
// expect a date OR count:
|
||||||
|
$validator->errors()->add('repeat_until', (string)trans('validation.require_repeat_until'));
|
||||||
|
$validator->errors()->add('nr_of_repetitions', (string)trans('validation.require_repeat_until'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Validator $validator
|
* @param Validator $validator
|
||||||
*/
|
*/
|
||||||
@@ -73,39 +106,6 @@ trait RecurrenceValidation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds an error to the validator when there are no repetitions in the array of data.
|
|
||||||
*
|
|
||||||
* @param Validator $validator
|
|
||||||
*/
|
|
||||||
public function validateOneRepetition(Validator $validator): void
|
|
||||||
{
|
|
||||||
$data = $validator->getData();
|
|
||||||
$repetitions = $data['repetitions'] ?? [];
|
|
||||||
// need at least one transaction
|
|
||||||
if (\count($repetitions) === 0) {
|
|
||||||
$validator->errors()->add('description', (string)trans('validation.at_least_one_repetition'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates that the recurrence has valid repetition information. It either doesn't stop,
|
|
||||||
* or stops after X times or at X date. Not both of them.,
|
|
||||||
*
|
|
||||||
* @param Validator $validator
|
|
||||||
*/
|
|
||||||
public function validateRecurrenceRepetition(Validator $validator): void
|
|
||||||
{
|
|
||||||
$data = $validator->getData();
|
|
||||||
$repetitions = $data['nr_of_repetitions'] ?? null;
|
|
||||||
$repeatUntil = $data['repeat_until'] ?? null;
|
|
||||||
if (null !== $repetitions && null !== $repeatUntil) {
|
|
||||||
// expect a date OR count:
|
|
||||||
$validator->errors()->add('repeat_until', (string)trans('validation.require_repeat_until'));
|
|
||||||
$validator->errors()->add('nr_of_repetitions', (string)trans('validation.require_repeat_until'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the repetition type is daily, the moment should be empty.
|
* If the repetition type is daily, the moment should be empty.
|
||||||
*
|
*
|
||||||
@@ -145,7 +145,7 @@ trait RecurrenceValidation
|
|||||||
protected function validateNdom(Validator $validator, int $index, string $moment): void
|
protected function validateNdom(Validator $validator, int $index, string $moment): void
|
||||||
{
|
{
|
||||||
$parameters = explode(',', $moment);
|
$parameters = explode(',', $moment);
|
||||||
if (\count($parameters) !== 2) {
|
if (2 !== \count($parameters)) {
|
||||||
$validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
|
$validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -338,13 +338,13 @@ trait TransactionValidation
|
|||||||
if ($accountId < 1 && '' === $accountName) {
|
if ($accountId < 1 && '' === $accountName) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ($accountId !== 0) {
|
if (0 !== $accountId) {
|
||||||
// ID belongs to user and is $type account:
|
// ID belongs to user and is $type account:
|
||||||
/** @var AccountRepositoryInterface $repository */
|
/** @var AccountRepositoryInterface $repository */
|
||||||
$repository = app(AccountRepositoryInterface::class);
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
$repository->setUser($admin);
|
$repository->setUser($admin);
|
||||||
$set = $repository->getAccountsById([$accountId]);
|
$set = $repository->getAccountsById([$accountId]);
|
||||||
if ($set->count() === 1) {
|
if (1 === $set->count()) {
|
||||||
/** @var Account $first */
|
/** @var Account $first */
|
||||||
$first = $set->first();
|
$first = $set->first();
|
||||||
if ($first->accountType->type !== $type) {
|
if ($first->accountType->type !== $type) {
|
||||||
|
|||||||
@@ -806,7 +806,6 @@ Route::group(
|
|||||||
Route::post('update/{rule}', ['uses' => 'Rule\EditController@update', 'as' => 'update']);
|
Route::post('update/{rule}', ['uses' => 'Rule\EditController@update', 'as' => 'update']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ class AvailableBudgetControllerTest extends TestCase
|
|||||||
|
|
||||||
|
|
||||||
// test API
|
// test API
|
||||||
$response = $this->post('/api/v1/available_budgets', $data,['Accept' => 'application/json']);
|
$response = $this->post('/api/v1/available_budgets', $data, ['Accept' => 'application/json']);
|
||||||
$response->assertStatus(500);
|
$response->assertStatus(500);
|
||||||
$response->assertSee('Could not find the indicated currency.');
|
$response->assertSee('Could not find the indicated currency.');
|
||||||
$response->assertHeader('Content-Type', 'application/json');
|
$response->assertHeader('Content-Type', 'application/json');
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ class BillControllerTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Store with minimum amount more than maximum amount
|
* Store with minimum amount more than maximum amount
|
||||||
|
*
|
||||||
* @covers \FireflyIII\Api\V1\Controllers\BillController
|
* @covers \FireflyIII\Api\V1\Controllers\BillController
|
||||||
* @covers \FireflyIII\Api\V1\Requests\BillRequest
|
* @covers \FireflyIII\Api\V1\Requests\BillRequest
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ class CurrencyControllerTest extends TestCase
|
|||||||
$response = $this->get('/api/v1/currencies');
|
$response = $this->get('/api/v1/currencies');
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
$response->assertJson(['data' => [],]);
|
$response->assertJson(['data' => [],]);
|
||||||
$response->assertJson([
|
$response->assertJson(
|
||||||
|
[
|
||||||
'meta' => [
|
'meta' => [
|
||||||
'pagination' => [
|
'pagination' => [
|
||||||
'total' => $collection->count(),
|
'total' => $collection->count(),
|
||||||
|
|||||||
@@ -103,40 +103,6 @@ class CurrencyExchangeRateControllerTest extends TestCase
|
|||||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Api\V1\Controllers\CurrencyExchangeRateController
|
|
||||||
*/
|
|
||||||
public function testIndexBadSource(): void
|
|
||||||
{
|
|
||||||
// mock repository
|
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
|
||||||
$service = $this->mock(ExchangeRateInterface::class);
|
|
||||||
|
|
||||||
$rate = new CurrencyExchangeRate();
|
|
||||||
$rate->date = new Carbon();
|
|
||||||
$rate->updated_at = new Carbon();
|
|
||||||
$rate->created_at = new Carbon();
|
|
||||||
$rate->rate = '0.5';
|
|
||||||
$rate->to_currency_id = 1;
|
|
||||||
$rate->from_currency_id = 2;
|
|
||||||
|
|
||||||
// mock calls:
|
|
||||||
$repository->shouldReceive('setUser')->once();
|
|
||||||
$repository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once();
|
|
||||||
$repository->shouldReceive('findByCodeNull')->withArgs(['USD'])->andReturn(TransactionCurrency::whereCode('USD')->first())->once();
|
|
||||||
|
|
||||||
// test API
|
|
||||||
$params = [
|
|
||||||
'from' => 'EUR',
|
|
||||||
'to' => 'USD',
|
|
||||||
'date' => '2018-01-01',
|
|
||||||
];
|
|
||||||
$response = $this->get('/api/v1/cer?' . http_build_query($params), ['Accept' => 'application/json']);
|
|
||||||
$response->assertStatus(500);
|
|
||||||
$response->assertSee('Unknown source currency.');
|
|
||||||
$response->assertHeader('Content-Type', 'application/json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Api\V1\Controllers\CurrencyExchangeRateController
|
* @covers \FireflyIII\Api\V1\Controllers\CurrencyExchangeRateController
|
||||||
*/
|
*/
|
||||||
@@ -170,4 +136,38 @@ class CurrencyExchangeRateControllerTest extends TestCase
|
|||||||
$response->assertSee('Unknown destination currency.');
|
$response->assertSee('Unknown destination currency.');
|
||||||
$response->assertHeader('Content-Type', 'application/json');
|
$response->assertHeader('Content-Type', 'application/json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \FireflyIII\Api\V1\Controllers\CurrencyExchangeRateController
|
||||||
|
*/
|
||||||
|
public function testIndexBadSource(): void
|
||||||
|
{
|
||||||
|
// mock repository
|
||||||
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$service = $this->mock(ExchangeRateInterface::class);
|
||||||
|
|
||||||
|
$rate = new CurrencyExchangeRate();
|
||||||
|
$rate->date = new Carbon();
|
||||||
|
$rate->updated_at = new Carbon();
|
||||||
|
$rate->created_at = new Carbon();
|
||||||
|
$rate->rate = '0.5';
|
||||||
|
$rate->to_currency_id = 1;
|
||||||
|
$rate->from_currency_id = 2;
|
||||||
|
|
||||||
|
// mock calls:
|
||||||
|
$repository->shouldReceive('setUser')->once();
|
||||||
|
$repository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once();
|
||||||
|
$repository->shouldReceive('findByCodeNull')->withArgs(['USD'])->andReturn(TransactionCurrency::whereCode('USD')->first())->once();
|
||||||
|
|
||||||
|
// test API
|
||||||
|
$params = [
|
||||||
|
'from' => 'EUR',
|
||||||
|
'to' => 'USD',
|
||||||
|
'date' => '2018-01-01',
|
||||||
|
];
|
||||||
|
$response = $this->get('/api/v1/cer?' . http_build_query($params), ['Accept' => 'application/json']);
|
||||||
|
$response->assertStatus(500);
|
||||||
|
$response->assertSee('Unknown source currency.');
|
||||||
|
$response->assertHeader('Content-Type', 'application/json');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -749,12 +749,12 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit the minimum amount to store a recurring transaction (using source ID field).
|
* Add a recurring but refer to an asset as destination.
|
||||||
*
|
*
|
||||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
|
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
|
||||||
*/
|
*/
|
||||||
public function testStoreFailInvalidWeekly(): void
|
public function testStoreFailInvalidDestinationId(): void
|
||||||
{
|
{
|
||||||
/** @var Recurrence $recurrence */
|
/** @var Recurrence $recurrence */
|
||||||
$recurrence = $this->user()->recurrences()->first();
|
$recurrence = $this->user()->recurrences()->first();
|
||||||
@@ -776,6 +776,19 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
// used by the validator to find the source_id:
|
// used by the validator to find the source_id:
|
||||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
||||||
->andReturn(new Collection([$assetAccount]));
|
->andReturn(new Collection([$assetAccount]));
|
||||||
|
$accountRepos->shouldReceive('getAccountsById')->withArgs([[$assetAccount->id]])->once()
|
||||||
|
->andReturn(new Collection([$assetAccount]));
|
||||||
|
|
||||||
|
|
||||||
|
// entries used by the transformer
|
||||||
|
$repository->shouldReceive('getNoteText')->andReturn('Note text');
|
||||||
|
$repository->shouldReceive('repetitionDescription')->andReturn('Some description.');
|
||||||
|
$repository->shouldReceive('getXOccurrences')->andReturn([]);
|
||||||
|
|
||||||
|
// entries used by the transformer (the fake entry has a category + a budget):
|
||||||
|
$factory->shouldReceive('findOrCreate')->andReturn(null);
|
||||||
|
$budgetRepos->shouldReceive('findNull')->andReturn(null);
|
||||||
|
|
||||||
|
|
||||||
// data to submit
|
// data to submit
|
||||||
$firstDate = new Carbon;
|
$firstDate = new Carbon;
|
||||||
@@ -792,12 +805,13 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
'currency_id' => '1',
|
'currency_id' => '1',
|
||||||
'description' => 'Test description',
|
'description' => 'Test description',
|
||||||
'source_id' => '1',
|
'source_id' => '1',
|
||||||
|
'destination_id' => $assetAccount->id,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'repetitions' => [
|
'repetitions' => [
|
||||||
[
|
[
|
||||||
'type' => 'weekly',
|
'type' => 'daily',
|
||||||
'moment' => '8',
|
'moment' => '',
|
||||||
'skip' => '0',
|
'skip' => '0',
|
||||||
'weekend' => '1',
|
'weekend' => '1',
|
||||||
|
|
||||||
@@ -811,8 +825,8 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
[
|
[
|
||||||
'message' => 'The given data was invalid.',
|
'message' => 'The given data was invalid.',
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'repetitions.0.moment' => [
|
'transactions.0.destination_id' => [
|
||||||
'Invalid repetition moment for this type of repetition.',
|
'This value is invalid for this field.',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
@@ -967,6 +981,79 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$response->assertHeader('Content-Type', 'application/json');
|
$response->assertHeader('Content-Type', 'application/json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submit the minimum amount to store a recurring transaction (using source ID field).
|
||||||
|
*
|
||||||
|
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||||
|
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
|
||||||
|
*/
|
||||||
|
public function testStoreFailInvalidNdomCount(): void
|
||||||
|
{
|
||||||
|
/** @var Recurrence $recurrence */
|
||||||
|
$recurrence = $this->user()->recurrences()->first();
|
||||||
|
|
||||||
|
// mock stuff:
|
||||||
|
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||||
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
|
// mock calls:
|
||||||
|
$repository->shouldReceive('setUser');
|
||||||
|
$factory->shouldReceive('setUser');
|
||||||
|
$budgetRepos->shouldReceive('setUser');
|
||||||
|
$accountRepos->shouldReceive('setUser');
|
||||||
|
|
||||||
|
// used by the validator to find the source_id:
|
||||||
|
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
||||||
|
->andReturn(new Collection([$assetAccount]));
|
||||||
|
|
||||||
|
// data to submit
|
||||||
|
$firstDate = new Carbon;
|
||||||
|
$firstDate->addDays(2);
|
||||||
|
$data = [
|
||||||
|
'type' => 'withdrawal',
|
||||||
|
'title' => 'Hello',
|
||||||
|
'first_date' => $firstDate->format('Y-m-d'),
|
||||||
|
'apply_rules' => 1,
|
||||||
|
'active' => 1,
|
||||||
|
'transactions' => [
|
||||||
|
[
|
||||||
|
'amount' => '100',
|
||||||
|
'currency_id' => '1',
|
||||||
|
'description' => 'Test description',
|
||||||
|
'source_id' => '1',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'repetitions' => [
|
||||||
|
[
|
||||||
|
'type' => 'ndom',
|
||||||
|
'moment' => '9',
|
||||||
|
'skip' => '0',
|
||||||
|
'weekend' => '1',
|
||||||
|
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// test API
|
||||||
|
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']);
|
||||||
|
$response->assertExactJson(
|
||||||
|
[
|
||||||
|
'message' => 'The given data was invalid.',
|
||||||
|
'errors' => [
|
||||||
|
'repetitions.0.moment' => [
|
||||||
|
'Invalid repetition moment for this type of repetition.',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$response->assertStatus(422);
|
||||||
|
$response->assertHeader('Content-Type', 'application/json');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit the minimum amount to store a recurring transaction (using source ID field).
|
* Submit the minimum amount to store a recurring transaction (using source ID field).
|
||||||
*
|
*
|
||||||
@@ -1046,7 +1133,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
|
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
|
||||||
*/
|
*/
|
||||||
public function testStoreFailInvalidNdomCount(): void
|
public function testStoreFailInvalidWeekly(): void
|
||||||
{
|
{
|
||||||
/** @var Recurrence $recurrence */
|
/** @var Recurrence $recurrence */
|
||||||
$recurrence = $this->user()->recurrences()->first();
|
$recurrence = $this->user()->recurrences()->first();
|
||||||
@@ -1088,8 +1175,8 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
],
|
],
|
||||||
'repetitions' => [
|
'repetitions' => [
|
||||||
[
|
[
|
||||||
'type' => 'ndom',
|
'type' => 'weekly',
|
||||||
'moment' => '9',
|
'moment' => '8',
|
||||||
'skip' => '0',
|
'skip' => '0',
|
||||||
'weekend' => '1',
|
'weekend' => '1',
|
||||||
|
|
||||||
@@ -1113,93 +1200,6 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$response->assertHeader('Content-Type', 'application/json');
|
$response->assertHeader('Content-Type', 'application/json');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a recurring but refer to an asset as destination.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
|
||||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
|
|
||||||
*/
|
|
||||||
public function testStoreFailInvalidDestinationId(): void
|
|
||||||
{
|
|
||||||
/** @var Recurrence $recurrence */
|
|
||||||
$recurrence = $this->user()->recurrences()->first();
|
|
||||||
|
|
||||||
// mock stuff:
|
|
||||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
|
||||||
$factory = $this->mock(CategoryFactory::class);
|
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
|
||||||
|
|
||||||
// mock calls:
|
|
||||||
$repository->shouldReceive('setUser');
|
|
||||||
$factory->shouldReceive('setUser');
|
|
||||||
$budgetRepos->shouldReceive('setUser');
|
|
||||||
$accountRepos->shouldReceive('setUser');
|
|
||||||
|
|
||||||
// used by the validator to find the source_id:
|
|
||||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
|
||||||
->andReturn(new Collection([$assetAccount]));
|
|
||||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[$assetAccount->id]])->once()
|
|
||||||
->andReturn(new Collection([$assetAccount]));
|
|
||||||
|
|
||||||
|
|
||||||
// entries used by the transformer
|
|
||||||
$repository->shouldReceive('getNoteText')->andReturn('Note text');
|
|
||||||
$repository->shouldReceive('repetitionDescription')->andReturn('Some description.');
|
|
||||||
$repository->shouldReceive('getXOccurrences')->andReturn([]);
|
|
||||||
|
|
||||||
// entries used by the transformer (the fake entry has a category + a budget):
|
|
||||||
$factory->shouldReceive('findOrCreate')->andReturn(null);
|
|
||||||
$budgetRepos->shouldReceive('findNull')->andReturn(null);
|
|
||||||
|
|
||||||
|
|
||||||
// data to submit
|
|
||||||
$firstDate = new Carbon;
|
|
||||||
$firstDate->addDays(2);
|
|
||||||
$data = [
|
|
||||||
'type' => 'withdrawal',
|
|
||||||
'title' => 'Hello',
|
|
||||||
'first_date' => $firstDate->format('Y-m-d'),
|
|
||||||
'apply_rules' => 1,
|
|
||||||
'active' => 1,
|
|
||||||
'transactions' => [
|
|
||||||
[
|
|
||||||
'amount' => '100',
|
|
||||||
'currency_id' => '1',
|
|
||||||
'description' => 'Test description',
|
|
||||||
'source_id' => '1',
|
|
||||||
'destination_id' => $assetAccount->id,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'repetitions' => [
|
|
||||||
[
|
|
||||||
'type' => 'daily',
|
|
||||||
'moment' => '',
|
|
||||||
'skip' => '0',
|
|
||||||
'weekend' => '1',
|
|
||||||
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
// test API
|
|
||||||
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']);
|
|
||||||
$response->assertExactJson(
|
|
||||||
[
|
|
||||||
'message' => 'The given data was invalid.',
|
|
||||||
'errors' => [
|
|
||||||
'transactions.0.destination_id' => [
|
|
||||||
'This value is invalid for this field.',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
$response->assertStatus(422);
|
|
||||||
$response->assertHeader('Content-Type', 'application/json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit without a source account.
|
* Submit without a source account.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ namespace Tests\Feature\Controllers\Account;
|
|||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
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\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
|
|||||||
@@ -30,8 +30,9 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Tests\TestCase;
|
|
||||||
use Log;
|
use Log;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Class DeleteControllerTest
|
* Class DeleteControllerTest
|
||||||
@@ -46,6 +47,7 @@ class DeleteControllerTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\Account\DeleteController
|
* @covers \FireflyIII\Http\Controllers\Account\DeleteController
|
||||||
* @covers \FireflyIII\Http\Controllers\Controller
|
* @covers \FireflyIII\Http\Controllers\Controller
|
||||||
|
|||||||
@@ -26,16 +26,16 @@ namespace Tests\Feature\Controllers\Account;
|
|||||||
|
|
||||||
use Amount;
|
use Amount;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Note;
|
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Log;
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Class EditControllerTest
|
* Class EditControllerTest
|
||||||
@@ -50,6 +50,7 @@ class EditControllerTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\Account\EditController
|
* @covers \FireflyIII\Http\Controllers\Account\EditController
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
|||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
|
||||||
use Mockery;
|
use Mockery;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ConfigurationControllerTest
|
* Class ConfigurationControllerTest
|
||||||
@@ -217,7 +217,7 @@ class ReconcileControllerTest extends TestCase
|
|||||||
$journalRepos->shouldReceive('store')->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('store')->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('getReconciliation')->andReturn(new Account);
|
$repository->shouldReceive('getReconciliation')->andReturn(new Account);
|
||||||
$repository->shouldReceive('findNull')->andReturn(new Account);
|
$repository->shouldReceive('findNull')->andReturn(new Account);
|
||||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(),'currency_id'])->andReturn('1');
|
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'transactions' => [1, 2, 3],
|
'transactions' => [1, 2, 3],
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
|||||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Models\Rule;
|
use FireflyIII\Models\Rule;
|
||||||
use FireflyIII\Models\RuleGroup;
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
@@ -67,7 +66,7 @@ class BillControllerTest extends TestCase
|
|||||||
// mock stuff
|
// mock stuff
|
||||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@@ -85,7 +84,7 @@ class BillControllerTest extends TestCase
|
|||||||
// mock stuff
|
// mock stuff
|
||||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@@ -104,7 +103,7 @@ class BillControllerTest extends TestCase
|
|||||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$repository->shouldReceive('destroy')->andReturn(true);
|
$repository->shouldReceive('destroy')->andReturn(true);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
@@ -123,7 +122,7 @@ class BillControllerTest extends TestCase
|
|||||||
// mock stuff
|
// mock stuff
|
||||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@@ -144,7 +143,7 @@ class BillControllerTest extends TestCase
|
|||||||
$bill = factory(Bill::class)->make();
|
$bill = factory(Bill::class)->make();
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$collection = new Collection([$bill]);
|
$collection = new Collection([$bill]);
|
||||||
$repository->shouldReceive('getPaginator')->andReturn(new LengthAwarePaginator($collection, 1, 50))->once();
|
$repository->shouldReceive('getPaginator')->andReturn(new LengthAwarePaginator($collection, 1, 50))->once();
|
||||||
@@ -171,7 +170,7 @@ class BillControllerTest extends TestCase
|
|||||||
$journal = factory(TransactionJournal::class)->make();
|
$journal = factory(TransactionJournal::class)->make();
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('getRulesForBill')->andReturn(new Collection([$rule]));
|
$repository->shouldReceive('getRulesForBill')->andReturn(new Collection([$rule]));
|
||||||
|
|
||||||
@@ -199,7 +198,7 @@ class BillControllerTest extends TestCase
|
|||||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@@ -218,7 +217,7 @@ class BillControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$collector = $this->mock(JournalCollectorInterface::class);
|
$collector = $this->mock(JournalCollectorInterface::class);
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$repository->shouldReceive('getYearAverage')->andReturn('0');
|
$repository->shouldReceive('getYearAverage')->andReturn('0');
|
||||||
$repository->shouldReceive('getOverallAverage')->andReturn('0');
|
$repository->shouldReceive('getOverallAverage')->andReturn('0');
|
||||||
$repository->shouldReceive('nextExpectedMatch')->andReturn(new Carbon);
|
$repository->shouldReceive('nextExpectedMatch')->andReturn(new Carbon);
|
||||||
@@ -255,7 +254,7 @@ class BillControllerTest extends TestCase
|
|||||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('store')->andReturn($bill);
|
$repository->shouldReceive('store')->andReturn($bill);
|
||||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||||
@@ -289,7 +288,7 @@ class BillControllerTest extends TestCase
|
|||||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$bill = $this->user()->bills()->first();
|
$bill = $this->user()->bills()->first();
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('store')->andReturn($bill);
|
$repository->shouldReceive('store')->andReturn($bill);
|
||||||
@@ -314,41 +313,6 @@ class BillControllerTest extends TestCase
|
|||||||
$response->assertSessionHas('success');
|
$response->assertSessionHas('success');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Http\Controllers\BillController::store
|
|
||||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
|
||||||
* @covers \FireflyIII\Http\Requests\Request
|
|
||||||
*/
|
|
||||||
public function testStoreNoGroup(): void
|
|
||||||
{
|
|
||||||
// mock stuff
|
|
||||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
|
||||||
$repository->shouldReceive('store')->andReturn(new Bill);
|
|
||||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
|
||||||
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'name' => 'New Bill ' . random_int(1000, 9999),
|
|
||||||
'amount_min' => '100',
|
|
||||||
'transaction_currency_id' => 1,
|
|
||||||
'skip' => 0,
|
|
||||||
'create_another' => '1',
|
|
||||||
'strict' => 1,
|
|
||||||
'amount_max' => '100',
|
|
||||||
'date' => '2016-01-01',
|
|
||||||
'repeat_freq' => 'monthly',
|
|
||||||
];
|
|
||||||
$this->session(['bills.create.uri' => 'http://localhost']);
|
|
||||||
$this->be($this->user());
|
|
||||||
$response = $this->post(route('bills.store'), $data);
|
|
||||||
$response->assertStatus(302);
|
|
||||||
$response->assertSessionHas('success');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\BillController::store
|
* @covers \FireflyIII\Http\Controllers\BillController::store
|
||||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||||
@@ -360,7 +324,7 @@ class BillControllerTest extends TestCase
|
|||||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('store')->andReturn(null);
|
$repository->shouldReceive('store')->andReturn(null);
|
||||||
|
|
||||||
@@ -381,6 +345,41 @@ class BillControllerTest extends TestCase
|
|||||||
$response->assertRedirect(route('bills.create'));
|
$response->assertRedirect(route('bills.create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \FireflyIII\Http\Controllers\BillController::store
|
||||||
|
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||||
|
* @covers \FireflyIII\Http\Requests\Request
|
||||||
|
*/
|
||||||
|
public function testStoreNoGroup(): void
|
||||||
|
{
|
||||||
|
// mock stuff
|
||||||
|
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||||
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
$repository->shouldReceive('store')->andReturn(new Bill);
|
||||||
|
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||||
|
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'name' => 'New Bill ' . random_int(1000, 9999),
|
||||||
|
'amount_min' => '100',
|
||||||
|
'transaction_currency_id' => 1,
|
||||||
|
'skip' => 0,
|
||||||
|
'create_another' => '1',
|
||||||
|
'strict' => 1,
|
||||||
|
'amount_max' => '100',
|
||||||
|
'date' => '2016-01-01',
|
||||||
|
'repeat_freq' => 'monthly',
|
||||||
|
];
|
||||||
|
$this->session(['bills.create.uri' => 'http://localhost']);
|
||||||
|
$this->be($this->user());
|
||||||
|
$response = $this->post(route('bills.store'), $data);
|
||||||
|
$response->assertStatus(302);
|
||||||
|
$response->assertSessionHas('success');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\BillController::update
|
* @covers \FireflyIII\Http\Controllers\BillController::update
|
||||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||||
@@ -392,7 +391,7 @@ class BillControllerTest extends TestCase
|
|||||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('update')->andReturn(new Bill);
|
$repository->shouldReceive('update')->andReturn(new Bill);
|
||||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||||
|
|||||||
@@ -24,13 +24,9 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Feature\Controllers\Category;
|
namespace Tests\Feature\Controllers\Category;
|
||||||
|
|
||||||
|
|
||||||
use Tests\TestCase;
|
|
||||||
use Log;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||||
use FireflyIII\Models\Category;
|
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
@@ -38,7 +34,10 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
|||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Log;
|
||||||
use Navigation;
|
use Navigation;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Class ShowControllerTest
|
* Class ShowControllerTest
|
||||||
@@ -200,7 +199,7 @@ class ShowControllerTest extends TestCase
|
|||||||
public function testShowEmpty(string $range): void
|
public function testShowEmpty(string $range): void
|
||||||
{
|
{
|
||||||
$latestJournal = $this->user()->transactionJournals()
|
$latestJournal = $this->user()->transactionJournals()
|
||||||
->orderBy('date','DESC')->first();
|
->orderBy('date', 'DESC')->first();
|
||||||
|
|
||||||
Log::debug(sprintf('Test testShowEmpty(%s)', $range));
|
Log::debug(sprintf('Test testShowEmpty(%s)', $range));
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user