Beispiel #1
0
 private void processResponseOnExport(ClientResponse response, ExchangeContext context)
     throws Exception {
   context.setVariable("smevPool", false);
   String exportType = getStringFromContext(context, "exportRequestType", "");
   addAdditionalXmlSchema(response, exportType);
   ExportDataResponse exportDataResponse =
       (ExportDataResponse)
           new XmlTypes(ExportDataResponse.class).toBean(response.appData.getFirstChild());
   if (exportDataResponse.getResponseTemplate().getRequestProcessResult() != null) {
     context.setVariable("responseSuccess", false);
     String errorCode =
         exportDataResponse.getResponseTemplate().getRequestProcessResult().getErrorCode();
     processInternalErrorService(context, errorCode);
     context.setVariable("requestProcessResultErrorCode", errorCode);
     context.setVariable(
         "requestProcessResultErrorDescription",
         exportDataResponse.getResponseTemplate().getRequestProcessResult().getErrorDescription());
   } else {
     context.setVariable("responseSuccess", true);
     if ("QUITTANCE".equals(exportType)) {
       processExportQuittanceResponse(context, exportDataResponse);
     } else if (Arrays.asList("CHARGE", "CHARGESTATUS", "CHARGENOTFULLMATCHED")
         .contains(exportType)) {
       processExportChargeResponse(context, exportDataResponse);
     } else if (Arrays.asList("PAYMENT", "PAYMENTMODIFIED", "PAYMENTUNMATCHED")
         .contains(exportType)) {
       processExportPaymentResponse(context, exportDataResponse);
     } else {
       throw new IllegalArgumentException("Unknown export type " + exportType);
     }
   }
 }
Beispiel #2
0
 private void processResponseOnImportChargeRequest(
     ClientResponse response, ExchangeContext context) {
   ImportDataResponse importDataResponse =
       (ImportDataResponse)
           new XmlTypes(ImportDataResponse.class).toBean(response.appData.getFirstChild());
   if (importDataResponse == null)
     throw new IllegalStateException("Can't parse import data response");
   Ticket ticket = importDataResponse.getTicket();
   context.setVariable("ticketPostBlockID", ticket.getPostBlock().getID());
   context.setVariable(
       "ticketPostBlockSenderIdentifier", ticket.getPostBlock().getSenderIdentifier());
   context.setVariable(
       "ticketPostBlockTimeStamp",
       ticket.getPostBlock().getTimeStamp().toGregorianCalendar().getTime());
   if (ticket.getRequestProcessResult() != null) {
     String errorCode = ticket.getRequestProcessResult().getErrorCode();
     context.setVariable("requestProcessResultErrorCode", errorCode);
     context.setVariable(
         "requestProcessResultErrorDescription",
         ticket.getRequestProcessResult().getErrorDescription());
     context.setVariable("responseSuccess", false);
     context.setVariable("smevPool", false);
     processInternalErrorService(context, errorCode);
   } else {
     context.setVariable("responseSuccess", true);
     context.setVariable("smevPool", false);
   }
 }
Beispiel #3
0
  private void fillUnifiedPayerIds(ExchangeContext ctx, DataRequest dataRequest) {
    if (ctx.getVariable("payerIdBlock") == null) return;
    Long countPayers = (Long) ctx.getVariable("payerIdBlock");
    if (countPayers > 0) {
      DataRequest.Payers payers = new DataRequest.Payers();
      dataRequest.setPayers(payers);

      for (int idx = 0; idx < countPayers; idx++) {
        payers.getPayerIdentifier().add(buildUnifiedPayerID(ctx, "_" + (idx + 1)));
      }
    }
  }
Beispiel #4
0
 private void processInternalErrorService(ExchangeContext context, String errorCode) {
   if ("EBPP5000".equals(errorCode)) {
     int countRetries =
         context.getVariableNames().contains("countRetries")
             ? (Integer) context.getVariable("countRetries")
             : 0;
     countRetries++;
     context.setVariable("countRetries", countRetries);
     context.setVariable("smevTimeOut", calcTimeOut(countRetries));
     context.setVariable("smevPool", countRetries < 5);
   }
 }
Beispiel #5
0
  private void fillApplicationIds(ExchangeContext ctx, DataRequest dataRequest) {
    if (ctx.getVariable("ApplicationIdBlock") == null) return;
    Long countApplicationIds = (Long) ctx.getVariable("ApplicationIdBlock");
    if (countApplicationIds > 0) {
      DataRequest.ApplicationIDs applicationIDs = new DataRequest.ApplicationIDs();
      dataRequest.setApplicationIDs(applicationIDs);

      for (int idx = 0; idx < countApplicationIds; idx++) {
        Object supplierBillID = ctx.getVariable("ApplicationId_" + (idx + 1));
        if (supplierBillID != null) applicationIDs.getApplicationID().add((String) supplierBillID);
      }
    }
  }
