From ade6558769ba807f6ba182d5b97062822728a342 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 07:22:26 +0100 Subject: [PATCH 001/448] Mea culpa. Removed ide specific files from git ignore. --- .gitignore | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.gitignore b/.gitignore index d58cb9cb4e..24a6fb22e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,6 @@ /vendor /node_modules -Homestead.yaml -Homestead.json .env -_ide_helper.php -_ide_helper_models.php -.phpstorm.meta.php storage/ - -# Eclipse project files -.buildpath -.project -.settings/ - .env.local From 749dd1e8e37089558a9d907f54feac57210da4dc Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 07:22:38 +0100 Subject: [PATCH 002/448] Text alignment. --- app/User.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/User.php b/app/User.php index f093b495c4..c183f7b64a 100644 --- a/app/User.php +++ b/app/User.php @@ -27,8 +27,8 @@ use Zizaco\Entrust\Traits\EntrustUserTrait; * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Preference[] $preferences * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionjournals * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Role[] $roles - * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\RuleGroup[] $ruleGroups - * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Rule[] $rules + * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\RuleGroup[] $ruleGroups + * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Rule[] $rules */ class User extends Authenticatable { From 0df8d096f01fa93ce07a2871e9612a19eed531a9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 07:23:02 +0100 Subject: [PATCH 003/448] Removed unused use statements. --- app/Handlers/Events/ScanForBillsAfterStore.php | 1 - app/Handlers/Events/ScanForBillsAfterUpdate.php | 1 - 2 files changed, 2 deletions(-) diff --git a/app/Handlers/Events/ScanForBillsAfterStore.php b/app/Handlers/Events/ScanForBillsAfterStore.php index 81fa3f870f..05fdff406f 100644 --- a/app/Handlers/Events/ScanForBillsAfterStore.php +++ b/app/Handlers/Events/ScanForBillsAfterStore.php @@ -11,7 +11,6 @@ namespace FireflyIII\Handlers\Events; use FireflyIII\Events\TransactionJournalStored; use FireflyIII\Support\Events\BillScanner; -use Log; /** * Class RescanJournal diff --git a/app/Handlers/Events/ScanForBillsAfterUpdate.php b/app/Handlers/Events/ScanForBillsAfterUpdate.php index c17a79360a..5aec28cb61 100644 --- a/app/Handlers/Events/ScanForBillsAfterUpdate.php +++ b/app/Handlers/Events/ScanForBillsAfterUpdate.php @@ -11,7 +11,6 @@ namespace FireflyIII\Handlers\Events; use FireflyIII\Events\TransactionJournalUpdated; use FireflyIII\Support\Events\BillScanner; -use Log; /** * Class RescanJournal From bd40615f8e27666737ebce9bec0d5ce808335277 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 07:23:14 +0100 Subject: [PATCH 004/448] Code cleanup. --- app/Helpers/FiscalHelper.php | 43 ++++++++++++++------------- app/Helpers/FiscalHelperInterface.php | 24 +++++++-------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/app/Helpers/FiscalHelper.php b/app/Helpers/FiscalHelper.php index 1d33aa5d8f..5b15450be8 100644 --- a/app/Helpers/FiscalHelper.php +++ b/app/Helpers/FiscalHelper.php @@ -31,6 +31,27 @@ class FiscalHelper implements FiscalHelperInterface } } + /** + * @param Carbon $date + * + * @return Carbon date object + */ + public function endOfFiscalYear(Carbon $date) + { + // get start of fiscal year for passed date + $endDate = $this->startOfFiscalYear($date); + if ($this->useCustomFiscalYear === true) { + // add 1 year and sub 1 day + $endDate->addYear(); + $endDate->subDay(); + } else { + $endDate->endOfYear(); + } + + + return $endDate; + } + /** * @param Carbon $date * @@ -52,27 +73,7 @@ class FiscalHelper implements FiscalHelperInterface } else { $startDate->startOfYear(); } + return $startDate; } - - /** - * @param Carbon $date - * - * @return Carbon date object - */ - public function endOfFiscalYear(Carbon $date) - { - // get start of fiscal year for passed date - $endDate = $this->startOfFiscalYear($date); - if ($this->useCustomFiscalYear === true) { - // add 1 year and sub 1 day - $endDate->addYear(); - $endDate->subDay(); - } else { - $endDate->endOfYear(); - } - - - return $endDate; - } } diff --git a/app/Helpers/FiscalHelperInterface.php b/app/Helpers/FiscalHelperInterface.php index f4ec6fba1a..e5f805a855 100644 --- a/app/Helpers/FiscalHelperInterface.php +++ b/app/Helpers/FiscalHelperInterface.php @@ -14,22 +14,22 @@ interface FiscalHelperInterface /** * This method produces a clone of the Carbon date object passed, checks preferences - * and calculates the first day of the fiscal year. + * and calculates the last day of the fiscal year. * - * @param Carbon $date - * - * @return Carbon date object - */ - public function startOfFiscalYear(Carbon $date); - - /** - * This method produces a clone of the Carbon date object passed, checks preferences - * and calculates the last day of the fiscal year. - * - * @param Carbon $date + * @param Carbon $date * * @return Carbon date object */ public function endOfFiscalYear(Carbon $date); + /** + * This method produces a clone of the Carbon date object passed, checks preferences + * and calculates the first day of the fiscal year. + * + * @param Carbon $date + * + * @return Carbon date object + */ + public function startOfFiscalYear(Carbon $date); + } From c1ecc62ac1e248e6d63539849f59e5b323db2ca4 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 07:27:03 +0100 Subject: [PATCH 005/448] Replaced Session::get() with session() --- app/Helpers/Csv/Converter/Date.php | 3 +-- app/Helpers/Csv/Data.php | 18 +++++++-------- app/Http/Controllers/AccountController.php | 16 +++++++------- app/Http/Controllers/AttachmentController.php | 6 ++--- app/Http/Controllers/BillController.php | 12 +++++----- app/Http/Controllers/BudgetController.php | 22 +++++++++---------- app/Http/Controllers/CategoryController.php | 14 ++++++------ .../Controllers/Chart/AccountController.php | 15 ++++++------- app/Http/Controllers/Chart/BillController.php | 7 +++--- .../Controllers/Chart/BudgetController.php | 9 ++++---- .../Controllers/Chart/CategoryController.php | 13 +++++------ app/Http/Controllers/CsvController.php | 14 ++++++------ app/Http/Controllers/CurrencyController.php | 12 +++++----- app/Http/Controllers/HomeController.php | 4 ++-- app/Http/Controllers/JsonController.php | 19 +++++++--------- app/Http/Controllers/PiggyBankController.php | 18 +++++++-------- app/Http/Controllers/RuleController.php | 10 ++++----- app/Http/Controllers/RuleGroupController.php | 10 ++++----- app/Http/Controllers/TagController.php | 10 ++++----- .../Controllers/TransactionController.php | 14 ++++++------ .../Account/AccountRepository.php | 9 ++++---- app/Support/ExpandedForm.php | 4 ++-- app/Support/Twig/General.php | 3 +-- 23 files changed, 126 insertions(+), 136 deletions(-) diff --git a/app/Helpers/Csv/Converter/Date.php b/app/Helpers/Csv/Converter/Date.php index d2487ccd24..1024e6e42c 100644 --- a/app/Helpers/Csv/Converter/Date.php +++ b/app/Helpers/Csv/Converter/Date.php @@ -6,7 +6,6 @@ use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use InvalidArgumentException; use Log; -use Session; /** * Class Date @@ -22,7 +21,7 @@ class Date extends BasicConverter implements ConverterInterface */ public function convert() { - $format = Session::get('csv-date-format'); + $format = session('csv-date-format'); try { $date = Carbon::createFromFormat($format, $this->value); } catch (InvalidArgumentException $e) { diff --git a/app/Helpers/Csv/Data.php b/app/Helpers/Csv/Data.php index 32e1ca4477..da4cc224fb 100644 --- a/app/Helpers/Csv/Data.php +++ b/app/Helpers/Csv/Data.php @@ -260,63 +260,63 @@ class Data protected function sessionCsvFileLocation() { if (Session::has('csv-file')) { - $this->csvFileLocation = (string)Session::get('csv-file'); + $this->csvFileLocation = (string)session('csv-file'); } } protected function sessionDateFormat() { if (Session::has('csv-date-format')) { - $this->dateFormat = (string)Session::get('csv-date-format'); + $this->dateFormat = (string)session('csv-date-format'); } } protected function sessionDelimiter() { if (Session::has('csv-delimiter')) { - $this->delimiter = Session::get('csv-delimiter'); + $this->delimiter = session('csv-delimiter'); } } protected function sessionHasHeaders() { if (Session::has('csv-has-headers')) { - $this->hasHeaders = (bool)Session::get('csv-has-headers'); + $this->hasHeaders = (bool)session('csv-has-headers'); } } protected function sessionImportAccount() { if (Session::has('csv-import-account')) { - $this->importAccount = intval(Session::get('csv-import-account')); + $this->importAccount = intval(session('csv-import-account')); } } protected function sessionMap() { if (Session::has('csv-map')) { - $this->map = (array)Session::get('csv-map'); + $this->map = (array)session('csv-map'); } } protected function sessionMapped() { if (Session::has('csv-mapped')) { - $this->mapped = (array)Session::get('csv-mapped'); + $this->mapped = (array)session('csv-mapped'); } } protected function sessionRoles() { if (Session::has('csv-roles')) { - $this->roles = (array)Session::get('csv-roles'); + $this->roles = (array)session('csv-roles'); } } protected function sessionSpecifix() { if (Session::has('csv-specifix')) { - $this->specifix = (array)Session::get('csv-specifix'); + $this->specifix = (array)session('csv-specifix'); } } } diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 44d210ca40..2c2083522b 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -22,7 +22,7 @@ use View; class AccountController extends Controller { /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -44,7 +44,7 @@ class AccountController extends Controller $subTitle = trans('firefly.make_new_' . $what . '_account'); // put previous url in session if not redirect from store (not "create another"). - if (Session::get('accounts.create.fromStore') !== true) { + if (session('accounts.create.fromStore') !== true) { Session::put('accounts.create.url', URL::previous()); } Session::forget('accounts.create.fromStore'); @@ -94,7 +94,7 @@ class AccountController extends Controller Session::flash('success', trans('firefly.' . $typeName . '_deleted', ['name' => $name])); Preferences::mark(); - return redirect(Session::get('accounts.delete.url')); + return redirect(session('accounts.delete.url')); } /** @@ -112,7 +112,7 @@ class AccountController extends Controller $openingBalance = $repository->openingBalanceTransaction($account); // put previous url in session if not redirect from store (not "return_to_edit"). - if (Session::get('accounts.edit.fromUpdate') !== true) { + if (session('accounts.edit.fromUpdate') !== true) { Session::put('accounts.edit.url', URL::previous()); } Session::forget('accounts.edit.fromUpdate'); @@ -154,8 +154,8 @@ class AccountController extends Controller $subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what); $types = Config::get('firefly.accountTypesByIdentifier.' . $what); $accounts = $repository->getAccounts($types); - $start = clone Session::get('start', Carbon::now()->startOfMonth()); - $end = clone Session::get('end', Carbon::now()->endOfMonth()); + $start = clone session('start', Carbon::now()->startOfMonth()); + $end = clone session('end', Carbon::now()->endOfMonth()); $start->subDay(); $ids = $accounts->pluck('id')->toArray(); @@ -229,7 +229,7 @@ class AccountController extends Controller } // redirect to previous URL. - return redirect(Session::get('accounts.create.url')); + return redirect(session('accounts.create.url')); } /** @@ -268,7 +268,7 @@ class AccountController extends Controller } // redirect to previous URL. - return redirect(Session::get('accounts.edit.url')); + return redirect(session('accounts.edit.url')); } diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php index 0e818f3f20..861d8c7062 100644 --- a/app/Http/Controllers/AttachmentController.php +++ b/app/Http/Controllers/AttachmentController.php @@ -65,7 +65,7 @@ class AttachmentController extends Controller Session::flash('success', trans('firefly.attachment_deleted', ['name' => $name])); Preferences::mark(); - return redirect(Session::get('attachments.delete.url')); + return redirect(session('attachments.delete.url')); } /** @@ -110,7 +110,7 @@ class AttachmentController extends Controller $subTitle = trans('firefly.edit_attachment', ['name' => $attachment->filename]); // put previous url in session if not redirect from store (not "return_to_edit"). - if (Session::get('attachments.edit.fromUpdate') !== true) { + if (session('attachments.edit.fromUpdate') !== true) { Session::put('attachments.edit.url', URL::previous()); } Session::forget('attachments.edit.fromUpdate'); @@ -167,7 +167,7 @@ class AttachmentController extends Controller } // redirect to previous URL. - return redirect(Session::get('attachments.edit.url')); + return redirect(session('attachments.edit.url')); } diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index ca59f0d256..e74da3c093 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -20,7 +20,7 @@ class BillController extends Controller { /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -39,7 +39,7 @@ class BillController extends Controller // put previous url in session if not redirect from store (not "create another"). - if (Session::get('bills.create.fromStore') !== true) { + if (session('bills.create.fromStore') !== true) { Session::put('bills.create.url', URL::previous()); } Session::forget('bills.create.fromStore'); @@ -78,7 +78,7 @@ class BillController extends Controller Session::flash('success', 'The bill was deleted.'); Preferences::mark(); - return redirect(Session::get('bills.delete.url')); + return redirect(session('bills.delete.url')); } /** @@ -92,7 +92,7 @@ class BillController extends Controller $subTitle = trans('firefly.edit_bill', ['name' => $bill->name]); // put previous url in session if not redirect from store (not "return_to_edit"). - if (Session::get('bills.edit.fromUpdate') !== true) { + if (session('bills.edit.fromUpdate') !== true) { Session::put('bills.edit.url', URL::previous()); } Session::forget('bills.edit.fromUpdate'); @@ -184,7 +184,7 @@ class BillController extends Controller } // redirect to previous URL. - return redirect(Session::get('bills.create.url')); + return redirect(session('bills.create.url')); } @@ -211,7 +211,7 @@ class BillController extends Controller } // redirect to previous URL. - return redirect(Session::get('bills.edit.url')); + return redirect(session('bills.edit.url')); } diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index e86d95bb46..325f5a0352 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -26,7 +26,7 @@ class BudgetController extends Controller { /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -45,7 +45,7 @@ class BudgetController extends Controller public function amount(BudgetRepositoryInterface $repository, Budget $budget) { $amount = intval(Input::get('amount')); - $date = Session::get('start', Carbon::now()->startOfMonth()); + $date = session('start', Carbon::now()->startOfMonth()); $limitRepetition = $repository->updateLimitAmount($budget, $date, $amount); if ($amount == 0) { $limitRepetition = null; @@ -62,7 +62,7 @@ class BudgetController extends Controller public function create() { // put previous url in session if not redirect from store (not "create another"). - if (Session::get('budgets.create.fromStore') !== true) { + if (session('budgets.create.fromStore') !== true) { Session::put('budgets.create.url', URL::previous()); } Session::forget('budgets.create.fromStore'); @@ -107,7 +107,7 @@ class BudgetController extends Controller Preferences::mark(); - return redirect(Session::get('budgets.delete.url')); + return redirect(session('budgets.delete.url')); } /** @@ -120,7 +120,7 @@ class BudgetController extends Controller $subTitle = trans('firefly.edit_budget', ['name' => $budget->name]); // put previous url in session if not redirect from store (not "return_to_edit"). - if (Session::get('budgets.edit.fromUpdate') !== true) { + if (session('budgets.edit.fromUpdate') !== true) { Session::put('budgets.edit.url', URL::previous()); } Session::forget('budgets.edit.fromUpdate'); @@ -145,7 +145,7 @@ class BudgetController extends Controller $spent = '0'; $budgeted = '0'; $range = Preferences::get('viewRange', '1M')->data; - $start = Navigation::startOfPeriod(Session::get('start', new Carbon), $range); + $start = Navigation::startOfPeriod(session('start', new Carbon), $range); $end = Navigation::endOfPeriod($start, $range); $key = 'budgetIncomeTotal' . $start->format('Ymd') . $end->format('Ymd'); $budgetIncomeTotal = Preferences::get($key, 1000)->data; @@ -187,7 +187,7 @@ class BudgetController extends Controller public function noBudget(BudgetRepositoryInterface $repository) { $range = Preferences::get('viewRange', '1M')->data; - $start = Navigation::startOfPeriod(Session::get('start', new Carbon), $range); + $start = Navigation::startOfPeriod(session('start', new Carbon), $range); $end = Navigation::endOfPeriod($start, $range); $list = $repository->getWithoutBudget($start, $end); $subTitle = trans( @@ -204,7 +204,7 @@ class BudgetController extends Controller public function postUpdateIncome() { $range = Preferences::get('viewRange', '1M')->data; - $start = Navigation::startOfPeriod(Session::get('start', new Carbon), $range); + $start = Navigation::startOfPeriod(session('start', new Carbon), $range); $end = Navigation::endOfPeriod($start, $range); $key = 'budgetIncomeTotal' . $start->format('Ymd') . $end->format('Ymd'); @@ -282,7 +282,7 @@ class BudgetController extends Controller } // redirect to previous URL. - return redirect(Session::get('budgets.create.url')); + return redirect(session('budgets.create.url')); } @@ -313,7 +313,7 @@ class BudgetController extends Controller } // redirect to previous URL. - return redirect(Session::get('budgets.edit.url')); + return redirect(session('budgets.edit.url')); } @@ -323,7 +323,7 @@ class BudgetController extends Controller public function updateIncome() { $range = Preferences::get('viewRange', '1M')->data; - $start = Navigation::startOfPeriod(Session::get('start', new Carbon), $range); + $start = Navigation::startOfPeriod(session('start', new Carbon), $range); $end = Navigation::endOfPeriod($start, $range); $key = 'budgetIncomeTotal' . $start->format('Ymd') . $end->format('Ymd'); $amount = Preferences::get($key, 1000); diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 1b59519808..1a9f305b8e 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -25,7 +25,7 @@ class CategoryController extends Controller { /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -40,7 +40,7 @@ class CategoryController extends Controller public function create() { // put previous url in session if not redirect from store (not "create another"). - if (Session::get('categories.create.fromStore') !== true) { + if (session('categories.create.fromStore') !== true) { Session::put('categories.create.url', URL::previous()); } Session::forget('categories.create.fromStore'); @@ -83,7 +83,7 @@ class CategoryController extends Controller Session::flash('success', 'The category "' . e($name) . '" was deleted.'); Preferences::mark(); - return redirect(Session::get('categories.delete.url')); + return redirect(session('categories.delete.url')); } /** @@ -96,7 +96,7 @@ class CategoryController extends Controller $subTitle = trans('firefly.edit_category', ['name' => $category->name]); // put previous url in session if not redirect from store (not "return_to_edit"). - if (Session::get('categories.edit.fromUpdate') !== true) { + if (session('categories.edit.fromUpdate') !== true) { Session::put('categories.edit.url', URL::previous()); } Session::forget('categories.edit.fromUpdate'); @@ -133,8 +133,8 @@ class CategoryController extends Controller */ public function noCategory(CRI $repository) { - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->startOfMonth()); + $start = session('start', Carbon::now()->startOfMonth()); + $end = session('end', Carbon::now()->startOfMonth()); $list = $repository->listNoCategory($start, $end); $subTitle = trans( 'firefly.without_category_between', @@ -284,7 +284,7 @@ class CategoryController extends Controller } // redirect to previous URL. - return redirect(Session::get('categories.edit.url')); + return redirect(session('categories.edit.url')); } diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index 1110abaa27..6a5a3ea715 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -10,7 +10,6 @@ use FireflyIII\Support\CacheProperties; use Illuminate\Support\Collection; use Preferences; use Response; -use Session; /** * Class AccountController @@ -24,7 +23,7 @@ class AccountController extends Controller protected $generator; /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -75,8 +74,8 @@ class AccountController extends Controller */ public function expenseAccounts(ARI $repository) { - $start = clone Session::get('start', Carbon::now()->startOfMonth()); - $end = clone Session::get('end', Carbon::now()->endOfMonth()); + $start = clone session('start', Carbon::now()->startOfMonth()); + $end = clone session('end', Carbon::now()->endOfMonth()); $accounts = $repository->getAccounts(['Expense account', 'Beneficiary account']); // chart properties for cache: @@ -106,8 +105,8 @@ class AccountController extends Controller public function frontpage(ARI $repository) { $frontPage = Preferences::get('frontPageAccounts', []); - $start = clone Session::get('start', Carbon::now()->startOfMonth()); - $end = clone Session::get('end', Carbon::now()->endOfMonth()); + $start = clone session('start', Carbon::now()->startOfMonth()); + $end = clone session('end', Carbon::now()->endOfMonth()); $accounts = $repository->getFrontpageAccounts($frontPage); // chart properties for cache: @@ -138,8 +137,8 @@ class AccountController extends Controller { - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); + $start = session('start', Carbon::now()->startOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); // chart properties for cache: $cache = new CacheProperties(); diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php index d1e58998c5..6772b4a4b6 100644 --- a/app/Http/Controllers/Chart/BillController.php +++ b/app/Http/Controllers/Chart/BillController.php @@ -9,7 +9,6 @@ use FireflyIII\Models\TransactionJournal; use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Support\CacheProperties; use Response; -use Session; /** * Class BillController @@ -23,7 +22,7 @@ class BillController extends Controller protected $generator; /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -41,8 +40,8 @@ class BillController extends Controller */ public function frontpage(BillRepositoryInterface $repository) { - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); + $start = session('start', Carbon::now()->startOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); $paid = $repository->getBillsPaidInRange($start, $end); // will be a negative amount. $unpaid = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount. $creditCardDue = $repository->getCreditCardBill($start, $end); diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index 848a13179b..1677b2b817 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -13,7 +13,6 @@ use Illuminate\Support\Collection; use Navigation; use Preferences; use Response; -use Session; /** * Class BudgetController @@ -27,7 +26,7 @@ class BudgetController extends Controller protected $generator; /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -129,7 +128,7 @@ class BudgetController extends Controller // dates and times $first = $repository->getFirstBudgetLimitDate($budget); $range = Preferences::get('viewRange', '1M')->data; - $last = Session::get('end', new Carbon); + $last = session('end', new Carbon); // chart properties for cache: $cache = new CacheProperties(); @@ -236,8 +235,8 @@ class BudgetController extends Controller */ public function frontpage(BudgetRepositoryInterface $repository, ARI $accountRepository) { - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); + $start = session('start', Carbon::now()->startOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); // chart properties for cache: $cache = new CacheProperties(); diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index 95c1985206..e571535670 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -13,7 +13,6 @@ use Illuminate\Support\Collection; use Navigation; use Preferences; use Response; -use Session; use stdClass; /** @@ -27,7 +26,7 @@ class CategoryController extends Controller protected $generator; /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -92,8 +91,8 @@ class CategoryController extends Controller */ public function currentPeriod(SCRI $repository, Category $category) { - $start = clone Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); + $start = clone session('start', Carbon::now()->startOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); $data = $this->makePeriodChart($repository, $category, $start, $end); return Response::json($data); @@ -176,8 +175,8 @@ class CategoryController extends Controller public function frontpage(CRI $repository) { - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); + $start = session('start', Carbon::now()->startOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); // chart properties for cache: $cache = new CacheProperties; @@ -395,7 +394,7 @@ class CategoryController extends Controller $cache->addProperty($category->id); $cache->addProperty('specific-period'); if ($cache->has()) { - return $cache->get(); // @codeCoverageIgnore + return $cache->get(); // } $entries = new Collection; diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 75fa433460..24ef30c3ea 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -31,7 +31,7 @@ class CsvController extends Controller protected $wizard; /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -106,21 +106,21 @@ class CsvController extends Controller return redirect(route('csv.index')); } $data = [ - 'date-format' => Session::get('csv-date-format'), - 'has-headers' => Session::get('csv-has-headers'), + 'date-format' => session('csv-date-format'), + 'has-headers' => session('csv-has-headers'), ]; if (Session::has('csv-map')) { - $data['map'] = Session::get('csv-map'); + $data['map'] = session('csv-map'); } if (Session::has('csv-roles')) { - $data['roles'] = Session::get('csv-roles'); + $data['roles'] = session('csv-roles'); } if (Session::has('csv-mapped')) { - $data['mapped'] = Session::get('csv-mapped'); + $data['mapped'] = session('csv-mapped'); } if (Session::has('csv-specifix')) { - $data['specifix'] = Session::get('csv-specifix'); + $data['specifix'] = session('csv-specifix'); } $result = json_encode($data, JSON_PRETTY_PRINT); diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index d62ba35cb1..80280c94ca 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -22,7 +22,7 @@ class CurrencyController extends Controller /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -40,7 +40,7 @@ class CurrencyController extends Controller $subTitle = trans('firefly.create_currency'); // put previous url in session if not redirect from store (not "create another"). - if (Session::get('currency.create.fromStore') !== true) { + if (session('currency.create.fromStore') !== true) { Session::put('currency.create.url', URL::previous()); } Session::forget('currency.create.fromStore'); @@ -114,7 +114,7 @@ class CurrencyController extends Controller $currency->delete(); } - return redirect(Session::get('currency.delete.url')); + return redirect(session('currency.delete.url')); } /** @@ -129,7 +129,7 @@ class CurrencyController extends Controller $currency->symbol = htmlentities($currency->symbol); // put previous url in session if not redirect from store (not "return_to_edit"). - if (Session::get('currency.edit.fromUpdate') !== true) { + if (session('currency.edit.fromUpdate') !== true) { Session::put('currency.edit.url', URL::previous()); } Session::forget('currency.edit.fromUpdate'); @@ -183,7 +183,7 @@ class CurrencyController extends Controller } // redirect to previous URL. - return redirect(Session::get('currency.create.url')); + return redirect(session('currency.create.url')); } @@ -212,7 +212,7 @@ class CurrencyController extends Controller } // redirect to previous URL. - return redirect(Session::get('currency.edit.url')); + return redirect(session('currency.edit.url')); } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 1d638813da..d4ada04d04 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -90,8 +90,8 @@ class HomeController extends Controller $mainTitleIcon = 'fa-fire'; $transactions = []; $frontPage = Preferences::get('frontPageAccounts', []); - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); + $start = session('start', Carbon::now()->startOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); $showTour = Preferences::get('tour', true)->data; $accounts = $repository->getFrontpageAccounts($frontPage); $savings = $repository->getSavingsAccounts(); diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index 682299f4d3..fab1453a10 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -13,7 +13,6 @@ use FireflyIII\Support\CacheProperties; use Input; use Preferences; use Response; -use Session; /** * Class JsonController @@ -24,8 +23,6 @@ class JsonController extends Controller { /** * JsonController constructor. - * - * @codeCoverageIgnore */ public function __construct() { @@ -56,8 +53,8 @@ class JsonController extends Controller */ public function boxBillsPaid(BillRepositoryInterface $repository) { - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); + $start = session('start', Carbon::now()->startOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); bcscale(2); /* @@ -84,8 +81,8 @@ class JsonController extends Controller public function boxBillsUnpaid(BillRepositoryInterface $repository) { bcscale(2); - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); + $start = session('start', Carbon::now()->startOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); $amount = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount. $creditCardDue = $repository->getCreditCardBill($start, $end); @@ -109,8 +106,8 @@ class JsonController extends Controller */ public function boxIn(ReportQueryInterface $reportQuery, ARI $accountRepository) { - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); + $start = session('start', Carbon::now()->startOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); // works for json too! $cache = new CacheProperties; @@ -138,8 +135,8 @@ class JsonController extends Controller */ public function boxOut(ReportQueryInterface $reportQuery, ARI $accountRepository) { - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); + $start = session('start', Carbon::now()->startOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); $accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']); diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 56ea5322ab..56ec30ceac 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -28,7 +28,7 @@ class PiggyBankController extends Controller { /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -48,7 +48,7 @@ class PiggyBankController extends Controller public function add(ARI $repository, PiggyBank $piggyBank) { bcscale(2); - $date = Session::get('end', Carbon::now()->endOfMonth()); + $date = session('end', Carbon::now()->endOfMonth()); $leftOnAccount = $repository->leftOnAccount($piggyBank->account, $date); $savedSoFar = $piggyBank->currentRelevantRep()->currentamount; $leftToSave = bcsub($piggyBank->targetamount, $savedSoFar); @@ -71,7 +71,7 @@ class PiggyBankController extends Controller $subTitleIcon = 'fa-plus'; // put previous url in session if not redirect from store (not "create another"). - if (Session::get('piggy-banks.create.fromStore') !== true) { + if (session('piggy-banks.create.fromStore') !== true) { Session::put('piggy-banks.create.url', URL::previous()); } Session::forget('piggy-banks.create.fromStore'); @@ -112,7 +112,7 @@ class PiggyBankController extends Controller Preferences::mark(); $repository->destroy($piggyBank); - return redirect(Session::get('piggy-banks.delete.url')); + return redirect(session('piggy-banks.delete.url')); } /** @@ -148,7 +148,7 @@ class PiggyBankController extends Controller Session::flash('gaEventAction', 'edit'); // put previous url in session if not redirect from store (not "return_to_edit"). - if (Session::get('piggy-banks.edit.fromUpdate') !== true) { + if (session('piggy-banks.edit.fromUpdate') !== true) { Session::put('piggy-banks.edit.url', URL::previous()); } Session::forget('piggy-banks.edit.fromUpdate'); @@ -166,7 +166,7 @@ class PiggyBankController extends Controller { /** @var Collection $piggyBanks */ $piggyBanks = $piggyRepository->getPiggyBanks(); - $end = Session::get('end', Carbon::now()->endOfMonth()); + $end = session('end', Carbon::now()->endOfMonth()); bcscale(2); $accounts = []; @@ -228,7 +228,7 @@ class PiggyBankController extends Controller { bcscale(2); $amount = round(Input::get('amount'), 2); - $date = Session::get('end', Carbon::now()->endOfMonth()); + $date = session('end', Carbon::now()->endOfMonth()); $leftOnAccount = $accounts->leftOnAccount($piggyBank->account, $date); $savedSoFar = $piggyBank->currentRelevantRep()->currentamount; $leftToSave = bcsub($piggyBank->targetamount, $savedSoFar); @@ -341,7 +341,7 @@ class PiggyBankController extends Controller // redirect to previous URL. - return redirect(Session::get('piggy-banks.create.url')); + return redirect(session('piggy-banks.create.url')); } /** @@ -376,7 +376,7 @@ class PiggyBankController extends Controller // redirect to previous URL. - return redirect(Session::get('piggy-banks.edit.url')); + return redirect(session('piggy-banks.edit.url')); } diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.php index bafd1d793d..22fc883e94 100644 --- a/app/Http/Controllers/RuleController.php +++ b/app/Http/Controllers/RuleController.php @@ -72,7 +72,7 @@ class RuleController extends Controller $subTitle = trans('firefly.make_new_rule', ['title' => $ruleGroup->title]); // put previous url in session if not redirect from store (not "create another"). - if (Session::get('rules.rule.create.fromStore') !== true) { + if (session('rules.rule.create.fromStore') !== true) { Session::put('rules.rule.create.url', URL::previous()); } Session::forget('rules.rule.create.fromStore'); @@ -118,7 +118,7 @@ class RuleController extends Controller Preferences::mark(); - return redirect(Session::get('rules.rule.delete.url')); + return redirect(session('rules.rule.delete.url')); } /** @@ -160,7 +160,7 @@ class RuleController extends Controller $subTitle = trans('firefly.edit_rule', ['title' => $rule->title]); // put previous url in session if not redirect from store (not "return_to_edit"). - if (Session::get('rules.rule.edit.fromUpdate') !== true) { + if (session('rules.rule.edit.fromUpdate') !== true) { Session::put('rules.rule.edit.url', URL::previous()); } Session::forget('rules.rule.edit.fromUpdate'); @@ -274,7 +274,7 @@ class RuleController extends Controller } // redirect to previous URL. - return redirect(Session::get('rules.rule.create.url')); + return redirect(session('rules.rule.create.url')); } @@ -329,7 +329,7 @@ class RuleController extends Controller } // redirect to previous URL. - return redirect(Session::get('rules.rule.edit.url')); + return redirect(session('rules.rule.edit.url')); } private function createDefaultRule() diff --git a/app/Http/Controllers/RuleGroupController.php b/app/Http/Controllers/RuleGroupController.php index 375a42666e..8e436645d8 100644 --- a/app/Http/Controllers/RuleGroupController.php +++ b/app/Http/Controllers/RuleGroupController.php @@ -39,7 +39,7 @@ class RuleGroupController extends Controller $subTitle = trans('firefly.make_new_rule_group'); // put previous url in session if not redirect from store (not "create another"). - if (Session::get('rules.rule-group.create.fromStore') !== true) { + if (session('rules.rule-group.create.fromStore') !== true) { Session::put('rules.rule-group.create.url', URL::previous()); } Session::forget('rules.rule-group.create.fromStore'); @@ -90,7 +90,7 @@ class RuleGroupController extends Controller Preferences::mark(); - return redirect(Session::get('rules.rule-group.delete.url')); + return redirect(session('rules.rule-group.delete.url')); } /** @@ -117,7 +117,7 @@ class RuleGroupController extends Controller $subTitle = trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]); // put previous url in session if not redirect from store (not "return_to_edit"). - if (Session::get('rules.rule-group.edit.fromUpdate') !== true) { + if (session('rules.rule-group.edit.fromUpdate') !== true) { Session::put('rules.rule-group.edit.url', URL::previous()); } Session::forget('rules.rule-group.edit.fromUpdate'); @@ -155,7 +155,7 @@ class RuleGroupController extends Controller } // redirect to previous URL. - return redirect(Session::get('rules.rule-group.create.url')); + return redirect(session('rules.rule-group.create.url')); } /** @@ -200,7 +200,7 @@ class RuleGroupController extends Controller } // redirect to previous URL. - return redirect(Session::get('rules.rule-group.edit.url')); + return redirect(session('rules.rule-group.edit.url')); } diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index bdd0c6bab5..be29b9ec53 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -35,7 +35,7 @@ class TagController extends Controller public $tagOptions = []; /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -66,7 +66,7 @@ class TagController extends Controller Session::flash('preFilled', $preFilled); } // put previous url in session if not redirect from store (not "create another"). - if (Session::get('tags.create.fromStore') !== true) { + if (session('tags.create.fromStore') !== true) { Session::put('tags.create.url', URL::previous()); } Session::forget('tags.create.fromStore'); @@ -144,7 +144,7 @@ class TagController extends Controller // put previous url in session if not redirect from store (not "return_to_edit"). - if (Session::get('tags.edit.fromUpdate') !== true) { + if (session('tags.edit.fromUpdate') !== true) { Session::put('tags.edit.url', URL::previous()); } Session::forget('tags.edit.fromUpdate'); @@ -264,7 +264,7 @@ class TagController extends Controller } // redirect to previous URL. - return redirect(Session::get('tags.create.url')); + return redirect(session('tags.create.url')); } @@ -311,6 +311,6 @@ class TagController extends Controller } // redirect to previous URL. - return redirect(Session::get('tags.edit.url')); + return redirect(session('tags.edit.url')); } } diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 41b0a4975f..e8b92dadba 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -34,7 +34,7 @@ use View; class TransactionController extends Controller { /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -66,7 +66,7 @@ class TransactionController extends Controller $piggies = ExpandedForm::makeSelectList($piggyBanks); $piggies[0] = trans('form.noPiggybank'); - $preFilled = Session::has('preFilled') ? Session::get('preFilled') : []; + $preFilled = Session::has('preFilled') ? session('preFilled') : []; $respondTo = ['account_id', 'account_from_id']; $subTitle = trans('form.add_new_' . $what); @@ -76,7 +76,7 @@ class TransactionController extends Controller Session::put('preFilled', $preFilled); // put previous url in session if not redirect from store (not "create another"). - if (Session::get('transactions.create.fromStore') !== true) { + if (session('transactions.create.fromStore') !== true) { Session::put('transactions.create.url', URL::previous()); } Session::forget('transactions.create.fromStore'); @@ -126,7 +126,7 @@ class TransactionController extends Controller Preferences::mark(); // redirect to previous URL: - return redirect(Session::get('transactions.delete.url')); + return redirect(session('transactions.delete.url')); } /** @@ -196,7 +196,7 @@ class TransactionController extends Controller Session::flash('gaEventAction', 'edit-' . $what); // put previous url in session if not redirect from store (not "return_to_edit"). - if (Session::get('transactions.edit.fromUpdate') !== true) { + if (session('transactions.edit.fromUpdate') !== true) { Session::put('transactions.edit.url', URL::previous()); } Session::forget('transactions.edit.fromUpdate'); @@ -327,7 +327,7 @@ class TransactionController extends Controller } // redirect to previous URL. - return redirect(Session::get('transactions.create.url')); + return redirect(session('transactions.create.url')); } @@ -372,7 +372,7 @@ class TransactionController extends Controller } // redirect to previous URL. - return redirect(Session::get('transactions.edit.url')); + return redirect(session('transactions.edit.url')); } diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 996ba8ca59..ea19ac2dc2 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -18,7 +18,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Collection; use Log; -use Session; use Steam; @@ -225,8 +224,8 @@ class AccountRepository implements AccountRepositoryInterface */ public function getPiggyBankAccounts() { - $start = clone Session::get('start', new Carbon); - $end = clone Session::get('end', new Carbon); + $start = clone session('start', new Carbon); + $end = clone session('end', new Carbon); $collection = new Collection(DB::table('piggy_banks')->distinct()->get(['piggy_banks.account_id'])); $ids = $collection->pluck('account_id')->toArray(); $accounts = new Collection; @@ -273,8 +272,8 @@ class AccountRepository implements AccountRepositoryInterface ->where('accounts.active', 1) ->where('account_meta.data', '"savingAsset"') ->get(['accounts.*']); - $start = clone Session::get('start', new Carbon); - $end = clone Session::get('end', new Carbon); + $start = clone session('start', new Carbon); + $end = clone session('end', new Carbon); bcscale(2); diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index 2fe9edcd3e..302e26aaa6 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -387,7 +387,7 @@ class ExpandedForm protected function fillFieldValue($name, $value) { if (Session::has('preFilled')) { - $preFilled = Session::get('preFilled'); + $preFilled = session('preFilled'); $value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value; } // @codeCoverageIgnoreStart @@ -415,7 +415,7 @@ class ExpandedForm * Get errors from session: */ /** @var MessageBag $errors */ - $errors = Session::get('errors'); + $errors = session('errors'); $classes = 'form-group'; if (!is_null($errors) && $errors->has($name)) { diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index 4534c3f86b..c95751acf8 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -7,7 +7,6 @@ use Config; use FireflyIII\Models\Account; use FireflyIII\Models\Transaction; use Route; -use Session; use Twig_Extension; use Twig_SimpleFilter; use Twig_SimpleFunction; @@ -169,7 +168,7 @@ class General extends Twig_Extension if (is_null($account)) { return 'NULL'; } - $date = Session::get('end', Carbon::now()->endOfMonth()); + $date = session('end', Carbon::now()->endOfMonth()); return app('steam')->balance($account, $date); } From 7343304284d9f86a676ef7e6c234af30fd49b51b Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 07:28:39 +0100 Subject: [PATCH 006/448] Code cleanup. --- .../Csv/Specifix/SpecifixInterface.php | 1 + app/Helpers/Report/BalanceReportHelper.php | 1 - app/Http/Controllers/Auth/AuthController.php | 1 - .../Controllers/Chart/PiggyBankController.php | 2 +- .../Controllers/Chart/ReportController.php | 4 +- .../Controllers/PreferencesController.php | 2 +- app/Http/Controllers/ReportController.php | 163 +++++++++--------- app/Http/Middleware/Authenticate.php | 3 +- app/Http/Requests/AccountFormRequest.php | 2 +- app/Http/Requests/AttachmentFormRequest.php | 2 +- app/Http/Requests/BillFormRequest.php | 2 +- app/Http/Requests/BudgetFormRequest.php | 2 +- app/Http/Requests/CategoryFormRequest.php | 2 +- app/Http/Requests/CurrencyFormRequest.php | 2 +- .../Requests/DeleteAccountFormRequest.php | 2 +- app/Http/Requests/JournalFormRequest.php | 2 +- app/Http/Requests/NewUserFormRequest.php | 2 +- app/Http/Requests/PiggyBankFormRequest.php | 2 +- app/Http/Requests/ProfileFormRequest.php | 2 +- app/Http/Requests/RuleFormRequest.php | 2 +- app/Http/Requests/RuleGroupFormRequest.php | 2 +- app/Http/Requests/TagFormRequest.php | 2 +- app/Models/Component.php | 10 +- app/Models/TransactionJournal.php | 4 +- app/Support/Binder/Date.php | 2 +- 25 files changed, 113 insertions(+), 108 deletions(-) diff --git a/app/Helpers/Csv/Specifix/SpecifixInterface.php b/app/Helpers/Csv/Specifix/SpecifixInterface.php index 34e9a3e833..805df80083 100644 --- a/app/Helpers/Csv/Specifix/SpecifixInterface.php +++ b/app/Helpers/Csv/Specifix/SpecifixInterface.php @@ -10,6 +10,7 @@ interface SpecifixInterface { const PRE_PROCESSOR = 1; const POST_PROCESSOR = 2; + /** * Implement bank and locale related fixes. */ diff --git a/app/Helpers/Report/BalanceReportHelper.php b/app/Helpers/Report/BalanceReportHelper.php index 85d5dc1ef2..ca1451d1a2 100644 --- a/app/Helpers/Report/BalanceReportHelper.php +++ b/app/Helpers/Report/BalanceReportHelper.php @@ -78,7 +78,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface $balance->addBalanceLine($this->createEmptyBalanceLine($accounts, $spentData)); $balance->addBalanceLine($this->createTagsBalanceLine($accounts, $start, $end)); $balance->addBalanceLine($this->createDifferenceBalanceLine($accounts, $spentData, $start, $end)); - $balance->setBalanceHeader($header); return $balance; diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 79c24d30c2..9d430846bb 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -150,7 +150,6 @@ class AuthController extends Controller return redirect($this->redirectPath()); } - // @codeCoverageIgnoreStart abort(500, 'Not a user!'); diff --git a/app/Http/Controllers/Chart/PiggyBankController.php b/app/Http/Controllers/Chart/PiggyBankController.php index b21153bfa9..45f3cf3cd0 100644 --- a/app/Http/Controllers/Chart/PiggyBankController.php +++ b/app/Http/Controllers/Chart/PiggyBankController.php @@ -22,7 +22,7 @@ class PiggyBankController extends Controller protected $generator; /** - * @codeCoverageIgnore + * */ public function __construct() { diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php index c5aba22ad1..43e0928f90 100644 --- a/app/Http/Controllers/Chart/ReportController.php +++ b/app/Http/Controllers/Chart/ReportController.php @@ -22,7 +22,7 @@ class ReportController extends Controller protected $generator; /** - * @codeCoverageIgnore + * */ public function __construct() { @@ -127,6 +127,7 @@ class ReportController extends Controller */ protected function singleYearInOutSummarized(array $earned, array $spent, Carbon $start, Carbon $end) { + bcscale(2); $income = '0'; $expense = '0'; $count = 0; @@ -156,6 +157,7 @@ class ReportController extends Controller */ protected function multiYearInOutSummarized(array $earned, array $spent, Carbon $start, Carbon $end) { + bcscale(2); $income = '0'; $expense = '0'; $count = 0; diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index 5ef8f38630..799facd837 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -16,7 +16,7 @@ class PreferencesController extends Controller { /** - * @codeCoverageIgnore + * */ public function __construct() { diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index c917fef16c..c5640d0b5a 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -5,6 +5,7 @@ use FireflyIII\Helpers\Report\ReportHelperInterface; use FireflyIII\Models\Account; use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI; use Illuminate\Support\Collection; +use Log; use Preferences; use Session; use View; @@ -25,7 +26,7 @@ class ReportController extends Controller protected $helper; /** - * @codeCoverageIgnore + * * * @param ReportHelperInterface $helper */ @@ -43,6 +44,32 @@ class ReportController extends Controller } + /** + * @param ARI $repository + * + * @return View + * @internal param ReportHelperInterface $helper + */ + public function index(ARI $repository) + { + $start = session('first'); + $months = $this->helper->listOfMonths($start); + $customFiscalYear = Preferences::get('customFiscalYear', 0)->data; + + // does the user have shared accounts? + $accounts = $repository->getAccounts(['Default account', 'Asset account']); + // get id's for quick links: + $accountIds = []; + /** @var Account $account */ + foreach ($accounts as $account) { + $accountIds [] = $account->id; + } + $accountList = join(',', $accountIds); + + + return view('reports.index', compact('months', 'accounts', 'start', 'accountList', 'customFiscalYear')); + } + /** * @param $reportType * @param Carbon $start @@ -51,7 +78,59 @@ class ReportController extends Controller * * @return View */ - public function defaultMonth($reportType, Carbon $start, Carbon $end, Collection $accounts) + public function report($reportType, Carbon $start, Carbon $end, Collection $accounts) + { + // throw an error if necessary. + if ($end < $start) { + + return view('error')->with('message', 'End date cannot be before start date, silly!'); + } + + // lower threshold + if ($start < session('first')) { + Log::debug('Start is ' . $start . ' but sessionfirst is ' . session('first')); + $start = session('first'); + } + + switch ($reportType) { + default: + case 'default': + + View::share( + 'subTitle', trans( + 'firefly.report_default', + [ + 'start' => $start->formatLocalized($this->monthFormat), + 'end' => $end->formatLocalized($this->monthFormat), + ] + ) + ); + View::share('subTitleIcon', 'fa-calendar'); + + // more than one year date difference means year report. + if ($start->diffInMonths($end) > 12) { + return $this->defaultMultiYear($reportType, $start, $end, $accounts); + } + // more than two months date difference means year report. + if ($start->diffInMonths($end) > 1) { + return $this->defaultYear($reportType, $start, $end, $accounts); + } + + return $this->defaultMonth($reportType, $start, $end, $accounts); + } + + + } + + /** + * @param $reportType + * @param Carbon $start + * @param Carbon $end + * @param Collection $accounts + * + * @return View + */ + private function defaultMonth($reportType, Carbon $start, Carbon $end, Collection $accounts) { $incomeTopLength = 8; $expenseTopLength = 8; @@ -92,7 +171,7 @@ class ReportController extends Controller * * @return View */ - public function defaultMultiYear($reportType, $start, $end, $accounts) + private function defaultMultiYear($reportType, $start, $end, $accounts) { $incomeTopLength = 8; @@ -129,7 +208,7 @@ class ReportController extends Controller * * @return View */ - public function defaultYear($reportType, Carbon $start, Carbon $end, Collection $accounts) + private function defaultYear($reportType, Carbon $start, Carbon $end, Collection $accounts) { $incomeTopLength = 8; $expenseTopLength = 8; @@ -159,81 +238,5 @@ class ReportController extends Controller ); } - /** - * @param ARI $repository - * - * @return View - * @internal param ReportHelperInterface $helper - */ - public function index(ARI $repository) - { - $start = Session::get('first'); - $months = $this->helper->listOfMonths($start); - $customFiscalYear = Preferences::get('customFiscalYear', 0)->data; - - // does the user have shared accounts? - $accounts = $repository->getAccounts(['Default account', 'Asset account']); - // get id's for quick links: - $accountIds = []; - /** @var Account $account */ - foreach ($accounts as $account) { - $accountIds [] = $account->id; - } - $accountList = join(',', $accountIds); - - - return view('reports.index', compact('months', 'accounts', 'start', 'accountList','customFiscalYear')); - } - - /** - * @param $reportType - * @param Carbon $start - * @param Carbon $end - * @param Collection $accounts - * - * @return View - */ - public function report($reportType, Carbon $start, Carbon $end, Collection $accounts) - { - // throw an error if necessary. - if ($end < $start) { - return view('error')->with('message', 'End date cannot be before start date, silly!'); - } - - // lower threshold - if ($start < Session::get('first')) { - $start = Session::get('first'); - } - - switch ($reportType) { - default: - case 'default': - - View::share( - 'subTitle', trans( - 'firefly.report_default', - [ - 'start' => $start->formatLocalized($this->monthFormat), - 'end' => $end->formatLocalized($this->monthFormat), - ] - ) - ); - View::share('subTitleIcon', 'fa-calendar'); - - // more than one year date difference means year report. - if ($start->diffInMonths($end) > 12) { - return $this->defaultMultiYear($reportType, $start, $end, $accounts); - } - // more than two months date difference means year report. - if ($start->diffInMonths($end) > 1) { - return $this->defaultYear($reportType, $start, $end, $accounts); - } - - return $this->defaultMonth($reportType, $start, $end, $accounts); - } - - - } - } diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index b67cee9d53..16ddd2e939 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -3,8 +3,9 @@ namespace FireflyIII\Http\Middleware; use Closure; -use Illuminate\Support\Facades\Auth; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; + /** * Class Authenticate * diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php index 004336e184..cd2f71e86b 100644 --- a/app/Http/Requests/AccountFormRequest.php +++ b/app/Http/Requests/AccountFormRequest.php @@ -10,7 +10,7 @@ use Input; /** * Class AccountFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class AccountFormRequest extends Request diff --git a/app/Http/Requests/AttachmentFormRequest.php b/app/Http/Requests/AttachmentFormRequest.php index 50a6665591..0dc97519bd 100644 --- a/app/Http/Requests/AttachmentFormRequest.php +++ b/app/Http/Requests/AttachmentFormRequest.php @@ -7,7 +7,7 @@ use Auth; /** * Class AttachmentFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class AttachmentFormRequest extends Request diff --git a/app/Http/Requests/BillFormRequest.php b/app/Http/Requests/BillFormRequest.php index 45de345a75..786997e445 100644 --- a/app/Http/Requests/BillFormRequest.php +++ b/app/Http/Requests/BillFormRequest.php @@ -9,7 +9,7 @@ use Input; /** * Class BillFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class BillFormRequest extends Request diff --git a/app/Http/Requests/BudgetFormRequest.php b/app/Http/Requests/BudgetFormRequest.php index 8d99f5f52a..17330ca7b6 100644 --- a/app/Http/Requests/BudgetFormRequest.php +++ b/app/Http/Requests/BudgetFormRequest.php @@ -9,7 +9,7 @@ use Input; /** * Class BudgetFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class BudgetFormRequest extends Request diff --git a/app/Http/Requests/CategoryFormRequest.php b/app/Http/Requests/CategoryFormRequest.php index 04a16ce9b6..48dfe409b9 100644 --- a/app/Http/Requests/CategoryFormRequest.php +++ b/app/Http/Requests/CategoryFormRequest.php @@ -9,7 +9,7 @@ use Input; /** * Class CategoryFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class CategoryFormRequest extends Request diff --git a/app/Http/Requests/CurrencyFormRequest.php b/app/Http/Requests/CurrencyFormRequest.php index d2de6cfad1..4944df3dee 100644 --- a/app/Http/Requests/CurrencyFormRequest.php +++ b/app/Http/Requests/CurrencyFormRequest.php @@ -8,7 +8,7 @@ use Input; /** * Class BillFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class CurrencyFormRequest extends Request diff --git a/app/Http/Requests/DeleteAccountFormRequest.php b/app/Http/Requests/DeleteAccountFormRequest.php index 895c3d4183..b493095984 100644 --- a/app/Http/Requests/DeleteAccountFormRequest.php +++ b/app/Http/Requests/DeleteAccountFormRequest.php @@ -7,7 +7,7 @@ use Auth; /** * Class DeleteAccountFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class DeleteAccountFormRequest extends Request diff --git a/app/Http/Requests/JournalFormRequest.php b/app/Http/Requests/JournalFormRequest.php index b3377b4a47..0fe499a2a4 100644 --- a/app/Http/Requests/JournalFormRequest.php +++ b/app/Http/Requests/JournalFormRequest.php @@ -11,7 +11,7 @@ use Input; /** * Class JournalFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class JournalFormRequest extends Request diff --git a/app/Http/Requests/NewUserFormRequest.php b/app/Http/Requests/NewUserFormRequest.php index a7fa888e43..6135f4c6f1 100644 --- a/app/Http/Requests/NewUserFormRequest.php +++ b/app/Http/Requests/NewUserFormRequest.php @@ -7,7 +7,7 @@ use Auth; /** * Class NewUserFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class NewUserFormRequest extends Request diff --git a/app/Http/Requests/PiggyBankFormRequest.php b/app/Http/Requests/PiggyBankFormRequest.php index f601fa45f5..b67ee14502 100644 --- a/app/Http/Requests/PiggyBankFormRequest.php +++ b/app/Http/Requests/PiggyBankFormRequest.php @@ -8,7 +8,7 @@ use Input; /** * Class PiggyBankFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class PiggyBankFormRequest extends Request diff --git a/app/Http/Requests/ProfileFormRequest.php b/app/Http/Requests/ProfileFormRequest.php index 932873318b..092f355724 100644 --- a/app/Http/Requests/ProfileFormRequest.php +++ b/app/Http/Requests/ProfileFormRequest.php @@ -7,7 +7,7 @@ use Auth; /** * Class ProfileFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class ProfileFormRequest extends Request diff --git a/app/Http/Requests/RuleFormRequest.php b/app/Http/Requests/RuleFormRequest.php index be60f0e06a..cee59baa52 100644 --- a/app/Http/Requests/RuleFormRequest.php +++ b/app/Http/Requests/RuleFormRequest.php @@ -17,7 +17,7 @@ use Input; /** * Class RuleFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class RuleFormRequest extends Request diff --git a/app/Http/Requests/RuleGroupFormRequest.php b/app/Http/Requests/RuleGroupFormRequest.php index 112a1dcca6..34f9e2a9c7 100644 --- a/app/Http/Requests/RuleGroupFormRequest.php +++ b/app/Http/Requests/RuleGroupFormRequest.php @@ -16,7 +16,7 @@ use Input; /** * Class RuleGroupFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class RuleGroupFormRequest extends Request diff --git a/app/Http/Requests/TagFormRequest.php b/app/Http/Requests/TagFormRequest.php index a4f5da9021..17e46bec51 100644 --- a/app/Http/Requests/TagFormRequest.php +++ b/app/Http/Requests/TagFormRequest.php @@ -8,7 +8,7 @@ use Input; /** * Class TagFormRequest * - * @codeCoverageIgnore + * * @package FireflyIII\Http\Requests */ class TagFormRequest extends Request diff --git a/app/Models/Component.php b/app/Models/Component.php index 52f4dc4ba8..fca471f070 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -5,15 +5,15 @@ use Illuminate\Database\Eloquent\Model; /** * Class Component * - * @property int $transaction_journal_id + * @property int $transaction_journal_id * @package FireflyIII\Models - * @property integer $id + * @property integer $id * @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $deleted_at - * @property string $name - * @property integer $user_id - * @property string $class + * @property string $name + * @property integer $user_id + * @property string $class */ class Component extends Model { diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index dcfd4ab316..25728ed5e3 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -54,8 +54,8 @@ use Watson\Validating\ValidatingTrait; * @method static \Illuminate\Database\Query\Builder|TransactionJournal transactionTypes($types) * @method static \Illuminate\Database\Query\Builder|TransactionJournal withRelevantData() * @property string $type - * @property \Carbon\Carbon $interest_date - * @property \Carbon\Carbon $book_date + * @property \Carbon\Carbon $interest_date + * @property \Carbon\Carbon $book_date */ class TransactionJournal extends Model { diff --git a/app/Support/Binder/Date.php b/app/Support/Binder/Date.php index d2db45ef9e..a6c637500b 100644 --- a/app/Support/Binder/Date.php +++ b/app/Support/Binder/Date.php @@ -11,8 +11,8 @@ namespace FireflyIII\Support\Binder; use Auth; use Carbon\Carbon; -use FireflyIII\Helpers\FiscalHelper; use Exception; +use FireflyIII\Helpers\FiscalHelper; use Log; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; From fb119cc208fd286e4eb905e4d8bc26e213e7c62a Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 07:30:12 +0100 Subject: [PATCH 007/448] Replaced success() with done () --- public/js/budgets.js | 2 +- public/js/charts.js | 10 +++++----- public/js/firefly.js | 2 +- public/js/help.js | 2 +- public/js/index.js | 4 ++-- public/js/piggy-banks/index.js | 2 +- public/js/reports/default/reports.js | 2 +- public/js/rules/create-edit.js | 4 ++-- public/js/transactions/create-edit.js | 10 +++++----- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/public/js/budgets.js b/public/js/budgets.js index 635942d1df..c8ca145734 100644 --- a/public/js/budgets.js +++ b/public/js/budgets.js @@ -62,7 +62,7 @@ function updateBudgetedAmounts(e) { drawBudgetedBar(); // send a post to Firefly to update the amount: - $.post('budgets/amount/' + id, {amount: value, _token: token}).success(function (data) { + $.post('budgets/amount/' + id, {amount: value, _token: token}).done(function (data) { // update the link if relevant: if (data.repetition > 0) { $('.budget-link[data-id="' + id + '"]').attr('href', 'budgets/show/' + id + '/' + data.repetition); diff --git a/public/js/charts.js b/public/js/charts.js index b4ad2736c9..5b3ce5fcc3 100644 --- a/public/js/charts.js +++ b/public/js/charts.js @@ -136,7 +136,7 @@ var defaultStackedColumnOptions = { */ function lineChart(URL, container, options) { "use strict"; - $.getJSON(URL).success(function (data) { + $.getJSON(URL).done(function (data) { var ctx = document.getElementById(container).getContext("2d"); var newData = {}; newData.datasets = []; @@ -170,7 +170,7 @@ function lineChart(URL, container, options) { function areaChart(URL, container, options) { "use strict"; - $.getJSON(URL).success(function (data) { + $.getJSON(URL).done(function (data) { var ctx = document.getElementById(container).getContext("2d"); var newData = {}; newData.datasets = []; @@ -206,7 +206,7 @@ function columnChart(URL, container, options) { options = options || {}; - $.getJSON(URL).success(function (data) { + $.getJSON(URL).done(function (data) { var result = true; if (options.beforeDraw) { @@ -252,7 +252,7 @@ function stackedColumnChart(URL, container, options) { options = options || {}; - $.getJSON(URL).success(function (data) { + $.getJSON(URL).done(function (data) { var result = true; if (options.beforeDraw) { @@ -295,7 +295,7 @@ function stackedColumnChart(URL, container, options) { function pieChart(URL, container, options) { "use strict"; - $.getJSON(URL).success(function (data) { + $.getJSON(URL).done(function (data) { var ctx = document.getElementById(container).getContext("2d"); new Chart(ctx).Pie(data, defaultPieOptions); diff --git a/public/js/firefly.js b/public/js/firefly.js index 019726a578..3130714722 100644 --- a/public/js/firefly.js +++ b/public/js/firefly.js @@ -47,7 +47,7 @@ $(function () { end: end.format('YYYY-MM-DD'), label: label, _token: token - }).success(function () { + }).done(function () { console.log('Succesfully sent new date range.'); window.location.reload(true); }).fail(function () { diff --git a/public/js/help.js b/public/js/help.js index fab1272029..e5d8fc59ae 100644 --- a/public/js/help.js +++ b/public/js/help.js @@ -16,7 +16,7 @@ function showHelp(e) { $('#helpTitle').html('Please hold...'); $('#helpModal').modal('show'); - $.getJSON('help/' + encodeURI(route)).success(function (data) { + $.getJSON('help/' + encodeURI(route)).done(function (data) { $('#helpBody').html(data.text); $('#helpTitle').html(data.title); }).fail(function () { diff --git a/public/js/index.js b/public/js/index.js index 87bae2bf0f..faeed6f099 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -5,7 +5,7 @@ $(function () { // do chart JS stuff. drawChart(); if (showTour) { - $.getJSON('json/tour').success(function (data) { + $.getJSON('json/tour').done(function (data) { var tour = new Tour( { steps: data.steps, @@ -70,7 +70,7 @@ function getBoxAmounts() { var boxes = ['in', 'out', 'bills-unpaid', 'bills-paid']; for (var x in boxes) { var box = boxes[x]; - $.getJSON('json/box/' + box).success(putData).fail(failData); + $.getJSON('json/box/' + box).done(putData).fail(failData); } } diff --git a/public/js/piggy-banks/index.js b/public/js/piggy-banks/index.js index 9c2464df39..9fa00d2375 100644 --- a/public/js/piggy-banks/index.js +++ b/public/js/piggy-banks/index.js @@ -79,7 +79,7 @@ function stopSorting() { var id = holder.data('id'); order.push(id); }); - $.post('/piggy-banks/sort', {_token: token, order: order}).success(function () { + $.post('/piggy-banks/sort', {_token: token, order: order}).done(function () { $('.loadSpin').removeClass('fa fa-refresh fa-spin'); }); } \ No newline at end of file diff --git a/public/js/reports/default/reports.js b/public/js/reports/default/reports.js index 23adac5fcd..8e7721e75b 100644 --- a/public/js/reports/default/reports.js +++ b/public/js/reports/default/reports.js @@ -126,7 +126,7 @@ function openModal(e) { var target = $(e.target).parent(); var URL = target.attr('href'); - $.get(URL).success(function (data) { + $.get(URL).done(function (data) { $('#defaultModal').empty().html(data).modal('show'); }).fail(function () { diff --git a/public/js/rules/create-edit.js b/public/js/rules/create-edit.js index 13c4027f10..3434bcd851 100644 --- a/public/js/rules/create-edit.js +++ b/public/js/rules/create-edit.js @@ -20,7 +20,7 @@ function addNewTrigger() { "use strict"; triggerCount++; - $.getJSON('json/trigger', {count: triggerCount}).success(function (data) { + $.getJSON('json/trigger', {count: triggerCount}).done(function (data) { //console.log(data.html); $('tbody.rule-trigger-tbody').append(data.html); }).fail(function () { @@ -32,7 +32,7 @@ function addNewAction() { "use strict"; actionCount++; - $.getJSON('json/action', {count: actionCount}).success(function (data) { + $.getJSON('json/action', {count: actionCount}).done(function (data) { //console.log(data.html); $('tbody.rule-action-tbody').append(data.html); }).fail(function () { diff --git a/public/js/transactions/create-edit.js b/public/js/transactions/create-edit.js index 974a2b14de..9adef04a04 100644 --- a/public/js/transactions/create-edit.js +++ b/public/js/transactions/create-edit.js @@ -9,13 +9,13 @@ $(document).ready(function () { "use strict"; if ($('input[name="expense_account"]').length > 0) { - $.getJSON('json/expense-accounts').success(function (data) { + $.getJSON('json/expense-accounts').done(function (data) { $('input[name="expense_account"]').typeahead({source: data}); }); } if ($('input[name="tags"]').length > 0) { - $.getJSON('json/tags').success(function (data) { + $.getJSON('json/tags').done(function (data) { var opt = { typeahead: { source: data @@ -28,19 +28,19 @@ $(document).ready(function () { } if ($('input[name="revenue_account"]').length > 0) { - $.getJSON('json/revenue-accounts').success(function (data) { + $.getJSON('json/revenue-accounts').done(function (data) { $('input[name="revenue_account"]').typeahead({source: data}); }); } if ($('input[name="description"]').length > 0 && what !== undefined) { - $.getJSON('json/transaction-journals/' + what).success(function (data) { + $.getJSON('json/transaction-journals/' + what).done(function (data) { $('input[name="description"]').typeahead({source: data}); }); } if ($('input[name="category"]').length > 0) { - $.getJSON('json/categories').success(function (data) { + $.getJSON('json/categories').done(function (data) { $('input[name="category"]').typeahead({source: data}); }); } From 3690a53dc9bb1794c71296361efde52eb952932b Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 07:30:48 +0100 Subject: [PATCH 008/448] expand tests --- tests/TestCase.php | 8 + .../Controllers/AccountControllerTest.php | 6 + .../Controllers/AttachmentControllerTest.php | 5 + .../Controllers/Auth/AuthControllerTest.php | 59 ++------ .../Controllers/BillControllerTest.php | 8 +- .../Controllers/BudgetControllerTest.php | 10 +- .../Controllers/CategoryControllerTest.php | 10 +- .../Chart/ChartAccountControllerTest.php | 1 + .../Chart/ChartBillControllerTest.php | 1 + .../Chart/ChartBudgetControllerTest.php | 1 + .../Chart/ChartCategoryControllerTest.php | 1 + .../Chart/ChartPiggyBankControllerTest.php | 1 + .../Chart/ChartReportControllerTest.php | 1 + .../Controllers/CsvControllerTest.php | 1 + .../Controllers/CurrencyControllerTest.php | 7 + .../Controllers/HelpControllerTest.php | 1 + .../Controllers/HomeControllerTest.php | 1 + .../Controllers/JsonControllerTest.php | 1 + .../Controllers/NewUserControllerTest.php | 9 +- .../Controllers/PiggyBankControllerTest.php | 8 +- .../Controllers/PreferencesControllerTest.php | 27 ++-- .../Controllers/ProfileControllerTest.php | 58 ++++---- .../Controllers/ReportControllerTest.php | 90 ++++++------ .../Controllers/RuleControllerTest.php | 139 +++++++++++------- .../Controllers/RuleGroupControllerTest.php | 88 ++++++----- .../Controllers/SearchControllerTest.php | 9 +- .../Controllers/TagControllerTest.php | 95 ++++++------ .../Controllers/TransactionControllerTest.php | 111 ++++++++------ 28 files changed, 432 insertions(+), 325 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 9ed7149f88..d3bb04192a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -36,6 +36,14 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase return User::find(2); } + /** + * @return User + */ + public function toBeDeletedUser() + { + return User::find(3); + } + /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. diff --git a/tests/acceptance/Controllers/AccountControllerTest.php b/tests/acceptance/Controllers/AccountControllerTest.php index e38518d2f2..bd24e88edf 100644 --- a/tests/acceptance/Controllers/AccountControllerTest.php +++ b/tests/acceptance/Controllers/AccountControllerTest.php @@ -14,6 +14,7 @@ class AccountControllerTest extends TestCase { /** * @covers FireflyIII\Http\Controllers\AccountController::create + * @covers FireflyIII\Http\Controllers\AccountController::__construct */ public function testCreate() { @@ -77,6 +78,9 @@ class AccountControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\AccountController::store + * @covers FireflyIII\Http\Requests\AccountFormRequest::authorize + * @covers FireflyIII\Http\Requests\AccountFormRequest::rules + * */ public function testStore() { @@ -97,6 +101,8 @@ class AccountControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\AccountController::update + * @covers FireflyIII\Http\Requests\AccountFormRequest::authorize + * @covers FireflyIII\Http\Requests\AccountFormRequest::rules */ public function testUpdate() { diff --git a/tests/acceptance/Controllers/AttachmentControllerTest.php b/tests/acceptance/Controllers/AttachmentControllerTest.php index 6ad10b9bb2..7907eae095 100644 --- a/tests/acceptance/Controllers/AttachmentControllerTest.php +++ b/tests/acceptance/Controllers/AttachmentControllerTest.php @@ -15,6 +15,7 @@ class AttachmentControllerTest extends TestCase { /** * @covers FireflyIII\Http\Controllers\AttachmentController::delete + * @covers FireflyIII\Http\Controllers\AttachmentController::__construct */ public function testDelete() { @@ -42,6 +43,8 @@ class AttachmentControllerTest extends TestCase $this->be($this->user()); $this->call('GET', '/attachment/download/1'); $this->assertResponseStatus(200); + // must have certain headers + } /** @@ -66,6 +69,8 @@ class AttachmentControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\AttachmentController::update + * @covers FireflyIII\Http\Requests\AttachmentFormRequest::authorize + * @covers FireflyIII\Http\Requests\AttachmentFormRequest::rules */ public function testUpdate() { diff --git a/tests/acceptance/Controllers/Auth/AuthControllerTest.php b/tests/acceptance/Controllers/Auth/AuthControllerTest.php index 0631aee89f..270c5de364 100644 --- a/tests/acceptance/Controllers/Auth/AuthControllerTest.php +++ b/tests/acceptance/Controllers/Auth/AuthControllerTest.php @@ -13,43 +13,6 @@ class AuthControllerTest extends TestCase { - /** - * @covers FireflyIII\Http\Controllers\Auth\AuthController::getLogin - */ - public function testGetLogin() - { - $this->call('GET', '/login'); - $this->assertResponseStatus(200); - } - - /** - * @covers FireflyIII\Http\Controllers\Auth\AuthController::getLogout - */ - public function testGetLogout() - { - $this->be($this->user()); - $this->call('GET', '/logout'); - $this->assertResponseStatus(302); - } - - /** - * @covers FireflyIII\Http\Controllers\Auth\AuthController::getRegister - */ - public function testGetRegister() - { - $this->call('GET', '/register'); - $this->assertResponseStatus(200); - } - - /** - * @covers FireflyIII\Http\Controllers\Auth\AuthController::login - */ - public function testLogin() - { - $this->call('GET', '/login'); - $this->assertResponseStatus(200); - } - /** * @covers FireflyIII\Http\Controllers\Auth\AuthController::logout */ @@ -62,14 +25,16 @@ class AuthControllerTest extends TestCase // index should now redirect: $this->call('GET', '/'); $this->assertResponseStatus(302); - - } /** - * @covers FireflyIII\Http\Controllers\Auth\AuthController::postLogin + * @covers FireflyIII\Http\Controllers\Auth\AuthController::login + * @covers FireflyIII\Http\Controllers\Auth\AuthController::__construct + * @covers FireflyIII\Http\Controllers\Auth\AuthController::sendFailedLoginResponse + * @covers FireflyIII\Http\Controllers\Auth\AuthController::getFailedLoginMessage + * */ - public function testPostLogin() + public function testLogin() { $args = [ 'email' => 'thegrumpydictator@gmail.com', @@ -86,9 +51,13 @@ class AuthControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\Auth\AuthController::postRegister + * @covers FireflyIII\Http\Controllers\Auth\AuthController::register + * @covers FireflyIII\Http\Controllers\Auth\AuthController::create + * @covers FireflyIII\Http\Controllers\Auth\AuthController::isBlockedDomain + * @covers FireflyIII\Http\Controllers\Auth\AuthController::getBlockedDomains + * @covers FireflyIII\Http\Controllers\Auth\AuthController::validator */ - public function testPostRegister() + public function testRegister() { $args = [ 'email' => 'thegrumpydictator+test@gmail.com', @@ -101,9 +70,9 @@ class AuthControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\Auth\AuthController::register + * @covers FireflyIII\Http\Controllers\Auth\AuthController::showRegistrationForm */ - public function testRegister() + public function testShowRegistrationForm() { $this->call('GET', '/register'); $this->assertResponseStatus(200); diff --git a/tests/acceptance/Controllers/BillControllerTest.php b/tests/acceptance/Controllers/BillControllerTest.php index 9917620b5b..d30195dfec 100644 --- a/tests/acceptance/Controllers/BillControllerTest.php +++ b/tests/acceptance/Controllers/BillControllerTest.php @@ -16,6 +16,7 @@ class BillControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BillController::create + * @covers FireflyIII\Http\Controllers\BillController::__construct */ public function testCreate() { @@ -26,7 +27,6 @@ class BillControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BillController::delete - * @todo Implement testDelete(). */ public function testDelete() { @@ -90,6 +90,9 @@ class BillControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BillController::store + * @covers FireflyIII\Http\Requests\BillFormRequest::authorize + * @covers FireflyIII\Http\Requests\BillFormRequest::getBillData + * @covers FireflyIII\Http\Requests\BillFormRequest::rules */ public function testStore() { @@ -115,6 +118,9 @@ class BillControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BillController::update + * @covers FireflyIII\Http\Requests\BillFormRequest::authorize + * @covers FireflyIII\Http\Requests\BillFormRequest::getBillData + * @covers FireflyIII\Http\Requests\BillFormRequest::rules */ public function testUpdate() { diff --git a/tests/acceptance/Controllers/BudgetControllerTest.php b/tests/acceptance/Controllers/BudgetControllerTest.php index 806805cb0f..defdab45ad 100644 --- a/tests/acceptance/Controllers/BudgetControllerTest.php +++ b/tests/acceptance/Controllers/BudgetControllerTest.php @@ -15,6 +15,7 @@ class BudgetControllerTest extends TestCase { /** * @covers FireflyIII\Http\Controllers\BudgetController::amount + * @covers FireflyIII\Http\Controllers\BudgetController::__construct */ public function testAmount() { @@ -116,13 +117,15 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::store + * @covers FireflyIII\Http\Requests\BudgetFormRequest::authorize + * @covers FireflyIII\Http\Requests\BudgetFormRequest::rules */ public function testStore() { $this->be($this->user()); $this->session(['budgets.create.url' => 'http://localhost']); $args = [ - 'name' => 'Some kind of test budget.', + 'name' => 'Some kind of test budget.', ]; $this->call('POST', '/budgets/store', $args); @@ -132,13 +135,16 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::update + * @covers FireflyIII\Http\Requests\BudgetFormRequest::authorize + * @covers FireflyIII\Http\Requests\BudgetFormRequest::rules */ public function testUpdate() { $this->be($this->user()); $this->session(['budgets.edit.url' => 'http://localhost']); $args = [ - 'name' => 'Some kind of test budget.', + 'name' => 'Some kind of test budget.', + 'id' => 1, ]; $this->call('POST', '/budgets/update/1', $args); diff --git a/tests/acceptance/Controllers/CategoryControllerTest.php b/tests/acceptance/Controllers/CategoryControllerTest.php index 2d2bb291e3..683772eb0b 100644 --- a/tests/acceptance/Controllers/CategoryControllerTest.php +++ b/tests/acceptance/Controllers/CategoryControllerTest.php @@ -16,6 +16,7 @@ class CategoryControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\CategoryController::create + * @covers FireflyIII\Http\Controllers\CategoryController::__construct */ public function testCreate() { @@ -102,13 +103,15 @@ class CategoryControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\CategoryController::store + * @covers FireflyIII\Http\Requests\CategoryFormRequest::authorize + * @covers FireflyIII\Http\Requests\CategoryFormRequest::rules */ public function testStore() { $this->be($this->user()); $this->session(['categories.create.url' => 'http://localhost']); $args = [ - 'name' => 'Some kind of test cat.', + 'name' => 'Some kind of test cat.', ]; $this->call('POST', '/categories/store', $args); @@ -118,13 +121,16 @@ class CategoryControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\CategoryController::update + * @covers FireflyIII\Http\Requests\CategoryFormRequest::authorize + * @covers FireflyIII\Http\Requests\CategoryFormRequest::rules */ public function testUpdate() { $this->be($this->user()); $this->session(['categories.edit.url' => 'http://localhost']); $args = [ - 'name' => 'Some kind of test category.', + 'name' => 'Some kind of test category.', + 'id' => 1, ]; $this->call('POST', '/categories/update/1', $args); diff --git a/tests/acceptance/Controllers/Chart/ChartAccountControllerTest.php b/tests/acceptance/Controllers/Chart/ChartAccountControllerTest.php index 4f02f165f8..6956629e10 100644 --- a/tests/acceptance/Controllers/Chart/ChartAccountControllerTest.php +++ b/tests/acceptance/Controllers/Chart/ChartAccountControllerTest.php @@ -14,6 +14,7 @@ class ChartAccountControllerTest extends TestCase { /** * @covers FireflyIII\Http\Controllers\Chart\AccountController::expenseAccounts + * @covers FireflyIII\Http\Controllers\Chart\AccountController::__construct */ public function testExpenseAccounts() { diff --git a/tests/acceptance/Controllers/Chart/ChartBillControllerTest.php b/tests/acceptance/Controllers/Chart/ChartBillControllerTest.php index 97fb4704eb..b361bd8834 100644 --- a/tests/acceptance/Controllers/Chart/ChartBillControllerTest.php +++ b/tests/acceptance/Controllers/Chart/ChartBillControllerTest.php @@ -15,6 +15,7 @@ class ChartBillControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\Chart\BillController::frontpage + * @covers FireflyIII\Http\Controllers\Chart\BillController::__construct */ public function testFrontpage() { diff --git a/tests/acceptance/Controllers/Chart/ChartBudgetControllerTest.php b/tests/acceptance/Controllers/Chart/ChartBudgetControllerTest.php index ab8cc339ee..ccdda57dd5 100644 --- a/tests/acceptance/Controllers/Chart/ChartBudgetControllerTest.php +++ b/tests/acceptance/Controllers/Chart/ChartBudgetControllerTest.php @@ -18,6 +18,7 @@ class ChartBudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\Chart\BudgetController::budget + * @covers FireflyIII\Http\Controllers\Chart\BudgetController::__construct */ public function testBudget() { diff --git a/tests/acceptance/Controllers/Chart/ChartCategoryControllerTest.php b/tests/acceptance/Controllers/Chart/ChartCategoryControllerTest.php index 0a6ccb44b0..7c8ebc3ebb 100644 --- a/tests/acceptance/Controllers/Chart/ChartCategoryControllerTest.php +++ b/tests/acceptance/Controllers/Chart/ChartCategoryControllerTest.php @@ -16,6 +16,7 @@ class ChartCategoryControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\Chart\CategoryController::all + * @covers FireflyIII\Http\Controllers\Chart\CategoryController::__construct */ public function testAll() { diff --git a/tests/acceptance/Controllers/Chart/ChartPiggyBankControllerTest.php b/tests/acceptance/Controllers/Chart/ChartPiggyBankControllerTest.php index ce3ae5beba..861f901ddb 100644 --- a/tests/acceptance/Controllers/Chart/ChartPiggyBankControllerTest.php +++ b/tests/acceptance/Controllers/Chart/ChartPiggyBankControllerTest.php @@ -15,6 +15,7 @@ class ChartPiggyBankControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\Chart\PiggyBankController::history + * @covers FireflyIII\Http\Controllers\Chart\PiggyBankController::__construct */ public function testHistory() { diff --git a/tests/acceptance/Controllers/Chart/ChartReportControllerTest.php b/tests/acceptance/Controllers/Chart/ChartReportControllerTest.php index 93fdba8cd1..6a36e48337 100644 --- a/tests/acceptance/Controllers/Chart/ChartReportControllerTest.php +++ b/tests/acceptance/Controllers/Chart/ChartReportControllerTest.php @@ -14,6 +14,7 @@ class ChartReportControllerTest extends TestCase { /** * @covers FireflyIII\Http\Controllers\Chart\ReportController::yearInOut + * @covers FireflyIII\Http\Controllers\Chart\ReportController::__construct */ public function testYearInOut() { diff --git a/tests/acceptance/Controllers/CsvControllerTest.php b/tests/acceptance/Controllers/CsvControllerTest.php index 9b46be9a58..ba7b6adf67 100644 --- a/tests/acceptance/Controllers/CsvControllerTest.php +++ b/tests/acceptance/Controllers/CsvControllerTest.php @@ -16,6 +16,7 @@ class CsvControllerTest extends TestCase { /** * @covers FireflyIII\Http\Controllers\CsvController::columnRoles + * @covers FireflyIII\Http\Controllers\CsvController::__construct */ public function testColumnRoles() { diff --git a/tests/acceptance/Controllers/CurrencyControllerTest.php b/tests/acceptance/Controllers/CurrencyControllerTest.php index eafd8d193e..ec4ce59ebd 100644 --- a/tests/acceptance/Controllers/CurrencyControllerTest.php +++ b/tests/acceptance/Controllers/CurrencyControllerTest.php @@ -16,6 +16,7 @@ class CurrencyControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\CurrencyController::create + * @covers FireflyIII\Http\Controllers\CurrencyController::__construct */ public function testCreate() { @@ -82,6 +83,9 @@ class CurrencyControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\CurrencyController::store + * @covers FireflyIII\Http\Requests\CurrencyFormRequest::authorize + * @covers FireflyIII\Http\Requests\CurrencyFormRequest::rules + * @covers FireflyIII\Http\Requests\CurrencyFormRequest::getCurrencyData */ public function testStore() { @@ -101,6 +105,9 @@ class CurrencyControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\CurrencyController::update + * @covers FireflyIII\Http\Requests\CurrencyFormRequest::authorize + * @covers FireflyIII\Http\Requests\CurrencyFormRequest::rules + * @covers FireflyIII\Http\Requests\CurrencyFormRequest::getCurrencyData */ public function testUpdate() { diff --git a/tests/acceptance/Controllers/HelpControllerTest.php b/tests/acceptance/Controllers/HelpControllerTest.php index e327a9f57f..aa44217e2a 100644 --- a/tests/acceptance/Controllers/HelpControllerTest.php +++ b/tests/acceptance/Controllers/HelpControllerTest.php @@ -16,6 +16,7 @@ class HelpControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\HelpController::show + * @covers FireflyIII\Http\Controllers\HelpController::__construct */ public function testShow() { diff --git a/tests/acceptance/Controllers/HomeControllerTest.php b/tests/acceptance/Controllers/HomeControllerTest.php index ba2d8cc4c6..299edd8274 100644 --- a/tests/acceptance/Controllers/HomeControllerTest.php +++ b/tests/acceptance/Controllers/HomeControllerTest.php @@ -11,6 +11,7 @@ class HomeControllerTest extends TestCase { /** * @covers FireflyIII\Http\Controllers\HomeController::dateRange + * @covers FireflyIII\Http\Controllers\HomeController::__construct */ public function testDateRange() { diff --git a/tests/acceptance/Controllers/JsonControllerTest.php b/tests/acceptance/Controllers/JsonControllerTest.php index e8ba9f8c16..7454260e70 100644 --- a/tests/acceptance/Controllers/JsonControllerTest.php +++ b/tests/acceptance/Controllers/JsonControllerTest.php @@ -17,6 +17,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::action + * @covers FireflyIII\Http\Controllers\JsonController::__construct */ public function testAction() { diff --git a/tests/acceptance/Controllers/NewUserControllerTest.php b/tests/acceptance/Controllers/NewUserControllerTest.php index 01841352f4..5563c8c92b 100644 --- a/tests/acceptance/Controllers/NewUserControllerTest.php +++ b/tests/acceptance/Controllers/NewUserControllerTest.php @@ -16,6 +16,7 @@ class NewUserControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\NewUserController::index + * @covers FireflyIII\Http\Controllers\NewUserController::__construct */ public function testIndex() { @@ -37,14 +38,18 @@ class NewUserControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\NewUserController::submit + * @covers FireflyIII\Http\Requests\NewUserFormRequest::authorize + * @covers FireflyIII\Http\Requests\NewUserFormRequest::rules */ public function testSubmit() { $this->be($this->emptyUser()); $args = [ - 'bank_name' => 'New bank', - 'bank_balance' => 100, + 'bank_name' => 'New bank', + 'bank_balance' => 100, + 'savings_balance' => 200, + 'credit_card_limit' => 1000, ]; $this->call('POST', '/new-user/submit', $args); diff --git a/tests/acceptance/Controllers/PiggyBankControllerTest.php b/tests/acceptance/Controllers/PiggyBankControllerTest.php index 2ab8691f3d..611d205b2f 100644 --- a/tests/acceptance/Controllers/PiggyBankControllerTest.php +++ b/tests/acceptance/Controllers/PiggyBankControllerTest.php @@ -15,6 +15,7 @@ class PiggyBankControllerTest extends TestCase { /** * @covers FireflyIII\Http\Controllers\PiggyBankController::add + * @covers FireflyIII\Http\Controllers\PiggyBankController::__construct */ public function testAdd() { @@ -35,7 +36,6 @@ class PiggyBankControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PiggyBankController::delete - * @todo Implement testDelete(). */ public function testDelete() { @@ -93,7 +93,6 @@ class PiggyBankControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PiggyBankController::postAdd - * @todo Implement testPostAdd(). */ public function testPostAdd() { @@ -144,6 +143,8 @@ class PiggyBankControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PiggyBankController::store + * @covers FireflyIII\Http\Requests\PiggyBankFormRequest::authorize + * @covers FireflyIII\Http\Requests\PiggyBankFormRequest::rules */ public function testStore() { @@ -163,6 +164,8 @@ class PiggyBankControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PiggyBankController::update + * @covers FireflyIII\Http\Requests\PiggyBankFormRequest::authorize + * @covers FireflyIII\Http\Requests\PiggyBankFormRequest::rules */ public function testUpdate() { @@ -173,6 +176,7 @@ class PiggyBankControllerTest extends TestCase 'name' => 'Updated', 'targetamount' => 100, 'account_id' => 2, + 'id' => 1, ]; $this->call('POST', '/piggy-banks/update/1', $args); diff --git a/tests/acceptance/Controllers/PreferencesControllerTest.php b/tests/acceptance/Controllers/PreferencesControllerTest.php index 4fbf98a051..3b29a397e5 100644 --- a/tests/acceptance/Controllers/PreferencesControllerTest.php +++ b/tests/acceptance/Controllers/PreferencesControllerTest.php @@ -16,25 +16,32 @@ class PreferencesControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PreferencesController::index - * @todo Implement testIndex(). + * @covers FireflyIII\Http\Controllers\PreferencesController::__construct */ public function testIndex() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/preferences'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\PreferencesController::postIndex - * @todo Implement testPostIndex(). */ public function testPostIndex() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $args = [ + 'frontPageAccounts' => [1], + 'viewRange' => '1M', + 'budgetMaximum' => 100, + 'customFiscalYear' => 1, + 'fiscalYearStart' => '01-01', + 'language' => 'en_US', + ]; + + $this->be($this->user()); + $this->call('POST', '/preferences', $args); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } } diff --git a/tests/acceptance/Controllers/ProfileControllerTest.php b/tests/acceptance/Controllers/ProfileControllerTest.php index ffdf216572..38f7799e93 100644 --- a/tests/acceptance/Controllers/ProfileControllerTest.php +++ b/tests/acceptance/Controllers/ProfileControllerTest.php @@ -15,61 +15,69 @@ class ProfileControllerTest extends TestCase { /** * @covers FireflyIII\Http\Controllers\ProfileController::changePassword - * @todo Implement testChangePassword(). + * @covers FireflyIII\Http\Controllers\ProfileController::__construct */ public function testChangePassword() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/profile/change-password'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\ProfileController::deleteAccount - * @todo Implement testDeleteAccount(). */ public function testDeleteAccount() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + + $this->be($this->user()); + $this->call('GET', '/profile/delete-account'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\ProfileController::index - * @todo Implement testIndex(). */ public function testIndex() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/profile'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\ProfileController::postChangePassword - * @todo Implement testPostChangePassword(). + * @covers FireflyIII\Http\Requests\ProfileFormRequest::authorize + * @covers FireflyIII\Http\Requests\ProfileFormRequest::rules */ public function testPostChangePassword() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $args = [ + 'current_password' => 'james', + 'new_password' => 'sander', + 'new_password_confirmation' => 'sander', + ]; + $this->be($this->user()); + $this->call('POST', '/profile/change-password', $args); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } /** * @covers FireflyIII\Http\Controllers\ProfileController::postDeleteAccount - * @todo Implement testPostDeleteAccount(). + * @covers FireflyIII\Http\Requests\DeleteAccountFormRequest::authorize + * @covers FireflyIII\Http\Requests\DeleteAccountFormRequest::rules */ public function testPostDeleteAccount() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $args = [ + 'password' => 'james', + ]; + + $this->be($this->toBeDeletedUser()); + $this->call('POST', '/profile/delete-account', $args); + $this->assertResponseStatus(302); + $this->assertRedirectedToRoute('index'); + $this->assertNull(DB::table('users')->find(3)); } } diff --git a/tests/acceptance/Controllers/ReportControllerTest.php b/tests/acceptance/Controllers/ReportControllerTest.php index 641f7def38..36841ab232 100644 --- a/tests/acceptance/Controllers/ReportControllerTest.php +++ b/tests/acceptance/Controllers/ReportControllerTest.php @@ -7,69 +7,67 @@ * of the MIT license. See the LICENSE file for details. */ +use FireflyIII\Helpers\Collection\Bill as BillCollection; +use FireflyIII\Helpers\Collection\Category as CategoryCollection; +use FireflyIII\Helpers\Collection\Expense; +use FireflyIII\Helpers\Collection\Income; /** * Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28. */ class ReportControllerTest extends TestCase { - /** - * @covers FireflyIII\Http\Controllers\ReportController::defaultMonth - * @todo Implement testDefaultMonth(). - */ - public function testDefaultMonth() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers FireflyIII\Http\Controllers\ReportController::defaultMultiYear - * @todo Implement testDefaultMultiYear(). - */ - public function testDefaultMultiYear() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers FireflyIII\Http\Controllers\ReportController::defaultYear - * @todo Implement testDefaultYear(). - */ - public function testDefaultYear() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } /** * @covers FireflyIII\Http\Controllers\ReportController::index - * @todo Implement testIndex(). */ public function testIndex() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/reports'); + $this->assertResponseStatus(200); + + } + + /** + * @covers FireflyIII\Http\Controllers\ReportController::__construct + * @covers FireflyIII\Http\Controllers\ReportController::report + * @covers FireflyIII\Http\Controllers\ReportController::defaultMonth + */ + public function testReportDefaultMonth() + { + // mock some stuff. + $repository = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface'); + $repository->shouldReceive('getCategoryReport')->once()->andReturn(new CategoryCollection); + $repository->shouldReceive('getIncomeReport')->once()->andReturn(new Income); + $repository->shouldReceive('getExpenseReport')->once()->andReturn(new Expense); + $repository->shouldReceive('getBillReport')->once()->andReturn(new BillCollection); + + + $this->be($this->user()); + $this->call('GET', '/reports/report/default/20160101/20160131/1,2'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\ReportController::report - * @todo Implement testReport(). + * @covers FireflyIII\Http\Controllers\ReportController::defaultYear */ - public function testReport() + public function testReportDefaultYear() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/reports/report/default/20160101/20161231/1,2'); + $this->assertResponseStatus(200); + } + + /** + * @covers FireflyIII\Http\Controllers\ReportController::report + * @covers FireflyIII\Http\Controllers\ReportController::defaultMultiYear + */ + public function testReportDefaultMultiYear() + { + $this->be($this->user()); + $this->call('GET', '/reports/report/default/20160101/20171231/1,2'); + $this->assertResponseStatus(200); } } diff --git a/tests/acceptance/Controllers/RuleControllerTest.php b/tests/acceptance/Controllers/RuleControllerTest.php index b33352c035..ab8ed0a935 100644 --- a/tests/acceptance/Controllers/RuleControllerTest.php +++ b/tests/acceptance/Controllers/RuleControllerTest.php @@ -15,134 +15,163 @@ class RuleControllerTest extends TestCase { /** + * @covers FireflyIII\Http\Controllers\RuleController::__construct * @covers FireflyIII\Http\Controllers\RuleController::create - * @todo Implement testCreate(). */ public function testCreate() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/rules/create/1'); + $this->assertResponseStatus(200); + } /** * @covers FireflyIII\Http\Controllers\RuleController::delete - * @todo Implement testDelete(). */ public function testDelete() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/rules/rules/delete/1'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\RuleController::destroy - * @todo Implement testDestroy(). */ public function testDestroy() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->session(['rules.rule.delete.url' => 'http://localhost']); + + $this->be($this->user()); + $this->call('POST', '/rules/destroy/1'); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } /** * @covers FireflyIII\Http\Controllers\RuleController::down - * @todo Implement testDown(). */ public function testDown() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/rules/rules/down/1'); + $this->assertResponseStatus(302); } /** * @covers FireflyIII\Http\Controllers\RuleController::edit - * @todo Implement testEdit(). + * @covers FireflyIII\Http\Controllers\RuleController::getCurrentTriggers + * @covers FireflyIII\Http\Controllers\RuleController::getCurrentActions */ public function testEdit() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/rules/rules/edit/1'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\RuleController::index - * @todo Implement testIndex(). + * @covers FireflyIII\Http\Controllers\RuleController::createDefaultRuleGroup + * @covers FireflyIII\Http\Controllers\RuleController::createDefaultRule */ public function testIndex() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/rules'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\RuleController::reorderRuleActions - * @todo Implement testReorderRuleActions(). */ public function testReorderRuleActions() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $args = ['actions' => [1, 2, 3]]; + $this->call('POST', '/rules/rules/action/reorder/1', $args); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\RuleController::reorderRuleTriggers - * @todo Implement testReorderRuleTriggers(). */ public function testReorderRuleTriggers() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $args = ['actions' => [1, 2]]; + $this->call('POST', '/rules/rules/trigger/reorder/1', $args); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\RuleController::store - * @todo Implement testStore(). + * @covers FireflyIII\Http\Requests\RuleFormRequest::authorize + * @covers FireflyIII\Http\Requests\RuleFormRequest::rules */ public function testStore() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->session(['rules.rule.create.url' => 'http://localhost']); + $this->be($this->user()); + $args = [ + 'rule_group_id' => 1, + 'title' => 'Some new rule', + 'user_id' => 1, + 'trigger' => 'store-journal', + 'description' => 'Some new rule', + 'rule-trigger' => ['description_is'], + 'rule-trigger-value' => ['something'], + 'rule-trigger-stop' => [], + 'rule-action' => ['set_category'], + 'rule-action-value' => ['something'], + 'rule-action-stop' => [], + 'stop_processing' => 0, + ]; + $this->call('POST', '/rules/store/1', $args); + + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } /** * @covers FireflyIII\Http\Controllers\RuleController::up - * @todo Implement testUp(). */ public function testUp() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + + $this->be($this->user()); + $this->call('GET', '/rules/rules/up/1'); + $this->assertResponseStatus(302); } /** * @covers FireflyIII\Http\Controllers\RuleController::update - * @todo Implement testUpdate(). + * @covers FireflyIII\Http\Requests\RuleFormRequest::authorize + * @covers FireflyIII\Http\Requests\RuleFormRequest::rules */ public function testUpdate() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->session(['rules.rule.edit.url' => 'http://localhost']); + + $this->be($this->user()); + $args = [ + 'title' => 'Some new rule update', + 'rule_group_id' => 1, + 'id' => 1, + 'active' => 1, + 'trigger' => 'store-journal', + 'description' => 'Some new rule', + 'rule-trigger' => ['description_is'], + 'rule-trigger-value' => ['something'], + 'rule-trigger-stop' => [], + 'rule-action' => ['set_category'], + 'rule-action-value' => ['something'], + 'rule-action-stop' => [], + 'stop_processing' => 0, + ]; + $this->call('POST', '/rules/update/1', $args); + $this->assertSessionHas('success'); + $this->assertResponseStatus(302); } } diff --git a/tests/acceptance/Controllers/RuleGroupControllerTest.php b/tests/acceptance/Controllers/RuleGroupControllerTest.php index f23e52417c..838b110815 100644 --- a/tests/acceptance/Controllers/RuleGroupControllerTest.php +++ b/tests/acceptance/Controllers/RuleGroupControllerTest.php @@ -16,97 +16,105 @@ class RuleGroupControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\RuleGroupController::create - * @todo Implement testCreate(). + * @covers FireflyIII\Http\Controllers\RuleGroupController::__construct */ public function testCreate() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/rules/groups/create'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\RuleGroupController::delete - * @todo Implement testDelete(). */ public function testDelete() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/rules/groups/delete/1'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\RuleGroupController::destroy - * @todo Implement testDestroy(). */ public function testDestroy() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->session(['rules.rule-group.delete.url' => 'http://localhost']); + + $this->be($this->user()); + $this->call('POST', '/rules/groups/destroy/1'); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } /** * @covers FireflyIII\Http\Controllers\RuleGroupController::down - * @todo Implement testDown(). */ public function testDown() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/rules/groups/down/1'); + $this->assertResponseStatus(302); } /** * @covers FireflyIII\Http\Controllers\RuleGroupController::edit - * @todo Implement testEdit(). */ public function testEdit() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/rules/groups/edit/1'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\RuleGroupController::store - * @todo Implement testStore(). + * @covers FireflyIII\Http\Requests\RuleGroupFormRequest::authorize + * @covers FireflyIII\Http\Requests\RuleGroupFormRequest::rules */ public function testStore() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->session(['rules.rule-group.create.url' => 'http://localhost']); + $args = [ + 'title' => 'Some new rule group', + 'description' => 'New rules', + ]; + + $this->be($this->user()); + $this->call('POST', '/rules/groups/store', $args); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } /** * @covers FireflyIII\Http\Controllers\RuleGroupController::up - * @todo Implement testUp(). */ public function testUp() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/rules/groups/up/1'); + $this->assertResponseStatus(302); } /** * @covers FireflyIII\Http\Controllers\RuleGroupController::update - * @todo Implement testUpdate(). + * @covers FireflyIII\Http\Requests\RuleGroupFormRequest::authorize + * @covers FireflyIII\Http\Requests\RuleGroupFormRequest::rules */ public function testUpdate() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->session(['rules.rule-group.edit.url' => 'http://localhost']); + $args = [ + 'id' => 1, + 'title' => 'Some new rule group X', + 'description' => 'New rules', + 'active' => 1, + ]; + + $this->be($this->user()); + $this->call('POST', '/rules/groups/update/1', $args); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } } diff --git a/tests/acceptance/Controllers/SearchControllerTest.php b/tests/acceptance/Controllers/SearchControllerTest.php index 70f44bc0bc..0d9838e37c 100644 --- a/tests/acceptance/Controllers/SearchControllerTest.php +++ b/tests/acceptance/Controllers/SearchControllerTest.php @@ -14,14 +14,13 @@ class SearchControllerTest extends TestCase { /** + * @covers FireflyIII\Http\Controllers\SearchController::__construct * @covers FireflyIII\Http\Controllers\SearchController::index - * @todo Implement testIndex(). */ public function testIndex() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/search?q=test&search='); + $this->assertResponseStatus(200); } } diff --git a/tests/acceptance/Controllers/TagControllerTest.php b/tests/acceptance/Controllers/TagControllerTest.php index 8aa3cad951..d323a08669 100644 --- a/tests/acceptance/Controllers/TagControllerTest.php +++ b/tests/acceptance/Controllers/TagControllerTest.php @@ -15,110 +15,115 @@ class TagControllerTest extends TestCase { /** + * @covers FireflyIII\Http\Controllers\TagController::__construct * @covers FireflyIII\Http\Controllers\TagController::create - * @todo Implement testCreate(). */ public function testCreate() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/tags/create'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\TagController::delete - * @todo Implement testDelete(). */ public function testDelete() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/tags/delete/1'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\TagController::destroy - * @todo Implement testDestroy(). */ public function testDestroy() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('POST', '/tags/destroy/1'); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } /** * @covers FireflyIII\Http\Controllers\TagController::edit - * @todo Implement testEdit(). */ public function testEdit() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/tags/edit/1'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\TagController::hideTagHelp - * @todo Implement testHideTagHelp(). */ public function testHideTagHelp() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('POST', '/tags/hideTagHelp/true'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\TagController::index - * @todo Implement testIndex(). */ public function testIndex() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/tags'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\TagController::show - * @todo Implement testShow(). */ public function testShow() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/tags/show/1'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\TagController::store - * @todo Implement testStore(). + * @covers FireflyIII\Http\Requests\TagFormRequest::authorize + * @covers FireflyIII\Http\Requests\TagFormRequest::rules */ public function testStore() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $args = [ + 'tag' => 'Some new tag', + 'tagMode' => 'nothing', + ]; + + $this->session(['tags.create.url' => 'http://localhost']); + + $this->be($this->user()); + $this->call('POST', '/tags/store', $args); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } /** * @covers FireflyIII\Http\Controllers\TagController::update - * @todo Implement testUpdate(). + * @covers FireflyIII\Http\Requests\TagFormRequest::authorize + * @covers FireflyIII\Http\Requests\TagFormRequest::rules */ public function testUpdate() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $args = [ + 'tag' => 'Some new tag yay', + 'id' => 1, + 'tagMode' => 'nothing', + ]; + + $this->session(['tags.edit.url' => 'http://localhost']); + + $this->be($this->user()); + $this->call('POST', '/tags/update/1', $args); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } } diff --git a/tests/acceptance/Controllers/TransactionControllerTest.php b/tests/acceptance/Controllers/TransactionControllerTest.php index 937acaccb8..0d71d0134a 100644 --- a/tests/acceptance/Controllers/TransactionControllerTest.php +++ b/tests/acceptance/Controllers/TransactionControllerTest.php @@ -16,109 +16,130 @@ class TransactionControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\TransactionController::create - * @todo Implement testCreate(). + * @covers FireflyIII\Http\Controllers\TransactionController::__construct */ public function testCreate() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/transactions/create/withdrawal'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\TransactionController::delete - * @todo Implement testDelete(). */ public function testDelete() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/transaction/delete/1'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\TransactionController::destroy - * @todo Implement testDestroy(). */ public function testDestroy() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->session(['transactions.delete.url' => 'http://localhost']); + + $this->be($this->user()); + $this->call('POST', '/transaction/destroy/1'); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } /** * @covers FireflyIII\Http\Controllers\TransactionController::edit - * @todo Implement testEdit(). */ public function testEdit() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/transaction/edit/1'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\TransactionController::index - * @todo Implement testIndex(). */ public function testIndex() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/transactions/deposit'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\TransactionController::reorder - * @todo Implement testReorder(). */ public function testReorder() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $args = [ + 'ids' => [1], + 'date' => '2015-01-01', + ]; + $this->be($this->user()); + $this->call('POST', '/transaction/reorder', $args); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\TransactionController::show - * @todo Implement testShow(). */ public function testShow() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('GET', '/transaction/show/1'); + $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\TransactionController::store - * @todo Implement testStore(). + * @covers FireflyIII\Http\Requests\JournalFormRequest::authorize + * @covers FireflyIII\Http\Requests\JournalFormRequest::rules + * @covers FireflyIII\Http\Requests\JournalFormRequest::getJournalData */ public function testStore() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->session(['transactions.create.url' => 'http://localhost']); + + $args = [ + 'what' => 'withdrawal', + 'description' => 'Something', + 'account_id' => '1', + 'expense_account' => 'Some expense', + 'amount' => 100, + 'amount_currency_id_amount' => 1, + 'date' => '2015-01-01', + ]; + $this->be($this->user()); + $this->call('POST', '/transactions/store/withdrawal', $args); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } /** * @covers FireflyIII\Http\Controllers\TransactionController::update - * @todo Implement testUpdate(). + * @covers FireflyIII\Http\Requests\JournalFormRequest::authorize + * @covers FireflyIII\Http\Requests\JournalFormRequest::rules + * @covers FireflyIII\Http\Requests\JournalFormRequest::getJournalData */ public function testUpdate() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->session(['transactions.edit.url' => 'http://localhost']); + + $args = [ + 'what' => 'withdrawal', + 'id' => 2, + 'description' => 'Something new', + 'account_id' => '1', + 'expense_account' => 'Some expense', + 'amount' => 100, + 'amount_currency_id_amount' => 1, + 'date' => '2015-01-01', + ]; + $this->be($this->user()); + $this->call('POST', '/transaction/update/1', $args); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); } } From 5c3165efa232967ace30bf6ad54d1608ec05feb0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 08:52:54 +0100 Subject: [PATCH 009/448] Site is gone. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 43bdb2df8d..9145983c08 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ [![Build Status](https://scrutinizer-ci.com/g/JC5/firefly-iii/badges/build.png?b=master)](https://scrutinizer-ci.com/g/JC5/firefly-iii/build-status/master) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/d44c7012-5f50-41ad-add8-8445330e4102/mini.png)](https://insight.sensiolabs.com/projects/d44c7012-5f50-41ad-add8-8445330e4102) [![Code Climate](https://codeclimate.com/github/JC5/firefly-iii/badges/gpa.svg)](https://codeclimate.com/github/JC5/firefly-iii) -[![Project Status](http://stillmaintained.com/JC5/firefly-iii.png?a=b)](http://stillmaintained.com/JC5/firefly-iii) ## About From 55e4875662d210d2455c65b0623e51f09064b343 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 08:53:15 +0100 Subject: [PATCH 010/448] New method to collect a users accounts by the given ids. --- app/Repositories/Account/AccountRepository.php | 16 +++++++++++++--- .../Account/AccountRepositoryInterface.php | 10 ++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index ea19ac2dc2..38bf2f0caa 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -72,6 +72,18 @@ class AccountRepository implements AccountRepositoryInterface return Auth::user()->accounts()->findOrNew($accountId); } + /** + * Gets all the accounts by ID, for a given set. + * + * @param array $ids + * + * @return Collection + */ + public function get(array $ids) + { + return Auth::user()->accounts()->whereIn('id', $ids)->get(['accounts.*']); + } + /** * @param array $types * @@ -464,9 +476,7 @@ class AccountRepository implements AccountRepositoryInterface if (!$existingAccount) { Log::error('Account create error: ' . $newAccount->getErrors()->toJson()); abort(500); - // @codeCoverageIgnoreStart } - // @codeCoverageIgnoreEnd $newAccount = $existingAccount; } @@ -554,7 +564,7 @@ class AccountRepository implements AccountRepositoryInterface { $journal->date = $data['openingBalanceDate']; $journal->save(); - + /** @var Transaction $transaction */ foreach ($journal->transactions()->get() as $transaction) { if ($account->id == $transaction->account_id) { diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php index 628aca2d15..9b10c383c7 100644 --- a/app/Repositories/Account/AccountRepositoryInterface.php +++ b/app/Repositories/Account/AccountRepositoryInterface.php @@ -17,6 +17,7 @@ use Illuminate\Support\Collection; */ interface AccountRepositoryInterface { + /** * @param array $types * @@ -41,6 +42,15 @@ interface AccountRepositoryInterface */ public function find($accountId); + /** + * Gets all the accounts by ID, for a given set. + * + * @param array $ids + * + * @return Collection + */ + public function get(array $ids); + /** * @param array $types * From 15104de84c31a9975ea2027b800850c4c6ebbf91 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 08:53:56 +0100 Subject: [PATCH 011/448] This should clean up the monthly report a bit. See issue #159 --- app/Helpers/Report/BudgetReportHelper.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/Helpers/Report/BudgetReportHelper.php b/app/Helpers/Report/BudgetReportHelper.php index ac34fef3ce..3191a36665 100644 --- a/app/Helpers/Report/BudgetReportHelper.php +++ b/app/Helpers/Report/BudgetReportHelper.php @@ -52,12 +52,15 @@ class BudgetReportHelper implements BudgetReportHelperInterface // no repetition(s) for this budget: if ($repetitions->count() == 0) { - $spent = array_sum($totalSpent); - $budgetLine = new BudgetLine; - $budgetLine->setBudget($budget); - $budgetLine->setOverspent($spent); - $object->addOverspent($spent); - $object->addBudgetLine($budgetLine); + + $spent = array_sum($totalSpent); + if ($spent > 0) { + $budgetLine = new BudgetLine; + $budgetLine->setBudget($budget); + $budgetLine->setOverspent($spent); + $object->addOverspent($spent); + $object->addBudgetLine($budgetLine); + } continue; } From 23f474b003420d4a885a8910e8e6c8770268d83d Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 08:55:06 +0100 Subject: [PATCH 012/448] Don't add inactive unhit bills, see #159 --- app/Helpers/Report/ReportHelper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index aafa134805..069aa947ee 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -88,8 +88,10 @@ class ReportHelper implements ReportHelperInterface } else { $billLine->setHit(false); } + if ($billLine->isHit() && $billLine->isActive()) { + $collection->addBill($billLine); + } - $collection->addBill($billLine); } From 151e8e8f173f17a73d2ab3881ab567da0d01f938 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 08:56:33 +0100 Subject: [PATCH 013/448] Experimenting with a negation for #159 --- app/Helpers/Report/ReportHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index 069aa947ee..5b2759a675 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -88,7 +88,7 @@ class ReportHelper implements ReportHelperInterface } else { $billLine->setHit(false); } - if ($billLine->isHit() && $billLine->isActive()) { + if (!(!$billLine->isHit() && !$billLine->isActive())) { $collection->addBill($billLine); } From f0bb462f1c8c2ec55ae36fe9aa30427e73fa92fe Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 11:00:26 +0100 Subject: [PATCH 014/448] New test data. --- app/Support/Migration/TestData.php | 124 ++++++++++++++++++++++++ database/seeds/TestDataSeeder.php | 42 ++------ database/seeds/VisualTestDataSeeder.php | 22 +---- 3 files changed, 137 insertions(+), 51 deletions(-) diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php index 6407ca013e..240afe1edb 100644 --- a/app/Support/Migration/TestData.php +++ b/app/Support/Migration/TestData.php @@ -9,11 +9,18 @@ namespace FireflyIII\Support\Migration; * of the MIT license. See the LICENSE file for details. */ +use Carbon\Carbon; use FireflyIII\Models\Account; use FireflyIII\Models\AccountMeta; use FireflyIII\Models\Bill; +use FireflyIII\Models\Budget; use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBankEvent; +use FireflyIII\Models\Rule; +use FireflyIII\Models\RuleAction; +use FireflyIII\Models\RuleGroup; +use FireflyIII\Models\RuleTrigger; +use FireflyIII\Models\Tag; use FireflyIII\User; use Log; @@ -93,6 +100,21 @@ class TestData 'skip' => 0, ] ); + + } + + /** + * @param User $user + */ + public static function createBudgets(User $user) + { + Budget::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]); + Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]); + + // some empty budgets. + foreach (['A', 'B', 'C', 'D', "E"] as $letter) { + Budget::firstOrCreateEncrypted(['name' => 'Empty budget ' . $letter, 'user_id' => $user->id]); + } } /** @@ -233,6 +255,108 @@ class TestData } + /** + * @param User $user + */ + public static function createRules(User $user) + { + $group = RuleGroup::create( + [ + 'user_id' => $user->id, + 'order' => 1, + 'title' => trans('firefly.default_rule_group_name'), + 'description' => trans('firefly.default_rule_group_description'), + 'active' => 1, + ] + ); + $rule = Rule::create( + [ + 'user_id' => $user->id, + 'rule_group_id' => $group->id, + 'order' => 1, + 'active' => 1, + 'stop_processing' => 0, + 'title' => trans('firefly.default_rule_name'), + 'description' => trans('firefly.default_rule_description'), + ] + ); + + // three triggers: + RuleTrigger::create( + [ + 'rule_id' => $rule->id, + 'order' => 1, + 'active' => 1, + 'stop_processing' => 0, + 'trigger_type' => 'user_action', + 'trigger_value' => 'store-journal', + ] + ); + RuleTrigger::create( + [ + 'rule_id' => $rule->id, + 'order' => 2, + 'active' => 1, + 'stop_processing' => 0, + 'trigger_type' => 'description_is', + 'trigger_value' => trans('firefly.default_rule_trigger_description'), + ] + ); + RuleTrigger::create( + [ + 'rule_id' => $rule->id, + 'order' => 3, + 'active' => 1, + 'stop_processing' => 0, + 'trigger_type' => 'from_account_is', + 'trigger_value' => trans('firefly.default_rule_trigger_from_account'), + ] + ); + + // two actions: + RuleAction::create( + [ + 'rule_id' => $rule->id, + 'order' => 1, + 'active' => 1, + 'action_type' => 'prepend_description', + 'action_value' => trans('firefly.default_rule_action_prepend'), + ] + ); + RuleAction::create( + [ + 'rule_id' => $rule->id, + 'order' => 1, + 'active' => 1, + 'action_type' => 'set_category', + 'action_value' => trans('firefly.default_rule_action_set_category'), + ] + ); + } + + /** + * @param User $user + * @param Carbon|null $date + */ + public static function createTags(User $user, Carbon $date = null) + { + $title = 'SomeTag nr. ' . rand(1, 1234); + if (!is_null($date)) { + $title = 'SomeTag' . $date->month . '.' . $date->year . '.nothing'; + } + + Tag::create( + [ + 'user_id' => $user->id, + 'tag' => $title, + 'tagMode' => 'nothing', + 'date' => is_null($date) ? null : $date->format('Y-m-d'), + + + ] + ); + } + /** * @param User $user * @param $name diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php index 05795f4679..3d7e29562e 100644 --- a/database/seeds/TestDataSeeder.php +++ b/database/seeds/TestDataSeeder.php @@ -39,6 +39,7 @@ class TestDataSeeder extends Seeder { $user = User::create(['email' => 'thegrumpydictator@gmail.com', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]); User::create(['email' => 'thegrumpydictator+empty@gmail.com', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]); + User::create(['email' => 'thegrumpydictator+deleteme@gmail.com', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]); $admin = Role::where('name', 'owner')->first(); @@ -52,7 +53,7 @@ class TestDataSeeder extends Seeder TestData::createBills($user); // create some budgets for user #1 - $this->createBudgets($user); + TestData::createBudgets($user); // create some categories for user #1 $this->createCategories($user); @@ -71,6 +72,12 @@ class TestDataSeeder extends Seeder // create opening balance for savings account: $this->openingBalanceSavings($user); + + // need at least one rule group and one rule: + TestData::createRules($user); + + // create a tag: + TestData::createTags($user); } /** @@ -89,7 +96,7 @@ class TestDataSeeder extends Seeder 'transaction_currency_id' => 1, 'description' => 'Some journal for attachment', 'completed' => 1, - 'date' => new Carbon, + 'date' => $this->start->format('Y-m-d'), ] ); Transaction::create( @@ -150,37 +157,6 @@ class TestDataSeeder extends Seeder } - /** - * @param $user - */ - private function createBudgets($user) - { - $set = [ - Budget::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]), - Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]), - ]; - $current = new Carbon; - /** @var Budget $budget */ - foreach ($set as $budget) { - - // some budget limits: - $start = clone $current; - $end = clone $current; - $start->startOfMonth(); - $end->endOfMonth(); - - BudgetLimit::create( - [ - 'budget_id' => $budget->id, - 'startdate' => $start->format('Y-m-d'), - 'amount' => 500, - 'repeats' => 0, - 'repeat_freq' => 'monthly', - ] - ); - } - } - /** * @param User $user */ diff --git a/database/seeds/VisualTestDataSeeder.php b/database/seeds/VisualTestDataSeeder.php index 6c6810d137..3445684e61 100644 --- a/database/seeds/VisualTestDataSeeder.php +++ b/database/seeds/VisualTestDataSeeder.php @@ -445,6 +445,9 @@ class VisualTestDataSeeder extends Seeder TestData::createBills($this->user); TestData::createPiggybanks($this->user); + // create some budgets for user + TestData::createBudgets($this->user); + $this->createRules(); // preference to only see account #1 on frontpage. @@ -472,7 +475,7 @@ class VisualTestDataSeeder extends Seeder $this->createGroceries($current); // create tag (each type of tag, for date): - $this->createTags($current); + TestData::createTags($this->user, $current); // go out for drinks: $this->createDrinksAndOthers($current); @@ -1003,23 +1006,6 @@ class VisualTestDataSeeder extends Seeder } - /** - * @param Carbon $date - */ - protected function createTags(Carbon $date) - { - Tag::create( - [ - 'user_id' => $this->user->id, - 'tag' => 'SomeTag' . $date->month . '.' . $date->year . '.nothing', - 'tagMode' => 'nothing', - 'date' => $date->format('Y-m-d'), - - - ] - ); - } - /** * */ From 93d9c44585b6f535be9315a0aec6b60e5d9614f8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 11:07:34 +0100 Subject: [PATCH 015/448] This should fix the tests. --- app/Support/Migration/TestData.php | 47 ++++++++++++++++++++++++ database/seeds/TestDataSeeder.php | 7 ++-- database/seeds/VisualTestDataSeeder.php | 48 ++----------------------- 3 files changed, 55 insertions(+), 47 deletions(-) diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php index 240afe1edb..b8f85c3950 100644 --- a/app/Support/Migration/TestData.php +++ b/app/Support/Migration/TestData.php @@ -14,6 +14,7 @@ use FireflyIII\Models\Account; use FireflyIII\Models\AccountMeta; use FireflyIII\Models\Bill; use FireflyIII\Models\Budget; +use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBankEvent; use FireflyIII\Models\Rule; @@ -31,6 +32,7 @@ use Log; */ class TestData { + /** * @param User $user */ @@ -103,6 +105,31 @@ class TestData } + /** + * @param User $user + * @param Carbon $current + * @param $name + * @param $amount + */ + public static function createBudgetLimit(User $user, Carbon $current, $name, $amount) + { + $start = clone $current; + $end = clone $current; + $budget = self::findBudget($user, $name); + $start->startOfMonth(); + $end->endOfMonth(); + + BudgetLimit::create( + [ + 'budget_id' => $budget->id, + 'startdate' => $start->format('Y-m-d'), + 'amount' => $amount, + 'repeats' => 0, + 'repeat_freq' => 'monthly', + ] + ); + } + /** * @param User $user */ @@ -110,6 +137,7 @@ class TestData { Budget::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]); Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]); + Budget::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]); // some empty budgets. foreach (['A', 'B', 'C', 'D', "E"] as $letter) { @@ -378,5 +406,24 @@ class TestData return null; } + /** + * @param User $user + * @param $name + * + * @return Budget|null + */ + public static function findBudget(User $user, $name) + { + /** @var Budget $budget */ + foreach (Budget::get() as $budget) { + if ($budget->name == $name && $user->id == $budget->user_id) { + return $budget; + break; + } + } + + return null; + } + } diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php index 3d7e29562e..ae2df0622c 100644 --- a/database/seeds/TestDataSeeder.php +++ b/database/seeds/TestDataSeeder.php @@ -3,8 +3,6 @@ use Carbon\Carbon; use FireflyIII\Models\Account; use FireflyIII\Models\Attachment; -use FireflyIII\Models\Budget; -use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\Category; use FireflyIII\Models\Role; use FireflyIII\Models\Transaction; @@ -55,6 +53,11 @@ class TestDataSeeder extends Seeder // create some budgets for user #1 TestData::createBudgets($user); + // create budget limits for these budgets + TestData::createBudgetLimit($user, new Carbon, 'Groceries', 400); + TestData::createBudgetLimit($user, new Carbon, 'Bills', 1000); + TestData::createBudgetLimit($user, new Carbon, 'Car', 100); + // create some categories for user #1 $this->createCategories($user); diff --git a/database/seeds/VisualTestDataSeeder.php b/database/seeds/VisualTestDataSeeder.php index 3445684e61..b158bb283b 100644 --- a/database/seeds/VisualTestDataSeeder.php +++ b/database/seeds/VisualTestDataSeeder.php @@ -487,9 +487,9 @@ class VisualTestDataSeeder extends Seeder $this->createCar($current); // budget limit for this month, on "Groceries". - $this->createBudgetLimit($current, 'Groceries', 400); - $this->createBudgetLimit($current, 'Bills', 1000); - $this->createBudgetLimit($current, 'Car', 100); + TestData::createBudgetLimit($current, 'Groceries', 400); + TestData::createBudgetLimit($current, 'Bills', 1000); + TestData::createBudgetLimit($current, 'Car', 100); echo 'Created test data for ' . $month . "\n"; $current->addMonth(); @@ -497,30 +497,6 @@ class VisualTestDataSeeder extends Seeder } - /** - * @param Carbon $current - * @param $name - * @param $amount - */ - protected function createBudgetLimit(Carbon $current, $name, $amount) - { - $start = clone $current; - $end = clone $current; - $budget = $this->findBudget($name); - $start->startOfMonth(); - $end->endOfMonth(); - - BudgetLimit::create( - [ - 'budget_id' => $budget->id, - 'startdate' => $start->format('Y-m-d'), - 'amount' => $amount, - 'repeats' => 0, - 'repeat_freq' => 'monthly', - ] - ); - } - /** * @param $date * @@ -1085,24 +1061,6 @@ class VisualTestDataSeeder extends Seeder return null; } - /** - * @param $name - * - * @return Budget|null - */ - protected function findBudget($name) - { - /** @var Budget $budget */ - foreach (Budget::get() as $budget) { - if ($budget->name == $name && $this->user->id == $budget->user_id) { - return $budget; - break; - } - } - - return null; - } - /** * @param $name * From 70ba9a4db57d78de3fc7fa8c0b03a0c9723a4134 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 17:13:34 +0100 Subject: [PATCH 016/448] Some phpunit updates. --- composer.json | 3 ++- composer.lock | 54 +++++++++++++++++++++++++++++++++++++++++++-- phpunit.default.xml | 4 ++++ phpunit.xml | 4 ++++ 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 7dbfee8eb0..d2b90cbf55 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,8 @@ "symfony/css-selector": "2.8.*|3.0.*", "symfony/dom-crawler": "2.8.*|3.0.*", "barryvdh/laravel-debugbar": "@stable", - "barryvdh/laravel-ide-helper": "~2.0" + "barryvdh/laravel-ide-helper": "~2.0", + "johnkary/phpunit-speedtrap": "^1.0" }, "autoload": { "classmap": [ diff --git a/composer.lock b/composer.lock index 5f29ed5b9e..fef713fd3d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "df00127da416acad2a36b6128b82fdd9", - "content-hash": "28b178f07a713b4db441e7e1f380916e", + "hash": "95c05ea11a9db657dc80a0d441c891c8", + "content-hash": "6259b53a188bcdb2ac3fa814b194481f", "packages": [ { "name": "classpreloader/classpreloader", @@ -2923,6 +2923,56 @@ ], "time": "2015-05-11 14:41:42" }, + { + "name": "johnkary/phpunit-speedtrap", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/johnkary/phpunit-speedtrap.git", + "reference": "76a26f8a903a9434608cdad2b41c40cd134ea326" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/johnkary/phpunit-speedtrap/zipball/76a26f8a903a9434608cdad2b41c40cd134ea326", + "reference": "76a26f8a903a9434608cdad2b41c40cd134ea326", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*|~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "JohnKary": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Kary", + "email": "john@johnkary.net" + } + ], + "description": "Find slow tests in your PHPUnit test suite", + "homepage": "https://github.com/johnkary/phpunit-speedtrap", + "keywords": [ + "phpunit", + "profile", + "slow" + ], + "time": "2015-09-13 19:01:00" + }, { "name": "maximebf/debugbar", "version": "v1.11.0", diff --git a/phpunit.default.xml b/phpunit.default.xml index cc0841c1d3..2664543d0a 100644 --- a/phpunit.default.xml +++ b/phpunit.default.xml @@ -24,4 +24,8 @@ + + + + diff --git a/phpunit.xml b/phpunit.xml index cc0841c1d3..2664543d0a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -24,4 +24,8 @@ + + + + From 78f8b1454db4805ed0db3517dbdf7e46745bde21 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 17:13:42 +0100 Subject: [PATCH 017/448] New export controller. --- app/Http/Controllers/ExportController.php | 182 ++++++++++++++++++++++ app/Http/routes.php | 8 + 2 files changed, 190 insertions(+) create mode 100644 app/Http/Controllers/ExportController.php diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php new file mode 100644 index 0000000000..828b65683d --- /dev/null +++ b/app/Http/Controllers/ExportController.php @@ -0,0 +1,182 @@ +key . '.zip'; + $date = date('Y-m-d \a\t H-i-s'); + $name = 'Export job on ' . $date . '.zip'; + $quoted = sprintf('"%s"', addcslashes($name, '"\\')); + + + return response(file_get_contents($file), 200) + ->header('Content-Description', 'File Transfer') + ->header('Content-Type', 'application/octet-stream') + ->header('Content-Disposition', 'attachment; filename=' . $quoted) + ->header('Content-Transfer-Encoding', 'binary') + ->header('Connection', 'Keep-Alive') + ->header('Expires', '0') + ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') + ->header('Pragma', 'public') + ->header('Content-Length', filesize($file)); + + } + + /** + * @return \Illuminate\Http\JsonResponse + */ + public function getStatus(ExportJob $job) + { + return Response::json(['status' => trans('firefly.' . $job->status)]); + } + + /** + * @param ARI $repository + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function index(ARI $repository, EJRI $jobs) + { + // create new export job. + $job = $jobs->create(); + // delete old ones. + $jobs->cleanup(); + + // does the user have shared accounts? + $accounts = $repository->getAccounts(['Default account', 'Asset account']); + $formats = array_keys(Config::get('firefly.export_formats')); + $defaultFormat = Preferences::get('export_format', Config::get('firefly.default_export_format'))->data; + //$first = session('first')->format('Y-m-d'); + $first = Carbon::create()->startOfYear()->format('Y-m-d'); + $today = Carbon::create()->format('Y-m-d'); + + return view('export.index', compact('accounts', 'job', 'formats', 'defaultFormat', 'first', 'today')); + + // select date range + // format + // select accounts + // include attachments + // include uploaded CSV files (if any) + } + + /** + * @param ExportFormRequest $request + * @param ARI $repository + * + * @return string + */ + public function postIndex(ExportFormRequest $request, ARI $repository, EJRI $jobs) + { + set_time_limit(0); + $job = $jobs->findByKey($request->get('job')); + $settings = [ + 'accounts' => $repository->get($request->get('accounts')), + 'startDate' => new Carbon($request->get('start_date')), + 'endDate' => new Carbon($request->get('end_date')), + 'exportFormat' => $request->get('exportFormat'), + 'includeAttachments' => intval($request->get('include_attachments')) === 1, + 'includeConfig' => intval($request->get('include_config')) === 1, + 'includeOldUploads' => intval($request->get('include_old_uploads')) === 1, + 'job' => $job, + ]; + + $job->change('export_status_make_exporter'); + $processor = new Processor($settings); + + /* + * Collect journals: + */ + $job->change('export_status_collecting_journals'); + $processor->collectJournals(); + $job->change('export_status_collected_journals'); + /* + * Transform to exportable entries: + */ + $job->change('export_status_converting_to_export_format'); + $processor->convertJournals(); + $job->change('export_status_converted_to_export_format'); + /* + * Transform to (temporary) file: + */ + $job->change('export_status_creating_journal_file'); + $processor->exportJournals(); + $job->change('export_status_created_journal_file'); + /* + * Collect attachments, if applicable. + */ + if ($settings['includeAttachments']) { + $job->change('export_status_collecting_attachments'); + $processor->collectAttachments(); + $job->change('export_status_collected_attachments'); + } + + /* + * Collect old uploads + */ + if ($settings['includeOldUploads']) { + $job->change('export_status_collecting_old_uploads'); + $processor->collectOldUploads(); + $job->change('export_status_collected_old_uploads'); + } + + /* + * Generate / collect config file. + */ + if ($settings['includeConfig']) { + $job->change('export_status_creating_config_file'); + $processor->createConfigFile(); + $job->change('export_status_created_config_file'); + } + + /* + * Create ZIP file: + */ + $job->change('export_status_creating_zip_file'); + $processor->createZipFile(); + $job->change('export_status_created_zip_file'); + + $job->change('export_status_finished'); + + return Response::json('ok'); + } +} diff --git a/app/Http/routes.php b/app/Http/routes.php index d0554de944..a77e391264 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -133,6 +133,14 @@ Route::group( Route::post('/currency/update/{currency}', ['uses' => 'CurrencyController@update', 'as' => 'currency.update']); Route::post('/currency/destroy/{currency}', ['uses' => 'CurrencyController@destroy', 'as' => 'currency.destroy']); + /** + * Export Controller + */ + Route::get('/export', ['uses' => 'ExportController@index', 'as' => 'export.index']); + Route::post('/export/submit', ['uses' => 'ExportController@postIndex', 'as' => 'export.export']); + Route::get('/export/status/{jobKey}', ['uses' => 'ExportController@getStatus', 'as' => 'export.status']); + Route::get('/export/download/{jobKey}', ['uses' => 'ExportController@download', 'as' => 'export.download']); + /** * ALL CHART Controllers From 3bb107e192cd2af70f851e08404a4218505758b6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 17:13:58 +0100 Subject: [PATCH 018/448] New migrations (also for export). --- .../2016_02_04_144117_changes_for_v380.php | 43 ++++++++++ database/seeds/TestDataSeeder.php | 79 +------------------ database/seeds/VisualTestDataSeeder.php | 10 ++- 3 files changed, 50 insertions(+), 82 deletions(-) create mode 100644 database/migrations/2016_02_04_144117_changes_for_v380.php diff --git a/database/migrations/2016_02_04_144117_changes_for_v380.php b/database/migrations/2016_02_04_144117_changes_for_v380.php new file mode 100644 index 0000000000..6169706fd4 --- /dev/null +++ b/database/migrations/2016_02_04_144117_changes_for_v380.php @@ -0,0 +1,43 @@ +increments('id'); + $table->timestamps(); + $table->integer('user_id')->unsigned(); + $table->string('key', 12)->unique(); + $table->string('status', 45); + + // connect rule groups to users + $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + + } + ); + } +} diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php index ae2df0622c..487d5a85a0 100644 --- a/database/seeds/TestDataSeeder.php +++ b/database/seeds/TestDataSeeder.php @@ -71,7 +71,7 @@ class TestDataSeeder extends Seeder $this->createRevenueAccounts($user); // create journal + attachment: - $this->createAttachments($user); + TestData::createAttachments($user, $this->start); // create opening balance for savings account: $this->openingBalanceSavings($user); @@ -83,83 +83,6 @@ class TestDataSeeder extends Seeder TestData::createTags($user); } - /** - * @param User $user - */ - private function createAttachments(User $user) - { - - $toAccount = TestData::findAccount($user, 'TestData Checking Account'); - $fromAccount = TestData::findAccount($user, 'Job'); - - $journal = TransactionJournal::create( - [ - 'user_id' => $user->id, - 'transaction_type_id' => 2, - 'transaction_currency_id' => 1, - 'description' => 'Some journal for attachment', - 'completed' => 1, - 'date' => $this->start->format('Y-m-d'), - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => -100, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 100, - - ] - ); - - // and now attachments - $encrypted = Crypt::encrypt('I are secret'); - Attachment::create( - [ - 'attachable_id' => $journal->id, - 'attachable_type' => 'FireflyIII\Models\TransactionJournal', - 'user_id' => $user->id, - 'md5' => md5('Hallo'), - 'filename' => 'empty-file.txt', - 'title' => 'Empty file', - 'description' => 'This file is empty', - 'notes' => 'What notes', - 'mime' => 'text/plain', - 'size' => strlen($encrypted), - 'uploaded' => 1, - ] - ); - - - // and now attachment. - Attachment::create( - [ - 'attachable_id' => $journal->id, - 'attachable_type' => 'FireflyIII\Models\TransactionJournal', - 'user_id' => $user->id, - 'md5' => md5('Ook hallo'), - 'filename' => 'empty-file-2.txt', - 'title' => 'Empty file 2', - 'description' => 'This file is empty too', - 'notes' => 'What notes do', - 'mime' => 'text/plain', - 'size' => strlen($encrypted), - 'uploaded' => 1, - ] - ); - // echo crypted data to the file. - file_put_contents(storage_path('upload/at-1.data'), $encrypted); - file_put_contents(storage_path('upload/at-2.data'), $encrypted); - - } - /** * @param User $user */ diff --git a/database/seeds/VisualTestDataSeeder.php b/database/seeds/VisualTestDataSeeder.php index b158bb283b..672ff770ac 100644 --- a/database/seeds/VisualTestDataSeeder.php +++ b/database/seeds/VisualTestDataSeeder.php @@ -3,7 +3,6 @@ use Carbon\Carbon; use FireflyIII\Models\Account; use FireflyIII\Models\Bill; use FireflyIII\Models\Budget; -use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\Category; use FireflyIII\Models\PiggyBank; use FireflyIII\Models\Preference; @@ -457,6 +456,9 @@ class VisualTestDataSeeder extends Seeder $start = Carbon::now()->subYears(2)->startOfMonth(); $end = Carbon::now()->endOfDay(); + // create journal + attachment: + TestData::createAttachments($this->user, $start); + $current = clone $start; while ($current < $end) { @@ -487,9 +489,9 @@ class VisualTestDataSeeder extends Seeder $this->createCar($current); // budget limit for this month, on "Groceries". - TestData::createBudgetLimit($current, 'Groceries', 400); - TestData::createBudgetLimit($current, 'Bills', 1000); - TestData::createBudgetLimit($current, 'Car', 100); + TestData::createBudgetLimit($this->user, $current, 'Groceries', 400); + TestData::createBudgetLimit($this->user, $current, 'Bills', 1000); + TestData::createBudgetLimit($this->user, $current, 'Car', 100); echo 'Created test data for ' . $month . "\n"; $current->addMonth(); From 902f310eb0db0d59e05fe8e13c4db83dcb1ed93c Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 17:14:32 +0100 Subject: [PATCH 019/448] New export directory. --- storage/export/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 storage/export/.gitignore diff --git a/storage/export/.gitignore b/storage/export/.gitignore new file mode 100644 index 0000000000..d6b7ef32c8 --- /dev/null +++ b/storage/export/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore From d7a66f6782b8c1d42f63434e3bc66967809522c5 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 17:14:59 +0100 Subject: [PATCH 020/448] New model for export. --- app/Models/ExportJob.php | 64 ++++++++++++++++++++++++++++++++++++++++ app/User.php | 9 ++++++ 2 files changed, 73 insertions(+) create mode 100644 app/Models/ExportJob.php diff --git a/app/Models/ExportJob.php b/app/Models/ExportJob.php new file mode 100644 index 0000000000..29551fb331 --- /dev/null +++ b/app/Models/ExportJob.php @@ -0,0 +1,64 @@ +where('user_id', Auth::user()->id)->first(); + if (!is_null($model)) { + return $model; + } + } + throw new NotFoundHttpException; + } + + /** + * @param $status + */ + public function change($status) + { + $this->status = $status; + $this->save(); + } + + /** + * @codeCoverageIgnore + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function user() + { + return $this->belongsTo('FireflyIII\User'); + } +} diff --git a/app/User.php b/app/User.php index c183f7b64a..3019d258ff 100644 --- a/app/User.php +++ b/app/User.php @@ -29,6 +29,7 @@ use Zizaco\Entrust\Traits\EntrustUserTrait; * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Role[] $roles * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\RuleGroup[] $ruleGroups * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Rule[] $rules + * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\ExportJob[] $exportjobs */ class User extends Authenticatable { @@ -97,6 +98,14 @@ class User extends Authenticatable return $this->hasMany('FireflyIII\Models\Category'); } + /** + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function exportjobs() + { + return $this->hasMany('FireflyIII\Models\ExportJob'); + } + /** * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough */ From 86c22c9fdd74689f88cc74cd58b5891f7d3adccb Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 17:16:16 +0100 Subject: [PATCH 021/448] New export functionality. --- app/Export/Collector/AttachmentCollector.php | 54 ++++++ app/Export/Collector/BasicCollector.php | 55 +++++++ app/Export/Collector/CollectorInterface.php | 21 +++ app/Export/Collector/UploadCollector.php | 60 +++++++ app/Export/ConfigurationFile.php | 55 +++++++ app/Export/Entry.php | 120 ++++++++++++++ app/Export/Exporter/BasicExporter.php | 55 +++++++ app/Export/Exporter/CsvExporter.php | 80 +++++++++ app/Export/Exporter/ExporterInterface.php | 41 +++++ app/Export/JournalCollector.php | 65 ++++++++ app/Export/Processor.php | 154 ++++++++++++++++++ app/Http/Requests/ExportFormRequest.php | 52 ++++++ app/Providers/FireflyServiceProvider.php | 2 +- .../ExportJob/ExportJobRepository.php | 66 ++++++++ .../ExportJobRepositoryInterface.php | 38 +++++ app/Support/Migration/TestData.php | 82 ++++++++++ app/Validation/FireflyValidator.php | 4 +- config/firefly.php | 20 ++- public/images/loading-wide.gif | Bin 0 -> 12274 bytes public/js/export/index.js | 121 ++++++++++++++ resources/lang/en_US/firefly.php | 12 ++ resources/lang/en_US/form.php | 6 + resources/views/export/index.twig | 129 +++++++++++++++ resources/views/partials/menu-sidebar.twig | 32 +++- 24 files changed, 1311 insertions(+), 13 deletions(-) create mode 100644 app/Export/Collector/AttachmentCollector.php create mode 100644 app/Export/Collector/BasicCollector.php create mode 100644 app/Export/Collector/CollectorInterface.php create mode 100644 app/Export/Collector/UploadCollector.php create mode 100644 app/Export/ConfigurationFile.php create mode 100644 app/Export/Entry.php create mode 100644 app/Export/Exporter/BasicExporter.php create mode 100644 app/Export/Exporter/CsvExporter.php create mode 100644 app/Export/Exporter/ExporterInterface.php create mode 100644 app/Export/JournalCollector.php create mode 100644 app/Export/Processor.php create mode 100644 app/Http/Requests/ExportFormRequest.php create mode 100644 app/Repositories/ExportJob/ExportJobRepository.php create mode 100644 app/Repositories/ExportJob/ExportJobRepositoryInterface.php create mode 100644 public/images/loading-wide.gif create mode 100644 public/js/export/index.js create mode 100644 resources/views/export/index.twig diff --git a/app/Export/Collector/AttachmentCollector.php b/app/Export/Collector/AttachmentCollector.php new file mode 100644 index 0000000000..93bc425909 --- /dev/null +++ b/app/Export/Collector/AttachmentCollector.php @@ -0,0 +1,54 @@ +attachments()->get(); + + Log::debug('Found ' . $attachments->count() . ' attachments.'); + + /** @var Attachment $attachment */ + foreach ($attachments as $attachment) { + $originalFile = storage_path('upload') . DIRECTORY_SEPARATOR . 'at-' . $attachment->id . '.data'; + if (file_exists($originalFile)) { + Log::debug('Stored 1 attachment'); + $decrypted = Crypt::decrypt(file_get_contents($originalFile)); + $newFile = storage_path('export') . DIRECTORY_SEPARATOR . $this->job->key . '-Attachment nr. ' . $attachment->id . ' - ' . $attachment->filename; + file_put_contents($newFile, $decrypted); + $this->getFiles()->push($newFile); + } + } + } +} \ No newline at end of file diff --git a/app/Export/Collector/BasicCollector.php b/app/Export/Collector/BasicCollector.php new file mode 100644 index 0000000000..b6b98cf397 --- /dev/null +++ b/app/Export/Collector/BasicCollector.php @@ -0,0 +1,55 @@ +files = new Collection; + $this->job = $job; + } + + /** + * @return Collection + */ + public function getFiles() + { + return $this->files; + } + + /** + * @param Collection $files + */ + public function setFiles($files) + { + $this->files = $files; + } + + +} \ No newline at end of file diff --git a/app/Export/Collector/CollectorInterface.php b/app/Export/Collector/CollectorInterface.php new file mode 100644 index 0000000000..313816d4a2 --- /dev/null +++ b/app/Export/Collector/CollectorInterface.php @@ -0,0 +1,21 @@ +id . '-'; + $len = strlen($expected); + foreach ($files as $entry) { + if (substr($entry, 0, $len) === $expected) { + // this is an original upload. + $parts = explode('-', str_replace(['.csv.encrypted', $expected], '', $entry)); + $originalUpload = intval($parts[1]); + $date = date('Y-m-d \a\t H-i-s', $originalUpload); + $newFileName = 'Old CSV import dated ' . $date . '.csv'; + $content = Crypt::decrypt(file_get_contents($path . DIRECTORY_SEPARATOR . $entry)); + $fullPath = storage_path('export') . DIRECTORY_SEPARATOR . $this->job->key . '-' . $newFileName; + + // write to file: + file_put_contents($fullPath, $content); + + // add entry to set: + $this->getFiles()->push($fullPath); + } + } + } +} \ No newline at end of file diff --git a/app/Export/ConfigurationFile.php b/app/Export/ConfigurationFile.php new file mode 100644 index 0000000000..db86402d66 --- /dev/null +++ b/app/Export/ConfigurationFile.php @@ -0,0 +1,55 @@ +job = $job; + } + + /** + * @return bool + */ + public function make() + { + $fields = array_keys(get_class_vars(Entry::class)); + $types = Entry::getTypes(); + + $configuration = [ + 'date-format' => 'Y-m-d', // unfortunately, this is hard-coded. + 'has-headers' => true, + 'map' => [], // we could build a map if necessary for easy re-import. + 'roles' => [], + 'mapped' => [], + 'specifix' => [], + ]; + foreach ($fields as $field) { + $configuration['roles'][] = $types[$field]; + } + + $file = storage_path('export') . DIRECTORY_SEPARATOR . $this->job->key . '-configuration.json'; + file_put_contents($file, json_encode($configuration, JSON_PRETTY_PRINT)); + + return $file; + } + +} \ No newline at end of file diff --git a/app/Export/Entry.php b/app/Export/Entry.php new file mode 100644 index 0000000000..559327871a --- /dev/null +++ b/app/Export/Entry.php @@ -0,0 +1,120 @@ +setDescription($journal->description); + $entry->setDate($journal->date->format('Y-m-d')); + $entry->setAmount($journal->amount); + + return $entry; + + } + + /** + * @return array + */ + public static function getTypes() + { + // key = field name (see top of class) + // value = field type (see csv.php under 'roles') + return [ + 'amount' => 'amount', + 'date' => 'date-transaction', + 'description' => 'description', + ]; + } + + /** + * @return string + */ + public function getAmount() + { + return $this->amount; + } + + /** + * @param string $amount + */ + public function setAmount($amount) + { + $this->amount = $amount; + } + + /** + * @return string + */ + public function getDate() + { + return $this->date; + } + + /** + * @param string $date + */ + public function setDate($date) + { + $this->date = $date; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + +} \ No newline at end of file diff --git a/app/Export/Exporter/BasicExporter.php b/app/Export/Exporter/BasicExporter.php new file mode 100644 index 0000000000..aaa8ea1dad --- /dev/null +++ b/app/Export/Exporter/BasicExporter.php @@ -0,0 +1,55 @@ +entries = new Collection; + $this->job = $job; + } + + /** + * @return Collection + */ + public function getEntries() + { + return $this->entries; + } + + /** + * @param Collection $entries + */ + public function setEntries(Collection $entries) + { + $this->entries = $entries; + } + + + +} \ No newline at end of file diff --git a/app/Export/Exporter/CsvExporter.php b/app/Export/Exporter/CsvExporter.php new file mode 100644 index 0000000000..906667a5f2 --- /dev/null +++ b/app/Export/Exporter/CsvExporter.php @@ -0,0 +1,80 @@ +fileName; + } + + /** + * + */ + public function run() + { + // create temporary file: + $this->tempFile(); + + // create CSV writer: + $writer = Writer::createFromPath(new SplFileObject($this->fileName, 'a+'), 'w'); + //the $writer object open mode will be 'w'!! + + // all rows: + $rows = []; + + // add header: + $first = $this->getEntries()->first(); + $rows[] = array_keys(get_object_vars($first)); + + // then the rest: + /** @var Entry $entry */ + foreach ($this->getEntries() as $entry) { + $rows[] = array_values(get_object_vars($entry)); + + } + $writer->insertAll($rows); + } + + private function tempFile() + { + $fileName = $this->job->key . '-records.csv'; + $this->fileName = storage_path('export') . DIRECTORY_SEPARATOR . $fileName; + $this->handler = fopen($this->fileName, 'w'); + } +} \ No newline at end of file diff --git a/app/Export/Exporter/ExporterInterface.php b/app/Export/Exporter/ExporterInterface.php new file mode 100644 index 0000000000..b8f3431a51 --- /dev/null +++ b/app/Export/Exporter/ExporterInterface.php @@ -0,0 +1,41 @@ +accounts = $accounts; + $this->user = $user; + $this->start = $start; + $this->end = $end; + } + + /** + * @return Collection + */ + public function collect() + { + // get all the journals: + $ids = $this->accounts->pluck('id')->toArray(); + + return $this->user->transactionjournals() + ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') + ->whereIn('transactions.account_id', $ids) + ->before($this->end) + ->after($this->start) + ->orderBy('transaction_journals.date') + ->get(['transaction_journals.*']); + } + +} \ No newline at end of file diff --git a/app/Export/Processor.php b/app/Export/Processor.php new file mode 100644 index 0000000000..6f43561dd2 --- /dev/null +++ b/app/Export/Processor.php @@ -0,0 +1,154 @@ +settings = $settings; + $this->accounts = $settings['accounts']; + $this->exportFormat = $settings['exportFormat']; + $this->includeAttachments = $settings['includeAttachments']; + $this->includeConfig = $settings['includeConfig']; + $this->includeOldUploads = $settings['includeOldUploads']; + $this->job = $settings['job']; + $this->journals = new Collection; + $this->exportEntries = new Collection; + $this->files = new Collection; + + } + + /** + * + */ + public function collectAttachments() + { + $attachmentCollector = app('FireflyIII\Export\Collector\AttachmentCollector', [$this->job]); + $attachmentCollector->run(); + $this->files = $this->files->merge($attachmentCollector->getFiles()); + } + + /** + * + */ + public function collectJournals() + { + $args = [$this->accounts, Auth::user(), $this->settings['startDate'], $this->settings['endDate']]; + $journalCollector = app('FireflyIII\Export\JournalCollector', $args); + $this->journals = $journalCollector->collect(); + } + + public function collectOldUploads() + { + $uploadCollector = app('FireflyIII\Export\Collector\UploadCollector', [$this->job]); + $uploadCollector->run(); + + $this->files = $this->files->merge($uploadCollector->getFiles()); + } + + /** + * + */ + public function convertJournals() + { + /** @var TransactionJournal $journal */ + foreach ($this->journals as $journal) { + $this->exportEntries->push(Entry::fromJournal($journal)); + } + } + + public function createConfigFile() + { + $this->configurationMaker = app('FireflyIII\Export\ConfigurationFile', [$this->job]); + $this->files->push($this->configurationMaker->make()); + } + + public function createZipFile() + { + $zip = new ZipArchive; + $filename = storage_path('export') . DIRECTORY_SEPARATOR . $this->job->key . '.zip'; + + if ($zip->open($filename, ZipArchive::CREATE) !== true) { + throw new FireflyException('Cannot store zip file.'); + } + // for each file in the collection, add it to the zip file. + $search = storage_path('export') . DIRECTORY_SEPARATOR . $this->job->key . '-'; + /** @var string $file */ + foreach ($this->getFiles() as $file) { + $zipName = str_replace($search, '', $file); + $zip->addFile($file, $zipName); + } + $zip->close(); + } + + /** + * + */ + public function exportJournals() + { + $exporterClass = Config::get('firefly.export_formats.' . $this->exportFormat); + $exporter = app($exporterClass, [$this->job]); + $exporter->setEntries($this->exportEntries); + $exporter->run(); + $this->files->push($exporter->getFileName()); + } + + /** + * @return Collection + */ + public function getFiles() + { + return $this->files; + } +} \ No newline at end of file diff --git a/app/Http/Requests/ExportFormRequest.php b/app/Http/Requests/ExportFormRequest.php new file mode 100644 index 0000000000..979d63cbbb --- /dev/null +++ b/app/Http/Requests/ExportFormRequest.php @@ -0,0 +1,52 @@ +subDay()->format('Y-m-d'); + $today = Carbon::create()->addDay()->format('Y-m-d'); + $formats = join(',', array_keys(config('firefly.export_formats'))); + + return [ + 'start_date' => 'required|date|after:' . $first, + 'end_date' => 'required|date|before:' . $today, + 'accounts' => 'required', + 'job' => 'required|belongsToUser:export_jobs,key', + 'accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts', + 'include_attachments' => 'in:0,1', + 'include_config' => 'in:0,1', + 'exportFormat' => 'in:' . $formats, + ]; + } +} diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index 13712858c3..46f5160c57 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -93,6 +93,7 @@ class FireflyServiceProvider extends ServiceProvider $this->app->bind('FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface', 'FireflyIII\Repositories\Attachment\AttachmentRepository'); $this->app->bind('FireflyIII\Repositories\Rule\RuleRepositoryInterface', 'FireflyIII\Repositories\Rule\RuleRepository'); $this->app->bind('FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface', 'FireflyIII\Repositories\RuleGroup\RuleGroupRepository'); + $this->app->bind('FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface', 'FireflyIII\Repositories\ExportJob\ExportJobRepository'); $this->app->bind('FireflyIII\Support\Search\SearchInterface', 'FireflyIII\Support\Search\Search'); // CSV import @@ -126,7 +127,6 @@ class FireflyServiceProvider extends ServiceProvider $this->app->bind('FireflyIII\Helpers\Report\BalanceReportHelperInterface', 'FireflyIII\Helpers\Report\BalanceReportHelper'); $this->app->bind('FireflyIII\Helpers\Report\BudgetReportHelperInterface', 'FireflyIII\Helpers\Report\BudgetReportHelper'); - } } diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php new file mode 100644 index 0000000000..8125c61033 --- /dev/null +++ b/app/Repositories/ExportJob/ExportJobRepository.php @@ -0,0 +1,66 @@ +subDay(); + ExportJob::where('created_at', '<', $dayAgo->format('Y-m-d H:i:s')) + ->where('status', 'never_started') + // TODO also delete others. + ->delete(); + + return true; + } + + /** + * @return ExportJob + */ + public function create() + { + $exportJob = new ExportJob; + $exportJob->user()->associate(Auth::user()); + /* + * In theory this random string could give db error. + */ + $exportJob->key = Str::random(12); + $exportJob->status = 'export_status_never_started'; + $exportJob->save(); + + return $exportJob; + } + + /** + * @param $key + * + * @return ExportJob|null + */ + public function findByKey($key) + { + return Auth::user()->exportJobs()->where('key', $key)->first(); + } + +} \ No newline at end of file diff --git a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php new file mode 100644 index 0000000000..68265b2bc5 --- /dev/null +++ b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php @@ -0,0 +1,38 @@ + $user->id, + 'transaction_type_id' => 2, + 'transaction_currency_id' => 1, + 'description' => 'Some journal for attachment', + 'completed' => 1, + 'date' => $start->format('Y-m-d'), + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => -100, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => 100, + + ] + ); + + // and now attachments + $encrypted = Crypt::encrypt('I are secret'); + $one = Attachment::create( + [ + 'attachable_id' => $journal->id, + 'attachable_type' => 'FireflyIII\Models\TransactionJournal', + 'user_id' => $user->id, + 'md5' => md5('Hallo'), + 'filename' => 'empty-file.txt', + 'title' => 'Empty file', + 'description' => 'This file is empty', + 'notes' => 'What notes', + 'mime' => 'text/plain', + 'size' => strlen($encrypted), + 'uploaded' => 1, + ] + ); + + + // and now attachment. + $two = Attachment::create( + [ + 'attachable_id' => $journal->id, + 'attachable_type' => 'FireflyIII\Models\TransactionJournal', + 'user_id' => $user->id, + 'md5' => md5('Ook hallo'), + 'filename' => 'empty-file-2.txt', + 'title' => 'Empty file 2', + 'description' => 'This file is empty too', + 'notes' => 'What notes do', + 'mime' => 'text/plain', + 'size' => strlen($encrypted), + 'uploaded' => 1, + ] + ); + // echo crypted data to the file. + file_put_contents(storage_path('upload/at-' . $one->id . '.data'), $encrypted); + file_put_contents(storage_path('upload/at-' . $two->id . '.data'), $encrypted); + + } + /** * @param User $user */ diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 5ee847bdf3..29672b9645 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -49,8 +49,10 @@ class FireflyValidator extends Validator */ public function validateBelongsToUser($attribute, $value, $parameters) { + $field = isset($parameters[1]) ? $parameters[1] : 'id'; - $count = DB::table($parameters[0])->where('user_id', Auth::user()->id)->where('id', $value)->count(); + + $count = DB::table($parameters[0])->where('user_id', Auth::user()->id)->where($field, $value)->count(); if ($count == 1) { return true; } diff --git a/config/firefly.php b/config/firefly.php index f37b62ce98..d22b4a31c4 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -8,11 +8,18 @@ return [ 'csv_import_enabled' => true, 'maxUploadSize' => 5242880, 'allowedMimes' => ['image/png', 'image/jpeg', 'application/pdf'], + + 'export_formats' => [ + 'csv' => 'FireflyIII\Export\Exporter\CsvExporter', + //'mt940' => 'FireflyIII\Export\Exporter\MtExporter', + ], + 'default_export_format' => 'csv', + 'piggy_bank_periods' => [ 'week' => 'Week', 'month' => 'Month', 'quarter' => 'Quarter', - 'year' => 'Year' + 'year' => 'Year', ], 'periods_to_text' => [ 'weekly' => 'A week', @@ -35,10 +42,10 @@ return [ '1M' => 'month', '3M' => 'three months', '6M' => 'half year', - 'custom' => '(custom)' + 'custom' => '(custom)', ], 'ccTypes' => [ - 'monthlyFull' => 'Full payment every month' + 'monthlyFull' => 'Full payment every month', ], 'range_to_name' => [ '1D' => 'one day', @@ -54,7 +61,7 @@ return [ '1M' => 'monthly', '3M' => 'quarterly', '6M' => 'half-year', - 'custom' => 'monthly' + 'custom' => 'monthly', ], 'subTitlesByIdentifier' => [ @@ -160,6 +167,7 @@ return [ 'tag' => 'FireflyIII\Models\Tag', 'rule' => 'FireflyIII\Models\Rule', 'ruleGroup' => 'FireflyIII\Models\RuleGroup', + 'jobKey' => 'FireflyIII\Models\ExportJob', // lists 'accountList' => 'FireflyIII\Support\Binder\AccountList', 'budgetList' => 'FireflyIII\Support\Binder\BudgetList', @@ -167,7 +175,7 @@ return [ // others 'start_date' => 'FireflyIII\Support\Binder\Date', - 'end_date' => 'FireflyIII\Support\Binder\Date' + 'end_date' => 'FireflyIII\Support\Binder\Date', ], 'rule-triggers' => [ @@ -210,6 +218,6 @@ return [ 'set_description', 'append_description', 'prepend_description', - ] + ], ]; diff --git a/public/images/loading-wide.gif b/public/images/loading-wide.gif new file mode 100644 index 0000000000000000000000000000000000000000..135987902d0ba244552677baef4dc61ca1c86e23 GIT binary patch literal 12274 zcmeI2cTiJX-|v%<1QJl1(gGNycLWtw^ne}&Ea8!oacGo`_7&F=ed8}nKv_;WOi0&t+n@FpZ)!Qe@j>Yy2b^|2>>r( z2LL!YH~;_uO-)S&1qJEp>Gk#X&z?Q&?CcyF8F~Bm?ZCjm#KZ)X$()~`ud1qg_3G8~ z^78unI)lO3-rnBX+3D@={r2r!dwY9dU*E>Y#?a7EOG`^hNy+Z+ZgzHdVq&7$0lR_D zgZtOC@9L;3sjvVKI}`gYbj=lQ>5jHRdfB;Sk(TzB1V@~ujgpy&>Y)OUVS`%L3y}Q#ip<>f_^MIa>*8{Ub1M^+G94}_|6}jIiH>n&c z^SsDa1BOsrw`8cS>DAs7ll9XbJE_0)Mm7-*giY++C#Ki@)*kbAIOf z`SZ)y?^`Qt!_nkI5(|uRiJ&Z|O$Bgo_;mJVwo*<)4BiU#&0Y@>{NiUOP(7m;BEoxM z78pz>T?B5hjT!62Cy*e#uB+WD@d@t@HM|zr_jrr?a+boTG%u2u-#^vO*bkI@P|}nA zF#by0%l?uNMJ9!=gDVO4kCNosgpB~&ONu7=`^L#Phg&F~cuZIMrSHxbuTSoNYfJM| ze*7lj*szY7Mir{vMdXx}uyK_+qvk|^P`dH9RX0g-TBr1?B9-lg!j{4f2Ws!}s!L_R z$5%bpM+3||nqHH?Doi$_zZV?yRo{5kM*LABVz#?IUlrXNw2@x_X}Q(y@uSH!cX)r1 zVxUtGeS3F$0g^QwgIb^X`l%-?y3*g@yJ>4OyiPf*{`b#c3!ab7mk7Zi!U=qP*tl)g z89*wC!;_hf<2L9t3F5TU%K`W3CyNF57#lsI@lyoSL;i@>$PH~Y#xh|{Z9qJ3;M~Lh z`-1MtmXV{f3D$0xeq+s|HC73853b7TTE~ru*zv{>R=4NH3*72rgiCSUWe4x}?M?$N zphW{omP3!E{82ab3sS9|2MdgF7AKb;VfUZ(!ck}Y;0dfD*XJpISH4LHk`3B1_O!&1 zWlS)944W&j^l~(NSMTCTUWD9g(e0{TutoU{E*A2S&sc!+k27H+MtvBJLp>p zJn3UKat~W>lwZzMh4^p-fuW-36_6Kl6tk?_@-4Zlvdhiucp_F360okbfMbwYxPdkSm{sBJY1$f?v6j zl}RUlo|{Wa@;ZLm@B7!c<2P|@zZ%UxeO&tkqp9!<{Hsk2IpzDNx$d#&?}Y-;0gzvX z3kcyeGE9ZSNyA2_A~v1oRwpf_dx8Y*mra6(x?X5Q#XON>jvoZvtit3?9;JhnY4tNu z5qO6{$a#|(VAKfn-xxn==7k>+bvd&(R?+weHUNs+%W z+kK;9GFR2JC^3T}=sgLInvx|G3-^*pNirl^TUQRcZZb$-Hp!~^D#bS4Q^@nKT=@6m zl35=r`^2)M!O^2`ELS(^(3&4mgs`@ieHpet(F+zG;PiZhzRaxj)CF5JRXQ94p z(VsqsJ|ZDXIBt}-WltZjGE%(ScqoHDyeScb|e9dq&bksz)qHUKzWg>)=H{E zp0SK=V1vFLLq2VT9p^;UJ+Q*;NEll523RIBxm*Jes7)f zVi0#Z0D7JG$=K&J`z`vDBN63i3vw}YrJG~izlW7;d4vJq8#z!4JG%JzlJCX#yx576 z(Qm&*XJ$qfcPD(#Js{6m^_TAwh)X6jI ztJ~OLtLjktv0gLmf0gZ@!$mNw9f9pUc84^F7a04bEq42H-7!L)W~|m1USUT970SYi z@UtV~aa5XLXb3qn!Y9^V80Q?t8Q_~78AuDsB&9fe1wleH9n*3%vh2u}X+HT`4o{qf zMUSHnADs@u5CM3n5d07sAdEYNlWkxC&eqcx)6+jV*n_}~f1DbGL9u;U^uhqs-EVzr zcxfyIG5>{aDa>wfVRMo9i@X2Qb=K~wP_Jp6)08|o$ z@Y$A0T^9m*v#Wx8)3Ud&(ZgBQuY2xpO}7yxHO?n#xZdh`!V54I-c>{Q^6JfGF{n+fa;myT=nNcb4xyy5O`j8RjA;&g z-B2{8iZsx&4wt@{cPr{_9HtpHJTWp1Jsqc!AF0f!w+_8*$d?zTa8)q#oPl9VYGiP8 zh(x418NKXI-l8 zmT~YB^_iIWLN0B?ZW=wIkGU7UrWo^>=$Tm`krfM-!{Uh`cxE(Q;_fmPo2x});i&1F zq||)ioeaBleK!Ys#u%^|#^Js@p}Gr!t=lj(J47qQO}NTDh66nvSaHxby8}z9GvRB` z|FDuL*LFBdWmeW-4Ozc-66@e>S*U1Q@jPC~M?k0Eb$As9=8}_t^3pg@D^bE(R!J4W zE-M9PxDzE32#Um8suuSIZSr6@_awv5rW%e~LcTPXK2|f-&kWVL{sY%}&bjthgp9h6 zijz@pI`iE&&xESu_f!?YIW7q-5Xy>rX-cGl6nCzqe%y2GEA)dKJ-w-WK{}5I{3{n4 zASjpd;a9+)jj0bN{o zjO18IUR|YNXXyH5>o40R0;O41R8c2X{pRkOR?&^cGMJ_#VKDk8{{@}KPSO=7F>YMw zB?Up4da9p>Q-3)bmDQvX#W38`2z>8Le#=K^RsOm4mLI2iBt(90cdKvy{L-hZ{A*|6 z5$@O5e^iJBV^p?IfYaRfJ6!~X@rOR3f^&@aYW&Qdd|nbvSeO_@^z-m{@(J?gMEKiN z2rf7l&REZI8q|+$@8z7HN%m*K<8m{iW3md<6O&V72;SaF<)oS?cwsarM#0<*2Z47S zg5{7b*w90;^s~YHdjewYJ`7CuVEtn!CWoPj_W^VBBXQ#&2Zq?zXEr83!xqQvp_}u& z9zXUyT3HR^UXmC4p3dl2m}&pPIq^VCg#;nr=cKEU=+$!+5UWIpFmXnk8YRkp5ONDi zMpNRX|GH|lh04F3tctl()c33qoUUp&W(GSUNliUz7N)RTz1Wu|Z*W7cR z?cp_hU*St|J2v(F&K+hGVsF{ASiP>G$#-&Y{}X=}aqu?Fv#iEb3-SZG~ox4tI)j4&KJF{x)2?De@*MDyfnuN;c(jv)zpf*CA)Q*5f0?&V1i z6}4uMu@iKYWyISOKZMqFr@wPlDe&d%T$xpcO@t<=6cwiwf+5@A7Xvz1jE|+_tzHX&C=}bzlsq*|%GG;j zq9q?MbUJ&gMAd$&Byuo+OgnE}L~W#!Zn5m3$`GYGJkL+Hk3Oh=);sKQ?g20@tC)Ih z_*0319RFx;`+l$_9E{J_D#{zG7mH!S8j{cHFS3b67oLvU4EQ0J77>YvNnQ*7xlyRq zEXfecu?hVA)yDH14^*+$b43Pi^T!oC325a$dwzt-1K~Rz3Lmjf7@o(SvoEDNRJhGY zR>GQrj$mjyxi(zMNPhdF9&N(^m0l$RfBGchwT8bneck_h;Uq9cz>P! z_BqwKGsg-c*Vdli8W>Hu-8;CDAW~6@+sA0@$dgaDg%Wd&4 zepvZbZxdtvTM?>!@45DB0E`J?*L4*8n=C&+cRo5)E&m5uMlb>YsA|E`WqsgjHQv`2 zHKw+J-WgH|j^mpCTO$&`NuFL_L|1#5Ka2%Oji3elhvU7WzU~2NYG49qfJ2yYYM?7A zBsMq^ri%AFg1Abqds=H=WS@thPWh}-93 z84}eTScjMXS*(8S+IT(wFN0Fs_lgz`u-}tyX_n6Cn&8m642Rof>oz<)t7int*y>HV zr2AYNz|H3M3UX<1-Kf>#126oh)^)|vg*PSrqdEZKCpc*Bf#I$Lu$dMB^E@!;N>-x7 z`4ry1&=THtUT{ehuLu{uxU={yNV&t}PICvWZ(3E^qG#vx8{YcOuS#MUELPm9tsYsK znwpzqdHh+ndq2SAa!kH-^JR1u5FIILh&lj05&1UaiW6KOv8;gIWs;xD<{=$f4cmo4 zhYE%4I-?)LR22%*JMGSsim?b0?B=%&_8pWw9el3BOWaamXn6!0;Bi-gGDII~4&WBV z15MfMSvTzx2q0zS9&`gMf$@5zv z(=c`5lhjXbiz&0lOHb2fU+Ux%Y^1D3wQjr0CV}5=so%yJw7jrYb^Hk9C&@C0bbao4 z_5oSqZ|}tx&Jy9P7Qu`q+2X7?UD=TL<@(&aBb=v_w{95dn;tqc3`zB1;L0-qq{#tS4_Ki~oGFTG;_)f3JWT4zw${18&*={bR zsW$`|i`+0$y79z7em1r%wq&^Ck0zaxhLDCtB{N;40rLPeqHmD43t zaV?M?Z;c;=I9J`J5b{&pRo0!PEzJz<0H3fTI*2lR5)+%T@^jn%-0|C45Uz3n4a{{* ziyU9mH0D^@Af=)_xck~k5vp`gmpt;89PtHsVvGF|lN+O7pG(GQe4jQvKb7qjKE7uc zy{4~K-}-z^aUm)7&F$xEknE{n#N~)_zoKau7$9Oy&r$5i za>y3xf0QFpha9=|HYn2jwb-R8d@u5~!N>(1_1eLr<~qsV1{&ytb3?#F!(dcjZ)iwp zd?X?F~DX%yBYjUuaUts5O6aUg*tHqYy`afn8k zUD(#9CaK&n$scu{dzX9~80tv;vY?wPag*;d?1ALXq+95X{1m!WZ=Sx6$uC)trM~jN zu1SsUk?4P-1kMzltU^)7>v-3TTIqZn;|bqh4Zc9Alj*PVYMn0%vsF;_uG}Xq3Yb-< z%`oN}>Ttc{bi&Z~mFL0&&(&Mgxo;XJ8ec;KcY6OB++0#=S#&pN{m+2Y?BRh9 zmXsh2$m@$amvKfQ{FNUsXVgSR&_dYj9?$U~iaQQ3B_*<|(yLyq;C%j2u4o>285m|a zz4XTf&Z56j@xk}YF|O{AmQPo+(kIv9AgIJ$pdBn*D%m?sQ3`PIm`_+Q<+6aImO180 zwPA9gFS@GPsz<<SpXghRiD5>YH znp7lTcFLlb`My+U;!t)y8U0!?#l&6andEd>W^-pM_%B2CCF~jaODUXFJ6~S1Q_s?P zQe2zSaGWeaW)Lz~Jz^EkaUu!jIp8;@T_k4VHc@!rgd~^z>><6x!@nmeJ%8e4;V6-~ zs-Ny1J|nFio=Fiht{P3*w<}7COwGczpHE{xANV9ac~G9Y-|lFUZ$OfT1NgEBqrFA< zm@#LYZ1Y0kyCG{)rnPC>9@o#;lT8B6H7X%*$HJTamJ`>~Xa}l^^QPW#8ZKj>puLdN*Q>0BEV1%xgdDipPRe@Nf@BqlCUuoE|liiBNQxIjTj}xzg zN)jVp{u0qh4!cR$Fbj#6Q(zJqON80j_li}TQ{2~#c6*#xF3b7Gsb|vP%y&a~!61$= z=Xp%$D}HSJ&5;N0f4x0&KSvy?{Ez#|;sX6+aY_)VxmEU3@9{g9t+t}u@Z9L6;KHyl zd})42PFyuDsn8jrix#%DkY~wF=OhuKoI;1m>pMgj<>Qe!86IJSeR$C|IxwDYcw=)#|+Bt6A zYq^_sN;zsC_HfZalQSgO<}PxHQK-%?+?NtedJBXqSQ&*Mg(tkTj11CJ8mJDxWYBqc zc*FFyi$`WFdvZmf1DvPs7rVe6D~J#e@6bE-W>pBAgxb)WhUt8d>z?TK2xB0&fug2s z;Okx4J2-Oaup)D=LSVL!xCE-S^R3)Z&YC2vOi*e)c_=IvF@T2cS(lVcS*Gb179HVn zoP|mm?u+v+OP+5s1vEc@;Z0U=HMD53Sa~Cs7BKyD%>LNef^%J_v4`jPS>xJNn}%Yo z!!z>$FnWLnooF96kJh#o@^HDlYii32N^FL5N!6NAg`}#OB*A-9r+s*wW5_gNC2DS% zi$|Y!kgyfAn*yin8AtYNeCZCG`P3#x<6hMmracwo8-<<`?aB)lLfu8dSuL`e6og7& zzFC(gHVbNe4?7as(^)8qGQZx=k<6hbZRYBr8n2bM-v*IZyCMZhg0y{3S@eFld|@I2 zC%QNr$us{VBa1fGVM}NW4eZH5%?6Pg|?6lClk^miWr?*ZrnGd z$dF>5;YsyE1C=>{>5nGB9H2p+S;Z(x+Pae4Lfo-Lq-?CDy76?{dT4nnt9%K=JD7gp z`?lCV#k?aE(_9wzOL`T?>KW8*4g##qTPv3!#$qg_Z08$?b!cJ{bszOCVg)%GCu!$5 z((+y&)Q+suYbzYGf-j6QN@Jc*4y%N(-w3I~x5A}nUW3;V8`g4B4lMv4HoO*uuwc5} zlyU}YUXZ8L2qSLaJd(aFDo^1p@2KN+0_QCgXTcwy|>hAO*8b=#c_mkAOZyKhHh z&hK9KL=Y&#!oKzaWG{+0&D!p`2aFPdr}@XkMG$O*t^MPOfiWpzRG(mfXeu$XB&*aj zJlv-$n-d3uaiWhH0)wKCKchl8g@o7`3`FabcvvUf;1FBOOCsmM@LN`^px@WFZjGmrz2O2eM~R6g4{at^>#vrh8jii$ z7E`MYd_wuq-h9^9fgvRiLf-1}fLP+C<)a+C&PcXBQPXd_1$%}uh~$9#YVN7cy~_~` zzgi@C|LMogeW=KY$tfSV z2hI1sVCN@OUb*#C9%v<(8NYU5bwHXWB4=wnBwwK;zE`7QLwt{p3y*Hjw~|Mt?p7tM zSkm3rqH1ZDXI5X7oOw`$%vpnjSUvUq9h|N~*m+6p9Z*hS8=a3&LPlxEYwHCg<&mDe zCSj-1rmz%pMaRAKsQEy|F%hGJ4a^<&Q1l0C=QU<5U>m93O8~v@)J&hM!9SdYh zWG6W;B>if>Y-`p5AO~HgO?sDpUBodjp<^1_Ifx$f<8l3l46H!!idptxNn)7NYF2)l zh&y1M`n@Z-87i2qC#1$LhtDPOX$YVw0X>7cw9n;6*7hes`Y1T~#C>4swj`Yt?qICN zjf2}G7Xt0g1#>8-z38Vll5vT2(2B8&ZD@}p9gvhHOP#aAz%kM~+X>533Gd5|BWdhMg+kw=r@@#!A%##7(8Fvr*-?>}%0~pYJR}!Qm@geG zdjD4k-P>7~nQ5ZfB$p8*G6Lr;tyxUXH$4#~w_aLMEnNz3q1{-I?l6fdtITX;(uZ>5we zNZ*KcY`bcXHo2c9gw3+IDE?|ZuD$PSZIjaFn(*kEt?e~=68RqEndse&(od8^^O4GX z$812Xceg}4yOZ0ir`=?w@tr(7llFKHM|?e#hwC@4LcErr_%4!FuOcy)Qz#uW!X}Km zG#ginCd7^=RM<{kPFq#a&jU?m0^Zad@}z$0U$W$gC;t_l{Ff~Ghk0^$i$fS&(>x>V zIJG6-apuk?Xmp@|7IUBjN+uwD0{sHW6i!-%zqO}VIE)tWPmVcsJS-te1m8eJR17pF z2!?SWITZLNI)pwY#s@`Jhq-t|SZw~r35bXDcq;A?C~QJKJqTz{4WjGN=CC!V5(h_y z#_%8&&H?Ssf4CZy%Njj>fx;Fhc*GN+CH#ay zeYP$|2No}+HPY##O=jWaHG8$CCEgLqE_y(EE8u#qD;^=JS+A$od^1_q!Ainz+lCRN zz`GR)YZmW|xn@}amgQOLiN9cHatrPu)gH!El=(X@ zQM>i5fGI?)#m|MkGW?!4{tCBbVw$#vvuHq^E_oWxzXgsJI$iMM8@+1k7@LG?f1f}V zvvc_3T0(YxCFlcQS|_SV;48R+XPshz+AE)6KPjij)kvX}Azmj-OI4b$exBuf_WIp* z%}NM6JCDL0tqH=^a)0S5^{5Qz*NYv~*Oh;XY<<~iIjPs@Z|=SL5`MPKi(}I7=XO+H zWt1?n$)kRxZI~bQ<$`)MA@1{0O_&E;1%&oa1Z#t$UMB(^-c{9V6TB1n9@`*pPvtz7lr*k5##FtUxF?+b-WZIzZ0pUJ79)f@ zBukf3KHX;Z;nsXSZm>frw`6tqvDbW+mvH&!nI!&Fj{4w8(8;@O{FP1HC)X=3ev>n^ z?Jj@03TCA8#p?9({3toF8hH4_rp8_Inz>7_=(2p-csaxAac-s-K$Hj7#~*TAG%?vr zs2wp(-GYVWz1D5&R4~_RL7Rg%5}}(Ze2a}^c7jG7t6=>bjoPou42fAJ-ooVh)E~!7 z=d3q2>TFs$-_SOFq*Pb7I(C)PDq!>@kphvA!Ir*1tP>NvnO!-(m9AlGr5BaEWeYl1 z%z&X0f}Sg2E%r`@{2_Cb8r#o%KcxrMo}d4kR9-9O;f-+jE{0fhvdOxVRvm}^)Pp~L zLw!GYBvL+TDh6GD2|r~HnN@IZcCh+W+aEj~;sgn1;mc^0DfI$Ct{>0boQk|dU!AkK z^RAxW{?!D3wKML%lEzXcL;b?6!(R-uMN;mSY;gP^iWal;mznP-4~xhDiA#>slmBLO z{#E4pC)1NdnX)CrsS#Bp_G#?g}5#&{zIZ=XVcS2rvXOP}ncPpG*y+275S? z10!M4jwH&H=m2YIcmy8io)nf6pAh0;m*pK*oLuM~97@80h-k!N0(+=YK!-a`-uMKf zKtc=#8yf-|_#v>dXRznJcgny}&zqe1m!OGBD0O;fj&15AtaGL9Lj;6#W#sdxFPjU~ z#J#z1>pxvg`QfK7I|xXu3(+Y66$rZk@~BeW7S1Dj_U{T0D=Uv#cWt$JM>Nl$2L&|* z?L7S`4lS!!%iEHS1Q?I4f}LtXXBNzKdwtnWq9;fCa|DM;|9nT-b+4vCrW)t!{`S)!<1D6MQQ?Y_Uw4)PxPTpftnn-QZeF>Wt#Vtx`aylK+t$jW37EF*88|pJtuyl6m!;_`9B6uvn8h3!5(Ny_=>1(<(@merlRqfU5tG-(_gRfc6iClY89_pv zh76-CTm;q{R4e!pjnbl_BCoD6E;&VRb+fLY?YhNcCOL4vG|1*7qbsNxXozd?gQEh$ z&#alp3gthJI$bh*!_h5Jpm!oaso%b(y=QX5UEGT_Ibh5$FuAJ7^}W)+vMy7_rF2gY zN+x@*O*wRY|L)rfQ>qKw(KaZ86hISguAaDCXC}Y2Cbk7oMu}Iq{b#F*feydUz)=eO zZ<+EhtiZ$ofJ;YPGXH*QTDc;XufR2}t~|1Ib+&WHXewJ>xrjtM5#3xIAG>&F_!=U literal 0 HcmV?d00001 diff --git a/public/js/export/index.js b/public/js/export/index.js new file mode 100644 index 0000000000..a44fe721c7 --- /dev/null +++ b/public/js/export/index.js @@ -0,0 +1,121 @@ +/* globals token, jobKey */ + +/* + * index.js + * Copyright (C) 2016 Sander Dorigo + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +var intervalId = 0; + +$(function () { + "use strict"; + // on click of export button: + // - hide form + // - post export command + // - start polling progress. + // - return false, + + $('#export').submit(startExport); + } +); + +function startExport() { + "use strict"; + console.log('Start export...'); + hideForm(); + showLoading(); + + // do export + callExport(); + + return false; +} + + +function hideForm() { + "use strict"; + $('#form-body').hide(); + $('#do-export-button').hide(); +} + +function showForm() { + "use strict"; + $('#form-body').show(); + $('#do-export-button').show(); +} + +function showLoading() { + "use strict"; + $('#export-loading').show(); +} + +function hideLoading() { + "use strict"; + $('#export-loading').hide(); +} + +function showDownload() { + "use strict"; + $('#export-download').show(); +} + +function showError(text) { + "use strict"; + $('#export-error').show(); + $('#export-error>p').text(text); +} + +function callExport() { + "use strict"; + console.log('Start callExport()...') + var data = $('#export').serialize(); + + // call status, keep calling it until response is "finished"? + intervalId = window.setInterval(checkStatus, 500); + + $.post('export/submit', data).done(function (data) { + console.log('Export hath succeeded!'); + + // stop polling: + window.clearTimeout(intervalId); + + // call it one last time: + window.setTimeout(checkStatus, 500); + + // somewhere here is a download link. + + // keep the loading thing, for debug. + hideLoading(); + + // show download + showDownload(); + + }).fail(function () { + // show error. + // show form again. + showError('The export failed. Please check the log files to find out why.'); + + // stop polling: + window.clearTimeout(intervalId); + + hideLoading(); + showForm(); + + }); +} + +function checkStatus() { + "use strict"; + console.log('get status...'); + $.getJSON('export/status/' + jobKey).done(function (data) { + putStatusText(data.status); + }); +} + +function putStatusText(status) { + "use strict"; + $('#status-message').text(status); +} \ No newline at end of file diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 21ec2c6f79..36aa71df2d 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -38,6 +38,18 @@ return [ 'new_budget' => 'New budget', 'new_bill' => 'New bill', + // export data: + 'import_and_export' => 'Import and export', + 'export_data' => 'Export data', + 'export_data_intro' => 'For backup purposes, when migrating to another system or when migrating to another Firefly III installation.', + 'export_format' => 'Export format', + 'export_format_csv' => 'Comma separated values (CSV file)', + 'export_format_mt940' => 'MT940 compatible format', + 'export_included_accounts' => 'Export transactions from these accounts', + 'include_config_help' => 'For easy re-import into Firefly III', + 'include_old_uploads_help' => 'Firefly III does not throw away the original CSV files you have imported in the past. You can include them in your export.', + 'do_export' => 'Export', + // rules 'rules' => 'Rules', 'rules_explanation' => 'Here you can manage rules. Rules are triggered when a transaction is created or updated. Then, if the transaction has certain properties (called "triggers") Firefly will execute the "actions". Combined, you can make Firefly respond in a certain way to new transactions.', diff --git a/resources/lang/en_US/form.php b/resources/lang/en_US/form.php index d1d398ebc2..6cdb39a8bc 100644 --- a/resources/lang/en_US/form.php +++ b/resources/lang/en_US/form.php @@ -70,6 +70,12 @@ return [ 'size' => 'Size', 'trigger' => 'Trigger', 'stop_processing' => 'Stop processing', + 'start_date' => 'Start of export range', + 'end_date' => 'End of export range', + 'export_format' => 'File format', + 'include_attachments' => 'Include uploaded attachments', + 'include_config' => 'Include configuration file', + 'include_old_uploads' => 'Include imported data', 'csv_comma' => 'A comma (,)', 'csv_semicolon' => 'A semicolon (;)', diff --git a/resources/views/export/index.twig b/resources/views/export/index.twig new file mode 100644 index 0000000000..ad603cbc2d --- /dev/null +++ b/resources/views/export/index.twig @@ -0,0 +1,129 @@ +{% extends "./layout/default.twig" %} + +{% block breadcrumbs %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +{% endblock %} + +{% block content %} + + + +
+ + + +
+
+ +
+
+

{{ 'export_data'|_ }}

+
+
+ + + +
+

+ {{ 'export_data_intro'|_ }} +

+
+
+ {{ ExpandedForm.date('start_date', first) }} + + {{ ExpandedForm.date('end_date', today) }} + + +
+ + +
+ {% if errors.has('exportFormat') %} + + {% endif %} + + {% for format in formats %} +
+ +
+ {% endfor %} +
+
+ + + + +
+ + + +
+ + {% if errors.has('accounts') %} + + {% endif %} + {% for account in accounts %} +
+ +
+ {% endfor %} +
+
+ + {{ ExpandedForm.checkbox('include_attachments','1', true) }} + + {{ ExpandedForm.checkbox('include_config','1', true, {helpText: 'include_config_help'|_}) }} + + {{ ExpandedForm.checkbox('include_old_uploads','1', false, {helpText: 'include_old_uploads_help'|_}) }} +
+
+
+
+ +
+
+
+
+ + +{% endblock %} +{% block scripts %} + + +{% endblock %} diff --git a/resources/views/partials/menu-sidebar.twig b/resources/views/partials/menu-sidebar.twig index 1683986cbc..0f82830fc7 100644 --- a/resources/views/partials/menu-sidebar.twig +++ b/resources/views/partials/menu-sidebar.twig @@ -109,6 +109,33 @@ + +
  • + + + + {% if Config.get('firefly.csv_import_enabled') %} + {{ 'import_and_export'|_ }} + {% else %} + {{ 'export_data'|_ }} + {% endif %} + + + + + +
  • +
  • @@ -127,11 +154,6 @@
  • {{ 'currencies'|_ }}
  • - {% if Config.get('firefly.csv_import_enabled') %} -
  • - {{ 'csv_import'|_ }} -
  • - {% endif %} From 744205cb6e4eac46b9f6335368035a72ea0910de Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 17:21:46 +0100 Subject: [PATCH 022/448] New composer. --- composer.lock | 1615 ++----------------------------------------------- 1 file changed, 56 insertions(+), 1559 deletions(-) diff --git a/composer.lock b/composer.lock index fef713fd3d..144f131df6 100644 --- a/composer.lock +++ b/composer.lock @@ -759,16 +759,16 @@ }, { "name": "laravel/framework", - "version": "v5.2.12", + "version": "v5.2.14", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "6b6255ad7bfbdb721b8d00b09d52b146c5d363d7" + "reference": "ce63ba53d4891bdbb5e1aaeced1b5dd34edbc86f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/6b6255ad7bfbdb721b8d00b09d52b146c5d363d7", - "reference": "6b6255ad7bfbdb721b8d00b09d52b146c5d363d7", + "url": "https://api.github.com/repos/laravel/framework/zipball/ce63ba53d4891bdbb5e1aaeced1b5dd34edbc86f", + "reference": "ce63ba53d4891bdbb5e1aaeced1b5dd34edbc86f", "shasum": "" }, "require": { @@ -883,7 +883,7 @@ "framework", "laravel" ], - "time": "2016-01-26 04:15:37" + "time": "2016-02-03 14:19:04" }, { "name": "laravelcollective/html", @@ -1644,16 +1644,16 @@ }, { "name": "symfony/console", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "ebcdc507829df915f4ca23067bd59ee4ef61f6c3" + "reference": "5a02eaadaa285e2bb727eb6bbdfb8201fcd971b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/ebcdc507829df915f4ca23067bd59ee4ef61f6c3", - "reference": "ebcdc507829df915f4ca23067bd59ee4ef61f6c3", + "url": "https://api.github.com/repos/symfony/console/zipball/5a02eaadaa285e2bb727eb6bbdfb8201fcd971b0", + "reference": "5a02eaadaa285e2bb727eb6bbdfb8201fcd971b0", "shasum": "" }, "require": { @@ -1700,20 +1700,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2015-12-22 10:39:06" + "time": "2016-02-02 13:44:19" }, { "name": "symfony/debug", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "73612266ac709769effdbfc0762e5b07cfd2ac2a" + "reference": "29606049ced1ec715475f88d1bbe587252a3476e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/73612266ac709769effdbfc0762e5b07cfd2ac2a", - "reference": "73612266ac709769effdbfc0762e5b07cfd2ac2a", + "url": "https://api.github.com/repos/symfony/debug/zipball/29606049ced1ec715475f88d1bbe587252a3476e", + "reference": "29606049ced1ec715475f88d1bbe587252a3476e", "shasum": "" }, "require": { @@ -1757,20 +1757,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2015-12-26 13:39:53" + "time": "2016-01-27 05:14:46" }, { "name": "symfony/event-dispatcher", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "d36355e026905fa5229e1ed7b4e9eda2e67adfcf" + "reference": "4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d36355e026905fa5229e1ed7b4e9eda2e67adfcf", - "reference": "d36355e026905fa5229e1ed7b4e9eda2e67adfcf", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa", + "reference": "4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa", "shasum": "" }, "require": { @@ -1817,20 +1817,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2015-10-30 23:35:59" + "time": "2016-01-27 05:14:46" }, { "name": "symfony/finder", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "8617895eb798b6bdb338321ce19453dc113e5675" + "reference": "623bda0abd9aa29e529c8e9c08b3b84171914723" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/8617895eb798b6bdb338321ce19453dc113e5675", - "reference": "8617895eb798b6bdb338321ce19453dc113e5675", + "url": "https://api.github.com/repos/symfony/finder/zipball/623bda0abd9aa29e529c8e9c08b3b84171914723", + "reference": "623bda0abd9aa29e529c8e9c08b3b84171914723", "shasum": "" }, "require": { @@ -1866,20 +1866,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2015-12-05 11:13:14" + "time": "2016-01-27 05:14:46" }, { "name": "symfony/http-foundation", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "939c8c28a5b1e4ab7317bc30c1f9aa881c4b06b5" + "reference": "9344a87ceedfc50354a39653e54257ee9aa6a77d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/939c8c28a5b1e4ab7317bc30c1f9aa881c4b06b5", - "reference": "939c8c28a5b1e4ab7317bc30c1f9aa881c4b06b5", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/9344a87ceedfc50354a39653e54257ee9aa6a77d", + "reference": "9344a87ceedfc50354a39653e54257ee9aa6a77d", "shasum": "" }, "require": { @@ -1918,20 +1918,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2015-12-18 15:43:53" + "time": "2016-02-02 13:44:19" }, { "name": "symfony/http-kernel", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "f7933e9f19e26e7baba7ec04735b466fedd3a6db" + "reference": "cec02604450481ac26710ca4249cc61b57b23942" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/f7933e9f19e26e7baba7ec04735b466fedd3a6db", - "reference": "f7933e9f19e26e7baba7ec04735b466fedd3a6db", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/cec02604450481ac26710ca4249cc61b57b23942", + "reference": "cec02604450481ac26710ca4249cc61b57b23942", "shasum": "" }, "require": { @@ -2000,7 +2000,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2015-12-26 16:46:13" + "time": "2016-02-03 12:38:44" }, { "name": "symfony/polyfill-mbstring", @@ -2171,16 +2171,16 @@ }, { "name": "symfony/process", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "f4794f1d00f0746621be3020ffbd8c5e0b217ee3" + "reference": "dfecef47506179db2501430e732adbf3793099c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/f4794f1d00f0746621be3020ffbd8c5e0b217ee3", - "reference": "f4794f1d00f0746621be3020ffbd8c5e0b217ee3", + "url": "https://api.github.com/repos/symfony/process/zipball/dfecef47506179db2501430e732adbf3793099c8", + "reference": "dfecef47506179db2501430e732adbf3793099c8", "shasum": "" }, "require": { @@ -2216,20 +2216,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2015-12-23 11:04:02" + "time": "2016-02-02 13:44:19" }, { "name": "symfony/routing", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "3b1bac52f42cb0f54df1a2dbabd55a1d214e2a59" + "reference": "4686baa55a835e1c1ede9b86ba02415c8c8d6166" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/3b1bac52f42cb0f54df1a2dbabd55a1d214e2a59", - "reference": "3b1bac52f42cb0f54df1a2dbabd55a1d214e2a59", + "url": "https://api.github.com/repos/symfony/routing/zipball/4686baa55a835e1c1ede9b86ba02415c8c8d6166", + "reference": "4686baa55a835e1c1ede9b86ba02415c8c8d6166", "shasum": "" }, "require": { @@ -2290,20 +2290,20 @@ "uri", "url" ], - "time": "2015-12-23 08:00:11" + "time": "2016-01-27 05:14:46" }, { "name": "symfony/translation", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "dff0867826a7068d673801b7522f8e2634016ef9" + "reference": "2de0b6f7ebe43cffd8a06996ebec6aab79ea9e91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/dff0867826a7068d673801b7522f8e2634016ef9", - "reference": "dff0867826a7068d673801b7522f8e2634016ef9", + "url": "https://api.github.com/repos/symfony/translation/zipball/2de0b6f7ebe43cffd8a06996ebec6aab79ea9e91", + "reference": "2de0b6f7ebe43cffd8a06996ebec6aab79ea9e91", "shasum": "" }, "require": { @@ -2354,20 +2354,20 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2015-12-05 17:45:07" + "time": "2016-02-02 13:44:19" }, { "name": "symfony/var-dumper", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "87db8700deb12ba2b65e858f656a1f885530bcb0" + "reference": "24bb94807eff00db49374c37ebf56a0304e8aef3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/87db8700deb12ba2b65e858f656a1f885530bcb0", - "reference": "87db8700deb12ba2b65e858f656a1f885530bcb0", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/24bb94807eff00db49374c37ebf56a0304e8aef3", + "reference": "24bb94807eff00db49374c37ebf56a0304e8aef3", "shasum": "" }, "require": { @@ -2417,7 +2417,7 @@ "debug", "dump" ], - "time": "2015-12-05 11:13:14" + "time": "2016-01-07 13:38:51" }, { "name": "twig/twig", @@ -2654,1510 +2654,7 @@ "time": "2015-11-12 17:38:37" } ], - "packages-dev": [ - { - "name": "barryvdh/laravel-debugbar", - "version": "v2.1.1", - "source": { - "type": "git", - "url": "https://github.com/barryvdh/laravel-debugbar.git", - "reference": "974fd16e328ca851a081449100d9509af59cf0ff" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/974fd16e328ca851a081449100d9509af59cf0ff", - "reference": "974fd16e328ca851a081449100d9509af59cf0ff", - "shasum": "" - }, - "require": { - "illuminate/support": "~5.0.17|5.1.*|5.2.*", - "maximebf/debugbar": "~1.11.0", - "php": ">=5.4.0", - "symfony/finder": "~2.6|~3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "autoload": { - "psr-4": { - "Barryvdh\\Debugbar\\": "src/" - }, - "files": [ - "src/helpers.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Barry vd. Heuvel", - "email": "barryvdh@gmail.com" - } - ], - "description": "PHP Debugbar integration for Laravel", - "keywords": [ - "debug", - "debugbar", - "laravel", - "profiler", - "webprofiler" - ], - "time": "2015-12-22 06:22:38" - }, - { - "name": "barryvdh/laravel-ide-helper", - "version": "v2.1.2", - "source": { - "type": "git", - "url": "https://github.com/barryvdh/laravel-ide-helper.git", - "reference": "d82e8f191fb043a0f8cbf2de64fd3027bfa4f772" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/d82e8f191fb043a0f8cbf2de64fd3027bfa4f772", - "reference": "d82e8f191fb043a0f8cbf2de64fd3027bfa4f772", - "shasum": "" - }, - "require": { - "illuminate/console": "5.0.x|5.1.x|5.2.x", - "illuminate/filesystem": "5.0.x|5.1.x|5.2.x", - "illuminate/support": "5.0.x|5.1.x|5.2.x", - "php": ">=5.4.0", - "phpdocumentor/reflection-docblock": "2.0.4", - "symfony/class-loader": "~2.3" - }, - "require-dev": { - "doctrine/dbal": "~2.3" - }, - "suggest": { - "doctrine/dbal": "Load information from the database about models for phpdocs (~2.3)" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - }, - "autoload": { - "psr-4": { - "Barryvdh\\LaravelIdeHelper\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Barry vd. Heuvel", - "email": "barryvdh@gmail.com" - } - ], - "description": "Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.", - "keywords": [ - "autocomplete", - "codeintel", - "helper", - "ide", - "laravel", - "netbeans", - "phpdoc", - "phpstorm", - "sublime" - ], - "time": "2015-12-21 19:48:06" - }, - { - "name": "doctrine/instantiator", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2015-06-14 21:17:01" - }, - { - "name": "fzaninotto/faker", - "version": "v1.5.0", - "source": { - "type": "git", - "url": "https://github.com/fzaninotto/Faker.git", - "reference": "d0190b156bcca848d401fb80f31f504f37141c8d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/d0190b156bcca848d401fb80f31f504f37141c8d", - "reference": "d0190b156bcca848d401fb80f31f504f37141c8d", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~1.5" - }, - "suggest": { - "ext-intl": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.5.x-dev" - } - }, - "autoload": { - "psr-4": { - "Faker\\": "src/Faker/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "François Zaninotto" - } - ], - "description": "Faker is a PHP library that generates fake data for you.", - "keywords": [ - "data", - "faker", - "fixtures" - ], - "time": "2015-05-29 06:29:14" - }, - { - "name": "hamcrest/hamcrest-php", - "version": "v1.2.2", - "source": { - "type": "git", - "url": "https://github.com/hamcrest/hamcrest-php.git", - "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c", - "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "replace": { - "cordoval/hamcrest-php": "*", - "davedevelopment/hamcrest-php": "*", - "kodova/hamcrest-php": "*" - }, - "require-dev": { - "phpunit/php-file-iterator": "1.3.3", - "satooshi/php-coveralls": "dev-master" - }, - "type": "library", - "autoload": { - "classmap": [ - "hamcrest" - ], - "files": [ - "hamcrest/Hamcrest.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD" - ], - "description": "This is the PHP port of Hamcrest Matchers", - "keywords": [ - "test" - ], - "time": "2015-05-11 14:41:42" - }, - { - "name": "johnkary/phpunit-speedtrap", - "version": "v1.0.1", - "source": { - "type": "git", - "url": "https://github.com/johnkary/phpunit-speedtrap.git", - "reference": "76a26f8a903a9434608cdad2b41c40cd134ea326" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/johnkary/phpunit-speedtrap/zipball/76a26f8a903a9434608cdad2b41c40cd134ea326", - "reference": "76a26f8a903a9434608cdad2b41c40cd134ea326", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*|~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-0": { - "JohnKary": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "John Kary", - "email": "john@johnkary.net" - } - ], - "description": "Find slow tests in your PHPUnit test suite", - "homepage": "https://github.com/johnkary/phpunit-speedtrap", - "keywords": [ - "phpunit", - "profile", - "slow" - ], - "time": "2015-09-13 19:01:00" - }, - { - "name": "maximebf/debugbar", - "version": "v1.11.0", - "source": { - "type": "git", - "url": "https://github.com/maximebf/php-debugbar.git", - "reference": "07741d84d39d10f00551c94284cdefcc69703e77" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/07741d84d39d10f00551c94284cdefcc69703e77", - "reference": "07741d84d39d10f00551c94284cdefcc69703e77", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "psr/log": "^1.0", - "symfony/var-dumper": "^2.6|^3.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0|^5.0" - }, - "suggest": { - "kriswallsmith/assetic": "The best way to manage assets", - "monolog/monolog": "Log using Monolog", - "predis/predis": "Redis storage" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11-dev" - } - }, - "autoload": { - "psr-4": { - "DebugBar\\": "src/DebugBar/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Maxime Bouroumeau-Fuseau", - "email": "maxime.bouroumeau@gmail.com", - "homepage": "http://maximebf.com" - }, - { - "name": "Barry vd. Heuvel", - "email": "barryvdh@gmail.com" - } - ], - "description": "Debug bar in the browser for php application", - "homepage": "https://github.com/maximebf/php-debugbar", - "keywords": [ - "debug", - "debugbar" - ], - "time": "2015-12-10 09:50:24" - }, - { - "name": "mockery/mockery", - "version": "0.9.4", - "source": { - "type": "git", - "url": "https://github.com/padraic/mockery.git", - "reference": "70bba85e4aabc9449626651f48b9018ede04f86b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/padraic/mockery/zipball/70bba85e4aabc9449626651f48b9018ede04f86b", - "reference": "70bba85e4aabc9449626651f48b9018ede04f86b", - "shasum": "" - }, - "require": { - "hamcrest/hamcrest-php": "~1.1", - "lib-pcre": ">=7.0", - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.9.x-dev" - } - }, - "autoload": { - "psr-0": { - "Mockery": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Pádraic Brady", - "email": "padraic.brady@gmail.com", - "homepage": "http://blog.astrumfutura.com" - }, - { - "name": "Dave Marshall", - "email": "dave.marshall@atstsolutions.co.uk", - "homepage": "http://davedevelopment.co.uk" - } - ], - "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", - "homepage": "http://github.com/padraic/mockery", - "keywords": [ - "BDD", - "TDD", - "library", - "mock", - "mock objects", - "mockery", - "stub", - "test", - "test double", - "testing" - ], - "time": "2015-04-02 19:54:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "dflydev/markdown": "~1.0", - "erusev/parsedown": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "phpDocumentor": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "mike.vanriel@naenius.com" - } - ], - "time": "2015-02-03 12:10:50" - }, - { - "name": "phpspec/prophecy", - "version": "v1.5.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4745ded9307786b730d7a60df5cb5a6c43cf95f7", - "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "phpdocumentor/reflection-docblock": "~2.0", - "sebastian/comparator": "~1.1" - }, - "require-dev": { - "phpspec/phpspec": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "psr-0": { - "Prophecy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2015-08-13 10:07:40" - }, - { - "name": "phpunit/php-code-coverage", - "version": "2.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" - }, - "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2015-10-06 15:47:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2015-06-21 13:08:43" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21 13:50:34" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.7", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2015-06-21 08:01:12" - }, - { - "name": "phpunit/php-token-stream", - "version": "1.4.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2015-09-15 10:49:45" - }, - { - "name": "phpunit/phpunit", - "version": "4.8.21", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ea76b17bced0500a28098626b84eda12dbcf119c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ea76b17bced0500a28098626b84eda12dbcf119c", - "reference": "ea76b17bced0500a28098626b84eda12dbcf119c", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": ">=1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.1", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.8.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2015-12-12 07:45:58" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2015-10-02 06:51:40" - }, - { - "name": "sebastian/comparator", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2015-07-26 15:48:44" - }, - { - "name": "sebastian/diff", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "time": "2015-12-08 07:14:41" - }, - { - "name": "sebastian/environment", - "version": "1.3.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6e7133793a8e5a5714a551a8324337374be209df" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e7133793a8e5a5714a551a8324337374be209df", - "reference": "6e7133793a8e5a5714a551a8324337374be209df", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2015-12-02 08:37:27" - }, - { - "name": "sebastian/exporter", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "7ae5513327cb536431847bcc0c10edba2701064e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", - "reference": "7ae5513327cb536431847bcc0c10edba2701064e", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2015-06-21 07:55:53" - }, - { - "name": "sebastian/global-state", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2015-10-12 03:26:01" - }, - { - "name": "sebastian/recursion-context", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-11-11 19:50:13" - }, - { - "name": "sebastian/version", - "version": "1.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21 13:59:46" - }, - { - "name": "symfony/class-loader", - "version": "v2.8.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/class-loader.git", - "reference": "98e9089a428ed0e39423b67352c57ef5910a3269" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/class-loader/zipball/98e9089a428ed0e39423b67352c57ef5910a3269", - "reference": "98e9089a428ed0e39423b67352c57ef5910a3269", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "symfony/finder": "~2.0,>=2.0.5|~3.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\ClassLoader\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony ClassLoader Component", - "homepage": "https://symfony.com", - "time": "2016-01-03 15:33:41" - }, - { - "name": "symfony/css-selector", - "version": "v3.0.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/css-selector.git", - "reference": "4613311fd46e146f506403ce2f8a0c71d402d2a3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/4613311fd46e146f506403ce2f8a0c71d402d2a3", - "reference": "4613311fd46e146f506403ce2f8a0c71d402d2a3", - "shasum": "" - }, - "require": { - "php": ">=5.5.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\CssSelector\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jean-François Simon", - "email": "jeanfrancois.simon@sensiolabs.com" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony CssSelector Component", - "homepage": "https://symfony.com", - "time": "2015-12-05 17:45:07" - }, - { - "name": "symfony/dom-crawler", - "version": "v3.0.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/dom-crawler.git", - "reference": "7c622b0c9fb8bdb146d6dfa86c5f91dcbfdbc11d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/7c622b0c9fb8bdb146d6dfa86c5f91dcbfdbc11d", - "reference": "7c622b0c9fb8bdb146d6dfa86c5f91dcbfdbc11d", - "shasum": "" - }, - "require": { - "php": ">=5.5.9", - "symfony/polyfill-mbstring": "~1.0" - }, - "require-dev": { - "symfony/css-selector": "~2.8|~3.0" - }, - "suggest": { - "symfony/css-selector": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\DomCrawler\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony DomCrawler Component", - "homepage": "https://symfony.com", - "time": "2015-12-26 13:42:31" - }, - { - "name": "symfony/yaml", - "version": "v3.0.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "3df409958a646dad2bc5046c3fb671ee24a1a691" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/3df409958a646dad2bc5046c3fb671ee24a1a691", - "reference": "3df409958a646dad2bc5046c3fb671ee24a1a691", - "shasum": "" - }, - "require": { - "php": ">=5.5.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2015-12-26 13:39:53" - } - ], + "packages-dev": null, "aliases": [], "minimum-stability": "stable", "stability-flags": { From dd361bb9adf245de523aea7c68f74a1798a3456d Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 17:22:01 +0100 Subject: [PATCH 023/448] Delete files used. --- app/Export/Processor.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Export/Processor.php b/app/Export/Processor.php index 6f43561dd2..bd89e0bb0c 100644 --- a/app/Export/Processor.php +++ b/app/Export/Processor.php @@ -130,6 +130,11 @@ class Processor $zip->addFile($file, $zipName); } $zip->close(); + + // delete the files: + foreach ($this->getFiles() as $file) { + unlink($file); + } } /** From f300287814c04f58d8ff67b1c7a232a388e1d4c7 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 17:22:09 +0100 Subject: [PATCH 024/448] Better cleanup routine. --- app/Http/Controllers/ExportController.php | 2 ++ app/Repositories/ExportJob/ExportJobRepository.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 828b65683d..9c8c1e64c7 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -48,6 +48,8 @@ class ExportController extends Controller $name = 'Export job on ' . $date . '.zip'; $quoted = sprintf('"%s"', addcslashes($name, '"\\')); + $job->change('export_downloaded'); + return response(file_get_contents($file), 200) ->header('Content-Description', 'File Transfer') diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php index 8125c61033..20fe195cf1 100644 --- a/app/Repositories/ExportJob/ExportJobRepository.php +++ b/app/Repositories/ExportJob/ExportJobRepository.php @@ -29,8 +29,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface { $dayAgo = Carbon::create()->subDay(); ExportJob::where('created_at', '<', $dayAgo->format('Y-m-d H:i:s')) - ->where('status', 'never_started') - // TODO also delete others. + ->whereIn('status', ['never_started', 'export_status_finished', 'export_downloaded']) ->delete(); return true; From dbd32abdd1e17f8805fbdf9325594de3d30fa379 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 17:50:35 +0100 Subject: [PATCH 025/448] Also delete old files. --- .../ExportJob/ExportJobRepository.php | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php index 20fe195cf1..db5e1450e8 100644 --- a/app/Repositories/ExportJob/ExportJobRepository.php +++ b/app/Repositories/ExportJob/ExportJobRepository.php @@ -28,9 +28,24 @@ class ExportJobRepository implements ExportJobRepositoryInterface public function cleanup() { $dayAgo = Carbon::create()->subDay(); - ExportJob::where('created_at', '<', $dayAgo->format('Y-m-d H:i:s')) - ->whereIn('status', ['never_started', 'export_status_finished', 'export_downloaded']) - ->delete(); + $set = ExportJob::where('created_at', '<', $dayAgo->format('Y-m-d H:i:s')) + ->whereIn('status', ['never_started', 'export_status_finished', 'export_downloaded']) + ->get(); + + // loop set: + /** @var ExportJob $entry */ + foreach ($set as $entry) { + $key = $entry->key; + $len = strlen($key); + $files = scandir(storage_path('export')); + /** @var string $file */ + foreach ($files as $file) { + if (substr($file, 0, $len) === $key) { + unlink(storage_path('export') . DIRECTORY_SEPARATOR . $file); + } + } + $entry->delete(); + } return true; } From ee8c83bbd8cc5fe8f4d68e5c60f3af3cdc655e72 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 17:57:36 +0100 Subject: [PATCH 026/448] Some small fixes. --- app/Export/Collector/AttachmentCollector.php | 3 ++- app/Http/Controllers/ExportController.php | 10 ++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/Export/Collector/AttachmentCollector.php b/app/Export/Collector/AttachmentCollector.php index 93bc425909..56dc9704d0 100644 --- a/app/Export/Collector/AttachmentCollector.php +++ b/app/Export/Collector/AttachmentCollector.php @@ -45,7 +45,8 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface if (file_exists($originalFile)) { Log::debug('Stored 1 attachment'); $decrypted = Crypt::decrypt(file_get_contents($originalFile)); - $newFile = storage_path('export') . DIRECTORY_SEPARATOR . $this->job->key . '-Attachment nr. ' . $attachment->id . ' - ' . $attachment->filename; + $newFile = storage_path('export') . DIRECTORY_SEPARATOR . $this->job->key . '-Attachment nr. ' . $attachment->id . ' - ' + . $attachment->filename; file_put_contents($newFile, $decrypted); $this->getFiles()->push($newFile); } diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 9c8c1e64c7..01ee98ebcf 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -88,17 +88,11 @@ class ExportController extends Controller $accounts = $repository->getAccounts(['Default account', 'Asset account']); $formats = array_keys(Config::get('firefly.export_formats')); $defaultFormat = Preferences::get('export_format', Config::get('firefly.default_export_format'))->data; - //$first = session('first')->format('Y-m-d'); - $first = Carbon::create()->startOfYear()->format('Y-m-d'); - $today = Carbon::create()->format('Y-m-d'); + $first = session('first')->format('Y-m-d'); + $today = Carbon::create()->format('Y-m-d'); return view('export.index', compact('accounts', 'job', 'formats', 'defaultFormat', 'first', 'today')); - // select date range - // format - // select accounts - // include attachments - // include uploaded CSV files (if any) } /** From be74fbd677e84ff37c11ba43a1a91a0bef324023 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 06:31:27 +0100 Subject: [PATCH 027/448] The tests now reflect that not all category-related views support all date ranges, see issue #170 --- tests/TestCase.php | 51 ++++++++++++++++--- .../Controllers/AccountControllerTest.php | 16 ++++-- .../Controllers/CategoryControllerTest.php | 16 ++++-- 3 files changed, 68 insertions(+), 15 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index d3bb04192a..65fc680453 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,5 +1,6 @@ id)->where('name', 'viewRange')->delete(); + Preference::create( + [ + 'user_id' => $user->id, + 'name' => 'viewRange', + 'data' => $range, + ] + ); + } + } + /** * Creates the application. * @@ -29,19 +49,27 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase } /** - * @return User + * @return array */ - public function emptyUser() + public function dateRangeProvider() { - return User::find(2); + return [ + 'one day' => ['1D'], + 'one week' => ['1W'], + 'one month' => ['1M'], + 'three months' => ['3M'], + 'six months' => ['6M'], + 'one year' => ['1Y'], + 'custom range' => ['custom'], + ]; } /** * @return User */ - public function toBeDeletedUser() + public function emptyUser() { - return User::find(3); + return User::find(2); } /** @@ -73,6 +101,7 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase } // if the database copy does exists, copy back as original. + $this->session( [ 'start' => Carbon::now()->startOfMonth(), @@ -98,12 +127,22 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase } + /** + * @return User + */ + public function toBeDeletedUser() + { + return User::find(3); + } + /** * @return User */ public function user() { - return User::find(1); + $user = User::find(1); + + return $user; } /** diff --git a/tests/acceptance/Controllers/AccountControllerTest.php b/tests/acceptance/Controllers/AccountControllerTest.php index bd24e88edf..275b82b380 100644 --- a/tests/acceptance/Controllers/AccountControllerTest.php +++ b/tests/acceptance/Controllers/AccountControllerTest.php @@ -13,12 +13,14 @@ class AccountControllerTest extends TestCase { /** - * @covers FireflyIII\Http\Controllers\AccountController::create - * @covers FireflyIII\Http\Controllers\AccountController::__construct + * @covers FireflyIII\Http\Controllers\AccountController::create + * @covers FireflyIII\Http\Controllers\AccountController::__construct + * @dataProvider dateRangeProvider */ - public function testCreate() + public function testCreate($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/accounts/create/asset'); $this->assertResponseStatus(200); } @@ -58,20 +60,24 @@ class AccountControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\AccountController::index * @covers FireflyIII\Http\Controllers\AccountController::isInArray + * @dataProvider dateRangeProvider */ - public function testIndex() + public function testIndex($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/accounts/asset'); $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\AccountController::show + * @dataProvider dateRangeProvider */ - public function testShow() + public function testShow($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/accounts/show/1'); $this->assertResponseStatus(200); } diff --git a/tests/acceptance/Controllers/CategoryControllerTest.php b/tests/acceptance/Controllers/CategoryControllerTest.php index 683772eb0b..f476d946db 100644 --- a/tests/acceptance/Controllers/CategoryControllerTest.php +++ b/tests/acceptance/Controllers/CategoryControllerTest.php @@ -61,20 +61,24 @@ class CategoryControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\CategoryController::index + * */ - public function testIndex() + public function testIndex($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/categories'); $this->assertResponseStatus(200); } /** * @covers FireflyIII\Http\Controllers\CategoryController::noCategory + * @dataProvider dateRangeProvider */ - public function testNoCategory() + public function testNoCategory($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/categories/list/noCategory'); $this->assertResponseStatus(200); } @@ -82,10 +86,12 @@ class CategoryControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\CategoryController::show * @covers FireflyIII\Http\Controllers\Controller::getSumOfRange + * @dataProvider dateRangeProvider */ - public function testShow() + public function testShow($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/categories/show/1'); $this->assertResponseStatus(200); @@ -93,10 +99,12 @@ class CategoryControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\CategoryController::showWithDate + * @dataProvider dateRangeProvider */ - public function testShowWithDate() + public function testShowWithDate($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/categories/show/1/20150101'); $this->assertResponseStatus(200); } From a26e8a5f830c46a726cf6f1c96f27f99bdac0927 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 06:36:56 +0100 Subject: [PATCH 028/448] Added the $range argument to every test that might need it. See #170 --- tests/acceptance/Controllers/BillControllerTest.php | 6 +++--- .../acceptance/Controllers/BudgetControllerTest.php | 12 ++++++------ .../Controllers/CurrencyControllerTest.php | 2 +- tests/acceptance/Controllers/HomeControllerTest.php | 2 +- tests/acceptance/Controllers/JsonControllerTest.php | 12 ++++++------ .../Controllers/PiggyBankControllerTest.php | 6 +++--- .../Controllers/PreferencesControllerTest.php | 4 ++-- .../acceptance/Controllers/ReportControllerTest.php | 8 ++++---- .../Controllers/TransactionControllerTest.php | 4 ++-- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/acceptance/Controllers/BillControllerTest.php b/tests/acceptance/Controllers/BillControllerTest.php index d30195dfec..74246d4aba 100644 --- a/tests/acceptance/Controllers/BillControllerTest.php +++ b/tests/acceptance/Controllers/BillControllerTest.php @@ -60,7 +60,7 @@ class BillControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BillController::index */ - public function testIndex() + public function testIndex($range) { $this->be($this->user()); $this->call('GET', '/bills'); @@ -70,7 +70,7 @@ class BillControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BillController::rescan */ - public function testRescan() + public function testRescan($range) { $this->be($this->user()); $this->call('GET', '/bills/rescan/1'); @@ -81,7 +81,7 @@ class BillControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BillController::show */ - public function testShow() + public function testShow($range) { $this->be($this->user()); $this->call('GET', '/bills/show/1'); diff --git a/tests/acceptance/Controllers/BudgetControllerTest.php b/tests/acceptance/Controllers/BudgetControllerTest.php index defdab45ad..42ab7f5764 100644 --- a/tests/acceptance/Controllers/BudgetControllerTest.php +++ b/tests/acceptance/Controllers/BudgetControllerTest.php @@ -17,7 +17,7 @@ class BudgetControllerTest extends TestCase * @covers FireflyIII\Http\Controllers\BudgetController::amount * @covers FireflyIII\Http\Controllers\BudgetController::__construct */ - public function testAmount() + public function testAmount($range) { $args = [ 'amount' => 1200, @@ -74,7 +74,7 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::index */ - public function testIndex() + public function testIndex($range) { $this->be($this->user()); $this->call('GET', '/budgets'); @@ -84,7 +84,7 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::noBudget */ - public function testNoBudget() + public function testNoBudget($range) { $this->be($this->user()); $this->call('GET', '/budgets/list/noBudget'); @@ -94,7 +94,7 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::postUpdateIncome */ - public function testPostUpdateIncome() + public function testPostUpdateIncome($range) { $args = [ 'amount' => 1200, @@ -108,7 +108,7 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::show */ - public function testShow() + public function testShow($range) { $this->be($this->user()); $this->call('GET', '/budgets/show/1'); @@ -155,7 +155,7 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::updateIncome */ - public function testUpdateIncome() + public function testUpdateIncome($range) { $this->be($this->user()); $this->call('GET', '/budgets/income'); diff --git a/tests/acceptance/Controllers/CurrencyControllerTest.php b/tests/acceptance/Controllers/CurrencyControllerTest.php index ec4ce59ebd..9fe635883f 100644 --- a/tests/acceptance/Controllers/CurrencyControllerTest.php +++ b/tests/acceptance/Controllers/CurrencyControllerTest.php @@ -74,7 +74,7 @@ class CurrencyControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\CurrencyController::index */ - public function testIndex() + public function testIndex($range) { $this->be($this->user()); $this->call('GET', '/currency'); diff --git a/tests/acceptance/Controllers/HomeControllerTest.php b/tests/acceptance/Controllers/HomeControllerTest.php index 299edd8274..a92a1ac315 100644 --- a/tests/acceptance/Controllers/HomeControllerTest.php +++ b/tests/acceptance/Controllers/HomeControllerTest.php @@ -43,7 +43,7 @@ class HomeControllerTest extends TestCase * @covers FireflyIII\Http\Controllers\HomeController::index * @covers FireflyIII\Http\Controllers\Controller::__construct */ - public function testIndex() + public function testIndex($range) { $this->be($this->user()); $this->call('GET', '/'); diff --git a/tests/acceptance/Controllers/JsonControllerTest.php b/tests/acceptance/Controllers/JsonControllerTest.php index 7454260e70..6910a46ca3 100644 --- a/tests/acceptance/Controllers/JsonControllerTest.php +++ b/tests/acceptance/Controllers/JsonControllerTest.php @@ -29,7 +29,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::boxBillsPaid */ - public function testBoxBillsPaid() + public function testBoxBillsPaid($range) { $this->be($this->user()); $this->call('GET', '/json/box/bills-paid'); @@ -39,7 +39,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::boxBillsUnpaid */ - public function testBoxBillsUnpaid() + public function testBoxBillsUnpaid($range) { $this->be($this->user()); $this->call('GET', '/json/box/bills-unpaid'); @@ -49,7 +49,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::boxIn */ - public function testBoxIn() + public function testBoxIn($range) { $this->be($this->user()); $this->call('GET', '/json/box/in'); @@ -59,7 +59,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::boxOut */ - public function testBoxOut() + public function testBoxOut($range) { $this->be($this->user()); $this->call('GET', '/json/box/out'); @@ -69,7 +69,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::categories */ - public function testCategories() + public function testCategories($range) { $this->be($this->user()); $this->call('GET', '/json/categories'); @@ -130,7 +130,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::transactionJournals */ - public function testTransactionJournals() + public function testTransactionJournals($range) { $type = factory(FireflyIII\Models\TransactionType::class)->make(); $repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); diff --git a/tests/acceptance/Controllers/PiggyBankControllerTest.php b/tests/acceptance/Controllers/PiggyBankControllerTest.php index 611d205b2f..eae72120d1 100644 --- a/tests/acceptance/Controllers/PiggyBankControllerTest.php +++ b/tests/acceptance/Controllers/PiggyBankControllerTest.php @@ -17,7 +17,7 @@ class PiggyBankControllerTest extends TestCase * @covers FireflyIII\Http\Controllers\PiggyBankController::add * @covers FireflyIII\Http\Controllers\PiggyBankController::__construct */ - public function testAdd() + public function testAdd($range) { $this->be($this->user()); $this->call('GET', '/piggy-banks/add/1'); @@ -69,7 +69,7 @@ class PiggyBankControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PiggyBankController::index */ - public function testIndex() + public function testIndex($range) { $this->be($this->user()); $this->call('GET', '/piggy-banks'); @@ -134,7 +134,7 @@ class PiggyBankControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PiggyBankController::show */ - public function testShow() + public function testShow($range) { $this->be($this->user()); $this->call('GET', '/piggy-banks/show/1'); diff --git a/tests/acceptance/Controllers/PreferencesControllerTest.php b/tests/acceptance/Controllers/PreferencesControllerTest.php index 3b29a397e5..e1220058b6 100644 --- a/tests/acceptance/Controllers/PreferencesControllerTest.php +++ b/tests/acceptance/Controllers/PreferencesControllerTest.php @@ -28,11 +28,11 @@ class PreferencesControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PreferencesController::postIndex */ - public function testPostIndex() + public function testPostIndex($range) { $args = [ 'frontPageAccounts' => [1], - 'viewRange' => '1M', + 'viewRange' => $range, 'budgetMaximum' => 100, 'customFiscalYear' => 1, 'fiscalYearStart' => '01-01', diff --git a/tests/acceptance/Controllers/ReportControllerTest.php b/tests/acceptance/Controllers/ReportControllerTest.php index 36841ab232..ab8a00a858 100644 --- a/tests/acceptance/Controllers/ReportControllerTest.php +++ b/tests/acceptance/Controllers/ReportControllerTest.php @@ -21,7 +21,7 @@ class ReportControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\ReportController::index */ - public function testIndex() + public function testIndex($range) { $this->be($this->user()); $this->call('GET', '/reports'); @@ -34,7 +34,7 @@ class ReportControllerTest extends TestCase * @covers FireflyIII\Http\Controllers\ReportController::report * @covers FireflyIII\Http\Controllers\ReportController::defaultMonth */ - public function testReportDefaultMonth() + public function testReportDefaultMonth($range) { // mock some stuff. $repository = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface'); @@ -53,7 +53,7 @@ class ReportControllerTest extends TestCase * @covers FireflyIII\Http\Controllers\ReportController::report * @covers FireflyIII\Http\Controllers\ReportController::defaultYear */ - public function testReportDefaultYear() + public function testReportDefaultYear($range) { $this->be($this->user()); $this->call('GET', '/reports/report/default/20160101/20161231/1,2'); @@ -64,7 +64,7 @@ class ReportControllerTest extends TestCase * @covers FireflyIII\Http\Controllers\ReportController::report * @covers FireflyIII\Http\Controllers\ReportController::defaultMultiYear */ - public function testReportDefaultMultiYear() + public function testReportDefaultMultiYear($range) { $this->be($this->user()); $this->call('GET', '/reports/report/default/20160101/20171231/1,2'); diff --git a/tests/acceptance/Controllers/TransactionControllerTest.php b/tests/acceptance/Controllers/TransactionControllerTest.php index 0d71d0134a..5a807df98d 100644 --- a/tests/acceptance/Controllers/TransactionControllerTest.php +++ b/tests/acceptance/Controllers/TransactionControllerTest.php @@ -61,7 +61,7 @@ class TransactionControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\TransactionController::index */ - public function testIndex() + public function testIndex($range) { $this->be($this->user()); $this->call('GET', '/transactions/deposit'); @@ -85,7 +85,7 @@ class TransactionControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\TransactionController::show */ - public function testShow() + public function testShow($range) { $this->be($this->user()); $this->call('GET', '/transaction/show/1'); From 4531d0ee32fa8550c2affe2f5c314e94ed68afe1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 06:37:08 +0100 Subject: [PATCH 029/448] Expand test to set a "custom" range. --- tests/TestCase.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 65fc680453..15d5dcd64d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -32,6 +32,16 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase ] ); } + // if selected "custom", change the session to a weird custom range: + // (20 days): + if($range === "custom") { + $this->session( + [ + 'start' => Carbon::now(), + 'end' => Carbon::now()->subDays(20), + ] + ); + } } /** @@ -120,11 +130,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase public function tearDown() { parent::tearDown(); - - // delete copy original. - //$original = __DIR__.'/../storage/database/testing.db'; - //unlink($original); - } /** From 45deb493bac5b1b56967aa40d5b2010e0ee741b1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 06:41:28 +0100 Subject: [PATCH 030/448] Added the provider annotation to all tests. --- tests/acceptance/Controllers/BillControllerTest.php | 3 +++ tests/acceptance/Controllers/BudgetControllerTest.php | 6 ++++++ tests/acceptance/Controllers/CategoryControllerTest.php | 1 + tests/acceptance/Controllers/CurrencyControllerTest.php | 1 + tests/acceptance/Controllers/HomeControllerTest.php | 1 + tests/acceptance/Controllers/JsonControllerTest.php | 6 ++++++ tests/acceptance/Controllers/PiggyBankControllerTest.php | 3 +++ tests/acceptance/Controllers/PreferencesControllerTest.php | 1 + tests/acceptance/Controllers/ReportControllerTest.php | 4 ++++ tests/acceptance/Controllers/TransactionControllerTest.php | 2 ++ 10 files changed, 28 insertions(+) diff --git a/tests/acceptance/Controllers/BillControllerTest.php b/tests/acceptance/Controllers/BillControllerTest.php index 74246d4aba..e4d8ee3d67 100644 --- a/tests/acceptance/Controllers/BillControllerTest.php +++ b/tests/acceptance/Controllers/BillControllerTest.php @@ -59,6 +59,7 @@ class BillControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BillController::index + * @dataProvider dateRangeProvider */ public function testIndex($range) { @@ -69,6 +70,7 @@ class BillControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BillController::rescan + * @dataProvider dateRangeProvider */ public function testRescan($range) { @@ -80,6 +82,7 @@ class BillControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BillController::show + * @dataProvider dateRangeProvider */ public function testShow($range) { diff --git a/tests/acceptance/Controllers/BudgetControllerTest.php b/tests/acceptance/Controllers/BudgetControllerTest.php index 42ab7f5764..e35cdd0309 100644 --- a/tests/acceptance/Controllers/BudgetControllerTest.php +++ b/tests/acceptance/Controllers/BudgetControllerTest.php @@ -16,6 +16,7 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::amount * @covers FireflyIII\Http\Controllers\BudgetController::__construct + * @dataProvider dateRangeProvider */ public function testAmount($range) { @@ -73,6 +74,7 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::index + * @dataProvider dateRangeProvider */ public function testIndex($range) { @@ -83,6 +85,7 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::noBudget + * @dataProvider dateRangeProvider */ public function testNoBudget($range) { @@ -93,6 +96,7 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::postUpdateIncome + * @dataProvider dateRangeProvider */ public function testPostUpdateIncome($range) { @@ -107,6 +111,7 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::show + * @dataProvider dateRangeProvider */ public function testShow($range) { @@ -154,6 +159,7 @@ class BudgetControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\BudgetController::updateIncome + * @dataProvider dateRangeProvider */ public function testUpdateIncome($range) { diff --git a/tests/acceptance/Controllers/CategoryControllerTest.php b/tests/acceptance/Controllers/CategoryControllerTest.php index f476d946db..89fb3b26f1 100644 --- a/tests/acceptance/Controllers/CategoryControllerTest.php +++ b/tests/acceptance/Controllers/CategoryControllerTest.php @@ -61,6 +61,7 @@ class CategoryControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\CategoryController::index + * @dataProvider dateRangeProvider * */ public function testIndex($range) diff --git a/tests/acceptance/Controllers/CurrencyControllerTest.php b/tests/acceptance/Controllers/CurrencyControllerTest.php index 9fe635883f..1fa2638516 100644 --- a/tests/acceptance/Controllers/CurrencyControllerTest.php +++ b/tests/acceptance/Controllers/CurrencyControllerTest.php @@ -73,6 +73,7 @@ class CurrencyControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\CurrencyController::index + * @dataProvider dateRangeProvider */ public function testIndex($range) { diff --git a/tests/acceptance/Controllers/HomeControllerTest.php b/tests/acceptance/Controllers/HomeControllerTest.php index a92a1ac315..5bdf7ac572 100644 --- a/tests/acceptance/Controllers/HomeControllerTest.php +++ b/tests/acceptance/Controllers/HomeControllerTest.php @@ -42,6 +42,7 @@ class HomeControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\HomeController::index * @covers FireflyIII\Http\Controllers\Controller::__construct + * @dataProvider dateRangeProvider */ public function testIndex($range) { diff --git a/tests/acceptance/Controllers/JsonControllerTest.php b/tests/acceptance/Controllers/JsonControllerTest.php index 6910a46ca3..bae8241345 100644 --- a/tests/acceptance/Controllers/JsonControllerTest.php +++ b/tests/acceptance/Controllers/JsonControllerTest.php @@ -28,6 +28,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::boxBillsPaid + * @dataProvider dateRangeProvider */ public function testBoxBillsPaid($range) { @@ -38,6 +39,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::boxBillsUnpaid + * @dataProvider dateRangeProvider */ public function testBoxBillsUnpaid($range) { @@ -48,6 +50,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::boxIn + * @dataProvider dateRangeProvider */ public function testBoxIn($range) { @@ -58,6 +61,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::boxOut + * @dataProvider dateRangeProvider */ public function testBoxOut($range) { @@ -68,6 +72,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::categories + * @dataProvider dateRangeProvider */ public function testCategories($range) { @@ -129,6 +134,7 @@ class JsonControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\JsonController::transactionJournals + * @dataProvider dateRangeProvider */ public function testTransactionJournals($range) { diff --git a/tests/acceptance/Controllers/PiggyBankControllerTest.php b/tests/acceptance/Controllers/PiggyBankControllerTest.php index eae72120d1..7c12df546e 100644 --- a/tests/acceptance/Controllers/PiggyBankControllerTest.php +++ b/tests/acceptance/Controllers/PiggyBankControllerTest.php @@ -16,6 +16,7 @@ class PiggyBankControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PiggyBankController::add * @covers FireflyIII\Http\Controllers\PiggyBankController::__construct + * @dataProvider dateRangeProvider */ public function testAdd($range) { @@ -68,6 +69,7 @@ class PiggyBankControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PiggyBankController::index + * @dataProvider dateRangeProvider */ public function testIndex($range) { @@ -133,6 +135,7 @@ class PiggyBankControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PiggyBankController::show + * @dataProvider dateRangeProvider */ public function testShow($range) { diff --git a/tests/acceptance/Controllers/PreferencesControllerTest.php b/tests/acceptance/Controllers/PreferencesControllerTest.php index e1220058b6..75f6312107 100644 --- a/tests/acceptance/Controllers/PreferencesControllerTest.php +++ b/tests/acceptance/Controllers/PreferencesControllerTest.php @@ -27,6 +27,7 @@ class PreferencesControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PreferencesController::postIndex + * @dataProvider dateRangeProvider */ public function testPostIndex($range) { diff --git a/tests/acceptance/Controllers/ReportControllerTest.php b/tests/acceptance/Controllers/ReportControllerTest.php index ab8a00a858..08f3191c9a 100644 --- a/tests/acceptance/Controllers/ReportControllerTest.php +++ b/tests/acceptance/Controllers/ReportControllerTest.php @@ -20,6 +20,7 @@ class ReportControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\ReportController::index + * @dataProvider dateRangeProvider */ public function testIndex($range) { @@ -33,6 +34,7 @@ class ReportControllerTest extends TestCase * @covers FireflyIII\Http\Controllers\ReportController::__construct * @covers FireflyIII\Http\Controllers\ReportController::report * @covers FireflyIII\Http\Controllers\ReportController::defaultMonth + * @dataProvider dateRangeProvider */ public function testReportDefaultMonth($range) { @@ -52,6 +54,7 @@ class ReportControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\ReportController::report * @covers FireflyIII\Http\Controllers\ReportController::defaultYear + * @dataProvider dateRangeProvider */ public function testReportDefaultYear($range) { @@ -63,6 +66,7 @@ class ReportControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\ReportController::report * @covers FireflyIII\Http\Controllers\ReportController::defaultMultiYear + * @dataProvider dateRangeProvider */ public function testReportDefaultMultiYear($range) { diff --git a/tests/acceptance/Controllers/TransactionControllerTest.php b/tests/acceptance/Controllers/TransactionControllerTest.php index 5a807df98d..bf480606c3 100644 --- a/tests/acceptance/Controllers/TransactionControllerTest.php +++ b/tests/acceptance/Controllers/TransactionControllerTest.php @@ -60,6 +60,7 @@ class TransactionControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\TransactionController::index + * @dataProvider dateRangeProvider */ public function testIndex($range) { @@ -84,6 +85,7 @@ class TransactionControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\TransactionController::show + * @dataProvider dateRangeProvider */ public function testShow($range) { From 581e2ad4315a89d96eae5f523e0dcd9235003672 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 06:45:54 +0100 Subject: [PATCH 031/448] Updated all tests to include the range. --- tests/acceptance/Controllers/BillControllerTest.php | 3 +++ tests/acceptance/Controllers/BudgetControllerTest.php | 6 ++++++ .../acceptance/Controllers/CurrencyControllerTest.php | 1 + tests/acceptance/Controllers/HomeControllerTest.php | 1 + tests/acceptance/Controllers/JsonControllerTest.php | 6 ++++++ .../Controllers/PiggyBankControllerTest.php | 11 +++++++---- tests/acceptance/Controllers/ReportControllerTest.php | 4 ++++ .../Controllers/TransactionControllerTest.php | 2 ++ 8 files changed, 30 insertions(+), 4 deletions(-) diff --git a/tests/acceptance/Controllers/BillControllerTest.php b/tests/acceptance/Controllers/BillControllerTest.php index e4d8ee3d67..327b740c11 100644 --- a/tests/acceptance/Controllers/BillControllerTest.php +++ b/tests/acceptance/Controllers/BillControllerTest.php @@ -64,6 +64,7 @@ class BillControllerTest extends TestCase public function testIndex($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/bills'); $this->assertResponseStatus(200); } @@ -75,6 +76,7 @@ class BillControllerTest extends TestCase public function testRescan($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/bills/rescan/1'); $this->assertSessionHas('success'); $this->assertResponseStatus(302); @@ -87,6 +89,7 @@ class BillControllerTest extends TestCase public function testShow($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/bills/show/1'); $this->assertResponseStatus(200); } diff --git a/tests/acceptance/Controllers/BudgetControllerTest.php b/tests/acceptance/Controllers/BudgetControllerTest.php index e35cdd0309..59c05c094a 100644 --- a/tests/acceptance/Controllers/BudgetControllerTest.php +++ b/tests/acceptance/Controllers/BudgetControllerTest.php @@ -24,6 +24,7 @@ class BudgetControllerTest extends TestCase 'amount' => 1200, ]; $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('POST', '/budgets/amount/1', $args); $this->assertResponseStatus(200); @@ -79,6 +80,7 @@ class BudgetControllerTest extends TestCase public function testIndex($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/budgets'); $this->assertResponseStatus(200); } @@ -90,6 +92,7 @@ class BudgetControllerTest extends TestCase public function testNoBudget($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/budgets/list/noBudget'); $this->assertResponseStatus(200); } @@ -104,6 +107,7 @@ class BudgetControllerTest extends TestCase 'amount' => 1200, ]; $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('POST', '/budgets/income', $args); $this->assertResponseStatus(302); @@ -116,6 +120,7 @@ class BudgetControllerTest extends TestCase public function testShow($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/budgets/show/1'); $this->assertResponseStatus(200); } @@ -164,6 +169,7 @@ class BudgetControllerTest extends TestCase public function testUpdateIncome($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/budgets/income'); $this->assertResponseStatus(200); } diff --git a/tests/acceptance/Controllers/CurrencyControllerTest.php b/tests/acceptance/Controllers/CurrencyControllerTest.php index 1fa2638516..0031752c95 100644 --- a/tests/acceptance/Controllers/CurrencyControllerTest.php +++ b/tests/acceptance/Controllers/CurrencyControllerTest.php @@ -78,6 +78,7 @@ class CurrencyControllerTest extends TestCase public function testIndex($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/currency'); $this->assertResponseStatus(200); } diff --git a/tests/acceptance/Controllers/HomeControllerTest.php b/tests/acceptance/Controllers/HomeControllerTest.php index 5bdf7ac572..b60e754882 100644 --- a/tests/acceptance/Controllers/HomeControllerTest.php +++ b/tests/acceptance/Controllers/HomeControllerTest.php @@ -47,6 +47,7 @@ class HomeControllerTest extends TestCase public function testIndex($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/'); $this->assertResponseStatus(200); } diff --git a/tests/acceptance/Controllers/JsonControllerTest.php b/tests/acceptance/Controllers/JsonControllerTest.php index bae8241345..9ca2ee8c4c 100644 --- a/tests/acceptance/Controllers/JsonControllerTest.php +++ b/tests/acceptance/Controllers/JsonControllerTest.php @@ -33,6 +33,7 @@ class JsonControllerTest extends TestCase public function testBoxBillsPaid($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/json/box/bills-paid'); $this->assertResponseStatus(200); } @@ -44,6 +45,7 @@ class JsonControllerTest extends TestCase public function testBoxBillsUnpaid($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/json/box/bills-unpaid'); $this->assertResponseStatus(200); } @@ -55,6 +57,7 @@ class JsonControllerTest extends TestCase public function testBoxIn($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/json/box/in'); $this->assertResponseStatus(200); } @@ -66,6 +69,7 @@ class JsonControllerTest extends TestCase public function testBoxOut($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/json/box/out'); $this->assertResponseStatus(200); } @@ -77,6 +81,7 @@ class JsonControllerTest extends TestCase public function testCategories($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/json/categories'); $this->assertResponseStatus(200); } @@ -145,6 +150,7 @@ class JsonControllerTest extends TestCase $repository->shouldReceive('getJournalsOfType')->with($type)->once()->andReturn(new Collection); $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/json/transaction-journals/deposit'); $this->assertResponseStatus(200); } diff --git a/tests/acceptance/Controllers/PiggyBankControllerTest.php b/tests/acceptance/Controllers/PiggyBankControllerTest.php index 7c12df546e..b7be9a49fc 100644 --- a/tests/acceptance/Controllers/PiggyBankControllerTest.php +++ b/tests/acceptance/Controllers/PiggyBankControllerTest.php @@ -14,13 +14,14 @@ class PiggyBankControllerTest extends TestCase { /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::add - * @covers FireflyIII\Http\Controllers\PiggyBankController::__construct + * @covers FireflyIII\Http\Controllers\PiggyBankController::add + * @covers FireflyIII\Http\Controllers\PiggyBankController::__construct * @dataProvider dateRangeProvider */ public function testAdd($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/piggy-banks/add/1'); $this->assertResponseStatus(200); } @@ -68,12 +69,13 @@ class PiggyBankControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::index + * @covers FireflyIII\Http\Controllers\PiggyBankController::index * @dataProvider dateRangeProvider */ public function testIndex($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/piggy-banks'); $this->assertResponseStatus(200); } @@ -134,12 +136,13 @@ class PiggyBankControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\PiggyBankController::show + * @covers FireflyIII\Http\Controllers\PiggyBankController::show * @dataProvider dateRangeProvider */ public function testShow($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/piggy-banks/show/1'); $this->assertResponseStatus(200); } diff --git a/tests/acceptance/Controllers/ReportControllerTest.php b/tests/acceptance/Controllers/ReportControllerTest.php index 08f3191c9a..23a3d6a328 100644 --- a/tests/acceptance/Controllers/ReportControllerTest.php +++ b/tests/acceptance/Controllers/ReportControllerTest.php @@ -25,6 +25,7 @@ class ReportControllerTest extends TestCase public function testIndex($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/reports'); $this->assertResponseStatus(200); @@ -47,6 +48,7 @@ class ReportControllerTest extends TestCase $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/reports/report/default/20160101/20160131/1,2'); $this->assertResponseStatus(200); } @@ -59,6 +61,7 @@ class ReportControllerTest extends TestCase public function testReportDefaultYear($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/reports/report/default/20160101/20161231/1,2'); $this->assertResponseStatus(200); } @@ -71,6 +74,7 @@ class ReportControllerTest extends TestCase public function testReportDefaultMultiYear($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/reports/report/default/20160101/20171231/1,2'); $this->assertResponseStatus(200); } diff --git a/tests/acceptance/Controllers/TransactionControllerTest.php b/tests/acceptance/Controllers/TransactionControllerTest.php index bf480606c3..3cf1687722 100644 --- a/tests/acceptance/Controllers/TransactionControllerTest.php +++ b/tests/acceptance/Controllers/TransactionControllerTest.php @@ -65,6 +65,7 @@ class TransactionControllerTest extends TestCase public function testIndex($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/transactions/deposit'); $this->assertResponseStatus(200); } @@ -90,6 +91,7 @@ class TransactionControllerTest extends TestCase public function testShow($range) { $this->be($this->user()); + $this->changeDateRange($this->user(), $range); $this->call('GET', '/transaction/show/1'); $this->assertResponseStatus(200); } From bb8ce3055268bfcc3ea5d79074a2ff0026d1febf Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 06:56:10 +0100 Subject: [PATCH 032/448] Added missing ranges to Navigation, see issue #170 --- app/Support/Navigation.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index 25d8f93298..c06daf4cc7 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -70,7 +70,7 @@ class Navigation '1W' => 'addWeek', 'week' => 'addWeek', 'weekly' => 'addWeek', '1M' => 'addMonth', 'month' => 'addMonth', 'monthly' => 'addMonth', '3M' => 'addMonths', 'quarter' => 'addMonths', 'quarterly' => 'addMonths', '6M' => 'addMonths', 'half-year' => 'addMonths', - 'year' => 'addYear', 'yearly' => 'addYear', + 'year' => 'addYear', 'yearly' => 'addYear', '1Y' => 'addYear', ]; $modifierMap = [ 'quarter' => 3, @@ -163,6 +163,7 @@ class Navigation '1Y' => '%Y', 'year' => '%Y', 'yearly' => '%Y', + '6M' => '%B %Y', ]; @@ -198,6 +199,7 @@ class Navigation 'quarterly' => 'firstOfQuarter', 'year' => 'startOfYear', 'yearly' => 'startOfYear', + '1Y' => 'startOfYear', ]; if (isset($functionMap[$repeatFreq])) { $function = $functionMap[$repeatFreq]; @@ -214,6 +216,11 @@ class Navigation return $date; } + if ($repeatFreq === 'custom') { + return $theDate; // the date is already at the start. + } + + throw new FireflyException('Cannot do startOfPeriod for $repeat_freq "' . $repeatFreq . '"'); } @@ -239,12 +246,15 @@ class Navigation '1M' => 'subMonths', 'monthly' => 'subMonths', 'year' => 'subYears', + '1Y' => 'subYears', 'yearly' => 'subYears', ]; $modifierMap = [ 'quarter' => 3, + '3M' => 3, 'quarterly' => 3, 'half-year' => 6, + '6M' => 6, ]; if (isset($functionMap[$repeatFreq])) { $function = $functionMap[$repeatFreq]; From 6f9675b6d61d33aca21ad8ded028d1ca56138536 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 07:16:55 +0100 Subject: [PATCH 033/448] Catch the latest exceptions for #170. --- app/Support/Navigation.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index c06daf4cc7..1018b784e0 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -82,6 +82,20 @@ class Navigation $subDay = ['week', 'weekly', '1W', 'month', 'monthly', '1M', '3M', 'quarter', 'quarterly', '6M', 'half-year', 'year', 'yearly']; + // if the range is custom, the end of the period + // is another X days (x is the difference between start) + // and end added to $theCurrentEnd + if ($repeatFreq == 'custom') { + /** @var Carbon $tStart */ + $tStart = session('start', Carbon::now()->startOfMonth()); + /** @var Carbon $tEnd */ + $tEnd = session('end', Carbon::now()->endOfMonth()); + $diffInDays = $tStart->diffInDays($tEnd); + $currentEnd->addDays($diffInDays); + + return $currentEnd; + } + if (!isset($functionMap[$repeatFreq])) { throw new FireflyException('Cannot do endOfPeriod for $repeat_freq "' . $repeatFreq . '"'); } @@ -152,6 +166,7 @@ class Navigation $formatMap = [ '1D' => '%e %B %Y', 'daily' => '%e %B %Y', + 'custom' => '%e %B %Y', '1W' => 'Week %W, %Y', 'week' => 'Week %W, %Y', 'weekly' => 'Week %W, %Y', From 5a23b95352aa51578009c085c644d58a8f6945b4 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 07:21:51 +0100 Subject: [PATCH 034/448] Final fix for #170. Now to make a new release! --- app/Support/Navigation.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index 1018b784e0..fe83828573 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -232,7 +232,7 @@ class Navigation return $date; } if ($repeatFreq === 'custom') { - return $theDate; // the date is already at the start. + return $date; // the date is already at the start. } @@ -283,6 +283,18 @@ class Navigation return $date; } + // a custom range requires the session start + // and session end to calculate the difference in days. + // this is then subtracted from $theDate (* $subtract). + if($repeatFreq === 'custom') { + /** @var Carbon $tStart */ + $tStart = session('start', Carbon::now()->startOfMonth()); + /** @var Carbon $tEnd */ + $tEnd = session('end', Carbon::now()->endOfMonth()); + $diffInDays = $tStart->diffInDays($tEnd); + $date->subDays($diffInDays * $subtract); + return $date; + } throw new FireflyException('Cannot do subtractPeriod for $repeat_freq "' . $repeatFreq . '"'); } From fbbf7f75c37ff7a4705a1756b28f34cd7e3c645b Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 07:24:33 +0100 Subject: [PATCH 035/448] Fix for test. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f9ca51f24e..2d81087f34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,8 @@ php: - 7 install: - - composer install + - rm composer.lock + - composer update - php artisan env - mv -v .env.testing .env - php artisan env From 8cbbb970e199f0f7488295ce5440c2cd193e6357 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 07:26:20 +0100 Subject: [PATCH 036/448] Attempt to fix the tests. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2d81087f34..73d48f706b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ php: - 7 install: - - rm composer.lock + - composer install - composer update - php artisan env - mv -v .env.testing .env From 54bd54b52164694e32eb57bb0634cd7219425baf Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 07:27:07 +0100 Subject: [PATCH 037/448] First install with no-dev, then update? --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 73d48f706b..afa2aa426d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ php: - 7 install: - - composer install + - composer install --no-dev - composer update - php artisan env - mv -v .env.testing .env From c6cddad13ca2ce5e309f4520876f4b0fabecbf6e Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 07:31:22 +0100 Subject: [PATCH 038/448] Let's see if this works as well. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index afa2aa426d..abfb2812b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: - 7 install: + - composer selfupdate - composer install --no-dev - composer update - php artisan env From baecc256f6f1fc1f8cc53bdf8e737e1000555cb5 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 07:55:36 +0100 Subject: [PATCH 039/448] Secretly updated some migrations. --- .../2014_07_09_204843_create_session_table.php | 9 +++++---- .../migrations/2016_02_04_144117_changes_for_v380.php | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/database/migrations/2014_07_09_204843_create_session_table.php b/database/migrations/2014_07_09_204843_create_session_table.php index 240f66ba88..66842aa574 100644 --- a/database/migrations/2014_07_09_204843_create_session_table.php +++ b/database/migrations/2014_07_09_204843_create_session_table.php @@ -29,13 +29,14 @@ class CreateSessionTable extends Migration */ public function up() { - Schema::create( - 'sessions', function (Blueprint $table) { + Schema::create('sessions', function ($table) { $table->string('id')->unique(); + $table->integer('user_id')->nullable(); + $table->string('ip_address', 45)->nullable(); + $table->text('user_agent')->nullable(); $table->text('payload'); $table->integer('last_activity'); - } - ); + }); } } diff --git a/database/migrations/2016_02_04_144117_changes_for_v380.php b/database/migrations/2016_02_04_144117_changes_for_v380.php index 6169706fd4..277a1c2942 100644 --- a/database/migrations/2016_02_04_144117_changes_for_v380.php +++ b/database/migrations/2016_02_04_144117_changes_for_v380.php @@ -15,7 +15,8 @@ class ChangesForV380 extends Migration */ public function down() { - // + Schema::drop('export_jobs'); + } /** From 554640c34544d6ca287a19f1f8ced23fcb6da463 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 08:03:26 +0100 Subject: [PATCH 040/448] These are the first commits that make FF require php 7. --- .../Commands/UpgradeFireflyInstructions.php | 2 +- .../Account/ChartJsAccountChartGenerator.php | 2 +- app/Helpers/Collection/BalanceLine.php | 2 +- app/Helpers/Csv/Importer.php | 2 +- app/Helpers/Report/BudgetReportHelper.php | 2 +- .../Controllers/Chart/CategoryController.php | 4 ++-- .../Controllers/Chart/ReportController.php | 4 ++-- app/Models/Tag.php | 2 +- app/Support/Twig/General.php | 2 +- app/Validation/FireflyValidator.php | 18 +++++++++--------- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/Console/Commands/UpgradeFireflyInstructions.php b/app/Console/Commands/UpgradeFireflyInstructions.php index bb99309c05..36c4d7f472 100644 --- a/app/Console/Commands/UpgradeFireflyInstructions.php +++ b/app/Console/Commands/UpgradeFireflyInstructions.php @@ -44,7 +44,7 @@ class UpgradeFireflyInstructions extends Command // $version = Config::get('firefly.version'); $config = Config::get('upgrade.text'); - $text = isset($config[$version]) ? $config[$version] : null; + $text = $config[$version] ?? null; $this->line('+------------------------------------------------------------------------------+'); $this->line(''); diff --git a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php index db4b9ed1ad..95892049cc 100644 --- a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php +++ b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php @@ -137,7 +137,7 @@ class ChartJsAccountChartGenerator implements AccountChartGeneratorInterface while ($end >= $current) { $theDate = $current->format('Y-m-d'); - $balance = isset($range[$theDate]) ? $range[$theDate] : $previous; + $balance = $range[$theDate] ?? $previous; $data['labels'][] = $current->formatLocalized($format); $data['datasets'][0]['data'][] = $balance; diff --git a/app/Helpers/Collection/BalanceLine.php b/app/Helpers/Collection/BalanceLine.php index 0800010c42..f1debc6313 100644 --- a/app/Helpers/Collection/BalanceLine.php +++ b/app/Helpers/Collection/BalanceLine.php @@ -122,7 +122,7 @@ class BalanceLine */ public function leftOfRepetition() { - $start = isset($this->budget->amount) ? $this->budget->amount : 0; + $start = $this->budget->amount ?? 0; /** @var BalanceEntry $balanceEntry */ foreach ($this->getBalanceEntries() as $balanceEntry) { $start += $balanceEntry->getSpent(); diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 0386f71819..e72a127a24 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -228,7 +228,7 @@ class Importer $data = $this->getFiller(); // These fields are necessary to create a new transaction journal. Some are optional foreach ($row as $index => $value) { - $role = isset($this->roles[$index]) ? $this->roles[$index] : '_ignore'; + $role = $this->roles[$index] ?? '_ignore'; $class = Config::get('csv.roles.' . $role . '.converter'); $field = Config::get('csv.roles.' . $role . '.field'); diff --git a/app/Helpers/Report/BudgetReportHelper.php b/app/Helpers/Report/BudgetReportHelper.php index 3191a36665..fbd49a8c89 100644 --- a/app/Helpers/Report/BudgetReportHelper.php +++ b/app/Helpers/Report/BudgetReportHelper.php @@ -48,7 +48,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface return $rep->budget_id == $budget->id; } ); - $totalSpent = isset($allTotalSpent[$budget->id]) ? $allTotalSpent[$budget->id] : []; + $totalSpent = $allTotalSpent[$budget->id] ?? []; // no repetition(s) for this budget: if ($repetitions->count() == 0) { diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index e571535670..409c2bf72c 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -405,8 +405,8 @@ class CategoryController extends Controller while ($start <= $end) { $str = $start->format('Y-m-d'); - $spent = isset($spentArray[$str]) ? $spentArray[$str] : 0; - $earned = isset($earnedArray[$str]) ? $earnedArray[$str] : 0; + $spent = $spentArray[$str] ?? 0; + $earned = $earnedArray[$str] ?? 0; $date = Navigation::periodShow($start, '1D'); $entries->push([clone $start, $date, $spent, $earned]); $start->addDay(); diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php index 43e0928f90..a4b558876c 100644 --- a/app/Http/Controllers/Chart/ReportController.php +++ b/app/Http/Controllers/Chart/ReportController.php @@ -133,7 +133,7 @@ class ReportController extends Controller $count = 0; while ($start < $end) { $date = $start->format('Y-m'); - $currentIncome = isset($earned[$date]) ? $earned[$date] : 0; + $currentIncome = $earned[$date] ?? 0; $currentExpense = isset($spent[$date]) ? ($spent[$date] * -1) : 0; $income = bcadd($income, $currentIncome); $expense = bcadd($expense, $currentExpense); @@ -218,7 +218,7 @@ class ReportController extends Controller while ($start < $end) { // total income and total expenses: $date = $start->format('Y-m'); - $incomeSum = isset($earned[$date]) ? $earned[$date] : 0; + $incomeSum = $earned[$date] ?? 0; $expenseSum = isset($spent[$date]) ? ($spent[$date] * -1) : 0; $entries->push([clone $start, $incomeSum, $expenseSum]); diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 2ca139f9bd..a9b9e108d5 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -56,7 +56,7 @@ class Tag extends Model } // create it! $fields['tagMode'] = 'nothing'; - $fields['description'] = isset($fields['description']) && !is_null($fields['description']) ? $fields['description'] : ''; + $fields['description'] = $fields['description'] ?? ''; $tag = Tag::create($fields); return $tag; diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index c95751acf8..8ddcc82c0f 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -291,7 +291,7 @@ class General extends Twig_Extension $args = func_get_args(); $route = $args[1]; // name of the route. $what = $args[2]; // name of the route. - $activeWhat = isset($context['what']) ? $context['what'] : false; + $activeWhat = $context['what'] ?? false; if ($what == $activeWhat && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) { return 'active'; diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 29672b9645..4e18f0fa50 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -49,7 +49,7 @@ class FireflyValidator extends Validator */ public function validateBelongsToUser($attribute, $value, $parameters) { - $field = isset($parameters[1]) ? $parameters[1] : 'id'; + $field = $parameters[1] ?? 'id'; $count = DB::table($parameters[0])->where('user_id', Auth::user()->id)->where($field, $value)->count(); @@ -105,8 +105,8 @@ class FireflyValidator extends Validator // check if rule-action-value matches the thing. if (is_array($this->data['rule-action'])) { - $name = isset($this->data['rule-action'][$index]) ? $this->data['rule-action'][$index] : 'invalid'; - $value = isset($this->data['rule-action-value'][$index]) ? $this->data['rule-action-value'][$index] : false; + $name = $this->data['rule-action'][$index] ?? 'invalid'; + $value = $this->data['rule-action-value'][$index] ?? false; switch ($name) { default: Log::debug(' (' . $attribute . ') (index:' . $index . ') Name is "' . $name . '" so no action is taken.'); @@ -243,7 +243,7 @@ class FireflyValidator extends Validator // exclude? $table = $parameters[0]; $field = $parameters[1]; - $exclude = isset($parameters[2]) ? intval($parameters[2]) : 0; + $exclude = $parameters[2] ?? 0; // get entries from table $set = DB::table($table)->where('user_id', Auth::user()->id) @@ -272,7 +272,7 @@ class FireflyValidator extends Validator */ public function validateUniquePiggyBankForUser($attribute, $value, $parameters) { - $exclude = isset($parameters[0]) ? $parameters[0] : null; + $exclude = $parameters[0] ?? null; $query = DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at') ->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id); if (!is_null($exclude)) { @@ -369,7 +369,7 @@ class FireflyValidator extends Validator protected function validateByAccountTypeId($value, $parameters) { $type = AccountType::find($this->data['account_type_id'])->first(); - $ignore = isset($parameters[0]) ? intval($parameters[0]) : 0; + $ignore = $parameters[0] ?? 0; $value = $this->tryDecrypt($value); $set = Auth::user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get(); @@ -394,7 +394,7 @@ class FireflyValidator extends Validator { $search = Config::get('firefly.accountTypeByIdentifier.' . $this->data['what']); $type = AccountType::whereType($search)->first(); - $ignore = isset($parameters[0]) ? intval($parameters[0]) : 0; + $ignore = $parameters[0] ?? 0; $set = Auth::user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get(); /** @var Account $entry */ @@ -414,7 +414,7 @@ class FireflyValidator extends Validator */ private function getRuleTriggerName($index) { - return isset($this->data['rule-trigger'][$index]) ? $this->data['rule-trigger'][$index] : 'invalid'; + return $this->data['rule-trigger'][$index] ?? 'invalid'; } @@ -425,7 +425,7 @@ class FireflyValidator extends Validator */ private function getRuleTriggerValue($index) { - return isset($this->data['rule-trigger-value'][$index]) ? $this->data['rule-trigger-value'][$index] : ''; + return $this->data['rule-trigger-value'][$index] ?? ''; } } From 78bcd3e1bbad99eaa25a8b3b6c0e61870e7f1bf5 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 09:25:15 +0100 Subject: [PATCH 041/448] Changed a lot of parameters. --- app/Events/TransactionJournalStored.php | 4 +- app/Export/Collector/BasicCollector.php | 2 +- app/Export/Collector/CollectorInterface.php | 15 + app/Export/Collector/UploadCollector.php | 3 + app/Export/Entry.php | 6 +- .../Bill/BillChartGeneratorInterface.php | 2 +- .../Chart/Bill/ChartJsBillChartGenerator.php | 2 +- .../Report/ChartJsReportChartGenerator.php | 4 +- .../Report/ReportChartGeneratorInterface.php | 4 +- app/Helpers/Collection/Account.php | 28 +- app/Helpers/Collection/Balance.php | 2 +- app/Helpers/Collection/BalanceEntry.php | 22 +- app/Helpers/Collection/BalanceLine.php | 14 +- app/Helpers/Collection/BillLine.php | 16 +- app/Helpers/Collection/Budget.php | 24 +- app/Helpers/Collection/BudgetLine.php | 44 +- app/Helpers/Collection/Category.php | 4 +- app/Helpers/Collection/Expense.php | 4 +- app/Helpers/Collection/Income.php | 6 +- app/Helpers/Csv/Converter/Amount.php | 2 +- app/Helpers/Csv/Converter/AmountComma.php | 2 +- app/Helpers/Csv/Data.php | 14 +- app/Helpers/Csv/Importer.php | 8 +- .../Csv/Specifix/AbnAmroDescription.php | 4 +- app/Helpers/Csv/Specifix/Dummy.php | 4 +- .../Csv/Specifix/RabobankDescription.php | 4 +- app/Helpers/Csv/Specifix/Specifix.php | 4 +- .../Csv/Specifix/SpecifixInterface.php | 6 +- app/Helpers/Csv/Wizard.php | 16 +- app/Helpers/Csv/WizardInterface.php | 14 +- app/Helpers/Help/Help.php | 22 +- app/Helpers/Help/HelpInterface.php | 22 +- app/Helpers/Report/ReportHelper.php | 4 +- app/Helpers/Report/ReportHelperInterface.php | 4 +- app/Http/Controllers/AccountController.php | 8 +- app/Http/Controllers/Auth/AuthController.php | 13 +- app/Http/Controllers/BudgetController.php | 2 +- app/Http/Controllers/CategoryController.php | 2 +- .../Controllers/Chart/AccountController.php | 2 +- .../Controllers/Chart/BudgetController.php | 164 ++++---- .../Controllers/Chart/CategoryController.php | 4 +- .../Controllers/Chart/ReportController.php | 4 +- app/Http/Controllers/HelpController.php | 2 +- app/Http/Controllers/ProfileController.php | 2 +- app/Http/Controllers/ReportController.php | 8 +- app/Http/Controllers/TagController.php | 6 +- .../Controllers/TransactionController.php | 4 +- app/Http/breadcrumbs.php | 8 +- .../Account/AccountRepository.php | 4 +- .../Account/AccountRepositoryInterface.php | 4 +- app/Repositories/Budget/BudgetRepository.php | 7 +- .../Budget/BudgetRepositoryInterface.php | 2 +- .../ExportJob/ExportJobRepository.php | 4 +- .../ExportJobRepositoryInterface.php | 4 +- .../Journal/JournalRepository.php | 8 +- .../Journal/JournalRepositoryInterface.php | 8 +- .../PiggyBank/PiggyBankRepository.php | 6 +- .../PiggyBankRepositoryInterface.php | 6 +- app/Support/Amount.php | 19 +- app/Support/Binder/AccountList.php | 3 +- app/Support/ExpandedForm.php | 22 +- app/Support/Twig/General.php | 384 +++++++++--------- composer.json | 5 +- storage/build/test-upload.csv | 60 --- 64 files changed, 539 insertions(+), 572 deletions(-) diff --git a/app/Events/TransactionJournalStored.php b/app/Events/TransactionJournalStored.php index d2a0610485..0e5be2027b 100644 --- a/app/Events/TransactionJournalStored.php +++ b/app/Events/TransactionJournalStored.php @@ -30,9 +30,9 @@ class TransactionJournalStored extends Event * Create a new event instance. * * @param TransactionJournal $journal - * @param $piggyBankId + * @param int $piggyBankId */ - public function __construct(TransactionJournal $journal, $piggyBankId) + public function __construct(TransactionJournal $journal, int $piggyBankId) { // $this->journal = $journal; diff --git a/app/Export/Collector/BasicCollector.php b/app/Export/Collector/BasicCollector.php index b6b98cf397..723d5ee637 100644 --- a/app/Export/Collector/BasicCollector.php +++ b/app/Export/Collector/BasicCollector.php @@ -46,7 +46,7 @@ class BasicCollector /** * @param Collection $files */ - public function setFiles($files) + public function setFiles(Collection $files) { $this->files = $files; } diff --git a/app/Export/Collector/CollectorInterface.php b/app/Export/Collector/CollectorInterface.php index 313816d4a2..21007a871d 100644 --- a/app/Export/Collector/CollectorInterface.php +++ b/app/Export/Collector/CollectorInterface.php @@ -8,6 +8,7 @@ */ namespace FireflyIII\Export\Collector; +use Illuminate\Support\Collection; /** * Interface CollectorInterface @@ -16,6 +17,20 @@ namespace FireflyIII\Export\Collector; */ interface CollectorInterface { + /** + * @return bool + */ public function run(); + /** + * @return Collection + */ + public function getFiles(); + + /** + * @param Collection $files + * + */ + public function setFiles(Collection $files); + } \ No newline at end of file diff --git a/app/Export/Collector/UploadCollector.php b/app/Export/Collector/UploadCollector.php index 1162d22099..6cf04b52ac 100644 --- a/app/Export/Collector/UploadCollector.php +++ b/app/Export/Collector/UploadCollector.php @@ -31,6 +31,9 @@ class UploadCollector extends BasicCollector implements CollectorInterface parent::__construct($job); } + /** + * + */ public function run() { // grab upload directory. diff --git a/app/Export/Entry.php b/app/Export/Entry.php index 559327871a..557abe33f3 100644 --- a/app/Export/Entry.php +++ b/app/Export/Entry.php @@ -79,7 +79,7 @@ class Entry /** * @param string $amount */ - public function setAmount($amount) + public function setAmount(string $amount) { $this->amount = $amount; } @@ -95,7 +95,7 @@ class Entry /** * @param string $date */ - public function setDate($date) + public function setDate(string $date) { $this->date = $date; } @@ -111,7 +111,7 @@ class Entry /** * @param string $description */ - public function setDescription($description) + public function setDescription(string $description) { $this->description = $description; } diff --git a/app/Generator/Chart/Bill/BillChartGeneratorInterface.php b/app/Generator/Chart/Bill/BillChartGeneratorInterface.php index 077443ed94..a30220b410 100644 --- a/app/Generator/Chart/Bill/BillChartGeneratorInterface.php +++ b/app/Generator/Chart/Bill/BillChartGeneratorInterface.php @@ -27,7 +27,7 @@ interface BillChartGeneratorInterface * * @return array */ - public function frontpage($paid, $unpaid); + public function frontpage(string $paid, string $unpaid); /** * @param Bill $bill diff --git a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php index 879724d194..f191b48877 100644 --- a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php +++ b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php @@ -27,7 +27,7 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface * * @return array */ - public function frontpage($paid, $unpaid) + public function frontpage(string $paid, string $unpaid) { bcscale(2); $data = [ diff --git a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php index 9f13aa892e..fd749dfbaa 100644 --- a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php +++ b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php @@ -52,7 +52,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface * * @return array */ - public function multiYearInOutSummarized($income, $expense, $count) + public function multiYearInOutSummarized(string $income, string $expense, int $count) { $data = [ 'count' => 2, @@ -117,7 +117,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface * * @return array */ - public function yearInOutSummarized($income, $expense, $count) + public function yearInOutSummarized(string $income, string $expense, int $count) { $data = [ diff --git a/app/Generator/Chart/Report/ReportChartGeneratorInterface.php b/app/Generator/Chart/Report/ReportChartGeneratorInterface.php index 8b5f753232..25060a8f46 100644 --- a/app/Generator/Chart/Report/ReportChartGeneratorInterface.php +++ b/app/Generator/Chart/Report/ReportChartGeneratorInterface.php @@ -33,7 +33,7 @@ interface ReportChartGeneratorInterface * * @return array */ - public function multiYearInOutSummarized($income, $expense, $count); + public function multiYearInOutSummarized(string $income, string $expense, int $count); /** * @param Collection $entries @@ -49,6 +49,6 @@ interface ReportChartGeneratorInterface * * @return array */ - public function yearInOutSummarized($income, $expense, $count); + public function yearInOutSummarized(string $income, string $expense, int $count); } diff --git a/app/Helpers/Collection/Account.php b/app/Helpers/Collection/Account.php index 1906c651db..893d771a9f 100644 --- a/app/Helpers/Collection/Account.php +++ b/app/Helpers/Collection/Account.php @@ -15,11 +15,11 @@ class Account /** @var Collection */ protected $accounts; - /** @var float */ + /** @var string */ protected $difference; - /** @var float */ + /** @var string */ protected $end; - /** @var float */ + /** @var string */ protected $start; /** @@ -31,15 +31,15 @@ class Account } /** - * @param \Illuminate\Support\Collection $accounts + * @param Collection $accounts */ - public function setAccounts($accounts) + public function setAccounts(Collection $accounts) { $this->accounts = $accounts; } /** - * @return float + * @return string */ public function getDifference() { @@ -47,15 +47,15 @@ class Account } /** - * @param float $difference + * @param string $difference */ - public function setDifference($difference) + public function setDifference(string $difference) { $this->difference = $difference; } /** - * @return float + * @return string */ public function getEnd() { @@ -63,15 +63,15 @@ class Account } /** - * @param float $end + * @param string $end */ - public function setEnd($end) + public function setEnd(string $end) { $this->end = $end; } /** - * @return float + * @return string */ public function getStart() { @@ -79,9 +79,9 @@ class Account } /** - * @param float $start + * @param string $start */ - public function setStart($start) + public function setStart(string $start) { $this->start = $start; } diff --git a/app/Helpers/Collection/Balance.php b/app/Helpers/Collection/Balance.php index 48d8433c2f..9cc6887660 100644 --- a/app/Helpers/Collection/Balance.php +++ b/app/Helpers/Collection/Balance.php @@ -47,7 +47,7 @@ class Balance /** * @param BalanceHeader $balanceHeader */ - public function setBalanceHeader($balanceHeader) + public function setBalanceHeader(BalanceHeader $balanceHeader) { $this->balanceHeader = $balanceHeader; } diff --git a/app/Helpers/Collection/BalanceEntry.php b/app/Helpers/Collection/BalanceEntry.php index 7749226b82..f92ed56691 100644 --- a/app/Helpers/Collection/BalanceEntry.php +++ b/app/Helpers/Collection/BalanceEntry.php @@ -17,10 +17,10 @@ class BalanceEntry /** @var AccountModel */ protected $account; - /** @var float */ - protected $left = 0.0; - /** @var float */ - protected $spent = 0.0; + /** @var string */ + protected $left = '0'; + /** @var string */ + protected $spent = '0'; /** * @return AccountModel @@ -33,13 +33,13 @@ class BalanceEntry /** * @param AccountModel $account */ - public function setAccount($account) + public function setAccount(AccountModel $account) { $this->account = $account; } /** - * @return float + * @return string */ public function getLeft() { @@ -47,15 +47,15 @@ class BalanceEntry } /** - * @param float $left + * @param string $left */ - public function setLeft($left) + public function setLeft(string $left) { $this->left = $left; } /** - * @return float + * @return string */ public function getSpent() { @@ -63,9 +63,9 @@ class BalanceEntry } /** - * @param float $spent + * @param string $spent */ - public function setSpent($spent) + public function setSpent(string $spent) { $this->spent = $spent; } diff --git a/app/Helpers/Collection/BalanceLine.php b/app/Helpers/Collection/BalanceLine.php index f1debc6313..928a3c6f05 100644 --- a/app/Helpers/Collection/BalanceLine.php +++ b/app/Helpers/Collection/BalanceLine.php @@ -25,6 +25,7 @@ class BalanceLine /** @var BudgetModel */ protected $budget; + /** @var int */ protected $role = self::ROLE_DEFAULTROLE; /** @@ -54,7 +55,7 @@ class BalanceLine /** * @param Collection $balanceEntries */ - public function setBalanceEntries($balanceEntries) + public function setBalanceEntries(Collection $balanceEntries) { $this->balanceEntries = $balanceEntries; } @@ -70,7 +71,7 @@ class BalanceLine /** * @param BudgetModel $budget */ - public function setBudget($budget) + public function setBudget(BudgetModel $budget) { $this->budget = $budget; } @@ -86,7 +87,7 @@ class BalanceLine /** * @param int $role */ - public function setRole($role) + public function setRole(int $role) { $this->role = $role; } @@ -118,14 +119,15 @@ class BalanceLine * on the given budget/repetition. If you subtract all those amounts from the budget/repetition's * total amount, this is returned: * - * @return float + * @return string */ public function leftOfRepetition() { - $start = $this->budget->amount ?? 0; + bcscale(2); + $start = $this->budget->amount ?? '0'; /** @var BalanceEntry $balanceEntry */ foreach ($this->getBalanceEntries() as $balanceEntry) { - $start += $balanceEntry->getSpent(); + $start = bcadd($balanceEntry->getSpent(), $start); } return $start; diff --git a/app/Helpers/Collection/BillLine.php b/app/Helpers/Collection/BillLine.php index 5091747577..ba6703f0b5 100644 --- a/app/Helpers/Collection/BillLine.php +++ b/app/Helpers/Collection/BillLine.php @@ -38,7 +38,7 @@ class BillLine /** * @param string $amount */ - public function setAmount($amount) + public function setAmount(string $amount) { $this->amount = $amount; } @@ -54,7 +54,7 @@ class BillLine /** * @param BillModel $bill */ - public function setBill($bill) + public function setBill(BillModel $bill) { $this->bill = $bill; } @@ -70,7 +70,7 @@ class BillLine /** * @param string $max */ - public function setMax($max) + public function setMax(string $max) { $this->max = $max; } @@ -86,7 +86,7 @@ class BillLine /** * @param string $min */ - public function setMin($min) + public function setMin(string $min) { $this->min = $min; } @@ -100,9 +100,9 @@ class BillLine } /** - * @param boolean $active + * @param bool $active */ - public function setActive($active) + public function setActive(bool $active) { $this->active = $active; } @@ -116,9 +116,9 @@ class BillLine } /** - * @param boolean $hit + * @param bool $hit */ - public function setHit($hit) + public function setHit(bool $hit) { $this->hit = $hit; } diff --git a/app/Helpers/Collection/Budget.php b/app/Helpers/Collection/Budget.php index 53548291de..8bb3e1385f 100644 --- a/app/Helpers/Collection/Budget.php +++ b/app/Helpers/Collection/Budget.php @@ -41,9 +41,9 @@ class Budget } /** - * @param float $add + * @param string $add */ - public function addBudgeted($add) + public function addBudgeted(string $add) { $add = strval(round($add, 2)); bcscale(2); @@ -51,9 +51,9 @@ class Budget } /** - * @param float $add + * @param string $add */ - public function addLeft($add) + public function addLeft(string $add) { $add = strval(round($add, 2)); bcscale(2); @@ -61,9 +61,9 @@ class Budget } /** - * @param float $add + * @param string $add */ - public function addOverspent($add) + public function addOverspent(string $add) { $add = strval(round($add, 2)); bcscale(2); @@ -71,9 +71,9 @@ class Budget } /** - * @param float $add + * @param string $add */ - public function addSpent($add) + public function addSpent(string $add) { $add = strval(round($add, 2)); bcscale(2); @@ -99,7 +99,7 @@ class Budget /** * @param string $budgeted */ - public function setBudgeted($budgeted) + public function setBudgeted(string $budgeted) { $this->budgeted = $budgeted; } @@ -115,7 +115,7 @@ class Budget /** * @param string $left */ - public function setLeft($left) + public function setLeft(string $left) { $this->left = $left; } @@ -131,7 +131,7 @@ class Budget /** * @param string $overspent */ - public function setOverspent($overspent) + public function setOverspent(string $overspent) { $this->overspent = strval(round($overspent, 2)); } @@ -147,7 +147,7 @@ class Budget /** * @param string $spent */ - public function setSpent($spent) + public function setSpent(string $spent) { $this->spent = strval(round($spent, 2)); } diff --git a/app/Helpers/Collection/BudgetLine.php b/app/Helpers/Collection/BudgetLine.php index f26950f9f9..d906da3fe6 100644 --- a/app/Helpers/Collection/BudgetLine.php +++ b/app/Helpers/Collection/BudgetLine.php @@ -17,16 +17,16 @@ class BudgetLine /** @var BudgetModel */ protected $budget; - /** @var float */ - protected $budgeted = 0; - /** @var float */ - protected $left = 0; - /** @var float */ - protected $overspent = 0; + /** @var string */ + protected $budgeted = '0'; + /** @var string */ + protected $left = '0'; + /** @var string */ + protected $overspent = '0'; /** @var LimitRepetition */ protected $repetition; - /** @var float */ - protected $spent = 0; + /** @var string */ + protected $spent = '0'; /** * @return BudgetModel @@ -39,13 +39,13 @@ class BudgetLine /** * @param BudgetModel $budget */ - public function setBudget($budget) + public function setBudget(BudgetModel $budget) { $this->budget = $budget; } /** - * @return float + * @return string */ public function getBudgeted() { @@ -53,15 +53,15 @@ class BudgetLine } /** - * @param float $budgeted + * @param string $budgeted */ - public function setBudgeted($budgeted) + public function setBudgeted(string $budgeted) { $this->budgeted = $budgeted; } /** - * @return float + * @return string */ public function getLeft() { @@ -69,15 +69,15 @@ class BudgetLine } /** - * @param float $left + * @param string $left */ - public function setLeft($left) + public function setLeft(string $left) { $this->left = $left; } /** - * @return float + * @return string */ public function getOverspent() { @@ -85,9 +85,9 @@ class BudgetLine } /** - * @param float $overspent + * @param string $overspent */ - public function setOverspent($overspent) + public function setOverspent(string $overspent) { $this->overspent = $overspent; } @@ -103,13 +103,13 @@ class BudgetLine /** * @param LimitRepetition $repetition */ - public function setRepetition($repetition) + public function setRepetition(LimitRepetition $repetition) { $this->repetition = $repetition; } /** - * @return float + * @return string */ public function getSpent() { @@ -117,9 +117,9 @@ class BudgetLine } /** - * @param float $spent + * @param string $spent */ - public function setSpent($spent) + public function setSpent(string $spent) { $this->spent = $spent; } diff --git a/app/Helpers/Collection/Category.php b/app/Helpers/Collection/Category.php index 6e243a7631..d6dd0ac76a 100644 --- a/app/Helpers/Collection/Category.php +++ b/app/Helpers/Collection/Category.php @@ -42,9 +42,9 @@ class Category } /** - * @param float $add + * @param string $add */ - public function addTotal($add) + public function addTotal(string $add) { $add = strval(round($add, 2)); bcscale(2); diff --git a/app/Helpers/Collection/Expense.php b/app/Helpers/Collection/Expense.php index ce489c5118..de31ab76d1 100644 --- a/app/Helpers/Collection/Expense.php +++ b/app/Helpers/Collection/Expense.php @@ -58,9 +58,9 @@ class Expense } /** - * @param $add + * @param string $add */ - public function addToTotal($add) + public function addToTotal(string $add) { bcscale(2); diff --git a/app/Helpers/Collection/Income.php b/app/Helpers/Collection/Income.php index 6a66de8fef..ddaf21cdcb 100644 --- a/app/Helpers/Collection/Income.php +++ b/app/Helpers/Collection/Income.php @@ -20,7 +20,7 @@ class Income /** @var Collection */ protected $incomes; /** @var string */ - protected $total; + protected $total = '0'; /** * @@ -54,9 +54,9 @@ class Income } /** - * @param $add + * @param string $add */ - public function addToTotal($add) + public function addToTotal(string $add) { $add = strval(round($add, 2)); bcscale(2); diff --git a/app/Helpers/Csv/Converter/Amount.php b/app/Helpers/Csv/Converter/Amount.php index 7ec25ce17e..b33e15c9d4 100644 --- a/app/Helpers/Csv/Converter/Amount.php +++ b/app/Helpers/Csv/Converter/Amount.php @@ -19,6 +19,6 @@ class Amount extends BasicConverter implements ConverterInterface return $this->value; } - return 0; + return '0'; } } diff --git a/app/Helpers/Csv/Converter/AmountComma.php b/app/Helpers/Csv/Converter/AmountComma.php index 5fed5587b9..49ce80cbb0 100644 --- a/app/Helpers/Csv/Converter/AmountComma.php +++ b/app/Helpers/Csv/Converter/AmountComma.php @@ -23,6 +23,6 @@ class AmountComma extends BasicConverter implements ConverterInterface return floatval($value); } - return 0; + return '0'; } } diff --git a/app/Helpers/Csv/Data.php b/app/Helpers/Csv/Data.php index da4cc224fb..5b0fc93474 100644 --- a/app/Helpers/Csv/Data.php +++ b/app/Helpers/Csv/Data.php @@ -64,7 +64,7 @@ class Data * * @param string $csvFileContent */ - public function setCsvFileContent($csvFileContent) + public function setCsvFileContent(string $csvFileContent) { $this->csvFileContent = $csvFileContent; } @@ -82,7 +82,7 @@ class Data * * @param string $csvFileLocation */ - public function setCsvFileLocation($csvFileLocation) + public function setCsvFileLocation(string $csvFileLocation) { Session::put('csv-file', $csvFileLocation); $this->csvFileLocation = $csvFileLocation; @@ -99,9 +99,9 @@ class Data /** * - * @param mixed $dateFormat + * @param string $dateFormat */ - public function setDateFormat($dateFormat) + public function setDateFormat(string $dateFormat) { Session::put('csv-date-format', $dateFormat); $this->dateFormat = $dateFormat; @@ -120,7 +120,7 @@ class Data * * @param string $delimiter */ - public function setDelimiter($delimiter) + public function setDelimiter(string $delimiter) { Session::put('csv-delimiter', $delimiter); $this->delimiter = $delimiter; @@ -233,7 +233,7 @@ class Data * * @param bool $hasHeaders */ - public function setHasHeaders($hasHeaders) + public function setHasHeaders(bool $hasHeaders) { Session::put('csv-has-headers', $hasHeaders); $this->hasHeaders = $hasHeaders; @@ -243,7 +243,7 @@ class Data * * @param int $importAccount */ - public function setImportAccount($importAccount) + public function setImportAccount(int $importAccount) { Session::put('csv-import-account', $importAccount); $this->importAccount = $importAccount; diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index e72a127a24..48750670a9 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -136,7 +136,7 @@ class Importer /** * @param Data $data */ - public function setData($data) + public function setData(Data $data) { $this->data = $data; } @@ -218,12 +218,12 @@ class Importer } /** - * @param $row + * @param array $row * * @throws FireflyException * @return string|bool */ - protected function importRow($row) + protected function importRow(array $row) { $data = $this->getFiller(); // These fields are necessary to create a new transaction journal. Some are optional @@ -266,7 +266,7 @@ class Importer * * @return bool */ - protected function parseRow($index) + protected function parseRow(int $index) { return (($this->data->hasHeaders() && $index >= 1) || !$this->data->hasHeaders()); } diff --git a/app/Helpers/Csv/Specifix/AbnAmroDescription.php b/app/Helpers/Csv/Specifix/AbnAmroDescription.php index dac1899557..19655ef599 100644 --- a/app/Helpers/Csv/Specifix/AbnAmroDescription.php +++ b/app/Helpers/Csv/Specifix/AbnAmroDescription.php @@ -49,7 +49,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface /** * @param array $data */ - public function setData($data) + public function setData(array $data) { $this->data = $data; } @@ -57,7 +57,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface /** * @param array $row */ - public function setRow($row) + public function setRow(array $row) { $this->row = $row; } diff --git a/app/Helpers/Csv/Specifix/Dummy.php b/app/Helpers/Csv/Specifix/Dummy.php index 915e87bd37..3dc94e5cb0 100644 --- a/app/Helpers/Csv/Specifix/Dummy.php +++ b/app/Helpers/Csv/Specifix/Dummy.php @@ -35,7 +35,7 @@ class Dummy extends Specifix implements SpecifixInterface /** * @param array $data */ - public function setData($data) + public function setData(array $data) { $this->data = $data; } @@ -43,7 +43,7 @@ class Dummy extends Specifix implements SpecifixInterface /** * @param array $row */ - public function setRow($row) + public function setRow(array $row) { $this->row = $row; } diff --git a/app/Helpers/Csv/Specifix/RabobankDescription.php b/app/Helpers/Csv/Specifix/RabobankDescription.php index a8fced085a..83c6039184 100644 --- a/app/Helpers/Csv/Specifix/RabobankDescription.php +++ b/app/Helpers/Csv/Specifix/RabobankDescription.php @@ -40,7 +40,7 @@ class RabobankDescription extends Specifix implements SpecifixInterface /** * @param array $data */ - public function setData($data) + public function setData(array $data) { $this->data = $data; } @@ -48,7 +48,7 @@ class RabobankDescription extends Specifix implements SpecifixInterface /** * @param array $row */ - public function setRow($row) + public function setRow(array $row) { $this->row = $row; } diff --git a/app/Helpers/Csv/Specifix/Specifix.php b/app/Helpers/Csv/Specifix/Specifix.php index 2c2a191811..9a855b32a1 100644 --- a/app/Helpers/Csv/Specifix/Specifix.php +++ b/app/Helpers/Csv/Specifix/Specifix.php @@ -29,11 +29,11 @@ class Specifix } /** - * @param $processorType + * @param int $processorType * * @return $this */ - public function setProcessorType($processorType) + public function setProcessorType(int $processorType) { $this->processorType = $processorType; diff --git a/app/Helpers/Csv/Specifix/SpecifixInterface.php b/app/Helpers/Csv/Specifix/SpecifixInterface.php index 805df80083..852ea96cca 100644 --- a/app/Helpers/Csv/Specifix/SpecifixInterface.php +++ b/app/Helpers/Csv/Specifix/SpecifixInterface.php @@ -24,17 +24,17 @@ interface SpecifixInterface /** * @param array $data */ - public function setData($data); + public function setData(array $data); /** * @param int $processorType * * @return $this */ - public function setProcessorType($processorType); + public function setProcessorType(int $processorType); /** * @param array $row */ - public function setRow($row); + public function setRow(array $row); } diff --git a/app/Helpers/Csv/Wizard.php b/app/Helpers/Csv/Wizard.php index bf93c16ec8..92e2bc6e0f 100644 --- a/app/Helpers/Csv/Wizard.php +++ b/app/Helpers/Csv/Wizard.php @@ -26,7 +26,7 @@ class Wizard implements WizardInterface * * @return array */ - public function getMappableValues($reader, array $map, $hasHeaders) + public function getMappableValues(Reader $reader, array $map, bool $hasHeaders) { $values = []; /* @@ -52,11 +52,11 @@ class Wizard implements WizardInterface /** * @param array $roles - * @param mixed $map + * @param array $map * * @return array */ - public function processSelectedMapping(array $roles, $map) + public function processSelectedMapping(array $roles, array $map) { $configRoles = Config::get('csv.roles'); $maps = []; @@ -79,11 +79,11 @@ class Wizard implements WizardInterface } /** - * @param mixed $input + * @param array $input * * @return array */ - public function processSelectedRoles($input) + public function processSelectedRoles(array $input) { $roles = []; @@ -150,11 +150,11 @@ class Wizard implements WizardInterface } /** - * @param $path + * @param string $path * * @return string */ - public function storeCsvFile($path) + public function storeCsvFile(string $path) { $time = str_replace(' ', '-', microtime()); $fileName = 'csv-upload-' . Auth::user()->id . '-' . $time . '.csv.encrypted'; @@ -188,7 +188,7 @@ class Wizard implements WizardInterface * * @return bool */ - protected function useRow($hasHeaders, $index) + protected function useRow(bool $hasHeaders, int $index) { return ($hasHeaders && $index > 1) || !$hasHeaders; } diff --git a/app/Helpers/Csv/WizardInterface.php b/app/Helpers/Csv/WizardInterface.php index 6257a85694..1905f42d61 100644 --- a/app/Helpers/Csv/WizardInterface.php +++ b/app/Helpers/Csv/WizardInterface.php @@ -18,22 +18,22 @@ interface WizardInterface * * @return array */ - public function getMappableValues($reader, array $map, $hasHeaders); + public function getMappableValues(Reader $reader, array $map, bool $hasHeaders); /** * @param array $roles - * @param mixed $map + * @param array $map * * @return array */ - public function processSelectedMapping(array $roles, $map); + public function processSelectedMapping(array $roles, array $map); /** - * @param mixed $input + * @param array $input * * @return array */ - public function processSelectedRoles($input); + public function processSelectedRoles(array $input); /** * @param array $fields @@ -50,10 +50,10 @@ interface WizardInterface public function showOptions(array $map); /** - * @param $path + * @param string $path * * @return string */ - public function storeCsvFile($path); + public function storeCsvFile(string $path); } diff --git a/app/Helpers/Help/Help.php b/app/Helpers/Help/Help.php index 87b7703ef8..8bbb038627 100644 --- a/app/Helpers/Help/Help.php +++ b/app/Helpers/Help/Help.php @@ -19,11 +19,11 @@ class Help implements HelpInterface /** * @codeCoverageIgnore * - * @param $key + * @param string $key * * @return string */ - public function getFromCache($key) + public function getFromCache(string $key) { return Cache::get($key); } @@ -31,11 +31,11 @@ class Help implements HelpInterface /** * @codeCoverageIgnore * - * @param $route + * @param string $route * * @return array */ - public function getFromGithub($route) + public function getFromGithub(string $route) { $uri = 'https://raw.githubusercontent.com/JC5/firefly-iii-help/master/en/' . e($route) . '.md'; $routeIndex = str_replace('.', '-', $route); @@ -62,11 +62,11 @@ class Help implements HelpInterface /** * @codeCoverageIgnore * - * @param $route + * @param string $route * * @return bool */ - public function hasRoute($route) + public function hasRoute(string $route) { return Route::has($route); } @@ -74,11 +74,11 @@ class Help implements HelpInterface /** * @codeCoverageIgnore * - * @param $route + * @param string $route * * @return bool */ - public function inCache($route) + public function inCache(string $route) { return Cache::has('help.' . $route . '.title') && Cache::has('help.' . $route . '.text'); } @@ -86,12 +86,12 @@ class Help implements HelpInterface /** * @codeCoverageIgnore * - * @param $route - * @param array $content + * @param string $route + * @param array $content * * @internal param $title */ - public function putInCache($route, array $content) + public function putInCache(string $route, array $content) { Cache::put('help.' . $route . '.text', $content['text'], 10080); // a week. Cache::put('help.' . $route . '.title', $content['title'], 10080); diff --git a/app/Helpers/Help/HelpInterface.php b/app/Helpers/Help/HelpInterface.php index 3807c2c1ff..892e554f9e 100644 --- a/app/Helpers/Help/HelpInterface.php +++ b/app/Helpers/Help/HelpInterface.php @@ -11,38 +11,38 @@ interface HelpInterface { /** - * @param $key + * @param string $key * * @return string */ - public function getFromCache($key); + public function getFromCache(string $key); /** - * @param $route + * @param string $route * * @return array */ - public function getFromGithub($route); + public function getFromGithub(string $route); /** - * @param $route + * @param string $route * * @return bool */ - public function hasRoute($route); + public function hasRoute(string $route); /** - * @param $route + * @param string $route * * @return bool */ - public function inCache($route); + public function inCache(string $route); /** - * @param $route - * @param array $content + * @param string $route + * @param array $content * * @return void */ - public function putInCache($route, array $content); + public function putInCache(string $route, array $content); } diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index 5b2759a675..6717282493 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -132,7 +132,7 @@ class ReportHelper implements ReportHelperInterface * * @return Expense */ - public function getExpenseReport($start, $end, Collection $accounts) + public function getExpenseReport(Carbon $start, Carbon $end, Collection $accounts) { $object = new Expense; $set = $this->query->expense($accounts, $start, $end); @@ -154,7 +154,7 @@ class ReportHelper implements ReportHelperInterface * * @return Income */ - public function getIncomeReport($start, $end, Collection $accounts) + public function getIncomeReport(Carbon $start, Carbon $end, Collection $accounts) { $object = new Income; $set = $this->query->income($accounts, $start, $end); diff --git a/app/Helpers/Report/ReportHelperInterface.php b/app/Helpers/Report/ReportHelperInterface.php index 7a1833a230..1ff2fc08ef 100644 --- a/app/Helpers/Report/ReportHelperInterface.php +++ b/app/Helpers/Report/ReportHelperInterface.php @@ -49,7 +49,7 @@ interface ReportHelperInterface * * @return Expense */ - public function getExpenseReport($start, $end, Collection $accounts); + public function getExpenseReport(Carbon $start, Carbon $end, Collection $accounts); /** * Get a full report on the users incomes during the period for the given accounts. @@ -60,7 +60,7 @@ interface ReportHelperInterface * * @return Income */ - public function getIncomeReport($start, $end, Collection $accounts); + public function getIncomeReport(Carbon $start, Carbon $end, Collection $accounts); /** * @param Carbon $date diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 2c2083522b..7bda3cb6c3 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -36,7 +36,7 @@ class AccountController extends Controller * * @return \Illuminate\View\View */ - public function create($what = 'asset') + public function create(string $what = 'asset') { @@ -148,7 +148,7 @@ class AccountController extends Controller * * @return \Illuminate\View\View */ - public function index(ARI $repository, $what) + public function index(ARI $repository, string $what) { $subTitle = trans('firefly.' . $what . '_accounts'); $subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what); @@ -275,11 +275,11 @@ class AccountController extends Controller /** * @param array $array - * @param $entryId + * @param int $entryId * * @return null|mixed */ - protected function isInArray(array $array, $entryId) + protected function isInArray(array $array, int $entryId) { if (isset($array[$entryId])) { return $array[$entryId]; diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 9d430846bb..09c88dfeb3 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -205,11 +205,11 @@ class AuthController extends Controller /** * Get the failed login message. * - * @param $message + * @param string $message * * @return string */ - protected function getFailedLoginMessage($message) + protected function getFailedLoginMessage(string $message) { if (strlen($message) > 0) { return $message; @@ -221,11 +221,11 @@ class AuthController extends Controller } /** - * @param $email + * @param string $email * * @return bool */ - protected function isBlockedDomain($email) + protected function isBlockedDomain(string $email) { $parts = explode('@', $email); $blocked = $this->getBlockedDomains(); @@ -241,12 +241,11 @@ class AuthController extends Controller * Get the failed login response instance. * * @param \Illuminate\Http\Request $request - * - * @param $message + * @param string $message * * @return \Illuminate\Http\Response */ - protected function sendFailedLoginResponse(Request $request, $message) + protected function sendFailedLoginResponse(Request $request, string $message) { return redirect()->back() ->withInput($request->only($this->loginUsername(), 'remember')) diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 325f5a0352..33801802e6 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -229,7 +229,7 @@ class BudgetController extends Controller return view('error', compact('message')); } - $journals = $repository->getJournals($budget, $repetition); + $journals = $repository->getJournals($budget, $repetition, 50); if (is_null($repetition->id)) { $start = $repository->firstActivity($budget); diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 1a9f305b8e..c2e4bf1b32 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -213,7 +213,7 @@ class CategoryController extends Controller * * @return \Illuminate\View\View */ - public function showWithDate(SCRI $repository, Category $category, $date) + public function showWithDate(SCRI $repository, Category $category, string $date) { $carbon = new Carbon($date); $range = Preferences::get('viewRange', '1M')->data; diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index 6a5a3ea715..ff79d24537 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -43,7 +43,7 @@ class AccountController extends Controller * * @return \Illuminate\Http\JsonResponse */ - public function report($reportType, Carbon $start, Carbon $end, Collection $accounts) + public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts) { // chart properties for cache: $cache = new CacheProperties(); diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index 1677b2b817..7e947476c2 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -35,87 +35,6 @@ class BudgetController extends Controller $this->generator = app('FireflyIII\Generator\Chart\Budget\BudgetChartGeneratorInterface'); } - /** - * - * @param BudgetRepositoryInterface $repository - * @param $reportType - * @param Carbon $start - * @param Carbon $end - * @param Collection $accounts - * @param Collection $budgets - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) // need all parameters - * - * @return \Illuminate\Http\JsonResponse - */ - public function multiYear(BudgetRepositoryInterface $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $budgets) - { - // chart properties for cache: - $cache = new CacheProperties(); - $cache->addProperty($reportType); - $cache->addProperty($start); - $cache->addProperty($end); - $cache->addProperty($accounts); - $cache->addProperty($budgets); - $cache->addProperty('multiYearBudget'); - - if ($cache->has()) { - return Response::json($cache->get()); // @codeCoverageIgnore - } - - /* - * Get the budgeted amounts for each budgets in each year. - */ - $budgetedSet = $repository->getBudgetedPerYear($budgets, $start, $end); - $budgetedArray = []; - /** @var Budget $entry */ - foreach ($budgetedSet as $entry) { - $budgetedArray[$entry->id][$entry->dateFormatted] = $entry->budgeted; - } - - $set = $repository->getBudgetsAndExpensesPerYear($budgets, $accounts, $start, $end); - $entries = new Collection; - // go by budget, not by year. - /** @var Budget $budget */ - foreach ($budgets as $budget) { - $entry = ['name' => '', 'spent' => [], 'budgeted' => []]; - $id = $budget->id; - $currentStart = clone $start; - while ($currentStart < $end) { - // fix the date: - $currentEnd = clone $currentStart; - $currentEnd->endOfYear(); - - // save to array: - $year = $currentStart->year; - $entry['name'] = $budget->name; - $spent = 0; - $budgeted = 0; - if (isset($set[$id]['entries'][$year])) { - $spent = $set[$id]['entries'][$year] * -1; - } - - if (isset($budgetedArray[$id][$year])) { - $budgeted = round($budgetedArray[$id][$year], 2); - } - - $entry['spent'][$year] = $spent; - $entry['budgeted'][$year] = $budgeted; - - // jump to next year. - $currentStart = clone $currentEnd; - $currentStart->addDay(); - } - $entries->push($entry); - } - // generate chart with data: - $data = $this->generator->multiYear($entries); - $cache->store($data); - - return Response::json($data); - - } - /** * @param BudgetRepositoryInterface $repository * @param Budget $budget @@ -298,10 +217,91 @@ class BudgetController extends Controller * @param Carbon $start * @param Carbon $end * @param Collection $accounts + * @param Collection $budgets + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) // need all parameters * * @return \Illuminate\Http\JsonResponse */ - public function year(BudgetRepositoryInterface $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts) + public function multiYear(BudgetRepositoryInterface $repository, string $reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $budgets) + { + // chart properties for cache: + $cache = new CacheProperties(); + $cache->addProperty($reportType); + $cache->addProperty($start); + $cache->addProperty($end); + $cache->addProperty($accounts); + $cache->addProperty($budgets); + $cache->addProperty('multiYearBudget'); + + if ($cache->has()) { + return Response::json($cache->get()); // @codeCoverageIgnore + } + + /* + * Get the budgeted amounts for each budgets in each year. + */ + $budgetedSet = $repository->getBudgetedPerYear($budgets, $start, $end); + $budgetedArray = []; + /** @var Budget $entry */ + foreach ($budgetedSet as $entry) { + $budgetedArray[$entry->id][$entry->dateFormatted] = $entry->budgeted; + } + + $set = $repository->getBudgetsAndExpensesPerYear($budgets, $accounts, $start, $end); + $entries = new Collection; + // go by budget, not by year. + /** @var Budget $budget */ + foreach ($budgets as $budget) { + $entry = ['name' => '', 'spent' => [], 'budgeted' => []]; + $id = $budget->id; + $currentStart = clone $start; + while ($currentStart < $end) { + // fix the date: + $currentEnd = clone $currentStart; + $currentEnd->endOfYear(); + + // save to array: + $year = $currentStart->year; + $entry['name'] = $budget->name; + $spent = 0; + $budgeted = 0; + if (isset($set[$id]['entries'][$year])) { + $spent = $set[$id]['entries'][$year] * -1; + } + + if (isset($budgetedArray[$id][$year])) { + $budgeted = round($budgetedArray[$id][$year], 2); + } + + $entry['spent'][$year] = $spent; + $entry['budgeted'][$year] = $budgeted; + + // jump to next year. + $currentStart = clone $currentEnd; + $currentStart->addDay(); + } + $entries->push($entry); + } + // generate chart with data: + $data = $this->generator->multiYear($entries); + $cache->store($data); + + return Response::json($data); + + } + + /** + * + * @param BudgetRepositoryInterface $repository + * @param $reportType + * @param Carbon $start + * @param Carbon $end + * @param Collection $accounts + * + * @return \Illuminate\Http\JsonResponse + */ + public function year(BudgetRepositoryInterface $repository, string $reportType, Carbon $start, Carbon $end, Collection $accounts) { // chart properties for cache: $cache = new CacheProperties(); diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index 409c2bf72c..99482bf2ea 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -114,7 +114,7 @@ class CategoryController extends Controller * * @return \Illuminate\Http\JsonResponse */ - public function earnedInPeriod(CRI $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts) + public function earnedInPeriod(CRI $repository, string $reportType, Carbon $start, Carbon $end, Collection $accounts) { $cache = new CacheProperties; // chart properties for cache: $cache->addProperty($start); @@ -215,7 +215,7 @@ class CategoryController extends Controller * * @return \Illuminate\Http\JsonResponse */ - public function multiYear($reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $categories) + public function multiYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $categories) { /** @var CRI $repository */ $repository = app('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php index a4b558876c..1832a8ab6f 100644 --- a/app/Http/Controllers/Chart/ReportController.php +++ b/app/Http/Controllers/Chart/ReportController.php @@ -45,7 +45,7 @@ class ReportController extends Controller * * @return \Illuminate\Http\JsonResponse */ - public function yearInOut(ReportQueryInterface $query, $reportType, Carbon $start, Carbon $end, Collection $accounts) + public function yearInOut(ReportQueryInterface $query, string $reportType, Carbon $start, Carbon $end, Collection $accounts) { // chart properties for cache: $cache = new CacheProperties; @@ -88,7 +88,7 @@ class ReportController extends Controller * * @return \Illuminate\Http\JsonResponse */ - public function yearInOutSummarized(ReportQueryInterface $query, $reportType, Carbon $start, Carbon $end, Collection $accounts) + public function yearInOutSummarized(ReportQueryInterface $query, string $reportType, Carbon $start, Carbon $end, Collection $accounts) { // chart properties for cache: diff --git a/app/Http/Controllers/HelpController.php b/app/Http/Controllers/HelpController.php index 667aef28f3..4b346ec8fd 100644 --- a/app/Http/Controllers/HelpController.php +++ b/app/Http/Controllers/HelpController.php @@ -25,7 +25,7 @@ class HelpController extends Controller * * @return \Illuminate\Http\JsonResponse */ - public function show(HelpInterface $help, $route) + public function show(HelpInterface $help, string $route) { $content = [ 'text' => '

    There is no help for this route!

    ', diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 89c82545b6..a6509cd9f2 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -122,7 +122,7 @@ class ProfileController extends Controller * * @return string|bool */ - protected function validatePassword($old, $new1) + protected function validatePassword(string $old, string $new1) { if ($new1 == $old) { return trans('firefly.should_change'); diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index c5640d0b5a..3cab30df27 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -78,7 +78,7 @@ class ReportController extends Controller * * @return View */ - public function report($reportType, Carbon $start, Carbon $end, Collection $accounts) + public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts) { // throw an error if necessary. if ($end < $start) { @@ -130,7 +130,7 @@ class ReportController extends Controller * * @return View */ - private function defaultMonth($reportType, Carbon $start, Carbon $end, Collection $accounts) + private function defaultMonth(string $reportType, Carbon $start, Carbon $end, Collection $accounts) { $incomeTopLength = 8; $expenseTopLength = 8; @@ -171,7 +171,7 @@ class ReportController extends Controller * * @return View */ - private function defaultMultiYear($reportType, $start, $end, $accounts) + private function defaultMultiYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts) { $incomeTopLength = 8; @@ -208,7 +208,7 @@ class ReportController extends Controller * * @return View */ - private function defaultYear($reportType, Carbon $start, Carbon $end, Collection $accounts) + private function defaultYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts) { $incomeTopLength = 8; $expenseTopLength = 8; diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index be29b9ec53..a61d1e2d75 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -159,11 +159,11 @@ class TagController extends Controller * * @return \Symfony\Component\HttpFoundation\Response */ - public function hideTagHelp($state) + public function hideTagHelp(string $state) { - $state = $state == 'true' ? true : false; - Preferences::set('hideTagHelp', $state); + $newState = $state == 'true' ? true : false; + Preferences::set('hideTagHelp', $newState); return Response::json([true]); } diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index e8b92dadba..4081278afb 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -49,7 +49,7 @@ class TransactionController extends Controller * * @return \Illuminate\View\View */ - public function create(ARI $repository, $what = TransactionType::DEPOSIT) + public function create(ARI $repository, string $what = TransactionType::DEPOSIT) { $what = strtolower($what); $maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize')); @@ -211,7 +211,7 @@ class TransactionController extends Controller * * @return \Illuminate\View\View */ - public function index(JournalRepositoryInterface $repository, $what) + public function index(JournalRepositoryInterface $repository, string $what) { $subTitleIcon = Config::get('firefly.transactionIconsByWhat.' . $what); $types = Config::get('firefly.transactionTypesByWhat.' . $what); diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index 71b894a813..df5ff587a2 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -33,14 +33,14 @@ Breadcrumbs::register( // accounts Breadcrumbs::register( - 'accounts.index', function (BreadCrumbGenerator $breadcrumbs, $what) { + 'accounts.index', function (BreadCrumbGenerator $breadcrumbs, string $what) { $breadcrumbs->parent('home'); $breadcrumbs->push(trans('firefly.' . strtolower(e($what)) . '_accounts'), route('accounts.index', [$what])); } ); Breadcrumbs::register( - 'accounts.create', function (BreadCrumbGenerator $breadcrumbs, $what) { + 'accounts.create', function (BreadCrumbGenerator $breadcrumbs, string $what) { $breadcrumbs->parent('accounts.index', $what); $breadcrumbs->push(trans('firefly.new_' . strtolower(e($what)) . '_account'), route('accounts.create', [$what])); } @@ -384,13 +384,13 @@ Breadcrumbs::register( // transactions Breadcrumbs::register( - 'transactions.index', function (BreadCrumbGenerator $breadcrumbs, $what) { + 'transactions.index', function (BreadCrumbGenerator $breadcrumbs, string $what) { $breadcrumbs->parent('home'); $breadcrumbs->push(trans('breadcrumbs.' . $what . '_list'), route('transactions.index', [$what])); } ); Breadcrumbs::register( - 'transactions.create', function (BreadCrumbGenerator $breadcrumbs, $what) { + 'transactions.create', function (BreadCrumbGenerator $breadcrumbs, string $what) { $breadcrumbs->parent('transactions.index', $what); $breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('transactions.create', [$what])); } diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 38bf2f0caa..5b6c7deeb8 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -63,11 +63,11 @@ class AccountRepository implements AccountRepositoryInterface /** * @deprecated * - * @param $accountId + * @param int $accountId * * @return Account */ - public function find($accountId) + public function find(int $accountId) { return Auth::user()->accounts()->findOrNew($accountId); } diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php index 9b10c383c7..8f0d460abb 100644 --- a/app/Repositories/Account/AccountRepositoryInterface.php +++ b/app/Repositories/Account/AccountRepositoryInterface.php @@ -34,13 +34,13 @@ interface AccountRepositoryInterface public function destroy(Account $account, Account $moveTo = null); /** - * @param $accountId + * @param int $accountId * * @deprecated * * @return Account */ - public function find($accountId); + public function find(int $accountId); /** * Gets all the accounts by ID, for a given set. diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index dbf9d47c31..c789390f05 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -443,7 +443,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return LengthAwarePaginator */ - public function getJournals(Budget $budget, LimitRepetition $repetition = null, $take = 50) + public function getJournals(Budget $budget, LimitRepetition $repetition, int $take) { $offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0; $setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->offset($offset) @@ -493,7 +493,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * @param Carbon $start * @param Carbon $end * - * @return double + * @return string */ public function getWithoutBudgetSum(Carbon $start, Carbon $end) { @@ -519,6 +519,9 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn ) ->transactionTypes([TransactionType::WITHDRAWAL]) ->first([DB::Raw('SUM(`transactions`.`amount`) as `journalAmount`')]); + if (is_null($entry->journalAmount)) { + return ''; + } return $entry->journalAmount; } diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php index 0aec8c451a..67ba9bf499 100644 --- a/app/Repositories/Budget/BudgetRepositoryInterface.php +++ b/app/Repositories/Budget/BudgetRepositoryInterface.php @@ -168,7 +168,7 @@ interface BudgetRepositoryInterface * * @return LengthAwarePaginator */ - public function getJournals(Budget $budget, LimitRepetition $repetition = null, $take = 50); + public function getJournals(Budget $budget, LimitRepetition $repetition, int $take); /** * @param Carbon $start diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php index db5e1450e8..de0a41bab4 100644 --- a/app/Repositories/ExportJob/ExportJobRepository.php +++ b/app/Repositories/ExportJob/ExportJobRepository.php @@ -68,11 +68,11 @@ class ExportJobRepository implements ExportJobRepositoryInterface } /** - * @param $key + * @param string $key * * @return ExportJob|null */ - public function findByKey($key) + public function findByKey(string $key) { return Auth::user()->exportJobs()->where('key', $key)->first(); } diff --git a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php index 68265b2bc5..e270a0227d 100644 --- a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php +++ b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php @@ -29,10 +29,10 @@ interface ExportJobRepositoryInterface public function create(); /** - * @param $key + * @param string $key * * @return ExportJob|null */ - public function findByKey($key); + public function findByKey(string $key); } \ No newline at end of file diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index ba3b4200e3..cc152e2ff9 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -90,7 +90,7 @@ class JournalRepository implements JournalRepositoryInterface * * @return LengthAwarePaginator */ - public function getJournalsOfTypes(array $types, $offset, $page) + public function getJournalsOfTypes(array $types, int $offset, int $page) { $set = Auth::user()->transactionJournals()->transactionTypes($types)->withRelevantData()->take(50)->offset($offset) ->orderBy('date', 'DESC') @@ -106,11 +106,11 @@ class JournalRepository implements JournalRepositoryInterface } /** - * @param $type + * @param string $type * * @return TransactionType */ - public function getTransactionType($type) + public function getTransactionType(string $type) { return TransactionType::whereType($type)->first(); } @@ -121,7 +121,7 @@ class JournalRepository implements JournalRepositoryInterface * * @return TransactionJournal */ - public function getWithDate($journalId, Carbon $date) + public function getWithDate(int $journalId, Carbon $date) { return Auth::user()->transactionjournals()->where('id', $journalId)->where('date', $date->format('Y-m-d 00:00:00'))->first(); } diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php index fb7ccb6cc9..de65cf94ad 100644 --- a/app/Repositories/Journal/JournalRepositoryInterface.php +++ b/app/Repositories/Journal/JournalRepositoryInterface.php @@ -52,14 +52,14 @@ interface JournalRepositoryInterface * * @return LengthAwarePaginator */ - public function getJournalsOfTypes(array $types, $offset, $page); + public function getJournalsOfTypes(array $types, int $offset, int $page); /** - * @param $type + * @param string $type * * @return TransactionType */ - public function getTransactionType($type); + public function getTransactionType(string $type); /** * @param int $journalId @@ -67,7 +67,7 @@ interface JournalRepositoryInterface * * @return TransactionJournal */ - public function getWithDate($journalId, Carbon $date); + public function getWithDate(int $journalId, Carbon $date); /** * @param TransactionJournal $journal diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index 8d49f3c74f..cec8eeec5e 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -19,11 +19,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface /** * @param PiggyBank $piggyBank - * @param $amount + * @param string $amount * * @return bool */ - public function createEvent(PiggyBank $piggyBank, $amount) + public function createEvent(PiggyBank $piggyBank, string $amount) { PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]); @@ -107,7 +107,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface * * @return void */ - public function setOrder($piggyBankId, $order) + public function setOrder(int $piggyBankId, int $order) { $piggyBank = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id) ->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']); diff --git a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php index 8d0f81b654..3ce36c36b6 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php +++ b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php @@ -15,11 +15,11 @@ interface PiggyBankRepositoryInterface /** * @param PiggyBank $piggyBank - * @param $amount + * @param string $amount * * @return bool */ - public function createEvent(PiggyBank $piggyBank, $amount); + public function createEvent(PiggyBank $piggyBank, string $amount); /** * @param PiggyBank $piggyBank @@ -68,7 +68,7 @@ interface PiggyBankRepositoryInterface * * @return void */ - public function setOrder($piggyBankId, $order); + public function setOrder(int $piggyBankId, int $order); /** diff --git a/app/Support/Amount.php b/app/Support/Amount.php index a9ecd74414..8bdabed408 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -18,12 +18,12 @@ class Amount { /** - * @param $amount - * @param bool $coloured + * @param string $amount + * @param bool $coloured * * @return string */ - public function format($amount, $coloured = true) + public function format(string $amount, bool $coloured = true) { return $this->formatAnything($this->getDefaultCurrency(), $amount, $coloured); } @@ -33,16 +33,17 @@ class Amount * as a currency, given two things: the currency required and the current locale. * * @param TransactionCurrency $format - * @param $amount + * @param string $amount * @param bool $coloured * * @return string */ - public function formatAnything(TransactionCurrency $format, $amount, $coloured = true) + public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = true) { $locale = setlocale(LC_MONETARY, 0); + $float = floatval($amount); $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); - $result = $formatter->formatCurrency($amount, $format->code); + $result = $formatter->formatCurrency($float, $format->code); if ($coloured === true) { if ($amount == 0) { @@ -66,7 +67,7 @@ class Amount * * @return string */ - public function formatJournal(TransactionJournal $journal, $coloured = true) + public function formatJournal(TransactionJournal $journal, bool $coloured = true) { $cache = new CacheProperties; $cache->addProperty($journal->id); @@ -101,7 +102,7 @@ class Amount * * @return string */ - public function formatTransaction(Transaction $transaction, $coloured = true) + public function formatTransaction(Transaction $transaction, bool $coloured = true) { $currency = $transaction->transactionJournal->transactionCurrency; @@ -115,7 +116,7 @@ class Amount * * @return string */ - public function formatWithSymbol($symbol, $amount, $coloured = true) + public function formatWithSymbol(string $symbol, string $amount, $coloured = true) { return $this->formatAnything($this->getDefaultCurrency(), $amount, $coloured); } diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.php index b9cbde52ae..045275fe18 100644 --- a/app/Support/Binder/AccountList.php +++ b/app/Support/Binder/AccountList.php @@ -13,6 +13,7 @@ namespace FireflyIII\Support\Binder; use Auth; use FireflyIII\Models\Account; +use Illuminate\Support\Collection; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -27,7 +28,7 @@ class AccountList implements BinderInterface * @param $value * @param $route * - * @return mixed + * @return Collection */ public static function routeBinder($value, $route) { diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index 302e26aaa6..62eec09fb4 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -26,7 +26,7 @@ class ExpandedForm * * @return string */ - public function amount($name, $value = null, array $options = []) + public function amount(string $name, $value = null, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -51,7 +51,7 @@ class ExpandedForm * * @return string */ - public function balance($name, $value = null, array $options = []) + public function balance(string $name, $value = null, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -75,7 +75,7 @@ class ExpandedForm * * @return string */ - public function checkbox($name, $value = 1, $checked = null, $options = []) + public function checkbox(string $name, $value = 1, $checked = null, $options = []) { $options['checked'] = $checked === true ? true : null; $label = $this->label($name, $options); @@ -97,7 +97,7 @@ class ExpandedForm * * @return string */ - public function date($name, $value = null, array $options = []) + public function date(string $name, $value = null, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -115,7 +115,7 @@ class ExpandedForm * * @return string */ - public function file($name, array $options = []) + public function file(string $name, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -133,7 +133,7 @@ class ExpandedForm * * @return string */ - public function integer($name, $value = null, array $options = []) + public function integer(string $name, $value = null, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -153,7 +153,7 @@ class ExpandedForm * * @return string */ - public function location($name, $value = null, array $options = []) + public function location(string $name, $value = null, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -174,7 +174,7 @@ class ExpandedForm * * @return mixed */ - public function makeSelectList(Collection $set, $addEmpty = false) + public function makeSelectList(Collection $set, bool $addEmpty = false) { $selectList = []; if ($addEmpty) { @@ -205,7 +205,7 @@ class ExpandedForm * * @return string */ - public function multiCheckbox($name, array $list = [], $selected = null, array $options = []) + public function multiCheckbox(string $name, array $list = [], $selected = null, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -226,7 +226,7 @@ class ExpandedForm * * @return string */ - public function multiRadio($name, array $list = [], $selected = null, array $options = []) + public function multiRadio(string $name, array $list = [], $selected = null, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -271,7 +271,7 @@ class ExpandedForm * * @return string */ - public function select($name, array $list = [], $selected = null, array $options = []) + public function select(string $name, array $list = [], $selected = null, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index 8ddcc82c0f..9e0ca7d4e7 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -66,197 +66,6 @@ class General extends Twig_Extension return 'FireflyIII\Support\Twig\General'; } - /** - * @return Twig_SimpleFilter - */ - protected function formatFilesize() - { - return new Twig_SimpleFilter( - 'filesize', function ($size) { - $size = intval($size); - - // less than one GB, more than one MB - if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) { - return round($size / (1024 * 1024), 2) . ' MB'; - } - - // less than one MB - if ($size < (1024 * 1024)) { - return round($size / 1024, 2) . ' KB'; - } - - return $size . ' bytes'; - } - ); - } - - /** - * @return Twig_SimpleFilter - */ - protected function mimeIcon() - { - return new Twig_SimpleFilter( - 'mimeIcon', function ($string) { - switch ($string) { - default: - return 'fa-file-o'; - case 'application/pdf': - return 'fa-file-pdf-o'; - case 'image/png': - case 'image/jpeg': - return 'fa-file-image-o'; - } - }, ['is_safe' => ['html']] - ); - } - - /** - * @return Twig_SimpleFilter - */ - protected function formatAmount() - { - return new Twig_SimpleFilter( - 'formatAmount', function ($string) { - return app('amount')->format($string); - }, ['is_safe' => ['html']] - ); - } - - /** - * @return Twig_SimpleFilter - */ - protected function formatTransaction() - { - return new Twig_SimpleFilter( - 'formatTransaction', function (Transaction $transaction) { - return app('amount')->formatTransaction($transaction); - }, ['is_safe' => ['html']] - ); - } - - /** - * @return Twig_SimpleFilter - */ - protected function formatAmountPlain() - { - return new Twig_SimpleFilter( - 'formatAmountPlain', function ($string) { - return app('amount')->format($string, false); - }, ['is_safe' => ['html']] - ); - } - - /** - * @return Twig_SimpleFilter - */ - protected function formatJournal() - { - return new Twig_SimpleFilter( - 'formatJournal', function ($journal) { - return app('amount')->formatJournal($journal); - }, ['is_safe' => ['html']] - ); - } - - /** - * @return Twig_SimpleFilter - */ - protected function balance() - { - return new Twig_SimpleFilter( - 'balance', function (Account $account = null) { - if (is_null($account)) { - return 'NULL'; - } - $date = session('end', Carbon::now()->endOfMonth()); - - return app('steam')->balance($account, $date); - } - ); - } - - /** - * @return Twig_SimpleFilter - */ - protected function getAccountRole() - { - return new Twig_SimpleFilter( - 'getAccountRole', function ($name) { - return Config::get('firefly.accountRoles.' . $name); - } - ); - } - - /** - * @return Twig_SimpleFunction - */ - protected function getCurrencyCode() - { - return new Twig_SimpleFunction( - 'getCurrencyCode', function () { - return app('amount')->getCurrencyCode(); - } - ); - } - - /** - * @return Twig_SimpleFunction - */ - protected function getCurrencySymbol() - { - return new Twig_SimpleFunction( - 'getCurrencySymbol', function () { - return app('amount')->getCurrencySymbol(); - } - ); - } - - /** - * @return Twig_SimpleFunction - */ - protected function phpdate() - { - return new Twig_SimpleFunction( - 'phpdate', function ($str) { - return date($str); - } - ); - } - - /** - * @return Twig_SimpleFunction - */ - protected function env() - { - return new Twig_SimpleFunction( - 'env', function ($name, $default) { - return env($name, $default); - } - ); - } - - /** - * Will return "active" when the current route matches the given argument - * exactly. - * - * @return Twig_SimpleFunction - */ - protected function activeRouteStrict() - { - return new Twig_SimpleFunction( - 'activeRouteStrict', function () { - $args = func_get_args(); - $route = $args[0]; // name of the route. - - if (Route::getCurrentRoute()->getName() == $route) { - return 'active'; - } - - return ''; - } - ); - } - /** * Will return "active" when a part of the route matches the argument. * ie. "accounts" will match "accounts.index". @@ -302,4 +111,197 @@ class General extends Twig_Extension ); } + /** + * Will return "active" when the current route matches the given argument + * exactly. + * + * @return Twig_SimpleFunction + */ + protected function activeRouteStrict() + { + return new Twig_SimpleFunction( + 'activeRouteStrict', function () { + $args = func_get_args(); + $route = $args[0]; // name of the route. + + if (Route::getCurrentRoute()->getName() == $route) { + return 'active'; + } + + return ''; + } + ); + } + + /** + * @return Twig_SimpleFilter + */ + protected function balance() + { + return new Twig_SimpleFilter( + 'balance', function (Account $account = null) { + if (is_null($account)) { + return 'NULL'; + } + $date = session('end', Carbon::now()->endOfMonth()); + + return app('steam')->balance($account, $date); + } + ); + } + + /** + * @return Twig_SimpleFunction + */ + protected function env() + { + return new Twig_SimpleFunction( + 'env', function ($name, $default) { + return env($name, $default); + } + ); + } + + /** + * @return Twig_SimpleFilter + */ + protected function formatAmount() + { + return new Twig_SimpleFilter( + 'formatAmount', function ($string) { + $value = is_null($string) ? '0' : $string; + + return app('amount')->format($value); + }, ['is_safe' => ['html']] + ); + } + + /** + * @return Twig_SimpleFilter + */ + protected function formatAmountPlain() + { + return new Twig_SimpleFilter( + 'formatAmountPlain', function ($string) { + return app('amount')->format($string, false); + }, ['is_safe' => ['html']] + ); + } + + /** + * @return Twig_SimpleFilter + */ + protected function formatFilesize() + { + return new Twig_SimpleFilter( + 'filesize', function ($size) { + $size = intval($size); + + // less than one GB, more than one MB + if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) { + return round($size / (1024 * 1024), 2) . ' MB'; + } + + // less than one MB + if ($size < (1024 * 1024)) { + return round($size / 1024, 2) . ' KB'; + } + + return $size . ' bytes'; + } + ); + } + + /** + * @return Twig_SimpleFilter + */ + protected function formatJournal() + { + return new Twig_SimpleFilter( + 'formatJournal', function ($journal) { + return app('amount')->formatJournal($journal); + }, ['is_safe' => ['html']] + ); + } + + /** + * @return Twig_SimpleFilter + */ + protected function formatTransaction() + { + return new Twig_SimpleFilter( + 'formatTransaction', function (Transaction $transaction) { + return app('amount')->formatTransaction($transaction); + }, ['is_safe' => ['html']] + ); + } + + /** + * @return Twig_SimpleFilter + */ + protected function getAccountRole() + { + return new Twig_SimpleFilter( + 'getAccountRole', function ($name) { + return Config::get('firefly.accountRoles.' . $name); + } + ); + } + + /** + * @return Twig_SimpleFunction + */ + protected function getCurrencyCode() + { + return new Twig_SimpleFunction( + 'getCurrencyCode', function () { + return app('amount')->getCurrencyCode(); + } + ); + } + + /** + * @return Twig_SimpleFunction + */ + protected function getCurrencySymbol() + { + return new Twig_SimpleFunction( + 'getCurrencySymbol', function () { + return app('amount')->getCurrencySymbol(); + } + ); + } + + /** + * @return Twig_SimpleFilter + */ + protected function mimeIcon() + { + return new Twig_SimpleFilter( + 'mimeIcon', function ($string) { + switch ($string) { + default: + return 'fa-file-o'; + case 'application/pdf': + return 'fa-file-pdf-o'; + case 'image/png': + case 'image/jpeg': + return 'fa-file-image-o'; + } + }, ['is_safe' => ['html']] + ); + } + + /** + * @return Twig_SimpleFunction + */ + protected function phpdate() + { + return new Twig_SimpleFunction( + 'phpdate', function ($str) { + return date($str); + } + ); + } + } diff --git a/composer.json b/composer.json index d2b90cbf55..152fb7130e 100644 --- a/composer.json +++ b/composer.json @@ -26,13 +26,14 @@ }, "require-dev": { "fzaninotto/faker": "~1.4", - "mockery/mockery": "0.9.*", + "mockery/mockery": "dev-master", "phpunit/phpunit": "~4.0", "symfony/css-selector": "2.8.*|3.0.*", "symfony/dom-crawler": "2.8.*|3.0.*", "barryvdh/laravel-debugbar": "@stable", "barryvdh/laravel-ide-helper": "~2.0", - "johnkary/phpunit-speedtrap": "^1.0" + "johnkary/phpunit-speedtrap": "^1.0", + "hamcrest/hamcrest-php": "^2.0@dev" }, "autoload": { "classmap": [ diff --git a/storage/build/test-upload.csv b/storage/build/test-upload.csv index 1ad0102bb6..b77b81d550 100644 --- a/storage/build/test-upload.csv +++ b/storage/build/test-upload.csv @@ -1,63 +1,3 @@ -NL11XOLA6707795988,NL10TAPT8906262744,"Suspendisse tempus eros euismod leo consequat, non malesuada arcu pretium.",20160123,15.03,gifts,holiday -NL11XOLA6707795988,NL93UPSZ1261542703,"Morbi quis mauris nec tortor egestas blandit.",20160123,47.38,groceries,studies -NL11XOLA6707795988,NL86IHAL3264575116,"Proin eleifend magna et ante cursus laoreet.",20160123,43.73,"books and such",groceries -NL11XOLA6707795988,NL63BKBO9993148806,"In scelerisque velit eget ante pharetra pretium.",20160123,39.21,dinner,holiday -NL11XOLA6707795988,NL22EZVA6611573534,"Donec tincidunt nibh nec diam sodales, feugiat pulvinar ante consequat.",20160123,24.77,taxes,holiday -NL11XOLA6707795988,NL40KZVR5107424627,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,17.19,dinner,clothes -NL11XOLA6707795988,NL29RHEE6437366575,"Suspendisse tempus eros euismod leo consequat, non malesuada arcu pretium.",20160123,43.14,cash,studies -NL11XOLA6707795988,NL63IEPJ7437420074,"Nunc sed leo scelerisque quam consectetur elementum quis consequat dui.",20160123,35.25,gifts,bills -NL11XOLA6707795988,NL62HQWJ8837203470,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,42.07,taxes,holiday -NL11XOLA6707795988,NL89FPEA1494900858,"Vivamus ultrices tortor vel semper lacinia.",20160123,25.31,gifts,groceries -NL11XOLA6707795988,NL76MDMU3222445567,"In scelerisque velit eget ante pharetra pretium.",20160123,41.76,cash,clothes -NL11XOLA6707795988,NL07TDQA3309954056,"Curabitur vitae nisi consectetur, feugiat ipsum vitae, hendrerit sem.",20160123,10.81,food,studies -NL11XOLA6707795988,NL35MKIY9736938778,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,46.82,"books and such",bills -NL11XOLA6707795988,NL63IEPJ7437420074,"Nullam malesuada orci in vulputate imperdiet.",20160123,10.3,groceries,studies -NL11XOLA6707795988,NL56DNGY5455310496,"Morbi quis mauris nec tortor egestas blandit.",20160123,22.39,bike,bills -NL11XOLA6707795988,NL17LKFR7594179781,"Vivamus ultrices tortor vel semper lacinia.",20160123,11.45,gifts,clothes -NL11XOLA6707795988,NL76UJQI9524250446,"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",20160123,49.23,bike,studies -NL11XOLA6707795988,NL45YTPP6157249080,"Curabitur vitae nisi consectetur, feugiat ipsum vitae, hendrerit sem.",20160123,22.6,cash,"other stuff" -NL11XOLA6707795988,NL46TFVH5548690248,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,44.34,bike,holiday -NL11XOLA6707795988,NL79XZWN0846248670,"Donec tincidunt nibh nec diam sodales, feugiat pulvinar ante consequat.",20160123,12.96,car,groceries -NL11XOLA6707795988,NL52MKIO8325583045,"Duis fringilla libero eget quam pharetra, non gravida ex fermentum.",20160123,44.47,taxes,bills -NL11XOLA6707795988,NL47YVJU4419567422,"Curabitur vitae nisi consectetur, feugiat ipsum vitae, hendrerit sem.",20160123,17.51,car,bills -NL11XOLA6707795988,NL04TNIP4218080631,"Suspendisse tempus eros euismod leo consequat, non malesuada arcu pretium.",20160123,17.36,cash,groceries -NL11XOLA6707795988,NL68SOAC3516744723,"In scelerisque velit eget ante pharetra pretium.",20160123,34.22,taxes,groceries -NL11XOLA6707795988,NL53YVTS7223912863,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,27.9,food,"other stuff" -NL11XOLA6707795988,NL40QRBS9553175317,"Vivamus ultrices tortor vel semper lacinia.",20160123,-10.86,groceries,holiday -NL11XOLA6707795988,NL79XZWN0846248670,"Duis fringilla libero eget quam pharetra, non gravida ex fermentum.",20160123,-19.57,bike,household -NL11XOLA6707795988,NL54TZNZ2922111989,"Pellentesque sit amet enim ac tortor euismod ullamcorper vel et massa.",20160123,-12.05,cash,holiday -NL11XOLA6707795988,NL04BAGX3284775110,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,-15.98,groceries,bills -NL11XOLA6707795988,NL49LULH7261231215,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,-35.67,food,clothes -NL11XOLA6707795988,NL11YHMI8046080217,"Nunc sed leo scelerisque quam consectetur elementum quis consequat dui.",20160123,-48.94,dinner,clothes -NL11XOLA6707795988,NL89BXNF2470379032,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,-33.82,taxes,holiday -NL11XOLA6707795988,NL74SHGG7300113478,"In scelerisque velit eget ante pharetra pretium.",20160123,-17.36,food,"other stuff" -NL11XOLA6707795988,NL48ZPLO1718215436,"Duis fringilla libero eget quam pharetra, non gravida ex fermentum.",20160123,-19.31,food,holiday -NL11XOLA6707795988,NL13BJMO5341591615,"Pellentesque sit amet enim ac tortor euismod ullamcorper vel et massa.",20160123,-28.47,groceries,"other stuff" -NL11XOLA6707795988,NL59PKVU0116767154,"Proin eleifend magna et ante cursus laoreet.",20160123,-39.24,taxes,"other stuff" -NL11XOLA6707795988,NL72BQRL1220175315,"Nulla in neque sed velit ultricies placerat.",20160123,-17.53,groceries,bills -NL11XOLA6707795988,NL53QHDG0329036955,"Nulla a dui euismod nulla convallis dictum.",20160123,-39.45,"books and such",holiday -NL11XOLA6707795988,NL29RHEE6437366575,"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",20160123,-23.47,food,studies -NL11XOLA6707795988,NL48BLDJ9721843563,"Curabitur vitae nisi consectetur, feugiat ipsum vitae, hendrerit sem.",20160123,-16.56,food,"other stuff" -NL11XOLA6707795988,NL48BHXI9733658006,"Nulla in neque sed velit ultricies placerat.",20160123,-21.89,gifts,household -NL11XOLA6707795988,NL33VPSU8067103542,"Duis fringilla libero eget quam pharetra, non gravida ex fermentum.",20160123,-11.71,groceries,clothes -NL11XOLA6707795988,NL62UDLY8957139303,"Nunc sed leo scelerisque quam consectetur elementum quis consequat dui.",20160123,-38.08,gifts,groceries -NL11XOLA6707795988,NL28EDMD2653501341,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,-39.57,cash,holiday -NL11XOLA6707795988,NL92QMZD6854625548,"Duis fringilla libero eget quam pharetra, non gravida ex fermentum.",20160123,-48.8,car,groceries -NL11XOLA6707795988,NL37VSLJ0853659915,"Nulla a dui euismod nulla convallis dictum.",20160123,-34.55,bike,household -NL11XOLA6707795988,NL95NQHS4363870109,"Suspendisse tempus eros euismod leo consequat, non malesuada arcu pretium.",20160123,-34.95,dinner,studies -NL11XOLA6707795988,NL81LEJP9477634344,"Vivamus ultrices tortor vel semper lacinia.",20160123,-13.18,dinner,"other stuff" -NL11XOLA6707795988,NL14JYVJ1041891180,"Curabitur vitae nisi consectetur, feugiat ipsum vitae, hendrerit sem.",20160123,-12.79,groceries,bills -NL11XOLA6707795988,NL57SPBS0788124528,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,-35.53,bike,groceries -NL11XOLA6707795988,NL96DZCO4665940223,"Proin eleifend magna et ante cursus laoreet.",20160123,34.41,groceries, -NL11XOLA6707795988,NL96DZCO4665940223,"Curabitur vitae nisi consectetur, feugiat ipsum vitae, hendrerit sem.",20160123,35.8,groceries, -NL11XOLA6707795988,NL96DZCO4665940223,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,22.46,car, -NL11XOLA6707795988,NL96DZCO4665940223,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,43.74,bike, -NL11XOLA6707795988,NL96DZCO4665940223,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,28.68,dinner, -NL11XOLA6707795988,NL96DZCO4665940223,"Duis fringilla libero eget quam pharetra, non gravida ex fermentum.",20160123,32.36,car, -NL11XOLA6707795988,NL96DZCO4665940223,"Nam in purus porta, accumsan felis vitae, bibendum leo.",20160123,37.76,groceries, -NL11XOLA6707795988,NL96DZCO4665940223,"Nulla in neque sed velit ultricies placerat.",20160123,19.98,"books and such", -NL11XOLA6707795988,NL96DZCO4665940223,"Aenean dictum sem pellentesque, semper est eget, ultricies magna.",20160123,26.57,gifts, -NL11XOLA6707795988,NL96DZCO4665940223,"Morbi quis mauris nec tortor egestas blandit.",20160123,12.09,"books and such", NL11XOLA6707795988,NL96DZCO4665940223,"Vivamus ultrices tortor vel semper lacinia.",20160123,34.96,dinner, NL11XOLA6707795988,NL96DZCO4665940223,"Nullam malesuada orci in vulputate imperdiet.",20160123,16.62,food, NL11XOLA6707795988,NL96DZCO4665940223,"Nulla a dui euismod nulla convallis dictum.",20160123,31.14,car, From 0bad2275480bf19f11b7093ea8711de9a6bb81ac Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 09:30:06 +0100 Subject: [PATCH 042/448] No more PHP 5.6 tests. --- .travis.yml | 1 - app/Repositories/Budget/BudgetRepository.php | 2 +- .../Budget/BudgetRepositoryInterface.php | 2 +- app/Support/ExpandedForm.php | 16 ++++++++-------- app/Support/Navigation.php | 19 ++++++++++--------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index abfb2812b8..9a8d6aca69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ sudo: false php: - - 5.6 - 7 install: diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index c789390f05..19ca4c5ec5 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -443,7 +443,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn * * @return LengthAwarePaginator */ - public function getJournals(Budget $budget, LimitRepetition $repetition, int $take) + public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50) { $offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0; $setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->offset($offset) diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php index 67ba9bf499..ac530f81c3 100644 --- a/app/Repositories/Budget/BudgetRepositoryInterface.php +++ b/app/Repositories/Budget/BudgetRepositoryInterface.php @@ -168,7 +168,7 @@ interface BudgetRepositoryInterface * * @return LengthAwarePaginator */ - public function getJournals(Budget $budget, LimitRepetition $repetition, int $take); + public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50); /** * @param Carbon $start diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index 62eec09fb4..8c82ca64a6 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -291,7 +291,7 @@ class ExpandedForm * * @return string */ - public function staticText($name, $value, array $options = []) + public function staticText(string $name, $value, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -310,7 +310,7 @@ class ExpandedForm * * @return string */ - public function tags($name, $value = null, array $options = []) + public function tags(string $name, $value = null, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -329,7 +329,7 @@ class ExpandedForm * * @return string */ - public function text($name, $value = null, array $options = []) + public function text(string $name, $value = null, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -348,7 +348,7 @@ class ExpandedForm * * @return string */ - public function textarea($name, $value = null, array $options = []) + public function textarea(string $name, $value = null, array $options = []) { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -368,7 +368,7 @@ class ExpandedForm * * @return array */ - protected function expandOptionArray($name, $label, array $options) + protected function expandOptionArray(string $name, $label, array $options) { $options['class'] = 'form-control'; $options['id'] = 'ffInput_' . $name; @@ -384,7 +384,7 @@ class ExpandedForm * * @return mixed */ - protected function fillFieldValue($name, $value) + protected function fillFieldValue(string $name, $value) { if (Session::has('preFilled')) { $preFilled = session('preFilled'); @@ -409,7 +409,7 @@ class ExpandedForm * * @return string */ - protected function getHolderClasses($name) + protected function getHolderClasses(string $name) { /* * Get errors from session: @@ -431,7 +431,7 @@ class ExpandedForm * * @return mixed */ - protected function label($name, $options) + protected function label(string $name, array $options) { if (isset($options['label'])) { return $options['label']; diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index fe83828573..721a84507c 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -22,7 +22,7 @@ class Navigation * @return \Carbon\Carbon * @throws FireflyException */ - public function addPeriod(Carbon $theDate, $repeatFreq, $skip) + public function addPeriod(Carbon $theDate, string $repeatFreq, int $skip) { $date = clone $theDate; $add = ($skip + 1); @@ -61,7 +61,7 @@ class Navigation * @return \Carbon\Carbon * @throws FireflyException */ - public function endOfPeriod(Carbon $theCurrentEnd, $repeatFreq) + public function endOfPeriod(Carbon $theCurrentEnd, string $repeatFreq) { $currentEnd = clone $theCurrentEnd; @@ -120,7 +120,7 @@ class Navigation * * @return \Carbon\Carbon */ - public function endOfX(Carbon $theCurrentEnd, $repeatFreq, Carbon $maxDate = null) + public function endOfX(Carbon $theCurrentEnd, string $repeatFreq, Carbon $maxDate = null) { $functionMap = [ '1D' => 'endOfDay', @@ -161,7 +161,7 @@ class Navigation * @return string * @throws FireflyException */ - public function periodShow(Carbon $date, $repeatFrequency) + public function periodShow(Carbon $date, string $repeatFrequency) { $formatMap = [ '1D' => '%e %B %Y', @@ -196,7 +196,7 @@ class Navigation * @return \Carbon\Carbon * @throws FireflyException */ - public function startOfPeriod(Carbon $theDate, $repeatFreq) + public function startOfPeriod(Carbon $theDate, string $repeatFreq) { $date = clone $theDate; @@ -247,7 +247,7 @@ class Navigation * @return \Carbon\Carbon * @throws FireflyException */ - public function subtractPeriod(Carbon $theDate, $repeatFreq, $subtract = 1) + public function subtractPeriod(Carbon $theDate, string $repeatFreq, int $subtract = 1) { $date = clone $theDate; // 1D 1W 1M 3M 6M 1Y @@ -286,13 +286,14 @@ class Navigation // a custom range requires the session start // and session end to calculate the difference in days. // this is then subtracted from $theDate (* $subtract). - if($repeatFreq === 'custom') { + if ($repeatFreq === 'custom') { /** @var Carbon $tStart */ $tStart = session('start', Carbon::now()->startOfMonth()); /** @var Carbon $tEnd */ $tEnd = session('end', Carbon::now()->endOfMonth()); $diffInDays = $tStart->diffInDays($tEnd); $date->subDays($diffInDays * $subtract); + return $date; } @@ -306,7 +307,7 @@ class Navigation * @return \Carbon\Carbon * @throws FireflyException */ - public function updateEndDate($range, Carbon $start) + public function updateEndDate(string $range, Carbon $start) { $functionMap = [ '1D' => 'endOfDay', @@ -342,7 +343,7 @@ class Navigation * @return \Carbon\Carbon * @throws FireflyException */ - public function updateStartDate($range, Carbon $start) + public function updateStartDate(string $range, Carbon $start) { $functionMap = [ '1D' => 'startOfDay', From 8f7f263a48ebeeb77aa66834f4dd79ad7b10b95c Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 12:08:25 +0100 Subject: [PATCH 043/448] Declare strict type. --- app/Console/Commands/UpgradeFireflyInstructions.php | 1 + app/Console/Kernel.php | 2 ++ app/Events/Event.php | 2 +- app/Events/TransactionJournalStored.php | 1 + app/Events/TransactionJournalUpdated.php | 5 ++++- app/Exceptions/FireflyException.php | 2 +- app/Exceptions/Handler.php | 2 +- app/Exceptions/NotImplementedException.php | 1 + app/Exceptions/ValidationException.php | 1 + app/Export/Collector/AttachmentCollector.php | 1 + app/Export/Collector/BasicCollector.php | 1 + app/Export/Collector/CollectorInterface.php | 1 + app/Export/Collector/UploadCollector.php | 1 + app/Export/ConfigurationFile.php | 1 + app/Export/Entry.php | 1 + app/Export/Exporter/BasicExporter.php | 1 + app/Export/Exporter/CsvExporter.php | 1 + app/Export/Exporter/ExporterInterface.php | 1 + app/Export/JournalCollector.php | 1 + app/Export/Processor.php | 1 + .../Chart/Account/AccountChartGeneratorInterface.php | 1 + app/Generator/Chart/Account/ChartJsAccountChartGenerator.php | 2 +- app/Generator/Chart/Bill/BillChartGeneratorInterface.php | 1 + app/Generator/Chart/Bill/ChartJsBillChartGenerator.php | 1 + app/Generator/Chart/Budget/BudgetChartGeneratorInterface.php | 1 + app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php | 2 +- .../Chart/Category/CategoryChartGeneratorInterface.php | 1 + .../Chart/Category/ChartJsCategoryChartGenerator.php | 2 +- .../Chart/PiggyBank/ChartJsPiggyBankChartGenerator.php | 2 +- .../Chart/PiggyBank/PiggyBankChartGeneratorInterface.php | 1 + app/Generator/Chart/Report/ChartJsReportChartGenerator.php | 2 +- app/Generator/Chart/Report/ReportChartGeneratorInterface.php | 1 + app/Handlers/Events/ConnectJournalToPiggyBank.php | 5 ++++- app/Handlers/Events/FireRulesForStore.php | 1 + app/Handlers/Events/FireRulesForUpdate.php | 1 + app/Handlers/Events/ScanForBillsAfterStore.php | 1 + app/Handlers/Events/ScanForBillsAfterUpdate.php | 1 + app/Handlers/Events/UpdateJournalConnection.php | 4 +++- app/Helpers/Attachments/AttachmentHelper.php | 2 +- app/Helpers/Attachments/AttachmentHelperInterface.php | 2 +- app/Helpers/Collection/Account.php | 2 +- app/Helpers/Collection/Balance.php | 2 +- app/Helpers/Collection/BalanceEntry.php | 2 +- app/Helpers/Collection/BalanceHeader.php | 2 +- app/Helpers/Collection/BalanceLine.php | 2 +- app/Helpers/Collection/Bill.php | 2 +- app/Helpers/Collection/BillLine.php | 2 +- app/Helpers/Collection/Budget.php | 2 +- app/Helpers/Collection/BudgetLine.php | 2 +- app/Helpers/Collection/Category.php | 2 +- app/Helpers/Collection/Expense.php | 2 +- app/Helpers/Collection/Income.php | 2 +- app/Helpers/Csv/Converter/AccountId.php | 1 + app/Helpers/Csv/Converter/Amount.php | 2 +- app/Helpers/Csv/Converter/AmountComma.php | 2 +- app/Helpers/Csv/Converter/AssetAccountIban.php | 2 +- app/Helpers/Csv/Converter/AssetAccountName.php | 2 +- app/Helpers/Csv/Converter/BasicConverter.php | 2 +- app/Helpers/Csv/Converter/BillId.php | 2 +- app/Helpers/Csv/Converter/BillName.php | 2 +- app/Helpers/Csv/Converter/BudgetId.php | 1 + app/Helpers/Csv/Converter/BudgetName.php | 1 + app/Helpers/Csv/Converter/CategoryId.php | 1 + app/Helpers/Csv/Converter/CategoryName.php | 1 + app/Helpers/Csv/Converter/ConverterInterface.php | 2 +- app/Helpers/Csv/Converter/CurrencyCode.php | 2 +- app/Helpers/Csv/Converter/CurrencyId.php | 2 +- app/Helpers/Csv/Converter/CurrencyName.php | 2 +- app/Helpers/Csv/Converter/CurrencySymbol.php | 2 +- app/Helpers/Csv/Converter/Date.php | 2 +- app/Helpers/Csv/Converter/Description.php | 2 +- app/Helpers/Csv/Converter/Ignore.php | 2 +- app/Helpers/Csv/Converter/OpposingAccountIban.php | 2 +- app/Helpers/Csv/Converter/OpposingAccountId.php | 2 +- app/Helpers/Csv/Converter/OpposingAccountName.php | 2 +- app/Helpers/Csv/Converter/RabobankDebetCredit.php | 2 +- app/Helpers/Csv/Converter/TagsComma.php | 2 +- app/Helpers/Csv/Converter/TagsSpace.php | 2 +- app/Helpers/Csv/Data.php | 1 + app/Helpers/Csv/Importer.php | 2 +- app/Helpers/Csv/Mapper/AnyAccount.php | 2 +- app/Helpers/Csv/Mapper/AssetAccount.php | 2 +- app/Helpers/Csv/Mapper/Bill.php | 2 +- app/Helpers/Csv/Mapper/Budget.php | 2 +- app/Helpers/Csv/Mapper/Category.php | 2 +- app/Helpers/Csv/Mapper/MapperInterface.php | 2 +- app/Helpers/Csv/Mapper/Tag.php | 2 +- app/Helpers/Csv/Mapper/TransactionCurrency.php | 2 +- app/Helpers/Csv/PostProcessing/Amount.php | 2 +- app/Helpers/Csv/PostProcessing/AssetAccount.php | 2 +- app/Helpers/Csv/PostProcessing/Bill.php | 2 +- app/Helpers/Csv/PostProcessing/Currency.php | 2 +- app/Helpers/Csv/PostProcessing/Description.php | 2 +- app/Helpers/Csv/PostProcessing/OpposingAccount.php | 2 +- app/Helpers/Csv/PostProcessing/PostProcessorInterface.php | 2 +- app/Helpers/Csv/Specifix/AbnAmroDescription.php | 2 +- app/Helpers/Csv/Specifix/Dummy.php | 2 +- app/Helpers/Csv/Specifix/RabobankDescription.php | 2 +- app/Helpers/Csv/Specifix/Specifix.php | 1 + app/Helpers/Csv/Specifix/SpecifixInterface.php | 1 + app/Helpers/Csv/Wizard.php | 1 + app/Helpers/Csv/WizardInterface.php | 1 + app/Helpers/FiscalHelper.php | 1 + app/Helpers/FiscalHelperInterface.php | 1 + app/Helpers/Help/Help.php | 2 +- app/Helpers/Help/HelpInterface.php | 2 +- app/Helpers/Report/AccountReportHelper.php | 1 + app/Helpers/Report/AccountReportHelperInterface.php | 1 + app/Helpers/Report/BalanceReportHelper.php | 1 + app/Helpers/Report/BalanceReportHelperInterface.php | 1 + app/Helpers/Report/BudgetReportHelper.php | 1 + app/Helpers/Report/BudgetReportHelperInterface.php | 1 + app/Helpers/Report/ReportHelper.php | 1 + app/Helpers/Report/ReportHelperInterface.php | 1 + app/Helpers/Report/ReportQuery.php | 1 + app/Helpers/Report/ReportQueryInterface.php | 1 + app/Http/Controllers/AttachmentController.php | 1 + app/Http/Controllers/Auth/AuthController.php | 1 + app/Http/Controllers/Auth/PasswordController.php | 1 + app/Http/Controllers/Chart/AccountController.php | 1 + app/Http/Controllers/Chart/BillController.php | 1 + app/Http/Controllers/Chart/BudgetController.php | 1 + app/Http/Controllers/Chart/CategoryController.php | 1 + app/Http/Controllers/Chart/PiggyBankController.php | 1 + app/Http/Controllers/Chart/ReportController.php | 1 + app/Http/Controllers/Controller.php | 1 + app/Http/Controllers/CsvController.php | 1 + app/Http/Controllers/ExportController.php | 1 + app/Http/Controllers/RuleController.php | 1 + app/Http/Controllers/RuleGroupController.php | 1 + app/Http/Controllers/TagController.php | 1 + app/Http/Kernel.php | 1 + app/Http/Middleware/Authenticate.php | 1 + app/Http/Middleware/Binder.php | 1 + app/Http/Middleware/EncryptCookies.php | 1 + app/Http/Middleware/Range.php | 1 + app/Http/Middleware/RedirectIfAuthenticated.php | 1 + app/Http/Middleware/VerifyCsrfToken.php | 1 + app/Http/Requests/AccountFormRequest.php | 1 + app/Http/Requests/AttachmentFormRequest.php | 1 + app/Http/Requests/BillFormRequest.php | 1 + app/Http/Requests/BudgetFormRequest.php | 1 + app/Http/Requests/CategoryFormRequest.php | 1 + app/Http/Requests/CurrencyFormRequest.php | 1 + app/Http/Requests/DeleteAccountFormRequest.php | 1 + app/Http/Requests/ExportFormRequest.php | 1 + app/Http/Requests/JournalFormRequest.php | 1 + app/Http/Requests/NewUserFormRequest.php | 1 + app/Http/Requests/PiggyBankFormRequest.php | 1 + app/Http/Requests/ProfileFormRequest.php | 1 + app/Http/Requests/Request.php | 1 + app/Http/Requests/RuleFormRequest.php | 1 + app/Http/Requests/RuleGroupFormRequest.php | 1 + app/Http/Requests/TagFormRequest.php | 1 + app/Http/breadcrumbs.php | 1 + app/Http/routes.php | 1 + app/Jobs/Job.php | 1 + app/Models/Attachment.php | 1 + app/Models/ExportJob.php | 1 + app/Models/Permission.php | 1 + app/Models/Role.php | 1 + app/Models/Rule.php | 1 + app/Models/RuleAction.php | 1 + app/Models/RuleGroup.php | 1 + app/Models/RuleTrigger.php | 1 + app/Models/Tag.php | 1 + app/Providers/AppServiceProvider.php | 1 + app/Providers/AuthServiceProvider.php | 1 + app/Providers/EventServiceProvider.php | 1 + app/Providers/FireflyServiceProvider.php | 1 + app/Providers/RouteServiceProvider.php | 1 + app/Repositories/Account/AccountRepository.php | 1 + app/Repositories/Account/AccountRepositoryInterface.php | 1 + app/Repositories/Attachment/AttachmentRepository.php | 1 + .../Attachment/AttachmentRepositoryInterface.php | 1 + app/Repositories/Bill/BillRepository.php | 1 + app/Repositories/Bill/BillRepositoryInterface.php | 1 + app/Repositories/Budget/BudgetRepository.php | 1 + app/Repositories/Budget/BudgetRepositoryInterface.php | 1 + app/Repositories/Category/CategoryRepository.php | 1 + app/Repositories/Category/CategoryRepositoryInterface.php | 1 + app/Repositories/Category/SingleCategoryRepository.php | 1 + .../Category/SingleCategoryRepositoryInterface.php | 1 + app/Repositories/Currency/CurrencyRepository.php | 1 + app/Repositories/Currency/CurrencyRepositoryInterface.php | 1 + app/Repositories/ExportJob/ExportJobRepository.php | 1 + app/Repositories/ExportJob/ExportJobRepositoryInterface.php | 1 + app/Repositories/Journal/JournalRepository.php | 1 + app/Repositories/Journal/JournalRepositoryInterface.php | 1 + app/Repositories/PiggyBank/PiggyBankRepository.php | 1 + app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php | 1 + app/Repositories/Rule/RuleRepository.php | 1 + app/Repositories/Rule/RuleRepositoryInterface.php | 1 + app/Repositories/RuleGroup/RuleGroupRepository.php | 1 + app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php | 1 + app/Repositories/Shared/ComponentRepository.php | 1 + app/Repositories/Tag/TagRepository.php | 1 + app/Repositories/Tag/TagRepositoryInterface.php | 1 + app/Rules/Actions/ActionInterface.php | 1 + app/Rules/Actions/AddTag.php | 1 + app/Rules/Actions/AppendDescription.php | 1 + app/Rules/Actions/ClearBudget.php | 1 + app/Rules/Actions/ClearCategory.php | 1 + app/Rules/Actions/PrependDescription.php | 1 + app/Rules/Actions/RemoveAllTags.php | 1 + app/Rules/Actions/RemoveTag.php | 1 + app/Rules/Actions/SetBudget.php | 1 + app/Rules/Actions/SetCategory.php | 1 + app/Rules/Actions/SetDescription.php | 1 + app/Rules/Processor.php | 1 + app/Rules/Triggers/AmountExactly.php | 1 + app/Rules/Triggers/AmountLess.php | 1 + app/Rules/Triggers/AmountMore.php | 1 + app/Rules/Triggers/DescriptionContains.php | 1 + app/Rules/Triggers/DescriptionEnds.php | 1 + app/Rules/Triggers/DescriptionIs.php | 1 + app/Rules/Triggers/DescriptionStarts.php | 1 + app/Rules/Triggers/FromAccountContains.php | 1 + app/Rules/Triggers/FromAccountEnds.php | 1 + app/Rules/Triggers/FromAccountIs.php | 1 + app/Rules/Triggers/FromAccountStarts.php | 1 + app/Rules/Triggers/ToAccountContains.php | 1 + app/Rules/Triggers/ToAccountEnds.php | 1 + app/Rules/Triggers/ToAccountIs.php | 1 + app/Rules/Triggers/ToAccountStarts.php | 1 + app/Rules/Triggers/TransactionType.php | 1 + app/Rules/Triggers/TriggerInterface.php | 1 + app/Rules/Triggers/UserAction.php | 1 + app/Sql/Query.php | 1 + app/Support/Amount.php | 1 + app/Support/Binder/AccountList.php | 1 + app/Support/Binder/BinderInterface.php | 1 + app/Support/Binder/BudgetList.php | 1 + app/Support/Binder/CategoryList.php | 1 + app/Support/Binder/Date.php | 1 + app/Support/CacheProperties.php | 1 + app/Support/Domain.php | 1 + app/Support/Events/BillScanner.php | 1 + app/Support/ExpandedForm.php | 1 + app/Support/Facades/Amount.php | 1 + app/Support/Facades/ExpandedForm.php | 1 + app/Support/Facades/Navigation.php | 1 + app/Support/Facades/Preferences.php | 1 + app/Support/Facades/Steam.php | 1 + app/Support/Migration/TestData.php | 1 + app/Support/Navigation.php | 1 + app/Support/Preferences.php | 1 + app/Support/Search/Search.php | 1 + app/Support/Search/SearchInterface.php | 1 + app/Support/Steam.php | 1 + app/Support/Twig/Budget.php | 1 + app/Support/Twig/General.php | 1 + app/Support/Twig/Journal.php | 1 + app/Support/Twig/PiggyBank.php | 1 + app/Support/Twig/Rule.php | 1 + app/Support/Twig/Translation.php | 1 + app/User.php | 1 + app/Validation/FireflyValidator.php | 1 + 258 files changed, 267 insertions(+), 67 deletions(-) diff --git a/app/Console/Commands/UpgradeFireflyInstructions.php b/app/Console/Commands/UpgradeFireflyInstructions.php index 36c4d7f472..b15d3c4936 100644 --- a/app/Console/Commands/UpgradeFireflyInstructions.php +++ b/app/Console/Commands/UpgradeFireflyInstructions.php @@ -1,4 +1,5 @@ Date: Fri, 5 Feb 2016 12:28:05 +0100 Subject: [PATCH 044/448] Fixed all problems related to strict types. --- app/Helpers/Csv/Data.php | 4 +- app/Helpers/Report/BalanceReportHelper.php | 2 +- .../Controllers/Chart/BudgetController.php | 2 +- .../Controllers/Chart/ReportController.php | 78 +++++++++---------- app/Http/Controllers/TagController.php | 7 +- app/Http/Requests/JournalFormRequest.php | 3 +- .../Account/AccountRepository.php | 4 +- app/Repositories/Bill/BillRepository.php | 42 +++++----- .../Shared/ComponentRepository.php | 2 +- app/Support/Steam.php | 12 +-- app/Support/Twig/General.php | 8 +- 11 files changed, 87 insertions(+), 77 deletions(-) diff --git a/app/Helpers/Csv/Data.php b/app/Helpers/Csv/Data.php index 92d4089db1..19a5e0fbb9 100644 --- a/app/Helpers/Csv/Data.php +++ b/app/Helpers/Csv/Data.php @@ -58,7 +58,7 @@ class Data */ public function getCsvFileContent() { - return $this->csvFileContent; + return $this->csvFileContent ?? ''; } /** @@ -171,7 +171,7 @@ class Data */ public function getReader() { - if (strlen($this->csvFileContent) === 0) { + if (!is_null($this->csvFileContent) && strlen($this->csvFileContent) === 0) { $this->loadCsvFile(); } diff --git a/app/Helpers/Report/BalanceReportHelper.php b/app/Helpers/Report/BalanceReportHelper.php index 67654d89fd..6c317bbfdb 100644 --- a/app/Helpers/Report/BalanceReportHelper.php +++ b/app/Helpers/Report/BalanceReportHelper.php @@ -108,7 +108,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface return $model->account_id == $account->id && $model->budget_id == $budget->id; } ); - $spent = 0; + $spent = '0'; if (!is_null($entry->first())) { $spent = $entry->first()->spent; } diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index 41fe3213bd..a35e173a89 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -132,7 +132,7 @@ class BudgetController extends Controller /* * Sum of expenses on this day: */ - $amount = round(bcadd($amount, $sum), 2); + $amount = round(bcadd(strval($amount), $sum), 2); $entries->push([clone $start, $amount]); $start->addDay(); } diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php index 4a2f44868e..a2951cdf5a 100644 --- a/app/Http/Controllers/Chart/ReportController.php +++ b/app/Http/Controllers/Chart/ReportController.php @@ -126,24 +126,19 @@ class ReportController extends Controller * * @return array */ - protected function singleYearInOutSummarized(array $earned, array $spent, Carbon $start, Carbon $end) + protected function multiYearInOut(array $earned, array $spent, Carbon $start, Carbon $end) { - bcscale(2); - $income = '0'; - $expense = '0'; - $count = 0; + $entries = new Collection; while ($start < $end) { - $date = $start->format('Y-m'); - $currentIncome = $earned[$date] ?? 0; - $currentExpense = isset($spent[$date]) ? ($spent[$date] * -1) : 0; - $income = bcadd($income, $currentIncome); - $expense = bcadd($expense, $currentExpense); - $count++; - $start->addMonth(); + $incomeSum = $this->pluckFromArray($start->year, $earned); + $expenseSum = $this->pluckFromArray($start->year, $spent) * -1; + + $entries->push([clone $start, $incomeSum, $expenseSum]); + $start->addYear(); } - $data = $this->generator->yearInOutSummarized($income, $expense, $count); + $data = $this->generator->multiYearInOut($entries); return $data; } @@ -179,28 +174,23 @@ class ReportController extends Controller } /** - * @param array $earned - * @param array $spent - * @param Carbon $start - * @param Carbon $end + * @param int $year + * @param array $set * - * @return array + * @return string */ - protected function multiYearInOut(array $earned, array $spent, Carbon $start, Carbon $end) + protected function pluckFromArray($year, array $set) { - $entries = new Collection; - while ($start < $end) { - - $incomeSum = $this->pluckFromArray($start->year, $earned); - $expenseSum = $this->pluckFromArray($start->year, $spent) * -1; - - $entries->push([clone $start, $incomeSum, $expenseSum]); - $start->addYear(); + bcscale(2); + $sum = '0'; + foreach ($set as $date => $amount) { + if (substr($date, 0, 4) == $year) { + $sum = bcadd($sum, $amount); + } } - $data = $this->generator->multiYearInOut($entries); + return $sum; - return $data; } /** @@ -232,22 +222,32 @@ class ReportController extends Controller } /** - * @param int $year - * @param array $set + * @param array $earned + * @param array $spent + * @param Carbon $start + * @param Carbon $end * - * @return string + * @return array */ - protected function pluckFromArray($year, array $set) + protected function singleYearInOutSummarized(array $earned, array $spent, Carbon $start, Carbon $end) { bcscale(2); - $sum = '0'; - foreach ($set as $date => $amount) { - if (substr($date, 0, 4) == $year) { - $sum = bcadd($sum, $amount); - } + $income = '0'; + $expense = '0'; + $count = 0; + while ($start < $end) { + $date = $start->format('Y-m'); + $currentIncome = $earned[$date] ?? '0'; + $currentExpense = isset($spent[$date]) ? bcmul($spent[$date], '-1') : '0'; + $income = bcadd($income, $currentIncome); + $expense = bcadd($expense, $currentExpense); + + $count++; + $start->addMonth(); } - return $sum; + $data = $this->generator->yearInOutSummarized($income, $expense, $count); + return $data; } } diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index bc5b36e522..a74877aa3a 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -242,10 +242,11 @@ class TagController extends Controller $longitude = null; $zoomLevel = null; } + $date = $request->get('date') ?? ''; $data = [ 'tag' => $request->get('tag'), - 'date' => strlen($request->get('date')) > 0 ? new Carbon($request->get('date')) : null, + 'date' => strlen($date) > 0 ? new Carbon($date) : null, 'description' => strlen($request->get('description')) > 0 ? $request->get('description') : '', 'latitude' => $latitude, 'longitude' => $longitude, @@ -287,10 +288,12 @@ class TagController extends Controller $longitude = null; $zoomLevel = null; } + $date = $request->get('date') ?? ''; + $data = [ 'tag' => $request->get('tag'), - 'date' => strlen($request->get('date')) > 0 ? new Carbon($request->get('date')) : null, + 'date' => strlen($date) > 0 ? new Carbon($date) : null, 'description' => strlen($request->get('description')) > 0 ? $request->get('description') : '', 'latitude' => $latitude, 'longitude' => $longitude, diff --git a/app/Http/Requests/JournalFormRequest.php b/app/Http/Requests/JournalFormRequest.php index 758dd6f60a..2972f1572a 100644 --- a/app/Http/Requests/JournalFormRequest.php +++ b/app/Http/Requests/JournalFormRequest.php @@ -31,6 +31,7 @@ class JournalFormRequest extends Request */ public function getJournalData() { + $tags = $this->get('tags') ?? ''; return [ 'what' => $this->get('what'), 'description' => $this->get('description'), @@ -45,7 +46,7 @@ class JournalFormRequest extends Request 'date' => new Carbon($this->get('date')), 'budget_id' => intval($this->get('budget_id')), 'category' => $this->get('category'), - 'tags' => explode(',', $this->get('tags')), + 'tags' => explode(',', $tags), ]; } diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 1affad1770..f44b6ed7f6 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -253,10 +253,10 @@ class AccountRepository implements AccountRepositoryInterface function (Account $account) use ($start, $end) { $account->startBalance = Steam::balance($account, $start, true); $account->endBalance = Steam::balance($account, $end, true); - $account->piggyBalance = 0; + $account->piggyBalance = '0'; /** @var PiggyBank $piggyBank */ foreach ($account->piggyBanks as $piggyBank) { - $account->piggyBalance += $piggyBank->currentRelevantRep()->currentamount; + $account->piggyBalance = bcadd($piggyBank->currentRelevantRep()->currentamount, $account->piggyBalance); } // sum of piggy bank amounts on this account: // diff between endBalance and piggyBalance. diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index 55e210e2af..10dd09ad76 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -162,16 +162,17 @@ class BillRepository implements BillRepositoryInterface $ranges = $this->getRanges($bill, $start, $end); foreach ($ranges as $range) { - $paid = $bill->transactionjournals() - ->before($range['end']) - ->after($range['start']) - ->leftJoin( - 'transactions', function (JoinClause $join) { - $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0); - } - ) - ->first([DB::Raw('SUM(`transactions`.`amount`) as `sum_amount`')]); - $amount = bcadd($amount, $paid->sum_amount); + $paid = $bill->transactionjournals() + ->before($range['end']) + ->after($range['start']) + ->leftJoin( + 'transactions', function (JoinClause $join) { + $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0); + } + ) + ->first([DB::Raw('SUM(`transactions`.`amount`) as `sum_amount`')]); + $sumAmount = $paid->sum_amount ?? '0'; + $amount = bcadd($amount, $sumAmount); } } @@ -196,16 +197,17 @@ class BillRepository implements BillRepositoryInterface $ranges = $this->getRanges($bill, $start, $end); $paidBill = '0'; foreach ($ranges as $range) { - $paid = $bill->transactionjournals() - ->before($range['end']) - ->after($range['start']) - ->leftJoin( - 'transactions', function (JoinClause $join) { - $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '>', 0); - } - ) - ->first([DB::Raw('SUM(`transactions`.`amount`) as `sum_amount`')]); - $paidBill = bcadd($paid->sum_amount, $paidBill); + $paid = $bill->transactionjournals() + ->before($range['end']) + ->after($range['start']) + ->leftJoin( + 'transactions', function (JoinClause $join) { + $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '>', 0); + } + ) + ->first([DB::Raw('SUM(`transactions`.`amount`) as `sum_amount`')]); + $sumAmount = $paid->sum_amount ?? '0'; + $paidBill = bcadd($sumAmount, $paidBill); } if ($paidBill == 0) { $amount = bcadd($amount, $bill->expectedAmount); diff --git a/app/Repositories/Shared/ComponentRepository.php b/app/Repositories/Shared/ComponentRepository.php index ba285cc1a8..fff108104c 100644 --- a/app/Repositories/Shared/ComponentRepository.php +++ b/app/Repositories/Shared/ComponentRepository.php @@ -37,7 +37,7 @@ class ComponentRepository ->whereIn('accounts.id', $ids) ->after($start) ->first([DB::raw('SUM(`transactions`.`amount`) as `journalAmount`')]); - $amount = $entry->journalAmount; + $amount = $entry->journalAmount ?? '0'; return $amount; } diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 7431f715a7..e896c65c8c 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -23,7 +23,7 @@ class Steam * @param \Carbon\Carbon $date * @param bool $ignoreVirtualBalance * - * @return float + * @return string */ public function balance(Account $account, Carbon $date, $ignoreVirtualBalance = false) { @@ -45,11 +45,11 @@ class Steam )->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount'); if (!$ignoreVirtualBalance) { - $balance = bcadd($balance, $account->virtual_balance); + $balance = bcadd(strval($balance), $account->virtual_balance); } - $cache->store(round($balance, 2)); + $cache->store($balance); - return round($balance, 2); + return $balance; } /** @@ -177,14 +177,14 @@ class Steam if (!(strpos($string, 'k') === false)) { // has a K in it, remove the K and multiply by 1024. - $bytes = bcmul(rtrim($string, 'k'), 1024); + $bytes = bcmul(rtrim($string, 'k'), '1024'); return intval($bytes); } if (!(strpos($string, 'm') === false)) { // has a M in it, remove the M and multiply by 1048576. - $bytes = bcmul(rtrim($string, 'm'), 1048576); + $bytes = bcmul(rtrim($string, 'm'),'1048576'); return intval($bytes); } diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index d9e01f9e64..f04c087281 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -16,6 +16,7 @@ use Twig_SimpleFunction; * @codeCoverageIgnore * * Class TwigSupport + * @todo these functions should be parameterized. * * @package FireflyIII\Support */ @@ -164,13 +165,14 @@ class General extends Twig_Extension } /** + * * @return Twig_SimpleFilter */ protected function formatAmount() { return new Twig_SimpleFilter( 'formatAmount', function ($string) { - $value = is_null($string) ? '0' : $string; + $value = is_null($string) ? '0' : strval($string); return app('amount')->format($value); }, ['is_safe' => ['html']] @@ -184,7 +186,9 @@ class General extends Twig_Extension { return new Twig_SimpleFilter( 'formatAmountPlain', function ($string) { - return app('amount')->format($string, false); + $value = is_null($string) ? '0' : strval($string); + + return app('amount')->format($value, false); }, ['is_safe' => ['html']] ); } From df918e852941d67ab5aae6f9e1389760900a00cf Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 13:09:18 +0100 Subject: [PATCH 045/448] Fixed all problems related to strict types. --- .../Chart/Bill/ChartJsBillChartGenerator.php | 5 ++-- .../Budget/ChartJsBudgetChartGenerator.php | 5 ++-- .../ChartJsCategoryChartGenerator.php | 11 +++++---- .../Events/ConnectJournalToPiggyBank.php | 3 ++- app/Helpers/Report/BalanceReportHelper.php | 8 +++---- app/Http/Controllers/AccountController.php | 2 +- .../Controllers/Chart/BudgetController.php | 14 +++++------ .../Controllers/Chart/CategoryController.php | 4 ++-- app/Http/Controllers/JsonController.php | 2 +- app/Http/Controllers/PiggyBankController.php | 1 + app/Http/Controllers/TagController.php | 5 ++-- app/Http/Requests/JournalFormRequest.php | 6 ++--- .../Account/AccountRepository.php | 2 +- .../Journal/JournalRepository.php | 5 ++-- app/Support/Migration/TestData.php | 6 ++--- app/Support/Twig/General.php | 24 +++++++++---------- resources/views/piggy-banks/show.twig | 2 +- resources/views/reports/partials/balance.twig | 5 +++- 18 files changed, 58 insertions(+), 52 deletions(-) diff --git a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php index fb9ef0beea..3dbea5f630 100644 --- a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php +++ b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php @@ -39,7 +39,7 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface 'label' => trans('firefly.unpaid'), ], [ - 'value' => round($paid * -1, 2), // paid is negative, must be positive. + 'value' => round(bcmul($paid, '-1'), 2), // paid is negative, must be positive. 'color' => 'rgba(0, 141, 76, 0.7)', 'highlight' => 'rgba(0, 141, 76, 0.9)', 'label' => trans('firefly.paid'), @@ -57,6 +57,7 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface */ public function single(Bill $bill, Collection $entries) { + bcscale(2); $format = (string)trans('config.month'); $data = [ 'count' => 3, @@ -74,7 +75,7 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface /* * journalAmount has been collected in BillRepository::getJournals */ - $actualAmount[] = round(($entry->journalAmount * -1), 2); + $actualAmount[] = round(bcmul($entry->journalAmount, '-1'), 2); } $data['datasets'][] = [ diff --git a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php index a04697511d..568d0c54f7 100644 --- a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php +++ b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php @@ -68,6 +68,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface */ public function frontpage(Collection $entries) { + bcscale(2); $data = [ 'count' => 0, 'labels' => [], @@ -84,8 +85,8 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface foreach ($filtered as $entry) { $data['labels'][] = $entry[0]; $left[] = round($entry[1], 2); - $spent[] = round($entry[2] * -1, 2); // spent is coming in negative, must be positive - $overspent[] = round($entry[3] * -1, 2); // same + $spent[] = round(bcmul($entry[2],'-1'), 2); // spent is coming in negative, must be positive + $overspent[] = round(bcmul($entry[3],'-1'), 2); // same } $data['datasets'][] = [ diff --git a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php index f8b8ec3231..b972718905 100644 --- a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php +++ b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php @@ -39,11 +39,11 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface foreach ($entries as $entry) { $data['labels'][] = $entry[1]; - $spent = round($entry[2], 2); - $earned = round($entry[3], 2); + $spent = $entry[2]; + $earned = $entry[3]; - $data['datasets'][0]['data'][] = $spent == 0 ? null : $spent * -1; - $data['datasets'][1]['data'][] = $earned == 0 ? null : $earned; + $data['datasets'][0]['data'][] = bccomp($spent, '0') === 0 ? null : bcmul($spent, '-1'); + $data['datasets'][1]['data'][] = bccomp($earned, '0') === 0 ? null : $earned; } return $data; @@ -89,6 +89,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface */ public function frontpage(Collection $entries) { + bcscale(2); $data = [ 'count' => 1, 'labels' => [], @@ -102,7 +103,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface foreach ($entries as $entry) { if ($entry->spent != 0) { $data['labels'][] = $entry->name; - $data['datasets'][0]['data'][] = round(($entry->spent * -1), 2); + $data['datasets'][0]['data'][] = round(bcmul($entry->spent, '-1'), 2); } } diff --git a/app/Handlers/Events/ConnectJournalToPiggyBank.php b/app/Handlers/Events/ConnectJournalToPiggyBank.php index 59429bbbec..b62a9c2b10 100644 --- a/app/Handlers/Events/ConnectJournalToPiggyBank.php +++ b/app/Handlers/Events/ConnectJournalToPiggyBank.php @@ -40,6 +40,7 @@ class ConnectJournalToPiggyBank /** @var TransactionJournal $journal */ $journal = $event->journal; $piggyBankId = $event->piggyBankId; + bcscale(2); /** @var PiggyBank $piggyBank */ $piggyBank = Auth::user()->piggybanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']); @@ -57,7 +58,7 @@ class ConnectJournalToPiggyBank $amount = $journal->amount_positive; // if piggy account matches source account, the amount is positive if ($piggyBank->account_id == $journal->source_account->id) { - $amount = $amount * -1; + $amount = bcmul($amount,'-1'); } diff --git a/app/Helpers/Report/BalanceReportHelper.php b/app/Helpers/Report/BalanceReportHelper.php index 6c317bbfdb..bf3f961df6 100644 --- a/app/Helpers/Report/BalanceReportHelper.php +++ b/app/Helpers/Report/BalanceReportHelper.php @@ -142,7 +142,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface return $model->account_id == $account->id && is_null($model->budget_id); } ); - $spent = 0; + $spent = '0'; if (!is_null($entry->first())) { $spent = $entry->first()->spent; } @@ -151,7 +151,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface return $tag->account_id == $account->id; } ); - $left = 0; + $left = '0'; if (!is_null($leftEntry->first())) { $left = $leftEntry->first()->sum; } @@ -185,7 +185,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface return $model->account_id == $account->id && is_null($model->budget_id); } ); - $spent = 0; + $spent = '0'; if (!is_null($entry->first())) { $spent = $entry->first()->spent; } @@ -221,7 +221,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface return $tag->account_id == $account->id; } ); - $left = 0; + $left = '0'; if (!is_null($leftEntry->first())) { $left = $leftEntry->first()->sum; } diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 7bda3cb6c3..6dfe30c0d8 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -285,7 +285,7 @@ class AccountController extends Controller return $array[$entryId]; } - return null; + return ''; } } diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index a35e173a89..84c2095cb4 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -185,26 +185,26 @@ class BudgetController extends Controller $currentStart = clone $start; $currentEnd = clone $end; $expenses = $repository->balanceInPeriod($budget, $currentStart, $currentEnd, $accounts); - $amount = 0; - $left = 0; + $amount = '0'; + $left = '0'; $spent = $expenses; - $overspent = 0; + $overspent = '0'; } else { $currentStart = clone $budget->startdate; $currentEnd = clone $budget->enddate; $expenses = $repository->balanceInPeriod($budget, $currentStart, $currentEnd, $accounts); $amount = $budget->amount; // smaller than 1 means spent MORE than budget allows. - $left = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? 0 : bcadd($budget->amount, $expenses); - $spent = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? ($amount * -1) : $expenses; - $overspent = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? bcadd($budget->amount, $expenses) : 0; + $left = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? '0' : bcadd($budget->amount, $expenses); + $spent = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? bcmul($amount, '-1') : $expenses; + $overspent = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? bcadd($budget->amount, $expenses) : '0'; } $allEntries->push([$name, $left, $spent, $overspent, $amount, $expenses]); } $noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end); - $allEntries->push([trans('firefly.noBudget'), 0, 0, $noBudgetExpenses, 0, 0]); + $allEntries->push([trans('firefly.noBudget'), '0', '0', $noBudgetExpenses, '0', '0']); $data = $this->generator->frontpage($allEntries); $cache->store($data); diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index 2a503e1a50..c7e4b02178 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -406,8 +406,8 @@ class CategoryController extends Controller while ($start <= $end) { $str = $start->format('Y-m-d'); - $spent = $spentArray[$str] ?? 0; - $earned = $earnedArray[$str] ?? 0; + $spent = $spentArray[$str] ?? '0'; + $earned = $earnedArray[$str] ?? '0'; $date = Navigation::periodShow($start, '1D'); $entries->push([clone $start, $date, $spent, $earned]); $start->addDay(); diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index fab1453a10..85b6948c8e 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -66,7 +66,7 @@ class JsonController extends Controller if ($creditCardDue >= 0) { $amount = bcadd($amount, $creditCardDue); } - $amount = $amount * -1; + $amount = bcmul($amount,'-1'); $data = ['box' => 'bills-paid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 56ec30ceac..ca03321887 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -166,6 +166,7 @@ class PiggyBankController extends Controller { /** @var Collection $piggyBanks */ $piggyBanks = $piggyRepository->getPiggyBanks(); + /** @var Carbon $end */ $end = session('end', Carbon::now()->endOfMonth()); bcscale(2); diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index a74877aa3a..67869985d0 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -247,7 +247,7 @@ class TagController extends Controller $data = [ 'tag' => $request->get('tag'), 'date' => strlen($date) > 0 ? new Carbon($date) : null, - 'description' => strlen($request->get('description')) > 0 ? $request->get('description') : '', + 'description' => $request->get('description') ?? '', 'latitude' => $latitude, 'longitude' => $longitude, 'zoomLevel' => $zoomLevel, @@ -290,11 +290,10 @@ class TagController extends Controller } $date = $request->get('date') ?? ''; - $data = [ 'tag' => $request->get('tag'), 'date' => strlen($date) > 0 ? new Carbon($date) : null, - 'description' => strlen($request->get('description')) > 0 ? $request->get('description') : '', + 'description' => $request->get('description') ?? '', 'latitude' => $latitude, 'longitude' => $longitude, 'zoomLevel' => $zoomLevel, diff --git a/app/Http/Requests/JournalFormRequest.php b/app/Http/Requests/JournalFormRequest.php index 2972f1572a..ee9fdf0788 100644 --- a/app/Http/Requests/JournalFormRequest.php +++ b/app/Http/Requests/JournalFormRequest.php @@ -38,14 +38,14 @@ class JournalFormRequest extends Request 'account_id' => intval($this->get('account_id')), 'account_from_id' => intval($this->get('account_from_id')), 'account_to_id' => intval($this->get('account_to_id')), - 'expense_account' => $this->get('expense_account'), - 'revenue_account' => $this->get('revenue_account'), + 'expense_account' => $this->get('expense_account') ?? '', + 'revenue_account' => $this->get('revenue_account') ?? '', 'amount' => round($this->get('amount'), 2), 'user' => Auth::user()->id, 'amount_currency_id_amount' => intval($this->get('amount_currency_id_amount')), 'date' => new Carbon($this->get('date')), 'budget_id' => intval($this->get('budget_id')), - 'category' => $this->get('category'), + 'category' => $this->get('category') ?? '', 'tags' => explode(',', $tags), ]; } diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index f44b6ed7f6..f3486d1a47 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -330,7 +330,7 @@ class AccountRepository implements AccountRepositoryInterface $balance = Steam::balance($account, $date, true); /** @var PiggyBank $p */ foreach ($account->piggybanks()->get() as $p) { - $balance -= $p->currentRelevantRep()->currentamount; + $balance = bcsub($p->currentRelevantRep()->currentamount, $balance); } return $balance; diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 8e94cd7d79..6184ff9d47 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -65,9 +65,10 @@ class JournalRepository implements JournalRepositoryInterface ->where('transaction_journals.order', '>=', $journal->order) ->where('transaction_journals.id', '!=', $journal->id) ->get(['transactions.*']); - $sum = 0; + bcscale(2); + $sum = '0'; foreach ($set as $entry) { - $sum += $entry->amount; + $sum = bcadd($entry->amount, $sum); } return $sum; diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php index 341c192c89..69b8d12f1b 100644 --- a/app/Support/Migration/TestData.php +++ b/app/Support/Migration/TestData.php @@ -194,7 +194,7 @@ class TestData * @param $name * @param $amount */ - public static function createBudgetLimit(User $user, Carbon $current, $name, $amount) + public static function createBudgetLimit(User $user, Carbon $current, string $name, string $amount) { $start = clone $current; $end = clone $current; @@ -474,7 +474,7 @@ class TestData * * @return Account|null */ - public static function findAccount(User $user, $name) + public static function findAccount(User $user, string $name) { /** @var Account $account */ foreach ($user->accounts()->get() as $account) { @@ -495,7 +495,7 @@ class TestData * * @return Budget|null */ - public static function findBudget(User $user, $name) + public static function findBudget(User $user, string $name) { /** @var Budget $budget */ foreach (Budget::get() as $budget) { diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index f04c087281..55a5dd1093 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -7,6 +7,7 @@ use Carbon\Carbon; use Config; use FireflyIII\Models\Account; use FireflyIII\Models\Transaction; +use FireflyIII\Models\TransactionJournal; use Route; use Twig_Extension; use Twig_SimpleFilter; @@ -158,7 +159,7 @@ class General extends Twig_Extension protected function env() { return new Twig_SimpleFunction( - 'env', function ($name, $default) { + 'env', function (string $name, string $default) { return env($name, $default); } ); @@ -171,10 +172,9 @@ class General extends Twig_Extension protected function formatAmount() { return new Twig_SimpleFilter( - 'formatAmount', function ($string) { - $value = is_null($string) ? '0' : strval($string); + 'formatAmount', function (string $string) { - return app('amount')->format($value); + return app('amount')->format($string); }, ['is_safe' => ['html']] ); } @@ -185,10 +185,9 @@ class General extends Twig_Extension protected function formatAmountPlain() { return new Twig_SimpleFilter( - 'formatAmountPlain', function ($string) { - $value = is_null($string) ? '0' : strval($string); + 'formatAmountPlain', function (string $string) { - return app('amount')->format($value, false); + return app('amount')->format($string, false); }, ['is_safe' => ['html']] ); } @@ -199,8 +198,7 @@ class General extends Twig_Extension protected function formatFilesize() { return new Twig_SimpleFilter( - 'filesize', function ($size) { - $size = intval($size); + 'filesize', function (int $size) { // less than one GB, more than one MB if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) { @@ -223,7 +221,7 @@ class General extends Twig_Extension protected function formatJournal() { return new Twig_SimpleFilter( - 'formatJournal', function ($journal) { + 'formatJournal', function (TransactionJournal $journal) { return app('amount')->formatJournal($journal); }, ['is_safe' => ['html']] ); @@ -247,7 +245,7 @@ class General extends Twig_Extension protected function getAccountRole() { return new Twig_SimpleFilter( - 'getAccountRole', function ($name) { + 'getAccountRole', function (string $name) { return Config::get('firefly.accountRoles.' . $name); } ); @@ -283,7 +281,7 @@ class General extends Twig_Extension protected function mimeIcon() { return new Twig_SimpleFilter( - 'mimeIcon', function ($string) { + 'mimeIcon', function (string $string) { switch ($string) { default: return 'fa-file-o'; @@ -303,7 +301,7 @@ class General extends Twig_Extension protected function phpdate() { return new Twig_SimpleFunction( - 'phpdate', function ($str) { + 'phpdate', function (string $str) { return date($str); } ); diff --git a/resources/views/piggy-banks/show.twig b/resources/views/piggy-banks/show.twig index 2d7158f3eb..164d80241f 100644 --- a/resources/views/piggy-banks/show.twig +++ b/resources/views/piggy-banks/show.twig @@ -41,7 +41,7 @@ {{ 'target_amount'|_ }} - {{ piggyBank.targetAmount|formatAmount }} + {{ piggyBank.targetamount|formatAmount }} {{ 'saved_so_far'|_ }} diff --git a/resources/views/reports/partials/balance.twig b/resources/views/reports/partials/balance.twig index 74cf4804a9..b30e34ec0c 100644 --- a/resources/views/reports/partials/balance.twig +++ b/resources/views/reports/partials/balance.twig @@ -26,7 +26,10 @@ {{ balanceLine.getTitle }} - {{ balanceLine.getRepetition.amount|formatAmount }} + + [source] + + {% else %} {{ balanceLine.getTitle }} {% endif %} From c5e283a13ec0c9cb3128989c472dd33b21437773 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 13:13:47 +0100 Subject: [PATCH 046/448] This is a fix for #171 --- app/Http/Controllers/RuleController.php | 3 ++- app/Repositories/RuleGroup/RuleGroupRepository.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.php index 5ae5b60a4a..b8feba57e4 100644 --- a/app/Http/Controllers/RuleController.php +++ b/app/Http/Controllers/RuleController.php @@ -342,6 +342,7 @@ class RuleController extends Controller $data = [ 'rule_group_id' => $repository->getFirstRuleGroup()->id, 'stop_processing' => 0, + 'user_id' => Auth::user()->id, 'title' => trans('firefly.default_rule_name'), 'description' => trans('firefly.default_rule_description'), 'trigger' => 'store-journal', @@ -374,7 +375,7 @@ class RuleController extends Controller if ($repository->count() === 0) { $data = [ - 'user' => Auth::user()->id, + 'user_id' => Auth::user()->id, 'title' => trans('firefly.default_rule_group_name'), 'description' => trans('firefly.default_rule_group_description'), ]; diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php index ccbfe8f98e..d92321f0d0 100644 --- a/app/Repositories/RuleGroup/RuleGroupRepository.php +++ b/app/Repositories/RuleGroup/RuleGroupRepository.php @@ -171,7 +171,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface $newRuleGroup = new RuleGroup( [ - 'user_id' => $data['user'], + 'user_id' => $data['user_id'], 'title' => $data['title'], 'description' => $data['description'], 'order' => ($order + 1), From cb52af28e7f3ea8a4251a2e3f4e882aa21c739e5 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 13:20:10 +0100 Subject: [PATCH 047/448] Also fixes #171 --- app/Http/Controllers/RuleGroupController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/RuleGroupController.php b/app/Http/Controllers/RuleGroupController.php index 19e1466dbf..9e2cd73f85 100644 --- a/app/Http/Controllers/RuleGroupController.php +++ b/app/Http/Controllers/RuleGroupController.php @@ -140,7 +140,7 @@ class RuleGroupController extends Controller $data = [ 'title' => $request->input('title'), 'description' => $request->input('description'), - 'user' => Auth::user()->id, + 'user_id' => Auth::user()->id, ]; $ruleGroup = $repository->store($data); From e2d0ee125f83f5a287f3a2626e39044379422364 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 15:01:33 +0100 Subject: [PATCH 048/448] Cleaning up test data. --- app/Support/Migration/TestData.php | 223 +++- database/seeds/DatabaseSeeder.php | 7 +- database/seeds/OldTestDataSeeder.php | 68 ++ database/seeds/TestDataSeeder.php | 199 +--- database/seeds/VisualTestDataSeeder.php | 1306 +++++++++++------------ tests/TestCase.php | 8 +- 6 files changed, 962 insertions(+), 849 deletions(-) create mode 100644 database/seeds/OldTestDataSeeder.php diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php index 69b8d12f1b..da34e4061c 100644 --- a/app/Support/Migration/TestData.php +++ b/app/Support/Migration/TestData.php @@ -18,8 +18,10 @@ use FireflyIII\Models\Attachment; use FireflyIII\Models\Bill; use FireflyIII\Models\Budget; use FireflyIII\Models\BudgetLimit; +use FireflyIII\Models\Category; use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBankEvent; +use FireflyIII\Models\Role; use FireflyIII\Models\Rule; use FireflyIII\Models\RuleAction; use FireflyIII\Models\RuleGroup; @@ -37,7 +39,6 @@ use Log; */ class TestData { - /** * @param User $user */ @@ -228,6 +229,139 @@ class TestData } } + /** + * @param User $user + */ + public static function createCategories(User $user) + { + Category::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]); + Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]); + } + + /** + * @param User $user + */ + public static function createExpenseAccounts(User $user) + { + $expenses = ['Adobe', 'Google', 'Vitens', 'Albert Heijn', 'PLUS', 'Apple', 'Bakker', 'Belastingdienst', 'bol.com', 'Cafe Central', 'conrad.nl', + 'coolblue', 'Shell', + 'DUO', 'Etos', 'FEBO', 'Greenchoice', 'Halfords', 'XS4All', 'iCentre', 'Jumper', 'Land lord']; + foreach ($expenses as $name) { + // create account: + Account::create( + [ + 'user_id' => $user->id, + 'account_type_id' => 4, + 'name' => $name, + 'active' => 1, + 'encrypted' => 1, + ] + ); + } + + } + + /** + * @param User $user + * @param string $description + * @param Carbon $date + * @param string $amount + * + * @return TransactionJournal + */ + public static function createRent(User $user, string $description, Carbon $date, string $amount): TransactionJournal + { + $fromAccount = TestData::findAccount($user, 'TestData Checking Account'); + $toAccount = TestData::findAccount($user, 'Land lord'); + $category = Category::firstOrCreateEncrypted(['name' => 'Rent', 'user_id' => $user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]); + $journal = TransactionJournal::create( + [ + 'user_id' => $user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'bill_id' => 1, + 'description' => $description, + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount * -1, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + return $journal; + + } + + + /** + * @param User $user + * @param string $description + * @param Carbon $date + * @param string $amount + * + * @return TransactionJournal + */ + public static function createIncome(User $user, string $description, Carbon $date, string $amount): TransactionJournal + { + $date = new Carbon($date->format('Y-m') . '-23'); // paid on 23rd. + $today = new Carbon; + if ($date >= $today) { + return new TransactionJournal; + } + $toAccount = TestData::findAccount($user, 'TestData Checking Account'); + $fromAccount = TestData::findAccount($user, 'Job'); + $category = Category::firstOrCreateEncrypted(['name' => 'Salary', 'user_id' => $user->id]); + // create journal: + + $journal = TransactionJournal::create( + [ + 'user_id' => $user->id, + 'transaction_type_id' => 2, + 'transaction_currency_id' => 1, + 'description' => $description, + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount * -1, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + + return $journal; + + } + /** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @param User $user @@ -366,6 +500,26 @@ class TestData } + /** + * @param User $user + */ + public static function createRevenueAccounts(User $user) + { + $revenues = ['Job', 'Belastingdienst', 'Bank', 'KPN', 'Google']; + foreach ($revenues as $name) { + // create account: + Account::create( + [ + 'user_id' => $user->id, + 'account_type_id' => 5, + 'name' => $name, + 'active' => 1, + 'encrypted' => 1, + ] + ); + } + } + /** * @param User $user */ @@ -468,6 +622,22 @@ class TestData ); } + /** + * @return User + */ + public static function createUsers(): User + { + $user = User::create(['email' => 'thegrumpydictator@gmail.com', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]); + User::create(['email' => 'thegrumpydictator+empty@gmail.com', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]); + User::create(['email' => 'thegrumpydictator+deleteme@gmail.com', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]); + + + $admin = Role::where('name', 'owner')->first(); + $user->attachRole($admin); + + return $user; + } + /** * @param User $user * @param $name @@ -508,5 +678,56 @@ class TestData return null; } + /** + * @param User $user + * @param Carbon $date + */ + public static function openingBalanceSavings(User $user, Carbon $date) + { + // opposing account for opening balance: + $opposing = Account::create( + [ + 'user_id' => $user->id, + 'account_type_id' => 6, + 'name' => 'Opposing for savings', + 'active' => 1, + 'encrypted' => 1, + ] + ); + + // savings + $savings = TestData::findAccount($user, 'TestData Savings'); + + $journal = TransactionJournal::create( + [ + 'user_id' => $user->id, + 'transaction_type_id' => 4, + 'transaction_currency_id' => 1, + 'description' => 'Opening balance for savings account', + 'completed' => 1, + 'date' => $date->format('Y-m-d'), + ] + ); + + // transactions + Transaction::create( + [ + 'account_id' => $opposing->id, + 'transaction_journal_id' => $journal->id, + 'amount' => -10000, + ] + ); + + Transaction::create( + [ + 'account_id' => $savings->id, + 'transaction_journal_id' => $journal->id, + 'amount' => 10000, + ] + ); + + + } + } diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 69a846e857..bf4ec69932 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -23,14 +23,9 @@ class DatabaseSeeder extends Seeder $this->call('PermissionSeeder'); // set up basic test data (as little as possible): - if (App::environment() == 'testing') { + if (App::environment() == 'testing' || App::environment() == 'local') { $this->call('TestDataSeeder'); } - - // this one is reserved for more extensive testing. - if (App::environment() == 'local') { - $this->call('VisualTestDataSeeder'); - } } } diff --git a/database/seeds/OldTestDataSeeder.php b/database/seeds/OldTestDataSeeder.php new file mode 100644 index 0000000000..856ffe164c --- /dev/null +++ b/database/seeds/OldTestDataSeeder.php @@ -0,0 +1,68 @@ +start = Carbon::create()->subYear()->startOfYear(); + + } + + /** + * Run the database seeds. + * + * @return void + */ + public function run() + { + // create budget limits for these budgets +// TestData::createBudgetLimit($user, new Carbon, 'Groceries', 400); +// TestData::createBudgetLimit($user, new Carbon, 'Bills', 1000); +// TestData::createBudgetLimit($user, new Carbon, 'Car', 100); + + // create some categories for user #1 + $this->createCategories($user); + + // create some piggy banks for user #1 + TestData::createPiggybanks($user); + + // create some expense accounts for user #1 + $this->createExpenseAccounts($user); + + // create some revenue accounts for user #1 + $this->createRevenueAccounts($user); + + // create journal + attachment: + TestData::createAttachments($user, $this->start); + + // create opening balance for savings account: + $this->openingBalanceSavings($user); + + // need at least one rule group and one rule: + TestData::createRules($user); + + // create a tag: + TestData::createTags($user); + } + +} diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php index 487d5a85a0..fb281c39b3 100644 --- a/database/seeds/TestDataSeeder.php +++ b/database/seeds/TestDataSeeder.php @@ -1,14 +1,15 @@ start = Carbon::create()->subYear()->startOfYear(); + $this->start = Carbon::create()->subYears(2)->startOfYear(); + $this->end = Carbon::now(); } @@ -35,153 +39,58 @@ class TestDataSeeder extends Seeder */ public function run() { - $user = User::create(['email' => 'thegrumpydictator@gmail.com', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]); - User::create(['email' => 'thegrumpydictator+empty@gmail.com', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]); - User::create(['email' => 'thegrumpydictator+deleteme@gmail.com', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]); + // start by creating all users: + // method will return the first user. + $user = TestData::createUsers(); - - $admin = Role::where('name', 'owner')->first(); - $user->attachRole($admin); - - - // create asset accounts for user #1. + // create all kinds of static data: TestData::createAssetAccounts($user); - - // create bills for user #1 TestData::createBills($user); - - // create some budgets for user #1 TestData::createBudgets($user); - - // create budget limits for these budgets - TestData::createBudgetLimit($user, new Carbon, 'Groceries', 400); - TestData::createBudgetLimit($user, new Carbon, 'Bills', 1000); - TestData::createBudgetLimit($user, new Carbon, 'Car', 100); - - // create some categories for user #1 - $this->createCategories($user); - - // create some piggy banks for user #1 + TestData::createCategories($user); TestData::createPiggybanks($user); - - // create some expense accounts for user #1 - $this->createExpenseAccounts($user); - - // create some revenue accounts for user #1 - $this->createRevenueAccounts($user); - - // create journal + attachment: + TestData::createExpenseAccounts($user); + TestData::createRevenueAccounts($user); TestData::createAttachments($user, $this->start); - - // create opening balance for savings account: - $this->openingBalanceSavings($user); - - // need at least one rule group and one rule: + TestData::openingBalanceSavings($user, $this->start); TestData::createRules($user); - // create a tag: - TestData::createTags($user); - } + // loop from start to end, create dynamic info. + $current = clone $this->start; + while ($current < $this->end) { + $month = $current->format('F Y'); + // create salaries: + TestData::createIncome($user, 'Salary ' . $month, $current, strval(rand(2000, 2100))); - /** - * @param User $user - */ - private function createCategories(User $user) - { - Category::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]); - Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]); - } + // pay bills: + TestData::createRent($user, 'Rent for ' . $month, $current, '800'); + // $this->createWater('Water bill for ' . $month, $current, 15); + // $this->createTV('TV bill for ' . $month, $current, 60); + // $this->createPower('Power bill for ' . $month, $current, 120); - /** - * @param User $user - */ - private function createExpenseAccounts(User $user) - { - $expenses = ['Adobe', 'Google', 'Vitens', 'Albert Heijn', 'PLUS', 'Apple', 'Bakker', 'Belastingdienst', 'bol.com', 'Cafe Central', 'conrad.nl', - 'coolblue', 'Shell', - 'DUO', 'Etos', 'FEBO', 'Greenchoice', 'Halfords', 'XS4All', 'iCentre', 'Jumper', 'Land lord']; - foreach ($expenses as $name) { - // create account: - Account::create( - [ - 'user_id' => $user->id, - 'account_type_id' => 4, - 'name' => $name, - 'active' => 1, - 'encrypted' => 1, - ] - ); + + // pay daily groceries: + // $this->createGroceries($current); + + // create tag (each type of tag, for date): + // TestData::createTags($this->user, $current); + + // go out for drinks: + // $this->createDrinksAndOthers($current); + + // save money every month: + // $this->createSavings($current); + + // buy gas for the car every month: + // $this->createCar($current); + + // create budget limits. + TestData::createBudgetLimit($user, $current, 'Groceries', '400'); + TestData::createBudgetLimit($user, $current, 'Bills', '1000'); + TestData::createBudgetLimit($user, $current, 'Car', '100'); + + echo 'Created test data for ' . $month . "\n"; + $current->addMonth(); } - - } - - /** - * @param User $user - */ - private function createRevenueAccounts(User $user) - { - $revenues = ['Job', 'Belastingdienst', 'Bank', 'KPN', 'Google']; - foreach ($revenues as $name) { - // create account: - Account::create( - [ - 'user_id' => $user->id, - 'account_type_id' => 5, - 'name' => $name, - 'active' => 1, - 'encrypted' => 1, - ] - ); - } - } - - /** - * @param User $user - */ - private function openingBalanceSavings(User $user) - { - // opposing account for opening balance: - $opposing = Account::create( - [ - 'user_id' => $user->id, - 'account_type_id' => 6, - 'name' => 'Opposing for savings', - 'active' => 1, - 'encrypted' => 1, - ] - ); - - // savings - $savings = TestData::findAccount($user, 'TestData Savings'); - - $journal = TransactionJournal::create( - [ - 'user_id' => $user->id, - 'transaction_type_id' => 4, - 'transaction_currency_id' => 1, - 'description' => 'Opening balance for savings account', - 'completed' => 1, - 'date' => $this->start->format('Y-m-d'), - ] - ); - - // transactions - Transaction::create( - [ - 'account_id' => $opposing->id, - 'transaction_journal_id' => $journal->id, - 'amount' => -10000, - ] - ); - - Transaction::create( - [ - 'account_id' => $savings->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 10000, - ] - ); - - } } diff --git a/database/seeds/VisualTestDataSeeder.php b/database/seeds/VisualTestDataSeeder.php index 672ff770ac..0db640c9b0 100644 --- a/database/seeds/VisualTestDataSeeder.php +++ b/database/seeds/VisualTestDataSeeder.php @@ -28,13 +28,622 @@ use Illuminate\Database\Seeder; class VisualTestDataSeeder extends Seeder { - /** @var User */ - protected $user; + /** @var Carbon */ + public $end; + /** @var Carbon */ + public $start; + + /** + * TestDataSeeder constructor. + */ + public function __construct() + { + $this->start = Carbon::create()->subYears(2)->startOfYear(); + $this->end = Carbon::now(); + + } /** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function createRules() + public function run() + { + $this->createUsers(); + + // create accounts: + TestData::createAssetAccounts($this->user); + $this->createExpenseAccounts(); + $this->createRevenueAccounts(); + TestData::createBills($this->user); + TestData::createPiggybanks($this->user); + + // create some budgets for user + TestData::createBudgets($this->user); + + $this->createRules(); + + // preference to only see account #1 on frontpage. + $this->createPreferences(); + + // dates: + $start = Carbon::now()->subYears(2)->startOfMonth(); + $end = Carbon::now()->endOfDay(); + + // create journal + attachment: + TestData::createAttachments($this->user, $start); + + + $current = clone $start; + while ($current < $end) { + $month = $current->format('F Y'); + // create salaries: + $this->createIncome('Salary ' . $month, $current, rand(2000, 2100)); + + // pay bills: + $this->createRent('Rent for ' . $month, $current, 800); + $this->createWater('Water bill for ' . $month, $current, 15); + $this->createTV('TV bill for ' . $month, $current, 60); + $this->createPower('Power bill for ' . $month, $current, 120); + + + // pay daily groceries: + $this->createGroceries($current); + + // create tag (each type of tag, for date): + TestData::createTags($this->user, $current); + + // go out for drinks: + $this->createDrinksAndOthers($current); + + // save money every month: + $this->createSavings($current); + + // buy gas for the car every month: + $this->createCar($current); + + // budget limit for this month, on "Groceries". + TestData::createBudgetLimit($this->user, $current, 'Groceries', 400); + TestData::createBudgetLimit($this->user, $current, 'Bills', 1000); + TestData::createBudgetLimit($this->user, $current, 'Car', 100); + + echo 'Created test data for ' . $month . "\n"; + $current->addMonth(); + } + + } + + /** + * @param $date + * + * @return static + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + protected function createCar($date) + { + // twice: + $date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th + $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); + $toAccount = TestData::findAccount($this->user, 'Shell'); + $category = Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $this->user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $this->user->id]); + $amount = rand(4000, 5000) / 100; + $journal = TransactionJournal::create( + [ + 'user_id' => $this->user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => 'Bought gas', + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount * -1, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + // and again! + $date = new Carbon($date->format('Y-m') . '-20'); // paid on 20th + $amount = rand(4000, 5000) / 100; + + + $journal = TransactionJournal::create( + [ + 'user_id' => $this->user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => 'Gas for car', + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount * -1, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + + // and again! + + return $journal; + } + + /** + * @param Carbon $date + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + protected function createDrinksAndOthers(Carbon $date) + { + $start = clone $date; + $end = clone $date; + $today = new Carbon; + $start->startOfMonth(); + $end->endOfMonth(); + $current = clone $start; + while ($current < $end && $current < $today) { + + // weekly drink: + $thisDate = clone $current; + $thisDate->addDay(); + $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); + $toAccount = TestData::findAccount($this->user, 'Cafe Central'); + $category = Category::firstOrCreateEncrypted(['name' => 'Drinks', 'user_id' => $this->user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Going out', 'user_id' => $this->user->id]); + $amount = rand(1500, 3600) / 100; + $journal = TransactionJournal::create( + [ + 'user_id' => $this->user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => 'Going out for drinks', + 'completed' => 1, + 'date' => $thisDate, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount * -1, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + // shopping at some (online) shop: + + + $current->addWeek(); + } + } + + protected function createExpenseAccounts() + { + $expenses = ['Adobe', 'Google', 'Vitens', 'Albert Heijn', 'PLUS', 'Apple', 'Bakker', 'Belastingdienst', 'bol.com', 'Cafe Central', 'conrad.nl', + 'coolblue', 'Shell', + 'DUO', 'Etos', 'FEBO', 'Greenchoice', 'Halfords', 'XS4All', 'iCentre', 'Jumper', 'Land lord']; + foreach ($expenses as $name) { + // create account: + Account::create( + [ + 'user_id' => $this->user->id, + 'account_type_id' => 4, + 'name' => $name, + 'active' => 1, + 'encrypted' => 1, + ] + ); + } + + } + + /** + * @param Carbon $date + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + protected function createGroceries(Carbon $date) + { + $start = clone $date; + $end = clone $date; + $today = new Carbon; + $start->startOfMonth(); + $end->endOfMonth(); + + $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); + $stores = ['Albert Heijn', 'PLUS', 'Bakker']; + $descriptions = ['Groceries', 'Bought some groceries', 'Got groceries']; + $category = Category::firstOrCreateEncrypted(['name' => 'Daily groceries', 'user_id' => $this->user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $this->user->id]); + + $current = clone $start; + while ($current < $end && $current < $today) { + // daily groceries: + $amount = rand(1500, 2500) / 100; + $toAccount = TestData::findAccount($this->user, $stores[rand(0, count($stores) - 1)]); + + $journal = TransactionJournal::create( + [ + 'user_id' => $this->user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => $descriptions[rand(0, count($descriptions) - 1)], + 'completed' => 1, + 'date' => $current, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount * -1, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + + $current->addDay(); + } + } + + + + /** + * @param $description + * @param Carbon $date + * @param $amount + * + * @return TransactionJournal + */ + protected function createPower($description, Carbon $date, $amount) + { + $date = new Carbon($date->format('Y-m') . '-06'); // paid on 10th + $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); + $toAccount = TestData::findAccount($this->user, 'Greenchoice'); + $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $this->user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $this->user->id]); + $journal = TransactionJournal::create( + [ + 'user_id' => $this->user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => $description, + 'completed' => 1, + 'date' => $date, + ] + ); + if($journal->getErrors()->count() > 0) { + echo $journal->getErrors()->first(); + } + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount * -1, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + return $journal; + + } + + protected function createPreferences() + { + $preference = new Preference; + $preference->name = 'frontPageAccounts'; + $preference->data = [1]; + $preference->user()->associate($this->user); + $preference->save(); + } + + + /** + * + */ + protected function createRevenueAccounts() + { + $revenues = ['Job', 'Belastingdienst', 'Bank', 'KPN', 'Google']; + foreach ($revenues as $name) { + // create account: + Account::create( + [ + 'user_id' => $this->user->id, + 'account_type_id' => 5, + 'name' => $name, + 'active' => 1, + 'encrypted' => 1, + ] + ); + } + } + + /** + * @param Carbon $date + * + * @return TransactionJournal + */ + protected function createSavings(Carbon $date) + { + $date = new Carbon($date->format('Y-m') . '-24'); // paid on 24th. + $toAccount = TestData::findAccount($this->user, 'TestData Savings'); + $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); + $category = Category::firstOrCreateEncrypted(['name' => 'Money management', 'user_id' => $this->user->id]); + // create journal: + + $journal = TransactionJournal::create( + [ + 'user_id' => $this->user->id, + 'transaction_type_id' => 3, + 'transaction_currency_id' => 1, + 'description' => 'Save money', + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => -150, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => 150, + + ] + ); + $journal->categories()->save($category); + + return $journal; + + } + + /** + * @param $description + * @param Carbon $date + * @param $amount + * + * @return TransactionJournal + */ + protected function createTV($description, Carbon $date, $amount) + { + $date = new Carbon($date->format('Y-m') . '-15'); // paid on 10th + $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); + $toAccount = TestData::findAccount($this->user, 'XS4All'); + $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $this->user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $this->user->id]); + $journal = TransactionJournal::create( + [ + 'user_id' => $this->user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => $description, + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount * -1, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + return $journal; + + } + + /** + * + */ + protected function createUsers() + { + User::create(['email' => 'thegrumpydictator@gmail.com', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]); + $this->user = User::whereEmail('thegrumpydictator@gmail.com')->first(); + + // create rights: + $role = Role::find(1); + $this->user->roles()->save($role); + + } + + /** + * @param $description + * @param Carbon $date + * @param $amount + * + * @return TransactionJournal + */ + protected function createWater($description, Carbon $date, $amount) + { + $date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th + $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); + $toAccount = TestData::findAccount($this->user, 'Vitens'); + $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $this->user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $this->user->id]); + $journal = TransactionJournal::create( + [ + 'user_id' => $this->user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => $description, + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount * -1, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + return $journal; + + } + + /** + * @param $name + * + * @return Bill|null + */ + protected function findBill($name) + { + /** @var Bill $bill */ + foreach (Bill::get() as $bill) { + if ($bill->name == $name && $this->user->id == $bill->user_id) { + return $bill; + break; + } + } + + return null; + } + + /** + * @param $name + * + * @return Category|null + */ + protected function findCategory($name) + { + + /** @var Category $category */ + foreach (Category::get() as $category) { + if ($category->name == $name && $this->user->id == $category->user_id) { + return $category; + break; + } + } + + return null; + } + + /** + * @param $name + * + * @return PiggyBank|null + */ + protected function findPiggyBank($name) + { + + /** @var Budget $budget */ + foreach (PiggyBank::get() as $piggyBank) { + $account = $piggyBank->account()->first(); + if ($piggyBank->name == $name && $this->user->id == $account->user_id) { + return $piggyBank; + break; + } + } + + return null; + } + + /** + * @param $tagName + * + * @return Tag|null + * @internal param $tag + */ + protected function findTag($tagName) + { + /** @var Tag $tag */ + foreach (Tag::get() as $tag) { + if ($tag->tag == $tagName && $this->user->id == $tag->user_id) { + return $tag; + break; + } + } + + return null; + } + + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + private function createRules() { // three rule groups to get started. $ruleGroup = new RuleGroup; @@ -430,696 +1039,5 @@ class VisualTestDataSeeder extends Seeder unset($ruleAction); } - /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function run() - { - $this->createUsers(); - - // create accounts: - TestData::createAssetAccounts($this->user); - $this->createExpenseAccounts(); - $this->createRevenueAccounts(); - TestData::createBills($this->user); - TestData::createPiggybanks($this->user); - - // create some budgets for user - TestData::createBudgets($this->user); - - $this->createRules(); - - // preference to only see account #1 on frontpage. - $this->createPreferences(); - - // dates: - $start = Carbon::now()->subYears(2)->startOfMonth(); - $end = Carbon::now()->endOfDay(); - - // create journal + attachment: - TestData::createAttachments($this->user, $start); - - - $current = clone $start; - while ($current < $end) { - $month = $current->format('F Y'); - // create salaries: - $this->createIncome('Salary ' . $month, $current, rand(2000, 2100)); - - // pay bills: - $this->createRent('Rent for ' . $month, $current, 800); - $this->createWater('Water bill for ' . $month, $current, 15); - $this->createTV('TV bill for ' . $month, $current, 60); - $this->createPower('Power bill for ' . $month, $current, 120); - - - // pay daily groceries: - $this->createGroceries($current); - - // create tag (each type of tag, for date): - TestData::createTags($this->user, $current); - - // go out for drinks: - $this->createDrinksAndOthers($current); - - // save money every month: - $this->createSavings($current); - - // buy gas for the car every month: - $this->createCar($current); - - // budget limit for this month, on "Groceries". - TestData::createBudgetLimit($this->user, $current, 'Groceries', 400); - TestData::createBudgetLimit($this->user, $current, 'Bills', 1000); - TestData::createBudgetLimit($this->user, $current, 'Car', 100); - - echo 'Created test data for ' . $month . "\n"; - $current->addMonth(); - } - - } - - /** - * @param $date - * - * @return static - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function createCar($date) - { - // twice: - $date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $toAccount = TestData::findAccount($this->user, 'Shell'); - $category = Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $this->user->id]); - $amount = rand(4000, 5000) / 100; - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => 'Bought gas', - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - // and again! - $date = new Carbon($date->format('Y-m') . '-20'); // paid on 20th - $amount = rand(4000, 5000) / 100; - - - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => 'Gas for car', - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - - // and again! - - return $journal; - } - - /** - * @param Carbon $date - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function createDrinksAndOthers(Carbon $date) - { - $start = clone $date; - $end = clone $date; - $today = new Carbon; - $start->startOfMonth(); - $end->endOfMonth(); - $current = clone $start; - while ($current < $end && $current < $today) { - - // weekly drink: - $thisDate = clone $current; - $thisDate->addDay(); - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $toAccount = TestData::findAccount($this->user, 'Cafe Central'); - $category = Category::firstOrCreateEncrypted(['name' => 'Drinks', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Going out', 'user_id' => $this->user->id]); - $amount = rand(1500, 3600) / 100; - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => 'Going out for drinks', - 'completed' => 1, - 'date' => $thisDate, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - // shopping at some (online) shop: - - - $current->addWeek(); - } - } - - protected function createExpenseAccounts() - { - $expenses = ['Adobe', 'Google', 'Vitens', 'Albert Heijn', 'PLUS', 'Apple', 'Bakker', 'Belastingdienst', 'bol.com', 'Cafe Central', 'conrad.nl', - 'coolblue', 'Shell', - 'DUO', 'Etos', 'FEBO', 'Greenchoice', 'Halfords', 'XS4All', 'iCentre', 'Jumper', 'Land lord']; - foreach ($expenses as $name) { - // create account: - Account::create( - [ - 'user_id' => $this->user->id, - 'account_type_id' => 4, - 'name' => $name, - 'active' => 1, - 'encrypted' => 1, - ] - ); - } - - } - - /** - * @param Carbon $date - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function createGroceries(Carbon $date) - { - $start = clone $date; - $end = clone $date; - $today = new Carbon; - $start->startOfMonth(); - $end->endOfMonth(); - - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $stores = ['Albert Heijn', 'PLUS', 'Bakker']; - $descriptions = ['Groceries', 'Bought some groceries', 'Got groceries']; - $category = Category::firstOrCreateEncrypted(['name' => 'Daily groceries', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $this->user->id]); - - $current = clone $start; - while ($current < $end && $current < $today) { - // daily groceries: - $amount = rand(1500, 2500) / 100; - $toAccount = TestData::findAccount($this->user, $stores[rand(0, count($stores) - 1)]); - - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => $descriptions[rand(0, count($descriptions) - 1)], - 'completed' => 1, - 'date' => $current, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - - $current->addDay(); - } - } - - /** - * @param $description - * @param Carbon $date - * @param $amount - * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * - * @return TransactionJournal - */ - protected function createIncome($description, Carbon $date, $amount) - { - $date = new Carbon($date->format('Y-m') . '-23'); // paid on 23rd. - $today = new Carbon; - if ($date >= $today) { - return null; - } - $toAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $fromAccount = TestData::findAccount($this->user, 'Job'); - $category = Category::firstOrCreateEncrypted(['name' => 'Salary', 'user_id' => $this->user->id]); - // create journal: - - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 2, - 'transaction_currency_id' => 1, - 'description' => $description, - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - - return $journal; - - } - - /** - * @param $description - * @param Carbon $date - * @param $amount - * - * @return TransactionJournal - */ - protected function createPower($description, Carbon $date, $amount) - { - $date = new Carbon($date->format('Y-m') . '-06'); // paid on 10th - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $toAccount = TestData::findAccount($this->user, 'Greenchoice'); - $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $this->user->id]); - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => $description, - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - return $journal; - - } - - protected function createPreferences() - { - $preference = new Preference; - $preference->name = 'frontPageAccounts'; - $preference->data = [1]; - $preference->user()->associate($this->user); - $preference->save(); - } - - /** - * @param $description - * @param Carbon $date - * @param $amount - * - * @return TransactionJournal - */ - protected function createRent($description, Carbon $date, $amount) - { - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $toAccount = TestData::findAccount($this->user, 'Land lord'); - $category = Category::firstOrCreateEncrypted(['name' => 'Rent', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $this->user->id]); - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'bill_id' => 1, - 'description' => $description, - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - return $journal; - - } - - /** - * - */ - protected function createRevenueAccounts() - { - $revenues = ['Job', 'Belastingdienst', 'Bank', 'KPN', 'Google']; - foreach ($revenues as $name) { - // create account: - Account::create( - [ - 'user_id' => $this->user->id, - 'account_type_id' => 5, - 'name' => $name, - 'active' => 1, - 'encrypted' => 1, - ] - ); - } - } - - /** - * @param Carbon $date - * - * @return TransactionJournal - */ - protected function createSavings(Carbon $date) - { - $date = new Carbon($date->format('Y-m') . '-24'); // paid on 24th. - $toAccount = TestData::findAccount($this->user, 'TestData Savings'); - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $category = Category::firstOrCreateEncrypted(['name' => 'Money management', 'user_id' => $this->user->id]); - // create journal: - - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 3, - 'transaction_currency_id' => 1, - 'description' => 'Save money', - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => -150, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 150, - - ] - ); - $journal->categories()->save($category); - - return $journal; - - } - - /** - * @param $description - * @param Carbon $date - * @param $amount - * - * @return TransactionJournal - */ - protected function createTV($description, Carbon $date, $amount) - { - $date = new Carbon($date->format('Y-m') . '-15'); // paid on 10th - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $toAccount = TestData::findAccount($this->user, 'XS4All'); - $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $this->user->id]); - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => $description, - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - return $journal; - - } - - /** - * - */ - protected function createUsers() - { - User::create(['email' => 'thegrumpydictator@gmail.com', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]); - $this->user = User::whereEmail('thegrumpydictator@gmail.com')->first(); - - // create rights: - $role = Role::find(1); - $this->user->roles()->save($role); - - } - - /** - * @param $description - * @param Carbon $date - * @param $amount - * - * @return TransactionJournal - */ - protected function createWater($description, Carbon $date, $amount) - { - $date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $toAccount = TestData::findAccount($this->user, 'Vitens'); - $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $this->user->id]); - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => $description, - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - return $journal; - - } - - /** - * @param $name - * - * @return Bill|null - */ - protected function findBill($name) - { - /** @var Bill $bill */ - foreach (Bill::get() as $bill) { - if ($bill->name == $name && $this->user->id == $bill->user_id) { - return $bill; - break; - } - } - - return null; - } - - /** - * @param $name - * - * @return Category|null - */ - protected function findCategory($name) - { - - /** @var Category $category */ - foreach (Category::get() as $category) { - if ($category->name == $name && $this->user->id == $category->user_id) { - return $category; - break; - } - } - - return null; - } - - /** - * @param $name - * - * @return PiggyBank|null - */ - protected function findPiggyBank($name) - { - - /** @var Budget $budget */ - foreach (PiggyBank::get() as $piggyBank) { - $account = $piggyBank->account()->first(); - if ($piggyBank->name == $name && $this->user->id == $account->user_id) { - return $piggyBank; - break; - } - } - - return null; - } - - /** - * @param $tagName - * - * @return Tag|null - * @internal param $tag - */ - protected function findTag($tagName) - { - /** @var Tag $tag */ - foreach (Tag::get() as $tag) { - if ($tag->tag == $tagName && $this->user->id == $tag->user_id) { - return $tag; - break; - } - } - - return null; - } - } diff --git a/tests/TestCase.php b/tests/TestCase.php index 15d5dcd64d..b4c57aa833 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -31,15 +31,17 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase 'data' => $range, ] ); + // set period to match? + } // if selected "custom", change the session to a weird custom range: // (20 days): - if($range === "custom") { + if ($range === "custom") { $this->session( [ 'start' => Carbon::now(), - 'end' => Carbon::now()->subDays(20), - ] + 'end' => Carbon::now()->subDays(20), + ] ); } } From 4ef840e210fae62f4420dbaa6b224dfcb3f59548 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 15:20:44 +0100 Subject: [PATCH 049/448] More test data tweaks. --- app/Models/TransactionJournal.php | 2 +- app/Support/Migration/TestData.php | 469 +++++++++- app/Support/Steam.php | 2 +- database/seeds/OldTestDataSeeder.php | 68 -- database/seeds/TestDataSeeder.php | 17 +- database/seeds/VisualTestDataSeeder.php | 1043 ----------------------- 6 files changed, 439 insertions(+), 1162 deletions(-) delete mode 100644 database/seeds/OldTestDataSeeder.php delete mode 100644 database/seeds/VisualTestDataSeeder.php diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index 25728ed5e3..f00bf0ea58 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -158,7 +158,7 @@ class TransactionJournal extends Model $transaction = $this->transactions->sortByDesc('amount')->first(); $amount = $transaction->amount; if ($this->isWithdrawal()) { - $amount = $amount * -1; + $amount = bcmul($amount, '-1'); } $cache->store($amount); diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php index da34e4061c..7a8548faed 100644 --- a/app/Support/Migration/TestData.php +++ b/app/Support/Migration/TestData.php @@ -39,6 +39,8 @@ use Log; */ class TestData { + + /** * @param User $user */ @@ -99,7 +101,7 @@ class TestData [ 'account_id' => $fromAccount->id, 'transaction_journal_id' => $journal->id, - 'amount' => -100, + 'amount' => '-100', ] ); @@ -229,6 +231,88 @@ class TestData } } + /** + * @param User $user + * @param Carbon $date + * + * @return static + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public static function createCar(User $user, Carbon $date) + { + // twice: + $date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th + $fromAccount = TestData::findAccount($user, 'TestData Checking Account'); + $toAccount = TestData::findAccount($user, 'Shell'); + $category = Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]); + $amount = strval(rand(4000, 5000) / 100); + $journal = TransactionJournal::create( + [ + 'user_id' => $user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => 'Bought gas', + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => bcmul($amount, '-1'), + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + // and again! + $date = new Carbon($date->format('Y-m') . '-20'); // paid on 20th + $amount = rand(4000, 5000) / 100; + + + $journal = TransactionJournal::create( + [ + 'user_id' => $user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => 'Gas for car', + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount * -1, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + + // and again! + + return $journal; + } + /** * @param User $user */ @@ -238,6 +322,64 @@ class TestData Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]); } + /** + * @param Carbon $date + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public static function createDrinksAndOthers(User $user, Carbon $date) + { + $start = clone $date; + $end = clone $date; + $today = new Carbon; + $start->startOfMonth(); + $end->endOfMonth(); + $current = clone $start; + while ($current < $end && $current < $today) { + + // weekly drink: + $thisDate = clone $current; + $thisDate->addDay(); + $fromAccount = TestData::findAccount($user, 'TestData Checking Account'); + $toAccount = TestData::findAccount($user, 'Cafe Central'); + $category = Category::firstOrCreateEncrypted(['name' => 'Drinks', 'user_id' => $user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Going out', 'user_id' => $user->id]); + $amount = strval(rand(1500, 3600) / 100); + $journal = TransactionJournal::create( + [ + 'user_id' => $user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => 'Going out for drinks', + 'completed' => 1, + 'date' => $thisDate, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => bcmul($amount, '-1'), + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + // shopping at some (online) shop: + + + $current->addWeek(); + } + } + /** * @param User $user */ @@ -263,53 +405,61 @@ class TestData /** * @param User $user - * @param string $description * @param Carbon $date - * @param string $amount - * - * @return TransactionJournal + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public static function createRent(User $user, string $description, Carbon $date, string $amount): TransactionJournal + public static function createGroceries(User $user, Carbon $date) { - $fromAccount = TestData::findAccount($user, 'TestData Checking Account'); - $toAccount = TestData::findAccount($user, 'Land lord'); - $category = Category::firstOrCreateEncrypted(['name' => 'Rent', 'user_id' => $user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]); - $journal = TransactionJournal::create( - [ - 'user_id' => $user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'bill_id' => 1, - 'description' => $description, - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, + $start = clone $date; + $end = clone $date; + $today = new Carbon; + $start->startOfMonth(); + $end->endOfMonth(); - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, + $fromAccount = TestData::findAccount($user, 'TestData Checking Account'); + $stores = ['Albert Heijn', 'PLUS', 'Bakker']; + $descriptions = ['Groceries', 'Bought some groceries', 'Got groceries']; + $category = Category::firstOrCreateEncrypted(['name' => 'Daily groceries', 'user_id' => $user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]); - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); + $current = clone $start; + while ($current < $end && $current < $today) { + // daily groceries: + $amount = rand(1500, 2500) / 100; + $toAccount = TestData::findAccount($user, $stores[rand(0, count($stores) - 1)]); - return $journal; + $journal = TransactionJournal::create( + [ + 'user_id' => $user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => $descriptions[rand(0, count($descriptions) - 1)], + 'completed' => 1, + 'date' => $current, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount * -1, + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + $current->addDay(); + } } - /** * @param User $user * @param string $description @@ -344,7 +494,7 @@ class TestData [ 'account_id' => $fromAccount->id, 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, + 'amount' => bcmul($amount, '-1'), ] ); @@ -500,6 +650,104 @@ class TestData } + /** + * @param $description + * @param Carbon $date + * @param $amount + * + * @return TransactionJournal + */ + public static function createPower(User $user, string $description, Carbon $date, string $amount) + { + $date = new Carbon($date->format('Y-m') . '-06'); // paid on 10th + $fromAccount = TestData::findAccount($user, 'TestData Checking Account'); + $toAccount = TestData::findAccount($user, 'Greenchoice'); + $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]); + $journal = TransactionJournal::create( + [ + 'user_id' => $user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => $description, + 'completed' => 1, + 'date' => $date, + ] + ); + if ($journal->getErrors()->count() > 0) { + echo $journal->getErrors()->first(); + } + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => bcmul($amount, '-1'), + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + return $journal; + + } + + /** + * @param User $user + * @param string $description + * @param Carbon $date + * @param string $amount + * + * @return TransactionJournal + */ + public static function createRent(User $user, string $description, Carbon $date, string $amount): TransactionJournal + { + $fromAccount = TestData::findAccount($user, 'TestData Checking Account'); + $toAccount = TestData::findAccount($user, 'Land lord'); + $category = Category::firstOrCreateEncrypted(['name' => 'Rent', 'user_id' => $user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]); + $journal = TransactionJournal::create( + [ + 'user_id' => $user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'bill_id' => 1, + 'description' => $description, + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => bcmul($amount, '-1'), + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + return $journal; + + } + /** * @param User $user */ @@ -599,6 +847,99 @@ class TestData ); } + /** + * @param Carbon $date + * + * @return TransactionJournal + */ + public static function createSavings(User $user, Carbon $date): TransactionJournal + { + $date = new Carbon($date->format('Y-m') . '-24'); // paid on 24th. + $toAccount = TestData::findAccount($user, 'TestData Savings'); + $fromAccount = TestData::findAccount($user, 'TestData Checking Account'); + $category = Category::firstOrCreateEncrypted(['name' => 'Money management', 'user_id' => $user->id]); + // create journal: + + $journal = TransactionJournal::create( + [ + 'user_id' => $user->id, + 'transaction_type_id' => 3, + 'transaction_currency_id' => 1, + 'description' => 'Save money', + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => -150, + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => 150, + + ] + ); + $journal->categories()->save($category); + + return $journal; + + } + + /** + * @param User $user + * @param string $description + * @param Carbon $date + * @param string $amount + * + * @return static + */ + public static function createTV(User $user, string $description, Carbon $date, string $amount) + { + $date = new Carbon($date->format('Y-m') . '-15'); // paid on 10th + $fromAccount = TestData::findAccount($user, 'TestData Checking Account'); + $toAccount = TestData::findAccount($user, 'XS4All'); + $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]); + $journal = TransactionJournal::create( + [ + 'user_id' => $user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => $description, + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => bcmul($amount, '-1'), + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + return $journal; + + } + /** * @param User $user * @param Carbon|null $date @@ -638,6 +979,54 @@ class TestData return $user; } + /** + * @param User $user + * @param string $description + * @param Carbon $date + * @param string $amount + * + * @return static + */ + public static function createWater(User $user, string $description, Carbon $date, string $amount): TransactionJournal + { + $date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th + $fromAccount = TestData::findAccount($user, 'TestData Checking Account'); + $toAccount = TestData::findAccount($user, 'Vitens'); + $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $user->id]); + $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]); + $journal = TransactionJournal::create( + [ + 'user_id' => $user->id, + 'transaction_type_id' => 1, + 'transaction_currency_id' => 1, + 'description' => $description, + 'completed' => 1, + 'date' => $date, + ] + ); + Transaction::create( + [ + 'account_id' => $fromAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => bcmul($amount, '-1'), + + ] + ); + Transaction::create( + [ + 'account_id' => $toAccount->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + + return $journal; + + } + /** * @param User $user * @param $name diff --git a/app/Support/Steam.php b/app/Support/Steam.php index e896c65c8c..3592c1cd88 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -133,7 +133,7 @@ class Steam $result = []; foreach ($balances as $entry) { $accountId = intval($entry->account_id); - $balance = round($entry->aggregate, 2); + $balance = $entry->aggregate; $result[$accountId] = $balance; } diff --git a/database/seeds/OldTestDataSeeder.php b/database/seeds/OldTestDataSeeder.php deleted file mode 100644 index 856ffe164c..0000000000 --- a/database/seeds/OldTestDataSeeder.php +++ /dev/null @@ -1,68 +0,0 @@ -start = Carbon::create()->subYear()->startOfYear(); - - } - - /** - * Run the database seeds. - * - * @return void - */ - public function run() - { - // create budget limits for these budgets -// TestData::createBudgetLimit($user, new Carbon, 'Groceries', 400); -// TestData::createBudgetLimit($user, new Carbon, 'Bills', 1000); -// TestData::createBudgetLimit($user, new Carbon, 'Car', 100); - - // create some categories for user #1 - $this->createCategories($user); - - // create some piggy banks for user #1 - TestData::createPiggybanks($user); - - // create some expense accounts for user #1 - $this->createExpenseAccounts($user); - - // create some revenue accounts for user #1 - $this->createRevenueAccounts($user); - - // create journal + attachment: - TestData::createAttachments($user, $this->start); - - // create opening balance for savings account: - $this->openingBalanceSavings($user); - - // need at least one rule group and one rule: - TestData::createRules($user); - - // create a tag: - TestData::createTags($user); - } - -} diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php index fb281c39b3..663f5656e5 100644 --- a/database/seeds/TestDataSeeder.php +++ b/database/seeds/TestDataSeeder.php @@ -64,25 +64,24 @@ class TestDataSeeder extends Seeder // pay bills: TestData::createRent($user, 'Rent for ' . $month, $current, '800'); - // $this->createWater('Water bill for ' . $month, $current, 15); - // $this->createTV('TV bill for ' . $month, $current, 60); - // $this->createPower('Power bill for ' . $month, $current, 120); - + TestData::createWater($user, 'Water bill for ' . $month, $current, '15'); + TestData::createTV($user, 'TV bill for ' . $month, $current, '60'); + TestData::createPower($user, 'Power bill for ' . $month, $current, '120'); // pay daily groceries: - // $this->createGroceries($current); + TestData::createGroceries($user, $current); // create tag (each type of tag, for date): - // TestData::createTags($this->user, $current); + TestData::createTags($user, $current); // go out for drinks: - // $this->createDrinksAndOthers($current); + TestData::createDrinksAndOthers($user, $current); // save money every month: - // $this->createSavings($current); + TestData::createSavings($user, $current); // buy gas for the car every month: - // $this->createCar($current); + TestData::createCar($user, $current); // create budget limits. TestData::createBudgetLimit($user, $current, 'Groceries', '400'); diff --git a/database/seeds/VisualTestDataSeeder.php b/database/seeds/VisualTestDataSeeder.php deleted file mode 100644 index 0db640c9b0..0000000000 --- a/database/seeds/VisualTestDataSeeder.php +++ /dev/null @@ -1,1043 +0,0 @@ -start = Carbon::create()->subYears(2)->startOfYear(); - $this->end = Carbon::now(); - - } - - /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function run() - { - $this->createUsers(); - - // create accounts: - TestData::createAssetAccounts($this->user); - $this->createExpenseAccounts(); - $this->createRevenueAccounts(); - TestData::createBills($this->user); - TestData::createPiggybanks($this->user); - - // create some budgets for user - TestData::createBudgets($this->user); - - $this->createRules(); - - // preference to only see account #1 on frontpage. - $this->createPreferences(); - - // dates: - $start = Carbon::now()->subYears(2)->startOfMonth(); - $end = Carbon::now()->endOfDay(); - - // create journal + attachment: - TestData::createAttachments($this->user, $start); - - - $current = clone $start; - while ($current < $end) { - $month = $current->format('F Y'); - // create salaries: - $this->createIncome('Salary ' . $month, $current, rand(2000, 2100)); - - // pay bills: - $this->createRent('Rent for ' . $month, $current, 800); - $this->createWater('Water bill for ' . $month, $current, 15); - $this->createTV('TV bill for ' . $month, $current, 60); - $this->createPower('Power bill for ' . $month, $current, 120); - - - // pay daily groceries: - $this->createGroceries($current); - - // create tag (each type of tag, for date): - TestData::createTags($this->user, $current); - - // go out for drinks: - $this->createDrinksAndOthers($current); - - // save money every month: - $this->createSavings($current); - - // buy gas for the car every month: - $this->createCar($current); - - // budget limit for this month, on "Groceries". - TestData::createBudgetLimit($this->user, $current, 'Groceries', 400); - TestData::createBudgetLimit($this->user, $current, 'Bills', 1000); - TestData::createBudgetLimit($this->user, $current, 'Car', 100); - - echo 'Created test data for ' . $month . "\n"; - $current->addMonth(); - } - - } - - /** - * @param $date - * - * @return static - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function createCar($date) - { - // twice: - $date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $toAccount = TestData::findAccount($this->user, 'Shell'); - $category = Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $this->user->id]); - $amount = rand(4000, 5000) / 100; - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => 'Bought gas', - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - // and again! - $date = new Carbon($date->format('Y-m') . '-20'); // paid on 20th - $amount = rand(4000, 5000) / 100; - - - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => 'Gas for car', - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - - // and again! - - return $journal; - } - - /** - * @param Carbon $date - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function createDrinksAndOthers(Carbon $date) - { - $start = clone $date; - $end = clone $date; - $today = new Carbon; - $start->startOfMonth(); - $end->endOfMonth(); - $current = clone $start; - while ($current < $end && $current < $today) { - - // weekly drink: - $thisDate = clone $current; - $thisDate->addDay(); - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $toAccount = TestData::findAccount($this->user, 'Cafe Central'); - $category = Category::firstOrCreateEncrypted(['name' => 'Drinks', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Going out', 'user_id' => $this->user->id]); - $amount = rand(1500, 3600) / 100; - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => 'Going out for drinks', - 'completed' => 1, - 'date' => $thisDate, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - // shopping at some (online) shop: - - - $current->addWeek(); - } - } - - protected function createExpenseAccounts() - { - $expenses = ['Adobe', 'Google', 'Vitens', 'Albert Heijn', 'PLUS', 'Apple', 'Bakker', 'Belastingdienst', 'bol.com', 'Cafe Central', 'conrad.nl', - 'coolblue', 'Shell', - 'DUO', 'Etos', 'FEBO', 'Greenchoice', 'Halfords', 'XS4All', 'iCentre', 'Jumper', 'Land lord']; - foreach ($expenses as $name) { - // create account: - Account::create( - [ - 'user_id' => $this->user->id, - 'account_type_id' => 4, - 'name' => $name, - 'active' => 1, - 'encrypted' => 1, - ] - ); - } - - } - - /** - * @param Carbon $date - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function createGroceries(Carbon $date) - { - $start = clone $date; - $end = clone $date; - $today = new Carbon; - $start->startOfMonth(); - $end->endOfMonth(); - - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $stores = ['Albert Heijn', 'PLUS', 'Bakker']; - $descriptions = ['Groceries', 'Bought some groceries', 'Got groceries']; - $category = Category::firstOrCreateEncrypted(['name' => 'Daily groceries', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $this->user->id]); - - $current = clone $start; - while ($current < $end && $current < $today) { - // daily groceries: - $amount = rand(1500, 2500) / 100; - $toAccount = TestData::findAccount($this->user, $stores[rand(0, count($stores) - 1)]); - - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => $descriptions[rand(0, count($descriptions) - 1)], - 'completed' => 1, - 'date' => $current, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - - $current->addDay(); - } - } - - - - /** - * @param $description - * @param Carbon $date - * @param $amount - * - * @return TransactionJournal - */ - protected function createPower($description, Carbon $date, $amount) - { - $date = new Carbon($date->format('Y-m') . '-06'); // paid on 10th - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $toAccount = TestData::findAccount($this->user, 'Greenchoice'); - $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $this->user->id]); - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => $description, - 'completed' => 1, - 'date' => $date, - ] - ); - if($journal->getErrors()->count() > 0) { - echo $journal->getErrors()->first(); - } - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - return $journal; - - } - - protected function createPreferences() - { - $preference = new Preference; - $preference->name = 'frontPageAccounts'; - $preference->data = [1]; - $preference->user()->associate($this->user); - $preference->save(); - } - - - /** - * - */ - protected function createRevenueAccounts() - { - $revenues = ['Job', 'Belastingdienst', 'Bank', 'KPN', 'Google']; - foreach ($revenues as $name) { - // create account: - Account::create( - [ - 'user_id' => $this->user->id, - 'account_type_id' => 5, - 'name' => $name, - 'active' => 1, - 'encrypted' => 1, - ] - ); - } - } - - /** - * @param Carbon $date - * - * @return TransactionJournal - */ - protected function createSavings(Carbon $date) - { - $date = new Carbon($date->format('Y-m') . '-24'); // paid on 24th. - $toAccount = TestData::findAccount($this->user, 'TestData Savings'); - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $category = Category::firstOrCreateEncrypted(['name' => 'Money management', 'user_id' => $this->user->id]); - // create journal: - - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 3, - 'transaction_currency_id' => 1, - 'description' => 'Save money', - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => -150, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 150, - - ] - ); - $journal->categories()->save($category); - - return $journal; - - } - - /** - * @param $description - * @param Carbon $date - * @param $amount - * - * @return TransactionJournal - */ - protected function createTV($description, Carbon $date, $amount) - { - $date = new Carbon($date->format('Y-m') . '-15'); // paid on 10th - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $toAccount = TestData::findAccount($this->user, 'XS4All'); - $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $this->user->id]); - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => $description, - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - return $journal; - - } - - /** - * - */ - protected function createUsers() - { - User::create(['email' => 'thegrumpydictator@gmail.com', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]); - $this->user = User::whereEmail('thegrumpydictator@gmail.com')->first(); - - // create rights: - $role = Role::find(1); - $this->user->roles()->save($role); - - } - - /** - * @param $description - * @param Carbon $date - * @param $amount - * - * @return TransactionJournal - */ - protected function createWater($description, Carbon $date, $amount) - { - $date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th - $fromAccount = TestData::findAccount($this->user, 'TestData Checking Account'); - $toAccount = TestData::findAccount($this->user, 'Vitens'); - $category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $this->user->id]); - $budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $this->user->id]); - $journal = TransactionJournal::create( - [ - 'user_id' => $this->user->id, - 'transaction_type_id' => 1, - 'transaction_currency_id' => 1, - 'description' => $description, - 'completed' => 1, - 'date' => $date, - ] - ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); - - return $journal; - - } - - /** - * @param $name - * - * @return Bill|null - */ - protected function findBill($name) - { - /** @var Bill $bill */ - foreach (Bill::get() as $bill) { - if ($bill->name == $name && $this->user->id == $bill->user_id) { - return $bill; - break; - } - } - - return null; - } - - /** - * @param $name - * - * @return Category|null - */ - protected function findCategory($name) - { - - /** @var Category $category */ - foreach (Category::get() as $category) { - if ($category->name == $name && $this->user->id == $category->user_id) { - return $category; - break; - } - } - - return null; - } - - /** - * @param $name - * - * @return PiggyBank|null - */ - protected function findPiggyBank($name) - { - - /** @var Budget $budget */ - foreach (PiggyBank::get() as $piggyBank) { - $account = $piggyBank->account()->first(); - if ($piggyBank->name == $name && $this->user->id == $account->user_id) { - return $piggyBank; - break; - } - } - - return null; - } - - /** - * @param $tagName - * - * @return Tag|null - * @internal param $tag - */ - protected function findTag($tagName) - { - /** @var Tag $tag */ - foreach (Tag::get() as $tag) { - if ($tag->tag == $tagName && $this->user->id == $tag->user_id) { - return $tag; - break; - } - } - - return null; - } - - /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - private function createRules() - { - // three rule groups to get started. - $ruleGroup = new RuleGroup; - $ruleGroup->user()->associate($this->user); - $ruleGroup->order = 1; - $ruleGroup->active = 1; - $ruleGroup->title = 'Default rules'; - $ruleGroup->description = 'All your rules not in a particular group.'; - $ruleGroup->save(); - unset($ruleGroup); - - $ruleGroup = new RuleGroup; - $ruleGroup->user()->associate($this->user); - $ruleGroup->order = 2; - $ruleGroup->active = 1; - $ruleGroup->title = 'Empty rule group'; - $ruleGroup->description = 'Intentionally has no rules.'; - $ruleGroup->save(); - unset($ruleGroup); - - - $ruleGroup = new RuleGroup; - $ruleGroup->user()->associate($this->user); - $ruleGroup->order = 3; - $ruleGroup->active = 1; - $ruleGroup->title = 'Rules for bills'; - $ruleGroup->description = 'All rules for bills and recurring costs.'; - $ruleGroup->save(); - unset($ruleGroup); - - // move groceries to correct budget/category - $rule = new Rule; - $rule->user()->associate($this->user); - $rule->ruleGroup()->associate(RuleGroup::find(1)); - $rule->order = 1; - $rule->active = 1; - $rule->stop_processing = 0; - $rule->title = 'Move groceries'; - $rule->description = 'Move groceries to correct category and budget.'; - - $rule->save(); - - // initial trigger for this rule: - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 1; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'user_action'; - $ruleTrigger->trigger_value = 'store-journal'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // content trigger for this rule. - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 2; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'description_contains'; - $ruleTrigger->trigger_value = 'groceries'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // another - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 3; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'from_account_is'; - $ruleTrigger->trigger_value = 'TestData Checking Account'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // actions for this rule. one, set category - $ruleAction = new RuleAction; - $ruleAction->rule()->associate($rule); - $ruleAction->order = 1; - $ruleAction->active = 1; - $ruleAction->stop_processing = 0; - $ruleAction->action_type = 'set_category'; - $ruleAction->action_value = 'Groceries'; - $ruleAction->save(); - unset($ruleAction); - - // actions for this rule. one, set budget - $ruleAction = new RuleAction; - $ruleAction->rule()->associate($rule); - $ruleAction->order = 2; - $ruleAction->active = 1; - $ruleAction->stop_processing = 0; - $ruleAction->action_type = 'set_budget'; - $ruleAction->action_value = 'Groceries'; - $ruleAction->save(); - unset($ruleAction); - - - // move "gas" to "Car" and "Car" - $rule = new Rule; - $rule->user()->associate($this->user); - $rule->ruleGroup()->associate(RuleGroup::find(1)); - $rule->order = 2; - $rule->active = 1; - $rule->stop_processing = 0; - $rule->title = 'Move gas'; - $rule->description = null; - - $rule->save(); - - // initial trigger for this rule: - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 1; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'user_action'; - $ruleTrigger->trigger_value = 'store-journal'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // content trigger for this rule. - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 2; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'description_contains'; - $ruleTrigger->trigger_value = 'gas'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // another - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 3; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'from_account_is'; - $ruleTrigger->trigger_value = 'TestData Checking Account'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // actions for this rule. one, set category - $ruleAction = new RuleAction; - $ruleAction->rule()->associate($rule); - $ruleAction->order = 1; - $ruleAction->active = 1; - $ruleAction->stop_processing = 0; - $ruleAction->action_type = 'set_category'; - $ruleAction->action_value = 'Car'; - $ruleAction->save(); - unset($ruleAction); - - // actions for this rule. one, set budget - $ruleAction = new RuleAction; - $ruleAction->rule()->associate($rule); - $ruleAction->order = 2; - $ruleAction->active = 1; - $ruleAction->stop_processing = 0; - $ruleAction->action_type = 'set_budget'; - $ruleAction->action_value = 'Car'; - $ruleAction->save(); - unset($ruleAction); - - // move savings to money management - $rule = new Rule; - $rule->user()->associate($this->user); - $rule->ruleGroup()->associate(RuleGroup::find(1)); - $rule->order = 3; - $rule->active = 1; - $rule->stop_processing = 0; - $rule->title = 'Move savings'; - $rule->description = null; - - $rule->save(); - - // initial trigger for this rule: - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 1; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'user_action'; - $ruleTrigger->trigger_value = 'store-journal'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // is transfer - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 2; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'transaction_type'; - $ruleTrigger->trigger_value = 'Transfer'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // content trigger for this rule. - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 3; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'description_is'; - $ruleTrigger->trigger_value = 'Save money'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // another - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 4; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'from_account_is'; - $ruleTrigger->trigger_value = 'TestData Checking Account'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // another - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 5; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'to_account_is'; - $ruleTrigger->trigger_value = 'TestData Savings'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // actions for this rule. one, set category - $ruleAction = new RuleAction; - $ruleAction->rule()->associate($rule); - $ruleAction->order = 1; - $ruleAction->active = 1; - $ruleAction->stop_processing = 0; - $ruleAction->action_type = 'set_category'; - $ruleAction->action_value = 'Money Management'; - $ruleAction->save(); - unset($ruleAction); - - // move TV bill to "Bills" and "House" - $rule = new Rule; - $rule->user()->associate($this->user); - $rule->ruleGroup()->associate(RuleGroup::find(3)); - $rule->order = 1; - $rule->active = 1; - $rule->stop_processing = 0; - $rule->title = 'TV Bill'; - $rule->description = null; - - $rule->save(); - - // initial trigger for this rule: - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 1; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'user_action'; - $ruleTrigger->trigger_value = 'store-journal'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // content trigger for this rule. - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 2; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'description_contains'; - $ruleTrigger->trigger_value = 'tv bill'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // another - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 3; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'from_account_is'; - $ruleTrigger->trigger_value = 'TestData Checking Account'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // actions for this rule. one, set category - $ruleAction = new RuleAction; - $ruleAction->rule()->associate($rule); - $ruleAction->order = 1; - $ruleAction->active = 1; - $ruleAction->stop_processing = 0; - $ruleAction->action_type = 'set_category'; - $ruleAction->action_value = 'House'; - $ruleAction->save(); - unset($ruleAction); - - // actions for this rule. one, set budget - $ruleAction = new RuleAction; - $ruleAction->rule()->associate($rule); - $ruleAction->order = 2; - $ruleAction->active = 1; - $ruleAction->stop_processing = 0; - $ruleAction->action_type = 'set_budget'; - $ruleAction->action_value = 'Bills'; - $ruleAction->save(); - unset($ruleAction); - - // move rent to bills, rent. - $rule = new Rule; - $rule->user()->associate($this->user); - $rule->ruleGroup()->associate(RuleGroup::find(3)); - $rule->order = 2; - $rule->active = 1; - $rule->stop_processing = 1; - $rule->title = 'Rent'; - $rule->description = 'Do something with rent.'; - - $rule->save(); - - // initial trigger for this rule: - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 1; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'user_action'; - $ruleTrigger->trigger_value = 'update-journal'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // content trigger for this rule. - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 2; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 0; - $ruleTrigger->trigger_type = 'description_contains'; - $ruleTrigger->trigger_value = 'rent'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // another - $ruleTrigger = new RuleTrigger; - $ruleTrigger->rule()->associate($rule); - $ruleTrigger->order = 3; - $ruleTrigger->active = 1; - $ruleTrigger->stop_processing = 1; - $ruleTrigger->trigger_type = 'from_account_is'; - $ruleTrigger->trigger_value = 'TestData Checking Account'; - - $ruleTrigger->save(); - unset($ruleTrigger); - - // actions for this rule. one, set category - $ruleAction = new RuleAction; - $ruleAction->rule()->associate($rule); - $ruleAction->order = 1; - $ruleAction->active = 1; - $ruleAction->stop_processing = 0; - $ruleAction->action_type = 'set_category'; - $ruleAction->action_value = 'House'; - $ruleAction->save(); - unset($ruleAction); - - // actions for this rule. one, set budget - $ruleAction = new RuleAction; - $ruleAction->rule()->associate($rule); - $ruleAction->order = 2; - $ruleAction->active = 1; - $ruleAction->stop_processing = 1; - $ruleAction->action_type = 'set_budget'; - $ruleAction->action_value = 'Bills'; - $ruleAction->save(); - unset($ruleAction); - } - - -} From f5b89ca7837282a7ee8674daf9da3f109d47d5e1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 15:41:40 +0100 Subject: [PATCH 050/448] Some code cleanup. --- app/Export/Collector/AttachmentCollector.php | 3 ++ app/Export/Collector/BasicCollector.php | 2 ++ app/Export/ConfigurationFile.php | 5 +++ app/Export/Exporter/BasicExporter.php | 2 ++ app/Export/Exporter/CsvExporter.php | 2 ++ .../Budget/ChartJsBudgetChartGenerator.php | 4 +-- .../Events/ConnectJournalToPiggyBank.php | 2 +- app/Http/Controllers/AccountController.php | 2 ++ app/Http/Controllers/BudgetController.php | 34 ++++++++++++------- app/Http/Controllers/CategoryController.php | 4 ++- app/Http/Controllers/ExportController.php | 9 ++++- app/Http/Controllers/HomeController.php | 6 ++-- app/Http/Controllers/JsonController.php | 2 +- app/Http/Controllers/PiggyBankController.php | 2 ++ app/Http/Controllers/ReportController.php | 1 + app/Repositories/Budget/BudgetRepository.php | 4 +-- .../Budget/BudgetRepositoryInterface.php | 4 +-- app/Support/Amount.php | 6 ++-- app/Support/Migration/TestData.php | 9 +++-- app/Support/Steam.php | 2 +- ...2014_07_09_204843_create_session_table.php | 7 ++-- .../Controllers/AccountControllerTest.php | 12 +++++-- .../Controllers/BillControllerTest.php | 12 +++++-- .../Controllers/BudgetControllerTest.php | 26 ++++++++++---- .../Controllers/CategoryControllerTest.php | 17 +++++++--- .../Controllers/CurrencyControllerTest.php | 4 ++- .../Controllers/HomeControllerTest.php | 6 ++-- .../Controllers/JsonControllerTest.php | 24 +++++++++---- .../Controllers/PiggyBankControllerTest.php | 6 ++++ .../Controllers/PreferencesControllerTest.php | 4 ++- .../Controllers/ReportControllerTest.php | 24 ++++++++----- .../Controllers/TransactionControllerTest.php | 8 +++-- 32 files changed, 183 insertions(+), 72 deletions(-) diff --git a/app/Export/Collector/AttachmentCollector.php b/app/Export/Collector/AttachmentCollector.php index 0e9f419870..0caa41be07 100644 --- a/app/Export/Collector/AttachmentCollector.php +++ b/app/Export/Collector/AttachmentCollector.php @@ -33,6 +33,9 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface parent::__construct($job); } + /** + * + */ public function run() { // grab all the users attachments: diff --git a/app/Export/Collector/BasicCollector.php b/app/Export/Collector/BasicCollector.php index 5450608a6e..db91b161e4 100644 --- a/app/Export/Collector/BasicCollector.php +++ b/app/Export/Collector/BasicCollector.php @@ -29,6 +29,8 @@ class BasicCollector /** * BasicCollector constructor. + * + * @param ExportJob $job */ public function __construct(ExportJob $job) { diff --git a/app/Export/ConfigurationFile.php b/app/Export/ConfigurationFile.php index 2ac9d6d216..56507a7239 100644 --- a/app/Export/ConfigurationFile.php +++ b/app/Export/ConfigurationFile.php @@ -22,6 +22,11 @@ class ConfigurationFile /** @var ExportJob */ private $job; + /** + * ConfigurationFile constructor. + * + * @param ExportJob $job + */ public function __construct(ExportJob $job) { $this->job = $job; diff --git a/app/Export/Exporter/BasicExporter.php b/app/Export/Exporter/BasicExporter.php index d74550abd9..b48185e087 100644 --- a/app/Export/Exporter/BasicExporter.php +++ b/app/Export/Exporter/BasicExporter.php @@ -28,6 +28,8 @@ class BasicExporter /** * BasicExporter constructor. + * + * @param ExportJob $job */ public function __construct(ExportJob $job) { diff --git a/app/Export/Exporter/CsvExporter.php b/app/Export/Exporter/CsvExporter.php index 48c4f3130b..94dd3c5597 100644 --- a/app/Export/Exporter/CsvExporter.php +++ b/app/Export/Exporter/CsvExporter.php @@ -30,6 +30,8 @@ class CsvExporter extends BasicExporter implements ExporterInterface /** * CsvExporter constructor. + * + * @param ExportJob $job */ public function __construct(ExportJob $job) { diff --git a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php index 568d0c54f7..0bbce5b50b 100644 --- a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php +++ b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php @@ -85,8 +85,8 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface foreach ($filtered as $entry) { $data['labels'][] = $entry[0]; $left[] = round($entry[1], 2); - $spent[] = round(bcmul($entry[2],'-1'), 2); // spent is coming in negative, must be positive - $overspent[] = round(bcmul($entry[3],'-1'), 2); // same + $spent[] = round(bcmul($entry[2], '-1'), 2); // spent is coming in negative, must be positive + $overspent[] = round(bcmul($entry[3], '-1'), 2); // same } $data['datasets'][] = [ diff --git a/app/Handlers/Events/ConnectJournalToPiggyBank.php b/app/Handlers/Events/ConnectJournalToPiggyBank.php index b62a9c2b10..83da596d09 100644 --- a/app/Handlers/Events/ConnectJournalToPiggyBank.php +++ b/app/Handlers/Events/ConnectJournalToPiggyBank.php @@ -58,7 +58,7 @@ class ConnectJournalToPiggyBank $amount = $journal->amount_positive; // if piggy account matches source account, the amount is positive if ($piggyBank->account_id == $journal->source_account->id) { - $amount = bcmul($amount,'-1'); + $amount = bcmul($amount, '-1'); } diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 6dfe30c0d8..413c2992c2 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -154,7 +154,9 @@ class AccountController extends Controller $subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what); $types = Config::get('firefly.accountTypesByIdentifier.' . $what); $accounts = $repository->getAccounts($types); + /** @var Carbon $start */ $start = clone session('start', Carbon::now()->startOfMonth()); + /** @var Carbon $end */ $end = clone session('end', Carbon::now()->endOfMonth()); $start->subDay(); diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 33801802e6..dbbbd7c969 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -44,7 +44,8 @@ class BudgetController extends Controller */ public function amount(BudgetRepositoryInterface $repository, Budget $budget) { - $amount = intval(Input::get('amount')); + $amount = intval(Input::get('amount')); + /** @var Carbon $date */ $date = session('start', Carbon::now()->startOfMonth()); $limitRepetition = $repository->updateLimitAmount($budget, $date, $amount); if ($amount == 0) { @@ -140,12 +141,14 @@ class BudgetController extends Controller */ public function index(BudgetRepositoryInterface $repository, ARI $accountRepository) { - $budgets = $repository->getActiveBudgets(); - $inactive = $repository->getInactiveBudgets(); - $spent = '0'; - $budgeted = '0'; - $range = Preferences::get('viewRange', '1M')->data; - $start = Navigation::startOfPeriod(session('start', new Carbon), $range); + $budgets = $repository->getActiveBudgets(); + $inactive = $repository->getInactiveBudgets(); + $spent = '0'; + $budgeted = '0'; + $range = Preferences::get('viewRange', '1M')->data; + /** @var Carbon $date */ + $date = session('start', new Carbon); + $start = Navigation::startOfPeriod($date, $range); $end = Navigation::endOfPeriod($start, $range); $key = 'budgetIncomeTotal' . $start->format('Ymd') . $end->format('Ymd'); $budgetIncomeTotal = Preferences::get($key, 1000)->data; @@ -186,8 +189,10 @@ class BudgetController extends Controller */ public function noBudget(BudgetRepositoryInterface $repository) { - $range = Preferences::get('viewRange', '1M')->data; - $start = Navigation::startOfPeriod(session('start', new Carbon), $range); + $range = Preferences::get('viewRange', '1M')->data; + /** @var Carbon $date */ + $date = session('start', new Carbon); + $start = Navigation::startOfPeriod($date, $range); $end = Navigation::endOfPeriod($start, $range); $list = $repository->getWithoutBudget($start, $end); $subTitle = trans( @@ -204,7 +209,9 @@ class BudgetController extends Controller public function postUpdateIncome() { $range = Preferences::get('viewRange', '1M')->data; - $start = Navigation::startOfPeriod(session('start', new Carbon), $range); + /** @var Carbon $date */ + $date = session('start', new Carbon); + $start = Navigation::startOfPeriod($date, $range); $end = Navigation::endOfPeriod($start, $range); $key = 'budgetIncomeTotal' . $start->format('Ymd') . $end->format('Ymd'); @@ -322,8 +329,11 @@ class BudgetController extends Controller */ public function updateIncome() { - $range = Preferences::get('viewRange', '1M')->data; - $start = Navigation::startOfPeriod(session('start', new Carbon), $range); + $range = Preferences::get('viewRange', '1M')->data; + + /** @var Carbon $date */ + $date = session('start', new Carbon); + $start = Navigation::startOfPeriod($date, $range); $end = Navigation::endOfPeriod($start, $range); $key = 'budgetIncomeTotal' . $start->format('Ymd') . $end->format('Ymd'); $amount = Preferences::get($key, 1000); diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index c2e4bf1b32..f7239b898b 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -133,7 +133,9 @@ class CategoryController extends Controller */ public function noCategory(CRI $repository) { - $start = session('start', Carbon::now()->startOfMonth()); + /** @var Carbon $start */ + $start = session('start', Carbon::now()->startOfMonth()); + /** @var Carbon $end */ $end = session('end', Carbon::now()->startOfMonth()); $list = $repository->listNoCategory($start, $end); $subTitle = trans( diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index c898c05ab6..0396c98a63 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -66,6 +66,8 @@ class ExportController extends Controller } /** + * @param ExportJob $job + * * @return \Illuminate\Http\JsonResponse */ public function getStatus(ExportJob $job) @@ -74,7 +76,9 @@ class ExportController extends Controller } /** - * @param ARI $repository + * @param ARI $repository + * + * @param EJRI $jobs * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ @@ -100,7 +104,10 @@ class ExportController extends Controller * @param ExportFormRequest $request * @param ARI $repository * + * @param EJRI $jobs + * * @return string + * @throws \FireflyIII\Exceptions\FireflyException */ public function postIndex(ExportFormRequest $request, ARI $repository, EJRI $jobs) { diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index d4ada04d04..2f605947fe 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -90,7 +90,9 @@ class HomeController extends Controller $mainTitleIcon = 'fa-fire'; $transactions = []; $frontPage = Preferences::get('frontPageAccounts', []); + /** @var Carbon $start */ $start = session('start', Carbon::now()->startOfMonth()); + /** @var Carbon $end */ $end = session('end', Carbon::now()->endOfMonth()); $showTour = Preferences::get('tour', true)->data; $accounts = $repository->getFrontpageAccounts($frontPage); @@ -105,11 +107,11 @@ class HomeController extends Controller $sum = $repository->sumOfEverything(); - if ($sum != 0) { + if (bccomp($sum, '0') !== 0) { Session::flash( 'error', 'Your transactions are unbalanced. This means a' . ' withdrawal, deposit or transfer was not stored properly. ' - . 'Please check your accounts and transactions for errors.' + . 'Please check your accounts and transactions for errors (' . $sum . ').' ); } diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index 85b6948c8e..78fbc0ec4f 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -66,7 +66,7 @@ class JsonController extends Controller if ($creditCardDue >= 0) { $amount = bcadd($amount, $creditCardDue); } - $amount = bcmul($amount,'-1'); + $amount = bcmul($amount, '-1'); $data = ['box' => 'bills-paid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]; diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index ca03321887..a7ea7c006e 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -48,6 +48,7 @@ class PiggyBankController extends Controller public function add(ARI $repository, PiggyBank $piggyBank) { bcscale(2); + /** @var Carbon $date */ $date = session('end', Carbon::now()->endOfMonth()); $leftOnAccount = $repository->leftOnAccount($piggyBank->account, $date); $savedSoFar = $piggyBank->currentRelevantRep()->currentamount; @@ -229,6 +230,7 @@ class PiggyBankController extends Controller { bcscale(2); $amount = round(Input::get('amount'), 2); + /** @var Carbon $date */ $date = session('end', Carbon::now()->endOfMonth()); $leftOnAccount = $accounts->leftOnAccount($piggyBank->account, $date); $savedSoFar = $piggyBank->currentRelevantRep()->currentamount; diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 3cab30df27..6d1d4ba807 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -52,6 +52,7 @@ class ReportController extends Controller */ public function index(ARI $repository) { + /** @var Carbon $start */ $start = session('first'); $months = $this->helper->listOfMonths($start); $customFiscalYear = Preferences::get('customFiscalYear', 0)->data; diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index c148fbcceb..81996edb6d 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -696,11 +696,11 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn /** * @param Budget $budget * @param Carbon $date - * @param $amount + * @param int $amount * * @return BudgetLimit */ - public function updateLimitAmount(Budget $budget, Carbon $date, $amount) + public function updateLimitAmount(Budget $budget, Carbon $date, int $amount) { // there should be a budget limit for this startdate: /** @var BudgetLimit $limit */ diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php index 80d07ceb2e..c9d4826e46 100644 --- a/app/Repositories/Budget/BudgetRepositoryInterface.php +++ b/app/Repositories/Budget/BudgetRepositoryInterface.php @@ -253,10 +253,10 @@ interface BudgetRepositoryInterface /** * @param Budget $budget * @param Carbon $date - * @param $amount + * @param int $amount * * @return mixed */ - public function updateLimitAmount(Budget $budget, Carbon $date, $amount); + public function updateLimitAmount(Budget $budget, Carbon $date, int $amount); } diff --git a/app/Support/Amount.php b/app/Support/Amount.php index 66657f0b0c..b4f1df5a4d 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -111,9 +111,9 @@ class Amount } /** - * @param string $symbol - * @param float $amount - * @param bool $coloured + * @param string $symbol + * @param float|string $amount + * @param bool $coloured * * @return string */ diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php index 7a8548faed..944a30df36 100644 --- a/app/Support/Migration/TestData.php +++ b/app/Support/Migration/TestData.php @@ -323,6 +323,7 @@ class TestData } /** + * @param User $user * @param Carbon $date * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ @@ -651,9 +652,10 @@ class TestData } /** - * @param $description + * @param User $user + * @param string $description * @param Carbon $date - * @param $amount + * @param string $amount * * @return TransactionJournal */ @@ -848,6 +850,7 @@ class TestData } /** + * @param User $user * @param Carbon $date * * @return TransactionJournal @@ -985,7 +988,7 @@ class TestData * @param Carbon $date * @param string $amount * - * @return static + * @return TransactionJournal|static */ public static function createWater(User $user, string $description, Carbon $date, string $amount): TransactionJournal { diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 3592c1cd88..bbbbc49652 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -184,7 +184,7 @@ class Steam if (!(strpos($string, 'm') === false)) { // has a M in it, remove the M and multiply by 1048576. - $bytes = bcmul(rtrim($string, 'm'),'1048576'); + $bytes = bcmul(rtrim($string, 'm'), '1048576'); return intval($bytes); } diff --git a/database/migrations/2014_07_09_204843_create_session_table.php b/database/migrations/2014_07_09_204843_create_session_table.php index 66842aa574..a5ddae291f 100644 --- a/database/migrations/2014_07_09_204843_create_session_table.php +++ b/database/migrations/2014_07_09_204843_create_session_table.php @@ -1,7 +1,6 @@ string('id')->unique(); $table->integer('user_id')->nullable(); $table->string('ip_address', 45)->nullable(); $table->text('user_agent')->nullable(); $table->text('payload'); $table->integer('last_activity'); - }); + } + ); } } diff --git a/tests/acceptance/Controllers/AccountControllerTest.php b/tests/acceptance/Controllers/AccountControllerTest.php index 275b82b380..15e326bc4d 100644 --- a/tests/acceptance/Controllers/AccountControllerTest.php +++ b/tests/acceptance/Controllers/AccountControllerTest.php @@ -16,6 +16,8 @@ class AccountControllerTest extends TestCase * @covers FireflyIII\Http\Controllers\AccountController::create * @covers FireflyIII\Http\Controllers\AccountController::__construct * @dataProvider dateRangeProvider + * + * @param $range */ public function testCreate($range) { @@ -58,9 +60,11 @@ class AccountControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\AccountController::index - * @covers FireflyIII\Http\Controllers\AccountController::isInArray + * @covers FireflyIII\Http\Controllers\AccountController::index + * @covers FireflyIII\Http\Controllers\AccountController::isInArray * @dataProvider dateRangeProvider + * + * @param $range */ public function testIndex($range) { @@ -71,8 +75,10 @@ class AccountControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\AccountController::show + * @covers FireflyIII\Http\Controllers\AccountController::show * @dataProvider dateRangeProvider + * + * @param $range */ public function testShow($range) { diff --git a/tests/acceptance/Controllers/BillControllerTest.php b/tests/acceptance/Controllers/BillControllerTest.php index 327b740c11..023cb3eb05 100644 --- a/tests/acceptance/Controllers/BillControllerTest.php +++ b/tests/acceptance/Controllers/BillControllerTest.php @@ -58,8 +58,10 @@ class BillControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\BillController::index + * @covers FireflyIII\Http\Controllers\BillController::index * @dataProvider dateRangeProvider + * + * @param $range */ public function testIndex($range) { @@ -70,8 +72,10 @@ class BillControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\BillController::rescan + * @covers FireflyIII\Http\Controllers\BillController::rescan * @dataProvider dateRangeProvider + * + * @param $range */ public function testRescan($range) { @@ -83,8 +87,10 @@ class BillControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\BillController::show + * @covers FireflyIII\Http\Controllers\BillController::show * @dataProvider dateRangeProvider + * + * @param $range */ public function testShow($range) { diff --git a/tests/acceptance/Controllers/BudgetControllerTest.php b/tests/acceptance/Controllers/BudgetControllerTest.php index 59c05c094a..1462eeaf21 100644 --- a/tests/acceptance/Controllers/BudgetControllerTest.php +++ b/tests/acceptance/Controllers/BudgetControllerTest.php @@ -14,9 +14,11 @@ class BudgetControllerTest extends TestCase { /** - * @covers FireflyIII\Http\Controllers\BudgetController::amount - * @covers FireflyIII\Http\Controllers\BudgetController::__construct + * @covers FireflyIII\Http\Controllers\BudgetController::amount + * @covers FireflyIII\Http\Controllers\BudgetController::__construct * @dataProvider dateRangeProvider + * + * @param $range */ public function testAmount($range) { @@ -74,8 +76,10 @@ class BudgetControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\BudgetController::index + * @covers FireflyIII\Http\Controllers\BudgetController::index * @dataProvider dateRangeProvider + * + * @param $range */ public function testIndex($range) { @@ -86,8 +90,10 @@ class BudgetControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\BudgetController::noBudget + * @covers FireflyIII\Http\Controllers\BudgetController::noBudget * @dataProvider dateRangeProvider + * + * @param $range */ public function testNoBudget($range) { @@ -98,8 +104,10 @@ class BudgetControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\BudgetController::postUpdateIncome + * @covers FireflyIII\Http\Controllers\BudgetController::postUpdateIncome * @dataProvider dateRangeProvider + * + * @param $range */ public function testPostUpdateIncome($range) { @@ -114,8 +122,10 @@ class BudgetControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\BudgetController::show + * @covers FireflyIII\Http\Controllers\BudgetController::show * @dataProvider dateRangeProvider + * + * @param $range */ public function testShow($range) { @@ -163,8 +173,10 @@ class BudgetControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\BudgetController::updateIncome + * @covers FireflyIII\Http\Controllers\BudgetController::updateIncome * @dataProvider dateRangeProvider + * + * @param $range */ public function testUpdateIncome($range) { diff --git a/tests/acceptance/Controllers/CategoryControllerTest.php b/tests/acceptance/Controllers/CategoryControllerTest.php index 89fb3b26f1..66e6074c8f 100644 --- a/tests/acceptance/Controllers/CategoryControllerTest.php +++ b/tests/acceptance/Controllers/CategoryControllerTest.php @@ -60,9 +60,10 @@ class CategoryControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\CategoryController::index + * @covers FireflyIII\Http\Controllers\CategoryController::index * @dataProvider dateRangeProvider * + * @param $range */ public function testIndex($range) { @@ -73,8 +74,10 @@ class CategoryControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\CategoryController::noCategory + * @covers FireflyIII\Http\Controllers\CategoryController::noCategory * @dataProvider dateRangeProvider + * + * @param $range */ public function testNoCategory($range) { @@ -85,9 +88,11 @@ class CategoryControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\CategoryController::show - * @covers FireflyIII\Http\Controllers\Controller::getSumOfRange + * @covers FireflyIII\Http\Controllers\CategoryController::show + * @covers FireflyIII\Http\Controllers\Controller::getSumOfRange * @dataProvider dateRangeProvider + * + * @param $range */ public function testShow($range) { @@ -99,8 +104,10 @@ class CategoryControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\CategoryController::showWithDate + * @covers FireflyIII\Http\Controllers\CategoryController::showWithDate * @dataProvider dateRangeProvider + * + * @param $range */ public function testShowWithDate($range) { diff --git a/tests/acceptance/Controllers/CurrencyControllerTest.php b/tests/acceptance/Controllers/CurrencyControllerTest.php index 0031752c95..32f620e79c 100644 --- a/tests/acceptance/Controllers/CurrencyControllerTest.php +++ b/tests/acceptance/Controllers/CurrencyControllerTest.php @@ -72,8 +72,10 @@ class CurrencyControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\CurrencyController::index + * @covers FireflyIII\Http\Controllers\CurrencyController::index * @dataProvider dateRangeProvider + * + * @param $range */ public function testIndex($range) { diff --git a/tests/acceptance/Controllers/HomeControllerTest.php b/tests/acceptance/Controllers/HomeControllerTest.php index b60e754882..e3a5df16af 100644 --- a/tests/acceptance/Controllers/HomeControllerTest.php +++ b/tests/acceptance/Controllers/HomeControllerTest.php @@ -40,9 +40,11 @@ class HomeControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\HomeController::index - * @covers FireflyIII\Http\Controllers\Controller::__construct + * @covers FireflyIII\Http\Controllers\HomeController::index + * @covers FireflyIII\Http\Controllers\Controller::__construct * @dataProvider dateRangeProvider + * + * @param $range */ public function testIndex($range) { diff --git a/tests/acceptance/Controllers/JsonControllerTest.php b/tests/acceptance/Controllers/JsonControllerTest.php index 9ca2ee8c4c..f4b1dfb988 100644 --- a/tests/acceptance/Controllers/JsonControllerTest.php +++ b/tests/acceptance/Controllers/JsonControllerTest.php @@ -27,8 +27,10 @@ class JsonControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\JsonController::boxBillsPaid + * @covers FireflyIII\Http\Controllers\JsonController::boxBillsPaid * @dataProvider dateRangeProvider + * + * @param $range */ public function testBoxBillsPaid($range) { @@ -39,8 +41,10 @@ class JsonControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\JsonController::boxBillsUnpaid + * @covers FireflyIII\Http\Controllers\JsonController::boxBillsUnpaid * @dataProvider dateRangeProvider + * + * @param $range */ public function testBoxBillsUnpaid($range) { @@ -51,8 +55,10 @@ class JsonControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\JsonController::boxIn + * @covers FireflyIII\Http\Controllers\JsonController::boxIn * @dataProvider dateRangeProvider + * + * @param $range */ public function testBoxIn($range) { @@ -63,8 +69,10 @@ class JsonControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\JsonController::boxOut + * @covers FireflyIII\Http\Controllers\JsonController::boxOut * @dataProvider dateRangeProvider + * + * @param $range */ public function testBoxOut($range) { @@ -75,8 +83,10 @@ class JsonControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\JsonController::categories + * @covers FireflyIII\Http\Controllers\JsonController::categories * @dataProvider dateRangeProvider + * + * @param $range */ public function testCategories($range) { @@ -138,8 +148,10 @@ class JsonControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\JsonController::transactionJournals + * @covers FireflyIII\Http\Controllers\JsonController::transactionJournals * @dataProvider dateRangeProvider + * + * @param $range */ public function testTransactionJournals($range) { diff --git a/tests/acceptance/Controllers/PiggyBankControllerTest.php b/tests/acceptance/Controllers/PiggyBankControllerTest.php index b7be9a49fc..829ef8a3f4 100644 --- a/tests/acceptance/Controllers/PiggyBankControllerTest.php +++ b/tests/acceptance/Controllers/PiggyBankControllerTest.php @@ -17,6 +17,8 @@ class PiggyBankControllerTest extends TestCase * @covers FireflyIII\Http\Controllers\PiggyBankController::add * @covers FireflyIII\Http\Controllers\PiggyBankController::__construct * @dataProvider dateRangeProvider + * + * @param $range */ public function testAdd($range) { @@ -71,6 +73,8 @@ class PiggyBankControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PiggyBankController::index * @dataProvider dateRangeProvider + * + * @param $range */ public function testIndex($range) { @@ -138,6 +142,8 @@ class PiggyBankControllerTest extends TestCase /** * @covers FireflyIII\Http\Controllers\PiggyBankController::show * @dataProvider dateRangeProvider + * + * @param $range */ public function testShow($range) { diff --git a/tests/acceptance/Controllers/PreferencesControllerTest.php b/tests/acceptance/Controllers/PreferencesControllerTest.php index 75f6312107..ecfdc9a9a5 100644 --- a/tests/acceptance/Controllers/PreferencesControllerTest.php +++ b/tests/acceptance/Controllers/PreferencesControllerTest.php @@ -26,8 +26,10 @@ class PreferencesControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\PreferencesController::postIndex + * @covers FireflyIII\Http\Controllers\PreferencesController::postIndex * @dataProvider dateRangeProvider + * + * @param $range */ public function testPostIndex($range) { diff --git a/tests/acceptance/Controllers/ReportControllerTest.php b/tests/acceptance/Controllers/ReportControllerTest.php index 23a3d6a328..72bc946c06 100644 --- a/tests/acceptance/Controllers/ReportControllerTest.php +++ b/tests/acceptance/Controllers/ReportControllerTest.php @@ -19,8 +19,10 @@ class ReportControllerTest extends TestCase { /** - * @covers FireflyIII\Http\Controllers\ReportController::index + * @covers FireflyIII\Http\Controllers\ReportController::index * @dataProvider dateRangeProvider + * + * @param $range */ public function testIndex($range) { @@ -32,10 +34,12 @@ class ReportControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\ReportController::__construct - * @covers FireflyIII\Http\Controllers\ReportController::report - * @covers FireflyIII\Http\Controllers\ReportController::defaultMonth + * @covers FireflyIII\Http\Controllers\ReportController::__construct + * @covers FireflyIII\Http\Controllers\ReportController::report + * @covers FireflyIII\Http\Controllers\ReportController::defaultMonth * @dataProvider dateRangeProvider + * + * @param $range */ public function testReportDefaultMonth($range) { @@ -54,9 +58,11 @@ class ReportControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\ReportController::report - * @covers FireflyIII\Http\Controllers\ReportController::defaultYear + * @covers FireflyIII\Http\Controllers\ReportController::report + * @covers FireflyIII\Http\Controllers\ReportController::defaultYear * @dataProvider dateRangeProvider + * + * @param $range */ public function testReportDefaultYear($range) { @@ -67,9 +73,11 @@ class ReportControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\ReportController::report - * @covers FireflyIII\Http\Controllers\ReportController::defaultMultiYear + * @covers FireflyIII\Http\Controllers\ReportController::report + * @covers FireflyIII\Http\Controllers\ReportController::defaultMultiYear * @dataProvider dateRangeProvider + * + * @param $range */ public function testReportDefaultMultiYear($range) { diff --git a/tests/acceptance/Controllers/TransactionControllerTest.php b/tests/acceptance/Controllers/TransactionControllerTest.php index 3cf1687722..2b3e21ca51 100644 --- a/tests/acceptance/Controllers/TransactionControllerTest.php +++ b/tests/acceptance/Controllers/TransactionControllerTest.php @@ -59,8 +59,10 @@ class TransactionControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\TransactionController::index + * @covers FireflyIII\Http\Controllers\TransactionController::index * @dataProvider dateRangeProvider + * + * @param $range */ public function testIndex($range) { @@ -85,8 +87,10 @@ class TransactionControllerTest extends TestCase } /** - * @covers FireflyIII\Http\Controllers\TransactionController::show + * @covers FireflyIII\Http\Controllers\TransactionController::show * @dataProvider dateRangeProvider + * + * @param $range */ public function testShow($range) { From ba5db2c15f589ffc6006e87b19c3de7b964d1c5c Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 17:29:51 +0100 Subject: [PATCH 051/448] Fixed test data. --- app/Support/Migration/TestData.php | 245 ++++++----------------------- app/Support/Steam.php | 6 +- 2 files changed, 52 insertions(+), 199 deletions(-) diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php index 944a30df36..780bcf558b 100644 --- a/app/Support/Migration/TestData.php +++ b/app/Support/Migration/TestData.php @@ -97,22 +97,7 @@ class TestData 'date' => $start->format('Y-m-d'), ] ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => '-100', - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 100, - - ] - ); + self::createTransactions($journal, $fromAccount, $toAccount, '100'); // and now attachments $encrypted = Crypt::encrypt('I are secret'); @@ -257,22 +242,8 @@ class TestData 'date' => $date, ] ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => bcmul($amount, '-1'), + self::createTransactions($journal, $fromAccount, $toAccount, $amount); - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); $journal->categories()->save($category); $journal->budgets()->save($budget); @@ -291,22 +262,7 @@ class TestData 'date' => $date, ] ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); + self::createTransactions($journal, $fromAccount, $toAccount, '100'); // and again! @@ -355,22 +311,8 @@ class TestData 'date' => $thisDate, ] ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => bcmul($amount, '-1'), + self::createTransactions($journal, $fromAccount, $toAccount, $amount); - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); $journal->categories()->save($category); $journal->budgets()->save($budget); @@ -411,6 +353,7 @@ class TestData */ public static function createGroceries(User $user, Carbon $date) { + bcscale(2); $start = clone $date; $end = clone $date; $today = new Carbon; @@ -426,7 +369,6 @@ class TestData $current = clone $start; while ($current < $end && $current < $today) { // daily groceries: - $amount = rand(1500, 2500) / 100; $toAccount = TestData::findAccount($user, $stores[rand(0, count($stores) - 1)]); $journal = TransactionJournal::create( @@ -439,24 +381,15 @@ class TestData 'date' => $current, ] ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount * -1, + if ($journal->id) { + $number = (string)round((rand(1500, 2500) / 100), 2); + $amount = $number;//'10';//strval((rand(1500, 2500) / 100)); + self::createTransactions($journal, $fromAccount, $toAccount, $amount); + $journal->categories()->save($category); + $journal->budgets()->save($budget); + } - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - ] - ); - $journal->categories()->save($category); - $journal->budgets()->save($budget); $current->addDay(); } } @@ -491,22 +424,7 @@ class TestData 'date' => $date, ] ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => bcmul($amount, '-1'), - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); + self::createTransactions($journal, $fromAccount, $toAccount, $amount); $journal->categories()->save($category); return $journal; @@ -676,25 +594,7 @@ class TestData 'date' => $date, ] ); - if ($journal->getErrors()->count() > 0) { - echo $journal->getErrors()->first(); - } - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => bcmul($amount, '-1'), - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); + self::createTransactions($journal, $fromAccount, $toAccount, $amount); $journal->categories()->save($category); $journal->budgets()->save($budget); @@ -727,22 +627,8 @@ class TestData 'date' => $date, ] ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => bcmul($amount, '-1'), + self::createTransactions($journal, $fromAccount, $toAccount, $amount); - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); $journal->categories()->save($category); $journal->budgets()->save($budget); @@ -873,22 +759,7 @@ class TestData 'date' => $date, ] ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => -150, - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 150, - - ] - ); + self::createTransactions($journal, $fromAccount, $toAccount, '150'); $journal->categories()->save($category); return $journal; @@ -920,22 +791,8 @@ class TestData 'date' => $date, ] ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => bcmul($amount, '-1'), + self::createTransactions($journal, $fromAccount, $toAccount, $amount); - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); $journal->categories()->save($category); $journal->budgets()->save($budget); @@ -966,6 +823,34 @@ class TestData ); } + /** + * @param TransactionJournal $journal + * @param Account $from + * @param Account $to + * @param string $amount + */ + public static function createTransactions(TransactionJournal $journal, Account $from, Account $to, string $amount) + { + Log::debug('---- Transaction From: ' . bcmul($amount, '-1')); + Log::debug('---- Transaction To : ' . $amount); + Transaction::create( + [ + 'account_id' => $from->id, + 'transaction_journal_id' => $journal->id, + 'amount' => bcmul($amount, '-1'), + + ] + ); + Transaction::create( + [ + 'account_id' => $to->id, + 'transaction_journal_id' => $journal->id, + 'amount' => $amount, + + ] + ); + } + /** * @return User */ @@ -1007,22 +892,7 @@ class TestData 'date' => $date, ] ); - Transaction::create( - [ - 'account_id' => $fromAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => bcmul($amount, '-1'), - - ] - ); - Transaction::create( - [ - 'account_id' => $toAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $amount, - - ] - ); + self::createTransactions($journal, $fromAccount, $toAccount, $amount); $journal->categories()->save($category); $journal->budgets()->save($budget); @@ -1041,11 +911,11 @@ class TestData /** @var Account $account */ foreach ($user->accounts()->get() as $account) { if ($account->name == $name) { - Log::debug('Trying to find "' . $name . '" in "' . $account->name . '", and found it!'); + //Log::debug('Trying to find "' . $name . '" in "' . $account->name . '", and found it!'); return $account; } - Log::debug('Trying to find "' . $name . '" in "' . $account->name . '".'); + //Log::debug('Trying to find "' . $name . '" in "' . $account->name . '".'); } return null; @@ -1100,24 +970,7 @@ class TestData 'date' => $date->format('Y-m-d'), ] ); - - // transactions - Transaction::create( - [ - 'account_id' => $opposing->id, - 'transaction_journal_id' => $journal->id, - 'amount' => -10000, - ] - ); - - Transaction::create( - [ - 'account_id' => $savings->id, - 'transaction_journal_id' => $journal->id, - 'amount' => 10000, - ] - ); - + self::createTransactions($journal, $opposing, $savings, '10000'); } diff --git a/app/Support/Steam.php b/app/Support/Steam.php index bbbbc49652..8779d7cc4b 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -40,12 +40,12 @@ class Steam bcscale(2); - $balance = $account->transactions()->leftJoin( + $balance = strval($account->transactions()->leftJoin( 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id' - )->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount'); + )->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')); if (!$ignoreVirtualBalance) { - $balance = bcadd(strval($balance), $account->virtual_balance); + $balance = bcadd($balance, $account->virtual_balance); } $cache->store($balance); From f72a8c5c06671c96081df00b012e569a7cd1a1b5 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 17:38:58 +0100 Subject: [PATCH 052/448] Fixed some errors. Debug tests. --- .travis.yml | 2 +- app/Support/Migration/TestData.php | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9a8d6aca69..6472ddb017 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,4 +18,4 @@ install: - php artisan migrate --seed script: - - phpunit + - phpunit --debug diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php index 780bcf558b..c488655083 100644 --- a/app/Support/Migration/TestData.php +++ b/app/Support/Migration/TestData.php @@ -904,21 +904,18 @@ class TestData * @param User $user * @param $name * - * @return Account|null + * @return Account */ - public static function findAccount(User $user, string $name) + public static function findAccount(User $user, string $name): Account { /** @var Account $account */ foreach ($user->accounts()->get() as $account) { if ($account->name == $name) { - //Log::debug('Trying to find "' . $name . '" in "' . $account->name . '", and found it!'); - return $account; } - //Log::debug('Trying to find "' . $name . '" in "' . $account->name . '".'); } - return null; + return new Account; } /** From 1ee72a6ce5bf5a1dc2b70b9b1844e0ff2b6f1bc1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 18:53:31 +0100 Subject: [PATCH 053/448] Travis file update. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6472ddb017..4130ee699f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: install: - composer selfupdate + - composer --version - composer install --no-dev - composer update - php artisan env @@ -18,4 +19,4 @@ install: - php artisan migrate --seed script: - - phpunit --debug + - phpunit From b90c7c09b6f4d5088ecee050a3ed7bae8737b253 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 19:12:54 +0100 Subject: [PATCH 054/448] Smaller travis file. Try to fix the search. --- .travis.yml | 2 -- app/Http/Controllers/SearchController.php | 28 +++++++++++------------ resources/lang/en_US/firefly.php | 1 + 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4130ee699f..ac0efd49a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,6 @@ php: install: - composer selfupdate - - composer --version - - composer install --no-dev - composer update - php artisan env - mv -v .env.testing .env diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index e9793687f3..2e75c9b45e 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -28,26 +28,26 @@ class SearchController extends Controller public function index(SearchInterface $searcher) { - $subTitle = null; - $rawQuery = null; - $result = []; + $subTitle = null; + $query = null; + $result = []; + $title = trans('firefly.search'); + $mainTitleIcon = 'fa-search'; if (!is_null(Input::get('q')) && strlen(Input::get('q')) > 0) { - $rawQuery = trim(Input::get('q')); - $words = explode(' ', $rawQuery); - $subTitle = trans('firefly.search_results_for', ['query' => $rawQuery]); + $query = trim(Input::get('q')); + $words = explode(' ', $query); + $subTitle = trans('firefly.search_results_for', ['query' => $query]); - $transactions = $searcher->searchTransactions($words); - $accounts = $searcher->searchAccounts($words); - $categories = $searcher->searchCategories($words); - $budgets = $searcher->searchBudgets($words); - $tags = $searcher->searchTags($words); + $transactions = [];//$searcher->searchTransactions($words); + $accounts = [];//$searcher->searchAccounts($words); + $categories = [];//$searcher->searchCategories($words); + $budgets = [];//$searcher->searchBudgets($words); + $tags = [];//$searcher->searchTags($words); $result = ['transactions' => $transactions, 'accounts' => $accounts, 'categories' => $categories, 'budgets' => $budgets, 'tags' => $tags]; } - return view('search.index')->with('title', 'Search')->with('subTitle', $subTitle)->with( - 'mainTitleIcon', 'fa-search' - )->with('query', $rawQuery)->with('result', $result); + return view('search.index', compact('title', 'subTitle', 'mainTitleIcon', 'query', 'result')); } } diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 36aa71df2d..72f8eb612e 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -21,6 +21,7 @@ return [ 'showEverything' => 'Show everything', 'never' => 'Never', 'search_results_for' => 'Search results for ":query"', + 'search' => 'Search', 'bounced_error' => 'The message sent to :email bounced, so no access for you.', 'deleted_error' => 'These credentials do not match our records.', 'general_blocked_error' => 'Your account has been disabled, so you cannot login.', From 082e6f5e993baa90d511ed32810e39fe066a42b9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 19:14:06 +0100 Subject: [PATCH 055/448] Removed the composer.lock, see what happens. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ac0efd49a5..9c0ace389b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: install: - composer selfupdate + - rm composer.lock - composer update - php artisan env - mv -v .env.testing .env From 82a4c706b0ee6c668d32e012e77c37b70773e52b Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 19:16:42 +0100 Subject: [PATCH 056/448] Update something in travis. --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9c0ace389b..755aa122ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,9 @@ php: install: - composer selfupdate - rm composer.lock - - composer update + - composer update --no-scripts + - php artisan clear-compiled + - php artisan optimize - php artisan env - mv -v .env.testing .env - php artisan env From c9b215684ce453ecaf4c7363170b8d59869ce9fd Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 19:25:17 +0100 Subject: [PATCH 057/448] Also fixed tests. --- app/Http/Controllers/SearchController.php | 10 +++++----- tests/acceptance/Controllers/SearchControllerTest.php | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 2e75c9b45e..b634a85379 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -38,11 +38,11 @@ class SearchController extends Controller $words = explode(' ', $query); $subTitle = trans('firefly.search_results_for', ['query' => $query]); - $transactions = [];//$searcher->searchTransactions($words); - $accounts = [];//$searcher->searchAccounts($words); - $categories = [];//$searcher->searchCategories($words); - $budgets = [];//$searcher->searchBudgets($words); - $tags = [];//$searcher->searchTags($words); + $transactions = $searcher->searchTransactions($words); + $accounts = $searcher->searchAccounts($words); + $categories = $searcher->searchCategories($words); + $budgets = $searcher->searchBudgets($words); + $tags = $searcher->searchTags($words); $result = ['transactions' => $transactions, 'accounts' => $accounts, 'categories' => $categories, 'budgets' => $budgets, 'tags' => $tags]; } diff --git a/tests/acceptance/Controllers/SearchControllerTest.php b/tests/acceptance/Controllers/SearchControllerTest.php index 0d9838e37c..9e94467fa6 100644 --- a/tests/acceptance/Controllers/SearchControllerTest.php +++ b/tests/acceptance/Controllers/SearchControllerTest.php @@ -6,6 +6,7 @@ * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ +use Illuminate\Support\Collection; /** @@ -19,6 +20,13 @@ class SearchControllerTest extends TestCase */ public function testIndex() { + $searcher = $this->mock('FireflyIII\Support\Search\SearchInterface'); + $searcher->shouldReceive('searchTransactions')->once()->with(['test'])->andReturn(new Collection); + $searcher->shouldReceive('searchAccounts')->once()->with(['test'])->andReturn(new Collection); + $searcher->shouldReceive('searchCategories')->once()->with(['test'])->andReturn(new Collection); + $searcher->shouldReceive('searchBudgets')->once()->with(['test'])->andReturn(new Collection); + $searcher->shouldReceive('searchTags')->once()->with(['test'])->andReturn(new Collection); + $this->be($this->user()); $this->call('GET', '/search?q=test&search='); $this->assertResponseStatus(200); From cd871e5aad29323d327aee1c71dd192748734873 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 19:27:52 +0100 Subject: [PATCH 058/448] Let's see what happens. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 755aa122ce..7268560911 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ sudo: false php: - 7 +before_script: + - phpenv config-rm xdebug.ini install: - composer selfupdate From a4e699f7813376b7742a3e2fdf2181c75398d0ea Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 19:54:25 +0100 Subject: [PATCH 059/448] Fix another php7 bug. --- app/Helpers/Collection/BudgetLine.php | 12 ++++++------ app/Helpers/Report/BudgetReportHelper.php | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Helpers/Collection/BudgetLine.php b/app/Helpers/Collection/BudgetLine.php index d755a6cf02..d4a0cfc2c0 100644 --- a/app/Helpers/Collection/BudgetLine.php +++ b/app/Helpers/Collection/BudgetLine.php @@ -31,7 +31,7 @@ class BudgetLine /** * @return BudgetModel */ - public function getBudget() + public function getBudget(): BudgetModel { return $this->budget; } @@ -47,7 +47,7 @@ class BudgetLine /** * @return string */ - public function getBudgeted() + public function getBudgeted(): string { return $this->budgeted; } @@ -63,7 +63,7 @@ class BudgetLine /** * @return string */ - public function getLeft() + public function getLeft(): string { return $this->left; } @@ -79,7 +79,7 @@ class BudgetLine /** * @return string */ - public function getOverspent() + public function getOverspent(): string { return $this->overspent; } @@ -95,7 +95,7 @@ class BudgetLine /** * @return LimitRepetition */ - public function getRepetition() + public function getRepetition(): LimitRepetition { return $this->repetition; } @@ -111,7 +111,7 @@ class BudgetLine /** * @return string */ - public function getSpent() + public function getSpent(): string { return $this->spent; } diff --git a/app/Helpers/Report/BudgetReportHelper.php b/app/Helpers/Report/BudgetReportHelper.php index cea6d69ff9..57cd56d0c3 100644 --- a/app/Helpers/Report/BudgetReportHelper.php +++ b/app/Helpers/Report/BudgetReportHelper.php @@ -32,7 +32,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface * * @return BudgetCollection */ - public function getBudgetReport(Carbon $start, Carbon $end, Collection $accounts) + public function getBudgetReport(Carbon $start, Carbon $end, Collection $accounts): BudgetCollection { $object = new BudgetCollection; /** @var \FireflyIII\Repositories\Budget\BudgetRepositoryInterface $repository */ @@ -77,7 +77,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface // 200 en -200 is 0, vergeleken met 0 === 0 // 200 en -300 is -100, vergeleken met 0 === -1 - $left = bccomp(bcadd($repetition->amount, $expenses), '0') === 1 ? bcadd($repetition->amount, $expenses) : 0; + $left = bccomp(bcadd($repetition->amount, $expenses), '0') === 1 ? bcadd($repetition->amount, $expenses) : '0'; $spent = bccomp(bcadd($repetition->amount, $expenses), '0') === 1 ? $expenses : '0'; $overspent = bccomp(bcadd($repetition->amount, $expenses), '0') === 1 ? '0' : bcadd($expenses, $repetition->amount); From c3f78b698dadf75d05da3a83b7cead74bec5ed72 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 19:56:25 +0100 Subject: [PATCH 060/448] This PHP7 thing is strict! --- app/Helpers/Collection/BudgetLine.php | 2 +- resources/views/reports/partials/budgets.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Helpers/Collection/BudgetLine.php b/app/Helpers/Collection/BudgetLine.php index d4a0cfc2c0..97d8ca3579 100644 --- a/app/Helpers/Collection/BudgetLine.php +++ b/app/Helpers/Collection/BudgetLine.php @@ -33,7 +33,7 @@ class BudgetLine */ public function getBudget(): BudgetModel { - return $this->budget; + return $this->budget ?? new BudgetModel; } /** diff --git a/resources/views/reports/partials/budgets.twig b/resources/views/reports/partials/budgets.twig index aa8c9986e3..dd9bda2461 100644 --- a/resources/views/reports/partials/budgets.twig +++ b/resources/views/reports/partials/budgets.twig @@ -19,7 +19,7 @@ {% for budgetLine in budgets.getBudgetLines %} - {% if budgetLine.getBudget %} + {% if budgetLine.getBudget.id %} {{ budgetLine.getBudget.name }} {% else %} {{ 'noBudget'|_ }} From 9465a6d2b57de81fa8c7a4c38fff29f3bae359fb Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 19:57:17 +0100 Subject: [PATCH 061/448] This PHP7 thing is strict! --- app/Helpers/Collection/BudgetLine.php | 2 +- resources/views/reports/partials/budgets.twig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Helpers/Collection/BudgetLine.php b/app/Helpers/Collection/BudgetLine.php index 97d8ca3579..ecda6ac7ca 100644 --- a/app/Helpers/Collection/BudgetLine.php +++ b/app/Helpers/Collection/BudgetLine.php @@ -97,7 +97,7 @@ class BudgetLine */ public function getRepetition(): LimitRepetition { - return $this->repetition; + return $this->repetition ?? new LimitRepetition; } /** diff --git a/resources/views/reports/partials/budgets.twig b/resources/views/reports/partials/budgets.twig index dd9bda2461..19122b4cd7 100644 --- a/resources/views/reports/partials/budgets.twig +++ b/resources/views/reports/partials/budgets.twig @@ -26,12 +26,12 @@ {% endif %} - {% if budgetLine.getRepetition %} + {% if budgetLine.getRepetition.id %} {{ budgetLine.getRepetition.startdate.formatLocalized(monthAndDayFormat) }} {% endif %} - {% if budgetLine.getRepetition %} + {% if budgetLine.getRepetition.id %} {{ budgetLine.getRepetition.amount|formatAmount }} {% else %} {{ 0|formatAmount }} From d477feb9301f7d1f47b98889ea1d2212e18f4c89 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 19:59:07 +0100 Subject: [PATCH 062/448] Some fix [skip-ci] --- resources/views/reports/partials/balance.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/reports/partials/balance.twig b/resources/views/reports/partials/balance.twig index b30e34ec0c..3a50ffa4af 100644 --- a/resources/views/reports/partials/balance.twig +++ b/resources/views/reports/partials/balance.twig @@ -28,6 +28,7 @@ [source] + {{ balanceLine.getBudget.amount|formatAmount }} {% else %} From 7d05999ced6c34766a9de1006aef73982977977f Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 19:59:38 +0100 Subject: [PATCH 063/448] Fixed view. [skip-ci] --- resources/views/reports/partials/balance.twig | 2 -- 1 file changed, 2 deletions(-) diff --git a/resources/views/reports/partials/balance.twig b/resources/views/reports/partials/balance.twig index 3a50ffa4af..1643123c82 100644 --- a/resources/views/reports/partials/balance.twig +++ b/resources/views/reports/partials/balance.twig @@ -27,9 +27,7 @@ {{ balanceLine.getTitle }} - [source] {{ balanceLine.getBudget.amount|formatAmount }} - {% else %} {{ balanceLine.getTitle }} From f1b6b3386a18f8cb93d446b8d40150075332d018 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 21:10:55 +0100 Subject: [PATCH 064/448] Expanded entry for export. --- app/Export/Entry.php | 306 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 303 insertions(+), 3 deletions(-) diff --git a/app/Export/Entry.php b/app/Export/Entry.php index e5ffc32688..da30ec8444 100644 --- a/app/Export/Entry.php +++ b/app/Export/Entry.php @@ -10,6 +10,9 @@ declare(strict_types = 1); namespace FireflyIII\Export; +use FireflyIII\Models\Account; +use FireflyIII\Models\Budget; +use FireflyIII\Models\Category; use FireflyIII\Models\TransactionJournal; /** @@ -33,10 +36,38 @@ class Entry { /** @var string */ public $amount; + /** @var int */ + public $billId; + /** @var string */ + public $billName; + /** @var int */ + public $budgetId; + /** @var string */ + public $budgetName; + /** @var int */ + public $categoryId; + /** @var string */ + public $categoryName; /** @var string */ public $date; /** @var string */ public $description; + /** @var string */ + public $fromAccountIban; + /** @var int */ + public $fromAccountId; + /** @var string */ + public $fromAccountName; + /** @var string */ + public $fromAccountType; + /** @var string */ + public $toAccountIban; + /** @var int */ + public $toAccountId; + /** @var string */ + public $toAccountName; + /** @var string */ + public $toAccountType; /** * @param TransactionJournal $journal @@ -51,6 +82,37 @@ class Entry $entry->setDate($journal->date->format('Y-m-d')); $entry->setAmount($journal->amount); + /** @var Budget $budget */ + $budget = $journal->budgets->first(); + if (!is_null($budget)) { + $entry->setBudgetId($budget->id); + $entry->setBudgetName($budget->name); + } + + /** @var Category $category */ + $category = $journal->categories->first(); + if (!is_null($category)) { + $entry->setCategoryId($category->id); + $entry->setCategoryName($category->name); + } + + if (!is_null($journal->bill_id)) { + $entry->setBillId($journal->bill_id); + $entry->setBillName($journal->bill->name); + } + + /** @var Account $sourceAccount */ + $sourceAccount = $journal->source_account; + $entry->setFromAccountId($sourceAccount->id); + $entry->setFromAccountName($sourceAccount->name); + $entry->setFromAccountType($sourceAccount->accountType->type); + + /** @var Account $destination */ + $destination = $journal->destination_account; + $entry->setToAccountId($destination->id); + $entry->setToAccountName($destination->name); + $entry->setToAccountType($destination->accountType->type); + return $entry; } @@ -63,9 +125,23 @@ class Entry // key = field name (see top of class) // value = field type (see csv.php under 'roles') return [ - 'amount' => 'amount', - 'date' => 'date-transaction', - 'description' => 'description', + 'amount' => 'amount', + 'date' => 'date-transaction', + 'description' => 'description', + 'billId' => 'bill-id', + 'billName' => 'bill-name', + 'budgetId' => 'budget-id', + 'budgetName' => 'budget-name', + 'categoryId' => 'category-id', + 'categoryName' => 'category-name', + 'fromAccountId' => 'account-id', + 'fromAccountName' => 'account-name', + 'fromAccountIban' => 'account-iban', + 'fromAccountType' => '_ignore', + 'toAccountId' => 'opposing-id', + 'toAccountName' => 'opposing-name', + 'toAccountIban' => 'opposing-iban', + 'toAccountType' => '_ignore', ]; } @@ -85,6 +161,102 @@ class Entry $this->amount = $amount; } + /** + * @return int + */ + public function getBillId() + { + return $this->billId; + } + + /** + * @param int $billId + */ + public function setBillId($billId) + { + $this->billId = $billId; + } + + /** + * @return string + */ + public function getBillName() + { + return $this->billName; + } + + /** + * @param string $billName + */ + public function setBillName($billName) + { + $this->billName = $billName; + } + + /** + * @return int + */ + public function getBudgetId() + { + return $this->budgetId; + } + + /** + * @param int $budgetId + */ + public function setBudgetId($budgetId) + { + $this->budgetId = $budgetId; + } + + /** + * @return string + */ + public function getBudgetName() + { + return $this->budgetName; + } + + /** + * @param string $budgetName + */ + public function setBudgetName($budgetName) + { + $this->budgetName = $budgetName; + } + + /** + * @return int + */ + public function getCategoryId() + { + return $this->categoryId; + } + + /** + * @param int $categoryId + */ + public function setCategoryId($categoryId) + { + $this->categoryId = $categoryId; + } + + /** + * @return string + */ + public function getCategoryName() + { + return $this->categoryName; + } + + /** + * @param string $categoryName + */ + public function setCategoryName($categoryName) + { + $this->categoryName = $categoryName; + } + /** * @return string */ @@ -117,5 +289,133 @@ class Entry $this->description = $description; } + /** + * @return string + */ + public function getFromAccountIban() + { + return $this->fromAccountIban; + } + + /** + * @param string $fromAccountIban + */ + public function setFromAccountIban($fromAccountIban) + { + $this->fromAccountIban = $fromAccountIban; + } + + /** + * @return int + */ + public function getFromAccountId() + { + return $this->fromAccountId; + } + + /** + * @param int $fromAccountId + */ + public function setFromAccountId($fromAccountId) + { + $this->fromAccountId = $fromAccountId; + } + + /** + * @return string + */ + public function getFromAccountName() + { + return $this->fromAccountName; + } + + /** + * @param string $fromAccountName + */ + public function setFromAccountName($fromAccountName) + { + $this->fromAccountName = $fromAccountName; + } + + /** + * @return string + */ + public function getFromAccountType() + { + return $this->fromAccountType; + } + + /** + * @param string $fromAccountType + */ + public function setFromAccountType($fromAccountType) + { + $this->fromAccountType = $fromAccountType; + } + + /** + * @return string + */ + public function getToAccountIban() + { + return $this->toAccountIban; + } + + /** + * @param string $toAccountIban + */ + public function setToAccountIban($toAccountIban) + { + $this->toAccountIban = $toAccountIban; + } + + /** + * @return int + */ + public function getToAccountId() + { + return $this->toAccountId; + } + + /** + * @param int $toAccountId + */ + public function setToAccountId($toAccountId) + { + $this->toAccountId = $toAccountId; + } + + /** + * @return string + */ + public function getToAccountName() + { + return $this->toAccountName; + } + + /** + * @param string $toAccountName + */ + public function setToAccountName($toAccountName) + { + $this->toAccountName = $toAccountName; + } + + /** + * @return string + */ + public function getToAccountType() + { + return $this->toAccountType; + } + + /** + * @param string $toAccountType + */ + public function setToAccountType($toAccountType) + { + $this->toAccountType = $toAccountType; + } + } \ No newline at end of file From 1542d5e386babe6674da2d5fbe3a0d120a83e428 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 21:12:19 +0100 Subject: [PATCH 065/448] Include IBAN --- app/Export/Entry.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Export/Entry.php b/app/Export/Entry.php index da30ec8444..c84fb91280 100644 --- a/app/Export/Entry.php +++ b/app/Export/Entry.php @@ -105,12 +105,14 @@ class Entry $sourceAccount = $journal->source_account; $entry->setFromAccountId($sourceAccount->id); $entry->setFromAccountName($sourceAccount->name); + $entry->setFromAccountIban($sourceAccount->iban); $entry->setFromAccountType($sourceAccount->accountType->type); /** @var Account $destination */ $destination = $journal->destination_account; $entry->setToAccountId($destination->id); $entry->setToAccountName($destination->name); + $entry->setToAccountIban($destination->iban); $entry->setToAccountType($destination->accountType->type); return $entry; From bac392d33195075f5e8a2944a18452d51f3aee7a Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 21:23:10 +0100 Subject: [PATCH 066/448] Some new translations --- resources/lang/fr_FR/breadcrumbs.php | 0 resources/lang/fr_FR/config.php | 0 resources/lang/fr_FR/firefly.php | 170 ++++++++++++++++----------- resources/lang/fr_FR/form.php | 6 + resources/lang/fr_FR/help.php | 0 resources/lang/fr_FR/list.php | 0 resources/lang/fr_FR/pagination.php | 0 resources/lang/fr_FR/passwords.php | 2 +- resources/lang/fr_FR/validation.php | 0 resources/lang/nl_NL/breadcrumbs.php | 0 resources/lang/nl_NL/config.php | 0 resources/lang/nl_NL/firefly.php | 170 ++++++++++++++++----------- resources/lang/nl_NL/form.php | 6 + resources/lang/nl_NL/help.php | 0 resources/lang/nl_NL/list.php | 0 resources/lang/nl_NL/pagination.php | 0 resources/lang/nl_NL/passwords.php | 2 +- resources/lang/nl_NL/validation.php | 0 resources/lang/pt_BR/breadcrumbs.php | 0 resources/lang/pt_BR/config.php | 0 resources/lang/pt_BR/firefly.php | 170 ++++++++++++++++----------- resources/lang/pt_BR/form.php | 6 + resources/lang/pt_BR/help.php | 0 resources/lang/pt_BR/list.php | 0 resources/lang/pt_BR/pagination.php | 0 resources/lang/pt_BR/passwords.php | 2 +- resources/lang/pt_BR/validation.php | 0 27 files changed, 318 insertions(+), 216 deletions(-) mode change 100644 => 100755 resources/lang/fr_FR/breadcrumbs.php mode change 100644 => 100755 resources/lang/fr_FR/config.php mode change 100644 => 100755 resources/lang/fr_FR/firefly.php mode change 100644 => 100755 resources/lang/fr_FR/form.php mode change 100644 => 100755 resources/lang/fr_FR/help.php mode change 100644 => 100755 resources/lang/fr_FR/list.php mode change 100644 => 100755 resources/lang/fr_FR/pagination.php mode change 100644 => 100755 resources/lang/fr_FR/passwords.php mode change 100644 => 100755 resources/lang/fr_FR/validation.php mode change 100644 => 100755 resources/lang/nl_NL/breadcrumbs.php mode change 100644 => 100755 resources/lang/nl_NL/config.php mode change 100644 => 100755 resources/lang/nl_NL/firefly.php mode change 100644 => 100755 resources/lang/nl_NL/form.php mode change 100644 => 100755 resources/lang/nl_NL/help.php mode change 100644 => 100755 resources/lang/nl_NL/list.php mode change 100644 => 100755 resources/lang/nl_NL/pagination.php mode change 100644 => 100755 resources/lang/nl_NL/passwords.php mode change 100644 => 100755 resources/lang/nl_NL/validation.php mode change 100644 => 100755 resources/lang/pt_BR/breadcrumbs.php mode change 100644 => 100755 resources/lang/pt_BR/config.php mode change 100644 => 100755 resources/lang/pt_BR/firefly.php mode change 100644 => 100755 resources/lang/pt_BR/form.php mode change 100644 => 100755 resources/lang/pt_BR/help.php mode change 100644 => 100755 resources/lang/pt_BR/list.php mode change 100644 => 100755 resources/lang/pt_BR/pagination.php mode change 100644 => 100755 resources/lang/pt_BR/passwords.php mode change 100644 => 100755 resources/lang/pt_BR/validation.php diff --git a/resources/lang/fr_FR/breadcrumbs.php b/resources/lang/fr_FR/breadcrumbs.php old mode 100644 new mode 100755 diff --git a/resources/lang/fr_FR/config.php b/resources/lang/fr_FR/config.php old mode 100644 new mode 100755 diff --git a/resources/lang/fr_FR/firefly.php b/resources/lang/fr_FR/firefly.php old mode 100644 new mode 100755 index 502db22d64..7ac256f707 --- a/resources/lang/fr_FR/firefly.php +++ b/resources/lang/fr_FR/firefly.php @@ -2,79 +2,107 @@ return [ // general stuff: - 'language_incomplete' => 'Cette langue n\'est pas encore complètement traduite', - 'test' => 'Vous avez choisi Anglais', - 'close' => 'Fermer', - 'pleaseHold' => 'Veuillew patienter...', - 'actions' => 'Actions', - 'edit' => 'Editer', - 'delete' => 'Supprimer', - 'welcomeBack' => 'What\'s playing?', - 'everything' => 'Tout', - 'customRange' => 'Plage personnalisée', - 'apply' => 'Appliquer', - 'cancel' => 'Annuler', - 'from' => 'Depuis', - 'to' => 'To', - 'total_sum' => 'Montant total ', - 'period_sum' => 'Somme pour la période', - 'showEverything' => 'Tout Afficher', - 'never' => 'Jamais', - 'search_results_for' => 'Résultats de recherche pour ":query"', - 'bounced_error' => 'Le message envoyé à :email a été rejeté, donc pas d\'accès pour vous.', - 'deleted_error' => 'These credentials do not match our records.', - 'general_blocked_error' => 'Your account has been disabled, so you cannot login.', - 'removed_amount' => 'Supprimé :amount', - 'added_amount' => 'Ajouté :amount', - 'asset_account_role_help' => 'Any extra options resulting from your choice can be set later.', - 'Opening balance' => 'Solde initial', - 'create_new_stuff' => 'Create new stuff', - 'new_withdrawal' => 'Nouveau retrait', - 'new_deposit' => 'Nouveau dépôt', - 'new_transfer' => 'Nouveau transfert', - 'new_asset_account' => 'New asset account', - 'new_expense_account' => 'New expense account', - 'new_revenue_account' => 'Nouveau compte de recettes', - 'new_budget' => 'Nouveau budget', - 'new_bill' => 'Nouvelle facture', + 'language_incomplete' => 'Cette langue n\'est pas encore complètement traduite', + 'test' => 'Vous avez choisi Anglais', + 'close' => 'Fermer', + 'pleaseHold' => 'Veuillew patienter...', + 'actions' => 'Actions', + 'edit' => 'Editer', + 'delete' => 'Supprimer', + 'welcomeBack' => 'What\'s playing?', + 'everything' => 'Tout', + 'customRange' => 'Plage personnalisée', + 'apply' => 'Appliquer', + 'cancel' => 'Annuler', + 'from' => 'Depuis', + 'to' => 'To', + 'total_sum' => 'Montant total ', + 'period_sum' => 'Somme pour la période', + 'showEverything' => 'Tout Afficher', + 'never' => 'Jamais', + 'search_results_for' => 'Résultats de recherche pour ":query"', + 'bounced_error' => 'Le message envoyé à :email a été rejeté, donc pas d\'accès pour vous.', + 'deleted_error' => 'These credentials do not match our records.', + 'general_blocked_error' => 'Your account has been disabled, so you cannot login.', + 'removed_amount' => 'Supprimé :amount', + 'added_amount' => 'Ajouté :amount', + 'asset_account_role_help' => 'Any extra options resulting from your choice can be set later.', + 'Opening balance' => 'Solde initial', + 'create_new_stuff' => 'Create new stuff', + 'new_withdrawal' => 'Nouveau retrait', + 'new_deposit' => 'Nouveau dépôt', + 'new_transfer' => 'Nouveau transfert', + 'new_asset_account' => 'New asset account', + 'new_expense_account' => 'New expense account', + 'new_revenue_account' => 'Nouveau compte de recettes', + 'new_budget' => 'Nouveau budget', + 'new_bill' => 'Nouvelle facture', + + // export data: + 'import_and_export' => 'Import and export', + 'export_data' => 'Export data', + 'export_data_intro' => 'For backup purposes, when migrating to another system or when migrating to another Firefly III installation.', + 'export_format' => 'Export format', + 'export_format_csv' => 'Comma separated values (CSV file)', + 'export_format_mt940' => 'MT940 compatible format', + 'export_included_accounts' => 'Export transactions from these accounts', + 'include_config_help' => 'For easy re-import into Firefly III', + 'include_old_uploads_help' => 'Firefly III does not throw away the original CSV files you have imported in the past. You can include them in your export.', + 'do_export' => 'Export', + 'export_status_make_exporter' => 'Creating exporter thing...', + 'export_status_collecting_journals' => 'Collecting your transactions...', + 'export_status_collected_journals' => 'Collected your transactions!', + 'export_status_converting_to_export_format' => 'Converting your transactions...', + 'export_status_converted_to_export_format' => 'Converted your transactions!', + 'export_status_creating_journal_file' => 'Creating the export file...', + 'export_status_created_journal_file' => 'Created the export file!', + 'export_status_collecting_attachments' => 'Collecting all your attachments...', + 'export_status_collected_attachments' => 'Collected all your attachments!', + 'export_status_collecting_old_uploads' => 'Collecting all your previous uploads...', + 'export_status_collected_old_uploads' => 'Collected all your previous uploads!', + 'export_status_creating_config_file' => 'Creating a configuration file...', + 'export_status_created_config_file' => 'Created a configuration file!', + 'export_status_creating_zip_file' => 'Creating a zip file...', + 'export_status_created_zip_file' => 'Created a zip file!', + 'export_status_finished' => 'Export has succesfully finished! Yay!', // rules - 'rules' => 'Rules', - 'rules_explanation' => 'Here you can manage rules. Rules are triggered when a transaction is created or updated. Then, if the transaction has certain properties (called "triggers") Firefly will execute the "actions". Combined, you can make Firefly respond in a certain way to new transactions.', - 'rule_name' => 'Name of rule', - 'rule_triggers' => 'Rule triggers when', - 'rule_actions' => 'Rule will', - 'new_rule' => 'New rule', - 'new_rule_group' => 'New rule group', - 'rule_priority_up' => 'Give rule more priority', - 'rule_priority_down' => 'Give rule less priority', - 'make_new_rule_group' => 'Make new rule group', - 'store_new_rule_group' => 'Store new rule group', - 'created_new_rule_group' => 'New rule group ":title" stored!', - 'updated_rule_group' => 'Successfully updated rule group ":title".', - 'edit_rule_group' => 'Edit rule group ":title"', - 'delete_rule_group' => 'Delete rule group ":title"', - 'deleted_rule_group' => 'Deleted rule group ":title"', - 'update_rule_group' => 'Update rule group', - 'no_rules_in_group' => 'There are no rules in this group', - 'move_rule_group_up' => 'Move rule group up', - 'move_rule_group_down' => 'Move rule group down', - 'save_rules_by_moving' => 'Save these rule(s) by moving them to another rule group:', - 'make_new_rule' => 'Make new rule in rule group ":title"', - 'rule_help_stop_processing' => 'When you check this box, later rules in this group will not be executed.', - 'rule_help_active' => 'Inactive rules will never fire.', - 'stored_new_rule' => 'Stored new rule with title ":title"', - 'deleted_rule' => 'Deleted rule with title ":title"', - 'store_new_rule' => 'Store new rule', - 'updated_rule' => 'Updated rule with title ":title"', - 'default_rule_group_name' => 'Default rules', - 'default_rule_group_description' => 'All your rules not in a particular group.', - 'default_rule_name' => 'Your first default rule', - 'default_rule_description' => 'This rule is an example. You can safely delete it.', - 'default_rule_trigger_description' => 'The Man Who Sold the World', - 'default_rule_trigger_from_account' => 'David Bowie', - 'default_rule_action_prepend' => 'Bought the world from ', - 'default_rule_action_set_category' => 'Large expenses', + 'rules' => 'Rules', + 'rules_explanation' => 'Here you can manage rules. Rules are triggered when a transaction is created or updated. Then, if the transaction has certain properties (called "triggers") Firefly will execute the "actions". Combined, you can make Firefly respond in a certain way to new transactions.', + 'rule_name' => 'Name of rule', + 'rule_triggers' => 'Rule triggers when', + 'rule_actions' => 'Rule will', + 'new_rule' => 'New rule', + 'new_rule_group' => 'New rule group', + 'rule_priority_up' => 'Give rule more priority', + 'rule_priority_down' => 'Give rule less priority', + 'make_new_rule_group' => 'Make new rule group', + 'store_new_rule_group' => 'Store new rule group', + 'created_new_rule_group' => 'New rule group ":title" stored!', + 'updated_rule_group' => 'Successfully updated rule group ":title".', + 'edit_rule_group' => 'Edit rule group ":title"', + 'delete_rule_group' => 'Delete rule group ":title"', + 'deleted_rule_group' => 'Deleted rule group ":title"', + 'update_rule_group' => 'Update rule group', + 'no_rules_in_group' => 'There are no rules in this group', + 'move_rule_group_up' => 'Move rule group up', + 'move_rule_group_down' => 'Move rule group down', + 'save_rules_by_moving' => 'Save these rule(s) by moving them to another rule group:', + 'make_new_rule' => 'Make new rule in rule group ":title"', + 'rule_help_stop_processing' => 'When you check this box, later rules in this group will not be executed.', + 'rule_help_active' => 'Inactive rules will never fire.', + 'stored_new_rule' => 'Stored new rule with title ":title"', + 'deleted_rule' => 'Deleted rule with title ":title"', + 'store_new_rule' => 'Store new rule', + 'updated_rule' => 'Updated rule with title ":title"', + 'default_rule_group_name' => 'Default rules', + 'default_rule_group_description' => 'All your rules not in a particular group.', + 'default_rule_name' => 'Your first default rule', + 'default_rule_description' => 'This rule is an example. You can safely delete it.', + 'default_rule_trigger_description' => 'The Man Who Sold the World', + 'default_rule_trigger_from_account' => 'David Bowie', + 'default_rule_action_prepend' => 'Bought the world from ', + 'default_rule_action_set_category' => 'Large expenses', 'trigger' => 'Trigger', 'trigger_value' => 'Trigger on value', diff --git a/resources/lang/fr_FR/form.php b/resources/lang/fr_FR/form.php old mode 100644 new mode 100755 index a572419aec..c6366c8f89 --- a/resources/lang/fr_FR/form.php +++ b/resources/lang/fr_FR/form.php @@ -70,6 +70,12 @@ return [ 'size' => 'Size', 'trigger' => 'Trigger', 'stop_processing' => 'Stop processing', + 'start_date' => 'Start of export range', + 'end_date' => 'End of export range', + 'export_format' => 'File format', + 'include_attachments' => 'Include uploaded attachments', + 'include_config' => 'Include configuration file', + 'include_old_uploads' => 'Include imported data', 'csv_comma' => 'A comma (,)', 'csv_semicolon' => 'A semicolon (;)', diff --git a/resources/lang/fr_FR/help.php b/resources/lang/fr_FR/help.php old mode 100644 new mode 100755 diff --git a/resources/lang/fr_FR/list.php b/resources/lang/fr_FR/list.php old mode 100644 new mode 100755 diff --git a/resources/lang/fr_FR/pagination.php b/resources/lang/fr_FR/pagination.php old mode 100644 new mode 100755 diff --git a/resources/lang/fr_FR/passwords.php b/resources/lang/fr_FR/passwords.php old mode 100644 new mode 100755 index 49f2dfe6b1..836e9d8b0c --- a/resources/lang/fr_FR/passwords.php +++ b/resources/lang/fr_FR/passwords.php @@ -24,6 +24,6 @@ return [ "token" => "Le jeton de réinitialisation de mot de passe est invalide.", "sent" => "Nous avons envoyé votre lien de réinitialisation de mot de passe!", "reset" => "Le mot de passe a été réinitialisé!", - 'blocked' => 'Nice try though.', + 'blocked' => 'Nice try though.' ]; diff --git a/resources/lang/fr_FR/validation.php b/resources/lang/fr_FR/validation.php old mode 100644 new mode 100755 diff --git a/resources/lang/nl_NL/breadcrumbs.php b/resources/lang/nl_NL/breadcrumbs.php old mode 100644 new mode 100755 diff --git a/resources/lang/nl_NL/config.php b/resources/lang/nl_NL/config.php old mode 100644 new mode 100755 diff --git a/resources/lang/nl_NL/firefly.php b/resources/lang/nl_NL/firefly.php old mode 100644 new mode 100755 index 5f02d0c10a..30242ed88c --- a/resources/lang/nl_NL/firefly.php +++ b/resources/lang/nl_NL/firefly.php @@ -2,79 +2,107 @@ return [ // general stuff: - 'language_incomplete' => 'Deze taal is nog niet helemaal af', - 'test' => 'Nederlands geselecteerd!', - 'close' => 'Sluiten', - 'pleaseHold' => 'Momentje...', - 'actions' => 'Acties', - 'edit' => 'Wijzig', - 'delete' => 'Verwijder', - 'welcomeBack' => 'Hoe staat het er voor?', - 'everything' => 'Alles', - 'customRange' => 'Zelf bereik kiezen', - 'apply' => 'Go', - 'cancel' => 'Annuleren', - 'from' => 'Van', - 'to' => 'Tot', - 'total_sum' => 'Totale som', - 'period_sum' => 'Som van periode', - 'showEverything' => 'Laat alles zien', - 'never' => 'Nooit', - 'search_results_for' => 'Zoekresultaten voor ":query"', - 'bounced_error' => 'Het emailtje naar :email kwam nooit aan.', - 'deleted_error' => 'Deze gegevens zijn niet correct.', - 'general_blocked_error' => 'Je account is uitgeschakeld, je kan helaas niet inloggen.', - 'removed_amount' => ':amount weggehaald', - 'added_amount' => ':amount toegevoegd', - 'asset_account_role_help' => 'Voorkeuren die voortkomen uit je keuze hier kan je later aangeven.', - 'Opening balance' => 'Startsaldo', - 'create_new_stuff' => 'Nieuw', - 'new_withdrawal' => 'Nieuwe uitgave', - 'new_deposit' => 'Nieuwe inkomsten', - 'new_transfer' => 'Nieuwe overschrijving', - 'new_asset_account' => 'Nieuwe betaalrekening', - 'new_expense_account' => 'Nieuwe crediteur', - 'new_revenue_account' => 'Nieuwe debiteur', - 'new_budget' => 'Nieuw budget', - 'new_bill' => 'Nieuw contract', + 'language_incomplete' => 'Deze taal is nog niet helemaal af', + 'test' => 'Nederlands geselecteerd!', + 'close' => 'Sluiten', + 'pleaseHold' => 'Momentje...', + 'actions' => 'Acties', + 'edit' => 'Wijzig', + 'delete' => 'Verwijder', + 'welcomeBack' => 'Hoe staat het er voor?', + 'everything' => 'Alles', + 'customRange' => 'Zelf bereik kiezen', + 'apply' => 'Go', + 'cancel' => 'Annuleren', + 'from' => 'Van', + 'to' => 'Tot', + 'total_sum' => 'Totale som', + 'period_sum' => 'Som van periode', + 'showEverything' => 'Laat alles zien', + 'never' => 'Nooit', + 'search_results_for' => 'Zoekresultaten voor ":query"', + 'bounced_error' => 'Het emailtje naar :email kwam nooit aan.', + 'deleted_error' => 'Deze gegevens zijn niet correct.', + 'general_blocked_error' => 'Je account is uitgeschakeld, je kan helaas niet inloggen.', + 'removed_amount' => ':amount weggehaald', + 'added_amount' => ':amount toegevoegd', + 'asset_account_role_help' => 'Voorkeuren die voortkomen uit je keuze hier kan je later aangeven.', + 'Opening balance' => 'Startsaldo', + 'create_new_stuff' => 'Nieuw', + 'new_withdrawal' => 'Nieuwe uitgave', + 'new_deposit' => 'Nieuwe inkomsten', + 'new_transfer' => 'Nieuwe overschrijving', + 'new_asset_account' => 'Nieuwe betaalrekening', + 'new_expense_account' => 'Nieuwe crediteur', + 'new_revenue_account' => 'Nieuwe debiteur', + 'new_budget' => 'Nieuw budget', + 'new_bill' => 'Nieuw contract', + + // export data: + 'import_and_export' => 'Importeren en exporteren', + 'export_data' => 'Exporteren', + 'export_data_intro' => 'Om te backuppen, of wanneer je naar een ander systeem verhuist.', + 'export_format' => 'Exporteerformaat', + 'export_format_csv' => 'Komma-gescheiden bestand (CSV)', + 'export_format_mt940' => 'MT940 bestand', + 'export_included_accounts' => 'Exporteer transacties van deze rekeningen', + 'include_config_help' => 'Voor het makkelijk opnieuw importeren in Firefly III', + 'include_old_uploads_help' => 'Firefly III gooit je oude geïmporteerde CSV bestanden niet weg. Je kan ze meenemen in je exportbestand.', + 'do_export' => 'Exporteren', + 'export_status_make_exporter' => 'Exporteerding maken...', + 'export_status_collecting_journals' => 'Overboekingen verzamelen...', + 'export_status_collected_journals' => 'Overboekingen verzameld!', + 'export_status_converting_to_export_format' => 'Overboekingen overzetten...', + 'export_status_converted_to_export_format' => 'Overboekingen overgezet!', + 'export_status_creating_journal_file' => 'Exportbestand maken...', + 'export_status_created_journal_file' => 'Exportbestand gemaakt!', + 'export_status_collecting_attachments' => 'Bijlagen verzamelen...', + 'export_status_collected_attachments' => 'Bijlagen verzameld!', + 'export_status_collecting_old_uploads' => 'Oude uploads verzamelen...', + 'export_status_collected_old_uploads' => 'Oude uploads verzameld!', + 'export_status_creating_config_file' => 'Configuratiebestand maken...', + 'export_status_created_config_file' => 'Configuratiebestand gemaakt!', + 'export_status_creating_zip_file' => 'Zipbestand maken...', + 'export_status_created_zip_file' => 'Zipbestand gemaakt!', + 'export_status_finished' => 'Klaar met exportbestand! Hoera!', // rules - 'rules' => 'Regels', - 'rules_explanation' => 'Hier kan je regels instellen. Regels worden in werking gesteld als je een bij-, afschrijving of overboeking maakt (of verandert). Als die transactie bepaalde eigenschappen heeft (zogenaamde "triggers") zal Firefly de bijbehorende "acties" uitvoeren. Gecombineerd kan je Firefly op een bepaalde manier laten reageren op nieuwe transacties.', - 'rule_name' => 'Regelnaam', - 'rule_triggers' => 'Regel reageert op', - 'rule_actions' => 'Regel zal dan', - 'new_rule' => 'Nieuwe regel', - 'new_rule_group' => 'Nieuwe regelgroep', - 'rule_priority_up' => 'Geef regel meer prioriteit', - 'rule_priority_down' => 'Geef regel minder prioriteit', - 'make_new_rule_group' => 'Maak nieuwe regelgroep', - 'store_new_rule_group' => 'Sla nieuwe regelgroep op', - 'created_new_rule_group' => 'Nieuwe regelgroep ":title" opgeslagen!', - 'updated_rule_group' => 'Regelgroep ":title" geüpdatet.', - 'edit_rule_group' => 'Wijzig regelgroep ":title"', - 'delete_rule_group' => 'Verwijder regelgroep ":title"', - 'deleted_rule_group' => 'Regelgroep ":title" verwijderd', - 'update_rule_group' => 'Wijzig regelgroep', - 'no_rules_in_group' => 'Er zijn geen regels in deze groep', - 'move_rule_group_up' => 'Verplaats regelgroep omhoog', - 'move_rule_group_down' => 'Verplaats regelgroep omlaag', - 'save_rules_by_moving' => 'Red deze regel(s) van de ondergang door ze te verplaatsen naar een andere regelgroep:', - 'make_new_rule' => 'Maak een nieuwe regel in regelgroep ":title"', - 'rule_help_stop_processing' => 'Zet hier een vinkje om latere regels in deze groep te negeren.', - 'rule_help_active' => 'Niet actieve regels zullen nooit worden gecontroleerd.', - 'stored_new_rule' => 'Nieuwe regel ":title" opgeslagen', - 'deleted_rule' => 'Regel ":title" verwijderd', - 'store_new_rule' => 'Sla nieuwe regel op', - 'updated_rule' => 'Regel ":title" geüpdatet', - 'default_rule_group_name' => 'Standaard regels', - 'default_rule_group_description' => 'Al je regels die niet in een bepaalde groep zitten.', - 'default_rule_name' => 'Je eerste standaardregel', - 'default_rule_description' => 'Deze regel is een voorbeeld. Je kan hem rustig verwijderen.', - 'default_rule_trigger_description' => 'The Man Who Sold the World', - 'default_rule_trigger_from_account' => 'David Bowie', - 'default_rule_action_prepend' => 'Kocht de wereld van ', - 'default_rule_action_set_category' => 'Grote uitgaven', + 'rules' => 'Regels', + 'rules_explanation' => 'Hier kan je regels instellen. Regels worden in werking gesteld als je een bij-, afschrijving of overboeking maakt (of verandert). Als die transactie bepaalde eigenschappen heeft (zogenaamde "triggers") zal Firefly de bijbehorende "acties" uitvoeren. Gecombineerd kan je Firefly op een bepaalde manier laten reageren op nieuwe transacties.', + 'rule_name' => 'Regelnaam', + 'rule_triggers' => 'Regel reageert op', + 'rule_actions' => 'Regel zal dan', + 'new_rule' => 'Nieuwe regel', + 'new_rule_group' => 'Nieuwe regelgroep', + 'rule_priority_up' => 'Geef regel meer prioriteit', + 'rule_priority_down' => 'Geef regel minder prioriteit', + 'make_new_rule_group' => 'Maak nieuwe regelgroep', + 'store_new_rule_group' => 'Sla nieuwe regelgroep op', + 'created_new_rule_group' => 'Nieuwe regelgroep ":title" opgeslagen!', + 'updated_rule_group' => 'Regelgroep ":title" geüpdatet.', + 'edit_rule_group' => 'Wijzig regelgroep ":title"', + 'delete_rule_group' => 'Verwijder regelgroep ":title"', + 'deleted_rule_group' => 'Regelgroep ":title" verwijderd', + 'update_rule_group' => 'Wijzig regelgroep', + 'no_rules_in_group' => 'Er zijn geen regels in deze groep', + 'move_rule_group_up' => 'Verplaats regelgroep omhoog', + 'move_rule_group_down' => 'Verplaats regelgroep omlaag', + 'save_rules_by_moving' => 'Red deze regel(s) van de ondergang door ze te verplaatsen naar een andere regelgroep:', + 'make_new_rule' => 'Maak een nieuwe regel in regelgroep ":title"', + 'rule_help_stop_processing' => 'Zet hier een vinkje om latere regels in deze groep te negeren.', + 'rule_help_active' => 'Niet actieve regels zullen nooit worden gecontroleerd.', + 'stored_new_rule' => 'Nieuwe regel ":title" opgeslagen', + 'deleted_rule' => 'Regel ":title" verwijderd', + 'store_new_rule' => 'Sla nieuwe regel op', + 'updated_rule' => 'Regel ":title" geüpdatet', + 'default_rule_group_name' => 'Standaard regels', + 'default_rule_group_description' => 'Al je regels die niet in een bepaalde groep zitten.', + 'default_rule_name' => 'Je eerste standaardregel', + 'default_rule_description' => 'Deze regel is een voorbeeld. Je kan hem rustig verwijderen.', + 'default_rule_trigger_description' => 'The Man Who Sold the World', + 'default_rule_trigger_from_account' => 'David Bowie', + 'default_rule_action_prepend' => 'Kocht de wereld van ', + 'default_rule_action_set_category' => 'Grote uitgaven', 'trigger' => 'Trigger', 'trigger_value' => 'Trigger bij waarde', diff --git a/resources/lang/nl_NL/form.php b/resources/lang/nl_NL/form.php old mode 100644 new mode 100755 index cce6489790..ec3f60a664 --- a/resources/lang/nl_NL/form.php +++ b/resources/lang/nl_NL/form.php @@ -70,6 +70,12 @@ return [ 'size' => 'Grootte', 'trigger' => 'Trigger', 'stop_processing' => 'Stop met verwerken', + 'start_date' => 'Start van exportbereik', + 'end_date' => 'Einde van exportbereik', + 'export_format' => 'Bestandsformaat', + 'include_attachments' => 'Sla ook geüploade bijlagen op', + 'include_config' => 'Sla ook een configuratiebestand ook', + 'include_old_uploads' => 'Sla ook geïmporteerde bestanden op', 'csv_comma' => 'Een komma (,)', 'csv_semicolon' => 'Een puntkomma (;)', diff --git a/resources/lang/nl_NL/help.php b/resources/lang/nl_NL/help.php old mode 100644 new mode 100755 diff --git a/resources/lang/nl_NL/list.php b/resources/lang/nl_NL/list.php old mode 100644 new mode 100755 diff --git a/resources/lang/nl_NL/pagination.php b/resources/lang/nl_NL/pagination.php old mode 100644 new mode 100755 diff --git a/resources/lang/nl_NL/passwords.php b/resources/lang/nl_NL/passwords.php old mode 100644 new mode 100755 index c8451e8ac0..44c022cc18 --- a/resources/lang/nl_NL/passwords.php +++ b/resources/lang/nl_NL/passwords.php @@ -24,6 +24,6 @@ return [ "token" => "Ongeldig token! Sorry", "sent" => "Je krijgt een mailtje met een linkje om je wachtwoord te herstellen!", "reset" => "Je wachtwoord is hersteld!", - 'blocked' => 'Leuk geprobeerd wel.', + 'blocked' => 'Leuk geprobeerd wel.' ]; diff --git a/resources/lang/nl_NL/validation.php b/resources/lang/nl_NL/validation.php old mode 100644 new mode 100755 diff --git a/resources/lang/pt_BR/breadcrumbs.php b/resources/lang/pt_BR/breadcrumbs.php old mode 100644 new mode 100755 diff --git a/resources/lang/pt_BR/config.php b/resources/lang/pt_BR/config.php old mode 100644 new mode 100755 diff --git a/resources/lang/pt_BR/firefly.php b/resources/lang/pt_BR/firefly.php old mode 100644 new mode 100755 index 22805ae830..1b1cb48481 --- a/resources/lang/pt_BR/firefly.php +++ b/resources/lang/pt_BR/firefly.php @@ -2,79 +2,107 @@ return [ // general stuff: - 'language_incomplete' => 'This language is not yet fully translated', - 'test' => 'Você selecionou Inglês', - 'close' => 'Fechar', - 'pleaseHold' => 'Por favor espere...', - 'actions' => 'Ações', - 'edit' => 'Editar', - 'delete' => 'Apagar', - 'welcomeBack' => 'What\'s playing?', - 'everything' => 'Tudo', - 'customRange' => 'Intervalo Personalizado', - 'apply' => 'Aplicar', - 'cancel' => 'Cancelar', - 'from' => 'De', - 'to' => 'Até', - 'total_sum' => 'Soma Total', - 'period_sum' => 'Soma por período', - 'showEverything' => 'Mostrar tudo', - 'never' => 'Never', - 'search_results_for' => 'Pesquisar resultados por ":query"', - 'bounced_error' => 'A mensagem enviado para :email ressaltado, não tem acesso para você.', - 'deleted_error' => 'Estas credenciais não correspondem aos nossos registros.', - 'general_blocked_error' => 'Sua conta foi desativada, você não pode entrar.', - 'removed_amount' => ':amount removido', - 'added_amount' => ':amount adicionada', - 'asset_account_role_help' => 'Quaisquer opções extras resultantes da sua escolha pode ser definido mais tarde.', - 'Opening balance' => 'Saldo inicial', - 'create_new_stuff' => 'Criar novas coisas', - 'new_withdrawal' => 'Nova retirada', - 'new_deposit' => 'Novo depósito', - 'new_transfer' => 'Nova transferência', - 'new_asset_account' => 'Nova conta de ativo', - 'new_expense_account' => 'Nova conta de despesa', - 'new_revenue_account' => 'Nova conta de receita', - 'new_budget' => 'Novo orçamento', - 'new_bill' => 'Nova fatura', + 'language_incomplete' => 'This language is not yet fully translated', + 'test' => 'Você selecionou Inglês', + 'close' => 'Fechar', + 'pleaseHold' => 'Por favor espere...', + 'actions' => 'Ações', + 'edit' => 'Editar', + 'delete' => 'Apagar', + 'welcomeBack' => 'What\'s playing?', + 'everything' => 'Tudo', + 'customRange' => 'Intervalo Personalizado', + 'apply' => 'Aplicar', + 'cancel' => 'Cancelar', + 'from' => 'De', + 'to' => 'Até', + 'total_sum' => 'Soma Total', + 'period_sum' => 'Soma por período', + 'showEverything' => 'Mostrar tudo', + 'never' => 'Never', + 'search_results_for' => 'Pesquisar resultados por ":query"', + 'bounced_error' => 'A mensagem enviado para :email ressaltado, não tem acesso para você.', + 'deleted_error' => 'Estas credenciais não correspondem aos nossos registros.', + 'general_blocked_error' => 'Sua conta foi desativada, você não pode entrar.', + 'removed_amount' => ':amount removido', + 'added_amount' => ':amount adicionada', + 'asset_account_role_help' => 'Quaisquer opções extras resultantes da sua escolha pode ser definido mais tarde.', + 'Opening balance' => 'Saldo inicial', + 'create_new_stuff' => 'Criar novas coisas', + 'new_withdrawal' => 'Nova retirada', + 'new_deposit' => 'Novo depósito', + 'new_transfer' => 'Nova transferência', + 'new_asset_account' => 'Nova conta de ativo', + 'new_expense_account' => 'Nova conta de despesa', + 'new_revenue_account' => 'Nova conta de receita', + 'new_budget' => 'Novo orçamento', + 'new_bill' => 'Nova fatura', + + // export data: + 'import_and_export' => 'Import and export', + 'export_data' => 'Export data', + 'export_data_intro' => 'For backup purposes, when migrating to another system or when migrating to another Firefly III installation.', + 'export_format' => 'Export format', + 'export_format_csv' => 'Comma separated values (CSV file)', + 'export_format_mt940' => 'MT940 compatible format', + 'export_included_accounts' => 'Export transactions from these accounts', + 'include_config_help' => 'For easy re-import into Firefly III', + 'include_old_uploads_help' => 'Firefly III does not throw away the original CSV files you have imported in the past. You can include them in your export.', + 'do_export' => 'Export', + 'export_status_make_exporter' => 'Creating exporter thing...', + 'export_status_collecting_journals' => 'Collecting your transactions...', + 'export_status_collected_journals' => 'Collected your transactions!', + 'export_status_converting_to_export_format' => 'Converting your transactions...', + 'export_status_converted_to_export_format' => 'Converted your transactions!', + 'export_status_creating_journal_file' => 'Creating the export file...', + 'export_status_created_journal_file' => 'Created the export file!', + 'export_status_collecting_attachments' => 'Collecting all your attachments...', + 'export_status_collected_attachments' => 'Collected all your attachments!', + 'export_status_collecting_old_uploads' => 'Collecting all your previous uploads...', + 'export_status_collected_old_uploads' => 'Collected all your previous uploads!', + 'export_status_creating_config_file' => 'Creating a configuration file...', + 'export_status_created_config_file' => 'Created a configuration file!', + 'export_status_creating_zip_file' => 'Creating a zip file...', + 'export_status_created_zip_file' => 'Created a zip file!', + 'export_status_finished' => 'Export has succesfully finished! Yay!', // rules - 'rules' => 'Rules', - 'rules_explanation' => 'Here you can manage rules. Rules are triggered when a transaction is created or updated. Then, if the transaction has certain properties (called "triggers") Firefly will execute the "actions". Combined, you can make Firefly respond in a certain way to new transactions.', - 'rule_name' => 'Name of rule', - 'rule_triggers' => 'Rule triggers when', - 'rule_actions' => 'Rule will', - 'new_rule' => 'New rule', - 'new_rule_group' => 'New rule group', - 'rule_priority_up' => 'Give rule more priority', - 'rule_priority_down' => 'Give rule less priority', - 'make_new_rule_group' => 'Make new rule group', - 'store_new_rule_group' => 'Store new rule group', - 'created_new_rule_group' => 'New rule group ":title" stored!', - 'updated_rule_group' => 'Successfully updated rule group ":title".', - 'edit_rule_group' => 'Edit rule group ":title"', - 'delete_rule_group' => 'Delete rule group ":title"', - 'deleted_rule_group' => 'Deleted rule group ":title"', - 'update_rule_group' => 'Update rule group', - 'no_rules_in_group' => 'There are no rules in this group', - 'move_rule_group_up' => 'Move rule group up', - 'move_rule_group_down' => 'Move rule group down', - 'save_rules_by_moving' => 'Save these rule(s) by moving them to another rule group:', - 'make_new_rule' => 'Make new rule in rule group ":title"', - 'rule_help_stop_processing' => 'When you check this box, later rules in this group will not be executed.', - 'rule_help_active' => 'Inactive rules will never fire.', - 'stored_new_rule' => 'Stored new rule with title ":title"', - 'deleted_rule' => 'Deleted rule with title ":title"', - 'store_new_rule' => 'Store new rule', - 'updated_rule' => 'Updated rule with title ":title"', - 'default_rule_group_name' => 'Default rules', - 'default_rule_group_description' => 'All your rules not in a particular group.', - 'default_rule_name' => 'Your first default rule', - 'default_rule_description' => 'This rule is an example. You can safely delete it.', - 'default_rule_trigger_description' => 'The Man Who Sold the World', - 'default_rule_trigger_from_account' => 'David Bowie', - 'default_rule_action_prepend' => 'Bought the world from ', - 'default_rule_action_set_category' => 'Large expenses', + 'rules' => 'Rules', + 'rules_explanation' => 'Here you can manage rules. Rules are triggered when a transaction is created or updated. Then, if the transaction has certain properties (called "triggers") Firefly will execute the "actions". Combined, you can make Firefly respond in a certain way to new transactions.', + 'rule_name' => 'Name of rule', + 'rule_triggers' => 'Rule triggers when', + 'rule_actions' => 'Rule will', + 'new_rule' => 'New rule', + 'new_rule_group' => 'New rule group', + 'rule_priority_up' => 'Give rule more priority', + 'rule_priority_down' => 'Give rule less priority', + 'make_new_rule_group' => 'Make new rule group', + 'store_new_rule_group' => 'Store new rule group', + 'created_new_rule_group' => 'New rule group ":title" stored!', + 'updated_rule_group' => 'Successfully updated rule group ":title".', + 'edit_rule_group' => 'Edit rule group ":title"', + 'delete_rule_group' => 'Delete rule group ":title"', + 'deleted_rule_group' => 'Deleted rule group ":title"', + 'update_rule_group' => 'Update rule group', + 'no_rules_in_group' => 'There are no rules in this group', + 'move_rule_group_up' => 'Move rule group up', + 'move_rule_group_down' => 'Move rule group down', + 'save_rules_by_moving' => 'Save these rule(s) by moving them to another rule group:', + 'make_new_rule' => 'Make new rule in rule group ":title"', + 'rule_help_stop_processing' => 'When you check this box, later rules in this group will not be executed.', + 'rule_help_active' => 'Inactive rules will never fire.', + 'stored_new_rule' => 'Stored new rule with title ":title"', + 'deleted_rule' => 'Deleted rule with title ":title"', + 'store_new_rule' => 'Store new rule', + 'updated_rule' => 'Updated rule with title ":title"', + 'default_rule_group_name' => 'Default rules', + 'default_rule_group_description' => 'All your rules not in a particular group.', + 'default_rule_name' => 'Your first default rule', + 'default_rule_description' => 'This rule is an example. You can safely delete it.', + 'default_rule_trigger_description' => 'The Man Who Sold the World', + 'default_rule_trigger_from_account' => 'David Bowie', + 'default_rule_action_prepend' => 'Bought the world from ', + 'default_rule_action_set_category' => 'Large expenses', 'trigger' => 'Trigger', 'trigger_value' => 'Trigger on value', diff --git a/resources/lang/pt_BR/form.php b/resources/lang/pt_BR/form.php old mode 100644 new mode 100755 index 322c358c9c..d9b1cdff2f --- a/resources/lang/pt_BR/form.php +++ b/resources/lang/pt_BR/form.php @@ -70,6 +70,12 @@ return [ 'size' => 'Tamanho', 'trigger' => 'Trigger', 'stop_processing' => 'Stop processing', + 'start_date' => 'Start of export range', + 'end_date' => 'End of export range', + 'export_format' => 'File format', + 'include_attachments' => 'Include uploaded attachments', + 'include_config' => 'Include configuration file', + 'include_old_uploads' => 'Include imported data', 'csv_comma' => 'A comma (,)', 'csv_semicolon' => 'A semicolon (;)', diff --git a/resources/lang/pt_BR/help.php b/resources/lang/pt_BR/help.php old mode 100644 new mode 100755 diff --git a/resources/lang/pt_BR/list.php b/resources/lang/pt_BR/list.php old mode 100644 new mode 100755 diff --git a/resources/lang/pt_BR/pagination.php b/resources/lang/pt_BR/pagination.php old mode 100644 new mode 100755 diff --git a/resources/lang/pt_BR/passwords.php b/resources/lang/pt_BR/passwords.php old mode 100644 new mode 100755 index fa70e900ba..038669154e --- a/resources/lang/pt_BR/passwords.php +++ b/resources/lang/pt_BR/passwords.php @@ -24,6 +24,6 @@ return [ "token" => "Este token de redefinição de senha é inválido.", "sent" => "Nós te enviamos um email com um link para trocar a senha!", "reset" => "Sua senha foi redefinida!", - 'blocked' => 'Boa tentativa.', + 'blocked' => 'Boa tentativa.' ]; diff --git a/resources/lang/pt_BR/validation.php b/resources/lang/pt_BR/validation.php old mode 100644 new mode 100755 From 030d241130d20ac30c599772fe9e3b0faf32f560 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 21:29:03 +0100 Subject: [PATCH 067/448] Should fix a bug in Travis. --- resources/views/reports/partials/balance.twig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/views/reports/partials/balance.twig b/resources/views/reports/partials/balance.twig index 1643123c82..54cc50ed30 100644 --- a/resources/views/reports/partials/balance.twig +++ b/resources/views/reports/partials/balance.twig @@ -27,7 +27,11 @@ {{ balanceLine.getTitle }} - {{ balanceLine.getBudget.amount|formatAmount }} + {% if(balanceLine.getBudget.amount) %} + {{ balanceLine.getBudget.amount|formatAmount }} + {% else %} + {{ '0'|formatAmount }} + {% endif %} {% else %} {{ balanceLine.getTitle }} From 7fa93e97db84f90ff165972e8c4fd3572a3752e0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 21:30:56 +0100 Subject: [PATCH 068/448] Fix language [skip-ci] --- resources/lang/nl_NL/firefly.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lang/nl_NL/firefly.php b/resources/lang/nl_NL/firefly.php index 30242ed88c..5642324633 100755 --- a/resources/lang/nl_NL/firefly.php +++ b/resources/lang/nl_NL/firefly.php @@ -39,7 +39,7 @@ return [ 'new_bill' => 'Nieuw contract', // export data: - 'import_and_export' => 'Importeren en exporteren', + 'import_and_export' => 'Import en export', 'export_data' => 'Exporteren', 'export_data_intro' => 'Om te backuppen, of wanneer je naar een ander systeem verhuist.', 'export_format' => 'Exporteerformaat', From 388d141d825a3df0a1e977beb7e1b0cf9b907f96 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 04:32:30 +0100 Subject: [PATCH 069/448] Fix for #172 --- app/Helpers/Report/ReportHelper.php | 13 ++++++++++--- public/js/reports/index.js | 8 ++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index 2e890fdb27..666fbcf4dc 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -178,10 +178,13 @@ class ReportHelper implements ReportHelperInterface /** @var FiscalHelperInterface $fiscalHelper */ $fiscalHelper = app('FireflyIII\Helpers\FiscalHelperInterface'); $start = clone $date; - $end = Carbon::now(); - $months = []; + $start->startOfMonth(); + $end = Carbon::now(); + $end->endOfMonth(); + $months = []; while ($start <= $end) { + // current year: $year = $fiscalHelper->endOfFiscalYear($start)->year; if (!isset($months[$year])) { @@ -196,6 +199,7 @@ class ReportHelper implements ReportHelperInterface $currentEnd = clone $start; $currentEnd->endOfMonth(); + $months[$year]['months'][] = [ 'formatted' => $start->formatLocalized('%B %Y'), 'start' => $start->format('Y-m-d'), @@ -203,7 +207,10 @@ class ReportHelper implements ReportHelperInterface 'month' => $start->month, 'year' => $year, ]; - $start->addMonth(); + + // to make the hop to the next month properly: + $start = clone $currentEnd; + $start->addDay(); } return $months; diff --git a/public/js/reports/index.js b/public/js/reports/index.js index c3c3a2b150..0419062234 100644 --- a/public/js/reports/index.js +++ b/public/js/reports/index.js @@ -34,8 +34,8 @@ $(function () { var startStr = readCookie('report-start'); var endStr = readCookie('report-end'); if (startStr !== null && endStr !== null && startStr.length == 8 && endStr.length == 8) { - var startDate = moment(startStr, "YYYYMMDD"); - var endDate = moment(endStr, "YYYYMMDD"); + var startDate = moment(startStr, "YYYY-MM-DD"); + var endDate = moment(endStr, "YYYY-MM-DD"); var datePicker = $('#inputDateRange').data('daterangepicker'); datePicker.setStartDate(startDate); datePicker.setEndDate(endDate); @@ -87,8 +87,8 @@ function preSelectDate(e) { "use strict"; var link = $(e.target); var picker = $('#inputDateRange').data('daterangepicker'); - picker.setStartDate(link.data('start')); - picker.setEndDate(link.data('end')); + picker.setStartDate(moment(link.data('start'), "YYYY-MM-DD")); + picker.setEndDate(moment(link.data('end'), "YYYY-MM-DD")); return false; } From 69d0c31ae579035f84b1b6d2690d83c73ba6a19c Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 04:55:41 +0100 Subject: [PATCH 070/448] Translation. --- resources/lang/en_US/firefly.php | 1 + resources/views/errors/500.twig | 61 ++++++++++++++++++++ resources/views/errors/FireflyException.twig | 61 ++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 resources/views/errors/500.twig create mode 100644 resources/views/errors/FireflyException.twig diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 72f8eb612e..e9d81cfc83 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -41,6 +41,7 @@ return [ // export data: 'import_and_export' => 'Import and export', + 'export_data_please_wait' => 'Please wait...', 'export_data' => 'Export data', 'export_data_intro' => 'For backup purposes, when migrating to another system or when migrating to another Firefly III installation.', 'export_format' => 'Export format', diff --git a/resources/views/errors/500.twig b/resources/views/errors/500.twig new file mode 100644 index 0000000000..a6bea4e28b --- /dev/null +++ b/resources/views/errors/500.twig @@ -0,0 +1,61 @@ + + + + + + + +
    +
    +
    Be right back.
    +
    +
    + + + + + + diff --git a/resources/views/errors/FireflyException.twig b/resources/views/errors/FireflyException.twig new file mode 100644 index 0000000000..282a8b08ee --- /dev/null +++ b/resources/views/errors/FireflyException.twig @@ -0,0 +1,61 @@ + + + + + + Firefly III + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +
    +
    +

    Whoops! An error occurred.

    +
    +
    + +
    +
    +

    + Unfortunately, this error was not recoverable. Firefly III broke. +

    +

    + {{ exception.getMessage |default('General unknown errror') }} +

    +
    +
    + +
    + + \ No newline at end of file From 241190c4da17544c19d5eeb6a199ac5d7030b057 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 05:01:34 +0100 Subject: [PATCH 071/448] More consistent error handling. --- app/Exceptions/Handler.php | 6 ++++++ app/Http/Controllers/BudgetController.php | 10 +++++----- app/Http/Controllers/CsvController.php | 16 ++-------------- app/Http/Controllers/ReportController.php | 4 ++-- app/Http/Controllers/TransactionController.php | 3 ++- public/css/firefly.css | 8 +++++++- resources/views/errors/FireflyException.twig | 2 +- 7 files changed, 25 insertions(+), 24 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 051918b803..0286b50696 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -37,9 +37,15 @@ class Handler extends ExceptionHandler */ public function render($request, Exception $exception) { + if ($exception instanceof FireflyException) { + + return response()->view('errors.FireflyException', ['exception' => $exception], 500); + } + return parent::render($request, $exception); } + /** * Report or log an exception. * diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index dbbbd7c969..642d7f4f56 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -3,6 +3,7 @@ use Amount; use Auth; use Carbon\Carbon; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Requests\BudgetFormRequest; use FireflyIII\Models\Budget; use FireflyIII\Models\LimitRepetition; @@ -224,16 +225,15 @@ class BudgetController extends Controller /** * @param BudgetRepositoryInterface $repository * @param Budget $budget - * @param LimitRepetition $repetition + * @param LimitRepetition|null $repetition * - * @return \Illuminate\View\View + * @return View + * @throws FireflyException */ public function show(BudgetRepositoryInterface $repository, Budget $budget, LimitRepetition $repetition = null) { if (!is_null($repetition->id) && $repetition->budgetLimit->budget->id != $budget->id) { - $message = 'Invalid selection.'; - - return view('error', compact('message')); + throw new FireflyException('This budget limit is not part of this budget.'); } $journals = $repository->getJournals($budget, $repetition, 50); diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 2193980f2d..1e2f3259c1 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -278,13 +278,7 @@ class CsvController extends Controller * field id => field identifier. * ] */ - try { - $options = $this->wizard->showOptions($this->data->getMap()); - } catch (FireflyException $e) { - Log::error($e->getMessage()); - - return view('error', ['message' => $e->getMessage()]); - } + $options = $this->wizard->showOptions($this->data->getMap()); // After these values are prepped, read the actual CSV file $reader = $this->data->getReader(); @@ -321,13 +315,7 @@ class CsvController extends Controller Log::debug('Created importer'); $importer = new Importer; $importer->setData($this->data); - try { - $importer->run(); - } catch (FireflyException $e) { - Log::error('Catch error: ' . $e->getMessage()); - - return view('error', ['message' => $e->getMessage()]); - } + $importer->run(); Log::debug('Done importing!'); $rows = $importer->getRows(); diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 6d1d4ba807..99c52c574c 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -1,6 +1,7 @@ with('message', 'End date cannot be before start date, silly!'); + throw new FireflyException('End date cannot be before start date, silly!') } // lower threshold diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 4081278afb..4c021ce78b 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -7,6 +7,7 @@ use Config; use ExpandedForm; use FireflyIII\Events\TransactionJournalStored; use FireflyIII\Events\TransactionJournalUpdated; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Http\Requests\JournalFormRequest; use FireflyIII\Models\PiggyBank; @@ -141,7 +142,7 @@ class TransactionController extends Controller { // cannot edit opening balance if ($journal->isOpeningBalance()) { - return view('error')->with('message', 'Cannot edit this transaction. Edit the account instead!'); + throw new FireflyException('Cannot edit this transaction (#' . $journal->id . '). Edit the account instead!'); } diff --git a/public/css/firefly.css b/public/css/firefly.css index 898a85a3be..ebcb8946b3 100644 --- a/public/css/firefly.css +++ b/public/css/firefly.css @@ -12,7 +12,13 @@ padding: 0; } - +.error-page { + background: #d2d6de; +} +.error-box { + width: 460px; + margin: 7% auto; +} /* cursors */ .rule-triggers {cursor:move;} diff --git a/resources/views/errors/FireflyException.twig b/resources/views/errors/FireflyException.twig index 282a8b08ee..c11c212d30 100644 --- a/resources/views/errors/FireflyException.twig +++ b/resources/views/errors/FireflyException.twig @@ -48,7 +48,7 @@

    - Unfortunately, this error was not recoverable. Firefly III broke. + Unfortunately, this error was not recoverable. Firefly III broke. The error is:

    {{ exception.getMessage |default('General unknown errror') }} From 0e0c475c83a87f1d172b49715c436290342d9b01 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 05:04:41 +0100 Subject: [PATCH 072/448] Forgot a thing. --- app/Http/Controllers/ReportController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 99c52c574c..1568c6d66a 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -84,7 +84,7 @@ class ReportController extends Controller { // throw an error if necessary. if ($end < $start) { - throw new FireflyException('End date cannot be before start date, silly!') + throw new FireflyException('End date cannot be before start date, silly!'); } // lower threshold From e56920edeebc13119cf1afbbe6ea613320c2db55 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 05:15:17 +0100 Subject: [PATCH 073/448] Speed up some tests. [skip ci] --- tests/acceptance/Controllers/BudgetControllerTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/acceptance/Controllers/BudgetControllerTest.php b/tests/acceptance/Controllers/BudgetControllerTest.php index 1462eeaf21..ab7c9e8463 100644 --- a/tests/acceptance/Controllers/BudgetControllerTest.php +++ b/tests/acceptance/Controllers/BudgetControllerTest.php @@ -6,6 +6,8 @@ * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ +use Carbon\Carbon; +use Illuminate\Pagination\LengthAwarePaginator; /** @@ -129,6 +131,12 @@ class BudgetControllerTest extends TestCase */ public function testShow($range) { + // mock some stuff: + $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); + $repository->shouldReceive('getJournals')->once()->andReturn(new LengthAwarePaginator([], 0, 50)); + $repository->shouldReceive('firstActivity')->once()->andReturn(new Carbon); + $repository->shouldReceive('spentPerDay')->once()->andReturn([]); + $this->be($this->user()); $this->changeDateRange($this->user(), $range); $this->call('GET', '/budgets/show/1'); From c9b56efaaaf535f072e9f00e21d3167d6b9b2b36 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 09:52:31 +0100 Subject: [PATCH 074/448] Mock stuff in tests. --- tests/acceptance/Controllers/AccountControllerTest.php | 4 ++++ tests/acceptance/Controllers/BillControllerTest.php | 5 +++++ tests/acceptance/Controllers/TransactionControllerTest.php | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/tests/acceptance/Controllers/AccountControllerTest.php b/tests/acceptance/Controllers/AccountControllerTest.php index 15e326bc4d..fe4a6085d4 100644 --- a/tests/acceptance/Controllers/AccountControllerTest.php +++ b/tests/acceptance/Controllers/AccountControllerTest.php @@ -6,6 +6,7 @@ * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ +use Illuminate\Pagination\LengthAwarePaginator; /** * Class AccountControllerTest @@ -82,6 +83,9 @@ class AccountControllerTest extends TestCase */ public function testShow($range) { + $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); + $repository->shouldReceive('getJournals')->once()->andReturn(new LengthAwarePaginator([], 0, 50)); + $this->be($this->user()); $this->changeDateRange($this->user(), $range); $this->call('GET', '/accounts/show/1'); diff --git a/tests/acceptance/Controllers/BillControllerTest.php b/tests/acceptance/Controllers/BillControllerTest.php index 023cb3eb05..4c06d4a045 100644 --- a/tests/acceptance/Controllers/BillControllerTest.php +++ b/tests/acceptance/Controllers/BillControllerTest.php @@ -6,6 +6,8 @@ * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ +use Carbon\Carbon; +use Illuminate\Support\Collection; /** @@ -94,6 +96,9 @@ class BillControllerTest extends TestCase */ public function testShow($range) { + $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); + $repository->shouldReceive('getJournals')->once()->andReturn(new Collection); + $repository->shouldReceive('nextExpectedMatch')->once()->andReturn(new Carbon); $this->be($this->user()); $this->changeDateRange($this->user(), $range); $this->call('GET', '/bills/show/1'); diff --git a/tests/acceptance/Controllers/TransactionControllerTest.php b/tests/acceptance/Controllers/TransactionControllerTest.php index 2b3e21ca51..83613b9fdb 100644 --- a/tests/acceptance/Controllers/TransactionControllerTest.php +++ b/tests/acceptance/Controllers/TransactionControllerTest.php @@ -6,6 +6,7 @@ * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ +use Illuminate\Pagination\LengthAwarePaginator; /** @@ -66,6 +67,9 @@ class TransactionControllerTest extends TestCase */ public function testIndex($range) { + $journals = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface'); + $journals->shouldReceive('getJournalsOfTypes')->once()->andReturn(new LengthAwarePaginator([], 0, 50)); + $this->be($this->user()); $this->changeDateRange($this->user(), $range); $this->call('GET', '/transactions/deposit'); From 466067bd95fb454546fcdcb17316275b2ac86ab4 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 10:11:06 +0100 Subject: [PATCH 075/448] Added PHP7 return type statements. --- app/Support/Binder/AccountList.php | 2 +- app/Support/Binder/BudgetList.php | 3 +- app/Support/Binder/CategoryList.php | 3 +- app/Support/Binder/Date.php | 2 +- app/Support/Facades/Amount.php | 2 +- app/Support/Facades/ExpandedForm.php | 2 +- app/Support/Facades/Navigation.php | 2 +- app/Support/Facades/Preferences.php | 2 +- app/Support/Facades/Steam.php | 2 +- app/Support/Migration/TestData.php | 133 +++++++++++++++++++-------- app/User.php | 54 +++++------ app/Validation/FireflyValidator.php | 70 +++++++------- 12 files changed, 169 insertions(+), 108 deletions(-) diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.php index 3028d88f1c..29cfd8e7ea 100644 --- a/app/Support/Binder/AccountList.php +++ b/app/Support/Binder/AccountList.php @@ -31,7 +31,7 @@ class AccountList implements BinderInterface * * @return Collection */ - public static function routeBinder($value, $route) + public static function routeBinder($value, $route): Collection { if (Auth::check()) { diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.php index e957adad65..875d5e249b 100644 --- a/app/Support/Binder/BudgetList.php +++ b/app/Support/Binder/BudgetList.php @@ -12,6 +12,7 @@ namespace FireflyIII\Support\Binder; use Auth; use FireflyIII\Models\Budget; +use Illuminate\Support\Collection; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -29,7 +30,7 @@ class BudgetList implements BinderInterface * * @return mixed */ - public static function routeBinder($value, $route) + public static function routeBinder($value, $route): Collection { if (Auth::check()) { $ids = explode(',', $value); diff --git a/app/Support/Binder/CategoryList.php b/app/Support/Binder/CategoryList.php index a212d302c0..de14aa583b 100644 --- a/app/Support/Binder/CategoryList.php +++ b/app/Support/Binder/CategoryList.php @@ -12,6 +12,7 @@ namespace FireflyIII\Support\Binder; use Auth; use FireflyIII\Models\Category; +use Illuminate\Support\Collection; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -28,7 +29,7 @@ class CategoryList implements BinderInterface * * @return mixed */ - public static function routeBinder($value, $route) + public static function routeBinder($value, $route): Collection { if (Auth::check()) { $ids = explode(',', $value); diff --git a/app/Support/Binder/Date.php b/app/Support/Binder/Date.php index e910bc07d9..886c6090be 100644 --- a/app/Support/Binder/Date.php +++ b/app/Support/Binder/Date.php @@ -32,7 +32,7 @@ class Date implements BinderInterface * * @return mixed */ - public static function routeBinder($value, $route) + public static function routeBinder($value, $route): Carbon { $fiscalHelper = new FiscalHelper; diff --git a/app/Support/Facades/Amount.php b/app/Support/Facades/Amount.php index 2a9c0d01a0..c6d2b43250 100644 --- a/app/Support/Facades/Amount.php +++ b/app/Support/Facades/Amount.php @@ -18,7 +18,7 @@ class Amount extends Facade * * @return string */ - protected static function getFacadeAccessor() + protected static function getFacadeAccessor(): string { return 'amount'; } diff --git a/app/Support/Facades/ExpandedForm.php b/app/Support/Facades/ExpandedForm.php index 2fe33eedb1..006a88f2c3 100644 --- a/app/Support/Facades/ExpandedForm.php +++ b/app/Support/Facades/ExpandedForm.php @@ -18,7 +18,7 @@ class ExpandedForm extends Facade * * @return string */ - protected static function getFacadeAccessor() + protected static function getFacadeAccessor(): string { return 'expandedform'; } diff --git a/app/Support/Facades/Navigation.php b/app/Support/Facades/Navigation.php index cfbc44188d..dba4ed838b 100644 --- a/app/Support/Facades/Navigation.php +++ b/app/Support/Facades/Navigation.php @@ -18,7 +18,7 @@ class Navigation extends Facade * * @return string */ - protected static function getFacadeAccessor() + protected static function getFacadeAccessor(): string { return 'navigation'; } diff --git a/app/Support/Facades/Preferences.php b/app/Support/Facades/Preferences.php index 9b406b97f7..06b7033813 100644 --- a/app/Support/Facades/Preferences.php +++ b/app/Support/Facades/Preferences.php @@ -18,7 +18,7 @@ class Preferences extends Facade * * @return string */ - protected static function getFacadeAccessor() + protected static function getFacadeAccessor(): string { return 'preferences'; } diff --git a/app/Support/Facades/Steam.php b/app/Support/Facades/Steam.php index 69655ac55b..5c93adcd8b 100644 --- a/app/Support/Facades/Steam.php +++ b/app/Support/Facades/Steam.php @@ -18,7 +18,7 @@ class Steam extends Facade * * @return string */ - protected static function getFacadeAccessor() + protected static function getFacadeAccessor(): string { return 'steam'; } diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php index c488655083..8731dd1cac 100644 --- a/app/Support/Migration/TestData.php +++ b/app/Support/Migration/TestData.php @@ -43,8 +43,10 @@ class TestData /** * @param User $user + * + * @return bool */ - public static function createAssetAccounts(User $user) + public static function createAssetAccounts(User $user): bool { $assets = ['TestData Checking Account', 'TestData Savings', 'TestData Shared', 'TestData Creditcard', 'Emergencies', 'STE']; // first two ibans match test-upload.csv @@ -75,13 +77,17 @@ class TestData } } + return true; + } /** * @param User $user * @param Carbon $start + * + * @return TransactionJournal */ - public static function createAttachments(User $user, Carbon $start) + public static function createAttachments(User $user, Carbon $start): TransactionJournal { $toAccount = TestData::findAccount($user, 'TestData Checking Account'); @@ -138,12 +144,15 @@ class TestData file_put_contents(storage_path('upload/at-' . $one->id . '.data'), $encrypted); file_put_contents(storage_path('upload/at-' . $two->id . '.data'), $encrypted); + return $journal; } /** * @param User $user + * + * @return bool */ - public static function createBills(User $user) + public static function createBills(User $user): bool { Bill::create( [ @@ -174,15 +183,19 @@ class TestData ] ); + return true; + } /** * @param User $user * @param Carbon $current - * @param $name - * @param $amount + * @param string $name + * @param string $amount + * + * @return BudgetLimit */ - public static function createBudgetLimit(User $user, Carbon $current, string $name, string $amount) + public static function createBudgetLimit(User $user, Carbon $current, string $name, string $amount): BudgetLimit { $start = clone $current; $end = clone $current; @@ -190,7 +203,7 @@ class TestData $start->startOfMonth(); $end->endOfMonth(); - BudgetLimit::create( + $limit = BudgetLimit::create( [ 'budget_id' => $budget->id, 'startdate' => $start->format('Y-m-d'), @@ -199,12 +212,16 @@ class TestData 'repeat_freq' => 'monthly', ] ); + + return $limit; } /** * @param User $user + * + * @return bool */ - public static function createBudgets(User $user) + public static function createBudgets(User $user): bool { Budget::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]); Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]); @@ -214,16 +231,18 @@ class TestData foreach (['A', 'B', 'C', 'D', "E"] as $letter) { Budget::firstOrCreateEncrypted(['name' => 'Empty budget ' . $letter, 'user_id' => $user->id]); } + + return true; } /** * @param User $user * @param Carbon $date * - * @return static + * @return TransactionJournal * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public static function createCar(User $user, Carbon $date) + public static function createCar(User $user, Carbon $date): TransactionJournal { // twice: $date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th @@ -262,7 +281,7 @@ class TestData 'date' => $date, ] ); - self::createTransactions($journal, $fromAccount, $toAccount, '100'); + self::createTransactions($journal, $fromAccount, $toAccount, strval($amount)); // and again! @@ -271,19 +290,26 @@ class TestData /** * @param User $user + * + * @return bool */ - public static function createCategories(User $user) + public static function createCategories(User $user): bool { Category::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]); Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]); + + return true; } /** * @param User $user * @param Carbon $date + * + * @return bool + * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public static function createDrinksAndOthers(User $user, Carbon $date) + public static function createDrinksAndOthers(User $user, Carbon $date): bool { $start = clone $date; $end = clone $date; @@ -321,15 +347,19 @@ class TestData $current->addWeek(); } + + return true; } /** * @param User $user + * + * @return bool */ - public static function createExpenseAccounts(User $user) + public static function createExpenseAccounts(User $user): bool { $expenses = ['Adobe', 'Google', 'Vitens', 'Albert Heijn', 'PLUS', 'Apple', 'Bakker', 'Belastingdienst', 'bol.com', 'Cafe Central', 'conrad.nl', - 'coolblue', 'Shell', + 'Coolblue', 'Shell', 'DUO', 'Etos', 'FEBO', 'Greenchoice', 'Halfords', 'XS4All', 'iCentre', 'Jumper', 'Land lord']; foreach ($expenses as $name) { // create account: @@ -344,14 +374,19 @@ class TestData ); } + return true; + } /** * @param User $user * @param Carbon $date + * + * @return bool + * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public static function createGroceries(User $user, Carbon $date) + public static function createGroceries(User $user, Carbon $date): bool { bcscale(2); $start = clone $date; @@ -392,6 +427,8 @@ class TestData $current->addDay(); } + + return true; } /** @@ -432,10 +469,13 @@ class TestData } /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @param User $user + * + * @return bool + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public static function createPiggybanks(User $user) + public static function createPiggybanks(User $user): bool { $account = self::findAccount($user, 'TestData Savings'); @@ -567,6 +607,7 @@ class TestData ] ); + return true; } /** @@ -577,7 +618,7 @@ class TestData * * @return TransactionJournal */ - public static function createPower(User $user, string $description, Carbon $date, string $amount) + public static function createPower(User $user, string $description, Carbon $date, string $amount): TransactionJournal { $date = new Carbon($date->format('Y-m') . '-06'); // paid on 10th $fromAccount = TestData::findAccount($user, 'TestData Checking Account'); @@ -638,8 +679,10 @@ class TestData /** * @param User $user + * + * @return bool */ - public static function createRevenueAccounts(User $user) + public static function createRevenueAccounts(User $user): bool { $revenues = ['Job', 'Belastingdienst', 'Bank', 'KPN', 'Google']; foreach ($revenues as $name) { @@ -654,12 +697,16 @@ class TestData ] ); } + + return true; } /** * @param User $user + * + * @return RuleGroup */ - public static function createRules(User $user) + public static function createRules(User $user): RuleGroup { $group = RuleGroup::create( [ @@ -733,6 +780,8 @@ class TestData 'action_value' => trans('firefly.default_rule_action_set_category'), ] ); + + return $group; } /** @@ -772,9 +821,9 @@ class TestData * @param Carbon $date * @param string $amount * - * @return static + * @return TransactionJournal */ - public static function createTV(User $user, string $description, Carbon $date, string $amount) + public static function createTV(User $user, string $description, Carbon $date, string $amount): TransactionJournal { $date = new Carbon($date->format('Y-m') . '-15'); // paid on 10th $fromAccount = TestData::findAccount($user, 'TestData Checking Account'); @@ -801,26 +850,27 @@ class TestData } /** - * @param User $user - * @param Carbon|null $date + * @param User $user + * @param Carbon $date + * + * @return Tag */ - public static function createTags(User $user, Carbon $date = null) + public static function createTags(User $user, Carbon $date): Tag { - $title = 'SomeTag nr. ' . rand(1, 1234); - if (!is_null($date)) { - $title = 'SomeTag' . $date->month . '.' . $date->year . '.nothing'; - } + $title = 'SomeTag' . $date->month . '.' . $date->year . '.nothing'; - Tag::create( + $tag = Tag::create( [ 'user_id' => $user->id, 'tag' => $title, 'tagMode' => 'nothing', - 'date' => is_null($date) ? null : $date->format('Y-m-d'), + 'date' => $date->format('Y-m-d'), ] ); + + return $tag; } /** @@ -828,8 +878,10 @@ class TestData * @param Account $from * @param Account $to * @param string $amount + * + * @return bool */ - public static function createTransactions(TransactionJournal $journal, Account $from, Account $to, string $amount) + public static function createTransactions(TransactionJournal $journal, Account $from, Account $to, string $amount): bool { Log::debug('---- Transaction From: ' . bcmul($amount, '-1')); Log::debug('---- Transaction To : ' . $amount); @@ -849,6 +901,8 @@ class TestData ] ); + + return true; } /** @@ -873,7 +927,7 @@ class TestData * @param Carbon $date * @param string $amount * - * @return TransactionJournal|static + * @return TransactionJournal */ public static function createWater(User $user, string $description, Carbon $date, string $amount): TransactionJournal { @@ -922,9 +976,9 @@ class TestData * @param User $user * @param $name * - * @return Budget|null + * @return Budget */ - public static function findBudget(User $user, string $name) + public static function findBudget(User $user, string $name): Budget { /** @var Budget $budget */ foreach (Budget::get() as $budget) { @@ -934,14 +988,16 @@ class TestData } } - return null; + return new Budget; } /** * @param User $user * @param Carbon $date + * + * @return TransactionJournal */ - public static function openingBalanceSavings(User $user, Carbon $date) + public static function openingBalanceSavings(User $user, Carbon $date): TransactionJournal { // opposing account for opening balance: $opposing = Account::create( @@ -968,6 +1024,7 @@ class TestData ] ); self::createTransactions($journal, $opposing, $savings, '10000'); + return $journal; } diff --git a/app/User.php b/app/User.php index 917ea694a0..3f0b86d787 100644 --- a/app/User.php +++ b/app/User.php @@ -3,6 +3,8 @@ declare(strict_types = 1); namespace FireflyIII; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Foundation\Auth\User as Authenticatable; use Zizaco\Entrust\Traits\EntrustUserTrait; @@ -60,105 +62,105 @@ class User extends Authenticatable protected $table = 'users'; /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return HasMany */ - public function accounts() + public function accounts(): HasMany { return $this->hasMany('FireflyIII\Models\Account'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return HasMany */ - public function attachments() + public function attachments(): HasMany { return $this->hasMany('FireflyIII\Models\Attachment'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return HasMany */ - public function bills() + public function bills(): HasMany { return $this->hasMany('FireflyIII\Models\Bill'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return HasMany */ - public function budgets() + public function budgets(): HasMany { return $this->hasMany('FireflyIII\Models\Budget'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return HasMany */ - public function categories() + public function categories(): HasMany { return $this->hasMany('FireflyIII\Models\Category'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return HasMany */ - public function exportjobs() + public function exportjobs(): HasMany { return $this->hasMany('FireflyIII\Models\ExportJob'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough + * @return HasManyThrough */ - public function piggyBanks() + public function piggyBanks(): HasManyThrough { return $this->hasManyThrough('FireflyIII\Models\PiggyBank', 'FireflyIII\Models\Account'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return HasMany */ - public function preferences() + public function preferences(): HasMany { return $this->hasMany('FireflyIII\Models\Preference'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return HasMany */ - public function ruleGroups() + public function ruleGroups(): HasMany { return $this->hasMany('FireflyIII\Models\RuleGroup'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return HasMany */ - public function rules() + public function rules(): HasMany { return $this->hasMany('FireflyIII\Models\Rule'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return HasMany */ - public function tags() + public function tags(): HasMany { return $this->hasMany('FireflyIII\Models\Tag'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return HasMany */ - public function transactionjournals() + public function transactionjournals(): HasMany { return $this->hasMany('FireflyIII\Models\TransactionJournal'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough + * @return HasManyThrough */ - public function transactions() + public function transactions(): HasManyThrough { return $this->hasManyThrough('FireflyIII\Models\Transaction', 'FireflyIII\Models\TransactionJournal'); } diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index b640d8a6fc..b0517f8bd2 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -48,7 +48,7 @@ class FireflyValidator extends Validator * * @return bool */ - public function validateBelongsToUser($attribute, $value, $parameters) + public function validateBelongsToUser($attribute, $value, $parameters): bool { $field = $parameters[1] ?? 'id'; @@ -70,7 +70,7 @@ class FireflyValidator extends Validator * * @return bool */ - public function validateIban($attribute, $value) + public function validateIban($attribute, $value): bool { if (!is_string($value) || is_null($value) || strlen($value) < 6) { return false; @@ -97,7 +97,7 @@ class FireflyValidator extends Validator * * @return bool */ - public function validateRuleActionValue($attribute) + public function validateRuleActionValue($attribute): bool { // get the index from a string like "rule-action-value.2". $parts = explode('.', $attribute); @@ -139,7 +139,7 @@ class FireflyValidator extends Validator * * @return bool */ - public function validateRuleTriggerValue($attribute) + public function validateRuleTriggerValue($attribute): bool { // get the index from a string like "rule-trigger-value.2". $parts = explode('.', $attribute); @@ -176,7 +176,7 @@ class FireflyValidator extends Validator * * @return bool */ - public function validateUniqueAccountForUser($attribute, $value, $parameters) + public function validateUniqueAccountForUser($attribute, $value, $parameters): bool { // because a user does not have to be logged in (tests and what-not). if (!Auth::check()) { @@ -207,7 +207,7 @@ class FireflyValidator extends Validator * * @return bool */ - public function validateUniqueForUser($attribute, $value, $parameters) + public function validateUniqueForUser($attribute, $value, $parameters): bool { $query = DB::table($parameters[0])->where($parameters[1], $value); $query->where('user_id', Auth::user()->id); @@ -238,7 +238,7 @@ class FireflyValidator extends Validator * * @return bool */ - public function validateUniqueObjectForUser($attribute, $value, $parameters) + public function validateUniqueObjectForUser($attribute, $value, $parameters): bool { $value = $this->tryDecrypt($value); // exclude? @@ -271,9 +271,9 @@ class FireflyValidator extends Validator * * @return bool */ - public function validateUniquePiggyBankForUser($attribute, $value, $parameters) + public function validateUniquePiggyBankForUser($attribute, $value, $parameters): bool { - $exclude = $parameters[0] ?? null; + $exclude = $parameters[0] ?? null; $query = DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at') ->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id); if (!is_null($exclude)) { @@ -292,12 +292,33 @@ class FireflyValidator extends Validator return true; } + /** + * @param int $index + * + * @return string + */ + private function getRuleTriggerName($index): string + { + return $this->data['rule-trigger'][$index] ?? 'invalid'; + + } + + /** + * @param int $index + * + * @return string + */ + private function getRuleTriggerValue($index): string + { + return $this->data['rule-trigger-value'][$index] ?? ''; + } + /** * @param $value * * @return mixed */ - protected function tryDecrypt($value) + private function tryDecrypt($value) { try { $value = Crypt::decrypt($value); @@ -311,7 +332,7 @@ class FireflyValidator extends Validator /** * @return bool */ - protected function validateAccountAnonymously() + private function validateAccountAnonymously(): bool { if (!isset($this->data['user_id'])) { return false; @@ -340,7 +361,7 @@ class FireflyValidator extends Validator * @internal param $parameters * */ - protected function validateByAccountId($value) + private function validateByAccountId($value): bool { /** @var Account $existingAccount */ $existingAccount = Account::find($this->data['id']); @@ -367,7 +388,7 @@ class FireflyValidator extends Validator * * @return bool */ - protected function validateByAccountTypeId($value, $parameters) + private function validateByAccountTypeId($value, $parameters): bool { $type = AccountType::find($this->data['account_type_id'])->first(); $ignore = $parameters[0] ?? 0; @@ -391,7 +412,7 @@ class FireflyValidator extends Validator * * @return bool */ - protected function validateByAccountTypeString($value, $parameters) + private function validateByAccountTypeString($value, $parameters): bool { $search = Config::get('firefly.accountTypeByIdentifier.' . $this->data['what']); $type = AccountType::whereType($search)->first(); @@ -407,26 +428,5 @@ class FireflyValidator extends Validator return true; } - - /** - * @param int $index - * - * @return string - */ - private function getRuleTriggerName($index) - { - return $this->data['rule-trigger'][$index] ?? 'invalid'; - - } - - /** - * @param int $index - * - * @return string - */ - private function getRuleTriggerValue($index) - { - return $this->data['rule-trigger-value'][$index] ?? ''; - } } From aa38b31015581445197250d9c6ca3934fcc30470 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 10:15:07 +0100 Subject: [PATCH 076/448] Added PHP7 return type statements. --- app/Support/Search/Search.php | 10 +++---- app/Support/Search/SearchInterface.php | 10 +++---- app/Support/Twig/Budget.php | 4 +-- app/Support/Twig/General.php | 36 +++++++++++++------------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.php index d4fc3783ab..5af6acd5d1 100644 --- a/app/Support/Search/Search.php +++ b/app/Support/Search/Search.php @@ -23,7 +23,7 @@ class Search implements SearchInterface * * @return Collection */ - public function searchAccounts(array $words) + public function searchAccounts(array $words): Collection { return Auth::user()->accounts()->with('accounttype')->where( function (EloquentBuilder $q) use ($words) { @@ -39,7 +39,7 @@ class Search implements SearchInterface * * @return Collection */ - public function searchBudgets(array $words) + public function searchBudgets(array $words): Collection { /** @var Collection $set */ $set = Auth::user()->budgets()->get(); @@ -64,7 +64,7 @@ class Search implements SearchInterface * * @return Collection */ - public function searchCategories(array $words) + public function searchCategories(array $words): Collection { /** @var Collection $set */ $set = Auth::user()->categories()->get(); @@ -90,7 +90,7 @@ class Search implements SearchInterface * * @return Collection */ - public function searchTags(array $words) + public function searchTags(array $words): Collection { return new Collection; } @@ -100,7 +100,7 @@ class Search implements SearchInterface * * @return Collection */ - public function searchTransactions(array $words) + public function searchTransactions(array $words): Collection { // decrypted transaction journals: $decrypted = Auth::user()->transactionjournals()->withRelevantData()->where('encrypted', 0)->where( diff --git a/app/Support/Search/SearchInterface.php b/app/Support/Search/SearchInterface.php index ea862d5060..c44c0d8285 100644 --- a/app/Support/Search/SearchInterface.php +++ b/app/Support/Search/SearchInterface.php @@ -17,21 +17,21 @@ interface SearchInterface * * @return Collection */ - public function searchAccounts(array $words); + public function searchAccounts(array $words): Collection; /** * @param array $words * * @return Collection */ - public function searchBudgets(array $words); + public function searchBudgets(array $words): Collection; /** * @param array $words * * @return Collection */ - public function searchCategories(array $words); + public function searchCategories(array $words): Collection; /** * @@ -39,12 +39,12 @@ interface SearchInterface * * @return Collection */ - public function searchTags(array $words); + public function searchTags(array $words): Collection; /** * @param array $words * * @return Collection */ - public function searchTransactions(array $words); + public function searchTransactions(array $words): Collection; } diff --git a/app/Support/Twig/Budget.php b/app/Support/Twig/Budget.php index 938cabb929..d3a1d0cd89 100644 --- a/app/Support/Twig/Budget.php +++ b/app/Support/Twig/Budget.php @@ -20,7 +20,7 @@ class Budget extends Twig_Extension /** * {@inheritDoc} */ - public function getFunctions() + public function getFunctions(): array { $functions = []; $functions[] = new Twig_SimpleFunction( @@ -53,7 +53,7 @@ class Budget extends Twig_Extension /** * {@inheritDoc} */ - public function getName() + public function getName(): string { return 'FireflyIII\Support\Twig\Budget'; } diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index 55a5dd1093..b0c728fc10 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -28,7 +28,7 @@ class General extends Twig_Extension /** * @return array */ - public function getFilters() + public function getFilters(): array { return [ $this->formatAmount(), @@ -46,7 +46,7 @@ class General extends Twig_Extension /** * {@inheritDoc} */ - public function getFunctions() + public function getFunctions(): array { return [ $this->getCurrencyCode(), @@ -64,7 +64,7 @@ class General extends Twig_Extension /** * {@inheritDoc} */ - public function getName() + public function getName(): string { return 'FireflyIII\Support\Twig\General'; } @@ -75,10 +75,10 @@ class General extends Twig_Extension * * @return Twig_SimpleFunction */ - protected function activeRoutePartial() + protected function activeRoutePartial(): Twig_SimpleFunction { return new Twig_SimpleFunction( - 'activeRoutePartial', function () { + 'activeRoutePartial', function () : string { $args = func_get_args(); $route = $args[0]; // name of the route. if (!(strpos(Route::getCurrentRoute()->getName(), $route) === false)) { @@ -96,7 +96,7 @@ class General extends Twig_Extension * * @return Twig_SimpleFunction */ - protected function activeRoutePartialWhat() + protected function activeRoutePartialWhat(): Twig_SimpleFunction { return new Twig_SimpleFunction( 'activeRoutePartialWhat', function ($context) { @@ -120,7 +120,7 @@ class General extends Twig_Extension * * @return Twig_SimpleFunction */ - protected function activeRouteStrict() + protected function activeRouteStrict(): Twig_SimpleFunction { return new Twig_SimpleFunction( 'activeRouteStrict', function () { @@ -139,7 +139,7 @@ class General extends Twig_Extension /** * @return Twig_SimpleFilter */ - protected function balance() + protected function balance(): Twig_SimpleFilter { return new Twig_SimpleFilter( 'balance', function (Account $account = null) { @@ -156,7 +156,7 @@ class General extends Twig_Extension /** * @return Twig_SimpleFunction */ - protected function env() + protected function env(): Twig_SimpleFunction { return new Twig_SimpleFunction( 'env', function (string $name, string $default) { @@ -169,7 +169,7 @@ class General extends Twig_Extension * * @return Twig_SimpleFilter */ - protected function formatAmount() + protected function formatAmount(): Twig_SimpleFilter { return new Twig_SimpleFilter( 'formatAmount', function (string $string) { @@ -182,7 +182,7 @@ class General extends Twig_Extension /** * @return Twig_SimpleFilter */ - protected function formatAmountPlain() + protected function formatAmountPlain(): Twig_SimpleFilter { return new Twig_SimpleFilter( 'formatAmountPlain', function (string $string) { @@ -195,7 +195,7 @@ class General extends Twig_Extension /** * @return Twig_SimpleFilter */ - protected function formatFilesize() + protected function formatFilesize(): Twig_SimpleFilter { return new Twig_SimpleFilter( 'filesize', function (int $size) { @@ -218,7 +218,7 @@ class General extends Twig_Extension /** * @return Twig_SimpleFilter */ - protected function formatJournal() + protected function formatJournal(): Twig_SimpleFilter { return new Twig_SimpleFilter( 'formatJournal', function (TransactionJournal $journal) { @@ -230,7 +230,7 @@ class General extends Twig_Extension /** * @return Twig_SimpleFilter */ - protected function formatTransaction() + protected function formatTransaction(): Twig_SimpleFilter { return new Twig_SimpleFilter( 'formatTransaction', function (Transaction $transaction) { @@ -242,7 +242,7 @@ class General extends Twig_Extension /** * @return Twig_SimpleFilter */ - protected function getAccountRole() + protected function getAccountRole(): Twig_SimpleFilter { return new Twig_SimpleFilter( 'getAccountRole', function (string $name) { @@ -254,7 +254,7 @@ class General extends Twig_Extension /** * @return Twig_SimpleFunction */ - protected function getCurrencyCode() + protected function getCurrencyCode(): Twig_SimpleFunction { return new Twig_SimpleFunction( 'getCurrencyCode', function () { @@ -266,7 +266,7 @@ class General extends Twig_Extension /** * @return Twig_SimpleFunction */ - protected function getCurrencySymbol() + protected function getCurrencySymbol(): Twig_SimpleFunction { return new Twig_SimpleFunction( 'getCurrencySymbol', function () { @@ -278,7 +278,7 @@ class General extends Twig_Extension /** * @return Twig_SimpleFilter */ - protected function mimeIcon() + protected function mimeIcon(): Twig_SimpleFilter { return new Twig_SimpleFilter( 'mimeIcon', function (string $string) { From d1a184e3f2da3fdbdc4f40e35e3502a5bfb58dc5 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 10:17:41 +0100 Subject: [PATCH 077/448] Added PHP7 return type statements. --- app/Support/Amount.php | 4 ++-- app/Support/Steam.php | 2 +- app/Support/Twig/General.php | 28 ++++++++++++++-------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/Support/Amount.php b/app/Support/Amount.php index b4f1df5a4d..84b08b3da7 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -24,7 +24,7 @@ class Amount * * @return string */ - public function format(string $amount, bool $coloured = true) + public function format(string $amount, bool $coloured = true): string { return $this->formatAnything($this->getDefaultCurrency(), $amount, $coloured); } @@ -39,7 +39,7 @@ class Amount * * @return string */ - public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = true) + public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = true): string { $locale = setlocale(LC_MONETARY, 0); $float = floatval($amount); diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 8779d7cc4b..60f1506403 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -25,7 +25,7 @@ class Steam * * @return string */ - public function balance(Account $account, Carbon $date, $ignoreVirtualBalance = false) + public function balance(Account $account, Carbon $date, $ignoreVirtualBalance = false): string { // abuse chart properties: diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index b0c728fc10..1ae282f199 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -99,7 +99,7 @@ class General extends Twig_Extension protected function activeRoutePartialWhat(): Twig_SimpleFunction { return new Twig_SimpleFunction( - 'activeRoutePartialWhat', function ($context) { + 'activeRoutePartialWhat', function ($context) : string { $args = func_get_args(); $route = $args[1]; // name of the route. $what = $args[2]; // name of the route. @@ -123,7 +123,7 @@ class General extends Twig_Extension protected function activeRouteStrict(): Twig_SimpleFunction { return new Twig_SimpleFunction( - 'activeRouteStrict', function () { + 'activeRouteStrict', function () : string { $args = func_get_args(); $route = $args[0]; // name of the route. @@ -142,7 +142,7 @@ class General extends Twig_Extension protected function balance(): Twig_SimpleFilter { return new Twig_SimpleFilter( - 'balance', function (Account $account = null) { + 'balance', function (Account $account = null) : string { if (is_null($account)) { return 'NULL'; } @@ -159,7 +159,7 @@ class General extends Twig_Extension protected function env(): Twig_SimpleFunction { return new Twig_SimpleFunction( - 'env', function (string $name, string $default) { + 'env', function (string $name, string $default) : string { return env($name, $default); } ); @@ -172,7 +172,7 @@ class General extends Twig_Extension protected function formatAmount(): Twig_SimpleFilter { return new Twig_SimpleFilter( - 'formatAmount', function (string $string) { + 'formatAmount', function (string $string) : string { return app('amount')->format($string); }, ['is_safe' => ['html']] @@ -185,7 +185,7 @@ class General extends Twig_Extension protected function formatAmountPlain(): Twig_SimpleFilter { return new Twig_SimpleFilter( - 'formatAmountPlain', function (string $string) { + 'formatAmountPlain', function (string $string) : string { return app('amount')->format($string, false); }, ['is_safe' => ['html']] @@ -198,7 +198,7 @@ class General extends Twig_Extension protected function formatFilesize(): Twig_SimpleFilter { return new Twig_SimpleFilter( - 'filesize', function (int $size) { + 'filesize', function (int $size) : string { // less than one GB, more than one MB if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) { @@ -221,7 +221,7 @@ class General extends Twig_Extension protected function formatJournal(): Twig_SimpleFilter { return new Twig_SimpleFilter( - 'formatJournal', function (TransactionJournal $journal) { + 'formatJournal', function (TransactionJournal $journal) : string { return app('amount')->formatJournal($journal); }, ['is_safe' => ['html']] ); @@ -233,7 +233,7 @@ class General extends Twig_Extension protected function formatTransaction(): Twig_SimpleFilter { return new Twig_SimpleFilter( - 'formatTransaction', function (Transaction $transaction) { + 'formatTransaction', function (Transaction $transaction) : string { return app('amount')->formatTransaction($transaction); }, ['is_safe' => ['html']] ); @@ -245,7 +245,7 @@ class General extends Twig_Extension protected function getAccountRole(): Twig_SimpleFilter { return new Twig_SimpleFilter( - 'getAccountRole', function (string $name) { + 'getAccountRole', function (string $name) : string { return Config::get('firefly.accountRoles.' . $name); } ); @@ -257,7 +257,7 @@ class General extends Twig_Extension protected function getCurrencyCode(): Twig_SimpleFunction { return new Twig_SimpleFunction( - 'getCurrencyCode', function () { + 'getCurrencyCode', function () : string { return app('amount')->getCurrencyCode(); } ); @@ -269,7 +269,7 @@ class General extends Twig_Extension protected function getCurrencySymbol(): Twig_SimpleFunction { return new Twig_SimpleFunction( - 'getCurrencySymbol', function () { + 'getCurrencySymbol', function () : string { return app('amount')->getCurrencySymbol(); } ); @@ -281,7 +281,7 @@ class General extends Twig_Extension protected function mimeIcon(): Twig_SimpleFilter { return new Twig_SimpleFilter( - 'mimeIcon', function (string $string) { + 'mimeIcon', function (string $string) : string { switch ($string) { default: return 'fa-file-o'; @@ -301,7 +301,7 @@ class General extends Twig_Extension protected function phpdate() { return new Twig_SimpleFunction( - 'phpdate', function (string $str) { + 'phpdate', function (string $str) : string { return date($str); } ); From 1d0cb45e4c91f30ac8314bd01d4bcbb137a91730 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 15:00:48 +0100 Subject: [PATCH 078/448] List in translation. --- resources/lang/en_US/firefly.php | 180 +++++++++++++++++-------------- resources/lang/en_US/form.php | 1 + 2 files changed, 98 insertions(+), 83 deletions(-) diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index e9d81cfc83..e66602d6c2 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -2,93 +2,107 @@ return [ // general stuff: - 'language_incomplete' => 'This language is not yet fully translated', - 'test' => 'You have selected English.', - 'close' => 'Close', - 'pleaseHold' => 'Please hold...', - 'actions' => 'Actions', - 'edit' => 'Edit', - 'delete' => 'Delete', - 'welcomeBack' => 'What\'s playing?', - 'everything' => 'Everything', - 'customRange' => 'Custom range', - 'apply' => 'Apply', - 'cancel' => 'Cancel', - 'from' => 'From', - 'to' => 'To', - 'total_sum' => 'Total sum', - 'period_sum' => 'Sum for period', - 'showEverything' => 'Show everything', - 'never' => 'Never', - 'search_results_for' => 'Search results for ":query"', - 'search' => 'Search', - 'bounced_error' => 'The message sent to :email bounced, so no access for you.', - 'deleted_error' => 'These credentials do not match our records.', - 'general_blocked_error' => 'Your account has been disabled, so you cannot login.', - 'removed_amount' => 'Removed :amount', - 'added_amount' => 'Added :amount', - 'asset_account_role_help' => 'Any extra options resulting from your choice can be set later.', - 'Opening balance' => 'Opening balance', - 'create_new_stuff' => 'Create new stuff', - 'new_withdrawal' => 'New withdrawal', - 'new_deposit' => 'New deposit', - 'new_transfer' => 'New transfer', - 'new_asset_account' => 'New asset account', - 'new_expense_account' => 'New expense account', - 'new_revenue_account' => 'New revenue account', - 'new_budget' => 'New budget', - 'new_bill' => 'New bill', + 'language_incomplete' => 'This language is not yet fully translated', + 'test' => 'You have selected English.', + 'close' => 'Close', + 'pleaseHold' => 'Please hold...', + 'actions' => 'Actions', + 'edit' => 'Edit', + 'delete' => 'Delete', + 'welcomeBack' => 'What\'s playing?', + 'everything' => 'Everything', + 'customRange' => 'Custom range', + 'apply' => 'Apply', + 'cancel' => 'Cancel', + 'from' => 'From', + 'to' => 'To', + 'total_sum' => 'Total sum', + 'period_sum' => 'Sum for period', + 'showEverything' => 'Show everything', + 'never' => 'Never', + 'search_results_for' => 'Search results for ":query"', + 'bounced_error' => 'The message sent to :email bounced, so no access for you.', + 'deleted_error' => 'These credentials do not match our records.', + 'general_blocked_error' => 'Your account has been disabled, so you cannot login.', + 'removed_amount' => 'Removed :amount', + 'added_amount' => 'Added :amount', + 'asset_account_role_help' => 'Any extra options resulting from your choice can be set later.', + 'Opening balance' => 'Opening balance', + 'create_new_stuff' => 'Create new stuff', + 'new_withdrawal' => 'New withdrawal', + 'new_deposit' => 'New deposit', + 'new_transfer' => 'New transfer', + 'new_asset_account' => 'New asset account', + 'new_expense_account' => 'New expense account', + 'new_revenue_account' => 'New revenue account', + 'new_budget' => 'New budget', + 'new_bill' => 'New bill', // export data: - 'import_and_export' => 'Import and export', - 'export_data_please_wait' => 'Please wait...', - 'export_data' => 'Export data', - 'export_data_intro' => 'For backup purposes, when migrating to another system or when migrating to another Firefly III installation.', - 'export_format' => 'Export format', - 'export_format_csv' => 'Comma separated values (CSV file)', - 'export_format_mt940' => 'MT940 compatible format', - 'export_included_accounts' => 'Export transactions from these accounts', - 'include_config_help' => 'For easy re-import into Firefly III', - 'include_old_uploads_help' => 'Firefly III does not throw away the original CSV files you have imported in the past. You can include them in your export.', - 'do_export' => 'Export', + 'import_and_export' => 'Import and export', + 'export_data' => 'Export data', + 'export_data_intro' => 'For backup purposes, when migrating to another system or when migrating to another Firefly III installation.', + 'export_format' => 'Export format', + 'export_format_csv' => 'Comma separated values (CSV file)', + 'export_format_mt940' => 'MT940 compatible format', + 'export_included_accounts' => 'Export transactions from these accounts', + 'include_config_help' => 'For easy re-import into Firefly III', + 'include_old_uploads_help' => 'Firefly III does not throw away the original CSV files you have imported in the past. You can include them in your export.', + 'do_export' => 'Export', + 'export_status_make_exporter' => 'Creating exporter thing...', + 'export_status_collecting_journals' => 'Collecting your transactions...', + 'export_status_collected_journals' => 'Collected your transactions!', + 'export_status_converting_to_export_format' => 'Converting your transactions...', + 'export_status_converted_to_export_format' => 'Converted your transactions!', + 'export_status_creating_journal_file' => 'Creating the export file...', + 'export_status_created_journal_file' => 'Created the export file!', + 'export_status_collecting_attachments' => 'Collecting all your attachments...', + 'export_status_collected_attachments' => 'Collected all your attachments!', + 'export_status_collecting_old_uploads' => 'Collecting all your previous uploads...', + 'export_status_collected_old_uploads' => 'Collected all your previous uploads!', + 'export_status_creating_config_file' => 'Creating a configuration file...', + 'export_status_created_config_file' => 'Created a configuration file!', + 'export_status_creating_zip_file' => 'Creating a zip file...', + 'export_status_created_zip_file' => 'Created a zip file!', + 'export_status_finished' => 'Export has succesfully finished! Yay!', // rules - 'rules' => 'Rules', - 'rules_explanation' => 'Here you can manage rules. Rules are triggered when a transaction is created or updated. Then, if the transaction has certain properties (called "triggers") Firefly will execute the "actions". Combined, you can make Firefly respond in a certain way to new transactions.', - 'rule_name' => 'Name of rule', - 'rule_triggers' => 'Rule triggers when', - 'rule_actions' => 'Rule will', - 'new_rule' => 'New rule', - 'new_rule_group' => 'New rule group', - 'rule_priority_up' => 'Give rule more priority', - 'rule_priority_down' => 'Give rule less priority', - 'make_new_rule_group' => 'Make new rule group', - 'store_new_rule_group' => 'Store new rule group', - 'created_new_rule_group' => 'New rule group ":title" stored!', - 'updated_rule_group' => 'Successfully updated rule group ":title".', - 'edit_rule_group' => 'Edit rule group ":title"', - 'delete_rule_group' => 'Delete rule group ":title"', - 'deleted_rule_group' => 'Deleted rule group ":title"', - 'update_rule_group' => 'Update rule group', - 'no_rules_in_group' => 'There are no rules in this group', - 'move_rule_group_up' => 'Move rule group up', - 'move_rule_group_down' => 'Move rule group down', - 'save_rules_by_moving' => 'Save these rule(s) by moving them to another rule group:', - 'make_new_rule' => 'Make new rule in rule group ":title"', - 'rule_help_stop_processing' => 'When you check this box, later rules in this group will not be executed.', - 'rule_help_active' => 'Inactive rules will never fire.', - 'stored_new_rule' => 'Stored new rule with title ":title"', - 'deleted_rule' => 'Deleted rule with title ":title"', - 'store_new_rule' => 'Store new rule', - 'updated_rule' => 'Updated rule with title ":title"', - 'default_rule_group_name' => 'Default rules', - 'default_rule_group_description' => 'All your rules not in a particular group.', - 'default_rule_name' => 'Your first default rule', - 'default_rule_description' => 'This rule is an example. You can safely delete it.', - 'default_rule_trigger_description' => 'The Man Who Sold the World', - 'default_rule_trigger_from_account' => 'David Bowie', - 'default_rule_action_prepend' => 'Bought the world from ', - 'default_rule_action_set_category' => 'Large expenses', + 'rules' => 'Rules', + 'rules_explanation' => 'Here you can manage rules. Rules are triggered when a transaction is created or updated. Then, if the transaction has certain properties (called "triggers") Firefly will execute the "actions". Combined, you can make Firefly respond in a certain way to new transactions.', + 'rule_name' => 'Name of rule', + 'rule_triggers' => 'Rule triggers when', + 'rule_actions' => 'Rule will', + 'new_rule' => 'New rule', + 'new_rule_group' => 'New rule group', + 'rule_priority_up' => 'Give rule more priority', + 'rule_priority_down' => 'Give rule less priority', + 'make_new_rule_group' => 'Make new rule group', + 'store_new_rule_group' => 'Store new rule group', + 'created_new_rule_group' => 'New rule group ":title" stored!', + 'updated_rule_group' => 'Successfully updated rule group ":title".', + 'edit_rule_group' => 'Edit rule group ":title"', + 'delete_rule_group' => 'Delete rule group ":title"', + 'deleted_rule_group' => 'Deleted rule group ":title"', + 'update_rule_group' => 'Update rule group', + 'no_rules_in_group' => 'There are no rules in this group', + 'move_rule_group_up' => 'Move rule group up', + 'move_rule_group_down' => 'Move rule group down', + 'save_rules_by_moving' => 'Save these rule(s) by moving them to another rule group:', + 'make_new_rule' => 'Make new rule in rule group ":title"', + 'rule_help_stop_processing' => 'When you check this box, later rules in this group will not be executed.', + 'rule_help_active' => 'Inactive rules will never fire.', + 'stored_new_rule' => 'Stored new rule with title ":title"', + 'deleted_rule' => 'Deleted rule with title ":title"', + 'store_new_rule' => 'Store new rule', + 'updated_rule' => 'Updated rule with title ":title"', + 'default_rule_group_name' => 'Default rules', + 'default_rule_group_description' => 'All your rules not in a particular group.', + 'default_rule_name' => 'Your first default rule', + 'default_rule_description' => 'This rule is an example. You can safely delete it.', + 'default_rule_trigger_description' => 'The Man Who Sold the World', + 'default_rule_trigger_from_account' => 'David Bowie', + 'default_rule_action_prepend' => 'Bought the world from ', + 'default_rule_action_set_category' => 'Large expenses', 'trigger' => 'Trigger', 'trigger_value' => 'Trigger on value', diff --git a/resources/lang/en_US/form.php b/resources/lang/en_US/form.php index 6cdb39a8bc..20c645fd45 100644 --- a/resources/lang/en_US/form.php +++ b/resources/lang/en_US/form.php @@ -76,6 +76,7 @@ return [ 'include_attachments' => 'Include uploaded attachments', 'include_config' => 'Include configuration file', 'include_old_uploads' => 'Include imported data', + 'accounts' => 'Export transactions from these accounts', 'csv_comma' => 'A comma (,)', 'csv_semicolon' => 'A semicolon (;)', From 8256f6034019895a9ed74d1abd155b1c759f311f Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 15:00:57 +0100 Subject: [PATCH 079/448] Fixed form elements. --- app/Support/ExpandedForm.php | 42 ++++++++++++------------- resources/views/export/index.twig | 26 +-------------- resources/views/form/multiCheckbox.twig | 9 ++++-- 3 files changed, 29 insertions(+), 48 deletions(-) diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index f5559a475f..65dcb3dd86 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -27,7 +27,7 @@ class ExpandedForm * * @return string */ - public function amount(string $name, $value = null, array $options = []) + public function amount(string $name, $value = null, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -52,7 +52,7 @@ class ExpandedForm * * @return string */ - public function balance(string $name, $value = null, array $options = []) + public function balance(string $name, $value = null, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -76,7 +76,7 @@ class ExpandedForm * * @return string */ - public function checkbox(string $name, $value = 1, $checked = null, $options = []) + public function checkbox(string $name, $value = 1, $checked = null, $options = []): string { $options['checked'] = $checked === true ? true : null; $label = $this->label($name, $options); @@ -98,7 +98,7 @@ class ExpandedForm * * @return string */ - public function date(string $name, $value = null, array $options = []) + public function date(string $name, $value = null, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -116,7 +116,7 @@ class ExpandedForm * * @return string */ - public function file(string $name, array $options = []) + public function file(string $name, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -134,7 +134,7 @@ class ExpandedForm * * @return string */ - public function integer(string $name, $value = null, array $options = []) + public function integer(string $name, $value = null, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -154,7 +154,7 @@ class ExpandedForm * * @return string */ - public function location(string $name, $value = null, array $options = []) + public function location(string $name, $value = null, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -173,9 +173,9 @@ class ExpandedForm * @param \Illuminate\Support\Collection $set * @param bool $addEmpty * - * @return mixed + * @return array */ - public function makeSelectList(Collection $set, bool $addEmpty = false) + public function makeSelectList(Collection $set, bool $addEmpty = false): array { $selectList = []; if ($addEmpty) { @@ -206,7 +206,7 @@ class ExpandedForm * * @return string */ - public function multiCheckbox(string $name, array $list = [], $selected = null, array $options = []) + public function multiCheckbox(string $name, array $list = [], $selected = null, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -227,7 +227,7 @@ class ExpandedForm * * @return string */ - public function multiRadio(string $name, array $list = [], $selected = null, array $options = []) + public function multiRadio(string $name, array $list = [], $selected = null, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -246,7 +246,7 @@ class ExpandedForm * * @return string */ - public function optionsList($type, $name) + public function optionsList($type, $name): string { $previousValue = null; @@ -272,7 +272,7 @@ class ExpandedForm * * @return string */ - public function select(string $name, array $list = [], $selected = null, array $options = []) + public function select(string $name, array $list = [], $selected = null, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -292,7 +292,7 @@ class ExpandedForm * * @return string */ - public function staticText(string $name, $value, array $options = []) + public function staticText(string $name, $value, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -311,7 +311,7 @@ class ExpandedForm * * @return string */ - public function tags(string $name, $value = null, array $options = []) + public function tags(string $name, $value = null, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -330,7 +330,7 @@ class ExpandedForm * * @return string */ - public function text(string $name, $value = null, array $options = []) + public function text(string $name, $value = null, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -349,7 +349,7 @@ class ExpandedForm * * @return string */ - public function textarea(string $name, $value = null, array $options = []) + public function textarea(string $name, $value = null, array $options = []): string { $label = $this->label($name, $options); $options = $this->expandOptionArray($name, $label, $options); @@ -369,7 +369,7 @@ class ExpandedForm * * @return array */ - protected function expandOptionArray(string $name, $label, array $options) + protected function expandOptionArray(string $name, $label, array $options): array { $options['class'] = 'form-control'; $options['id'] = 'ffInput_' . $name; @@ -410,7 +410,7 @@ class ExpandedForm * * @return string */ - protected function getHolderClasses(string $name) + protected function getHolderClasses(string $name): string { /* * Get errors from session: @@ -432,13 +432,13 @@ class ExpandedForm * * @return mixed */ - protected function label(string $name, array $options) + protected function label(string $name, array $options): string { if (isset($options['label'])) { return $options['label']; } - return trans('form.' . $name); + return strval(trans('form.' . $name)); } } diff --git a/resources/views/export/index.twig b/resources/views/export/index.twig index ad603cbc2d..f63c39b898 100644 --- a/resources/views/export/index.twig +++ b/resources/views/export/index.twig @@ -76,31 +76,7 @@ - -

    - - - -
    - - {% if errors.has('accounts') %} - - {% endif %} - {% for account in accounts %} -
    - -
    - {% endfor %} -
    -
    + {{ ExpandedForm.multiCheckbox('accounts',accountList, checked, {' class': 'account-checkbox'}) }} {{ ExpandedForm.checkbox('include_attachments','1', true) }} diff --git a/resources/views/form/multiCheckbox.twig b/resources/views/form/multiCheckbox.twig index ef43eedd67..b743a4a7d9 100644 --- a/resources/views/form/multiCheckbox.twig +++ b/resources/views/form/multiCheckbox.twig @@ -3,9 +3,14 @@
    {% for value,description in list %} -
    + {% set options = options|merge({'id': 'ffInput_'~name~'_'~value}) %} +
    From b8c787645416bdd7bb9231b1c92279c42d704d39 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 15:01:26 +0100 Subject: [PATCH 080/448] Simplified export controller. --- app/Http/Controllers/ExportController.php | 5 +- app/Support/Amount.php | 2 +- app/Support/CacheProperties.php | 4 +- app/Support/Domain.php | 6 +- app/Support/Twig/Journal.php | 174 +++------------------- 5 files changed, 31 insertions(+), 160 deletions(-) diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 0396c98a63..27e65214af 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -12,6 +12,7 @@ namespace FireflyIII\Http\Controllers; use Carbon\Carbon; use Config; +use ExpandedForm; use FireflyIII\Export\Processor; use FireflyIII\Http\Requests; use FireflyIII\Http\Requests\ExportFormRequest; @@ -91,12 +92,14 @@ class ExportController extends Controller // does the user have shared accounts? $accounts = $repository->getAccounts(['Default account', 'Asset account']); + $accountList = ExpandedForm::makeSelectList($accounts); + $checked = array_keys($accountList); $formats = array_keys(Config::get('firefly.export_formats')); $defaultFormat = Preferences::get('export_format', Config::get('firefly.default_export_format'))->data; $first = session('first')->format('Y-m-d'); $today = Carbon::create()->format('Y-m-d'); - return view('export.index', compact('accounts', 'job', 'formats', 'defaultFormat', 'first', 'today')); + return view('export.index', compact('job', 'checked', 'accountList', 'formats', 'defaultFormat', 'first', 'today')); } diff --git a/app/Support/Amount.php b/app/Support/Amount.php index 84b08b3da7..ceed9f2e06 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -68,7 +68,7 @@ class Amount * * @return string */ - public function formatJournal(TransactionJournal $journal, bool $coloured = true) + public function formatJournal(TransactionJournal $journal, bool $coloured = true): string { $cache = new CacheProperties; $cache->addProperty($journal->id); diff --git a/app/Support/CacheProperties.php b/app/Support/CacheProperties.php index a67389eb2f..0b3bd7fb55 100644 --- a/app/Support/CacheProperties.php +++ b/app/Support/CacheProperties.php @@ -54,7 +54,7 @@ class CacheProperties /** * @return string */ - public function getMd5() + public function getMd5(): string { return $this->md5; } @@ -62,7 +62,7 @@ class CacheProperties /** * @return bool */ - public function has() + public function has(): bool { if (getenv('APP_ENV') == 'testing') { return false; diff --git a/app/Support/Domain.php b/app/Support/Domain.php index c7892278d3..d1df4dc185 100644 --- a/app/Support/Domain.php +++ b/app/Support/Domain.php @@ -22,7 +22,7 @@ class Domain /** * @return array */ - public static function getBindables() + public static function getBindables(): array { return Config::get('firefly.bindables'); @@ -31,7 +31,7 @@ class Domain /** * @return array */ - public static function getRuleActions() + public static function getRuleActions(): array { return Config::get('firefly.rule-actions'); } @@ -39,7 +39,7 @@ class Domain /** * @return array */ - public static function getRuleTriggers() + public static function getRuleTriggers(): array { return Config::get('firefly.rule-triggers'); } diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.php index 9962c16ac1..f84eaad0d4 100644 --- a/app/Support/Twig/Journal.php +++ b/app/Support/Twig/Journal.php @@ -12,8 +12,6 @@ use Twig_SimpleFilter; use Twig_SimpleFunction; /** - * @codeCoverageIgnore - * * Class Journal * * @package FireflyIII\Support\Twig @@ -24,7 +22,7 @@ class Journal extends Twig_Extension /** * @return array */ - public function getFilters() + public function getFilters(): array { $filters = [$this->typeIcon()]; @@ -34,11 +32,10 @@ class Journal extends Twig_Extension /** * @return array */ - public function getFunctions() + public function getFunctions(): array { $functions = [ $this->invalidJournal(), - $this->relevantTags(), ]; return $functions; @@ -49,18 +46,34 @@ class Journal extends Twig_Extension * * @return string The extension name */ - public function getName() + public function getName(): string { return 'FireflyIII\Support\Twig\Journals'; } + /** + * @return Twig_SimpleFunction + */ + protected function invalidJournal(): Twig_SimpleFunction + { + return new Twig_SimpleFunction( + 'invalidJournal', function (TransactionJournal $journal): bool { + if (!isset($journal->transactions[1]) || !isset($journal->transactions[0])) { + return true; + } + + return false; + } + ); + } + /** * @return Twig_SimpleFilter */ - protected function typeIcon() + protected function typeIcon(): Twig_SimpleFilter { return new Twig_SimpleFilter( - 'typeIcon', function (TransactionJournal $journal) { + 'typeIcon', function (TransactionJournal $journal): string { $cache = new CacheProperties(); $cache->addProperty($journal->id); @@ -94,149 +107,4 @@ class Journal extends Twig_Extension }, ['is_safe' => ['html']] ); } - - /** - * @return Twig_SimpleFunction - */ - protected function invalidJournal() - { - return new Twig_SimpleFunction( - 'invalidJournal', function (TransactionJournal $journal) { - if (!isset($journal->transactions[1]) || !isset($journal->transactions[0])) { - return true; - } - - return false; - } - ); - } - - /** - * @return Twig_SimpleFunction - */ - protected function relevantTags() - { - return new Twig_SimpleFunction( - 'relevantTags', function (TransactionJournal $journal) { - $cache = new CacheProperties; - $cache->addProperty('relevantTags'); - $cache->addProperty($journal->id); - - if ($cache->has()) { - return $cache->get(); // @codeCoverageIgnore - } - $count = $journal->tags->count(); - $string = ''; - - if ($count === 0) { - $string = $this->relevantTagsNoTags($journal); - } - - if ($count === 1) { - $string = $this->relevantTagsSingle($journal); - } - - if ($count > 1) { - $string = $this->relevantTagsMulti($journal); - } - - $cache->store($string); - - return $string; - } - ); - } - - /** - * @param TransactionJournal $journal - * - * @return string - */ - protected function relevantTagsNoTags(TransactionJournal $journal) - { - return app('amount')->formatJournal($journal); - } - - /** - * @param TransactionJournal $journal - * - * @return string - */ - protected function relevantTagsSingle(TransactionJournal $journal) - { - $tag = $journal->tags()->first(); - - return $this->formatJournalByTag($journal, $tag); - } - - /** - * @param TransactionJournal $journal - * @param Tag $tag - * - * @return string - */ - protected function formatJournalByTag(TransactionJournal $journal, Tag $tag) - { - if ($tag->tagMode == 'balancingAct') { - // return tag formatted for a "balancing act", even if other - // tags are present. - $amount = app('amount')->format($journal->amount_positive, false); - $string = ' ' . $tag->tag . ''; - - return $string; - } - - if ($tag->tagMode == 'advancePayment') { - if ($journal->isDeposit()) { - $amount = app('amount')->formatJournal($journal, false); - $string = ' ' . $tag->tag . ''; - - return $string; - } - - /* - * AdvancePayment with a withdrawal will show the amount with a link to - * the tag. The TransactionJournal should properly calculate the amount. - */ - if ($journal->isWithdrawal()) { - $amount = app('amount')->formatJournal($journal); - - $string = '' . $amount . ''; - - return $string; - } - } - - - return $this->relevantTagsNoTags($journal); - } - - /** - * If a transaction journal has multiple tags, we'll have to gamble. FF3 - * does not yet block adding multiple 'special' tags so we must wing it. - * - * We grab the first special tag (for advancePayment and for balancingAct - * and try to format those. If they're not present (it's all normal tags), - * we can format like any other journal. - * - * @param TransactionJournal $journal - * - * @return string - */ - protected function relevantTagsMulti(TransactionJournal $journal) - { - $firstBalancingAct = $journal->tags()->where('tagMode', 'balancingAct')->first(); - if ($firstBalancingAct) { - return $this->formatJournalByTag($journal, $firstBalancingAct); - } - - $firstAdvancePayment = $journal->tags()->where('tagMode', 'advancePayment')->first(); - if ($firstAdvancePayment) { - return $this->formatJournalByTag($journal, $firstAdvancePayment); - } - - return $this->relevantTagsNoTags($journal); - } } From 4424e48926c154b748d9af58f41f9c1060f29e10 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 16:22:12 +0100 Subject: [PATCH 081/448] Added PHP7 return type statements. --- app/Export/Entry.php | 6 +- app/Http/Controllers/AccountController.php | 2 +- .../Account/AccountRepository.php | 62 +++++++++++-------- .../Account/AccountRepositoryInterface.php | 40 ++++++------ 4 files changed, 59 insertions(+), 51 deletions(-) diff --git a/app/Export/Entry.php b/app/Export/Entry.php index c84fb91280..2f4d2dcab1 100644 --- a/app/Export/Entry.php +++ b/app/Export/Entry.php @@ -122,7 +122,7 @@ class Entry /** * @return array */ - public static function getTypes() + public static function getTypes(): array { // key = field name (see top of class) // value = field type (see csv.php under 'roles') @@ -139,7 +139,7 @@ class Entry 'fromAccountId' => 'account-id', 'fromAccountName' => 'account-name', 'fromAccountIban' => 'account-iban', - 'fromAccountType' => '_ignore', + 'fromAccountType' => '_ignore', // no, Firefly cannot import what it exports. I know :D 'toAccountId' => 'opposing-id', 'toAccountName' => 'opposing-name', 'toAccountIban' => 'opposing-iban', @@ -150,7 +150,7 @@ class Entry /** * @return string */ - public function getAmount() + public function getAmount(): string { return $this->amount; } diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 413c2992c2..68ccabbfb5 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -122,7 +122,7 @@ class AccountController extends Controller // the opening balance is tricky: $openingBalanceAmount = null; - if ($openingBalance) { + if ($openingBalance->id) { $transaction = $repository->getFirstTransaction($openingBalance, $account); $openingBalanceAmount = $transaction->amount; } diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index f3486d1a47..a0ce14bbc5 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -36,7 +36,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return int */ - public function countAccounts(array $types) + public function countAccounts(array $types): int { $count = Auth::user()->accounts()->accountTypeIn($types)->count(); @@ -47,9 +47,9 @@ class AccountRepository implements AccountRepositoryInterface * @param Account $account * @param Account $moveTo * - * @return boolean + * @return bool */ - public function destroy(Account $account, Account $moveTo = null) + public function destroy(Account $account, Account $moveTo = null): bool { if (!is_null($moveTo)) { // update all transactions: @@ -68,7 +68,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Account */ - public function find(int $accountId) + public function find(int $accountId): Account { return Auth::user()->accounts()->findOrNew($accountId); } @@ -80,7 +80,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Collection */ - public function get(array $ids) + public function get(array $ids): Collection { return Auth::user()->accounts()->whereIn('id', $ids)->get(['accounts.*']); } @@ -90,7 +90,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Collection */ - public function getAccounts(array $types) + public function getAccounts(array $types): Collection { /** @var Collection $result */ $result = Auth::user()->accounts()->with( @@ -119,7 +119,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Collection */ - public function getCreditCards(Carbon $date) + public function getCreditCards(Carbon $date): Collection { $set = Auth::user()->accounts() ->hasMetaValue('accountRole', 'ccAsset') @@ -147,7 +147,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Transaction */ - public function getFirstTransaction(TransactionJournal $journal, Account $account) + public function getFirstTransaction(TransactionJournal $journal, Account $account): Transaction { $transaction = $journal->transactions()->where('account_id', $account->id)->first(); @@ -159,7 +159,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Collection */ - public function getFrontpageAccounts(Preference $preference) + public function getFrontpageAccounts(Preference $preference): Collection { $query = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account']); @@ -181,9 +181,9 @@ class AccountRepository implements AccountRepositoryInterface * @param Carbon $start * @param Carbon $end * - * @return mixed + * @return Collection */ - public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end) + public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end): Collection { $set = Auth::user() ->transactionjournals() @@ -209,7 +209,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return LengthAwarePaginator */ - public function getJournals(Account $account, $page) + public function getJournals(Account $account, $page): LengthAwarePaginator { $offset = ($page - 1) * 50; $query = Auth::user() @@ -235,7 +235,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Collection */ - public function getPiggyBankAccounts() + public function getPiggyBankAccounts(): Collection { $start = clone session('start', new Carbon); $end = clone session('end', new Carbon); @@ -277,7 +277,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Collection */ - public function getSavingsAccounts() + public function getSavingsAccounts(): Collection { $accounts = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC') ->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id') @@ -322,9 +322,9 @@ class AccountRepository implements AccountRepositoryInterface * @param Account $account * @param Carbon $date * - * @return float + * @return string */ - public function leftOnAccount(Account $account, Carbon $date) + public function leftOnAccount(Account $account, Carbon $date): string { $balance = Steam::balance($account, $date, true); @@ -342,7 +342,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return TransactionJournal|null */ - public function openingBalanceTransaction(Account $account) + public function openingBalanceTransaction(Account $account): TransactionJournal { $journal = TransactionJournal ::orderBy('transaction_journals.date', 'ASC') @@ -351,6 +351,9 @@ class AccountRepository implements AccountRepositoryInterface ->transactionTypes([TransactionType::OPENING_BALANCE]) ->orderBy('created_at', 'ASC') ->first(['transaction_journals.*']); + if(is_null($journal)) { + return new TransactionJournal; + } return $journal; } @@ -360,7 +363,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Account */ - public function store(array $data) + public function store(array $data): Account { $newAccount = $this->storeAccount($data); if (!is_null($newAccount)) { @@ -392,7 +395,7 @@ class AccountRepository implements AccountRepositoryInterface /** * @return string */ - public function sumOfEverything() + public function sumOfEverything(): string { return Auth::user()->transactions()->sum('amount'); } @@ -405,7 +408,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Account */ - public function update(Account $account, array $data) + public function update(Account $account, array $data): Account { // update the account: $account->name = $data['name']; @@ -449,7 +452,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Account */ - protected function storeAccount(array $data) + private function storeAccount(array $data): Account { $type = Config::get('firefly.accountTypeByIdentifier.' . $data['accountType']); $accountType = AccountType::whereType($type)->first(); @@ -493,7 +496,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return TransactionJournal */ - protected function storeInitialBalance(Account $account, Account $opposing, array $data) + private function storeInitialBalance(Account $account, Account $opposing, array $data): TransactionJournal { $transactionType = TransactionType::whereType(TransactionType::OPENING_BALANCE)->first(); $journal = TransactionJournal::create( @@ -534,8 +537,10 @@ class AccountRepository implements AccountRepositoryInterface /** * @param Account $account * @param array $data + * + * @return bool */ - protected function storeMetadata(Account $account, array $data) + private function storeMetadata(Account $account, array $data): bool { $validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType']; foreach ($validFields as $field) { @@ -549,9 +554,9 @@ class AccountRepository implements AccountRepositoryInterface ); $metaData->save(); } - - } + + return true; } /** @@ -561,7 +566,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return TransactionJournal */ - protected function updateInitialBalance(Account $account, TransactionJournal $journal, array $data) + private function updateInitialBalance(Account $account, TransactionJournal $journal, array $data): TransactionJournal { $journal->date = $data['openingBalanceDate']; $journal->save(); @@ -585,8 +590,9 @@ class AccountRepository implements AccountRepositoryInterface * @param Account $account * @param array $data * + * @return bool */ - protected function updateMetadata(Account $account, array $data) + private function updateMetadata(Account $account, array $data): bool { $validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType']; @@ -611,5 +617,7 @@ class AccountRepository implements AccountRepositoryInterface } } + return true; + } } diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php index 52087d666e..58ec65daa9 100644 --- a/app/Repositories/Account/AccountRepositoryInterface.php +++ b/app/Repositories/Account/AccountRepositoryInterface.php @@ -24,7 +24,7 @@ interface AccountRepositoryInterface * * @return int */ - public function countAccounts(array $types); + public function countAccounts(array $types): int; /** * @param Account $account @@ -32,7 +32,7 @@ interface AccountRepositoryInterface * * @return boolean */ - public function destroy(Account $account, Account $moveTo = null); + public function destroy(Account $account, Account $moveTo = null): bool; /** * @param int $accountId @@ -41,7 +41,7 @@ interface AccountRepositoryInterface * * @return Account */ - public function find(int $accountId); + public function find(int $accountId): Account; /** * Gets all the accounts by ID, for a given set. @@ -50,14 +50,14 @@ interface AccountRepositoryInterface * * @return Collection */ - public function get(array $ids); + public function get(array $ids): Collection; /** * @param array $types * * @return Collection */ - public function getAccounts(array $types); + public function getAccounts(array $types): Collection; /** * This method returns the users credit cards, along with some basic information about the @@ -70,7 +70,7 @@ interface AccountRepositoryInterface * * @return Collection */ - public function getCreditCards(Carbon $date); + public function getCreditCards(Carbon $date): Collection; /** * @param TransactionJournal $journal @@ -78,23 +78,23 @@ interface AccountRepositoryInterface * * @return Transaction */ - public function getFirstTransaction(TransactionJournal $journal, Account $account); + public function getFirstTransaction(TransactionJournal $journal, Account $account): Transaction; /** * @param Preference $preference * * @return Collection */ - public function getFrontpageAccounts(Preference $preference); + public function getFrontpageAccounts(Preference $preference): Collection; /** * @param Account $account * @param Carbon $start * @param Carbon $end * - * @return mixed + * @return Collection */ - public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end); + public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end): Collection; /** * @param Account $account @@ -102,48 +102,48 @@ interface AccountRepositoryInterface * * @return LengthAwarePaginator */ - public function getJournals(Account $account, $page); + public function getJournals(Account $account, $page): LengthAwarePaginator; /** * Get the accounts of a user that have piggy banks connected to them. * * @return Collection */ - public function getPiggyBankAccounts(); + public function getPiggyBankAccounts(): Collection; /** * Get savings accounts and the balance difference in the period. * * @return Collection */ - public function getSavingsAccounts(); + public function getSavingsAccounts() : Collection; /** * @param Account $account * @param Carbon $date * - * @return float + * @return string */ - public function leftOnAccount(Account $account, Carbon $date); + public function leftOnAccount(Account $account, Carbon $date): string; /** * @param Account $account * - * @return TransactionJournal|null + * @return TransactionJournal */ - public function openingBalanceTransaction(Account $account); + public function openingBalanceTransaction(Account $account) : TransactionJournal; /** * @param array $data * * @return Account */ - public function store(array $data); + public function store(array $data) : Account; /** * @return string */ - public function sumOfEverything(); + public function sumOfEverything() : string; /** * @param Account $account @@ -151,5 +151,5 @@ interface AccountRepositoryInterface * * @return Account */ - public function update(Account $account, array $data); + public function update(Account $account, array $data): Account; } From 95c4c4a23888f5aa7640534bb28807b652196d5e Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 16:23:54 +0100 Subject: [PATCH 082/448] Fixed a small bug after changing the return type statements. --- app/Http/Controllers/AccountController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 68ccabbfb5..d1bb5041a3 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -131,7 +131,7 @@ class AccountController extends Controller 'accountRole' => $account->getMeta('accountRole'), 'ccType' => $account->getMeta('ccType'), 'ccMonthlyPaymentDate' => $account->getMeta('ccMonthlyPaymentDate'), - 'openingBalanceDate' => $openingBalance ? $openingBalance->date->format('Y-m-d') : null, + 'openingBalanceDate' => $openingBalance->id ? $openingBalance->date->format('Y-m-d') : null, 'openingBalance' => $openingBalanceAmount, 'virtualBalance' => round($account->virtual_balance, 2), ]; From 060b031272328fa2fb28f50e07233a399787d465 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 18:59:48 +0100 Subject: [PATCH 083/448] Added PHP7 return type statements. --- .../Attachment/AttachmentRepository.php | 5 +- .../AttachmentRepositoryInterface.php | 4 +- app/Repositories/Bill/BillRepository.php | 54 ++++++++++--------- .../Bill/BillRepositoryInterface.php | 42 +++++++-------- 4 files changed, 54 insertions(+), 51 deletions(-) diff --git a/app/Repositories/Attachment/AttachmentRepository.php b/app/Repositories/Attachment/AttachmentRepository.php index e486612bb8..d8520d0d54 100644 --- a/app/Repositories/Attachment/AttachmentRepository.php +++ b/app/Repositories/Attachment/AttachmentRepository.php @@ -18,7 +18,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface * * @return bool */ - public function destroy(Attachment $attachment) + public function destroy(Attachment $attachment): bool { /** @var \FireflyIII\Helpers\Attachments\AttachmentHelperInterface $helper */ $helper = app('FireflyIII\Helpers\Attachments\AttachmentHelperInterface'); @@ -26,6 +26,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface $file = $helper->getAttachmentLocation($attachment); unlink($file); $attachment->delete(); + return true; } /** @@ -34,7 +35,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface * * @return Attachment */ - public function update(Attachment $attachment, array $data) + public function update(Attachment $attachment, array $data): Attachment { $attachment->title = $data['title']; diff --git a/app/Repositories/Attachment/AttachmentRepositoryInterface.php b/app/Repositories/Attachment/AttachmentRepositoryInterface.php index 37386e1467..0cd01dff73 100644 --- a/app/Repositories/Attachment/AttachmentRepositoryInterface.php +++ b/app/Repositories/Attachment/AttachmentRepositoryInterface.php @@ -18,7 +18,7 @@ interface AttachmentRepositoryInterface * * @return bool */ - public function destroy(Attachment $attachment); + public function destroy(Attachment $attachment): bool; /** * @param Attachment $attachment @@ -26,6 +26,6 @@ interface AttachmentRepositoryInterface * * @return Attachment */ - public function update(Attachment $attachment, array $attachmentData); + public function update(Attachment $attachment, array $attachmentData): Attachment; } diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index 10dd09ad76..5c3d57223f 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -28,17 +28,19 @@ class BillRepository implements BillRepositoryInterface /** * @param Bill $bill * - * @return boolean|null + * @return boolean */ - public function destroy(Bill $bill) + public function destroy(Bill $bill): bool { - return $bill->delete(); + $bill->delete(); + + return true; } /** * @return Collection */ - public function getActiveBills() + public function getActiveBills(): Collection { /** @var Collection $set */ $set = Auth::user()->bills() @@ -63,7 +65,7 @@ class BillRepository implements BillRepositoryInterface * * @return Collection */ - public function getAllJournalsInRange(Collection $bills, Carbon $start, Carbon $end) + public function getAllJournalsInRange(Collection $bills, Carbon $start, Carbon $end): Collection { $ids = $bills->pluck('id')->toArray(); @@ -90,7 +92,7 @@ class BillRepository implements BillRepositoryInterface /** * @return Collection */ - public function getBills() + public function getBills(): Collection { /** @var Collection $set */ $set = Auth::user()->bills()->orderBy('name', 'ASC')->get(); @@ -112,7 +114,7 @@ class BillRepository implements BillRepositoryInterface * * @return Collection */ - public function getBillsForAccounts(Collection $accounts) + public function getBillsForAccounts(Collection $accounts): Collection { $ids = $accounts->pluck('id')->toArray(); $set = Auth::user()->bills() @@ -152,7 +154,7 @@ class BillRepository implements BillRepositoryInterface * * @return string */ - public function getBillsPaidInRange(Carbon $start, Carbon $end) + public function getBillsPaidInRange(Carbon $start, Carbon $end): string { $amount = '0'; $bills = $this->getActiveBills(); @@ -187,7 +189,7 @@ class BillRepository implements BillRepositoryInterface * * @return string */ - public function getBillsUnpaidInRange(Carbon $start, Carbon $end) + public function getBillsUnpaidInRange(Carbon $start, Carbon $end): string { $amount = '0'; $bills = $this->getActiveBills(); @@ -226,7 +228,7 @@ class BillRepository implements BillRepositoryInterface * * @return string */ - public function getCreditCardBill(Carbon $start, Carbon $end) + public function getCreditCardBill(Carbon $start, Carbon $end): string { /** @var AccountRepositoryInterface $accountRepository */ @@ -274,7 +276,7 @@ class BillRepository implements BillRepositoryInterface * * @return Collection */ - public function getJournals(Bill $bill) + public function getJournals(Bill $bill): Collection { $set = $bill->transactionjournals() ->leftJoin( @@ -302,7 +304,7 @@ class BillRepository implements BillRepositoryInterface * * @return Collection */ - public function getJournalsInRange(Bill $bill, Carbon $start, Carbon $end) + public function getJournalsInRange(Bill $bill, Carbon $start, Carbon $end): Collection { return $bill->transactionjournals()->before($end)->after($start)->get(); } @@ -312,7 +314,7 @@ class BillRepository implements BillRepositoryInterface * * @return Collection */ - public function getPossiblyRelatedJournals(Bill $bill) + public function getPossiblyRelatedJournals(Bill $bill): Collection { $set = new Collection( DB::table('transactions')->where('amount', '>', 0)->where('amount', '>=', $bill->amount_min)->where('amount', '<=', $bill->amount_max) @@ -339,9 +341,9 @@ class BillRepository implements BillRepositoryInterface * @param Carbon $start * @param Carbon $end * - * @return mixed + * @return array */ - public function getRanges(Bill $bill, Carbon $start, Carbon $end) + public function getRanges(Bill $bill, Carbon $start, Carbon $end): array { $startOfBill = $bill->date; $startOfBill = Navigation::startOfPeriod($startOfBill, $bill->repeat_freq); @@ -376,16 +378,16 @@ class BillRepository implements BillRepositoryInterface /** * @param Bill $bill * - * @return Carbon|null + * @return \Carbon\Carbon */ - public function lastFoundMatch(Bill $bill) + public function lastFoundMatch(Bill $bill): Carbon { $last = $bill->transactionjournals()->orderBy('date', 'DESC')->first(); if ($last) { return $last->date; } - return null; + return Carbon::now()->addDays(2); // in the future! } /** @@ -393,10 +395,10 @@ class BillRepository implements BillRepositoryInterface * * @return \Carbon\Carbon */ - public function nextExpectedMatch(Bill $bill) + public function nextExpectedMatch(Bill $bill): Carbon { - $finalDate = null; + $finalDate = Carbon::now()->subDays(2); if ($bill->active == 0) { return $finalDate; } @@ -440,9 +442,9 @@ class BillRepository implements BillRepositoryInterface * @param Bill $bill * @param TransactionJournal $journal * - * @return boolean|null + * @return bool */ - public function scan(Bill $bill, TransactionJournal $journal) + public function scan(Bill $bill, TransactionJournal $journal): bool { /* @@ -487,7 +489,7 @@ class BillRepository implements BillRepositoryInterface * * @return Bill */ - public function store(array $data) + public function store(array $data): Bill { @@ -516,7 +518,7 @@ class BillRepository implements BillRepositoryInterface * * @return Bill */ - public function update(Bill $bill, array $data) + public function update(Bill $bill, array $data): Bill { @@ -541,7 +543,7 @@ class BillRepository implements BillRepositoryInterface * * @return bool */ - protected function doAmountMatch($amount, $min, $max) + protected function doAmountMatch($amount, $min, $max): bool { if ($amount >= $min && $amount <= $max) { return true; @@ -556,7 +558,7 @@ class BillRepository implements BillRepositoryInterface * * @return bool */ - protected function doWordMatch(array $matches, $description) + protected function doWordMatch(array $matches, $description): bool { $wordMatch = false; $count = 0; diff --git a/app/Repositories/Bill/BillRepositoryInterface.php b/app/Repositories/Bill/BillRepositoryInterface.php index 79b99edb8e..10b3156dd1 100644 --- a/app/Repositories/Bill/BillRepositoryInterface.php +++ b/app/Repositories/Bill/BillRepositoryInterface.php @@ -19,14 +19,14 @@ interface BillRepositoryInterface /** * @param Bill $bill * - * @return mixed + * @return bool */ - public function destroy(Bill $bill); + public function destroy(Bill $bill): bool; /** * @return Collection */ - public function getActiveBills(); + public function getActiveBills(): Collection; /** * Returns all journals connected to these bills in the given range. Amount paid @@ -38,12 +38,12 @@ interface BillRepositoryInterface * * @return Collection */ - public function getAllJournalsInRange(Collection $bills, Carbon $start, Carbon $end); + public function getAllJournalsInRange(Collection $bills, Carbon $start, Carbon $end): Collection; /** * @return Collection */ - public function getBills(); + public function getBills(): Collection; /** * Gets the bills which have some kind of relevance to the accounts mentioned. @@ -52,7 +52,7 @@ interface BillRepositoryInterface * * @return Collection */ - public function getBillsForAccounts(Collection $accounts); + public function getBillsForAccounts(Collection $accounts): Collection; /** * Get the total amount of money paid for the users active bills in the date range given. @@ -62,7 +62,7 @@ interface BillRepositoryInterface * * @return string */ - public function getBillsPaidInRange(Carbon $start, Carbon $end); + public function getBillsPaidInRange(Carbon $start, Carbon $end): string; /** * Get the total amount of money due for the users active bills in the date range given. @@ -72,7 +72,7 @@ interface BillRepositoryInterface * * @return string */ - public function getBillsUnpaidInRange(Carbon $start, Carbon $end); + public function getBillsUnpaidInRange(Carbon $start, Carbon $end): string; /** * This method will tell you if you still have a CC bill to pay. Amount will be negative if the amount @@ -83,14 +83,14 @@ interface BillRepositoryInterface * * @return string */ - public function getCreditCardBill(Carbon $start, Carbon $end); + public function getCreditCardBill(Carbon $start, Carbon $end): string; /** * @param Bill $bill * * @return Collection */ - public function getJournals(Bill $bill); + public function getJournals(Bill $bill): Collection; /** * Get all journals that were recorded on this bill between these dates. @@ -101,14 +101,14 @@ interface BillRepositoryInterface * * @return Collection */ - public function getJournalsInRange(Bill $bill, Carbon $start, Carbon $end); + public function getJournalsInRange(Bill $bill, Carbon $start, Carbon $end): Collection; /** * @param Bill $bill * * @return Collection */ - public function getPossiblyRelatedJournals(Bill $bill); + public function getPossiblyRelatedJournals(Bill $bill): Collection; /** * Every bill repeats itself weekly, monthly or yearly (or whatever). This method takes a date-range (usually the view-range of Firefly itself) @@ -119,16 +119,16 @@ interface BillRepositoryInterface * @param Carbon $start * @param Carbon $end * - * @return mixed + * @return array */ - public function getRanges(Bill $bill, Carbon $start, Carbon $end); + public function getRanges(Bill $bill, Carbon $start, Carbon $end): array; /** * @param Bill $bill * - * @return Carbon|null + * @return \Carbon\Carbon */ - public function lastFoundMatch(Bill $bill); + public function lastFoundMatch(Bill $bill): Carbon; /** @@ -136,7 +136,7 @@ interface BillRepositoryInterface * * @return \Carbon\Carbon */ - public function nextExpectedMatch(Bill $bill); + public function nextExpectedMatch(Bill $bill): Carbon; /** * @param Bill $bill @@ -144,21 +144,21 @@ interface BillRepositoryInterface * * @return bool */ - public function scan(Bill $bill, TransactionJournal $journal); + public function scan(Bill $bill, TransactionJournal $journal): bool; /** * @param array $data * * @return Bill */ - public function store(array $data); + public function store(array $data): Bill; /** * @param Bill $bill * @param array $data * - * @return mixed + * @return Bill */ - public function update(Bill $bill, array $data); + public function update(Bill $bill, array $data): Bill; } From b875eb31d2b18e1c468f691d3c7ee51193904d93 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 19:00:01 +0100 Subject: [PATCH 084/448] Small cosmetic changes. --- resources/views/list/bills.twig | 4 ++-- resources/views/reports/partials/budgets.twig | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/views/list/bills.twig b/resources/views/list/bills.twig index ba83739b49..7b95561765 100644 --- a/resources/views/list/bills.twig +++ b/resources/views/list/bills.twig @@ -35,7 +35,7 @@ {{ entry.amount_max|formatAmount }} - {% if entry.lastFoundMatch %} + {% if not entry.lastFoundMatch.isFuture %} {{ entry.lastFoundMatch.formatLocalized(monthAndDayFormat) }} @@ -45,7 +45,7 @@ {% endif %} - {% if entry.nextExpectedMatch %} + {% if entry.nextExpectedMatch.isFuture %} {{ entry.nextExpectedMatch.formatLocalized(monthAndDayFormat) }} diff --git a/resources/views/reports/partials/budgets.twig b/resources/views/reports/partials/budgets.twig index 19122b4cd7..076487a1e0 100644 --- a/resources/views/reports/partials/budgets.twig +++ b/resources/views/reports/partials/budgets.twig @@ -47,7 +47,9 @@ {% endif %} - {{ budgetLine.getLeft|formatAmount }} + {% if(budgetLine.getOverspent == 0) %} + {{ budgetLine.getLeft|formatAmount }} + {% endif %} {% if budgetLine.getOverspent != 0 %} From 55afc98108a81599a1fc77d5e1cea50cd3b57dfd Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 19:06:10 +0100 Subject: [PATCH 085/448] Better maintenance page. --- resources/views/errors/503.twig | 36 ++++++++++----------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/resources/views/errors/503.twig b/resources/views/errors/503.twig index a6bea4e28b..5fb57c7f2a 100644 --- a/resources/views/errors/503.twig +++ b/resources/views/errors/503.twig @@ -1,6 +1,6 @@ - + @@ -34,28 +37,11 @@
    -
    Be right back.
    +
    Be right back!
    +

    + Firefly III is down for some necessary maintenance. Please check back in a second. +

    - - - - From 6c2df1a783f0b23e057f9b6d1bc5298e1e629adb Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 6 Feb 2016 19:10:24 +0100 Subject: [PATCH 086/448] Give maintenance page a title as well [skip ci] --- resources/views/errors/503.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/errors/503.twig b/resources/views/errors/503.twig index 5fb57c7f2a..71f7588ddd 100644 --- a/resources/views/errors/503.twig +++ b/resources/views/errors/503.twig @@ -1,7 +1,7 @@ - + Firefly III is in maintenance mode.