mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-31 19:27:51 -06:00
New test content.
This commit is contained in:
parent
d8fea44968
commit
b741565f57
@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
Schema::table(
|
||||
@ -411,18 +413,28 @@ class ChangesForV321 extends Migration
|
||||
|
||||
public function moveComponentIdToBudgetId()
|
||||
{
|
||||
\Log::debug('Now in moveComponentIdToBudgetId()');
|
||||
BudgetLimit::get()->each(
|
||||
function (BudgetLimit $bl) {
|
||||
\Log::debug('Now at budgetLimit #' . $bl->id . ' with component_id: ' . $bl->component_id);
|
||||
$component = Component::find($bl->component_id);
|
||||
if ($component) {
|
||||
\Log::debug('Found component with id #' . $component->id . ' and name ' . $component->name);
|
||||
$budget = Budget::whereName($component->name)->whereUserId($component->user_id)->first();
|
||||
if ($budget) {
|
||||
\Log::debug('Found a budget with ID #' . $budget->id . ' and name ' . $budget->name);
|
||||
$bl->budget_id = $budget->id;
|
||||
$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,
|
||||
]
|
||||
);
|
||||
$piggyBankEvent = PiggyBankEvent::create(['piggybank_id' => 1, 'date' => $startDate->format('Y-m-d'), 'amount' => 100]);
|
||||
$piggyBankRepetition = PiggybankRepetition::create(
|
||||
PiggyBankEvent::create(['piggybank_id' => 1, 'date' => $startDate->format('Y-m-d'), 'amount' => 100]);
|
||||
PiggybankRepetition::create(
|
||||
[
|
||||
'piggybank_id' => $piggy->id,
|
||||
'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 = \RecurringTransaction::create(
|
||||
[
|
||||
|
@ -334,7 +334,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
$limit->repeat_freq = 'monthly';
|
||||
$limit->repeats = 0;
|
||||
$result = $limit->save();
|
||||
\Log::info('Created new limit? ' . boolval($result));
|
||||
\Log::info('Created new limit? ' . boolstr($result));
|
||||
\Log::info('ID: ' . $limit->id);
|
||||
/*
|
||||
* A newly stored limit also created a limit repetition.
|
||||
|
@ -262,7 +262,9 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
*/
|
||||
public function leftOnAccount(\Account $account)
|
||||
{
|
||||
\Log::debug('Now in leftOnAccount() for account #'.$account->id.' ('.$account->name.')');
|
||||
$balance = \Steam::balance($account);
|
||||
\Log::debug('Steam says: ' . $balance);
|
||||
/** @var \Piggybank $p */
|
||||
foreach ($account->piggybanks()->get() as $p) {
|
||||
$balance -= $p->currentRelevantRep()->currentamount;
|
||||
|
@ -23,6 +23,7 @@ class Steam
|
||||
*/
|
||||
public function balance(\Account $account, Carbon $date = null)
|
||||
{
|
||||
\Log::debug('Now in Steam::balance() for account #' . $account->id.' ('.$account->name.')');
|
||||
if (is_null($date)) {
|
||||
$key = 'account.' . $account->id . '.latestBalance';
|
||||
} else {
|
||||
@ -33,6 +34,7 @@ class Steam
|
||||
#return \Cache::get($key);
|
||||
}
|
||||
$date = is_null($date) ? Carbon::now() : $date;
|
||||
\Log::debug('Now reached the moment we fire the query.');
|
||||
$balance = floatval(
|
||||
$account->transactions()->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
/**
|
||||
* Class Piggybank
|
||||
*/
|
||||
@ -90,6 +91,7 @@ class Piggybank extends Eloquent
|
||||
if ($this->repeats == 0) {
|
||||
$rep = $this->piggybankrepetitions()->first(['piggybank_repetitions.*']);
|
||||
$this->currentRep = $rep;
|
||||
\Log::debug('currentRelevantRep() reports $rep is null: ' . boolstr(is_null($rep)));
|
||||
|
||||
return $rep;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user