Skip to content

Commit

Permalink
feat: add YNAP parsing to transaction import
Browse files Browse the repository at this point in the history
This adds YNAP parsing to transaction importing, removing the need to
parse the file in the YNAP web app before uploading it to Envelope Zero.

Co-Authored-By: Fynn Heintz <[email protected]>
Co-Authored-By: Morre <[email protected]>
  • Loading branch information
morremeyer and malfynnction committed Sep 2, 2023
1 parent 5e66312 commit ffd66b4
Show file tree
Hide file tree
Showing 12 changed files with 1,137 additions and 1,689 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,30 @@ env:
jobs:
pre-commit:
runs-on: ubuntu-latest
permissions:
packages: read

steps:
- uses: actions/[email protected]

- name: Cache dependencies
uses: actions/[email protected]
with:
node-version: '16'
node-version: '20'
cache: 'npm'

- name: set npm auth
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc

- name: install node modules
run: npm ci

- uses: pre-commit/[email protected]

cypress:
runs-on: ubuntu-latest
permissions:
packages: read

# Current backend version as service container
services:
Expand All @@ -44,6 +52,9 @@ jobs:
steps:
- uses: actions/[email protected]

- name: set npm auth
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc

- uses: cypress-io/[email protected]
with:
start: npm run start-ci
Expand Down Expand Up @@ -93,9 +104,9 @@ jobs:
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: ${{ contains('refs/tags/', github.ref) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VITE_VERSION=${{ github.ref_name }}
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@envelope-zero:registry=https://npm.pkg.github.com
7 changes: 4 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ Contributions are welcome. Please note the [Code of Conduct](CODE_OF_CONDUCT.md)

## Tool & Repository setup

You will need the following tools:
You will need to:

- [pre-commit](https://pre-commit.com/)
- Install [pre-commit](https://pre-commit.com/)
- Set up a GitHub Personal Access Token to read from the GitHub package repository. Follow the steps in https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-with-a-personal-access-token.

Once those are installed, run `make setup` to perform the repository setup.
Once these steps are done, run `make setup` to perform the repository setup.

## Development server

Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ WORKDIR /app

# copy package.json first to avoid unnecessary npm install
COPY package.json package-lock.json /app/
RUN npm install

ARG GITHUB_TOKEN
RUN echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> ~/.npmrc && \
npm install --production

# Copy app files
COPY src /app/src
Expand Down
42 changes: 36 additions & 6 deletions cypress/e2e/transaction-import.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ describe('Transaction Import', () => {
cy.contains('My Other Account')
cy.contains('My Account').click()

cy.getInputFor('File').selectFile(
'cypress/fixtures/transactions-parsed.csv'
)
cy.getInputFor('File').selectFile('cypress/fixtures/comdirect.csv')

cy.clickAndWait('Submit')

Expand Down Expand Up @@ -163,11 +161,43 @@ describe('Transaction Import', () => {
cy.awaitLoading()

cy.getInputFor('Account').type('My account{enter}')
cy.getInputFor('File').selectFile(
'cypress/fixtures/transactions-parsed.csv'
)
cy.getInputFor('File').selectFile('cypress/fixtures/comdirect.csv')

cy.clickAndWait('Submit')
cy.contains('This is a duplicate of an existing transaction')
})

it('errors on already parsed file', function () {
cy.get('nav').contains('Transactions').click()
cy.getByTitle('Import Transactions').click()
cy.awaitLoading()

cy.getInputFor('Account').type('account')
cy.contains('External Account').should('not.exist')
cy.contains('My Other Account')
cy.contains('My Account').click()

cy.getInputFor('File').selectFile('cypress/fixtures/comdirect-ynap.csv')

cy.contains('Submit').click()
cy.contains('Error: This file has already been converted')
})

it('errors on an unparseable file', function () {
cy.get('nav').contains('Transactions').click()
cy.getByTitle('Import Transactions').click()
cy.awaitLoading()

cy.getInputFor('Account').type('account')
cy.contains('External Account').should('not.exist')
cy.contains('My Other Account')
cy.contains('My Account').click()

cy.getInputFor('File').selectFile(
'cypress/fixtures/transactions-no-parser.csv'
)

cy.contains('Submit').click()
cy.contains('Error: No parser is available for this file')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Date,Payee,Memo,Outflow,Inflow
06/20/2023,Non Existing Account,Text,84.76,
06/19/2023,My Other Account,Transfer from my other account,,5.00
06/16/2023,New Account,REDACTED,784.94,
06/15/2023,External Account,Text,52.03,
06/15/2023,External Account,Text,52.03,
11 changes: 11 additions & 0 deletions cypress/fixtures/comdirect.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
;
"Umsätze Verrechnungskonto ";"Zeitraum: 30 Tage";
"Neuer Kontostand";"16,94 EUR";

"Buchungstag";"Wertstellung (Valuta)";"Vorgang";"Buchungstext";"Umsatz in EUR";
"20.06.2023";"20.06.2023";"Irrevevant";"Empfänger: Non Existing Account Buchungstext: Text Ref. 000000000/0 ";"-84,76";
"19.06.2023";"19.06.2023";"Irrevevant";"Auftraggeber: My Other Account Buchungstext: Transfer from my other account Ref. 0000000000000/0 ";"5,00";
"16.06.2023";"16.06.2023";"Irrevevant";"Empfänger: New Account Buchungstext: REDACTED Ref. 000000000/0 ";"-784,94";
"15.06.2023";"15.06.2023";"Irrevevant";"Auftraggeber: External Account Buchungstext: Text Ref. 000000000/0 ";"-52,03";

"Alter Kontostand";"16,89 EUR";
5 changes: 5 additions & 0 deletions cypress/fixtures/transactions-no-parser.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Date,Payee,Memo,Outflow,Inflow
06/20/2023,Non Existing Account,Text,84.76,
06/19/2023,My Other Account,Transfer from my other account,,5.00
06/16/2023,New Account,REDACTED,784.94,
06/15/2023,External Account,Text,52.03,
Loading

0 comments on commit ffd66b4

Please sign in to comment.