/**
   * Constructor.
   *
   * @param payment
   * @param transactionId
   * @param transactionType
   * @throws Exception
   */
  public CreditCardTransactionData(MPayment payment, String transactionId, String transactionType)
      throws Exception {
    this.amount = payment.getPayAmt();
    this.currency = payment.getC_Currency().getISO_Code();
    String expMonth =
        payment.getCreditCardExpMM() < 10
            ? ("0" + payment.getCreditCardExpMM())
            : ("" + payment.getCreditCardExpMM());
    int expYear =
        payment.getCreditCardExpYY() < 1000
            ? (payment.getCreditCardExpYY() + 2000)
            : payment.getCreditCardExpYY();
    this.ccExpiry = expYear + expMonth;
    this.ccValidationNumber = payment.getCreditCardVV();
    this.ccNumber = payment.getCreditCardNumber();
    if (this.ccNumber != null) {
      this.ccNumber = this.ccNumber.replaceAll("\\D", "");
    }
    this.bankCode = payment.getRoutingNo();
    this.customerId = payment.getC_BPartner_ID() + "";
    I_C_BPartner bp = payment.getC_BPartner();
    if (bp != null) {
      this.customerId = bp.getValue();
    }

    this.transactionId = transactionId;
    this.transactionType = transactionType;
    this.authToken = payment.getR_AuthCode();
    this.reversalSequenceNo = payment.getOrig_TrxID();
  }
Пример #2
0
  public I_AD_Org createOrg(final String name) {
    final I_AD_Org org = InterfaceWrapperHelper.create(ctx, I_AD_Org.class, ITrx.TRXNAME_None);
    org.setValue(name);
    org.setName(name);
    InterfaceWrapperHelper.save(org);

    final I_AD_OrgInfo orgInfo = InterfaceWrapperHelper.newInstance(I_AD_OrgInfo.class, org);
    orgInfo.setAD_Org_ID(org.getAD_Org_ID());

    //
    // InTransit Warehouse
    final I_M_Warehouse warehouseInTransit = createWarehouse(name + "_InTransit", org);
    warehouseInTransit.setIsInTransit(true);
    InterfaceWrapperHelper.save(warehouseInTransit);

    //
    // BP Org Link
    final I_C_BPartner bpartner = createBPartner("BPOrg_" + name);
    // bpartner.setAD_OrgBP_ID(String.valueOf(org.getAD_Org_ID()));
    bpartner.setAD_OrgBP_ID(org.getAD_Org_ID());
    InterfaceWrapperHelper.save(bpartner);
    //
    final I_C_BPartner_Location bpLocation = createBPLocation(bpartner);
    orgInfo.setOrgBP_Location(bpLocation);
    InterfaceWrapperHelper.save(orgInfo);

    return org;
  }
Пример #3
0
 @Override
 public Object[] apply(final I_C_Order document) {
   final I_C_BPartner bpartner = document.getC_BPartner();
   final String bpValue = bpartner.getValue();
   final String bpName = bpartner.getName();
   return new Object[] {TableRecordReference.of(document), bpValue, bpName};
 }
Пример #4
0
 private Set<Integer> getAllBPartnerIds() {
   final List<I_C_BPartner> bpartnersList =
       pmmbPartnerDAO.retrieveAllPartnersWithProcurementUsers();
   for (final I_C_BPartner bpartner : bpartnersList) {
     bpartners.put(bpartner.getC_BPartner_ID(), bpartner);
   }
   return ImmutableSet.copyOf(bpartners.keySet());
 }
Пример #5
0
  public I_M_Shipper createShipper(final I_C_BPartner bpartner) {
    final I_M_Shipper shipper =
        InterfaceWrapperHelper.newInstance(I_M_Shipper.class, contextProvider);
    shipper.setName(bpartner.getName());
    shipper.setC_BPartner_ID(bpartner.getC_BPartner_ID());

    InterfaceWrapperHelper.save(shipper);
    return shipper;
  }
