mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-20 16:40:10 +00:00
Expand API with fields: liability_type, liability_amount, liability_start_date, interest, interest_period. Improve IBAN field. #1866
This commit is contained in:
@@ -180,14 +180,14 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
|
|
||||||
$openingBalance = null;
|
$openingBalance = null;
|
||||||
$openingBalanceDate = null;
|
$openingBalanceDate = null;
|
||||||
if ($type === AccountType::ASSET) {
|
if (\in_array($type, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], true)) {
|
||||||
/** @var AccountRepositoryInterface $repository */
|
$amount = $this->repository->getOpeningBalanceAmount($account);
|
||||||
$repository = app(AccountRepositoryInterface::class);
|
|
||||||
$repository->setUser($account->user);
|
|
||||||
$amount = $repository->getOpeningBalanceAmount($account);
|
|
||||||
$openingBalance = null === $amount ? null : round($amount, $decimalPlaces);
|
$openingBalance = null === $amount ? null : round($amount, $decimalPlaces);
|
||||||
$openingBalanceDate = $repository->getOpeningBalanceDate($account);
|
$openingBalanceDate = $this->repository->getOpeningBalanceDate($account);
|
||||||
}
|
}
|
||||||
|
$interest = $this->repository->getMetaValue($account, 'interest');
|
||||||
|
$interestPeriod = $this->repository->getMetaValue($account, 'interest_period');
|
||||||
|
$includeNetworth = '0' !== $this->repository->getMetaValue($account, 'include_net_worth');
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'id' => (int)$account->id,
|
'id' => (int)$account->id,
|
||||||
@@ -206,12 +206,18 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
'monthly_payment_date' => $monthlyPaymentDate,
|
'monthly_payment_date' => $monthlyPaymentDate,
|
||||||
'credit_card_type' => $creditCardType,
|
'credit_card_type' => $creditCardType,
|
||||||
'account_number' => $this->repository->getMetaValue($account, 'accountNumber'),
|
'account_number' => $this->repository->getMetaValue($account, 'accountNumber'),
|
||||||
'iban' => $account->iban,
|
'iban' => '' === $account->iban ? null : $account->iban,
|
||||||
'bic' => $this->repository->getMetaValue($account, 'BIC'),
|
'bic' => $this->repository->getMetaValue($account, 'BIC'),
|
||||||
'virtual_balance' => round($account->virtual_balance, $decimalPlaces),
|
'virtual_balance' => round($account->virtual_balance, $decimalPlaces),
|
||||||
'opening_balance' => $openingBalance,
|
'opening_balance' => $openingBalance,
|
||||||
'opening_balance_date' => $openingBalanceDate,
|
'opening_balance_date' => $openingBalanceDate,
|
||||||
'role' => $role,
|
'role' => $role,
|
||||||
|
'liability_type' => $type,
|
||||||
|
'liability_amount' => $openingBalance,
|
||||||
|
'liability_start_date' => $openingBalanceDate,
|
||||||
|
'interest' => $interest,
|
||||||
|
'interest_period' => $interestPeriod,
|
||||||
|
'include_in_net_worth' => $includeNetworth,
|
||||||
'links' => [
|
'links' => [
|
||||||
[
|
[
|
||||||
'rel' => 'self',
|
'rel' => 'self',
|
||||||
|
|||||||
Reference in New Issue
Block a user