use of name.abuchen.portfolio.model.Transaction.Unit in project portfolio by buchen.
the class FinTechGroupBankPDFExtractor method addTransferOutTransaction.
@SuppressWarnings("nls")
private void addTransferOutTransaction() {
DocumentType type = new DocumentType("Depotausgang");
this.addDocumentTyp(type);
Block block = new Block("Depotausgang(.*)");
type.addBlock(block);
block.set(new Transaction<BuySellEntry>().subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.SELL);
return entry;
}).section("date").match(//
"Fälligkeitstag(\\s*):(\\s+)(?<date>\\d+.\\d+.\\d{4})(.*)").assign((t, v) -> t.setDate(asDate(v.get("date")))).section("isin", "name").match(//
"Depotausgang *(?<name>.*) *\\((?<isin>[^/]*)\\)").assign((t, v) -> {
t.setSecurity(getOrCreateSecurity(v));
}).section("shares", "notation").match(//
"^Stk\\.\\/Nominale(\\s*):(\\s+)(?<shares>[\\.\\d]+(,\\d*)?) *(?<notation>St\\.|\\w{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("amount", "currency").match("(.*)Geldgegenwert\\*\\*(.*)(\\s*):(\\s*)(?<amount>[\\d.]+,\\d+)(\\s+)(?<currency>\\w{3}+)(.*)").assign((t, v) -> {
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("amount")));
}).section("fee", "currency").optional().match(".* Provision *(?<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(".* Eigene Spesen *(?<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(".* \\*Fremde Spesen *(?<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("tax", "currency").optional().match(//
"(.*)Einbeh. Steuer(.*):(\\s*)(?<tax>[\\d.]+,\\d+) (?<currency>\\w{3}+)").assign((t, v) -> t.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(asCurrencyCode(v.get("currency")), asAmount(v.get("tax")))))).wrap(t -> new BuySellEntryItem(t)));
}
use of name.abuchen.portfolio.model.Transaction.Unit in project portfolio by buchen.
the class CSVPortfolioTransactionExtractor method createGrossValueIfNecessary.
private void createGrossValueIfNecessary(String[] rawValues, Map<String, Column> field2column, PortfolioTransaction transaction) throws ParseException {
if (transaction.getSecurity().getCurrencyCode().equals(transaction.getCurrencyCode()))
return;
BigDecimal exchangeRate = getBigDecimal(Messages.CSVColumn_ExchangeRate, rawValues, field2column);
if (exchangeRate != null && exchangeRate.compareTo(BigDecimal.ZERO) != 0) {
Money grossValue = transaction.getGrossValue();
Money forex = Money.of(transaction.getSecurity().getCurrencyCode(), Math.round(exchangeRate.multiply(BigDecimal.valueOf(grossValue.getAmount())).doubleValue()));
exchangeRate = BigDecimal.ONE.divide(exchangeRate, 10, BigDecimal.ROUND_HALF_DOWN);
transaction.addUnit(new Unit(Unit.Type.GROSS_VALUE, grossValue, forex, exchangeRate));
}
}
use of name.abuchen.portfolio.model.Transaction.Unit in project portfolio by buchen.
the class CSVPortfolioTransactionExtractor method createDelivery.
private Item createDelivery(String[] rawValues, Map<String, Column> field2column, Type type, Security security, Money amount, Long fees, Long taxes, LocalDateTime date, String note, Long shares, Unit grossAmount) throws ParseException {
PortfolioTransaction t = new PortfolioTransaction();
t.setType(type);
t.setSecurity(security);
t.setDateTime(date);
t.setAmount(Math.abs(amount.getAmount()));
t.setCurrencyCode(amount.getCurrencyCode());
t.setShares(shares);
t.setNote(note);
if (grossAmount != null)
t.addUnit(grossAmount);
if (fees != null && fees.longValue() != 0)
t.addUnit(new Unit(Unit.Type.FEE, Money.of(amount.getCurrencyCode(), Math.abs(fees))));
if (taxes != null && taxes.longValue() != 0)
t.addUnit(new Unit(Unit.Type.TAX, Money.of(amount.getCurrencyCode(), Math.abs(taxes))));
if (grossAmount == null)
createGrossValueIfNecessary(rawValues, field2column, t);
return new TransactionItem(t);
}
use of name.abuchen.portfolio.model.Transaction.Unit in project portfolio by buchen.
the class CSVPortfolioTransactionExtractor method createBuySell.
private Item createBuySell(String[] rawValues, Map<String, Column> field2column, Type type, Security security, Money amount, Long fees, Long taxes, LocalDateTime date, String note, Long shares, Unit grossAmount) throws ParseException {
BuySellEntry entry = new BuySellEntry();
entry.setType(type);
entry.setSecurity(security);
entry.setDate(date);
entry.setAmount(Math.abs(amount.getAmount()));
entry.setCurrencyCode(amount.getCurrencyCode());
entry.setShares(shares);
entry.setNote(note);
if (grossAmount != null)
entry.getPortfolioTransaction().addUnit(grossAmount);
if (fees != null && fees.longValue() != 0)
entry.getPortfolioTransaction().addUnit(new Unit(Unit.Type.FEE, Money.of(amount.getCurrencyCode(), Math.abs(fees))));
if (taxes != null && taxes.longValue() != 0)
entry.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(amount.getCurrencyCode(), Math.abs(taxes))));
if (grossAmount == null)
createGrossValueIfNecessary(rawValues, field2column, entry.getPortfolioTransaction());
return new BuySellEntryItem(entry);
}
use of name.abuchen.portfolio.model.Transaction.Unit in project portfolio by buchen.
the class BaaderBankPDFExtractor method addBuyTransaction.
@SuppressWarnings("nls")
private void addBuyTransaction() {
DocumentType type = new DocumentType("Wertpapierabrechnung: Kauf");
this.addDocumentTyp(type);
Block block = new Block("Scalable Capital .*");
type.addBlock(block);
block.set(new Transaction<BuySellEntry>().subject(() -> {
BuySellEntry entry = new BuySellEntry();
entry.setType(PortfolioTransaction.Type.BUY);
return entry;
}).section("isin", "wkn", "name").match("Nominale *ISIN: *(?<isin>[^ ]*) *WKN: *(?<wkn>[^ ]*) *Kurs *").match("STK [^ ]* (?<name>.*) EUR [\\d.,]+,\\d{2,}+").assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))).section("shares").match("STK *(?<shares>[\\.\\d]+[,\\d]*) .*").assign((t, v) -> t.setShares(asShares(v.get("shares")))).section("date", "amount", "currency").match("Zu Lasten Konto \\d+ Valuta: \\d+\\.\\d+\\.\\d{4} *(?<currency>\\w{3}) *(?<amount>[\\d.]+,\\d{2})").find("Handelsdatum Handelsuhrzeit").match("^(?<date>\\d+\\.\\d+\\.\\d{4}) \\d{2}:\\d{2}:\\d{2}:\\d{2}$").assign((t, v) -> {
t.setDate(asDate(v.get("date")));
t.setCurrencyCode(asCurrencyCode(v.get("currency")));
t.setAmount(asAmount(v.get("amount")));
}).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)));
}
Aggregations