/** * Set Qty Entered - enforce entered UOM * * @param QtyEntered */ @Override public void setQtyEntered(BigDecimal QtyEntered) { if (QtyEntered != null && getC_UOM_ID() != 0) { int precision = MUOM.getPrecision(getCtx(), getC_UOM_ID()); QtyEntered = QtyEntered.setScale(precision, BigDecimal.ROUND_HALF_UP); } super.setQtyEntered(QtyEntered); } // setQtyEntered
/** * Set Qty Ordered - enforce Product UOM * * @param QtyOrdered */ @Override public void setQtyOrdered(BigDecimal QtyOrdered) { MProduct product = getProduct(); if (QtyOrdered != null && product != null) { int precision = product.getUOMPrecision(); QtyOrdered = QtyOrdered.setScale(precision, BigDecimal.ROUND_HALF_UP); } super.setQtyOrdered(QtyOrdered); } // setQtyOrdered
/** * Set Warehouse * * @param M_Warehouse_ID warehouse */ @Override public void setM_Warehouse_ID(int M_Warehouse_ID) { if (getM_Warehouse_ID() > 0 && getM_Warehouse_ID() != M_Warehouse_ID && !canChangeWarehouse( false) // trowEx=false for legacy purposes. We need to evaluate and consider to throw // exception ) { log.error("Ignored - Already Delivered/Invoiced/Reserved"); } else { super.setM_Warehouse_ID(M_Warehouse_ID); } } // setM_Warehouse_ID
/** * Set Qty Entered/Ordered. Use this Method if the Line UOM is the Product UOM * * @param Qty QtyOrdered/Entered */ public void setQty(BigDecimal Qty) { super.setQtyEntered(Qty); super.setQtyOrdered(getQtyEntered()); } // setQty
/** * Set C_Charge_ID * * @param C_Charge_ID charge */ @Override public void setC_Charge_ID(int C_Charge_ID) { super.setC_Charge_ID(C_Charge_ID); if (C_Charge_ID > 0) set_ValueNoCheck("C_UOM_ID", null); } // setC_Charge_ID
/** * Set M_AttributeSetInstance_ID * * @param M_AttributeSetInstance_ID id */ @Override public void setM_AttributeSetInstance_ID(int M_AttributeSetInstance_ID) { if (M_AttributeSetInstance_ID == 0) // 0 is valid ID set_Value("M_AttributeSetInstance_ID", new Integer(0)); else super.setM_AttributeSetInstance_ID(M_AttributeSetInstance_ID); } // setM_AttributeSetInstance_ID
/** * Set Product and UOM * * @param M_Product_ID product * @param C_UOM_ID uom */ public void setM_Product_ID(int M_Product_ID, int C_UOM_ID) { super.setM_Product_ID(M_Product_ID); if (C_UOM_ID != 0) super.setC_UOM_ID(C_UOM_ID); setM_AttributeSetInstance_ID(0); } // setM_Product_ID
/** * Set M_Product_ID * * @param M_Product_ID product * @param setUOM set also UOM */ public void setM_Product_ID(int M_Product_ID, boolean setUOM) { if (setUOM) setProduct(MProduct.get(getCtx(), M_Product_ID)); else super.setM_Product_ID(M_Product_ID); setM_AttributeSetInstance_ID(0); } // setM_Product_ID
/** Calculate Extended Amt. May or may not include tax */ public void setLineNetAmt() { BigDecimal bd = getPriceActual().multiply(getQtyOrdered()); // metas: tsa: begin: 01459 // Line Net Amt shall be zero if the line is not active if (!isActive()) { bd = Env.ZERO; } // metas: tsa: end: 01459 final boolean documentLevel = getTax().isDocumentLevel(); final boolean isTaxIncluded = Services.get(IOrderLineBL.class).isTaxIncluded(this); final int taxPrecision = Services.get(IOrderLineBL.class).getPrecision(this); // juddm: Tax Exempt & Tax Included in Price List & not Document Level - Adjust Line Amount // http://sourceforge.net/tracker/index.php?func=detail&aid=1733602&group_id=176962&atid=879332 if (isTaxIncluded && !documentLevel) { BigDecimal taxStdAmt = Env.ZERO, taxThisAmt = Env.ZERO; MTax orderTax = getTax(); MTax stdTax = null; // get the standard tax if (getProduct() == null) { if (getCharge() != null) // Charge { stdTax = new MTax( getCtx(), ((MTaxCategory) getCharge().getC_TaxCategory()).getDefaultTax().getC_Tax_ID(), get_TrxName()); } } else // Product { // FIXME metas 05129 need proper concept (link between M_Product and C_TaxCategory_ID was // removed!!!!!) throw new AdempiereException( "Unsupported tax calculation when tax is included, but it's not on document level"); // stdTax = new MTax (getCtx(), // ((MTaxCategory) getProduct().getC_TaxCategory()).getDefaultTax().getC_Tax_ID(), // get_TrxName()); } if (stdTax != null) { log.debug("stdTax rate is " + stdTax.getRate()); log.debug("orderTax rate is " + orderTax.getRate()); final ITaxBL taxBL = Services.get(ITaxBL.class); taxThisAmt = taxThisAmt.add(taxBL.calculateTax(orderTax, bd, isTaxIncluded, taxPrecision)); taxStdAmt = taxStdAmt.add(taxBL.calculateTax(stdTax, bd, isTaxIncluded, taxPrecision)); bd = bd.subtract(taxStdAmt).add(taxThisAmt); log.debug( "Price List includes Tax and Tax Changed on Order Line: New Tax Amt: " + taxThisAmt + " Standard Tax Amt: " + taxStdAmt + " Line Net Amt: " + bd); } } if (bd.scale() > taxPrecision) bd = bd.setScale(taxPrecision, BigDecimal.ROUND_HALF_UP); super.setLineNetAmt(bd); } // setLineNetAmt