Auto commit for release 'develop' on 2025-01-03

This commit is contained in:
github-actions
2025-01-03 07:01:02 +01:00
parent e878d5ce07
commit 58e2ef187d
7 changed files with 52 additions and 45 deletions

View File

@@ -154,22 +154,22 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
/** @var Transaction $destination */
$destination = $journal->transactions()->with(['account'])->where('amount', '>', 0)->first();
$hits = 0;
foreach($piggyBank->accounts as $account) {
$hits = 0;
foreach ($piggyBank->accounts as $account) {
// matches source, which means amount will be removed from piggy:
if($account->id === $source->account_id) {
if ($account->id === $source->account_id) {
$operator = 'negative';
$currency = $accountRepos->getAccountCurrency($source->account) ?? $defaultCurrency;
app('log')->debug(sprintf('Currency will draw money out of piggy bank. Source currency is %s', $currency->code));
$hits++;
++$hits;
}
// matches destination, which means amount will be added to piggy.
if ($account->id === $destination->account_id) {
$operator = 'positive';
$currency = $accountRepos->getAccountCurrency($destination->account) ?? $defaultCurrency;
app('log')->debug(sprintf('Currency will add money to piggy bank. Destination currency is %s', $currency->code));
$hits++;
++$hits;
}
}
if ($hits > 1) {

View File

@@ -84,8 +84,7 @@ class BelongsUser implements ValidationRule
$count = PiggyBank
::leftJoin('account_piggy_bank','account_piggy_bank.piggy_bank_id','=','piggy_banks.id')
$count = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('piggy_banks.id', '=', $value)
->where('accounts.user_id', '=', auth()->user()->id)->count()
@@ -96,14 +95,13 @@ class BelongsUser implements ValidationRule
private function validatePiggyBankName(string $value): bool
{
$count = PiggyBank
::leftJoin('account_piggy_bank','account_piggy_bank.piggy_bank_id','=','piggy_banks.id')
$count = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('piggy_banks.name', '=', $value)
->where('accounts.user_id', '=', auth()->user()->id)->count()
;
return $count>0;
return $count > 0;
}
protected function countField(string $class, string $field, string $value): int