Handles lifecycle and persistence of property transactions, including escrow, commission, blockchain recording, and audit logging.
POST /transactions— Create a transaction (agent/admin). Validates property, buyer, and seller existence and computes fees/commissions.GET /transactions— List transactions with filters (propertyId, buyerId, sellerId, status, type, pagination).GET /transactions/:id— Get transaction details.PUT /transactions/:id— Update transaction (status, notes). Status updates enforce lifecycle rules.POST /transactions/:id/record-on-blockchain— Record transaction on-chain and persist blockchain metadata.GET /transactions/:id/verify-blockchain— Verify blockchain recording and optionally mark complete.POST /transactions/:id/notes— Add a note to a transaction (visibility enforced).
- Status workflow: transactions follow a strict lifecycle validated by
transaction-status.constants.ts. Invalid transitions are rejected. - Audit logging: status transitions and critical operations are recorded via
TransactionAuditService— every status change should produce an audit entry. - Timeline events: status changes auto-create timeline stage events for operational tracking.
- Commissions & fees: when transactions are created/updated, the
CommissionsServiceandTransactionFeesServiceare invoked to calculate and persist commission records. - Blockchain: recording is asynchronous via
BlockchainService. The transaction storesblockchainHashandcontractAddressand verification can update status toCOMPLETED.
- Controller: src/transactions/transactions.controller.ts
- Service: src/transactions/transactions.service.ts
- DTOs: src/transactions/dto/transaction.dto.ts
- Status rules: src/transactions/transaction-status.constants.ts
- Audit service: src/transactions/transaction-audit.service.ts
- Tests: unit tests in [src/transactions/*.spec.ts]; integration tests may stub
BlockchainServiceandNotificationsServiceto keep CI stable.
- For CI smoke tests, stub external integrations (blockchain, notifications) and use an in-memory or ephemeral test DB.
- Ensure
TransactionAuditServicelogs are asserted when testing status transitions. - When testing
recordOnBlockchain, mockBlockchainService.recordTransactionOnBlockchainto return a deterministicblockchainHashandcontractAddress.