Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Improve bunq import for #1857
James Cole344742c4934e
diff --git a/app/Support/Import/Routine/Bunq/StageNewHandler.php b/app/Support/Import/Routine/Bunq/StageNewHandler.phpindex 89ef3a4075..20ef9712ca 100644--- a/app/Support/Import/Routine/Bunq/StageNewHandler.php+++ b/app/Support/Import/Routine/Bunq/StageNewHandler.php@@ -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:// @codeCoverageIgnoreStartthrow new FireflyException(sprintf('Bunq import routine cannot handle account of type "%s".', \get_class($object)));@@ -279,6 +285,52 @@ class StageNewHandlerreturn $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.*diff --git a/resources/views/v1/import/bunq/choose-accounts.twig b/resources/views/v1/import/bunq/choose-accounts.twigindex 566837af83..4d5f395f30 100644--- a/resources/views/v1/import/bunq/choose-accounts.twig+++ b/resources/views/v1/import/bunq/choose-accounts.twig@@ -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 }}]">