Compare commits

...

40 Commits

Author SHA1 Message Date
5d73b337aa 1.0.28
Some checks failed
Default (tags) / security (push) Failing after 13s
Default (tags) / test (push) Failing after 13s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2024-07-05 11:04:47 +02:00
aa8fd8b47d fix(documentation): Updated documentation in readme.md 2024-07-05 11:04:46 +02:00
2bc50c6714 1.0.27
Some checks failed
Default (tags) / security (push) Failing after 24s
Default (tags) / test (push) Failing after 16s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2024-07-02 23:20:45 +02:00
3f8e2045e5 fix(core): Fix npm package availability links and status badges in readme.md 2024-07-02 23:20:45 +02:00
da6676fdc1 1.0.26
Some checks failed
Default (tags) / security (push) Failing after 26s
Default (tags) / test (push) Failing after 17s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2024-07-02 23:16:45 +02:00
96d50962ea fix(core): Update package.json dependencies and metadata 2024-07-02 23:16:44 +02:00
5377a91cfd 1.0.25
Some checks failed
Default (tags) / security (push) Failing after 24s
Default (tags) / test (push) Failing after 18s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2023-11-17 12:31:37 +01:00
71f8dc7685 fix(core): update 2023-11-17 12:31:36 +01:00
44de2dadab 1.0.24
Some checks failed
Default (tags) / security (push) Failing after 23s
Default (tags) / test (push) Failing after 20s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2023-11-16 18:56:50 +01:00
d848387715 fix(core): update 2023-11-16 18:56:49 +01:00
0d9d365673 1.0.23
Some checks failed
Default (tags) / security (push) Failing after 22s
Default (tags) / test (push) Failing after 21s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2023-11-16 18:54:35 +01:00
e731e017bb fix(core): update 2023-11-16 18:54:35 +01:00
834ba90170 1.0.22
Some checks failed
Default (tags) / security (push) Failing after 22s
Default (tags) / test (push) Failing after 22s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2023-11-16 16:47:44 +01:00
d78183e596 fix(core): update 2023-11-16 16:47:43 +01:00
82d30a93c8 1.0.21
Some checks failed
Default (tags) / security (push) Failing after 21s
Default (tags) / test (push) Failing after 22s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2023-11-16 16:47:15 +01:00
51d894cba7 fix(core): update 2023-11-16 16:47:14 +01:00
bef9349216 1.0.20
Some checks failed
Default (tags) / security (push) Failing after 18s
Default (tags) / test (push) Failing after 24s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2023-11-16 02:22:02 +01:00
2017634f87 fix(core): update 2023-11-16 02:22:01 +01:00
56460edeb2 1.0.19
Some checks failed
Default (tags) / security (push) Failing after 19s
Default (tags) / test (push) Failing after 24s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2023-11-16 02:19:10 +01:00
e2851b36d0 fix(core): update 2023-11-16 02:19:09 +01:00
7f9ef12b61 1.0.18
Some checks failed
Default (tags) / security (push) Failing after 16s
Default (tags) / test (push) Failing after 24s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2023-11-16 02:11:26 +01:00
d3e39fcdf2 fix(core): update 2023-11-16 02:11:25 +01:00
f79c03afc5 1.0.17
Some checks failed
Default (tags) / security (push) Failing after 19s
Default (tags) / test (push) Failing after 24s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2023-11-16 02:10:55 +01:00
804d7f51f9 fix(core): update 2023-11-16 02:10:54 +01:00
e5cae293eb 1.0.16
Some checks failed
Default (tags) / security (push) Failing after 17s
Default (tags) / test (push) Failing after 25s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2023-11-16 02:09:48 +01:00
49bc354d01 fix(core): update 2023-11-16 02:09:48 +01:00
c7ce7af521 1.0.15 2021-04-16 20:28:50 +00:00
84c6a599ac fix(core): update 2021-04-16 20:28:49 +00:00
64e334761e 1.0.14 2021-04-15 01:06:42 +00:00
d2014b8e96 fix(core): update 2021-04-15 01:06:42 +00:00
fd3932976d 1.0.13 2021-04-15 01:06:14 +00:00
c0539be66e fix(core): update 2021-04-15 01:06:14 +00:00
00e5a96f05 1.0.12 2021-04-15 00:59:57 +00:00
53aada4638 fix(core): update 2021-04-15 00:59:56 +00:00
9724813028 1.0.11 2019-07-07 22:57:13 +02:00
e5b39e0709 fix(core): update 2019-07-07 22:57:12 +02:00
12242006aa 1.0.10 2019-07-07 18:10:57 +02:00
2e0164eaf0 fix(core): update 2019-07-07 18:10:57 +02:00
163f4c0154 1.0.9 2019-07-07 17:24:30 +02:00
7afcabf3f9 fix(core): add Base class for csv Parsers 2019-07-07 17:24:29 +02:00
28 changed files with 6458 additions and 1774 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
dist_*/
# custom

