mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Updated tests.
This commit is contained in:
@@ -2,22 +2,7 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
/*
|
'default' => 'mysql',
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| 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.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'connections' => [
|
'connections' => [
|
||||||
|
|
||||||
'mysql' => [
|
'mysql' => [
|
||||||
@@ -30,6 +15,11 @@ return [
|
|||||||
'collation' => 'utf8_unicode_ci',
|
'collation' => 'utf8_unicode_ci',
|
||||||
'prefix' => '',
|
'prefix' => '',
|
||||||
],
|
],
|
||||||
|
'sqlite' => [
|
||||||
|
'driver' => 'sqlite',
|
||||||
|
'database' => realpath(__DIR__.'/../../../tests/_data/testing.sqlite'),
|
||||||
|
'prefix' => ''
|
||||||
|
],
|
||||||
|
|
||||||
'pgsql' => [
|
'pgsql' => [
|
||||||
'driver' => 'pgsql',
|
'driver' => 'pgsql',
|
||||||
|
@@ -4,7 +4,7 @@ return [
|
|||||||
'connections' => [
|
'connections' => [
|
||||||
'sqlite' => [
|
'sqlite' => [
|
||||||
'driver' => 'sqlite',
|
'driver' => 'sqlite',
|
||||||
'database' => 'tests/_data/testing.sqlite',
|
'database' => realpath(__DIR__.'/../../../tests/_data/db.sqlite'),
|
||||||
'prefix' => ''
|
'prefix' => ''
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@@ -22,6 +22,7 @@ use Illuminate\Database\Schema\Blueprint;
|
|||||||
* 15. Do not recreate component_recurring_transaction
|
* 15. Do not recreate component_recurring_transaction
|
||||||
* 16. Do not recreate component_transaction
|
* 16. Do not recreate component_transaction
|
||||||
* 17. Do not recreate field 'piggybank_id' in 'transactions'
|
* 17. Do not recreate field 'piggybank_id' in 'transactions'
|
||||||
|
* 18. Recreate component_id in limits
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Up:
|
* Up:
|
||||||
@@ -41,7 +42,7 @@ use Illuminate\Database\Schema\Blueprint;
|
|||||||
* 13. Drop table component_recurring_transaction
|
* 13. Drop table component_recurring_transaction
|
||||||
* 14. Drop table component_transaction
|
* 14. Drop table component_transaction
|
||||||
* 15. Drop field 'piggybank_id' from 'transactions'
|
* 15. Drop field 'piggybank_id' from 'transactions'
|
||||||
*
|
* 16. Drop component_id from budget_limits.
|
||||||
*
|
*
|
||||||
* Class ChangesForV321
|
* Class ChangesForV321
|
||||||
*/
|
*/
|
||||||
@@ -230,6 +231,7 @@ class ChangesForV321 extends Migration
|
|||||||
$this->dropComponentRecurringTransactionTable(); // 13.
|
$this->dropComponentRecurringTransactionTable(); // 13.
|
||||||
$this->dropComponentTransactionTable(); // 14.
|
$this->dropComponentTransactionTable(); // 14.
|
||||||
$this->dropPiggyBankIdFromTransactions(); // 15.
|
$this->dropPiggyBankIdFromTransactions(); // 15.
|
||||||
|
$this->dropComponentIdFromBudgetLimits(); // 16.
|
||||||
|
|
||||||
|
|
||||||
// $this->doRenameInLimitRepetitions();
|
// $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()
|
// public function doRenameInLimitRepetitions()
|
||||||
// {
|
// {
|
||||||
|
@@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
App::before(
|
App::before(
|
||||||
function ($request) {
|
function ($request) {
|
||||||
|
|
||||||
|
// put IP in session if not already there.
|
||||||
|
|
||||||
$reminders = [];
|
$reminders = [];
|
||||||
|
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
|
@@ -36,8 +36,8 @@ class PiggybankPart
|
|||||||
public function getReminder()
|
public function getReminder()
|
||||||
{
|
{
|
||||||
if (is_null($this->reminder)) {
|
if (is_null($this->reminder)) {
|
||||||
$this->reminder = $this->repetition->piggybank->reminders()->where('startdate', $bar->getStartdate()->format('Y-m-d'))->where(
|
$this->reminder = $this->repetition->piggybank->reminders()->where('startdate', $this->getStartdate()->format('Y-m-d'))->where(
|
||||||
'enddate', $bar->getTargetdate()->format('Y-m-d')
|
'enddate', $this->getTargetdate()->format('Y-m-d')
|
||||||
)->first();
|
)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,22 +52,6 @@ class PiggybankPart
|
|||||||
$this->reminder = $reminder;
|
$this->reminder = $reminder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \PiggybankRepetition
|
|
||||||
*/
|
|
||||||
public function getRepetition()
|
|
||||||
{
|
|
||||||
return $this->repetition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \PiggybankRepetition $repetition
|
|
||||||
*/
|
|
||||||
public function setRepetition($repetition)
|
|
||||||
{
|
|
||||||
$this->repetition = $repetition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Carbon
|
* @return Carbon
|
||||||
*/
|
*/
|
||||||
@@ -100,6 +84,22 @@ class PiggybankPart
|
|||||||
$this->targetdate = $targetdate;
|
$this->targetdate = $targetdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \PiggybankRepetition
|
||||||
|
*/
|
||||||
|
public function getRepetition()
|
||||||
|
{
|
||||||
|
return $this->repetition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \PiggybankRepetition $repetition
|
||||||
|
*/
|
||||||
|
public function setRepetition($repetition)
|
||||||
|
{
|
||||||
|
$this->repetition = $repetition;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@@ -7,6 +7,7 @@ use FireflyIII\Database\CommonDatabaseCalls;
|
|||||||
use FireflyIII\Database\CUD;
|
use FireflyIII\Database\CUD;
|
||||||
use FireflyIII\Database\SwitchUser;
|
use FireflyIII\Database\SwitchUser;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
@@ -214,11 +215,11 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function destroy(\Eloquent $model)
|
public function destroy(Eloquent $model)
|
||||||
{
|
{
|
||||||
|
|
||||||
// delete journals:
|
// delete journals:
|
||||||
@@ -339,12 +340,12 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function update(\Eloquent $model, array $data)
|
public function update(Eloquent $model, array $data)
|
||||||
{
|
{
|
||||||
$model->name = $data['name'];
|
$model->name = $data['name'];
|
||||||
$model->active = isset($data['active']) ? intval($data['active']) : 0;
|
$model->active = isset($data['active']) ? intval($data['active']) : 0;
|
||||||
|
@@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
namespace FireflyIII\Database\AccountType;
|
namespace FireflyIII\Database\AccountType;
|
||||||
|
|
||||||
use FireflyIII\Exception\FireflyException;
|
|
||||||
use FireflyIII\Database\CommonDatabaseCalls;
|
use FireflyIII\Database\CommonDatabaseCalls;
|
||||||
use FireflyIII\Database\CUD;
|
use FireflyIII\Database\CUD;
|
||||||
|
use FireflyIII\Exception\FireflyException;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,12 +18,12 @@ class AccountType implements CUD, CommonDatabaseCalls
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws NotImplementedException
|
* @throws NotImplementedException
|
||||||
*/
|
*/
|
||||||
public function destroy(\Eloquent $model)
|
public function destroy(Eloquent $model)
|
||||||
{
|
{
|
||||||
// TODO: Implement destroy() method.
|
// TODO: Implement destroy() method.
|
||||||
throw new NotImplementedException;
|
throw new NotImplementedException;
|
||||||
@@ -41,13 +42,13 @@ class AccountType implements CUD, CommonDatabaseCalls
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws NotImplementedException
|
* @throws NotImplementedException
|
||||||
*/
|
*/
|
||||||
public function update(\Eloquent $model, array $data)
|
public function update(Eloquent $model, array $data)
|
||||||
{
|
{
|
||||||
// TODO: Implement update() method.
|
// TODO: Implement update() method.
|
||||||
throw new NotImplementedException;
|
throw new NotImplementedException;
|
||||||
|
@@ -7,6 +7,7 @@ use FireflyIII\Database\CUD;
|
|||||||
use FireflyIII\Database\SwitchUser;
|
use FireflyIII\Database\SwitchUser;
|
||||||
use FireflyIII\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
@@ -28,11 +29,11 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function destroy(\Eloquent $model)
|
public function destroy(Eloquent $model)
|
||||||
{
|
{
|
||||||
$model->delete();
|
$model->delete();
|
||||||
|
|
||||||
@@ -62,12 +63,12 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function update(\Eloquent $model, array $data)
|
public function update(Eloquent $model, array $data)
|
||||||
{
|
{
|
||||||
$model->name = $data['name'];
|
$model->name = $data['name'];
|
||||||
$model->save();
|
$model->save();
|
||||||
@@ -236,9 +237,9 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
|||||||
{
|
{
|
||||||
return \LimitRepetition::
|
return \LimitRepetition::
|
||||||
leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
|
leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
|
||||||
->where('limit_repetitions.startdate', $date->format('Y-m-d'))
|
->where('limit_repetitions.startdate', $date->format('Y-m-d'))
|
||||||
->where('budget_limits.budget_id', $budget->id)
|
->where('budget_limits.budget_id', $budget->id)
|
||||||
->first(['limit_repetitions.*']);
|
->first(['limit_repetitions.*']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -251,21 +252,22 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
|||||||
{
|
{
|
||||||
// Add expenses that have no budget:
|
// Add expenses that have no budget:
|
||||||
return $this->getUser()
|
return $this->getUser()
|
||||||
->transactionjournals()
|
->transactionjournals()
|
||||||
->whereNotIn('transaction_journals.id', function ($query) use ($start, $end) {
|
->whereNotIn(
|
||||||
$query
|
'transaction_journals.id', function ($query) use ($start, $end) {
|
||||||
->select('transaction_journals.id')
|
$query
|
||||||
->from('transaction_journals')
|
->select('transaction_journals.id')
|
||||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
->from('transaction_journals')
|
||||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'));
|
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
||||||
}
|
->where('transaction_journals.date', '<=', $end->format('Y-m-d'));
|
||||||
)
|
}
|
||||||
->before($end)
|
)
|
||||||
->after($start)
|
->before($end)
|
||||||
->lessThan(0)
|
->after($start)
|
||||||
->transactionTypes(['Withdrawal'])
|
->lessThan(0)
|
||||||
->get();
|
->transactionTypes(['Withdrawal'])
|
||||||
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -321,7 +323,9 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
|||||||
$limit->amount = $amount;
|
$limit->amount = $amount;
|
||||||
$limit->repeat_freq = 'monthly';
|
$limit->repeat_freq = 'monthly';
|
||||||
$limit->repeats = 0;
|
$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.
|
* A newly stored limit also created a limit repetition.
|
||||||
*/
|
*/
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace FireflyIII\Database;
|
namespace FireflyIII\Database;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,26 +14,26 @@ interface CUD
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function destroy(\Eloquent $model);
|
public function destroy(Eloquent $model);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return \Eloquent
|
* @return Eloquent
|
||||||
*/
|
*/
|
||||||
public function store(array $data);
|
public function store(array $data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function update(\Eloquent $model, array $data);
|
public function update(Eloquent $model, array $data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates an array. Returns an array containing MessageBags
|
* Validates an array. Returns an array containing MessageBags
|
||||||
|
@@ -7,10 +7,10 @@ use FireflyIII\Database\CUD;
|
|||||||
use FireflyIII\Database\SwitchUser;
|
use FireflyIII\Database\SwitchUser;
|
||||||
use FireflyIII\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Category
|
* Class Category
|
||||||
*
|
*
|
||||||
@@ -29,11 +29,11 @@ class Category implements CUD, CommonDatabaseCalls
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function destroy(\Eloquent $model)
|
public function destroy(Eloquent $model)
|
||||||
{
|
{
|
||||||
$model->delete();
|
$model->delete();
|
||||||
|
|
||||||
@@ -62,13 +62,13 @@ class Category implements CUD, CommonDatabaseCalls
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function update(\Eloquent $model, array $data)
|
public function update(Eloquent $model, array $data)
|
||||||
{
|
{
|
||||||
$model->name = $data['name'];
|
$model->name = $data['name'];
|
||||||
if (!$model->isValid()) {
|
if (!$model->isValid()) {
|
||||||
|
@@ -5,7 +5,6 @@ namespace FireflyIII\Database;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface CommonDatabaseCalls
|
* Interface CommonDatabaseCalls
|
||||||
*
|
*
|
||||||
|
@@ -7,10 +7,10 @@ use FireflyIII\Database\CUD;
|
|||||||
use FireflyIII\Database\SwitchUser;
|
use FireflyIII\Database\SwitchUser;
|
||||||
use FireflyIII\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Piggybank
|
* Class Piggybank
|
||||||
*
|
*
|
||||||
@@ -29,11 +29,11 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function destroy(\Eloquent $model)
|
public function destroy(Eloquent $model)
|
||||||
{
|
{
|
||||||
$model->delete();
|
$model->delete();
|
||||||
}
|
}
|
||||||
@@ -56,12 +56,12 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function update(\Eloquent $model, array $data)
|
public function update(Eloquent $model, array $data)
|
||||||
{
|
{
|
||||||
/** @var \Piggybank $model */
|
/** @var \Piggybank $model */
|
||||||
$model->name = $data['name'];
|
$model->name = $data['name'];
|
||||||
@@ -178,7 +178,9 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
|||||||
public function find($objectId)
|
public function find($objectId)
|
||||||
{
|
{
|
||||||
return \Piggybank::
|
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.*']);
|
->first(['piggybanks.*']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,6 +244,7 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
|||||||
if ($date >= $rep->startdate && $date <= $rep->targetdate) {
|
if ($date >= $rep->startdate && $date <= $rep->targetdate) {
|
||||||
return $rep;
|
return $rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@@ -9,10 +9,10 @@ use FireflyIII\Database\CommonDatabaseCalls;
|
|||||||
use FireflyIII\Database\CUD;
|
use FireflyIII\Database\CUD;
|
||||||
use FireflyIII\Database\SwitchUser;
|
use FireflyIII\Database\SwitchUser;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RepeatedExpense
|
* Class RepeatedExpense
|
||||||
*
|
*
|
||||||
@@ -98,12 +98,12 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws NotImplementedException
|
* @throws NotImplementedException
|
||||||
*/
|
*/
|
||||||
public function destroy(\Eloquent $model)
|
public function destroy(Eloquent $model)
|
||||||
{
|
{
|
||||||
// TODO: Implement destroy() method.
|
// TODO: Implement destroy() method.
|
||||||
throw new NotImplementedException;
|
throw new NotImplementedException;
|
||||||
@@ -135,13 +135,13 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws NotImplementedException
|
* @throws NotImplementedException
|
||||||
*/
|
*/
|
||||||
public function update(\Eloquent $model, array $data)
|
public function update(Eloquent $model, array $data)
|
||||||
{
|
{
|
||||||
// TODO: Implement update() method.
|
// TODO: Implement update() method.
|
||||||
throw new NotImplementedException;
|
throw new NotImplementedException;
|
||||||
|
@@ -8,6 +8,7 @@ use FireflyIII\Database\CommonDatabaseCalls;
|
|||||||
use FireflyIII\Database\CUD;
|
use FireflyIII\Database\CUD;
|
||||||
use FireflyIII\Database\SwitchUser;
|
use FireflyIII\Database\SwitchUser;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
@@ -29,11 +30,11 @@ class RecurringTransaction implements CUD, CommonDatabaseCalls, RecurringTransac
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function destroy(\Eloquent $model)
|
public function destroy(Eloquent $model)
|
||||||
{
|
{
|
||||||
$model->delete();
|
$model->delete();
|
||||||
|
|
||||||
@@ -74,12 +75,12 @@ class RecurringTransaction implements CUD, CommonDatabaseCalls, RecurringTransac
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function update(\Eloquent $model, array $data)
|
public function update(Eloquent $model, array $data)
|
||||||
{
|
{
|
||||||
$model->name = $data['name'];
|
$model->name = $data['name'];
|
||||||
$model->match = $data['match'];
|
$model->match = $data['match'];
|
||||||
@@ -113,45 +114,13 @@ class RecurringTransaction implements CUD, CommonDatabaseCalls, RecurringTransac
|
|||||||
$warnings = new MessageBag;
|
$warnings = new MessageBag;
|
||||||
$successes = new MessageBag;
|
$successes = new MessageBag;
|
||||||
$errors = 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'])) {
|
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_max', 'Maximum amount can not be less than minimum amount.');
|
||||||
$errors->add('amount_min', 'Minimum amount can not be more than maximum amount.');
|
$errors->add('amount_min', 'Minimum amount can not be more than maximum amount.');
|
||||||
}
|
}
|
||||||
|
$object = new \RecurringTransaction($model);
|
||||||
if ($model['date'] != '') {
|
$object->isValid();
|
||||||
try {
|
$errors->merge($object->getErrors());
|
||||||
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.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$set = ['name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active'];
|
$set = ['name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active'];
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
|
@@ -7,10 +7,10 @@ use FireflyIII\Database\CUD;
|
|||||||
use FireflyIII\Database\SwitchUser;
|
use FireflyIII\Database\SwitchUser;
|
||||||
use FireflyIII\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Transaction
|
* Class Transaction
|
||||||
*
|
*
|
||||||
@@ -21,12 +21,12 @@ class Transaction implements CUD, CommonDatabaseCalls
|
|||||||
use SwitchUser;
|
use SwitchUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws NotImplementedException
|
* @throws NotImplementedException
|
||||||
*/
|
*/
|
||||||
public function destroy(\Eloquent $model)
|
public function destroy(Eloquent $model)
|
||||||
{
|
{
|
||||||
// TODO: Implement destroy() method.
|
// TODO: Implement destroy() method.
|
||||||
throw new NotImplementedException;
|
throw new NotImplementedException;
|
||||||
@@ -60,13 +60,13 @@ class Transaction implements CUD, CommonDatabaseCalls
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws NotImplementedException
|
* @throws NotImplementedException
|
||||||
*/
|
*/
|
||||||
public function update(\Eloquent $model, array $data)
|
public function update(Eloquent $model, array $data)
|
||||||
{
|
{
|
||||||
// TODO: Implement update() method.
|
// TODO: Implement update() method.
|
||||||
throw new NotImplementedException;
|
throw new NotImplementedException;
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace FireflyIII\Database\TransactionCurrency;
|
namespace FireflyIII\Database\TransactionCurrency;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TransactionType
|
* Class TransactionType
|
||||||
*
|
*
|
||||||
|
@@ -9,6 +9,7 @@ use FireflyIII\Database\CUD;
|
|||||||
use FireflyIII\Database\SwitchUser;
|
use FireflyIII\Database\SwitchUser;
|
||||||
use FireflyIII\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
@@ -30,11 +31,11 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function destroy(\Eloquent $model)
|
public function destroy(Eloquent $model)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Trigger deletion.
|
* Trigger deletion.
|
||||||
@@ -84,13 +85,13 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function update(\Eloquent $model, array $data)
|
public function update(Eloquent $model, array $data)
|
||||||
{
|
{
|
||||||
$journalType = $this->getJournalType($data['what']);
|
$journalType = $this->getJournalType($data['what']);
|
||||||
$currency = $this->getJournalCurrency($data['currency']);
|
$currency = $this->getJournalCurrency($data['currency']);
|
||||||
|
@@ -7,6 +7,7 @@ use FireflyIII\Database\CommonDatabaseCalls;
|
|||||||
use FireflyIII\Database\CUD;
|
use FireflyIII\Database\CUD;
|
||||||
use FireflyIII\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
|
||||||
@@ -19,12 +20,12 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws NotImplementedException
|
* @throws NotImplementedException
|
||||||
*/
|
*/
|
||||||
public function destroy(\Eloquent $model)
|
public function destroy(Eloquent $model)
|
||||||
{
|
{
|
||||||
// TODO: Implement destroy() method.
|
// TODO: Implement destroy() method.
|
||||||
throw new NotImplementedException;
|
throw new NotImplementedException;
|
||||||
@@ -43,13 +44,13 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Eloquent $model
|
* @param Eloquent $model
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws NotImplementedException
|
* @throws NotImplementedException
|
||||||
*/
|
*/
|
||||||
public function update(\Eloquent $model, array $data)
|
public function update(Eloquent $model, array $data)
|
||||||
{
|
{
|
||||||
// TODO: Implement update() method.
|
// TODO: Implement update() method.
|
||||||
throw new NotImplementedException;
|
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\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Account
|
* Class Account
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class AccountMeta
|
* Class AccountMeta
|
||||||
*/
|
*/
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AccountType
|
* Class AccountType
|
||||||
*/
|
*/
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class Budget
|
* Class Budget
|
||||||
*/
|
*/
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\QueryException;
|
use Illuminate\Database\QueryException;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class Limit
|
* Class Limit
|
||||||
*/
|
*/
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class Category
|
* Class Category
|
||||||
*/
|
*/
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class Component
|
* Class Component
|
||||||
*/
|
*/
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use FireflyIII\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class LimitRepetition
|
* Class LimitRepetition
|
||||||
*/
|
*/
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class Piggybank
|
* Class Piggybank
|
||||||
*/
|
*/
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class PiggyBankEvent
|
* Class PiggyBankEvent
|
||||||
*/
|
*/
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class PiggybankRepetition
|
* Class PiggybankRepetition
|
||||||
*/
|
*/
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class Preference
|
* Class Preference
|
||||||
*/
|
*/
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class RecurringTransaction
|
* Class RecurringTransaction
|
||||||
*/
|
*/
|
||||||
@@ -9,22 +9,19 @@ class RecurringTransaction extends Eloquent
|
|||||||
{
|
{
|
||||||
|
|
||||||
use ValidatingTrait;
|
use ValidatingTrait;
|
||||||
public static $rules
|
protected $rules
|
||||||
= [
|
= [
|
||||||
'user_id' => 'required|exists:users,id',
|
'user_id' => 'required|exists:users,id',
|
||||||
'name' => 'required|between:1,255',
|
'name' => 'required|between:1,255|min:1',
|
||||||
'match' => 'required',
|
'match' => 'required',
|
||||||
'amount_max' => 'required|between:0,65536',
|
'amount_max' => 'required|between:0,65536',
|
||||||
'amount_min' => 'required|between:0,65536',
|
'amount_min' => 'required|between:0,65536',
|
||||||
'date' => 'required|date',
|
'date' => 'required|date',
|
||||||
'active' => 'required|between:0,1',
|
'active' => 'between:0,1',
|
||||||
'automatch' => 'required|between:0,1',
|
'automatch' => 'between:0,1',
|
||||||
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly',
|
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly',
|
||||||
'skip' => 'required|between:0,31',];
|
'skip' => 'required|between:0,31',];
|
||||||
// @codingStandardsIgnoreStart
|
|
||||||
protected $fillable = ['user_id', 'name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'active', 'automatch'];
|
protected $fillable = ['user_id', 'name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'active', 'automatch'];
|
||||||
// @codingStandardsIgnoreEnd
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class Reminder
|
* Class Reminder
|
||||||
*/
|
*/
|
||||||
|
@@ -4,7 +4,7 @@ use Carbon\Carbon;
|
|||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
/**
|
/**
|
||||||
* Class Transaction
|
* Class Transaction
|
||||||
*/
|
*/
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TransactionCurrency
|
* Class TransactionCurrency
|
||||||
*/
|
*/
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TransactionGroup
|
* Class TransactionGroup
|
||||||
|
@@ -4,6 +4,7 @@ use Carbon\Carbon;
|
|||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TransactionJournal
|
* Class TransactionJournal
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TransactionRelation
|
* Class TransactionRelation
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TransactionType
|
* Class TransactionType
|
||||||
|
@@ -5,6 +5,7 @@ use Illuminate\Auth\Reminders\RemindableTrait;
|
|||||||
use Illuminate\Auth\UserInterface;
|
use Illuminate\Auth\UserInterface;
|
||||||
use Illuminate\Auth\UserTrait;
|
use Illuminate\Auth\UserTrait;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class User
|
* 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()}}
|
{{Form::token()}}
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
@@ -1,17 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
//exec('php artisan migrate --seed --env=testing');
|
||||||
// This is global bootstrap for autoloading
|
// This is global bootstrap for autoloading
|
||||||
$db = realpath(__DIR__ . '/_data') . '/testing.sqlite';
|
//
|
||||||
|
//
|
||||||
if (!file_exists($db)) {
|
//$db = realpath(__DIR__ . '/_data') . '/testing.sqlite';
|
||||||
exec('touch ' . $db);
|
//if (!file_exists($db)) {
|
||||||
exec('php artisan migrate --seed --env=testing');
|
// echo 'Recreating database...' . "\n";
|
||||||
}
|
// exec('touch ' . $db);
|
||||||
exec('cp ' . $db . ' ' . realpath(__DIR__ . '/_data') . '/clean.sqlite');
|
//
|
||||||
|
//} else {
|
||||||
/**
|
// echo 'Database exists!' . "\n";
|
||||||
* Class resetToClean
|
//}
|
||||||
* @SuppressWarnings("CamelCase")
|
//echo 'Copy database to clean database (turned off)...' . "\n";
|
||||||
*/
|
//exec('cp ' . $db . ' ' . realpath(__DIR__ . '/_data') . '/clean.sqlite');
|
||||||
|
//
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * Class resetToClean
|
||||||
|
// * @SuppressWarnings("CamelCase")
|
||||||
|
// */
|
||||||
class resetToClean
|
class resetToClean
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -19,6 +26,6 @@ class resetToClean
|
|||||||
*/
|
*/
|
||||||
static public function clean()
|
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)
|
public function amount(FunctionalTester $I)
|
||||||
{
|
{
|
||||||
$I->wantTo('update the amount for a budget and limit repetition');
|
$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)
|
public function destroy(FunctionalTester $I)
|
||||||
{
|
{
|
||||||
$I->wantTo('destroy a budget');
|
$I->wantTo('destroy a budget');
|
||||||
#$I->amOnPage('/budgets/delete/3');
|
$I->amOnPage('/budgets/delete/3');
|
||||||
#$I->see('Delete budget "Delete me"');
|
$I->see('Delete budget "Delete me"');
|
||||||
#$I->submitForm('#destroy', []);
|
$I->submitForm('#destroy', []);
|
||||||
#$I->see('Budget "Delete me" was deleted.');
|
$I->see('Budget "Delete me" was deleted.');
|
||||||
#$I->dontSeeInDatabase('components', ['name' => 'Delete me', 'class' => 'Budget','deleted_at' => null]);
|
#$I->dontSeeInDatabase('budgets', ['name' => 'Delete me','deleted_at' => null]);
|
||||||
//resetToClean::clean();
|
resetToClean::clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,7 +97,12 @@ class BudgetControllerCest
|
|||||||
*/
|
*/
|
||||||
public function postUpdateIncome(FunctionalTester $I)
|
public function postUpdateIncome(FunctionalTester $I)
|
||||||
{
|
{
|
||||||
|
$date = date('FY');
|
||||||
$I->wantTo('process the update to my monthly income');
|
$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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user