Transaction Actions

Server actions for managing financial transactions.

createTransaction

Creates a new transaction record in the database.

const newTransaction = await createTransaction({
  name: "Monthly Rent",
  amount: "1500.00",
  senderId: "user_123",
  senderBankId: "bank_456",
  receiverId: "user_789",
  receiverBankId: "bank_012",
  email: "landlord@example.com"
})

// Transaction is automatically categorized as 'Transfer'
// and channel is set to 'online'

getTransactionsByBankId

Retrieves all transactions for a specific bank account.

const { total, documents } = await getTransactionsByBankId({
  bankId: "bank_123"
})

// Returns both sent and received transactions
console.log(`Total transactions: ${total}`)
console.log('Transactions:', documents)

Type Definitions

interface CreateTransactionProps {
  name: string
  amount: string
  senderId: string
  senderBankId: string
  receiverId: string
  receiverBankId: string
  email: string
  channel?: string // Defaults to 'online'
  category?: string // Defaults to 'Transfer'
}

interface Transaction {
  _id: string
  name: string
  amount: string
  senderId: string
  senderBankId: string
  receiverId: string
  receiverBankId: string
  email: string
  channel: string
  category: string
  $createdAt: string
}

interface getTransactionsByBankIdProps {
  bankId: string
}

Features

Bi-directional Querying

Retrieves both sent and received transactions for comprehensive transaction history.

Automatic Categorization

Default categorization and channel assignment for new transactions.

Appwrite Integration

Seamless integration with Appwrite database for transaction storage.