diff --git a/app/Support/Import/Routine/Bunq/StageNewHandler.php b/app/Support/Import/Routine/Bunq/StageNewHandler.php index 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: // @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. * diff --git a/resources/views/v1/import/bunq/choose-accounts.twig b/resources/views/v1/import/bunq/choose-accounts.twig index 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 @@ - {{ account.description }}
+ {{ account.description }} +