use of name.abuchen.portfolio.model.BuySellEntry in project portfolio by buchen.
the class INGDiBaExtractor method addTaxSectionToBuySellEntry.
@SuppressWarnings("nls")
private void addTaxSectionToBuySellEntry(DocumentType type, Transaction<BuySellEntry> transaction) {
// Kapitalerstragsteuer (Einzelkonto)
//
transaction.section("tax", "currency").optional().match("Kapitalertragsteuer \\d+,\\d+ ?% (?<currency>\\w{3}+) (?<tax>[\\d.]+,\\d+)").assign((t, v) -> t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("tax")))))).section("tax1", "currency1", "tax2", "currency2").optional().match("KapSt anteilig 50,00 ?% \\d+,\\d+ ?% (?<currency1>\\w{3}+) (?<tax1>[\\d.]+,\\d+)").match("KapSt anteilig 50,00 ?% \\d+,\\d+ ?% (?<currency2>\\w{3}+) (?<tax2>[\\d.]+,\\d+)").assign((t, v) -> {
t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency1")), asAmount(v.get("tax1")))));
t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency2")), asAmount(v.get("tax2")))));
}).section("tax", "currency").optional().match("Solidarit.tszuschlag \\d+,\\d+ ?% (?<currency>\\w{3}+) (?<tax>[\\d.]+,\\d+)").assign((t, v) -> {
if (!Boolean.parseBoolean(type.getCurrentContext().get(IS_JOINT_ACCOUNT)))
t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("tax")))));
}).section("tax1", "currency1", "tax2", "currency2").optional().match("Solidarit.tszuschlag \\d+,\\d+ ?% (?<currency1>\\w{3}+) (?<tax1>[\\d.]+,\\d+)").match("Solidarit.tszuschlag \\d+,\\d+ ?% (?<currency2>\\w{3}+) (?<tax2>[\\d.]+,\\d+)").assign((t, v) -> {
t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency1")), asAmount(v.get("tax1")))));
t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency2")), asAmount(v.get("tax2")))));
}).section("tax", "currency").optional().match("Kirchensteuer \\d+,\\d+ ?% (?<currency>\\w{3}+) (?<tax>[\\d.]+,\\d+)").assign((t, v) -> {
if (!Boolean.parseBoolean(type.getCurrentContext().get(IS_JOINT_ACCOUNT)))
t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("tax")))));
}).section("tax1", "currency1", "tax2", "currency2").optional().match("Kirchensteuer \\d+,\\d+ ?% (?<currency1>\\w{3}+) (?<tax1>[\\d.]+,\\d+)").match("Kirchensteuer \\d+,\\d+ ?% (?<currency2>\\w{3}+) (?<tax2>[\\d.]+,\\d+)").assign((t, v) -> {
t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency1")), asAmount(v.get("tax1")))));
t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency2")), asAmount(v.get("tax2")))));
});
}
use of name.abuchen.portfolio.model.BuySellEntry in project portfolio by buchen.
the class OnvistaPDFExtractor method addSellTransaction.
private void addSellTransaction() {
DocumentType type = new DocumentType("Wir haben für Sie verkauft");
this.addDocumentTyp(type);
Block block = new Block("Wir haben für Sie verkauft(.*)");
type.addBlock(block);
Transaction<BuySellEntry> pdfTransaction = new Transaction<>();
pdfTransaction.subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.SELL);
return entry;
});
block.set(pdfTransaction);
//
pdfTransaction.section("name", "isin").find(//
"Gattungsbezeichnung ISIN").match(//
"(?<name>.*) (?<isin>[^ ]\\S*)$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("notation", "shares").find("Nominal Kurs").match(//
"(?<notation>^\\w{3}+) (?<shares>\\d{1,3}(\\.\\d{3})*(,\\d{3,})?)(.*)").assign((t, v) -> {
String notation = v.get("notation");
if (notation != null && !notation.equalsIgnoreCase("STK")) {
// Prozent-Notierung, Workaround..
t.setShares((asShares(v.get("shares")) / 100));
} else {
t.setShares(asShares(v.get("shares")));
}
}).section("date", "time", "amount", //
"currency").match("Handelstag (?<date>\\d+.\\d+.\\d{4}+) (.*)").match("Handelszeit (?<time>\\d+:\\d+)(.*)").find("Wert(\\s+)Konto-Nr. Betrag zu Ihren Gunsten(\\s*)$").match("(\\d+.\\d+.\\d{4}+) (\\d{6,12}) (?<currency>\\w{3}+) (?<amount>\\d{1,3}(\\.\\d{3})*(,\\d{2})?)").assign((t, v) -> {
t.setDate(asDate(v.get("date"), v.get("time")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).wrap(BuySellEntryItem::new);
addTaxesSectionsTransaction(pdfTransaction);
addFeesSectionsTransaction(pdfTransaction);
}
use of name.abuchen.portfolio.model.BuySellEntry in project portfolio by buchen.
the class SBrokerPDFExtractor method addBuyTransaction.
@SuppressWarnings("nls")
private void addBuyTransaction() {
DocumentType type = new DocumentType("Kauf");
this.addDocumentTyp(type);
Block block = new Block("Kauf .*");
type.addBlock(block);
block.set(new Transaction<BuySellEntry>().subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.BUY);
return entry;
}).section("isin", //
"name").find(//
"Gattungsbezeichnung ISIN").match("(?<name>.*) Inhaber-Anteile (?<isin>.*)").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("date", "amount", //
"currency").find("Wert Konto-Nr. Betrag zu Ihren Lasten").match(//
"(?<date>\\d+.\\d+.\\d{4}) \\d{2}/\\d{4}/\\d{3} (?<currency>\\w{3}+) (?<amount>[\\d.]+,\\d+)").assign((t, v) -> {
t.setDate(asDate(v.get("date")));
t.setAmount(asAmount(v.get("amount")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
}).section(//
"shares").match(//
"^STK (?<shares>\\d+,\\d+?) .*").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("fee", "currency").optional().match(//
".* Orderentgelt (?<currency>\\w{3}+) (?<fee>[\\d.]+,\\d+)-").assign((t, v) -> t.getPortfolioTransaction().addUnit(new //
Unit(//
Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))))).section("fee", "currency").optional().match(//
".* Börsengebühr (?<currency>\\w{3}+) (?<fee>[\\d.]+,\\d+)-").assign((t, v) -> t.getPortfolioTransaction().addUnit(new //
Unit(//
Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))))).wrap(t -> new BuySellEntryItem(t)));
}
use of name.abuchen.portfolio.model.BuySellEntry in project portfolio by buchen.
the class UnicreditPDFExtractor method addBuyTransaction.
@SuppressWarnings("nls")
private void addBuyTransaction() {
DocumentType type = new DocumentType("UniCredit");
this.addDocumentTyp(type);
Block block = new Block("W e r t p a p i e r - A b r e c h n u n g K a u f .*");
type.addBlock(block);
block.set(new Transaction<BuySellEntry>().subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.BUY);
return entry;
}).section("name", "wkn", "isin").find("Nennbetrag Wertpapierbezeichnung Wertpapierkennnummer/ISIN").match("^(?<name>.*) (?<wkn>[^ ]*)$").match("^.* (?<isin>[A-Z]{2}[A-Z\\d]{9}\\d)$").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("shares").match("^ST *(?<shares>[\\.\\d]+[,\\d]*)$").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("amount", "currency").match("^Belastung.* (?<currency>\\w{3}) (?<amount>[\\d.]+,\\d{2})$").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("amount")));
}).section("date").match("^Valuta (?<date>\\d+\\.\\d+\\.\\d{4}) .*").assign((t, v) -> t.setDate(asDate(v.get("date")))).section("fee", "currency").optional().match("^Brokerkommission.* (?<currency>\\w{3}) (?<fee>[\\d.]+,\\d{2})$").assign((t, v) -> t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))))).section("fee", "currency").optional().match("^Transaktionsentgelt.* (?<currency>\\w{3}) (?<fee>[\\d.]+,\\d{2})$").assign((t, v) -> t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))))).section("fee", "currency").optional().match("^Provision.* (?<currency>\\w{3}) (?<fee>[\\d.]+,\\d{2})$").assign((t, v) -> t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.FEE, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("fee")))))).wrap(t -> new BuySellEntryItem(t)));
}
use of name.abuchen.portfolio.model.BuySellEntry in project portfolio by buchen.
the class CSVAccountTransactionExtractor method extract.
@Override
void extract(List<Item> items, String[] rawValues, Map<String, Column> field2column) throws ParseException {
// check if we have a security
Security security = getSecurity(rawValues, field2column, s -> s.setCurrencyCode(getCurrencyCode(Messages.CSVColumn_TransactionCurrency, rawValues, field2column)));
// check for the transaction amount
Money amount = getMoney(rawValues, field2column);
// determine type (if not explicitly given by import)
Type type = inferType(rawValues, field2column, security, amount);
// extract remaining fields
LocalDateTime date = getDate(Messages.CSVColumn_Date, rawValues, field2column);
if (date == null)
throw new ParseException(MessageFormat.format(Messages.CSVImportMissingField, Messages.CSVColumn_Date), 0);
String note = getText(Messages.CSVColumn_Note, rawValues, field2column);
Long shares = getShares(Messages.CSVColumn_Shares, rawValues, field2column);
Long taxes = getAmount(Messages.CSVColumn_Taxes, rawValues, field2column);
switch(type) {
case TRANSFER_IN:
case TRANSFER_OUT:
AccountTransferEntry entry = new AccountTransferEntry();
entry.setAmount(Math.abs(amount.getAmount()));
entry.setCurrencyCode(amount.getCurrencyCode());
entry.setDate(date);
entry.setNote(note);
items.add(new AccountTransferItem(entry, type == Type.TRANSFER_OUT));
break;
case BUY:
case SELL:
if (security == null)
throw new ParseException(MessageFormat.format(Messages.CSVImportMissingSecurity, // $NON-NLS-1$
new StringJoiner(", ").add(Messages.CSVColumn_ISIN).add(Messages.CSVColumn_TickerSymbol).add(Messages.CSVColumn_WKN).toString()), 0);
if (shares == null)
throw new ParseException(MessageFormat.format(Messages.CSVImportMissingField, Messages.CSVColumn_Shares), 0);
BuySellEntry buySellEntry = new BuySellEntry();
buySellEntry.setType(PortfolioTransaction.Type.valueOf(type.name()));
buySellEntry.setAmount(Math.abs(amount.getAmount()));
buySellEntry.setShares(Math.abs(shares));
buySellEntry.setCurrencyCode(amount.getCurrencyCode());
buySellEntry.setSecurity(security);
buySellEntry.setDate(date);
buySellEntry.setNote(note);
items.add(new BuySellEntryItem(buySellEntry));
break;
case DIVIDENDS:
if (security == null)
throw new ParseException(MessageFormat.format(Messages.CSVImportMissingSecurity, // $NON-NLS-1$
new StringJoiner(", ").add(Messages.CSVColumn_ISIN).add(Messages.CSVColumn_TickerSymbol).add(Messages.CSVColumn_WKN).toString()), 0);
case DEPOSIT:
case TAXES:
case TAX_REFUND:
case FEES:
case FEES_REFUND:
case INTEREST:
case INTEREST_CHARGE:
case REMOVAL:
AccountTransaction t = new AccountTransaction();
t.setType(type);
t.setAmount(Math.abs(amount.getAmount()));
t.setCurrencyCode(amount.getCurrencyCode());
if (type == Type.DIVIDENDS || type == Type.TAX_REFUND)
t.setSecurity(security);
t.setDateTime(date);
t.setNote(note);
if (shares != null && type == Type.DIVIDENDS)
t.setShares(Math.abs(shares));
if (type == Type.DIVIDENDS && taxes != null && taxes.longValue() != 0)
t.addUnit(new Unit(Unit.Type.TAX, Money.of(t.getCurrencyCode(), Math.abs(taxes))));
items.add(new TransactionItem(t));
break;
default:
throw new IllegalArgumentException(type.toString());
}
}
Aggregations