timi-codes/Banka

View on GitHub
API/services/transaction.service.js

Summary

Maintainability
D
2 days
Test Coverage

Showing 4 of 5 total issues

Function debitAccount has 34 lines of code (exceeds 30 allowed). Consider refactoring.
Wontfix

static async debitAccount(cashierId, accountNumber, amount) {
try {
const account = await Account.findByAccountNumber(Number(accountNumber));
 
if (account) {
Severity: Minor
Found in API/services/transaction.service.js - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    if (account.balance >= amount) {
    const user = await User.findUserById(Number(account.owner));
     
    const transaction = await Transaction.debit(account, amount, cashierId);
     
     
    Severity: Major
    Found in API/services/transaction.service.js and 1 other location - About 6 hrs to fix
    API/services/transaction.service.js on lines 71..96

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    if (account) {
    const user = await User.findUserById(Number(account.owner));
     
    const transaction = await Transaction.credit(account, amount, cashierId);
     
     
    Severity: Major
    Found in API/services/transaction.service.js and 1 other location - About 6 hrs to fix
    API/services/transaction.service.js on lines 28..53

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    return transactions.map((transaction) => {
    const {
    id, transactiontype, accountnumber, createdon, oldbalance, newbalance, ...data
    } = transaction;
     
     
    Severity: Major
    Found in API/services/transaction.service.js and 1 other location - About 2 hrs to fix
    API/services/transaction.service.js on lines 144..158

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    if (transaction) {
    const {
    id, transactiontype, accountnumber, createdon, oldbalance, newbalance, ...data
    } = transaction;
     
     
    Severity: Major
    Found in API/services/transaction.service.js and 1 other location - About 2 hrs to fix
    API/services/transaction.service.js on lines 114..128

    There are no issues that match your filters.

    Category
    Status