Budget handling using npm package saksh-wallet

Budget Management

Set Budget:

• Users can set budgets for specific categories and periods (daily, weekly, monthly).

• The system checks for overlapping budgets to prevent multiple budgets for the same category and period.

Adjust Budget:
• Users …


This content originally appeared on DEV Community and was authored by Susheel kumar

Budget Management

Set Budget:

• Users can set budgets for specific categories and periods (daily, weekly, monthly).

• The system checks for overlapping budgets to prevent multiple budgets for the same category and period.

Adjust Budget:
• Users can adjust their existing budgets.

• The system maintains a history of budget adjustments.

Check Budget:
• The system checks if a new transaction will exceed the user's budget for a specific category and period.

• If the budget is exceeded, an error is thrown, and the transaction is prevented.

Get Budget Status:
• Users can retrieve the status of their budgets, including total budget, total spent, and available budget.

• The status includes details such as category, period, start date, and end date.

Enable/Disable Budget:
• Users can enable or disable budget checks.

• When the budget is disabled, transactions are not checked against the budget limits.

Event Emission:
• The system emits a budgetExceeded event when a budget is exceeded, providing details such as user ID, category, amount spent, and budget amount.

Example Usage


const SakshBudgetManagement = require('./SakshBudgetManagement');
const budgetManagement = new SakshBudgetManagement();

// Set a budget
await budgetManagement.sakshSetBudget(userId, 'groceries', 5000, 'monthly');

// Adjust a budget
await budgetManagement.sakshAdjustBudget(userId, 'groceries', 6000);

// Check budget before a transaction
await budgetManagement.sakshCheckBudget(userId, 'groceries', 1000);

// Get budget status
const status = await budgetManagement.sakshGetBudgetStatus(userId, 'groceries');
console.log(status);

// Enable or disable budget
await budgetManagement.sakshToggleBudget(userId, true); // Enable budget
await budgetManagement.sakshToggleBudget(userId, false); // Disable budget

Here is the full code which used you can review the code from https://www.npmjs.com/package/saksh-wallet and suggest

or contact at susheel2339@gmail.com


This content originally appeared on DEV Community and was authored by Susheel kumar


Print Share Comment Cite Upload Translate Updates
APA

Susheel kumar | Sciencx (2024-09-08T02:38:09+00:00) Budget handling using npm package saksh-wallet. Retrieved from https://www.scien.cx/2024/09/08/budget-handling-using-npm-package-saksh-wallet/

MLA
" » Budget handling using npm package saksh-wallet." Susheel kumar | Sciencx - Sunday September 8, 2024, https://www.scien.cx/2024/09/08/budget-handling-using-npm-package-saksh-wallet/
HARVARD
Susheel kumar | Sciencx Sunday September 8, 2024 » Budget handling using npm package saksh-wallet., viewed ,<https://www.scien.cx/2024/09/08/budget-handling-using-npm-package-saksh-wallet/>
VANCOUVER
Susheel kumar | Sciencx - » Budget handling using npm package saksh-wallet. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/08/budget-handling-using-npm-package-saksh-wallet/
CHICAGO
" » Budget handling using npm package saksh-wallet." Susheel kumar | Sciencx - Accessed . https://www.scien.cx/2024/09/08/budget-handling-using-npm-package-saksh-wallet/
IEEE
" » Budget handling using npm package saksh-wallet." Susheel kumar | Sciencx [Online]. Available: https://www.scien.cx/2024/09/08/budget-handling-using-npm-package-saksh-wallet/. [Accessed: ]
rf:citation
» Budget handling using npm package saksh-wallet | Susheel kumar | Sciencx | https://www.scien.cx/2024/09/08/budget-handling-using-npm-package-saksh-wallet/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.