Skip to content
This repository was archived by the owner on May 4, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ accounts:
- bunq_account_name: "Your bunq account name"
ynab_budget_name: "Your YNAB budget name"
ynab_account_name: "Your YNAB account name"
from: "2024-01-13" # optional start date

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain in readme

- bunq_account_name: "Your bunq account name 2"
ynab_budget_name: "Your YNAB budget name 2"
ynab_account_name: "Your YNAB account name 2"
7 changes: 4 additions & 3 deletions internal/core/entity/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ type Config struct {
// ConfigAccount is the configuration for a single account.
// This is what will get synced.
type ConfigAccount struct {
BunqAccountName string `yaml:"bunq_account_name"`
YnabBudgetName string `yaml:"ynab_budget_name"`
YnabAccountName string `yaml:"ynab_account_name"`
BunqAccountName string `yaml:"bunq_account_name"`
YnabBudgetName string `yaml:"ynab_budget_name"`
YnabAccountName string `yaml:"ynab_account_name"`
From *string `yaml:"from"`
}
13 changes: 12 additions & 1 deletion internal/core/service/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package sync
import (
"context"
"fmt"
"log/slog"
"time"

"github.com/bad33ndj3/bunq2ynab/internal/core/entity"
"github.com/pkg/errors"
"log/slog"
)

type Service interface {
Expand Down Expand Up @@ -70,6 +70,17 @@ func (c *Client) Sync(ctx context.Context, from time.Time) error {
slog.Info("----------------------------------------")
slog.Info("Syncing account", slog.String("account", account.BunqAccountName))

if account.From != nil {
limitFrom, err := time.Parse(time.DateOnly, *account.From)
if err != nil {
return errors.Wrap(err, "parsing from date")
}

if limitFrom.After(from) {
from = limitFrom
}
}

Comment on lines +73 to +83

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unclutter

var transactions []*entity.Transaction
for _, transaction := range ba.Transactions {
if transaction.Date.Before(from) {
Expand Down
4 changes: 2 additions & 2 deletions internal/driven/ynab/ynab.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func accountToDomain(account *account.Account) *entity.Account {
func (c *Client) GetBudgetByName(name string) (*entity.Budget, error) {
sm, err := c.yn.Budget().GetBudgets()
if err != nil {
return nil, err
return nil, errors.Wrap(err, "getting budgets")
}

for i := range sm {
Expand All @@ -116,7 +116,7 @@ func (c *Client) GetBudgetByName(name string) (*entity.Budget, error) {
}
}

return nil, errors.New("budget not found")
return nil, errors.Wrapf(errors.New("budget not found"), "budget name: %s", name)
}

func (c *Client) GetAllCategories(
Expand Down