Пример #6
0
  public void calculateItems(String childValue) {
    singleMonth = Env.ZERO;
    ;
    singleYear = Env.ZERO;
    ;
    singleTotal = Env.ZERO;

    consolidatedMonth = Env.ZERO;
    consolidatedYear = Env.ZERO;
    consolidatedTotal = Env.ZERO;
    paymentValue = Env.ZERO;

    I_C_BPartner student = studentList.get(childValue);

    for (MTimeExpenseLine paymentSchedule : paymentSchedules) {
      if (paymentSchedule.getC_BPartner_ID() == student.getC_BPartner_ID()) {
        if (!(paymentSchedule.get_ValueAsBoolean("IsPaid"))) {
          I_M_Product concept = paymentSchedule.getM_Product();
          MExpenseType conceptType = (MExpenseType) concept.getS_ExpenseType();

          String type = conceptType.get_ValueAsString(MInvoiceSchedule.COLUMNNAME_InvoiceFrequency);
          if (MInvoiceSchedule.INVOICEFREQUENCY_Monthly.equals(type))
            singleMonth = singleMonth.add(paymentSchedule.getApprovalAmt());
          else if ("Y".equals(type)) singleYear = singleYear.add(paymentSchedule.getApprovalAmt());

          singleTotal = singleTotal.add(paymentSchedule.getApprovalAmt());
        }
      }

      if (!(paymentSchedule.get_ValueAsBoolean("IsPaid"))) {
        MProduct concept = (MProduct) paymentSchedule.getM_Product();
        MExpenseType conceptType = (MExpenseType) concept.getS_ExpenseType();
        String type = conceptType.get_ValueAsString(MInvoiceSchedule.COLUMNNAME_InvoiceFrequency);
        if (MInvoiceSchedule.INVOICEFREQUENCY_Monthly.equals(type))
          consolidatedMonth = consolidatedMonth.add(paymentSchedule.getApprovalAmt());
        else if ("Y".equals(type))
          consolidatedYear = consolidatedYear.add(paymentSchedule.getApprovalAmt());

        consolidatedTotal = consolidatedTotal.add(paymentSchedule.getApprovalAmt());
      }
    }
  }
Пример #7
0
  public Vector<Vector<Object>> getStudentData(MCAHolder holder) {
    Vector<Vector<Object>> data = new Vector<Vector<Object>>();

    for (MCAHolderRelation relation : holder.getHolderRelations()) {
      I_C_BPartner bpartner = relation.getC_BPartner();

      Vector<Object> line = new Vector<Object>();
      line.add(true);
      line.add(bpartner.getValue());
      line.add(bpartner.getName());
      line.add("0000"); // replace by SecureCode
      line.add("0000"); // replace by Enrollment
      line.add("0000"); // replace by Transport Code
      line.add(relation.getChildNo());
      data.add(line);
      studentList.put(bpartner.getValue(), bpartner);
      findPaymentSchedule(bpartner);
    }
    return data;
  }
Пример #8
0
 public I_C_BPartner_Location createBPLocation(final I_C_BPartner bpartner) {
   final I_C_BPartner_Location bpLocation =
       InterfaceWrapperHelper.newInstance(I_C_BPartner_Location.class, bpartner);
   bpLocation.setC_BPartner_ID(bpartner.getC_BPartner_ID());
   bpLocation.setIsBillToDefault(true);
   bpLocation.setIsBillTo(true);
   bpLocation.setIsShipToDefault(true);
   bpLocation.setIsShipTo(true);
   InterfaceWrapperHelper.save(bpLocation);
   return bpLocation;
 }
