forked from adempiere/adempiere
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C_Invoice" like Dynamic Form adempiere#114 * Set defaut info for CreateFromPanel
- Loading branch information
1 parent
c0eda4a
commit 3e60440
Showing
14 changed files
with
527 additions
and
166 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
client/src/org/compiere/apps/form/CreateFromHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/****************************************************************************** | ||
* Product: Adempiere ERP & CRM Smart Business Solution * | ||
* 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 * | ||
* Copyright (C) 2003-2015 E.R.P. Consultores y Asociados, C.A. * | ||
* All Rights Reserved. * | ||
* Contributor(s): Yamel Senih www.erpcya.com * | ||
*****************************************************************************/ | ||
package org.compiere.apps.form; | ||
|
||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.util.ArrayList; | ||
import java.util.logging.Level; | ||
|
||
import org.compiere.util.CLogger; | ||
import org.compiere.util.DB; | ||
import org.compiere.util.DisplayType; | ||
import org.compiere.util.Env; | ||
import org.compiere.util.KeyNamePair; | ||
|
||
/** | ||
* @author Yamel Senih, ysenih@erpcya.com, ERPCyA http://www.erpcya.com | ||
* <li> FR [ 114 ] Change "Create From" UI for Form like Dialog in window without "hardcode" | ||
* @see https://github.com/adempiere/adempiere/issues/114 | ||
*/ | ||
public class CreateFromHelper { | ||
/** Logger */ | ||
protected CLogger log = CLogger.getCLogger(getClass()); | ||
|
||
/** | ||
* Load PBartner dependent Order/Invoice/Shipment Field. | ||
* @param C_BPartner_ID BPartner | ||
* @param forInvoice for invoice | ||
* @param p_M_Warehouse_ID | ||
* Yamel Senih FR [ 114 ] moved from org.compiere.grid.CreateFrom | ||
*/ | ||
protected ArrayList<KeyNamePair> loadOrderData (int C_BPartner_ID, boolean forInvoice, int p_M_Warehouse_ID) { | ||
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>(); | ||
|
||
// Display | ||
StringBuffer display = new StringBuffer("o.DocumentNo||' - ' ||") | ||
.append(DB.TO_CHAR("o.DateOrdered", DisplayType.Date, Env.getAD_Language(Env.getCtx()))) | ||
.append("||' - '||") | ||
.append(DB.TO_CHAR("o.GrandTotal", DisplayType.Amount, Env.getAD_Language(Env.getCtx()))); | ||
// | ||
String column = "ol.QtyDelivered"; | ||
if (forInvoice) | ||
column = "ol.QtyInvoiced"; | ||
StringBuffer sql = new StringBuffer("SELECT o.C_Order_ID,").append(display) | ||
.append(" FROM C_Order o " | ||
+ "WHERE o.C_BPartner_ID=? AND o.IsSOTrx='N' AND o.DocStatus IN ('CL','CO')" | ||
+ " AND o.C_Order_ID IN " | ||
+ "(SELECT ol.C_Order_ID FROM C_OrderLine ol" | ||
+ " WHERE ol.QtyOrdered - ").append(column).append(" != 0) "); | ||
if(p_M_Warehouse_ID > 0) | ||
{ | ||
sql = sql.append(" AND o.M_Warehouse_ID=? "); | ||
} | ||
sql = sql.append("ORDER BY o.DateOrdered"); | ||
// | ||
PreparedStatement pstmt = null; | ||
ResultSet rs = null; | ||
try | ||
{ | ||
pstmt = DB.prepareStatement(sql.toString(), null); | ||
pstmt.setInt(1, C_BPartner_ID); | ||
if(p_M_Warehouse_ID > 0) | ||
{ | ||
//only active for material receipts | ||
pstmt.setInt(2, p_M_Warehouse_ID); | ||
} | ||
rs = pstmt.executeQuery(); | ||
while (rs.next()) | ||
{ | ||
list.add(new KeyNamePair(rs.getInt(1), rs.getString(2))); | ||
} | ||
} | ||
catch (SQLException e) | ||
{ | ||
log.log(Level.SEVERE, sql.toString(), e); | ||
} | ||
finally | ||
{ | ||
DB.close(rs, pstmt); | ||
rs = null; pstmt = null; | ||
} | ||
|
||
return list; | ||
} // initBPartnerOIS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.