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

import com.brilliance.isc.swift.objmtconvert.model.AbsMTCreator;
import com.brilliance.isc.swift.objmtconvert.model.AbsTagCreate;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.MT210Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt2xx.mt2XXAbsCreator.MT210AbsCreator;

import java.util.List;

/**
 * @author huangmengyuan
 * @create 2023/2/28
 */
public class TagCycleCreator extends AbsTagCreate {
    private MT210Creator mt210Creator;

    public TagCycleCreator(AbsMTCreator absMTCreator) {
        super(absMTCreator);
        this.mt210Creator = (MT210Creator) absMTCreator;
    }

    @Override
    public void creator() {
        List<MT210AbsCreator> cycleList = mt210Creator.getCycleDomain();
        for (MT210AbsCreator cycleMT210 : cycleList) {
            mt210Creator.set("21", cycleMT210.getRelatedReference());
            mt210Creator.set("32"+cycleMT210.getCurrencyCodeAmount().getTagResult().getTagEnd(),cycleMT210.getCurrencyCodeAmount().getTagResult().getValue());
            if (cycleMT210.getOrderingCustomer() != null) {
                mt210Creator.set("50" + cycleMT210.getOrderingCustomer().getTagResult().getTagEnd(), cycleMT210.getOrderingCustomer().getTagResult().getValue());
            }
            if (cycleMT210.getOrderingInstitution() != null) {
                mt210Creator.set("52" + cycleMT210.getOrderingInstitution().getTagResult().getTagEnd(), cycleMT210.getOrderingInstitution().getTagResult().getValue());
            }
            if (cycleMT210.getIntermediary() != null) {
                mt210Creator.set("56" + cycleMT210.getIntermediary().getTagResult().getTagEnd(), cycleMT210.getIntermediary().getTagResult().getValue());
            }

        }
    }
}
