Skip to content

Commit 9c3286f

Browse files
Adding ability to skip emoji, foreign currency flags and tags
Closes #63
1 parent 368e168 commit 9c3286f

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

app.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@
2020
"description": "Optional: Starling account id. If not provided, we will use the first YNAB account.",
2121
"required": false
2222
},
23+
"SKIP_EMOJI": {
24+
"description": "Optional: This will tell Fintech to YNAB not to add the emoji to the descriptions. (Monzo Only)",
25+
"required": false
26+
},
27+
"SKIP_FOREIGN_CURRENCY_FLAG": {
28+
"description": "Optional: This will tell Fintech to YNAB not to add flags to foreign currency transactions.",
29+
"required": false
30+
},
31+
"SKIP_TAGS": {
32+
"description": "Optional: This will tell Fintech to YNAB not to add hashtags to the transaction description. (Monzo Only)",
33+
"required": false
34+
},
2335
"URL_SECRET": {
2436
"description": "Optional: This is a secret used for the webhooks endpoint.",
2537
"required": false

app/controllers/monzo_controller.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@ def receive
1818
if foreign_transaction
1919
money = Money.new(webhook[:data][:local_amount].abs, webhook[:data][:local_currency])
2020
description.prepend("(#{money.format}) ")
21-
flag = 'orange'
21+
flag = 'orange' unless ENV['SKIP_FOREIGN_CURRENCY_FLAG'].present?
2222
end
2323

24-
description.prepend("#{webhook[:data][:merchant][:emoji]} ") if webhook[:data][:merchant].try(:[], :emoji)
25-
description << webhook[:data][:merchant][:metadata][:suggested_tags] if webhook[:data][:merchant].try(:[], :metadata).try(:[], :suggested_tags)
24+
unless ENV['SKIP_EMOJI'].present?
25+
description.prepend("#{webhook[:data][:merchant][:emoji]} ") if webhook[:data][:merchant].try(:[], :emoji)
26+
end
27+
28+
unless ENV['SKIP_TAGS'].present?
29+
description << webhook[:data][:merchant][:metadata][:suggested_tags] if webhook[:data][:merchant].try(:[], :metadata).try(:[], :suggested_tags)
30+
end
2631

2732
ynab_creator = YNAB::TransactionCreator.new(
2833
date: Time.parse(webhook[:data][:created]).to_date,

app/controllers/starling_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def receive
3737
flag = nil
3838

3939
foreign_transaction = webhook[:content][:sourceCurrency] != 'GBP'
40-
flag = 'orange' if foreign_transaction
40+
flag = 'orange' if foreign_transaction && !ENV['SKIP_FOREIGN_CURRENCY_FLAG']
4141
else
4242
return render json: { error: :unsupported_type }
4343
end

app/services/import/monzo.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ def import
2424
if foreign_transaction
2525
money = Money.new(transaction[:local_amount].abs, transaction[:local_currency])
2626
description.prepend("(#{money.format}) ")
27-
flag = 'orange'
27+
flag = 'orange' unless ENV['SKIP_FOREIGN_CURRENCY_FLAG'].present?
2828
end
2929

30-
description.prepend("#{transaction[:merchant][:emoji]} ") if transaction[:merchant].try(:[], :emoji).present?
31-
description << transaction[:merchant][:metadata][:suggested_tags] if transaction[:merchant].try(:[], :metadata).try(:[], :suggested_tags).present?
30+
unless ENV['SKIP_EMOJI'].present?
31+
description.prepend("#{transaction[:merchant][:emoji]} ") if transaction[:merchant].try(:[], :emoji)
32+
end
33+
34+
unless ENV['SKIP_TAGS'].present?
35+
description << transaction[:merchant][:metadata][:suggested_tags] if transaction[:merchant].try(:[], :metadata).try(:[], :suggested_tags)
36+
end
3237

3338
transactions_to_create << {
3439
amount: transaction[:amount] * 10,

0 commit comments

Comments
 (0)