mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix tests and fix coverage.
This commit is contained in:
@@ -157,7 +157,7 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
$preFilled['amount'] = $journal->actual_amount;
|
||||
$preFilled['account_id'] = $journal->asset_account->id;
|
||||
$preFilled['account_id'] = $journal->destination_account->id;
|
||||
$preFilled['expense_account'] = $transactions[0]->account->name;
|
||||
$preFilled['revenue_account'] = $transactions[1]->account->name;
|
||||
$preFilled['account_from_id'] = $transactions[1]->account->id;
|
||||
|
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Log;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
@@ -71,7 +72,7 @@ use Watson\Validating\ValidatingTrait;
|
||||
* @property-read mixed $correct_amount
|
||||
* @method static \FireflyIII\Models\TransactionJournal orderBy
|
||||
* @method static \FireflyIII\Models\TransactionJournal|null first
|
||||
* @property-read mixed $source_account
|
||||
* @property-read mixed $source_account
|
||||
*/
|
||||
class TransactionJournal extends Model
|
||||
{
|
||||
@@ -219,36 +220,6 @@ class TransactionJournal extends Model
|
||||
return $this->belongsToMany('FireflyIII\Models\Tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Account
|
||||
*/
|
||||
public function getAssetAccountAttribute()
|
||||
{
|
||||
// if it's a deposit, it's the one thats positive
|
||||
// if it's a withdrawal, it's the one thats negative
|
||||
// otherwise, it's either (return first one):
|
||||
|
||||
switch ($this->transactionType->type) {
|
||||
case 'Deposit':
|
||||
return $this->transactions()->where('amount', '>', 0)->first()->account;
|
||||
case 'Withdrawal':
|
||||
return $this->transactions()->where('amount', '<', 0)->first()->account;
|
||||
|
||||
}
|
||||
|
||||
return $this->transactions()->first()->account;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasMany('FireflyIII\Models\Transaction');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@@ -265,6 +236,15 @@ class TransactionJournal extends Model
|
||||
return '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasMany('FireflyIII\Models\Transaction');
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return string[]
|
||||
@@ -308,27 +288,6 @@ class TransactionJournal extends Model
|
||||
return $account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Account
|
||||
*/
|
||||
public function getExpenseAccountAttribute()
|
||||
{
|
||||
// if it's a deposit, it's the one thats negative
|
||||
// if it's a withdrawal, it's the one thats positive
|
||||
// otherwise, it's either (return first one):
|
||||
|
||||
switch ($this->transactionType->type) {
|
||||
case 'Deposit':
|
||||
return $this->transactions()->where('amount', '<', 0)->first()->account;
|
||||
case 'Withdrawal':
|
||||
return $this->transactions()->where('amount', '>', 0)->first()->account;
|
||||
|
||||
}
|
||||
|
||||
return $this->transactions()->first()->account;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Account
|
||||
*/
|
||||
@@ -341,6 +300,7 @@ class TransactionJournal extends Model
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$account = $this->transactions()->where('amount', '<', 0)->first()->account;
|
||||
|
||||
$cache->store($account);
|
||||
|
||||
return $account;
|
||||
|
@@ -53,11 +53,14 @@ class EventServiceProvider extends ServiceProvider
|
||||
$this->registerCreateEvents();
|
||||
BudgetLimit::saved(
|
||||
function(BudgetLimit $budgetLimit) {
|
||||
Log::debug('Saved!');
|
||||
|
||||
$end = Navigation::addPeriod(clone $budgetLimit->startdate, $budgetLimit->repeat_freq, 0);
|
||||
$end->subDay();
|
||||
$set = $budgetLimit->limitrepetitions()->where('startdate', $budgetLimit->startdate->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))
|
||||
->get();
|
||||
$set = $budgetLimit->limitrepetitions()
|
||||
->where('startdate', $budgetLimit->startdate->format('Y-m-d 00:00:00'))
|
||||
->where('enddate', $end->format('Y-m-d 00:00:00'))
|
||||
->get();
|
||||
if ($set->count() == 0) {
|
||||
$repetition = new LimitRepetition;
|
||||
$repetition->startdate = $budgetLimit->startdate;
|
||||
@@ -68,8 +71,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
try {
|
||||
$repetition->save();
|
||||
} catch (QueryException $e) {
|
||||
Log::error('Trying to save new LimitRepetition failed!');
|
||||
Log::error($e->getMessage());
|
||||
Log::error('Trying to save new LimitRepetition failed: '.$e->getMessage()); // @codeCoverageIgnore
|
||||
}
|
||||
} else {
|
||||
if ($set->count() == 1) {
|
||||
|
@@ -265,7 +265,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
$amountMatch = false;
|
||||
$wordMatch = false;
|
||||
$matches = explode(',', $bill->match);
|
||||
$description = strtolower($journal->description) . ' ' . strtolower($journal->expense_account->name);
|
||||
$description = strtolower($journal->description) . ' ' . strtolower($journal->destination_account->name);
|
||||
$count = 0;
|
||||
foreach ($matches as $word) {
|
||||
if (!(strpos($description, strtolower($word)) === false)) {
|
||||
|
@@ -48,11 +48,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
*/
|
||||
public function delete(TransactionJournal $journal)
|
||||
{
|
||||
// delete transactions first:
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions()->get() as $transaction) {
|
||||
$transaction->delete();
|
||||
}
|
||||
$journal->delete();
|
||||
|
||||
return true;
|
||||
|
@@ -318,7 +318,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
$match = true;
|
||||
/** @var TransactionJournal $check */
|
||||
foreach ($tag->transactionjournals as $check) {
|
||||
if ($check->asset_account->id != $journal->asset_account->id) {
|
||||
if ($check->source_account->id != $journal->source_account->id) {
|
||||
$match = false;
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ class Amount
|
||||
public function getCurrencySymbol()
|
||||
{
|
||||
if (defined('FFCURRENCYSYMBOL')) {
|
||||
return FFCURRENCYSYMBOL;
|
||||
return FFCURRENCYSYMBOL; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
||||
@@ -149,7 +149,7 @@ class Amount
|
||||
public function getCurrencyCode()
|
||||
{
|
||||
if (defined('FFCURRENCYCODE')) {
|
||||
return FFCURRENCYCODE;
|
||||
return FFCURRENCYCODE; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
||||
|
@@ -9,6 +9,7 @@ use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
use Preferences as Prefs;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class CacheProperties
|
||||
@@ -62,6 +63,9 @@ class CacheProperties
|
||||
*/
|
||||
public function has()
|
||||
{
|
||||
if(getenv('APP_ENV') == 'testing') {
|
||||
return false;
|
||||
}
|
||||
$this->md5();
|
||||
|
||||
return Cache::has($this->md5);
|
||||
|
@@ -36,7 +36,6 @@ class Preferences
|
||||
return Cache::get($fullName);
|
||||
}
|
||||
|
||||
|
||||
$preference = Preference::where('user_id', Auth::user()->id)->where('name', $name)->first(['id', 'name', 'data_encrypted']);
|
||||
|
||||
if ($preference) {
|
||||
|
Reference in New Issue
Block a user