Auto commit for release 'branch-v6.2' on 2024-12-14

This commit is contained in:
github-actions
2024-12-14 21:55:42 +01:00
parent 28d7e24d30
commit e2289ce1e6
54 changed files with 911 additions and 723 deletions

View File

@@ -1,4 +1,5 @@
<?php <?php
/* /*
* UserAttemptedLogin.php * UserAttemptedLogin.php
* Copyright (c) 2024 james@firefly-iii.org. * Copyright (c) 2024 james@firefly-iii.org.
@@ -34,7 +35,7 @@ class UserAttemptedLogin extends Event
public User $user; public User $user;
public function __construct(null | Authenticatable | User $user) public function __construct(null|Authenticatable|User $user)
{ {
if ($user instanceof User) { if ($user instanceof User) {
$this->user = $user; $this->user = $user;

View File

@@ -32,7 +32,6 @@ use FireflyIII\Events\DetectedNewIPAddress;
use FireflyIII\Events\RegisteredUser; use FireflyIII\Events\RegisteredUser;
use FireflyIII\Events\RequestedNewPassword; use FireflyIII\Events\RequestedNewPassword;
use FireflyIII\Events\Security\UserAttemptedLogin; use FireflyIII\Events\Security\UserAttemptedLogin;
use FireflyIII\Events\Test\OwnerTestNotificationChannel;
use FireflyIII\Events\Test\UserTestNotificationChannel; use FireflyIII\Events\Test\UserTestNotificationChannel;
use FireflyIII\Events\UserChangedEmail; use FireflyIII\Events\UserChangedEmail;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
@@ -44,10 +43,6 @@ use FireflyIII\Models\UserGroup;
use FireflyIII\Models\UserRole; use FireflyIII\Models\UserRole;
use FireflyIII\Notifications\Admin\UserRegistration as AdminRegistrationNotification; use FireflyIII\Notifications\Admin\UserRegistration as AdminRegistrationNotification;
use FireflyIII\Notifications\Security\UserFailedLoginAttempt; use FireflyIII\Notifications\Security\UserFailedLoginAttempt;
use FireflyIII\Notifications\Test\OwnerTestNotificationEmail;
use FireflyIII\Notifications\Test\OwnerTestNotificationNtfy;
use FireflyIII\Notifications\Test\OwnerTestNotificationPushover;
use FireflyIII\Notifications\Test\OwnerTestNotificationSlack;
use FireflyIII\Notifications\Test\UserTestNotificationEmail; use FireflyIII\Notifications\Test\UserTestNotificationEmail;
use FireflyIII\Notifications\Test\UserTestNotificationNtfy; use FireflyIII\Notifications\Test\UserTestNotificationNtfy;
use FireflyIII\Notifications\Test\UserTestNotificationPushover; use FireflyIII\Notifications\Test\UserTestNotificationPushover;
@@ -437,7 +432,8 @@ class UserEventHandler
} }
} }
public function sendLoginAttemptNotification(UserAttemptedLogin $event): void { public function sendLoginAttemptNotification(UserAttemptedLogin $event): void
{
try { try {
Notification::send($event->user, new UserFailedLoginAttempt($event->user)); Notification::send($event->user, new UserFailedLoginAttempt($event->user));
} catch (\Exception $e) { // @phpstan-ignore-line } catch (\Exception $e) { // @phpstan-ignore-line

View File

@@ -39,6 +39,7 @@ class AccountObserver
{ {
app('log')->debug('Observe "deleting" of an account.'); app('log')->debug('Observe "deleting" of an account.');
$account->accountMeta()->delete(); $account->accountMeta()->delete();
/** @var PiggyBank $piggy */ /** @var PiggyBank $piggy */
foreach ($account->piggyBanks()->get() as $piggy) { foreach ($account->piggyBanks()->get() as $piggy) {
$piggy->accounts()->detach($account); $piggy->accounts()->detach($account);

View File

@@ -133,7 +133,7 @@ class LoginController extends Controller
// send event to owner. // send event to owner.
event(new UnknownUserAttemptedLogin($username)); event(new UnknownUserAttemptedLogin($username));
} }
if(null !== $user) { if (null !== $user) {
event(new UserAttemptedLogin($user)); event(new UserAttemptedLogin($user));
} }

View File

@@ -29,7 +29,6 @@ use Exception;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Middleware\IsDemoUser; use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Support\Http\Controllers\GetConfigurationData; use FireflyIII\Support\Http\Controllers\GetConfigurationData;

View File

@@ -130,6 +130,7 @@ class AmountController extends Controller
$amounts = $data['amount'] ?? []; $amounts = $data['amount'] ?? [];
$total = '0'; $total = '0';
Log::debug('Start with loop.'); Log::debug('Start with loop.');
/** @var Account $account */ /** @var Account $account */
foreach ($piggyBank->accounts as $account) { foreach ($piggyBank->accounts as $account) {
$amount = (string) ($amounts[$account->id] ?? '0'); $amount = (string) ($amounts[$account->id] ?? '0');
@@ -183,6 +184,7 @@ class AmountController extends Controller
$amounts = []; $amounts = [];
} }
$total = '0'; $total = '0';
/** @var Account $account */ /** @var Account $account */
foreach ($piggyBank->accounts as $account) { foreach ($piggyBank->accounts as $account) {
$amount = (string) ($amounts[$account->id] ?? '0'); $amount = (string) ($amounts[$account->id] ?? '0');
@@ -235,6 +237,7 @@ class AmountController extends Controller
'saved_so_far' => $this->piggyRepos->getCurrentAmount($piggyBank, $account), 'saved_so_far' => $this->piggyRepos->getCurrentAmount($piggyBank, $account),
]; ];
} }
return view('piggy-banks.remove', compact('piggyBank', 'accounts')); return view('piggy-banks.remove', compact('piggyBank', 'accounts'));
} }

View File

@@ -89,7 +89,7 @@ class EditController extends Controller
'object_group' => null !== $piggyBank->objectGroups->first() ? $piggyBank->objectGroups->first()->title : '', 'object_group' => null !== $piggyBank->objectGroups->first() ? $piggyBank->objectGroups->first()->title : '',
'notes' => null === $note ? '' : $note->text, 'notes' => null === $note ? '' : $note->text,
]; ];
foreach($piggyBank->accounts as $account) { foreach ($piggyBank->accounts as $account) {
$preFilled['accounts'][] = $account->id; $preFilled['accounts'][] = $account->id;
} }
if (0 === bccomp($piggyBank->target_amount, '0')) { if (0 === bccomp($piggyBank->target_amount, '0')) {

View File

@@ -30,7 +30,6 @@ use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference; use FireflyIII\Models\Preference;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
@@ -342,6 +341,7 @@ class PreferencesController extends Controller
event(new UserTestNotificationChannel($channel, $user)); event(new UserTestNotificationChannel($channel, $user));
session()->flash('success', (string) trans('firefly.notification_test_executed', ['channel' => $channel])); session()->flash('success', (string) trans('firefly.notification_test_executed', ['channel' => $channel]));
} }
return ''; return '';
} }
} }

