diff --git a/name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/quirinbankag/QuirinPrivatbankAGPDFExtractorTest.java b/name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/quirinbankag/QuirinPrivatbankAGPDFExtractorTest.java index 6c74f08d94..4ca7ad317a 100644 --- a/name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/quirinbankag/QuirinPrivatbankAGPDFExtractorTest.java +++ b/name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/pdf/quirinbankag/QuirinPrivatbankAGPDFExtractorTest.java @@ -280,7 +280,7 @@ public void testWertpapierKauf04() // check taxes transaction assertThat(results, hasItem(taxes( // - hasDate("2014-03-10T00:00"), hasShares(0.1320), // + hasDate("2014-03-10T00:00"), hasShares(0.1318), // hasSource("Kauf04.txt"), // hasNote("Zwischengewinn 0,17 EUR | Ref.-Nr.: O:002831939:1"), // hasAmount("EUR", 0.05), hasGrossValue("EUR", 0.05), // diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/DZBankGruppePDFExtractor.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/DZBankGruppePDFExtractor.java index 66e08716ef..0a27e278fc 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/DZBankGruppePDFExtractor.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/DZBankGruppePDFExtractor.java @@ -72,15 +72,15 @@ private void addBuySellTransaction() final DocumentType type = new DocumentType("Wertpapier Abrechnung (Kauf|Verkauf)", jointAccount); this.addDocumentTyp(type); - // Handshake for tax refund transaction - Map context = type.getCurrentContext(); - Transaction pdfTransaction = new Transaction<>(); Block firstRelevantLine = new Block("^Wertpapier Abrechnung (Kauf|Verkauf).*$"); type.addBlock(firstRelevantLine); firstRelevantLine.set(pdfTransaction); + // Map for tax lost adjustment transaction + Map context = type.getCurrentContext(); + pdfTransaction // .subject(() -> { @@ -112,11 +112,6 @@ private void addBuySellTransaction() v.put("name", trim(v.get("name")) + " " + trim(v.get("name1"))); t.setSecurity(getOrCreateSecurity(v)); - - // Handshake, if there is a tax refund - context.put("name", v.get("name")); - context.put("isin", v.get("isin")); - context.put("wkn", v.get("wkn")); }) // @formatter:off @@ -124,12 +119,7 @@ private void addBuySellTransaction() // @formatter:on .section("shares") // .match("^St.ck (?[\\.,\\d]+) .*$") // - .assign((t, v) -> { - t.setShares(asShares(v.get("shares"))); - - // Handshake, if there is a tax refund - context.put("shares", v.get("shares")); - }) + .assign((t, v) -> t.setShares(asShares(v.get("shares")))) // @formatter:off // Schlusstag/-Zeit 17.02.2021 09:04:10 Auftraggeber Max Mustermann @@ -158,11 +148,24 @@ private void addBuySellTransaction() .match("^(?(Limit|Stoplimit) .*)$") // .assign((t, v) -> t.setNote(trim(v.get("note")))) - .wrap(BuySellEntryItem::new); + .wrap(t -> { + BuySellEntryItem item = new BuySellEntryItem(t); + + // @formatter:off + // Handshake for tax lost adjustment transaction + // Also use number for that is also used to (later) convert it back to a number + // @formatter:on + context.put("name", item.getSecurity().getName()); + context.put("isin", item.getSecurity().getIsin()); + context.put("wkn", item.getSecurity().getWkn()); + context.put("shares", Long.toString(item.getShares())); + + return item; + }); addTaxesSectionsTransaction(pdfTransaction, type); addFeesSectionsTransaction(pdfTransaction, type); - addTaxReturnBlock(context, type); + addTaxLostAdjustmentTransaction(context, type); } private void addDividendeTransaction() @@ -954,7 +957,7 @@ public void addDepotStatementTransaction() }); } - private void addTaxReturnBlock(Map context, DocumentType type) + private void addTaxLostAdjustmentTransaction(Map context, DocumentType type) { Transaction pdfTransaction = new Transaction<>(); @@ -979,11 +982,11 @@ private void addTaxReturnBlock(Map context, DocumentType type) .match("^Den Gegenwert buchen wir mit Valuta (?[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}) .*$") // .assign((t, v) -> { t.setDateTime(asDate(v.get("date"))); - t.setCurrencyCode(asCurrencyCode(v.get("currency"))); - t.setAmount(asAmount(v.get("amount"))); - t.setShares(asShares(context.get("shares"))); - + t.setShares(Long.parseLong(context.get("shares"))); t.setSecurity(getOrCreateSecurity(context)); + + t.setCurrencyCode(asCurrencyCode(v.get("currency"))); + t.setAmount(asAmount(v.get("amount"))); }) // @formatter:off diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/Direkt1822BankPDFExtractor.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/Direkt1822BankPDFExtractor.java index ca4c472459..b10bb4edc3 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/Direkt1822BankPDFExtractor.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/Direkt1822BankPDFExtractor.java @@ -6,6 +6,7 @@ import static name.abuchen.portfolio.util.TextUtil.trim; import java.math.BigDecimal; +import java.util.Map; import name.abuchen.portfolio.Messages; import name.abuchen.portfolio.datatransfer.ExtrExchangeRate; @@ -40,7 +41,6 @@ public Direkt1822BankPDFExtractor(Client client) addBuySellTransaction(); addDividendeTransaction(); addAdvanceTaxTransaction(); - addTaxesLostAdjustmentTransaction(); addAccountStatementTransaction(); addNonImportableTransaction(); } @@ -62,6 +62,9 @@ private void addBuySellTransaction() type.addBlock(firstRelevantLine); firstRelevantLine.set(pdfTransaction); + // Map for tax lost adjustment transaction + Map context = type.getCurrentContext(); + pdfTransaction // .subject(() -> { @@ -161,10 +164,24 @@ private void addBuySellTransaction() .conclude(ExtractorUtils.fixGrossValueBuySell()) - .wrap(BuySellEntryItem::new); + .wrap(t -> { + BuySellEntryItem item = new BuySellEntryItem(t); + + // @formatter:off + // Handshake for tax lost adjustment transaction + // Also use number for that is also used to (later) convert it back to a number + // @formatter:on + context.put("name", item.getSecurity().getName()); + context.put("isin", item.getSecurity().getIsin()); + context.put("wkn", item.getSecurity().getWkn()); + context.put("shares", Long.toString(item.getShares())); + + return item; + }); addTaxesSectionsTransaction(pdfTransaction, type); addFeesSectionsTransaction(pdfTransaction, type); + addTaxLostAdjustmentTransaction(context, type); } private void addDividendeTransaction() @@ -319,15 +336,8 @@ private void addAdvanceTaxTransaction() .wrap(TransactionItem::new); } - private void addTaxesLostAdjustmentTransaction() + private void addTaxLostAdjustmentTransaction(Map context, DocumentType type) { - DocumentType type = new DocumentType("(Wertpapier Abrechnung (Verkauf|(Ausgabe|R.cknahme) Investmentfonds)" // - + "|Gutschrift von .*" // - + "|Aussch.ttung Investmentfonds" // - + "|Aussch.ttung aus Genussschein" // - + "|Dividendengutschrift)"); - this.addDocumentTyp(type); - Transaction pdfTransaction = new Transaction<>(); Block firstRelevantLine = new Block("^Postfach.*$"); @@ -342,99 +352,24 @@ private void addTaxesLostAdjustmentTransaction() return accountTransaction; }) - .oneOf( // - // @formatter:off - // Stück 13 COMSTA.-MSCI EM.MKTS.TRN U.ETF LU0635178014 (ETF127) - // INHABER-ANTEILE I O.N. - // Börse Außerbörslich (gemäß Weisung) - // Ausführungskurs 40,968 EUR Auftragserteilung Online-Banking - // @formatter:on - section -> section // - .attributes("name", "isin", "wkn", "name1", "currency") // - .match("^St.ck [\\.,\\d]+ (?.*) (?[A-Z]{2}[A-Z0-9]{9}[0-9]) \\((?[A-Z0-9]{6})\\)$") // - .match("(?.*)$") // - .match("^Ausf.hrungskurs [\\.,\\d]+ (?[\\w]{3}) .*$") // - .assign((t, v) -> { - if (!v.get("name1").startsWith("Börse")) - v.put("name", trim(v.get("name")) + " " + trim(v.get("name1"))); - - t.setSecurity(getOrCreateSecurity(v)); - }), - // @formatter:off - // Stück 920 ISHSIV-FA.AN.HI.YI.CO.BD U.ETF IE00BYM31M36 (A2AFCX) - // REGISTERED SHARES USD O.N. - // Zahlbarkeitstag 29.12.2017 Ertrag pro St. 0,123000000 USD - // @formatter:on - section -> section // - .attributes("name", "isin", "wkn", "nameContinued", "currency") // - .match("^St.ck [\\.,\\d]+ (?.*) (?[A-Z]{2}[A-Z0-9]{9}[0-9]) \\((?[A-Z0-9]{6})\\)$") // - .match("(?.*)") // - .match("^Zahlbarkeitstag [\\d]{2}\\.[\\d]{2}\\.[\\d]{4} (Aussch.ttung|Dividende|Ertrag) pro (St\\.|St.ck) [\\.,\\d]+ (?[\\w]{3})$") // - .assign((t, v) -> t.setSecurity(getOrCreateSecurity(v)))) - - // @formatter:off - // Stück 13 COMSTA.-MSCI EM.MKTS.TRN U.ETF LU0635178014 (ETF127) - // @formatter:on - .section("shares") // - .match("^St.ck (?[\\.,\\d]+) .* [A-Z]{2}[A-Z0-9]{9}[0-9] \\([A-Z0-9]{6}\\)$") // - .assign((t, v) -> t.setShares(asShares(v.get("shares")))) - - .oneOf( // - // @formatter:off - // Schlusstag/-Zeit 01.12.2017 10:30:52 Auftraggeber Mustermann, Max - // @formatter:on - section -> section // - .attributes("date", "time") // - .match("^Schlusstag\\/\\-Zeit (?[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}) (?