📄 inventoryvaluedetail.bsh
字号:
/* * Copyright (C) 2006 Open Source Strategies, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *//* * Inventory valuation detail * Inventory item QoH value converted to organization currency (non serialized for now) * * @author Leon Torres (leon@opensourcestrategies.com) * @author Si Chen (sichen@opensourcestrategies.com) */ import java.math.BigDecimal;import javolution.util.FastMap;import org.ofbiz.base.util.*;import org.ofbiz.entity.condition.*;import org.ofbiz.service.*;import com.opensourcestrategies.financials.financials.FinancialServices;organizationPartyId = session.getAttribute("organizationPartyId");userLogin = context.get("userLogin");// make a map of the inventoryItem to the QoH valueinventoryValueDetail = FastMap.newInstance();// organization party conversion factor is already in parameters, thanks to main-decorator.bshorgCurrencyUomId = parameters.get("orgCurrencyUomId");// go through each inventory item and determine the (conversionFactor * QoH amount * unitCost)inventoryItemConditions = new EntityConditionList(UtilMisc.toList( new EntityExpr("ownerPartyId", EntityOperator.EQUALS, organizationPartyId), new EntityExpr("inventoryItemTypeId", EntityOperator.EQUALS, "NON_SERIAL_INV_ITEM"), new EntityExpr("quantityOnHandTotal", EntityOperator.NOT_EQUAL, 0)), EntityOperator.AND);inventoryItems = delegator.findByCondition("InventoryItem", inventoryItemConditions, null, UtilMisc.toList("productId", "inventoryItemId")); // order by productId, inventoryItemIdfor (iter = inventoryItems.iterator(); iter.hasNext(); ) { inventoryItem = iter.next(); // this check may not be a good idea long term if we had serialized items, unless those serialized items had QOH filled in by another service if (inventoryItem.get("quantityOnHandTotal") != null) { amount = inventoryItem.getBigDecimal("quantityOnHandTotal").multiply(inventoryItem.getBigDecimal("unitCost")).setScale(FinancialServices.decimals, FinancialServices.rounding); // convert (ugh) serviceResults = dispatcher.runSync("convertUom", UtilMisc.toMap("uomId", inventoryItem.get("currencyUomId"), "uomIdTo", orgCurrencyUomId, "originalValue", new Double(amount.doubleValue()))); amount = new BigDecimal(((Double) serviceResults.get("convertedValue")).doubleValue()); // round off and store amount = amount.setScale(FinancialServices.decimals, FinancialServices.rounding); inventoryValueDetail.put(inventoryItem, amount); }}context.put("inventoryValueDetail", inventoryValueDetail);// next, report the posted balances of the INV_ADJ_AVG_COST and WIP_INVENTORY accountsadjustmentAccountTypes = new EntityConditionList(UtilMisc.toList( new EntityExpr("glAccountTypeId", EntityOperator.IN, UtilMisc.toList("INV_ADJ_AVG_COST", "WIP_INVENTORY")) ), EntityOperator.AND);adjustmentAccounts = delegator.findByCondition("GlAccountOrganizationAndClass", adjustmentAccountTypes, null, null);context.put("adjustmentAccounts", adjustmentAccounts);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -