Refactor project namespace from 'andromedia.midsuit' to 'balinusa.midsuit'
- Updated feature.xml to change plugin ID. - Modified MID_CalloutFactory.xml, MID_CreateFromFactory.xml, MID_DocFactory.xml, MID_FormFactory.xml, MID_ModelFactory.xml, MID_ProcessFactory.xml, and MID_ValidatorFactory.xml to reflect new namespace. - Adjusted MID_FormFactory.java and MID_ModelFactory.java to update class references and mappings. - Refactored MID_InsertIntoAllTable.java and MID_UploadPEB.java to change database URL references. - Created new MID_Product.java class to define product behavior under the new namespace.
This commit is contained in:
parent
72126805b6
commit
a7a5195e59
|
|
@ -17,7 +17,7 @@
|
|||
</license>
|
||||
|
||||
<plugin
|
||||
id="andromedia.midsuit.project"
|
||||
id="balinusa.midsuit.project"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="andromedia.midsuit.callout">
|
||||
<implementation class="andromedia.midsuit.factory.MID_CalloutFactory"/>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="balinusa.midsuit.callout">
|
||||
<implementation class="balinusa.midsuit.factory.MID_CalloutFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<service>
|
||||
<provide interface="org.adempiere.base.IColumnCalloutFactory"/>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="andromedia.midsuit.createFrom">
|
||||
<implementation class="andromedia.midsuit.factory.MID_CreateFromFactory"/>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="balinusa.midsuit.createFrom">
|
||||
<implementation class="balinusa.midsuit.factory.MID_CreateFromFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.ICreateFromFactory"/>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="andromedia.midsuit.Doc">
|
||||
<implementation class="andromedia.midsuit.factory.MID_DocFactory"/>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="balinusa.midsuit.Doc">
|
||||
<implementation class="balinusa.midsuit.factory.MID_DocFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<property name="gaap" type="String" value="*"/>
|
||||
<service>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="andromedia.midsuit.form">
|
||||
<implementation class="andromedia.midsuit.factory.MID_FormFactory"/>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="balinusa.midsuit.form">
|
||||
<implementation class="balinusa.midsuit.factory.MID_FormFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<service>
|
||||
<provide interface="org.adempiere.webui.factory.IFormFactory"/>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="andromedia.midsuit.project">
|
||||
<implementation class="andromedia.midsuit.factory.MID_ModelFactory"/>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="balinusa.midsuit.project">
|
||||
<implementation class="balinusa.midsuit.factory.MID_ModelFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<service>
|
||||
<provide interface="org.adempiere.base.IModelFactory"/>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="andromedia.midsuit.proces">
|
||||
<implementation class="andromedia.midsuit.factory.MID_ProcessFactory"/>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="balinusa.midsuit.proces">
|
||||
<implementation class="balinusa.midsuit.factory.MID_ProcessFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<service>
|
||||
<provide interface="org.adempiere.base.IProcessFactory"/>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="andromedia.midsuit.validator">
|
||||
<implementation class="andromedia.midsuit.factory.MID_ValidatorFactory"/>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="balinusa.midsuit.validator">
|
||||
<implementation class="balinusa.midsuit.factory.MID_ValidatorFactory"/>
|
||||
<reference bind="bindEventManager" cardinality="1..1" interface="org.adempiere.base.event.IEventManager" name="IEventManager" policy="static" unbind="unbindEventManager"/>
|
||||
</scr:component>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class MID_FormFactory implements IFormFactory {
|
|||
@Override
|
||||
public ADForm newFormInstance(String formName) {
|
||||
// TODO Auto-generated method stub
|
||||
if (formName.startsWith("andromedia.midsuit.form")) {
|
||||
if (formName.startsWith("balinusa.midsuit.form")) {
|
||||
Object form = null;
|
||||
Class<?> clazz = null;
|
||||
ClassLoader loader = getClass().getClassLoader();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import org.adempiere.base.IModelFactory;
|
|||
import org.compiere.model.MMovement;
|
||||
import org.compiere.model.MMovementLine;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.X_M_Product;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
import balinusa.midsuit.model.MID_Aging;
|
||||
|
|
@ -57,47 +58,48 @@ public class MID_ModelFactory implements IModelFactory{
|
|||
private static HashMap<String, String> mapTableModels = new HashMap<String, String>();
|
||||
static {
|
||||
//Ex mapTableModels.put(MOrderLine.Table_Name, "org.semeru.project.model.SMT_MOrderLine");
|
||||
mapTableModels.put(MID_MRequisitionTrx.Table_Name, "andromedia.midsuit.model.MID_MRequisitionTrx");
|
||||
mapTableModels.put(MID_MRequisitionTrxLine.Table_Name, "andromedia.midsuit.model.MID_MRequisitionTrxLine");
|
||||
mapTableModels.put(X_zpos_Cashier.Table_Name, "andromedia.midsuit.model.X_zpos_Cashier");
|
||||
mapTableModels.put(MID_Aging.Table_Name, "andromedia.midsuit.model.MID_Aging");
|
||||
mapTableModels.put(MID_MBillingList.Table_Name, "andromedia.midsuit.model.MID_MBillingList");
|
||||
mapTableModels.put(MID_MBillingListLine.Table_Name, "andromedia.midsuit.model.MID_MBillingListLine");
|
||||
mapTableModels.put(MID_PPO.Table_Name, "andromedia.midsuit.model.MID_PPO");
|
||||
mapTableModels.put(MID_MProductionConfirm.Table_Name, "andromedia.midsuit.model.MID_MProductionConfirm");
|
||||
mapTableModels.put(MID_Analysis.Table_Name, "andromedia.midsuit.model.MID_Analysis");
|
||||
mapTableModels.put(MID_AnalysisPro.Table_Name, "andromedia.midsuit.model.MID_AnalysisPro");
|
||||
mapTableModels.put(MID_AnalysisLine.Table_Name, "andromedia.midsuit.model.MID_AnalysisLine");
|
||||
mapTableModels.put(MID_MDDOrder.Table_Name, "andromedia.midsuit.model.MID_MDDOrder");
|
||||
mapTableModels.put(MID_MDDOrderLine.Table_Name, "andromedia.midsuit.model.MID_MDDOrderLine");
|
||||
mapTableModels.put(MID_PPOLine.Table_Name, "andromedia.midsuit.model.MID_PPOLine");
|
||||
mapTableModels.put(X_C_OrderLineMA.Table_Name, "andromedia.midsuit.model.X_C_OrderLineMA");
|
||||
mapTableModels.put(X_M_RMAMA.Table_Name, "andromedia.midsuit.model.X_M_RMAMA");
|
||||
mapTableModels.put(MID_MRequisition.Table_Name, "andromedia.midsuit.model.MID_MRequisition");
|
||||
mapTableModels.put(MID_MRequisitionLine.Table_Name, "andromedia.midsuit.model.MID_MRequisitionLine");
|
||||
mapTableModels.put(MID_MDepreciationEntry.Table_Name, "andromedia.midsuit.model.MID_MDepreciationEntry");
|
||||
mapTableModels.put(MID_MAssetAddition.Table_Name, "andromedia.midsuit.model.MID_MAssetAddition");
|
||||
mapTableModels.put(MID_MAssetDisposed.Table_Name, "andromedia.midsuit.model.MID_MAssetDisposed");
|
||||
mapTableModels.put(MID_UnrealizedRate.Table_Name, "andromedia.midsuit.model.MID_UnrealizedRate");
|
||||
mapTableModels.put(MID_UnrealizedRateLine.Table_Name, "andromedia.midsuit.model.MID_UnrealizedRateLine");
|
||||
mapTableModels.put(MID_MOrder.Table_Name, "andromedia.midsuit.model.MID_MOrder");
|
||||
mapTableModels.put(MMovement.Table_Name, "andromedia.midsuit.model.MID_MMovement");
|
||||
mapTableModels.put(MMovementLine.Table_Name, "andromedia.midsuit.model.MID_MMovementLine");
|
||||
mapTableModels.put(X_MID_UploadPEBLine.Table_Name, "andromedia.midsuit.model.X_MID_UploadPEBLine");
|
||||
mapTableModels.put(X_MID_UploadPEB.Table_Name, "andromedia.midsuit.model.X_MID_UploadPEB");
|
||||
mapTableModels.put(X_MID_UploadTPB.Table_Name, "andromedia.midsuit.model.X_MID_UploadTPB");
|
||||
mapTableModels.put(X_MID_UploadTPBLine.Table_Name, "andromedia.midsuit.model.X_MID_UploadTPBLine");
|
||||
mapTableModels.put(X_MID_UploadTPBLineDet.Table_Name, "andromedia.midsuit.model.X_MID_UploadTPBLineDet");
|
||||
mapTableModels.put(MID_MInventory.Table_Name, "andromedia.midsuit.model.MID_MInventory");
|
||||
mapTableModels.put(X_M_RequisitionTax.Table_Name, "andromedia.midsuit.model.X_M_RequisitionTax");
|
||||
mapTableModels.put(MID_MPayment.Table_Name, "andromedia.midsuit.model.MID_MPayment");
|
||||
mapTableModels.put(X_mid_ceisa_upload.Table_Name, "andromedia.midsuit.model.X_mid_ceisa_upload");
|
||||
mapTableModels.put(MID_Ceisa_Order.Table_Name, "andromedia.midsuit.model.MID_Ceisa_Order");
|
||||
mapTableModels.put(X_mid_ceisa_entitas.Table_Name, "andromedia.midsuit.model.X_mid_ceisa_entitas");
|
||||
mapTableModels.put(X_mid_ceisa_orderline.Table_Name, "andromedia.midsuit.model.X_mid_ceisa_orderline");
|
||||
mapTableModels.put(MWarehouse.Table_Name, "andromedia.midsuit.model.MWarehouse");
|
||||
mapTableModels.put(MID_MInvoice.Table_Name, "andromedia.midsuit.model.MID_MInvoice");
|
||||
mapTableModels.put(MID_MOrderLine.Table_Name, "andromedia.midsuit.model.MID_MOrderLine");
|
||||
mapTableModels.put(X_M_Product.Table_Name, "balinusa.midsuit.model.MID_Product");
|
||||
mapTableModels.put(MID_MRequisitionTrx.Table_Name, "balinusa.midsuit.model.MID_MRequisitionTrx");
|
||||
mapTableModels.put(MID_MRequisitionTrxLine.Table_Name, "balinusa.midsuit.model.MID_MRequisitionTrxLine");
|
||||
mapTableModels.put(X_zpos_Cashier.Table_Name, "balinusa.midsuit.model.X_zpos_Cashier");
|
||||
mapTableModels.put(MID_Aging.Table_Name, "balinusa.midsuit.model.MID_Aging");
|
||||
mapTableModels.put(MID_MBillingList.Table_Name, "balinusa.midsuit.model.MID_MBillingList");
|
||||
mapTableModels.put(MID_MBillingListLine.Table_Name, "balinusa.midsuit.model.MID_MBillingListLine");
|
||||
mapTableModels.put(MID_PPO.Table_Name, "balinusa.midsuit.model.MID_PPO");
|
||||
mapTableModels.put(MID_MProductionConfirm.Table_Name, "balinusa.midsuit.model.MID_MProductionConfirm");
|
||||
mapTableModels.put(MID_Analysis.Table_Name, "balinusa.midsuit.model.MID_Analysis");
|
||||
mapTableModels.put(MID_AnalysisPro.Table_Name, "balinusa.midsuit.model.MID_AnalysisPro");
|
||||
mapTableModels.put(MID_AnalysisLine.Table_Name, "balinusa.midsuit.model.MID_AnalysisLine");
|
||||
mapTableModels.put(MID_MDDOrder.Table_Name, "balinusa.midsuit.model.MID_MDDOrder");
|
||||
mapTableModels.put(MID_MDDOrderLine.Table_Name, "balinusa.midsuit.model.MID_MDDOrderLine");
|
||||
mapTableModels.put(MID_PPOLine.Table_Name, "balinusa.midsuit.model.MID_PPOLine");
|
||||
mapTableModels.put(X_C_OrderLineMA.Table_Name, "balinusa.midsuit.model.X_C_OrderLineMA");
|
||||
mapTableModels.put(X_M_RMAMA.Table_Name, "balinusa.midsuit.model.X_M_RMAMA");
|
||||
mapTableModels.put(MID_MRequisition.Table_Name, "balinusa.midsuit.model.MID_MRequisition");
|
||||
mapTableModels.put(MID_MRequisitionLine.Table_Name, "balinusa.midsuit.model.MID_MRequisitionLine");
|
||||
mapTableModels.put(MID_MDepreciationEntry.Table_Name, "balinusa.midsuit.model.MID_MDepreciationEntry");
|
||||
mapTableModels.put(MID_MAssetAddition.Table_Name, "balinusa.midsuit.model.MID_MAssetAddition");
|
||||
mapTableModels.put(MID_MAssetDisposed.Table_Name, "balinusa.midsuit.model.MID_MAssetDisposed");
|
||||
mapTableModels.put(MID_UnrealizedRate.Table_Name, "balinusa.midsuit.model.MID_UnrealizedRate");
|
||||
mapTableModels.put(MID_UnrealizedRateLine.Table_Name, "balinusa.midsuit.model.MID_UnrealizedRateLine");
|
||||
mapTableModels.put(MID_MOrder.Table_Name, "balinusa.midsuit.model.MID_MOrder");
|
||||
mapTableModels.put(MMovement.Table_Name, "balinusa.midsuit.model.MID_MMovement");
|
||||
mapTableModels.put(MMovementLine.Table_Name, "balinusa.midsuit.model.MID_MMovementLine");
|
||||
mapTableModels.put(X_MID_UploadPEBLine.Table_Name, "balinusa.midsuit.model.X_MID_UploadPEBLine");
|
||||
mapTableModels.put(X_MID_UploadPEB.Table_Name, "balinusa.midsuit.model.X_MID_UploadPEB");
|
||||
mapTableModels.put(X_MID_UploadTPB.Table_Name, "balinusa.midsuit.model.X_MID_UploadTPB");
|
||||
mapTableModels.put(X_MID_UploadTPBLine.Table_Name, "balinusa.midsuit.model.X_MID_UploadTPBLine");
|
||||
mapTableModels.put(X_MID_UploadTPBLineDet.Table_Name, "balinusa.midsuit.model.X_MID_UploadTPBLineDet");
|
||||
mapTableModels.put(MID_MInventory.Table_Name, "balinusa.midsuit.model.MID_MInventory");
|
||||
mapTableModels.put(X_M_RequisitionTax.Table_Name, "balinusa.midsuit.model.X_M_RequisitionTax");
|
||||
mapTableModels.put(MID_MPayment.Table_Name, "balinusa.midsuit.model.MID_MPayment");
|
||||
mapTableModels.put(X_mid_ceisa_upload.Table_Name, "balinusa.midsuit.model.X_mid_ceisa_upload");
|
||||
mapTableModels.put(MID_Ceisa_Order.Table_Name, "balinusa.midsuit.model.MID_Ceisa_Order");
|
||||
mapTableModels.put(X_mid_ceisa_entitas.Table_Name, "balinusa.midsuit.model.X_mid_ceisa_entitas");
|
||||
mapTableModels.put(X_mid_ceisa_orderline.Table_Name, "balinusa.midsuit.model.X_mid_ceisa_orderline");
|
||||
mapTableModels.put(MWarehouse.Table_Name, "balinusa.midsuit.model.MWarehouse");
|
||||
mapTableModels.put(MID_MInvoice.Table_Name, "balinusa.midsuit.model.MID_MInvoice");
|
||||
mapTableModels.put(MID_MOrderLine.Table_Name, "balinusa.midsuit.model.MID_MOrderLine");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,420 @@
|
|||
package balinusa.midsuit.model;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MAccount;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MAttributeSetInstance;
|
||||
import org.compiere.model.MClient;
|
||||
import org.compiere.model.MClientInfo;
|
||||
import org.compiere.model.MCost;
|
||||
import org.compiere.model.MCostElement;
|
||||
import org.compiere.model.MOrderLine;
|
||||
import org.compiere.model.MOrg;
|
||||
import org.compiere.model.MProduct;
|
||||
import org.compiere.model.MProductCategory;
|
||||
import org.compiere.model.MRequisitionLine;
|
||||
import org.compiere.model.MSequence;
|
||||
import org.compiere.model.MStorageOnHand;
|
||||
import org.compiere.model.MStorageReservation;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.model.MTree;
|
||||
import org.compiere.model.MTreeNode;
|
||||
import org.compiere.model.MTree_Base;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.X_AD_Tree;
|
||||
import org.compiere.model.X_M_CostElement;
|
||||
import org.compiere.model.X_M_Product;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
import org.eevolution.model.MPPProductBOM;
|
||||
import org.eevolution.model.MPPProductBOMLine;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
public class MID_Product extends MProduct{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1563913040977233621L;
|
||||
private boolean isValueEmptyBeforeSave = false;
|
||||
private static CLogger s_log = CLogger.getCLogger (MCost.class);
|
||||
|
||||
public MID_Product(Properties ctx, int mid_ceisa_order_ID, String trxName) {
|
||||
super(ctx, mid_ceisa_order_ID, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
/** UOM Precision */
|
||||
private Integer m_precision = null;
|
||||
|
||||
/**
|
||||
* Verify that product has no on hand, ordered and reserved quantity.
|
||||
* @return error message or empty string
|
||||
*/
|
||||
private String verifyStorage() {
|
||||
BigDecimal qtyOnHand = Env.ZERO;
|
||||
BigDecimal qtyOrdered = Env.ZERO;
|
||||
BigDecimal qtyReserved = Env.ZERO;
|
||||
for (MStorageOnHand ohs: MStorageOnHand.getOfProduct(getCtx(), get_ID(), get_TrxName()))
|
||||
{
|
||||
qtyOnHand = qtyOnHand.add(ohs.getQtyOnHand());
|
||||
}
|
||||
for (MStorageReservation rs : MStorageReservation.getOfProduct(getCtx(), get_ID(), get_TrxName()))
|
||||
{
|
||||
if (rs.isSOTrx())
|
||||
qtyReserved = qtyReserved.add(rs.getQty());
|
||||
else
|
||||
qtyOrdered = qtyOrdered.add(rs.getQty());
|
||||
}
|
||||
|
||||
StringBuilder errMsg = new StringBuilder();
|
||||
if (qtyOnHand.signum() != 0)
|
||||
errMsg.append("@QtyOnHand@ = ").append(qtyOnHand);
|
||||
if (qtyOrdered.signum() != 0)
|
||||
errMsg.append(" - @QtyOrdered@ = ").append(qtyOrdered);
|
||||
if (qtyReserved.signum() != 0)
|
||||
errMsg.append(" - @QtyReserved@").append(qtyReserved);
|
||||
return errMsg.toString();
|
||||
}
|
||||
/**
|
||||
* Delete storage on hand and reservation records.<br/>
|
||||
* For product that's using Lot or Serial, on hand is update to zero instead of delete.
|
||||
*/
|
||||
private void removeStorageRecords() {
|
||||
int cnt = 0;
|
||||
//safe to remove if not using lot or serial
|
||||
if (isLot() || isSerial()) {
|
||||
//for lot/serial, make sure everything is zero
|
||||
cnt = DB.executeUpdateEx("UPDATE M_StorageOnHand SET QtyOnHand=0 WHERE M_Product_ID=? AND QtyOnHand != 0", new Object[] {getM_Product_ID()}, get_TrxName());
|
||||
if (log.isLoggable(Level.INFO)) {
|
||||
log.log(Level.INFO, toString()+" #M_StorageOnHand Updated=" + cnt);
|
||||
}
|
||||
} else {
|
||||
cnt = DB.executeUpdateEx("DELETE FROM M_StorageOnHand WHERE M_Product_ID=?", new Object[] {getM_Product_ID()}, get_TrxName());
|
||||
if (log.isLoggable(Level.INFO)) {
|
||||
log.log(Level.INFO, toString()+" #M_StorageOnHand Deleted=" + cnt);
|
||||
}
|
||||
}
|
||||
|
||||
//clear all reservation data
|
||||
cnt = DB.executeUpdateEx("DELETE FROM M_StorageReservation WHERE M_Product_ID=?", new Object[] {getM_Product_ID()}, get_TrxName());
|
||||
if (log.isLoggable(Level.INFO)) {
|
||||
log.log(Level.INFO, toString()+" #M_StorageReservation Deleted=" + cnt);
|
||||
}
|
||||
cnt = DB.executeUpdateEx("DELETE FROM M_StorageReservationLog WHERE M_Product_ID=?", new Object[] {getM_Product_ID()}, get_TrxName());
|
||||
if (log.isLoggable(Level.INFO)) {
|
||||
log.log(Level.INFO, toString()+" #M_StorageReservationLog Deleted=" + cnt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify product not in any active BOM.
|
||||
* @return error message or null
|
||||
*/
|
||||
private String verifyBOM() {
|
||||
Query query = new Query(getCtx(), MPPProductBOMLine.Table_Name, MPPProductBOMLine.COLUMNNAME_M_Product_ID+"=?", get_TrxName());
|
||||
List<MPPProductBOMLine> list = query.setOnlyActiveRecords(true)
|
||||
.setClient_ID()
|
||||
.setParameters(getM_Product_ID())
|
||||
.list();
|
||||
for(MPPProductBOMLine line : list) {
|
||||
MPPProductBOM bom = line.getParent();
|
||||
if (bom.isActive()) {
|
||||
StringBuilder errMsg = new StringBuilder();
|
||||
errMsg.append(Msg.getMsg(Env.getCtx(), "DeActivateProductInActiveBOM"));
|
||||
String bomName = bom.getName();
|
||||
errMsg.append(" (BOM: ")
|
||||
.append(bomName);
|
||||
String parentValue = MProduct.get(bom.getM_Product_ID()).getValue();
|
||||
if (!parentValue.equals(bomName))
|
||||
errMsg.append(", ").append(parentValue);
|
||||
errMsg.append(")");
|
||||
return errMsg.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected boolean beforeSave(boolean newRecord) {
|
||||
if (newRecord && (getValue() == null || getValue().isEmpty())) {
|
||||
isValueEmptyBeforeSave = true; // simpan status ini
|
||||
}
|
||||
|
||||
// Check Storage
|
||||
if (!newRecord && //
|
||||
((is_ValueChanged("IsActive") && !isActive()) // now not active
|
||||
|| (is_ValueChanged("IsStocked") && !isStocked()) // now not stocked
|
||||
|| (is_ValueChanged("ProductType") // from Item
|
||||
&& PRODUCTTYPE_Item.equals(get_ValueOld("ProductType")))))
|
||||
{
|
||||
String errMsg = verifyStorage();
|
||||
if (! Util.isEmpty(errMsg))
|
||||
{
|
||||
log.saveError("Error", Msg.parseTranslation(getCtx(), errMsg));
|
||||
return false;
|
||||
}
|
||||
|
||||
removeStorageRecords();
|
||||
|
||||
// check bom
|
||||
if (is_ValueChanged("IsActive") && !isActive())
|
||||
{
|
||||
errMsg = verifyBOM();
|
||||
if (! Util.isEmpty(errMsg))
|
||||
{
|
||||
log.saveError("Error", errMsg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // storage
|
||||
|
||||
// it checks if UOM has been changed , if so disallow the change if the condition is true.
|
||||
if ((!newRecord) && is_ValueChanged("C_UOM_ID") && hasInventoryOrCost ()) {
|
||||
log.saveError("Error", Msg.getMsg(getCtx(), "SaveUomError"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset Stocked if not Item
|
||||
//AZ Goodwill: Bug Fix isStocked always return false
|
||||
if (!PRODUCTTYPE_Item.equals(getProductType()))
|
||||
setIsStocked(false);
|
||||
|
||||
// UOM reset
|
||||
if (m_precision != null && is_ValueChanged("C_UOM_ID"))
|
||||
m_precision = null;
|
||||
|
||||
// AttributeSetInstance reset
|
||||
if (getM_AttributeSetInstance_ID() > 0 && is_ValueChanged(COLUMNNAME_M_AttributeSet_ID))
|
||||
{
|
||||
MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(), getM_AttributeSetInstance_ID(), get_TrxName());
|
||||
if (asi.getM_AttributeSet_ID() != getM_AttributeSet_ID())
|
||||
setM_AttributeSetInstance_ID(0);
|
||||
}
|
||||
if (!newRecord && is_ValueChanged(COLUMNNAME_M_AttributeSetInstance_ID))
|
||||
{
|
||||
// IDEMPIERE-2752 check if the ASI is referenced in other products before trying to delete it
|
||||
int oldasiid = get_ValueOldAsInt(COLUMNNAME_M_AttributeSetInstance_ID);
|
||||
if (oldasiid > 0) {
|
||||
MAttributeSetInstance oldasi = new MAttributeSetInstance(getCtx(), get_ValueOldAsInt(COLUMNNAME_M_AttributeSetInstance_ID), get_TrxName());
|
||||
int cnt = DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM M_Product WHERE M_AttributeSetInstance_ID=?", oldasi.getM_AttributeSetInstance_ID());
|
||||
if (cnt == 1) {
|
||||
// Delete the old m_attributesetinstance
|
||||
try {
|
||||
oldasi.deleteEx(true, get_TrxName());
|
||||
} catch (AdempiereException ex)
|
||||
{
|
||||
log.saveError("Error", "Error deleting the AttributeSetInstance");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean afterSave(boolean newRecord, boolean success) {
|
||||
if (!success)
|
||||
return success;
|
||||
|
||||
if (success && newRecord && isValueEmptyBeforeSave) {
|
||||
String year = new java.text.SimpleDateFormat("yyyy").format(new java.util.Date());
|
||||
String newValue = getValue() + "-" + year;
|
||||
MID_Product product = new MID_Product(getCtx(), getM_Product_ID(), get_TrxName());
|
||||
product.setValue(newValue);
|
||||
if (!product.save()) {
|
||||
throw new AdempiereException("Failed to update product value after save");
|
||||
}
|
||||
}
|
||||
// Value/Name change in Account
|
||||
if (!newRecord && (is_ValueChanged("Value") || is_ValueChanged("Name")))
|
||||
MAccount.updateValueDescription(getCtx(), "M_Product_ID=" + getM_Product_ID(), get_TrxName());
|
||||
|
||||
// Name/Description Change in Asset MAsset.setValueNameDescription
|
||||
if (!newRecord && (is_ValueChanged("Name") || is_ValueChanged("Description")))
|
||||
{
|
||||
String sql = "UPDATE A_Asset a "
|
||||
+ "SET (Name, Description)="
|
||||
+ "(SELECT SUBSTR((SELECT bp.Name FROM C_BPartner bp WHERE bp.C_BPartner_ID=a.C_BPartner_ID) || ' - ' || p.Name,1,60), p.Description "
|
||||
+ "FROM M_Product p "
|
||||
+ "WHERE p.M_Product_ID=a.M_Product_ID) "
|
||||
+ "WHERE IsActive='Y'"
|
||||
+ " AND M_Product_ID=" + getM_Product_ID();
|
||||
int no = DB.executeUpdate(sql, get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Asset Description updated #" + no);
|
||||
}
|
||||
|
||||
// New - Acct, Tree, Old Costing
|
||||
if (newRecord)
|
||||
{
|
||||
insert_Accounting("M_Product_Acct", "M_Product_Category_Acct",
|
||||
"p.M_Product_Category_ID=" +
|
||||
(getM_Product_Category_ID() > MTable.MAX_OFFICIAL_ID && Env.isLogMigrationScript(get_TableName())
|
||||
? "toRecordId('M_Product_Category',"+DB.TO_STRING(MProductCategory.get(getM_Product_Category_ID()).getM_Product_Category_UU())+")"
|
||||
: getM_Product_Category_ID()));
|
||||
insert_Tree(X_AD_Tree.TREETYPE_Product);
|
||||
}
|
||||
if (newRecord || is_ValueChanged(COLUMNNAME_Value))
|
||||
update_Tree(MTree_Base.TREETYPE_Product);
|
||||
|
||||
// New Costing
|
||||
if (newRecord || is_ValueChanged("M_Product_Category_ID")) {
|
||||
createCost(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!newRecord && success && is_ValueChanged(COLUMNNAME_IsActive))
|
||||
{
|
||||
if (!isActive() && isBOM())
|
||||
{
|
||||
StringBuilder where = new StringBuilder();
|
||||
where.append("AD_Client_ID=? ")
|
||||
.append("AND M_Product_ID=? ")
|
||||
.append("AND IsActive='Y'");
|
||||
Query query = new Query(Env.getCtx(), MPPProductBOM.Table_Name, where.toString(), get_TrxName());
|
||||
List<MPPProductBOM> boms = query.setParameters(getAD_Client_ID(), getM_Product_ID()).list();
|
||||
for(MPPProductBOM bom : boms)
|
||||
{
|
||||
bom.setIsActive(false);
|
||||
bom.saveEx();
|
||||
}
|
||||
}
|
||||
}
|
||||
return success;
|
||||
|
||||
}
|
||||
protected static void createCost (MProduct product)
|
||||
{
|
||||
|
||||
// Cost Elements
|
||||
MCostElement[] ces = MCostElement.getCostingMethods(product);
|
||||
MCostElement ce = null;
|
||||
for (MCostElement element : ces) {
|
||||
if (X_M_CostElement.COSTINGMETHOD_StandardCosting.equals(element.getCostingMethod()))
|
||||
{
|
||||
ce = element;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ce == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MAcctSchema[] mass = MAcctSchema.getClientAcctSchema(product.getCtx(),
|
||||
product.getAD_Client_ID(), product.get_TrxName());
|
||||
MOrg[] orgs = null;
|
||||
|
||||
int M_ASI_ID = 0; // No Attribute
|
||||
for (MAcctSchema as : mass)
|
||||
{
|
||||
String cl = product.getCostingLevel(as);
|
||||
// Create Std Costing
|
||||
if (MAcctSchema.COSTINGLEVEL_Client.equals(cl))
|
||||
{
|
||||
createCostingRecord(product, M_ASI_ID, as, 0,ce.getM_CostElement_ID() );
|
||||
}
|
||||
else if (MAcctSchema.COSTINGLEVEL_Organization.equals(cl))
|
||||
{
|
||||
if (as.getAD_OrgOnly_ID() > 0 && MOrg.get(product.getCtx(), as.getAD_OrgOnly_ID()).isSummary())
|
||||
{
|
||||
MClient client = MClient.get(product.getCtx(), product.getAD_Client_ID());
|
||||
MClientInfo ci = client.getInfo();
|
||||
MTree vTree = new MTree (product.getCtx(), ci.getAD_Tree_Org_ID(), false, true, true, product.get_TrxName());
|
||||
|
||||
MTreeNode root = vTree.getRoot();
|
||||
createForChildOrg(root, product, as, M_ASI_ID, ce, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (orgs == null)
|
||||
orgs = MOrg.getOfClient(product);
|
||||
|
||||
for (MOrg o : orgs)
|
||||
{
|
||||
if (o.isSummary())
|
||||
continue;
|
||||
if (as.getAD_OrgOnly_ID() == o.getAD_Org_ID() || as.getAD_OrgOnly_ID() == 0)
|
||||
{
|
||||
createCostingRecord(product, M_ASI_ID, as, o.getAD_Org_ID(), ce.getM_CostElement_ID() );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
s_log.warning("Not created: Std.Cost for " + product.getName()
|
||||
+ " - Costing Level on Batch/Lot");
|
||||
}// accounting schema loop
|
||||
}
|
||||
} // create
|
||||
/**
|
||||
* Create costing record (MCost).
|
||||
* @param product
|
||||
* @param M_ASI_ID
|
||||
* @param as
|
||||
* @param AD_Org_ID
|
||||
* @param M_CostElement_ID
|
||||
*/
|
||||
private static void createCostingRecord(MProduct product,int M_ASI_ID, MAcctSchema as, int AD_Org_ID, int M_CostElement_ID) {
|
||||
MCost cost = MCost.get (product, M_ASI_ID,
|
||||
as, AD_Org_ID, M_CostElement_ID, product.get_TrxName());
|
||||
if (cost.is_new())
|
||||
{
|
||||
if (cost.save()) {
|
||||
if (s_log.isLoggable(Level.CONFIG)) s_log.config("Std.Cost for " + product.getName()
|
||||
+ " - " + as.getName());
|
||||
} else {
|
||||
s_log.warning("Not created: Std.Cost for " + product.getName()
|
||||
+ " - " + as.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Organization costing level - create costing records for child organization
|
||||
* @param root
|
||||
* @param product
|
||||
* @param as
|
||||
* @param M_ASI_ID
|
||||
* @param ce
|
||||
* @param found
|
||||
*/
|
||||
private static void createForChildOrg(MTreeNode root, MProduct product, MAcctSchema as, int M_ASI_ID, MCostElement ce, boolean found)
|
||||
{
|
||||
int parentId = root.getNode_ID();
|
||||
if (!found)
|
||||
found = (parentId == as.getAD_OrgOnly_ID());
|
||||
Enumeration<?> nodeEnum = root.children();
|
||||
MTreeNode child = null;
|
||||
while(nodeEnum.hasMoreElements())
|
||||
{
|
||||
child = (MTreeNode)nodeEnum.nextElement();
|
||||
if (child != null && child.getChildCount() > 0)
|
||||
{
|
||||
createForChildOrg(child, product, as, M_ASI_ID, ce, found);
|
||||
}
|
||||
else if (found)
|
||||
{
|
||||
int orgId = child.getNode_ID();
|
||||
MOrg org = MOrg.get(product.getCtx(), orgId);
|
||||
if (!org.isSummary())
|
||||
createCostingRecord(product, M_ASI_ID, as, orgId, ce.getM_CostElement_ID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
|||
"compiere.model", // globalqss allow compatibility with other plugins
|
||||
"adempiere.model", // Extensions
|
||||
"org.adempiere.model",
|
||||
"andromedia.midsuit.model"
|
||||
"balinusa.midsuit.model"
|
||||
};
|
||||
|
||||
public Class<?> getClass(String tableName) {
|
||||
|
|
@ -309,7 +309,7 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
|||
return clazz;
|
||||
}
|
||||
|
||||
clazz = getPOclass("andromedia.midsuit.model.X_" + tableName, tableName);
|
||||
clazz = getPOclass("balinusa.midsuit.model.X_" + tableName, tableName);
|
||||
if (clazz != null)
|
||||
{
|
||||
s_classCache.put(tableName, clazz);
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ public class MID_UploadPEB extends SvrProcess{
|
|||
private void readAccess(File TPB) throws Exception{
|
||||
String msg = "";
|
||||
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
|
||||
String databaseURL = "jdbc:ucanaccess://" + TPB.getPath() + ";jackcessOpener=andromedia.midsuit.process.CryptCodecOpener";
|
||||
String databaseURL = "jdbc:ucanaccess://" + TPB.getPath() + ";jackcessOpener=balinusa.midsuit.process.CryptCodecOpener";
|
||||
try (Connection conn = DriverManager.getConnection(databaseURL)) {
|
||||
|
||||
String sql = "SELECT * FROM tblPebHdr";
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ public class MID_UploadPEBOrder extends SvrProcess{
|
|||
private void readAccess(File TPB, MID_MOrder order) throws Exception{
|
||||
String msg = "";
|
||||
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
|
||||
String databaseURL = "jdbc:ucanaccess://" + TPB.getPath() + ";jackcessOpener=andromedia.midsuit.process.CryptCodecOpener";
|
||||
String databaseURL = "jdbc:ucanaccess://" + TPB.getPath() + ";jackcessOpener=balinusa.midsuit.process.CryptCodecOpener";
|
||||
try (Connection conn = DriverManager.getConnection(databaseURL)) {
|
||||
|
||||
String sql = "SELECT * FROM tblPebHdr";
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public class MID_UploadPEBWindow extends SvrProcess{
|
|||
private void readAccess(File TPB, X_MID_UploadPEB peb) throws Exception{
|
||||
String msg = "";
|
||||
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
|
||||
String databaseURL = "jdbc:ucanaccess://" + TPB.getPath() + ";jackcessOpener=andromedia.midsuit.process.CryptCodecOpener";
|
||||
String databaseURL = "jdbc:ucanaccess://" + TPB.getPath() + ";jackcessOpener=balinusa.midsuit.process.CryptCodecOpener";
|
||||
try (Connection conn = DriverManager.getConnection(databaseURL)) {
|
||||
|
||||
String sql = "SELECT * FROM tblPebHdr";
|
||||
|
|
|
|||
Loading…
Reference in New Issue