Class

TransactionRepository

TransactionRepository()

Constructor

# new TransactionRepository()

TransactionRepository - Manages transactions data.

View Source src/transactions/TransactionRepository.js, line 11

Methods

# async getDiscount(transactionId, couponCodeId) → {Object}

Get discounts for a transaction or transaction_item.

Parameters:
Name Type Description
transactionId Number

The transaction ID.

couponCodeId Number

The coupon code ID.

View Source src/transactions/TransactionRepository.js, line 143

  • If an error occurs.
Error
  • The discounts object.
Object

# async getDiscountsForEntities(transactionItemId) → {Object}

Get discounts for a transaction item.

Parameters:
Name Type Description
transactionItemId Number

The transaction item ID.

View Source src/transactions/TransactionRepository.js, line 162

  • If an error occurs.
Error
  • The discounts object.
Object

# async getPaymentTypes() → {Array.<PaymentTypeEntity>}

Get all payment types.

View Source src/transactions/TransactionRepository.js, line 185

  • If an error occurs.
Error
  • An array of payment type entities.
Array.<PaymentTypeEntity>

# async getTransactionByUserId(userId) → {Object}

Get a transaction by user ID.

Parameters:
Name Type Description
userId Number

The user ID.

View Source src/transactions/TransactionRepository.js, line 74

  • If an error occurs.
Error
  • The transaction object.
Object

# async getTransactionCategories() → {Array.<TransactionCategoryEntity>}

Get all transaction categories.

View Source src/transactions/TransactionRepository.js, line 215

  • If an error occurs.
Error
  • An array of transaction category entities.
Array.<TransactionCategoryEntity>

# getTransactionDataByCartId(cartId) → {Object}

Get transaction data by cart ID.

Parameters:
Name Type Description
cartId Number

The cart ID.

View Source src/transactions/TransactionRepository.js, line 386

  • If an error occurs.
Error
  • The transaction data.
Object

# getTransactionDataByOrderId(orderId) → {Object}

Get transaction data by order ID.

Parameters:
Name Type Description
orderId Number

The order ID.

View Source src/transactions/TransactionRepository.js, line 375

  • If an error occurs.
Error
  • The transaction data.
Object

# getTransactionDataByTransactionId(transactionId) → {Object}

Get transaction data by transaction ID.

Parameters:
Name Type Description
transactionId Number

The transaction ID.

View Source src/transactions/TransactionRepository.js, line 364

  • If an error occurs.
Error
  • The transaction data.
Object

# async getTransactionTypes() → {Array.<TransactionTypeEntity>}

Get all transaction types.

View Source src/transactions/TransactionRepository.js, line 200

  • If an error occurs.
Error
  • An array of transaction type entities.
Array.<TransactionTypeEntity>

# async getTransactionWithItems(transactionId) → {Object}

Get a transaction by ID and fetch related data.

Parameters:
Name Type Description
transactionId Number

The transaction ID.

View Source src/transactions/TransactionRepository.js, line 36

  • If an error occurs.
Error
  • The transaction object.
Object

# async insertDiscount(transactionItemId) → {Object}

Get discounts for a transaction item.

Parameters:
Name Type Description
transactionItemId Number

The transaction item ID.

View Source src/transactions/TransactionRepository.js, line 106

  • If an error occurs.
Error
  • The discounts object.
Object

# async updateTotals(transactionId) → {Number}

Update the totals of a transaction.

Parameters:
Name Type Description
transactionId Number

The transaction ID.

View Source src/transactions/TransactionRepository.js, line 88

  • If an error occurs.
Error
  • The transaction total.
Number

# async upsertDiscount(data) → {Object}

Upsert a discount for a transaction or transaction item.

Parameters:
Name Type Description
data Object

The discount data.

entity_type string

The entity type (transaction or transaction_item).

entity_id number

The entity ID.

coupon_code_id number

The coupon code ID.

View Source src/transactions/TransactionRepository.js, line 119

  • If an error occurs.
Error
  • The upserted discount object.
Object

