From 2ef641ab5e4fb0e2123178f2a209bcb0e47e6108 Mon Sep 17 00:00:00 2001 From: Nirus2000 Date: Wed, 20 Mar 2024 20:45:18 +0100 Subject: [PATCH] Improve Banque Pictet & Cie SA PDF-Importer Format source to standard eclipse format Improve regulare expressions Remove obsolet source --- .../pdf/PictetCieGruppeSAPDFExtractor.java | 371 ++++++++++-------- 1 file changed, 208 insertions(+), 163 deletions(-) diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/PictetCieGruppeSAPDFExtractor.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/PictetCieGruppeSAPDFExtractor.java index afd0cc9433..f0f968d39a 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/PictetCieGruppeSAPDFExtractor.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/pdf/PictetCieGruppeSAPDFExtractor.java @@ -39,105 +39,125 @@ private void addBuySellTransaction() this.addDocumentTyp(type); Transaction pdfTransaction = new Transaction<>(); - pdfTransaction.subject(() -> { - BuySellEntry entry = new BuySellEntry(); - entry.setType(PortfolioTransaction.Type.BUY); - return entry; - }); Block firstRelevantLine = new Block("^Transaction no\\.: .*$"); type.addBlock(firstRelevantLine); firstRelevantLine.set(pdfTransaction); - pdfTransaction - // Is type --> "Sale" change from BUY to SELL - .section("type").optional() - .match("^(?(Purchase|Sale)) (\\-)?[\\.'\\d]+ .* [\\w]{3} [\\.'\\d]+$") - .assign((t, v) -> { - if ("Sale".equals(v.get("type"))) - t.setType(PortfolioTransaction.Type.SELL); - }) - - // Is type --> "Sale" change from BUY to SELL - .section("type").optional() - .match("^(?(Purchase|Sale)) [\\w]{3} (\\-)?[\\.'\\d]+ .* [\\.'\\d]+%$") - .assign((t, v) -> { - if ("Sale".equals(v.get("type"))) - t.setType(PortfolioTransaction.Type.SELL); - }) - - // @formatter:off - // Purchase 24'728.000 PIMCO GIS-GL.LO.DUR.R/R INS.USD-ACC at USD 11.97 - // ISIN: IE00BHZKQ946 Telekurs ID: 23335253 Value date 25.05.2022Booking date 24.05.2022 - // @formatter:on - .section("name", "isin", "currency").optional() .match("^(Purchase|Sale) (\\-)?[\\.'\\d]+ (?.*) at (?[\\w]{3}) [\\.'\\d]+$") - .match("^ISIN: (?[A-Z]{2}[A-Z0-9]{9}[0-9]) .*$") - .assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))) - - // @formatter:off - // Purchase GBP 180'000 6.516% MS (SX5E/SPX) 22/23 at 100.00% - // ISIN: XS2425022303 Telekurs ID: 110605684 Value date 28.03.2022Booking date 25.03.2022 - // @formatter:on - .section("name", "isin", "currency").optional() - .match("^(Purchase|Sale) (?[\\w]{3}) (\\-)?[\\.'\\d]+ (?.*) at [\\.'\\d]+%$") - .match("^ISIN: (?[A-Z]{2}[A-Z0-9]{9}[0-9]) .*$") - .assign((t, v) -> t.setSecurity(getOrCreateSecurity(v))) - - .oneOf( - // @formatter:off - // Purchase 24'728.000 PIMCO GIS-GL.LO.DUR.R/R INS.USD-ACC at USD 11.97 - // Sale -74.620 AGIF-CHINA A-SHARES PT GBP-ACC. at GBP 1'565.99 - // @formatter:on - section -> section - .attributes("shares") - .match("^(Purchase|Sale) (\\-)?(?[\\.'\\d]+) .* at [\\w]{3} [\\.'\\d]+$") - .assign((t, v) -> t.setShares(asShares(v.get("shares")))) - , - // @formatter:off - // Purchase GBP 180'000 6.516% MS (SX5E/SPX) 22/23 at 100.00% - // @formatter:on - section -> section - .attributes("shares") - .match("^(Purchase|Sale) [\\w]{3} (\\-)?(?[\\.'\\d]+) (?.*) at [\\.'\\d]+%$") - .assign((t, v) -> { - // Percentage quotation, workaround for bonds - BigDecimal shares = asExchangeRate(v.get("shares")); - t.setShares(Values.Share.factorize(shares.doubleValue() / 100)); - }) - ) - - // Order date 20.05.2022 at 05:06:32 pm - .section("date", "time") - .match("^Order date (?[\\d]{2}\\.[\\d]{2}\\.[\\d]{4}) at (?