mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Updated tests.
This commit is contained in:
parent
e86547645c
commit
82e438d29b
@ -2,22 +2,7 @@
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here are each of the database connections setup for your application.
|
||||
| Of course, examples of configuring each database platform that is
|
||||
| supported by Laravel is shown below to make development simple.
|
||||
|
|
||||
|
|
||||
| All database work in Laravel is done through the PHP PDO facilities
|
||||
| so make sure you have the driver for your particular database of
|
||||
| choice installed on your machine before you begin development.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => 'mysql',
|
||||
'connections' => [
|
||||
|
||||
'mysql' => [
|
||||
@ -30,6 +15,11 @@ return [
|
||||
'collation' => 'utf8_unicode_ci',
|
||||
'prefix' => '',
|
||||
],
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'database' => realpath(__DIR__.'/../../../tests/_data/testing.sqlite'),
|
||||
'prefix' => ''
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
|
@ -4,7 +4,7 @@ return [
|
||||
'connections' => [
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'database' => 'tests/_data/testing.sqlite',
|
||||
'database' => realpath(__DIR__.'/../../../tests/_data/db.sqlite'),
|
||||
'prefix' => ''
|
||||
]
|
||||
|
||||
|
@ -22,6 +22,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
* 15. Do not recreate component_recurring_transaction
|
||||
* 16. Do not recreate component_transaction
|
||||
* 17. Do not recreate field 'piggybank_id' in 'transactions'
|
||||
* 18. Recreate component_id in limits
|
||||
*
|
||||
*
|
||||
* Up:
|
||||
@ -41,7 +42,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
* 13. Drop table component_recurring_transaction
|
||||
* 14. Drop table component_transaction
|
||||
* 15. Drop field 'piggybank_id' from 'transactions'
|
||||
*
|
||||
* 16. Drop component_id from budget_limits.
|
||||
*
|
||||
* Class ChangesForV321
|
||||
*/
|
||||
@ -230,6 +231,7 @@ class ChangesForV321 extends Migration
|
||||
$this->dropComponentRecurringTransactionTable(); // 13.
|
||||
$this->dropComponentTransactionTable(); // 14.
|
||||
$this->dropPiggyBankIdFromTransactions(); // 15.
|
||||
$this->dropComponentIdFromBudgetLimits(); // 16.
|
||||
|
||||
|
||||
// $this->doRenameInLimitRepetitions();
|
||||
@ -431,6 +433,16 @@ class ChangesForV321 extends Migration
|
||||
);
|
||||
}
|
||||
|
||||
public function dropComponentIdFromBudgetLimits()
|
||||
{
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
$table->dropForeign('limits_component_id_foreign');
|
||||
$table->dropColumn('component_id');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// public function doRenameInLimitRepetitions()
|
||||
// {
|
||||
|
@ -4,6 +4,9 @@
|
||||
|
||||
App::before(
|
||||
function ($request) {
|
||||
|
||||
// put IP in session if not already there.
|
||||
|
||||
$reminders = [];
|
||||
|
||||
if (Auth::check()) {
|
||||
|
@ -36,8 +36,8 @@ class PiggybankPart
|
||||
public function getReminder()
|
||||
{
|
||||
if (is_null($this->reminder)) {
|
||||
$this->reminder = $this->repetition->piggybank->reminders()->where('startdate', $bar->getStartdate()->format('Y-m-d'))->where(
|
||||
'enddate', $bar->getTargetdate()->format('Y-m-d')
|
||||
$this->reminder = $this->repetition->piggybank->reminders()->where('startdate', $this->getStartdate()->format('Y-m-d'))->where(
|
||||
'enddate', $this->getTargetdate()->format('Y-m-d')
|
||||
)->first();
|
||||
}
|
||||
|
||||
@ -52,22 +52,6 @@ class PiggybankPart
|
||||
$this->reminder = $reminder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \PiggybankRepetition
|
||||
*/
|
||||
public function getRepetition()
|
||||
{
|
||||
return $this->repetition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \PiggybankRepetition $repetition
|
||||
*/
|
||||
public function setRepetition($repetition)
|
||||
{
|
||||
$this->repetition = $repetition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Carbon
|
||||
*/
|
||||
@ -100,6 +84,22 @@ class PiggybankPart
|
||||
$this->targetdate = $targetdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \PiggybankRepetition
|
||||
*/
|
||||
public function getRepetition()
|
||||
{
|
||||
return $this->repetition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \PiggybankRepetition $repetition
|
||||
*/
|
||||
public function setRepetition($repetition)
|
||||
{
|
||||
$this->repetition = $repetition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -7,6 +7,7 @@ use FireflyIII\Database\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
@ -214,11 +215,11 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
public function destroy(Eloquent $model)
|
||||
{
|
||||
|
||||
// delete journals:
|
||||
@ -339,12 +340,12 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
public function update(Eloquent $model, array $data)
|
||||
{
|
||||
$model->name = $data['name'];
|
||||
$model->active = isset($data['active']) ? intval($data['active']) : 0;
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
namespace FireflyIII\Database\AccountType;
|
||||
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Database\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@ -17,12 +18,12 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
{
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
public function destroy(Eloquent $model)
|
||||
{
|
||||
// TODO: Implement destroy() method.
|
||||
throw new NotImplementedException;
|
||||
@ -41,13 +42,13 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
public function update(Eloquent $model, array $data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
throw new NotImplementedException;
|
||||
|
@ -7,6 +7,7 @@ use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
@ -28,11 +29,11 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
public function destroy(Eloquent $model)
|
||||
{
|
||||
$model->delete();
|
||||
|
||||
@ -62,12 +63,12 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
public function update(Eloquent $model, array $data)
|
||||
{
|
||||
$model->name = $data['name'];
|
||||
$model->save();
|
||||
@ -236,9 +237,9 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
{
|
||||
return \LimitRepetition::
|
||||
leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
|
||||
->where('limit_repetitions.startdate', $date->format('Y-m-d'))
|
||||
->where('budget_limits.budget_id', $budget->id)
|
||||
->first(['limit_repetitions.*']);
|
||||
->where('limit_repetitions.startdate', $date->format('Y-m-d'))
|
||||
->where('budget_limits.budget_id', $budget->id)
|
||||
->first(['limit_repetitions.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,21 +252,22 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
{
|
||||
// Add expenses that have no budget:
|
||||
return $this->getUser()
|
||||
->transactionjournals()
|
||||
->whereNotIn('transaction_journals.id', function ($query) use ($start, $end) {
|
||||
$query
|
||||
->select('transaction_journals.id')
|
||||
->from('transaction_journals')
|
||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'));
|
||||
}
|
||||
)
|
||||
->before($end)
|
||||
->after($start)
|
||||
->lessThan(0)
|
||||
->transactionTypes(['Withdrawal'])
|
||||
->get();
|
||||
->transactionjournals()
|
||||
->whereNotIn(
|
||||
'transaction_journals.id', function ($query) use ($start, $end) {
|
||||
$query
|
||||
->select('transaction_journals.id')
|
||||
->from('transaction_journals')
|
||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'));
|
||||
}
|
||||
)
|
||||
->before($end)
|
||||
->after($start)
|
||||
->lessThan(0)
|
||||
->transactionTypes(['Withdrawal'])
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -321,7 +323,9 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
$limit->amount = $amount;
|
||||
$limit->repeat_freq = 'monthly';
|
||||
$limit->repeats = 0;
|
||||
$limit->save();
|
||||
$result = $limit->save();
|
||||
\Log::info('Created new limit? ' . boolval($result));
|
||||
\Log::info('ID: ' . $limit->id);
|
||||
/*
|
||||
* A newly stored limit also created a limit repetition.
|
||||
*/
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace FireflyIII\Database;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
|
||||
/**
|
||||
@ -13,26 +14,26 @@ interface CUD
|
||||
{
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(\Eloquent $model);
|
||||
public function destroy(Eloquent $model);
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return \Eloquent
|
||||
* @return Eloquent
|
||||
*/
|
||||
public function store(array $data);
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data);
|
||||
public function update(Eloquent $model, array $data);
|
||||
|
||||
/**
|
||||
* Validates an array. Returns an array containing MessageBags
|
||||
|
@ -7,10 +7,10 @@ use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
|
||||
/**
|
||||
* Class Category
|
||||
*
|
||||
@ -29,11 +29,11 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
public function destroy(Eloquent $model)
|
||||
{
|
||||
$model->delete();
|
||||
|
||||
@ -62,13 +62,13 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
public function update(Eloquent $model, array $data)
|
||||
{
|
||||
$model->name = $data['name'];
|
||||
if (!$model->isValid()) {
|
||||
|
@ -5,7 +5,6 @@ namespace FireflyIII\Database;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Interface CommonDatabaseCalls
|
||||
*
|
||||
|
@ -7,10 +7,10 @@ use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
|
||||
/**
|
||||
* Class Piggybank
|
||||
*
|
||||
@ -29,11 +29,11 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
public function destroy(Eloquent $model)
|
||||
{
|
||||
$model->delete();
|
||||
}
|
||||
@ -56,12 +56,12 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
public function update(Eloquent $model, array $data)
|
||||
{
|
||||
/** @var \Piggybank $model */
|
||||
$model->name = $data['name'];
|
||||
@ -178,7 +178,9 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
public function find($objectId)
|
||||
{
|
||||
return \Piggybank::
|
||||
leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where('piggybanks.id', '=', $objectId)->where('accounts.user_id', $this->getUser()->id)
|
||||
leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where('piggybanks.id', '=', $objectId)->where(
|
||||
'accounts.user_id', $this->getUser()->id
|
||||
)
|
||||
->first(['piggybanks.*']);
|
||||
}
|
||||
|
||||
@ -242,6 +244,7 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
if ($date >= $rep->startdate && $date <= $rep->targetdate) {
|
||||
return $rep;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
@ -9,10 +9,10 @@ use FireflyIII\Database\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
|
||||
/**
|
||||
* Class RepeatedExpense
|
||||
*
|
||||
@ -98,12 +98,12 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
public function destroy(Eloquent $model)
|
||||
{
|
||||
// TODO: Implement destroy() method.
|
||||
throw new NotImplementedException;
|
||||
@ -135,13 +135,13 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
public function update(Eloquent $model, array $data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
throw new NotImplementedException;
|
||||
|
@ -8,6 +8,7 @@ use FireflyIII\Database\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
@ -29,11 +30,11 @@ class RecurringTransaction implements CUD, CommonDatabaseCalls, RecurringTransac
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
public function destroy(Eloquent $model)
|
||||
{
|
||||
$model->delete();
|
||||
|
||||
@ -74,12 +75,12 @@ class RecurringTransaction implements CUD, CommonDatabaseCalls, RecurringTransac
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
public function update(Eloquent $model, array $data)
|
||||
{
|
||||
$model->name = $data['name'];
|
||||
$model->match = $data['match'];
|
||||
@ -113,45 +114,13 @@ class RecurringTransaction implements CUD, CommonDatabaseCalls, RecurringTransac
|
||||
$warnings = new MessageBag;
|
||||
$successes = new MessageBag;
|
||||
$errors = new MessageBag;
|
||||
|
||||
if (isset($model['name']) && strlen($model['name']) == 0) {
|
||||
$errors->add('name', 'Name must be longer.');
|
||||
}
|
||||
if (isset($model['name']) && strlen($model['name']) > 200) {
|
||||
$errors->add('name', 'Name must be shorter.');
|
||||
}
|
||||
|
||||
if (isset($model['match']) && strlen(trim($model['match'])) <= 2) {
|
||||
$errors->add('match', 'Needs more matches.');
|
||||
}
|
||||
|
||||
if (isset($model['amount_min']) && floatval($model['amount_min']) < 0.01) {
|
||||
$errors->add('amount_min', 'Minimum amount must be higher.');
|
||||
}
|
||||
if (isset($model['amount_max']) && floatval($model['amount_max']) < 0.02) {
|
||||
$errors->add('amount_max', 'Maximum amount must be higher.');
|
||||
}
|
||||
if (isset($model['amount_min']) && isset($model['amount_max']) && floatval($model['amount_min']) > floatval($model['amount_max'])) {
|
||||
$errors->add('amount_max', 'Maximum amount can not be less than minimum amount.');
|
||||
$errors->add('amount_min', 'Minimum amount can not be more than maximum amount.');
|
||||
}
|
||||
|
||||
if ($model['date'] != '') {
|
||||
try {
|
||||
new Carbon($model['date']);
|
||||
} catch (\Exception $e) {
|
||||
$errors->add('date', 'Invalid date.');
|
||||
}
|
||||
}
|
||||
|
||||
$reminders = \Config::get('firefly.budget_periods');
|
||||
if (!isset($model['repeat_freq']) || (isset($model['repeat_freq']) && !in_array($model['repeat_freq'], $reminders))) {
|
||||
$errors->add('repeat_freq', 'Invalid reminder period');
|
||||
}
|
||||
|
||||
if (isset($model['skip']) && intval($model['skip']) < 0) {
|
||||
$errors->add('skip', 'Invalid skip.');
|
||||
}
|
||||
$object = new \RecurringTransaction($model);
|
||||
$object->isValid();
|
||||
$errors->merge($object->getErrors());
|
||||
|
||||
$set = ['name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active'];
|
||||
foreach ($set as $entry) {
|
||||
|
@ -7,10 +7,10 @@ use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
|
||||
/**
|
||||
* Class Transaction
|
||||
*
|
||||
@ -21,12 +21,12 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
use SwitchUser;
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
public function destroy(Eloquent $model)
|
||||
{
|
||||
// TODO: Implement destroy() method.
|
||||
throw new NotImplementedException;
|
||||
@ -60,13 +60,13 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
public function update(Eloquent $model, array $data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
throw new NotImplementedException;
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace FireflyIII\Database\TransactionCurrency;
|
||||
|
||||
|
||||
/**
|
||||
* Class TransactionType
|
||||
*
|
||||
|
@ -9,6 +9,7 @@ use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
@ -30,11 +31,11 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
public function destroy(Eloquent $model)
|
||||
{
|
||||
/*
|
||||
* Trigger deletion.
|
||||
@ -84,13 +85,13 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
public function update(Eloquent $model, array $data)
|
||||
{
|
||||
$journalType = $this->getJournalType($data['what']);
|
||||
$currency = $this->getJournalCurrency($data['currency']);
|
||||
|
@ -7,6 +7,7 @@ use FireflyIII\Database\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
@ -19,12 +20,12 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
{
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
public function destroy(Eloquent $model)
|
||||
{
|
||||
// TODO: Implement destroy() method.
|
||||
throw new NotImplementedException;
|
||||
@ -43,13 +44,13 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param Eloquent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
public function update(Eloquent $model, array $data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
throw new NotImplementedException;
|
||||
|
@ -1,109 +0,0 @@
|
||||
<?php
|
||||
namespace FireflyIII\Shared;
|
||||
|
||||
/**
|
||||
* Class SingleTableInheritanceEntity
|
||||
*
|
||||
* @package FireflyIII\Shared
|
||||
*/
|
||||
abstract class SingleTableInheritanceEntity extends \Eloquent
|
||||
{
|
||||
/**
|
||||
* must be overridden and set to true in subclasses
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected $isSubclass = false;
|
||||
protected $subclassField = null;
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Model|static
|
||||
*/
|
||||
public function newFromBuilder($attributes = [])
|
||||
{
|
||||
$instance = $this->mapData((array)$attributes)->newInstance([], true);
|
||||
$instance->setRawAttributes((array)$attributes, true);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* instead of using $this->newInstance(), call
|
||||
* newInstance() on the object from mapData
|
||||
*
|
||||
* @param bool $excludeDeleted
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder|static
|
||||
*/
|
||||
public function newQuery($excludeDeleted = true)
|
||||
{
|
||||
// If using Laravel 4.0.x then use the following commented version of this command
|
||||
// $builder = new Builder($this->newBaseQueryBuilder());
|
||||
// newEloquentBuilder() was added in 4.1
|
||||
$builder = $this->newEloquentBuilder($this->newBaseQueryBuilder());
|
||||
|
||||
// Once Firefly has the query builders, it will set the model instances so the
|
||||
// builder can easily access any information it may need from the model
|
||||
// while it is constructing and executing various queries against it.
|
||||
$builder->setModel($this)->with($this->with);
|
||||
|
||||
if ($excludeDeleted && $this->softDelete) {
|
||||
$builder->whereNull($this->getQualifiedDeletedAtColumn());
|
||||
}
|
||||
|
||||
if ($this->subclassField && $this->isSubclass()) {
|
||||
$builder->where($this->subclassField, '=', get_class($this));
|
||||
}
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* ensure that the subclass field is assigned on save
|
||||
*
|
||||
* @param array $rules
|
||||
* @param array $customMessages
|
||||
* @param array $options
|
||||
* @param callable $beforeSave
|
||||
* @param callable $afterSave
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save(array $rules = [], array $customMessages = [], array $options = [], \Closure $beforeSave = null, \Closure $afterSave = null)
|
||||
{
|
||||
if ($this->subclassField) {
|
||||
$this->attributes[$this->subclassField] = get_class($this);
|
||||
}
|
||||
|
||||
return parent::save($rules, $customMessages, $options, $beforeSave, $afterSave);
|
||||
}
|
||||
|
||||
/**
|
||||
* if no subclass is defined, function as normal
|
||||
*
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Model|static
|
||||
*/
|
||||
public function mapData(array $attributes)
|
||||
{
|
||||
if (!$this->subclassField) {
|
||||
return $this->newInstance();
|
||||
}
|
||||
|
||||
return new $attributes[$this->subclassField];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSubclass()
|
||||
{
|
||||
return $this->isSubclass;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
/**
|
||||
* Class Account
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class AccountMeta
|
||||
*/
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class AccountType
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class Budget
|
||||
*/
|
||||
|
@ -3,7 +3,7 @@
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class Limit
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class Category
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class Component
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class LimitRepetition
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class Piggybank
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class PiggyBankEvent
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class PiggybankRepetition
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class Preference
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class RecurringTransaction
|
||||
*/
|
||||
@ -9,22 +9,19 @@ class RecurringTransaction extends Eloquent
|
||||
{
|
||||
|
||||
use ValidatingTrait;
|
||||
public static $rules
|
||||
protected $rules
|
||||
= [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
'name' => 'required|between:1,255',
|
||||
'name' => 'required|between:1,255|min:1',
|
||||
'match' => 'required',
|
||||
'amount_max' => 'required|between:0,65536',
|
||||
'amount_min' => 'required|between:0,65536',
|
||||
'date' => 'required|date',
|
||||
'active' => 'required|between:0,1',
|
||||
'automatch' => 'required|between:0,1',
|
||||
'active' => 'between:0,1',
|
||||
'automatch' => 'between:0,1',
|
||||
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly',
|
||||
'skip' => 'required|between:0,31',];
|
||||
// @codingStandardsIgnoreStart
|
||||
protected $fillable = ['user_id', 'name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'active', 'automatch'];
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class Reminder
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@ use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Class Transaction
|
||||
*/
|
||||
|
@ -2,7 +2,6 @@
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class TransactionCurrency
|
||||
*/
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
/**
|
||||
* Class TransactionGroup
|
||||
|
@ -4,6 +4,7 @@ use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
/**
|
||||
* Class TransactionJournal
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
/**
|
||||
* Class TransactionRelation
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
/**
|
||||
* Class TransactionType
|
||||
|
@ -5,6 +5,7 @@ use Illuminate\Auth\Reminders\RemindableTrait;
|
||||
use Illuminate\Auth\UserInterface;
|
||||
use Illuminate\Auth\UserTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
|
@ -1,4 +1,4 @@
|
||||
<form style="display: inline;" action="{{route('budgets.postIncome')}}" method="POST">
|
||||
<form style="display: inline;" id="income" action="{{route('budgets.postIncome')}}" method="POST">
|
||||
{{Form::token()}}
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
@ -1,17 +1,24 @@
|
||||
<?php
|
||||
//exec('php artisan migrate --seed --env=testing');
|
||||
// This is global bootstrap for autoloading
|
||||
$db = realpath(__DIR__ . '/_data') . '/testing.sqlite';
|
||||
|
||||
if (!file_exists($db)) {
|
||||
exec('touch ' . $db);
|
||||
exec('php artisan migrate --seed --env=testing');
|
||||
}
|
||||
exec('cp ' . $db . ' ' . realpath(__DIR__ . '/_data') . '/clean.sqlite');
|
||||
|
||||
/**
|
||||
* Class resetToClean
|
||||
* @SuppressWarnings("CamelCase")
|
||||
*/
|
||||
//
|
||||
//
|
||||
//$db = realpath(__DIR__ . '/_data') . '/testing.sqlite';
|
||||
//if (!file_exists($db)) {
|
||||
// echo 'Recreating database...' . "\n";
|
||||
// exec('touch ' . $db);
|
||||
//
|
||||
//} else {
|
||||
// echo 'Database exists!' . "\n";
|
||||
//}
|
||||
//echo 'Copy database to clean database (turned off)...' . "\n";
|
||||
//exec('cp ' . $db . ' ' . realpath(__DIR__ . '/_data') . '/clean.sqlite');
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * Class resetToClean
|
||||
// * @SuppressWarnings("CamelCase")
|
||||
// */
|
||||
class resetToClean
|
||||
{
|
||||
/**
|
||||
@ -19,6 +26,6 @@ class resetToClean
|
||||
*/
|
||||
static public function clean()
|
||||
{
|
||||
exec('cp ' . realpath(__DIR__ . '/_data') . '/clean.sqlite ' . realpath(__DIR__ . '/_data') . '/testing.sqlite');
|
||||
//exec('cp ' . realpath(__DIR__ . '/_data') . '/clean.sqlite ' . realpath(__DIR__ . '/_data') . '/testing.sqlite');
|
||||
}
|
||||
}
|
1798
tests/_data/dump.sql
Normal file
1798
tests/_data/dump.sql
Normal file
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,15 @@ class BudgetControllerCest
|
||||
public function amount(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('update the amount for a budget and limit repetition');
|
||||
$I->amOnPage('/budgets/income');
|
||||
$I->amOnPage('/budgets');
|
||||
|
||||
///budgets/income
|
||||
|
||||
$I->sendAjaxPostRequest('/budgets/amount/1', ['amount' => 100]);
|
||||
$I->canSeeResponseCodeIs(200);
|
||||
$I->see('Groceries');
|
||||
$I->seeInDatabase('budgets', ['id' => 1]);
|
||||
#$I->seeInDatabase('budget_limits', ['budget_id' => 1, 'amount' => 100.00]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,12 +66,12 @@ class BudgetControllerCest
|
||||
public function destroy(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('destroy a budget');
|
||||
#$I->amOnPage('/budgets/delete/3');
|
||||
#$I->see('Delete budget "Delete me"');
|
||||
#$I->submitForm('#destroy', []);
|
||||
#$I->see('Budget "Delete me" was deleted.');
|
||||
#$I->dontSeeInDatabase('components', ['name' => 'Delete me', 'class' => 'Budget','deleted_at' => null]);
|
||||
//resetToClean::clean();
|
||||
$I->amOnPage('/budgets/delete/3');
|
||||
$I->see('Delete budget "Delete me"');
|
||||
$I->submitForm('#destroy', []);
|
||||
$I->see('Budget "Delete me" was deleted.');
|
||||
#$I->dontSeeInDatabase('budgets', ['name' => 'Delete me','deleted_at' => null]);
|
||||
resetToClean::clean();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,7 +97,12 @@ class BudgetControllerCest
|
||||
*/
|
||||
public function postUpdateIncome(FunctionalTester $I)
|
||||
{
|
||||
$date = date('FY');
|
||||
$I->wantTo('process the update to my monthly income');
|
||||
$I->amOnPage('/budgets/income');
|
||||
$I->see('Update (expected) income for');
|
||||
$I->submitForm('#income', ['amount' => 1200]);
|
||||
$I->seeRecord('preferences', ['name' => 'budgetIncomeTotal' . $date, 'data' => 1200]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user