TransactionRepository(DB) → {TransactionRepository}

Constructor

# new TransactionRepository(DB) → {TransactionRepository}

Parameters:
Name Type Description
DB Object

View Source src/transactions/TransactionRepository.js, line 22

Methods

# async getDiscount(transactionId, couponCodeId) → {Object}

Get discounts for a transaction or transaction_item.

Parameters:
Name Type Description
transactionId Number

The transaction ID.

couponCodeId Number

The coupon code ID.

View Source src/transactions/TransactionRepository.js, line 143

  • If an error occurs.
Error
  • The discounts object.
Object

# async getDiscountsForEntities(transactionItemId) → {Object}

Get discounts for a transaction item.

Parameters:
Name Type Description
transactionItemId Number

The transaction item ID.

View Source src/transactions/TransactionRepository.js, line 162

  • If an error occurs.
Error
  • The discounts object.
Object

# async getPaymentTypes() → {Array.<PaymentTypeEntity>}

Get all payment types.

View Source src/transactions/TransactionRepository.js, line 185

  • If an error occurs.
Error
  • An array of payment type entities.
Array.<PaymentTypeEntity>

# async getTransactionByUserId(userId) → {Object}

Get a transaction by user ID.

Parameters:
Name Type Description
userId Number

The user ID.

View Source src/transactions/TransactionRepository.js, line 74

  • If an error occurs.
Error
  • The transaction object.
Object

# async getTransactionCategories() → {Array.<TransactionCategoryEntity>}

Get all transaction categories.

View Source src/transactions/TransactionRepository.js, line 215

  • If an error occurs.
Error
  • An array of transaction category entities.
Array.<TransactionCategoryEntity>

# getTransactionDataByCartId(cartId) → {Object}

Get transaction data by cart ID.

Parameters:
Name Type Description
cartId Number

The cart ID.

View Source src/transactions/TransactionRepository.js, line 386

  • If an error occurs.
Error
  • The transaction data.
Object

# getTransactionDataByOrderId(orderId) → {Object}

Get transaction data by order ID.

Parameters:
Name Type Description
orderId Number

The order ID.

View Source src/transactions/TransactionRepository.js, line 375

  • If an error occurs.
Error
  • The transaction data.
Object

# getTransactionDataByTransactionId(transactionId) → {Object}

Get transaction data by transaction ID.

Parameters:
Name Type Description
transactionId Number

The transaction ID.

View Source src/transactions/TransactionRepository.js, line 364

  • If an error occurs.
Error
  • The transaction data.
Object

# async getTransactionTypes() → {Array.<TransactionTypeEntity>}

Get all transaction types.

View Source src/transactions/TransactionRepository.js, line 200

  • If an error occurs.
Error
  • An array of transaction type entities.
Array.<TransactionTypeEntity>

# async getTransactionWithItems(transactionId) → {Object}

Get a transaction by ID and fetch related data.

Parameters:
Name Type Description
transactionId Number

The transaction ID.

View Source src/transactions/TransactionRepository.js, line 36

  • If an error occurs.
Error
  • The transaction object.
Object

# async insertDiscount(transactionItemId) → {Object}

Get discounts for a transaction item.

Parameters:
Name Type Description
transactionItemId Number

The transaction item ID.

View Source src/transactions/TransactionRepository.js, line 106

  • If an error occurs.
Error
  • The discounts object.
Object

# async updateTotals(transactionId) → {Number}

Update the totals of a transaction.

Parameters:
Name Type Description
transactionId Number

The transaction ID.

View Source src/transactions/TransactionRepository.js, line 88

  • If an error occurs.
Error
  • The transaction total.
Number

# async upsertDiscount(data) → {Object}

Upsert a discount for a transaction or transaction item.

Parameters:
Name Type Description
data Object

The discount data.

entity_type string

The entity type (transaction or transaction_item).

entity_id number

The entity ID.

coupon_code_id number

The coupon code ID.

View Source src/transactions/TransactionRepository.js, line 119

  • If an error occurs.
Error
  • The upserted discount object.
Object