package com.liquidnet.service.goblin.test;

import com.liquidnet.service.goblin.dto.vo.GoblinOrderSkuVo;
import com.liquidnet.service.goblin.service.impl.helper.GoblinRefundHelper;
import org.junit.Assert;
import org.junit.Test;

import java.math.BigDecimal;

public class GoblinRefundHelperTest {

    @Test
    public void remainRefundPriceSubtractsRefundedAndApplyingAmount() {
        GoblinOrderSkuVo skuVo = new GoblinOrderSkuVo();
        skuVo.setSkuPriceActual(new BigDecimal("100.00"));
        skuVo.setPriceRefund(new BigDecimal("30.00"));

        BigDecimal remain = GoblinRefundHelper.remainRefundPrice(skuVo, new BigDecimal("20.00"));

        Assert.assertEquals(0, new BigDecimal("50.00").compareTo(remain));
    }

    @Test
    public void remainRefundPriceNeverReturnsNegativeAmount() {
        GoblinOrderSkuVo skuVo = new GoblinOrderSkuVo();
        skuVo.setSkuPriceActual(new BigDecimal("10.00"));
        skuVo.setPriceRefund(new BigDecimal("8.00"));

        BigDecimal remain = GoblinRefundHelper.remainRefundPrice(skuVo, new BigDecimal("5.00"));

        Assert.assertEquals(0, BigDecimal.ZERO.compareTo(remain));
    }

    @Test
    public void beforeShipRefundIncludesExpressFee() {
        BigDecimal refundPrice = GoblinRefundHelper.beforeShipRefundPrice(new BigDecimal("80.00"), new BigDecimal("12.00"));

        Assert.assertEquals(0, new BigDecimal("92.00").compareTo(refundPrice));
    }
}
