DEV Community

Susheel kumar
Susheel kumar

Posted on

Function definitions for the reporting section

Reporting Methods

The SakshWallet class includes a comprehensive set of reporting methods to help users analyze their transactions and balances. Below are the available reporting methods:

sakshGetBalanceSummary(userId)

  • Description: Get the balance summary for a user.
  • Parameters:
    • userId (String): The ID of the user.
  • Returns: An object containing the balance summary of the user.

sakshGetMonthlyTransactionReport(userId, year, month)

  • Description: Get the monthly transaction report for a user.
  • Parameters:
    • userId (String): The ID of the user.
    • year (Number): The year of the report.
    • month (Number): The month of the report.
  • Returns: An array of transactions for the specified month.

sakshGetDailyTransactionReport(userId, date)

  • Description: Get the daily transaction report for a user.
  • Parameters:
    • userId (String): The ID of the user.
    • date (Date): The date of the report.
  • Returns: An array of transactions for the specified date.

sakshGetYearlyTransactionReport(userId, year)

  • Description: Get the yearly transaction report for a user.
  • Parameters:
    • userId (String): The ID of the user.
    • year (Number): The year of the report.
  • Returns: An array of transactions for the specified year.

sakshGetTransactionsByCategory(userId, category)

  • Description: Get transactions filtered by a specific category for a user.
  • Parameters:
    • userId (String): The ID of the user.
    • category (String): The category of the transactions.
  • Returns: An array of transactions for the specified category.

sakshGetSpendingSummary(userId, startDate, endDate)

  • Description: Get a summary of spending over a specified period for a user.
  • Parameters:
    • userId (String): The ID of the user.
    • startDate (Date): The start date of the period.
    • endDate (Date): The end date of the period.
  • Returns: An object containing the spending summary for the specified period.

sakshGetTransactionCount(userId)

  • Description: Get the total number of transactions for a user.
  • Parameters:
    • userId (String): The ID of the user.
  • Returns: The total number of transactions.

sakshGetAverageTransactionAmount(userId, startDate, endDate)

  • Description: Calculate the average amount of transactions over a specified period for a user.
  • Parameters:
    • userId (String): The ID of the user.
    • startDate (Date): The start date of the period.
    • endDate (Date): The end date of the period.
  • Returns: The average transaction amount.

sakshGetLargestTransaction(userId)

  • Description: Find the largest transaction made by a user.
  • Parameters:
    • userId (String): The ID of the user.
  • Returns: The largest transaction.

sakshGetSmallestTransaction(userId)

  • Description: Find the smallest transaction made by a user.
  • Parameters:
    • userId (String): The ID of the user.
  • Returns: The smallest transaction.

sakshGetTransactionsByPaymentMethod(userId, paymentMethod)

  • Description: Filter transactions based on the payment method used for a user.
  • Parameters:
    • userId (String): The ID of the user.
    • paymentMethod (String): The payment method of the transactions.
  • Returns: An array of transactions for the specified payment method.

sakshGetBalanceByCurrency(userId)

  • Description: Get the balance summary for a user by currency.
  • Parameters:
    • userId (String): The ID of the user.
  • Returns: An object containing the balance summary of the user by currency.

sakshGetAllUsersBalanceByCurrency()

  • Description: Get the balance summary for all users by currency.
  • Returns: An object containing the balance summary of all users by currency.

sakshGetAllUsersBalanceByCategory()

  • Description: Get the balance summary for all users by category.
  • Returns: An object containing the balance summary of all users by category.

sakshGetAllUsersBalanceAtDate(date)

  • Description: Get the balance summary for all users at a given date.
  • Parameters:
    • date (Date): The date for which to get the balance summary.
  • Returns: An object containing the balance summary of all users at the given date.

Section for the reporting methods in the SakshWallet class.

Example Usage

Here are some examples of how to use the reporting methods in the SakshWallet class:

  1. Get Balance Summary for a User
   const SakshWallet = require('./SakshWallet');
   const wallet = new SakshWallet();

   async function getBalanceSummaryExample() {
       const userId = 'user123';
       const balanceSummary = await wallet.sakshGetBalanceSummary(userId);
       console.log('Balance Summary:', balanceSummary);
   }

   getBalanceSummaryExample();
Enter fullscreen mode Exit fullscreen mode
  1. Get Monthly Transaction Report for a User
   const wallet = new SakshWallet();

   async function getMonthlyTransactionReportExample() {
       const userId = 'user123';
       const year = 2024;
       const month = 8; // August
       const monthlyReport = await wallet.sakshGetMonthlyTransactionReport(userId, year, month);
       console.log('Monthly Transaction Report:', monthlyReport);
   }

   getMonthlyTransactionReportExample();
Enter fullscreen mode Exit fullscreen mode
  1. Get Daily Transaction Report for a User
   const wallet = new SakshWallet();

   async function getDailyTransactionReportExample() {
       const userId = 'user123';
       const date = new Date('2024-09-01');
       const dailyReport = await wallet.sakshGetDailyTransactionReport(userId, date);
       console.log('Daily Transaction Report:', dailyReport);
   }

   getDailyTransactionReportExample();
