📄 uiwebscreensectionopportunity.java
字号:
/*
*
* Copyright (c) 2004 SourceTap - www.sourcetap.com
*
* The contents of this file are subject to the SourceTap Public License
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
*/
package com.sourcetap.sfa.opportunity;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import com.sourcetap.sfa.event.EventUtility;
import com.sourcetap.sfa.ui.UICache;
import com.sourcetap.sfa.ui.UIFieldInfo;
import com.sourcetap.sfa.ui.UIWebScreenSection;
import com.sourcetap.sfa.util.UserInfo;
/**
* DOCUMENT ME!
*
*/
public class UIWebScreenSectionOpportunity extends UIWebScreenSection {
public static final String module = UIWebScreenSectionOpportunity.class.getName();
public UIWebScreenSectionOpportunity(UserInfo userInfo, String screenName,
String sectionName, GenericDelegator delegator, UICache uiCache)
throws GenericEntityException {
super(userInfo, screenName, sectionName, delegator, uiCache);
}
/**
* DOCUMENT ME!
*
* @param fieldInfo
* @param entityDetailsVector
* @param action
* @param row
* @param isSubsection
* @param tabOffset
*
* @return
*/
public String displayField(UIFieldInfo fieldInfo,
Vector entityDetailsVector, String action, int row,
boolean isSubsection, int tabOffset) {
if (fieldInfo.getUiAttribute().getAttributeName().trim().equals("amount")) {
GenericValue fieldEntityDetails = (GenericValue) entityDetailsVector.get(0);
String useProductsForAmount = (fieldEntityDetails.get(
"useProductsForAmount") == null) ? "N"
: fieldEntityDetails.getString(
"useProductsForAmount");
if (useProductsForAmount.equalsIgnoreCase("Y")) {
// Get Opportunity Products for the opportunity and add up their amounts.
double amount = 0.0;
try {
HashMap dealMap = new HashMap();
dealMap.put("dealId", fieldEntityDetails.getString("dealId"));
List opportunityProductList = delegator.findByAnd("OpportunityProduct",
dealMap, null);
GenericValue[] oppProds = (GenericValue[]) opportunityProductList.toArray(new GenericValue[0]);
GenericValue oppProd = null;
long quantity = 0;
for (int i = 0; i < oppProds.length; i++) {
oppProd = oppProds[i];
quantity = (((oppProd.getString("quantity") == null) ||
oppProd.getString("quantity").equalsIgnoreCase("null"))
? 1 : oppProd.getLong("quantity").longValue());
// Get the quantity * price
if ((oppProd.getString("quantity") == null) ||
(oppProd.getString("defaultPrice") == null)) {
amount = amount +
(oppProd.getDouble("defaultPrice").doubleValue() * quantity);
} else if (oppProd.getString("amount") != null) {
amount = amount +
oppProd.getDouble("amount").doubleValue();
} else {
amount = amount + 0.0;
}
}
} catch (GenericEntityException e) {
Debug.logError(
"[UIWebScreenSectionOpportunity.displayField]: Error occurred while searching for opportunity products: ", module);
Debug.logError(" " + e.getLocalizedMessage(), module);
}
// Store the new amount in the generic value so the super can display the new amount.
fieldEntityDetails.set("amount",
EventUtility.parseNumber(String.valueOf(amount)));
}
}
return super.displayField(fieldInfo, entityDetailsVector, action, row,
isSubsection, tabOffset);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -