Ejemplo n.º 1
0
  @Override
  protected String doIt() throws Exception {
    if (shipmentSchedule == null || shipmentSchedule.getM_ShipmentSchedule_ID() <= 0) {
      throw new FillMandatoryException(I_M_ShipmentSchedule.COLUMNNAME_M_ShipmentSchedule_ID);
    }

    final I_C_OrderLine orderLine = shipmentSchedule.getC_OrderLine();
    final OlAndSched olAndSched = new OlAndSched(orderLine, shipmentSchedule);

    final ShipmentScheduleQtyOnHandStorage storagesContainer =
        new ShipmentScheduleQtyOnHandStorage();
    storagesContainer.setContext(this);
    storagesContainer.setDate(SystemTime.asDayTimestamp());
    storagesContainer.setCachedObjects(new CachedObjects());
    storagesContainer.loadStoragesFor(olAndSched);

    final List<ShipmentScheduleStorageRecord> storageRecords =
        storagesContainer.getStorageRecordsMatching(olAndSched);

    final BigDecimal qtyOnHandTotal =
        Services.get(IStorageBL.class).calculateQtyOnHandSum(storageRecords);
    addLog("@QtyOnHand@ (@Total@): " + qtyOnHandTotal);

    for (final ShipmentScheduleStorageRecord storage : storageRecords) {
      addLog("------------------------------------------------------------");
      addLog(storage.getSummary());
    }

    //
    // Also show the Storage Query
    {
      final IStorageQuery storageQuery = storagesContainer.createStorageQuery(olAndSched);
      addLog("------------------------------------------------------------");
      addLog("Storage Query:");
      addLog(storageQuery.getSummary());
    }

    return MSG_OK;
  }