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
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.