本文整理汇总了Java中org.compiere.util.Env.ONE属性的典型用法代码示例。如果您正苦于以下问题:Java Env.ONE属性的具体用法?Java Env.ONE怎么用?Java Env.ONE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.compiere.util.Env
的用法示例。
在下文中一共展示了Env.ONE属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: issueInventory
/**
* Issue from Inventory
* @return Message (clear text)
*/
private String issueInventory()
{
if (m_M_Locator_ID == 0)
throw new IllegalArgumentException("No Locator");
if (m_M_Product_ID == 0)
throw new IllegalArgumentException("No Product");
// Set to Qty 1
if (m_MovementQty == null || m_MovementQty.signum() == 0)
m_MovementQty = Env.ONE;
//
MProjectIssue pi = new MProjectIssue (m_project);
pi.setMandatory (m_M_Locator_ID, m_M_Product_ID, m_MovementQty);
if (m_MovementDate != null) // default today
pi.setMovementDate(m_MovementDate);
if (m_Description != null && m_Description.length() > 0)
pi.setDescription(m_Description);
pi.process();
// Create Project Line
MProjectLine pl = new MProjectLine(m_project);
pl.setMProjectIssue(pi);
pl.save();
addLog(pi.getLine(), pi.getMovementDate(), pi.getMovementQty(), null);
return "@[email protected] 1";
}
示例2: getFunctionValue
/**
* Get Function Value
* @return length or numeric value
*/
public BigDecimal getFunctionValue()
{
if (m_value == null)
return Env.ZERO;
// Numbers - return number value
if (m_value instanceof BigDecimal)
return (BigDecimal)m_value;
if (m_value instanceof Number)
return new BigDecimal(((Number)m_value).doubleValue());
// Boolean - return 1 for true 0 for false
if (m_value instanceof Boolean)
{
if (((Boolean)m_value).booleanValue())
return Env.ONE;
else
return Env.ZERO;
}
// Return Length
String s = m_value.toString();
return new BigDecimal(s.length());
}
示例3: planned
/**
* Project Planned - Price + Qty.
* - called from PlannedPrice, PlannedQty
* - calculates PlannedAmt (same as Trigger)
* @param ctx context
* @param WindowNo current Window No
* @param mTab Grid Tab
* @param mField Grid Field
* @param value New Value
* @return null or error message
*/
public String planned (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
if (isCalloutActive() || value == null)
return "";
BigDecimal PlannedQty, PlannedPrice;
int StdPrecision = Env.getContextAsInt(ctx, WindowNo, "StdPrecision");
// get values
PlannedQty = (BigDecimal)mTab.getValue("PlannedQty");
if (PlannedQty == null)
PlannedQty = Env.ONE;
PlannedPrice = ((BigDecimal)mTab.getValue("PlannedPrice"));
if (PlannedPrice == null)
PlannedPrice = Env.ZERO;
//
BigDecimal PlannedAmt = PlannedQty.multiply(PlannedPrice);
if (PlannedAmt.scale() > StdPrecision)
PlannedAmt = PlannedAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP);
//
log.debug("PlannedQty=" + PlannedQty + " * PlannedPrice=" + PlannedPrice + " -> PlannedAmt=" + PlannedAmt + " (Precision=" + StdPrecision+ ")");
mTab.setValue("PlannedAmt", PlannedAmt);
return "";
}
示例4: setCurrencyRate
/**
* Set Currency Rate
*
* @param CurrencyRate check for null (->one)
*/
@Override
public void setCurrencyRate(BigDecimal CurrencyRate)
{
if (CurrencyRate == null)
{
log.warn("was NULL - set to 1");
super.setCurrencyRate(Env.ONE);
}
else if (CurrencyRate.signum() < 0)
{
log.warn("negative - " + CurrencyRate + " - set to 1");
super.setCurrencyRate(Env.ONE);
}
else
super.setCurrencyRate(CurrencyRate);
}
示例5: getMultiplier
/**
* Get Multiplier from Scope to Display
* @param goal goal
* @return null if error or multiplier
*/
public static BigDecimal getMultiplier (MGoal goal)
{
String MeasureScope = goal.getMeasureScope();
String MeasureDisplay = goal.getMeasureDisplay();
if (MeasureDisplay == null
|| MeasureScope.equals(MeasureDisplay))
return Env.ONE; // 1:1
if (MeasureScope.equals(MEASURESCOPE_Total)
|| MeasureDisplay.equals(MEASUREDISPLAY_Total))
return null; // Error
BigDecimal Multiplier = null;
if (MeasureScope.equals(MEASURESCOPE_Year))
{
if (MeasureDisplay.equals(MEASUREDISPLAY_Quarter))
Multiplier = new BigDecimal(1.0/4.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Month))
Multiplier = new BigDecimal(1.0/12.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Week))
Multiplier = new BigDecimal(1.0/52.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Day))
Multiplier = new BigDecimal(1.0/364.0);
}
else if (MeasureScope.equals(MEASURESCOPE_Quarter))
{
if (MeasureDisplay.equals(MEASUREDISPLAY_Year))
Multiplier = new BigDecimal(4.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Month))
Multiplier = new BigDecimal(1.0/3.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Week))
Multiplier = new BigDecimal(1.0/13.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Day))
Multiplier = new BigDecimal(1.0/91.0);
}
else if (MeasureScope.equals(MEASURESCOPE_Month))
{
if (MeasureDisplay.equals(MEASUREDISPLAY_Year))
Multiplier = new BigDecimal(12.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Quarter))
Multiplier = new BigDecimal(3.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Week))
Multiplier = new BigDecimal(1.0/4.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Day))
Multiplier = new BigDecimal(1.0/30.0);
}
else if (MeasureScope.equals(MEASURESCOPE_Week))
{
if (MeasureDisplay.equals(MEASUREDISPLAY_Year))
Multiplier = new BigDecimal(52.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Quarter))
Multiplier = new BigDecimal(13.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Month))
Multiplier = new BigDecimal(4.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Day))
Multiplier = new BigDecimal(1.0/7.0);
}
else if (MeasureScope.equals(MEASURESCOPE_Day))
{
if (MeasureDisplay.equals(MEASUREDISPLAY_Year))
Multiplier = new BigDecimal(364.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Quarter))
Multiplier = new BigDecimal(91.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Month))
Multiplier = new BigDecimal(30.0);
else if (MeasureDisplay.equals(MEASUREDISPLAY_Week))
Multiplier = new BigDecimal(7.0);
}
return Multiplier;
}
示例6: fetchOpenAmount
/**
* Get Open Amount invoice
*
* @param payment
* @param creditMemoAdjusted True if we want to get absolute values for Credit Memos
* @return
*/
private BigDecimal fetchOpenAmount(final I_C_Payment payment, final boolean creditMemoAdjusted)
{
final Properties ctx = InterfaceWrapperHelper.getCtx(payment);
BigDecimal InvoiceOpenAmt = Env.ZERO;
final int C_Invoice_ID = payment.getC_Invoice_ID();
final int C_Order_ID = payment.getC_Order_ID();
if (C_Invoice_ID > 0)
{
InvoiceOpenAmt = Services.get(IPaymentDAO.class).getInvoiceOpenAmount(payment, creditMemoAdjusted);
}
else if (C_Order_ID > 0)
{
final BigDecimal grandTotal = payment.getC_Order().getGrandTotal();
final BigDecimal allocated = Services.get(IPrepayOrderBL.class).retrieveAllocatedAmt(ctx, C_Order_ID, ITrx.TRXNAME_None);
InvoiceOpenAmt = grandTotal.subtract(allocated);
}
log.debug("Open=" + InvoiceOpenAmt + ", C_Invoice_ID=" + C_Invoice_ID);
final int C_Currency_ID = payment.getC_Currency_ID();
final I_C_Currency currency = payment.getC_Currency();
final int C_Currency_Invoice_ID = fetchC_Currency_Invoice_ID(payment);
final Timestamp ConvDate = payment.getDateTrx();
final int C_ConversionType_ID = payment.getC_ConversionType_ID();
final int AD_Client_ID = payment.getAD_Client_ID();
final int AD_Org_ID = payment.getAD_Org_ID();
// Get Currency Rate
BigDecimal CurrencyRate = Env.ONE;
if ((C_Currency_ID > 0 && C_Currency_Invoice_ID > 0 && C_Currency_ID != C_Currency_Invoice_ID))
{
log.debug("InvCurrency=" + C_Currency_Invoice_ID + ", PayCurrency="
+ C_Currency_ID + ", Date=" + ConvDate + ", Type="
+ C_ConversionType_ID);
CurrencyRate = Services.get(ICurrencyBL.class).getRate(C_Currency_Invoice_ID, C_Currency_ID, ConvDate, C_ConversionType_ID, AD_Client_ID, AD_Org_ID);
if (CurrencyRate == null || CurrencyRate.compareTo(Env.ZERO) == 0)
{
if (C_Currency_Invoice_ID == 0)
{
return InvoiceOpenAmt;
}
throw new AdempiereException("NoCurrencyConversion");
}
//
InvoiceOpenAmt = InvoiceOpenAmt.multiply(CurrencyRate).setScale(
currency.getStdPrecision(), BigDecimal.ROUND_HALF_UP);
log.debug("Rate=" + CurrencyRate + ", InvoiceOpenAmt="
+ InvoiceOpenAmt);
}
return InvoiceOpenAmt;
}
示例7: onCurrencyChange
@Override
public void onCurrencyChange(final I_C_Payment payment)
{
final int C_Invoice_ID = payment.getC_Invoice_ID();
final int C_Order_ID = payment.getC_Order_ID();
// Get Currency Info
final int C_Currency_ID = payment.getC_Currency_ID();
final I_C_Currency currency = payment.getC_Currency();
final int C_Currency_Invoice_ID = fetchC_Currency_Invoice_ID(payment);
final Timestamp ConvDate = payment.getDateTrx();
final int C_ConversionType_ID = payment.getC_ConversionType_ID();
final int AD_Client_ID = payment.getAD_Client_ID();
final int AD_Org_ID = payment.getAD_Org_ID();
// Get Currency Rate
BigDecimal CurrencyRate = Env.ONE;
if ((C_Currency_ID > 0 && C_Currency_Invoice_ID > 0 && C_Currency_ID != C_Currency_Invoice_ID))
{
log.debug("InvCurrency={}, PayCurrency={}, Date={}, Type={}"
, new Object[] { C_Currency_Invoice_ID, C_Currency_ID, C_Currency_ID, ConvDate, C_ConversionType_ID });
final ICurrencyBL currencyBL = Services.get(ICurrencyBL.class);
CurrencyRate = currencyBL.getRate(C_Currency_Invoice_ID, C_Currency_ID, ConvDate, C_ConversionType_ID, AD_Client_ID, AD_Org_ID);
if (Check.isEmpty(CurrencyRate))
{
if (C_Currency_Invoice_ID <= 0)
{
return; // no error message when no invoice is selected
}
final ICurrencyConversionContext conversionCtx = currencyBL.createCurrencyConversionContext(ConvDate, C_ConversionType_ID, AD_Client_ID, AD_Org_ID);
throw new NoCurrencyRateFoundException(conversionCtx, C_Currency_Invoice_ID, C_Currency_ID);
}
}
BigDecimal PayAmt = payment.getPayAmt();
BigDecimal DiscountAmt = payment.getDiscountAmt();
BigDecimal WriteOffAmt = payment.getWriteOffAmt();
BigDecimal OverUnderAmt = payment.getOverUnderAmt();
PayAmt = PayAmt.multiply(CurrencyRate).setScale(currency.getStdPrecision(), BigDecimal.ROUND_HALF_UP);
payment.setPayAmt(PayAmt);
DiscountAmt = DiscountAmt.multiply(CurrencyRate).setScale(currency.getStdPrecision(), BigDecimal.ROUND_HALF_UP);
payment.setDiscountAmt(DiscountAmt);
WriteOffAmt = WriteOffAmt.multiply(CurrencyRate).setScale(currency.getStdPrecision(), BigDecimal.ROUND_HALF_UP);
payment.setWriteOffAmt(WriteOffAmt);
OverUnderAmt = OverUnderAmt.multiply(CurrencyRate).setScale(currency.getStdPrecision(), BigDecimal.ROUND_HALF_UP);
payment.setOverUnderAmt(OverUnderAmt);
// No Invoice or Order - Set Discount, Witeoff, Under/Over to 0
if (C_Invoice_ID <= 0 && C_Order_ID <= 0)
{
if (Env.ZERO.compareTo(DiscountAmt) != 0)
{
payment.setDiscountAmt(Env.ZERO);
}
if (Env.ZERO.compareTo(WriteOffAmt) != 0)
{
payment.setWriteOffAmt(Env.ZERO);
}
if (Env.ZERO.compareTo(OverUnderAmt) != 0)
{
payment.setOverUnderAmt(Env.ZERO);
}
}
}