Beispiel #6
0
  private String buildSystemIdentifierForImportPaymentOperation(ExchangeContext ctx) {
    String bik = getStringFromContext(ctx, "paymentBIK", "");
    Long branchId = (Long) ctx.getVariable("paymentBankBranch");
    Date paymentDate = (Date) ctx.getVariable("paymentDate");
    if (ctx.getVariable("paymentId") == null) {
      throw new RuntimeException(
          "Уникальный номер платежа внутри отделения в теч. дня должен быть заполнен");
    }
    Long paymentId = (Long) ctx.getVariable("paymentId");

    String branchPart = leftPad(branchId.toString(), 6, '0');
    String datePaymentPart = new SimpleDateFormat("yyMMdd").format(paymentDate);
    String paymentIdPart = leftPad(paymentId.toString(), 10, '0');
    return "1" + bik + branchPart + datePaymentPart + paymentIdPart;
  }
Beispiel #7
0
  public ClientRequest createClientRequest(ExchangeContext ctx) {
    final String originRequestId = (String) ctx.getVariable("smevOriginRequestId");

    final Packet packet = new Packet();
    packet.recipient = new InfoSystem("RKZN35001", "Казначейство России");
    InfoSystem pnzr8201 =
        new InfoSystem(
            "8201",
            "Комплексная система предоставления государственных и муниципальных услуг Пензенской области");
    packet.sender = packet.originator = pnzr8201;

    packet.typeCode = Packet.Type.EXECUTION;

    packet.date = new Date();
    packet.exchangeType = "6"; // 1 - Запрос на оказание услуги

    packet.originRequestIdRef = originRequestId;
    packet.testMsg = (String) ctx.getVariable("smevTest");

    final ClientRequest request = new ClientRequest();

    BigInteger caseNumber = generateCaseNumber();
    packet.caseNumber = caseNumber.toString();
    ctx.setVariable(SMEV_INITIAL_REG_NUMBER, caseNumber);
    ctx.setVariable(SMEV_INITIAL_REG_DATE, new Date());
    request.packet = packet;
    request.action = new QName("http://roskazna.ru/SmevUnifoService/", "UnifoTransferMsg");
    packet.status = Packet.Status.REQUEST;
    try {
      String typeOperation = getStringFromContext(ctx, "operationType", "");
      if (IMPORT_CHARGE_OPERATION.equals(typeOperation)) {
        request.appData = createAppDataForImportChargeOperation(ctx);
      } else if (EXPORT_OPERATION.equals(typeOperation)) {
        request.appData = createAppDataForExportOperation(ctx);
      } else if (IMPORT_PAYMENT_OPERATION.equals(typeOperation)) {
        request.appData = createAppDataForImportPaymentOperation(ctx);
      } else if (DO_ACKNOWLEDGMENT_OPERATION.equals(typeOperation)) {
        request.appData = createAcknowledgmentRequest(ctx);
      } else {
        throw new IllegalArgumentException("Тип операции не верен");
      }
    } catch (Exception e) {
      logger.log(Level.SEVERE, e.getMessage(), e);
      throw new RuntimeException(e.getMessage(), e);
    }

    return request;
  }
Beispiel #8
0
 private void fillPaymentAdditionalData(PaymentInfoType paymentInfo, ExchangeContext ctx) {
   Long valuesCount = (Long) ctx.getVariable("payeeAddDataBlock");
   for (long idx = 0; idx < valuesCount; idx++) {
     PaymentType.AdditionalData additionalData = new PaymentType.AdditionalData();
     additionalData.setName(getStringFromContext(ctx, "payeeAddDataKey_" + (idx + 1), ""));
     additionalData.setValue(getStringFromContext(ctx, "payeeAddDataValue_" + (idx + 1), ""));
     paymentInfo.getAdditionalData().add(additionalData);
   }
 }
Beispiel #9
0
 private PostBlock createPostBlock(ExchangeContext ctx, String postBlockSenderIdentifier) {
   final PostBlock postBlock = new PostBlock();
   String postBlockID =
       ctx.getVariable("postBlockId") == null
           ? UUID.randomUUID().toString()
           : (String) ctx.getVariable("postBlockId");
   ctx.setVariable("postBlockId", postBlockID);
   postBlock.setID(postBlockID); // идентификатор запроса
   postBlock.setSenderIdentifier(postBlockSenderIdentifier);
   Date postBlockTimeStamp =
       ctx.getVariable("postBlockTimeStamp") != null
           ? (Date) ctx.getVariable("postBlockTimeStamp")
           : new Date();
   postBlock.setTimeStamp(
       XmlTypes.dateTimeAndZeroMilliseconds(
           formatDate(postBlockTimeStamp, "dd.MM.yyyy HH:mm:ss"))); // дата составления запроса
   return postBlock;
 }
