mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
chore: code cleanup.
This commit is contained in:
@@ -157,17 +157,31 @@ class AccountTransformer extends AbstractTransformer
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO duplicated in the V2 transformer.
|
||||
* @return Carbon
|
||||
* @param Account $account
|
||||
* @param string|null $accountRole
|
||||
* @param string $accountType
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getDate(): Carbon
|
||||
private function getCCInfo(Account $account, ?string $accountRole, string $accountType): array
|
||||
{
|
||||
$date = today(config('app.timezone'));
|
||||
if (null !== $this->parameters->get('date')) {
|
||||
$date = $this->parameters->get('date');
|
||||
$monthlyPaymentDate = null;
|
||||
$creditCardType = null;
|
||||
if ('ccAsset' === $accountRole && 'asset' === $accountType) {
|
||||
$creditCardType = $this->repository->getMetaValue($account, 'cc_type');
|
||||
$monthlyPaymentDate = $this->repository->getMetaValue($account, 'cc_monthly_payment_date');
|
||||
}
|
||||
if (null !== $monthlyPaymentDate) {
|
||||
// try classic date:
|
||||
if (10 === strlen($monthlyPaymentDate)) {
|
||||
$monthlyPaymentDate = Carbon::createFromFormat('!Y-m-d', $monthlyPaymentDate, config('app.timezone'))->toAtomString();
|
||||
}
|
||||
if (10 !== strlen($monthlyPaymentDate)) {
|
||||
$monthlyPaymentDate = Carbon::parse($monthlyPaymentDate, config('app.timezone'))->toAtomString();
|
||||
}
|
||||
}
|
||||
|
||||
return $date;
|
||||
return [$creditCardType, $monthlyPaymentDate];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,32 +207,36 @@ class AccountTransformer extends AbstractTransformer
|
||||
return [$currencyId, $currencyCode, $currencySymbol, $decimalPlaces];
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO duplicated in the V2 transformer.
|
||||
* @return Carbon
|
||||
*/
|
||||
private function getDate(): Carbon
|
||||
{
|
||||
$date = today(config('app.timezone'));
|
||||
if (null !== $this->parameters->get('date')) {
|
||||
$date = $this->parameters->get('date');
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param string|null $accountRole
|
||||
* @param string $accountType
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getCCInfo(Account $account, ?string $accountRole, string $accountType): array
|
||||
private function getInterest(Account $account, string $accountType): array
|
||||
{
|
||||
$monthlyPaymentDate = null;
|
||||
$creditCardType = null;
|
||||
if ('ccAsset' === $accountRole && 'asset' === $accountType) {
|
||||
$creditCardType = $this->repository->getMetaValue($account, 'cc_type');
|
||||
$monthlyPaymentDate = $this->repository->getMetaValue($account, 'cc_monthly_payment_date');
|
||||
}
|
||||
if (null !== $monthlyPaymentDate) {
|
||||
// try classic date:
|
||||
if(10 === strlen($monthlyPaymentDate)) {
|
||||
$monthlyPaymentDate = Carbon::createFromFormat('!Y-m-d', $monthlyPaymentDate, config('app.timezone'))->toAtomString();
|
||||
}
|
||||
if(10 !== strlen($monthlyPaymentDate)) {
|
||||
$monthlyPaymentDate = Carbon::parse($monthlyPaymentDate, config('app.timezone'))->toAtomString();
|
||||
}
|
||||
$interest = null;
|
||||
$interestPeriod = null;
|
||||
if ('liabilities' === $accountType) {
|
||||
$interest = $this->repository->getMetaValue($account, 'interest');
|
||||
$interestPeriod = $this->repository->getMetaValue($account, 'interest_period');
|
||||
}
|
||||
|
||||
return [$creditCardType, $monthlyPaymentDate];
|
||||
return [$interest, $interestPeriod];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,22 +262,4 @@ class AccountTransformer extends AbstractTransformer
|
||||
|
||||
return [$openingBalance, $openingBalanceDate];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param string $accountType
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getInterest(Account $account, string $accountType): array
|
||||
{
|
||||
$interest = null;
|
||||
$interestPeriod = null;
|
||||
if ('liabilities' === $accountType) {
|
||||
$interest = $this->repository->getMetaValue($account, 'interest');
|
||||
$interestPeriod = $this->repository->getMetaValue($account, 'interest_period');
|
||||
}
|
||||
|
||||
return [$interest, $interestPeriod];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user