Пример #9
0
  private SyncBPartner createSyncBPartnerWithoutContracts(final int bpartnerId) {
    final I_C_BPartner bpartner = getC_BPartnerById(bpartnerId);

    final SyncBPartner syncBPartner = new SyncBPartner();
    syncBPartner.setName(bpartner.getName());
    syncBPartner.setUuid(SyncUUIDs.toUUIDString(bpartner));

    // Contracts: we are not populating them here, so, for now we flag them as "do not sync"
    syncBPartner.setSyncContracts(false);

    // not a vendor: no need to look at the contacts. delete the bpartner.
    if (!bpartner.isVendor()) {
      syncBPartner.setDeleted(true);
      return syncBPartner;
    }

    final String adLanguage = bpartner.getAD_Language();

    //
    // Fill Users
    final List<I_AD_User> contacts =
        InterfaceWrapperHelper.createList(bpartnerDAO.retrieveContacts(bpartner), I_AD_User.class);

    for (final I_AD_User contact : contacts) {
      final SyncUser syncUser = createSyncUser(contact, adLanguage);
      if (syncUser == null) {
        continue;
      }
      syncBPartner.getUsers().add(syncUser);
    }

    // no users: also delete the BPartner
    if (syncBPartner.getUsers().isEmpty()) {
      syncBPartner.setDeleted(true);
    }

    return syncBPartner;
  }
Пример #10
0
  public void findPaymentSchedule(I_C_BPartner student) {
    List<MTimeExpenseLine> changes =
        new Query(
                ctx,
                MTimeExpenseLine.Table_Name,
                I_S_TimeExpenseLine.COLUMNNAME_C_BPartner_ID + "=?",
                null)
            .setParameters(student.getC_BPartner_ID())
            .list();

    if (paymentSchedules != null) {
      paymentSchedules.addAll(changes);
    }
  }
Пример #11
0
  public I_C_BPartner createBPartner(final String name) {
    final I_C_BPartner bpartner =
        InterfaceWrapperHelper.newInstance(I_C_BPartner.class, contextProvider);
    bpartner.setValue(name);
    bpartner.setName(name);
    bpartner.setIsCustomer(true);
    bpartner.setIsVendor(true);
    bpartner.setAD_OrgBP_ID(-1);
    bpartner.setC_BP_Group_ID(bpGroupDefault == null ? -1 : bpGroupDefault.getC_BP_Group_ID());

    InterfaceWrapperHelper.save(bpartner);
    return bpartner;
  }