Beispiel #10
0
 private void processExportChargeResponse(
     ExchangeContext context, ExportDataResponse exportDataResponse) throws Exception {
   ExportChargesResponse exportResponse =
       (ExportChargesResponse) exportDataResponse.getResponseTemplate();
   if (exportResponse.getCharges() != null) {
     List<ExportChargesResponse.Charges.ChargeInfo> charges =
         exportResponse.getCharges().getChargeInfo();
     context.setVariable("chargeBlock", (long) charges.size());
     for (int idx = 0; idx < charges.size(); idx++) {
       int blockIndex = idx + 1;
       ExportChargesResponse.Charges.ChargeInfo chargeInfo = charges.get(idx);
       context.setVariable("amountToPay_" + blockIndex, chargeInfo.getAmountToPay());
       context.setVariable(
           "quittanceWithPaymentStatus_" + blockIndex, chargeInfo.getQuittanceWithPaymentStatus());
       context.setVariable(
           "quittanceWithIncomeStatus_" + blockIndex, chargeInfo.getQuittanceWithIncomeStatus());
       if (chargeInfo.getIsRevoked() != null) {
         context.setVariable("isRevoked_" + blockIndex, chargeInfo.getIsRevoked().isValue());
         if (chargeInfo.getIsRevoked().getDate() != null) {
           context.setVariable(
               "revokedDate_" + blockIndex,
               chargeInfo.getIsRevoked().getDate().toGregorianCalendar().getTime());
         } else {
           context.setVariable("revokedDate_" + blockIndex, null);
         }
       } else {
         context.setVariable("revokedDate_" + blockIndex, null);
         context.setVariable("isRevoked_" + blockIndex, false);
       }
       if (chargeInfo.getChargeData() != null) {
         ChargeType charge =
             (ChargeType)
                 parseEntity(
                     chargeInfo.getChargeData(),
                     "http://roskazna.ru/xsd/Charge",
                     "Charge",
                     ChargeType.class);
         addChargeToContext(charge, context, blockIndex);
       }
     }
   } else {
     context.setVariable("chargeBlock", 0l);
   }
 }
Beispiel #11
0
 private void processResponseOnAcknowledgmentOperation(
     ClientResponse response, ExchangeContext context) {
   context.setVariable("smevPool", false);
   DoAcknowledgmentResponseType acknowledgmentResponse =
       (DoAcknowledgmentResponseType)
           new XmlTypes(DoAcknowledgmentResponseType.class)
               .toBean(response.appData.getFirstChild());
   if (acknowledgmentResponse.getRequestProcessResult() != null) {
     context.setVariable("responseSuccess", false);
     String errorCode = acknowledgmentResponse.getRequestProcessResult().getErrorCode();
     processInternalErrorService(context, errorCode);
     context.setVariable("requestProcessResultErrorCode", errorCode);
     context.setVariable(
         "requestProcessResultErrorDescription",
         acknowledgmentResponse.getRequestProcessResult().getErrorDescription());
   } else {
     context.setVariable("responseSuccess", true);
     fillAcknowledgmentQuinttancesToContext(
         context, acknowledgmentResponse.getQuittances().getQuittance());
   }
 }
Beispiel #12
0
  String createAppDataForExportOperation(ExchangeContext ctx) {
    ExportData exportData = new ExportData();
    DataRequest dataRequest = new DataRequest();
    Date startDate = (Date) ctx.getVariable("startDate");
    if (startDate != null) {
      dataRequest.setStartDate(
          XmlTypes.dateTimeAndZeroMilliseconds(formatDate(startDate, "dd.MM.yyyy HH:mm:ss")));
    }

    Date endDate = (Date) ctx.getVariable("endDate");
    if (endDate != null) {
      dataRequest.setEndDate(
          XmlTypes.dateTimeAndZeroMilliseconds(formatDate(endDate, "dd.MM.yyyy HH:mm:ss")));
    }
    exportData.setDataRequest(dataRequest);
    dataRequest.setKind((String) ctx.getVariable("exportRequestType"));
    String postBlockSenderIdentifier = (String) ctx.getVariable("postBlockSenderIdentifier");
    final PostBlock postBlock = createPostBlock(ctx, postBlockSenderIdentifier);
    dataRequest.setPostBlock(postBlock);
    fillSupplierBillIds(ctx, dataRequest);
    fillApplicationIds(ctx, dataRequest);
    fillUnifiedPayerIds(ctx, dataRequest);
    return new XmlTypes(ExportData.class).toXml(exportData);
  }
Beispiel #13
0
 private String createAcknowledgmentRequest(ExchangeContext ctx) {
   final DoAcknowledgmentRequestType acknowledgmentRequest = new DoAcknowledgmentRequestType();
   String postBlockSenderIdentifier = getStringFromContext(ctx, "postBlockSenderIdentifier", "");
   final PostBlock postBlock = createPostBlock(ctx, postBlockSenderIdentifier);
   acknowledgmentRequest.setPostBlock(postBlock);
   acknowledgmentRequest.setSupplierBillID(getStringFromContext(ctx, "SupplierBillID", ""));
   long countPayments = (Long) ctx.getVariable("paymentBlock");
   if (countPayments > 0l) {
     acknowledgmentRequest.setPayments(new DoAcknowledgmentRequestType.Payments());
     for (long paymentIdx = 0; paymentIdx < countPayments; paymentIdx++) {
       String paymentId = getStringFromContext(ctx, "paymentSystemId_" + (paymentIdx + 1), "");
       acknowledgmentRequest.getPayments().getPaymentSystemIdentifier().add(paymentId);
     }
   }
   return new XmlTypes(DoAcknowledgmentRequestType.class).toXml(acknowledgmentRequest);
 }
Beispiel #14
0
 public void processClientResponse(ClientResponse response, ExchangeContext context) {
   try {
     context.setVariable("smevPool", true); // сервис синхронный
     if (response.verifyResult.error != null) {
       context.setVariable("smevError", response.verifyResult.error);
       context.setVariable("responseSuccess", false);
       context.setVariable("smevPool", false);
       context.setVariable("requestProcessResultErrorDescription", response.verifyResult.error);
     } else if (new QName("http://roskazna.ru/SmevUnifoService/", "UnifoTransferMsg")
         .equals(response.action)) {
       processResponseWithFinalData(response, context);
     } else {
       context.setVariable("smevError", "Неизвестный ответ " + response.action);
     }
   } catch (Exception e) {
     throw new RuntimeException(e.getMessage(), e);
   }
 }
Beispiel #15
0
 private String getStringFromContext(ExchangeContext ctx, String varName, String defaultString) {
   return ctx.getVariable(varName) == null ? defaultString : (String) ctx.getVariable(varName);
 }
Beispiel #16
0
  private String createAppDataForImportPaymentOperation(ExchangeContext ctx) throws Exception {
    ImportData importData = new ImportData();
    final ImportRequest importRequest = new ImportRequest();
    importData.setImportRequest(importRequest);
    String postBlockSenderIdentifier = (String) ctx.getVariable("postBlockSenderIdentifier");
    final PostBlock postBlock = createPostBlock(ctx, postBlockSenderIdentifier);
    importRequest.setPostBlock(postBlock);
    PaymentInfoType paymentInfo = new PaymentInfoType();
    importRequest.setFinalPayment(paymentInfo);

    paymentInfo.setNarrative(getStringFromContext(ctx, "paymentNarrative", ""));
    paymentInfo.setSupplierBillID(getStringFromContext(ctx, "paymentSupplierBillID", ""));
    paymentInfo.setAmount(toLong((String) ctx.getVariable("paymentAmount")));
    paymentInfo.setPaymentDate(
        XmlTypes.date(formatDate((Date) ctx.getVariable("paymentDate"), "dd.MM.yyyy")));
    paymentInfo.setChangeStatus(getStringFromContext(ctx, "paymentChangeStatus", "1"));
    paymentInfo.setPayeeINN(getStringFromContext(ctx, "paymentPayeeINN", ""));
    paymentInfo.setPayeeKPP(getStringFromContext(ctx, "paymentPayeeKPP", ""));
    paymentInfo.setKBK(getStringFromContext(ctx, "paymentKBK", ""));
    paymentInfo.setOKATO(getStringFromContext(ctx, "paymentOKATO", ""));
    paymentInfo.setPayerPA(getStringFromContext(ctx, "paymentPA", ""));

    Account payeeBankAcc = new Account();
    paymentInfo.setPayeeBankAcc(payeeBankAcc);
    payeeBankAcc.setAccount(getStringFromContext(ctx, "paymentPayeeAccount", ""));
    payeeBankAcc.setKind(getStringFromContext(ctx, "paymentPayeeBankAccKind", "!"));
    Bank payeeBank = new Bank();
    payeeBankAcc.setBank(payeeBank);
    payeeBank.setName(getStringFromContext(ctx, "paymentPayeeBankName", ""));
    payeeBank.setCorrespondentBankAccount(
        getStringFromContext(ctx, "paymentCorrespondentBankAccount", ""));
    payeeBank.setBIK(getStringFromContext(ctx, "paymentPayeeBankBIK", ""));

    PaymentIdentificationDataType paymentIdentificationData = new PaymentIdentificationDataType();
    paymentInfo.setPaymentIdentificationData(paymentIdentificationData);
    Bank bank = new Bank();
    paymentIdentificationData.setBank(bank);
    bank.setBIK(getStringFromContext(ctx, "paymentBIK", ""));
    bank.setName(getStringFromContext(ctx, "paymentBankName", ""));
    paymentIdentificationData.setSystemIdentifier(
        buildSystemIdentifierForImportPaymentOperation(ctx));

    fillPaymentAdditionalData(paymentInfo, ctx);
    final BudgetIndex budgetIndex = new BudgetIndex();
    paymentInfo.setBudgetIndex(budgetIndex);
    budgetIndex.setStatus(getStringFromContext(ctx, "Status", "0")); // Статус плательщика
    budgetIndex.setPaymentType(getStringFromContext(ctx, "PaymentType", "0")); // тип платежа
    budgetIndex.setPurpose(
        getStringFromContext(ctx, "Purpose", "0")); // основание платежа 2 символа максимум
    budgetIndex.setTaxPeriod(
        getStringFromContext(ctx, "TaxPeriod", "0")); // налоговый период до 10 символов
    budgetIndex.setTaxDocNumber(
        getStringFromContext(ctx, "TaxDocNumber", "0")); // Показатель номера документа
    budgetIndex.setTaxDocDate(
        getStringFromContext(ctx, "TaxDocDate", "0")); // Показатель даты документа

    paymentInfo.setPayerIdentifier(buildUnifiedPayerID(ctx, ""));

    String importDataStr = new XmlTypes(ImportData.class).toXml(importData);
    return cryptoProvider.signElement(importDataStr, "FinalPayment", null, true, true, false);
  }
Beispiel #17
0
 private void processExportQuittanceResponse(
     ExchangeContext context, ExportDataResponse exportDataResponse) {
   ExportQuittanceResponse exportQuittanceResponse =
       (ExportQuittanceResponse) exportDataResponse.getResponseTemplate();
   List<ExportQuittanceResponse.Quittances.Quittance> quittanceList =
       exportQuittanceResponse.getQuittances() != null
           ? exportQuittanceResponse.getQuittances().getQuittance()
           : Arrays.<ExportQuittanceResponse.Quittances.Quittance>asList();
   context.setVariable("quittance", (long) quittanceList.size());
   // context.setVariable("-quittance", "");
   for (int idx = 0; idx < quittanceList.size(); idx++) {
     int blockIndex = idx + 1;
     ExportQuittanceResponse.Quittances.Quittance quittance = quittanceList.get(idx);
     context.setVariable("quittanceIsRevoked_" + blockIndex, quittance.isIsRevoked());
     context.setVariable("quittanceSupplierBillID_" + blockIndex, quittance.getSupplierBillID());
     context.setVariable("quittancePayerIdentifier_" + blockIndex, quittance.getPayerIdentifier());
     context.setVariable("quittanceBalance_" + blockIndex, quittance.getBalance());
     context.setVariable("quittanceBillStatus_" + blockIndex, quittance.getBillStatus());
     PaymentIdentificationDataType paymentIdentificationData =
         quittance.getPaymentIdentificationData();
     if (paymentIdentificationData != null) {
       context.setVariable(
           "quittanceSystemIdentifier_" + blockIndex,
           paymentIdentificationData.getSystemIdentifier());
       context.setVariable(
           "quittanceBankBIK_" + blockIndex, paymentIdentificationData.getBank().getBIK());
       context.setVariable(
           "quittanceBankName_" + blockIndex, paymentIdentificationData.getBank().getName());
       context.setVariable(
           "quittanceBankCorrAccount_" + blockIndex,
           paymentIdentificationData.getBank().getCorrespondentBankAccount());
       context.setVariable(
           "quittanceBankSWIFT_" + blockIndex, paymentIdentificationData.getBank().getSWIFT());
     } else {
       PaymentIdentificationDataType incomeRowIdentificationData =
           quittance.getIncomeRowIdentificationData();
       if (incomeRowIdentificationData != null) {
         context.setVariable(
             "quittanceUFKName_" + blockIndex, incomeRowIdentificationData.getUFK());
       }
     }
     context.setVariable("quittanceApplicationId_" + blockIndex, quittance.getApplicationID());
     context.setVariable("payeeINN_" + blockIndex, quittance.getPayeeINN());
     context.setVariable("payeeKPP_" + blockIndex, quittance.getPayeeKPP());
     context.setVariable("KBK_" + blockIndex, quittance.getKBK());
     context.setVariable("OKATO_" + blockIndex, quittance.getOKATO());
   }
 }
