mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Improve bunq import for #1857
This commit is contained in:
parent
886d05d436
commit
344742c493
@ -28,6 +28,7 @@ use bunq\Model\Generated\Endpoint\MonetaryAccount as BunqMonetaryAccount;
|
||||
use bunq\Model\Generated\Endpoint\MonetaryAccountBank;
|
||||
use bunq\Model\Generated\Endpoint\MonetaryAccountJoint;
|
||||
use bunq\Model\Generated\Endpoint\MonetaryAccountLight;
|
||||
use bunq\Model\Generated\Endpoint\MonetaryAccountSavings;
|
||||
use bunq\Model\Generated\Object\CoOwner;
|
||||
use bunq\Model\Generated\Object\Pointer;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@ -122,6 +123,11 @@ class StageNewHandler
|
||||
/** @var MonetaryAccountLight $object */
|
||||
$array = $this->processMal($object);
|
||||
break;
|
||||
case MonetaryAccountSavings::class;
|
||||
/** @var MonetaryAccountSavings $object */
|
||||
$array = $this->processMas($object);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
// @codeCoverageIgnoreStart
|
||||
throw new FireflyException(sprintf('Bunq import routine cannot handle account of type "%s".', \get_class($object)));
|
||||
@ -279,6 +285,52 @@ class StageNewHandler
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MonetaryAccountSavings $object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function processMas(MonetaryAccountSavings $object): array
|
||||
{
|
||||
$setting = $object->getSetting();
|
||||
$return = [
|
||||
'id' => $object->getId(),
|
||||
'currency_code' => $object->getCurrency(),
|
||||
'description' => $object->getDescription(),
|
||||
'balance' => $object->getBalance(),
|
||||
'status' => $object->getStatus(),
|
||||
'type' => 'MonetaryAccountSavings',
|
||||
'aliases' => [],
|
||||
'savingsGoal' => [],
|
||||
];
|
||||
|
||||
if (null !== $setting) {
|
||||
$return['settings'] = [
|
||||
'color' => $object->getSetting()->getColor(),
|
||||
'default_avatar_status' => $object->getSetting()->getDefaultAvatarStatus(),
|
||||
'restriction_chat' => $object->getSetting()->getRestrictionChat(),
|
||||
];
|
||||
}
|
||||
if (null !== $object->getAlias()) {
|
||||
/** @var Pointer $alias */
|
||||
foreach ($object->getAlias() as $alias) {
|
||||
$return['aliases'][] = [
|
||||
'type' => $alias->getType(),
|
||||
'name' => $alias->getName(),
|
||||
'value' => $alias->getValue(),
|
||||
];
|
||||
}
|
||||
}
|
||||
$goal = $object->getSavingsGoal();
|
||||
$return['savingsGoal'] = [
|
||||
'currency' => $goal->getCurrency(),
|
||||
'value' => $goal->getValue(),
|
||||
'percentage' => $object->getSavingsGoalProgress(),
|
||||
];
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic report method.
|
||||
*
|
||||
|
@ -56,13 +56,20 @@
|
||||
<tr>
|
||||
<td style="background:{{ account.settings.color }};"></td>
|
||||
<td>
|
||||
<strong>{{ account.description }}</strong><br />
|
||||
<strong>{{ account.description }}</strong>
|
||||
<ul>
|
||||
{% for alias in account.aliases %}
|
||||
{% if alias.type == 'IBAN' %}
|
||||
{{ alias.name }}: {{ alias.value }}
|
||||
{% set currentIban = alias.value %}
|
||||
<li>{{ alias.name }}: {{ alias.value }}{% set currentIban = alias.value %}</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if account.status != 'ACTIVE' %}
|
||||
<li>{{ trans('import.bunq_account_status_'~account.status) }}</li>
|
||||
{% endif %}
|
||||
{% if account.type == 'MonetaryAccountSavings' %}
|
||||
<li>{{ trans('import.bunq_savings_goal', {'amount': account.savingsGoal.currency ~' '~account.savingsGoal.value,'percentage' : account.savingsGoal.percentage}) }}</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" name="account_mapping[{{ account.id }}]">
|
||||
|
Loading…
Reference in New Issue
Block a user