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
type DiscountPolicy ¶
type DiscountPolicy policy_evaluator.PolicyEvaluator
type TaxPolicy ¶
type TaxPolicy policy_evaluator.PolicyEvaluator
Click to show internal directories.
Click to hide internal directories.