Beispiel #18
0
  private void addChargeToContext(ChargeType charge, ExchangeContext context, int blockIndex) {
    context.setVariable("SupplierBillID_" + blockIndex, charge.getSupplierBillID());
    context.setVariable("UnifiedPayerId_" + blockIndex, charge.getUnifiedPayerIdentifier());
    context.setVariable(
        "BillDate_" + blockIndex, charge.getBillDate().toGregorianCalendar().getTime());
    context.setVariable("SupplierOrgInfoName_" + blockIndex, charge.getSupplierOrgInfo().getName());
    context.setVariable("SupplierOrgInfoINN_" + blockIndex, charge.getSupplierOrgInfo().getINN());
    context.setVariable("SupplierOrgInfoKPP_" + blockIndex, charge.getSupplierOrgInfo().getKPP());
    context.setVariable(
        "SupplierOrgAccountKind_" + blockIndex, charge.getSupplierOrgInfo().getAccount().getKind());
    context.setVariable(
        "SupplierOrgAccountNumber_" + blockIndex,
        charge.getSupplierOrgInfo().getAccount().getAccount());
    context.setVariable(
        "SupplierOrgAccountBankName_" + blockIndex,
        charge.getSupplierOrgInfo().getAccount().getBank().getName());
    context.setVariable(
        "SupplierOrgAccountBankBIK_" + blockIndex,
        charge.getSupplierOrgInfo().getAccount().getBank().getBIK());
    context.setVariable("ChargeChangeStatus_" + blockIndex, charge.getChangeStatus());
    context.setVariable("ChargeKBK_" + blockIndex, charge.getKBK());
    context.setVariable("ChargeOKATO_" + blockIndex, charge.getOKATO());
    context.setVariable("ChargeTreasureBranch_" + blockIndex, charge.getTreasureBranch());
    context.setVariable("budgetStatus_" + blockIndex, charge.getBudgetIndex().getStatus());
    context.setVariable("budgetPurpose_" + blockIndex, charge.getBudgetIndex().getPurpose());
    context.setVariable(
        "budgetPaymentType_" + blockIndex, charge.getBudgetIndex().getPaymentType());
    context.setVariable("budgetTaxPeriod_" + blockIndex, charge.getBudgetIndex().getTaxPeriod());
    context.setVariable(
        "budgetTaxDocNumber_" + blockIndex, charge.getBudgetIndex().getTaxDocNumber());
    context.setVariable("budgetTaxDocDate_" + blockIndex, charge.getBudgetIndex().getTaxDocDate());
    context.setVariable("TotalAmount_" + blockIndex, charge.getTotalAmount());
    if (charge.getAdditionalData() != null) {
      context.setVariable("additionalData_" + blockIndex, (long) charge.getAdditionalData().size());
      int additionalDataIdx = 0;
      for (Bill.AdditionalData additionalData : charge.getAdditionalData()) {
        additionalDataIdx++;
        context.setVariable(
            "additionalDataKey_" + blockIndex + "_" + additionalDataIdx, additionalData.getName());
        context.setVariable(
            "additionalDataValue_" + blockIndex + "_" + additionalDataIdx,
            additionalData.getValue());
      }
    } else {
      context.setVariable("additionalData_" + blockIndex, 0l);
    }
    if (charge.getSupplierOrgInfo().getAddresses() != null) {
      int addressIdx = 0;
      context.setVariable(
          "SupplierOrgAddress_" + blockIndex,
          (long) charge.getSupplierOrgInfo().getAddresses().getAddress().size());
      for (AddressType address : charge.getSupplierOrgInfo().getAddresses().getAddress()) {
        addressIdx++;
        context.setVariable("addressType_" + blockIndex + "_" + addressIdx, address.getKind());
        context.setVariable("addressView_" + blockIndex + "_" + addressIdx, address.getView());
      }
    } else {
      context.setVariable("SupplierOrgAddress_" + blockIndex, 0l);
    }

    if (charge.getSupplierOrgInfo().getContacts() != null) {
      int contactIdx = 0;
      context.setVariable(
          "SupplierOrgContact_" + blockIndex,
          (long) charge.getSupplierOrgInfo().getContacts().getContact().size());
      for (ContactInfoType contact : charge.getSupplierOrgInfo().getContacts().getContact()) {
        contactIdx++;
        context.setVariable("contactType_" + blockIndex + "_" + contactIdx, contact.getKind());
        context.setVariable("contactValue_" + blockIndex + "_" + contactIdx, contact.getValue());
        context.setVariable(
            "contactComment_" + blockIndex + "_" + contactIdx, contact.getComment());
      }
    } else {
      context.setVariable("SupplierOrgContact_" + blockIndex, 0l);
    }
  }