Пример #12
0
  public boolean completePayments(int docType_ID, String documentNo, Timestamp trxDate) {
    boolean success = false;

    message_error = "No se pudo completar los pagos";

    try {

      success = validatePayments();

      // create header

      caPayment = new X_CA_Payment(ctx, 0, null);
      caPayment.setC_BPartner_ID(m_bpartner.get_ID());
      caPayment.setDocumentNo(documentNo);
      caPayment.setC_DocType_ID(docType_ID);
      caPayment.setDateTrx(trxDate);
      caPayment.saveEx();

      // save lines

      // buscar tabla de prioridades
      // List<X_CA_PaymentPreference> priorities = new Query(ctx, X_CA_PaymentPreference.Table_Name,
      // "", null)
      // .setOnlyActiveRecords(true).setOrderBy("SeqNo").list();

      for (int tableRow = 0; tableRow <= paymentTable.getRowCount() - 1; tableRow++) {

        String type = getComboValue(tableRow, 0);

        if (!"AN".equals(type) && !"ME".equals(type))
          throw new AdempiereException("Indicar tipo de pago (Anual/Mensual)");

        String paymentType = getComboValue(tableRow, 1);
        String card = getComboValue(tableRow, 2);
        java.lang.Number quote = (java.lang.Number) paymentTable.getValueAt(tableRow, 3);
        Boolean hasinteres = (Boolean) paymentTable.getValueAt(tableRow, 4);
        String account = getComboValue(tableRow, 5);
        String reference = (String) paymentTable.getValueAt(tableRow, 6);
        java.lang.Number amount = (java.lang.Number) paymentTable.getValueAt(tableRow, 7);

        for (int studentRow = 0; studentRow <= studentTable.getRowCount() - 1; studentRow++) {

          String value = (String) studentTable.getValueAt(studentRow, INDEX_VALUE);
          I_C_BPartner student = studentList.get(value);
          Boolean doPay = (Boolean) studentTable.getValueAt(studentRow, 5);

          if (doPay) {
            MTimeExpenseLine currentSchedule = null;

            for (MTimeExpenseLine schedule : paymentSchedules) {
              if (schedule.getC_BPartner_ID() == student.getC_BPartner_ID()) {
                currentSchedule = schedule;
              }
            }

            if (currentSchedule == null) throw new AdempiereException("No existe programa de Pago");

            // generar nuevo pago
            MPayment payment = new MPayment(ctx, 0, null);

            payment.set_ValueOfColumn("CA_Payment_ID", caPayment.get_ID());
            payment.setC_DocType_ID(1000008); // pago, que siempre no, que es cobro
            payment.setC_BankAccount_ID(Integer.parseInt(account));

            payment.set_ValueOfColumn("SalesRep_ID", Env.getContextAsInt(ctx, "#AD_User_ID"));

            payment.setTenderType(paymentType);

            if ("K".equals(paymentType)
                || "Q".equals(paymentType)) // cheque nacional - internacional
            {
              payment.setCheckNo(reference);
            } else if ("A".equals(paymentType)) // Depósito directo
            {
              payment.setAccountNo(reference);
            } else if ("C".equals(paymentType)) // Tarjeta de Crédito
            {
              payment.setCreditCardType(card);
              payment.setCreditCardNumber(reference);
              payment.set_ValueOfColumn("NumberOfShares", new BigDecimal(String.valueOf(quote)));
              payment.set_ValueOfColumn("HasInterests", hasinteres);
            }

            payment.setC_BPartner_ID(student.getC_BPartner_ID());

            payment.setPayAmt(new BigDecimal(String.valueOf(getAmount(currentSchedule, type))));
            payment.setC_Order_ID(currentSchedule.get_ID());
            payment.setC_Currency_ID(100); // USD

            if (payment.getPayAmt().compareTo(new BigDecimal("0")) > 0) {
              payment.saveEx();
              payment.processIt(DocAction.ACTION_Complete);
            }
          }
        }
      }

      success = true;
    } catch (Exception e) {
      success = false;
      e.printStackTrace();
      message_error = e.getMessage();
    }

    return success;
  }