View File

@ -1,16 +1,16 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
- security
- test
- release
- metadata
# ====================
# security stage
@ -18,102 +18,114 @@ stages:
mirror:
stage: security
script:
- npmci git mirror
- npmci git mirror
only:
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
snyk:
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
- notpriv
- docker
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
# ====================
# test stage
# ====================
testLTS:
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
- docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
- docker
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
- npmci node install stable
- npmci npm publish
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
only:
- tags
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- docker
- priv
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
- npmci trigger
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npm install -g @gitzone/tsdoc
- npmci node install lts
- npmci command npm install -g @git.zone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
@ -121,5 +133,5 @@ pages:
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

1
.npmrc Normal file
View File

@ -0,0 +1 @@
registry=https://verdaccio.nevermind.cloud

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

50
changelog.md Normal file
View File

@ -0,0 +1,50 @@
# Changelog
## 2024-07-05 - 1.0.28 - fix(documentation)
Updated documentation in readme.md
- Fixed and elaborated on the installation steps for npm and yarn.
- Added usage examples and interfaces overview sections.
- Included sections on advanced usage scenarios like handling multiple CSV files, transaction filtering and aggregation.
## 2024-07-02 - 1.0.27 - fix(core)
Fix npm package availability links and status badges in readme.md
- Updated npm, GitLab, and GitHub links in readme.md.
- Enhanced status badges for clearer visibility.
## 2024-07-02 - 1.0.26 - fix(core)
Update package.json dependencies and metadata
- Updated devDependencies versions in package.json
## 2023-11-17 - 1.0.25 - core
Fixes and updates to the core functionalities.
- update
## 2023-11-16 - 1.0.15 to 1.0.24 - core
Series of fixes and updates to the core functionalities.
- update
## 2021-04-16 - 1.0.11 to 1.0.15 - core
Series of fixes and updates to the core functionalities.
- update
## 2019-07-07 - 1.0.8 - core
Fixes and added new features related to CSV parsing.
- add Base class for CSV Parsers
## 2019-06-24 - 1.0.5 to 1.0.7 - core
Series of fixes and updates to the core functionalities.
- update
## 2019-05-23 - 1.0.1 to 1.0.4 - core
Initial series of updates and fixes following project launch.
- update

View File

@ -1,4 +1,4 @@
Copyright (c) 2019 Lossless GmbH (hello@lossless.com)
Copyright (c) 2019 Task Venture Capital GmbH (hello@task.vc)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,13 +1,23 @@
{
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "financeplus",
"gitrepo": "finplus-interfaces",
"shortDescription": "an interface package for the financeplus organization",
"npmPackagename": "@financeplus/finplus-interfaces",
"gitscope": "fin.cx",
"gitrepo": "portablefinance",
"description": "An interface package for handling financial transactions and account data within the financeplus organization.",
"npmPackagename": "@fin.cx/portablefinance",
"license": "MIT",
"projectDomain": "finance.plus"
"projectDomain": "fin.cx",
"keywords": [
"finance",
"financial transactions",
"payment accounts",
"interfaces",
"vouchers",
"csv",
"typescript"
]
}
},
"npmci": {

1644
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +1,55 @@
{
"name": "@financeplus/finplus-interfaces",
"version": "1.0.8",
"name": "@fin.cx/portablefinance",
"version": "1.0.28",
"private": false,
"description": "an interface package for the financeplus organization",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"description": "An interface package for handling financial transactions and account data within the financeplus organization.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)",
"format": "(gitzone format)"
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.11.7",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0"
"@git.zone/tsbuild": "^2.1.25",
"@git.zone/tsrun": "^1.2.46",
"@git.zone/tstest": "^1.0.52",
"@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^20.9.0"
},
"dependencies": {}
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
],
"repository": {
"type": "git",
"url": "git+https://gitlab.com/fin.cx/portablefinance.git"
},
"bugs": {
"url": "https://gitlab.com/fin.cx/portablefinance/issues"
},
"homepage": "https://gitlab.com/fin.cx/portablefinance#readme",
"type": "module",
"keywords": [
"finance",
"financial transactions",
"payment accounts",
"interfaces",
"vouchers",
"csv",
"typescript"
]
}