Beispiel #19
0
 private void processExportPaymentResponse(
     ExchangeContext ctx, ExportDataResponse exportDataResponse) throws Exception {
   ExportPaymentsResponse exportResponse =
       (ExportPaymentsResponse) exportDataResponse.getResponseTemplate();
   if (exportResponse.getPayments() != null) {
     List<ExportPaymentsResponse.Payments.PaymentInfo> paymentInfoList =
         exportResponse.getPayments().getPaymentInfo();
     ctx.setVariable("paymentBlock", (long) paymentInfoList.size());
     int blockIndex = 0;
     for (ExportPaymentsResponse.Payments.PaymentInfo paymentInfo : paymentInfoList) {
       blockIndex++;
       PaymentInfoType paymentType =
           (PaymentInfoType)
               parseEntity(
                   paymentInfo.getPaymentData(),
                   "http://roskazna.ru/xsd/PaymentInfo",
                   "FinalPayment",
                   PaymentInfoType.class);
       ctx.setVariable("paymentNarrative" + "_" + blockIndex, paymentType.getNarrative());
       ctx.setVariable(
           "paymentSupplierBillID" + "_" + blockIndex, paymentType.getSupplierBillID());
       ctx.setVariable("paymentAmount" + "_" + blockIndex, paymentType.getAmount());
       ctx.setVariable(
           "paymentDate" + "_" + blockIndex,
           paymentType.getPaymentDate().toGregorianCalendar().getTime());
       ctx.setVariable("paymentChangeStatus" + "_" + blockIndex, paymentType.getChangeStatus());
       ctx.setVariable("paymentPayeeINN" + "_" + blockIndex, paymentType.getPayeeINN());
       ctx.setVariable("paymentPayeeKPP" + "_" + blockIndex, paymentType.getPayeeKPP());
       ctx.setVariable("paymentKBK" + "_" + blockIndex, paymentType.getKBK());
       ctx.setVariable("paymentOKATO" + "_" + blockIndex, paymentType.getOKATO());
       ctx.setVariable("paymentPA" + "_" + blockIndex, paymentType.getPayerPA());
       if (paymentType.getPayeeBankAcc() != null) {
         ctx.setVariable(
             "paymentPayeeAccount" + "_" + blockIndex, paymentType.getPayeeBankAcc().getAccount());
         ctx.setVariable(
             "paymentPayeeBankAccKind" + "_" + blockIndex,
             paymentType.getPayeeBankAcc().getKind());
         ctx.setVariable(
             "paymentPayeeBankName" + "_" + blockIndex,
             paymentType.getPayeeBankAcc().getBank().getName());
         ctx.setVariable(
             "paymentCorrespondentBankAccount" + "_" + blockIndex,
             paymentType.getPayeeBankAcc().getBank().getCorrespondentBankAccount());
         ctx.setVariable(
             "paymentPayeeBankBIK" + "_" + blockIndex,
             paymentType.getPayeeBankAcc().getBank().getBIK());
       }
       ctx.setVariable("Status" + "_" + blockIndex, paymentType.getBudgetIndex().getStatus());
       ctx.setVariable(
           "PaymentType" + "_" + blockIndex, paymentType.getBudgetIndex().getPaymentType());
       ctx.setVariable("Purpose" + "_" + blockIndex, paymentType.getBudgetIndex().getPurpose());
       ctx.setVariable(
           "TaxPeriod" + "_" + blockIndex, paymentType.getBudgetIndex().getTaxPeriod());
       ctx.setVariable(
           "TaxDocNumber" + "_" + blockIndex, paymentType.getBudgetIndex().getTaxDocNumber());
       ctx.setVariable(
           "TaxDocDate" + "_" + blockIndex, paymentType.getBudgetIndex().getTaxDocDate());
       ctx.setVariable(
           "paymentSystemId" + "_" + blockIndex,
           paymentType.getPaymentIdentificationData().getSystemIdentifier());
       ctx.setVariable(
           "paymentBIK" + "_" + blockIndex,
           paymentType.getPaymentIdentificationData().getBank().getBIK());
       ctx.setVariable(
           "paymentBankName" + "_" + blockIndex,
           paymentType.getPaymentIdentificationData().getBank().getName());
       ctx.setVariable("payerId" + "_" + blockIndex, paymentType.getPayerIdentifier());
     }
   } else {
     ctx.setVariable("paymentBlock", 0l);
   }
 }
Beispiel #20
0
 private void fillAcknowledgmentQuinttancesToContext(
     ExchangeContext context,
     List<DoAcknowledgmentResponseType.Quittances.Quittance> quittanceList) {
   context.setVariable("quittance", (long) quittanceList.size());
   // context.setVariable("-quittance", "");
   for (int idx = 0; idx < quittanceList.size(); idx++) {
     int blockIndex = idx + 1;
     DoAcknowledgmentResponseType.Quittances.Quittance quittance = quittanceList.get(idx);
     context.setVariable("quittanceSupplierBillID_" + blockIndex, quittance.getSupplierBillID());
     context.setVariable("quittancePayerIdentifier_" + blockIndex, quittance.getPayerIdentifier());
     context.setVariable("quittanceBalance_" + blockIndex, quittance.getBalance());
     context.setVariable("quittanceBillStatus_" + blockIndex, quittance.getBillStatus());
     PaymentIdentificationDataType paymentIdentificationData =
         quittance.getPaymentIdentificationData();
     if (paymentIdentificationData != null) {
       context.setVariable(
           "quittanceSystemIdentifier_" + blockIndex,
           paymentIdentificationData.getSystemIdentifier());
       context.setVariable(
           "quittanceBankBIK_" + blockIndex, paymentIdentificationData.getBank().getBIK());
       context.setVariable(
           "quittanceBankName_" + blockIndex, paymentIdentificationData.getBank().getName());
       context.setVariable(
           "quittanceBankCorrAccount_" + blockIndex,
           paymentIdentificationData.getBank().getCorrespondentBankAccount());
       context.setVariable(
           "quittanceBankSWIFT_" + blockIndex, paymentIdentificationData.getBank().getSWIFT());
     } else {
       PaymentIdentificationDataType incomeRowIdentificationData =
           quittance.getIncomeRowIdentificationData();
       if (incomeRowIdentificationData != null) {
         context.setVariable(
             "quittanceUFKName_" + blockIndex, incomeRowIdentificationData.getUFK());
       }
     }
     context.setVariable("quittanceApplicationId_" + blockIndex, quittance.getApplicationID());
     context.setVariable("payeeINN_" + blockIndex, quittance.getPayeeINN());
     context.setVariable("payeeKPP_" + blockIndex, quittance.getPayeeKPP());
     context.setVariable("KBK_" + blockIndex, quittance.getKBK());
     context.setVariable("OKATO_" + blockIndex, quittance.getOKATO());
   }
 }
