Commit 91498bcd by zhanghou

完成940,950,swiftDto转mt

parent ef7af9d2
......@@ -22,14 +22,14 @@ public class Camt053001Parse20Field extends AbstractMt2SwiftDtoParseFields {
Field20 field20 = mt940.getField20();
if(field20!=null){
bankToCustomerStatement.setMessageId(field20.getValue());
bankToCustomerStatement.setMtType("940");
bankToCustomerStatement.setCd("FWAV");
}
}else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
Field20 field20 = mt950.getField20();
if(field20!=null){
bankToCustomerStatement.setMessageId(field20.getValue());
bankToCustomerStatement.setMtType("950");
bankToCustomerStatement.setCd("");
}
}
}catch (Exception e) {
......
......@@ -3,6 +3,7 @@ package com.brilliance.swift.mt2SwiftDto.camt053001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.PartyAccount;
import com.prowidesoftware.swift.model.field.Field25;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT940;
......@@ -21,13 +22,17 @@ public class Camt053001Parse25aField extends AbstractMt2SwiftDtoParseFields {
MT940 mt940 = (MT940) context.get(AbstractMT.class);
Field25 field25 = mt940.getField25();
if(field25!=null){
bankToCustomerStatement.setIbanId(field25.getValue());
PartyAccount account = new PartyAccount();
account.setAccount(field25.getValue());
bankToCustomerStatement.setAccount(account);
}
}else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
Field25 field25 = mt950.getField25();
if(field25!=null){
bankToCustomerStatement.setIbanId(field25.getValue());
PartyAccount account = new PartyAccount();
account.setAccount(field25.getValue());
bankToCustomerStatement.setAccount(account);
}
}
}catch (Exception e){
......
......@@ -5,6 +5,7 @@ import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.BalDto;
import com.prowidesoftware.swift.model.field.DateContainer;
import com.prowidesoftware.swift.model.field.Field60M;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT940;
......@@ -26,11 +27,19 @@ public class Camt053001Parse60aField extends AbstractMt2SwiftDtoParseFields {
}else if(mt940.getField60M()!=null){
Field60M field60M = mt940.getField60M();
BalDto balDto = new BalDto();
balDto.setBalCdtDbtInd(field60M.getDCMark());
balDto.setCd("ITBD");
String dcMark = field60M.getDCMark();
if("D".equals(dcMark)){
balDto.setCdtDbtInd("DBIT");
}else if("C".equals(dcMark)) {
balDto.setCdtDbtInd("CRDT");
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
balDto.setDate(DateUtil.parseDate("20"+field60M.getDate(), "yyyyMMdd"));
balDto.setCcy(field60M.getCurrency());
balDto.setAmt(field60M.amount());
bankToCustomerStatement.setOpenBal(balDto);
bankToCustomerStatement.setOpenBalance(balDto);
}
}else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
......@@ -39,11 +48,19 @@ public class Camt053001Parse60aField extends AbstractMt2SwiftDtoParseFields {
}else if(mt950.getField60M()!=null){
Field60M field60M = mt950.getField60M();
BalDto balDto = new BalDto();
balDto.setBalCdtDbtInd(field60M.getDCMark());
balDto.setCd("ITBD");
String dcMark = field60M.getDCMark();
if("D".equals(dcMark)){
balDto.setCdtDbtInd("DBIT");
}else if("C".equals(dcMark)) {
balDto.setCdtDbtInd("CRDT");
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
balDto.setDate(DateUtil.parseDate("20"+field60M.getDate(), "yyyyMMdd"));
balDto.setCcy(field60M.getCurrency());
balDto.setAmt(field60M.amount());
bankToCustomerStatement.setOpenBal(balDto);
bankToCustomerStatement.setOpenBalance(balDto);
}
}
}catch (Exception e){
......
......@@ -4,8 +4,9 @@ import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.AbstractMt2SwiftDtoParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.NtryDto;
import com.brilliance.swift.vo.common.statementBreakdown;
import com.prowidesoftware.swift.model.field.Field61;
import com.prowidesoftware.swift.model.field.Field86;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt9xx.MT940;
import com.prowidesoftware.swift.model.mt9xx.MT950;
......@@ -24,20 +25,29 @@ public class Camt053001Parse61Field extends AbstractMt2SwiftDtoParseFields {
if(context.get(AbstractMT.class).getMessageType().equals("940")){
MT940 mt940 = (MT940) context.get(AbstractMT.class);
List<Field61> field61List = mt940.getField61();
List<Field86> field86List = mt940.getField86();
if(field61List.size()>0) {
for (int i = 0; i < field61List.size(); i++) {
NtryDto ntryDto = new NtryDto();
ntryDto.setValDate(DateUtil.parseDate("20"+field61List.get(i).getValueDate(), "yyyyMMdd"));
ntryDto.setBookDate(DateUtil.parseDate("20"+field61List.get(i).getEntryDate(), "yyyyMMdd"));
ntryDto.setCdtDbtInd(field61List.get(i).getDCMark());
ntryDto.setCcy(field61List.get(i).getFundsCode());
ntryDto.setAmt(field61List.get(i).amount());
ntryDto.setTransactionType(field61List.get(i).getTransactionType());
ntryDto.setIdentificationCode(field61List.get(i).getIdentificationCode());
ntryDto.setEndToEndId(field61List.get(i).getReferenceForTheAccountOwner());
ntryDto.setAddtlTxInf(field61List.get(i).getReferenceOfTheAccountServicingInstitution());
ntryDto.setAddtlNtryInf(field61List.get(i).getSupplementaryDetails());
bankToCustomerStatement.addNtryDto(ntryDto);
statementBreakdown statementBreakdown = new statementBreakdown();
statementBreakdown.setValueDate(DateUtil.parseDate("20"+field61List.get(i).getValueDate(), "yyyyMMdd"));
statementBreakdown.setBookDate(DateUtil.parseDate("20"+field61List.get(i).getEntryDate(), "yyyyMMdd"));
String dcMark = field61List.get(i).getDCMark();
if("D".equals(dcMark)||"RC".equals(dcMark)){
statementBreakdown.setCdtDbtInd("DBIT");
}else if("C".equals(dcMark)||"RD".equals(dcMark)) {
statementBreakdown.setCdtDbtInd("CRDT");
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
statementBreakdown.setCcy(field61List.get(i).getFundsCode());
statementBreakdown.setAmt(field61List.get(i).amount());
statementBreakdown.setTransactionType(field61List.get(i).getTransactionType());
statementBreakdown.setIdentificationCode(field61List.get(i).getIdentificationCode());
statementBreakdown.setEndToEndId(field61List.get(i).getReferenceForTheAccountOwner());
statementBreakdown.setAcctSvcrRef(field61List.get(i).getReferenceOfTheAccountServicingInstitution());
statementBreakdown.setAddtlTxInf(field61List.get(i).getSupplementaryDetails());
statementBreakdown.setAddtlNtryInf(field86List.get(i).getValue());
bankToCustomerStatement.addNtryDto(statementBreakdown);
}
}
}else {
......@@ -45,18 +55,25 @@ public class Camt053001Parse61Field extends AbstractMt2SwiftDtoParseFields {
List<Field61> field61List = mt950.getField61();
if(field61List.size()>0) {
for (int i = 0; i < field61List.size(); i++) {
NtryDto ntryDto = new NtryDto();
ntryDto.setValDate(DateUtil.parseDate("20"+field61List.get(i).getValueDate(), "yyyyMMdd"));
ntryDto.setBookDate(DateUtil.parseDate("20"+field61List.get(i).getEntryDate(), "yyyyMMdd"));
ntryDto.setCdtDbtInd(field61List.get(i).getDCMark());
ntryDto.setCcy(field61List.get(i).getFundsCode());
ntryDto.setAmt(field61List.get(i).amount());
ntryDto.setTransactionType(field61List.get(i).getTransactionType());
ntryDto.setIdentificationCode(field61List.get(i).getIdentificationCode());
ntryDto.setEndToEndId(field61List.get(i).getReferenceForTheAccountOwner());
ntryDto.setAddtlTxInf(field61List.get(i).getReferenceOfTheAccountServicingInstitution());
ntryDto.setAddtlNtryInf(field61List.get(i).getSupplementaryDetails());
bankToCustomerStatement.addNtryDto(ntryDto);
statementBreakdown statementBreakdown = new statementBreakdown();
statementBreakdown.setValueDate(DateUtil.parseDate("20"+field61List.get(i).getValueDate(), "yyyyMMdd"));
statementBreakdown.setBookDate(DateUtil.parseDate("20"+field61List.get(i).getEntryDate(), "yyyyMMdd"));
String dcMark = field61List.get(i).getDCMark();
if("D".equals(dcMark)||"RC".equals(dcMark)){
statementBreakdown.setCdtDbtInd("DBIT");
}else if("C".equals(dcMark)||"RD".equals(dcMark)) {
statementBreakdown.setCdtDbtInd("CRDT");
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
statementBreakdown.setCcy(field61List.get(i).getFundsCode());
statementBreakdown.setAmt(field61List.get(i).amount());
statementBreakdown.setTransactionType(field61List.get(i).getTransactionType());
statementBreakdown.setIdentificationCode(field61List.get(i).getIdentificationCode());
statementBreakdown.setEndToEndId(field61List.get(i).getReferenceForTheAccountOwner());
statementBreakdown.setAcctSvcrRef(field61List.get(i).getReferenceOfTheAccountServicingInstitution());
statementBreakdown.setAddtlTxInf(field61List.get(i).getSupplementaryDetails());
bankToCustomerStatement.addNtryDto(statementBreakdown);
}
}
}
......
......@@ -26,11 +26,19 @@ public class Camt053001Parse62aField extends AbstractMt2SwiftDtoParseFields {
}else if(mt940.getField62M()!=null){
Field62M field62M = mt940.getField62M();
BalDto balDto = new BalDto();
balDto.setBalCdtDbtInd(field62M.getDCMark());
balDto.setCd("ITBD");
String dcMark = field62M.getDCMark();
if("D".equals(dcMark)){
balDto.setCdtDbtInd("DBIT");
}else if("C".equals(dcMark)) {
balDto.setCdtDbtInd("CRDT");
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
balDto.setDate(DateUtil.parseDate("20"+field62M.getDate(), "yyyyMMdd"));
balDto.setCcy(field62M.getCurrency());
balDto.setAmt(field62M.amount());
bankToCustomerStatement.setClosBal(balDto);
bankToCustomerStatement.setClosingBalance(balDto);
}
}else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
......@@ -39,11 +47,19 @@ public class Camt053001Parse62aField extends AbstractMt2SwiftDtoParseFields {
}else if(mt950.getField62M()!=null){
Field62M field62M = mt950.getField62M();
BalDto balDto = new BalDto();
balDto.setBalCdtDbtInd(field62M.getDCMark());
balDto.setCd("ITBD");
String dcMark = field62M.getDCMark();
if("D".equals(dcMark)){
balDto.setCdtDbtInd("DBIT");
}else if("C".equals(dcMark)) {
balDto.setCdtDbtInd("CRDT");
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
balDto.setDate(DateUtil.parseDate("20"+field62M.getDate(), "yyyyMMdd"));
balDto.setCcy(field62M.getCurrency());
balDto.setAmt(field62M.amount());
bankToCustomerStatement.setClosBal(balDto);
bankToCustomerStatement.setClosingBalance(balDto);
}
}
}catch (Exception e){
......
......@@ -24,22 +24,38 @@ public class Camt053001Parse64Field extends AbstractMt2SwiftDtoParseFields {
Field64 field64 = mt940.getField64();
if(field64!=null) {
BalDto balDto = new BalDto();
balDto.setBalCdtDbtInd(field64.getDCMark());
balDto.setCd("CLAV");
String dcMark = field64.getDCMark();
if("D".equals(dcMark)){
balDto.setCdtDbtInd("DBIT");
}else if("C".equals(dcMark)) {
balDto.setCdtDbtInd("CRDT");
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
balDto.setDate(DateUtil.parseDate("20"+field64.getDate(), "yyyyMMdd"));
balDto.setCcy(field64.getCurrency());
balDto.setAmt(field64.amount());
bankToCustomerStatement.setClosAvaBal(balDto);
bankToCustomerStatement.setClosingAvailableBalance(balDto);
}
}else {
MT950 mt950 = (MT950) context.get(AbstractMT.class);
Field64 field64 = mt950.getField64();
if(field64!=null) {
BalDto balDto = new BalDto();
balDto.setBalCdtDbtInd(field64.getDCMark());
balDto.setCd("CLAV");
String dcMark = field64.getDCMark();
if("D".equals(dcMark)){
balDto.setCdtDbtInd("DBIT");
}else if("C".equals(dcMark)) {
balDto.setCdtDbtInd("CRDT");
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
balDto.setDate(DateUtil.parseDate("20"+field64.getDate(), "yyyyMMdd"));
balDto.setCcy(field64.getCurrency());
balDto.setAmt(field64.amount());
bankToCustomerStatement.setClosAvaBal(balDto);
bankToCustomerStatement.setClosingAvailableBalance(balDto);
}
}
}catch (Exception e) {
......
......@@ -26,7 +26,15 @@ public class Camt053001Parse65Field extends AbstractMt2SwiftDtoParseFields {
if(field65List.size()>0){
for (int i = 0; i < field65List.size(); i++) {
BalDto balDto = new BalDto();
balDto.setBalCdtDbtInd(field65List.get(i).getDCMark());
balDto.setCd("FWAV");
String dcMark = field65List.get(i).getDCMark();
if("D".equals(dcMark)){
balDto.setCdtDbtInd("DBIT");
}else if("C".equals(dcMark)) {
balDto.setCdtDbtInd("CRDT");
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
balDto.setDate(DateUtil.parseDate("20"+field65List.get(i).getDate(), "yyyyMMdd"));
balDto.setCcy(field65List.get(i).getCurrency());
balDto.setAmt(field65List.get(i).amount());
......
......@@ -4,6 +4,7 @@ import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.mt103.SwiftDto2Mt103Creator;
import com.brilliance.swift.swiftdto2mt.mt202.SwiftDto2Mt202Creator;
import com.brilliance.swift.swiftdto2mt.mt900910.SwiftDto2Mt900910Creator;
import com.brilliance.swift.swiftdto2mt.mt940950.SwiftDto2Mt940950Creator;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftDto;
import org.apache.commons.io.FileUtils;
......@@ -53,7 +54,10 @@ public class SwiftDto2MtCreatorManager {
return new SwiftDto2Mt202Creator();
}else if("camt.054.001".equals(messageType)){
return new SwiftDto2Mt900910Creator();
} else {
} else if("camt.053.001".equals(messageType)){
return new SwiftDto2Mt940950Creator();
}
else {
throw new SwiftException("Invalid message type");
}
}
......
......@@ -17,11 +17,15 @@ public class Tag20Generate extends AbstractSwiftDto2MtTagGenerate {
@Override
public void tagGenerate() throws SwiftException {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if (StringUtil.isNotEmpty(bankToCustomerDebitCreditNotification.getMessageId())) {
tags.add(new Tag(name, bankToCustomerDebitCreditNotification.getMessageId()));
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if (StringUtil.isNotEmpty(bankToCustomerDebitCreditNotification.getMessageId())) {
tags.add(new Tag(name, bankToCustomerDebitCreditNotification.getMessageId()));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -17,11 +17,15 @@ public class Tag21Generate extends AbstractSwiftDto2MtTagGenerate {
@Override
public void tagGenerate() throws SwiftException {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if (StringUtil.isNotEmpty(bankToCustomerDebitCreditNotification.getEndToEndId())) {
tags.add(new Tag(name, bankToCustomerDebitCreditNotification.getEndToEndId()));
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if (StringUtil.isNotEmpty(bankToCustomerDebitCreditNotification.getEndToEndId())) {
tags.add(new Tag(name, bankToCustomerDebitCreditNotification.getEndToEndId()));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -16,11 +16,16 @@ public class Tag25aGenerate extends AbstractSwiftDto2MtTagGenerate {
@Override
public void tagGenerate() throws SwiftException {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if(bankToCustomerDebitCreditNotification.getAccount()!=null){
tags.add(new Tag(name, bankToCustomerDebitCreditNotification.getAccount().getAccount()));
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if(bankToCustomerDebitCreditNotification.getAccount()!=null){
tags.add(new Tag(name, bankToCustomerDebitCreditNotification.getAccount().getAccount()));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -20,17 +20,22 @@ public class Tag32AGenerate extends AbstractSwiftDto2MtTagGenerate {
@Override
public void tagGenerate() throws SwiftException {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
Date valueDate = bankToCustomerDebitCreditNotification.getValueDate();
CcyFormatAmount valueAmount = bankToCustomerDebitCreditNotification.getValueAmount();
if(valueDate != null && valueAmount != null){
String dateStr = DateUtil.format(valueDate, "yyMMdd");
String ccy = valueAmount.getCcy();
String amt = NumberUtil.formatAmt(valueAmount.getAmt(), ccy);
tags.add(new Tag(name, dateStr+ccy+amt));
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
Date valueDate = bankToCustomerDebitCreditNotification.getValueDate();
CcyFormatAmount valueAmount = bankToCustomerDebitCreditNotification.getValueAmount();
if(valueDate != null && valueAmount != null){
String dateStr = DateUtil.format(valueDate, "yyMMdd");
String ccy = valueAmount.getCcy();
String amt = NumberUtil.formatAmt(valueAmount.getAmt(), ccy);
tags.add(new Tag(name, dateStr+ccy+amt));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -23,37 +23,42 @@ public class Tag50aGenerate extends AbstractSwiftDto2MtTagGenerate {
@Override
public void tagGenerate() throws SwiftException {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto debitParty = bankToCustomerDebitCreditNotification.getDebitParty();
if (debitParty != null) {
String account = getAccount(debitParty);
String bicCode = debitParty.getPartyBic();
String name = debitParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto debitParty = bankToCustomerDebitCreditNotification.getDebitParty();
if (debitParty != null) {
String account = getAccount(debitParty);
String bicCode = debitParty.getPartyBic();
String name = debitParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = debitParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_K, value));
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = debitParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_K, value));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -21,37 +21,42 @@ public class Tag52aGenerate extends AbstractSwiftDto2MtTagGenerate {
@Override
public void tagGenerate() throws SwiftException {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto debitAgtParty = bankToCustomerDebitCreditNotification.getDebitAgtParty();
if (debitAgtParty != null) {
String account = getAccount(debitAgtParty);
String bicCode = debitAgtParty.getPartyBic();
String name = debitAgtParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto debitAgtParty = bankToCustomerDebitCreditNotification.getDebitAgtParty();
if (debitAgtParty != null) {
String account = getAccount(debitAgtParty);
String bicCode = debitAgtParty.getPartyBic();
String name = debitAgtParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = debitAgtParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_D, value));
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = debitAgtParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_D, value));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -23,39 +23,44 @@ public class Tag56aGenerate extends AbstractSwiftDto2MtTagGenerate {
@Override
public void tagGenerate() throws SwiftException {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto intrymyAgtParty = bankToCustomerDebitCreditNotification.getIntrmyAgtParty();
if (intrymyAgtParty != null) {
String account = getAccount(intrymyAgtParty);
String bicCode = intrymyAgtParty.getPartyBic();
String name = intrymyAgtParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
try {
BankToCustomerDebitCreditNotification bankToCustomerDebitCreditNotification = (BankToCustomerDebitCreditNotification)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
PartyDto intrymyAgtParty = bankToCustomerDebitCreditNotification.getIntrmyAgtParty();
if (intrymyAgtParty != null) {
String account = getAccount(intrymyAgtParty);
String bicCode = intrymyAgtParty.getPartyBic();
String name = intrymyAgtParty.getPartyName();
String value = "";
if (StringUtil.isNotEmpty(bicCode)) {
value = bicCode;
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + bicCode;
}
tags.add(new Tag(name_A, value));
} else if (StringUtil.isNotEmpty(name)) {
if (name.length() > 35) name = name.substring(0, 35);
if (StringUtil.isNotEmpty(account)) {
value = account + Mx2MtConstants.NEW_LINE + name;
} else {
value = name;
}
List<String> addressList = intrymyAgtParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
}
tags.add(new Tag(name_D, value));
} else {
value = name;
}
List<String> addressList = intrymyAgtParty.getAddressList();
for (int i=0; i<addressList.size(); i++) {
if (i == 3) break;
String address = addressList.get(i);
if (address.length() > 35) address = address.substring(0, 35);
value += Mx2MtConstants.NEW_LINE + address;
tags.add(new Tag(name_C, account));
}
tags.add(new Tag(name_D, value));
} else {
tags.add(new Tag(name_C, account));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.swiftdto2mt.mt940950;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtCreator;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.mt940950.impl.*;
import com.brilliance.swift.vo.BankToCustomerStatement;
import java.util.ArrayList;
import java.util.List;
public class SwiftDto2Mt940950Creator extends AbstractSwiftDto2MtCreator {
@Override
public List<SwiftDto2MtTagGenerate> getGenerateTagList() {
List<SwiftDto2MtTagGenerate> list = new ArrayList<>();
list.add(new Tag20Generate());
list.add(new Tag21Generate());
list.add(new Tag25aGenerate());
list.add(new Tag28CGenerate());
list.add(new Tag60aGenerate());
list.add(new Tag61Generate());
list.add(new Tag62aGenerate());
list.add(new Tag64Generate());
list.add(new Tag65Generate());
list.add(new Tag86Generate());
return list;
}
@Override
protected String getMtType() {
BankToCustomerStatement bankToCustomerStatement = (BankToCustomerStatement)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
if(bankToCustomerStatement.getCd().equals("FWAV")||bankToCustomerStatement.getAddtlStmtInf()!=null){
return "940";
}else {
return "950";
}
}
}
package com.brilliance.swift.swiftdto2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerDebitCreditNotification;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag20Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "20";
@Override
public void tagGenerate() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = (BankToCustomerStatement)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if (StringUtil.isNotEmpty(bankToCustomerStatement.getMessageId())) {
tags.add(new Tag(name, bankToCustomerStatement.getMessageId()));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.swiftdto2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag21Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "21";
@Override
public void tagGenerate() throws SwiftException {
try {
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.swiftdto2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag25aGenerate extends AbstractSwiftDto2MtTagGenerate {
private String name = "25";
@Override
public void tagGenerate() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = (BankToCustomerStatement)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
if(bankToCustomerStatement.getAccount()!=null){
tags.add(new Tag(name, bankToCustomerStatement.getAccount().getAccount()));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.swiftdto2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag28CGenerate extends AbstractSwiftDto2MtTagGenerate {
private String name = "28";
@Override
public void tagGenerate() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = (BankToCustomerStatement)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
String elctrncSeqNb = bankToCustomerStatement.getElctrncSeqNb();
String pgNb = bankToCustomerStatement.getPgNb();
String value = pgNb + "/" + elctrncSeqNb;
tags.add(new Tag(name, value));
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.swiftdto2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.BalDto;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
public class Tag60aGenerate extends AbstractSwiftDto2MtTagGenerate {
private String name_F = "60F";
private String name_M = "60M";
@Override
public void tagGenerate() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = (BankToCustomerStatement)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
BalDto openBalance = bankToCustomerStatement.getOpenBalance();
if(openBalance!=null){
String value = "";
String dcMark = "";
if("PRCD".equals(openBalance.getCd())){
tags.add(new Tag(name_F, ""));
}else if("ITBD".equals(openBalance.getCd())){
if("CRDT".equals(openBalance.getCdtDbtInd())){
dcMark = "C";
}else if("DBIT".equals(openBalance.getCdtDbtInd())){
dcMark = "D";
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
Date date = openBalance.getDate();
String ccy = openBalance.getCcy();
BigDecimal amt = openBalance.getAmt();
if(date!=null && ccy!=null){
String dateStr = DateUtil.format(date, "yyMMdd");
value = dcMark + dateStr + ccy + amt;
}
}else {
throw new SwiftException("ERROR", "cannot find filed60Option.");
}
tags.add(new Tag(name_M, value));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.swiftdto2mt.mt940950.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.statementBreakdown;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
public class Tag61Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "61";
@Override
public void tagGenerate() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = (BankToCustomerStatement)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
List<statementBreakdown> statementLineList = bankToCustomerStatement.getStatementLine();
StringBuilder sb = new StringBuilder();
if(statementLineList.size() > 0){
int count = 0;
for (statementBreakdown statementBreakdown : statementLineList) {
if(count>=1){
sb.append(Mx2MtConstants.NEW_LINE).append(":61:");
}
String valueDateStr = "";
String bookDateStr = "";
String dcMark = "";
Date valueDate = statementBreakdown.getValueDate();
Date bookDate = statementBreakdown.getBookDate();
if(valueDate != null){
valueDateStr = DateUtil.format(valueDate, "yyMMdd");
}
if(bookDate != null){
bookDateStr = DateUtil.format(valueDate, "yyMMdd");
}
if("CRDT".equals(statementBreakdown.getCdtDbtInd())){
if("true".equals(statementBreakdown.getCdtDbtInd())){
dcMark = "RD";
}else {
dcMark = "C";
}
}else if("DBIT".equals(statementBreakdown.getCdtDbtInd())){
if("true".equals(statementBreakdown.getCdtDbtInd())){
dcMark = "RC";
}else {
dcMark = "D";
}
}else {
throw new SwiftException("ERROR", "cannot find filed61 D/C Mark.");
}
String ccy = statementBreakdown.getCcy();
BigDecimal amt = statementBreakdown.getAmt();
String transactionType = statementBreakdown.getTransactionType();
String identificationCode = statementBreakdown.getIdentificationCode();
String endToEndId = statementBreakdown.getEndToEndId();
String acctSvcrRef = statementBreakdown.getAcctSvcrRef();
String addtlTxInf = statementBreakdown.getAddtlTxInf();
String addtlNtryInf = statementBreakdown.getAddtlNtryInf();
sb.append(valueDateStr)
.append(bookDateStr)
.append(dcMark)
.append(ccy)
.append(amt)
.append(transactionType)
.append(identificationCode)
.append(endToEndId);
if (StringUtil.isNotEmpty(acctSvcrRef)) {
sb.append("//"+acctSvcrRef);
}
if (StringUtil.isNotEmpty(addtlTxInf)) {
sb.append(Mx2MtConstants.NEW_LINE+addtlTxInf);
}
if(StringUtil.isNotEmpty(addtlNtryInf)){
sb.append(Mx2MtConstants.NEW_LINE).append(":86:").append(StringUtil.getStringByEnter(addtlNtryInf, 35, 6));
}
count++;
}
}
tags.add(new Tag(name, sb.toString()));
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.swiftdto2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.BalDto;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
public class Tag62aGenerate extends AbstractSwiftDto2MtTagGenerate {
private String name_F = "62F";
private String name_M = "62M";
@Override
public void tagGenerate() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = (BankToCustomerStatement)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
BalDto closingBalance = bankToCustomerStatement.getClosingBalance();
if(closingBalance!=null){
String value = "";
String dcMark = "";
if("CLBD".equals(closingBalance.getCd())){
tags.add(new Tag(name_F, ""));
}else if("ITBD".equals(closingBalance.getCd())){
if("CRDT".equals(closingBalance.getCdtDbtInd())){
dcMark = "C";
}else if("DBIT".equals(closingBalance.getCdtDbtInd())){
dcMark = "D";
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
Date date = closingBalance.getDate();
String ccy = closingBalance.getCcy();
BigDecimal amt = closingBalance.getAmt();
if(date!=null && ccy!=null){
String dateStr = DateUtil.format(date, "yyMMdd");
value = dcMark + dateStr + ccy + amt;
}
}else {
throw new SwiftException("ERROR", "cannot find filed60Option.");
}
tags.add(new Tag(name_M, value));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.swiftdto2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.BalDto;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
public class Tag64Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "64";
@Override
public void tagGenerate() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = (BankToCustomerStatement)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
BalDto closingAvailableBalance = bankToCustomerStatement.getClosingAvailableBalance();
if(closingAvailableBalance!=null && "CLBD".equals(closingAvailableBalance.getCd())){
String value = "";
String dcMark = "";
if("CRDT".equals(closingAvailableBalance.getCdtDbtInd())){
dcMark = "C";
}else if("DBIT".equals(closingAvailableBalance.getCdtDbtInd())){
dcMark = "D";
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
Date date = closingAvailableBalance.getDate();
String ccy = closingAvailableBalance.getCcy();
BigDecimal amt = closingAvailableBalance.getAmt();
if(date!=null && ccy!=null){
String dateStr = DateUtil.format(date, "yyMMdd");
value = dcMark + dateStr + ccy + amt;
}
tags.add(new Tag(name, value));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.swiftdto2mt.mt940950.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.brilliance.swift.vo.common.BalDto;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.model.mx.dic.Value;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
public class Tag65Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "65";
@Override
public void tagGenerate() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = (BankToCustomerStatement)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
List<BalDto> forwardAvailableBalanceList = bankToCustomerStatement.getForwardAvailableBalance();
StringBuilder sb = new StringBuilder();
if(forwardAvailableBalanceList.size()>0){
int count = 0;
for (BalDto forwardAvailableBalance : forwardAvailableBalanceList) {
if(count>=1){
sb.append(Mx2MtConstants.NEW_LINE).append(":65:");
}
if(forwardAvailableBalance!=null && "FWAV".equals(forwardAvailableBalance.getCd())){
String dcMark = "";
if("CRDT".equals(forwardAvailableBalance.getCdtDbtInd())){
dcMark = "C";
}else if("DBIT".equals(forwardAvailableBalance.getCdtDbtInd())){
dcMark = "D";
}else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
Date date = forwardAvailableBalance.getDate();
String ccy = forwardAvailableBalance.getCcy();
BigDecimal amt = forwardAvailableBalance.getAmt();
if(date!=null && ccy!=null){
String dateStr = DateUtil.format(date, "yyMMdd");
sb.append(dcMark).append(dateStr).append(ccy).append(amt);
}
}
count++;
}
tags.add(new Tag(name, sb.toString()));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.swiftdto2mt.mt940950.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.swiftdto2mt.AbstractSwiftDto2MtTagGenerate;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtContextIdentifier;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.BankToCustomerStatement;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.Tag;
import java.util.List;
public class Tag86Generate extends AbstractSwiftDto2MtTagGenerate {
private String name = "86";
@Override
public void tagGenerate() throws SwiftException {
try {
BankToCustomerStatement bankToCustomerStatement = (BankToCustomerStatement)context.get(SwiftDto2MtContextIdentifier.SWIFT_DTO_OBJ, true);
SwiftMessage swiftMessage = context.get(SwiftMessage.class);
List<Tag> tags = swiftMessage.getBlock4().getTags();
List<String> addtlStmtInfList = bankToCustomerStatement.getAddtlStmtInf();
StringBuilder sb = new StringBuilder();
if(addtlStmtInfList.size()>0){
int count = 0;
for (String addtlStmtInf : addtlStmtInfList) {
if(count>=1){
sb.append(Mx2MtConstants.NEW_LINE).append(":86:");
}
sb.append(StringUtil.getStringByEnter(addtlStmtInf, 35, 6));
count++;
}
tags.add(new Tag(name, sb.toString()));
}
}catch (Exception e){
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -104,4 +104,5 @@ public class BankToCustomerDebitCreditNotification extends SwiftDto{
public void setAddtlTxInf(String addtlTxInf) {
this.addtlTxInf = addtlTxInf;
}
}
package com.brilliance.swift.vo;
import com.brilliance.swift.vo.common.BalDto;
import com.brilliance.swift.vo.common.NtryDto;
import com.brilliance.swift.vo.common.PartyAccount;
import com.brilliance.swift.vo.common.statementBreakdown;
import java.util.ArrayList;
import java.util.List;
......@@ -12,40 +13,40 @@ import java.util.List;
*/
public class BankToCustomerStatement extends SwiftDto{
protected String mtType;
protected String cd;
protected String ibanId;
protected PartyAccount account;
protected String pgNb;
protected String elctrncSeqNb;
protected BalDto openBal;
protected BalDto openingBalance;
protected List<NtryDto> lineNtry;
protected List<statementBreakdown> statementLine;
protected BalDto closBal;
protected BalDto closingBalance;
protected BalDto closAvaBal;
protected BalDto closingAvailableBalance;
protected List<BalDto> forwAvaBal;
protected List<BalDto> forwardAvailableBalance;
protected List<String> addtlStmtInf;
public String getMtType() {
return mtType;
public String getCd() {
return cd;
}
public void setMtType(String mtType) {
this.mtType = mtType;
public void setCd(String cd) {
this.cd = cd;
}
public String getIbanId() {
return ibanId;
public PartyAccount getAccount() {
return account;
}
public void setIbanId(String ibanId) {
this.ibanId = ibanId;
public void setAccount(PartyAccount account) {
this.account = account;
}
public String getPgNb() {
......@@ -64,31 +65,31 @@ public class BankToCustomerStatement extends SwiftDto{
this.elctrncSeqNb = elctrncSeqNb;
}
public BalDto getOpenBal() {
return openBal;
public BalDto getOpenBalance() {
return openingBalance;
}
public void setOpenBal(BalDto openBal) {
this.openBal = openBal;
public void setOpenBalance(BalDto openBalance) {
this.openingBalance = openBalance;
}
public BalDto getClosAvaBal() {
return closAvaBal;
public BalDto getClosingAvailableBalance() {
return closingAvailableBalance;
}
public void setClosAvaBal(BalDto closAvaBal) {
this.closAvaBal = closAvaBal;
public void setClosingAvailableBalance(BalDto closingAvailableBalance) {
this.closingAvailableBalance = closingAvailableBalance;
}
public List<BalDto> getForwAvaBal() {
if(forwAvaBal == null){
forwAvaBal = new ArrayList<>();
public List<BalDto> getForwardAvailableBalance() {
if(forwardAvailableBalance == null){
forwardAvailableBalance = new ArrayList<>();
}
return forwAvaBal;
return forwardAvailableBalance;
}
public BankToCustomerStatement addBalDtoSixFive(BalDto balDtoSixFive) {
getForwAvaBal().add(balDtoSixFive);
getForwardAvailableBalance().add(balDtoSixFive);
return this;
}
......@@ -104,23 +105,23 @@ public class BankToCustomerStatement extends SwiftDto{
return this;
}
public BankToCustomerStatement addNtryDto(NtryDto ntryDto){
getLineNtry().add(ntryDto);
public BankToCustomerStatement addNtryDto(statementBreakdown statementBreakdown){
getStatementLine().add(statementBreakdown);
return this;
}
public List<NtryDto> getLineNtry() {
if(lineNtry == null){
lineNtry = new ArrayList<>();
public List<statementBreakdown> getStatementLine() {
if(statementLine == null){
statementLine = new ArrayList<>();
}
return lineNtry;
return statementLine;
}
public BalDto getClosBal() {
return closBal;
public BalDto getClosingBalance() {
return closingBalance;
}
public void setClosBal(BalDto closBal) {
this.closBal = closBal;
public void setClosingBalance(BalDto closingBalance) {
this.closingBalance = closingBalance;
}
}
......@@ -24,6 +24,8 @@ public class SwiftDtoAdapter implements JsonSerializer<SwiftDto>, JsonDeserializ
className = "com.brilliance.swift.vo.VoFinancialInstitutionCreditTransfer";
}else if("camt.054.001".equals(prim.getAsString())){
className = "com.brilliance.swift.vo.BankToCustomerDebitCreditNotification";
}else if("camt.053.001".equals(prim.getAsString())){
className = "com.brilliance.swift.vo.BankToCustomerStatement";
}
klass = Class.forName(className);
} catch (ClassNotFoundException e) {
......
......@@ -9,7 +9,9 @@ import java.util.Date;
*/
public class BalDto {
private String balCdtDbtInd;
private String cd;
private String CdtDbtInd;
private Date date;
......@@ -17,12 +19,20 @@ public class BalDto {
private BigDecimal amt = BigDecimal.ZERO;
public String getBalCdtDbtInd() {
return balCdtDbtInd;
public String getCd() {
return cd;
}
public void setCd(String cd) {
this.cd = cd;
}
public String getCdtDbtInd() {
return CdtDbtInd;
}
public void setBalCdtDbtInd(String balCdtDbtInd) {
this.balCdtDbtInd = balCdtDbtInd;
public void setCdtDbtInd(String cdtDbtInd) {
this.CdtDbtInd = cdtDbtInd;
}
public Date getDate() {
......
package com.brilliance.swift.vo.common;
import com.sun.org.apache.bcel.internal.classfile.Code;
import java.math.BigDecimal;
import java.util.Date;
......@@ -9,14 +7,16 @@ import java.util.Date;
* @author zh
* @create 2022-04-21 14:08
*/
public class NtryDto {
public class statementBreakdown {
private Date ValDate;
private Date valueDate;
private Date BookDate;
private String cdtDbtInd;
private String rvslInd = "false";
private String ccy;
private BigDecimal amt = BigDecimal.ZERO;
......@@ -27,16 +27,18 @@ public class NtryDto {
private String endToEndId;
private String acctSvcrRef;
private String addtlTxInf;
private String addtlNtryInf;
public Date getValDate() {
return ValDate;
public Date getValueDate() {
return valueDate;
}
public void setValDate(Date valDate) {
ValDate = valDate;
public void setValueDate(Date valueDate) {
this.valueDate = valueDate;
}
public Date getBookDate() {
......@@ -55,6 +57,14 @@ public class NtryDto {
this.cdtDbtInd = cdtDbtInd;
}
public String getRvslInd() {
return rvslInd;
}
public void setRvslInd(String rvslInd) {
this.rvslInd = rvslInd;
}
public String getCcy() {
return ccy;
}
......@@ -95,6 +105,14 @@ public class NtryDto {
this.endToEndId = endToEndId;
}
public String getAcctSvcrRef() {
return acctSvcrRef;
}
public void setAcctSvcrRef(String acctSvcrRef) {
this.acctSvcrRef = acctSvcrRef;
}
public String getAddtlTxInf() {
return addtlTxInf;
}
......
{
"cdtDbtCode": "910",
"cdtDbtCode": "CRDT",
"endToEndId": "E2E1201",
"account": {"account": "S15612345678012345"},
"account": {
"account": "S15612345678012345"
},
"valueDate": "2022-03-30 00:00:00,000",
"valueAmount": {
"ccy": "EUR",
......@@ -26,15 +28,15 @@
"ADDRESS 3"
],
"partyAcct": {
"ibanAcct": "FR7630588000010050000143176"
"account": "R7630588000010050000143176"
}
},
"addtlTxInf": "ENRICHED|TRUE SETT_METHOD|SEPA IAT_IND|FALSE DOMESTIC_IND|FALSE PRIORITY_IND|FALSE",
"messageType": "camt.054.001",
"senderBic": "DEUTDEFF",
"receiverBic": "DEUTNL2A",
"createDate": "2022-04-27 09:14:15,482",
"createDate": "2022-04-28 10:10:13,797",
"messagePriority": "NORM",
"messageId": "FRDA000003421606",
"uetr": "8a562c67-ca16-48ba-b074-65581be6f001"
}
}
\ No newline at end of file
{
"cdtDbtCode": "DBIT",
"endToEndId": "E2E1201",
"account": {"account": "S15612345678012345"},
"account": {
"account": "S15612345678012345"
},
"valueDate": "2022-03-30 00:00:00,000",
"valueAmount": {
"ccy": "EUR",
"amt": 126
},
"debitAgtParty": {
"partyName": "Creditor 1",
"addressList": [
"TEST1",
"TEST2",
"TEST3"
],
"partyAcct": {
"ibanAcct": "FR7630588000010050000143176"
}
},
"addtlTxInf": "ENRICHED|TRUE SETT_METHOD|SEPA IAT_IND|FALSE DOMESTIC_IND|FALSE PRIORITY_IND|FALSEENRICHED|TRUE SETT_METHOD|SEPA IAT_ENRICHED|TRUE SETT_METHOD|SEPA IAT_ENRICHED|TRUE SETT_METHOD|SEPA IAT_ENRICHED|TRUE SETT_METH",
"messageType": "camt.054.001",
"senderBic": "DEUTDEFF",
"receiverBic": "DEUTNL2A",
"createDate": "2022-04-27 09:37:39,978",
"createDate": "2022-04-28 10:10:09,688",
"messagePriority": "NORM",
"messageId": "FRDA000003421606",
"uetr": "8a562c67-ca16-48ba-b074-65581be6f001"
}
}
\ No newline at end of file
{
"cd": "FWAV",
"account": {
"account": "S15612345678012345"
},
"pgNb": "178",
"elctrncSeqNb": "200",
"openingBalance": {
"cd": "ITBD",
"CdtDbtInd": "DBIT",
"date": "2022-03-30 00:00:00,000",
"ccy": "USD",
"amt": 120274.34
},
"statementLine": [
{
"valueDate": "2022-03-30 00:00:00,000",
"BookDate": "2022-03-30 00:00:00,000",
"cdtDbtInd": "DBIT",
"rvslInd": "false",
"ccy": "USD",
"amt": 393.17,
"transactionType": "F",
"identificationCode": "CHK",
"endToEndId": "S100000189-735",
"acctSvcrRef": "1309170100000390154395",
"addtlTxInf": "PLACI LOVECNAMENSKIH WUHAN",
"addtlNtryInf": "CHINESE BEIJING"
},
{
"valueDate": "2022-03-30 00:00:00,000",
"BookDate": "2022-03-30 00:00:00,000",
"cdtDbtInd": "DBIT",
"rvslInd": "false",
"ccy": "USD",
"amt": 445,
"transactionType": "F",
"identificationCode": "CHK",
"endToEndId": "S100000189-735",
"acctSvcrRef": "1309170100000390154395",
"addtlTxInf": "PLACI LOVECNAMENSKIH STORITEV",
"addtlNtryInf": "HELLO WORLD"
}
],
"closingBalance": {
"cd": "ITBD",
"CdtDbtInd": "DBIT",
"date": "2022-03-30 00:00:00,000",
"ccy": "USD",
"amt": 123456.29
},
"closingAvailableBalance": {
"cd": "CLAV",
"CdtDbtInd": "DBIT",
"date": "2022-03-30 00:00:00,000",
"ccy": "USD",
"amt": 119609.29
},
"forwardAvailableBalance": [
{
"cd": "FWAV",
"CdtDbtInd": "DBIT",
"date": "2022-03-30 00:00:00,000",
"ccy": "USD",
"amt": 120274.34
}
],
"addtlStmtInf": [
"CHINESE BEIJING",
"HELLO WORLD"
],
"messageType": "camt.053.001",
"senderBic": "SHWHQWER123",
"receiverBic": "BJWHS12X",
"createDate": "2022-04-28 10:23:46,048",
"messagePriority": "NORM",
"messageId": "00010013800002001234"
}
\ No newline at end of file
{
"cd": "",
"account": {
"account": "S15612345678012345"
},
"pgNb": "178",
"elctrncSeqNb": "200",
"openingBalance": {
"cd": "ITBD",
"CdtDbtInd": "DBIT",
"date": "2022-03-30 00:00:00,000",
"ccy": "USD",
"amt": 120274.34
},
"statementLine": [
{
"valueDate": "2022-03-30 00:00:00,000",
"BookDate": "2022-03-30 00:00:00,000",
"cdtDbtInd": "DBIT",
"rvslInd": "false",
"ccy": "USD",
"amt": 393.17,
"transactionType": "F",
"identificationCode": "CHK",
"endToEndId": "S100000189-735",
"acctSvcrRef": "1309170100000390154395",
"addtlTxInf": "PLACI LOVECNAMENSKIH WUHAN"
},
{
"valueDate": "2022-03-30 00:00:00,000",
"BookDate": "2022-03-30 00:00:00,000",
"cdtDbtInd": "DBIT",
"rvslInd": "false",
"ccy": "USD",
"amt": 445,
"transactionType": "F",
"identificationCode": "CHK",
"endToEndId": "S100000189-735",
"acctSvcrRef": "1309170100000390154395",
"addtlTxInf": "PLACI LOVECNAMENSKIH STORITEV"
}
],
"closingBalance": {
"cd": "ITBD",
"CdtDbtInd": "DBIT",
"date": "2022-03-30 00:00:00,000",
"ccy": "USD",
"amt": 123456.29
},
"messageType": "camt.053.001",
"senderBic": "SHWHQWER123",
"receiverBic": "BJWHS12X",
"createDate": "2022-04-28 10:24:00,960",
"messagePriority": "NORM",
"messageId": "00010013800002001234"
}
\ No newline at end of file
......@@ -8,8 +8,6 @@ Creditor 1
TEST1
TEST2
TEST3
:52A:/null
QWERASDF
:56D:/FR7630588000010050000143176
81939316
ADDRESS 1
......
......@@ -75,7 +75,7 @@
<Bal>
<Tp>
<CdOrPrtry>
<Cd>ITBD</Cd>
<Cd>FWAV</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="USD">123456.29</Amt>
......@@ -87,7 +87,7 @@
<Bal>
<Tp>
<CdOrPrtry>
<Cd>CLAV</Cd>
<Cd>FWAV</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="USD">119609.29</Amt>
......
package com.brilliance.mt2swiftdto.camt053001;
import com.brilliance.swift.mt2SwiftDto.Mt2SwiftDtoCreateManager;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.vo.SwiftDto;
import java.io.File;
public class Test900Camt053001 {
public class Test940Camt053001 {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\MT900.txt");
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\MT940.txt");
SwiftDto swiftDto = new SwiftTransfer().mt2SwiftDto(file, "D:/test1/BankToCustomerStatement.json", null);
System.out.println(swiftDto.toString());
}
}
package com.brilliance.mt2swiftdto.camt053001;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.vo.SwiftDto;
import java.io.File;
public class Test950Camt053001 {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\MT950.txt");
SwiftDto swiftDto = new SwiftTransfer().mt2SwiftDto(file, "D:/test1/BankToStatement.json", null);
System.out.println(swiftDto.toString());
}
}
package com.brilliance.mt2swiftdto.camt054001;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.vo.SwiftDto;
import java.io.File;
public class Test900Camt054001 {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\MT900.txt");
SwiftDto swiftDto = new SwiftTransfer().mt2SwiftDto(file, "D:/test1/BankToCustomerDebitNotification.json", null);
System.out.println(swiftDto.toString());
}
}
package com.brilliance.mt2swiftdto.camt054001;
import com.brilliance.swift.SwiftTransfer;
import com.brilliance.swift.vo.SwiftDto;
import java.io.File;
public class Test910Camt054001 {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\MT910.txt");
SwiftDto swiftDto = new SwiftTransfer().mt2SwiftDto(file, "D:/test1/BankToCustomerCreditNotification.json", null);
System.out.println(swiftDto.toString());
}
}
......@@ -7,8 +7,8 @@ import java.io.File;
public class Test {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\");
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(file, null, null);
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\BankToCustomerDebitNotification.json");
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(file, "D:/test2/MT900.txt", null);
System.out.println(mtStr);
}
}
......@@ -7,8 +7,8 @@ import java.io.File;
public class Test {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\");
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(file, null, null);
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\BankToCustomerCreditNotification.json");
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(file, "D:/test2/MT910.txt", null);
System.out.println(mtStr);
}
}
package com.brilliance.swiftdto2mt.mt940;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtCreatorManager;
import java.io.File;
public class Test {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\BankToCustomerStatement.json");
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(file, "D:/test2/MT940.txt", null);
System.out.println(mtStr);
}
}
package com.brilliance.swiftdto2mt.mt950;
import com.brilliance.swift.swiftdto2mt.SwiftDto2MtCreatorManager;
import java.io.File;
public class Test {
public static void main(String[] args) {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftJson\\BankToStatement.json");
String mtStr = new SwiftDto2MtCreatorManager().swiftDto2Mt(file, "D:/test2/MT950.txt", null);
System.out.println(mtStr);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment