Exemplo n.º 1
0
  @Override
  public Timestamp calculatePreparationDateOrNull(
      IContextAware context,
      boolean isSOTrx,
      Timestamp datePromised,
      final int bpartnerLocationId) {
    // task 09004: add the current time as parameter and fetch the closest next fit delivery day
    final Timestamp calculationTime = SystemTime.asTimestamp();

    //
    // Create Delivery Day Query Parameters
    final PlainDeliveryDayQueryParams deliveryDayQueryParams = new PlainDeliveryDayQueryParams();
    deliveryDayQueryParams.setC_BPartner_Location_ID(bpartnerLocationId);
    deliveryDayQueryParams.setDeliveryDate(datePromised);
    deliveryDayQueryParams.setToBeFetched(!isSOTrx);
    deliveryDayQueryParams.setProcessed(false);
    deliveryDayQueryParams.setCalculationTime(calculationTime);

    //
    // Find matching delivery day record
    final IDeliveryDayDAO deliveryDayDAO = Services.get(IDeliveryDayDAO.class);
    final I_M_DeliveryDay dd = deliveryDayDAO.retrieveDeliveryDay(context, deliveryDayQueryParams);

    //
    // Extract PreparationDate from DeliveryDay record
    final Timestamp preparationDate;
    if (dd == null) {
      preparationDate = null;
    } else {
      preparationDate = dd.getDeliveryDate();
    }

    return preparationDate;
  }
Exemplo n.º 2
0
  private PlainDeliveryDayQueryParams createDeliveryDayQueryParams(
      final IDeliveryDayAllocable deliveryDayAllocable) {
    final PlainDeliveryDayQueryParams params = new PlainDeliveryDayQueryParams();
    params.setC_BPartner_Location_ID(deliveryDayAllocable.getC_BPartner_Location_ID());
    params.setDeliveryDate(deliveryDayAllocable.getDeliveryDate());
    params.setToBeFetched(deliveryDayAllocable.isToBeFetched());

    return params;
  }