package io.github.zutherb.appstash.shop.service.checkout.impl;

import io.github.zutherb.appstash.shop.service.cart.api.Cart;
import io.github.zutherb.appstash.shop.service.checkout.api.Checkout;
import io.github.zutherb.appstash.shop.service.order.model.OrderItemInfo;
import io.github.zutherb.appstash.shop.service.cart.api.Cart;
import io.github.zutherb.appstash.shop.service.checkout.api.Checkout;
import io.github.zutherb.appstash.shop.service.order.model.OrderItemInfo;
import org.dozer.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zutherb
 */
@Component("checkout")
@Scope(value = "singleton", proxyMode = ScopedProxyMode.INTERFACES)
public class CheckoutImpl implements Checkout {

    private Cart cart;
    private Mapper mapper;

    @Autowired
    public CheckoutImpl(@Qualifier("cart") Cart cart,
                        @Qualifier("dozerMapper") Mapper mapper) {
        this.cart = cart;
        this.mapper = mapper;
    }

    @Override
    public List<OrderItemInfo> getOrderItemInfos() {
        return cart.getAll().stream()
                .map(cartItemInfo -> mapper.map(cartItemInfo, OrderItemInfo.class))
                .collect(Collectors.toList());
    }

    @Override
    public BigDecimal getTotalSum() {
        return cart.getTotalSum();
    }
}

@@ -1628,10 +1628,119 @@
 ;%0A    %7D%0A
+    %0A    @Override%0A    public BigDecimal getDiscountSum() %7B%0A        return cart.getDiscountSum();%0A    %7D%0A    %0A
 %7D%0A

Update CheckoutImpl.java