UNPKG

saksh-wallet

Version:

A Node.js library for managing user wallets, including functionalities for crediting, debiting, and converting currencies, as well as retrieving balances and transaction reports.

179 lines (139 loc) 6.54 kB
const SakshUserManagement = require('./SakshUserManagement'); const SakshTransactionManagement = require('./SakshTransactionManagement'); const SakshBudgetManagement = require('./SakshBudgetManagement'); const SakshRecurringPayments = require('./SakshRecurringPayments'); const SakshReporting = require('./SakshReporting'); const Transaction = require('./models/Transaction'); const Budget = require('./models/Budget'); class SakshWallet extends SakshUserManagement { constructor() { super(); this.transactionManagement = new SakshTransactionManagement(this); this.budgetManagement = new SakshBudgetManagement(); this.recurringPayments = new SakshRecurringPayments(); this.reporting = new SakshReporting(); } // User Management methods sakshSetAdmin(adminUserId) { return super.sakshSetAdmin(adminUserId); } sakshSetLimit(nolimit) { return super.sakshSetLimit(nolimit); } sakshGetBalance(userId, currency) { return super.sakshGetBalance(userId, currency); } sakshGetBalanceSummary(userId) { return super.sakshGetBalanceSummary(userId); } // Transaction Management methods sakshCredit(userId, amount, currency, description, referenceNumber, category) { return this.transactionManagement.sakshCredit(userId, amount, currency, description, referenceNumber, category); } sakshDebit(userId, amount, currency, description, referenceNumber, category) { return this.transactionManagement.sakshDebit(userId, amount, currency, description, referenceNumber, category); } sakshTransferFunds(fromUserId, toUserId, amount, currency, description, referenceNumber, category, customFeeCallback = null) { return this.transactionManagement.sakshTransferFunds(fromUserId, toUserId, amount, currency, description, referenceNumber, category, customFeeCallback); } sakshGetTransactionReport(userId) { return this.transactionManagement.sakshGetTransactionReport(userId); } sakshReverseTransaction(transactionId, session) { return this.transactionManagement.sakshReverseTransaction(transactionId, session); } sakshReverseMultipleTransactions(transactionIds) { return this.transactionManagement.sakshReverseMultipleTransactions(transactionIds); } // Budget Management methods async sakshSetBudget(userId, category, amount, period) { const user = await WalletUser.findOne({ userId }); if (!user.budgetEnabled) { user.budgetEnabled = true; await user.save(); } return this.budgetManagement.sakshSetBudget(userId, category, amount, period); } sakshAdjustBudget(userId, category, newAmount) { return this.budgetManagement.sakshAdjustBudget(userId, category, newAmount); } sakshCheckBudget(userId, category, amount) { return this.budgetManagement.sakshCheckBudget(userId, category, amount); } sakshGetBudgetStatus(userId, category) { return this.budgetManagement.sakshGetBudgetStatus(userId, category); } // Recurring Payments methods sakshCreateRecurringPayment(userId, toUserId, amount, currency, description, referenceNumber, interval, feeCallback = null) { return this.recurringPayments.sakshCreateRecurringPayment(userId, toUserId, amount, currency, description, referenceNumber, interval, feeCallback); } sakshUpdateRecurringPayment(paymentId, updates) { return this.recurringPayments.sakshUpdateRecurringPayment(paymentId, updates); } sakshDeleteRecurringPayment(paymentId) { return this.recurringPayments.sakshDeleteRecurringPayment(paymentId); } sakshProcessDuePayments() { return this.recurringPayments.sakshProcessDuePayments(); } // Reporting methods sakshGetBalanceSummary(userId) { return this.reporting.sakshGetBalanceSummary(userId); } sakshGetMonthlyTransactionReport(userId, year, month) { return this.reporting.sakshGetMonthlyTransactionReport(userId, year, month); } sakshGetDailyTransactionReport(userId, date) { return this.reporting.sakshGetDailyTransactionReport(userId, date); } sakshGetYearlyTransactionReport(userId, year) { return this.reporting.sakshGetYearlyTransactionReport(userId, year); } sakshGetTransactionsByCategory(userId, category) { return this.reporting.sakshGetTransactionsByCategory(userId, category); } sakshGetSpendingSummary(userId, startDate, endDate) { return this.reporting.sakshGetSpendingSummary(userId, startDate, endDate); } sakshGetTransactionCount(userId) { return this.reporting.sakshGetTransactionCount(userId); } sakshGetAverageTransactionAmount(userId, startDate, endDate) { return this.reporting.sakshGetAverageTransactionAmount(userId, startDate, endDate); } sakshGetLargestTransaction(userId) { return this.reporting.sakshGetLargestTransaction(userId); } sakshGetSmallestTransaction(userId) { return this.reporting.sakshGetSmallestTransaction(userId); } sakshGetTransactionsByPaymentMethod(userId, paymentMethod) { return this.reporting.sakshGetTransactionsByPaymentMethod(userId, paymentMethod); } sakshGetBalanceByCurrency(userId) { return this.reporting.sakshGetBalanceByCurrency(userId); } sakshGetAllUsersBalanceByCurrency() { return this.reporting.sakshGetAllUsersBalanceByCurrency(); } sakshGetAllUsersBalanceByCategory() { return this.reporting.sakshGetAllUsersBalanceByCategory(); } sakshGetAllUsersBalanceAtDate(date) { return this.reporting.sakshGetAllUsersBalanceAtDate(date); } // AI Reporting methods sakshGeminiAIKey(gemini_ai_key, aimodel, max_tokens) { return this.aiReporting.sakshGeminiAIKey(gemini_ai_key, aimodel, max_tokens); } sakshGenerateReportSummary(transactions) { return this.aiReporting.sakshGenerateReportSummary(transactions); } sakshHandleUserQuery(query) { return this.aiReporting.sakshHandleUserQuery(query); } sakshGenerateReport(prompt, userId) { return this.aiReporting.sakshGenerateReport(prompt, userId); } } module.exports = SakshWallet;