Skip to content

Commit

Permalink
Improved handling of inbound and outbound transfers in CSV importer
Browse files Browse the repository at this point in the history
  • Loading branch information
buchen committed Jul 17, 2016
1 parent 65c9317 commit 2890208
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,12 @@ public Status apply(ImportAction action, Context context)
static class AccountTransferItem extends Item
{
private final AccountTransferEntry entry;
private final boolean isOutbound;

public AccountTransferItem(AccountTransferEntry entry)
public AccountTransferItem(AccountTransferEntry entry, boolean isOutbound)
{
this.entry = entry;
this.isOutbound = isOutbound;
}

@Override
Expand All @@ -192,7 +194,8 @@ public Annotated getSubject()
@Override
public String getTypeInformation()
{
return Messages.LabelTransferAccount;
return isOutbound ? PortfolioTransaction.Type.TRANSFER_OUT.toString()
: PortfolioTransaction.Type.TRANSFER_IN.toString();
}

@Override
Expand All @@ -216,7 +219,10 @@ public Security getSecurity()
@Override
public Status apply(ImportAction action, Context context)
{
return action.process(entry, context.getAccount(), context.getSecondaryAccount());
if (isOutbound)
return action.process(entry, context.getAccount(), context.getSecondaryAccount());
else
return action.process(entry, context.getSecondaryAccount(), context.getAccount());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void extract(List<Item> items, String[] rawValues, Map<String, Column> field2col
entry.setCurrencyCode(amount.getCurrencyCode());
entry.setDate(date);
entry.setNote(note);
items.add(new AccountTransferItem(entry));
items.add(new AccountTransferItem(entry, type == Type.TRANSFER_OUT));
break;
case BUY:
case SELL:
Expand Down

0 comments on commit 2890208

Please sign in to comment.