move branch adempire311 to trunk
This commit is contained in:
parent
ecf759dc1f
commit
ecad54b7cf
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="src" path="/base"/>
|
||||||
|
<classpathentry kind="src" path="/dbPort"/>
|
||||||
|
<classpathentry kind="src" path="/tools"/>
|
||||||
|
<classpathentry kind="src" path="/looks"/>
|
||||||
|
<classpathentry kind="src" path="/print"/>
|
||||||
|
<classpathentry kind="output" path="build"/>
|
||||||
|
</classpath>
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>extend</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
<project>base</project>
|
||||||
|
<project>dbPort</project>
|
||||||
|
<project>looks</project>
|
||||||
|
<project>print</project>
|
||||||
|
<project>tools</project>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1,26 @@
|
||||||
|
<HTML>
|
||||||
|
<HEAD>
|
||||||
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
|
||||||
|
<TITLE>Project Extend.jpx</TITLE>
|
||||||
|
</HEAD>
|
||||||
|
<BODY>
|
||||||
|
<H1>Project Notes</H1>
|
||||||
|
<HR>
|
||||||
|
<FONT SIZE=+1>
|
||||||
|
<STRONG>Project: </STRONG>Product Extensions<BR>
|
||||||
|
<STRONG>Author: </STRONG>Jorg Janke<BR>
|
||||||
|
<STRONG>Version: </STRONG>$Id: Extend.html,v 1.1 2006/04/21 17:55:19 jjanke Exp $<BR>
|
||||||
|
<hr>
|
||||||
|
<STRONG>Description: </STRONG><BR>
|
||||||
|
Create Jar Extend.jar to be included in Base => Client.
|
||||||
|
Example of extensions
|
||||||
|
<HR>
|
||||||
|
<STRONG>Things to do... </STRONG><BR>
|
||||||
|
</FONT>
|
||||||
|
<UL>
|
||||||
|
<!-- Edit this section to keep track of your to do items -->
|
||||||
|
<LI>Item 1
|
||||||
|
<LI>Item 2
|
||||||
|
</UL>
|
||||||
|
</BODY>
|
||||||
|
</HTML>
|
|
@ -0,0 +1,19 @@
|
||||||
|
@Title Build Extend
|
||||||
|
@Rem $Header: /cvsroot/adempiere/extend/RUN_build.bat,v 1.9 2005/09/16 00:49:02 jjanke Exp $
|
||||||
|
|
||||||
|
@CALL ..\utils_dev\myDevEnv.bat
|
||||||
|
@IF NOT %ADEMPIERE_ENV%==Y GOTO NOBUILD
|
||||||
|
|
||||||
|
@echo Cleanup ...
|
||||||
|
@"%JAVA_HOME%\bin\java" -Dant.home="." %ANT_PROPERTIES% org.apache.tools.ant.Main clean
|
||||||
|
|
||||||
|
@echo Building ...
|
||||||
|
@"%JAVA_HOME%\bin\java" -Dant.home="." %ANT_PROPERTIES% org.apache.tools.ant.Main dist
|
||||||
|
|
||||||
|
@Echo Done ...
|
||||||
|
@sleep 60
|
||||||
|
@exit
|
||||||
|
|
||||||
|
:NOBUILD
|
||||||
|
@Echo Check myDevEnv.bat (copy from myDevEnvTemplate.bat)
|
||||||
|
@Pause
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Module compiling script
|
||||||
|
# Ported from Windows script Marek Mosiewicz<marek.mosiewicz@jotel.com.pl>
|
||||||
|
|
||||||
|
|
||||||
|
SAVED_DIR=`pwd` #save current dir
|
||||||
|
cd `dirname $0`/../utils_dev #change dir to place where script resides - doesn not work with sym links
|
||||||
|
UTILS_DEV=`pwd` #this is adempiere source
|
||||||
|
cd $SAVED_DIR #back to the saved directory
|
||||||
|
|
||||||
|
. $UTILS_DEV/myDevEnv.sh #call environment
|
||||||
|
echo done
|
||||||
|
if [ ! $ADEMPIERE_ENV==Y ] ; then
|
||||||
|
echo "Can't set developemeent environemnt - check myDevEnv.sh"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo running Ant
|
||||||
|
$JAVA_HOME/bin/java -Dant.home="." $ANT_PROPERTIES org.apache.tools.ant.Main
|
|
@ -0,0 +1,80 @@
|
||||||
|
<!-- ============================================= -->
|
||||||
|
<!-- Extend -->
|
||||||
|
<!-- ============================================= -->
|
||||||
|
<!-- $Header: /cvs/adempiere/extend/build.xml,v 1.1 2006/04/21 17:55:19 jjanke Exp $ -->
|
||||||
|
|
||||||
|
<project name="extend" default="dist" basedir=".">
|
||||||
|
|
||||||
|
<description>
|
||||||
|
This buildfile is used to build the extend subproject within
|
||||||
|
the Adempiere project.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<!-- set global properties for this build -->
|
||||||
|
<property name="src" value="src"/>
|
||||||
|
<property name="build.dir" value="build"/>
|
||||||
|
<property name="dist.dir" value="."/>
|
||||||
|
<property name="jar.path" value="../lib"/>
|
||||||
|
<property name="jar.name" value="Extend"/>
|
||||||
|
|
||||||
|
<!-- set path to include the necessary jar files for javac -->
|
||||||
|
<path id="project.class.path">
|
||||||
|
<pathelement path="${classpath}"/>
|
||||||
|
<pathelement path="${jar.path}/CCTools.jar"/>
|
||||||
|
<pathelement path="../dbPort/dbPort.jar"/>
|
||||||
|
<pathelement path="../base/Base.jar"/>
|
||||||
|
<pathelement path="../looks/CLooks.jar"/>
|
||||||
|
</path>
|
||||||
|
|
||||||
|
<target name="init" description="initialization target">
|
||||||
|
<echo message="=========== Build Extend"/>
|
||||||
|
<!-- create the time stamp -->
|
||||||
|
<tstamp/>
|
||||||
|
<!-- create the build directory structure used by compile -->
|
||||||
|
<mkdir dir="${build.dir}"/>
|
||||||
|
<!-- check for the distribution directory -->
|
||||||
|
<available file="${dist.dir}" type="dir" property="dist.dir.exists"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="makedir" depends="init" unless="dist.dir.exists">
|
||||||
|
<!-- create the distribution directory if not available -->
|
||||||
|
<mkdir dir="${dist}/${dist.dir}"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="compile" depends="makedir">
|
||||||
|
<!-- compile the java code from ${src} into ${build.dir} -->
|
||||||
|
<javac srcdir="${src}" destdir="${build.dir}" deprecation="on" debug="on">
|
||||||
|
<classpath refid="project.class.path"/>
|
||||||
|
</javac>
|
||||||
|
<!-- copy all image & sound files from src to the build directory -->
|
||||||
|
<copy todir="${build.dir}">
|
||||||
|
<fileset dir="${src}">
|
||||||
|
<include name="**/images/*"/>
|
||||||
|
<include name="**/*.gif"/>
|
||||||
|
<include name="**/*.jpg"/>
|
||||||
|
<include name="**/*.wav"/>
|
||||||
|
<include name="**/*.htm"/>
|
||||||
|
<include name="**/*.html"/>
|
||||||
|
<include name="**/*.properties"/>
|
||||||
|
<exclude name="**/package.html"/>
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- =========================================== -->
|
||||||
|
<!-- Distribution -->
|
||||||
|
<!-- =========================================== -->
|
||||||
|
<target name="dist" depends="compile">
|
||||||
|
<!-- put everything from ${build.dir} into the ${jar.name}.jar file -->
|
||||||
|
<jar jarfile="${dist.dir}/${jar.name}.jar" basedir="${build.dir}"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
|
||||||
|
<target name="clean">
|
||||||
|
<!-- Delete the ${build.dir} directory trees -->
|
||||||
|
<delete dir="${build.dir}"/>
|
||||||
|
<delete file="${dist.dir}/${jar.name}.jar" failonerror="false"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,34 @@
|
||||||
|
/**
|
||||||
|
* Example View DDL SQL
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: XX_View.sql,v 1.1 2006/04/21 17:55:19 jjanke Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
-- Inspect data
|
||||||
|
SELECT C_Invoice_ID,
|
||||||
|
AD_Client_ID,AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy,
|
||||||
|
IsSOTrx, DocumentNo, DocStatus, DocAction, Processed,
|
||||||
|
SalesRep_ID, DateInvoiced, DatePrinted, DateAcct,
|
||||||
|
C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID,
|
||||||
|
C_Currency_ID,
|
||||||
|
TotalLines, GrandTotal,
|
||||||
|
Multiplier, MultiplierAP, DocBaseType
|
||||||
|
FROM C_Invoice_V
|
||||||
|
/
|
||||||
|
|
||||||
|
-- The view
|
||||||
|
CREATE OR REPLACE VIEW XX_BPartner_Total
|
||||||
|
AS
|
||||||
|
SELECT AD_Client_ID,AD_Org_ID,
|
||||||
|
'Y' AS IsActive, SysDate AS Created, 0 AS CreatedBy, SysDate AS Updated, 0 AS UpdatedBy,
|
||||||
|
C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID,
|
||||||
|
C_Currency_ID,
|
||||||
|
SUM(InvoiceOpen (C_Invoice_ID, 0) * MultiplierAP) AS OpenAmount
|
||||||
|
FROM C_Invoice_V
|
||||||
|
WHERE Processed='Y'
|
||||||
|
AND IsPaid='N'
|
||||||
|
GROUP BY AD_Client_ID,AD_Org_ID,
|
||||||
|
C_BPartner_ID, C_BPartner_Location_ID, AD_User_ID,
|
||||||
|
C_Currency_ID
|
||||||
|
/
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
* Example Table DDL SQL
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: XX_Visit.sql,v 1.1 2006/04/21 17:55:19 jjanke Exp $
|
||||||
|
*/
|
||||||
|
CREATE TABLE XX_Visit(
|
||||||
|
XX_Visit_ID NUMBER(10, 0) NOT NULL,
|
||||||
|
AD_Client_ID NUMBER(10, 0) NOT NULL,
|
||||||
|
AD_Org_ID NUMBER(10, 0) NOT NULL,
|
||||||
|
IsActive CHAR(1) DEFAULT 'Y' NOT NULL
|
||||||
|
CHECK (IsActive in ('Y','N')),
|
||||||
|
Created DATE DEFAULT SYSDATE NOT NULL,
|
||||||
|
CreatedBy NUMBER(10, 0) NOT NULL,
|
||||||
|
Updated DATE DEFAULT SYSDATE NOT NULL,
|
||||||
|
UpdatedBy NUMBER(10, 0) NOT NULL,
|
||||||
|
Name NVARCHAR2(60) NOT NULL,
|
||||||
|
Description NVARCHAR2(255),
|
||||||
|
VisitTime DATE NOT NULL,
|
||||||
|
Minutes NUMBER(10, 0) NOT NULL,
|
||||||
|
C_BPartner_ID NUMBER(10, 0) NOT NULL,
|
||||||
|
C_BPartner_Location_ID NUMBER(10, 0) NOT NULL,
|
||||||
|
AD_User_ID NUMBER(10, 0) NOT NULL,
|
||||||
|
SalesRep_ID NUMBER(10, 0) NOT NULL,
|
||||||
|
R_InterestArea_ID NUMBER(10, 0) NOT NULL,
|
||||||
|
Processed CHAR(1),
|
||||||
|
Processing CHAR(1),
|
||||||
|
CONSTRAINT XX_Visit_Key PRIMARY KEY (XX_Visit_ID),
|
||||||
|
CONSTRAINT CBPLoction_XXVisit FOREIGN KEY (C_BPartner_Location_ID)
|
||||||
|
REFERENCES C_BPartner_Location(C_BPartner_Location_ID),
|
||||||
|
CONSTRAINT ADUser_XXVisit FOREIGN KEY (AD_User_ID)
|
||||||
|
REFERENCES AD_User(AD_User_ID),
|
||||||
|
CONSTRAINT RInterestArea_XXVisit FOREIGN KEY (R_InterestArea_ID)
|
||||||
|
REFERENCES R_InterestArea(R_InterestArea_ID),
|
||||||
|
CONSTRAINT ADUserSalesRep_XXVisit FOREIGN KEY (SalesRep_ID)
|
||||||
|
REFERENCES AD_User(AD_User_ID),
|
||||||
|
CONSTRAINT CBPartner_XXVisit FOREIGN KEY (C_BPartner_ID)
|
||||||
|
REFERENCES C_BPartner(C_BPartner_ID)
|
||||||
|
)
|
||||||
|
/
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
@Rem API Documentation for Base
|
||||||
|
|
||||||
|
call ..\doc\documentation.bat src doc -private
|
||||||
|
|
||||||
|
@pause
|
|
@ -0,0 +1 @@
|
||||||
|
com.adempiere.custom
|
|
@ -0,0 +1,220 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. 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., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
package compiere.model;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.compiere.model.*;
|
||||||
|
import java.util.logging.*;
|
||||||
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User Callout Example.
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: CalloutUser.java,v 1.2 2006/07/30 00:51:57 jjanke Exp $
|
||||||
|
*/
|
||||||
|
public class CalloutUser extends CalloutEngine
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* JustAnExample.
|
||||||
|
* The string in the Callout field is:
|
||||||
|
* <code>com.adempiere.custom.CalloutEngine.justAnExample</code>
|
||||||
|
*
|
||||||
|
* @param ctx Context
|
||||||
|
* @param WindowNo current Window No
|
||||||
|
* @param mTab Model Tab
|
||||||
|
* @param mField Model Field
|
||||||
|
* @param value The new value
|
||||||
|
* @param oldValue The old value
|
||||||
|
* @return error message or "" if OK
|
||||||
|
*/
|
||||||
|
public String justAnExample (Properties ctx, int WindowNo,
|
||||||
|
GridTab mTab, GridField mField, Object value, Object oldValue)
|
||||||
|
{
|
||||||
|
log.info("JustAnExample");
|
||||||
|
return "";
|
||||||
|
} // justAnExample
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoice Header- BPartner.
|
||||||
|
* - C_BPartner_Location_ID
|
||||||
|
* - AD_User_ID
|
||||||
|
* @param ctx Context
|
||||||
|
* @param WindowNo current Window No
|
||||||
|
* @param mTab Model Tab
|
||||||
|
* @param mField Model Field
|
||||||
|
* @param value The new value
|
||||||
|
* @param oldValue The old value
|
||||||
|
* @return error message
|
||||||
|
*/
|
||||||
|
public String bPartner (Properties ctx, int WindowNo,
|
||||||
|
GridTab mTab, GridField mField, Object value, Object oldValue)
|
||||||
|
{
|
||||||
|
Integer C_BPartner_ID = (Integer)value;
|
||||||
|
if (C_BPartner_ID == null || C_BPartner_ID.intValue() == 0)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
String sql = "SELECT p.AD_Language,p.C_PaymentTerm_ID,"
|
||||||
|
+ " COALESCE(p.M_PriceList_ID,g.M_PriceList_ID) AS M_PriceList_ID, p.PaymentRule,p.POReference,"
|
||||||
|
+ " p.SO_Description,p.IsDiscountPrinted,"
|
||||||
|
+ " p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable,"
|
||||||
|
+ " l.C_BPartner_Location_ID,c.AD_User_ID,"
|
||||||
|
+ " COALESCE(p.PO_PriceList_ID,g.PO_PriceList_ID) AS PO_PriceList_ID, p.PaymentRulePO,p.PO_PaymentTerm_ID "
|
||||||
|
+ "FROM C_BPartner p"
|
||||||
|
+ " INNER JOIN C_BP_Group g ON (p.C_BP_Group_ID=g.C_BP_Group_ID)"
|
||||||
|
+ " LEFT OUTER JOIN C_BPartner_Location l ON (p.C_BPartner_ID=l.C_BPartner_ID AND l.IsBillTo='Y' AND l.IsActive='Y')"
|
||||||
|
+ " LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID) "
|
||||||
|
+ "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||||
|
pstmt.setInt(1, C_BPartner_ID.intValue());
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
//
|
||||||
|
if (rs.next())
|
||||||
|
{
|
||||||
|
// Location
|
||||||
|
int locID = rs.getInt("C_BPartner_Location_ID");
|
||||||
|
// overwritten by InfoBP selection - works only if InfoWindow
|
||||||
|
// was used otherwise creates error (uses last value, may belong to differnt BP)
|
||||||
|
if (C_BPartner_ID.toString().equals(Env.getContext(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "C_BPartner_ID")))
|
||||||
|
{
|
||||||
|
String loc = Env.getContext(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "C_BPartner_Location_ID");
|
||||||
|
if (loc.length() > 0)
|
||||||
|
locID = Integer.parseInt(loc);
|
||||||
|
}
|
||||||
|
if (locID == 0)
|
||||||
|
mTab.setValue("C_BPartner_Location_ID", null);
|
||||||
|
else
|
||||||
|
mTab.setValue("C_BPartner_Location_ID", new Integer(locID));
|
||||||
|
|
||||||
|
// Contact - overwritten by InfoBP selection
|
||||||
|
int contID = rs.getInt("AD_User_ID");
|
||||||
|
if (C_BPartner_ID.toString().equals(Env.getContext(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "C_BPartner_ID")))
|
||||||
|
{
|
||||||
|
String cont = Env.getContext(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "AD_User_ID");
|
||||||
|
if (cont.length() > 0)
|
||||||
|
contID = Integer.parseInt(cont);
|
||||||
|
}
|
||||||
|
if (contID == 0)
|
||||||
|
mTab.setValue("AD_User_ID", null);
|
||||||
|
else
|
||||||
|
mTab.setValue("AD_User_ID", new Integer(contID));
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, sql, e);
|
||||||
|
return e.getLocalizedMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
} // bPartner
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Frie Value - convert to standardized Name
|
||||||
|
*
|
||||||
|
* @param value Name
|
||||||
|
* @return Name
|
||||||
|
*/
|
||||||
|
public String Frie_Name (String value)
|
||||||
|
{
|
||||||
|
if (value == null || value.length() == 0)
|
||||||
|
return "";
|
||||||
|
//
|
||||||
|
String retValue = value;
|
||||||
|
String SQL = "SELECT FRIE_Name(?) FROM DUAL";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
|
||||||
|
pstmt.setString(1, value);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
retValue = rs.getString(1);
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, SQL, e);
|
||||||
|
}
|
||||||
|
return retValue;
|
||||||
|
} // Frie_Name
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frie Value - convert Name to Value
|
||||||
|
*
|
||||||
|
* @param value Name
|
||||||
|
* @return Value of Name
|
||||||
|
*/
|
||||||
|
public String Frie_Value (String value)
|
||||||
|
{
|
||||||
|
if (value == null || value.length() == 0)
|
||||||
|
return "";
|
||||||
|
//
|
||||||
|
String retValue = value;
|
||||||
|
String SQL = "SELECT FRIE_Value(FRIE_Name(?)) FROM DUAL";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
|
||||||
|
pstmt.setString(1, value);
|
||||||
|
ResultSet rs = pstmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
retValue = rs.getString(1);
|
||||||
|
rs.close();
|
||||||
|
pstmt.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, SQL, e);
|
||||||
|
}
|
||||||
|
return retValue;
|
||||||
|
} // Frie_Value
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frie Status - convert to Status.
|
||||||
|
*
|
||||||
|
* @param value value
|
||||||
|
* @return Status
|
||||||
|
*/
|
||||||
|
public String Frie_Status (String value)
|
||||||
|
{
|
||||||
|
String retValue = "N"; // default
|
||||||
|
if (value != null && value.equals("A")) // Auslaufartikel
|
||||||
|
retValue = "Y"; //
|
||||||
|
return retValue;
|
||||||
|
} // Frie_Status
|
||||||
|
|
||||||
|
} // CalloutUser
|
|
@ -0,0 +1,63 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* The contents of this file are subject to the Adempiere License Version 1.1
|
||||||
|
* ("License"); You may not use this file except in compliance with the License
|
||||||
|
* You may obtain a copy of the License at http://www.adempiere.org/license.html
|
||||||
|
* 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 Original Code is Adempiere ERP & CRM Smart Business Solution. The Initial
|
||||||
|
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
|
||||||
|
* are Copyright (C) 1999-2006 Jorg Janke.
|
||||||
|
* All parts are Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
|
||||||
|
* Contributor(s): ______________________________________.
|
||||||
|
*****************************************************************************/
|
||||||
|
package adempiere.model;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visit Business Model
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: MVisit.java.txt,v 1.1 2006/04/21 17:55:19 jjanke Exp $
|
||||||
|
*/
|
||||||
|
public class MVisit extends X_XX_Visit
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Standard Constructor
|
||||||
|
* @param ctx context
|
||||||
|
* @param XX_Visit_ID id
|
||||||
|
* @param trxName transaction
|
||||||
|
*/
|
||||||
|
public MVisit(Properties ctx, int XX_Visit_ID, String trxName)
|
||||||
|
{
|
||||||
|
super(ctx, XX_Visit_ID, trxName);
|
||||||
|
} // MVisit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Constructor
|
||||||
|
* @param ctx context
|
||||||
|
* @param rs result set
|
||||||
|
* @param trxName transaction
|
||||||
|
*/
|
||||||
|
public MVisit(Properties ctx, ResultSet rs, String trxName)
|
||||||
|
{
|
||||||
|
super(ctx, rs, trxName);
|
||||||
|
} // MVisit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Before Save "Trigger"
|
||||||
|
* @param newRecord new
|
||||||
|
* @return true if can be saved
|
||||||
|
*/
|
||||||
|
protected boolean beforeSave(boolean newRecord)
|
||||||
|
{
|
||||||
|
// Invoice at least 5 minutes
|
||||||
|
if (newRecord && getMinutes() < 5)
|
||||||
|
setMinutes(5);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} // beforeSave
|
||||||
|
|
||||||
|
} // MVisit
|
|
@ -0,0 +1,84 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. 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., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
package compiere.model;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.compiere.model.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a non-working example of a Persistent Business Object.
|
||||||
|
* You would extend the class generated by GenerateModel.java
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: MyModelExample.java,v 1.2 2006/07/30 00:51:57 jjanke Exp $
|
||||||
|
*/
|
||||||
|
public class MyModelExample extends PO
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Standard constructor.
|
||||||
|
* You must implement this constructor for Adempiere Persistency
|
||||||
|
* @param ctx context
|
||||||
|
* @param ID the primary key ID
|
||||||
|
* @param trxName transaction
|
||||||
|
*/
|
||||||
|
public MyModelExample (Properties ctx, int ID, String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, ID, trxName);
|
||||||
|
} // MyModelExample
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional Load Constructor.
|
||||||
|
* You would use this constructor to load several business objects.
|
||||||
|
* <code>
|
||||||
|
* SELECT * FROM MyModelExample WHERE ...
|
||||||
|
* </code>
|
||||||
|
* @param ctx context
|
||||||
|
* @param rs result set
|
||||||
|
* @param trxName transaction
|
||||||
|
*/
|
||||||
|
public MyModelExample (Properties ctx, ResultSet rs, String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, rs, trxName);
|
||||||
|
} // MyModelExample
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init Persistent Object.
|
||||||
|
* You would NOT create this method as it is created by the persistency
|
||||||
|
* class generated by GenerateModel.java
|
||||||
|
* @param ctx context
|
||||||
|
* @return PO information
|
||||||
|
*/
|
||||||
|
protected POInfo initPO (Properties ctx)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
} // initPO
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Access Level
|
||||||
|
* @return access level
|
||||||
|
*/
|
||||||
|
protected int get_AccessLevel()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
} // get_AccessLevel
|
||||||
|
|
||||||
|
} // MyModelExample
|
|
@ -0,0 +1,200 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. 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., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
package compiere.model;
|
||||||
|
|
||||||
|
import java.math.*;
|
||||||
|
import org.compiere.model.*;
|
||||||
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validator Example Implementation
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: MyValidator.java,v 1.2 2006/07/30 00:51:57 jjanke Exp $
|
||||||
|
*/
|
||||||
|
public class MyValidator implements ModelValidator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* The class is instanciated when logging in and client is selected/known
|
||||||
|
*/
|
||||||
|
public MyValidator ()
|
||||||
|
{
|
||||||
|
super ();
|
||||||
|
} // MyValidator
|
||||||
|
|
||||||
|
/** Logger */
|
||||||
|
private static CLogger log = CLogger.getCLogger(MyValidator.class);
|
||||||
|
/** Client */
|
||||||
|
private int m_AD_Client_ID = -1;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Validation
|
||||||
|
* @param engine validation engine
|
||||||
|
* @param client client
|
||||||
|
*/
|
||||||
|
public void initialize (ModelValidationEngine engine, MClient client)
|
||||||
|
{
|
||||||
|
m_AD_Client_ID = client.getAD_Client_ID();
|
||||||
|
if (m_AD_Client_ID != 11) // GardenWorld Example
|
||||||
|
return;
|
||||||
|
log.info(client.toString());
|
||||||
|
|
||||||
|
// We want to be informed when C_Order is created/changed
|
||||||
|
engine.addModelChange("C_Order", this);
|
||||||
|
// We want to validate Order before preparing
|
||||||
|
engine.addDocValidate("C_Order", this);
|
||||||
|
} // initialize
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model Change of a monitored Table.
|
||||||
|
* Called after PO.beforeSave/PO.beforeDelete
|
||||||
|
* when you called addModelChange for the table
|
||||||
|
* @param po persistent object
|
||||||
|
* @param type TYPE_
|
||||||
|
* @return error message or null
|
||||||
|
* @exception Exception if the recipient wishes the change to be not accept.
|
||||||
|
*/
|
||||||
|
public String modelChange (PO po, int type) throws Exception
|
||||||
|
{
|
||||||
|
if (po.get_TableName().equals("C_Order") && type == TYPE_CHANGE)
|
||||||
|
{
|
||||||
|
MOrder order = (MOrder)po;
|
||||||
|
log.info(po.toString());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} // modelChange
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate Document.
|
||||||
|
* Called as first step of DocAction.prepareIt
|
||||||
|
* when you called addDocValidate for the table.
|
||||||
|
* Note that totals, etc. may not be correct.
|
||||||
|
* @param po persistent object
|
||||||
|
* @param timing see TIMING_ constants
|
||||||
|
* @return error message or null
|
||||||
|
*/
|
||||||
|
public String docValidate (PO po, int timing)
|
||||||
|
{
|
||||||
|
// Ignore all after Complete events
|
||||||
|
if (timing == TIMING_AFTER_COMPLETE)
|
||||||
|
return null;
|
||||||
|
// TIMING_BEFORE_PREPARE
|
||||||
|
if (po.get_TableName().equals(MOrder.Table_Name))
|
||||||
|
{
|
||||||
|
/** Order Discount Example *
|
||||||
|
MOrder order = (MOrder)po;
|
||||||
|
String error = orderDiscount(order);
|
||||||
|
if (error != null)
|
||||||
|
return error;
|
||||||
|
/** Order Discount Example */
|
||||||
|
log.info(po.toString());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} // docValidate
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order Discount.
|
||||||
|
* Make sure that last line is discount and check correctness
|
||||||
|
* @param order order
|
||||||
|
* @return error message or null
|
||||||
|
*/
|
||||||
|
private String orderDiscount (MOrder order)
|
||||||
|
{
|
||||||
|
String DISCOUNT = "Discount";
|
||||||
|
int C_Tax_ID = 0;
|
||||||
|
BigDecimal totalLines = Env.ZERO;
|
||||||
|
MOrderLine discountLine = null;
|
||||||
|
//
|
||||||
|
MOrderLine[] lines = order.getLines();
|
||||||
|
for (int i = 0; i < lines.length; i++)
|
||||||
|
{
|
||||||
|
MOrderLine oLine = lines[i];
|
||||||
|
String description = oLine.getDescription();
|
||||||
|
if (description != null && description.equals(DISCOUNT))
|
||||||
|
discountLine = oLine;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
totalLines = totalLines.add(oLine.getLineNetAmt());
|
||||||
|
if (C_Tax_ID == 0)
|
||||||
|
C_Tax_ID = oLine.getC_Tax_ID();
|
||||||
|
else if (C_Tax_ID != oLine.getC_Tax_ID())
|
||||||
|
return "Order has more then one Tax, cannot add discount";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (discountLine == null)
|
||||||
|
{
|
||||||
|
discountLine = new MOrderLine(order);
|
||||||
|
discountLine.setDescription(DISCOUNT);
|
||||||
|
discountLine.setQty(Env.ONE);
|
||||||
|
discountLine.setC_Tax_ID(C_Tax_ID);
|
||||||
|
discountLine.setLine(9999);
|
||||||
|
}
|
||||||
|
// Calculate Discount
|
||||||
|
BigDecimal discountPercent = new BigDecimal(3); // 3% example
|
||||||
|
BigDecimal discountAmt = totalLines.multiply(discountPercent);
|
||||||
|
discountAmt = discountAmt.divide(Env.ONEHUNDRED, order.getPrecision(), BigDecimal.ROUND_HALF_UP);
|
||||||
|
discountLine.setPrice(discountAmt.negate());
|
||||||
|
if (!discountLine.save())
|
||||||
|
return "Could not save discount line";
|
||||||
|
|
||||||
|
log.info(discountLine.toString());
|
||||||
|
order.getLines(true, null);
|
||||||
|
return null;
|
||||||
|
} // orderDiscount
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User Login.
|
||||||
|
* Called when preferences are set
|
||||||
|
* @param AD_Org_ID org
|
||||||
|
* @param AD_Role_ID role
|
||||||
|
* @param AD_User_ID user
|
||||||
|
* @return error message or null
|
||||||
|
*/
|
||||||
|
public String login (int AD_Org_ID, int AD_Role_ID, int AD_User_ID)
|
||||||
|
{
|
||||||
|
log.info("AD_User_ID=" + AD_User_ID);
|
||||||
|
return null;
|
||||||
|
} // login
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Client to be monitored
|
||||||
|
* @return AD_Client_ID client
|
||||||
|
*/
|
||||||
|
public int getAD_Client_ID()
|
||||||
|
{
|
||||||
|
return m_AD_Client_ID;
|
||||||
|
} // getAD_Client_ID
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String Representation
|
||||||
|
* @return info
|
||||||
|
*/
|
||||||
|
public String toString ()
|
||||||
|
{
|
||||||
|
StringBuffer sb = new StringBuffer ("MyValidator[Order@Gardenworld");
|
||||||
|
sb.append ("]");
|
||||||
|
return sb.toString ();
|
||||||
|
} // toString
|
||||||
|
|
||||||
|
} // MyValidator
|
|
@ -0,0 +1,96 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* The contents of this file are subject to the Adempiere License Version 1.1
|
||||||
|
* ("License"); You may not use this file except in compliance with the License
|
||||||
|
* You may obtain a copy of the License at http://www.adempiere.org/license.html
|
||||||
|
* 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 Original Code is Adempiere ERP & CRM Smart Business Solution. The Initial
|
||||||
|
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
|
||||||
|
* are Copyright (C) 1999-2006 Jorg Janke.
|
||||||
|
* All parts are Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
|
||||||
|
* Contributor(s): ______________________________________.
|
||||||
|
*****************************************************************************/
|
||||||
|
package adempiere.model;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import org.compiere.model.*;
|
||||||
|
import org.compiere.process.SvrProcess;
|
||||||
|
import org.compiere.util.AdempiereSystemError;
|
||||||
|
import org.compiere.util.AdempiereUserError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate Invoice for Visit Process
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: XXVisitInvoice.java.txt,v 1.1 2006/04/21 17:55:19 jjanke Exp $
|
||||||
|
*/
|
||||||
|
public class XXVisitInvoice extends SvrProcess
|
||||||
|
{
|
||||||
|
/** Parameter */
|
||||||
|
private int p_XX_Visit_ID = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare
|
||||||
|
* @see org.compiere.process.SvrProcess#prepare()
|
||||||
|
*/
|
||||||
|
protected void prepare()
|
||||||
|
{
|
||||||
|
p_XX_Visit_ID = getRecord_ID();
|
||||||
|
} // prepare
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process
|
||||||
|
* @see org.compiere.process.SvrProcess#doIt()
|
||||||
|
* @return summary
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected String doIt() throws Exception
|
||||||
|
{
|
||||||
|
log.info("XX_Visit_ID=" + p_XX_Visit_ID);
|
||||||
|
MVisit visit = new MVisit (getCtx(), p_XX_Visit_ID, get_TrxName());
|
||||||
|
if (visit.get_ID() == 0 || visit.get_ID() != p_XX_Visit_ID)
|
||||||
|
throw new AdempiereSystemError("@NotFound@ @XX_Visit_ID@ " + p_XX_Visit_ID);
|
||||||
|
// Nothing to do
|
||||||
|
if (visit.isProcessed())
|
||||||
|
throw new AdempiereUserError("@XX_Visit_ID@ @Processed@");
|
||||||
|
// Create Invoice Header
|
||||||
|
MInvoice invoice = new MInvoice (getCtx(), 0, get_TrxName());
|
||||||
|
invoice.setIsSOTrx(true);
|
||||||
|
invoice.setC_DocTypeTarget_ID();
|
||||||
|
// Set Business Partner
|
||||||
|
MBPartner bp = new MBPartner (getCtx(), visit.getC_BPartner_ID(), null);
|
||||||
|
invoice.setBPartner(bp);
|
||||||
|
invoice.setC_BPartner_Location_ID(visit.getC_BPartner_Location_ID());
|
||||||
|
invoice.setAD_User_ID(visit.getAD_User_ID());
|
||||||
|
// Other Invoice Details
|
||||||
|
invoice.setSalesRep_ID(visit.getSalesRep_ID());
|
||||||
|
invoice.setDescription(visit.getName());
|
||||||
|
if (!invoice.save())
|
||||||
|
throw new AdempiereSystemError("Could not save Invoice");
|
||||||
|
|
||||||
|
// Create Invoice Line
|
||||||
|
MInvoiceLine line = new MInvoiceLine(invoice);
|
||||||
|
line.setQty(visit.getMinutes());
|
||||||
|
line.setPrice(new BigDecimal(5));
|
||||||
|
line.setDescription(visit.getDescription());
|
||||||
|
if (line.getDescription() == null)
|
||||||
|
line.setDescription(visit.getName());
|
||||||
|
line.setTax();
|
||||||
|
if (!line.save())
|
||||||
|
throw new AdempiereSystemError("Could not save invoice line");
|
||||||
|
|
||||||
|
// Update Visit
|
||||||
|
visit.setProcessed(true);
|
||||||
|
visit.save();
|
||||||
|
|
||||||
|
// Process Invoice
|
||||||
|
invoice.setDocAction(MInvoice.DOCACTION_Complete);
|
||||||
|
invoice.processIt(MInvoice.DOCACTION_Complete);
|
||||||
|
invoice.save();
|
||||||
|
|
||||||
|
return "@C_Invoice_ID@ " + invoice.getDocumentNo();
|
||||||
|
} // doIt
|
||||||
|
|
||||||
|
} // XXVisitInvoice
|
|
@ -0,0 +1,285 @@
|
||||||
|
/** Generated Model - DO NOT CHANGE - Copyright (C) 1999-2005 Jorg Janke */
|
||||||
|
package adempiere.model;
|
||||||
|
|
||||||
|
import org.compiere.model.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.math.*;
|
||||||
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated Model for XX_Visit
|
||||||
|
*
|
||||||
|
* @author Jorg Janke (generated)
|
||||||
|
* @version Release 2.5.3c - 2006-03-08 11:13:42.216
|
||||||
|
*/
|
||||||
|
public class X_XX_Visit extends PO {
|
||||||
|
/** Standard Constructor */
|
||||||
|
public X_XX_Visit(Properties ctx, int XX_Visit_ID, String trxName) {
|
||||||
|
super(ctx, XX_Visit_ID, trxName);
|
||||||
|
/**
|
||||||
|
* if (XX_Visit_ID == 0) { setAD_User_ID (0); setC_BPartner_ID (0);
|
||||||
|
* setC_BPartner_Location_ID (0); setMinutes (0); setName (null);
|
||||||
|
* setR_InterestArea_ID (0); setSalesRep_ID (0); setVISITTIME (new
|
||||||
|
* Timestamp(System.currentTimeMillis())); setXX_Visit_ID (0); }
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load Constructor */
|
||||||
|
public X_XX_Visit(Properties ctx, ResultSet rs, String trxName) {
|
||||||
|
super(ctx, rs, trxName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** AD_Table_ID=1000001 */
|
||||||
|
public static final int Table_ID = 1000001;
|
||||||
|
|
||||||
|
/** TableName=XX_Visit */
|
||||||
|
public static final String Table_Name = "XX_Visit";
|
||||||
|
|
||||||
|
protected static KeyNamePair Model = new KeyNamePair(1000001, "XX_Visit");
|
||||||
|
|
||||||
|
protected BigDecimal accessLevel = new BigDecimal(1);
|
||||||
|
|
||||||
|
/** AccessLevel 1 - Org */
|
||||||
|
protected int get_AccessLevel() {
|
||||||
|
return accessLevel.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load Meta Data */
|
||||||
|
protected POInfo initPO(Properties ctx) {
|
||||||
|
POInfo poi = POInfo.getPOInfo(ctx, Table_ID);
|
||||||
|
return poi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer sb = new StringBuffer("X_XX_Visit[").append(get_ID())
|
||||||
|
.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set User/Contact. User within the system - Internal or Business Partner
|
||||||
|
* Contact
|
||||||
|
*/
|
||||||
|
public void setAD_User_ID(int AD_User_ID) {
|
||||||
|
if (AD_User_ID < 1)
|
||||||
|
throw new IllegalArgumentException("AD_User_ID is mandatory.");
|
||||||
|
set_Value("AD_User_ID", new Integer(AD_User_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get User/Contact. User within the system - Internal or Business Partner
|
||||||
|
* Contact
|
||||||
|
*/
|
||||||
|
public int getAD_User_ID() {
|
||||||
|
Integer ii = (Integer) get_Value("AD_User_ID");
|
||||||
|
if (ii == null)
|
||||||
|
return 0;
|
||||||
|
return ii.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Business Partner . Identifies a Business Partner
|
||||||
|
*/
|
||||||
|
public void setC_BPartner_ID(int C_BPartner_ID) {
|
||||||
|
if (C_BPartner_ID < 1)
|
||||||
|
throw new IllegalArgumentException("C_BPartner_ID is mandatory.");
|
||||||
|
set_Value("C_BPartner_ID", new Integer(C_BPartner_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Business Partner . Identifies a Business Partner
|
||||||
|
*/
|
||||||
|
public int getC_BPartner_ID() {
|
||||||
|
Integer ii = (Integer) get_Value("C_BPartner_ID");
|
||||||
|
if (ii == null)
|
||||||
|
return 0;
|
||||||
|
return ii.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Partner Location. Identifies the (ship to) address for this Business
|
||||||
|
* Partner
|
||||||
|
*/
|
||||||
|
public void setC_BPartner_Location_ID(int C_BPartner_Location_ID) {
|
||||||
|
if (C_BPartner_Location_ID < 1)
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"C_BPartner_Location_ID is mandatory.");
|
||||||
|
set_Value("C_BPartner_Location_ID", new Integer(C_BPartner_Location_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Partner Location. Identifies the (ship to) address for this Business
|
||||||
|
* Partner
|
||||||
|
*/
|
||||||
|
public int getC_BPartner_Location_ID() {
|
||||||
|
Integer ii = (Integer) get_Value("C_BPartner_Location_ID");
|
||||||
|
if (ii == null)
|
||||||
|
return 0;
|
||||||
|
return ii.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Description. Optional short description of the record
|
||||||
|
*/
|
||||||
|
public void setDescription(String Description) {
|
||||||
|
if (Description != null && Description.length() > 255) {
|
||||||
|
log.warning("Length > 255 - truncated");
|
||||||
|
Description = Description.substring(0, 254);
|
||||||
|
}
|
||||||
|
set_Value("Description", Description);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Description. Optional short description of the record
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return (String) get_Value("Description");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Minutes. Minutes spent with the BPatyner
|
||||||
|
*/
|
||||||
|
public void setMinutes(int Minutes) {
|
||||||
|
set_Value("Minutes", new Integer(Minutes));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Minutes. Minutes spent with the BPatyner
|
||||||
|
*/
|
||||||
|
public int getMinutes() {
|
||||||
|
Integer ii = (Integer) get_Value("Minutes");
|
||||||
|
if (ii == null)
|
||||||
|
return 0;
|
||||||
|
return ii.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Name. Alphanumeric identifier of the entity
|
||||||
|
*/
|
||||||
|
public void setName(String Name) {
|
||||||
|
if (Name == null)
|
||||||
|
throw new IllegalArgumentException("Name is mandatory.");
|
||||||
|
if (Name.length() > 120) {
|
||||||
|
log.warning("Length > 120 - truncated");
|
||||||
|
Name = Name.substring(0, 119);
|
||||||
|
}
|
||||||
|
set_Value("Name", Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Name. Alphanumeric identifier of the entity
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return (String) get_Value("Name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyNamePair getKeyNamePair() {
|
||||||
|
return new KeyNamePair(get_ID(), getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Processed. The document has been processed
|
||||||
|
*/
|
||||||
|
public void setProcessed(boolean Processed) {
|
||||||
|
set_Value("Processed", new Boolean(Processed));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Processed. The document has been processed
|
||||||
|
*/
|
||||||
|
public boolean isProcessed() {
|
||||||
|
Object oo = get_Value("Processed");
|
||||||
|
if (oo != null) {
|
||||||
|
if (oo instanceof Boolean)
|
||||||
|
return ((Boolean) oo).booleanValue();
|
||||||
|
return "Y".equals(oo);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set Process Now */
|
||||||
|
public void setProcessing(boolean Processing) {
|
||||||
|
set_Value("Processing", new Boolean(Processing));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Process Now */
|
||||||
|
public boolean isProcessing() {
|
||||||
|
Object oo = get_Value("Processing");
|
||||||
|
if (oo != null) {
|
||||||
|
if (oo instanceof Boolean)
|
||||||
|
return ((Boolean) oo).booleanValue();
|
||||||
|
return "Y".equals(oo);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Interest Area. Interest Area or Topic
|
||||||
|
*/
|
||||||
|
public void setR_InterestArea_ID(int R_InterestArea_ID) {
|
||||||
|
if (R_InterestArea_ID < 1)
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"R_InterestArea_ID is mandatory.");
|
||||||
|
set_Value("R_InterestArea_ID", new Integer(R_InterestArea_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Interest Area. Interest Area or Topic
|
||||||
|
*/
|
||||||
|
public int getR_InterestArea_ID() {
|
||||||
|
Integer ii = (Integer) get_Value("R_InterestArea_ID");
|
||||||
|
if (ii == null)
|
||||||
|
return 0;
|
||||||
|
return ii.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** SalesRep_ID AD_Reference_ID=190 */
|
||||||
|
public static final int SALESREP_ID_AD_Reference_ID = 190;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Sales Representative. Sales Representative or Company Agent
|
||||||
|
*/
|
||||||
|
public void setSalesRep_ID(int SalesRep_ID) {
|
||||||
|
if (SalesRep_ID < 1)
|
||||||
|
throw new IllegalArgumentException("SalesRep_ID is mandatory.");
|
||||||
|
set_Value("SalesRep_ID", new Integer(SalesRep_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Sales Representative. Sales Representative or Company Agent
|
||||||
|
*/
|
||||||
|
public int getSalesRep_ID() {
|
||||||
|
Integer ii = (Integer) get_Value("SalesRep_ID");
|
||||||
|
if (ii == null)
|
||||||
|
return 0;
|
||||||
|
return ii.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set VISITTIME */
|
||||||
|
public void setVISITTIME(Timestamp VISITTIME) {
|
||||||
|
if (VISITTIME == null)
|
||||||
|
throw new IllegalArgumentException("VISITTIME is mandatory.");
|
||||||
|
set_Value("VISITTIME", VISITTIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get VISITTIME */
|
||||||
|
public Timestamp getVISITTIME() {
|
||||||
|
return (Timestamp) get_Value("VISITTIME");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set Visit */
|
||||||
|
public void setXX_Visit_ID(int XX_Visit_ID) {
|
||||||
|
if (XX_Visit_ID < 1)
|
||||||
|
throw new IllegalArgumentException("XX_Visit_ID is mandatory.");
|
||||||
|
set_ValueNoCheck("XX_Visit_ID", new Integer(XX_Visit_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Visit */
|
||||||
|
public int getXX_Visit_ID() {
|
||||||
|
Integer ii = (Integer) get_Value("XX_Visit_ID");
|
||||||
|
if (ii == null)
|
||||||
|
return 0;
|
||||||
|
return ii.intValue();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,180 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. 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., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.test;
|
||||||
|
|
||||||
|
import java.math.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.logging.*;
|
||||||
|
import org.compiere.*;
|
||||||
|
import org.compiere.model.*;
|
||||||
|
import org.compiere.process.*;
|
||||||
|
import org.compiere.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order Test Example
|
||||||
|
*
|
||||||
|
* @author Jorg Janke
|
||||||
|
* @version $Id: OrderTest.java,v 1.2 2006/07/30 00:51:57 jjanke Exp $
|
||||||
|
*/
|
||||||
|
public class OrderTest implements Runnable
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* OrderTest
|
||||||
|
* @param no thread number
|
||||||
|
* @param numberOrders number of orders to create
|
||||||
|
*/
|
||||||
|
public OrderTest (int no, int numberOrders, int avgLines)
|
||||||
|
{
|
||||||
|
super ();
|
||||||
|
m_no = no;
|
||||||
|
m_numberOrders = numberOrders;
|
||||||
|
m_maxLines = avgLines * 2;
|
||||||
|
} // OrderTest
|
||||||
|
|
||||||
|
int m_no = 0;
|
||||||
|
int m_numberOrders = 0;
|
||||||
|
int m_maxLines = 20;
|
||||||
|
|
||||||
|
int m_errors = 0;
|
||||||
|
/** Logger */
|
||||||
|
private static CLogger log = CLogger.getCLogger (OrderTest.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run
|
||||||
|
*/
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
int count = 0;
|
||||||
|
MBPartner bp = new MBPartner(Env.getCtx(), 117, null);
|
||||||
|
bp.setSOCreditStatus(MBPartner.SOCREDITSTATUS_NoCreditCheck);
|
||||||
|
bp.save();
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = 0; i < m_numberOrders; i++)
|
||||||
|
{
|
||||||
|
Trx trx = Trx.get(Trx.createTrxName("Test" + m_no + "_" + i),true);
|
||||||
|
trx.start();
|
||||||
|
//
|
||||||
|
MOrder order = new MOrder(Env.getCtx(),0,trx.getTrxName());
|
||||||
|
order.setDescription("#" + m_no + "_" + i);
|
||||||
|
order.setC_DocTypeTarget_ID(135); // POS
|
||||||
|
order.setC_BPartner_ID(117); // C&W
|
||||||
|
order.setSalesRep_ID(101); // GardenAdmin
|
||||||
|
order.setDeliveryRule(MOrder.DELIVERYRULE_Force);
|
||||||
|
if (!order.save())
|
||||||
|
{
|
||||||
|
log.warning("#" + m_no + "_" + i + ": Not saved(1)");
|
||||||
|
m_errors++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Random r = new Random();
|
||||||
|
int linesNumber = r.nextInt(m_maxLines) + 1;
|
||||||
|
for (int j = 0; j < linesNumber; j++)
|
||||||
|
{
|
||||||
|
MOrderLine line = new MOrderLine(order);
|
||||||
|
line.setM_Product_ID(123); // Oak Tree
|
||||||
|
line.setQty(new BigDecimal(5));
|
||||||
|
if (!line.save())
|
||||||
|
{
|
||||||
|
log.warning("#" + m_no + "_" + i + ": Line not saved");
|
||||||
|
m_errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Process
|
||||||
|
order.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
if (!order.processIt(DocAction.ACTION_Complete))
|
||||||
|
{
|
||||||
|
log.warning("#" + m_no + "_" + i + ": Not processed");
|
||||||
|
m_errors++;
|
||||||
|
trx.rollback();
|
||||||
|
trx.close();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!order.save())
|
||||||
|
{
|
||||||
|
log.warning("#" + m_no + "_" + i + ": Not saved(2)");
|
||||||
|
m_errors++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
count++;
|
||||||
|
trx.commit();
|
||||||
|
trx.close();
|
||||||
|
//
|
||||||
|
log.info(order.toString());
|
||||||
|
}
|
||||||
|
time = System.currentTimeMillis() - time;
|
||||||
|
log.warning("#" + m_no + ", Errors=" + m_errors
|
||||||
|
+ ", Count=" + count
|
||||||
|
+ " " + ((float)count*100/m_numberOrders)
|
||||||
|
+ "% - " + time + "ms - ea " + ((float)time/count) + "ms");
|
||||||
|
} // run
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test
|
||||||
|
* @param args ignored
|
||||||
|
*/
|
||||||
|
public static void main (String[] args)
|
||||||
|
{
|
||||||
|
Adempiere.startup(true);
|
||||||
|
CLogMgt.setLoggerLevel(Level.INFO, null);
|
||||||
|
CLogMgt.setLevel(Level.INFO);
|
||||||
|
//
|
||||||
|
Ini.setProperty(Ini.P_UID,"SuperUser");
|
||||||
|
Ini.setProperty(Ini.P_PWD,"System");
|
||||||
|
Ini.setProperty(Ini.P_ROLE,"GardenWorld Admin");
|
||||||
|
Ini.setProperty(Ini.P_CLIENT, "GardenWorld");
|
||||||
|
Ini.setProperty(Ini.P_ORG,"HQ");
|
||||||
|
Ini.setProperty(Ini.P_WAREHOUSE,"HQ Warehouse");
|
||||||
|
Ini.setProperty(Ini.P_LANGUAGE,"English");
|
||||||
|
Login login = new Login(Env.getCtx());
|
||||||
|
if (!login.batchLogin(null))
|
||||||
|
System.exit(1);
|
||||||
|
//
|
||||||
|
CLogMgt.setLoggerLevel(Level.WARNING, null);
|
||||||
|
CLogMgt.setLevel(Level.WARNING);
|
||||||
|
|
||||||
|
int NO_TESTS = 2;
|
||||||
|
int NO_ORDERS = 200;
|
||||||
|
int NO_LINES = 20;
|
||||||
|
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
Thread[] tests = new Thread[NO_TESTS];
|
||||||
|
for (int i = 0; i < tests.length; i++)
|
||||||
|
{
|
||||||
|
tests[i] = new Thread(new OrderTest(i, NO_ORDERS, NO_LINES));
|
||||||
|
tests[i].start();
|
||||||
|
}
|
||||||
|
// Wait
|
||||||
|
for (int i = 0; i < tests.length; i++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tests[i].join();
|
||||||
|
}
|
||||||
|
catch (InterruptedException e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
time = System.currentTimeMillis() - time;
|
||||||
|
|
||||||
|
System.out.println("Time (ms)=" + time);
|
||||||
|
|
||||||
|
} // main
|
||||||
|
|
||||||
|
} // OrderTest
|
Loading…
Reference in New Issue