mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 12:28:46 +00:00
New test content.
This commit is contained in:
@@ -75,22 +75,6 @@ class ChangesForV321 extends Migration
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createComponentId() {
|
|
||||||
Schema::table(
|
|
||||||
'budget_limits', function (Blueprint $table) {
|
|
||||||
$table->integer('component_id')->unsigned();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createComponentIdForeignKey() {
|
|
||||||
Schema::table(
|
|
||||||
'budget_limits', function (Blueprint $table) {
|
|
||||||
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function moveBudgetsBack()
|
public function moveBudgetsBack()
|
||||||
{
|
{
|
||||||
Budget::get()->each(
|
Budget::get()->each(
|
||||||
@@ -121,6 +105,15 @@ class ChangesForV321 extends Migration
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createComponentId()
|
||||||
|
{
|
||||||
|
Schema::table(
|
||||||
|
'budget_limits', function (Blueprint $table) {
|
||||||
|
$table->integer('component_id')->unsigned();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function updateComponentInBudgetLimits()
|
public function updateComponentInBudgetLimits()
|
||||||
{
|
{
|
||||||
BudgetLimit::get()->each(
|
BudgetLimit::get()->each(
|
||||||
@@ -138,6 +131,15 @@ class ChangesForV321 extends Migration
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createComponentIdForeignKey()
|
||||||
|
{
|
||||||
|
Schema::table(
|
||||||
|
'budget_limits', function (Blueprint $table) {
|
||||||
|
$table->foreign('component_id','limits_component_id_foreign')->references('id')->on('components')->onDelete('cascade');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function dropBudgetIdColumnInBudgetLimits()
|
public function dropBudgetIdColumnInBudgetLimits()
|
||||||
{
|
{
|
||||||
Schema::table(
|
Schema::table(
|
||||||
@@ -411,18 +413,28 @@ class ChangesForV321 extends Migration
|
|||||||
|
|
||||||
public function moveComponentIdToBudgetId()
|
public function moveComponentIdToBudgetId()
|
||||||
{
|
{
|
||||||
|
\Log::debug('Now in moveComponentIdToBudgetId()');
|
||||||
BudgetLimit::get()->each(
|
BudgetLimit::get()->each(
|
||||||
function (BudgetLimit $bl) {
|
function (BudgetLimit $bl) {
|
||||||
|
\Log::debug('Now at budgetLimit #' . $bl->id . ' with component_id: ' . $bl->component_id);
|
||||||
$component = Component::find($bl->component_id);
|
$component = Component::find($bl->component_id);
|
||||||
if ($component) {
|
if ($component) {
|
||||||
|
\Log::debug('Found component with id #' . $component->id . ' and name ' . $component->name);
|
||||||
$budget = Budget::whereName($component->name)->whereUserId($component->user_id)->first();
|
$budget = Budget::whereName($component->name)->whereUserId($component->user_id)->first();
|
||||||
if ($budget) {
|
if ($budget) {
|
||||||
|
\Log::debug('Found a budget with ID #' . $budget->id . ' and name ' . $budget->name);
|
||||||
$bl->budget_id = $budget->id;
|
$bl->budget_id = $budget->id;
|
||||||
$bl->save();
|
$bl->save();
|
||||||
|
\Log::debug('Connected budgetLimit #' . $bl->id . ' to budget_id' . $budget->id);
|
||||||
|
} else {
|
||||||
|
\Log::debug('Could not find a matching budget with name ' . $component->name);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
\Log::debug('Could not find a component with id ' . $bl->component_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
\Log::debug('Done with moveComponentIdToBudgetId()');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ class TestContentSeeder extends Seeder
|
|||||||
'order' => 0,
|
'order' => 0,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$piggyBankEvent = PiggyBankEvent::create(['piggybank_id' => 1, 'date' => $startDate->format('Y-m-d'), 'amount' => 100]);
|
PiggyBankEvent::create(['piggybank_id' => 1, 'date' => $startDate->format('Y-m-d'), 'amount' => 100]);
|
||||||
$piggyBankRepetition = PiggybankRepetition::create(
|
PiggybankRepetition::create(
|
||||||
[
|
[
|
||||||
'piggybank_id' => $piggy->id,
|
'piggybank_id' => $piggy->id,
|
||||||
'startdate' => Carbon::now()->format('Y-m-d'),
|
'startdate' => Carbon::now()->format('Y-m-d'),
|
||||||
@@ -106,6 +106,35 @@ class TestContentSeeder extends Seeder
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// piggy bank
|
||||||
|
$piggyTargeted = Piggybank::create(
|
||||||
|
[
|
||||||
|
'account_id' => $savings->id,
|
||||||
|
'name' => 'New clothes',
|
||||||
|
'targetamount' => 2000,
|
||||||
|
'startdate' => Carbon::now()->format('Y-m-d'),
|
||||||
|
'targetdate' => Carbon::now()->addMonths(4)->format('Y-m-d'),
|
||||||
|
'repeats' => 0,
|
||||||
|
'rep_length' => null,
|
||||||
|
'rep_every' => 0,
|
||||||
|
'rep_times' => null,
|
||||||
|
'reminder' => null,
|
||||||
|
'reminder_skip' => 0,
|
||||||
|
'remind_me' => 0,
|
||||||
|
'order' => 0,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
PiggyBankEvent::create(['piggybank_id' => $piggyTargeted->id, 'date' => $startDate->format('Y-m-d'), 'amount' => 100]);
|
||||||
|
PiggybankRepetition::create(
|
||||||
|
[
|
||||||
|
'piggybank_id' => $piggyTargeted->id,
|
||||||
|
'startdate' => Carbon::now()->format('Y-m-d'),
|
||||||
|
'targetdate' => Carbon::now()->addMonths(4)->format('Y-m-d'),
|
||||||
|
'currentamount' => 0
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
// recurring transaction
|
// recurring transaction
|
||||||
$recurring = \RecurringTransaction::create(
|
$recurring = \RecurringTransaction::create(
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
|||||||
$limit->repeat_freq = 'monthly';
|
$limit->repeat_freq = 'monthly';
|
||||||
$limit->repeats = 0;
|
$limit->repeats = 0;
|
||||||
$result = $limit->save();
|
$result = $limit->save();
|
||||||
\Log::info('Created new limit? ' . boolval($result));
|
\Log::info('Created new limit? ' . boolstr($result));
|
||||||
\Log::info('ID: ' . $limit->id);
|
\Log::info('ID: ' . $limit->id);
|
||||||
/*
|
/*
|
||||||
* A newly stored limit also created a limit repetition.
|
* A newly stored limit also created a limit repetition.
|
||||||
|
|||||||
@@ -262,7 +262,9 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
|||||||
*/
|
*/
|
||||||
public function leftOnAccount(\Account $account)
|
public function leftOnAccount(\Account $account)
|
||||||
{
|
{
|
||||||
|
\Log::debug('Now in leftOnAccount() for account #'.$account->id.' ('.$account->name.')');
|
||||||
$balance = \Steam::balance($account);
|
$balance = \Steam::balance($account);
|
||||||
|
\Log::debug('Steam says: ' . $balance);
|
||||||
/** @var \Piggybank $p */
|
/** @var \Piggybank $p */
|
||||||
foreach ($account->piggybanks()->get() as $p) {
|
foreach ($account->piggybanks()->get() as $p) {
|
||||||
$balance -= $p->currentRelevantRep()->currentamount;
|
$balance -= $p->currentRelevantRep()->currentamount;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class Steam
|
|||||||
*/
|
*/
|
||||||
public function balance(\Account $account, Carbon $date = null)
|
public function balance(\Account $account, Carbon $date = null)
|
||||||
{
|
{
|
||||||
|
\Log::debug('Now in Steam::balance() for account #' . $account->id.' ('.$account->name.')');
|
||||||
if (is_null($date)) {
|
if (is_null($date)) {
|
||||||
$key = 'account.' . $account->id . '.latestBalance';
|
$key = 'account.' . $account->id . '.latestBalance';
|
||||||
} else {
|
} else {
|
||||||
@@ -33,6 +34,7 @@ class Steam
|
|||||||
#return \Cache::get($key);
|
#return \Cache::get($key);
|
||||||
}
|
}
|
||||||
$date = is_null($date) ? Carbon::now() : $date;
|
$date = is_null($date) ? Carbon::now() : $date;
|
||||||
|
\Log::debug('Now reached the moment we fire the query.');
|
||||||
$balance = floatval(
|
$balance = floatval(
|
||||||
$account->transactions()->leftJoin(
|
$account->transactions()->leftJoin(
|
||||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
|
||||||
/**
|
/**
|
||||||
* Class Piggybank
|
* Class Piggybank
|
||||||
*/
|
*/
|
||||||
@@ -90,6 +91,7 @@ class Piggybank extends Eloquent
|
|||||||
if ($this->repeats == 0) {
|
if ($this->repeats == 0) {
|
||||||
$rep = $this->piggybankrepetitions()->first(['piggybank_repetitions.*']);
|
$rep = $this->piggybankrepetitions()->first(['piggybank_repetitions.*']);
|
||||||
$this->currentRep = $rep;
|
$this->currentRep = $rep;
|
||||||
|
\Log::debug('currentRelevantRep() reports $rep is null: ' . boolstr(is_null($rep)));
|
||||||
|
|
||||||
return $rep;
|
return $rep;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user