package com.ruoyi.web.modules.trading.support;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.math.BigDecimal;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import com.ruoyi.web.modules.trading.TradeOrderTestSamples;

@DisplayName("SettlementFeeCalculator")
class SettlementFeeCalculatorTest
{
    @Test
    @DisplayName("ZCZX-JYDDGL-UT-018 按户服务费为0")
    void ut018_perAccount()
    {
        com.ruoyi.web.modules.trading.domain.BizSupplier supplier = TradeOrderTestSamples.supplierPerHead();
        supplier.setFeeMethod(SupplierRules.FEE_METHOD_PER_ACCOUNT);
        BigDecimal fee = SettlementFeeCalculator.calcServiceFee(supplier, 3, new BigDecimal("10000"));
        assertEquals(new BigDecimal("0.00"), fee);
        assertEquals(new BigDecimal("10000.00"),
                SettlementFeeCalculator.calcPayableAmount(new BigDecimal("10000"), fee));
    }

    @Test
    @DisplayName("ZCZX-JYDDGL-UT-019 按头计费")
    void ut019_perHead()
    {
        BigDecimal fee = SettlementFeeCalculator.calcServiceFee(
                TradeOrderTestSamples.supplierPerHead(), 3, new BigDecimal("15500"));
        assertEquals(new BigDecimal("30.00"), fee);
        assertEquals(new BigDecimal("15470.00"),
                SettlementFeeCalculator.calcPayableAmount(new BigDecimal("15500"), fee));
    }

    @Test
    @DisplayName("ZCZX-JYDDGL-UT-020 按额四舍五入")
    void ut020_perAmount()
    {
        com.ruoyi.web.modules.trading.domain.BizSupplier supplier = TradeOrderTestSamples.supplierPerHead();
        supplier.setFeeMethod(SupplierRules.FEE_METHOD_PER_AMOUNT);
        supplier.setTransactionFeeRate(new BigDecimal("1"));
        supplier.setManagementFeeRate(new BigDecimal("0.5"));
        BigDecimal fee = SettlementFeeCalculator.calcServiceFee(supplier, 1, new BigDecimal("10000"));
        assertEquals(new BigDecimal("150.00"), fee);
    }
}
