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

feat: add YNAP parsing to transaction import #1044

Merged
merged 3 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -97,9 +108,9 @@ jobs:
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: true
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
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ WORKDIR /app
# copy package.json first to avoid unnecessary npm install when other files change
# Unless packages change, this layer will be cached
COPY package.json package-lock.json /app/
RUN npm install
COPY patches /app/patches

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
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from 'cypress'

export default defineConfig({
video: true,
e2e: {
baseUrl: 'http://localhost:3000',
supportFile: 'cypress/support/e2e.ts',
Expand Down
44 changes: 38 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,45 @@ 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(
'This file has already been parsed. Please upload the CSV file from your bank.'
)
})

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('This file can not be parsed.')
})
})
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,
6 changes: 6 additions & 0 deletions docker-compose-production.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
version: '3'

volumes:
ez-production-data:

services:
backend:
image: ghcr.io/envelope-zero/backend:v3.1.1
volumes:
- ez-production-data:/data
environment:
API_URL: http://localhost:3001/api
CORS_ALLOW_ORIGINS: http://localhost:3001
Expand Down
Loading