Example #1
0
 public static void printOrder(Properties ctx, MOrder order, OrderLineBean bean)
     throws OperationException {
   if (order.getOrderType().equals(UDIOrderTypes.POS_ORDER.getOrderType())) {
     PrintManager.openCashDrawer(ctx);
   }
   PrintManager.print(ctx, ReportEngine.ORDER, order.get_ID(), bean);
 }
Example #2
0
  public static MOrder createOrder(
      Properties ctx,
      int bPartnerId,
      boolean isSotrx,
      int priceListId,
      String orderType,
      int warehouseId,
      String paymentRule,
      String trxName)
      throws OperationException {
    int terminalId = POSTerminalManager.getTerminalId(ctx);
    if (terminalId == 0) {
      throw new OperationException("NO POS Terminal!!!");
    }

    MOrder order = new MOrder(ctx, 0, trxName);
    MBPartner bPartner = new MBPartner(ctx, bPartnerId, trxName);

    if (bPartner.getPrimaryC_BPartner_Location_ID() == 0)
      throw new BPartnerNoLocationException("Business partner has no location");
    order.setAD_Org_ID(Env.getAD_Org_ID(ctx));
    // order.setC_POS_ID(terminalId);  TODO - Trifon; order.setU_POSTerminal_ID(terminalId);
    order.setBPartner(bPartner);
    order.setC_BPartner_ID(bPartner.get_ID());
    order.setC_BPartner_Location_ID(bPartner.getPrimaryC_BPartner_Location_ID());
    order.setIsSOTrx(isSotrx);

    order.setM_PriceList_ID(priceListId);

    MPriceList priceList = new MPriceList(ctx, priceListId, null);
    order.setC_Currency_ID(priceList.getC_Currency_ID());
    order.setDocAction(DocumentEngine.ACTION_Complete);
    order.setSalesRep_ID(Env.getAD_User_ID(ctx));

    if (orderType.equalsIgnoreCase(UDIOrderTypes.CREDIT_ORDER_NO_SHIPMENT.getOrderType())) {
      /**
       * because for credit orders, compiere generates shipment automatically, so we want a credit
       * order with standard doc type
       */
      order.setC_DocTypeTarget_ID(
          getDocTypeFromOrderType(ctx, UDIOrderTypes.POS_ORDER.getOrderType(), isSotrx));
      order.setOrderType(UDIOrderTypes.CREDIT_ORDER.getOrderType());
    } else {
      order.setC_DocTypeTarget_ID(getDocTypeFromOrderType(ctx, orderType, isSotrx));
      order.setOrderType(orderType);
    }

    order.setM_Warehouse_ID(warehouseId);
    order.setIsDiscountPrinted(true);
    if (paymentRule != null) order.setPaymentRule(paymentRule);

    order.setDateOrdered(new Timestamp(System.currentTimeMillis()));
    order.setInvoiceRule(MOrder.INVOICERULE_Immediate);

    PoManager.save(order);

    return order;
  }
Example #3
0
  public static int getDocTypeFromOrderType(Properties ctx, String orderType, Boolean isSotrx)
      throws OperationException {

    MDocType[] docBaseTypes;

    if (orderType.equalsIgnoreCase(UDIOrderTypes.POS_ORDER.getOrderType())) {

      return getDocTypeIDForStandardOrder(ctx);
    }

    if (orderType.equalsIgnoreCase(UDIOrderTypes.CUSTOMER_RETURN_ORDER.getOrderType())) {
      return getDocTypeIDForCustomerReturnOrder(ctx, isSotrx);
    }

    if (orderType.equalsIgnoreCase(UDIOrderTypes.POS_GOODS_RETURN_NOTE.getOrderType())) {
      docBaseTypes = MDocType.getOfDocBaseType(ctx, MDocType.DOCBASETYPE_APCreditMemo);
      if (docBaseTypes.length > 1)
        throw new OperationException(
            "Expected one document type for AP Credit Memo but got more than 1");

      return docBaseTypes[0].get_ID();
    }

    if (orderType.equalsIgnoreCase(UDIOrderTypes.POS_GOODS_RECEIVE_NOTE.getOrderType())) {
      docBaseTypes = MDocType.getOfDocBaseType(ctx, MDocType.DOCBASETYPE_PurchaseOrder);

      for (int i = 0; i < docBaseTypes.length; i++) {
        MDocType doctype = (MDocType) docBaseTypes[i];

        if (doctype.getDocSubTypeSO() == null) {
          return doctype.get_ID();
        }
      }
    }

    if (orderType.equalsIgnoreCase(UDIOrderTypes.WEBSTORE_ORDER.getOrderType())) {
      MDocType.getAllIDs(
          MDocType.Table_Name,
          "AD_CLIENT_ID="
              + Env.getAD_Client_ID(ctx)
              + " and DOCSUBTYPESO='"
              + MDocType.DOCSUBTYPESO_StandardOrder
              + "'",
          null);
      return getDocTypeIDForStandardOrder(ctx);
    }

    if (orderType.equalsIgnoreCase(UDIOrderTypes.CREDIT_ORDER.getOrderType())) {
      return getDocTypeIDForCreditOrder(ctx);
    } else return getDocTypeIDForStandardOrder(ctx);
  }
Example #4
0
 public static void printOrder(Properties ctx, MOrder order) throws OperationException {
   if (order.getOrderType().equals(UDIOrderTypes.POS_ORDER.getOrderType())) {
     PrintManager.openCashDrawer(ctx);
   }
   PrintManager.printOrder(ctx, order.get_ID(), null);
 }