package com.yem.wm.fm.lettercredit.form;

import com.yem.wm.utils.NumberChineseUtil;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;

import java.math.BigDecimal;

/**
 * @author xwudd
 * @date 10:48
 * @Description
 **/
public class LetterCreditEdit extends AbstractBillPlugIn {

    @Override
    public void propertyChanged(PropertyChangedArgs e) {
        String name = e.getProperty().getName();
        switch(name){
            case "yem_amount" :
                setAmtInWords();
                break;
        }
    }

    public void setAmtInWords(){
        IDataModel model = this.getModel();
        BigDecimal amount = (BigDecimal) model.getValue("yem_amount");
        String format = NumberChineseUtil.format(amount.doubleValue(), false, true);
        model.setValue("yem_amtinwords",format);
    }
}