5701
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

0
readme.hints.md Normal file
View File

245
readme.md
View File

@ -1,26 +1,235 @@
# @financeplus/finplus-interfaces
# @fin.cx/portablefinance
an interface package for the financeplus organization
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@financeplus/finplus-interfaces)
* [gitlab.com (source)](https://gitlab.com/financeplus/finplus-interfaces)
* [github.com (source mirror)](https://github.com/financeplus/finplus-interfaces)
* [docs (typedoc)](https://financeplus.gitlab.io/finplus-interfaces/)
## Install
To install the `@fin.cx/portablefinance` package, you can use npm or yarn. Make sure you have Node.js installed on your machine.
## Status for master
[![build status](https://gitlab.com/financeplus/finplus-interfaces/badges/master/build.svg)](https://gitlab.com/financeplus/finplus-interfaces/commits/master)
[![coverage report](https://gitlab.com/financeplus/finplus-interfaces/badges/master/coverage.svg)](https://gitlab.com/financeplus/finplus-interfaces/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@financeplus/finplus-interfaces.svg)](https://www.npmjs.com/package/@financeplus/finplus-interfaces)
[![Known Vulnerabilities](https://snyk.io/test/npm/@financeplus/finplus-interfaces/badge.svg)](https://snyk.io/test/npm/@financeplus/finplus-interfaces)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
Using npm:
```sh
npm install @fin.cx/portablefinance
```
Using yarn:
```sh
yarn add @fin.cx/portablefinance
```
## Usage
For further information read the linked docs at the top of this readme.
```typescript
import {
AcCsvParser,
IMonetaryTransaction,
IPaymentAccount,
IMonthlyCheckpoint,
IVoucher,
ICsvDescriptor
} from '@fin.cx/portablefinance';
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
// 1. Define a CSV Parser
class MyCsvParser extends AcCsvParser<IMonetaryTransaction> {
public paymentProviderName = 'mybank';
public description = 'Custom CSV Parser for MyBank';
private transactions: IMonetaryTransaction[] = [];
[![repo-footer](https://financeplus.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)
public addCsvDecriptor(csvDescriptorArg: ICsvDescriptor): void {
// Implement the logic to parse the CSV and populate transactions array
// For simplicity, assume the CSV is correctly formatted and contains the necessary transaction details.
this.transactions = [
{
id: 'txn1',
data: {
paymentAccountId: 'acc1',
originTransactionId: 'orig1',
originAccountId: 'origAcc1',
additionalIds: ['add1', 'add2'],
date: Date.now(),
amount: 1000,
description: 'Payment for services',
name: 'Service Payment',
},
},
];
}
public async getTransactions(): Promise<IMonetaryTransaction[]> {
return this.transactions;
}
}
// 2. Define a Payment Account
const myVoucher: IVoucher = {
voucherDate: new Date(),
voucherId: 'vch1',
voucherStatus: 'uploaded',
voucherBinaryString: 'binarystringdata',
};
const myAccount: IPaymentAccount = {
id: 'acc1',
data: {
status: 'active',
connectionData: {
bankAdapterType: 'mybank',
credentials: {
username: 'user',
password: 'pass',
},
},
currency: 'USD',
name: 'MyBankAccount',
checkpoints: {
'2021': {
1: {
start: new Date('2021-01-01').getTime(),
end: new Date('2021-01-31').getTime(),
pdfVoucher: myVoucher,
},
2: {
start: new Date('2021-02-01').getTime(),
end: new Date('2021-02-28').getTime(),
pdfVoucher: myVoucher,
},
},
},
},
};
// 3. Working with Transactions and Accounts
(async () => {
const csvParser = new MyCsvParser();
const csvDescriptor: ICsvDescriptor = {
name: 'transactions.csv',
contentString: 'dummy content', // Replace with actual CSV content
};
csvParser.addCsvDecriptor(csvDescriptor);
const transactions = await csvParser.getTransactions();
console.log('Parsed Transactions:', transactions);
console.log('Payment Account:', myAccount);
})();
```
In this example, we demonstrate how to:
1. Define a custom CSV parser class (`MyCsvParser`) that extends the `AcCsvParser` abstract class.
2. Implement the `addCsvDecriptor` method to parse CSV content and populate transactions.
3. Define a sample payment account (`myAccount`) with necessary details.
4. Integrate the parser and account information in an asynchronous function to showcase the usage of parsed transactions and account data.
### Interfaces Overview
#### IVoucher Interface
The `IVoucher` interface is used to represent payment vouchers, with the following fields:
* `voucherDate`: Date The date the voucher was created.
* `voucherId`: string Unique identifier for the voucher.
* `voucherStatus`: 'uploaded' | 'transmitted' The status of the voucher.
* `voucherBinaryString`: string The binary string representation of the voucher content.
#### IMonetaryTransaction Interface
The `IMonetaryTransaction` interface is used to represent monetary transactions, with the following fields:
* `id`: string Unique identifier for the transaction.
* `data`: object Contains key details about the transaction:
* `paymentAccountId`: string Identifier for the payment account involved in the transaction.
* `originTransactionId`: string Identifier for the original transaction (in case of related transactions).
* `originAccountId`: string Identifier for the account from where the transaction originated.
* `additionalIds`: string[] Additional identifiers related to the transaction.
* `date`: number Date of the transaction (timestamp).
* `amount`: number Amount involved in the transaction.
* `description`: string Description of the transaction.
* `name`: string Name associated with the transaction.
* Optional properties for additional voucher data and metadata.
#### IPaymentAccount Interface
The `IPaymentAccount` interface represents a payment account with various properties, organized into nested structures.
* `id`: string Unique identifier for the payment account.
* `data`: object Contains the core data for the payment account:
* `status`: 'active' | 'inactive' | 'deleted' Status of the account.
* `connectionData`: object Holds connection-related data such as type and credentials.
* `currency`: 'EUR' | 'USD' Currency of the account.
* `name`: string Name of the account.
* `checkpoints`: object Monthly checkpoint data structured by year.
#### ICsvDescriptor Interface
The `ICsvDescriptor` interface describes a CSV file, consisting of:
* `name`: string Name of the CSV file.
* `contentString`: string The content of the CSV file as a string.
### Abstract Class AcCsvParser
The `AcCsvParser` abstract class serves as a blueprint for creating specific CSV parsers for different payment providers. It includes:
* `paymentProviderName`: Abstract property for the name of the payment provider.
* `description`: Abstract property for a description of the parser.
* `addCsvDecriptor`: Abstract method accepting a `ICsvDescriptor` object to process CSV data.
* `getTransactions`: Abstract method returning a promise which resolves to an array of `IMonetaryTransaction` objects.
### Advanced Usage
Beyond the basic usage demonstrated above, the `@fin.cx/portablefinance` package can be utilized for more advanced financial data management scenarios:
#### Handling Multiple CSV Files
```typescript
// Define multiple CSV descriptors
const csvDescriptors: ICsvDescriptor[] = [
{
name: 'transactions_jan.csv',
contentString: 'dummy content January', // Replace with actual content
},
{
name: 'transactions_feb.csv',
contentString: 'dummy content February', // Replace with actual content
},
];
// Add and parse all CSV files
csvDescriptors.forEach((descriptor) => {
csvParser.addCsvDecriptor(descriptor);
});
// Retrieve and process all transactions
const allTransactions = await csvParser.getTransactions();
console.log('All Transactions:', allTransactions);
```
#### Transaction Filtering and Aggregation
```typescript
// Filter transactions by date or amount
const filteredTransactions = allTransactions.filter((transaction) => {
return transaction.data.amount > 500; // Example: transactions greater than 500
});
console.log('Filtered Transactions:', filteredTransactions);
// Aggregate transaction amounts
const totalAmount = allTransactions.reduce((acc, transaction) => acc + transaction.data.amount, 0);
console.log('Total Transaction Amount:', totalAmount);
```
#### Integration with Payment Accounts
```typescript
// Assume we have multiple accounts
const accounts: IPaymentAccount[] = [myAccount]; // Add more accounts as needed
// Link transactions to payment accounts
const transactionsByAccount = accounts.map((account) => {
return {
accountId: account.id,
transactions: allTransactions.filter((txn) => txn.data.paymentAccountId === account.id),
};
});
console.log('Transactions by Account:', transactionsByAccount);
```
This comprehensive usage example covers the complete set of features provided by the `@fin.cx/portablefinance` package, demonstrating how to extend the abstract CSV parser, work with interfaces, handle multiple CSV files, filter and aggregate transactions, and integrate them with payment accounts. Feel free to customize the example based on your specific use cases and workflows.
For further information, consult the linked documentation at the top of this README.
Happy coding! 😊

View File

@ -1,9 +1,19 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as finplusInterfaces from '../ts/index';
import { expect, tap } from '@push.rocks/tapbundle';
import * as finplusInterfaces from '../ts/index.js';
tap.test('first test', async () => {
let dummyCsvParser : finplusInterfaces.ICsvParser;
dummyCsvParser;
interface ITestTransaction {
date: Date;
amount: number;
}
tap.test('implement test csv parser', async () => {
class MyCsvParser extends finplusInterfaces.AcCsvParser<ITestTransaction> {
paymentProviderName: 'bunq';
public transactionArray: ITestTransaction[] = [];
public async getTransactions(): Promise<ITestTransaction[]> {
return this.transactionArray;
}
}
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@fin.cx/portablefinance',
version: '1.0.28',
description: 'An interface package for handling financial transactions and account data within the financeplus organization.'
}

View File

@ -0,0 +1,9 @@
import type { ICsvDescriptor } from '../interfaces/csvdescriptor.js';
import { type IMonetaryTransaction } from '../interfaces/transaction.js';
export abstract class AcCsvParser<TOriginalTrnasction> {
public abstract paymentProviderName: string;
public abstract description: string;
public abstract addCsvDecriptor(csvDescriptorArg: ICsvDescriptor): void;
public abstract getTransactions(): Promise<IMonetaryTransaction[]>;
}

View File

@ -0,0 +1 @@
export * from './csvparser.js';

View File

@ -1,4 +1,2 @@
import * as plugins from './finplus-interfaces.plugins';
export * from './interfaces/csvparser';
export * from './abstractclasses/index.js';
export * from './interfaces/index.js';

View File

@ -0,0 +1,4 @@
export interface ICsvDescriptor {
name: string;
contentString: string;
}

View File

@ -1,4 +0,0 @@
export abstract class AcCsvParser<T> {
public abstract transactionArray: T[];
public abstract async getTransactions (): Promise<T>;
}

View File

@ -1 +1,4 @@
export * from './csvparser';
export * from './csvdescriptor.js';
export * from './paymentaccount.js';
export * from './transaction.js';
export * from './voucher.js';

View File

@ -0,0 +1,36 @@
import { type IVoucher } from './voucher.js';
export interface IMonthlyCheckpoint {
start: number;
end: number;
pdfVoucher: IVoucher;
}
export interface IPaymentAccount {
id: string;
data: {
status: 'active' | 'inactive' | 'deleted';
connectionData: {
bankAdapterType: string;
credentials: unknown;
};
currency: 'EUR' | 'USD';
name: string;
checkpoints: {
[key: string]: {
1: IMonthlyCheckpoint;
2: IMonthlyCheckpoint;
3: IMonthlyCheckpoint;
4: IMonthlyCheckpoint;
5: IMonthlyCheckpoint;
6: IMonthlyCheckpoint;
7: IMonthlyCheckpoint;
8: IMonthlyCheckpoint;
9: IMonthlyCheckpoint;
10: IMonthlyCheckpoint;
11: IMonthlyCheckpoint;
12: IMonthlyCheckpoint;
};
};
};
}

View File

@ -0,0 +1,21 @@
import { type IVoucher } from './voucher.js';
export interface IMonetaryTransaction {
id: string;
data: {
paymentAccountId: string;
originTransactionId: string;
originAccountId: string;
additionalIds: string[];
date: number;
amount: number;
description: string;
name: string;
voucherData?: IVoucher;
justForLooks?: {
paymentAcountName: string;
voucherSizeInMB: number;
dateIso?: string;
};
};
}

6
ts/interfaces/voucher.ts Normal file
View File

@ -0,0 +1,6 @@
export interface IVoucher {
voucherDate: Date;
voucherId: string;
voucherStatus: 'uploaded' | 'transmitted';
voucherBinaryString: string;
}

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}