Пример #13
0
 public SyncBPartner createSyncBPartnerWithoutContracts(final I_C_BPartner bpartner) {
   Check.assumeNotNull(bpartner, "bpartner not null");
   return createSyncBPartnerWithoutContracts(bpartner.getC_BPartner_ID());
 }
  @Override
  public void createSupply(final IMRPCreateSupplyRequest request) {
    final IMRPContext mrpContext = request.getMRPContext();
    final IMRPExecutor executor = request.getMRPExecutor();

    final Properties ctx = mrpContext.getCtx();
    final I_PP_Product_Planning productPlanningData = mrpContext.getProductPlanning();
    final I_AD_Org org = mrpContext.getAD_Org();
    final I_S_Resource plant = mrpContext.getPlant();
    final Timestamp supplyDateFinishSchedule = TimeUtil.asTimestamp(request.getDemandDate());

    // QtyToSupply: qty for which we need to produce the supply
    final BigDecimal qtyToSupply = request.getQtyToSupply();

    // TODO vpj-cd I need to create logic for DRP-040 Shipment Due Action Notice
    // Indicates that a shipment for a Order Distribution is due.
    // Action should be taken at the source warehouse to ensure that the order is received on time.

    // TODO vpj-cd I need to create logic for DRP-050 Shipment Pas Due Action Notice
    // Indicates that a shipment for a Order Distribution is past due. You should either delay the
    // orders created the requirement for the product
    // or expedite them when the product does arrive.

    if (productPlanningData.getDD_NetworkDistribution_ID() <= 0) {
      // Indicates that the Product Planning Data for this product does not specify a valid network
      // distribution.
      executor.newMRPNote(mrpContext, ERR_DRP_060_NoSourceOfSupply).collect();
      //
      return;
    }

    final I_DD_NetworkDistribution network = productPlanningData.getDD_NetworkDistribution();
    final List<I_DD_NetworkDistributionLine> networkLines =
        Services.get(IDistributionNetworkDAO.class)
            .retrieveNetworkLinesByTargetWarehouse(
                network, productPlanningData.getM_Warehouse_ID());
    if (networkLines.isEmpty()) {
      // No network lines were found for our target warehouse
      final I_M_Warehouse warehouseTo = productPlanningData.getM_Warehouse();
      executor
          .newMRPNote(mrpContext, ERR_DRP_060_NoSourceOfSupply)
          .setComment("@NotFound@ @DD_NetworkDistributionLine_ID@")
          .addParameter(
              I_DD_NetworkDistribution.COLUMNNAME_DD_NetworkDistribution_ID,
              network == null ? "?" : network.getName())
          .addParameter("M_Warehouse_Dest_ID", warehouseTo == null ? "?" : warehouseTo.getName())
          .collect();
      //
      return;
    }

    int M_Shipper_ID = -1;
    I_DD_Order order = null;

    BigDecimal qtyToSupplyRemaining = qtyToSupply;
    for (final I_DD_NetworkDistributionLine networkLine : networkLines) {
      //
      // Check: if we created DD Orders for all qty that needed to be supplied, stop here
      if (qtyToSupplyRemaining.signum() <= 0) {
        break;
      }

      // get supply source warehouse and locator
      final I_M_Warehouse warehouseFrom = networkLine.getM_WarehouseSource();
      final I_M_Locator locatorFrom =
          Services.get(IWarehouseBL.class).getDefaultLocator(warehouseFrom);

      // get supply target warehouse and locator
      final I_M_Warehouse warehouseTo = networkLine.getM_Warehouse();
      final I_M_Locator locatorTo = Services.get(IWarehouseBL.class).getDefaultLocator(warehouseTo);

      if (locatorFrom == null || locatorTo == null) {
        executor
            .newMRPNote(mrpContext, "DRP-001") // FIXME: DRP-001 error code does not exist
            .addParameter(
                I_DD_NetworkDistribution.COLUMNNAME_DD_NetworkDistribution_ID,
                network == null ? "?" : network.getName())
            .addParameter(
                I_DD_NetworkDistributionLine.COLUMNNAME_M_WarehouseSource_ID,
                warehouseFrom.getName())
            .addParameter(
                I_DD_NetworkDistributionLine.COLUMNNAME_M_Warehouse_ID, warehouseTo.getName())
            .setComment("No locators found for source or target warehouse")
            .collect();
        //
        continue;
      }

      //
      // Get the warehouse in transit
      final I_M_Warehouse warehouseInTrasit =
          retrieveInTransitWarehouse(ctx, warehouseFrom.getAD_Org_ID());
      if (warehouseInTrasit == null) {
        // DRP-010: Do not exist Transit Warehouse to this Organization
        executor
            .newMRPNote(mrpContext, ERR_DRP_010_InTransitWarehouseNotFound)
            .addParameter(I_AD_Org.COLUMNNAME_AD_Org_ID, org.getName())
            .collect();
        //
        continue;
      }

      //
      // DRP-030: Do not exist Shipper for Create Distribution Order
      if (networkLine.getM_Shipper_ID() <= 0) {
        executor
            .newMRPNote(mrpContext, "DRP-030")
            .addParameter(
                I_DD_NetworkDistribution.COLUMNNAME_DD_NetworkDistribution_ID,
                network == null ? "?" : network.getName())
            .addParameter(
                I_DD_NetworkDistributionLine.COLUMNNAME_DD_NetworkDistributionLine_ID, networkLine)
            .collect();
        //
        continue;
      }

      if (M_Shipper_ID != networkLine.getM_Shipper_ID()) {
        // Org Must be linked to BPartner
        final I_AD_Org locatorToOrg = locatorTo.getAD_Org();
        final IBPartnerOrgBL bpartnerOrgBL = Services.get(IBPartnerOrgBL.class);
        final I_C_BPartner orgBPartner = bpartnerOrgBL.retrieveLinkedBPartner(locatorToOrg);
        if (orgBPartner == null) {
          // DRP-020: Target Org has no BP linked to it
          executor
              .newMRPNote(mrpContext, "DRP-020")
              .addParameter(I_AD_Org.COLUMNNAME_AD_Org_ID, locatorToOrg.getName())
              .collect();
          //
          continue;
        }

        final I_C_BPartner_Location orgBPLocation =
            bpartnerOrgBL.retrieveOrgBPLocation(
                mrpContext.getCtx(), locatorToOrg.getAD_Org_ID(), ITrx.TRXNAME_None);

        //
        // Try found some DD_Order with Shipper , Business Partner and Doc Status = Draft
        // Consolidate the demand in a single order for each Shipper , Business Partner ,
        // DemandDateStartSchedule
        order =
            getDDOrderFromCache(
                org,
                plant,
                warehouseInTrasit,
                networkLine.getM_Shipper_ID(),
                orgBPartner.getC_BPartner_ID(),
                supplyDateFinishSchedule);
        if (order == null) {
          order = InterfaceWrapperHelper.newInstance(I_DD_Order.class, mrpContext);
          order.setMRP_Generated(true);
          order.setMRP_AllowCleanup(true);
          order.setAD_Org_ID(warehouseTo.getAD_Org_ID());
          order.setPP_Plant(plant);
          order.setC_BPartner(orgBPartner);
          order.setC_BPartner_Location(orgBPLocation);
          // order.setAD_User_ID(productPlanningData.getPlanner_ID()); // FIXME: improve
          // performances/cache and retrive Primary BP's User
          order.setSalesRep_ID(productPlanningData.getPlanner_ID());

          final int docTypeDO_ID =
              getC_DocType_ID(mrpContext, X_C_DocType.DOCBASETYPE_DistributionOrder);
          order.setC_DocType_ID(docTypeDO_ID);
          order.setM_Warehouse(warehouseInTrasit);
          order.setDocStatus(X_DD_Order.DOCSTATUS_Drafted);
          order.setDocAction(X_DD_Order.DOCACTION_Complete);
          order.setDateOrdered(mrpContext.getDateAsTimestamp());
          order.setDatePromised(supplyDateFinishSchedule);
          order.setM_Shipper_ID(networkLine.getM_Shipper_ID());
          order.setIsInDispute(false);
          order.setIsInTransit(false);

          InterfaceWrapperHelper.save(order);

          executor.addGeneratedSupplyDocument(order);
          addToCache(order);
        }
        M_Shipper_ID = networkLine.getM_Shipper_ID();
      }

      //
      // Crate DD order line
      final BigDecimal qtyToMove =
          calculateQtyToMove(qtyToSupplyRemaining, networkLine.getPercent());
      createDD_OrderLine(
          mrpContext,
          order,
          networkLine,
          locatorFrom,
          locatorTo,
          qtyToMove,
          supplyDateFinishSchedule,
          request);

      qtyToSupplyRemaining = qtyToSupplyRemaining.subtract(qtyToMove);
    }

    //
    // Check: remaining qtyToSupply shall be ZERO
    if (qtyToSupplyRemaining.signum() != 0) {
      // TODO: introduce DRP-XXX notice
      throw new LiberoException(
          "Cannot create DD Order for required Qty To Supply."
              + "\nQtyToSupply: "
              + qtyToSupply
              + "\nQtyToSupply (remaining): "
              + qtyToSupplyRemaining
              + "\n@DD_NetworkDistribution_ID@: "
              + network
              + "\n@DD_NetworkDistributionLine_ID@: "
              + networkLines
              + "\nMRPContext: "
              + mrpContext);
    }
  }
