Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CetesDirecto PDF Extractor #4511

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

jonathlan
Copy link
Contributor

Issue: https://forum.portfolio-performance.info/t/pdf-import-from-cetesdirecto/31306

Add initial implementation to import CetesDirecto PDF which was not there before.
This required a new date format "dd/MM/yy" and MXN currency type for Mexico.

@Nirus2000 Nirus2000 added the pdf label Feb 6, 2025
@Nirus2000 Nirus2000 self-assigned this Feb 6, 2025
buchen pushed a commit that referenced this pull request Feb 23, 2025
Issue: #4511
Signed-off-by: Jonathan <[email protected]>
[squashed commits; use latest matcher for test; removed global variable
CurrencyUnit.MXN; rebased to master]
Signed-off-by: Andreas Buchen <[email protected]>
buchen added a commit that referenced this pull request Feb 23, 2025
Copy link
Member

@buchen buchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jonathlan for your contribution.
I have merged the change (with some minor refactoring)

// addFeesSectionsTransaction(pdfTransaction, type);
}

private <T extends Transaction<?>> void addTaxesSectionsTransaction(T transaction, DocumentType type)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is never used locally.

Comment on lines +63 to +81
BuySellEntry entry = (BuySellEntry) results.stream().filter(BuySellEntryItem.class::isInstance).findFirst()
.orElseThrow(IllegalArgumentException::new).getSubject();

assertThat(entry.getPortfolioTransaction().getType(), is(PortfolioTransaction.Type.BUY));
assertThat(entry.getAccountTransaction().getType(), is(AccountTransaction.Type.BUY));

assertThat(entry.getPortfolioTransaction().getDateTime(), is(LocalDateTime.parse("2022-01-06T00:00:00")));
assertThat(entry.getPortfolioTransaction().getShares(), is(Values.Share.factorize(6080)));
assertThat(entry.getSource(), is("EdoCta01.txt"));
assertThat(entry.getNote(), is("ID:SVD147529623 Series:220203 Term:2 Rate:5.51"));

assertThat(entry.getPortfolioTransaction().getMonetaryAmount(),
is(Money.of(CurrencyUnit.MXN, Values.Amount.factorize(60540.38))));
assertThat(entry.getPortfolioTransaction().getGrossValue(),
is(Money.of(CurrencyUnit.MXN, Values.Amount.factorize(60540.38))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.TAX),
is(Money.of(CurrencyUnit.MXN, Values.Amount.factorize(0.00))));
assertThat(entry.getPortfolioTransaction().getUnitSum(Unit.Type.FEE),
is(Money.of(CurrencyUnit.MXN, Values.Amount.factorize(0.00))));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We created custom matcher that make these kinds of tests easier to write and easier to read. I have refactored the code accordingly.

@buchen buchen closed this Feb 23, 2025
@buchen buchen reopened this Feb 23, 2025
@Nirus2000 Nirus2000 marked this pull request as draft February 23, 2025 10:18
@Nirus2000
Copy link
Member

Nirus2000 commented Feb 23, 2025

Hello @jonathlan
We prefer individual statements for PDF import, as we have repeatedly found that important content is missing from collective statements. Sometimes taxes are missing, sometimes fees or even withholding taxes. Missing information such as transaction numbers is also problematic. If possible, we add these to the notes.

Another problem with collective statements is that it is not clear in which currency the security is held. This leads to further difficulties, especially with dividend payments. There is also the problem that the import is made in dollars, although the settlement is made in another currency, which leads to incorrect results.

Hence our request: Create the individual statements as an importer. Alternatively, PDF debugs can be posted in the forum in a corresponding thread.

Regards
Alex :-)

Set commit to draft

@jonathlan
Copy link
Contributor Author

Thanks @Nirus2000 !

I just double checked but this is the only type of PDF I can get from CetesDirecto. I was not aware this was a collective statement.
But what can we do if I don't have any other format?

I tried to convert it to csv, but the buy and sales operations have different columns, hence requires a lot of manual work. That's what encouraged me to develop the importer.

Thank a lot!

@Nirus2000
Copy link
Member

Hello @jonathlan
If it's possible to write an email to your Broker to ask for individual statements in pdf for transactions?! (Share the answer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Code changes requested
Development

Successfully merging this pull request may close these issues.

3 participants