package com.brilliance.isc.swift.objmtconvert.model.mt1xx.tag.tag101;

import com.brilliance.isc.swift.objmtconvert.model.AbsMTCreator;
import com.brilliance.isc.swift.objmtconvert.model.AbsTagCreate;
import com.brilliance.isc.swift.objmtconvert.model.mt1xx.mt1XXAbsCreator.MT101AbsCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt1xx.MT101Creator;

import java.util.List;

public class TagCycleCreator extends AbsTagCreate {
    private MT101Creator mt101Creator;

    public TagCycleCreator(AbsMTCreator absMTCreator) {
        super(absMTCreator);
        mt101Creator = (MT101Creator) absMTCreator;
    }

    @Override
    public void creator() {
        List<MT101AbsCreator> cycleDomain = mt101Creator.getCycleDomain();
        for (MT101AbsCreator cycle:cycleDomain) {
            mt101Creator.set("21", cycle.getTransactionReference());
            mt101Creator.set("21F", cycle.getFXDealReference());
            mt101Creator.set("23E", cycle.getInstructionCode(), true);
            mt101Creator.set("32B", cycle.getCurrencyTransactionAmount());
            mt101Creator.set("50" + cycle.getInstructionParty().getTagResult().getTagEnd(),
                    cycle.getInstructionParty().getTagResult().getValue());
            mt101Creator.set("50" + cycle.getOrderingCustomer().getTagResult().getTagEnd(),
                    cycle.getOrderingCustomer().getTagResult().getValue());
            mt101Creator.set("52" + cycle.getAccountServicingInstitution().getTagResult().getTagEnd(),
                    cycle.getAccountServicingInstitution().getTagResult().getValue());
            mt101Creator.set("56" + cycle.getIntermediary().getTagResult().getTagEnd(),
                    cycle.getIntermediary().getTagResult().getValue());
            mt101Creator.set("57" + cycle.getAccountWithInstitution().getTagResult().getTagEnd(),
                    cycle.getAccountWithInstitution().getTagResult().getValue());
            mt101Creator.set("59" + cycle.getBeneficiary().getTagResult().getTagEnd(),
                    cycle.getBeneficiary().getTagResult().getValue());
//            handlerBicAdrCreator(cycle, "actnoBicAdrTag50a");
//            handlerBicAdrCreator(cycle, "actnoBicAdrTag50a2");
//            handlerBicAdrCreator(cycle, "actnoBicAdrTag52a");
//            handlerBicAdrCreator(cycle, "actnoBicAdrTag56a");
//            handlerBicAdrCreator(cycle, "actnoBicAdrTag57a");
//            handlerBicAdrCreator(cycle, "actnoBicAdrTag59a");
            mt101Creator.set("70", cycle.getRemittanceInformation());
            mt101Creator.set("77B", cycle.getRegulatoryReporting());
            mt101Creator.set("33B", cycle.getCurrencyOriginalOrderedAmount());
            mt101Creator.set("71A", cycle.getDetailsOfCharges());
            mt101Creator.set("25A", cycle.getChargesAccount());
            mt101Creator.set("36", cycle.getExchangeRate());
        }
    }
}