Enter fullscreen mode Exit fullscreen mode
  1. Get Yearly Transaction Report for a User
   const wallet = new SakshWallet();

   async function getYearlyTransactionReportExample() {
       const userId = 'user123';
       const year = 2024;
       const yearlyReport = await wallet.sakshGetYearlyTransactionReport(userId, year);
       console.log('Yearly Transaction Report:', yearlyReport);
   }

   getYearlyTransactionReportExample();
Enter fullscreen mode Exit fullscreen mode
  1. Get Transactions by Category for a User
   const wallet = new SakshWallet();

   async function getTransactionsByCategoryExample() {
       const userId = 'user123';
       const category = 'Groceries';
       const transactions = await wallet.sakshGetTransactionsByCategory(userId, category);
       console.log('Transactions by Category:', transactions);
   }

   getTransactionsByCategoryExample();
Enter fullscreen mode Exit fullscreen mode
  1. Get Spending Summary for a User
   const wallet = new SakshWallet();

   async function getSpendingSummaryExample() {
       const userId = 'user123';
       const startDate = new Date('2024-01-01');
       const endDate = new Date('2024-08-31');
       const spendingSummary = await wallet.sakshGetSpendingSummary(userId, startDate, endDate);
       console.log('Spending Summary:', spendingSummary);
   }

   getSpendingSummaryExample();
Enter fullscreen mode Exit fullscreen mode
  1. Get Transaction Count for a User
   const wallet = new SakshWallet();

   async function getTransactionCountExample() {
       const userId = 'user123';
       const transactionCount = await wallet.sakshGetTransactionCount(userId);
       console.log('Transaction Count:', transactionCount);
   }

   getTransactionCountExample();
Enter fullscreen mode Exit fullscreen mode
  1. Get Average Transaction Amount for a User
   const wallet = new SakshWallet();

   async function getAverageTransactionAmountExample() {
       const userId = 'user123';
       const startDate = new Date('2024-01-01');
       const endDate = new Date('2024-08-31');
       const averageAmount = await wallet.sakshGetAverageTransactionAmount(userId, startDate, endDate);
       console.log('Average Transaction Amount:', averageAmount);
   }

   getAverageTransactionAmountExample();
Enter fullscreen mode Exit fullscreen mode
  1. Get Largest Transaction for a User
   const wallet = new SakshWallet();

   async function getLargestTransactionExample() {
       const userId = 'user123';
       const largestTransaction = await wallet.sakshGetLargestTransaction(userId);
       console.log('Largest Transaction:', largestTransaction);
   }

   getLargestTransactionExample();
Enter fullscreen mode Exit fullscreen mode
  1. Get Smallest Transaction for a User

    const wallet = new SakshWallet();
    
    async function getSmallestTransactionExample() {
        const userId = 'user123';
        const smallestTransaction = await wallet.sakshGetSmallestTransaction(userId);
        console.log('Smallest Transaction:', smallestTransaction);
    }
    
    getSmallestTransactionExample();
    
  2. Get Transactions by Payment Method for a User

    const wallet = new SakshWallet();
    
    async function getTransactionsByPaymentMethodExample() {
        const userId = 'user123';
        const paymentMethod = 'Credit Card';
        const transactions = await wallet.sakshGetTransactionsByPaymentMethod(userId, paymentMethod);
        console.log('Transactions by Payment Method:', transactions);
    }
    
    getTransactionsByPaymentMethodExample();
    
  3. Get Balance by Currency for a User

    const wallet = new SakshWallet();
    
    async function getBalanceByCurrencyExample() {
        const userId = 'user123';
        const balanceByCurrency = await wallet.sakshGetBalanceByCurrency(userId);
        console.log('Balance by Currency:', balanceByCurrency);
    }
    
    getBalanceByCurrencyExample();
    
  4. Get All Users' Balance by Currency

    const wallet = new SakshWallet();
    
    async function getAllUsersBalanceByCurrencyExample() {
        const allUsersBalanceByCurrency = await wallet.sakshGetAllUsersBalanceByCurrency();
        console.log('All Users Balance by Currency:', allUsersBalanceByCurrency);
    }
    
    getAllUsersBalanceByCurrencyExample();
    
  5. Get All Users' Balance by Category

    const wallet = new SakshWallet();
    
    async function getAllUsersBalanceByCategoryExample() {
        const allUsersBalanceByCategory = await wallet.sakshGetAllUsersBalanceByCategory();
        console.log('All Users Balance by Category:', allUsersBalanceByCategory);
    }
    
    getAllUsersBalanceByCategoryExample();
    
  6. Get All Users' Balance at a Given Date

    const wallet = new SakshWallet();
    
    async function getAllUsersBalanceAtDateExample() {
        const date = new Date('2024-08-31');
        const allUsersBalanceAtDate = await wallet.sakshGetAllUsersBalanceAtDate(date);
        console.log('All Users Balance at Date:', allUsersBalanceAtDate);
    }
    
    getAllUsersBalanceAtDateExample();
    

These examples demonstrate how to use the various reporting methods in the SakshWallet class.

for support you can contact me to susheel 2339 @ gmail.com

Top comments (0)