Пример #15
0
  /**
   * If the bpartner's <code>DocumentCopies</code> changes, then this method updates all unprocessed
   * C_Printing_Queues which reference the bpartner. The update is performed in a dedicated
   * transaction, after the MV's current trx is committed.
   *
   * @task
   *     http://dewiki908/mediawiki/index.php/08958_Druck_Warteschlange_Sortierung_Massendruck_%28103271838939%29
   */
  @ModelChange(
      timings = {ModelValidator.TYPE_AFTER_CHANGE},
      ifColumnsChanged = I_C_BPartner.COLUMNNAME_DocumentCopies)
  public void setCopiesFromBPartner(final I_C_BPartner bPartner) {
    final int documentCopies =
        bPartner.getDocumentCopies() > 0 ? bPartner.getDocumentCopies() : 1; // default

    final ITrxManager trxManager = Services.get(ITrxManager.class);
    trxManager
        .getTrxListenerManager(InterfaceWrapperHelper.getTrxName(bPartner))
        .registerListener(
            new TrxListenerAdapter() {
              @Override
              public void afterCommit(final ITrx trx) {
                trxManager.run(
                    new TrxRunnable() {
                      @Override
                      public void run(final String localTrxName) throws Exception {
                        final Properties ctx = InterfaceWrapperHelper.getCtx(bPartner);

                        final IQueryBL queryBL = Services.get(IQueryBL.class);

                        // 08958: for the starts, we only update queue items that reference invoices
                        final IQuery<I_C_DocType> invoicedocTypeQuery =
                            queryBL
                                .createQueryBuilder(
                                    I_C_DocType.class, ctx, ITrx.TRXNAME_ThreadInherited)
                                .addOnlyActiveRecordsFilter()
                                .addInArrayFilter(
                                    I_C_DocType.COLUMNNAME_DocBaseType,
                                    X_C_DocType.DOCBASETYPE_APCreditMemo,
                                    X_C_DocType.DOCBASETYPE_APInvoice,
                                    X_C_DocType.DOCBASETYPE_ARCreditMemo,
                                    X_C_DocType.DOCBASETYPE_ARInvoice,
                                    X_C_DocType.DOCBASETYPE_ARProFormaInvoice)
                                .create();

                        final int updatedCount =
                            queryBL
                                .createQueryBuilder(
                                    I_C_Printing_Queue.class, ctx, ITrx.TRXNAME_ThreadInherited)
                                .addOnlyActiveRecordsFilter()
                                .addEqualsFilter(
                                    I_C_Printing_Queue.COLUMN_C_BPartner_ID,
                                    bPartner.getC_BPartner_ID())
                                .addEqualsFilter(I_C_Printing_Queue.COLUMN_Processed, false)
                                .addInSubQueryFilter(
                                    I_C_Printing_Queue.COLUMN_C_DocType_ID,
                                    I_C_DocType.COLUMN_C_DocType_ID,
                                    invoicedocTypeQuery)
                                .addNotEqualsFilter(
                                    I_C_Printing_Queue.COLUMN_Copies, documentCopies)
                                .create()
                                .updateDirectly()
                                .addSetColumnValue(
                                    I_C_Printing_Queue.COLUMNNAME_Copies, documentCopies)
                                .setExecuteDirectly(true) // just to be sure
                                .execute();

                        logger.debug(
                            "C_BPartner={}: set C_Printing_Queue.Copies={} for {} C_Printing_Queue records",
                            new Object[] {bPartner, documentCopies, updatedCount});
                      }
                    });
              }
            });
  }