Search in sources :

Example 1 with I_M_Shipper

use of org.compiere.model.I_M_Shipper in project adempiere by adempiere.

the class FreightModelValidator method getFreight.

/**
     * get Freight based on Sales Order Line and inOutBound
     *
     * @param orderLine
     * @param inOutBound
     * @return
     */
private BigDecimal getFreight(MOrderLine orderLine, MWMInOutBound inOutBound) {
    MOrder order = orderLine.getParent();
    MWarehouse warehouse = (MWarehouse) order.getM_Warehouse();
    I_M_Shipper shipper = MOrder.FREIGHTCOSTRULE_Line.equals(order.getFreightCostRule()) ? orderLine.getM_Shipper() : order.getM_Shipper();
    int freightCategoryId = inOutBound == null ? MOrder.FREIGHTCOSTRULE_Line.equals(order.getFreightCostRule()) ? orderLine.getM_FreightCategory_ID() : order.getM_FreightCategory_ID() : inOutBound.getM_FreightCategory_ID();
    if (isCalculatedFreight(order.getFreightCostRule()) && freightCategoryId > 0) {
        freightEngine = FreightEngineFactory.getFreightEngine(orderLine.getAD_Client_ID());
        return freightEngine.getFreightRuleFactory(shipper, order.getFreightCostRule()).calculate(order.getCtx(), orderLine.getM_Product_ID(), shipper.getM_Shipper_ID(), warehouse.getC_Location_ID(), order.getC_BPartner_Location().getC_Location_ID(), freightCategoryId, order.getC_Currency_ID(), order.getDateOrdered(), order.get_TrxName());
    }
    return BigDecimal.ZERO;
}
Also used : MOrder(org.compiere.model.MOrder) MWarehouse(org.compiere.model.MWarehouse) I_M_Shipper(org.compiere.model.I_M_Shipper)

Example 2 with I_M_Shipper

use of org.compiere.model.I_M_Shipper in project adempiere by adempiere.

the class FreightModelValidator method getFreight.

/**
     * get Freight based on Distribution Order and inOutBound
     *
     * @param orderLine
     * @param inOutBound
     * @return
     */
private BigDecimal getFreight(MDDOrderLine orderLine, MWMInOutBound inOutBound) {
    MDDOrder order = orderLine.getParent();
    I_M_Shipper shipper = MOrder.FREIGHTCOSTRULE_Line.equals(order.getFreightCostRule()) ? orderLine.getM_Shipper() : order.getM_Shipper();
    int freightCategoryId = inOutBound == null ? MOrder.FREIGHTCOSTRULE_Line.equals(order.getFreightCostRule()) ? orderLine.getM_FreightCategory_ID() : order.getM_FreightCategory_ID() : inOutBound.getM_FreightCategory_ID();
    if (isCalculatedFreight(order.getFreightCostRule()) && freightCategoryId > 0) {
        return freightEngine.getFreightRuleFactory(shipper, order.getFreightCostRule()).calculate(order.getCtx(), orderLine.getM_Product_ID(), shipper.getM_Shipper_ID(), orderLine.getM_Locator().getM_Warehouse().getC_Location_ID(), order.getC_BPartner_Location().getC_Location_ID(), freightCategoryId, order.getC_Currency_ID(), order.getDateOrdered(), order.get_TrxName());
    }
    return BigDecimal.ZERO;
}
Also used : I_M_Shipper(org.compiere.model.I_M_Shipper)

Aggregations

I_M_Shipper (org.compiere.model.I_M_Shipper)2 MOrder (org.compiere.model.MOrder)1 MWarehouse (org.compiere.model.MWarehouse)1