Template
1
0

feat: add payment module

This commit is contained in:
2025-12-05 01:56:42 +01:00
parent a818f3135a
commit be9b8e9e55
160 changed files with 8615 additions and 1158 deletions

View File

@@ -0,0 +1,40 @@
import z from "zod";
import { TransactionParticipantType } from "./transaction-participant.ts";
/*
|--------------------------------------------------------------------------------
| Transaction
|--------------------------------------------------------------------------------
|
| A transaction is a description of value being moved from a source to a target.
| Transaction must have at least one "account" participant or it is considered
| invalid as our system does not support "external" -> "external" transactions.
|
| Which ledger the transaction resides in is determined by the participants
| account traced upwards tx -> account -> wallet -> ledger. A transaction is
| invalid if both source and target participant account leads to different
| ledgers.
|
*/
export const TransactionSchema = z.strictObject({
_id: z.uuid().describe("Primary identifier of the transaction"),
sourceType: TransactionParticipantType,
sourceId: z.string().describe("Identifier of the source sending value"),
targetType: TransactionParticipantType,
targetId: z.string().describe("Identifier of the target receiving value"),
amount: z.string().describe("Value amount being transferred"),
conversionRate: z
.number()
.optional()
.describe("Conversation rate from source to target if they operate in different currencies"),
occurredAt: z.coerce.date().describe("Timestamp of when the transaction occured"),
approvedBy: z.string().describe("Identifier of the individual who approved the transfer"),
});
export type Transaction = z.output<typeof TransactionSchema>;