/** Setup the collections */
  private void setup() {
    if (p_M_CostType_ID > 0) costTypes.add(new MCostType(getCtx(), p_M_CostType_ID, get_TrxName()));
    else costTypes = MCostType.get(getCtx(), get_TrxName());

    if (p_M_CostElement_ID > 0) costElements.add(MCostElement.get(getCtx(), p_M_CostElement_ID));
    else costElements = MCostElement.getCostElement(getCtx(), get_TrxName());

    if (p_M_Warehouse_ID > 0)
      warehouses.add(MWarehouse.get(getCtx(), p_M_Warehouse_ID, get_TrxName()));
    else {
      warehouses =
          new Query(getCtx(), MWarehouse.Table_Name, "", get_TrxName()).setClient_ID().list();
    }
  }
  /** execute the Valuation Effective Date */
  protected String doIt() throws Exception {
    setup();

    for (MWarehouse warehouse : warehouses)
      for (MCostType costType : costTypes)
        for (MCostElement costElement : costElements)
          generateInventoryValue(
              warehouse.getM_Warehouse_ID(),
              costType.getM_CostType_ID(),
              costElement.getM_CostElement_ID());

    DB.executeUpdate(
        "UPDATE T_InventoryValue SET cost = CASE WHEN QtyOnHand <> 0 THEN (CostAmt + CostAmtLL) / QtyOnHand ELSE  0 END  , CumulatedAmt = CostAmt + CostAmtLL,  DateValue = "
            + DB.TO_DATE(p_DateValue)
            + " WHERE AD_PInstance_ID=?",
        getAD_PInstance_ID(),
        get_TrxName());

    return "@Ok@";
  }
Esempio n. 3
0
 public BigDecimal getResourceStandardCostRate(
     I_PP_Cost_Collector cc, int S_Resource_ID, CostDimension d, String trxName) {
   final Properties ctx = InterfaceWrapperHelper.getCtx(cc);
   final I_M_Product resourceProduct =
       MProduct.forS_Resource_ID(ctx, S_Resource_ID, ITrx.TRXNAME_None);
   return getProductStandardCostPrice(
       cc,
       resourceProduct,
       MAcctSchema.get(ctx, d.getC_AcctSchema_ID()),
       MCostElement.get(ctx, d.getM_CostElement_ID()));
 }
Esempio n. 4
0
 public BigDecimal getResourceActualCostRate(
     I_PP_Cost_Collector cc, int S_Resource_ID, CostDimension d, String trxName) {
   if (S_Resource_ID <= 0) return Env.ZERO;
   final MProduct resourceProduct = MProduct.forS_Resource_ID(Env.getCtx(), S_Resource_ID, null);
   return getProductActualCostPrice(
       cc,
       resourceProduct,
       MAcctSchema.get(Env.getCtx(), d.getC_AcctSchema_ID()),
       MCostElement.get(Env.getCtx(), d.getM_CostElement_ID()),
       trxName);
 }
Esempio n. 5
0
 private Collection<I_M_CostElement> getCostElements(Properties ctx) {
   return MCostElement.getByCostingMethod(ctx, getCostingMethod());
 }