package com.ga.core.mapper.commission;

import com.ga.core.vo.commission.HqSettleItemResp;
import com.ga.core.vo.commission.HqSettleItemSearchParam;
import com.ga.core.vo.commission.HqSettleItemVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

/**
 * hq_settle_item Mapper.
 * 본사정산: GA 자체 수입/비용 항목. 손익 = Σ(INCOME) − Σ(EXPENSE).
 */
@Mapper
public interface HqSettleItemMapper {

    HqSettleItemResp selectById(@Param("itemId") Long itemId);

    List<HqSettleItemResp> selectList(HqSettleItemSearchParam param);

    /**
     * 정산월 + 항목유형별 금액 합계 — 본사손익 집계용.
     * itemType = INCOME or EXPENSE
     */
    BigDecimal sumByMonthAndType(@Param("settleMonth") String settleMonth,
                                 @Param("itemType") String itemType);

    int insert(HqSettleItemVO vo);

    int update(HqSettleItemVO vo);

    int delete(@Param("itemId") Long itemId);
}
