Exemple #1
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);
    }
  }
Exemple #2
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);
  }