package nckd.jxccl.swc.stm.plugin.form.ttlwg;

import kd.bos.entity.datamodel.events.PackageDataEvent;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.sdk.plugin.Plugin;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
* 工资总额预算分解总表
* 实体标识：nckd_ttlwgexecdeco_layout
* @author W.Y.C
* @date 2025/12/15 19:28
* @version 1.0
*/
public class TtlWgBgtDeCompListLayoutPlugin extends AbstractListPlugin implements Plugin {


    @Override
    public void packageData(PackageDataEvent e) {
        String colKey = e.getColKey();
        if("nckd_diff".equalsIgnoreCase(colKey)){
            BigDecimal itemAmtEx = e.getRowData().getBigDecimal("nckd_itemamtex");
            BigDecimal itemAmt = e.getRowData().getBigDecimal("nckd_itemamt");

            // 空值处理
            if (itemAmtEx == null) {
                itemAmtEx = BigDecimal.ZERO;
            }
            if (itemAmt == null) {
                itemAmt = BigDecimal.ZERO;
            }

            e.setFormatValue("¥"+itemAmtEx.subtract(itemAmt).setScale(2, RoundingMode.HALF_UP).toString());
        }
    }
}