-
Notifications
You must be signed in to change notification settings - Fork 8
36-feat-card-transactions #48
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
Draft
parthux1
wants to merge
10
commits into
dhojayev:main
Choose a base branch
from
parthux1:36-feat-card-transactions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5d6e0ee
feat: add eventType for successful card transactions
parthux1 5dae3e1
feat(detector): incomplete detector for card transactions.
parthux1 f19e81c
chore: add const type and string definition
parthux1 32d511c
feat(InstrumentBuilder): extract InstrumentName for Card Payments
parthux1 74d7131
feat(ModelBuilder): add PaymentTransactionBuilder
parthux1 f6b147c
feat(CSVEntryFactory): write CardPaymentTransactions to CSV
parthux1 28fa6f5
chore: rm user name on TODO
parthux1 1a992a8
chore(PaymentTransactionModelBuilder): rm TODO since problem in quest…
parthux1 52c0b64
feat(CardPaymentTransaction)remove warning on headers "Hilfe" and "Vo…
parthux1 86e1747
chore: unfinished test case modification
parthux1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,147 @@ | ||
package fakes | ||
|
||
import "github.com/dhojayev/traderepublic-portfolio-downloader/internal/traderepublc/api/timeline/transactions" | ||
import ( | ||
"time" | ||
|
||
"github.com/dhojayev/traderepublic-portfolio-downloader/internal" | ||
"github.com/dhojayev/traderepublic-portfolio-downloader/internal/filesystem" | ||
"github.com/dhojayev/traderepublic-portfolio-downloader/internal/traderepublc/api/timeline/details" | ||
"github.com/dhojayev/traderepublic-portfolio-downloader/internal/traderepublc/api/timeline/transactions" | ||
"github.com/dhojayev/traderepublic-portfolio-downloader/internal/traderepublc/portfolio/instrument" | ||
"github.com/dhojayev/traderepublic-portfolio-downloader/internal/traderepublc/portfolio/transaction" | ||
) | ||
|
||
var CardSuccessfulTransaction01 = TransactionTestCase{ | ||
TimelineTransactionsData: TimelineTransactionsTestData{ | ||
Raw: []byte(`[ | ||
{ | ||
} | ||
]`)}, | ||
TimelineDetailsData: TimelineDetailsTestData{ | ||
Raw: []byte(`{ | ||
"items": | ||
[ | ||
{ | ||
"action": { | ||
"payload": "6221f5fb-b8fa-4ad6-8c99-c3fb3c31da10", | ||
"type": "timelineDetail" | ||
"id": "f729b13a-ed08-5e48-bdde-87f17c478e48", | ||
"sections": [ | ||
{ | ||
"data": { | ||
"icon": "merchant-logos/a95de37b-f62d-42fe-b226-0d3bcae8df0c", | ||
"status": "executed", | ||
"timestamp": "2024-04-07T18:03:33.954+0000" | ||
}, | ||
"title": "Du hast 2,00 € ausgegeben", | ||
"type": "header" | ||
}, | ||
{ | ||
"data": [ | ||
{ | ||
"detail": { | ||
"functionalStyle": "EXECUTED", | ||
"text": "Fertig", | ||
"type": "status" | ||
}, | ||
"style": "plain", | ||
"title": "Status" | ||
}, | ||
"amount": { | ||
"currency": "EUR", | ||
"fractionDigits": 2, | ||
"value": -5.95 | ||
{ | ||
"detail": { | ||
"icon": "logos/bank_traderepublic/v2", | ||
"text": "··1234", | ||
"type": "iconWithText" | ||
}, | ||
"style": "plain", | ||
"title": "Zahlung" | ||
}, | ||
"badge": null, | ||
"eventType": "card_successful_transaction", | ||
"icon": "logos/merchant-45180dc7-8917-45c9-b926-6ae7b3befe28/v2", | ||
"id": "6221f5fb-b8fa-4ad6-8c99-c3fb3c31da10", | ||
"status": "EXECUTED", | ||
"subAmount": null, | ||
"subtitle": null, | ||
"timestamp": "2024-05-27T13:51:55.167+0000", | ||
"title": "Aldi" | ||
} | ||
] | ||
}`), | ||
Unmarshalled: transactions.ResponseItem{ | ||
Action: transactions.ResponseItemAction{ | ||
Payload: "6221f5fb-b8fa-4ad6-8c99-c3fb3c31da10", | ||
Type: "timelineDetail", | ||
{ | ||
"detail": { | ||
"text": "Stayery", | ||
"type": "text" | ||
}, | ||
"style": "plain", | ||
"title": "Händler" | ||
} | ||
], | ||
"title": "Übersicht", | ||
"type": "table" | ||
}, | ||
Amount: transactions.ResponseItemAmount{ | ||
Currency: "EUR", | ||
FractionDigits: 2, | ||
Value: -5.95, | ||
{ | ||
"data": [ | ||
{ | ||
"detail": { | ||
"action": { | ||
"type": "benefitsSavebackOverview" | ||
}, | ||
"amount": "0,02 €", | ||
"icon": "logos/IE0031442068/v2", | ||
"status": "executed", | ||
"subtitle": "Saveback", | ||
"timestamp": "2024-04-07T18:03:34.802+0000", | ||
"title": "Core S\u0026P 500 USD (Dist)", | ||
"type": "embeddedTimelineItem" | ||
}, | ||
"style": "plain", | ||
"title": "Core S\u0026P 500 USD (Dist)" | ||
} | ||
], | ||
"title": "Vorteile", | ||
"type": "table" | ||
}, | ||
{ | ||
"data": [ | ||
{ | ||
"detail": { | ||
"action": { | ||
"payload": { | ||
"contextCategory": "card-dispute", | ||
"contextParams": { | ||
"card-dispute-txId": "f729b13a-ed08-5e48-bdde-87f17c478e48" | ||
}, | ||
"transactionId": "f729b13a-ed08-5e48-bdde-87f17c478e48" | ||
}, | ||
"type": "customerSupportChat" | ||
}, | ||
"icon": "logos/timeline_communication/v2", | ||
"type": "listItemAvatarDefault" | ||
}, | ||
"style": "highlighted", | ||
"title": "Problem melden" | ||
} | ||
], | ||
"title": "Hilfe", | ||
"type": "table" | ||
} | ||
] | ||
}`), | ||
Normalized: details.NormalizedResponse{ | ||
ID: "f729b13a-ed08-5e48-bdde-87f17c478e48", | ||
Header: details.NormalizedResponseHeaderSection{ | ||
Data: details.NormalizedResponseHeaderSectionData{ | ||
Icon: "merchant-logos/a95de37b-f62d-42fe-b226-0d3bcae8df0c", | ||
Status: "executed", | ||
Timestamp: "2024-04-07T18:03:33.954+0000", | ||
}, | ||
Title: "Du hast 2,00 € ausgegeben", | ||
Type: "header", | ||
}, | ||
EventType: "card_successful_transaction", | ||
Icon: "logos/merchant-45180dc7-8917-45c9-b926-6ae7b3befe28/v2", | ||
ID: "6221f5fb-b8fa-4ad6-8c99-c3fb3c31da10", | ||
Status: "EXECUTED", | ||
Timestamp: "2024-05-27T13:51:55.167+0000", | ||
Title: "Aldi", | ||
}, | ||
}, | ||
TimelineDetailsData: TimelineDetailsTestData{ | ||
Raw: []byte("{}"), | ||
EventType: transactions.EventTypeCardSuccessfulTransaction, | ||
Transaction: transaction.Model{ | ||
UUID: "f729b13a-ed08-5e48-bdde-87f17c478e48", | ||
Type: transaction.TypeCardPaymentTransaction, | ||
Status: "executed", | ||
Total: 2, | ||
Instrument: instrument.Model{ | ||
Name: "Stayery", | ||
}, | ||
}, | ||
CSVEntry: filesystem.CSVEntry{ | ||
ID: "f729b13a-ed08-5e48-bdde-87f17c478e48", | ||
Debit: 2, | ||
Type: transaction.TypeCardPaymentTransaction, | ||
}, | ||
} | ||
|
||
func init() { | ||
RegisterUnsupported("CardSuccessfulTransaction01", CardSuccessfulTransaction01) | ||
CardSuccessfulTransaction01.Transaction.Timestamp, _ = time.Parse(details.ResponseTimeFormat, "2024-04-07T18:03:33.954+0000") | ||
CardSuccessfulTransaction01.CSVEntry.Timestamp = internal.DateTime{Time: CardSuccessfulTransaction01.Transaction.Timestamp} | ||
RegisterSupported("CardSuccessfulTransaction01", CardSuccessfulTransaction01) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to this you are expecting to have 3 columns to be filled-in in the CSV file. Is that correct? I finally understand the purpose of these changes and have a many doubts if this even should be here.
The original idea of the
transactions.csv
file is to contain transactions related to the depot. Card transactions will simply pollute the data in the csv file. I am ready to accept it if we will put this functionality under some argument that can be passed to enable it. Otherwise I would not like to have all card transactions in the same file where I track my depot changes.If you agree to put this behind an argument we can do it either by me adding support of custom arguments that can be passed to enable "extra functionality" or you adding it yourself.
Or we can have a separate file for that which would require more changes in the code but in the end sounds like a cleaner solution. Plus, we don't have to normalize all card transactions to asset transactions, since card transactions don't have fields such as "instrument", "ISIN", etc.
Let me know which approach we shall take and I can support you with coding if needed. But again, adding all card transactions among asset transactions sounds like a bad idea to me.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry about any delays. I'm currently not in a hurry to implement this feature (i'm going to do it, but at some days I'm just not in the mood 😓)
the following columns of the CSV are currently filled:
ID, Debit, Type are currently set in the class instantiation. Timestamp is set in the init-call in ln. 145
Status and Name are in fact missing 😓
Let's write card transaction related to the credit card in a separate CSV only containing the designated fields.
maybe a lot of the code will work out of the box if we update the writer to accept a CSVEntryInterface where the implementations contain different fields?
Adding fields as an dynamic field by using e.g. a map would probably be easier, but you'd loose easy strong typing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I finally found some time to work on this :)
Let me check what we can do to write card transactions into a separate csv file. I will report back shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I checked it. It requires some changes. I need to rewrite the way data is being written into a CSV file. It is currently written in a way that it is not easy to write into another csv file using different structure. I will create a branch in my repo and a PR and will keep you posted about the progress. Once we merge my changes we can adapt yours to utilize writing into another csv file using a structure that is more suitable for card transactions.