http://jira.mfd.msk:8088/browse/CLS-189 PaymentInstructionCreator
This commit is contained in:
parent
bfbd0a8da4
commit
bb18e4909b
1 changed files with 277 additions and 157 deletions
|
|
@ -101,32 +101,16 @@ public class PaymentInstructionCreator {
|
|||
|
||||
// I
|
||||
if (clearingCategory.contains(ClearingCategory.I)) {
|
||||
log.debug("By liabilitiesClaimsAssets[{}] create for category I 2 PaymentInstruction record", liabilitiesClaimsAssets.getId());
|
||||
log.debug("By liabilitiesClaimsAssets[{}] create for category I 1 PaymentInstruction record", liabilitiesClaimsAssets.getId());
|
||||
PaymentInstruction payment1 = new PaymentInstruction();
|
||||
PaymentInstruction payment2 = new PaymentInstruction();
|
||||
|
||||
payment1.setId(idGenerator.nextId());
|
||||
payment1.setCreated(now);
|
||||
payment1.setClearingDate(TimeUtil.toLocalDate(now));
|
||||
payment2.setId(idGenerator.nextId());
|
||||
payment2.setCreated(now);
|
||||
payment2.setClearingDate(TimeUtil.toLocalDate(now));
|
||||
|
||||
payment1.setSenderId(liabilitiesClaimsAssets.getCompanyId());
|
||||
payment2.setSenderId(SPVB_ID); // СПВБ
|
||||
|
||||
payment1.setAddresseeId(SPVB_ID); // СПВБ
|
||||
{
|
||||
String sqlLCA = String.format("exchangeExecutionId = %s and side != '%s'",
|
||||
executionDeposit.getExchangeExecutionId(), executionDeposit.getSide());
|
||||
ExecutionDeposit counterExecutionDeposit = executionDepositImdg.getSingleObjectBySQL(sqlLCA);
|
||||
if (counterExecutionDeposit == null) {
|
||||
log.warn("Counter ExecutionDeposit not found for : {}", sqlLCA);
|
||||
} else {
|
||||
payment2.setAddresseeId(counterExecutionDeposit.getCompanyId());
|
||||
log.trace("payment2.AddresseeId={} found by: {}", payment2.getAddresseeId(), sqlLCA);
|
||||
}
|
||||
}
|
||||
|
||||
String symbol1 = selectSymbolValue(payment1.getAddresseeId(), CompanySymbol.BIC);
|
||||
if (symbol1 == null) {
|
||||
|
|
@ -134,12 +118,6 @@ public class PaymentInstructionCreator {
|
|||
} else {
|
||||
payment1.setAdresseeBic(symbol1);
|
||||
}
|
||||
String symbol2 = selectSymbolValue(payment2.getAddresseeId(), CompanySymbol.BIC);
|
||||
if (symbol2 == null) {
|
||||
log.warn("CompanySymbols BIC not found for companyId={}", payment2.getAddresseeId());
|
||||
} else {
|
||||
payment2.setAdresseeBic(symbol2);
|
||||
}
|
||||
|
||||
Company companyPRC = companyImdg.getSingleObjectByID(PRC_ID); // 2 "НКО АО ПРЦ"
|
||||
String companyPRCName = null;
|
||||
|
|
@ -149,53 +127,31 @@ public class PaymentInstructionCreator {
|
|||
companyPRCName = companyPRC.getShortName();
|
||||
}
|
||||
payment1.setPayeeBankName(companyPRCName);
|
||||
payment2.setPayeeBankName(companyPRCName);
|
||||
|
||||
String symbolPRC = selectSymbolValue(PRC_ID, CompanySymbol.BIC); // 2 "НКО АО ПРЦ"
|
||||
payment1.setPayeeBic(symbolPRC);
|
||||
payment2.setPayeeBic(symbolPRC);
|
||||
|
||||
payment1.setAddresseeBankName(companyPRCName);
|
||||
payment2.setAddresseeBankName(companyPRCName);
|
||||
|
||||
payment1.setPaymentDate(TimeUtil.localDateToInstant(liabilitiesClaimsAssets.getSettlementDate()));
|
||||
payment2.setPaymentDate(TimeUtil.localDateToInstant(liabilitiesClaimsAssets.getSettlementDate()));
|
||||
|
||||
payment1.setPaymentPurpose("Размещение депозита " + liabilitiesClaimsAssets.getContract());
|
||||
payment2.setPaymentPurpose("Размещение депозита " + liabilitiesClaimsAssets.getContract());
|
||||
|
||||
payment1.setSettlementDate(liabilitiesClaimsAssets.getSettlementDate());
|
||||
payment2.setSettlementDate(liabilitiesClaimsAssets.getSettlementDate());
|
||||
|
||||
Long amount = liabilitiesClaimsAssets.getLiabilitiesQuantity() == null ? null : liabilitiesClaimsAssets.getLiabilitiesQuantity().abs().longValue();
|
||||
payment1.setCreditLegAmount(amount);
|
||||
payment2.setCreditLegAmount(amount);
|
||||
payment1.setDebitLegAmount(amount);
|
||||
payment2.setDebitLegAmount(amount);
|
||||
|
||||
payment1.setCreditLegAccountId(liabilitiesClaimsAssets.getAccountId());
|
||||
{
|
||||
Account anotherAcc = selectAccount(payment2.getSenderId(), AccountType.Tran, Status.Active, Allowed.ALLOWED);
|
||||
if (anotherAcc == null) {
|
||||
log.warn("Account not found: companyId = {} AND accountType={} AND accountStatus={} AND processingSign={}",
|
||||
payment2.getSenderId(), AccountType.Tran, Status.Active, Allowed.ALLOWED);
|
||||
} else {
|
||||
payment2.setCreditLegAccountId(anotherAcc.getId());
|
||||
}
|
||||
}
|
||||
|
||||
payment1.setCreditCsAccount(null);
|
||||
payment2.setCreditCsAccount(null);
|
||||
|
||||
{
|
||||
Account acc1 = accountImdg.getSingleObjectByID(payment1.getCreditLegAccountId());
|
||||
if (acc1 != null) {
|
||||
payment1.setCreditLegAccount(acc1.getAccount());
|
||||
}
|
||||
Account acc2 = accountImdg.getSingleObjectByID(payment2.getCreditLegAccountId());
|
||||
if (acc2 != null) {
|
||||
payment2.setCreditLegAccount(acc2.getAccount());
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -204,45 +160,31 @@ public class PaymentInstructionCreator {
|
|||
payment1.setDebitLegAccountId(acc1.getId());
|
||||
payment1.setDebitLegAccount(acc1.getAccount());
|
||||
}
|
||||
Account acc2 = selectAccount(payment2.getAddresseeId(), AccountType.Clrn, Status.Active, Allowed.ALLOWED);
|
||||
if (acc2 != null) {
|
||||
payment2.setDebitLegAccountId(acc2.getId());
|
||||
payment2.setDebitLegAccount(acc2.getAccount());
|
||||
}
|
||||
}
|
||||
|
||||
payment1.setDebitCsAccount(null);
|
||||
payment2.setDebitCsAccount(null);
|
||||
|
||||
// payment1.setCreditLegDirection(InOutDirection.out.getKey());
|
||||
// payment2.setCreditLegDirection(InOutDirection.out.getKey());
|
||||
// payment1.setDebitLegDirection(InOutDirection.in.getKey());
|
||||
// payment2.setDebitLegDirection(InOutDirection.in.getKey());
|
||||
|
||||
payment1.setCreditLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
payment2.setCreditLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
payment1.setDebitLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
payment2.setDebitLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
|
||||
payment1.setTransactionStatus(TransactionStatus.stld.getKey());
|
||||
payment2.setTransactionStatus(TransactionStatus.stld.getKey());
|
||||
|
||||
|
||||
payment1.setDocumentNumber(nextDocumentNumber(liabilitiesClaimsAssets, payment1));
|
||||
payment2.setDocumentNumber(nextDocumentNumber(liabilitiesClaimsAssets, payment2));
|
||||
|
||||
newPaymentInstructions.add(payment1);
|
||||
newPaymentInstructions.add(payment2);
|
||||
} else {
|
||||
// V / B
|
||||
if (clearingCategory.contains(ClearingCategory.V)) {
|
||||
log.debug("By liabilitiesClaimsAssets[{}] create for category V 1 PaymentInstruction record", liabilitiesClaimsAssets.getId());
|
||||
PaymentInstruction payment1 = new PaymentInstruction();
|
||||
payment1.setId(idGenerator.nextId());
|
||||
payment1.setCreated(now);
|
||||
payment1.setClearingDate(TimeUtil.toLocalDate(now));
|
||||
|
||||
payment1.setSenderId(SPVB_ID); // СПВБ
|
||||
/*{
|
||||
PaymentInstruction payment2 = new PaymentInstruction();
|
||||
|
||||
payment2.setId(idGenerator.nextId());
|
||||
payment2.setCreated(now);
|
||||
payment2.setClearingDate(TimeUtil.toLocalDate(now));
|
||||
|
||||
payment2.setSenderId(SPVB_ID); // СПВБ
|
||||
|
||||
{
|
||||
String sqlLCA = String.format("exchangeExecutionId = %s and side != '%s'",
|
||||
|
|
@ -251,16 +193,16 @@ public class PaymentInstructionCreator {
|
|||
if (counterExecutionDeposit == null) {
|
||||
log.warn("Counter ExecutionDeposit not found for : {}", sqlLCA);
|
||||
} else {
|
||||
payment1.setAddresseeId(counterExecutionDeposit.getCompanyId());
|
||||
log.trace("payment1.AddresseeId={} found by: {}", payment1.getAddresseeId(), sqlLCA);
|
||||
payment2.setAddresseeId(counterExecutionDeposit.getCompanyId());
|
||||
log.trace("payment2.AddresseeId={} found by: {}", payment2.getAddresseeId(), sqlLCA);
|
||||
}
|
||||
}
|
||||
|
||||
String symbol1 = selectSymbolValue(payment1.getAddresseeId(), CompanySymbol.BIC);
|
||||
if (symbol1 == null) {
|
||||
log.warn("CompanySymbols BIC not found for companyId={}", payment1.getAddresseeId());
|
||||
String symbol2 = selectSymbolValue(payment2.getAddresseeId(), CompanySymbol.BIC);
|
||||
if (symbol2 == null) {
|
||||
log.warn("CompanySymbols BIC not found for companyId={}", payment2.getAddresseeId());
|
||||
} else {
|
||||
payment1.setAdresseeBic(symbol1);
|
||||
payment2.setAdresseeBic(symbol2);
|
||||
}
|
||||
|
||||
Company companyPRC = companyImdg.getSingleObjectByID(PRC_ID); // 2 "НКО АО ПРЦ"
|
||||
|
|
@ -270,136 +212,314 @@ public class PaymentInstructionCreator {
|
|||
} else {
|
||||
companyPRCName = companyPRC.getShortName();
|
||||
}
|
||||
payment1.setPayeeBankName(companyPRCName);
|
||||
payment2.setPayeeBankName(companyPRCName);
|
||||
|
||||
String symbolPRC = selectSymbolValue(PRC_ID, CompanySymbol.BIC); // 2 "НКО АО ПРЦ"
|
||||
payment1.setPayeeBic(symbolPRC);
|
||||
payment2.setPayeeBic(symbolPRC);
|
||||
|
||||
payment1.setAddresseeBankName(companyPRCName);
|
||||
payment2.setAddresseeBankName(companyPRCName);
|
||||
|
||||
payment1.setPaymentDate(TimeUtil.localDateToInstant(liabilitiesClaimsAssets.getSettlementDate()));
|
||||
payment2.setPaymentDate(TimeUtil.localDateToInstant(liabilitiesClaimsAssets.getSettlementDate()));
|
||||
|
||||
payment1.setPaymentPurpose("Размещение депозита " + liabilitiesClaimsAssets.getContract());
|
||||
payment2.setPaymentPurpose("Размещение депозита " + liabilitiesClaimsAssets.getContract());
|
||||
|
||||
payment1.setSettlementDate(liabilitiesClaimsAssets.getSettlementDate());
|
||||
payment2.setSettlementDate(liabilitiesClaimsAssets.getSettlementDate());
|
||||
|
||||
Long amount = liabilitiesClaimsAssets.getLiabilitiesQuantity() == null ? null : liabilitiesClaimsAssets.getLiabilitiesQuantity().abs().longValue();
|
||||
payment1.setCreditLegAmount(amount);
|
||||
payment1.setDebitLegAmount(amount);
|
||||
payment2.setCreditLegAmount(amount);
|
||||
payment2.setDebitLegAmount(amount);
|
||||
|
||||
{
|
||||
Account acc1 = selectAccount(payment1.getSenderId(), AccountType.Anlt, Status.Active, Allowed.ALLOWED);
|
||||
if (acc1 == null) {
|
||||
Account anotherAcc = selectAccount(payment2.getSenderId(), AccountType.Tran, Status.Active, Allowed.ALLOWED);
|
||||
if (anotherAcc == null) {
|
||||
log.warn("Account not found: companyId = {} AND accountType={} AND accountStatus={} AND processingSign={}",
|
||||
payment1.getSenderId(), AccountType.Anlt, Status.Active, Allowed.ALLOWED);
|
||||
payment2.getSenderId(), AccountType.Tran, Status.Active, Allowed.ALLOWED);
|
||||
} else {
|
||||
payment1.setCreditLegAccountId(acc1.getId());
|
||||
payment1.setCreditLegAccount(acc1.getAccount());
|
||||
payment2.setCreditLegAccountId(anotherAcc.getId());
|
||||
}
|
||||
}
|
||||
|
||||
payment1.setCreditCsAccount(null);
|
||||
payment2.setCreditCsAccount(null);
|
||||
|
||||
{
|
||||
Account acc1 = selectAccount(payment1.getAddresseeId(), AccountType.Corr, Status.Active, Allowed.ALLOWED);
|
||||
if (acc1 != null) {
|
||||
payment1.setDebitLegAccountId(acc1.getId());
|
||||
payment1.setDebitLegAccount(acc1.getAccount());
|
||||
Account acc2 = accountImdg.getSingleObjectByID(payment2.getCreditLegAccountId());
|
||||
if (acc2 != null) {
|
||||
payment2.setCreditLegAccount(acc2.getAccount());
|
||||
}
|
||||
}
|
||||
|
||||
payment1.setDebitCsAccount(null);
|
||||
{
|
||||
Account acc2 = selectAccount(payment2.getAddresseeId(), AccountType.Clrn, Status.Active, Allowed.ALLOWED);
|
||||
if (acc2 != null) {
|
||||
payment2.setDebitLegAccountId(acc2.getId());
|
||||
payment2.setDebitLegAccount(acc2.getAccount());
|
||||
}
|
||||
}
|
||||
|
||||
// payment1.setCreditLegDirection(InOutDirection.out.getKey());
|
||||
// payment1.setDebitLegDirection(InOutDirection.in.getKey());
|
||||
payment2.setDebitCsAccount(null);
|
||||
|
||||
payment1.setCreditLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
payment1.setDebitLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
// payment2.setCreditLegDirection(InOutDirection.out.getKey());
|
||||
// payment2.setDebitLegDirection(InOutDirection.in.getKey());
|
||||
|
||||
payment1.setTransactionStatus(TransactionStatus.stld.getKey());
|
||||
payment2.setCreditLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
payment2.setDebitLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
|
||||
payment2.setTransactionStatus(TransactionStatus.stld.getKey());
|
||||
|
||||
|
||||
payment1.setDocumentNumber(nextDocumentNumber(liabilitiesClaimsAssets, payment1));
|
||||
payment2.setDocumentNumber(nextDocumentNumber(liabilitiesClaimsAssets, payment2));
|
||||
|
||||
newPaymentInstructions.add(payment1);
|
||||
} else // Для V,B только 1 PaymentInstruction
|
||||
newPaymentInstructions.add(payment2);
|
||||
}*/
|
||||
} else {
|
||||
// V / B
|
||||
if (clearingCategory.contains(ClearingCategory.V)) {
|
||||
log.debug("By liabilitiesClaimsAssets[{}] create for category V 0 PaymentInstruction record - ignore", liabilitiesClaimsAssets.getId());
|
||||
// PaymentInstruction payment1 = new PaymentInstruction();
|
||||
// payment1.setId(idGenerator.nextId());
|
||||
// payment1.setCreated(now);
|
||||
// payment1.setClearingDate(TimeUtil.toLocalDate(now));
|
||||
//
|
||||
// payment1.setSenderId(SPVB_ID); // СПВБ
|
||||
//
|
||||
// {
|
||||
// String sqlLCA = String.format("exchangeExecutionId = %s and side != '%s'",
|
||||
// executionDeposit.getExchangeExecutionId(), executionDeposit.getSide());
|
||||
// ExecutionDeposit counterExecutionDeposit = executionDepositImdg.getSingleObjectBySQL(sqlLCA);
|
||||
// if (counterExecutionDeposit == null) {
|
||||
// log.warn("Counter ExecutionDeposit not found for : {}", sqlLCA);
|
||||
// } else {
|
||||
// payment1.setAddresseeId(counterExecutionDeposit.getCompanyId());
|
||||
// log.trace("payment1.AddresseeId={} found by: {}", payment1.getAddresseeId(), sqlLCA);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// String symbol1 = selectSymbolValue(payment1.getAddresseeId(), CompanySymbol.BIC);
|
||||
// if (symbol1 == null) {
|
||||
// log.warn("CompanySymbols BIC not found for companyId={}", payment1.getAddresseeId());
|
||||
// } else {
|
||||
// payment1.setAdresseeBic(symbol1);
|
||||
// }
|
||||
//
|
||||
// Company companyPRC = companyImdg.getSingleObjectByID(PRC_ID); // 2 "НКО АО ПРЦ"
|
||||
// String companyPRCName = null;
|
||||
// if (companyPRC == null) {
|
||||
// log.warn("Company.id={} not found", PRC_ID);
|
||||
// } else {
|
||||
// companyPRCName = companyPRC.getShortName();
|
||||
// }
|
||||
// payment1.setPayeeBankName(companyPRCName);
|
||||
//
|
||||
// String symbolPRC = selectSymbolValue(PRC_ID, CompanySymbol.BIC); // 2 "НКО АО ПРЦ"
|
||||
// payment1.setPayeeBic(symbolPRC);
|
||||
//
|
||||
// payment1.setAddresseeBankName(companyPRCName);
|
||||
//
|
||||
// payment1.setPaymentDate(TimeUtil.localDateToInstant(liabilitiesClaimsAssets.getSettlementDate()));
|
||||
//
|
||||
// payment1.setPaymentPurpose("Размещение депозита " + liabilitiesClaimsAssets.getContract());
|
||||
//
|
||||
// payment1.setSettlementDate(liabilitiesClaimsAssets.getSettlementDate());
|
||||
//
|
||||
// Long amount = liabilitiesClaimsAssets.getLiabilitiesQuantity() == null ? null : liabilitiesClaimsAssets.getLiabilitiesQuantity().abs().longValue();
|
||||
// payment1.setCreditLegAmount(amount);
|
||||
// payment1.setDebitLegAmount(amount);
|
||||
//
|
||||
// {
|
||||
// Account acc1 = selectAccount(payment1.getSenderId(), AccountType.Anlt, Status.Active, Allowed.ALLOWED);
|
||||
// if (acc1 == null) {
|
||||
// log.warn("Account not found: companyId = {} AND accountType={} AND accountStatus={} AND processingSign={}",
|
||||
// payment1.getSenderId(), AccountType.Anlt, Status.Active, Allowed.ALLOWED);
|
||||
// } else {
|
||||
// payment1.setCreditLegAccountId(acc1.getId());
|
||||
// payment1.setCreditLegAccount(acc1.getAccount());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// payment1.setCreditCsAccount(null);
|
||||
//
|
||||
// {
|
||||
// Account acc1 = selectAccount(payment1.getAddresseeId(), AccountType.Corr, Status.Active, Allowed.ALLOWED);
|
||||
// if (acc1 != null) {
|
||||
// payment1.setDebitLegAccountId(acc1.getId());
|
||||
// payment1.setDebitLegAccount(acc1.getAccount());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// payment1.setDebitCsAccount(null);
|
||||
//
|
||||
//// payment1.setCreditLegDirection(InOutDirection.out.getKey());
|
||||
//// payment1.setDebitLegDirection(InOutDirection.in.getKey());
|
||||
//
|
||||
// payment1.setCreditLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
// payment1.setDebitLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
//
|
||||
// payment1.setTransactionStatus(TransactionStatus.stld.getKey());
|
||||
//
|
||||
//
|
||||
// payment1.setDocumentNumber(nextDocumentNumber(liabilitiesClaimsAssets, payment1));
|
||||
//
|
||||
// newPaymentInstructions.add(payment1);
|
||||
}
|
||||
if (clearingCategory.contains(ClearingCategory.B)) {
|
||||
log.debug("By liabilitiesClaimsAssets[{}] create for category B 1 PaymentInstruction record", liabilitiesClaimsAssets.getId());
|
||||
PaymentInstruction payment1 = new PaymentInstruction();
|
||||
payment1.setId(idGenerator.nextId());
|
||||
payment1.setCreated(now);
|
||||
payment1.setClearingDate(TimeUtil.toLocalDate(now));
|
||||
log.debug("By liabilitiesClaimsAssets[{}] create for category B 2 PaymentInstruction record", liabilitiesClaimsAssets.getId());
|
||||
{ // record 1
|
||||
{
|
||||
PaymentInstruction payment1 = new PaymentInstruction();
|
||||
payment1.setId(idGenerator.nextId());
|
||||
payment1.setCreated(now);
|
||||
payment1.setClearingDate(TimeUtil.toLocalDate(now));
|
||||
|
||||
payment1.setSenderId(liabilitiesClaimsAssets.getCompanyId());
|
||||
payment1.setSenderId(SPVB_ID); // СПВБ
|
||||
payment1.setAddresseeId(liabilitiesClaimsAssets.getCompanyId());
|
||||
|
||||
payment1.setAddresseeId(liabilitiesClaimsAssets.getCompanyId());
|
||||
String symbol2 = selectSymbolValue(payment1.getAddresseeId(), CompanySymbol.BIC);
|
||||
if (symbol2 == null) {
|
||||
log.warn("CompanySymbols BIC not found for companyId={}", payment1.getAddresseeId());
|
||||
} else {
|
||||
payment1.setAdresseeBic(symbol2);
|
||||
}
|
||||
|
||||
Company companyPRC = companyImdg.getSingleObjectByID(PRC_ID); // 2 "НКО АО ПРЦ"
|
||||
String companyPRCName = null;
|
||||
if (companyPRC == null) {
|
||||
log.warn("Company.id={} not found", PRC_ID);
|
||||
} else {
|
||||
companyPRCName = companyPRC.getShortName();
|
||||
}
|
||||
payment1.setPayeeBankName(companyPRCName);
|
||||
|
||||
String symbolPRC = selectSymbolValue(PRC_ID, CompanySymbol.BIC); // 2 "НКО АО ПРЦ"
|
||||
payment1.setPayeeBic(symbolPRC);
|
||||
|
||||
payment1.setAddresseeBankName(companyPRCName);
|
||||
payment1.setPaymentDate(TimeUtil.localDateToInstant(liabilitiesClaimsAssets.getSettlementDate()));
|
||||
payment1.setPaymentPurpose("Размещение депозита " + liabilitiesClaimsAssets.getContract());
|
||||
payment1.setSettlementDate(liabilitiesClaimsAssets.getSettlementDate());
|
||||
|
||||
Long amount = liabilitiesClaimsAssets.getLiabilitiesQuantity() == null ? null : liabilitiesClaimsAssets.getClaimsQuantity().abs().longValue();
|
||||
payment1.setCreditLegAmount(amount);
|
||||
payment1.setDebitLegAmount(amount);
|
||||
|
||||
{
|
||||
Account anotherAcc = selectAccount(payment1.getSenderId(), AccountType.Tran, Status.Active, Allowed.ALLOWED);
|
||||
if (anotherAcc == null) {
|
||||
log.warn("Account not found: companyId = {} AND accountType={} AND accountStatus={} AND processingSign={}",
|
||||
payment1.getSenderId(), AccountType.Tran, Status.Active, Allowed.ALLOWED);
|
||||
} else {
|
||||
payment1.setCreditLegAccountId(anotherAcc.getId());
|
||||
}
|
||||
}
|
||||
|
||||
payment1.setCreditCsAccount(null);
|
||||
|
||||
{
|
||||
Account acc2 = accountImdg.getSingleObjectByID(payment1.getCreditLegAccountId());
|
||||
if (acc2 != null) {
|
||||
payment1.setCreditLegAccount(acc2.getAccount());
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
Account acc2 = accountImdg.getSingleObjectByID(liabilitiesClaimsAssets.getAccountId());
|
||||
if (acc2 != null) {
|
||||
payment1.setDebitLegAccountId(acc2.getId());
|
||||
payment1.setDebitLegAccount(acc2.getAccount());
|
||||
}
|
||||
}
|
||||
|
||||
payment1.setDebitCsAccount(null);
|
||||
|
||||
// payment2.setCreditLegDirection(InOutDirection.out.getKey());
|
||||
// payment2.setDebitLegDirection(InOutDirection.in.getKey());
|
||||
|
||||
payment1.setCreditLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
payment1.setDebitLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
|
||||
payment1.setTransactionStatus(TransactionStatus.stld.getKey());
|
||||
|
||||
payment1.setDocumentNumber(nextDocumentNumber(liabilitiesClaimsAssets, payment1));
|
||||
|
||||
newPaymentInstructions.add(payment1);
|
||||
}
|
||||
|
||||
String symbol1 = selectSymbolValue(payment1.getAddresseeId(), CompanySymbol.BIC);
|
||||
if (symbol1 == null) {
|
||||
log.warn("CompanySymbols BIC not found for companyId={}", payment1.getAddresseeId());
|
||||
} else {
|
||||
payment1.setAdresseeBic(symbol1);
|
||||
}
|
||||
{ // record 2
|
||||
PaymentInstruction payment2 = new PaymentInstruction();
|
||||
payment2.setId(idGenerator.nextId());
|
||||
payment2.setCreated(now);
|
||||
payment2.setClearingDate(TimeUtil.toLocalDate(now));
|
||||
|
||||
Company companyPRC = companyImdg.getSingleObjectByID(PRC_ID); // 2 "НКО АО ПРЦ"
|
||||
String companyPRCName = null;
|
||||
if (companyPRC == null) {
|
||||
log.warn("Company.id={} not found", PRC_ID);
|
||||
} else {
|
||||
companyPRCName = companyPRC.getShortName();
|
||||
}
|
||||
payment1.setPayeeBankName(companyPRCName);
|
||||
payment2.setSenderId(liabilitiesClaimsAssets.getCompanyId());
|
||||
|
||||
String symbolPRC = selectSymbolValue(PRC_ID, CompanySymbol.BIC); // 2 "НКО АО ПРЦ"
|
||||
payment1.setPayeeBic(symbolPRC);
|
||||
payment2.setAddresseeId(liabilitiesClaimsAssets.getCompanyId());
|
||||
|
||||
payment1.setAddresseeBankName(companyPRCName);
|
||||
|
||||
payment1.setPaymentDate(TimeUtil.localDateToInstant(liabilitiesClaimsAssets.getSettlementDate()));
|
||||
|
||||
payment1.setPaymentPurpose("Размещение депозита " + liabilitiesClaimsAssets.getContract());
|
||||
|
||||
payment1.setSettlementDate(liabilitiesClaimsAssets.getSettlementDate());
|
||||
|
||||
Long amount = liabilitiesClaimsAssets.getClaimsQuantity() == null ? null : liabilitiesClaimsAssets.getClaimsQuantity().abs().longValue();
|
||||
payment1.setCreditLegAmount(amount);
|
||||
payment1.setDebitLegAmount(amount);
|
||||
|
||||
{
|
||||
Long accountId = liabilitiesClaimsAssets.getAccountId();
|
||||
Account acc1 = accountImdg.getSingleObjectByID(accountId);
|
||||
if (acc1 == null) {
|
||||
log.warn("Account not found: {}", accountId);
|
||||
String symbol1 = selectSymbolValue(payment2.getAddresseeId(), CompanySymbol.BIC);
|
||||
if (symbol1 == null) {
|
||||
log.warn("CompanySymbols BIC not found for companyId={}", payment2.getAddresseeId());
|
||||
} else {
|
||||
payment1.setCreditLegAccountId(acc1.getId());
|
||||
payment1.setCreditLegAccount(acc1.getAccount());
|
||||
payment2.setAdresseeBic(symbol1);
|
||||
}
|
||||
}
|
||||
|
||||
payment1.setCreditCsAccount(null);
|
||||
|
||||
{
|
||||
Account acc1 = selectAccount(payment1.getAddresseeId(), AccountType.Corr, Status.Active, Allowed.ALLOWED);
|
||||
if (acc1 != null) {
|
||||
payment1.setDebitLegAccountId(acc1.getId());
|
||||
payment1.setDebitLegAccount(acc1.getAccount());
|
||||
Company companyPRC = companyImdg.getSingleObjectByID(PRC_ID); // 2 "НКО АО ПРЦ"
|
||||
String companyPRCName = null;
|
||||
if (companyPRC == null) {
|
||||
log.warn("Company.id={} not found", PRC_ID);
|
||||
} else {
|
||||
companyPRCName = companyPRC.getShortName();
|
||||
}
|
||||
}
|
||||
payment2.setPayeeBankName(companyPRCName);
|
||||
|
||||
payment1.setDebitCsAccount(null);
|
||||
String symbolPRC = selectSymbolValue(PRC_ID, CompanySymbol.BIC); // 2 "НКО АО ПРЦ"
|
||||
payment2.setPayeeBic(symbolPRC);
|
||||
|
||||
payment2.setAddresseeBankName(companyPRCName);
|
||||
|
||||
payment2.setPaymentDate(TimeUtil.localDateToInstant(liabilitiesClaimsAssets.getSettlementDate()));
|
||||
|
||||
payment2.setPaymentPurpose("Размещение депозита " + liabilitiesClaimsAssets.getContract());
|
||||
|
||||
payment2.setSettlementDate(liabilitiesClaimsAssets.getSettlementDate());
|
||||
|
||||
Long amount = liabilitiesClaimsAssets.getClaimsQuantity() == null ? null : liabilitiesClaimsAssets.getClaimsQuantity().abs().longValue();
|
||||
payment2.setCreditLegAmount(amount);
|
||||
payment2.setDebitLegAmount(amount);
|
||||
|
||||
{
|
||||
Long accountId = liabilitiesClaimsAssets.getAccountId();
|
||||
Account acc1 = accountImdg.getSingleObjectByID(accountId);
|
||||
if (acc1 == null) {
|
||||
log.warn("Account not found: {}", accountId);
|
||||
} else {
|
||||
payment2.setCreditLegAccountId(acc1.getId());
|
||||
payment2.setCreditLegAccount(acc1.getAccount());
|
||||
}
|
||||
}
|
||||
|
||||
payment2.setCreditCsAccount(null);
|
||||
|
||||
{
|
||||
Account acc1 = selectAccount(payment2.getAddresseeId(), AccountType.Corr, Status.Active, Allowed.ALLOWED);
|
||||
if (acc1 != null) {
|
||||
payment2.setDebitLegAccountId(acc1.getId());
|
||||
payment2.setDebitLegAccount(acc1.getAccount());
|
||||
}
|
||||
}
|
||||
|
||||
payment2.setDebitCsAccount(null);
|
||||
|
||||
// payment1.setCreditLegDirection(InOutDirection.out.getKey());
|
||||
// payment1.setDebitLegDirection(InOutDirection.in.getKey());
|
||||
|
||||
payment1.setCreditLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
payment1.setDebitLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
payment2.setCreditLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
payment2.setDebitLegCurrencyCode(liabilitiesClaimsAssets.getCurrency());
|
||||
|
||||
payment1.setTransactionStatus(TransactionStatus.stld.getKey());
|
||||
payment2.setTransactionStatus(TransactionStatus.stld.getKey());
|
||||
|
||||
payment2.setDocumentNumber(nextDocumentNumber(liabilitiesClaimsAssets, payment2));
|
||||
|
||||
payment1.setDocumentNumber(nextDocumentNumber(liabilitiesClaimsAssets, payment1));
|
||||
|
||||
newPaymentInstructions.add(payment1);
|
||||
newPaymentInstructions.add(payment2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return newPaymentInstructions;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue