当前位置: 首页>>代码示例>>Java>>正文


Java Env.getContextAsDate方法代码示例

本文整理汇总了Java中org.compiere.util.Env.getContextAsDate方法的典型用法代码示例。如果您正苦于以下问题:Java Env.getContextAsDate方法的具体用法?Java Env.getContextAsDate怎么用?Java Env.getContextAsDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.compiere.util.Env的用法示例。


在下文中一共展示了Env.getContextAsDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepare

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
    *  Prepare - e.g., get Parameters.
    */
   @Override
protected void prepare()
   {
       
       ProcessInfoParameter[] para = getParametersAsArray();
       for (int i = 0; i < para.length; i++)
       {
           String name = para[i].getParameterName();
           if (para[i].getParameter() == null)
               ;
           else if (name.equals("Selection"))
               p_Selection = "Y".equals(para[i].getParameter());
           else if (name.equals("DocAction"))
               p_docAction = (String)para[i].getParameter();
           else
               log.error("Unknown Parameter: " + name);
       }
       
       m_dateinvoiced = Env.getContextAsDate(getCtx(), "#Date");
       if (m_dateinvoiced == null)
       {
           m_dateinvoiced = new Timestamp(System.currentTimeMillis());
       }
   }
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:28,代码来源:InvoiceGenerateRMA.java

示例2: prepare

