mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Multi account piggy banks.
This commit is contained in:
@@ -27,12 +27,14 @@ namespace FireflyIII\Repositories\PiggyBank;
|
||||
use FireflyIII\Events\Model\PiggyBank\ChangedAmount;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\PiggyBankFactory;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\PiggyBankRepetition;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\ObjectGroup\CreatesObjectGroups;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Trait ModifiesPiggyBanks
|
||||
@@ -55,30 +57,42 @@ trait ModifiesPiggyBanks
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool
|
||||
public function removeAmount(PiggyBank $piggyBank,Account $account, string $amount, ?TransactionJournal $journal = null): bool
|
||||
{
|
||||
$repetition = $this->getRepetition($piggyBank);
|
||||
if (null === $repetition) {
|
||||
return false;
|
||||
}
|
||||
$repetition->current_amount = bcsub($repetition->current_amount, $amount);
|
||||
$repetition->save();
|
||||
$currentAmount = $this->getCurrentAmount($piggyBank, $account);
|
||||
$pivot = $piggyBank->accounts()->where('accounts.id', $account->id)->first()->pivot;
|
||||
$pivot->current_amount = bcsub($currentAmount, $amount);
|
||||
$pivot->save();
|
||||
|
||||
app('log')->debug('addAmount [a]: Trigger change for negative amount.');
|
||||
app('log')->debug('removeAmount [a]: Trigger change for negative amount.');
|
||||
event(new ChangedAmount($piggyBank, bcmul($amount, '-1'), $journal, null));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function addAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool
|
||||
public function removeAmountFromAll(PiggyBank $piggyBank, string $amount): void
|
||||
{
|
||||
$repetition = $this->getRepetition($piggyBank);
|
||||
if (null === $repetition) {
|
||||
return false;
|
||||
foreach($piggyBank->accounts as $account) {
|
||||
$current = $account->pivot->current_amount;
|
||||
// if this account contains more than the amount, remove the amount and return.
|
||||
if (1 === bccomp($current, $amount)) {
|
||||
$this->removeAmount($piggyBank, $account, $amount);
|
||||
return;
|
||||
}
|
||||
// if this account contains less than the amount, remove the current amount, update the amount and continue.
|
||||
if (bccomp($current, $amount) < 1) {
|
||||
$this->removeAmount($piggyBank, $account, $current);
|
||||
$amount = bcsub($amount, $current);
|
||||
}
|
||||
}
|
||||
$currentAmount = $repetition->current_amount ?? '0';
|
||||
$repetition->current_amount = bcadd($currentAmount, $amount);
|
||||
$repetition->save();
|
||||
}
|
||||
|
||||
public function addAmount(PiggyBank $piggyBank, Account $account, string $amount, ?TransactionJournal $journal = null): bool
|
||||
{
|
||||
$currentAmount = $this->getCurrentAmount($piggyBank, $account);
|
||||
$pivot = $piggyBank->accounts()->where('accounts.id', $account->id)->first()->pivot;
|
||||
$pivot->current_amount = bcadd($currentAmount, $amount);
|
||||
$pivot->save();
|
||||
|
||||
app('log')->debug('addAmount [b]: Trigger change for positive amount.');
|
||||
event(new ChangedAmount($piggyBank, $amount, $journal, null));
|
||||
@@ -86,37 +100,36 @@ trait ModifiesPiggyBanks
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canAddAmount(PiggyBank $piggyBank, string $amount): bool
|
||||
public function canAddAmount(PiggyBank $piggyBank, Account $account, string $amount): bool
|
||||
{
|
||||
$today = today(config('app.timezone'));
|
||||
$leftOnAccount = $this->leftOnAccount($piggyBank, $today);
|
||||
$savedSoFar = $this->getRepetition($piggyBank)->current_amount;
|
||||
Log::debug('Now in canAddAmount');
|
||||
$today = today(config('app.timezone'))->endOfDay();
|
||||
$leftOnAccount = $this->leftOnAccount($piggyBank, $account, $today);
|
||||
$savedSoFar = $this->getCurrentAmount($piggyBank);
|
||||
$maxAmount = $leftOnAccount;
|
||||
$leftToSave = null;
|
||||
|
||||
app('log')->debug(sprintf('Left on account: %s on %s', $leftOnAccount, $today->format('Y-m-d H:i:s')));
|
||||
app('log')->debug(sprintf('Saved so far: %s', $savedSoFar));
|
||||
|
||||
|
||||
if (0 !== bccomp($piggyBank->target_amount, '0')) {
|
||||
$leftToSave = bcsub($piggyBank->target_amount, $savedSoFar);
|
||||
$maxAmount = 1 === bccomp($leftOnAccount, $leftToSave) ? $leftToSave : $leftOnAccount;
|
||||
app('log')->debug(sprintf('Left to save: %s', $leftToSave));
|
||||
app('log')->debug(sprintf('Maximum amount: %s', $maxAmount));
|
||||
}
|
||||
|
||||
$compare = bccomp($amount, $maxAmount);
|
||||
$result = $compare <= 0;
|
||||
|
||||
app('log')->debug(sprintf('Left on account: %s on %s', $leftOnAccount, $today->format('Y-m-d')));
|
||||
app('log')->debug(sprintf('Saved so far: %s', $savedSoFar));
|
||||
app('log')->debug(sprintf('Left to save: %s', $leftToSave));
|
||||
app('log')->debug(sprintf('Maximum amount: %s', $maxAmount));
|
||||
app('log')->debug(sprintf('Compare <= 0? %d, so %s', $compare, var_export($result, true)));
|
||||
app('log')->debug(sprintf('Compare <= 0? %d, so canAddAmount is %s', $compare, var_export($result, true)));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function canRemoveAmount(PiggyBank $piggyBank, string $amount): bool
|
||||
public function canRemoveAmount(PiggyBank $piggyBank, Account $account, string $amount): bool
|
||||
{
|
||||
$repetition = $this->getRepetition($piggyBank);
|
||||
if (null === $repetition) {
|
||||
return false;
|
||||
}
|
||||
$savedSoFar = $repetition->current_amount;
|
||||
$savedSoFar = $this->getCurrentAmount($piggyBank, $account);
|
||||
|
||||
return bccomp($amount, $savedSoFar) <= 0;
|
||||
}
|
||||
@@ -244,17 +257,24 @@ trait ModifiesPiggyBanks
|
||||
$this->setOrder($piggyBank, $newOrder);
|
||||
}
|
||||
|
||||
// update the accounts
|
||||
$factory = new PiggyBankFactory();
|
||||
$factory->user = $this->user;
|
||||
$factory->linkToAccountIds($piggyBank, $data['accounts']);
|
||||
|
||||
|
||||
// if the piggy bank is now smaller than the current relevant rep,
|
||||
// remove money from the rep.
|
||||
$repetition = $this->getRepetition($piggyBank);
|
||||
if (null !== $repetition && $repetition->current_amount > $piggyBank->target_amount && 0 !== bccomp($piggyBank->target_amount, '0')) {
|
||||
$difference = bcsub($piggyBank->target_amount, $repetition->current_amount);
|
||||
$currentAmount = $this->getCurrentAmount($piggyBank);
|
||||
if (1 === bccomp($currentAmount, '100') && 0 !== bccomp($piggyBank->target_amount, '0')) {
|
||||
$difference = bcsub($piggyBank->target_amount, $currentAmount);
|
||||
|
||||
// an amount will be removed, create "negative" event:
|
||||
event(new ChangedAmount($piggyBank, $difference, null, null));
|
||||
|
||||
$repetition->current_amount = $piggyBank->target_amount;
|
||||
$repetition->save();
|
||||
// question is, from which account(s) to remove the difference?
|
||||
// solution: just start from the top until there is no more money left to remove.
|
||||
$this->removeAmountFromAll($piggyBank, app('steam')->positive($difference));
|
||||
}
|
||||
|
||||
// update using name:
|
||||
@@ -295,22 +315,19 @@ trait ModifiesPiggyBanks
|
||||
if (array_key_exists('name', $data) && '' !== $data['name']) {
|
||||
$piggyBank->name = $data['name'];
|
||||
}
|
||||
if (array_key_exists('account_id', $data) && 0 !== $data['account_id']) {
|
||||
$piggyBank->account_id = (int)$data['account_id'];
|
||||
if (array_key_exists('target_amount', $data) && '' !== $data['target_amount']) {
|
||||
$piggyBank->target_amount = $data['target_amount'];
|
||||
}
|
||||
if (array_key_exists('targetamount', $data) && '' !== $data['targetamount']) {
|
||||
$piggyBank->target_amount = $data['targetamount'];
|
||||
}
|
||||
if (array_key_exists('targetamount', $data) && '' === $data['targetamount']) {
|
||||
if (array_key_exists('target_amount', $data) && '' === $data['target_amount']) {
|
||||
$piggyBank->target_amount = '0';
|
||||
}
|
||||
if (array_key_exists('targetdate', $data) && '' !== $data['targetdate']) {
|
||||
$piggyBank->target_date = $data['targetdate'];
|
||||
$piggyBank->target_date_tz = $data['targetdate']?->format('e');
|
||||
if (array_key_exists('target_date', $data) && '' !== $data['target_date']) {
|
||||
$piggyBank->target_date = $data['target_date'];
|
||||
$piggyBank->target_date_tz = $data['target_date']?->format('e');
|
||||
}
|
||||
if (array_key_exists('startdate', $data)) {
|
||||
$piggyBank->start_date = $data['startdate'];
|
||||
$piggyBank->start_date_tz = $data['targetdate']?->format('e');
|
||||
if (array_key_exists('start_date', $data)) {
|
||||
$piggyBank->start_date = $data['start_date'];
|
||||
$piggyBank->start_date_tz = $data['target_date']?->format('e');
|
||||
}
|
||||
$piggyBank->save();
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Repositories\PiggyBank;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\PiggyBankFactory;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
@@ -95,7 +96,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
|
||||
public function getAttachments(PiggyBank $piggyBank): Collection
|
||||
{
|
||||
$set = $piggyBank->attachments()->get();
|
||||
$set = $piggyBank->attachments()->get();
|
||||
|
||||
/** @var \Storage $disk */
|
||||
$disk = \Storage::disk('upload');
|
||||
@@ -114,22 +115,28 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
/**
|
||||
* Get current amount saved in piggy bank.
|
||||
*/
|
||||
public function getCurrentAmount(PiggyBank $piggyBank): string
|
||||
public function getCurrentAmount(PiggyBank $piggyBank, ?Account $account = null): string
|
||||
{
|
||||
$sum = '0';
|
||||
foreach ($piggyBank->accounts as $account) {
|
||||
$amount = (string) $account->pivot->current_amount;
|
||||
foreach ($piggyBank->accounts as $current) {
|
||||
if(null !== $account && $account->id !== $current->id) {
|
||||
continue;
|
||||
}
|
||||
$amount = (string) $current->pivot->current_amount;
|
||||
$amount = '' === $amount ? '0' : $amount;
|
||||
$sum = bcadd($sum, $amount);
|
||||
}
|
||||
Log::debug(sprintf('Current amount in piggy bank #%d ("%s") is %s', $piggyBank->id, $piggyBank->name, $sum));
|
||||
|
||||
return $sum;
|
||||
}
|
||||
|
||||
public function getRepetition(PiggyBank $piggyBank): ?PiggyBankRepetition
|
||||
public function getRepetition(PiggyBank $piggyBank, bool $overrule = false): ?PiggyBankRepetition
|
||||
{
|
||||
throw new FireflyException('[b] Piggy bank repetitions are EOL.');
|
||||
|
||||
if (false === $overrule) {
|
||||
throw new FireflyException('[b] Piggy bank repetitions are EOL.');
|
||||
}
|
||||
Log::warning('Piggy bank repetitions are EOL.');
|
||||
return $piggyBank->piggyBankRepetitions()->first();
|
||||
}
|
||||
|
||||
@@ -148,15 +155,15 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
throw new FireflyException('[c] Piggy bank repetitions are EOL.');
|
||||
app('log')->debug(sprintf('Now in getExactAmount(%d, %d, %d)', $piggyBank->id, $repetition->id, $journal->id));
|
||||
|
||||
$operator = null;
|
||||
$currency = null;
|
||||
$operator = null;
|
||||
$currency = null;
|
||||
|
||||
/** @var JournalRepositoryInterface $journalRepost */
|
||||
$journalRepost = app(JournalRepositoryInterface::class);
|
||||
$journalRepost = app(JournalRepositoryInterface::class);
|
||||
$journalRepost->setUser($this->user);
|
||||
|
||||
/** @var AccountRepositoryInterface $accountRepos */
|
||||
$accountRepos = app(AccountRepositoryInterface::class);
|
||||
$accountRepos = app(AccountRepositoryInterface::class);
|
||||
$accountRepos->setUser($this->user);
|
||||
|
||||
$defaultCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);
|
||||
@@ -165,10 +172,10 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
app('log')->debug(sprintf('Piggy bank #%d currency is %s', $piggyBank->id, $piggyBankCurrency->code));
|
||||
|
||||
/** @var Transaction $source */
|
||||
$source = $journal->transactions()->with(['account'])->where('amount', '<', 0)->first();
|
||||
$source = $journal->transactions()->with(['account'])->where('amount', '<', 0)->first();
|
||||
|
||||
/** @var Transaction $destination */
|
||||
$destination = $journal->transactions()->with(['account'])->where('amount', '>', 0)->first();
|
||||
$destination = $journal->transactions()->with(['account'])->where('amount', '>', 0)->first();
|
||||
|
||||
// matches source, which means amount will be removed from piggy:
|
||||
if ($source->account_id === $piggyBank->account_id) {
|
||||
@@ -190,7 +197,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
}
|
||||
// currency of the account + the piggy bank currency are almost the same.
|
||||
// which amount from the transaction matches?
|
||||
$amount = null;
|
||||
$amount = null;
|
||||
if ((int) $source->transaction_currency_id === $currency->id) {
|
||||
app('log')->debug('Use normal amount');
|
||||
$amount = app('steam')->{$operator}($source->amount); // @phpstan-ignore-line
|
||||
@@ -206,8 +213,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
}
|
||||
|
||||
app('log')->debug(sprintf('The currency is %s and the amount is %s', $currency->code, $amount));
|
||||
$room = bcsub($piggyBank->target_amount, $repetition->current_amount);
|
||||
$compare = bcmul($repetition->current_amount, '-1');
|
||||
$room = bcsub($piggyBank->target_amount, $repetition->current_amount);
|
||||
$compare = bcmul($repetition->current_amount, '-1');
|
||||
|
||||
if (0 === bccomp($piggyBank->target_amount, '0')) {
|
||||
// amount is zero? then the "room" is positive amount of we wish to add or remove.
|
||||
@@ -239,7 +246,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
return (string) $amount;
|
||||
}
|
||||
|
||||
public function setUser(null|Authenticatable|User $user): void
|
||||
public function setUser(null | Authenticatable | User $user): void
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
@@ -264,12 +271,12 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
{
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
$set = $this->getPiggyBanks();
|
||||
$set = $this->getPiggyBanks();
|
||||
|
||||
/** @var PiggyBank $piggy */
|
||||
foreach ($set as $piggy) {
|
||||
$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;
|
||||
@@ -278,16 +285,15 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
public function getPiggyBanks(): Collection
|
||||
{
|
||||
return PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', auth()->user()->id)
|
||||
->with(
|
||||
[
|
||||
'account',
|
||||
'objectGroups',
|
||||
]
|
||||
)
|
||||
->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*'])
|
||||
;
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', auth()->user()->id)
|
||||
->with(
|
||||
[
|
||||
'account',
|
||||
'objectGroups',
|
||||
]
|
||||
)
|
||||
->orderBy('piggy_banks.order', 'ASC')->distinct()->get(['piggy_banks.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,21 +326,22 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
/**
|
||||
* Get for piggy account what is left to put in piggies.
|
||||
*/
|
||||
public function leftOnAccount(PiggyBank $piggyBank, Carbon $date): string
|
||||
public function leftOnAccount(PiggyBank $piggyBank, Account $account, Carbon $date): string
|
||||
{
|
||||
$balance = app('steam')->balanceIgnoreVirtual($piggyBank->account, $date);
|
||||
Log::debug(sprintf('leftOnAccount("%s","%s","%s")', $piggyBank->name, $account->name, $date->format('Y-m-d H:i:s')));
|
||||
$balance = app('steam')->balanceConvertedIgnoreVirtual($account, $date, $piggyBank->transactionCurrency);
|
||||
Log::debug(sprintf('Balance is: %s', $balance));
|
||||
|
||||
/** @var Collection $piggies */
|
||||
$piggies = $piggyBank->account->piggyBanks;
|
||||
$piggies = $account->piggyBanks;
|
||||
|
||||
/** @var PiggyBank $current */
|
||||
foreach ($piggies as $current) {
|
||||
$repetition = $this->getRepetition($current);
|
||||
if (null !== $repetition) {
|
||||
$balance = bcsub($balance, $repetition->current_amount);
|
||||
}
|
||||
$amount = $this->getCurrentAmount($current, $account);
|
||||
$balance = bcsub($balance, $amount);
|
||||
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));
|
||||
return $balance;
|
||||
}
|
||||
|
||||
@@ -345,8 +352,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
$search->whereLike('piggy_banks.name', sprintf('%%%s%%', $query));
|
||||
}
|
||||
$search->orderBy('piggy_banks.order', 'ASC')
|
||||
->orderBy('piggy_banks.name', 'ASC')
|
||||
;
|
||||
->orderBy('piggy_banks.name', 'ASC');
|
||||
|
||||
return $search->take($limit)->get();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace FireflyIII\Repositories\PiggyBank;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\PiggyBankRepetition;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@@ -37,13 +38,13 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface PiggyBankRepositoryInterface
|
||||
{
|
||||
public function addAmount(PiggyBank $piggyBank, string $amount, ?TransactionJournal $journal = null): bool;
|
||||
public function addAmount(PiggyBank $piggyBank, Account $account, string $amount, ?TransactionJournal $journal = null): bool;
|
||||
|
||||
public function addAmountToRepetition(PiggyBankRepetition $repetition, string $amount, TransactionJournal $journal): void;
|
||||
|
||||
public function canAddAmount(PiggyBank $piggyBank, string $amount): bool;
|
||||
public function canAddAmount(PiggyBank $piggyBank, Account $account, string $amount): bool;
|
||||
|
||||
public function canRemoveAmount(PiggyBank $piggyBank, string $amount): bool;
|
||||
public function canRemoveAmount(PiggyBank $piggyBank, Account $account, string $amount): bool;
|
||||
|
||||
/**
|
||||
* Destroy piggy bank.
|
||||
@@ -68,7 +69,10 @@ interface PiggyBankRepositoryInterface
|
||||
/**
|
||||
* Get current amount saved in piggy bank.
|
||||
*/
|
||||
public function getCurrentAmount(PiggyBank $piggyBank): string;
|
||||
public function getCurrentAmount(PiggyBank $piggyBank, ?Account $account = null): string;
|
||||
/**
|
||||
* Get current amount saved in piggy bank.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get all events.
|
||||
@@ -97,7 +101,7 @@ interface PiggyBankRepositoryInterface
|
||||
*/
|
||||
public function getPiggyBanksWithAmount(): Collection;
|
||||
|
||||
public function getRepetition(PiggyBank $piggyBank): ?PiggyBankRepetition;
|
||||
public function getRepetition(PiggyBank $piggyBank, bool $overrule = false): ?PiggyBankRepetition;
|
||||
|
||||
/**
|
||||
* Returns the suggested amount the user should save per month, or "".
|
||||
@@ -107,9 +111,10 @@ interface PiggyBankRepositoryInterface
|
||||
/**
|
||||
* Get for piggy account what is left to put in piggies.
|
||||
*/
|
||||
public function leftOnAccount(PiggyBank $piggyBank, Carbon $date): string;
|
||||
public function leftOnAccount(PiggyBank $piggyBank,Account $account, Carbon $date): string;
|
||||
|
||||
public function removeAmount(PiggyBank $piggyBank, 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 removeObjectGroup(PiggyBank $piggyBank): PiggyBank;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user