package com.brilliance.isc.swift.objmtconvert.model.mt2xx.tag.tag203;

import com.brilliance.isc.swift.objmtconvert.model.AbsMTCreator;
import com.brilliance.isc.swift.objmtconvert.model.AbsTagCreate;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.MT203Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.mt2XXAbsCreator.MT203AbsCreator;

import java.util.List;

/**
 * @author huangmengyuan
 * @create 2023/2/27
 */
public class TagCycleCreator extends AbsTagCreate {
    private MT203Creator mt203Creator;

    public TagCycleCreator(AbsMTCreator absMTCreator) {
        super(absMTCreator);
        this.mt203Creator = (MT203Creator) absMTCreator;
    }

    @Override
    public void creator() {
        List<MT203AbsCreator> cycleList = mt203Creator.getCycleDomain();
        for (MT203AbsCreator cycleMT203 : cycleList) {
            mt203Creator.set("20", cycleMT203.getTransactionReferenceNumber());
            mt203Creator.set("21", cycleMT203.getRelatedReference());
            mt203Creator.set("32"+cycleMT203.getDateCurAmt32B().getTagResult().getTagEnd(),cycleMT203.getDateCurAmt32B().getTagResult().getValue());
            if (cycleMT203.getActnoBicAdr56a()!=null){
                mt203Creator.set("56"+cycleMT203.getActnoBicAdr56a().getTagResult().getTagEnd(), cycleMT203.getActnoBicAdr56a().getTagResult().getValue());
            }
            if (cycleMT203.getActnoBicAdr57a()!=null){
                mt203Creator.set("57"+cycleMT203.getActnoBicAdr57a().getTagResult().getTagEnd(), cycleMT203.getActnoBicAdr57a().getTagResult().getValue());
            }

            mt203Creator.set("58"+cycleMT203.getActnoBicAdr58a().getTagResult().getTagEnd(), cycleMT203.getActnoBicAdr58a().getTagResult().getValue());
            mt203Creator.set("72", cycleMT203.getSendertoReceiverInformationB());
        }
    }
}
