Skip to content

Commit

Permalink
Merge pull request #7 from petermax2/revolut_fee_amount
Browse files Browse the repository at this point in the history
Revolut import: consider fee amount in CSV
  • Loading branch information
petermax2 committed Jul 6, 2024
2 parents f4ad4f4 + 657eb78 commit 65d4f62
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/importers/revolut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ impl RevolutTransaction {
Some(config) => config.account.clone(),
None => return Err(ImportError::MissingConfig("revolut".to_owned())),
};

let revolut_amount = AmountAndCommodity {
amount: self.amount()?,
commodity: self.currency.clone(),
Expand All @@ -164,13 +165,23 @@ impl RevolutTransaction {
};

let mut postings = vec![Posting {
account: revolut_account,
account: revolut_account.clone(),
amount: Some(revolut_amount),
comment: None,
tags: Vec::new(),
}];

if fee_amount.amount != BigDecimal::zero() {
postings.push(Posting {
account: revolut_account.clone(),
amount: Some(AmountAndCommodity {
amount: fee_amount.amount.clone() * (-1),
commodity: fee_amount.commodity.clone(),
}),
comment: Some("fee".to_owned()),
tags: Vec::new(),
});

if let Some(config) = &config.revolut {
if let Some(fee_account) = &config.fee_account {
postings.push(Posting {
Expand Down

0 comments on commit 65d4f62

Please sign in to comment.