示例#1
0
 /**
  * Create shipment/receipt line
  *
  * @param invoice
  * @param invoiceLine
  * @return shipment/receipt line
  */
 private MInOutLine createLine(MInvoice invoice, MInvoiceLine invoiceLine) {
   BigDecimal qtyMatched = invoiceLine.getMatchedQty();
   BigDecimal qtyInvoiced = invoiceLine.getQtyInvoiced();
   BigDecimal qtyNotMatched = qtyInvoiced.subtract(qtyMatched);
   // If is fully matched don't create anything
   if (qtyNotMatched.signum() == 0) {
     return null;
   }
   MInOut inout = getCreateHeader(invoice);
   MInOutLine sLine = new MInOutLine(inout);
   sLine.setInvoiceLine(
       invoiceLine,
       0, //	Locator
       invoice.isSOTrx() ? qtyNotMatched : Env.ZERO);
   sLine.setQtyEntered(qtyNotMatched);
   sLine.setMovementQty(qtyNotMatched);
   if (invoice.isCreditMemo()) {
     sLine.setQtyEntered(sLine.getQtyEntered().negate());
     sLine.setMovementQty(sLine.getMovementQty().negate());
   }
   sLine.saveEx();
   //
   invoiceLine.setM_InOutLine_ID(sLine.getM_InOutLine_ID());
   invoiceLine.saveEx();
   //
   return sLine;
 }
  private void resetQtyDeliverables() {
    olId2QtyDeliverable.clear();

    for (final MInOutLine inOutLine : line2InOut.keySet()) {
      if (inOutLine.getMovementQty().signum() != 0) {
        olId2QtyDeliverable.put(inOutLine.getC_OrderLine_ID(), inOutLine.getMovementQty());
      }
    }
  }
示例#3
0
  public static MTransaction get(MInOutLine line, int M_ASI_ID) {
    final String whereClause =
        I_M_InOutLine.COLUMNNAME_M_Product_ID
            + "=? AND "
            + I_M_InOutLine.COLUMNNAME_M_InOutLine_ID
            + "=? AND "
            + I_M_InOutLine.COLUMNNAME_M_AttributeSetInstance_ID
            + "=?";

    return new Query(line.getCtx(), Table_Name, whereClause, line.get_TrxName())
        .setClient_ID()
        .setParameters(line.getM_Product_ID(), line.getM_InOutLine_ID(), M_ASI_ID)
        .firstOnly();
  }
示例#4
0
  /**
   * get all material transaction for MInOutLine
   *
   * @param line MInOutLine
   * @return List the MTransaction
   */
  public static List<MTransaction> getByInOutLine(MInOutLine line) {
    ArrayList<MTransaction> transactions = new ArrayList();

    List<MInOutLineMA> lines =
        MInOutLineMA.get(line.getCtx(), line.getM_InOutLine_ID(), line.get_TrxName());
    if (lines != null && lines.size() == 0) {
      MTransaction transaction = get(line, line.getM_AttributeSetInstance_ID());
      if (transaction != null && transaction.get_ID() > 0) transactions.add(transaction);

      return transactions;
    }
    for (MInOutLineMA ma : lines) {
      MTransaction trx = get(line, ma.getM_AttributeSetInstance_ID());
      transactions.add(trx);
    }
    return transactions;
  }
  private void updateCompleteStatus() {

    for (final MOrder order : order2InOutLine.keySet()) {
      final String deliveryRule = order.getDeliveryRule();

      if (X_C_Order.DELIVERYRULE_CompleteLine.equals(deliveryRule)) {
        // We only deliver if the line qty is same as the qty
        // ordered by the customer
        for (final MInOutLine inOutLinePO : order2InOutLine.get(order)) {
          if (CompleteStatus.INCOMPLETE_LINE.equals(line2CompleteStatus.get(inOutLinePO))) {
            inOutLinePO.setQtyEntered(BigDecimal.ZERO);
            inOutLinePO.setMovementQty(BigDecimal.ZERO);
          }
        }
      } else if (X_C_Order.DELIVERYRULE_CompleteOrder.equals(deliveryRule)) {
        // We only deliver any line at all if all line qtys as the
        // same as the qty ordered by the customer
        boolean removeAll = false;
        for (final MInOutLine inOutLinePO : order2InOutLine.get(order)) {
          if (CompleteStatus.INCOMPLETE_LINE.equals(line2CompleteStatus.get(inOutLinePO))) {
            removeAll = true;
            break;
          }
        }
        if (removeAll) {
          for (final MInOutLine inOutLinePO : order2InOutLine.get(order)) {
            inOutLinePO.setQtyEntered(BigDecimal.ZERO);
            inOutLinePO.setMovementQty(BigDecimal.ZERO);

            // update the status to show why we set the quantity to zero
            line2CompleteStatus.put(inOutLinePO, CompleteStatus.INCOMPLETE_ORDER);
          }
        }
      } else {
        for (MInOutLine inOutLinePO : order2InOutLine.get(order)) {
          // update the status to show that the "completeness" of this inOuLine is irrelevant
          line2CompleteStatus.put(inOutLinePO, CompleteStatus.OK);
        }
      }
    }
  }