chore: reformat code.

This commit is contained in:
James Cole
2023-06-21 12:34:58 +02:00
parent 8d87abde64
commit 3dcb35710b
799 changed files with 23319 additions and 22173 deletions

View File

@@ -73,23 +73,23 @@ class CreditRecalculateService
}
/**
* @param Account|null $account
*
*/
public function setAccount(?Account $account): void
private function processGroup(): void
{
$this->account = $account;
/** @var TransactionJournal $journal */
foreach ($this->group->transactionJournals as $journal) {
try {
$this->findByJournal($journal);
} catch (FireflyException $e) {
Log::error($e->getTraceAsString());
Log::error(sprintf('Could not find work account for transaction group #%d.', $this->group->id));
}
}
}
/**
* @param TransactionGroup $group
*/
public function setGroup(TransactionGroup $group): void
{
$this->group = $group;
}
/**
* @param TransactionJournal $journal
* @param TransactionJournal $journal
*
* @throws FireflyException
*/
@@ -109,8 +109,19 @@ class CreditRecalculateService
}
/**
* @param TransactionJournal $journal
* @param string $direction
* @param TransactionJournal $journal
*
* @return Account
* @throws FireflyException
*/
private function getSourceAccount(TransactionJournal $journal): Account
{
return $this->getAccountByDirection($journal, '<');
}
/**
* @param TransactionJournal $journal
* @param string $direction
*
* @return Account
* @throws FireflyException
@@ -131,7 +142,7 @@ class CreditRecalculateService
}
/**
* @param TransactionJournal $journal
* @param TransactionJournal $journal
*
* @return Account
* @throws FireflyException
@@ -141,17 +152,6 @@ class CreditRecalculateService
return $this->getAccountByDirection($journal, '>');
}
/**
* @param TransactionJournal $journal
*
* @return Account
* @throws FireflyException
*/
private function getSourceAccount(TransactionJournal $journal): Account
{
return $this->getAccountByDirection($journal, '<');
}
/**
*
*/
@@ -166,24 +166,47 @@ class CreditRecalculateService
/**
*
*/
private function processGroup(): void
private function processWork(): void
{
/** @var TransactionJournal $journal */
foreach ($this->group->transactionJournals as $journal) {
try {
$this->findByJournal($journal);
} catch (FireflyException $e) {
Log::error($e->getTraceAsString());
Log::error(sprintf('Could not find work account for transaction group #%d.', $this->group->id));
}
$this->repository = app(AccountRepositoryInterface::class);
foreach ($this->work as $account) {
$this->processWorkAccount($account);
}
}
/**
* @param Account $account
* @param string $direction
* @param Transaction $transaction
* @param string $amount
* @param Account $account
*/
private function processWorkAccount(Account $account): void
{
// get opening balance (if present)
$this->repository->setUser($account->user);
$startOfDebt = $this->repository->getOpeningBalanceAmount($account) ?? '0';
$leftOfDebt = app('steam')->positive($startOfDebt);
/** @var AccountMetaFactory $factory */
$factory = app(AccountMetaFactory::class);
// amount is positive or negative, doesn't matter.
$factory->crud($account, 'start_of_debt', $startOfDebt);
// get direction of liability:
$direction = (string)$this->repository->getMetaValue($account, 'liability_direction');
// now loop all transactions (except opening balance and credit thing)
$transactions = $account->transactions()->get();
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
$leftOfDebt = $this->processTransaction($account, $direction, $transaction, $leftOfDebt);
}
$factory->crud($account, 'current_debt', $leftOfDebt);
}
/**
* @param Account $account
* @param string $direction
* @param Transaction $transaction
* @param string $amount
*
* @return string
*/
@@ -277,41 +300,18 @@ class CreditRecalculateService
}
/**
*
* @param Account|null $account
*/
private function processWork(): void
public function setAccount(?Account $account): void
{
$this->repository = app(AccountRepositoryInterface::class);
foreach ($this->work as $account) {
$this->processWorkAccount($account);
}
$this->account = $account;
}
/**
* @param Account $account
* @param TransactionGroup $group
*/
private function processWorkAccount(Account $account): void
public function setGroup(TransactionGroup $group): void
{
// get opening balance (if present)
$this->repository->setUser($account->user);
$startOfDebt = $this->repository->getOpeningBalanceAmount($account) ?? '0';
$leftOfDebt = app('steam')->positive($startOfDebt);
/** @var AccountMetaFactory $factory */
$factory = app(AccountMetaFactory::class);
// amount is positive or negative, doesn't matter.
$factory->crud($account, 'start_of_debt', $startOfDebt);
// get direction of liability:
$direction = (string)$this->repository->getMetaValue($account, 'liability_direction');
// now loop all transactions (except opening balance and credit thing)
$transactions = $account->transactions()->get();
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
$leftOfDebt = $this->processTransaction($account, $direction, $transaction, $leftOfDebt);
}
$factory->crud($account, 'current_debt', $leftOfDebt);
$this->group = $group;
}
}