View File

@@ -61,6 +61,7 @@ class PiggyBankUpdateRequest extends FormRequest
foreach ($accounts as $item) { foreach ($accounts as $item) {
$data['accounts'][] = ['account_id' => (int) $item]; $data['accounts'][] = ['account_id' => (int) $item];
} }
return $data; return $data;
} }
@@ -121,6 +122,7 @@ class PiggyBankUpdateRequest extends FormRequest
Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray()); Log::channel('audit')->error(sprintf('Validation errors in %s', __CLASS__), $validator->errors()->toArray());
} }
} }
private function getCurrencyFromData(array $data): TransactionCurrency private function getCurrencyFromData(array $data): TransactionCurrency
{ {
$currencyId = (int) ($data['transaction_currency_id'] ?? 0); $currencyId = (int) ($data['transaction_currency_id'] ?? 0);

View File

@@ -1,4 +1,5 @@
<?php <?php
/* /*
* PreferencesRequest.php * PreferencesRequest.php
* Copyright (c) 2024 james@firefly-iii.org. * Copyright (c) 2024 james@firefly-iii.org.
@@ -31,7 +32,6 @@ class PreferencesRequest extends FormRequest
{ {
use ChecksLogin; use ChecksLogin;
/** /**
* Rules for this request. * Rules for this request.
*/ */

View File

@@ -84,6 +84,7 @@ class PiggyBank extends Model
{ {
return $this->belongsTo(TransactionCurrency::class); return $this->belongsTo(TransactionCurrency::class);
} }
public function account(): BelongsTo public function account(): BelongsTo
{ {
throw new FireflyException('This method is not available on PiggyBank.'); throw new FireflyException('This method is not available on PiggyBank.');

View File

@@ -61,7 +61,8 @@ class UnknownUserLoginAttempt extends Notification
{ {
return new MailMessage() return new MailMessage()
->markdown('emails.owner.unknown-user', ['address' => $this->address]) ->markdown('emails.owner.unknown-user', ['address' => $this->address])
->subject((string) trans('email.unknown_user_subject')); ->subject((string) trans('email.unknown_user_subject'))
;
} }
/** /**
@@ -84,7 +85,8 @@ class UnknownUserLoginAttempt extends Notification
public function toPushover(OwnerNotifiable $notifiable): PushoverMessage public function toPushover(OwnerNotifiable $notifiable): PushoverMessage
{ {
return PushoverMessage::create((string) trans('email.unknown_user_message', ['address' => $this->address])) return PushoverMessage::create((string) trans('email.unknown_user_message', ['address' => $this->address]))
->title((string) trans('email.unknown_user_subject')); ->title((string) trans('email.unknown_user_subject'))
;
} }
/** /**

View File

@@ -46,7 +46,6 @@ class UserInvitation extends Notification
private InvitedUser $invitee; private InvitedUser $invitee;
private OwnerNotifiable $owner; private OwnerNotifiable $owner;
public function __construct(OwnerNotifiable $owner, InvitedUser $invitee) public function __construct(OwnerNotifiable $owner, InvitedUser $invitee)
{ {
$this->invitee = $invitee; $this->invitee = $invitee;
@@ -69,7 +68,8 @@ class UserInvitation extends Notification
{ {
return (new MailMessage()) return (new MailMessage())
->markdown('emails.invitation-created', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email]) ->markdown('emails.invitation-created', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email])
->subject((string) trans('email.invitation_created_subject')); ->subject((string) trans('email.invitation_created_subject'))
;
} }
/** /**
@@ -95,7 +95,8 @@ class UserInvitation extends Notification
Log::debug('Now in toPushover() for UserInvitation'); Log::debug('Now in toPushover() for UserInvitation');
return PushoverMessage::create((string) trans('email.invitation_created_body', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email])) return PushoverMessage::create((string) trans('email.invitation_created_body', ['email' => $this->invitee->user->email, 'invitee' => $this->invitee->email]))
->title((string) trans('email.invitation_created_subject')); ->title((string) trans('email.invitation_created_subject'))
;
} }
/** /**

View File

@@ -46,7 +46,6 @@ class UserRegistration extends Notification
private OwnerNotifiable $owner; private OwnerNotifiable $owner;
private User $user; private User $user;
public function __construct(OwnerNotifiable $owner, User $user) public function __construct(OwnerNotifiable $owner, User $user)
{ {
$this->user = $user; $this->user = $user;
@@ -69,7 +68,8 @@ class UserRegistration extends Notification
{ {
return (new MailMessage()) return (new MailMessage())
->markdown('emails.registered-admin', ['email' => $this->user->email, 'id' => $this->user->id]) ->markdown('emails.registered-admin', ['email' => $this->user->email, 'id' => $this->user->id])
->subject((string) trans('email.registered_subject_admin')); ->subject((string) trans('email.registered_subject_admin'))
;
} }
/** /**
@@ -95,7 +95,8 @@ class UserRegistration extends Notification
Log::debug('Now in toPushover() for UserRegistration'); Log::debug('Now in toPushover() for UserRegistration');
return PushoverMessage::create((string) trans('email.admin_new_user_registered', ['email' => $this->user->email, 'invitee' => $this->user->email])) return PushoverMessage::create((string) trans('email.admin_new_user_registered', ['email' => $this->user->email, 'invitee' => $this->user->email]))
->title((string) trans('email.registered_subject_admin')); ->title((string) trans('email.registered_subject_admin'))
;
} }
/** /**

View File

@@ -44,7 +44,6 @@ class VersionCheckResult extends Notification
private string $message; private string $message;
public function __construct(string $message) public function __construct(string $message)
{ {
$this->message = $message; $this->message = $message;
@@ -66,7 +65,8 @@ class VersionCheckResult extends Notification
{ {
return (new MailMessage()) return (new MailMessage())
->markdown('emails.new-version', ['message' => $this->message]) ->markdown('emails.new-version', ['message' => $this->message])
->subject((string) trans('email.new_version_email_subject')); ->subject((string) trans('email.new_version_email_subject'))
;
} }
/** /**
@@ -92,7 +92,8 @@ class VersionCheckResult extends Notification
Log::debug('Now in toPushover() for VersionCheckResult'); Log::debug('Now in toPushover() for VersionCheckResult');
return PushoverMessage::create($this->message) return PushoverMessage::create($this->message)
->title((string) trans('email.new_version_email_subject')); ->title((string) trans('email.new_version_email_subject'))
;
} }
/** /**
@@ -103,7 +104,8 @@ class VersionCheckResult extends Notification
return new SlackMessage()->content($this->message) return new SlackMessage()->content($this->message)
->attachment(static function ($attachment): void { ->attachment(static function ($attachment): void {
$attachment->title('Firefly III @ GitHub', 'https://github.com/firefly-iii/firefly-iii/releases'); $attachment->title('Firefly III @ GitHub', 'https://github.com/firefly-iii/firefly-iii/releases');
}); })
;
} }
/** /**

View File

@@ -41,7 +41,7 @@ class OwnerNotifiable
*/ */
public function routeNotificationFor($driver, $notification = null) public function routeNotificationFor($driver, $notification = null)
{ {
$method = 'routeNotificationFor' . Str::studly($driver); $method = 'routeNotificationFor'.Str::studly($driver);
if (method_exists($this, $method)) { if (method_exists($this, $method)) {
Log::debug(sprintf('Redirect for settings to "%s".', $method)); Log::debug(sprintf('Redirect for settings to "%s".', $method));
@@ -62,7 +62,8 @@ class OwnerNotifiable
$pushoverUserToken = (string) app('fireflyconfig')->getEncrypted('pushover_user_token', '')->data; $pushoverUserToken = (string) app('fireflyconfig')->getEncrypted('pushover_user_token', '')->data;
return PushoverReceiver::withUserKey($pushoverUserToken) return PushoverReceiver::withUserKey($pushoverUserToken)
->withApplicationToken($pushoverAppToken); ->withApplicationToken($pushoverAppToken)
;
} }
public function routeNotificationForSlack(): string public function routeNotificationForSlack(): string

View File

@@ -31,7 +31,6 @@ use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Notification; use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log;
use NotificationChannels\Pushover\PushoverMessage; use NotificationChannels\Pushover\PushoverMessage;
use Ntfy\Message; use Ntfy\Message;
@@ -82,7 +81,8 @@ class DisabledMFANotification extends Notification
public function toPushover(User $notifiable): PushoverMessage public function toPushover(User $notifiable): PushoverMessage
{ {
return PushoverMessage::create((string) trans('email.disabled_mfa_slack', ['email' => $this->user->email])) return PushoverMessage::create((string) trans('email.disabled_mfa_slack', ['email' => $this->user->email]))
->title((string) trans('email.disabled_mfa_subject')); ->title((string) trans('email.disabled_mfa_subject'))
;
} }
/** /**

View File

@@ -40,7 +40,6 @@ class EnabledMFANotification extends Notification
private User $user; private User $user;
public function __construct(User $user) public function __construct(User $user)
{ {
$this->user = $user; $this->user = $user;
@@ -82,7 +81,8 @@ class EnabledMFANotification extends Notification
public function toPushover(User $notifiable): PushoverMessage public function toPushover(User $notifiable): PushoverMessage
{ {
return PushoverMessage::create((string) trans('email.enabled_mfa_slack', ['email' => $this->user->email])) return PushoverMessage::create((string) trans('email.enabled_mfa_slack', ['email' => $this->user->email]))
->title((string) trans('email.enabled_mfa_subject')); ->title((string) trans('email.enabled_mfa_subject'))
;
} }
/** /**
@@ -95,7 +95,6 @@ class EnabledMFANotification extends Notification
return new SlackMessage()->content($message); return new SlackMessage()->content($message);
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */

View File

@@ -93,10 +93,10 @@ class MFABackupFewLeftNotification extends Notification
public function toPushover(User $notifiable): PushoverMessage public function toPushover(User $notifiable): PushoverMessage
{ {
return PushoverMessage::create((string) trans('email.mfa_few_backups_left_slack', ['email' => $this->user->email, 'count' => $this->count])) return PushoverMessage::create((string) trans('email.mfa_few_backups_left_slack', ['email' => $this->user->email, 'count' => $this->count]))
->title((string) trans('email.mfa_few_backups_left_subject')); ->title((string) trans('email.mfa_few_backups_left_subject'))
;
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */

View File

@@ -40,7 +40,6 @@ class MFABackupNoLeftNotification extends Notification
private User $user; private User $user;
public function __construct(User $user) public function __construct(User $user)
{ {
$this->user = $user; $this->user = $user;
@@ -92,10 +91,10 @@ class MFABackupNoLeftNotification extends Notification
public function toPushover(User $notifiable): PushoverMessage public function toPushover(User $notifiable): PushoverMessage
{ {
return PushoverMessage::create((string) trans('email.mfa_few_backups_left_slack', ['email' => $this->user->email])) return PushoverMessage::create((string) trans('email.mfa_few_backups_left_slack', ['email' => $this->user->email]))
->title((string) trans('email.mfa_no_backups_left_slack')); ->title((string) trans('email.mfa_no_backups_left_slack'))
;
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */

View File

@@ -47,7 +47,6 @@ class MFAManyFailedAttemptsNotification extends Notification
$this->count = $count; $this->count = $count;
} }
public function toArray(User $notifiable) public function toArray(User $notifiable)
{ {
return [ return [
@@ -91,10 +90,10 @@ class MFAManyFailedAttemptsNotification extends Notification
public function toPushover(User $notifiable): PushoverMessage public function toPushover(User $notifiable): PushoverMessage
{ {
return PushoverMessage::create((string) trans('email.mfa_many_failed_slack', ['email' => $this->user->email, 'count' => $this->count])) return PushoverMessage::create((string) trans('email.mfa_many_failed_slack', ['email' => $this->user->email, 'count' => $this->count]))
->title((string) trans('email.mfa_many_failed_subject')); ->title((string) trans('email.mfa_many_failed_subject'))
;
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */

View File

@@ -40,7 +40,6 @@ class MFAUsedBackupCodeNotification extends Notification
private User $user; private User $user;
public function __construct(User $user) public function __construct(User $user)
{ {
$this->user = $user; $this->user = $user;
@@ -92,7 +91,8 @@ class MFAUsedBackupCodeNotification extends Notification
public function toPushover(User $notifiable): PushoverMessage public function toPushover(User $notifiable): PushoverMessage
{ {
return PushoverMessage::create((string) trans('email.used_backup_code_slack', ['email' => $this->user->email])) return PushoverMessage::create((string) trans('email.used_backup_code_slack', ['email' => $this->user->email]))
->title((string) trans('email.used_backup_code_subject')); ->title((string) trans('email.used_backup_code_subject'))
;
} }
/** /**

View File

@@ -40,7 +40,6 @@ class NewBackupCodesNotification extends Notification
private User $user; private User $user;
public function __construct(User $user) public function __construct(User $user)
{ {
$this->user = $user; $this->user = $user;
@@ -92,7 +91,8 @@ class NewBackupCodesNotification extends Notification
public function toPushover(User $notifiable): PushoverMessage public function toPushover(User $notifiable): PushoverMessage
{ {
return PushoverMessage::create((string) trans('email.new_backup_codes_slack', ['email' => $this->user->email])) return PushoverMessage::create((string) trans('email.new_backup_codes_slack', ['email' => $this->user->email]))
->title((string) trans('email.new_backup_codes_subject')); ->title((string) trans('email.new_backup_codes_subject'))
;
} }
/** /**

View File

@@ -1,4 +1,5 @@
<?php <?php
/* /*
* UserFailedLoginAttempt.php * UserFailedLoginAttempt.php
* Copyright (c) 2024 james@firefly-iii.org. * Copyright (c) 2024 james@firefly-iii.org.
@@ -39,13 +40,11 @@ class UserFailedLoginAttempt extends Notification
private User $user; private User $user;
public function __construct(User $user) public function __construct(User $user)
{ {
$this->user = $user; $this->user = $user;
} }
public function toArray(User $notifiable) public function toArray(User $notifiable)
{ {
return [ return [
@@ -89,7 +88,8 @@ class UserFailedLoginAttempt extends Notification
public function toPushover(User $notifiable): PushoverMessage public function toPushover(User $notifiable): PushoverMessage
{ {
return PushoverMessage::create((string) trans('email.failed_login_message', ['email' => $this->user->email])) return PushoverMessage::create((string) trans('email.failed_login_message', ['email' => $this->user->email]))
->title((string) trans('email.failed_login_subject')); ->title((string) trans('email.failed_login_subject'))
;
} }
/** /**

View File

@@ -38,7 +38,6 @@ class OwnerTestNotificationEmail extends Notification
private OwnerNotifiable $owner; private OwnerNotifiable $owner;
public function __construct(OwnerNotifiable $owner) public function __construct(OwnerNotifiable $owner)
{ {
$this->owner = $owner; $this->owner = $owner;
@@ -62,7 +61,8 @@ class OwnerTestNotificationEmail extends Notification
return (new MailMessage()) return (new MailMessage())
->markdown('emails.admin-test', ['email' => $address]) ->markdown('emails.admin-test', ['email' => $address])
->subject((string) trans('email.admin_test_subject')); ->subject((string) trans('email.admin_test_subject'))
;
} }
/** /**

View File

@@ -42,7 +42,6 @@ class OwnerTestNotificationNtfy extends Notification
public OwnerNotifiable $owner; public OwnerNotifiable $owner;
public function __construct(OwnerNotifiable $owner) public function __construct(OwnerNotifiable $owner)
{ {
$this->owner = $owner; $this->owner = $owner;
@@ -50,6 +49,8 @@ class OwnerTestNotificationNtfy extends Notification
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param mixed $notifiable
*/ */
public function toArray($notifiable) public function toArray($notifiable)
{ {

View File

@@ -42,7 +42,6 @@ class OwnerTestNotificationPushover extends Notification
private OwnerNotifiable $owner; private OwnerNotifiable $owner;
public function __construct(OwnerNotifiable $owner) public function __construct(OwnerNotifiable $owner)
{ {
$this->owner = $owner; $this->owner = $owner;
@@ -65,7 +64,8 @@ class OwnerTestNotificationPushover extends Notification
Log::debug('Now in toPushover()'); Log::debug('Now in toPushover()');
return PushoverMessage::create((string) trans('email.admin_test_message', ['channel' => 'Pushover'])) return PushoverMessage::create((string) trans('email.admin_test_message', ['channel' => 'Pushover']))
->title((string) trans('email.admin_test_subject')); ->title((string) trans('email.admin_test_subject'))
;
} }
/** /**

View File

@@ -40,7 +40,6 @@ class OwnerTestNotificationSlack extends Notification
private OwnerNotifiable $owner; private OwnerNotifiable $owner;
public function __construct(OwnerNotifiable $owner) public function __construct(OwnerNotifiable $owner)
{ {
$this->owner = $owner; $this->owner = $owner;

View File

@@ -38,7 +38,6 @@ class UserTestNotificationEmail extends Notification
private User $user; private User $user;
public function __construct(User $user) public function __construct(User $user)
{ {
$this->user = $user; $this->user = $user;
@@ -53,14 +52,14 @@ class UserTestNotificationEmail extends Notification
]; ];
} }
public function toMail(User $notifiable) public function toMail(User $notifiable)
{ {
$address = (string) $notifiable->email; $address = (string) $notifiable->email;
return (new MailMessage()) return (new MailMessage())
->markdown('emails.admin-test', ['email' => $address]) ->markdown('emails.admin-test', ['email' => $address])
->subject((string) trans('email.admin_test_subject')); ->subject((string) trans('email.admin_test_subject'))
;
} }
/** /**

View File

@@ -42,7 +42,6 @@ class UserTestNotificationNtfy extends Notification
public User $user; public User $user;
public function __construct(User $user) public function __construct(User $user)
{ {
$this->user = $user; $this->user = $user;

View File

@@ -42,7 +42,6 @@ class UserTestNotificationPushover extends Notification
private User $user; private User $user;
public function __construct(User $user) public function __construct(User $user)
{ {
$this->user = $user; $this->user = $user;
@@ -65,7 +64,8 @@ class UserTestNotificationPushover extends Notification
Log::debug('Now in (user) toPushover()'); Log::debug('Now in (user) toPushover()');
return PushoverMessage::create((string) trans('email.admin_test_message', ['channel' => 'Pushover'])) return PushoverMessage::create((string) trans('email.admin_test_message', ['channel' => 'Pushover']))
->title((string) trans('email.admin_test_subject')); ->title((string) trans('email.admin_test_subject'))
;
} }
/** /**

View File

@@ -46,7 +46,6 @@ class BillReminder extends Notification
private int $diff; private int $diff;
private string $field; private string $field;
public function __construct(Bill $bill, string $field, int $diff) public function __construct(Bill $bill, string $field, int $diff)
{ {
$this->bill = $bill; $this->bill = $bill;
@@ -54,7 +53,6 @@ class BillReminder extends Notification
$this->diff = $diff; $this->diff = $diff;
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
@@ -71,7 +69,8 @@ class BillReminder extends Notification
{ {
return (new MailMessage()) return (new MailMessage())
->markdown('emails.bill-warning', ['field' => $this->field, 'diff' => $this->diff, 'bill' => $this->bill]) ->markdown('emails.bill-warning', ['field' => $this->field, 'diff' => $this->diff, 'bill' => $this->bill])
->subject($this->getSubject()); ->subject($this->getSubject())
;
} }
/** /**
@@ -87,7 +86,8 @@ class BillReminder extends Notification
->attachment(static function ($attachment) use ($bill, $url): void { ->attachment(static function ($attachment) use ($bill, $url): void {
$attachment->title((string) trans('firefly.visit_bill', ['name' => $bill->name]), $url); $attachment->title((string) trans('firefly.visit_bill', ['name' => $bill->name]), $url);
}) })
->content($this->getSubject()); ->content($this->getSubject())
;
} }
public function toNtfy(User $notifiable): Message public function toNtfy(User $notifiable): Message
@@ -107,7 +107,8 @@ class BillReminder extends Notification
public function toPushover(User $notifiable): PushoverMessage public function toPushover(User $notifiable): PushoverMessage
{ {
return PushoverMessage::create((string) trans('email.bill_warning_please_action')) return PushoverMessage::create((string) trans('email.bill_warning_please_action'))
->title($this->getSubject()); ->title($this->getSubject())
;
} }
private function getSubject(): string private function getSubject(): string
@@ -116,6 +117,7 @@ class BillReminder extends Notification
if (0 === $this->diff) { if (0 === $this->diff) {
$message = (string) trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]); $message = (string) trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);
} }
return $message; return $message;
} }

View File

@@ -41,10 +41,8 @@ class NewAccessToken extends Notification
{ {
use Queueable; use Queueable;
public function __construct() {} public function __construct() {}
public function toArray(User $notifiable) public function toArray(User $notifiable)
{ {
return [ return [
@@ -58,7 +56,8 @@ class NewAccessToken extends Notification
{ {
return (new MailMessage()) return (new MailMessage())
->markdown('emails.token-created') ->markdown('emails.token-created')
->subject((string) trans('email.access_token_created_subject')); ->subject((string) trans('email.access_token_created_subject'))
;
} }
/** /**
@@ -86,7 +85,8 @@ class NewAccessToken extends Notification
public function toPushover(User $notifiable): PushoverMessage public function toPushover(User $notifiable): PushoverMessage
{ {
return PushoverMessage::create((string) trans('email.access_token_created_body')) return PushoverMessage::create((string) trans('email.access_token_created_body'))
->title((string) trans('email.access_token_created_subject')); ->title((string) trans('email.access_token_created_subject'))
;
} }
/** /**

View File

@@ -46,7 +46,6 @@ class RuleActionFailed extends Notification
private string $ruleLink; private string $ruleLink;
private string $ruleTitle; private string $ruleTitle;
public function __construct(array $params) public function __construct(array $params)
{ {
[$mainMessage, $groupTitle, $groupLink, $ruleTitle, $ruleLink] = $params; [$mainMessage, $groupTitle, $groupLink, $ruleTitle, $ruleLink] = $params;
@@ -83,7 +82,6 @@ class RuleActionFailed extends Notification
}); });
} }
public function toNtfy(User $notifiable): Message public function toNtfy(User $notifiable): Message
{ {
$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable); $settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);
@@ -108,9 +106,10 @@ class RuleActionFailed extends Notification
public function via(User $notifiable) public function via(User $notifiable)
{ {
$channels = ReturnsAvailableChannels::returnChannels('user', $notifiable); $channels = ReturnsAvailableChannels::returnChannels('user', $notifiable);
if (($key = array_search('mail', $channels)) !== false) { if (($key = array_search('mail', $channels, true)) !== false) {
unset($channels[$key]); unset($channels[$key]);
} }
return $channels; return $channels;
} }
} }

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\User; namespace FireflyIII\Notifications\User;
use FireflyIII\Notifications\ReturnsAvailableChannels;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
@@ -39,7 +38,6 @@ class TransactionCreation extends Notification
private array $collection; private array $collection;
public function __construct(array $collection) public function __construct(array $collection)
{ {
$this->collection = $collection; $this->collection = $collection;
@@ -57,15 +55,14 @@ class TransactionCreation extends Notification
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function toMail(User $notifiable) public function toMail(User $notifiable)
{ {
return (new MailMessage()) return (new MailMessage())
->markdown('emails.report-new-journals', ['transformed' => $this->collection]) ->markdown('emails.report-new-journals', ['transformed' => $this->collection])
->subject(trans_choice('email.new_journals_subject', count($this->collection))); ->subject(trans_choice('email.new_journals_subject', count($this->collection)))
;
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */

View File

@@ -44,13 +44,11 @@ class UserLogin extends Notification
private string $ip; private string $ip;
public function __construct(string $ip) public function __construct(string $ip)
{ {
$this->ip = $ip; $this->ip = $ip;
} }
public function toArray(User $notifiable) public function toArray(User $notifiable)
{ {
return [ return [
@@ -66,7 +64,8 @@ class UserLogin extends Notification
return (new MailMessage()) return (new MailMessage())
->markdown('emails.new-ip', ['time' => $time, 'ipAddress' => $this->ip, 'host' => $this->getHost()]) ->markdown('emails.new-ip', ['time' => $time, 'ipAddress' => $this->ip, 'host' => $this->getHost()])
->subject((string) trans('email.login_from_new_ip')); ->subject((string) trans('email.login_from_new_ip'))
;
} }
public function toNtfy(User $notifiable): Message public function toNtfy(User $notifiable): Message
@@ -86,7 +85,8 @@ class UserLogin extends Notification
public function toPushover(User $notifiable): PushoverMessage public function toPushover(User $notifiable): PushoverMessage
{ {
return PushoverMessage::create((string) trans('email.slack_login_from_new_ip', ['host' => $this->getHost(), 'ip' => $this->ip])) return PushoverMessage::create((string) trans('email.slack_login_from_new_ip', ['host' => $this->getHost(), 'ip' => $this->ip]))
->title((string) trans('email.login_from_new_ip')); ->title((string) trans('email.login_from_new_ip'))
;
} }
/** /**
@@ -105,7 +105,8 @@ class UserLogin extends Notification
return ReturnsAvailableChannels::returnChannels('user', $notifiable); return ReturnsAvailableChannels::returnChannels('user', $notifiable);
} }
private function getHost(): string { private function getHost(): string
{
$host = ''; $host = '';
try { try {
@@ -117,6 +118,7 @@ class UserLogin extends Notification
if ($hostName !== $this->ip) { if ($hostName !== $this->ip) {
$host = $hostName; $host = $hostName;
} }
return $host; return $host;
} }
} }

View File

@@ -43,7 +43,6 @@ class UserNewPassword extends Notification
private string $url; private string $url;
public function __construct(string $url) public function __construct(string $url)
{ {
$this->url = $url; $this->url = $url;
@@ -65,7 +64,8 @@ class UserNewPassword extends Notification
{ {
return (new MailMessage()) return (new MailMessage())
->markdown('emails.password', ['url' => $this->url]) ->markdown('emails.password', ['url' => $this->url])
->subject((string) trans('email.reset_pw_subject')); ->subject((string) trans('email.reset_pw_subject'))
;
} }
/** /**

View File

@@ -36,7 +36,6 @@ class UserRegistration extends Notification
{ {
use Queueable; use Queueable;
public function __construct() {} public function __construct() {}
/** /**
@@ -55,7 +54,8 @@ class UserRegistration extends Notification
{ {
return (new MailMessage()) return (new MailMessage())
->markdown('emails.registered', ['address' => route('index')]) ->markdown('emails.registered', ['address' => route('index')])
->subject((string) trans('email.registered_subject')); ->subject((string) trans('email.registered_subject'))
;
} }
/** /**

View File

@@ -57,7 +57,7 @@ trait ModifiesPiggyBanks
} }
} }
public function removeAmount(PiggyBank $piggyBank,Account $account, string $amount, ?TransactionJournal $journal = null): bool public function removeAmount(PiggyBank $piggyBank, Account $account, string $amount, ?TransactionJournal $journal = null): bool
{ {
$currentAmount = $this->getCurrentAmount($piggyBank, $account); $currentAmount = $this->getCurrentAmount($piggyBank, $account);
$pivot = $piggyBank->accounts()->where('accounts.id', $account->id)->first()->pivot; $pivot = $piggyBank->accounts()->where('accounts.id', $account->id)->first()->pivot;
@@ -72,11 +72,12 @@ trait ModifiesPiggyBanks
public function removeAmountFromAll(PiggyBank $piggyBank, string $amount): void public function removeAmountFromAll(PiggyBank $piggyBank, string $amount): void
{ {
foreach($piggyBank->accounts as $account) { foreach ($piggyBank->accounts as $account) {
$current = $account->pivot->current_amount; $current = $account->pivot->current_amount;
// if this account contains more than the amount, remove the amount and return. // if this account contains more than the amount, remove the amount and return.
if (1 === bccomp($current, $amount)) { if (1 === bccomp($current, $amount)) {
$this->removeAmount($piggyBank, $account, $amount); $this->removeAmount($piggyBank, $account, $amount);
return; return;
} }
// if this account contains less than the amount, remove the current amount, update the amount and continue. // if this account contains less than the amount, remove the current amount, update the amount and continue.
@@ -209,7 +210,8 @@ trait ModifiesPiggyBanks
->where('accounts.user_id', $this->user->id) ->where('accounts.user_id', $this->user->id)
->where('piggy_banks.order', '<=', $newOrder)->where('piggy_banks.order', '>', $oldOrder) ->where('piggy_banks.order', '<=', $newOrder)->where('piggy_banks.order', '>', $oldOrder)
->where('piggy_banks.id', '!=', $piggyBank->id) ->where('piggy_banks.id', '!=', $piggyBank->id)
->distinct()->decrement('piggy_banks.order'); ->distinct()->decrement('piggy_banks.order')
;
$piggyBank->order = $newOrder; $piggyBank->order = $newOrder;
app('log')->debug(sprintf('[1] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder)); app('log')->debug(sprintf('[1] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
@@ -222,7 +224,8 @@ trait ModifiesPiggyBanks
->where('accounts.user_id', $this->user->id) ->where('accounts.user_id', $this->user->id)
->where('piggy_banks.order', '>=', $newOrder)->where('piggy_banks.order', '<', $oldOrder) ->where('piggy_banks.order', '>=', $newOrder)->where('piggy_banks.order', '<', $oldOrder)
->where('piggy_banks.id', '!=', $piggyBank->id) ->where('piggy_banks.id', '!=', $piggyBank->id)
->distinct()->increment('piggy_banks.order'); ->distinct()->increment('piggy_banks.order')
;
$piggyBank->order = $newOrder; $piggyBank->order = $newOrder;
app('log')->debug(sprintf('[2] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder)); app('log')->debug(sprintf('[2] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));

View File

@@ -119,7 +119,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
{ {
$sum = '0'; $sum = '0';
foreach ($piggyBank->accounts as $current) { foreach ($piggyBank->accounts as $current) {
if(null !== $account && $account->id !== $current->id) { if (null !== $account && $account->id !== $current->id) {
continue; continue;
} }
$amount = (string) $current->pivot->current_amount; $amount = (string) $current->pivot->current_amount;
@@ -137,6 +137,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
throw new FireflyException('[b] Piggy bank repetitions are EOL.'); throw new FireflyException('[b] Piggy bank repetitions are EOL.');
} }
Log::warning('Piggy bank repetitions are EOL.'); Log::warning('Piggy bank repetitions are EOL.');
return $piggyBank->piggyBankRepetitions()->first(); return $piggyBank->piggyBankRepetitions()->first();
} }
@@ -246,7 +247,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return (string) $amount; return (string) $amount;
} }
public function setUser(null | Authenticatable | User $user): void public function setUser(null|Authenticatable|User $user): void
{ {
if ($user instanceof User) { if ($user instanceof User) {
$this->user = $user; $this->user = $user;
@@ -276,7 +277,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
/** @var PiggyBank $piggy */ /** @var PiggyBank $piggy */
foreach ($set as $piggy) { foreach ($set as $piggy) {
$currentAmount = $this->getRepetition($piggy)->current_amount ?? '0'; $currentAmount = $this->getRepetition($piggy)->current_amount ?? '0';
$piggy->name = $piggy->name . ' (' . app('amount')->formatAnything($currency, $currentAmount, false) . ')'; $piggy->name = $piggy->name.' ('.app('amount')->formatAnything($currency, $currentAmount, false).')';
} }
return $set; return $set;
@@ -292,7 +293,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
'objectGroups', 'objectGroups',
] ]
) )
->orderBy('piggy_banks.order', 'ASC')->distinct()->get(['piggy_banks.*']); ->orderBy('piggy_banks.order', 'ASC')->distinct()->get(['piggy_banks.*'])
;
} }
/** /**
@@ -341,6 +343,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
Log::debug(sprintf('Piggy bank: #%d with amount %s, balance is now %s', $current->id, $amount, $balance)); Log::debug(sprintf('Piggy bank: #%d with amount %s, balance is now %s', $current->id, $amount, $balance));
} }
Log::debug(sprintf('Final balance is: %s', $balance)); Log::debug(sprintf('Final balance is: %s', $balance));
return $balance; return $balance;
} }
@@ -351,7 +354,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
$search->whereLike('piggy_banks.name', sprintf('%%%s%%', $query)); $search->whereLike('piggy_banks.name', sprintf('%%%s%%', $query));
} }
$search->orderBy('piggy_banks.order', 'ASC') $search->orderBy('piggy_banks.order', 'ASC')
->orderBy('piggy_banks.name', 'ASC'); ->orderBy('piggy_banks.name', 'ASC')
;
return $search->take($limit)->get(); return $search->take($limit)->get();
} }

View File

@@ -111,9 +111,10 @@ interface PiggyBankRepositoryInterface
/** /**
* Get for piggy account what is left to put in piggies. * Get for piggy account what is left to put in piggies.
*/ */
public function leftOnAccount(PiggyBank $piggyBank,Account $account, Carbon $date): string; public function leftOnAccount(PiggyBank $piggyBank, Account $account, Carbon $date): string;
public function removeAmount(PiggyBank $piggyBank, Account $account, string $amount, ?TransactionJournal $journal = null): bool; public function removeAmount(PiggyBank $piggyBank, Account $account, string $amount, ?TransactionJournal $journal = null): bool;
public function removeAmountFromAll(PiggyBank $piggyBank, string $amount): void; public function removeAmountFromAll(PiggyBank $piggyBank, string $amount): void;
public function removeObjectGroup(PiggyBank $piggyBank): PiggyBank; public function removeObjectGroup(PiggyBank $piggyBank): PiggyBank;

View File

@@ -105,6 +105,7 @@ class Preferences
return $this->getForUser($user, $name, $default); return $this->getForUser($user, $name, $default);
} }
public function getEncryptedForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference public function getEncryptedForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference
{ {
$result = $this->getForUser($user, $name, $default); $result = $this->getForUser($user, $name, $default);

View File

@@ -45,6 +45,7 @@ class Steam
public function balanceIgnoreVirtual(Account $account, Carbon $date): string public function balanceIgnoreVirtual(Account $account, Carbon $date): string
{ {
throw new FireflyException('Deprecated method balanceIgnoreVirtual.'); throw new FireflyException('Deprecated method balanceIgnoreVirtual.');
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class); $repository = app(AccountRepositoryInterface::class);
$repository->setUser($account->user); $repository->setUser($account->user);
@@ -54,7 +55,8 @@ class Steam
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
->where('transactions.transaction_currency_id', $currencyId) ->where('transactions.transaction_currency_id', $currencyId)
->get(['transactions.amount'])->toArray(); ->get(['transactions.amount'])->toArray()
;
$nativeBalance = $this->sumTransactions($transactions, 'amount'); $nativeBalance = $this->sumTransactions($transactions, 'amount');
// get all balances in foreign currency: // get all balances in foreign currency:
@@ -63,14 +65,14 @@ class Steam
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
->where('transactions.foreign_currency_id', $currencyId) ->where('transactions.foreign_currency_id', $currencyId)
->where('transactions.transaction_currency_id', '!=', $currencyId) ->where('transactions.transaction_currency_id', '!=', $currencyId)
->get(['transactions.foreign_amount'])->toArray(); ->get(['transactions.foreign_amount'])->toArray()
;
$foreignBalance = $this->sumTransactions($transactions, 'foreign_amount'); $foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');
return bcadd($nativeBalance, $foreignBalance); return bcadd($nativeBalance, $foreignBalance);
} }
public function balanceConvertedIgnoreVirtual(Account $account, Carbon $date, TransactionCurrency $currency): string public function balanceConvertedIgnoreVirtual(Account $account, Carbon $date, TransactionCurrency $currency): string
{ {
$balance = $this->balanceConverted($account, $date, $currency); $balance = $this->balanceConverted($account, $date, $currency);
@@ -158,7 +160,8 @@ class Steam
'transactions.foreign_currency_id', 'transactions.foreign_currency_id',
\DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'), \DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'),
] ]
); )
;
$currentBalance = $startBalance; $currentBalance = $startBalance;
@@ -204,7 +207,8 @@ class Steam
->orderBy('transaction_journals.date', 'desc') ->orderBy('transaction_journals.date', 'desc')
->orderBy('transaction_journals.order', 'asc') ->orderBy('transaction_journals.order', 'asc')
->orderBy('transaction_journals.description', 'desc') ->orderBy('transaction_journals.description', 'desc')
->orderBy('transactions.amount', 'desc'); ->orderBy('transactions.amount', 'desc')
;
if (null !== $currency) { if (null !== $currency) {
$query->where('transactions.transaction_currency_id', $currency->id); $query->where('transactions.transaction_currency_id', $currency->id);
$query->limit(1); $query->limit(1);
@@ -257,7 +261,8 @@ class Steam
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
->where('transactions.transaction_currency_id', $currency->id) ->where('transactions.transaction_currency_id', $currency->id)
->get(['transactions.amount'])->toArray(); ->get(['transactions.amount'])->toArray()
;
$nativeBalance = $this->sumTransactions($transactions, 'amount'); $nativeBalance = $this->sumTransactions($transactions, 'amount');
// get all balances in foreign currency: // get all balances in foreign currency:
$transactions = $account->transactions() $transactions = $account->transactions()
@@ -265,7 +270,8 @@ class Steam
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
->where('transactions.foreign_currency_id', $currency->id) ->where('transactions.foreign_currency_id', $currency->id)
->where('transactions.transaction_currency_id', '!=', $currency->id) ->where('transactions.transaction_currency_id', '!=', $currency->id)
->get(['transactions.foreign_amount'])->toArray(); ->get(['transactions.foreign_amount'])->toArray()
;
$foreignBalance = $this->sumTransactions($transactions, 'foreign_amount'); $foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');
$balance = bcadd($nativeBalance, $foreignBalance); $balance = bcadd($nativeBalance, $foreignBalance);
$virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance; $virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;
@@ -324,7 +330,8 @@ class Steam
'transactions.foreign_currency_id', 'transactions.foreign_currency_id',
'transactions.foreign_amount', 'transactions.foreign_amount',
] ]
)->toArray(); )->toArray()
;
// loop the set and convert if necessary: // loop the set and convert if necessary:
$currentBalance = $startBalance; $currentBalance = $startBalance;
@@ -438,14 +445,16 @@ class Steam
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
->where('transactions.transaction_currency_id', $currency->id) ->where('transactions.transaction_currency_id', $currency->id)
->whereNull('transactions.foreign_currency_id') ->whereNull('transactions.foreign_currency_id')
->get(['transaction_journals.date', 'transactions.amount'])->toArray(); ->get(['transaction_journals.date', 'transactions.amount'])->toArray()
;
Log::debug(sprintf('%d transaction(s) in set #1', count($new[0]))); Log::debug(sprintf('%d transaction(s) in set #1', count($new[0])));
$existing[] = $account->transactions() // 2 $existing[] = $account->transactions() // 2
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
->where('transactions.transaction_currency_id', $native->id) ->where('transactions.transaction_currency_id', $native->id)
->whereNull('transactions.foreign_currency_id') ->whereNull('transactions.foreign_currency_id')
->get(['transactions.amount'])->toArray(); ->get(['transactions.amount'])->toArray()
;
Log::debug(sprintf('%d transaction(s) in set #2', count($existing[0]))); Log::debug(sprintf('%d transaction(s) in set #2', count($existing[0])));
$new[] = $account->transactions() // 3 $new[] = $account->transactions() // 3
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
@@ -453,14 +462,16 @@ class Steam
->where('transactions.transaction_currency_id', '!=', $currency->id) ->where('transactions.transaction_currency_id', '!=', $currency->id)
->where('transactions.transaction_currency_id', '!=', $native->id) ->where('transactions.transaction_currency_id', '!=', $native->id)
->whereNull('transactions.foreign_currency_id') ->whereNull('transactions.foreign_currency_id')
->get(['transaction_journals.date', 'transactions.amount'])->toArray(); ->get(['transaction_journals.date', 'transactions.amount'])->toArray()
;
Log::debug(sprintf('%d transactions in set #3', count($new[1]))); Log::debug(sprintf('%d transactions in set #3', count($new[1])));
$existing[] = $account->transactions() // 4 $existing[] = $account->transactions() // 4
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
->where('transactions.foreign_currency_id', $native->id) ->where('transactions.foreign_currency_id', $native->id)
->whereNotNull('transactions.foreign_amount') ->whereNotNull('transactions.foreign_amount')
->get(['transactions.foreign_amount'])->toArray(); ->get(['transactions.foreign_amount'])->toArray()
;
Log::debug(sprintf('%d transactions in set #4', count($existing[1]))); Log::debug(sprintf('%d transactions in set #4', count($existing[1])));
$new[] = $account->transactions()// 5 $new[] = $account->transactions()// 5
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
@@ -468,7 +479,8 @@ class Steam
->where('transactions.transaction_currency_id', $currency->id) ->where('transactions.transaction_currency_id', $currency->id)
->where('transactions.foreign_currency_id', '!=', $native->id) ->where('transactions.foreign_currency_id', '!=', $native->id)
->whereNotNull('transactions.foreign_amount') ->whereNotNull('transactions.foreign_amount')
->get(['transaction_journals.date', 'transactions.amount'])->toArray(); ->get(['transaction_journals.date', 'transactions.amount'])->toArray()
;
Log::debug(sprintf('%d transactions in set #5', count($new[2]))); Log::debug(sprintf('%d transactions in set #5', count($new[2])));
$new[] = $account->transactions()// 6 $new[] = $account->transactions()// 6
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
@@ -476,7 +488,8 @@ class Steam
->where('transactions.transaction_currency_id', '!=', $currency->id) ->where('transactions.transaction_currency_id', '!=', $currency->id)
->where('transactions.foreign_currency_id', '!=', $native->id) ->where('transactions.foreign_currency_id', '!=', $native->id)
->whereNotNull('transactions.foreign_amount') ->whereNotNull('transactions.foreign_amount')
->get(['transaction_journals.date', 'transactions.amount'])->toArray(); ->get(['transaction_journals.date', 'transactions.amount'])->toArray()
;
Log::debug(sprintf('%d transactions in set #6', count($new[3]))); Log::debug(sprintf('%d transactions in set #6', count($new[3])));
// process both sets of transactions. Of course, no need to convert set "existing". // process both sets of transactions. Of course, no need to convert set "existing".
@@ -651,7 +664,8 @@ class Steam
$query = $account->transactions() $query = $account->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
->groupBy('transactions.transaction_currency_id'); ->groupBy('transactions.transaction_currency_id')
;
$balances = $query->get(['transactions.transaction_currency_id', \DB::raw('SUM(transactions.amount) as sum_for_currency')]); // @phpstan-ignore-line $balances = $query->get(['transactions.transaction_currency_id', \DB::raw('SUM(transactions.amount) as sum_for_currency')]); // @phpstan-ignore-line
$return = []; $return = [];
@@ -683,10 +697,10 @@ class Steam
// Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision)); // Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision));
if (str_contains($number, '.')) { if (str_contains($number, '.')) {
if ('-' !== $number[0]) { if ('-' !== $number[0]) {
return bcadd($number, '0.' . str_repeat('0', $precision) . '5', $precision); return bcadd($number, '0.'.str_repeat('0', $precision).'5', $precision);
} }
return bcsub($number, '0.' . str_repeat('0', $precision) . '5', $precision); return bcsub($number, '0.'.str_repeat('0', $precision).'5', $precision);
} }
return $number; return $number;

View File

@@ -82,6 +82,7 @@ class UpdatePiggybank implements ActionInterface
if ($source->account_id === $piggyBank->account_id) { if ($source->account_id === $piggyBank->account_id) {
app('log')->debug('Piggy bank account is linked to source, so remove amount from piggy bank.'); app('log')->debug('Piggy bank account is linked to source, so remove amount from piggy bank.');
throw new FireflyException('Reference the correct account here.'); throw new FireflyException('Reference the correct account here.');
$this->removeAmount($piggyBank, $journal, $journalObj, $destination->amount); $this->removeAmount($piggyBank, $journal, $journalObj, $destination->amount);

View File

@@ -36,7 +36,6 @@ use FireflyIII\Models\Category;
use FireflyIII\Models\CurrencyExchangeRate; use FireflyIII\Models\CurrencyExchangeRate;
use FireflyIII\Models\GroupMembership; use FireflyIII\Models\GroupMembership;
use FireflyIII\Models\ObjectGroup; use FireflyIII\Models\ObjectGroup;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Preference; use FireflyIII\Models\Preference;
use FireflyIII\Models\Recurrence; use FireflyIII\Models\Recurrence;
use FireflyIII\Models\Role; use FireflyIII\Models\Role;
@@ -107,7 +106,8 @@ class User extends Authenticatable
return $this->hasMany(Account::class); return $this->hasMany(Account::class);
} }
public function piggyBanks() { public function piggyBanks(): void
{
throw new FireflyException('Method no longer supported.'); throw new FireflyException('Method no longer supported.');
} }
@@ -360,7 +360,7 @@ class User extends Authenticatable
*/ */
public function routeNotificationFor($driver, $notification = null) public function routeNotificationFor($driver, $notification = null)
{ {
$method = 'routeNotificationFor' . Str::studly($driver); $method = 'routeNotificationFor'.Str::studly($driver);
if (method_exists($this, $method)) { if (method_exists($this, $method)) {
return $this->{$method}($notification); // @phpstan-ignore-line return $this->{$method}($notification); // @phpstan-ignore-line
} }

View File

@@ -110,7 +110,7 @@ return [
'running_balance_column' => env('USE_RUNNING_BALANCE', false), 'running_balance_column' => env('USE_RUNNING_BALANCE', false),
// see cer.php for exchange rates feature flag. // see cer.php for exchange rates feature flag.
], ],
'version' => 'develop/2024-11-25', 'version' => 'branch-v6.2',
'api_version' => '2.1.0', // field is no longer used. 'api_version' => '2.1.0', // field is no longer used.
'db_version' => 25, 'db_version' => 25,

View File

@@ -28,8 +28,8 @@ return [
'slack' => ['enabled' => true, 'ui_configurable' => 1], 'slack' => ['enabled' => true, 'ui_configurable' => 1],
'ntfy' => ['enabled' => true, 'ui_configurable' => 1], 'ntfy' => ['enabled' => true, 'ui_configurable' => 1],
'pushover' => ['enabled' => true, 'ui_configurable' => 1], 'pushover' => ['enabled' => true, 'ui_configurable' => 1],
// 'gotify' => ['enabled' => false, 'ui_configurable' => 0], // 'gotify' => ['enabled' => false, 'ui_configurable' => 0],
// 'pushbullet' => ['enabled' => false, 'ui_configurable' => 0], // 'pushbullet' => ['enabled' => false, 'ui_configurable' => 0],
], ],
'notifications' => [ 'notifications' => [
'user' => [ 'user' => [

761
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,8 +5,8 @@
"flash_warning": "\u00a1Advertencia!", "flash_warning": "\u00a1Advertencia!",
"flash_success": "\u00a1Operaci\u00f3n correcta!", "flash_success": "\u00a1Operaci\u00f3n correcta!",
"close": "Cerrar", "close": "Cerrar",
"select_dest_account": "Please select or type a valid destination account name", "select_dest_account": "Por favor, seleccione o escriba un nombre de cuenta de destino v\u00e1lido",
"select_source_account": "Please select or type a valid source account name", "select_source_account": "Por favor, seleccione o escriba un nombre de cuenta de origen v\u00e1lido",
"split_transaction_title": "Descripci\u00f3n de la transacci\u00f3n dividida", "split_transaction_title": "Descripci\u00f3n de la transacci\u00f3n dividida",
"errors_submission": "Hubo un problema con su env\u00edo. Por favor, compruebe los siguientes errores.", "errors_submission": "Hubo un problema con su env\u00edo. Por favor, compruebe los siguientes errores.",
"split": "Separar", "split": "Separar",