mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Clean up code, remove unused methods.
This commit is contained in:
parent
dbbf0ff5e4
commit
a722dc4235
@ -27,7 +27,6 @@ namespace FireflyIII\Mail;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Laravel\Passport\Token;
|
||||
|
||||
/**
|
||||
* Class AccessTokenCreatedMail
|
||||
@ -47,7 +46,6 @@ class AccessTokenCreatedMail extends Mailable
|
||||
*
|
||||
* @param string $email
|
||||
* @param string $ipAddress
|
||||
* @param Token $token
|
||||
*/
|
||||
public function __construct(string $email, string $ipAddress)
|
||||
{
|
||||
@ -60,7 +58,7 @@ class AccessTokenCreatedMail extends Mailable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
public function build(): self
|
||||
{
|
||||
return $this->view('emails.access-token-created-html')->text('emails.access-token-created-text')
|
||||
->subject('A new access token was created');
|
||||
|
@ -57,7 +57,7 @@ class AdminTestMail extends Mailable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
public function build(): self
|
||||
{
|
||||
return $this->view('emails.admin-test-html')->text('emails.admin-test-text')
|
||||
->subject('A test message from your Firefly III installation');
|
||||
|
@ -65,7 +65,7 @@ class ConfirmEmailChangeMail extends Mailable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
public function build(): self
|
||||
{
|
||||
return $this->view('emails.confirm-email-change-html')->text('emails.confirm-email-change-text')
|
||||
->subject('Your Firefly III email address has changed');
|
||||
|
@ -57,7 +57,7 @@ class RegisteredUser extends Mailable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
public function build(): self
|
||||
{
|
||||
return $this->view('emails.registered-html')->text('emails.registered-text')->subject('Welcome to Firefly III!');
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class ReportNewJournalsMail extends Mailable
|
||||
*/
|
||||
public function build(): self
|
||||
{
|
||||
$subject = $this->journals->count() === 1
|
||||
$subject = 1 === $this->journals->count()
|
||||
? 'Firefly III has created a new transaction'
|
||||
: sprintf(
|
||||
'Firefly III has created new %d transactions', $this->journals->count()
|
||||
|
@ -56,7 +56,7 @@ class RequestedNewPassword extends Mailable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
public function build(): self
|
||||
{
|
||||
return $this->view('emails.password-html')->text('emails.password-text')->subject('Your password reset request');
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class UndoEmailChangeMail extends Mailable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
public function build(): self
|
||||
{
|
||||
return $this->view('emails.undo-email-change-html')->text('emails.undo-email-change-text')
|
||||
->subject('Your Firefly III email address has changed');
|
||||
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Crypt;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\User;
|
||||
@ -31,7 +32,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
@ -45,12 +46,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property bool $active
|
||||
* @property string $virtual_balance
|
||||
* @property User $user
|
||||
* @property mixed|null startBalance
|
||||
* @property mixed|null endBalance
|
||||
* @property string startBalance
|
||||
* @property string endBalance
|
||||
* @property string difference
|
||||
* @property mixed|null endBalance
|
||||
* @property mixed|null startBalance
|
||||
* @property mixed|null lastActivityDate
|
||||
* @property Carbon lastActivityDate
|
||||
* @property Collection accountMeta
|
||||
* @property bool encrypted
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class Account extends Model
|
||||
{
|
||||
@ -76,48 +79,6 @@ class Account extends Model
|
||||
/** @var bool */
|
||||
private $joinedAccountTypes;
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
*
|
||||
* @return Account
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public static function firstOrCreateEncrypted(array $fields)
|
||||
{
|
||||
if (!isset($fields['user_id'])) {
|
||||
throw new FireflyException('Missing required field "user_id".');
|
||||
}
|
||||
// everything but the name:
|
||||
$query = self::orderBy('id');
|
||||
$search = $fields;
|
||||
unset($search['name'], $search['iban']);
|
||||
|
||||
foreach ($search as $name => $value) {
|
||||
$query->where($name, $value);
|
||||
}
|
||||
$set = $query->get(['accounts.*']);
|
||||
|
||||
// account must have a name. If not set, use IBAN.
|
||||
if (!isset($fields['name'])) {
|
||||
$fields['name'] = $fields['iban'];
|
||||
}
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($set as $account) {
|
||||
if ($account->name === $fields['name']) {
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
|
||||
// create it!
|
||||
$account = self::create($fields);
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
@ -128,7 +89,10 @@ class Account extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$accountId = (int)$value;
|
||||
$account = auth()->user()->accounts()->find($accountId);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Account $account */
|
||||
$account = $user->accounts()->find($accountId);
|
||||
if (null !== $account) {
|
||||
return $account;
|
||||
}
|
||||
@ -178,7 +142,7 @@ class Account extends Model
|
||||
*/
|
||||
public function getIbanAttribute($value): string
|
||||
{
|
||||
if (null === $value || '' === (string)$value) {
|
||||
if ('' === (string)$value) {
|
||||
return '';
|
||||
}
|
||||
try {
|
||||
@ -195,25 +159,6 @@ class Account extends Model
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param string $fieldName
|
||||
*
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
public function getMeta(string $fieldName): string
|
||||
{
|
||||
foreach ($this->accountMeta as $meta) {
|
||||
if ($meta->name === $fieldName) {
|
||||
return (string)$meta->data;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
@ -273,7 +218,7 @@ class Account extends Model
|
||||
* @param EloquentBuilder $query
|
||||
* @param array $types
|
||||
*/
|
||||
public function scopeAccountTypeIn(EloquentBuilder $query, array $types)
|
||||
public function scopeAccountTypeIn(EloquentBuilder $query, array $types): void
|
||||
{
|
||||
if (null === $this->joinedAccountTypes) {
|
||||
$query->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id');
|
||||
@ -283,35 +228,12 @@ class Account extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @deprecated
|
||||
*
|
||||
* @param EloquentBuilder $query
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
*/
|
||||
public function scopeHasMetaValue(EloquentBuilder $query, $name, $value)
|
||||
{
|
||||
$joinName = str_replace('.', '_', $name);
|
||||
$query->leftJoin(
|
||||
'account_meta as ' . $joinName,
|
||||
function (JoinClause $join) use ($joinName, $name) {
|
||||
$join->on($joinName . '.account_id', '=', 'accounts.id')->where($joinName . '.name', '=', $name);
|
||||
}
|
||||
);
|
||||
$query->where($joinName . '.data', json_encode($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param $value
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function setIbanAttribute($value)
|
||||
public function setIbanAttribute($value): void
|
||||
{
|
||||
$this->attributes['iban'] = Crypt::encrypt($value);
|
||||
}
|
||||
@ -323,7 +245,7 @@ class Account extends Model
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function setNameAttribute($value)
|
||||
public function setNameAttribute($value): void
|
||||
{
|
||||
$encrypt = config('firefly.encryption');
|
||||
$this->attributes['name'] = $encrypt ? Crypt::encrypt($value) : $value;
|
||||
@ -337,7 +259,7 @@ class Account extends Model
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setVirtualBalanceAttribute($value)
|
||||
public function setVirtualBalanceAttribute($value): void
|
||||
{
|
||||
$this->attributes['virtual_balance'] = (string)$value;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class AccountMeta extends Model
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setDataAttribute($value)
|
||||
public function setDataAttribute($value): void
|
||||
{
|
||||
$this->attributes['data'] = json_encode($value);
|
||||
}
|
||||
|
@ -78,7 +78,10 @@ class Attachment extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$attachmentId = (int)$value;
|
||||
$attachment = auth()->user()->attachments()->find($attachmentId);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Attachment $attachment */
|
||||
$attachment = $user->attachments()->find($attachmentId);
|
||||
if (null !== $attachment) {
|
||||
return $attachment;
|
||||
}
|
||||
|
@ -71,7 +71,10 @@ class AvailableBudget extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$availableBudgetId = (int)$value;
|
||||
$availableBudget = auth()->user()->availableBudgets()->find($availableBudgetId);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var AvailableBudget $availableBudget */
|
||||
$availableBudget = $user->availableBudgets()->find($availableBudgetId);
|
||||
if (null !== $availableBudget) {
|
||||
return $availableBudget;
|
||||
}
|
||||
|
@ -51,6 +51,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property bool $automatch
|
||||
* @property User $user
|
||||
* @property string $match
|
||||
* @property bool match_encrypted
|
||||
* @property bool name_encrypted
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class Bill extends Model
|
||||
{
|
||||
@ -93,7 +97,10 @@ class Bill extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$billId = (int)$value;
|
||||
$bill = auth()->user()->bills()->find($billId);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Bill $bill */
|
||||
$bill = $user->bills()->find($billId);
|
||||
if (null !== $bill) {
|
||||
return $bill;
|
||||
}
|
||||
@ -105,7 +112,7 @@ class Bill extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
*/
|
||||
public function attachments()
|
||||
public function attachments(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
}
|
||||
@ -118,7 +125,7 @@ class Bill extends Model
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Encryption\DecryptException
|
||||
*/
|
||||
public function getMatchAttribute($value)
|
||||
public function getMatchAttribute($value): string
|
||||
{
|
||||
if (1 === (int)$this->match_encrypted) {
|
||||
return Crypt::decrypt($value);
|
||||
@ -135,7 +142,7 @@ class Bill extends Model
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Encryption\DecryptException
|
||||
*/
|
||||
public function getNameAttribute($value)
|
||||
public function getNameAttribute($value): string
|
||||
{
|
||||
if (1 === (int)$this->name_encrypted) {
|
||||
return Crypt::decrypt($value);
|
||||
@ -158,7 +165,7 @@ class Bill extends Model
|
||||
*
|
||||
* @param $value
|
||||
*/
|
||||
public function setAmountMaxAttribute($value)
|
||||
public function setAmountMaxAttribute($value): void
|
||||
{
|
||||
$this->attributes['amount_max'] = (string)$value;
|
||||
}
|
||||
@ -168,7 +175,7 @@ class Bill extends Model
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setAmountMinAttribute($value)
|
||||
public function setAmountMinAttribute($value): void
|
||||
{
|
||||
$this->attributes['amount_min'] = (string)$value;
|
||||
}
|
||||
@ -179,7 +186,7 @@ class Bill extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function setMatchAttribute($value)
|
||||
public function setMatchAttribute($value): void
|
||||
{
|
||||
$encrypt = config('firefly.encryption');
|
||||
$this->attributes['match'] = $encrypt ? Crypt::encrypt($value) : $value;
|
||||
@ -192,7 +199,7 @@ class Bill extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function setNameAttribute($value)
|
||||
public function setNameAttribute($value): void
|
||||
{
|
||||
$encrypt = config('firefly.encryption');
|
||||
$this->attributes['name'] = $encrypt ? Crypt::encrypt($value) : $value;
|
||||
|
@ -37,6 +37,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property bool $active
|
||||
* @property int $user_id
|
||||
* @property-read string $email
|
||||
* @property bool encrypted
|
||||
*/
|
||||
class Budget extends Model
|
||||
{
|
||||
@ -60,34 +61,6 @@ class Budget extends Model
|
||||
/** @var array */
|
||||
protected $hidden = ['encrypted'];
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
*
|
||||
* @deprecated
|
||||
* @return Budget
|
||||
*/
|
||||
public static function firstOrCreateEncrypted(array $fields)
|
||||
{
|
||||
// everything but the name:
|
||||
$query = self::orderBy('id');
|
||||
$search = $fields;
|
||||
unset($search['name']);
|
||||
foreach ($search as $name => $value) {
|
||||
$query->where($name, $value);
|
||||
}
|
||||
$set = $query->get(['budgets.*']);
|
||||
/** @var Budget $budget */
|
||||
foreach ($set as $budget) {
|
||||
if ($budget->name === $fields['name']) {
|
||||
return $budget;
|
||||
}
|
||||
}
|
||||
// create it!
|
||||
$budget = self::create($fields);
|
||||
|
||||
return $budget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
@ -98,7 +71,10 @@ class Budget extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$budgetId = (int)$value;
|
||||
$budget = auth()->user()->budgets()->find($budgetId);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Budget $budget */
|
||||
$budget = $user->budgets()->find($budgetId);
|
||||
if (null !== $budget) {
|
||||
return $budget;
|
||||
}
|
||||
@ -110,7 +86,7 @@ class Budget extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function budgetlimits()
|
||||
public function budgetlimits(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(BudgetLimit::class);
|
||||
}
|
||||
@ -123,7 +99,7 @@ class Budget extends Model
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Encryption\DecryptException
|
||||
*/
|
||||
public function getNameAttribute($value)
|
||||
public function getNameAttribute($value): string
|
||||
{
|
||||
if ($this->encrypted) {
|
||||
return Crypt::decrypt($value);
|
||||
@ -139,7 +115,7 @@ class Budget extends Model
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function setNameAttribute($value)
|
||||
public function setNameAttribute($value): void
|
||||
{
|
||||
$encrypt = config('firefly.encryption');
|
||||
$this->attributes['name'] = $encrypt ? Crypt::encrypt($value) : $value;
|
||||
@ -150,7 +126,7 @@ class Budget extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function transactionJournals()
|
||||
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(TransactionJournal::class, 'budget_transaction_journal', 'budget_id');
|
||||
}
|
||||
@ -159,7 +135,7 @@ class Budget extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function transactions()
|
||||
public function transactions(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Transaction::class, 'budget_transaction', 'budget_id');
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property int $id
|
||||
* @property float $spent // used in category reports
|
||||
* @property Carbon|null lastActivity
|
||||
* @property bool encrypted
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
@ -58,34 +59,6 @@ class Category extends Model
|
||||
/** @var array */
|
||||
protected $hidden = ['encrypted'];
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
*
|
||||
* @deprecated
|
||||
* @return Category
|
||||
*/
|
||||
public static function firstOrCreateEncrypted(array $fields)
|
||||
{
|
||||
// everything but the name:
|
||||
$query = self::orderBy('id');
|
||||
$search = $fields;
|
||||
unset($search['name']);
|
||||
foreach ($search as $name => $value) {
|
||||
$query->where($name, $value);
|
||||
}
|
||||
$set = $query->get(['categories.*']);
|
||||
/** @var Category $category */
|
||||
foreach ($set as $category) {
|
||||
if ($category->name === $fields['name']) {
|
||||
return $category;
|
||||
}
|
||||
}
|
||||
// create it!
|
||||
$category = self::create($fields);
|
||||
|
||||
return $category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
@ -96,7 +69,10 @@ class Category extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$categoryId = (int)$value;
|
||||
$category = auth()->user()->categories()->find($categoryId);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Category $category */
|
||||
$category = $user->categories()->find($categoryId);
|
||||
if (null !== $category) {
|
||||
return $category;
|
||||
}
|
||||
@ -112,7 +88,7 @@ class Category extends Model
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Encryption\DecryptException
|
||||
*/
|
||||
public function getNameAttribute($value)
|
||||
public function getNameAttribute($value): string
|
||||
{
|
||||
if ($this->encrypted) {
|
||||
return Crypt::decrypt($value);
|
||||
@ -128,7 +104,7 @@ class Category extends Model
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function setNameAttribute($value)
|
||||
public function setNameAttribute($value): void
|
||||
{
|
||||
$encrypt = config('firefly.encryption');
|
||||
$this->attributes['name'] = $encrypt ? Crypt::encrypt($value) : $value;
|
||||
@ -139,7 +115,7 @@ class Category extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function transactionJournals()
|
||||
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(TransactionJournal::class, 'category_transaction_journal', 'category_id');
|
||||
}
|
||||
@ -148,7 +124,7 @@ class Category extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function transactions()
|
||||
public function transactions(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Transaction::class, 'category_transaction', 'category_id');
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class Configuration extends Model
|
||||
*
|
||||
* @param $value
|
||||
*/
|
||||
public function setDataAttribute($value)
|
||||
public function setDataAttribute($value): void
|
||||
{
|
||||
$this->attributes['data'] = json_encode($value);
|
||||
}
|
||||
|
@ -54,7 +54,10 @@ class ExportJob extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$key = trim($value);
|
||||
$exportJob = auth()->user()->exportJobs()->where('key', $key)->first();
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var ExportJob $exportJob */
|
||||
$exportJob = $user->exportJobs()->where('key', $key)->first();
|
||||
if (null !== $exportJob) {
|
||||
return $exportJob;
|
||||
}
|
||||
@ -67,7 +70,7 @@ class ExportJob extends Model
|
||||
*
|
||||
* @param $status
|
||||
*/
|
||||
public function change($status)
|
||||
public function change($status): void
|
||||
{
|
||||
$this->status = $status;
|
||||
$this->save();
|
||||
@ -77,7 +80,7 @@ class ExportJob extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
@ -73,7 +73,10 @@ class ImportJob extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$key = trim($value);
|
||||
$importJob = auth()->user()->importJobs()->where('key', $key)->first();
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var ImportJob $importJob */
|
||||
$importJob = $user->importJobs()->where('key', $key)->first();
|
||||
if (null !== $importJob) {
|
||||
return $importJob;
|
||||
}
|
||||
@ -85,7 +88,7 @@ class ImportJob extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
*/
|
||||
public function attachments()
|
||||
public function attachments(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
}
|
||||
@ -94,7 +97,7 @@ class ImportJob extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function tag()
|
||||
public function tag(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tag::class);
|
||||
}
|
||||
@ -103,7 +106,7 @@ class ImportJob extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class LinkType extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function transactionJournalLinks()
|
||||
public function transactionJournalLinks(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournalLink::class);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class Note extends Model
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
public function setTextAttribute($value)
|
||||
public function setTextAttribute($value): void
|
||||
{
|
||||
$this->attributes['text'] = e($value);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property int $account_id
|
||||
* @property bool encrypted
|
||||
*
|
||||
*/
|
||||
class PiggyBank extends Model
|
||||
@ -101,28 +102,6 @@ class PiggyBank extends Model
|
||||
return $this->belongsTo(Account::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs the PiggyBankRepetition that's currently relevant / active.
|
||||
*
|
||||
* @deprecated
|
||||
* @returns PiggyBankRepetition
|
||||
*/
|
||||
public function currentRelevantRep(): PiggyBankRepetition
|
||||
{
|
||||
if (null !== $this->currentRep) {
|
||||
return $this->currentRep;
|
||||
}
|
||||
// repeating piggy banks are no longer supported.
|
||||
/** @var PiggyBankRepetition $rep */
|
||||
$rep = $this->piggyBankRepetitions()->first(['piggy_bank_repetitions.*']);
|
||||
if (null === $rep) {
|
||||
return new PiggyBankRepetition();
|
||||
}
|
||||
$this->currentRep = $rep;
|
||||
|
||||
return $rep;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
@ -131,7 +110,7 @@ class PiggyBank extends Model
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Encryption\DecryptException
|
||||
*/
|
||||
public function getNameAttribute($value)
|
||||
public function getNameAttribute($value): string
|
||||
{
|
||||
if ($this->encrypted) {
|
||||
return Crypt::decrypt($value);
|
||||
@ -140,25 +119,6 @@ class PiggyBank extends Model
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
public function leftOnAccount(Carbon $date): string
|
||||
{
|
||||
$balance = app('steam')->balanceIgnoreVirtual($this->account, $date);
|
||||
/** @var PiggyBank $piggyBank */
|
||||
foreach ($this->account->piggyBanks as $piggyBank) {
|
||||
$currentAmount = $piggyBank->currentRelevantRep()->currentamount ?? '0';
|
||||
|
||||
$balance = bcsub($balance, $currentAmount);
|
||||
}
|
||||
|
||||
return $balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* Get all of the piggy bank's notes.
|
||||
@ -172,7 +132,7 @@ class PiggyBank extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function piggyBankEvents()
|
||||
public function piggyBankEvents(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(PiggyBankEvent::class);
|
||||
}
|
||||
@ -181,7 +141,7 @@ class PiggyBank extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function piggyBankRepetitions()
|
||||
public function piggyBankRepetitions(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(PiggyBankRepetition::class);
|
||||
}
|
||||
@ -193,7 +153,7 @@ class PiggyBank extends Model
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function setNameAttribute($value)
|
||||
public function setNameAttribute($value): void
|
||||
{
|
||||
$encrypt = config('firefly.encryption');
|
||||
$this->attributes['name'] = $encrypt ? Crypt::encrypt($value) : $value;
|
||||
@ -205,7 +165,7 @@ class PiggyBank extends Model
|
||||
*
|
||||
* @param $value
|
||||
*/
|
||||
public function setTargetamountAttribute($value)
|
||||
public function setTargetamountAttribute($value): void
|
||||
{
|
||||
$this->attributes['targetamount'] = (string)$value;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class PiggyBankEvent extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function piggyBank()
|
||||
public function piggyBank(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PiggyBank::class);
|
||||
}
|
||||
@ -71,7 +71,7 @@ class PiggyBankEvent extends Model
|
||||
*
|
||||
* @param $value
|
||||
*/
|
||||
public function setAmountAttribute($value)
|
||||
public function setAmountAttribute($value): void
|
||||
{
|
||||
$this->attributes['amount'] = (string)$value;
|
||||
}
|
||||
@ -80,7 +80,7 @@ class PiggyBankEvent extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function transactionJournal()
|
||||
public function transactionJournal(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionJournal::class);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class PiggyBankRepetition extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function piggyBank()
|
||||
public function piggyBank(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PiggyBank::class);
|
||||
}
|
||||
@ -71,7 +71,7 @@ class PiggyBankRepetition extends Model
|
||||
*
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function scopeOnDates(EloquentBuilder $query, Carbon $start, Carbon $target)
|
||||
public function scopeOnDates(EloquentBuilder $query, Carbon $start, Carbon $target): EloquentBuilder
|
||||
{
|
||||
return $query->where('startdate', $start->format('Y-m-d'))->where('targetdate', $target->format('Y-m-d'));
|
||||
}
|
||||
@ -105,7 +105,7 @@ class PiggyBankRepetition extends Model
|
||||
*
|
||||
* @param $value
|
||||
*/
|
||||
public function setCurrentamountAttribute($value)
|
||||
public function setCurrentamountAttribute($value): void
|
||||
{
|
||||
$this->attributes['currentamount'] = (string)$value;
|
||||
}
|
||||
|
@ -40,8 +40,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property Carbon $updated_at
|
||||
* @property Carbon $created_at
|
||||
* @property int $id
|
||||
* @property mixed user
|
||||
* @property mixed user
|
||||
* @property User user
|
||||
*/
|
||||
class Preference extends Model
|
||||
{
|
||||
@ -62,14 +61,17 @@ class Preference extends Model
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return Account
|
||||
* @return Preference
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value): Preference
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$preferenceId = (int)$value;
|
||||
$preference = auth()->user()->preferences()->find($preferenceId);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Preference $preference */
|
||||
$preference = $user->preferences()->find($preferenceId);
|
||||
if (null !== $preference) {
|
||||
return $preference;
|
||||
}
|
||||
@ -84,6 +86,7 @@ class Preference extends Model
|
||||
* @return mixed
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function getDataAttribute($value)
|
||||
{
|
||||
@ -91,7 +94,7 @@ class Preference extends Model
|
||||
try {
|
||||
$data = Crypt::decrypt($value);
|
||||
} catch (DecryptException $e) {
|
||||
Log::error('Could not decrypt preference.', ['id' => $this->id, 'name' => $this->name, 'data' => $value]);
|
||||
Log::error(sprintf('Could not decrypt preference: %s', $e->getMessage()), ['id' => $this->id, 'name' => $this->name, 'data' => $value]);
|
||||
throw new FireflyException(
|
||||
sprintf('Could not decrypt preference #%d. If this error persists, please run "php artisan cache:clear" on the command line.', $this->id)
|
||||
);
|
||||
@ -119,7 +122,7 @@ class Preference extends Model
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function setDataAttribute($value)
|
||||
public function setDataAttribute($value): void
|
||||
{
|
||||
$this->attributes['data'] = Crypt::encrypt(json_encode($value));
|
||||
}
|
||||
@ -128,7 +131,7 @@ class Preference extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
@ -97,7 +97,10 @@ class Recurrence extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$recurrenceId = (int)$value;
|
||||
$recurrence = auth()->user()->recurrences()->find($recurrenceId);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $user->recurrences()->find($recurrenceId);
|
||||
if (null !== $recurrence) {
|
||||
return $recurrence;
|
||||
}
|
||||
|
@ -83,7 +83,10 @@ class Rule extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$ruleId = (int)$value;
|
||||
$rule = auth()->user()->rules()->find($ruleId);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Rule $rule */
|
||||
$rule = $user->rules()->find($ruleId);
|
||||
if (null !== $rule) {
|
||||
return $rule;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class RuleAction extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function rule()
|
||||
public function rule(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Rule::class);
|
||||
}
|
||||
|
@ -74,7 +74,10 @@ class RuleGroup extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$ruleGroupId = (int)$value;
|
||||
$ruleGroup = auth()->user()->ruleGroups()->find($ruleGroupId);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var RuleGroup $ruleGroup */
|
||||
$ruleGroup = $user->ruleGroups()->find($ruleGroupId);
|
||||
if (null !== $ruleGroup) {
|
||||
return $ruleGroup;
|
||||
}
|
||||
@ -86,7 +89,7 @@ class RuleGroup extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(Rule::class);
|
||||
}
|
||||
@ -95,7 +98,7 @@ class RuleGroup extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class RuleTrigger extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function rule()
|
||||
public function rule(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Rule::class);
|
||||
}
|
||||
|
@ -59,38 +59,6 @@ class Tag extends Model
|
||||
/** @var array */
|
||||
protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode'];
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
*
|
||||
* @deprecated
|
||||
* @return Tag|null
|
||||
*/
|
||||
public static function firstOrCreateEncrypted(array $fields)
|
||||
{
|
||||
// everything but the tag:
|
||||
unset($fields['tagMode']);
|
||||
$search = $fields;
|
||||
unset($search['tag']);
|
||||
|
||||
$query = self::orderBy('id');
|
||||
foreach ($search as $name => $value) {
|
||||
$query->where($name, $value);
|
||||
}
|
||||
$set = $query->get(['tags.*']);
|
||||
/** @var Tag $tag */
|
||||
foreach ($set as $tag) {
|
||||
if ($tag->tag === $fields['tag']) {
|
||||
return $tag;
|
||||
}
|
||||
}
|
||||
// create it!
|
||||
$fields['tagMode'] = 'nothing';
|
||||
$fields['description'] = $fields['description'] ?? '';
|
||||
$tag = self::create($fields);
|
||||
|
||||
return $tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
@ -101,7 +69,10 @@ class Tag extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$tagId = (int)$value;
|
||||
$tag = auth()->user()->tags()->find($tagId);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Tag $tag */
|
||||
$tag = $user->tags()->find($tagId);
|
||||
if (null !== $tag) {
|
||||
return $tag;
|
||||
}
|
||||
@ -117,7 +88,7 @@ class Tag extends Model
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Encryption\DecryptException
|
||||
*/
|
||||
public function getDescriptionAttribute($value)
|
||||
public function getDescriptionAttribute($value): string
|
||||
{
|
||||
if (null === $value) {
|
||||
return $value;
|
||||
@ -131,10 +102,10 @@ class Tag extends Model
|
||||
*
|
||||
* @param $value
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
* @throws \Illuminate\Contracts\Encryption\DecryptException
|
||||
*/
|
||||
public function getTagAttribute($value)
|
||||
public function getTagAttribute($value): ?string
|
||||
{
|
||||
if (null === $value) {
|
||||
return null;
|
||||
@ -150,7 +121,7 @@ class Tag extends Model
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function setDescriptionAttribute($value)
|
||||
public function setDescriptionAttribute($value): void
|
||||
{
|
||||
$this->attributes['description'] = Crypt::encrypt($value);
|
||||
}
|
||||
@ -162,7 +133,7 @@ class Tag extends Model
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function setTagAttribute($value)
|
||||
public function setTagAttribute($value): void
|
||||
{
|
||||
$this->attributes['tag'] = Crypt::encrypt($value);
|
||||
}
|
||||
@ -171,7 +142,7 @@ class Tag extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function transactionJournals()
|
||||
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(TransactionJournal::class);
|
||||
}
|
||||
@ -180,7 +151,7 @@ class Tag extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@ -88,6 +89,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property string $after // used in audit reports.
|
||||
* @property int $opposing_id // ID of the opposing transaction, used in collector
|
||||
* @property bool $encrypted // is the journal encrypted
|
||||
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
||||
*/
|
||||
class Transaction extends Model
|
||||
{
|
||||
@ -150,8 +152,10 @@ class Transaction extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$transactionId = (int)$value;
|
||||
$transaction = auth()->user()->transactions()->where('transactions.id', $transactionId)
|
||||
->first(['transactions.*']);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $user->transactions()->where('transactions.id', $transactionId)->first(['transactions.*']);
|
||||
if (null !== $transaction) {
|
||||
return $transaction;
|
||||
}
|
||||
@ -166,7 +170,7 @@ class Transaction extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function account()
|
||||
public function account(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Account::class);
|
||||
}
|
||||
@ -175,7 +179,7 @@ class Transaction extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function budgets()
|
||||
public function budgets(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Budget::class);
|
||||
}
|
||||
@ -184,7 +188,7 @@ class Transaction extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function categories()
|
||||
public function categories(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Category::class);
|
||||
}
|
||||
@ -193,30 +197,18 @@ class Transaction extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function foreignCurrency()
|
||||
public function foreignCurrency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class, 'foreign_currency_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param $value
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getAmountAttribute($value)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function scopeAfter(Builder $query, Carbon $date)
|
||||
public function scopeAfter(Builder $query, Carbon $date): void
|
||||
{
|
||||
if (!self::isJoined($query, 'transaction_journals')) {
|
||||
$query->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id');
|
||||
@ -230,7 +222,7 @@ class Transaction extends Model
|
||||
* @param Builder $query
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function scopeBefore(Builder $query, Carbon $date)
|
||||
public function scopeBefore(Builder $query, Carbon $date): void
|
||||
{
|
||||
if (!self::isJoined($query, 'transaction_journals')) {
|
||||
$query->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id');
|
||||
@ -244,7 +236,7 @@ class Transaction extends Model
|
||||
* @param Builder $query
|
||||
* @param array $types
|
||||
*/
|
||||
public function scopeTransactionTypes(Builder $query, array $types)
|
||||
public function scopeTransactionTypes(Builder $query, array $types): void
|
||||
{
|
||||
if (!self::isJoined($query, 'transaction_journals')) {
|
||||
$query->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id');
|
||||
@ -261,7 +253,7 @@ class Transaction extends Model
|
||||
*
|
||||
* @param $value
|
||||
*/
|
||||
public function setAmountAttribute($value)
|
||||
public function setAmountAttribute($value): void
|
||||
{
|
||||
$this->attributes['amount'] = (string)$value;
|
||||
}
|
||||
|
@ -33,14 +33,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property string $symbol
|
||||
* @property int $decimal_places
|
||||
* @property int $id
|
||||
* @property mixed name
|
||||
* @property mixed name
|
||||
* @property mixed name
|
||||
* @property mixed name
|
||||
* @property mixed name
|
||||
* @property mixed name
|
||||
* @property mixed name
|
||||
* @property mixed name
|
||||
* @property string name
|
||||
*
|
||||
*/
|
||||
class TransactionCurrency extends Model
|
||||
@ -86,7 +79,7 @@ class TransactionCurrency extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function transactionJournals()
|
||||
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournal::class);
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Crypt;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Models\TransactionJournalTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
@ -33,7 +32,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
@ -54,6 +52,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property Carbon interest_date
|
||||
* @property Carbon book_date
|
||||
* @property Carbon process_date
|
||||
* @property bool encrypted
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class TransactionJournal extends Model
|
||||
{
|
||||
@ -97,8 +99,11 @@ class TransactionJournal extends Model
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$journalId = (int)$value;
|
||||
$journal = auth()->user()->transactionJournals()->where('transaction_journals.id', $journalId)
|
||||
->first(['transaction_journals.*']);
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $user->transactionJournals()->where('transaction_journals.id', $journalId)
|
||||
->first(['transaction_journals.*']);
|
||||
if (null !== $journal) {
|
||||
return $journal;
|
||||
}
|
||||
@ -111,7 +116,7 @@ class TransactionJournal extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
*/
|
||||
public function attachments()
|
||||
public function attachments(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
}
|
||||
@ -120,7 +125,7 @@ class TransactionJournal extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function bill()
|
||||
public function bill(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Bill::class);
|
||||
}
|
||||
@ -143,31 +148,6 @@ class TransactionJournal extends Model
|
||||
return $this->belongsToMany(Category::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @deprecated
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteMeta(string $name): bool
|
||||
{
|
||||
$this->transactionJournalMeta()->where('name', $name)->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function destinationJournalLinks(): HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournalLink::class, 'destination_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
@ -176,7 +156,7 @@ class TransactionJournal extends Model
|
||||
* @return string
|
||||
* @throws \Illuminate\Contracts\Encryption\DecryptException
|
||||
*/
|
||||
public function getDescriptionAttribute($value)
|
||||
public function getDescriptionAttribute($value): string
|
||||
{
|
||||
if ($this->encrypted) {
|
||||
return Crypt::decrypt($value);
|
||||
@ -185,56 +165,6 @@ class TransactionJournal extends Model
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
public function getMeta(string $name)
|
||||
{
|
||||
$value = null;
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty('journal-meta');
|
||||
$cache->addProperty($this->id);
|
||||
$cache->addProperty($name);
|
||||
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Looking for journal #%d meta field "%s".', $this->id, $name));
|
||||
$entry = $this->transactionJournalMeta()->where('name', $name)->first();
|
||||
if (null !== $entry) {
|
||||
$value = $entry->data;
|
||||
// cache:
|
||||
$cache->store($value);
|
||||
}
|
||||
|
||||
// convert to Carbon if name is _date
|
||||
if (null !== $value && '_date' === substr($name, -5)) {
|
||||
$value = new Carbon($value);
|
||||
// cache:
|
||||
$cache->store($value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @deprecated
|
||||
* @return bool
|
||||
*/
|
||||
public function hasMeta(string $name): bool
|
||||
{
|
||||
return null !== $this->getMeta($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return bool
|
||||
@ -313,7 +243,7 @@ class TransactionJournal extends Model
|
||||
*
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function scopeAfter(EloquentBuilder $query, Carbon $date)
|
||||
public function scopeAfter(EloquentBuilder $query, Carbon $date): EloquentBuilder
|
||||
{
|
||||
return $query->where('transaction_journals.date', '>=', $date->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
@ -326,7 +256,7 @@ class TransactionJournal extends Model
|
||||
*
|
||||
* @return EloquentBuilder
|
||||
*/
|
||||
public function scopeBefore(EloquentBuilder $query, Carbon $date)
|
||||
public function scopeBefore(EloquentBuilder $query, Carbon $date): EloquentBuilder
|
||||
{
|
||||
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
@ -337,7 +267,7 @@ class TransactionJournal extends Model
|
||||
* @param EloquentBuilder $query
|
||||
* @param array $types
|
||||
*/
|
||||
public function scopeTransactionTypes(EloquentBuilder $query, array $types)
|
||||
public function scopeTransactionTypes(EloquentBuilder $query, array $types): void
|
||||
{
|
||||
if (!self::isJoined($query, 'transaction_types')) {
|
||||
$query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
|
||||
@ -354,52 +284,13 @@ class TransactionJournal extends Model
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function setDescriptionAttribute($value)
|
||||
public function setDescriptionAttribute($value): void
|
||||
{
|
||||
$encrypt = config('firefly.encryption');
|
||||
$this->attributes['description'] = $encrypt ? Crypt::encrypt($value) : $value;
|
||||
$this->attributes['encrypted'] = $encrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* @param string $name
|
||||
* @param $value
|
||||
*
|
||||
* @return TransactionJournalMeta
|
||||
*/
|
||||
public function setMeta(string $name, $value): TransactionJournalMeta
|
||||
{
|
||||
if (null === $value) {
|
||||
$this->deleteMeta($name);
|
||||
|
||||
return new TransactionJournalMeta();
|
||||
}
|
||||
if (\is_string($value) && 0 === \strlen($value)) {
|
||||
$this->deleteMeta($name);
|
||||
|
||||
return new TransactionJournalMeta();
|
||||
}
|
||||
|
||||
if ($value instanceof Carbon) {
|
||||
$value = $value->toW3cString();
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Going to set "%s" with value "%s"', $name, json_encode($value)));
|
||||
$entry = $this->transactionJournalMeta()->where('name', $name)->first();
|
||||
if (null === $entry) {
|
||||
$entry = new TransactionJournalMeta();
|
||||
$entry->transactionJournal()->associate($this);
|
||||
$entry->name = $name;
|
||||
}
|
||||
$entry->data = $value;
|
||||
$entry->save();
|
||||
app('preferences')->mark();
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return HasMany
|
||||
@ -413,7 +304,7 @@ class TransactionJournal extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function tags()
|
||||
public function tags(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Tag::class);
|
||||
}
|
||||
@ -422,7 +313,7 @@ class TransactionJournal extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function transactionCurrency()
|
||||
public function transactionCurrency(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionCurrency::class);
|
||||
}
|
||||
@ -440,7 +331,7 @@ class TransactionJournal extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function transactionType()
|
||||
public function transactionType(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionType::class);
|
||||
}
|
||||
@ -458,7 +349,7 @@ class TransactionJournal extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class TransactionJournalLink extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function destination()
|
||||
public function destination(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionJournal::class, 'destination_id');
|
||||
}
|
||||
@ -137,7 +137,7 @@ class TransactionJournalLink extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function source()
|
||||
public function source(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TransactionJournal::class, 'source_id');
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class TransactionJournalMeta extends Model
|
||||
*
|
||||
* @param $value
|
||||
*/
|
||||
public function setDataAttribute($value)
|
||||
public function setDataAttribute($value): void
|
||||
{
|
||||
$data = json_encode($value);
|
||||
$this->attributes['data'] = $data;
|
||||
|
@ -128,7 +128,7 @@ class TransactionType extends Model
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function transactionJournals()
|
||||
public function transactionJournals(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(TransactionJournal::class);
|
||||
}
|
||||
|
@ -64,7 +64,6 @@ use FireflyIII\Support\Twig\Journal;
|
||||
use FireflyIII\Support\Twig\Loader\AccountLoader;
|
||||
use FireflyIII\Support\Twig\Loader\TransactionJournalLoader;
|
||||
use FireflyIII\Support\Twig\Loader\TransactionLoader;
|
||||
use FireflyIII\Support\Twig\PiggyBank;
|
||||
use FireflyIII\Support\Twig\Rule;
|
||||
use FireflyIII\Support\Twig\Transaction;
|
||||
use FireflyIII\Support\Twig\Translation;
|
||||
@ -96,7 +95,6 @@ class FireflyServiceProvider extends ServiceProvider
|
||||
Twig::addRuntimeLoader(new TransactionLoader);
|
||||
Twig::addRuntimeLoader(new AccountLoader);
|
||||
Twig::addRuntimeLoader(new TransactionJournalLoader);
|
||||
Twig::addExtension(new PiggyBank);
|
||||
Twig::addExtension(new General);
|
||||
Twig::addExtension(new Journal);
|
||||
Twig::addExtension(new Translation);
|
||||
|
@ -168,10 +168,10 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
Log::debug(sprintf('Hash of hash is: %s', $hashOfHash));
|
||||
|
||||
$result = TransactionJournalMeta::withTrashed()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
|
||||
->where('hash', $hashOfHash)
|
||||
->where('name', 'importHashV2')
|
||||
->first(['journal_meta.*']);
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
|
||||
->where('hash', $hashOfHash)
|
||||
->where('name', 'importHashV2')
|
||||
->first(['journal_meta.*']);
|
||||
if (null === $result) {
|
||||
Log::debug('Result is null');
|
||||
}
|
||||
@ -350,16 +350,14 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$journal->save();
|
||||
|
||||
// create meta entry
|
||||
$journal->setMeta($field, $carbon);
|
||||
$this->setMetaDate($journal, $field, $carbon);
|
||||
|
||||
// return that one instead.
|
||||
return $carbon->format('Y-m-d');
|
||||
}
|
||||
$metaField = $journal->getMeta($field);
|
||||
$metaField = $this->getMetaDate($journal, $field);
|
||||
if (null !== $metaField) {
|
||||
$carbon = new Carbon($metaField);
|
||||
|
||||
return $carbon->format('Y-m-d');
|
||||
return $metaField->format('Y-m-d');
|
||||
}
|
||||
|
||||
return '';
|
||||
|
@ -86,8 +86,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
*/
|
||||
public function canAddAmount(PiggyBank $piggyBank, string $amount): bool
|
||||
{
|
||||
$leftOnAccount = $piggyBank->leftOnAccount(new Carbon);
|
||||
$savedSoFar = (string)$piggyBank->currentRelevantRep()->currentamount;
|
||||
$leftOnAccount = $this->leftOnAccount($piggyBank, new Carbon);
|
||||
$savedSoFar = (string)$this->getRepetition($piggyBank)->currentamount;
|
||||
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
||||
$maxAmount = (string)min(round($leftOnAccount, 12), round($leftToSave, 12));
|
||||
|
||||
@ -415,7 +415,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
*/
|
||||
public function removeAmount(PiggyBank $piggyBank, string $amount): bool
|
||||
{
|
||||
$repetition = $piggyBank->currentRelevantRep();
|
||||
$repetition = $this->getRepetition($piggyBank);
|
||||
$repetition->currentamount = bcsub($repetition->currentamount, $amount);
|
||||
$repetition->save();
|
||||
|
||||
|
@ -52,7 +52,6 @@ class ExpandedForm
|
||||
* @param null $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function activeAssetAccountList(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -69,9 +68,9 @@ class ExpandedForm
|
||||
/** @var Account $account */
|
||||
foreach ($assetAccounts as $account) {
|
||||
$balance = app('steam')->balance($account, new Carbon);
|
||||
$currencyId = (int)$account->getMeta('currency_id');
|
||||
$currencyId = (int)$repository->getMetaValue($account, 'currency_id');
|
||||
$currency = $currencyRepos->findNull($currencyId);
|
||||
$role = $account->getMeta('accountRole');
|
||||
$role = $repository->getMetaValue($account, 'accountRole');
|
||||
if ('' === $role) {
|
||||
$role = 'no_account_type'; // @codeCoverageIgnore
|
||||
}
|
||||
@ -93,7 +92,6 @@ class ExpandedForm
|
||||
*
|
||||
* @return string
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
|
||||
*/
|
||||
public function amount(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -106,7 +104,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function amountNoCurrency(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -145,7 +142,6 @@ class ExpandedForm
|
||||
* @param null $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function assetAccountCheckList(string $name, $options = null): string
|
||||
{
|
||||
@ -183,7 +179,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function assetAccountList(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -200,9 +195,9 @@ class ExpandedForm
|
||||
/** @var Account $account */
|
||||
foreach ($assetAccounts as $account) {
|
||||
$balance = app('steam')->balance($account, new Carbon);
|
||||
$currencyId = (int)$account->getMeta('currency_id');
|
||||
$currencyId = (int)$repository->getMetaValue($account,'currency_id');
|
||||
$currency = $currencyRepos->findNull($currencyId);
|
||||
$role = $account->getMeta('accountRole');
|
||||
$role = $repository->getMetaValue($account,'accountRole');
|
||||
if (0 === \strlen($role)) {
|
||||
$role = 'no_account_type'; // @codeCoverageIgnore
|
||||
}
|
||||
@ -225,7 +220,6 @@ class ExpandedForm
|
||||
*
|
||||
* @return string
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
|
||||
*/
|
||||
public function balance(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -239,7 +233,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function checkbox(string $name, $value = 1, $checked = null, $options = []): string
|
||||
{
|
||||
@ -268,7 +261,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function currencyList(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -293,7 +285,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function currencyListEmpty(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -320,7 +311,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function date(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -339,7 +329,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function file(string $name, array $options = []): string
|
||||
{
|
||||
@ -357,7 +346,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function integer(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -377,7 +365,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function location(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -450,7 +437,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function multiRadio(string $name, array $list = [], $selected = null, array $options = []): string
|
||||
{
|
||||
@ -472,7 +458,6 @@ class ExpandedForm
|
||||
*
|
||||
* @return string
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
|
||||
*/
|
||||
public function nonSelectableAmount(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -501,7 +486,6 @@ class ExpandedForm
|
||||
*
|
||||
* @return string
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
|
||||
*/
|
||||
public function nonSelectableBalance(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -530,7 +514,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function number(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -551,7 +534,6 @@ class ExpandedForm
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function optionsList(string $type, string $name): string
|
||||
{
|
||||
@ -565,7 +547,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function password(string $name, array $options = null): string
|
||||
{
|
||||
@ -584,7 +565,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function piggyBankList(string $name, $value = null, array $options = null): string
|
||||
{
|
||||
@ -610,7 +590,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function ruleGroupList(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -664,7 +643,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function select(string $name, array $list = [], $selected = null, array $options = []): string
|
||||
{
|
||||
@ -684,7 +662,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function staticText(string $name, $value, array $options = []): string
|
||||
{
|
||||
@ -702,7 +679,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function tags(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -722,7 +698,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function text(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -741,7 +716,6 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
|
||||
*/
|
||||
public function textarea(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
@ -843,7 +817,6 @@ class ExpandedForm
|
||||
* @return string
|
||||
*
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
|
||||
*/
|
||||
private function currencyField(string $name, string $view, $value = null, array $options = []): string
|
||||
{
|
||||
|
@ -101,8 +101,11 @@ class Steam
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$currencyId = (int)$account->getMeta('currency_id');
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$repository->setUser($account->user);
|
||||
|
||||
$currencyId = (int)$repository->getMetaValue($account, 'currency_id');
|
||||
$nativeBalance = (string)$account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d'))
|
||||
@ -152,8 +155,12 @@ class Steam
|
||||
$formatted = $start->format('Y-m-d');
|
||||
$startBalance = $this->balance($account, $start);
|
||||
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$repository->setUser($account->user);
|
||||
|
||||
$balances[$formatted] = $startBalance;
|
||||
$currencyId = (int)$account->getMeta('currency_id');
|
||||
$currencyId = (int)$repository->getMetaValue($account, 'currency_id');
|
||||
$start->addDay();
|
||||
|
||||
// query!
|
||||
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PiggyBank.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Twig;
|
||||
|
||||
use FireflyIII\Models\PiggyBank as PB;
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
* Class PiggyBank.
|
||||
*/
|
||||
class PiggyBank extends Twig_Extension
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getFunctions(): array
|
||||
{
|
||||
$functions = [];
|
||||
|
||||
$functions[] = new Twig_SimpleFunction(
|
||||
'currentRelevantRepAmount',
|
||||
function (PB $piggyBank) {
|
||||
return $piggyBank->currentRelevantRep()->currentamount;
|
||||
}
|
||||
);
|
||||
|
||||
return $functions;
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Factory\CategoryFactory;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@ -55,8 +55,12 @@ class SetCategory implements ActionInterface
|
||||
*/
|
||||
public function act(TransactionJournal $journal): bool
|
||||
{
|
||||
$name = $this->action->action_value;
|
||||
$category = Category::firstOrCreateEncrypted(['name' => $name, 'user_id' => $journal->user->id]);
|
||||
$name = $this->action->action_value;
|
||||
|
||||
/** @var CategoryFactory $factory */
|
||||
$factory = app(CategoryFactory::class);
|
||||
$factory->setUser($journal->user);
|
||||
$category = $factory->findOrCreate(null, $name);
|
||||
|
||||
$journal->categories()->detach();
|
||||
// set category on transactions:
|
||||
|
@ -26,6 +26,7 @@ namespace FireflyIII\Transformers;
|
||||
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\PiggyBankEvent;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\Fractal\Resource\Item;
|
||||
@ -117,8 +118,12 @@ class PiggyBankEventTransformer extends TransformerAbstract
|
||||
*/
|
||||
public function transform(PiggyBankEvent $event): array
|
||||
{
|
||||
$account = $event->piggyBank->account;
|
||||
$currencyId = (int)$account->getMeta('currency_id');
|
||||
$account = $event->piggyBank->account;
|
||||
/** @var AccountRepositoryInterface $accountRepos */
|
||||
$accountRepos = app(AccountRepositoryInterface::class);
|
||||
$accountRepos->setUser($account->user);
|
||||
|
||||
$currencyId = (int)$accountRepos->getMetaValue($account, 'currency_id');
|
||||
$decimalPlaces = 2;
|
||||
if ($currencyId > 0) {
|
||||
/** @var CurrencyRepositoryInterface $repository */
|
||||
|
Loading…
Reference in New Issue
Block a user