Fix issues where data-variable was not initialized properly.

This commit is contained in:
James Cole
2018-07-25 07:11:04 +02:00
parent 7c950c3022
commit 7f4ecd40ce
11 changed files with 40 additions and 36 deletions

View File

@@ -199,7 +199,7 @@ class UpgradeDatabase extends Command
[ [
'rule_id' => $rule->id, 'rule_id' => $rule->id,
'trigger_type' => 'amount_more', 'trigger_type' => 'amount_more',
'trigger_value' => round($bill->amount_min, $currency->decimal_places), 'trigger_value' => round((float)$bill->amount_min, $currency->decimal_places),
'active' => 1, 'active' => 1,
'stop_processing' => 0, 'stop_processing' => 0,
'order' => 4, 'order' => 4,
@@ -211,7 +211,7 @@ class UpgradeDatabase extends Command
[ [
'rule_id' => $rule->id, 'rule_id' => $rule->id,
'trigger_type' => 'amount_exactly', 'trigger_type' => 'amount_exactly',
'trigger_value' => round($bill->amount_min, $currency->decimal_places), 'trigger_value' => round((float)$bill->amount_min, $currency->decimal_places),
'active' => 1, 'active' => 1,
'stop_processing' => 0, 'stop_processing' => 0,
'order' => 3, 'order' => 3,

View File

@@ -166,8 +166,8 @@ class BillController extends Controller
} }
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
$bill->amount_min = round($bill->amount_min, $currency->decimal_places); $bill->amount_min = round((float)$bill->amount_min, $currency->decimal_places);
$bill->amount_max = round($bill->amount_max, $currency->decimal_places); $bill->amount_max = round((float)$bill->amount_max, $currency->decimal_places);
$defaultCurrency = app('amount')->getDefaultCurrency(); $defaultCurrency = app('amount')->getDefaultCurrency();
// code to handle active-checkboxes // code to handle active-checkboxes

View File

@@ -281,7 +281,7 @@ class ReportController extends Controller
try { try {
$attributes['endDate'] = Carbon::createFromFormat('Ymd', $attributes['endDate']); $attributes['endDate'] = Carbon::createFromFormat('Ymd', $attributes['endDate']);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
Log::debug('Not important error message: %s', $e->getMessage()); Log::debug(sprintf('Not important error message: %s', $e->getMessage()));
$date = Carbon::create()->startOfMonth(); $date = Carbon::create()->startOfMonth();
$attributes['endDate'] = $date; $attributes['endDate'] = $date;
} }

View File

@@ -223,8 +223,8 @@ class CreateController extends Controller
$triggers = ['currency_is', 'amount_more', 'amount_less', 'description_contains']; $triggers = ['currency_is', 'amount_more', 'amount_less', 'description_contains'];
$values = [ $values = [
$bill->transactionCurrency()->first()->name, $bill->transactionCurrency()->first()->name,
round($bill->amount_min, 12), round((float)$bill->amount_min, 12),
round($bill->amount_max, 12), round((float)$bill->amount_max, 12),
$bill->name, $bill->name,
]; ];
foreach ($triggers as $index => $trigger) { foreach ($triggers as $index => $trigger) {

View File

@@ -270,6 +270,7 @@ class JournalFormRequest extends Request
*/ */
private function validateDeposit(Validator $validator): void private function validateDeposit(Validator $validator): void
{ {
$data = $validator->getData();
$selectedCurrency = (int)($data['amount_currency_id_amount'] ?? 0); $selectedCurrency = (int)($data['amount_currency_id_amount'] ?? 0);
$accountCurrency = (int)($data['destination_account_currency'] ?? 0); $accountCurrency = (int)($data['destination_account_currency'] ?? 0);
$nativeAmount = (string)($data['native_amount'] ?? ''); $nativeAmount = (string)($data['native_amount'] ?? '');
@@ -289,6 +290,7 @@ class JournalFormRequest extends Request
*/ */
private function validateTransfer(Validator $validator): void private function validateTransfer(Validator $validator): void
{ {
$data = $validator->getData();
$sourceCurrency = (int)($data['source_account_currency'] ?? 0); $sourceCurrency = (int)($data['source_account_currency'] ?? 0);
$destinationCurrency = (int)($data['destination_account_currency'] ?? 0); $destinationCurrency = (int)($data['destination_account_currency'] ?? 0);
$sourceAmount = (string)($data['source_amount'] ?? ''); $sourceAmount = (string)($data['source_amount'] ?? '');

View File

@@ -24,8 +24,8 @@ namespace FireflyIII\Models;
use Carbon\Carbon; use Carbon\Carbon;
use Crypt; use Crypt;
use FireflyIII\Support\Models\TransactionJournalTrait;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\BelongsToMany;
@@ -33,7 +33,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Illuminate\Database\Eloquent\Builder;
/** /**
@@ -58,6 +57,8 @@ use Illuminate\Database\Eloquent\Builder;
* @property int order * @property int order
* @property int budget_id * @property int budget_id
* @property string period_marker * @property string period_marker
* @property Carbon $date
* @property string $transaction_type_type
* *
* @SuppressWarnings(PHPMD.TooManyPublicMethods) * @SuppressWarnings(PHPMD.TooManyPublicMethods)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -94,6 +95,27 @@ class TransactionJournal extends Model
/** @var array */ /** @var array */
protected $hidden = ['encrypted']; protected $hidden = ['encrypted'];
/**
* @param Builder $query
* @param string $table
*
* @return bool
*/
public static function isJoined(Builder $query, string $table): bool
{
$joins = $query->getQuery()->joins;
if (null === $joins) {
return false;
}
foreach ($joins as $join) {
if ($join->table === $table) {
return true;
}
}
return false;
}
/** /**
* @param string $value * @param string $value
* *
@@ -266,27 +288,6 @@ class TransactionJournal extends Model
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00')); return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
} }
/**
* @param Builder $query
* @param string $table
*
* @return bool
*/
public static function isJoined(Builder $query, string $table): bool
{
$joins = $query->getQuery()->joins;
if (null === $joins) {
return false;
}
foreach ($joins as $join) {
if ($join->table === $table) {
return true;
}
}
return false;
}
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
* *

View File

@@ -229,8 +229,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
*/ */
public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): TransactionJournalLink public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): TransactionJournalLink
{ {
$linkType = $this->find((int)($information['link_type_id'] ?? 0)); $linkType = $this->findNull((int)($information['link_type_id'] ?? 0));
if (null === $linkType->id) { if (null === $linkType) {
throw new FireflyException(sprintf('Link type #%d cannot be resolved to an actual link type', $information['link_type_id'] ?? 0)); throw new FireflyException(sprintf('Link type #%d cannot be resolved to an actual link type', $information['link_type_id'] ?? 0));
} }

View File

@@ -267,7 +267,6 @@ class TagRepository implements TagRepositoryInterface
public function tagCloud(?int $year): array public function tagCloud(?int $year): array
{ {
// Some vars // Some vars
$return = [];
$tags = $this->getTagsInYear($year); $tags = $this->getTagsInYear($year);
$max = $this->getMaxAmount($tags); $max = $this->getMaxAmount($tags);
$min = $this->getMinAmount($tags); $min = $this->getMinAmount($tags);

View File

@@ -28,8 +28,8 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Facade; use Illuminate\Support\Facades\Facade;
/** /**
* @codeCoverageIgnore
* Class Steam. * Class Steam.
*
* @method string balance(Account $account, Carbon $date) * @method string balance(Account $account, Carbon $date)
* @method string balanceIgnoreVirtual(Account $account, Carbon $date) * @method string balanceIgnoreVirtual(Account $account, Carbon $date)
* @method array balanceInRange(Account $account, Carbon $start, Carbon $end) * @method array balanceInRange(Account $account, Carbon $start, Carbon $end)
@@ -42,6 +42,7 @@ use Illuminate\Support\Facades\Facade;
* @method tryDecrypt($value) * @method tryDecrypt($value)
* @method string positive(string $amount) * @method string positive(string $amount)
* *
* @codeCoverageIgnore
*/ */
class Steam extends Facade class Steam extends Facade
{ {

View File

@@ -150,6 +150,7 @@ class General extends Twig_Extension
if (null === $account) { if (null === $account) {
return 'NULL'; return 'NULL';
} }
/** @var Carbon $date */
$date = session('end', Carbon::now()->endOfMonth()); $date = session('end', Carbon::now()->endOfMonth());
return app('steam')->balance($account, $date); return app('steam')->balance($account, $date);

View File

@@ -174,8 +174,8 @@ class BillTransformer extends TransformerAbstract
'name' => $bill->name, 'name' => $bill->name,
'currency_id' => $bill->transaction_currency_id, 'currency_id' => $bill->transaction_currency_id,
'currency_code' => $bill->transactionCurrency->code, 'currency_code' => $bill->transactionCurrency->code,
'amount_min' => round($bill->amount_min, 2), 'amount_min' => round((float)$bill->amount_min, 2),
'amount_max' => round($bill->amount_max, 2), 'amount_max' => round((float)$bill->amount_max, 2),
'date' => $bill->date->format('Y-m-d'), 'date' => $bill->date->format('Y-m-d'),
'repeat_freq' => $bill->repeat_freq, 'repeat_freq' => $bill->repeat_freq,
'skip' => (int)$bill->skip, 'skip' => (int)$bill->skip,