Options
All
  • Public
  • Public/Protected
  • All
Menu

Model entity for a shopping cart.

Hierarchy

  • Cart

Index

Constructors

constructor

  • new Cart(subtotal: number, discount: number, taxes: number, total?: number, id?: number): Cart
  • Create a Cart model entity.

    Parameters

    • subtotal: number

      subtotal of Cart

    • discount: number

      discount percent to be applied subtotal of the Cart

    • taxes: number

      total tax amount to be applied to Cart

    • Optional total: number

      (Optional) total price of the Cart with taxes and discount applied, if not specified will be calculated from subtotal, discount and taxes

    • Optional id: number

      (Optional) unique identifier of the Cart, required for accessing existing Cart in database

    Returns Cart

Properties

Private _discount

_discount: number

Private Optional _id

_id: number

Private _subtotal

_subtotal: number

Private _taxes

_taxes: number

Private _total

_total: number

Accessors

discount

  • get discount(): number
  • set discount(v: number): void
  • returns the discounted percent of the Cart.

    Returns number

  • sets the discounted percent of the Cart.

    Parameters

    • v: number

    Returns void

id

  • get id(): number
  • set id(v: number): void
  • returns Cart unique identifier.

    Returns number

  • sets Cart unique identifier.

    Parameters

    • v: number

    Returns void

subtotal

  • get subtotal(): number
  • set subtotal(v: number): void
  • returns the subtotal of the Cart.

    Returns number

  • sets the subtotal of the Cart.

    Parameters

    • v: number

    Returns void

taxes

  • get taxes(): number
  • set taxes(v: number): void
  • returns the total tax amount of the Cart.

    Returns number

  • sets the total tax amount of the Cart.

    Parameters

    • v: number

    Returns void

total

  • get total(): number
  • set total(v: number): void
  • returns the total price of the Cart.

    Returns number

  • sets the total price of the Cart.

    Parameters

    • v: number

    Returns void

Methods

toJson

  • toJson(): any
  • Creates a JSON object repersentation of Cart entity.

    Returns any

    JSON object repersentation of Cart entity

Static calcTotalPrice

  • calcTotalPrice(subtotal: number, tax: number, discount: number): number
  • Calculates the total price of a cart.

    Parameters

    • subtotal: number

      Subtotal amount of cart

    • tax: number

      Tax amount of cart

    • discount: number

      Discount percentage to apply

    Returns number

    The total price of a cart after tax and discount is applied.

Static fromJson

  • Converts a JSON record result from pg query to a Cart model entity.

    see

    CartDao

    Parameters

    Returns Cart

    A Cart model entity.

Generated using TypeDoc