Пример #1
0
  @Override
  public void add(final I_C_Order order) {
    Loggables.get().addLog("@Created@ " + order.getDocumentNo());

    orderGeneratedNotifier.notify(order, defaultNotificationRecipientId);

    countOrders.incrementAndGet();
  }
Пример #2
0
  @Override
  protected String doIt() throws Exception {
    final long startTime = System.currentTimeMillis();

    // note: delete the scheds via API to make sure that the appropriate relations are also removed
    final List<MMPurchaseSchedule> schedsToDelete =
        new Query(getCtx(), I_M_PurchaseSchedule.Table_Name, "", get_TrxName())
            .setClient_ID()
            .list();
    for (final MMPurchaseSchedule sched : schedsToDelete) {
      // addLog("Deleting " + sched);
      sched.deleteEx(false);
    }

    final long afterDeleteTime = System.currentTimeMillis();
    addLog(
        "Deleted "
            + schedsToDelete.size()
            + " @M_PurchaseSchedule_ID@ records in "
            + TimeUtil.formatElapsed(afterDeleteTime - startTime));

    final IOrderPA orderPA = Services.get(IOrderPA.class);
    final IPurchaseScheduleBL purchaseScheduleBL = Services.get(IPurchaseScheduleBL.class);

    int createCounter = 0;
    for (final I_C_Order order :
        orderPA.retrieveOpenOrders(DocAction.STATUS_Completed, get_TrxName())) {
      if (!order.isSOTrx()) {
        continue;
      }

      final Collection<MMPurchaseSchedule> purchaseScheds =
          purchaseScheduleBL.retrieveOrCreateForSO(getCtx(), order, get_TrxName());
      for (final MMPurchaseSchedule ps : purchaseScheds) {
        purchaseScheduleBL.updateStorageData(getCtx(), ps, get_TrxName());
        purchaseScheduleBL.updateQtyToOrder(ps);
        ps.saveEx();
      }

      addLog(
          "Created "
              + purchaseScheds.size()
              + " @M_PurchaseSchedule_ID@ records for @C_Order_ID@ "
              + order.getDocumentNo());
      createCounter += purchaseScheds.size();
    }

    addLog(
        "Created "
            + createCounter
            + " purchase schedule records in "
            + TimeUtil.formatElapsed(System.currentTimeMillis() - afterDeleteTime));
    return "@Success@";
  }