Пример #1
0
  private final void addAllocationPerformed(final IMRPDemandToSupplyAllocation alloc) {
    Check.assumeNotNull(alloc, "alloc not null");

    final I_PP_MRP mrpSupplyRecord = alloc.getMRPSupply();
    final BigDecimal mrpSupplyQty = alloc.getQtyAllocated();

    //
    // Check allocated MRP supply and create MRP notes in case something is not ok
    checkMRPSupplyDates(alloc);

    //
    // Update cummulated values
    if (mrpBL.isQtyOnHandReservation(mrpSupplyRecord)) {
      this.qtyOnHandReserved = this.qtyOnHandReserved.add(mrpSupplyQty);
    } else if (mrpBL.isQtyOnHandAnyReservation(mrpSupplyRecord)) {
      // skip any other kind of reservations
    } else {
      final boolean mrpSupplyIsFirm = mrpBL.isReleased(mrpSupplyRecord);
      if (mrpSupplyIsFirm) {
        this.qtyScheduledReceipts = qtyScheduledReceipts.add(mrpSupplyQty);
      }
      this.qtySuppliedTotal = qtySuppliedTotal.add(mrpSupplyQty);
    }

    subtractFromQtyToSupplyRemaining(mrpSupplyQty);

    mrpDemand2supplyAllocations.add(alloc);
  }
Пример #2
0
  /** Check Scheduled Dates for given MRP Supply record and creates MRP notes if needed */
  private void checkMRPSupplyDates(final IMRPDemandToSupplyAllocation mrpDemandToSupplyAlloc) {
    //
    // Extract from parameters only what we need
    final IMRPContext mrpContext = getMRPContext();
    final Date mrpRunDate =
        mrpContext.getDate(); // date when MRP is executed; this is our reference date
    final I_PP_MRP mrpDemandRecord =
        mrpDemandToSupplyAlloc
            .getMRPDemand(); // NOTE: MRP Demand is needed only as a reference, no other
    // informations are/shall be used from there
    final I_PP_MRP mrpSupplyRecord = mrpDemandToSupplyAlloc.getMRPSupply();
    final BigDecimal mrpSupplyQty = mrpDemandToSupplyAlloc.getQtyAllocated();

    // In case is QOH allocation, consider it valid
    if (mrpBL.isQtyOnHandAnyReservation(mrpSupplyRecord)) {
      return;
    }

    //
    //
    final boolean mrpSupplyIsFirm = mrpBL.isReleased(mrpSupplyRecord);
    final boolean mrpSupplyQtyNotZero = mrpSupplyQty.signum() != 0;
    final Date mrpSupplyDateFinishSchedule =
        mrpSupplyRecord
            .getDateFinishSchedule(); // Date when the supply it's scheduled by MRP to be available
    // in our warehouse
    final Date mrpSupplyDatePromised =
        mrpSupplyRecord
            .getDatePromised(); // Date when supply is promised by "vendor" to be available in our
    // warehouse

    //
    // MRP-030 De-Expedite Action Notice
    // Indicates that a schedule supply order is due before it is needed and should be delayed,
    // or demand rescheduled to an earlier date.
    // aka: Push Out
    if (mrpSupplyIsFirm
        && mrpSupplyQtyNotZero
        && mrpSupplyDateFinishSchedule != null
        && mrpSupplyDateFinishSchedule.compareTo(demandDateStartSchedule)
            < 0 // supply is scheduled to arrive before it's needed
    ) {
      newSupplyMRPNote(mrpSupplyRecord, "MRP-030")
          .addParameter("DateSupply", mrpSupplyDateFinishSchedule)
          .addParameter("DateDemand", demandDateStartSchedule)
          .addParameter("PP_MRP_Demand_ID", mrpDemandRecord)
          .collect();
    }

    //
    // MRP-040 Expedite Action Notice
    // Indicates that a scheduled supply order is due after is needed and should be rescheduled to
    // an earlier date or demand rescheduled to a later date.
    // aka: Pull In
    if (mrpSupplyIsFirm
        && mrpSupplyQtyNotZero
        && mrpSupplyDateFinishSchedule != null
        && mrpSupplyDateFinishSchedule.compareTo(demandDateStartSchedule)
            > 0 // supply is scheduled to arrive after it's needed (that could be a serious problem)
    ) {
      newSupplyMRPNote(mrpSupplyRecord, "MRP-040")
          .addParameter("DateSupply", mrpSupplyDateFinishSchedule)
          .addParameter("DateDemand", demandDateStartSchedule)
          .addParameter("PP_MRP_Demand_ID", mrpDemandRecord)
          .collect();
    }

    //
    // MRP-060 Release Due For Action Notice in time
    // Indicate that a supply order should be released. if it is a draft order, it must also be
    // approved.
    // if(date release > today && date release + after floating)
    if (!mrpSupplyIsFirm
        && mrpSupplyQtyNotZero
        && mrpSupplyDatePromised.compareTo(mrpRunDate) >= 0) {
      newSupplyMRPNote(mrpSupplyRecord, MRPExecutor.MRP_ERROR_060_SupplyDueButNotReleased)
          .addParameter("SupplyDatePromised", mrpSupplyDatePromised)
          .addParameter("MRPDateRun", mrpRunDate)
          .collect();
    }

    //
    // MRP-070 Release Past Due For Action Notice overdue
    // Indicates that a supply order was not released when it was due, and should be either released
    // or expedited now, or the demand rescheduled for a later date.
    // if (date release < today && date erelese + before floating)
    if (!mrpSupplyIsFirm
        && mrpSupplyQtyNotZero
        && mrpSupplyDatePromised.compareTo(mrpRunDate) < 0) {
      newSupplyMRPNote(mrpSupplyRecord, MRPExecutor.MRP_ERROR_070_SupplyPastDueButNotReleased)
          .addParameter("SupplyDatePromised", mrpSupplyDatePromised)
          .addParameter("MRPDateRun", mrpRunDate)
          .collect();
    }

    //
    // MRP-110 Past Due Action Notice
    // Indicates that a schedule supply order receipt is past due.
    // i.e. it's a firm supply which was scheduled to be released in the past, but so far it's not
    // received yet.
    if (mrpSupplyIsFirm && mrpSupplyDatePromised.compareTo(mrpRunDate) < 0) {
      newSupplyMRPNote(mrpSupplyRecord, MRPExecutor.MRP_ERROR_110_SupplyPastDueButReleased)
          .addParameter("SupplyDatePromised", mrpSupplyDatePromised)
          .addParameter("MRPDateRun", mrpRunDate)
          .collect();
    }
  }