import org.compiere.util.Env; //导入方法依赖的package包/类
protected void prepare()
{
    ProcessInfoParameter[] para = getParametersAsArray();
    for (int i = 0; i < para.length; i++)
    {
        String name = para[i].getParameterName();
        if (para[i].getParameter() == null)
            ;
        else if (name.equals("M_Warehouse_ID"))
            p_M_Warehouse_ID = para[i].getParameterAsInt();
        else if (name.equals("Selection"))
            p_Selection = "Y".equals(para[i].getParameter());
        else if (name.equals("DocAction"))
            p_docAction = (String)para[i].getParameter();
        else
            log.error("Unknown Parameter: " + name);
    }
    
    m_movementDate = Env.getContextAsDate(getCtx(), "#Date");
    if (m_movementDate == null)
    {
        m_movementDate = new Timestamp(System.currentTimeMillis());
    }
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:25,代码来源:InOutGenerateRMA.java

示例3: transferMaterialToNewHUs

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 * Sets up a {@link HUListAllocationSourceDestination} for the given {@code sourceHUs} and loads them to the given {@code lutuProducer}.
 * <p>
 * You can use {@link LUTUProducerDestination#getCreatedHUs()} to collect the results after the loading.
 * Note that this method does less than {@link IHUSplitBuilder}. E.g. it does not:
 * <li>propagate the source HUs' Locator, Status etc
 * <li>destroy empty source HUs
 *
 * @param sourceHUs
 * @param lutuProducer used as the loader's {@link IAllocationDestination}
 * @param qty
 * @param product
 * @param uom
 * @return
 */
public void transferMaterialToNewHUs(final List<I_M_HU> sourceHUs,
		final LUTUProducerDestination lutuProducer,
		final BigDecimal qty,
		final I_M_Product product,
		final I_C_UOM uom)
{
	Check.assume(Adempiere.isUnitTestMode(), "This method shall be executed only in JUnit test mode");

	final IMutableHUContext huContext = getHUContext();
	final Date date = Env.getContextAsDate(Env.getCtx(), "#Date"); // FIXME use context date for now

	final IAllocationSource source = HUListAllocationSourceDestination.of(sourceHUs);

	final HULoader loader = HULoader.of(source, lutuProducer);

	// allowing partial loads and unloads because that's interesting cases to test
	loader.setAllowPartialUnloads(true);
	loader.setAllowPartialLoads(true);

	final IAllocationRequest request = AllocationUtils.createQtyRequest(huContext, product, qty, uom, date);

	loader.load(request); // use context date for now
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:39,代码来源:HUTestHelper.java

示例4: setCommission_Calendar_ID

import org.compiere.util.Env; //导入方法依赖的package包/类
private void setCommission_Calendar_ID(final Properties ctx)
{
	final de.metas.adempiere.model.I_AD_User loggedUser = Services.get(IUserDAO.class).retrieveUser(Env.getAD_User_ID(ctx));
	final I_C_BPartner bp = InterfaceWrapperHelper.create(loggedUser.getC_BPartner(), I_C_BPartner.class);
	if (bp == null || bp.getC_BPartner_ID() == 0)
	{
		return;
	}

	final ISponsorBL sponsorBL = Services.get(ISponsorBL.class);

	final Timestamp date = Env.getContextAsDate(ctx, "#Date");
	final I_C_Sponsor sponsor = retrieveSalesrepOrCustomerSponsorAt(bp, date);

	final I_C_AdvCommissionCondition contract = sponsorBL.retrieveContract(ctx, sponsor, date, null);
	if (contract == null)
	{
		return;
	}
	final int C_Calendar_ID = contract.getC_Calendar_ID();
	if (C_Calendar_ID >= 0)
	{
		Env.setContext(ctx, CommissionValidator.CTX_Commission_Calendar_ID, C_Calendar_ID);
		Env.setContext(ctx, CommissionValidator.CTX_Commission_System_ID, contract.getC_AdvComSystem_ID());
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:27,代码来源:CommissionValidator.java

示例5: prepare

import org.compiere.util.Env; //导入方法依赖的package包/类
@Override
protected void prepare()
{
	// Defaults
	p_DunningDate = Env.getContextAsDate(getCtx(), "#Date");
	p_IsFullUpdate = false;

	for (ProcessInfoParameter para : getParametersAsArray())
	{
		if (para.getParameter() == null)
		{
			// skip if no parameter value
			continue;
		}

		final String name = para.getParameterName();
		if (PARAM_DunningDate.equals(name))
		{
			p_DunningDate = para.getParameterAsTimestamp();
		}
		else if (PARAM_IsFullUpdate.equals(name))
		{
			p_IsFullUpdate = para.getParameterAsBoolean();
		}
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:27,代码来源:C_Dunning_Candidate_Create.java

示例6: prepare

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 * Prepare - e.g., get Parameters.
 */
@Override
protected void prepare()
{
	ProcessInfoParameter[] para = getParametersAsArray();
	for (int i = 0; i < para.length; i++)
	{
		String name = para[i].getParameterName();
		if (para[i].getParameter() == null)
			;
		else if (name.equals("Selection"))
			p_Selection = "Y".equals(para[i].getParameter());
		else if (name.equals("DateInvoiced"))
			p_DateInvoiced = (Timestamp)para[i].getParameter();
		else if (name.equals("AD_Org_ID"))
			p_AD_Org_ID = para[i].getParameterAsInt();
		else if (name.equals("C_BPartner_ID"))
			p_C_BPartner_ID = para[i].getParameterAsInt();
		else if (name.equals("C_Order_ID"))
			p_C_Order_ID = para[i].getParameterAsInt();
		else if (name.equals("ConsolidateDocument"))
			p_ConsolidateDocument = "Y".equals(para[i].getParameter());
		else if (name.equals("DocAction"))
			p_docAction = (String)para[i].getParameter();
		else
			log.error("Unknown Parameter: " + name);
	}

	// Login Date
	if (p_DateInvoiced == null)
		p_DateInvoiced = Env.getContextAsDate(getCtx(), "#Date");
	if (p_DateInvoiced == null)
		p_DateInvoiced = new Timestamp(System.currentTimeMillis());

	// DocAction check
	if (!IDocument.ACTION_Complete.equals(p_docAction))
		p_docAction = IDocument.ACTION_Prepare;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:41,代码来源:InvoiceGenerate.java

示例7: doIt

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 *  Perform process.
 *  @return Message (translated text)
 *  @throws Exception if not successful
 */
@Override
protected String doIt() throws Exception
{
	log.info("From Bank="+p_From_C_BP_BankAccount_ID+" - To Bank="+p_To_C_BP_BankAccount_ID
			+ " - C_CashBook_ID="+p_C_CashBook_ID+" - Amount="+p_Amount+" - Name="+p_Name
			+ " - Description="+p_Description+ " - Statement Date="+p_StatementDate+
			" - Date Account="+p_DateAcct);

	if (p_To_C_BP_BankAccount_ID == 0 || p_From_C_BP_BankAccount_ID == 0)
		throw new IllegalArgumentException("Banks required");

	if (p_Name == null || p_Name.length() == 0)
		throw new IllegalArgumentException("Name required");

	// To_C_BP_BankAccount_ID MUST be different than From_C_BP_BankAccount_ID
	if (p_To_C_BP_BankAccount_ID == p_From_C_BP_BankAccount_ID)
		throw new AdempiereUserError ("Banks From and To must be different");

	// Banks and CashBook must have same currency
	if (!isSameCurrency())
		throw new AdempiereUserError ("Banks and CashBook must have same currency");		

	if (p_Amount.compareTo(new BigDecimal(0)) == 0)
		throw new AdempiereUserError ("Amount required");

	//	Login Date
	if (p_StatementDate == null)
		p_StatementDate = Env.getContextAsDate(getCtx(), "#Date");
	if (p_StatementDate == null)
		p_StatementDate = new Timestamp(System.currentTimeMillis());			

	if (p_DateAcct == null)
		p_DateAcct = p_StatementDate;

	generateBankTransfer();

	return "@[email protected] = " + m_created;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:44,代码来源:ImmediateBankTransfer.java

示例8: mkRoutingQuery

import org.compiere.util.Env; //导入方法依赖的package包/类
public RoutingQuery mkRoutingQuery(
		final Properties ctx,
		final I_M_InOut inOut, 
		final I_M_Package pack,
		final String serviceOverride)
{

	final I_C_Location loc = inOut.getC_BPartner_Location().getC_Location();

	final String rDepot = MSysConfig.getValue(
			AD_SYSCONFIG_DPD_VERSANDDEPOT, inOut.getAD_Client_ID(), inOut.getAD_Org_ID());

	final Timestamp date = Env.getContextAsDate(ctx, "#Date");

	final String dCountry = loc.getC_Country().getCountryCode();

	final String postCode = loc.getPostal();

	final String area = loc.getRegionName();

	final String city = loc.getCity();

	final String service;
	if (serviceOverride == null)
	{
		service = getServiceCode(pack);
	}
	else
	{
		service = serviceOverride;
	}
	return new RoutingQuery(rDepot, date, service, dCountry, postCode,				area, city);
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:34,代码来源:DPDRoutingService.java

示例9: amount

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 *	Expense - Amount.
 *		- called from ExpenseAmt, C_Currency_ID
 *		- calculates ConvertedAmt
 *  @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 amount (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
	if (isCalloutActive())
		return "";

	//	get values
	BigDecimal ExpenseAmt = (BigDecimal)mTab.getValue("ExpenseAmt");
	Integer C_Currency_From_ID = (Integer)mTab.getValue("C_Currency_ID");
	int C_Currency_To_ID = Env.getContextAsInt(ctx, "$C_Currency_ID");
	Timestamp DateExpense = Env.getContextAsDate(ctx, WindowNo, "DateExpense");
	//
	log.debug("Amt=" + ExpenseAmt + ", C_Currency_ID=" + C_Currency_From_ID);
	//	Converted Amount = Unit price
	BigDecimal ConvertedAmt = ExpenseAmt;
	//	convert if required
	if (!ConvertedAmt.equals(Env.ZERO) && C_Currency_To_ID != C_Currency_From_ID.intValue())
	{
		int AD_Client_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Client_ID");
		int AD_Org_ID = Env.getContextAsInt (ctx, WindowNo, "AD_Org_ID");
		ConvertedAmt = Services.get(ICurrencyBL.class).convert (ctx,
			ConvertedAmt, C_Currency_From_ID.intValue(), C_Currency_To_ID, 
			DateExpense, 0, AD_Client_ID, AD_Org_ID);
	}
	mTab.setValue("ConvertedAmt", ConvertedAmt);
	log.debug("= ConvertedAmt=" + ConvertedAmt);

	return "";
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:40,代码来源:CalloutTimeExpense.java

示例10: doIt

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 *  Perform process.
 *  @return Message (translated text)
 *  @throws Exception if not successful
 */
protected String doIt() throws Exception
{
	log.info("From Bank="+p_From_C_BankAccount_ID+" - To Bank="+p_To_C_BankAccount_ID
			+ " - C_BPartner_ID="+p_C_BPartner_ID+"- C_Charge_ID= "+p_C_Charge_ID+" - Amount="+p_Amount+" - DocumentNo="+p_DocumentNo
			+ " - Description="+p_Description+ " - Statement Date="+p_StatementDate+
			" - Date Account="+p_DateAcct);

	if (p_To_C_BankAccount_ID == 0 || p_From_C_BankAccount_ID == 0)
		throw new IllegalArgumentException("Banks required");

	if (p_DocumentNo == null || p_DocumentNo.length() == 0)
		throw new IllegalArgumentException("Document No required");

	if (p_To_C_BankAccount_ID == p_From_C_BankAccount_ID)
		throw new AdempiereUserError ("Banks From and To must be different");
	
	if (p_C_BPartner_ID == 0)
		throw new AdempiereUserError ("Business Partner required");
	
	if (p_C_Currency_ID == 0)
		throw new AdempiereUserError ("Currency required");
	
	if (p_C_Charge_ID == 0)
		throw new AdempiereUserError ("Business Partner required");

	if (p_Amount.compareTo(new BigDecimal(0)) == 0)
		throw new AdempiereUserError ("Amount required");

	//	Login Date
	if (p_StatementDate == null)
		p_StatementDate = Env.getContextAsDate(getCtx(), "#Date");
	if (p_StatementDate == null)
		p_StatementDate = new Timestamp(System.currentTimeMillis());			

	if (p_DateAcct == null)
		p_DateAcct = p_StatementDate;

	generateBankTransfer();

	return "@[email protected] ";
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:47,代码来源:BankTransfer.java

示例11: dynInit

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 *  Dynamic Init
 *  @throws Exception if Lookups cannot be initialized
 *  @return true if initialized
 */
@Override
public boolean dynInit() throws Exception
{
	log.info("");
	
	super.dynInit();
	
	//Refresh button
	CButton refreshButton = ConfirmPanel.createRefreshButton(false);
	refreshButton.setMargin(new Insets (1, 10, 0, 10));
	refreshButton.setDefaultCapable(true);
	refreshButton.addActionListener(this);
	dialog.getConfirmPanel().addButton(refreshButton);
	dialog.getRootPane().setDefaultButton(refreshButton);
			
	if (getGridTab().getValue("C_BankStatement_ID") == null)
	{
		ADialog.error(0, dialog, "SaveErrorRowNotFound");
		return false;
	}
	
	dialog.setTitle(getTitle());

	int AD_Column_ID = 4917;        //  C_BankStatement.C_BP_BankAccount_ID
	MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
	bankAccountField = new VLookup ("C_BP_BankAccount_ID", true, true, true, lookup);
	//  Set Default
	int C_BP_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BP_BankAccount_ID");
	bankAccountField.setValue(new Integer(C_BP_BankAccount_ID));
	//  initial Loading
	authorizationField = new VString ("authorization", false, false, true, 10, 30, null, null);
	authorizationField.addActionListener(this);

	MLookup lookupDocument = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_C_DocType_ID), DisplayType.TableDir);
	documentTypeField = new VLookup (MPayment.COLUMNNAME_C_DocType_ID,false,false,true,lookupDocument);
	documentTypeField.addActionListener(this);
	
	MLookup lookupTender = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_TenderType), DisplayType.List);
	tenderTypeField = new VLookup (MPayment.COLUMNNAME_TenderType,false,false,true,lookupTender);
	tenderTypeField.addActionListener(this);
	
	bPartnerLookup = new VLookup("C_BPartner_ID", false, false, true,
			MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search));
	BPartner_idLabel.setLabelFor(bPartnerLookup);
	
	Timestamp date = Env.getContextAsDate(Env.getCtx(), p_WindowNo, MBankStatement.COLUMNNAME_StatementDate);
	dateToField.setValue(date);

	bankAccount = InterfaceWrapperHelper.create(Env.getCtx(), C_BP_BankAccount_ID, I_C_BP_BankAccount.class, ITrx.TRXNAME_None);
	
	loadBankAccount();
	
	return true;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:60,代码来源:VCreateFromStatementUI.java

示例12: setReplicationCtx

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 * Method sets the given context values to the given context.
 * 
 * @param ctx the context to be updated
 * @param name the name of the context value to be updated
 * @param value the actual new value
 * @param overwrite if <code>true</code> then the given <code>value</code> is set, even if there is already a different value. Otherwise, a {@link ReplicationException} is thrown.
 * @throws ReplicationException if the name is already set to a different value.
 */
public static void setReplicationCtx(final Properties ctx,
		final String name,
		final Object value,
		final boolean overwrite)
{
	if (value instanceof Integer)
	{
		final Integer valueInt = (Integer)value;
		final Integer valueOldInt = Env.containsKey(ctx, name) ? Env.getContextAsInt(ctx, name) : null;
		if (Objects.equals(valueInt, valueOldInt))
		{
			// nothing to do
			return;
		}
		else if (overwrite || valueOldInt == null)
		{
			Env.setContext(ctx, name, valueInt);
		}
		else
		{
			throw new ReplicationException(MSG_XMLInvalidContext)
					.setParameter("AttributeName", name)
					.setParameter("Value", valueInt)
					.setParameter("ValueOld", valueOldInt);
		}
	}
	else if (value instanceof Timestamp)
	{
		final Timestamp valueTS = (Timestamp)value;
		final Timestamp valueOldTS = Env.containsKey(ctx, name) ? Env.getContextAsDate(ctx, name) : null;
		if (Objects.equals(valueTS, valueOldTS))
		{
			// nothing to do
			return;
		}
		else if (overwrite || valueOldTS == null)
		{
			Env.setContext(ctx, name, valueTS);
		}
		else
		{
			throw new ReplicationException(MSG_XMLInvalidContext)
					.setParameter("AttributeName", name)
					.setParameter("Value", valueTS)
					.setParameter("ValueOld", valueOldTS);
		}
	}
	else
	{
		final String valueStr = value == null ? null : value.toString();
		final String valueOldStr = Env.containsKey(ctx, name) ? Env.getContext(ctx, name) : null;
		if (Objects.equals(valueStr, valueOldStr))
		{
			// nothing to do
			return;
		}
		else if (overwrite || valueOldStr == null)
		{
			Env.setContext(ctx, name, valueStr);
		}
		else
		{
			throw new ReplicationException(MSG_XMLInvalidContext)
					.setParameter("AttributeName", name)
					.setParameter("Value", valueStr)
					.setParameter("ValueOld", valueOldStr);
		}
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:79,代码来源:ReplicationHelper.java

示例13: invoice

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 *  Cash Journal Line Invoice.
 *  when Invoice selected
 *  - set C_Currency, DiscountAnt, Amount, WriteOffAmt
 *	@param ctx context
 *	@param WindowNo window no
 *	@param mTab tab
 *	@param mField field
 *	@param value value
 *	@return null or error message
 */
public String invoice (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
	if (isCalloutActive())		//	assuming it is resetting value
		return "";

	Integer C_Invoice_ID = (Integer)value;
	if (C_Invoice_ID == null || C_Invoice_ID.intValue() == 0)
	{
		mTab.setValue("C_Currency_ID", null);
		return "";
	}
	
	int C_InvoicePaySchedule_ID = 0;
	if (Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_Invoice_ID") == C_Invoice_ID.intValue ()
		&& Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID") != 0)
		C_InvoicePaySchedule_ID = Env.getContextAsInt (ctx, WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID");

	//  Date
	Timestamp ts = Env.getContextAsDate(ctx, WindowNo, "DateAcct");     //  from C_Cash
	if (ts == null)
		ts = new Timestamp(System.currentTimeMillis());
	//
	String sql = "SELECT C_BPartner_ID, C_Currency_ID,"		//	1..2
		+ "invoiceOpen(C_Invoice_ID, ?), IsSOTrx, "			//	3..4
		+ "invoiceDiscount(C_Invoice_ID,?,?) "              //  5
		+ "FROM C_Invoice WHERE C_Invoice_ID=?";
	PreparedStatement pstmt = null;
	ResultSet rs = null;
	try
	{
		pstmt = DB.prepareStatement(sql, null);
		pstmt.setInt (1, C_InvoicePaySchedule_ID);
		pstmt.setTimestamp (2, ts);
		pstmt.setInt (3, C_InvoicePaySchedule_ID);
		pstmt.setInt(4, C_Invoice_ID.intValue());
		rs = pstmt.executeQuery();
		if (rs.next())
		{
			mTab.setValue("C_Currency_ID", new Integer(rs.getInt(2)));
			BigDecimal PayAmt = rs.getBigDecimal(3);
			BigDecimal DiscountAmt = rs.getBigDecimal(5);
			boolean isSOTrx = "Y".equals(rs.getString(4));
			if (!isSOTrx)
			{
				PayAmt = PayAmt.negate();
				DiscountAmt = DiscountAmt.negate();
			}
			//
			mTab.setValue("Amount", PayAmt.subtract(DiscountAmt));
			mTab.setValue("DiscountAmt", DiscountAmt);
			mTab.setValue("WriteOffAmt", Env.ZERO);
			Env.setContext(ctx, WindowNo, "InvTotalAmt", PayAmt.toString());
		}
	}
	catch (SQLException e)
	{
		log.error("invoice", e);
		return e.getLocalizedMessage();
	}
	finally
	{
		DB.close(rs, pstmt);
		rs = null; pstmt = null;
	}
	return "";
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:78,代码来源:CalloutCashJournal.java

示例14: tax

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 *	Invoice Line - Tax.
 *		- basis: Charge, BPartner Location
 *		- sets C_Tax_ID
 *  Calles Amount
 *	@param ctx context
 *	@param WindowNo window no
 *	@param mTab tab
 *	@param mField field
 *	@param value value
 *	@return null or error message
 */
public String tax (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
	String column = mField.getColumnName();
	if (value == null)
		return "";

	int C_Charge_ID = 0;
	if (column.equals("C_Charge_ID"))
		C_Charge_ID = ((Integer)value).intValue();
	else
		C_Charge_ID = Env.getContextAsInt(ctx, WindowNo, "C_Charge_ID");
	log.debug("C_Charge_ID=" + C_Charge_ID);
	if (C_Charge_ID == 0)
		return amt (ctx, WindowNo, mTab, mField, value);	//

	//	Check Partner Location
	int C_BPartner_Location_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_Location_ID");
	if (C_BPartner_Location_ID == 0)
		return amt (ctx, WindowNo, mTab, mField, value);	//
	log.debug("BP_Location=" + C_BPartner_Location_ID);

	//	Dates
	Timestamp billDate = Env.getContextAsDate(ctx, WindowNo, "DateInvoiced");
	log.debug("Bill Date=" + billDate);
	Timestamp shipDate = billDate;
	log.debug("Ship Date=" + shipDate);

	int AD_Org_ID = Env.getContextAsInt(ctx, WindowNo, "AD_Org_ID");
	log.debug("Org=" + AD_Org_ID);

	int M_Warehouse_ID = Env.getContextAsInt(ctx, "#M_Warehouse_ID");
	log.debug("Warehouse=" + M_Warehouse_ID);

	//
	int C_Tax_ID = Tax.get(ctx, 0, C_Charge_ID, billDate, shipDate,
		AD_Org_ID, M_Warehouse_ID, C_BPartner_Location_ID, C_BPartner_Location_ID,
		Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"));
	log.info("Tax ID=" + C_Tax_ID);
	//
	if (C_Tax_ID == 0)
		mTab.fireDataStatusEEvent(MetasfreshLastError.retrieveError());
	else
		mTab.setValue("C_Tax_ID", new Integer(C_Tax_ID));
	//
	return amt (ctx, WindowNo, mTab, mField, value);
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:59,代码来源:CalloutInvoiceBatch.java

示例15: findPLV

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 * Find Price List Version and update context
 * 
 * @param M_PriceList_ID
 *            price list
 * @return M_PriceList_Version_ID price list version
 */
private int findPLV(int M_PriceList_ID)
{
	final int p_WindowNo = getWindowNo();
	
	Timestamp priceDate = null;
	// Sales Order Date
	String dateStr = Env.getContext(Env.getCtx(), p_WindowNo, "DateOrdered");
	if (dateStr != null && dateStr.length() > 0)
		priceDate = Env.getContextAsDate(Env.getCtx(), p_WindowNo, "DateOrdered");
	else
	// Invoice Date
	{
		dateStr = Env.getContext(Env.getCtx(), p_WindowNo, "DateInvoiced");
		if (dateStr != null && dateStr.length() > 0)
			priceDate = Env.getContextAsDate(Env.getCtx(), p_WindowNo, "DateInvoiced");
	}
	// Today
	if (priceDate == null)
		priceDate = new Timestamp(System.currentTimeMillis());
	//
	log.info("M_PriceList_ID=" + M_PriceList_ID + " - " + priceDate);
	int retValue = 0;
	String sql = "SELECT plv.M_PriceList_Version_ID, plv.ValidFrom "
			+ "FROM M_PriceList pl, M_PriceList_Version plv "
			+ "WHERE pl.M_PriceList_ID=plv.M_PriceList_ID"
			+ " AND plv.IsActive='Y'" + " AND pl.M_PriceList_ID=? " // 1
			+ "ORDER BY plv.ValidFrom DESC";
	// find newest one
	PreparedStatement pstmt = null;
	ResultSet rs = null;
	try
	{
		pstmt = DB.prepareStatement(sql, null);
		pstmt.setInt(1, M_PriceList_ID);
		rs = pstmt.executeQuery();
		while (rs.next() && retValue == 0)
		{
			Timestamp plDate = rs.getTimestamp(2);
			if (!priceDate.before(plDate))
				retValue = rs.getInt(1);
		}
	}
	catch (SQLException e)
	{
		log.error(sql, e);
	}
	finally
	{
		DB.close(rs, pstmt);
		rs = null;
		pstmt = null;
	}
	Env.setContext(Env.getCtx(), p_WindowNo, "M_PriceList_Version_ID",
			retValue);
	return retValue;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:64,代码来源:InfoProduct.java


注:本文中的org.compiere.util.Env.getContextAsDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。