mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Improve bunq import for #1857
This commit is contained in:
@@ -28,6 +28,7 @@ use bunq\Model\Generated\Endpoint\MonetaryAccount as BunqMonetaryAccount;
|
|||||||
use bunq\Model\Generated\Endpoint\MonetaryAccountBank;
|
use bunq\Model\Generated\Endpoint\MonetaryAccountBank;
|
||||||
use bunq\Model\Generated\Endpoint\MonetaryAccountJoint;
|
use bunq\Model\Generated\Endpoint\MonetaryAccountJoint;
|
||||||
use bunq\Model\Generated\Endpoint\MonetaryAccountLight;
|
use bunq\Model\Generated\Endpoint\MonetaryAccountLight;
|
||||||
|
use bunq\Model\Generated\Endpoint\MonetaryAccountSavings;
|
||||||
use bunq\Model\Generated\Object\CoOwner;
|
use bunq\Model\Generated\Object\CoOwner;
|
||||||
use bunq\Model\Generated\Object\Pointer;
|
use bunq\Model\Generated\Object\Pointer;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
@@ -122,6 +123,11 @@ class StageNewHandler
|
|||||||
/** @var MonetaryAccountLight $object */
|
/** @var MonetaryAccountLight $object */
|
||||||
$array = $this->processMal($object);
|
$array = $this->processMal($object);
|
||||||
break;
|
break;
|
||||||
|
case MonetaryAccountSavings::class;
|
||||||
|
/** @var MonetaryAccountSavings $object */
|
||||||
|
$array = $this->processMas($object);
|
||||||
|
break;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
throw new FireflyException(sprintf('Bunq import routine cannot handle account of type "%s".', \get_class($object)));
|
throw new FireflyException(sprintf('Bunq import routine cannot handle account of type "%s".', \get_class($object)));
|
||||||
@@ -279,6 +285,52 @@ class StageNewHandler
|
|||||||
return $return;
|
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.
|
* Basic report method.
|
||||||
*
|
*
|
||||||
|
@@ -56,13 +56,20 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td style="background:{{ account.settings.color }};"></td>
|
<td style="background:{{ account.settings.color }};"></td>
|
||||||
<td>
|
<td>
|
||||||
<strong>{{ account.description }}</strong><br />
|
<strong>{{ account.description }}</strong>
|
||||||
|
<ul>
|
||||||
{% for alias in account.aliases %}
|
{% for alias in account.aliases %}
|
||||||
{% if alias.type == 'IBAN' %}
|
{% if alias.type == 'IBAN' %}
|
||||||
{{ alias.name }}: {{ alias.value }}
|
<li>{{ alias.name }}: {{ alias.value }}{% set currentIban = alias.value %}</li>
|
||||||
{% set currentIban = alias.value %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% 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>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" name="account_mapping[{{ account.id }}]">
|
<select class="form-control" name="account_mapping[{{ account.id }}]">
|
||||||
|
Reference in New Issue
Block a user