IDEMPIERE-5358 Refactor CreateFrom (#1413)
* IDEMPIERE-5358 Refactor CreateFrom * IDEMPIERE-5358 Refactor CreateFrom - Fix java doc * IDEMPIERE-5358 Refactor CreateFrom - Fix SQL error for Oracle (SELECT without FROM only works for PostgreSQL). * IDEMPIERE-5358 Refactor CreateFrom - revert change of protected method name.
This commit is contained in:
parent
00daca9c94
commit
1fcbd5ea07
|
@ -589,7 +589,7 @@ public class GridTable extends AbstractTableModel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all Fields
|
* Get all Fields
|
||||||
* @return GridFields
|
* @return GridField[]
|
||||||
*/
|
*/
|
||||||
public GridField[] getFields ()
|
public GridField[] getFields ()
|
||||||
{
|
{
|
||||||
|
@ -599,8 +599,8 @@ public class GridTable extends AbstractTableModel
|
||||||
} // getField
|
} // getField
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Open Database.
|
* Open connection to db and load data from table.
|
||||||
* if already opened, data is refreshed
|
* If already opened, data is refreshed
|
||||||
* @param maxRows maximum number of rows or 0 for all
|
* @param maxRows maximum number of rows or 0 for all
|
||||||
* @return true if success
|
* @return true if success
|
||||||
*/
|
*/
|
||||||
|
@ -710,7 +710,7 @@ public class GridTable extends AbstractTableModel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is Loading
|
* Is Loading
|
||||||
* @return true if loading
|
* @return true if loading is in progress
|
||||||
*/
|
*/
|
||||||
public boolean isLoading()
|
public boolean isLoading()
|
||||||
{
|
{
|
||||||
|
@ -1084,7 +1084,7 @@ public class GridTable extends AbstractTableModel
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Get Value in Resultset
|
* Get Value at row and column
|
||||||
* @param row row
|
* @param row row
|
||||||
* @param col col
|
* @param col col
|
||||||
* @return Object of that row/column
|
* @return Object of that row/column
|
||||||
|
@ -1114,6 +1114,10 @@ public class GridTable extends AbstractTableModel
|
||||||
return rowData[col];
|
return rowData[col];
|
||||||
} // getValueAt
|
} // getValueAt
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wait for loading of row
|
||||||
|
* @param row
|
||||||
|
*/
|
||||||
public void waitLoadingForRow(int row) {
|
public void waitLoadingForRow(int row) {
|
||||||
// need to wait for data read into buffer
|
// need to wait for data read into buffer
|
||||||
int loops = 0;
|
int loops = 0;
|
||||||
|
@ -2887,7 +2891,7 @@ public class GridTable extends AbstractTableModel
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Ignore changes
|
* Ignore/Undo changes
|
||||||
*/
|
*/
|
||||||
public void dataIgnore()
|
public void dataIgnore()
|
||||||
{
|
{
|
||||||
|
@ -3127,6 +3131,13 @@ public class GridTable extends AbstractTableModel
|
||||||
return true;
|
return true;
|
||||||
} // dataRequery
|
} // dataRequery
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param whereClause
|
||||||
|
* @param onlyCurrentRows
|
||||||
|
* @param onlyCurrentDays
|
||||||
|
* @return true if success
|
||||||
|
*/
|
||||||
public boolean dataRequery (String whereClause, boolean onlyCurrentRows, int onlyCurrentDays)
|
public boolean dataRequery (String whereClause, boolean onlyCurrentRows, int onlyCurrentDays)
|
||||||
{
|
{
|
||||||
return dataRequery (whereClause, onlyCurrentRows, onlyCurrentDays, true);
|
return dataRequery (whereClause, onlyCurrentRows, onlyCurrentDays, true);
|
||||||
|
@ -3562,6 +3573,10 @@ public class GridTable extends AbstractTableModel
|
||||||
.append(",Tab=").append(m_TabNo).append("]").toString();
|
.append(",Tab=").append(m_TabNo).append("]").toString();
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return new row added
|
||||||
|
*/
|
||||||
public int getNewRow()
|
public int getNewRow()
|
||||||
{
|
{
|
||||||
return m_newRow;
|
return m_newRow;
|
||||||
|
@ -3612,7 +3627,7 @@ public class GridTable extends AbstractTableModel
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(m_SQL_Count, null);
|
pstmt = DB.prepareStatement(m_SQL_Count, get_TrxName());
|
||||||
setParameter (pstmt, true);
|
setParameter (pstmt, true);
|
||||||
int timeout = MSysConfig.getIntValue(MSysConfig.GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS, DEFAULT_GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS, Env.getAD_Client_ID(Env.getCtx()));
|
int timeout = MSysConfig.getIntValue(MSysConfig.GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS, DEFAULT_GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS, Env.getAD_Client_ID(Env.getCtx()));
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
|
@ -3646,12 +3661,15 @@ public class GridTable extends AbstractTableModel
|
||||||
} // open
|
} // open
|
||||||
|
|
||||||
private void openResultSet() {
|
private void openResultSet() {
|
||||||
|
String trxName = get_TrxName();
|
||||||
//postgresql need trx to use cursor based resultset
|
//postgresql need trx to use cursor based resultset
|
||||||
//https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor
|
//https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor
|
||||||
String trxName = m_virtual ? Trx.createTrxName("Loader") : null;
|
if (trxName == null) {
|
||||||
trx = trxName != null ? Trx.get(trxName, true) : null;
|
trxName = m_virtual ? Trx.createTrxName("Loader") : null;
|
||||||
if (trx != null)
|
trx = trxName != null ? Trx.get(trxName, true) : null;
|
||||||
trx.setDisplayName(getClass().getName()+"_openResultSet");
|
if (trx != null)
|
||||||
|
trx.setDisplayName(getClass().getName()+"_openResultSet");
|
||||||
|
}
|
||||||
// open Statement (closed by Loader.close)
|
// open Statement (closed by Loader.close)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -3685,7 +3703,10 @@ public class GridTable extends AbstractTableModel
|
||||||
m_rs = null;
|
m_rs = null;
|
||||||
m_pstmt = null;
|
m_pstmt = null;
|
||||||
if (trx != null)
|
if (trx != null)
|
||||||
|
{
|
||||||
trx.close();
|
trx.close();
|
||||||
|
trx = null;
|
||||||
|
}
|
||||||
} // close
|
} // close
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3848,7 +3869,11 @@ public class GridTable extends AbstractTableModel
|
||||||
}
|
}
|
||||||
} // setFieldVFormat
|
} // setFieldVFormat
|
||||||
|
|
||||||
// verify if the current record has changed
|
/**
|
||||||
|
* verify if the record at row has changed
|
||||||
|
* @param row
|
||||||
|
* @return true if has changes
|
||||||
|
*/
|
||||||
public boolean hasChanged(int row) {
|
public boolean hasChanged(int row) {
|
||||||
// not so aggressive (it can has still concurrency problems)
|
// not so aggressive (it can has still concurrency problems)
|
||||||
// compare Updated, IsProcessed
|
// compare Updated, IsProcessed
|
||||||
|
@ -4063,6 +4088,11 @@ public class GridTable extends AbstractTableModel
|
||||||
return bChanged;
|
return bChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load PO for row
|
||||||
|
* @param row
|
||||||
|
* @return PO
|
||||||
|
*/
|
||||||
public PO getPO(int row) {
|
public PO getPO(int row) {
|
||||||
MTable table = MTable.get (m_ctx, m_AD_Table_ID);
|
MTable table = MTable.get (m_ctx, m_AD_Table_ID);
|
||||||
PO po = null;
|
PO po = null;
|
||||||
|
@ -4074,15 +4104,28 @@ public class GridTable extends AbstractTableModel
|
||||||
return po;
|
return po;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param importing import mode
|
||||||
|
* @param trxName optional trx name
|
||||||
|
*/
|
||||||
public void setImportingMode(boolean importing, String trxName) {
|
public void setImportingMode(boolean importing, String trxName) {
|
||||||
m_importing = importing;
|
m_importing = importing;
|
||||||
m_trxName = trxName;
|
m_trxName = trxName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if it is in import mode
|
||||||
|
*/
|
||||||
public boolean isImporting() {
|
public boolean isImporting() {
|
||||||
return m_importing;
|
return m_importing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return trx name
|
||||||
|
*/
|
||||||
public String get_TrxName() {
|
public String get_TrxName() {
|
||||||
return m_trxName;
|
return m_trxName;
|
||||||
}
|
}
|
||||||
|
@ -4095,6 +4138,10 @@ public class GridTable extends AbstractTableModel
|
||||||
m_lastSortedAscending = true;
|
m_lastSortedAscending = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return index of primary key column
|
||||||
|
*/
|
||||||
public int getKeyColumnIndex() {
|
public int getKeyColumnIndex() {
|
||||||
return m_indexKeyColumn;
|
return m_indexKeyColumn;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,25 +196,32 @@ public class SystemIDs
|
||||||
|
|
||||||
public final static int WINDOW_ACCOUNTCOMBINATION = 153;
|
public final static int WINDOW_ACCOUNTCOMBINATION = 153;
|
||||||
public final static int WINDOW_ATTRIBUTESETINSTANCE = 358;
|
public final static int WINDOW_ATTRIBUTESETINSTANCE = 358;
|
||||||
|
public final static int WINDOW_BANK_STATEMENT = 194;
|
||||||
public final static int WINDOW_BUSINESS_PARTNER = 123;
|
public final static int WINDOW_BUSINESS_PARTNER = 123;
|
||||||
public static final int WINDOW_CHART = 53124;
|
public static final int WINDOW_CHART = 53124;
|
||||||
public final static int WINDOW_CUSTOMERRETURN = 53097;
|
public final static int WINDOW_CUSTOMERRETURN = 53097;
|
||||||
|
public final static int WINDOW_CUSTOMER_RMA = 320;
|
||||||
public final static int WINDOW_IMAGE = 227;
|
public final static int WINDOW_IMAGE = 227;
|
||||||
public final static int WINDOW_INVOICE_CUSTOMER = 167;
|
public final static int WINDOW_INVOICE_CUSTOMER = 167;
|
||||||
|
public final static int WINDOW_INVOICE_VENDOR = 183;
|
||||||
public final static int WINDOW_LOCATION = 121;
|
public final static int WINDOW_LOCATION = 121;
|
||||||
public final static int WINDOW_LOCATOR = 139;
|
public final static int WINDOW_LOCATOR = 139;
|
||||||
public final static int WINDOW_LOT = 257;
|
public final static int WINDOW_LOT = 257;
|
||||||
|
public final static int WINDOW_MATERIAL_RECEIPT = 184;
|
||||||
public final static int WINDOW_MATERIALTRANSACTIONS_INDIRECTUSER = 223;
|
public final static int WINDOW_MATERIALTRANSACTIONS_INDIRECTUSER = 223;
|
||||||
public final static int WINDOW_MY_REQUESTS = 237;
|
public final static int WINDOW_MY_REQUESTS = 237;
|
||||||
public final static int WINDOW_NOTICE = 193;
|
public final static int WINDOW_NOTICE = 193;
|
||||||
|
public final static int WINDOW_PAYMENTS_INTO_BATCH = 200031;
|
||||||
public final static int WINDOW_REQUEST = 201;
|
public final static int WINDOW_REQUEST = 201;
|
||||||
public final static int WINDOW_REQUESTS_ALL = 232;
|
public final static int WINDOW_REQUESTS_ALL = 232;
|
||||||
public final static int WINDOW_RESOURCE = 236;
|
public final static int WINDOW_RESOURCE = 236;
|
||||||
public final static int WINDOW_RETURNTOVENDOR = 53098;
|
public final static int WINDOW_RETURNTOVENDOR = 53098;
|
||||||
public final static int WINDOW_SALES_ORDER = 143;
|
public final static int WINDOW_SALES_ORDER = 143;
|
||||||
|
public final static int WINDOW_SHIPMENT_CUSTOMER = 169;
|
||||||
|
public final static int WINDOW_VENDOR_RMA = 53099;
|
||||||
public final static int WINDOW_WAREHOUSE_LOCATOR = 139;
|
public final static int WINDOW_WAREHOUSE_LOCATOR = 139;
|
||||||
public final static int WINDOW_WINDOW_TAB_FIELD = 102;
|
public final static int WINDOW_WINDOW_TAB_FIELD = 102;
|
||||||
public final static int WINDOW_WORKFLOW_ACTIVITIES = 298;
|
public final static int WINDOW_WORKFLOW_ACTIVITIES = 298;
|
||||||
|
|
||||||
public final static int TAB_TAB = 106;
|
public final static int TAB_TAB = 106;
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,14 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
|
||||||
{
|
{
|
||||||
private WCreateFromWindow window;
|
private WCreateFromWindow window;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param tab
|
||||||
|
*/
|
||||||
public WCreateFromDepositBatchUI(GridTab tab)
|
public WCreateFromDepositBatchUI(GridTab tab)
|
||||||
{
|
{
|
||||||
super(tab);
|
super(tab);
|
||||||
log.info(getGridTab().toString());
|
if (log.isLoggable(Level.INFO)) log.info(getGridTab().toString());
|
||||||
|
|
||||||
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
||||||
|
|
||||||
|
@ -125,14 +129,10 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
|
||||||
protected Label dateToLabel = new Label("-");
|
protected Label dateToLabel = new Label("-");
|
||||||
protected WDateEditor dateToField = new WDateEditor("DateTo", false, false, true, Msg.translate(Env.getCtx(), "DateTo"));
|
protected WDateEditor dateToField = new WDateEditor("DateTo", false, false, true, Msg.translate(Env.getCtx(), "DateTo"));
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Dynamic Init
|
protected boolean dynInit() throws Exception
|
||||||
* @throws Exception if Lookups cannot be initialized
|
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
public boolean dynInit() throws Exception
|
|
||||||
{
|
{
|
||||||
log.config("");
|
if (log.isLoggable(Level.CONFIG)) log.config("");
|
||||||
|
|
||||||
super.dynInit();
|
super.dynInit();
|
||||||
|
|
||||||
|
@ -157,17 +157,14 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
|
||||||
bankAccountField.setValue(Integer.valueOf(C_BankAccount_ID));
|
bankAccountField.setValue(Integer.valueOf(C_BankAccount_ID));
|
||||||
// initial Loading
|
// initial Loading
|
||||||
authorizationField = new WStringEditor ("authorization", false, false, true, 10, 30, null, null);
|
authorizationField = new WStringEditor ("authorization", false, false, true, 10, 30, null, null);
|
||||||
// authorizationField.getComponent().addEventListener(Events.ON_CHANGE, this);
|
|
||||||
|
|
||||||
lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_C_DocType_ID), DisplayType.TableDir);
|
lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_C_DocType_ID), DisplayType.TableDir);
|
||||||
documentTypeField = new WTableDirEditor (MPayment.COLUMNNAME_C_DocType_ID,false,false,true,lookup);
|
documentTypeField = new WTableDirEditor (MPayment.COLUMNNAME_C_DocType_ID,false,false,true,lookup);
|
||||||
int C_DocType_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_DocType_ID");
|
int C_DocType_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_DocType_ID");
|
||||||
documentTypeField.setValue(Integer.valueOf(C_DocType_ID));
|
documentTypeField.setValue(Integer.valueOf(C_DocType_ID));
|
||||||
// documentTypeField.getComponent().addEventListener(Events.ON_CHANGE, this);
|
|
||||||
|
|
||||||
lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_TenderType), DisplayType.List);
|
lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_TenderType), DisplayType.List);
|
||||||
tenderTypeField = new WTableDirEditor (MPayment.COLUMNNAME_TenderType,false,false,true,lookup);
|
tenderTypeField = new WTableDirEditor (MPayment.COLUMNNAME_TenderType,false,false,true,lookup);
|
||||||
// tenderTypeField.getComponent().addEventListener(Events.ON_CHANGE, this);
|
|
||||||
|
|
||||||
lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search);
|
lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search);
|
||||||
bPartnerLookup = new WSearchEditor ("C_BPartner_ID", false, false, true, lookup);
|
bPartnerLookup = new WSearchEditor ("C_BPartner_ID", false, false, true, lookup);
|
||||||
|
@ -269,7 +266,7 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
|
||||||
/**
|
/**
|
||||||
* Action Listener
|
* Action Listener
|
||||||
* @param e event
|
* @param e event
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void onEvent(Event e) throws Exception
|
public void onEvent(Event e) throws Exception
|
||||||
{
|
{
|
||||||
|
@ -281,14 +278,21 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load payments for selected bank account
|
||||||
|
*/
|
||||||
protected void loadBankAccount()
|
protected void loadBankAccount()
|
||||||
{
|
{
|
||||||
loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(),
|
loadTableOIS(getBankAccountData((Integer)bankAccountField.getValue(), (Integer)bPartnerLookup.getValue(),
|
||||||
documentNoField.getValue().toString(), dateFromField.getValue(), dateToField.getValue(),
|
documentNoField.getValue().toString(), dateFromField.getValue(), dateToField.getValue(),
|
||||||
amtFromField.getValue(), amtToField.getValue(),
|
amtFromField.getValue(), amtToField.getValue(),
|
||||||
documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getValue().toString()));
|
(Integer)documentTypeField.getValue(), (String)tenderTypeField.getValue(), authorizationField.getValue().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load data into list box
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
protected void loadTableOIS (Vector<?> data)
|
protected void loadTableOIS (Vector<?> data)
|
||||||
{
|
{
|
||||||
window.getWListbox().clear();
|
window.getWListbox().clear();
|
||||||
|
@ -304,11 +308,13 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
|
||||||
configureMiniTable(window.getWListbox());
|
configureMiniTable(window.getWListbox());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void showWindow()
|
public void showWindow()
|
||||||
{
|
{
|
||||||
window.setVisible(true);
|
window.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void closeWindow()
|
public void closeWindow()
|
||||||
{
|
{
|
||||||
window.dispose();
|
window.dispose();
|
||||||
|
|
|
@ -68,6 +68,10 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
|
||||||
|
|
||||||
public static final String SELECT_ALL = "SelectAll";
|
public static final String SELECT_ALL = "SelectAll";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param createFrom
|
||||||
|
*/
|
||||||
public WCreateFromForm(CreateFromForm createFrom)
|
public WCreateFromForm(CreateFromForm createFrom)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
@ -78,7 +82,8 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
|
||||||
setBorder("normal");
|
setBorder("normal");
|
||||||
setSclass("create-from-form");
|
setSclass("create-from-form");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void initForm()
|
protected void initForm()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -91,7 +96,7 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +149,7 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
|
||||||
ZKUpdateUtil.setHeight(contentPane, "100%");
|
ZKUpdateUtil.setHeight(contentPane, "100%");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event e) throws Exception
|
public void onEvent(Event e) throws Exception
|
||||||
{
|
{
|
||||||
// OK - Save
|
// OK - Save
|
||||||
|
@ -191,6 +197,7 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void tableChanged (WTableModelEvent e)
|
public void tableChanged (WTableModelEvent e)
|
||||||
{
|
{
|
||||||
int type = -1;
|
int type = -1;
|
||||||
|
@ -203,6 +210,11 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
|
||||||
info();
|
info();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param trxName
|
||||||
|
* @return true if save success
|
||||||
|
*/
|
||||||
public boolean save(String trxName)
|
public boolean save(String trxName)
|
||||||
{
|
{
|
||||||
ListModelTable model = dataTable.getModel();
|
ListModelTable model = dataTable.getModel();
|
||||||
|
@ -213,6 +225,9 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
|
||||||
return form.save(dataTable, trxName, getGridTab());
|
return form.save(dataTable, trxName, getGridTab());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update status bar
|
||||||
|
*/
|
||||||
public void info()
|
public void info()
|
||||||
{
|
{
|
||||||
ListModelTable model = dataTable.getModel();
|
ListModelTable model = dataTable.getModel();
|
||||||
|
@ -228,6 +243,11 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
|
||||||
form.info(dataTable, statusBar);
|
form.info(dataTable, statusBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set status bar text
|
||||||
|
* @param selectedRowCount
|
||||||
|
* @param text
|
||||||
|
*/
|
||||||
public void setStatusLine(int selectedRowCount, String text)
|
public void setStatusLine(int selectedRowCount, String text)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder(String.valueOf(selectedRowCount));
|
StringBuilder sb = new StringBuilder(String.valueOf(selectedRowCount));
|
||||||
|
@ -239,26 +259,45 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
|
||||||
confirmPanel.getOKButton().setEnabled(selectedRowCount > 0);
|
confirmPanel.getOKButton().setEnabled(selectedRowCount > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return {@link WListbox}
|
||||||
|
*/
|
||||||
public WListbox getWListbox()
|
public WListbox getWListbox()
|
||||||
{
|
{
|
||||||
return dataTable;
|
return dataTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return {@link Panel}
|
||||||
|
*/
|
||||||
public Panel getParameterPanel()
|
public Panel getParameterPanel()
|
||||||
{
|
{
|
||||||
return parameterPanel;
|
return parameterPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return {@link ConfirmPanel}
|
||||||
|
*/
|
||||||
public ConfirmPanel getConfirmPanel()
|
public ConfirmPanel getConfirmPanel()
|
||||||
{
|
{
|
||||||
return confirmPanel;
|
return confirmPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if cancel by user
|
||||||
|
*/
|
||||||
public boolean isCancel()
|
public boolean isCancel()
|
||||||
{
|
{
|
||||||
return isCancel;
|
return isCancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* post execute query event
|
||||||
|
*/
|
||||||
public void postQueryEvent()
|
public void postQueryEvent()
|
||||||
{
|
{
|
||||||
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Processing"));
|
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Processing"));
|
||||||
|
|
|
@ -55,10 +55,19 @@ import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zul.Space;
|
import org.zkoss.zul.Space;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventListener<Event>, ValueChangeListener
|
public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventListener<Event>, ValueChangeListener
|
||||||
{
|
{
|
||||||
private WCreateFromWindow window;
|
private WCreateFromWindow window;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param tab
|
||||||
|
*/
|
||||||
public WCreateFromInvoiceUI(GridTab tab)
|
public WCreateFromInvoiceUI(GridTab tab)
|
||||||
{
|
{
|
||||||
super(tab);
|
super(tab);
|
||||||
|
@ -107,14 +116,10 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
|
||||||
|
|
||||||
private boolean isCreditMemo = false;
|
private boolean isCreditMemo = false;
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Dynamic Init
|
|
||||||
* @throws Exception if Lookups cannot be initialized
|
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
public boolean dynInit() throws Exception
|
public boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
log.config("");
|
if (log.isLoggable(Level.CONFIG)) log.config("");
|
||||||
|
|
||||||
super.dynInit();
|
super.dynInit();
|
||||||
|
|
||||||
|
@ -220,11 +225,7 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
|
||||||
|
|
||||||
private int noOfParameterColumn;
|
private int noOfParameterColumn;
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Action Listener
|
|
||||||
* @param e event
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public void onEvent(Event e) throws Exception
|
public void onEvent(Event e) throws Exception
|
||||||
{
|
{
|
||||||
if (m_actionActive)
|
if (m_actionActive)
|
||||||
|
@ -270,10 +271,7 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
|
||||||
m_actionActive = false;
|
m_actionActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Change Listener
|
|
||||||
* @param e event
|
|
||||||
*/
|
|
||||||
public void valueChange (ValueChangeEvent e)
|
public void valueChange (ValueChangeEvent e)
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config(e.getPropertyName() + "=" + e.getNewValue());
|
if (log.isLoggable(Level.CONFIG)) log.config(e.getPropertyName() + "=" + e.getNewValue());
|
||||||
|
@ -308,7 +306,7 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
|
||||||
} // initBPartner
|
} // initBPartner
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load PBartner dependent Order/Invoice/Shipment Field.
|
* Load BPartner dependent Order/Shipment/RMA Field.
|
||||||
* @param C_BPartner_ID BPartner
|
* @param C_BPartner_ID BPartner
|
||||||
* @param forInvoice for invoice
|
* @param forInvoice for invoice
|
||||||
*/
|
*/
|
||||||
|
@ -331,14 +329,14 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
|
||||||
initBPDetails(C_BPartner_ID);
|
initBPDetails(C_BPartner_ID);
|
||||||
} // initBPartnerOIS
|
} // initBPartnerOIS
|
||||||
|
|
||||||
public void initBPDetails(int C_BPartner_ID)
|
private void initBPDetails(int C_BPartner_ID)
|
||||||
{
|
{
|
||||||
initBPShipmentDetails(C_BPartner_ID);
|
initBPShipmentDetails(C_BPartner_ID);
|
||||||
initBPRMADetails(C_BPartner_ID);
|
initBPRMADetails(C_BPartner_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load PBartner dependent Order/Invoice/Shipment Field.
|
* Load PBartner dependent Shipment Field.
|
||||||
* @param C_BPartner_ID
|
* @param C_BPartner_ID
|
||||||
*/
|
*/
|
||||||
private void initBPShipmentDetails(int C_BPartner_ID)
|
private void initBPShipmentDetails(int C_BPartner_ID)
|
||||||
|
@ -361,7 +359,7 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load RMA that are candidates for shipment
|
* Load RMA that are candidates for billing
|
||||||
* @param C_BPartner_ID BPartner
|
* @param C_BPartner_ID BPartner
|
||||||
*/
|
*/
|
||||||
private void initBPRMADetails(int C_BPartner_ID)
|
private void initBPRMADetails(int C_BPartner_ID)
|
||||||
|
@ -381,7 +379,7 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Data - Order
|
* Load Order Line records
|
||||||
* @param C_Order_ID Order
|
* @param C_Order_ID Order
|
||||||
* @param forInvoice true if for invoice vs. delivery qty
|
* @param forInvoice true if for invoice vs. delivery qty
|
||||||
*/
|
*/
|
||||||
|
@ -390,18 +388,26 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
|
||||||
loadTableOIS(getOrderData(C_Order_ID, forInvoice, isCreditMemo));
|
loadTableOIS(getOrderData(C_Order_ID, forInvoice, isCreditMemo));
|
||||||
} // LoadOrder
|
} // LoadOrder
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load RMA Line records
|
||||||
|
* @param M_RMA_ID
|
||||||
|
*/
|
||||||
protected void loadRMA (int M_RMA_ID)
|
protected void loadRMA (int M_RMA_ID)
|
||||||
{
|
{
|
||||||
loadTableOIS(getRMAData(M_RMA_ID));
|
loadTableOIS(getRMAData(M_RMA_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load shipment line records
|
||||||
|
* @param M_InOut_ID
|
||||||
|
*/
|
||||||
protected void loadShipment (int M_InOut_ID)
|
protected void loadShipment (int M_InOut_ID)
|
||||||
{
|
{
|
||||||
loadTableOIS(getShipmentData(M_InOut_ID));
|
loadTableOIS(getShipmentData(M_InOut_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Order/Invoice/Shipment data into Table
|
* Load datas into list box
|
||||||
* @param data data
|
* @param data data
|
||||||
*/
|
*/
|
||||||
protected void loadTableOIS (Vector<?> data)
|
protected void loadTableOIS (Vector<?> data)
|
||||||
|
@ -419,11 +425,13 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
|
||||||
configureMiniTable(window.getWListbox());
|
configureMiniTable(window.getWListbox());
|
||||||
} // loadOrder
|
} // loadOrder
|
||||||
|
|
||||||
|
@Override
|
||||||
public void showWindow()
|
public void showWindow()
|
||||||
{
|
{
|
||||||
window.setVisible(true);
|
window.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void closeWindow()
|
public void closeWindow()
|
||||||
{
|
{
|
||||||
window.dispose();
|
window.dispose();
|
||||||
|
@ -434,6 +442,10 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* configure layout of parameter grid
|
||||||
|
* @param parameterGrid
|
||||||
|
*/
|
||||||
protected void setupColumns(Grid parameterGrid) {
|
protected void setupColumns(Grid parameterGrid) {
|
||||||
noOfParameterColumn = ClientInfo.maxWidth((ClientInfo.EXTRA_SMALL_WIDTH+ClientInfo.SMALL_WIDTH)/2) ? 2 : 4;
|
noOfParameterColumn = ClientInfo.maxWidth((ClientInfo.EXTRA_SMALL_WIDTH+ClientInfo.SMALL_WIDTH)/2) ? 2 : 4;
|
||||||
Columns columns = new Columns();
|
Columns columns = new Columns();
|
||||||
|
@ -464,6 +476,9 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle onClientInfo event
|
||||||
|
*/
|
||||||
protected void onClientInfo()
|
protected void onClientInfo()
|
||||||
{
|
{
|
||||||
if (ClientInfo.isMobile() && parameterStdLayout != null && parameterStdLayout.getRows() != null)
|
if (ClientInfo.isMobile() && parameterStdLayout != null && parameterStdLayout.getRows() != null)
|
||||||
|
|
|
@ -34,10 +34,14 @@ public class WCreateFromPackageShipmentUI extends CreateFromPackageShipment
|
||||||
{
|
{
|
||||||
private WCreateFromWindow window;
|
private WCreateFromWindow window;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param mTab
|
||||||
|
*/
|
||||||
public WCreateFromPackageShipmentUI(GridTab mTab)
|
public WCreateFromPackageShipmentUI(GridTab mTab)
|
||||||
{
|
{
|
||||||
super(mTab);
|
super(mTab);
|
||||||
log.info(mTab.toString());
|
if (log.isLoggable(Level.INFO)) log.info(mTab.toString());
|
||||||
|
|
||||||
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
||||||
|
|
||||||
|
@ -58,9 +62,10 @@ public class WCreateFromPackageShipmentUI extends CreateFromPackageShipment
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static final CLogger log = CLogger.getCLogger(WCreateFromPackageShipmentUI.class);
|
private static final CLogger log = CLogger.getCLogger(WCreateFromPackageShipmentUI.class);
|
||||||
|
|
||||||
public boolean dynInit() throws Exception
|
@Override
|
||||||
|
protected boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
log.config("");
|
if (log.isLoggable(Level.CONFIG)) log.config("");
|
||||||
|
|
||||||
super.dynInit();
|
super.dynInit();
|
||||||
|
|
||||||
|
@ -74,6 +79,10 @@ public class WCreateFromPackageShipmentUI extends CreateFromPackageShipment
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load data into list box
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
protected void loadTableOIS (Vector<?> data)
|
protected void loadTableOIS (Vector<?> data)
|
||||||
{
|
{
|
||||||
window.getWListbox().clear();
|
window.getWListbox().clear();
|
||||||
|
@ -89,11 +98,13 @@ public class WCreateFromPackageShipmentUI extends CreateFromPackageShipment
|
||||||
configureMiniTable(window.getWListbox());
|
configureMiniTable(window.getWListbox());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void showWindow()
|
public void showWindow()
|
||||||
{
|
{
|
||||||
window.setVisible(true);
|
window.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void closeWindow()
|
public void closeWindow()
|
||||||
{
|
{
|
||||||
window.dispose();
|
window.dispose();
|
||||||
|
|
|
@ -42,14 +42,23 @@ import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListener
|
public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListener
|
||||||
{
|
{
|
||||||
private WCreateFromWindow window;
|
private WCreateFromWindow window;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param tab
|
||||||
|
*/
|
||||||
public WCreateFromRMAUI(GridTab tab)
|
public WCreateFromRMAUI(GridTab tab)
|
||||||
{
|
{
|
||||||
super(tab);
|
super(tab);
|
||||||
log.info(getGridTab().toString());
|
if (log.isLoggable(Level.INFO)) log.info(getGridTab().toString());
|
||||||
|
|
||||||
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
||||||
|
|
||||||
|
@ -79,12 +88,8 @@ public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListen
|
||||||
protected Label bPartnerLabel = new Label();
|
protected Label bPartnerLabel = new Label();
|
||||||
protected WEditor bPartnerField;
|
protected WEditor bPartnerField;
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Dynamic Init
|
protected boolean dynInit() throws Exception
|
||||||
* @throws Exception if Lookups cannot be initialized
|
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
public boolean dynInit() throws Exception
|
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
|
|
||||||
|
@ -124,10 +129,7 @@ public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Change Listener
|
|
||||||
* @param e event
|
|
||||||
*/
|
|
||||||
public void valueChange (ValueChangeEvent e)
|
public void valueChange (ValueChangeEvent e)
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config(e.getPropertyName() + "=" + e.getNewValue());
|
if (log.isLoggable(Level.CONFIG)) log.config(e.getPropertyName() + "=" + e.getNewValue());
|
||||||
|
@ -156,13 +158,16 @@ public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListen
|
||||||
bPartnerField.setValue(Integer.valueOf(C_BPartner_ID));
|
bPartnerField.setValue(Integer.valueOf(C_BPartner_ID));
|
||||||
} // initBPartner
|
} // initBPartner
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load RMA lines
|
||||||
|
*/
|
||||||
protected void loadRMA()
|
protected void loadRMA()
|
||||||
{
|
{
|
||||||
loadTableOIS(getRMAData());
|
loadTableOIS(getRMAData());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Order/Invoice/Shipment data into Table
|
* Load data into list box
|
||||||
* @param data data
|
* @param data data
|
||||||
*/
|
*/
|
||||||
protected void loadTableOIS (Vector<?> data)
|
protected void loadTableOIS (Vector<?> data)
|
||||||
|
@ -180,11 +185,13 @@ public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListen
|
||||||
configureMiniTable(window.getWListbox());
|
configureMiniTable(window.getWListbox());
|
||||||
} // loadOrder
|
} // loadOrder
|
||||||
|
|
||||||
|
@Override
|
||||||
public void showWindow()
|
public void showWindow()
|
||||||
{
|
{
|
||||||
window.setVisible(true);
|
window.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void closeWindow()
|
public void closeWindow()
|
||||||
{
|
{
|
||||||
window.dispose();
|
window.dispose();
|
||||||
|
@ -195,6 +202,9 @@ public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListen
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle onClientInfo event
|
||||||
|
*/
|
||||||
protected void onClientInfo() {
|
protected void onClientInfo() {
|
||||||
ZKUpdateUtil.setCSSHeight(window);
|
ZKUpdateUtil.setCSSHeight(window);
|
||||||
ZKUpdateUtil.setCSSWidth(window);
|
ZKUpdateUtil.setCSSWidth(window);
|
||||||
|
|
|
@ -63,15 +63,24 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
import org.zkoss.zul.Space;
|
import org.zkoss.zul.Space;
|
||||||
import org.zkoss.zul.Vlayout;
|
import org.zkoss.zul.Vlayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WCreateFromShipmentUI extends CreateFromShipment implements EventListener<Event>, ValueChangeListener
|
public class WCreateFromShipmentUI extends CreateFromShipment implements EventListener<Event>, ValueChangeListener
|
||||||
{
|
{
|
||||||
|
|
||||||
private WCreateFromWindow window;
|
private WCreateFromWindow window;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param tab
|
||||||
|
*/
|
||||||
public WCreateFromShipmentUI(GridTab tab)
|
public WCreateFromShipmentUI(GridTab tab)
|
||||||
{
|
{
|
||||||
super(tab);
|
super(tab);
|
||||||
log.info(getGridTab().toString());
|
if (log.isLoggable(Level.INFO)) log.info(getGridTab().toString());
|
||||||
|
|
||||||
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
||||||
|
|
||||||
|
@ -122,14 +131,10 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
||||||
|
|
||||||
private int noOfParameterColumn;
|
private int noOfParameterColumn;
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Dynamic Init
|
protected boolean dynInit() throws Exception
|
||||||
* @throws Exception if Lookups cannot be initialized
|
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
public boolean dynInit() throws Exception
|
|
||||||
{
|
{
|
||||||
log.config("");
|
if (log.isLoggable(Level.CONFIG)) log.config("");
|
||||||
|
|
||||||
super.dynInit();
|
super.dynInit();
|
||||||
|
|
||||||
|
@ -222,11 +227,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
||||||
|
|
||||||
private boolean m_actionActive = false;
|
private boolean m_actionActive = false;
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Action Listener
|
|
||||||
* @param e event
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public void onEvent(Event e) throws Exception
|
public void onEvent(Event e) throws Exception
|
||||||
{
|
{
|
||||||
if (m_actionActive)
|
if (m_actionActive)
|
||||||
|
@ -333,10 +334,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Change Listener
|
|
||||||
* @param e event
|
|
||||||
*/
|
|
||||||
public void valueChange (ValueChangeEvent e)
|
public void valueChange (ValueChangeEvent e)
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config(e.getPropertyName() + "=" + e.getNewValue());
|
if (log.isLoggable(Level.CONFIG)) log.config(e.getPropertyName() + "=" + e.getNewValue());
|
||||||
|
@ -398,7 +396,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load PBartner dependent Order/Invoice/Shipment Field.
|
* Load BPartner dependent Order Field.
|
||||||
* @param C_BPartner_ID BPartner
|
* @param C_BPartner_ID BPartner
|
||||||
* @param forInvoice for invoice
|
* @param forInvoice for invoice
|
||||||
*/
|
*/
|
||||||
|
@ -431,7 +429,11 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
||||||
initBPDetails(C_BPartner_ID);
|
initBPDetails(C_BPartner_ID);
|
||||||
} // initBPOrderDetails
|
} // initBPOrderDetails
|
||||||
|
|
||||||
public void initBPDetails(int C_BPartner_ID)
|
/**
|
||||||
|
* load bpartner related details
|
||||||
|
* @param C_BPartner_ID
|
||||||
|
*/
|
||||||
|
protected void initBPDetails(int C_BPartner_ID)
|
||||||
{
|
{
|
||||||
initBPInvoiceDetails(C_BPartner_ID);
|
initBPInvoiceDetails(C_BPartner_ID);
|
||||||
initBPRMADetails(C_BPartner_ID);
|
initBPRMADetails(C_BPartner_ID);
|
||||||
|
@ -459,27 +461,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Data - Order
|
* Load Order lines
|
||||||
* @param C_Order_ID Order
|
|
||||||
* @param forInvoice true if for invoice vs. delivery qty
|
|
||||||
*/
|
|
||||||
/* protected void loadOrder (int C_Order_ID, boolean forInvoice)
|
|
||||||
{
|
|
||||||
loadTableOIS(getOrderData(C_Order_ID, forInvoice));
|
|
||||||
} // LoadOrder
|
|
||||||
|
|
||||||
protected void loadRMA (int M_RMA_ID)
|
|
||||||
{
|
|
||||||
loadTableOIS(getRMAData(M_RMA_ID));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void loadShipment (int M_InOut_ID)
|
|
||||||
{
|
|
||||||
loadTableOIS(getShipmentData(M_InOut_ID));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load Data - Order
|
|
||||||
* @param C_Order_ID Order
|
* @param C_Order_ID Order
|
||||||
* @param forInvoice true if for invoice vs. delivery qty
|
* @param forInvoice true if for invoice vs. delivery qty
|
||||||
* @param M_Locator_ID
|
* @param M_Locator_ID
|
||||||
|
@ -490,7 +472,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
||||||
} // LoadOrder
|
} // LoadOrder
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Data - RMA
|
* Load RMA lines
|
||||||
* @param M_RMA_ID RMA
|
* @param M_RMA_ID RMA
|
||||||
* @param M_Locator_ID
|
* @param M_Locator_ID
|
||||||
*/
|
*/
|
||||||
|
@ -500,7 +482,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Data - Invoice
|
* Load Invoice Lines
|
||||||
* @param C_Invoice_ID Invoice
|
* @param C_Invoice_ID Invoice
|
||||||
* @param M_Locator_ID
|
* @param M_Locator_ID
|
||||||
*/
|
*/
|
||||||
|
@ -510,7 +492,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Order/Invoice/Shipment data into Table
|
* Load data into list box
|
||||||
* @param data data
|
* @param data data
|
||||||
*/
|
*/
|
||||||
protected void loadTableOIS (Vector<?> data)
|
protected void loadTableOIS (Vector<?> data)
|
||||||
|
@ -528,11 +510,13 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
||||||
configureMiniTable(window.getWListbox());
|
configureMiniTable(window.getWListbox());
|
||||||
} // loadOrder
|
} // loadOrder
|
||||||
|
|
||||||
|
@Override
|
||||||
public void showWindow()
|
public void showWindow()
|
||||||
{
|
{
|
||||||
window.setVisible(true);
|
window.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void closeWindow()
|
public void closeWindow()
|
||||||
{
|
{
|
||||||
window.dispose();
|
window.dispose();
|
||||||
|
@ -543,6 +527,10 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure layout of parameter grid
|
||||||
|
* @param parameterGrid
|
||||||
|
*/
|
||||||
protected void setupColumns(Grid parameterGrid) {
|
protected void setupColumns(Grid parameterGrid) {
|
||||||
noOfParameterColumn = ClientInfo.maxWidth((ClientInfo.EXTRA_SMALL_WIDTH+ClientInfo.SMALL_WIDTH)/2) ? 2 : 4;
|
noOfParameterColumn = ClientInfo.maxWidth((ClientInfo.EXTRA_SMALL_WIDTH+ClientInfo.SMALL_WIDTH)/2) ? 2 : 4;
|
||||||
Columns columns = new Columns();
|
Columns columns = new Columns();
|
||||||
|
@ -573,6 +561,9 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle onClientInfo event
|
||||||
|
*/
|
||||||
protected void onClientInfo()
|
protected void onClientInfo()
|
||||||
{
|
{
|
||||||
if (ClientInfo.isMobile() && parameterStdLayout != null && parameterStdLayout.getRows() != null)
|
if (ClientInfo.isMobile() && parameterStdLayout != null && parameterStdLayout.getRows() != null)
|
||||||
|
|
|
@ -66,10 +66,14 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
|
||||||
{
|
{
|
||||||
private WCreateFromWindow window;
|
private WCreateFromWindow window;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param tab
|
||||||
|
*/
|
||||||
public WCreateFromStatementUI(GridTab tab)
|
public WCreateFromStatementUI(GridTab tab)
|
||||||
{
|
{
|
||||||
super(tab);
|
super(tab);
|
||||||
log.info(getGridTab().toString());
|
if (log.isLoggable(Level.INFO)) log.info(getGridTab().toString());
|
||||||
|
|
||||||
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
||||||
|
|
||||||
|
@ -126,12 +130,8 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
|
||||||
|
|
||||||
protected Grid parameterBankLayout;
|
protected Grid parameterBankLayout;
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Dynamic Init
|
protected boolean dynInit() throws Exception
|
||||||
* @throws Exception if Lookups cannot be initialized
|
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
public boolean dynInit() throws Exception
|
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
|
|
||||||
|
@ -245,6 +245,10 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure layout of parameter grid
|
||||||
|
* @param parameterBankLayout
|
||||||
|
*/
|
||||||
protected void setupColumns(Grid parameterBankLayout) {
|
protected void setupColumns(Grid parameterBankLayout) {
|
||||||
Columns columns = new Columns();
|
Columns columns = new Columns();
|
||||||
parameterBankLayout.appendChild(columns);
|
parameterBankLayout.appendChild(columns);
|
||||||
|
@ -277,8 +281,9 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
|
||||||
/**
|
/**
|
||||||
* Action Listener
|
* Action Listener
|
||||||
* @param e event
|
* @param e event
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onEvent(Event e) throws Exception
|
public void onEvent(Event e) throws Exception
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getTarget().getId());
|
if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getTarget().getId());
|
||||||
|
@ -289,14 +294,21 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load bank account transactions
|
||||||
|
*/
|
||||||
protected void loadBankAccount()
|
protected void loadBankAccount()
|
||||||
{
|
{
|
||||||
loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(),
|
loadTableOIS(getBankAccountData((Integer)bankAccountField.getValue(), (Integer)bPartnerLookup.getValue(),
|
||||||
documentNoField.getValue().toString(), dateFromField.getValue(), dateToField.getValue(),
|
documentNoField.getValue().toString(), dateFromField.getValue(), dateToField.getValue(),
|
||||||
amtFromField.getValue(), amtToField.getValue(),
|
amtFromField.getValue(), amtToField.getValue(),
|
||||||
documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getValue().toString()));
|
(Integer)documentTypeField.getValue(), (String)tenderTypeField.getValue(), authorizationField.getValue().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load data into listbox
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
protected void loadTableOIS (Vector<?> data)
|
protected void loadTableOIS (Vector<?> data)
|
||||||
{
|
{
|
||||||
window.getWListbox().clear();
|
window.getWListbox().clear();
|
||||||
|
@ -312,11 +324,13 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
|
||||||
configureMiniTable(window.getWListbox());
|
configureMiniTable(window.getWListbox());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void showWindow()
|
public void showWindow()
|
||||||
{
|
{
|
||||||
window.setVisible(true);
|
window.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void closeWindow()
|
public void closeWindow()
|
||||||
{
|
{
|
||||||
window.dispose();
|
window.dispose();
|
||||||
|
|
|
@ -40,6 +40,11 @@ import org.zkoss.zul.North;
|
||||||
import org.zkoss.zul.Separator;
|
import org.zkoss.zul.Separator;
|
||||||
import org.zkoss.zul.South;
|
import org.zkoss.zul.South;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WCreateFromWindow extends Window implements EventListener<Event>, WTableModelListener, DialogEvents
|
public class WCreateFromWindow extends Window implements EventListener<Event>, WTableModelListener, DialogEvents
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -60,6 +65,11 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
|
||||||
public static final String SELECT_DESELECT_ALL = "SelectAll";
|
public static final String SELECT_DESELECT_ALL = "SelectAll";
|
||||||
private boolean checkAllSelected = true;
|
private boolean checkAllSelected = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param createFrom
|
||||||
|
* @param windowNo
|
||||||
|
*/
|
||||||
public WCreateFromWindow(CreateFrom createFrom, int windowNo)
|
public WCreateFromWindow(CreateFrom createFrom, int windowNo)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
@ -135,6 +145,7 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
|
||||||
ZKUpdateUtil.setHeight(contentPane, "100%");
|
ZKUpdateUtil.setHeight(contentPane, "100%");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEvent(Event e) throws Exception
|
public void onEvent(Event e) throws Exception
|
||||||
{
|
{
|
||||||
// OK - Save
|
// OK - Save
|
||||||
|
@ -185,6 +196,7 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void tableChanged (WTableModelEvent e)
|
public void tableChanged (WTableModelEvent e)
|
||||||
{
|
{
|
||||||
int type = -1;
|
int type = -1;
|
||||||
|
@ -210,6 +222,11 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
|
||||||
info();
|
info();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param trxName
|
||||||
|
* @return true if save successfully
|
||||||
|
*/
|
||||||
public boolean save(String trxName)
|
public boolean save(String trxName)
|
||||||
{
|
{
|
||||||
ListModelTable model = dataTable.getModel();
|
ListModelTable model = dataTable.getModel();
|
||||||
|
@ -220,6 +237,9 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
|
||||||
return createFrom.save(dataTable, trxName);
|
return createFrom.save(dataTable, trxName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update status
|
||||||
|
*/
|
||||||
public void info()
|
public void info()
|
||||||
{
|
{
|
||||||
ListModelTable model = dataTable.getModel();
|
ListModelTable model = dataTable.getModel();
|
||||||
|
@ -235,6 +255,11 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
|
||||||
createFrom.info(dataTable, statusBar);
|
createFrom.info(dataTable, statusBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param selectedRowCount
|
||||||
|
* @param text
|
||||||
|
*/
|
||||||
public void setStatusLine(int selectedRowCount, String text)
|
public void setStatusLine(int selectedRowCount, String text)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder(String.valueOf(selectedRowCount));
|
StringBuilder sb = new StringBuilder(String.valueOf(selectedRowCount));
|
||||||
|
@ -246,31 +271,55 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
|
||||||
confirmPanel.getOKButton().setEnabled(selectedRowCount > 0);
|
confirmPanel.getOKButton().setEnabled(selectedRowCount > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return {@link StatusBarPanel}
|
||||||
|
*/
|
||||||
public StatusBarPanel getStatusBar()
|
public StatusBarPanel getStatusBar()
|
||||||
{
|
{
|
||||||
return statusBar;
|
return statusBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param statusBar
|
||||||
|
*/
|
||||||
public void setStatusBar(StatusBarPanel statusBar)
|
public void setStatusBar(StatusBarPanel statusBar)
|
||||||
{
|
{
|
||||||
this.statusBar = statusBar;
|
this.statusBar = statusBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return {@link WListbox}
|
||||||
|
*/
|
||||||
public WListbox getWListbox()
|
public WListbox getWListbox()
|
||||||
{
|
{
|
||||||
return dataTable;
|
return dataTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return {@link Panel}
|
||||||
|
*/
|
||||||
public Panel getParameterPanel()
|
public Panel getParameterPanel()
|
||||||
{
|
{
|
||||||
return parameterPanel;
|
return parameterPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return {@link ConfirmPanel}
|
||||||
|
*/
|
||||||
public ConfirmPanel getConfirmPanel()
|
public ConfirmPanel getConfirmPanel()
|
||||||
{
|
{
|
||||||
return confirmPanel;
|
return confirmPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if dialog cancel by user
|
||||||
|
*/
|
||||||
public boolean isCancel()
|
public boolean isCancel()
|
||||||
{
|
{
|
||||||
return isCancel;
|
return isCancel;
|
||||||
|
|
|
@ -67,11 +67,15 @@ public class WStatementCreateFromBatch extends StatementCreateFromBatch implemen
|
||||||
{
|
{
|
||||||
private WCreateFromForm form;
|
private WCreateFromForm form;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default constructor
|
||||||
|
*/
|
||||||
public WStatementCreateFromBatch()
|
public WStatementCreateFromBatch()
|
||||||
{
|
{
|
||||||
form = new WCreateFromForm(this);
|
form = new WCreateFromForm(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void initForm()
|
public void initForm()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -127,16 +131,12 @@ public class WStatementCreateFromBatch extends StatementCreateFromBatch implemen
|
||||||
|
|
||||||
protected Grid parameterBankLayout;
|
protected Grid parameterBankLayout;
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Dynamic Init
|
protected boolean dynInit() throws Exception
|
||||||
* @throws Exception if Lookups cannot be initialized
|
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
public boolean dynInit() throws Exception
|
|
||||||
{
|
{
|
||||||
super.dynInit();
|
super.dynInit();
|
||||||
|
|
||||||
log.config("");
|
if (log.isLoggable(Level.CONFIG)) log.config("");
|
||||||
|
|
||||||
//Refresh button
|
//Refresh button
|
||||||
Button refreshButton = form.getConfirmPanel().createButton(ConfirmPanel.A_REFRESH);
|
Button refreshButton = form.getConfirmPanel().createButton(ConfirmPanel.A_REFRESH);
|
||||||
|
@ -180,6 +180,9 @@ public class WStatementCreateFromBatch extends StatementCreateFromBatch implemen
|
||||||
return true;
|
return true;
|
||||||
} // dynInit
|
} // dynInit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle onClientInfo event
|
||||||
|
*/
|
||||||
protected void onClientInfo()
|
protected void onClientInfo()
|
||||||
{
|
{
|
||||||
if (ClientInfo.isMobile() && parameterBankLayout != null && parameterBankLayout.getColumns() != null)
|
if (ClientInfo.isMobile() && parameterBankLayout != null && parameterBankLayout.getColumns() != null)
|
||||||
|
@ -269,6 +272,10 @@ public class WStatementCreateFromBatch extends StatementCreateFromBatch implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure layout of parameter grid
|
||||||
|
* @param parameterBankLayout
|
||||||
|
*/
|
||||||
protected void setupColumns(Grid parameterBankLayout) {
|
protected void setupColumns(Grid parameterBankLayout) {
|
||||||
Columns columns = new Columns();
|
Columns columns = new Columns();
|
||||||
parameterBankLayout.appendChild(columns);
|
parameterBankLayout.appendChild(columns);
|
||||||
|
@ -298,11 +305,7 @@ public class WStatementCreateFromBatch extends StatementCreateFromBatch implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Action Listener
|
|
||||||
* @param e event
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public void onEvent(Event e) throws Exception
|
public void onEvent(Event e) throws Exception
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getTarget().getId());
|
if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getTarget().getId());
|
||||||
|
@ -313,15 +316,20 @@ public class WStatementCreateFromBatch extends StatementCreateFromBatch implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void executeQuery()
|
public void executeQuery()
|
||||||
{
|
{
|
||||||
loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(),
|
loadTableOIS(getBankAccountData((Integer)bankAccountField.getValue(), (Integer)bPartnerLookup.getValue(),
|
||||||
documentNoField.getValue().toString(), dateFromField.getValue(), dateToField.getValue(),
|
documentNoField.getValue().toString(), dateFromField.getValue(), dateToField.getValue(),
|
||||||
amtFromField.getValue(), amtToField.getValue(),
|
amtFromField.getValue(), amtToField.getValue(),
|
||||||
documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getValue().toString(),
|
(Integer)documentTypeField.getValue(), (String)tenderTypeField.getValue(), authorizationField.getValue().toString(),
|
||||||
form.getGridTab()));
|
form.getGridTab()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load data into list box
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
protected void loadTableOIS (Vector<?> data)
|
protected void loadTableOIS (Vector<?> data)
|
||||||
{
|
{
|
||||||
form.getWListbox().clear();
|
form.getWListbox().clear();
|
||||||
|
@ -337,6 +345,7 @@ public class WStatementCreateFromBatch extends StatementCreateFromBatch implemen
|
||||||
configureMiniTable(form.getWListbox());
|
configureMiniTable(form.getWListbox());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ADForm getForm()
|
public ADForm getForm()
|
||||||
{
|
{
|
||||||
return form;
|
return form;
|
||||||
|
|
|
@ -268,7 +268,7 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue()
|
public BigDecimal getValue()
|
||||||
{
|
{
|
||||||
return getComponent().getValue();
|
return getComponent().getValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,21 +30,52 @@ public abstract class CreateFromForm
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialize form
|
||||||
|
*/
|
||||||
public abstract void initForm();
|
public abstract void initForm();
|
||||||
|
|
||||||
public abstract boolean dynInit() throws Exception;
|
/**
|
||||||
|
* dynamic initialization, usually for loading of data
|
||||||
|
* @return true if initialization is ok
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected abstract boolean dynInit() throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update status bar with info from miniTable
|
||||||
|
* @param miniTable
|
||||||
|
* @param statusBar
|
||||||
|
*/
|
||||||
public abstract void info(IMiniTable miniTable, IStatusBar statusBar);
|
public abstract void info(IMiniTable miniTable, IStatusBar statusBar);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save changes
|
||||||
|
* @param miniTable
|
||||||
|
* @param trxName
|
||||||
|
* @param gridTab
|
||||||
|
* @return true if save succeed
|
||||||
|
*/
|
||||||
public abstract boolean save(IMiniTable miniTable, String trxName, GridTab gridTab);
|
public abstract boolean save(IMiniTable miniTable, String trxName, GridTab gridTab);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return title
|
||||||
|
*/
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param title
|
||||||
|
*/
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* execute query
|
||||||
|
*/
|
||||||
public abstract void executeQuery();
|
public abstract void executeQuery();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,8 @@ public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
/** Logger */
|
/** Logger */
|
||||||
protected transient CLogger log = CLogger.getCLogger(getClass());
|
protected transient CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
|
||||||
public boolean dynInit() throws Exception
|
@Override
|
||||||
|
protected boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
setTitle(Msg.getElement(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.getElement(Env.getCtx(), "X_CreateFromBatch"));
|
setTitle(Msg.getElement(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.getElement(Env.getCtx(), "X_CreateFromBatch"));
|
||||||
|
@ -53,8 +54,29 @@ public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String getSQLWhere(Object BPartner, String DocumentNo, Object DateFrom, Object DateTo,
|
public String getSQLWhere(Object BPartner, String DocumentNo, Object DateFrom, Object DateTo,
|
||||||
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
||||||
|
{
|
||||||
|
return getSQLWhere((Integer)BPartner, DocumentNo, (Timestamp)DateFrom, (Timestamp)DateTo,
|
||||||
|
(BigDecimal)AmtFrom, (BigDecimal)AmtTo, (Integer)DocType, (String)TenderType, AuthCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param BPartner
|
||||||
|
* @param DocumentNo
|
||||||
|
* @param DateFrom
|
||||||
|
* @param DateTo
|
||||||
|
* @param AmtFrom
|
||||||
|
* @param AmtTo
|
||||||
|
* @param DocType
|
||||||
|
* @param TenderType
|
||||||
|
* @param AuthCode
|
||||||
|
* @return where clause
|
||||||
|
*/
|
||||||
|
public String getSQLWhere(Integer BPartner, String DocumentNo, Timestamp DateFrom, Timestamp DateTo,
|
||||||
|
BigDecimal AmtFrom, BigDecimal AmtTo, Integer DocType, String TenderType, String AuthCode)
|
||||||
{
|
{
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("WHERE p.Processed='Y' AND p.IsReconciled='N'");
|
sql.append("WHERE p.Processed='Y' AND p.IsReconciled='N'");
|
||||||
|
@ -76,25 +98,21 @@ public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
|
|
||||||
if(AmtFrom != null || AmtTo != null)
|
if(AmtFrom != null || AmtTo != null)
|
||||||
{
|
{
|
||||||
BigDecimal from = (BigDecimal) AmtFrom;
|
if(AmtFrom == null && AmtTo != null)
|
||||||
BigDecimal to = (BigDecimal) AmtTo;
|
|
||||||
if(from == null && to != null)
|
|
||||||
sql.append(" AND p.PayAmt <= ?");
|
sql.append(" AND p.PayAmt <= ?");
|
||||||
else if(from != null && to == null)
|
else if(AmtFrom != null && AmtTo == null)
|
||||||
sql.append(" AND p.PayAmt >= ?");
|
sql.append(" AND p.PayAmt >= ?");
|
||||||
else if(from != null && to != null)
|
else if(AmtFrom != null && AmtTo != null)
|
||||||
sql.append(" AND p.PayAmt BETWEEN ? AND ?");
|
sql.append(" AND p.PayAmt BETWEEN ? AND ?");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DateFrom != null || DateTo != null)
|
if(DateFrom != null || DateTo != null)
|
||||||
{
|
{
|
||||||
Timestamp from = (Timestamp) DateFrom;
|
if(DateFrom == null && DateTo != null)
|
||||||
Timestamp to = (Timestamp) DateTo;
|
|
||||||
if(from == null && to != null)
|
|
||||||
sql.append(" AND TRUNC(p.DateTrx) <= ?");
|
sql.append(" AND TRUNC(p.DateTrx) <= ?");
|
||||||
else if(from != null && to == null)
|
else if(DateFrom != null && DateTo == null)
|
||||||
sql.append(" AND TRUNC(p.DateTrx) >= ?");
|
sql.append(" AND TRUNC(p.DateTrx) >= ?");
|
||||||
else if(from != null && to != null)
|
else if(DateFrom != null && DateTo != null)
|
||||||
sql.append(" AND TRUNC(p.DateTrx) BETWEEN ? AND ?");
|
sql.append(" AND TRUNC(p.DateTrx) BETWEEN ? AND ?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,22 +120,47 @@ public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
return sql.toString();
|
return sql.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
void setParameters(PreparedStatement pstmt, Object BankAccount, Object BPartner, String DocumentNo, Object DateFrom, Object DateTo,
|
void setParameters(PreparedStatement pstmt, Object BankAccount, Object BPartner, String DocumentNo, Object DateFrom, Object DateTo,
|
||||||
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode, GridTab gridTab)
|
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode, GridTab gridTab)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
|
{
|
||||||
|
setParameters(pstmt, (Integer)BankAccount, (Integer)BPartner, DocumentNo, (Timestamp)DateFrom, (Timestamp)DateTo,
|
||||||
|
(BigDecimal)AmtFrom, (BigDecimal)AmtTo, (Integer)DocType, (String)TenderType, AuthCode, gridTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param pstmt
|
||||||
|
* @param BankAccount
|
||||||
|
* @param BPartner
|
||||||
|
* @param DocumentNo
|
||||||
|
* @param DateFrom
|
||||||
|
* @param DateTo
|
||||||
|
* @param AmtFrom
|
||||||
|
* @param AmtTo
|
||||||
|
* @param DocType
|
||||||
|
* @param TenderType
|
||||||
|
* @param AuthCode
|
||||||
|
* @param gridTab
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
protected void setParameters(PreparedStatement pstmt, Integer BankAccount, Integer BPartner, String DocumentNo, Timestamp DateFrom, Timestamp DateTo,
|
||||||
|
BigDecimal AmtFrom, BigDecimal AmtTo, Integer DocType, String TenderType, String AuthCode, GridTab gridTab)
|
||||||
|
throws SQLException
|
||||||
{
|
{
|
||||||
int index = 1;
|
int index = 1;
|
||||||
|
|
||||||
pstmt.setInt(index++, BankAccount != null ? (Integer) BankAccount : (Integer) gridTab.getValue("C_BankAccount_ID"));
|
pstmt.setInt(index++, BankAccount != null ? BankAccount : (Integer) gridTab.getValue("C_BankAccount_ID"));
|
||||||
|
|
||||||
if(DocType != null)
|
if(DocType != null)
|
||||||
pstmt.setInt(index++, (Integer) DocType);
|
pstmt.setInt(index++, DocType);
|
||||||
|
|
||||||
if(TenderType != null && TenderType.toString().length() > 0)
|
if(TenderType != null && TenderType.toString().length() > 0)
|
||||||
pstmt.setString(index++, (String) TenderType);
|
pstmt.setString(index++, TenderType);
|
||||||
|
|
||||||
if(BPartner != null)
|
if(BPartner != null)
|
||||||
pstmt.setInt(index++, (Integer) BPartner);
|
pstmt.setInt(index++, BPartner);
|
||||||
|
|
||||||
if(DocumentNo.length() > 0)
|
if(DocumentNo.length() > 0)
|
||||||
pstmt.setString(index++, getSQLText(DocumentNo));
|
pstmt.setString(index++, getSQLText(DocumentNo));
|
||||||
|
@ -127,33 +170,29 @@ public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
|
|
||||||
if(AmtFrom != null || AmtTo != null)
|
if(AmtFrom != null || AmtTo != null)
|
||||||
{
|
{
|
||||||
BigDecimal from = (BigDecimal) AmtFrom;
|
if (log.isLoggable(Level.FINE)) log.fine("Amt From=" + AmtFrom + ", To=" + AmtTo);
|
||||||
BigDecimal to = (BigDecimal) AmtTo;
|
if(AmtFrom == null && AmtTo != null)
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("Amt From=" + from + ", To=" + to);
|
pstmt.setBigDecimal(index++, AmtTo);
|
||||||
if(from == null && to != null)
|
else if(AmtFrom != null && AmtTo == null)
|
||||||
pstmt.setBigDecimal(index++, to);
|
pstmt.setBigDecimal(index++, AmtFrom);
|
||||||
else if(from != null && to == null)
|
else if(AmtFrom != null && AmtTo != null)
|
||||||
pstmt.setBigDecimal(index++, from);
|
|
||||||
else if(from != null && to != null)
|
|
||||||
{
|
{
|
||||||
pstmt.setBigDecimal(index++, from);
|
pstmt.setBigDecimal(index++, AmtFrom);
|
||||||
pstmt.setBigDecimal(index++, to);
|
pstmt.setBigDecimal(index++, AmtTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DateFrom != null || DateTo != null)
|
if(DateFrom != null || DateTo != null)
|
||||||
{
|
{
|
||||||
Timestamp from = (Timestamp) DateFrom;
|
if (log.isLoggable(Level.FINE)) log.fine("Date From=" + DateFrom + ", To=" + DateTo);
|
||||||
Timestamp to = (Timestamp) DateTo;
|
if(DateFrom == null && DateTo != null)
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("Date From=" + from + ", To=" + to);
|
pstmt.setTimestamp(index++, DateTo);
|
||||||
if(from == null && to != null)
|
else if(DateFrom != null && DateTo == null)
|
||||||
pstmt.setTimestamp(index++, to);
|
pstmt.setTimestamp(index++, DateFrom);
|
||||||
else if(from != null && to == null)
|
else if(DateFrom != null && DateTo != null)
|
||||||
pstmt.setTimestamp(index++, from);
|
|
||||||
else if(from != null && to != null)
|
|
||||||
{
|
{
|
||||||
pstmt.setTimestamp(index++, from);
|
pstmt.setTimestamp(index++, DateFrom);
|
||||||
pstmt.setTimestamp(index++, to);
|
pstmt.setTimestamp(index++, DateTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,9 +206,33 @@ public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
protected Vector<Vector<Object>> getBankAccountData(Object BankAccount, Object BPartner, String DocumentNo,
|
protected Vector<Vector<Object>> getBankAccountData(Object BankAccount, Object BPartner, String DocumentNo,
|
||||||
Object DateFrom, Object DateTo, Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode,
|
Object DateFrom, Object DateTo, Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode,
|
||||||
GridTab gridTab)
|
GridTab gridTab)
|
||||||
|
{
|
||||||
|
return getBankAccountData((Integer)BankAccount, (Integer)BPartner, DocumentNo, (Timestamp)DateFrom, (Timestamp)DateTo,
|
||||||
|
(BigDecimal)AmtFrom, (BigDecimal)AmtTo, (Integer)DocType, (String)TenderType, AuthCode, gridTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param BankAccount
|
||||||
|
* @param BPartner
|
||||||
|
* @param DocumentNo
|
||||||
|
* @param DateFrom
|
||||||
|
* @param DateTo
|
||||||
|
* @param AmtFrom
|
||||||
|
* @param AmtTo
|
||||||
|
* @param DocType
|
||||||
|
* @param TenderType
|
||||||
|
* @param AuthCode
|
||||||
|
* @param gridTab
|
||||||
|
* @return list of bank account records
|
||||||
|
*/
|
||||||
|
protected Vector<Vector<Object>> getBankAccountData(Integer BankAccount, Integer BPartner, String DocumentNo,
|
||||||
|
Timestamp DateFrom, Timestamp DateTo, BigDecimal AmtFrom, BigDecimal AmtTo, Integer DocType, String TenderType, String AuthCode,
|
||||||
|
GridTab gridTab)
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config ("C_BankAccount_ID=" + BankAccount);
|
if (log.isLoggable(Level.CONFIG)) log.config ("C_BankAccount_ID=" + BankAccount);
|
||||||
|
|
||||||
|
@ -224,6 +287,10 @@ public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param miniTable
|
||||||
|
*/
|
||||||
protected void configureMiniTable (IMiniTable miniTable)
|
protected void configureMiniTable (IMiniTable miniTable)
|
||||||
{
|
{
|
||||||
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||||
|
@ -236,6 +303,7 @@ public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
miniTable.autoSize();
|
miniTable.autoSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean save(IMiniTable miniTable, String trxName, GridTab gridTab)
|
public boolean save(IMiniTable miniTable, String trxName, GridTab gridTab)
|
||||||
{
|
{
|
||||||
// fixed values
|
// fixed values
|
||||||
|
@ -314,6 +382,10 @@ public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return column names
|
||||||
|
*/
|
||||||
protected Vector<String> getOISColumnNames()
|
protected Vector<String> getOISColumnNames()
|
||||||
{
|
{
|
||||||
// Header Info
|
// Header Info
|
||||||
|
@ -328,6 +400,7 @@ public abstract class StatementCreateFromBatch extends CreateFromForm
|
||||||
return columnNames;
|
return columnNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void info(IMiniTable miniTable, IStatusBar statusBar)
|
public void info(IMiniTable miniTable, IStatusBar statusBar)
|
||||||
{
|
{
|
||||||
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
|
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||||
|
|
|
@ -33,6 +33,11 @@ import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
public abstract class CreateFrom implements ICreateFrom
|
public abstract class CreateFrom implements ICreateFrom
|
||||||
{
|
{
|
||||||
/** Logger */
|
/** Logger */
|
||||||
|
@ -52,6 +57,13 @@ public abstract class CreateFrom implements ICreateFrom
|
||||||
|
|
||||||
protected boolean isSOTrx = false;
|
protected boolean isSOTrx = false;
|
||||||
|
|
||||||
|
/** optional db trx name **/
|
||||||
|
private String m_trxName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param gridTab
|
||||||
|
*/
|
||||||
public CreateFrom(GridTab gridTab) {
|
public CreateFrom(GridTab gridTab) {
|
||||||
this.gridTab = gridTab;
|
this.gridTab = gridTab;
|
||||||
|
|
||||||
|
@ -62,36 +74,63 @@ public abstract class CreateFrom implements ICreateFrom
|
||||||
isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), gridTab.getWindowNo(), "IsSOTrx"));
|
isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), gridTab.getWindowNo(), "IsSOTrx"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean dynInit() throws Exception;
|
/**
|
||||||
|
* dynamic initialization, usually for loading of data
|
||||||
public abstract void info(IMiniTable miniTable, IStatusBar statusBar);
|
* @return true if initialization success
|
||||||
|
* @throws Exception
|
||||||
public abstract boolean save(IMiniTable miniTable, String trxName);
|
*/
|
||||||
|
protected abstract boolean dynInit() throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init OK to be able to make changes?
|
* update status bar with info from miniTable
|
||||||
* @return on if initialized
|
* @param miniTable
|
||||||
|
* @param statusBar
|
||||||
*/
|
*/
|
||||||
|
public abstract void info(IMiniTable miniTable, IStatusBar statusBar);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save changes
|
||||||
|
* @param miniTable
|
||||||
|
* @param trxName
|
||||||
|
* @return true if save successfully
|
||||||
|
*/
|
||||||
|
public abstract boolean save(IMiniTable miniTable, String trxName);
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isInitOK()
|
public boolean isInitOK()
|
||||||
{
|
{
|
||||||
return initOK;
|
return initOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param initOK
|
||||||
|
*/
|
||||||
public void setInitOK(boolean initOK)
|
public void setInitOK(boolean initOK)
|
||||||
{
|
{
|
||||||
this.initOK = initOK;
|
this.initOK = initOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load PBartner dependent Order/Invoice/Shipment Field.
|
* Load BPartner related Orders.
|
||||||
* @param C_BPartner_ID BPartner
|
* @param C_BPartner_ID BPartner
|
||||||
* @param forInvoice for invoice
|
* @param forInvoice for invoice
|
||||||
|
* @param sameWarehouseOnly
|
||||||
|
* @return list of order records
|
||||||
*/
|
*/
|
||||||
protected ArrayList<KeyNamePair> loadOrderData (int C_BPartner_ID, boolean forInvoice, boolean sameWarehouseOnly)
|
protected ArrayList<KeyNamePair> loadOrderData (int C_BPartner_ID, boolean forInvoice, boolean sameWarehouseOnly)
|
||||||
{
|
{
|
||||||
return loadOrderData(C_BPartner_ID, forInvoice, sameWarehouseOnly, false);
|
return loadOrderData(C_BPartner_ID, forInvoice, sameWarehouseOnly, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load order records
|
||||||
|
* @param C_BPartner_ID
|
||||||
|
* @param forInvoice
|
||||||
|
* @param sameWarehouseOnly
|
||||||
|
* @param forCreditMemo
|
||||||
|
* @return list of order records
|
||||||
|
*/
|
||||||
protected ArrayList<KeyNamePair> loadOrderData (int C_BPartner_ID, boolean forInvoice, boolean sameWarehouseOnly, boolean forCreditMemo)
|
protected ArrayList<KeyNamePair> loadOrderData (int C_BPartner_ID, boolean forInvoice, boolean sameWarehouseOnly, boolean forCreditMemo)
|
||||||
{
|
{
|
||||||
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
|
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
|
||||||
|
@ -133,7 +172,7 @@ public abstract class CreateFrom implements ICreateFrom
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), m_trxName);
|
||||||
pstmt.setInt(1, C_BPartner_ID);
|
pstmt.setInt(1, C_BPartner_ID);
|
||||||
pstmt.setString(2, isSOTrxParam);
|
pstmt.setString(2, isSOTrxParam);
|
||||||
if(sameWarehouseOnly)
|
if(sameWarehouseOnly)
|
||||||
|
@ -161,15 +200,23 @@ public abstract class CreateFrom implements ICreateFrom
|
||||||
} // initBPartnerOIS
|
} // initBPartnerOIS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Data - Order
|
* Load Order Line records
|
||||||
* @param C_Order_ID Order
|
* @param C_Order_ID Order
|
||||||
* @param forInvoice true if for invoice vs. delivery qty
|
* @param forInvoice true if for invoice vs. delivery qty
|
||||||
|
* @return list of order line records
|
||||||
*/
|
*/
|
||||||
protected Vector<Vector<Object>> getOrderData (int C_Order_ID, boolean forInvoice)
|
protected Vector<Vector<Object>> getOrderData (int C_Order_ID, boolean forInvoice)
|
||||||
{
|
{
|
||||||
return getOrderData (C_Order_ID, forInvoice, false);
|
return getOrderData (C_Order_ID, forInvoice, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get order line records
|
||||||
|
* @param C_Order_ID
|
||||||
|
* @param forInvoice
|
||||||
|
* @param forCreditMemo
|
||||||
|
* @return list of order line records
|
||||||
|
*/
|
||||||
protected Vector<Vector<Object>> getOrderData (int C_Order_ID, boolean forInvoice, boolean forCreditMemo)
|
protected Vector<Vector<Object>> getOrderData (int C_Order_ID, boolean forInvoice, boolean forCreditMemo)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -183,7 +230,7 @@ public abstract class CreateFrom implements ICreateFrom
|
||||||
* InvoiceLine - 7
|
* InvoiceLine - 7
|
||||||
*/
|
*/
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config("C_Order_ID=" + C_Order_ID);
|
if (log.isLoggable(Level.CONFIG)) log.config("C_Order_ID=" + C_Order_ID);
|
||||||
p_order = new MOrder (Env.getCtx(), C_Order_ID, null);
|
p_order = new MOrder (Env.getCtx(), C_Order_ID, getTrxName());
|
||||||
|
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||||
StringBuilder sql = new StringBuilder("SELECT ");
|
StringBuilder sql = new StringBuilder("SELECT ");
|
||||||
|
@ -216,7 +263,7 @@ public abstract class CreateFrom implements ICreateFrom
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
pstmt.setInt(1, C_Order_ID);
|
pstmt.setInt(1, C_Order_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
|
@ -231,7 +278,7 @@ public abstract class CreateFrom implements ICreateFrom
|
||||||
line.add(pp); // 2-UOM
|
line.add(pp); // 2-UOM
|
||||||
pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
|
pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
|
||||||
line.add(pp); // 3-Product
|
line.add(pp); // 3-Product
|
||||||
line.add(rs.getString(7)); // 4-VendorProductNo
|
line.add(rs.getString(7)); // 4-VendorProductNo
|
||||||
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
|
pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
|
||||||
line.add(pp); // 5-OrderLine
|
line.add(pp); // 5-OrderLine
|
||||||
line.add(null); // 6-Ship
|
line.add(null); // 6-Ship
|
||||||
|
@ -252,16 +299,22 @@ public abstract class CreateFrom implements ICreateFrom
|
||||||
return data;
|
return data;
|
||||||
} // LoadOrder
|
} // LoadOrder
|
||||||
|
|
||||||
|
@Override
|
||||||
public void showWindow()
|
public void showWindow()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void closeWindow()
|
public void closeWindow()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return {@link GridTab}
|
||||||
|
*/
|
||||||
public GridTab getGridTab()
|
public GridTab getGridTab()
|
||||||
{
|
{
|
||||||
return gridTab;
|
return gridTab;
|
||||||
|
@ -276,11 +329,35 @@ public abstract class CreateFrom implements ICreateFrom
|
||||||
return Env.getContextAsInt(Env.getCtx(), gridTab.getWindowNo(), "M_Warehouse_ID");
|
return Env.getContextAsInt(Env.getCtx(), gridTab.getWindowNo(), "M_Warehouse_ID");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return title
|
||||||
|
*/
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param title
|
||||||
|
*/
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return trx name
|
||||||
|
*/
|
||||||
|
public String getTrxName() {
|
||||||
|
return m_trxName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set optional trx name
|
||||||
|
* @param trxName
|
||||||
|
*/
|
||||||
|
public void setTrxName(String trxName) {
|
||||||
|
m_trxName = trxName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,38 @@ import org.compiere.util.Msg;
|
||||||
*/
|
*/
|
||||||
public abstract class CreateFromBatch extends CreateFrom
|
public abstract class CreateFromBatch extends CreateFrom
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param gridTab
|
||||||
|
*/
|
||||||
public CreateFromBatch(GridTab gridTab)
|
public CreateFromBatch(GridTab gridTab)
|
||||||
{
|
{
|
||||||
super(gridTab);
|
super(gridTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String getSQLWhere(Object BPartner, String DocumentNo, Object DateFrom, Object DateTo,
|
public String getSQLWhere(Object BPartner, String DocumentNo, Object DateFrom, Object DateTo,
|
||||||
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
||||||
|
{
|
||||||
|
return getSQLWhere((Integer)BPartner, DocumentNo, (Timestamp)DateFrom, (Timestamp)DateTo,
|
||||||
|
(BigDecimal)AmtFrom, (BigDecimal)AmtTo, (Integer)DocType, (String)TenderType, AuthCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param BPartner
|
||||||
|
* @param DocumentNo
|
||||||
|
* @param DateFrom
|
||||||
|
* @param DateTo
|
||||||
|
* @param AmtFrom
|
||||||
|
* @param AmtTo
|
||||||
|
* @param DocType
|
||||||
|
* @param TenderType
|
||||||
|
* @param AuthCode
|
||||||
|
* @return where clause
|
||||||
|
*/
|
||||||
|
protected String getSQLWhere(Integer BPartner, String DocumentNo, Timestamp DateFrom, Timestamp DateTo,
|
||||||
|
BigDecimal AmtFrom, BigDecimal AmtTo, Integer DocType, String TenderType, String AuthCode)
|
||||||
{
|
{
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("WHERE p.Processed='Y' AND p.IsReconciled='N'");
|
sql.append("WHERE p.Processed='Y' AND p.IsReconciled='N'");
|
||||||
|
@ -56,32 +81,28 @@ public abstract class CreateFromBatch extends CreateFrom
|
||||||
if(BPartner != null)
|
if(BPartner != null)
|
||||||
sql.append(" AND p.C_BPartner_ID=?");
|
sql.append(" AND p.C_BPartner_ID=?");
|
||||||
|
|
||||||
if(DocumentNo.length() > 0)
|
if(DocumentNo != null && DocumentNo.length() > 0)
|
||||||
sql.append(" AND UPPER(p.DocumentNo) LIKE ?");
|
sql.append(" AND UPPER(p.DocumentNo) LIKE ?");
|
||||||
if(AuthCode.length() > 0)
|
if(AuthCode != null && AuthCode.length() > 0)
|
||||||
sql.append(" AND p.R_AuthCode LIKE ?");
|
sql.append(" AND p.R_AuthCode LIKE ?");
|
||||||
|
|
||||||
if(AmtFrom != null || AmtTo != null)
|
if(AmtFrom != null || AmtTo != null)
|
||||||
{
|
{
|
||||||
BigDecimal from = (BigDecimal) AmtFrom;
|
if(AmtFrom == null && AmtTo != null)
|
||||||
BigDecimal to = (BigDecimal) AmtTo;
|
|
||||||
if(from == null && to != null)
|
|
||||||
sql.append(" AND p.PayAmt <= ?");
|
sql.append(" AND p.PayAmt <= ?");
|
||||||
else if(from != null && to == null)
|
else if(AmtFrom != null && AmtTo == null)
|
||||||
sql.append(" AND p.PayAmt >= ?");
|
sql.append(" AND p.PayAmt >= ?");
|
||||||
else if(from != null && to != null)
|
else if(AmtFrom != null && AmtTo != null)
|
||||||
sql.append(" AND p.PayAmt BETWEEN ? AND ?");
|
sql.append(" AND p.PayAmt BETWEEN ? AND ?");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DateFrom != null || DateTo != null)
|
if(DateFrom != null || DateTo != null)
|
||||||
{
|
{
|
||||||
Timestamp from = (Timestamp) DateFrom;
|
if(DateFrom == null && DateTo != null)
|
||||||
Timestamp to = (Timestamp) DateTo;
|
|
||||||
if(from == null && to != null)
|
|
||||||
sql.append(" AND TRUNC(p.DateTrx) <= ?");
|
sql.append(" AND TRUNC(p.DateTrx) <= ?");
|
||||||
else if(from != null && to == null)
|
else if(DateFrom != null && DateTo == null)
|
||||||
sql.append(" AND TRUNC(p.DateTrx) >= ?");
|
sql.append(" AND TRUNC(p.DateTrx) >= ?");
|
||||||
else if(from != null && to != null)
|
else if(DateFrom != null && DateTo != null)
|
||||||
sql.append(" AND TRUNC(p.DateTrx) BETWEEN ? AND ?");
|
sql.append(" AND TRUNC(p.DateTrx) BETWEEN ? AND ?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,64 +110,78 @@ public abstract class CreateFromBatch extends CreateFrom
|
||||||
return sql.toString();
|
return sql.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
void setParameters(PreparedStatement pstmt, Object BankAccount, Object BPartner, String DocumentNo, Object DateFrom, Object DateTo,
|
void setParameters(PreparedStatement pstmt, Object BankAccount, Object BPartner, String DocumentNo, Object DateFrom, Object DateTo,
|
||||||
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
// Get StatementDate
|
setParameters(pstmt, (Integer)BankAccount, (Integer)BPartner, DocumentNo, (Timestamp)DateFrom, (Timestamp)DateTo,
|
||||||
//Timestamp ts = (Timestamp) getGridTab().getValue("StatementDate");
|
(BigDecimal)AmtFrom, (BigDecimal)AmtTo, (Integer)DocType, (String)TenderType, AuthCode);
|
||||||
//if (ts == null)
|
}
|
||||||
//ts = new Timestamp(System.currentTimeMillis());
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param pstmt
|
||||||
|
* @param BankAccount
|
||||||
|
* @param BPartner
|
||||||
|
* @param DocumentNo
|
||||||
|
* @param DateFrom
|
||||||
|
* @param DateTo
|
||||||
|
* @param AmtFrom
|
||||||
|
* @param AmtTo
|
||||||
|
* @param DocType
|
||||||
|
* @param TenderType
|
||||||
|
* @param AuthCode
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
protected void setParameters(PreparedStatement pstmt, Integer BankAccount, Integer BPartner, String DocumentNo, Timestamp DateFrom, Timestamp DateTo,
|
||||||
|
BigDecimal AmtFrom, BigDecimal AmtTo, Integer DocType, String TenderType, String AuthCode)
|
||||||
|
throws SQLException
|
||||||
|
{
|
||||||
int index = 1;
|
int index = 1;
|
||||||
|
|
||||||
//pstmt.setTimestamp(index++, ts);
|
pstmt.setInt(index++, BankAccount != null ? BankAccount : (Integer) getGridTab().getValue("C_BankAccount_ID"));
|
||||||
pstmt.setInt(index++, BankAccount != null ? (Integer) BankAccount : (Integer) getGridTab().getValue("C_BankAccount_ID"));
|
|
||||||
|
|
||||||
if(DocType != null)
|
if(DocType != null)
|
||||||
pstmt.setInt(index++, (Integer) DocType);
|
pstmt.setInt(index++, DocType);
|
||||||
|
|
||||||
if(TenderType != null && TenderType.toString().length() > 0)
|
if(TenderType != null && TenderType.toString().length() > 0)
|
||||||
pstmt.setString(index++, (String) TenderType);
|
pstmt.setString(index++, TenderType);
|
||||||
|
|
||||||
if(BPartner != null)
|
if(BPartner != null)
|
||||||
pstmt.setInt(index++, (Integer) BPartner);
|
pstmt.setInt(index++, BPartner);
|
||||||
|
|
||||||
if(DocumentNo.length() > 0)
|
if(DocumentNo != null && DocumentNo.length() > 0)
|
||||||
pstmt.setString(index++, getSQLText(DocumentNo));
|
pstmt.setString(index++, getSQLText(DocumentNo));
|
||||||
|
|
||||||
if(AuthCode.length() > 0)
|
if(AuthCode != null && AuthCode.length() > 0)
|
||||||
pstmt.setString(index++, getSQLText(AuthCode));
|
pstmt.setString(index++, getSQLText(AuthCode));
|
||||||
|
|
||||||
if(AmtFrom != null || AmtTo != null)
|
if(AmtFrom != null || AmtTo != null)
|
||||||
{
|
{
|
||||||
BigDecimal from = (BigDecimal) AmtFrom;
|
if (log.isLoggable(Level.FINE)) log.fine("Amt From=" + AmtFrom + ", To=" + AmtTo);
|
||||||
BigDecimal to = (BigDecimal) AmtTo;
|
if(AmtFrom == null && AmtTo != null)
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("Amt From=" + from + ", To=" + to);
|
pstmt.setBigDecimal(index++, AmtTo);
|
||||||
if(from == null && to != null)
|
else if(AmtFrom != null && AmtTo == null)
|
||||||
pstmt.setBigDecimal(index++, to);
|
pstmt.setBigDecimal(index++, AmtFrom);
|
||||||
else if(from != null && to == null)
|
else if(AmtFrom != null && AmtTo != null)
|
||||||
pstmt.setBigDecimal(index++, from);
|
|
||||||
else if(from != null && to != null)
|
|
||||||
{
|
{
|
||||||
pstmt.setBigDecimal(index++, from);
|
pstmt.setBigDecimal(index++, AmtFrom);
|
||||||
pstmt.setBigDecimal(index++, to);
|
pstmt.setBigDecimal(index++, AmtTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DateFrom != null || DateTo != null)
|
if(DateFrom != null || DateTo != null)
|
||||||
{
|
{
|
||||||
Timestamp from = (Timestamp) DateFrom;
|
if (log.isLoggable(Level.FINE)) log.fine("Date From=" + DateFrom + ", To=" + DateTo);
|
||||||
Timestamp to = (Timestamp) DateTo;
|
if(DateFrom == null && DateTo != null)
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("Date From=" + from + ", To=" + to);
|
pstmt.setTimestamp(index++, DateTo);
|
||||||
if(from == null && to != null)
|
else if(DateFrom != null && DateTo == null)
|
||||||
pstmt.setTimestamp(index++, to);
|
pstmt.setTimestamp(index++, DateFrom);
|
||||||
else if(from != null && to == null)
|
else if(DateFrom != null && DateTo != null)
|
||||||
pstmt.setTimestamp(index++, from);
|
|
||||||
else if(from != null && to != null)
|
|
||||||
{
|
{
|
||||||
pstmt.setTimestamp(index++, from);
|
pstmt.setTimestamp(index++, DateFrom);
|
||||||
pstmt.setTimestamp(index++, to);
|
pstmt.setTimestamp(index++, DateTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,9 +195,32 @@ public abstract class CreateFromBatch extends CreateFrom
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Vector<Vector<Object>> getBankAccountData(Object BankAccount, Object BPartner, String DocumentNo,
|
@Deprecated
|
||||||
Object DateFrom, Object DateTo, Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode);
|
protected Vector<Vector<Object>> getBankAccountData(Object BankAccount, Object BPartner, String DocumentNo,
|
||||||
|
Object DateFrom, Object DateTo, Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
||||||
|
{
|
||||||
|
return getBankAccountData((Integer)BankAccount, (Integer)BPartner, DocumentNo, (Timestamp)DateFrom, (Timestamp)DateTo,
|
||||||
|
(BigDecimal)AmtFrom, (BigDecimal)AmtTo, (Integer)DocType, (String)TenderType, AuthCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param BankAccount
|
||||||
|
* @param BPartner
|
||||||
|
* @param DocumentNo
|
||||||
|
* @param DateFrom
|
||||||
|
* @param DateTo
|
||||||
|
* @param AmtFrom
|
||||||
|
* @param AmtTo
|
||||||
|
* @param DocType
|
||||||
|
* @param TenderType
|
||||||
|
* @param AuthCode
|
||||||
|
* @return list of transaction records (usually payments) for bank account
|
||||||
|
*/
|
||||||
|
protected abstract Vector<Vector<Object>> getBankAccountData(Integer BankAccount, Integer BPartner, String DocumentNo,
|
||||||
|
Timestamp DateFrom, Timestamp DateTo, BigDecimal AmtFrom, BigDecimal AmtTo, Integer DocType, String TenderType, String AuthCode);
|
||||||
|
|
||||||
|
@Override
|
||||||
public void info(IMiniTable miniTable, IStatusBar statusBar)
|
public void info(IMiniTable miniTable, IStatusBar statusBar)
|
||||||
{
|
{
|
||||||
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
|
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||||
|
|
|
@ -32,28 +32,37 @@ import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Create C_DepositBatchLine for C_DepositBatch from C_Payment
|
||||||
* @author Elaine
|
* @author Elaine
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class CreateFromDepositBatch extends CreateFromBatch
|
public abstract class CreateFromDepositBatch extends CreateFromBatch
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param mTab
|
||||||
|
*/
|
||||||
public CreateFromDepositBatch(GridTab mTab)
|
public CreateFromDepositBatch(GridTab mTab)
|
||||||
{
|
{
|
||||||
super(mTab);
|
super(mTab);
|
||||||
if (log.isLoggable(Level.INFO)) log.info(mTab.toString());
|
if (log.isLoggable(Level.INFO)) log.info(mTab.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean dynInit() throws Exception
|
@Override
|
||||||
|
protected boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
log.config("");
|
if (log.isLoggable(Level.CONFIG)) log.config("");
|
||||||
setTitle(Msg.getElement(Env.getCtx(), "C_DepositBatch_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
setTitle(Msg.getElement(Env.getCtx(), "C_DepositBatch_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Vector<Vector<Object>> getBankAccountData(Object BankAccount, Object BPartner, String DocumentNo,
|
/**
|
||||||
Object DateFrom, Object DateTo, Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
* @return transaction records (selection,datetrx,[c_payment_id,documentno],[c_currency_id,iso_code],payamt,converted amt,bp name)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Vector<Vector<Object>> getBankAccountData(Integer BankAccount, Integer BPartner, String DocumentNo,
|
||||||
|
Timestamp DateFrom, Timestamp DateTo, BigDecimal AmtFrom, BigDecimal AmtTo, Integer DocType, String TenderType, String AuthCode)
|
||||||
{
|
{
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||||
|
|
||||||
|
@ -77,7 +86,7 @@ public abstract class CreateFromDepositBatch extends CreateFromBatch
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
setParameters(pstmt, BankAccount, BPartner, DocumentNo, DateFrom, DateTo, AmtFrom, AmtTo, DocType, TenderType, AuthCode);
|
setParameters(pstmt, BankAccount, BPartner, DocumentNo, DateFrom, DateTo, AmtFrom, AmtTo, DocType, TenderType, AuthCode);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while(rs.next())
|
while(rs.next())
|
||||||
|
@ -108,6 +117,10 @@ public abstract class CreateFromDepositBatch extends CreateFromBatch
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set class/type of columns
|
||||||
|
* @param miniTable
|
||||||
|
*/
|
||||||
protected void configureMiniTable(IMiniTable miniTable)
|
protected void configureMiniTable(IMiniTable miniTable)
|
||||||
{
|
{
|
||||||
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||||
|
@ -121,6 +134,10 @@ public abstract class CreateFromDepositBatch extends CreateFromBatch
|
||||||
miniTable.autoSize();
|
miniTable.autoSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create C_DepositBatchLine
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public boolean save(IMiniTable miniTable, String trxName)
|
public boolean save(IMiniTable miniTable, String trxName)
|
||||||
{
|
{
|
||||||
// fixed values
|
// fixed values
|
||||||
|
@ -139,12 +156,10 @@ public abstract class CreateFromDepositBatch extends CreateFromBatch
|
||||||
pp = (KeyNamePair) miniTable.getValueAt(i, 3); // 3-Currency
|
pp = (KeyNamePair) miniTable.getValueAt(i, 3); // 3-Currency
|
||||||
int C_Currency_ID = pp.getKey();
|
int C_Currency_ID = pp.getKey();
|
||||||
BigDecimal TrxAmt = (BigDecimal) miniTable.getValueAt(i, 4); // 4-PayAmt
|
BigDecimal TrxAmt = (BigDecimal) miniTable.getValueAt(i, 4); // 4-PayAmt
|
||||||
// BigDecimal StmtAmt = (BigDecimal) miniTable.getValueAt(i, 5);// 5-Conv Amt
|
|
||||||
//
|
//
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("Line Date=" + trxDate + ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt);
|
if (log.isLoggable(Level.FINE)) log.fine("Line Date=" + trxDate + ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt);
|
||||||
//
|
//
|
||||||
MDepositBatchLine dbl = new MDepositBatchLine(db);
|
MDepositBatchLine dbl = new MDepositBatchLine(db);
|
||||||
// dbl.setStatementLineDate(trxDate);
|
|
||||||
dbl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, trxName));
|
dbl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, trxName));
|
||||||
if(!dbl.save())
|
if(!dbl.save())
|
||||||
log.log(Level.SEVERE, "Line not created #" + i);
|
log.log(Level.SEVERE, "Line not created #" + i);
|
||||||
|
@ -153,6 +168,10 @@ public abstract class CreateFromDepositBatch extends CreateFromBatch
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return column header names (select,date,c_payment_id,c_currency_id,amount,converted amount,c_bpartner_id)
|
||||||
|
*/
|
||||||
protected Vector<String> getOISColumnNames()
|
protected Vector<String> getOISColumnNames()
|
||||||
{
|
{
|
||||||
// Header Info
|
// Header Info
|
||||||
|
|
|
@ -48,7 +48,7 @@ import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Invoice Transactions from PO Orders or Receipt
|
* Create Invoice Lines from Purchase Order, Material Receipt or Vendor RMA
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: VCreateFromInvoice.java,v 1.4 2006/07/30 00:51:28 jjanke Exp $
|
* @version $Id: VCreateFromInvoice.java,v 1.4 2006/07/30 00:51:28 jjanke Exp $
|
||||||
|
@ -60,20 +60,17 @@ import org.compiere.util.Msg;
|
||||||
public abstract class CreateFromInvoice extends CreateFrom
|
public abstract class CreateFromInvoice extends CreateFrom
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Protected Constructor
|
* Constructor
|
||||||
* @param mTab MTab
|
* @param mTab MTab
|
||||||
*/
|
*/
|
||||||
public CreateFromInvoice(GridTab mTab)
|
public CreateFromInvoice(GridTab mTab)
|
||||||
{
|
{
|
||||||
super(mTab);
|
super(mTab);
|
||||||
if (log.isLoggable(Level.INFO)) log.info(mTab.toString());
|
if (log.isLoggable(Level.INFO)) log.info(mTab.toString());
|
||||||
} // VCreateFromInvoice
|
} // CreateFromInvoice
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Dynamic Init
|
protected boolean dynInit() throws Exception
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
public boolean dynInit() throws Exception
|
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
setTitle(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
setTitle(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||||
|
@ -82,8 +79,9 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
} // dynInit
|
} // dynInit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load PBartner dependent Order/Invoice/Shipment Field.
|
* Load BPartner related Shipment records.
|
||||||
* @param C_BPartner_ID
|
* @param C_BPartner_ID
|
||||||
|
* @return list of shipment records
|
||||||
*/
|
*/
|
||||||
protected ArrayList<KeyNamePair> loadShipmentData (int C_BPartner_ID)
|
protected ArrayList<KeyNamePair> loadShipmentData (int C_BPartner_ID)
|
||||||
{
|
{
|
||||||
|
@ -117,7 +115,7 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
pstmt.setInt(1, C_BPartner_ID);
|
pstmt.setInt(1, C_BPartner_ID);
|
||||||
pstmt.setString(2, isSOTrxParam);
|
pstmt.setString(2, isSOTrxParam);
|
||||||
pstmt.setInt(3, C_BPartner_ID);
|
pstmt.setInt(3, C_BPartner_ID);
|
||||||
|
@ -143,8 +141,9 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load PBartner dependent Order/Invoice/Shipment Field.
|
* Load BPartner related RMA records
|
||||||
* @param C_BPartner_ID BPartner
|
* @param C_BPartner_ID BPartner
|
||||||
|
* @return list of RMA records
|
||||||
*/
|
*/
|
||||||
protected ArrayList<KeyNamePair> loadRMAData(int C_BPartner_ID) {
|
protected ArrayList<KeyNamePair> loadRMAData(int C_BPartner_ID) {
|
||||||
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
|
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
|
||||||
|
@ -158,7 +157,7 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
pstmt = DB.prepareStatement(sqlStmt, null);
|
pstmt = DB.prepareStatement(sqlStmt, getTrxName());
|
||||||
pstmt.setInt(1, C_BPartner_ID);
|
pstmt.setInt(1, C_BPartner_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
@ -176,21 +175,21 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Data - Shipment not invoiced
|
* Load Shipment Lines not invoiced
|
||||||
* @param M_InOut_ID InOut
|
* @param M_InOut_ID InOut
|
||||||
|
* @return shipment lines (selection,qty,[c_uom_id,uomSymbol/name],[m_product_id,name],vendorProductNo,[c_orderline_id,.],[m_inoutline_id,line],null)
|
||||||
*/
|
*/
|
||||||
protected Vector<Vector<Object>> getShipmentData(int M_InOut_ID)
|
protected Vector<Vector<Object>> getShipmentData(int M_InOut_ID)
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config("M_InOut_ID=" + M_InOut_ID);
|
if (log.isLoggable(Level.CONFIG)) log.config("M_InOut_ID=" + M_InOut_ID);
|
||||||
MInOut inout = new MInOut(Env.getCtx(), M_InOut_ID, null);
|
MInOut inout = new MInOut(Env.getCtx(), M_InOut_ID, getTrxName());
|
||||||
p_order = null;
|
p_order = null;
|
||||||
if (inout.getC_Order_ID() != 0)
|
if (inout.getC_Order_ID() != 0)
|
||||||
p_order = new MOrder (Env.getCtx(), inout.getC_Order_ID(), null);
|
p_order = new MOrder (Env.getCtx(), inout.getC_Order_ID(), getTrxName());
|
||||||
|
|
||||||
m_rma = null;
|
m_rma = null;
|
||||||
if (inout.getM_RMA_ID() != 0)
|
if (inout.getM_RMA_ID() != 0)
|
||||||
m_rma = new MRMA (Env.getCtx(), inout.getM_RMA_ID(), null);
|
m_rma = new MRMA (Env.getCtx(), inout.getM_RMA_ID(), getTrxName());
|
||||||
|
|
||||||
//
|
//
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||||
StringBuilder sql = new StringBuilder("SELECT "); // QtyEntered
|
StringBuilder sql = new StringBuilder("SELECT "); // QtyEntered
|
||||||
|
@ -231,7 +230,7 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
pstmt.setInt(1, M_InOut_ID);
|
pstmt.setInt(1, M_InOut_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
|
@ -270,18 +269,17 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
} // loadShipment
|
} // getShipmentData
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load RMA details
|
* Load RMA line records
|
||||||
* @param M_RMA_ID RMA
|
* @param M_RMA_ID RMA
|
||||||
|
* @return RMA lines (selection,qty,[c_uom_id,uomSymbol/name],[m_product_id,name],null,null,null,[m_rmaline_id,line])
|
||||||
*/
|
*/
|
||||||
protected Vector<Vector<Object>> getRMAData(int M_RMA_ID)
|
protected Vector<Vector<Object>> getRMAData(int M_RMA_ID)
|
||||||
{
|
{
|
||||||
p_order = null;
|
p_order = null;
|
||||||
|
|
||||||
// MRMA m_rma = new MRMA(Env.getCtx(), M_RMA_ID, null);
|
|
||||||
|
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||||
StringBuilder sqlStmt = new StringBuilder();
|
StringBuilder sqlStmt = new StringBuilder();
|
||||||
sqlStmt.append("SELECT rl.M_RMALine_ID, rl.line, rl.Qty - COALESCE(rl.QtyInvoiced, 0), iol.M_Product_ID, p.Name, uom.C_UOM_ID, COALESCE(uom.UOMSymbol,uom.Name) ");
|
sqlStmt.append("SELECT rl.M_RMALine_ID, rl.line, rl.Qty - COALESCE(rl.QtyInvoiced, 0), iol.M_Product_ID, p.Name, uom.C_UOM_ID, COALESCE(uom.UOMSymbol,uom.Name) ");
|
||||||
|
@ -320,7 +318,7 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sqlStmt.toString(), null);
|
pstmt = DB.prepareStatement(sqlStmt.toString(), getTrxName());
|
||||||
pstmt.setInt(1, M_RMA_ID);
|
pstmt.setInt(1, M_RMA_ID);
|
||||||
pstmt.setInt(2, M_RMA_ID);
|
pstmt.setInt(2, M_RMA_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
|
@ -355,18 +353,20 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* List number of rows selected
|
|
||||||
*/
|
|
||||||
public void info(IMiniTable miniTable, IStatusBar statusBar)
|
public void info(IMiniTable miniTable, IStatusBar statusBar)
|
||||||
{
|
{
|
||||||
|
|
||||||
} // infoInvoice
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set class/type of columns
|
||||||
|
* @param miniTable
|
||||||
|
*/
|
||||||
protected void configureMiniTable (IMiniTable miniTable)
|
protected void configureMiniTable (IMiniTable miniTable)
|
||||||
{
|
{
|
||||||
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||||
miniTable.setColumnClass(1, BigDecimal.class, false); // 1-Qty
|
miniTable.setColumnClass(1, BigDecimal.class, false); // 1-Qty
|
||||||
miniTable.setColumnClass(2, String.class, true); // 2-UOM
|
miniTable.setColumnClass(2, String.class, true); // 2-UOM
|
||||||
miniTable.setColumnClass(3, String.class, true); // 3-Product
|
miniTable.setColumnClass(3, String.class, true); // 3-Product
|
||||||
miniTable.setColumnClass(4, String.class, true); // 4-VendorProductNo
|
miniTable.setColumnClass(4, String.class, true); // 4-VendorProductNo
|
||||||
|
@ -381,6 +381,7 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
* Save - Create Invoice Lines
|
* Save - Create Invoice Lines
|
||||||
* @return true if saved
|
* @return true if saved
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean save(IMiniTable miniTable, String trxName)
|
public boolean save(IMiniTable miniTable, String trxName)
|
||||||
{
|
{
|
||||||
// Invoice
|
// Invoice
|
||||||
|
@ -400,18 +401,6 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
invoice.saveEx();
|
invoice.saveEx();
|
||||||
}
|
}
|
||||||
|
|
||||||
// MInOut inout = null;
|
|
||||||
// if (m_M_InOut_ID > 0)
|
|
||||||
// {
|
|
||||||
// inout = new MInOut(Env.getCtx(), m_M_InOut_ID, trxName);
|
|
||||||
// }
|
|
||||||
// if (inout != null && inout.getM_InOut_ID() != 0
|
|
||||||
// && inout.getC_Invoice_ID() == 0) // only first time
|
|
||||||
// {
|
|
||||||
// inout.setC_Invoice_ID(C_Invoice_ID);
|
|
||||||
// inout.saveEx();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Lines
|
// Lines
|
||||||
for (int i = 0; i < miniTable.getRowCount(); i++)
|
for (int i = 0; i < miniTable.getRowCount(); i++)
|
||||||
{
|
{
|
||||||
|
@ -475,7 +464,7 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
//
|
//
|
||||||
MRMALine rmaLine = null;
|
MRMALine rmaLine = null;
|
||||||
if (M_RMALine_ID > 0)
|
if (M_RMALine_ID > 0)
|
||||||
rmaLine = new MRMALine (Env.getCtx(), M_RMALine_ID, null);
|
rmaLine = new MRMALine (Env.getCtx(), M_RMALine_ID, trxName);
|
||||||
//
|
//
|
||||||
MInOutLine inoutLine = null;
|
MInOutLine inoutLine = null;
|
||||||
if (M_InOutLine_ID != 0)
|
if (M_InOutLine_ID != 0)
|
||||||
|
@ -510,17 +499,12 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if (inoutLine == null)
|
|
||||||
// {
|
|
||||||
// inoutLine = lines[0]; // first as default
|
|
||||||
// M_InOutLine_ID = inoutLine.getM_InOutLine_ID();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (M_RMALine_ID != 0)
|
else if (M_RMALine_ID != 0)
|
||||||
{
|
{
|
||||||
String whereClause = "EXISTS (SELECT 1 FROM M_InOut io WHERE io.M_InOut_ID=M_InOutLine.M_InOut_ID AND io.DocStatus IN ('CO','CL'))";
|
String whereClause = "EXISTS (SELECT 1 FROM M_InOut io WHERE io.M_InOut_ID=M_InOutLine.M_InOut_ID AND io.DocStatus IN ('CO','CL'))";
|
||||||
MInOutLine[] lines = MInOutLine.getOfRMALine(Env.getCtx(), M_RMALine_ID, whereClause, null);
|
MInOutLine[] lines = MInOutLine.getOfRMALine(Env.getCtx(), M_RMALine_ID, whereClause, trxName);
|
||||||
if (log.isLoggable(Level.FINE)) log.fine ("Receipt Lines with RMALine = #" + lines.length);
|
if (log.isLoggable(Level.FINE)) log.fine ("Receipt Lines with RMALine = #" + lines.length);
|
||||||
if (lines.length > 0)
|
if (lines.length > 0)
|
||||||
{
|
{
|
||||||
|
@ -559,7 +543,7 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.fine("No Receipt Line");
|
if (log.isLoggable(Level.FINE)) log.fine("No Receipt Line");
|
||||||
// Order Info
|
// Order Info
|
||||||
if (orderLine != null)
|
if (orderLine != null)
|
||||||
{
|
{
|
||||||
|
@ -567,7 +551,7 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log.fine("No Order Line");
|
if (log.isLoggable(Level.FINE)) log.fine("No Order Line");
|
||||||
invoiceLine.setPrice();
|
invoiceLine.setPrice();
|
||||||
invoiceLine.setTax();
|
invoiceLine.setTax();
|
||||||
}
|
}
|
||||||
|
@ -578,7 +562,9 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
invoiceLine.setRMALine(rmaLine); // overwrites
|
invoiceLine.setRMALine(rmaLine); // overwrites
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
log.fine("No RMA Line");
|
{
|
||||||
|
if (log.isLoggable(Level.FINE)) log.fine("No RMA Line");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
invoiceLine.saveEx();
|
invoiceLine.saveEx();
|
||||||
} // if selected
|
} // if selected
|
||||||
|
@ -622,8 +608,12 @@ public abstract class CreateFromInvoice extends CreateFrom
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // saveInvoice
|
} // save
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return column header names (select,quantity,uom,product,vendorProductNo,order,shipment,rma)
|
||||||
|
*/
|
||||||
protected Vector<String> getOISColumnNames()
|
protected Vector<String> getOISColumnNames()
|
||||||
{
|
{
|
||||||
// Header Info
|
// Header Info
|
||||||
|
|
|
@ -35,26 +35,36 @@ import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Create M_PackageLine for M_PackageMPS from shipment lines
|
||||||
* @author Elaine
|
* @author Elaine
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class CreateFromPackageShipment extends CreateFrom
|
public abstract class CreateFromPackageShipment extends CreateFrom
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param gridTab
|
||||||
|
*/
|
||||||
public CreateFromPackageShipment(GridTab gridTab)
|
public CreateFromPackageShipment(GridTab gridTab)
|
||||||
{
|
{
|
||||||
super(gridTab);
|
super(gridTab);
|
||||||
if (log.isLoggable(Level.INFO)) log.info(gridTab.toString());
|
if (log.isLoggable(Level.INFO)) log.info(gridTab.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean dynInit() throws Exception
|
@Override
|
||||||
|
protected boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
log.config("");
|
if (log.isLoggable(Level.CONFIG)) log.config("");
|
||||||
setTitle(Msg.getElement(Env.getCtx(), "M_PackageMPS_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
setTitle(Msg.getElement(Env.getCtx(), "M_PackageMPS_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param M_InOut_ID
|
||||||
|
* @return shipment lines (selection,[m_inoutline_id,line],qty,[m_product_id,name],uom)
|
||||||
|
*/
|
||||||
protected Vector<Vector<Object>> getShipmentData(int M_InOut_ID)
|
protected Vector<Vector<Object>> getShipmentData(int M_InOut_ID)
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config("M_InOut_ID=" + M_InOut_ID);
|
if (log.isLoggable(Level.CONFIG)) log.config("M_InOut_ID=" + M_InOut_ID);
|
||||||
|
@ -69,7 +79,7 @@ public abstract class CreateFromPackageShipment extends CreateFrom
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sqlStmt.toString(), null);
|
pstmt = DB.prepareStatement(sqlStmt.toString(), getTrxName());
|
||||||
pstmt.setInt(1, M_InOut_ID);
|
pstmt.setInt(1, M_InOut_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
|
@ -78,10 +88,9 @@ public abstract class CreateFromPackageShipment extends CreateFrom
|
||||||
line.add(Boolean.FALSE); // 0-Selection
|
line.add(Boolean.FALSE); // 0-Selection
|
||||||
KeyNamePair lineKNPair = new KeyNamePair(rs.getInt(1), rs.getString(2)); // M_InOutLine_ID, Line
|
KeyNamePair lineKNPair = new KeyNamePair(rs.getInt(1), rs.getString(2)); // M_InOutLine_ID, Line
|
||||||
line.add(lineKNPair);
|
line.add(lineKNPair);
|
||||||
line.add(rs.getBigDecimal(3)); //Qty
|
line.add(rs.getBigDecimal(3)); //Qty
|
||||||
KeyNamePair productKNPair = new KeyNamePair(rs.getInt(4), rs.getString(5)); // ProductID, Product Name
|
KeyNamePair productKNPair = new KeyNamePair(rs.getInt(4), rs.getString(5)); // ProductID, Product Name
|
||||||
line.add(productKNPair); //Product
|
line.add(productKNPair); //Product
|
||||||
//line.add(rs.getString(5));
|
|
||||||
line.add(rs.getString(6)); //UOM
|
line.add(rs.getString(6)); //UOM
|
||||||
|
|
||||||
data.add(line);
|
data.add(line);
|
||||||
|
@ -101,11 +110,16 @@ public abstract class CreateFromPackageShipment extends CreateFrom
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void info(IMiniTable miniTable, IStatusBar statusBar)
|
public void info(IMiniTable miniTable, IStatusBar statusBar)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set class/type of columns
|
||||||
|
* @param miniTable
|
||||||
|
*/
|
||||||
protected void configureMiniTable (IMiniTable miniTable)
|
protected void configureMiniTable (IMiniTable miniTable)
|
||||||
{
|
{
|
||||||
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||||
|
@ -117,13 +131,17 @@ public abstract class CreateFromPackageShipment extends CreateFrom
|
||||||
miniTable.autoSize();
|
miniTable.autoSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create M_PackageLine
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public boolean save(IMiniTable miniTable, String trxName)
|
public boolean save(IMiniTable miniTable, String trxName)
|
||||||
{
|
{
|
||||||
int M_PackageMPS_ID = (Integer) getGridTab().getValue(MPackageMPS.COLUMNNAME_M_PackageMPS_ID);
|
int M_PackageMPS_ID = (Integer) getGridTab().getValue(MPackageMPS.COLUMNNAME_M_PackageMPS_ID);
|
||||||
MPackageMPS packageMPS = new MPackageMPS(Env.getCtx(), M_PackageMPS_ID, null);
|
MPackageMPS packageMPS = new MPackageMPS(Env.getCtx(), M_PackageMPS_ID, trxName);
|
||||||
|
|
||||||
MPackage mPackage = new MPackage(Env.getCtx(), packageMPS.getM_Package_ID(), null);
|
MPackage mPackage = new MPackage(Env.getCtx(), packageMPS.getM_Package_ID(), trxName);
|
||||||
MInOut shipment = new MInOut(Env.getCtx(), mPackage.getM_InOut_ID(), null);
|
MInOut shipment = new MInOut(Env.getCtx(), mPackage.getM_InOut_ID(), trxName);
|
||||||
MInOutLine[] shipmentLines = shipment.getLines(false);
|
MInOutLine[] shipmentLines = shipment.getLines(false);
|
||||||
|
|
||||||
HashMap<Integer, MInOutLine> lineMap = new HashMap<Integer, MInOutLine>();
|
HashMap<Integer, MInOutLine> lineMap = new HashMap<Integer, MInOutLine>();
|
||||||
|
@ -148,18 +166,18 @@ public abstract class CreateFromPackageShipment extends CreateFrom
|
||||||
packageLine.setInOutLine((MInOutLine)lineMap.get(inOutLineId));
|
packageLine.setInOutLine((MInOutLine)lineMap.get(inOutLineId));
|
||||||
packageLine.setM_Product_ID(productId);
|
packageLine.setM_Product_ID(productId);
|
||||||
packageLine.setQty(qty);
|
packageLine.setQty(qty);
|
||||||
packageLine.setM_PackageMPS_ID(M_PackageMPS_ID);
|
packageLine.setM_PackageMPS_ID(M_PackageMPS_ID);
|
||||||
|
packageLine.saveEx(mPackage.get_TrxName());
|
||||||
if (!packageLine.save(mPackage.get_TrxName()))
|
|
||||||
{
|
|
||||||
throw new IllegalStateException("Could not create Package Line");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return column header names (select,line,quantity,product,uom)
|
||||||
|
*/
|
||||||
protected Vector<String> getOISColumnNames()
|
protected Vector<String> getOISColumnNames()
|
||||||
{
|
{
|
||||||
Vector<String> columnNames = new Vector<String>(5);
|
Vector<String> columnNames = new Vector<String>(5);
|
||||||
|
|
|
@ -31,13 +31,17 @@ import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Transactions for RMA
|
* Create M_RMALine for M_RMA from shipment lines
|
||||||
* @author ashley
|
* @author ashley
|
||||||
* @author Teo Sarca, www.arhipac.ro
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
* <li>BF [ 2007837 ] VCreateFrom.save() should run in trx
|
* <li>BF [ 2007837 ] VCreateFrom.save() should run in trx
|
||||||
*/
|
*/
|
||||||
public abstract class CreateFromRMA extends CreateFrom {
|
public abstract class CreateFromRMA extends CreateFrom {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param mTab
|
||||||
|
*/
|
||||||
public CreateFromRMA(GridTab mTab)
|
public CreateFromRMA(GridTab mTab)
|
||||||
{
|
{
|
||||||
super(mTab);
|
super(mTab);
|
||||||
|
@ -45,7 +49,7 @@ public abstract class CreateFromRMA extends CreateFrom {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dynInit() throws Exception
|
protected boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
setTitle(Msg.getElement(Env.getCtx(), "M_RMA_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
setTitle(Msg.getElement(Env.getCtx(), "M_RMA_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||||
|
@ -53,6 +57,10 @@ public abstract class CreateFromRMA extends CreateFrom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get shipment lines
|
||||||
|
* @return shipment lines (selection,[m_inoutline_id,line],productName,serialNo,qtyEntered,movementQty,lineDescription)
|
||||||
|
*/
|
||||||
protected Vector<Vector<Object>> getRMAData()
|
protected Vector<Vector<Object>> getRMAData()
|
||||||
{
|
{
|
||||||
int M_InOut_ID = Env.getContextAsInt(Env.getCtx(), getGridTab().getWindowNo(), "InOut_ID");
|
int M_InOut_ID = Env.getContextAsInt(Env.getCtx(), getGridTab().getWindowNo(), "InOut_ID");
|
||||||
|
@ -62,18 +70,19 @@ public abstract class CreateFromRMA extends CreateFrom {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1 M_InOutLine_ID
|
* 1 M_InOutLine_ID
|
||||||
* 2 Line
|
* 2 Line No
|
||||||
* 3 Product Name
|
* 3 Product Name
|
||||||
* 4 Qty Entered
|
* 4 Qty Entered
|
||||||
* 5 Movement Qty
|
* 5 Movement Qty
|
||||||
* 6 ASI
|
* 6 ASI
|
||||||
|
* 7 Line Description
|
||||||
*/
|
*/
|
||||||
StringBuilder sqlStmt = new StringBuilder();
|
StringBuilder sqlStmt = new StringBuilder();
|
||||||
|
|
||||||
sqlStmt.append("SELECT iol.M_InOutLine_ID, iol.Line, ");
|
sqlStmt.append("SELECT iol.M_InOutLine_ID, iol.Line, ");
|
||||||
sqlStmt.append("COALESCE(p.Name, c.Name) AS ProductName, ");
|
sqlStmt.append("COALESCE(p.Name, c.Name) AS ProductName, ");
|
||||||
sqlStmt.append("iol.QtyEntered, ");
|
sqlStmt.append("iol.QtyEntered, ");
|
||||||
sqlStmt.append("iol.movementQty-(SELECT COALESCE((SELECT SUM(rmal.qty) FROM M_RMALine rmal JOIN M_RMA rma ON rma.M_RMA_ID=rmal.M_RMA_ID WHERE rmal.M_InOutLine_ID=iol.M_InOutLine_ID AND rma.DocStatus IN ('CO','CL')),0)) AS MovementQty, ");
|
sqlStmt.append("iol.movementQty-(COALESCE((SELECT SUM(rmal.qty) FROM M_RMALine rmal JOIN M_RMA rma ON rma.M_RMA_ID=rmal.M_RMA_ID WHERE rmal.M_InOutLine_ID=iol.M_InOutLine_ID AND rma.DocStatus IN ('CO','CL')),0)) AS MovementQty, ");
|
||||||
sqlStmt.append("CASE WHEN iol.M_AttributeSetInstance_ID IS NOT NULL THEN (SELECT SerNo FROM M_AttributeSetInstance asi WHERE asi.M_AttributeSetInstance_ID=iol.M_AttributeSetInstance_ID) END as ASI, ");
|
sqlStmt.append("CASE WHEN iol.M_AttributeSetInstance_ID IS NOT NULL THEN (SELECT SerNo FROM M_AttributeSetInstance asi WHERE asi.M_AttributeSetInstance_ID=iol.M_AttributeSetInstance_ID) END as ASI, ");
|
||||||
sqlStmt.append("iol.Description " );
|
sqlStmt.append("iol.Description " );
|
||||||
sqlStmt.append("FROM M_InOutLine iol ");
|
sqlStmt.append("FROM M_InOutLine iol ");
|
||||||
|
@ -87,7 +96,7 @@ public abstract class CreateFromRMA extends CreateFrom {
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sqlStmt.toString(), null);
|
pstmt = DB.prepareStatement(sqlStmt.toString(), getTrxName());
|
||||||
pstmt.setInt(1, M_InOut_ID);
|
pstmt.setInt(1, M_InOut_ID);
|
||||||
pstmt.setInt(2, M_RMA_ID);
|
pstmt.setInt(2, M_RMA_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
|
@ -131,6 +140,10 @@ public abstract class CreateFromRMA extends CreateFrom {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set class/type of columns
|
||||||
|
* @param miniTable
|
||||||
|
*/
|
||||||
protected void configureMiniTable (IMiniTable miniTable)
|
protected void configureMiniTable (IMiniTable miniTable)
|
||||||
{
|
{
|
||||||
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||||
|
@ -145,23 +158,23 @@ public abstract class CreateFromRMA extends CreateFrom {
|
||||||
miniTable.autoSize();
|
miniTable.autoSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create M_RMALine
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean save(IMiniTable miniTable, String trxName)
|
public boolean save(IMiniTable miniTable, String trxName)
|
||||||
{
|
{
|
||||||
log.config("");
|
if (log.isLoggable(Level.CONFIG)) log.config("");
|
||||||
int M_RMA_ID = Env.getContextAsInt(Env.getCtx(), getGridTab().getWindowNo(), "M_RMA_ID");
|
int M_RMA_ID = Env.getContextAsInt(Env.getCtx(), getGridTab().getWindowNo(), "M_RMA_ID");
|
||||||
|
|
||||||
// Integer bpId = (Integer)bPartnerField.getValue();
|
|
||||||
MRMA rma = new MRMA(Env.getCtx(), M_RMA_ID, trxName);
|
MRMA rma = new MRMA(Env.getCtx(), M_RMA_ID, trxName);
|
||||||
//update BP
|
|
||||||
// rma.setC_BPartner_ID(bpId);
|
|
||||||
|
|
||||||
for (int i = 0; i < miniTable.getRowCount(); i++)
|
for (int i = 0; i < miniTable.getRowCount(); i++)
|
||||||
{
|
{
|
||||||
if (((Boolean)miniTable.getValueAt(i, 0)).booleanValue())
|
if (((Boolean)miniTable.getValueAt(i, 0)).booleanValue())
|
||||||
{
|
{
|
||||||
BigDecimal d = (BigDecimal)miniTable.getValueAt(i, 5); // 5-Movement Qty
|
BigDecimal d = (BigDecimal)miniTable.getValueAt(i, 5); // 5-Movement Qty
|
||||||
KeyNamePair pp = (KeyNamePair)miniTable.getValueAt(i, 1); // 1-Line
|
KeyNamePair pp = (KeyNamePair)miniTable.getValueAt(i, 1); // 1-Line (M_InOutLine_ID, Line)
|
||||||
|
|
||||||
int inOutLineId = pp.getKey();
|
int inOutLineId = pp.getKey();
|
||||||
|
|
||||||
|
@ -171,16 +184,17 @@ public abstract class CreateFromRMA extends CreateFrom {
|
||||||
rmaLine.setQty(d);
|
rmaLine.setQty(d);
|
||||||
rmaLine.setAD_Org_ID(rma.getAD_Org_ID());
|
rmaLine.setAD_Org_ID(rma.getAD_Org_ID());
|
||||||
rmaLine.setDescription((String)miniTable.getValueAt(i, 6));
|
rmaLine.setDescription((String)miniTable.getValueAt(i, 6));
|
||||||
if (!rmaLine.save())
|
rmaLine.saveEx();
|
||||||
{
|
|
||||||
throw new IllegalStateException("Could not create RMA Line");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rma.saveEx();
|
rma.saveEx();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return column header names (select,line,product,serialNo,quantity,qtyDelivered,description)
|
||||||
|
*/
|
||||||
protected Vector<String> getOISColumnNames()
|
protected Vector<String> getOISColumnNames()
|
||||||
{
|
{
|
||||||
// Header Info
|
// Header Info
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Invoice Transactions from PO Orders or Receipt
|
* Create M_InOutLine for M_InOut from Purchase Orders, Vendor Invoice or Customer RMA
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: VCreateFromShipment.java,v 1.4 2006/07/30 00:51:28 jjanke Exp $
|
* @version $Id: VCreateFromShipment.java,v 1.4 2006/07/30 00:51:28 jjanke Exp $
|
||||||
|
@ -62,22 +62,19 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
private int defaultLocator_ID=0;
|
private int defaultLocator_ID=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protected Constructor
|
* Constructor
|
||||||
* @param mTab MTab
|
* @param mTab MTab
|
||||||
*/
|
*/
|
||||||
public CreateFromShipment(GridTab mTab)
|
public CreateFromShipment(GridTab mTab)
|
||||||
{
|
{
|
||||||
super(mTab);
|
super(mTab);
|
||||||
if (log.isLoggable(Level.INFO)) log.info(mTab.toString());
|
if (log.isLoggable(Level.INFO)) log.info(mTab.toString());
|
||||||
} // VCreateFromShipment
|
} // CreateFromShipment
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Dynamic Init
|
protected boolean dynInit() throws Exception
|
||||||
* @return true if initialized
|
|
||||||
*/
|
|
||||||
public boolean dynInit() throws Exception
|
|
||||||
{
|
{
|
||||||
log.config("");
|
if (log.isLoggable(Level.CONFIG)) log.config("");
|
||||||
setTitle(Msg.getElement(Env.getCtx(), "M_InOut_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
setTitle(Msg.getElement(Env.getCtx(), "M_InOut_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -85,8 +82,9 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load PBartner dependent Order/Invoice/Shipment Field.
|
* Load BPartner related RMA records.
|
||||||
* @param C_BPartner_ID BPartner
|
* @param C_BPartner_ID BPartner
|
||||||
|
* @return list of RMA records
|
||||||
*/
|
*/
|
||||||
protected ArrayList<KeyNamePair> loadRMAData(int C_BPartner_ID) {
|
protected ArrayList<KeyNamePair> loadRMAData(int C_BPartner_ID) {
|
||||||
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
|
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
|
||||||
|
@ -101,7 +99,7 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
pstmt = DB.prepareStatement(sqlStmt, null);
|
pstmt = DB.prepareStatement(sqlStmt, getTrxName());
|
||||||
pstmt.setInt(1, C_BPartner_ID);
|
pstmt.setInt(1, C_BPartner_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
@ -119,8 +117,9 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load PBartner dependent Order/Invoice/Shipment Field.
|
* Load BPartner related Invoices
|
||||||
* @param C_BPartner_ID
|
* @param C_BPartner_ID
|
||||||
|
* @return list of invoice records
|
||||||
*/
|
*/
|
||||||
protected ArrayList<KeyNamePair> loadInvoiceData (int C_BPartner_ID)
|
protected ArrayList<KeyNamePair> loadInvoiceData (int C_BPartner_ID)
|
||||||
{
|
{
|
||||||
|
@ -148,7 +147,7 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
pstmt.setInt(1, C_BPartner_ID);
|
pstmt.setInt(1, C_BPartner_ID);
|
||||||
pstmt.setInt(2, C_BPartner_ID);
|
pstmt.setInt(2, C_BPartner_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
|
@ -160,7 +159,8 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql.toString(), e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}finally
|
}
|
||||||
|
finally
|
||||||
{
|
{
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
rs = null;
|
rs = null;
|
||||||
|
@ -171,9 +171,10 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Data - Order
|
* Load Order Lines
|
||||||
* @param C_Order_ID Order
|
* @param C_Order_ID Order
|
||||||
* @param forInvoice true if for invoice vs. delivery qty
|
* @param forInvoice true if for invoice vs. delivery qty
|
||||||
|
* @return Order lines (selection,qty,[c_uom_id,uomSymbol/name],[m_locator_id,value][m_product_id,name],vendorProductNo,[c_orderline_id,line],null,null)
|
||||||
*/
|
*/
|
||||||
protected Vector<Vector<Object>> getOrderData (int C_Order_ID, boolean forInvoice)
|
protected Vector<Vector<Object>> getOrderData (int C_Order_ID, boolean forInvoice)
|
||||||
{
|
{
|
||||||
|
@ -189,14 +190,14 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
* InvoiceLine - 8
|
* InvoiceLine - 8
|
||||||
*/
|
*/
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config("C_Order_ID=" + C_Order_ID);
|
if (log.isLoggable(Level.CONFIG)) log.config("C_Order_ID=" + C_Order_ID);
|
||||||
p_order = new MOrder (Env.getCtx(), C_Order_ID, null); // save
|
p_order = new MOrder (Env.getCtx(), C_Order_ID, getTrxName()); // save
|
||||||
|
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||||
StringBuilder sql = new StringBuilder("SELECT "
|
StringBuilder sql = new StringBuilder("SELECT "
|
||||||
+ "l.QtyOrdered-SUM(COALESCE(m.Qty,0))"
|
|
||||||
// subtract drafted lines from this or other orders IDEMPIERE-2889
|
// subtract drafted lines from this or other orders IDEMPIERE-2889
|
||||||
+ "-COALESCE((SELECT SUM(MovementQty) FROM M_InOutLine iol JOIN M_InOut io ON iol.M_InOut_ID=io.M_InOut_ID WHERE l.C_OrderLine_ID=iol.C_OrderLine_ID AND io.Processed='N'),0)," // 1
|
+ "l.QtyOrdered-SUM(COALESCE(m.Qty,0))" // 1
|
||||||
+ "CASE WHEN l.QtyOrdered=0 THEN 0 ELSE l.QtyEntered/l.QtyOrdered END," // 2
|
+ "-COALESCE((SELECT SUM(MovementQty) FROM M_InOutLine iol JOIN M_InOut io ON iol.M_InOut_ID=io.M_InOut_ID WHERE l.C_OrderLine_ID=iol.C_OrderLine_ID AND io.Processed='N'),0),"
|
||||||
|
+ " CASE WHEN l.QtyOrdered=0 THEN 0 ELSE l.QtyEntered/l.QtyOrdered END," // 2
|
||||||
+ " l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name)," // 3..4
|
+ " l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name)," // 3..4
|
||||||
+ " p.M_Locator_ID, loc.Value, " // 5..6
|
+ " p.M_Locator_ID, loc.Value, " // 5..6
|
||||||
+ " COALESCE(l.M_Product_ID,0),COALESCE(p.Name,c.Name), " // 7..8
|
+ " COALESCE(l.M_Product_ID,0),COALESCE(p.Name,c.Name), " // 7..8
|
||||||
|
@ -227,7 +228,7 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
pstmt.setInt(1, C_Order_ID);
|
pstmt.setInt(1, C_Order_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
|
@ -241,11 +242,11 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(4).trim());
|
KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(4).trim());
|
||||||
line.add(pp); // 2-UOM
|
line.add(pp); // 2-UOM
|
||||||
// Add locator
|
// Add locator
|
||||||
line.add(getLocatorKeyNamePair(rs.getInt(5)));// 3-Locator
|
line.add(getLocatorKeyNamePair(rs.getInt(5))); // 3-Locator
|
||||||
// Add product
|
// Add product
|
||||||
pp = new KeyNamePair(rs.getInt(7), rs.getString(8));
|
pp = new KeyNamePair(rs.getInt(7), rs.getString(8));
|
||||||
line.add(pp); // 4-Product
|
line.add(pp); // 4-Product
|
||||||
line.add(rs.getString(9)); // 5-VendorProductNo
|
line.add(rs.getString(9)); // 5-VendorProductNo
|
||||||
pp = new KeyNamePair(rs.getInt(10), rs.getString(11));
|
pp = new KeyNamePair(rs.getInt(10), rs.getString(11));
|
||||||
line.add(pp); // 6-OrderLine
|
line.add(pp); // 6-OrderLine
|
||||||
line.add(null); // 7-Ship
|
line.add(null); // 7-Ship
|
||||||
|
@ -256,7 +257,6 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql.toString(), e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
//throw new DBException(e, sql.toString());
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -267,14 +267,15 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
} // LoadOrder
|
} // LoadOrder
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load RMA details
|
* Load RMA lines
|
||||||
* @param M_RMA_ID RMA
|
* @param M_RMA_ID RMA
|
||||||
|
* @return RMA lines (selection,qty,[c_uom_id,uomSymbol/name],[m_locator_id,value],[m_product_id,name],null,null,[m_rmaline_id,line],null)
|
||||||
*/
|
*/
|
||||||
protected Vector<Vector<Object>> getRMAData(int M_RMA_ID)
|
protected Vector<Vector<Object>> getRMAData(int M_RMA_ID)
|
||||||
{
|
{
|
||||||
m_invoice = null;
|
m_invoice = null;
|
||||||
p_order = null;
|
p_order = null;
|
||||||
m_rma = new MRMA(Env.getCtx(), M_RMA_ID, null);
|
m_rma = new MRMA(Env.getCtx(), M_RMA_ID, getTrxName());
|
||||||
|
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||||
StringBuilder sqlStmt = new StringBuilder();
|
StringBuilder sqlStmt = new StringBuilder();
|
||||||
|
@ -332,7 +333,7 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sqlStmt.toString(), null);
|
pstmt = DB.prepareStatement(sqlStmt.toString(), getTrxName());
|
||||||
pstmt.setInt(1, M_RMA_ID);
|
pstmt.setInt(1, M_RMA_ID);
|
||||||
pstmt.setInt(2, M_RMA_ID);
|
pstmt.setInt(2, M_RMA_ID);
|
||||||
pstmt.setInt(3, M_RMA_ID);
|
pstmt.setInt(3, M_RMA_ID);
|
||||||
|
@ -370,12 +371,13 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Invoice details
|
* Load Invoice lines
|
||||||
* @param C_Invoice_ID Invoice
|
* @param C_Invoice_ID Invoice
|
||||||
|
* @return Invoice lines (selection,qty,[c_uom_id,uomSymbol/name],[m_locator_id,value],[m_product_id,name],vendorProductNo,[c_orderline_id,.],null,[c_invoiceline_id,line])
|
||||||
*/
|
*/
|
||||||
protected Vector<Vector<Object>> getInvoiceData(int C_Invoice_ID)
|
protected Vector<Vector<Object>> getInvoiceData(int C_Invoice_ID)
|
||||||
{
|
{
|
||||||
m_invoice = new MInvoice(Env.getCtx(), C_Invoice_ID, null); // save
|
m_invoice = new MInvoice(Env.getCtx(), C_Invoice_ID, getTrxName()); // save
|
||||||
p_order = null;
|
p_order = null;
|
||||||
m_rma = null;
|
m_rma = null;
|
||||||
|
|
||||||
|
@ -409,7 +411,7 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
pstmt.setInt(1, C_Invoice_ID);
|
pstmt.setInt(1, C_Invoice_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
|
@ -441,7 +443,6 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql.toString(), e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
//throw new DBException(e, sql);
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -456,7 +457,7 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
* If no locator specified or the specified locator is not valid (e.g. warehouse not match),
|
* If no locator specified or the specified locator is not valid (e.g. warehouse not match),
|
||||||
* a default one will be used.
|
* a default one will be used.
|
||||||
* @param M_Locator_ID
|
* @param M_Locator_ID
|
||||||
* @return KeyNamePair
|
* @return KeyNamePair (m_locator_id,value)
|
||||||
*/
|
*/
|
||||||
protected KeyNamePair getLocatorKeyNamePair(int M_Locator_ID)
|
protected KeyNamePair getLocatorKeyNamePair(int M_Locator_ID)
|
||||||
{
|
{
|
||||||
|
@ -504,14 +505,16 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
return pp;
|
return pp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* List number of rows selected
|
|
||||||
*/
|
|
||||||
public void info(IMiniTable miniTable, IStatusBar statusBar)
|
public void info(IMiniTable miniTable, IStatusBar statusBar)
|
||||||
{
|
{
|
||||||
|
|
||||||
} // infoInvoice
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set class/type of columns
|
||||||
|
* @param miniTable
|
||||||
|
*/
|
||||||
protected void configureMiniTable (IMiniTable miniTable)
|
protected void configureMiniTable (IMiniTable miniTable)
|
||||||
{
|
{
|
||||||
miniTable.setColumnClass(0, Boolean.class, false); // Selection
|
miniTable.setColumnClass(0, Boolean.class, false); // Selection
|
||||||
|
@ -525,30 +528,16 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
miniTable.setColumnClass(8, String.class, true); // Invoice
|
miniTable.setColumnClass(8, String.class, true); // Invoice
|
||||||
|
|
||||||
// Table UI
|
// Table UI
|
||||||
miniTable.autoSize();
|
miniTable.autoSize();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save - Create Invoice Lines
|
* Create M_InOutLine
|
||||||
* @return true if saved
|
* @return true if saved
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean save(IMiniTable miniTable, String trxName)
|
public boolean save(IMiniTable miniTable, String trxName)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
dataTable.stopEditor(true);
|
|
||||||
log.config("");
|
|
||||||
TableModel model = dataTable.getModel();
|
|
||||||
int rows = model.getRowCount();
|
|
||||||
if (rows == 0)
|
|
||||||
return false;
|
|
||||||
//
|
|
||||||
Integer defaultLoc = (Integer) locatorField.getValue();
|
|
||||||
if (defaultLoc == null || defaultLoc.intValue() == 0) {
|
|
||||||
locatorField.setBackground(AdempierePLAF.getFieldBackground_Error());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
int M_Locator_ID = defaultLocator_ID;
|
int M_Locator_ID = defaultLocator_ID;
|
||||||
if (M_Locator_ID == 0) {
|
if (M_Locator_ID == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -588,7 +577,6 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
C_InvoiceLine_ID = pp.getKey();
|
C_InvoiceLine_ID = pp.getKey();
|
||||||
if (C_InvoiceLine_ID != 0)
|
if (C_InvoiceLine_ID != 0)
|
||||||
il = new MInvoiceLine (Env.getCtx(), C_InvoiceLine_ID, trxName);
|
il = new MInvoiceLine (Env.getCtx(), C_InvoiceLine_ID, trxName);
|
||||||
//boolean isInvoiced = (C_InvoiceLine_ID != 0);
|
|
||||||
// Precision of Qty UOM
|
// Precision of Qty UOM
|
||||||
int precision = 2;
|
int precision = 2;
|
||||||
if (M_Product_ID != 0)
|
if (M_Product_ID != 0)
|
||||||
|
@ -753,6 +741,10 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
|
|
||||||
} // saveInvoice
|
} // saveInvoice
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return column header names (select,quantity,uom,locator,product,vendorProductNo,order,rma,invoice)
|
||||||
|
*/
|
||||||
protected Vector<String> getOISColumnNames()
|
protected Vector<String> getOISColumnNames()
|
||||||
{
|
{
|
||||||
// Header Info
|
// Header Info
|
||||||
|
@ -770,18 +762,37 @@ public abstract class CreateFromShipment extends CreateFrom
|
||||||
return columnNames;
|
return columnNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load order lines
|
||||||
|
* @param C_Order_ID
|
||||||
|
* @param forInvoice
|
||||||
|
* @param M_Locator_ID
|
||||||
|
* @return order lines
|
||||||
|
*/
|
||||||
protected Vector<Vector<Object>> getOrderData (int C_Order_ID, boolean forInvoice, int M_Locator_ID)
|
protected Vector<Vector<Object>> getOrderData (int C_Order_ID, boolean forInvoice, int M_Locator_ID)
|
||||||
{
|
{
|
||||||
defaultLocator_ID = M_Locator_ID;
|
defaultLocator_ID = M_Locator_ID;
|
||||||
return getOrderData (C_Order_ID, forInvoice);
|
return getOrderData (C_Order_ID, forInvoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param M_RMA_ID
|
||||||
|
* @param M_Locator_ID
|
||||||
|
* @return RMA lines
|
||||||
|
*/
|
||||||
protected Vector<Vector<Object>> getRMAData (int M_RMA_ID, int M_Locator_ID)
|
protected Vector<Vector<Object>> getRMAData (int M_RMA_ID, int M_Locator_ID)
|
||||||
{
|
{
|
||||||
defaultLocator_ID = M_Locator_ID;
|
defaultLocator_ID = M_Locator_ID;
|
||||||
return getRMAData (M_RMA_ID);
|
return getRMAData (M_RMA_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param C_Invoice_ID
|
||||||
|
* @param M_Locator_ID
|
||||||
|
* @return Invoice lines
|
||||||
|
*/
|
||||||
protected Vector<Vector<Object>> getInvoiceData (int C_Invoice_ID, int M_Locator_ID)
|
protected Vector<Vector<Object>> getInvoiceData (int C_Invoice_ID, int M_Locator_ID)
|
||||||
{
|
{
|
||||||
defaultLocator_ID = M_Locator_ID;
|
defaultLocator_ID = M_Locator_ID;
|
||||||
|
|
|
@ -32,19 +32,24 @@ import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Create C_BankStatementLine for C_BankStatement
|
||||||
* @author Elaine
|
* @author Elaine
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class CreateFromStatement extends CreateFromBatch
|
public abstract class CreateFromStatement extends CreateFromBatch
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param mTab
|
||||||
|
*/
|
||||||
public CreateFromStatement(GridTab mTab)
|
public CreateFromStatement(GridTab mTab)
|
||||||
{
|
{
|
||||||
super(mTab);
|
super(mTab);
|
||||||
if (log.isLoggable(Level.INFO)) log.info(mTab.toString());
|
if (log.isLoggable(Level.INFO)) log.info(mTab.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean dynInit() throws Exception
|
@Override
|
||||||
|
protected boolean dynInit() throws Exception
|
||||||
{
|
{
|
||||||
log.config("");
|
log.config("");
|
||||||
setTitle(Msg.getElement(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
setTitle(Msg.getElement(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||||
|
@ -52,8 +57,12 @@ public abstract class CreateFromStatement extends CreateFromBatch
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Vector<Vector<Object>> getBankAccountData(Object BankAccount, Object BPartner, String DocumentNo,
|
/**
|
||||||
Object DateFrom, Object DateTo, Object AmtFrom, Object AmtTo, Object DocType, Object TenderType, String AuthCode)
|
* @return transactions (selection,dateTrx,[c_payment_id,documentNo],[c_currency_id,iso_code],payamt,convertedAmt,bpName)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Vector<Vector<Object>> getBankAccountData(Integer BankAccount, Integer BPartner, String DocumentNo,
|
||||||
|
Timestamp DateFrom, Timestamp DateTo, BigDecimal AmtFrom, BigDecimal AmtTo, Integer DocType, String TenderType, String AuthCode)
|
||||||
{
|
{
|
||||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||||
|
|
||||||
|
@ -71,7 +80,7 @@ public abstract class CreateFromStatement extends CreateFromBatch
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
|
||||||
setParameters(pstmt, BankAccount, BPartner, DocumentNo, DateFrom, DateTo, AmtFrom, AmtTo, DocType, TenderType, AuthCode);
|
setParameters(pstmt, BankAccount, BPartner, DocumentNo, DateFrom, DateTo, AmtFrom, AmtTo, DocType, TenderType, AuthCode);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while(rs.next())
|
while(rs.next())
|
||||||
|
@ -102,6 +111,10 @@ public abstract class CreateFromStatement extends CreateFromBatch
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set class/type of columns
|
||||||
|
* @param miniTable
|
||||||
|
*/
|
||||||
protected void configureMiniTable(IMiniTable miniTable)
|
protected void configureMiniTable(IMiniTable miniTable)
|
||||||
{
|
{
|
||||||
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
miniTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||||
|
@ -115,6 +128,10 @@ public abstract class CreateFromStatement extends CreateFromBatch
|
||||||
miniTable.autoSize();
|
miniTable.autoSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create C_BankStatementLine
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public boolean save(IMiniTable miniTable, String trxName)
|
public boolean save(IMiniTable miniTable, String trxName)
|
||||||
{
|
{
|
||||||
// fixed values
|
// fixed values
|
||||||
|
@ -152,6 +169,10 @@ public abstract class CreateFromStatement extends CreateFromBatch
|
||||||
return true;
|
return true;
|
||||||
} // save
|
} // save
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return column header names (select,date,payment,currency,amount,convertedAmount,bpartner)
|
||||||
|
*/
|
||||||
protected Vector<String> getOISColumnNames()
|
protected Vector<String> getOISColumnNames()
|
||||||
{
|
{
|
||||||
// Header Info
|
// Header Info
|
||||||
|
|
|
@ -13,13 +13,32 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.grid;
|
package org.compiere.grid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface ICreateFrom
|
public interface ICreateFrom
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return true if initialization success
|
||||||
|
*/
|
||||||
public boolean isInitOK();
|
public boolean isInitOK();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show dialog
|
||||||
|
*/
|
||||||
public void showWindow();
|
public void showWindow();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* close dialog
|
||||||
|
*/
|
||||||
public void closeWindow();
|
public void closeWindow();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return dialog object
|
||||||
|
*/
|
||||||
public Object getWindow();
|
public Object getWindow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,11 @@ import org.compiere.model.GridTab;
|
||||||
*/
|
*/
|
||||||
public interface ICreateFromFactory {
|
public interface ICreateFromFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new ICreateFrom instance
|
||||||
|
* @param mTab
|
||||||
|
* @return {@link ICreateFrom}
|
||||||
|
*/
|
||||||
public ICreateFrom create(GridTab mTab);
|
public ICreateFrom create(GridTab mTab);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -429,6 +429,18 @@ public final class DictionaryIDs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum M_Shipper {
|
||||||
|
UPS(100),
|
||||||
|
FERTILIZER_INTERNAL_SHIPPER(50001),
|
||||||
|
FURNITURE_INTERNAL_SHIPPER(50002);
|
||||||
|
|
||||||
|
public final int id;
|
||||||
|
|
||||||
|
private M_Shipper(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public enum M_Warehouse {
|
public enum M_Warehouse {
|
||||||
HQ(103),
|
HQ(103),
|
||||||
STORE_CENTRAL(104),
|
STORE_CENTRAL(104),
|
||||||
|
|
|
@ -0,0 +1,180 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* This file is part of iDempiere ERP Open Source *
|
||||||
|
* http://www.idempiere.org *
|
||||||
|
* *
|
||||||
|
* Copyright (C) Contributors *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||||
|
* MA 02110-1301, USA. *
|
||||||
|
* *
|
||||||
|
* Contributors: *
|
||||||
|
* - hengsin *
|
||||||
|
**********************************************************************/
|
||||||
|
package org.idempiere.test.form;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.compiere.grid.CreateFromDepositBatch;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.GridWindow;
|
||||||
|
import org.compiere.model.MDepositBatch;
|
||||||
|
import org.compiere.model.MDepositBatchLine;
|
||||||
|
import org.compiere.model.MPayment;
|
||||||
|
import org.compiere.model.MQuery;
|
||||||
|
import org.compiere.model.SystemIDs;
|
||||||
|
import org.compiere.process.DocAction;
|
||||||
|
import org.compiere.process.ProcessInfo;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
|
import org.compiere.util.TimeUtil;
|
||||||
|
import org.compiere.wf.MWorkflow;
|
||||||
|
import org.idempiere.test.AbstractTestCase;
|
||||||
|
import org.idempiere.test.DictionaryIDs;
|
||||||
|
import org.idempiere.test.ui.MiniTableImpl;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CreateFromDepositBatchFormTest extends AbstractTestCase {
|
||||||
|
|
||||||
|
public CreateFromDepositBatchFormTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateFromDepositBatch() {
|
||||||
|
MPayment payment = new MPayment(Env.getCtx(), 0, getTrxName());
|
||||||
|
payment.setC_DocType_ID(true);
|
||||||
|
payment.setC_BPartner_ID(DictionaryIDs.C_BPartner.JOE_BLOCK.id);
|
||||||
|
payment.setTenderType(MPayment.TENDERTYPE_DirectDebit);
|
||||||
|
int C_BankAccount_ID = DB.getSQLValueEx(getTrxName(), "SELECT C_BankAccount_ID FROM C_BankAccount WHERE IsActive='Y' AND AD_Client_ID=? "
|
||||||
|
+ "AND IsDefault='Y' ORDER BY C_BankAccount_ID", getAD_Client_ID());
|
||||||
|
payment.setC_BankAccount_ID(C_BankAccount_ID);
|
||||||
|
payment.setC_Currency_ID(Env.getContextAsInt(Env.getCtx(), Env.C_CURRENCY_ID));
|
||||||
|
payment.setPayAmt(new BigDecimal("10.00"));
|
||||||
|
payment.saveEx();
|
||||||
|
|
||||||
|
ProcessInfo pi = MWorkflow.runDocumentActionWorkflow(payment, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(pi.isError(), pi.getSummary());
|
||||||
|
|
||||||
|
payment.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, payment.getDocStatus(), "Unexpected document status");
|
||||||
|
|
||||||
|
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
|
||||||
|
MDepositBatch batch = new MDepositBatch(Env.getCtx(), 0, getTrxName());
|
||||||
|
batch.setC_BankAccount_ID(C_BankAccount_ID);
|
||||||
|
batch.setC_DocType_ID(payment.getC_DocType_ID());
|
||||||
|
batch.setDateDeposit(today);
|
||||||
|
batch.setDateAcct(today);
|
||||||
|
batch.setDateDoc(today);
|
||||||
|
batch.saveEx();
|
||||||
|
|
||||||
|
GridWindow gridWindow = GridWindow.get(Env.getCtx(), 1, SystemIDs.WINDOW_PAYMENTS_INTO_BATCH);
|
||||||
|
assertNotNull(gridWindow, "Failed to load grid window of Payments into batch");
|
||||||
|
gridWindow.initTab(0);
|
||||||
|
GridTab gridTab = gridWindow.getTab(0);
|
||||||
|
MQuery query = new MQuery(MDepositBatch.Table_Name);
|
||||||
|
query.addRestriction(MDepositBatch.COLUMNNAME_C_DepositBatch_ID, "=", batch.get_ID());
|
||||||
|
gridTab.setQuery(query);
|
||||||
|
gridTab.getTableModel().setImportingMode(false, getTrxName());
|
||||||
|
gridTab.query(false);
|
||||||
|
|
||||||
|
assertEquals(1, gridTab.getRowCount(), "Unexpected number of row retrieve from DB");
|
||||||
|
assertEquals(batch.get_ID(), gridTab.getRecord_ID(), "Wrong record id");
|
||||||
|
|
||||||
|
CreateFromDepositBatchImpl form = new CreateFromDepositBatchImpl(gridTab);
|
||||||
|
form.setTrxName(getTrxName());
|
||||||
|
Timestamp dateFrom = TimeUtil.addDays(today, -1);
|
||||||
|
Timestamp dateTo = TimeUtil.addDays(today, 1);
|
||||||
|
form.loadPayments(C_BankAccount_ID, null, null, dateFrom, dateTo, null, null, payment.getC_DocType_ID(), null, null);
|
||||||
|
assertTrue(form.minitable.getRowCount() > 0, "Failed to load data from DB");
|
||||||
|
|
||||||
|
form.minitable.setSelectedRow(-1);
|
||||||
|
for (int i = 0; i < form.minitable.getRowCount(); i++) {
|
||||||
|
KeyNamePair pp = (KeyNamePair) form.minitable.getValueAt(i, 2);
|
||||||
|
if (pp.getKey() == payment.get_ID()) {
|
||||||
|
form.minitable.setValueAt(Boolean.TRUE, i, 0);
|
||||||
|
form.minitable.setSelectedRow(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(form.minitable.getSelectedRow() >= 0, "Failed to find payment record");
|
||||||
|
assertTrue(form.save(form.minitable, getTrxName()), "Failed to save changes");
|
||||||
|
|
||||||
|
batch.load(getTrxName());
|
||||||
|
MDepositBatchLine[] lines = batch.getLines();
|
||||||
|
assertNotNull(lines, "Null deposit batch line");
|
||||||
|
assertEquals(1, lines.length, "Unexpected number of batch lines");
|
||||||
|
assertEquals(payment.get_ID(), lines[0].getC_Payment_ID());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class CreateFromDepositBatchImpl extends CreateFromDepositBatch {
|
||||||
|
|
||||||
|
private MiniTableImpl minitable = null;
|
||||||
|
|
||||||
|
public CreateFromDepositBatchImpl(GridTab mTab) {
|
||||||
|
super(mTab);
|
||||||
|
|
||||||
|
try {
|
||||||
|
dynInit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getWindow() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean dynInit() throws Exception {
|
||||||
|
super.dynInit();
|
||||||
|
minitable = new MiniTableImpl();
|
||||||
|
for(String column : getOISColumnNames()) {
|
||||||
|
minitable.addColumn(column);
|
||||||
|
}
|
||||||
|
configureMiniTable(minitable);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadPayments(Integer BankAccount, Integer BPartner, String DocumentNo,
|
||||||
|
Timestamp DateFrom, Timestamp DateTo, BigDecimal AmtFrom, BigDecimal AmtTo, Integer DocType,
|
||||||
|
String TenderType, String AuthCode) {
|
||||||
|
Vector<Vector<Object>> datas = super.getBankAccountData(BankAccount, BPartner, DocumentNo, DateFrom, DateTo, AmtFrom, AmtTo, DocType,
|
||||||
|
TenderType, AuthCode);
|
||||||
|
|
||||||
|
for(int i = 0; i < datas.size(); i++) {
|
||||||
|
minitable.setRowCount(i+1);
|
||||||
|
Vector<Object> data = datas.get(i);
|
||||||
|
for(int j = 0; j < data.size(); j++) {
|
||||||
|
minitable.setValueAt(data.get(j), i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,333 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* This file is part of iDempiere ERP Open Source *
|
||||||
|
* http://www.idempiere.org *
|
||||||
|
* *
|
||||||
|
* Copyright (C) Contributors *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||||
|
* MA 02110-1301, USA. *
|
||||||
|
* *
|
||||||
|
* Contributors: *
|
||||||
|
* - hengsin *
|
||||||
|
**********************************************************************/
|
||||||
|
package org.idempiere.test.form;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.compiere.grid.CreateFromInvoice;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.GridWindow;
|
||||||
|
import org.compiere.model.MBPartner;
|
||||||
|
import org.compiere.model.MInOut;
|
||||||
|
import org.compiere.model.MInOutLine;
|
||||||
|
import org.compiere.model.MInvoice;
|
||||||
|
import org.compiere.model.MInvoiceLine;
|
||||||
|
import org.compiere.model.MOrder;
|
||||||
|
import org.compiere.model.MOrderLine;
|
||||||
|
import org.compiere.model.MProduct;
|
||||||
|
import org.compiere.model.MQuery;
|
||||||
|
import org.compiere.model.SystemIDs;
|
||||||
|
import org.compiere.process.DocAction;
|
||||||
|
import org.compiere.process.ProcessInfo;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
|
import org.compiere.util.TimeUtil;
|
||||||
|
import org.compiere.wf.MWorkflow;
|
||||||
|
import org.idempiere.test.AbstractTestCase;
|
||||||
|
import org.idempiere.test.DictionaryIDs;
|
||||||
|
import org.idempiere.test.ui.MiniTableImpl;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CreateFromInvoiceFormTest extends AbstractTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default constructor
|
||||||
|
*/
|
||||||
|
public CreateFromInvoiceFormTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateFromPurchaseOrder() {
|
||||||
|
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
|
||||||
|
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id));
|
||||||
|
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
|
||||||
|
order.setIsSOTrx(false);
|
||||||
|
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
|
||||||
|
order.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
order.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
|
||||||
|
order.setDateOrdered(today);
|
||||||
|
order.setDatePromised(today);
|
||||||
|
order.saveEx();
|
||||||
|
|
||||||
|
MOrderLine line1 = new MOrderLine(order);
|
||||||
|
line1.setLine(10);
|
||||||
|
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id));
|
||||||
|
line1.setQty(new BigDecimal("1"));
|
||||||
|
line1.setDatePromised(today);
|
||||||
|
line1.saveEx();
|
||||||
|
|
||||||
|
ProcessInfo info = MWorkflow.runDocumentActionWorkflow(order, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError());
|
||||||
|
order.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
|
||||||
|
|
||||||
|
MInvoice invoice = new MInvoice(Env.getCtx(), 0, getTrxName());
|
||||||
|
invoice.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id));
|
||||||
|
invoice.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.AP_INVOICE.id);
|
||||||
|
invoice.setIsSOTrx(false);
|
||||||
|
invoice.setSalesRep_ID(order.getSalesRep_ID());
|
||||||
|
invoice.setC_Currency_ID(order.getC_Currency_ID());
|
||||||
|
invoice.setDateInvoiced(today);
|
||||||
|
invoice.setDateAcct(today);
|
||||||
|
invoice.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
invoice.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
invoice.saveEx();
|
||||||
|
|
||||||
|
GridWindow gridWindow = GridWindow.get(Env.getCtx(), 1, SystemIDs.WINDOW_INVOICE_VENDOR);
|
||||||
|
assertNotNull(gridWindow, "Failed to load grid window of Invoice (Vendor)");
|
||||||
|
gridWindow.initTab(0);
|
||||||
|
GridTab gridTab = gridWindow.getTab(0);
|
||||||
|
MQuery query = new MQuery(MInvoice.Table_Name);
|
||||||
|
query.addRestriction(MInvoice.COLUMNNAME_C_Invoice_ID, "=", invoice.get_ID());
|
||||||
|
gridTab.setQuery(query);
|
||||||
|
gridTab.getTableModel().setImportingMode(false, getTrxName());
|
||||||
|
gridTab.query(false);
|
||||||
|
|
||||||
|
assertEquals(1, gridTab.getRowCount(), "Unexpected number of row retrieve from DB");
|
||||||
|
assertEquals(invoice.get_ID(), gridTab.getRecord_ID(), "Wrong record id");
|
||||||
|
|
||||||
|
CreateFromInvoiceImpl form = new CreateFromInvoiceImpl(gridTab);
|
||||||
|
form.setTrxName(getTrxName());
|
||||||
|
ArrayList<KeyNamePair> POs = form.getOrders(order.getC_BPartner_ID());
|
||||||
|
assertNotNull(POs, "Can't load POs for BP");
|
||||||
|
assertTrue(POs.size() > 0, "Can't load POs for BP");
|
||||||
|
boolean found = false;
|
||||||
|
for(KeyNamePair knp : POs) {
|
||||||
|
if (knp.getKey() == order.get_ID()) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(found, "Fail to load PO");
|
||||||
|
form.loadOrderLines(order.get_ID());
|
||||||
|
assertTrue(form.minitable.getRowCount() > 0, "Failed to load data from DB");
|
||||||
|
|
||||||
|
form.minitable.setSelectedRow(-1);
|
||||||
|
for (int i = 0; i < form.minitable.getRowCount(); i++) {
|
||||||
|
KeyNamePair pp = (KeyNamePair) form.minitable.getValueAt(i, 5);
|
||||||
|
if (pp.getKey() == line1.get_ID()) {
|
||||||
|
form.minitable.setValueAt(Boolean.TRUE, i, 0);
|
||||||
|
form.minitable.setSelectedRow(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(form.minitable.getSelectedRow() >= 0, "Failed to find order line record");
|
||||||
|
assertTrue(form.save(form.minitable, getTrxName()), "Failed to save changes");
|
||||||
|
|
||||||
|
invoice.load(getTrxName());
|
||||||
|
MInvoiceLine[] lines = invoice.getLines(true);
|
||||||
|
assertEquals(1, lines.length, "Unexpected number of invoice lines ");
|
||||||
|
assertEquals(lines[0].getM_Product_ID(), line1.getM_Product_ID());
|
||||||
|
assertEquals(lines[0].getQtyInvoiced().setScale(2, RoundingMode.HALF_UP), line1.getQtyOrdered().setScale(2, RoundingMode.HALF_UP));
|
||||||
|
|
||||||
|
info = MWorkflow.runDocumentActionWorkflow(invoice, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError());
|
||||||
|
invoice.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, invoice.getDocStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateFromMaterialReceipt() {
|
||||||
|
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
|
||||||
|
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id));
|
||||||
|
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
|
||||||
|
order.setIsSOTrx(false);
|
||||||
|
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
|
||||||
|
order.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
order.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
|
||||||
|
order.setDateOrdered(today);
|
||||||
|
order.setDatePromised(today);
|
||||||
|
order.saveEx();
|
||||||
|
|
||||||
|
MOrderLine line1 = new MOrderLine(order);
|
||||||
|
line1.setLine(10);
|
||||||
|
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id));
|
||||||
|
line1.setQty(new BigDecimal("1"));
|
||||||
|
line1.setDatePromised(today);
|
||||||
|
line1.saveEx();
|
||||||
|
|
||||||
|
ProcessInfo info = MWorkflow.runDocumentActionWorkflow(order, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError());
|
||||||
|
order.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
|
||||||
|
|
||||||
|
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
|
||||||
|
receipt.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
receipt.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
receipt.saveEx();
|
||||||
|
|
||||||
|
MInOutLine receiptLine1 = new MInOutLine(receipt);
|
||||||
|
receiptLine1.setOrderLine(line1, 0, new BigDecimal("1"));
|
||||||
|
receiptLine1.setQty(new BigDecimal("1"));
|
||||||
|
receiptLine1.saveEx();
|
||||||
|
|
||||||
|
info = MWorkflow.runDocumentActionWorkflow(receipt, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError());
|
||||||
|
receipt.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, receipt.getDocStatus());
|
||||||
|
|
||||||
|
MInvoice invoice = new MInvoice(Env.getCtx(), 0, getTrxName());
|
||||||
|
invoice.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id));
|
||||||
|
invoice.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.AP_INVOICE.id);
|
||||||
|
invoice.setIsSOTrx(false);
|
||||||
|
invoice.setSalesRep_ID(order.getSalesRep_ID());
|
||||||
|
invoice.setC_Currency_ID(order.getC_Currency_ID());
|
||||||
|
invoice.setDateInvoiced(today);
|
||||||
|
invoice.setDateAcct(today);
|
||||||
|
invoice.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
invoice.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
invoice.saveEx();
|
||||||
|
|
||||||
|
GridWindow gridWindow = GridWindow.get(Env.getCtx(), 1, SystemIDs.WINDOW_INVOICE_VENDOR);
|
||||||
|
assertNotNull(gridWindow, "Failed to load grid window of Invoice (Vendor)");
|
||||||
|
gridWindow.initTab(0);
|
||||||
|
GridTab gridTab = gridWindow.getTab(0);
|
||||||
|
MQuery query = new MQuery(MInvoice.Table_Name);
|
||||||
|
query.addRestriction(MInvoice.COLUMNNAME_C_Invoice_ID, "=", invoice.get_ID());
|
||||||
|
gridTab.setQuery(query);
|
||||||
|
gridTab.getTableModel().setImportingMode(false, getTrxName());
|
||||||
|
gridTab.query(false);
|
||||||
|
|
||||||
|
assertEquals(1, gridTab.getRowCount(), "Unexpected number of row retrieve from DB");
|
||||||
|
assertEquals(invoice.get_ID(), gridTab.getRecord_ID(), "Wrong record id");
|
||||||
|
|
||||||
|
CreateFromInvoiceImpl form = new CreateFromInvoiceImpl(gridTab);
|
||||||
|
form.setTrxName(getTrxName());
|
||||||
|
ArrayList<KeyNamePair> MRs = form.getShipments(order.getC_BPartner_ID());
|
||||||
|
assertNotNull(MRs, "Can't load MRs for BP");
|
||||||
|
assertTrue(MRs.size() > 0, "Can't load MRs for BP");
|
||||||
|
boolean found = false;
|
||||||
|
for(KeyNamePair knp : MRs) {
|
||||||
|
if (knp.getKey() == receipt.get_ID()) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(found, "Fail to load MR");
|
||||||
|
form.loadShipmentLines(receipt.get_ID());
|
||||||
|
assertTrue(form.minitable.getRowCount() > 0, "Failed to load data from DB");
|
||||||
|
|
||||||
|
form.minitable.setSelectedRow(-1);
|
||||||
|
for (int i = 0; i < form.minitable.getRowCount(); i++) {
|
||||||
|
KeyNamePair pp = (KeyNamePair) form.minitable.getValueAt(i, 6);
|
||||||
|
if (pp.getKey() == receiptLine1.get_ID()) {
|
||||||
|
form.minitable.setValueAt(Boolean.TRUE, i, 0);
|
||||||
|
form.minitable.setSelectedRow(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(form.minitable.getSelectedRow() >= 0, "Failed to find receipt line record");
|
||||||
|
assertTrue(form.save(form.minitable, getTrxName()), "Failed to save changes");
|
||||||
|
|
||||||
|
invoice.load(getTrxName());
|
||||||
|
MInvoiceLine[] lines = invoice.getLines(true);
|
||||||
|
assertEquals(1, lines.length, "Unexpected number of invoice lines ");
|
||||||
|
assertEquals(lines[0].getM_Product_ID(), line1.getM_Product_ID());
|
||||||
|
assertEquals(lines[0].getQtyInvoiced().setScale(2, RoundingMode.HALF_UP), line1.getQtyOrdered().setScale(2, RoundingMode.HALF_UP));
|
||||||
|
|
||||||
|
info = MWorkflow.runDocumentActionWorkflow(invoice, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError());
|
||||||
|
invoice.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, invoice.getDocStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class CreateFromInvoiceImpl extends CreateFromInvoice {
|
||||||
|
|
||||||
|
private MiniTableImpl minitable = null;
|
||||||
|
|
||||||
|
public CreateFromInvoiceImpl(GridTab mTab) {
|
||||||
|
super(mTab);
|
||||||
|
|
||||||
|
try {
|
||||||
|
dynInit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getWindow() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean dynInit() throws Exception {
|
||||||
|
super.dynInit();
|
||||||
|
minitable = new MiniTableImpl();
|
||||||
|
for(String column : getOISColumnNames()) {
|
||||||
|
minitable.addColumn(column);
|
||||||
|
}
|
||||||
|
configureMiniTable(minitable);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<KeyNamePair> getOrders (int C_BPartner_ID) {
|
||||||
|
return super.loadOrderData(C_BPartner_ID, true, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadOrderLines (int C_Order_ID) {
|
||||||
|
Vector<Vector<Object>> datas = super.getOrderData(C_Order_ID, true, false);
|
||||||
|
for(int i = 0; i < datas.size(); i++) {
|
||||||
|
minitable.setRowCount(i+1);
|
||||||
|
Vector<Object> data = datas.get(i);
|
||||||
|
for(int j = 0; j < data.size(); j++) {
|
||||||
|
minitable.setValueAt(data.get(j), i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<KeyNamePair> getShipments(int C_BPartner_ID) {
|
||||||
|
return super.loadShipmentData(C_BPartner_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadShipmentLines(int M_InOut_ID) {
|
||||||
|
Vector<Vector<Object>> datas = super.getShipmentData(M_InOut_ID);
|
||||||
|
for(int i = 0; i < datas.size(); i++) {
|
||||||
|
minitable.setRowCount(i+1);
|
||||||
|
Vector<Object> data = datas.get(i);
|
||||||
|
for(int j = 0; j < data.size(); j++) {
|
||||||
|
minitable.setValueAt(data.get(j), i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,231 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* This file is part of iDempiere ERP Open Source *
|
||||||
|
* http://www.idempiere.org *
|
||||||
|
* *
|
||||||
|
* Copyright (C) Contributors *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||||
|
* MA 02110-1301, USA. *
|
||||||
|
* *
|
||||||
|
* Contributors: *
|
||||||
|
* - hengsin *
|
||||||
|
**********************************************************************/
|
||||||
|
package org.idempiere.test.form;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.compiere.grid.CreateFromPackageShipment;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.GridWindow;
|
||||||
|
import org.compiere.model.MBPartner;
|
||||||
|
import org.compiere.model.MInOut;
|
||||||
|
import org.compiere.model.MInOutLine;
|
||||||
|
import org.compiere.model.MOrder;
|
||||||
|
import org.compiere.model.MOrderLine;
|
||||||
|
import org.compiere.model.MPackage;
|
||||||
|
import org.compiere.model.MPackageLine;
|
||||||
|
import org.compiere.model.MPackageMPS;
|
||||||
|
import org.compiere.model.MProduct;
|
||||||
|
import org.compiere.model.MQuery;
|
||||||
|
import org.compiere.model.MShipper;
|
||||||
|
import org.compiere.model.Query;
|
||||||
|
import org.compiere.model.SystemIDs;
|
||||||
|
import org.compiere.process.DocAction;
|
||||||
|
import org.compiere.process.ProcessInfo;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
|
import org.compiere.util.TimeUtil;
|
||||||
|
import org.compiere.wf.MWorkflow;
|
||||||
|
import org.idempiere.test.AbstractTestCase;
|
||||||
|
import org.idempiere.test.DictionaryIDs;
|
||||||
|
import org.idempiere.test.ui.MiniTableImpl;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CreateFromPackageShipmentFormTest extends AbstractTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default constructor
|
||||||
|
*/
|
||||||
|
public CreateFromPackageShipmentFormTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateFromShipmentLine() {
|
||||||
|
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
|
||||||
|
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
|
||||||
|
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
|
||||||
|
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
|
||||||
|
order.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
order.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
|
||||||
|
order.setDatePromised(today);
|
||||||
|
order.saveEx();
|
||||||
|
|
||||||
|
MOrderLine orderLine = new MOrderLine(order);
|
||||||
|
orderLine.setLine(10);
|
||||||
|
orderLine.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
|
||||||
|
orderLine.setQty(new BigDecimal("1"));
|
||||||
|
orderLine.setDatePromised(today);
|
||||||
|
orderLine.saveEx();
|
||||||
|
|
||||||
|
ProcessInfo info = MWorkflow.runDocumentActionWorkflow(order, DocAction.ACTION_Complete);
|
||||||
|
order.load(getTrxName());
|
||||||
|
assertFalse(info.isError(), info.getSummary());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
|
||||||
|
|
||||||
|
MInOut shipment = new MInOut(order, DictionaryIDs.C_DocType.MM_SHIPMENT.id, order.getDateOrdered());
|
||||||
|
shipment.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
shipment.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
shipment.saveEx();
|
||||||
|
|
||||||
|
//shipment
|
||||||
|
MInOutLine shipmentLine = new MInOutLine(shipment);
|
||||||
|
shipmentLine.setOrderLine(orderLine, 0, new BigDecimal("1"));
|
||||||
|
shipmentLine.setQty(new BigDecimal("1"));
|
||||||
|
shipmentLine.saveEx();
|
||||||
|
|
||||||
|
info = MWorkflow.runDocumentActionWorkflow(shipment, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError());
|
||||||
|
shipment.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, shipment.getDocStatus());
|
||||||
|
|
||||||
|
MShipper shipper = new MShipper(Env.getCtx(), DictionaryIDs.M_Shipper.UPS.id, getTrxName());
|
||||||
|
//package
|
||||||
|
MPackage mPackage = new MPackage(shipment, shipper);
|
||||||
|
mPackage.setBoxCount(1);
|
||||||
|
mPackage.saveEx();
|
||||||
|
|
||||||
|
Query q = new Query(Env.getCtx(), MPackageMPS.Table_Name, MPackageMPS.COLUMNNAME_M_Package_ID+"=?", getTrxName());
|
||||||
|
MPackageMPS mps = q.setParameters(mPackage.getM_Package_ID()).first();
|
||||||
|
|
||||||
|
GridWindow gridWindow = GridWindow.get(Env.getCtx(), 1, SystemIDs.WINDOW_SHIPMENT_CUSTOMER);
|
||||||
|
assertNotNull(gridWindow, "Failed to load grid window of Shipment (Customer)");
|
||||||
|
int index = -1;
|
||||||
|
for(int i = 0; i < gridWindow.getTabCount(); i++) {
|
||||||
|
gridWindow.initTab(i);
|
||||||
|
GridTab gt = gridWindow.getTab(i);
|
||||||
|
if (gt.getAD_Table_ID() == MPackageMPS.Table_ID) {
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(index > 0, "Failed to find Grid Tab for MPackageMPS");
|
||||||
|
MQuery query = new MQuery(MInOut.Table_Name);
|
||||||
|
query.addRestriction(MInOut.COLUMNNAME_M_InOut_ID, "=", shipment.get_ID());
|
||||||
|
gridWindow.getTab(0).setQuery(query);
|
||||||
|
gridWindow.getTab(0).getTableModel().setImportingMode(false, getTrxName());
|
||||||
|
gridWindow.getTab(0).query(false);
|
||||||
|
|
||||||
|
assertEquals(1, gridWindow.getTab(0).getRowCount(), "Unexpected number of row retrieve from DB");
|
||||||
|
assertEquals(shipment.get_ID(), gridWindow.getTab(0).getRecord_ID(), "Wrong shipment record id");
|
||||||
|
|
||||||
|
List<GridTab> gtabs = new ArrayList<>();
|
||||||
|
gtabs.add(gridWindow.getTab(index));
|
||||||
|
int currentLevel = gridWindow.getTab(index).getTabLevel();
|
||||||
|
for(int i = index - 1 ; i > 0; i--) {
|
||||||
|
int level = gridWindow.getTab(i).getTabLevel();
|
||||||
|
if (level > currentLevel)
|
||||||
|
break;
|
||||||
|
else if (level == currentLevel)
|
||||||
|
continue;
|
||||||
|
currentLevel = level;
|
||||||
|
gtabs.add(gridWindow.getTab(i));
|
||||||
|
}
|
||||||
|
for (int i = gtabs.size()-1; i>= 0; i--) {
|
||||||
|
gtabs.get(i).getTableModel().setImportingMode(false, getTrxName());
|
||||||
|
gtabs.get(i).query(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(mps.get_ID(), gridWindow.getTab(index).getValue(MPackageMPS.COLUMNNAME_M_PackageMPS_ID), "Wrong MPackageMPS record id");
|
||||||
|
|
||||||
|
CreateFromPackageShipmentImpl form = new CreateFromPackageShipmentImpl(gridWindow.getTab(index));
|
||||||
|
form.setTrxName(getTrxName());
|
||||||
|
form.loadShipmentLines(shipment.get_ID());
|
||||||
|
assertTrue(form.minitable.getRowCount() > 0, "Failed to load data from DB");
|
||||||
|
|
||||||
|
form.minitable.setSelectedRow(-1);
|
||||||
|
for (int i = 0; i < form.minitable.getRowCount(); i++) {
|
||||||
|
KeyNamePair pp = (KeyNamePair) form.minitable.getValueAt(i, 1);
|
||||||
|
if (pp.getKey() == shipmentLine.get_ID()) {
|
||||||
|
form.minitable.setValueAt(Boolean.TRUE, i, 0);
|
||||||
|
form.minitable.setSelectedRow(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(form.minitable.getSelectedRow() >= 0, "Failed to find shipment line record");
|
||||||
|
assertTrue(form.save(form.minitable, getTrxName()), "Failed to save changes");
|
||||||
|
|
||||||
|
q = new Query(Env.getCtx(), MPackageLine.Table_Name, MPackageLine.COLUMNNAME_M_PackageMPS_ID+"=?", getTrxName());
|
||||||
|
List<MPackageLine> pls = q.setParameters(mps.get_ID()).list();
|
||||||
|
assertTrue(pls.size() > 0, "Failed to create new MPackageLine record");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class CreateFromPackageShipmentImpl extends CreateFromPackageShipment {
|
||||||
|
|
||||||
|
private MiniTableImpl minitable = null;
|
||||||
|
|
||||||
|
public CreateFromPackageShipmentImpl(GridTab gridTab) {
|
||||||
|
super(gridTab);
|
||||||
|
|
||||||
|
try {
|
||||||
|
dynInit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getWindow() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean dynInit() throws Exception {
|
||||||
|
super.dynInit();
|
||||||
|
minitable = new MiniTableImpl();
|
||||||
|
for(String column : getOISColumnNames()) {
|
||||||
|
minitable.addColumn(column);
|
||||||
|
}
|
||||||
|
configureMiniTable(minitable);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadShipmentLines(int M_InOut_ID) {
|
||||||
|
Vector<Vector<Object>> datas = super.getShipmentData(M_InOut_ID);
|
||||||
|
for(int i = 0; i < datas.size(); i++) {
|
||||||
|
minitable.setRowCount(i+1);
|
||||||
|
Vector<Object> data = datas.get(i);
|
||||||
|
for(int j = 0; j < data.size(); j++) {
|
||||||
|
minitable.setValueAt(data.get(j), i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,202 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* This file is part of iDempiere ERP Open Source *
|
||||||
|
* http://www.idempiere.org *
|
||||||
|
* *
|
||||||
|
* Copyright (C) Contributors *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||||
|
* MA 02110-1301, USA. *
|
||||||
|
* *
|
||||||
|
* Contributors: *
|
||||||
|
* - hengsin *
|
||||||
|
**********************************************************************/
|
||||||
|
package org.idempiere.test.form;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.compiere.grid.CreateFromRMA;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.GridWindow;
|
||||||
|
import org.compiere.model.MBPartner;
|
||||||
|
import org.compiere.model.MInOut;
|
||||||
|
import org.compiere.model.MInOutLine;
|
||||||
|
import org.compiere.model.MOrder;
|
||||||
|
import org.compiere.model.MOrderLine;
|
||||||
|
import org.compiere.model.MProduct;
|
||||||
|
import org.compiere.model.MQuery;
|
||||||
|
import org.compiere.model.MRMA;
|
||||||
|
import org.compiere.model.MRMALine;
|
||||||
|
import org.compiere.model.SystemIDs;
|
||||||
|
import org.compiere.process.DocAction;
|
||||||
|
import org.compiere.process.ProcessInfo;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
|
import org.compiere.util.TimeUtil;
|
||||||
|
import org.compiere.wf.MWorkflow;
|
||||||
|
import org.idempiere.test.AbstractTestCase;
|
||||||
|
import org.idempiere.test.DictionaryIDs;
|
||||||
|
import org.idempiere.test.ui.MiniTableImpl;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CreateFromRMAFormTest extends AbstractTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default constructor
|
||||||
|
*/
|
||||||
|
public CreateFromRMAFormTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateFromShipmentLine() {
|
||||||
|
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
|
||||||
|
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id));
|
||||||
|
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
|
||||||
|
order.setIsSOTrx(false);
|
||||||
|
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
|
||||||
|
order.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
order.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
|
||||||
|
order.setDateOrdered(today);
|
||||||
|
order.setDatePromised(today);
|
||||||
|
order.saveEx();
|
||||||
|
|
||||||
|
MOrderLine orderLine = new MOrderLine(order);
|
||||||
|
orderLine.setLine(10);
|
||||||
|
orderLine.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id));
|
||||||
|
orderLine.setQty(new BigDecimal("1"));
|
||||||
|
orderLine.setDatePromised(today);
|
||||||
|
orderLine.saveEx();
|
||||||
|
|
||||||
|
ProcessInfo info = MWorkflow.runDocumentActionWorkflow(order, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError());
|
||||||
|
order.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
|
||||||
|
|
||||||
|
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
|
||||||
|
receipt.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
receipt.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
receipt.saveEx();
|
||||||
|
|
||||||
|
MInOutLine receiptLine = new MInOutLine(receipt);
|
||||||
|
receiptLine.setOrderLine(orderLine, 0, new BigDecimal("1"));
|
||||||
|
receiptLine.setQty(new BigDecimal("1"));
|
||||||
|
receiptLine.saveEx();
|
||||||
|
|
||||||
|
info = MWorkflow.runDocumentActionWorkflow(receipt, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError());
|
||||||
|
receipt.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, receipt.getDocStatus());
|
||||||
|
|
||||||
|
MRMA rma = new MRMA(Env.getCtx(), 0, getTrxName());
|
||||||
|
rma.setM_InOut_ID(receipt.getM_InOut_ID());
|
||||||
|
rma.setC_BPartner_ID(receipt.getC_BPartner_ID());
|
||||||
|
rma.setC_Currency_ID(order.getC_Currency_ID());
|
||||||
|
rma.setIsSOTrx(false);
|
||||||
|
rma.setName("testVendorRMA");
|
||||||
|
rma.setC_DocType_ID(DictionaryIDs.C_DocType.VENDOR_RETURN_MATERIAL.id);
|
||||||
|
rma.setSalesRep_ID(order.getSalesRep_ID());
|
||||||
|
rma.setM_RMAType_ID(DictionaryIDs.M_RMAType.DAMAGE_ON_ARRIVAL.id);
|
||||||
|
rma.saveEx();
|
||||||
|
|
||||||
|
GridWindow gridWindow = GridWindow.get(Env.getCtx(), 1, SystemIDs.WINDOW_VENDOR_RMA);
|
||||||
|
assertNotNull(gridWindow, "Failed to load grid window of Vendor RMA");
|
||||||
|
gridWindow.initTab(0);
|
||||||
|
GridTab gridTab = gridWindow.getTab(0);
|
||||||
|
MQuery query = new MQuery(MRMA.Table_Name);
|
||||||
|
query.addRestriction(MRMA.COLUMNNAME_M_RMA_ID, "=", rma.get_ID());
|
||||||
|
gridTab.setQuery(query);
|
||||||
|
gridTab.getTableModel().setImportingMode(false, getTrxName());
|
||||||
|
gridTab.query(false);
|
||||||
|
|
||||||
|
assertEquals(1, gridTab.getRowCount(), "Unexpected number of row retrieve from DB");
|
||||||
|
assertEquals(rma.get_ID(), gridTab.getRecord_ID(), "Wrong RMA record id");
|
||||||
|
|
||||||
|
CreateFromRMAImpl form = new CreateFromRMAImpl(gridTab);
|
||||||
|
form.setTrxName(getTrxName());
|
||||||
|
form.loadShipmentLines();
|
||||||
|
assertTrue(form.minitable.getRowCount() > 0, "Failed to load data from DB");
|
||||||
|
|
||||||
|
form.minitable.setSelectedRow(-1);
|
||||||
|
for (int i = 0; i < form.minitable.getRowCount(); i++) {
|
||||||
|
KeyNamePair pp = (KeyNamePair) form.minitable.getValueAt(i, 1);
|
||||||
|
if (pp.getKey() == receiptLine.get_ID()) {
|
||||||
|
form.minitable.setValueAt(Boolean.TRUE, i, 0);
|
||||||
|
form.minitable.setSelectedRow(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(form.minitable.getSelectedRow() >= 0, "Failed to find receipt line record");
|
||||||
|
assertTrue(form.save(form.minitable, getTrxName()), "Failed to save changes");
|
||||||
|
|
||||||
|
rma.load(getTrxName());
|
||||||
|
MRMALine[] rmaLines = rma.getLines(true);
|
||||||
|
assertEquals(1, rmaLines.length, "Unexpected number of RMA Line records");
|
||||||
|
assertEquals(receiptLine.get_ID(), rmaLines[0].getM_InOutLine_ID(), "Materia receipt line not match to RMA line");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class CreateFromRMAImpl extends CreateFromRMA {
|
||||||
|
|
||||||
|
private MiniTableImpl minitable = null;
|
||||||
|
|
||||||
|
public CreateFromRMAImpl(GridTab mTab) {
|
||||||
|
super(mTab);
|
||||||
|
|
||||||
|
try {
|
||||||
|
dynInit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getWindow() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean dynInit() throws Exception {
|
||||||
|
super.dynInit();
|
||||||
|
minitable = new MiniTableImpl();
|
||||||
|
for(String column : getOISColumnNames()) {
|
||||||
|
minitable.addColumn(column);
|
||||||
|
}
|
||||||
|
configureMiniTable(minitable);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadShipmentLines() {
|
||||||
|
Vector<Vector<Object>> datas = super.getRMAData();
|
||||||
|
for(int i = 0; i < datas.size(); i++) {
|
||||||
|
minitable.setRowCount(i+1);
|
||||||
|
Vector<Object> data = datas.get(i);
|
||||||
|
for(int j = 0; j < data.size(); j++) {
|
||||||
|
minitable.setValueAt(data.get(j), i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,446 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* This file is part of iDempiere ERP Open Source *
|
||||||
|
* http://www.idempiere.org *
|
||||||
|
* *
|
||||||
|
* Copyright (C) Contributors *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||||
|
* MA 02110-1301, USA. *
|
||||||
|
* *
|
||||||
|
* Contributors: *
|
||||||
|
* - hengsin *
|
||||||
|
**********************************************************************/
|
||||||
|
package org.idempiere.test.form;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.compiere.grid.CreateFromShipment;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.GridWindow;
|
||||||
|
import org.compiere.model.MBPartner;
|
||||||
|
import org.compiere.model.MInOut;
|
||||||
|
import org.compiere.model.MInOutLine;
|
||||||
|
import org.compiere.model.MInvoice;
|
||||||
|
import org.compiere.model.MInvoiceLine;
|
||||||
|
import org.compiere.model.MLocator;
|
||||||
|
import org.compiere.model.MOrder;
|
||||||
|
import org.compiere.model.MOrderLine;
|
||||||
|
import org.compiere.model.MProduct;
|
||||||
|
import org.compiere.model.MQuery;
|
||||||
|
import org.compiere.model.MRMA;
|
||||||
|
import org.compiere.model.MRMALine;
|
||||||
|
import org.compiere.model.MWarehouse;
|
||||||
|
import org.compiere.model.SystemIDs;
|
||||||
|
import org.compiere.process.DocAction;
|
||||||
|
import org.compiere.process.ProcessInfo;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
|
import org.compiere.util.TimeUtil;
|
||||||
|
import org.compiere.wf.MWorkflow;
|
||||||
|
import org.idempiere.test.AbstractTestCase;
|
||||||
|
import org.idempiere.test.DictionaryIDs;
|
||||||
|
import org.idempiere.test.ui.MiniTableImpl;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CreateFromShipmentFormTest extends AbstractTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default constructor
|
||||||
|
*/
|
||||||
|
public CreateFromShipmentFormTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateFromOrderLine() {
|
||||||
|
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
|
||||||
|
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id));
|
||||||
|
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
|
||||||
|
order.setIsSOTrx(false);
|
||||||
|
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
|
||||||
|
order.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
order.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
|
||||||
|
order.setDateOrdered(today);
|
||||||
|
order.setDatePromised(today);
|
||||||
|
order.saveEx();
|
||||||
|
|
||||||
|
MOrderLine orderLine = new MOrderLine(order);
|
||||||
|
orderLine.setLine(10);
|
||||||
|
orderLine.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id));
|
||||||
|
orderLine.setQty(new BigDecimal("1"));
|
||||||
|
orderLine.setDatePromised(today);
|
||||||
|
orderLine.saveEx();
|
||||||
|
|
||||||
|
ProcessInfo info = MWorkflow.runDocumentActionWorkflow(order, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError());
|
||||||
|
order.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
|
||||||
|
|
||||||
|
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
|
||||||
|
receipt.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
receipt.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
receipt.saveEx();
|
||||||
|
|
||||||
|
GridWindow gridWindow = GridWindow.get(Env.getCtx(), 1, SystemIDs.WINDOW_MATERIAL_RECEIPT);
|
||||||
|
assertNotNull(gridWindow, "Failed to load grid window of Material Receipt");
|
||||||
|
gridWindow.initTab(0);
|
||||||
|
GridTab gridTab = gridWindow.getTab(0);
|
||||||
|
MQuery query = new MQuery(MInOut.Table_Name);
|
||||||
|
query.addRestriction(MInOut.COLUMNNAME_M_InOut_ID, "=", receipt.get_ID());
|
||||||
|
gridTab.setQuery(query);
|
||||||
|
gridTab.getTableModel().setImportingMode(false, getTrxName());
|
||||||
|
gridTab.query(false);
|
||||||
|
|
||||||
|
assertEquals(1, gridTab.getRowCount(), "Unexpected number of row retrieve from DB");
|
||||||
|
assertEquals(receipt.get_ID(), gridTab.getRecord_ID(), "Wrong Material Receipt record id");
|
||||||
|
|
||||||
|
CreateFromShipmentImpl form = new CreateFromShipmentImpl(gridTab);
|
||||||
|
form.setTrxName(getTrxName());
|
||||||
|
ArrayList<KeyNamePair> orders = form.getOrders(order.getC_BPartner_ID());
|
||||||
|
assertNotNull(orders, "Can't load Orders for BP");
|
||||||
|
assertTrue(orders.size() > 0, "Can't load Orders for BP");
|
||||||
|
boolean found = false;
|
||||||
|
for(KeyNamePair knp : orders) {
|
||||||
|
if (knp.getKey() == order.get_ID()) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(found, "Fail to load Order");
|
||||||
|
|
||||||
|
form.loadOrderLines(order.get_ID());
|
||||||
|
assertTrue(form.minitable.getRowCount() > 0, "Failed to load data from DB");
|
||||||
|
|
||||||
|
form.minitable.setSelectedRow(-1);
|
||||||
|
for (int i = 0; i < form.minitable.getRowCount(); i++) {
|
||||||
|
KeyNamePair pp = (KeyNamePair) form.minitable.getValueAt(i, 6);
|
||||||
|
if (pp.getKey() == orderLine.get_ID()) {
|
||||||
|
form.minitable.setValueAt(Boolean.TRUE, i, 0);
|
||||||
|
form.minitable.setSelectedRow(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(form.minitable.getSelectedRow() >= 0, "Failed to find order line record");
|
||||||
|
assertTrue(form.save(form.minitable, getTrxName()), "Failed to save changes");
|
||||||
|
|
||||||
|
receipt.load(getTrxName());
|
||||||
|
MInOutLine[] receiptLines = receipt.getLines(true);
|
||||||
|
assertEquals(1, receiptLines.length, "Unexpected number of Material Receipt Line records");
|
||||||
|
assertEquals(orderLine.get_ID(), receiptLines[0].getC_OrderLine_ID(), "Order line not match to material receipt line");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateFromInvoiceLine() {
|
||||||
|
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
|
||||||
|
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id));
|
||||||
|
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
|
||||||
|
order.setIsSOTrx(false);
|
||||||
|
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
|
||||||
|
order.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
order.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
|
||||||
|
order.setDateOrdered(today);
|
||||||
|
order.setDatePromised(today);
|
||||||
|
order.saveEx();
|
||||||
|
|
||||||
|
MOrderLine orderLine = new MOrderLine(order);
|
||||||
|
orderLine.setLine(10);
|
||||||
|
orderLine.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id));
|
||||||
|
orderLine.setQty(new BigDecimal("1"));
|
||||||
|
orderLine.setDatePromised(today);
|
||||||
|
orderLine.saveEx();
|
||||||
|
|
||||||
|
ProcessInfo info = MWorkflow.runDocumentActionWorkflow(order, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError(), info.getSummary());
|
||||||
|
order.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
|
||||||
|
|
||||||
|
MInvoice invoice = new MInvoice(order, DictionaryIDs.C_DocType.AP_INVOICE.id, today);
|
||||||
|
invoice.saveEx();
|
||||||
|
MInvoiceLine invoiceLine = new MInvoiceLine(invoice);
|
||||||
|
invoiceLine.setOrderLine(orderLine);
|
||||||
|
invoiceLine.setQty(new BigDecimal("1"));
|
||||||
|
invoiceLine.saveEx();
|
||||||
|
|
||||||
|
info = MWorkflow.runDocumentActionWorkflow(invoice, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError(), info.getSummary());
|
||||||
|
invoice.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, invoice.getDocStatus());
|
||||||
|
|
||||||
|
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
|
||||||
|
receipt.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
receipt.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
receipt.saveEx();
|
||||||
|
|
||||||
|
GridWindow gridWindow = GridWindow.get(Env.getCtx(), 1, SystemIDs.WINDOW_MATERIAL_RECEIPT);
|
||||||
|
assertNotNull(gridWindow, "Failed to load grid window of Material Receipt");
|
||||||
|
gridWindow.initTab(0);
|
||||||
|
GridTab gridTab = gridWindow.getTab(0);
|
||||||
|
MQuery query = new MQuery(MInOut.Table_Name);
|
||||||
|
query.addRestriction(MInOut.COLUMNNAME_M_InOut_ID, "=", receipt.get_ID());
|
||||||
|
gridTab.setQuery(query);
|
||||||
|
gridTab.getTableModel().setImportingMode(false, getTrxName());
|
||||||
|
gridTab.query(false);
|
||||||
|
|
||||||
|
assertEquals(1, gridTab.getRowCount(), "Unexpected number of row retrieve from DB");
|
||||||
|
assertEquals(receipt.get_ID(), gridTab.getRecord_ID(), "Wrong Material Receipt record id");
|
||||||
|
|
||||||
|
CreateFromShipmentImpl form = new CreateFromShipmentImpl(gridTab);
|
||||||
|
form.setTrxName(getTrxName());
|
||||||
|
ArrayList<KeyNamePair> invoices = form.getInvoices(order.getC_BPartner_ID());
|
||||||
|
assertNotNull(invoices, "Can't load Invoices for BP");
|
||||||
|
assertTrue(invoices.size() > 0, "Can't load Invoices for BP");
|
||||||
|
boolean found = false;
|
||||||
|
for(KeyNamePair knp : invoices) {
|
||||||
|
if (knp.getKey() == invoice.get_ID()) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(found, "Fail to load Invoice");
|
||||||
|
|
||||||
|
form.loadInvoiceLines(invoice.get_ID());
|
||||||
|
assertTrue(form.minitable.getRowCount() > 0, "Failed to load data from DB");
|
||||||
|
|
||||||
|
form.minitable.setSelectedRow(-1);
|
||||||
|
for (int i = 0; i < form.minitable.getRowCount(); i++) {
|
||||||
|
KeyNamePair pp = (KeyNamePair) form.minitable.getValueAt(i, 8);
|
||||||
|
if (pp.getKey() == invoiceLine.get_ID()) {
|
||||||
|
form.minitable.setValueAt(Boolean.TRUE, i, 0);
|
||||||
|
form.minitable.setSelectedRow(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(form.minitable.getSelectedRow() >= 0, "Failed to find invoice line record");
|
||||||
|
assertTrue(form.save(form.minitable, getTrxName()), "Failed to save changes");
|
||||||
|
|
||||||
|
receipt.load(getTrxName());
|
||||||
|
MInOutLine[] receiptLines = receipt.getLines(true);
|
||||||
|
assertEquals(1, receiptLines.length, "Unexpected number of Material Receipt Line records");
|
||||||
|
invoiceLine.load(getTrxName());
|
||||||
|
assertEquals(invoiceLine.getM_InOutLine_ID(), receiptLines[0].get_ID(), "Invoice line not match to material receipt line");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateFromCustomerRMALines() {
|
||||||
|
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
|
||||||
|
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
|
||||||
|
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
|
||||||
|
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
|
||||||
|
order.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
order.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
|
||||||
|
order.setDateOrdered(today);
|
||||||
|
order.setDatePromised(today);
|
||||||
|
order.setSalesRep_ID(getAD_User_ID());
|
||||||
|
order.saveEx();
|
||||||
|
|
||||||
|
MOrderLine line1 = new MOrderLine(order);
|
||||||
|
line1.setLine(10);
|
||||||
|
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
|
||||||
|
line1.setQty(new BigDecimal("1"));
|
||||||
|
line1.setDatePromised(today);
|
||||||
|
line1.saveEx();
|
||||||
|
|
||||||
|
ProcessInfo info = MWorkflow.runDocumentActionWorkflow(order, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError(), info.getSummary());
|
||||||
|
order.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, order.getDocStatus(), "Unexpected Document Status");
|
||||||
|
line1.load(getTrxName());
|
||||||
|
assertEquals(1, line1.getQtyReserved().intValue());
|
||||||
|
|
||||||
|
MInOut shipment = new MInOut(order, DictionaryIDs.C_DocType.MM_SHIPMENT.id, order.getDateOrdered());
|
||||||
|
shipment.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
shipment.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
shipment.saveEx();
|
||||||
|
|
||||||
|
MInOutLine shipmentLine = new MInOutLine(shipment);
|
||||||
|
shipmentLine.setOrderLine(line1, 0, new BigDecimal("1"));
|
||||||
|
shipmentLine.setQty(new BigDecimal("1"));
|
||||||
|
shipmentLine.saveEx();
|
||||||
|
|
||||||
|
info = MWorkflow.runDocumentActionWorkflow(shipment, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError(), info.getSummary());
|
||||||
|
shipment.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, shipment.getDocStatus(), "Unexpected Document Status");
|
||||||
|
|
||||||
|
MRMA rma = new MRMA(Env.getCtx(), 0, getTrxName());
|
||||||
|
rma.setC_BPartner_ID(order.getC_BPartner_ID());
|
||||||
|
rma.setM_InOut_ID(shipment.getM_InOut_ID());
|
||||||
|
rma.setC_DocType_ID(DictionaryIDs.C_DocType.CUSTOMER_RETURN_MATERIAL.id);
|
||||||
|
rma.setC_Currency_ID(order.getC_Currency_ID());
|
||||||
|
rma.setName("testCreateFromCustomerRMALines");
|
||||||
|
rma.setIsSOTrx(true);
|
||||||
|
rma.setSalesRep_ID(order.getSalesRep_ID());
|
||||||
|
rma.setM_RMAType_ID(DictionaryIDs.M_RMAType.DAMAGE_ON_ARRIVAL.id);
|
||||||
|
rma.saveEx();
|
||||||
|
|
||||||
|
MRMALine rmaLine = new MRMALine(Env.getCtx(), 0, getTrxName());
|
||||||
|
rmaLine.setM_RMA_ID(rma.get_ID());
|
||||||
|
rmaLine.setM_InOutLine_ID(shipmentLine.get_ID());
|
||||||
|
rmaLine.setM_Product_ID(shipmentLine.getM_Product_ID());
|
||||||
|
rmaLine.setQty(new BigDecimal("1"));
|
||||||
|
rmaLine.saveEx();
|
||||||
|
|
||||||
|
info = MWorkflow.runDocumentActionWorkflow(rma, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(info.isError(), info.getSummary());
|
||||||
|
rma.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, rma.getDocStatus(), "Unexpected Document Status");
|
||||||
|
|
||||||
|
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
|
||||||
|
receipt.setDocStatus(DocAction.STATUS_Drafted);
|
||||||
|
receipt.setDocAction(DocAction.ACTION_Complete);
|
||||||
|
receipt.saveEx();
|
||||||
|
|
||||||
|
GridWindow gridWindow = GridWindow.get(Env.getCtx(), 1, SystemIDs.WINDOW_MATERIAL_RECEIPT);
|
||||||
|
assertNotNull(gridWindow, "Failed to load grid window of Material Receipt");
|
||||||
|
gridWindow.initTab(0);
|
||||||
|
GridTab gridTab = gridWindow.getTab(0);
|
||||||
|
MQuery query = new MQuery(MInOut.Table_Name);
|
||||||
|
query.addRestriction(MInOut.COLUMNNAME_M_InOut_ID, "=", receipt.get_ID());
|
||||||
|
gridTab.setQuery(query);
|
||||||
|
gridTab.getTableModel().setImportingMode(false, getTrxName());
|
||||||
|
gridTab.query(false);
|
||||||
|
|
||||||
|
assertEquals(1, gridTab.getRowCount(), "Unexpected number of row retrieve from DB");
|
||||||
|
assertEquals(receipt.get_ID(), gridTab.getRecord_ID(), "Wrong Material Receipt record id");
|
||||||
|
|
||||||
|
CreateFromShipmentImpl form = new CreateFromShipmentImpl(gridTab);
|
||||||
|
form.setTrxName(getTrxName());
|
||||||
|
ArrayList<KeyNamePair> RMAs = form.getRMAs(order.getC_BPartner_ID());
|
||||||
|
assertNotNull(RMAs, "Can't load RMAs for BP");
|
||||||
|
assertTrue(RMAs.size() > 0, "Can't load RMAsfor BP");
|
||||||
|
boolean found = false;
|
||||||
|
for(KeyNamePair knp : RMAs) {
|
||||||
|
if (knp.getKey() == rma.get_ID()) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(found, "Fail to load RMA");
|
||||||
|
|
||||||
|
form.loadRMALines(rma.get_ID());
|
||||||
|
assertTrue(form.minitable.getRowCount() > 0, "Failed to load data from DB");
|
||||||
|
|
||||||
|
form.minitable.setSelectedRow(-1);
|
||||||
|
for (int i = 0; i < form.minitable.getRowCount(); i++) {
|
||||||
|
KeyNamePair pp = (KeyNamePair) form.minitable.getValueAt(i, 7);
|
||||||
|
if (pp.getKey() == rmaLine.get_ID()) {
|
||||||
|
form.minitable.setValueAt(Boolean.TRUE, i, 0);
|
||||||
|
form.minitable.setSelectedRow(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(form.minitable.getSelectedRow() >= 0, "Failed to find RMA line record");
|
||||||
|
assertTrue(form.save(form.minitable, getTrxName()), "Failed to save changes");
|
||||||
|
|
||||||
|
receipt.load(getTrxName());
|
||||||
|
MInOutLine[] receiptLines = receipt.getLines(true);
|
||||||
|
assertEquals(1, receiptLines.length, "Unexpected number of Material Receipt Line records");
|
||||||
|
rmaLine.load(getTrxName());
|
||||||
|
assertEquals(rmaLine.get_ID(), receiptLines[0].getM_RMALine_ID(), "RMA line not match to material receipt line");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class CreateFromShipmentImpl extends CreateFromShipment {
|
||||||
|
|
||||||
|
private MiniTableImpl minitable = null;
|
||||||
|
|
||||||
|
public CreateFromShipmentImpl(GridTab mTab) {
|
||||||
|
super(mTab);
|
||||||
|
|
||||||
|
try {
|
||||||
|
dynInit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getWindow() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean dynInit() throws Exception {
|
||||||
|
super.dynInit();
|
||||||
|
minitable = new MiniTableImpl();
|
||||||
|
for(String column : getOISColumnNames()) {
|
||||||
|
minitable.addColumn(column);
|
||||||
|
}
|
||||||
|
configureMiniTable(minitable);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<KeyNamePair> getOrders(int C_BPartner_ID) {
|
||||||
|
return super.loadOrderData(C_BPartner_ID, false, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadOrderLines(int C_Order_ID) {
|
||||||
|
Vector<Vector<Object>> datas = super.getOrderData(C_Order_ID, false, MLocator.getDefault(MWarehouse.get(getM_Warehouse_ID())).getM_Locator_ID());
|
||||||
|
for(int i = 0; i < datas.size(); i++) {
|
||||||
|
minitable.setRowCount(i+1);
|
||||||
|
Vector<Object> data = datas.get(i);
|
||||||
|
for(int j = 0; j < data.size(); j++) {
|
||||||
|
minitable.setValueAt(data.get(j), i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<KeyNamePair> getInvoices(int C_BPartner_ID) {
|
||||||
|
return super.loadInvoiceData(C_BPartner_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadInvoiceLines(int C_Invoice_ID) {
|
||||||
|
Vector<Vector<Object>> datas = super.getInvoiceData(C_Invoice_ID, MLocator.getDefault(MWarehouse.get(getM_Warehouse_ID())).getM_Locator_ID());
|
||||||
|
for(int i = 0; i < datas.size(); i++) {
|
||||||
|
minitable.setRowCount(i+1);
|
||||||
|
Vector<Object> data = datas.get(i);
|
||||||
|
for(int j = 0; j < data.size(); j++) {
|
||||||
|
minitable.setValueAt(data.get(j), i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<KeyNamePair> getRMAs(int C_BPartner_ID) {
|
||||||
|
return super.loadRMAData(C_BPartner_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadRMALines(int M_RMA_ID) {
|
||||||
|
Vector<Vector<Object>> datas = super.getRMAData(M_RMA_ID, MLocator.getDefault(MWarehouse.get(getM_Warehouse_ID())).getM_Locator_ID());
|
||||||
|
for(int i = 0; i < datas.size(); i++) {
|
||||||
|
minitable.setRowCount(i+1);
|
||||||
|
Vector<Object> data = datas.get(i);
|
||||||
|
for(int j = 0; j < data.size(); j++) {
|
||||||
|
minitable.setValueAt(data.get(j), i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,180 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* This file is part of iDempiere ERP Open Source *
|
||||||
|
* http://www.idempiere.org *
|
||||||
|
* *
|
||||||
|
* Copyright (C) Contributors *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* 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., 51 Franklin Street, Fifth Floor, Boston, *
|
||||||
|
* MA 02110-1301, USA. *
|
||||||
|
* *
|
||||||
|
* Contributors: *
|
||||||
|
* - hengsin *
|
||||||
|
**********************************************************************/
|
||||||
|
package org.idempiere.test.form;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.compiere.grid.CreateFromStatement;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.GridWindow;
|
||||||
|
import org.compiere.model.MBankStatement;
|
||||||
|
import org.compiere.model.MBankStatementLine;
|
||||||
|
import org.compiere.model.MPayment;
|
||||||
|
import org.compiere.model.MQuery;
|
||||||
|
import org.compiere.model.SystemIDs;
|
||||||
|
import org.compiere.process.DocAction;
|
||||||
|
import org.compiere.process.ProcessInfo;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
|
import org.compiere.util.TimeUtil;
|
||||||
|
import org.compiere.wf.MWorkflow;
|
||||||
|
import org.idempiere.test.AbstractTestCase;
|
||||||
|
import org.idempiere.test.DictionaryIDs;
|
||||||
|
import org.idempiere.test.ui.MiniTableImpl;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CreateFromStatementFormTest extends AbstractTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default constructor
|
||||||
|
*/
|
||||||
|
public CreateFromStatementFormTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateFromPayments() {
|
||||||
|
MPayment payment = new MPayment(Env.getCtx(), 0, getTrxName());
|
||||||
|
payment.setC_DocType_ID(true);
|
||||||
|
payment.setC_BPartner_ID(DictionaryIDs.C_BPartner.JOE_BLOCK.id);
|
||||||
|
payment.setTenderType(MPayment.TENDERTYPE_DirectDebit);
|
||||||
|
int C_BankAccount_ID = DB.getSQLValueEx(getTrxName(), "SELECT C_BankAccount_ID FROM C_BankAccount WHERE IsActive='Y' AND AD_Client_ID=? "
|
||||||
|
+ "AND IsDefault='Y' ORDER BY C_BankAccount_ID", getAD_Client_ID());
|
||||||
|
payment.setC_BankAccount_ID(C_BankAccount_ID);
|
||||||
|
payment.setC_Currency_ID(Env.getContextAsInt(Env.getCtx(), Env.C_CURRENCY_ID));
|
||||||
|
payment.setPayAmt(new BigDecimal("10.00"));
|
||||||
|
payment.saveEx();
|
||||||
|
|
||||||
|
ProcessInfo pi = MWorkflow.runDocumentActionWorkflow(payment, DocAction.ACTION_Complete);
|
||||||
|
assertFalse(pi.isError(), pi.getSummary());
|
||||||
|
payment.load(getTrxName());
|
||||||
|
assertEquals(DocAction.STATUS_Completed, payment.getDocStatus(), "Unexpected document status");
|
||||||
|
|
||||||
|
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
|
||||||
|
MBankStatement stmt = new MBankStatement(Env.getCtx(), 0, getTrxName());
|
||||||
|
stmt.setC_BankAccount_ID(C_BankAccount_ID);
|
||||||
|
stmt.setDateAcct(today);
|
||||||
|
stmt.setName("testCreateFromPayments");
|
||||||
|
stmt.setStatementDate(today);
|
||||||
|
stmt.saveEx();
|
||||||
|
|
||||||
|
GridWindow gridWindow = GridWindow.get(Env.getCtx(), 1, SystemIDs.WINDOW_BANK_STATEMENT);
|
||||||
|
assertNotNull(gridWindow, "Failed to load grid window of Bank Statement");
|
||||||
|
gridWindow.initTab(0);
|
||||||
|
GridTab gridTab = gridWindow.getTab(0);
|
||||||
|
MQuery query = new MQuery(MBankStatement.Table_Name);
|
||||||
|
query.addRestriction(MBankStatement.COLUMNNAME_C_BankStatement_ID, "=", stmt.get_ID());
|
||||||
|
gridTab.setQuery(query);
|
||||||
|
gridTab.getTableModel().setImportingMode(false, getTrxName());
|
||||||
|
gridTab.query(false);
|
||||||
|
|
||||||
|
assertEquals(1, gridTab.getRowCount(), "Unexpected number of row retrieve from DB");
|
||||||
|
assertEquals(stmt.get_ID(), gridTab.getRecord_ID(), "Wrong Bank Statement record id");
|
||||||
|
|
||||||
|
CreateFromStatementImpl form = new CreateFromStatementImpl(gridTab);
|
||||||
|
form.setTrxName(getTrxName());
|
||||||
|
|
||||||
|
Timestamp dateFrom = TimeUtil.addDays(today, -1);
|
||||||
|
Timestamp dateTo = TimeUtil.addDays(today, 1);
|
||||||
|
form.loadPayments(C_BankAccount_ID, null, null, dateFrom, dateTo, null, null, payment.getC_DocType_ID(), null, null);
|
||||||
|
assertTrue(form.minitable.getRowCount() > 0, "Failed to load data from DB");
|
||||||
|
|
||||||
|
form.minitable.setSelectedRow(-1);
|
||||||
|
for (int i = 0; i < form.minitable.getRowCount(); i++) {
|
||||||
|
KeyNamePair pp = (KeyNamePair) form.minitable.getValueAt(i, 2);
|
||||||
|
if (pp.getKey() == payment.get_ID()) {
|
||||||
|
form.minitable.setValueAt(Boolean.TRUE, i, 0);
|
||||||
|
form.minitable.setSelectedRow(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(form.minitable.getSelectedRow() >= 0, "Failed to find payment record");
|
||||||
|
assertTrue(form.save(form.minitable, getTrxName()), "Failed to save changes");
|
||||||
|
|
||||||
|
stmt.load(getTrxName());
|
||||||
|
MBankStatementLine[] lines = stmt.getLines(true);
|
||||||
|
assertNotNull(lines, "Null bank statement line");
|
||||||
|
assertEquals(1, lines.length, "Unexpected number of bank statement line records");
|
||||||
|
assertEquals(payment.get_ID(), lines[0].getC_Payment_ID());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class CreateFromStatementImpl extends CreateFromStatement {
|
||||||
|
|
||||||
|
private MiniTableImpl minitable = null;
|
||||||
|
|
||||||
|
public CreateFromStatementImpl(GridTab mTab) {
|
||||||
|
super(mTab);
|
||||||
|
|
||||||
|
try {
|
||||||
|
dynInit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getWindow() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean dynInit() throws Exception {
|
||||||
|
super.dynInit();
|
||||||
|
minitable = new MiniTableImpl();
|
||||||
|
for(String column : getOISColumnNames()) {
|
||||||
|
minitable.addColumn(column);
|
||||||
|
}
|
||||||
|
configureMiniTable(minitable);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadPayments(Integer BankAccount, Integer BPartner, String DocumentNo,
|
||||||
|
Timestamp DateFrom, Timestamp DateTo, BigDecimal AmtFrom, BigDecimal AmtTo, Integer DocType,
|
||||||
|
String TenderType, String AuthCode) {
|
||||||
|
Vector<Vector<Object>> datas = super.getBankAccountData(BankAccount, BPartner, DocumentNo, DateFrom, DateTo, AmtFrom, AmtTo, DocType,
|
||||||
|
TenderType, AuthCode);
|
||||||
|
|
||||||
|
for(int i = 0; i < datas.size(); i++) {
|
||||||
|
minitable.setRowCount(i+1);
|
||||||
|
Vector<Object> data = datas.get(i);
|
||||||
|
for(int j = 0; j < data.size(); j++) {
|
||||||
|
minitable.setValueAt(data.get(j), i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue