Skip to content

Commit

Permalink
Add a note to descriptions for split repayments
Browse files Browse the repository at this point in the history
  • Loading branch information
scottrobertson committed Aug 17, 2018
1 parent 8fd1aaa commit 5e2600f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/monzo_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def receive
description << webhook[:data][:merchant][:metadata][:suggested_tags] if webhook[:data][:merchant].try(:[], :metadata).try(:[], :suggested_tags)
end

# If this is a split repayment, then add that to the description
if webhook[:data][:metadata].try(:[], :p2p_initiator) == 'payment-request' && webhook[:data][:merchant].present? && webhook[:data][:counterparty].present?
description << " (Repayment to #{webhook[:data][:counterparty][:name]})"
end

ynab_creator = YNAB::TransactionCreator.new(
id: "M#{webhook[:data][:id]}",
date: Time.parse(webhook[:data][:created]).to_date,
Expand Down

0 comments on commit 5e2600f

Please sign in to comment.