application

package
v0.0.0-...-e3c39ba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CartService

type CartService struct {
	DiscountPolicy policy_evaluator.PolicyEvaluator
	TaxPolicy      policy_evaluator.PolicyEvaluator
	PolicyNames    []string
	// contains filtered or unexported fields
}

CartService orchestrates cart operations

func NewCartService

func NewCartService(log logger.Logger, discountPolicy DiscountPolicy, taxPolicy TaxPolicy, policyNames []string) *CartService

NewCartService creates a new CartService

func (*CartService) CalculateTotal

func (s *CartService) CalculateTotal(ctx context.Context, cart *domain.Cart, discountParams, taxParams map[string]interface{}) (CartTotal, error)

CalculateTotal computes the total price, applying discounts and taxes

type CartTotal

type CartTotal struct {
	TotalTax      decimal.Decimal `json:"totalTax"`
	TotalDiscount decimal.Decimal `json:"totalDiscount"`
	FinalPrice    decimal.Decimal `json:"finalPrice"`
	Policies      []string        `json:"policies"`
}

CartTotal represents the total calculation result

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL