mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-19 16:10:00 +00:00
A giant rename action in preparation of v3.2.2
This commit is contained in:
@@ -12,7 +12,7 @@ use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
/**
|
||||
* Class Piggybank
|
||||
* Class PiggyBank
|
||||
*
|
||||
* @package FireflyIII\Database
|
||||
*/
|
||||
@@ -49,7 +49,7 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
if (!isset($data['remind_me']) || (isset($data['remind_me']) && $data['remind_me'] == 0)) {
|
||||
$data['reminder'] = null;
|
||||
}
|
||||
$piggyBank = new \Piggybank($data);
|
||||
$piggyBank = new \PiggyBank($data);
|
||||
$piggyBank->save();
|
||||
|
||||
return $piggyBank;
|
||||
@@ -63,7 +63,7 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
*/
|
||||
public function update(Eloquent $model, array $data)
|
||||
{
|
||||
/** @var \Piggybank $model */
|
||||
/** @var \PiggyBank $model */
|
||||
$model->name = $data['name'];
|
||||
$model->account_id = intval($data['account_id']);
|
||||
$model->targetamount = floatval($data['targetamount']);
|
||||
@@ -129,7 +129,7 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
if (floatval($model['targetamount']) < 0.01) {
|
||||
$errors->add('targetamount', 'Amount should be above 0.01.');
|
||||
}
|
||||
if (!in_array(ucfirst($model['reminder']), \Config::get('firefly.piggybank_periods'))) {
|
||||
if (!in_array(ucfirst($model['reminder']), \Config::get('firefly.piggy_bank_periods'))) {
|
||||
$errors->add('reminder', 'Invalid reminder period (' . $model['reminder'] . ')');
|
||||
}
|
||||
// check period.
|
||||
@@ -152,7 +152,7 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
}
|
||||
}
|
||||
|
||||
$validator = \Validator::make($model, \Piggybank::$rules);
|
||||
$validator = \Validator::make($model, \PiggyBank::$rules);
|
||||
if ($validator->invalid()) {
|
||||
$errors->merge($errors);
|
||||
}
|
||||
@@ -177,11 +177,11 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
*/
|
||||
public function find($objectId)
|
||||
{
|
||||
return \Piggybank::
|
||||
leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where('piggybanks.id', '=', $objectId)->where(
|
||||
return \PiggyBank::
|
||||
leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('piggy_banks.id', '=', $objectId)->where(
|
||||
'accounts.user_id', $this->getUser()->id
|
||||
)
|
||||
->first(['piggybanks.*']);
|
||||
->first(['piggy_banks.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +205,7 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return $this->getUser()->piggybanks()->where('repeats', 0)->get();
|
||||
return $this->getUser()->piggyBanks()->where('repeats', 0)->get();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,17 +221,17 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Piggybank $piggyBank
|
||||
* @param \PiggyBank $piggyBank
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return mixed
|
||||
* @throws FireflyException
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function findRepetitionByDate(\Piggybank $piggyBank, Carbon $date)
|
||||
public function findRepetitionByDate(\PiggyBank $piggyBank, Carbon $date)
|
||||
{
|
||||
/** @var Collection $reps */
|
||||
$reps = $piggyBank->piggybankrepetitions()->get();
|
||||
$reps = $piggyBank->piggyBankRepetitions()->get();
|
||||
if ($reps->count() == 1) {
|
||||
return $reps->first();
|
||||
}
|
||||
@@ -240,7 +240,7 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
}
|
||||
// should filter the one we need:
|
||||
$repetitions = $reps->filter(
|
||||
function (\PiggybankRepetition $rep) use ($date) {
|
||||
function (\PiggyBankRepetition $rep) use ($date) {
|
||||
if ($date >= $rep->startdate && $date <= $rep->targetdate) {
|
||||
return $rep;
|
||||
}
|
||||
@@ -265,8 +265,8 @@ class PiggyBank implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
\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) {
|
||||
/** @var \PiggyBank $p */
|
||||
foreach ($account->piggyBanks()->get() as $p) {
|
||||
$balance -= $p->currentRelevantRep()->currentamount;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace FireflyIII\Database\PiggyBank;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Collection\PiggybankPart;
|
||||
use FireflyIII\Collection\PiggyBankPart;
|
||||
use FireflyIII\Database\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
@@ -35,14 +35,14 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
* other variables this method tries to divide the piggy bank into equal parts. Each is
|
||||
* accommodated by a reminder (if everything goes to plan).
|
||||
*
|
||||
* @param \PiggybankRepetition $repetition
|
||||
* @param \PiggyBankRepetition $repetition
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function calculateParts(\PiggybankRepetition $repetition)
|
||||
public function calculateParts(\PiggyBankRepetition $repetition)
|
||||
{
|
||||
/** @var \Piggybank $piggyBank */
|
||||
$piggyBank = $repetition->piggybank()->first();
|
||||
/** @var \PiggyBank $piggyBank */
|
||||
$piggyBank = $repetition->piggyBank()->first();
|
||||
$bars = new Collection;
|
||||
$currentStart = clone $repetition->startdate;
|
||||
|
||||
@@ -66,7 +66,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
}
|
||||
$amountPerBar = floatval($piggyBank->targetamount) / $bars->count();
|
||||
$cumulative = $amountPerBar;
|
||||
/** @var PiggybankPart $bar */
|
||||
/** @var PiggyBankPart $bar */
|
||||
foreach ($bars as $index => $bar) {
|
||||
$bar->setAmountPerBar($amountPerBar);
|
||||
$bar->setCumulativeAmount($cumulative);
|
||||
@@ -82,11 +82,11 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return PiggybankPart
|
||||
* @return PiggyBankPart
|
||||
*/
|
||||
public function createPiggyBankPart(array $data)
|
||||
{
|
||||
$part = new PiggybankPart;
|
||||
$part = new PiggyBankPart;
|
||||
$part->setRepetition($data['repetition']);
|
||||
$part->setAmountPerBar($data['amountPerBar']);
|
||||
$part->setCurrentamount($data['currentAmount']);
|
||||
@@ -128,7 +128,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
$data['reminder'] = null;
|
||||
}
|
||||
|
||||
$repeated = new \Piggybank($data);
|
||||
$repeated = new \PiggyBank($data);
|
||||
$repeated->save();
|
||||
|
||||
return $repeated;
|
||||
@@ -200,11 +200,11 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
if (floatval($model['targetamount']) < 0.01) {
|
||||
$errors->add('targetamount', 'Amount should be above 0.01.');
|
||||
}
|
||||
if (!in_array(ucfirst($model['reminder']), \Config::get('firefly.piggybank_periods'))) {
|
||||
if (!in_array(ucfirst($model['reminder']), \Config::get('firefly.piggy_bank_periods'))) {
|
||||
$errors->add('reminder', 'Invalid reminder period (' . $model['reminder'] . ')');
|
||||
}
|
||||
|
||||
if (!in_array(ucfirst($model['rep_length']), \Config::get('firefly.piggybank_periods'))) {
|
||||
if (!in_array(ucfirst($model['rep_length']), \Config::get('firefly.piggy_bank_periods'))) {
|
||||
$errors->add('rep_length', 'Invalid repeat period (' . $model['rep_length'] . ')');
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
}
|
||||
}
|
||||
|
||||
$validator = \Validator::make($model, \Piggybank::$rules);
|
||||
$validator = \Validator::make($model, \PiggyBank::$rules);
|
||||
if ($validator->invalid()) {
|
||||
$errors->merge($errors);
|
||||
}
|
||||
@@ -279,7 +279,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggyBankInterface
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return $this->getUser()->piggybanks()->where('repeats', 1)->get();
|
||||
return $this->getUser()->piggyBanks()->where('repeats', 1)->get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,8 +44,8 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
$transaction->account()->associate($data['account']);
|
||||
$transaction->transactionJournal()->associate($data['transaction_journal']);
|
||||
$transaction->amount = floatval($data['amount']);
|
||||
if (isset($data['piggybank'])) {
|
||||
$transaction->piggybank()->associate($data['piggybank']);
|
||||
if (isset($data['piggyBank'])) {
|
||||
$transaction->piggyBank()->associate($data['piggyBank']);
|
||||
}
|
||||
if (isset($data['description'])) {
|
||||
$transaction->description = $data['description'];
|
||||
|
||||
Reference in New Issue
Block a user