Beispiel #21
0
  String createAppDataForImportChargeOperation(ExchangeContext ctx) throws Exception {
    ImportData importData = new ImportData();
    final ImportRequest importRequest = new ImportRequest();
    String postBlockSenderIdentifier = (String) ctx.getVariable("postBlockSenderIdentifier");
    final PostBlock postBlock = createPostBlock(ctx, postBlockSenderIdentifier);
    importRequest.setPostBlock(postBlock);
    final ChargeType charge = new ChargeType();
    importRequest.setCharge(charge);

    String ordinalNumber = (String) ctx.getVariable("ordinalNumber");
    if (ordinalNumber == null || "".equals(ordinalNumber)) {
      ordinalNumber = formatDate(new Date(), "ddMMyyHHmmss");
    }

    String supplierBillID =
        UINGenerator.generateChargeUIN(postBlockSenderIdentifier, ordinalNumber);
    ctx.setVariable("supplierBillID", supplierBillID);
    charge.setSupplierBillID(supplierBillID); // Уникальный идентификатор счёта в ИСП
    charge.setBillDate(
        XmlTypes.date(
            formatDate(
                (Date) ctx.getVariable("chargeBillDate"), "dd.MM.yyyy"))); // Дата выставления счёта

    final Organization supplierOrgInfo = new Organization();
    supplierOrgInfo.setName((String) ctx.getVariable("supplierOrgInfoName"));
    supplierOrgInfo.setINN((String) ctx.getVariable("supplierOrgInfoINN"));
    supplierOrgInfo.setKPP((String) ctx.getVariable("supplierOrgInfoKPP"));
    final Account account = new Account();
    account.setAccount((String) ctx.getVariable("accountAccount"));
    account.setKind((String) ctx.getVariable("accountKind"));
    final Bank bank = new Bank();
    bank.setBIK((String) ctx.getVariable("bankBIK"));
    bank.setName((String) ctx.getVariable("bankName"));
    account.setBank(bank);
    supplierOrgInfo.setAccount(account);
    charge.setSupplierOrgInfo(supplierOrgInfo);
    charge.setBillFor((String) ctx.getVariable("chargeBillFor"));
    charge.setTotalAmount(toLong((String) ctx.getVariable("chargeTotalAmount")));
    charge.setChangeStatus(
        (String)
            ctx.getVariable(
                "chargeChangeStatus")); /* Статус счёта 1 - новый  2 - изменение  3 - аннулирование */
    charge.setTreasureBranch(
        (String)
            ctx.getVariable(
                "chargeTreasureBranch")); // Орган ФК, на счёт которого должны поступать средства
                                          // плательщика
    charge.setKBK((String) ctx.getVariable("chargeKBK"));
    charge.setOKATO((String) ctx.getVariable("chargeOKATO"));

    final BudgetIndex budgetIndex = new BudgetIndex();
    budgetIndex.setStatus((String) ctx.getVariable("budgetIndexStatus")); // Статус плательщика
    budgetIndex.setPaymentType((String) ctx.getVariable("budgetPaymentType")); // тип платежа
    budgetIndex.setPurpose(
        (String) ctx.getVariable("budgetPurpose")); // основание платежа 2 символа максимум
    budgetIndex.setTaxPeriod(
        (String) ctx.getVariable("budgetTaxPeriod")); // налоговый период до 10 символов
    budgetIndex.setTaxDocNumber(
        (String) ctx.getVariable("budgetTaxDocNumber")); // Показатель номера документа
    budgetIndex.setTaxDocDate(
        (String) ctx.getVariable("budgetTaxDocDate")); // Показатель даты документа
    charge.setBudgetIndex(budgetIndex);
    if ("".equals(getStringFromContext(ctx, "chargeApplicationID", ""))) {
      String applicationID = String.valueOf(System.currentTimeMillis());
      ctx.setVariable("chargeApplicationID", applicationID);
      charge.setApplicationID(applicationID);
    } else {
      charge.setApplicationID((String) ctx.getVariable("chargeApplicationID"));
    }

    String unifiedPayerIdentifier = buildUnifiedPayerID(ctx, "");
    ctx.setVariable("unifiedPayerIdentifier", unifiedPayerIdentifier);
    charge.setUnifiedPayerIdentifier(unifiedPayerIdentifier); //  единый идентификатор плательщика
    importData.setImportRequest(importRequest);
    String importDataStr = new XmlTypes(ImportData.class).toXml(importData);
    return cryptoProvider.signElement(importDataStr, "Charge", null, true, true, false);
  }