Skip to content

Conversation

@Ndifreke000
Copy link
Contributor

@Ndifreke000 Ndifreke000 commented Apr 25, 2025

Brief Description of Actions Taken and Issues Faced

Actions Taken

  • File Creation and Updates: Created nine files (configuration.ts, data-source.ts, transaction.entity.ts, ledger-entry.entity.ts, audit-log.entity.ts, account.entity.ts, transaction.service.ts, transaction.controller.ts, and the migrations/ directory) and updated treasury.module.ts to define entities, services, controllers, and TypeORM configuration for the Treasury module. These files implement a double-entry bookkeeping system with transaction management, audit logging, reconciliation, and reporting.
  • Local PostgreSQL Setup: Installed PostgreSQL locally in the Codespace environment, started the service, configured the postgres user with a password (password), and created a budgetchain database to match src/config/configuration.ts. This enabled TypeORM to connect to a local database.
  • Dependency Installation: Installed Node.js dependencies (typeorm, pg, @nestjs/typeorm, @nestjs/config, ts-node, typeorm-ts-node-commonjs) and PostgreSQL packages (postgresql, postgresql-contrib) to support the application and database.
  • package.json Configuration: Added TypeORM scripts (typeorm, typeorm:migration:generate, typeorm:migration:run) to package.json to enable migration generation and execution.
  • Database Configuration: Updated src/config/configuration.ts to define explicit database credentials (host: 'localhost', port: 5432, user: 'postgres', password: 'password', name: 'budgetchain') and ensured src/config/data-source.ts correctly accessed these for TypeORM migrations.
  • Testing Instructions: Provided commands to generate and run migrations, start the NestJS application, and test API endpoints (POST /transactions, GET /transactions, POST /transactions/reconcile, GET /transactions/report) with curl.

Issues Faced with the Database

  • No Database Configured: The initial error (ECONNREFUSED on localhost:5432) occurred because no PostgreSQL server was running locally, preventing TypeORM from connecting. This was evident from repeated connection failures in the logs.
  • Configuration Mismatch: Earlier versions of data-source.ts had incorrect ConfigService usage (e.g., configService.get('database.host') instead of configService.get('database').host), causing TypeScript errors due to mismatched types and unrecognized nested keys.
  • Missing PostgreSQL Installation: The Codespace environment lacked a PostgreSQL server, requiring manual installation and configuration of the database service, user, and database.
  • Authentication Setup: The default postgres user needed a password to match the application’s configuration, and a specific database (budgetchain) had to be created to align with configuration.ts.

closes #20

@anonfedora
Copy link
Contributor

Please, fix conflicts

@Ndifreke000 Ndifreke000 changed the title BE: Implement Comprehensive Transaction History and Ledger System #20 Closes #20 Implement Comprehensive Transaction History and Ledger System #20 Apr 29, 2025
@Ndifreke000 Ndifreke000 changed the title Closes #20 Implement Comprehensive Transaction History and Ledger System #20 Closes #20 Implement Comprehensive Transaction History and Ledger System Apr 29, 2025
@Ndifreke000 Ndifreke000 changed the title Closes #20 Implement Comprehensive Transaction History and Ledger System Closes #20 Apr 29, 2025
@Ndifreke000 Ndifreke000 changed the title Closes #20 Closes #20 Implement Comprehensive Transaction History and Ledger System Apr 30, 2025
@anonfedora anonfedora merged commit 70f5614 into BudgetChain:main Apr 30, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BE: Implement Comprehensive Transaction History and Ledger System

2 participants