Compare commits
10 Commits
34bd52134b
...
0bd6eeb7e0
| Author | SHA1 | Date |
|---|---|---|
|
|
0bd6eeb7e0 | |
|
|
7d516dffb8 | |
|
|
5c0439178d | |
|
|
9e06e5da46 | |
|
|
c5907186e5 | |
|
|
82ddd9984a | |
|
|
054818d41d | |
|
|
8cff305095 | |
|
|
6750c29996 | |
|
|
8619e9fb6c |
|
|
@ -22,6 +22,8 @@ public class MID_CalloutOrderCeisa extends CalloutEngine implements IColumnCallo
|
|||
MOrder order = new MOrder(ctx, (int) value, null);
|
||||
mTab.setValue(X_mid_ceisa_order.COLUMNNAME_M_PriceList_ID, order.getM_PriceList_ID());
|
||||
mTab.setValue(X_mid_ceisa_order.COLUMNNAME_M_Warehouse_ID, order.getM_Warehouse_ID());
|
||||
mTab.setValue("C_BPartner_ID", order.get_ValueAsInt("C_BPartner_ID"));
|
||||
mTab.setValue("C_BPartner_Location_ID", order.get_ValueAsInt("C_BPartner_Location_ID"));
|
||||
}
|
||||
if (mField.getColumnName().equals(X_mid_ceisa_order.COLUMNNAME_M_Requisition_ID)) {
|
||||
if (value == null)
|
||||
|
|
@ -29,12 +31,16 @@ public class MID_CalloutOrderCeisa extends CalloutEngine implements IColumnCallo
|
|||
MRequisition req = new MRequisition(ctx, (int) value, null);
|
||||
mTab.setValue(X_mid_ceisa_order.COLUMNNAME_M_PriceList_ID, req.getM_PriceList_ID());
|
||||
mTab.setValue(X_mid_ceisa_order.COLUMNNAME_M_Warehouse_ID, req.getM_Warehouse_ID());
|
||||
mTab.setValue("C_BPartner_ID", req.get_ValueAsInt("C_BPartner_ID"));
|
||||
mTab.setValue("C_BPartner_Location_ID", req.get_ValueAsInt("C_BPartner_Location_ID"));
|
||||
}
|
||||
if (mField.getColumnName().equals(X_mid_ceisa_order.COLUMNNAME_M_RMA_ID)) {
|
||||
if (value == null)
|
||||
return "";
|
||||
MRMA rma = new MRMA(ctx, (int) value, null);
|
||||
mTab.setValue(X_mid_ceisa_order.COLUMNNAME_M_Warehouse_ID, rma.getInOut().getM_Warehouse_ID());
|
||||
mTab.setValue("C_BPartner_ID", rma.get_ValueAsInt("C_BPartner_ID"));
|
||||
mTab.setValue("C_BPartner_Location_ID", rma.get_ValueAsInt("C_BPartner_Location_ID"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import andromedia.midsuit.model.MID_MRequisition;
|
|||
import andromedia.midsuit.model.MID_MRequisitionLine;
|
||||
import andromedia.midsuit.model.MID_MRequisitionTrx;
|
||||
import andromedia.midsuit.model.MID_MRequisitionTrxLine;
|
||||
import andromedia.midsuit.model.MID_MRequsitionTax;
|
||||
import andromedia.midsuit.model.MID_PPO;
|
||||
import andromedia.midsuit.model.MID_PPOLine;
|
||||
import andromedia.midsuit.model.MID_UnrealizedRate;
|
||||
|
|
|
|||
|
|
@ -9,9 +9,11 @@ import org.compiere.model.MInOut;
|
|||
import org.compiere.model.MInventory;
|
||||
import org.compiere.model.MInventoryLine;
|
||||
import org.compiere.model.MInventoryLineMA;
|
||||
import org.compiere.model.MInvoiceTax;
|
||||
import org.compiere.model.MJournal;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MOrderLine;
|
||||
import org.compiere.model.MOrderTax;
|
||||
import org.compiere.model.MPayment;
|
||||
import org.compiere.model.MPaymentAllocate;
|
||||
import org.compiere.model.MPriceList;
|
||||
|
|
@ -24,19 +26,23 @@ import org.compiere.model.PO;
|
|||
import org.compiere.util.CLogger;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
import andromedia.midsuit.model.X_M_RequisitionTax;
|
||||
import andromedia.midsuit.validator.MID_CurrencyRateValidator;
|
||||
import andromedia.midsuit.validator.MID_DeprWorkfileValidator;
|
||||
import andromedia.midsuit.validator.MID_InOutValidator;
|
||||
import andromedia.midsuit.validator.MID_InventoryLineMAValidator;
|
||||
import andromedia.midsuit.validator.MID_InventoryLineValidator;
|
||||
import andromedia.midsuit.validator.MID_InventoryValidator;
|
||||
import andromedia.midsuit.validator.MID_InvoiceTaxValidator;
|
||||
import andromedia.midsuit.validator.MID_JournalValidator;
|
||||
import andromedia.midsuit.validator.MID_OrderLineValidator;
|
||||
import andromedia.midsuit.validator.MID_OrderTaxValidator;
|
||||
import andromedia.midsuit.validator.MID_OrderValidator;
|
||||
import andromedia.midsuit.validator.MID_PaymentValidator;
|
||||
import andromedia.midsuit.validator.MID_ProductValidator;
|
||||
import andromedia.midsuit.validator.MID_ProductionLineValidator;
|
||||
import andromedia.midsuit.validator.MID_ProductionValidator;
|
||||
import andromedia.midsuit.validator.MID_RequisitionTaxValidator;
|
||||
|
||||
public class MID_ValidatorFactory extends AbstractEventHandler {
|
||||
public CLogger log = CLogger.getCLogger(MID_ValidatorFactory.class);
|
||||
|
|
@ -72,6 +78,12 @@ public class MID_ValidatorFactory extends AbstractEventHandler {
|
|||
msg = MID_PaymentValidator.executeEvent(event, getPO(event));
|
||||
if(getPO(event).get_TableName().equals(MProduct.Table_Name))
|
||||
msg = MID_ProductValidator.executeEvent(event, getPO(event));
|
||||
if(getPO(event).get_TableName().equals(MOrderTax.Table_Name))
|
||||
msg = MID_OrderTaxValidator.executeEvent(event, getPO(event));
|
||||
if(getPO(event).get_TableName().equals(MInvoiceTax.Table_Name))
|
||||
msg = MID_InvoiceTaxValidator.executeEvent(event, getPO(event));
|
||||
if(getPO(event).get_TableName().equals(X_M_RequisitionTax.Table_Name))
|
||||
msg = MID_RequisitionTaxValidator.executeEvent(event, getPO(event));
|
||||
logEvent(event, getPO(event), msg);
|
||||
}
|
||||
|
||||
|
|
@ -144,10 +156,17 @@ public class MID_ValidatorFactory extends AbstractEventHandler {
|
|||
registerTableEvent(IEventTopics.PO_BEFORE_NEW, MPayment.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_BEFORE_CHANGE, MPayment.Table_Name);
|
||||
// registerTableEvent(IEventTopics.PO_AFTER_NEW,MInvoice.Table_Name);
|
||||
|
||||
//MProduct
|
||||
//MProduct
|
||||
registerTableEvent(IEventTopics.PO_BEFORE_NEW, MProduct.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_BEFORE_CHANGE, MProduct.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_AFTER_NEW, MOrderTax.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_AFTER_CHANGE, MOrderTax.Table_Name);
|
||||
|
||||
registerTableEvent(IEventTopics.PO_AFTER_NEW, MInvoiceTax.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_AFTER_CHANGE, MInvoiceTax.Table_Name);
|
||||
|
||||
registerTableEvent(IEventTopics.PO_AFTER_NEW, X_M_RequisitionTax.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_AFTER_CHANGE, X_M_RequisitionTax.Table_Name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import org.compiere.model.MOrderLine;
|
|||
import org.compiere.model.MRequisitionLine;
|
||||
import org.compiere.model.Query;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
|
||||
public class MID_Ceisa_Order extends X_mid_ceisa_order{
|
||||
|
|
@ -38,10 +40,12 @@ public class MID_Ceisa_Order extends X_mid_ceisa_order{
|
|||
int MreqLineId = 0;
|
||||
|
||||
for(MRequisitionLine MreqLine : MReqLines) {
|
||||
|
||||
if(orderLine.getM_Product_ID() == MreqLine.getM_Product_ID() && orderLine.getC_UOM_ID() == MreqLine.getC_UOM_ID() && orderLine.getQty().equals(MreqLine.getQty())) {
|
||||
BigDecimal qty = orderLine.getQty().setScale(4,RoundingMode.HALF_UP);
|
||||
if(orderLine.getM_Product_ID() == MreqLine.getM_Product_ID() && orderLine.getC_UOM_ID() == MreqLine.getC_UOM_ID() && qty.compareTo(MreqLine.getQty()) == 0) {
|
||||
MreqLineId = MreqLine.get_ID();
|
||||
break;
|
||||
}else {
|
||||
log.warning("log "+orderLine.getM_Product_ID()+", "+MreqLine.getM_Product_ID()+"|"+orderLine.getC_UOM_ID()+","+ MreqLine.getC_UOM_ID()+"|"+ qty+","+MreqLine.getQty());
|
||||
}
|
||||
}
|
||||
if(MreqLineId > 0) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,494 @@
|
|||
package andromedia.midsuit.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.NegativeInventoryDisallowedException;
|
||||
import org.compiere.model.I_M_AttributeSet;
|
||||
import org.compiere.model.I_M_Cost;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MClient;
|
||||
import org.compiere.model.MClientInfo;
|
||||
import org.compiere.model.MCost;
|
||||
import org.compiere.model.MDocType;
|
||||
import org.compiere.model.MInventory;
|
||||
import org.compiere.model.MInventoryLine;
|
||||
import org.compiere.model.MInventoryLineMA;
|
||||
import org.compiere.model.MPeriod;
|
||||
import org.compiere.model.MProduct;
|
||||
import org.compiere.model.MStorageOnHand;
|
||||
import org.compiere.model.MTransaction;
|
||||
import org.compiere.model.MWarehouse;
|
||||
import org.compiere.model.ModelValidationEngine;
|
||||
import org.compiere.model.ModelValidator;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.TimeUtil;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
public class MID_MInventory extends MInventory {
|
||||
|
||||
private String m_processMsg = null;
|
||||
/** Just Prepared Flag */
|
||||
private boolean m_justPrepared = false;
|
||||
|
||||
public MID_MInventory(Properties ctx, int M_Inventory_ID, String trxName) {
|
||||
super(ctx, M_Inventory_ID, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public MID_MInventory(Properties ctx, ResultSet rs, String trxName) {
|
||||
super(ctx, rs, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public MID_MInventory(MWarehouse wh, String trxName) {
|
||||
super(wh, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
private void setDefiniteDocumentNo() {
|
||||
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
|
||||
if (dt.isOverwriteDateOnComplete()) {
|
||||
setMovementDate(TimeUtil.getDay(0));
|
||||
MPeriod.testPeriodOpen(getCtx(), getMovementDate(), MDocType.DOCBASETYPE_MaterialPhysicalInventory, getAD_Org_ID());
|
||||
}
|
||||
if (dt.isOverwriteSeqOnComplete()) {
|
||||
String value = DB.getDocumentNo(getC_DocType_ID(), get_TrxName(), true, this);
|
||||
if (value != null)
|
||||
setDocumentNo(value);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkMaterialPolicy(MInventoryLine line, BigDecimal qtyDiff)
|
||||
{
|
||||
|
||||
int no = MID_MInventoryLineMA.deleteInventoryLineMA(line.getM_InventoryLine_ID(), get_TrxName());
|
||||
if (no > 0)
|
||||
if (log.isLoggable(Level.CONFIG)) log.config("Delete old #" + no);
|
||||
|
||||
if(qtyDiff.compareTo(Env.ZERO)==0)
|
||||
return;
|
||||
|
||||
// Attribute Set Instance
|
||||
if (line.getM_AttributeSetInstance_ID() == 0)
|
||||
{
|
||||
MProduct product = MProduct.get(getCtx(), line.getM_Product_ID());
|
||||
if (qtyDiff.signum() > 0) // Incoming Trx
|
||||
{
|
||||
//auto balance negative on hand
|
||||
MStorageOnHand[] storages = MStorageOnHand.getWarehouseNegative(getCtx(), getM_Warehouse_ID(), line.getM_Product_ID(), 0,
|
||||
null, MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), line.getM_Locator_ID(), get_TrxName(), false);
|
||||
for (MStorageOnHand storage : storages)
|
||||
{
|
||||
if (storage.getQtyOnHand().signum() < 0)
|
||||
{
|
||||
BigDecimal maQty = qtyDiff;
|
||||
if(maQty.compareTo(storage.getQtyOnHand().negate())>0)
|
||||
{
|
||||
maQty = storage.getQtyOnHand().negate();
|
||||
}
|
||||
|
||||
//backward compatibility: -ve in MA is incoming trx, +ve in MA is outgoing trx
|
||||
MID_MInventoryLineMA lineMA = new MID_MInventoryLineMA(line, storage.getM_AttributeSetInstance_ID(), maQty.negate(), storage.getDateMaterialPolicy(),true);
|
||||
lineMA.saveEx();
|
||||
|
||||
qtyDiff = qtyDiff.subtract(maQty);
|
||||
if (qtyDiff.compareTo(Env.ZERO)==0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(qtyDiff.compareTo(Env.ZERO)>0)
|
||||
{
|
||||
//AttributeSetInstance enable
|
||||
I_M_AttributeSet as = line.getM_Product().getM_AttributeSet();
|
||||
if (as != null && as.isInstanceAttribute())
|
||||
{
|
||||
//add quantity to last attributesetinstance
|
||||
storages = MStorageOnHand.getWarehouse(getCtx(), getM_Warehouse_ID(), line.getM_Product_ID(), 0, null,
|
||||
false, true, 0, get_TrxName());
|
||||
for (MStorageOnHand storage : storages)
|
||||
{
|
||||
DB.getSQLValueTS(get_TrxName(),"SELECT datematerialpolicy FROM M_StorageOnHand WHERE M_Product_ID = ? AND M_Locator_ID = ? AND M_AttributeSetInstance_ID = ? AND DateMaterialPolicy = ?", new Object[] {});
|
||||
log.warning("STORAGE "+ storage.getDateMaterialPolicy().toLocaleString());
|
||||
BigDecimal maQty = qtyDiff;
|
||||
//backward compatibility: -ve in MA is incoming trx, +ve in MA is outgoing trx
|
||||
MID_MInventoryLineMA lineMA = new MID_MInventoryLineMA(line, storage.getM_AttributeSetInstance_ID(), maQty.negate(), storage.getDateMaterialPolicy(),true);
|
||||
lineMA.saveEx();
|
||||
qtyDiff = qtyDiff.subtract(maQty);
|
||||
|
||||
if (qtyDiff.compareTo(Env.ZERO)==0)
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
if(qtyDiff.compareTo(Env.ZERO)>0)
|
||||
{
|
||||
MClientInfo m_clientInfo = MClientInfo.get(getCtx(), getAD_Client_ID(), get_TrxName());
|
||||
MAcctSchema acctSchema = new MAcctSchema(getCtx(), m_clientInfo.getC_AcctSchema1_ID(), get_TrxName());
|
||||
if (MAcctSchema.COSTINGLEVEL_BatchLot.equals(product.getCostingLevel(acctSchema)) )
|
||||
{
|
||||
String sqlWhere = "M_Product_ID=? AND M_Locator_ID=? AND QtyOnHand = 0 AND M_AttributeSetInstance_ID > 0 ";
|
||||
MStorageOnHand storage = new Query(getCtx(), MStorageOnHand.Table_Name, sqlWhere, get_TrxName())
|
||||
.setParameters(line.getM_Product_ID(), line.getM_Locator_ID())
|
||||
.setOrderBy(MStorageOnHand.COLUMNNAME_DateMaterialPolicy+","+ MStorageOnHand.COLUMNNAME_M_AttributeSetInstance_ID)
|
||||
.first();
|
||||
|
||||
if (storage != null )
|
||||
{
|
||||
MID_MInventoryLineMA lineMA = MID_MInventoryLineMA.addOrCreate(line, storage.getM_AttributeSetInstance_ID(), qtyDiff.negate(), getMovementDate(),true);
|
||||
lineMA.saveEx();
|
||||
}
|
||||
else
|
||||
{
|
||||
String costingMethod = product.getCostingMethod(acctSchema);
|
||||
StringBuilder localWhereClause = new StringBuilder("M_Product_ID =?" )
|
||||
.append(" AND C_AcctSchema_ID=?")
|
||||
.append(" AND ce.CostingMethod = ? ")
|
||||
.append(" AND CurrentCostPrice <> 0 ");
|
||||
MCost cost = new Query(getCtx(),I_M_Cost.Table_Name,localWhereClause.toString(),get_TrxName())
|
||||
.setParameters(line.getM_Product_ID(), acctSchema.get_ID(), costingMethod)
|
||||
.addJoinClause(" INNER JOIN M_CostElement ce ON (M_Cost.M_CostElement_ID =ce.M_CostElement_ID ) ")
|
||||
.setOrderBy("Updated DESC")
|
||||
.first();
|
||||
if (cost != null)
|
||||
{
|
||||
MID_MInventoryLineMA lineMA = MID_MInventoryLineMA.addOrCreate(line, cost.getM_AttributeSetInstance_ID(), qtyDiff.negate(), getMovementDate(),true);
|
||||
lineMA.saveEx();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_processMsg = "Cannot retrieve cost of Inventory " ;
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
MID_MInventoryLineMA lineMA = MID_MInventoryLineMA.addOrCreate(line, 0, qtyDiff.negate(), getMovementDate(),true);
|
||||
lineMA.saveEx();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Outgoing Trx
|
||||
{
|
||||
String MMPolicy = product.getMMPolicy();
|
||||
MStorageOnHand[] storages = MStorageOnHand.getWarehouse(getCtx(), getM_Warehouse_ID(), line.getM_Product_ID(), 0,
|
||||
null, MClient.MMPOLICY_FiFo.equals(MMPolicy), true, line.getM_Locator_ID(), get_TrxName(), false);
|
||||
|
||||
BigDecimal qtyToDeliver = qtyDiff.negate();
|
||||
for (MStorageOnHand storage: storages)
|
||||
{
|
||||
if (storage.getQtyOnHand().compareTo(qtyToDeliver) >= 0)
|
||||
{
|
||||
MID_MInventoryLineMA ma = new MID_MInventoryLineMA (line,
|
||||
storage.getM_AttributeSetInstance_ID(),
|
||||
qtyToDeliver,storage.getDateMaterialPolicy(),true);
|
||||
ma.saveEx();
|
||||
qtyToDeliver = Env.ZERO;
|
||||
if (log.isLoggable(Level.FINE)) log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
|
||||
}
|
||||
else
|
||||
{
|
||||
MID_MInventoryLineMA ma = new MID_MInventoryLineMA (line,
|
||||
storage.getM_AttributeSetInstance_ID(),
|
||||
storage.getQtyOnHand(),storage.getDateMaterialPolicy(),true);
|
||||
ma.saveEx();
|
||||
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
|
||||
if (log.isLoggable(Level.FINE)) log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
|
||||
}
|
||||
if (qtyToDeliver.signum() == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
// No AttributeSetInstance found for remainder
|
||||
if (qtyToDeliver.signum() != 0)
|
||||
{
|
||||
MID_MInventoryLineMA lineMA = MID_MInventoryLineMA.addOrCreate(line, 0, qtyToDeliver, getMovementDate(),true);
|
||||
lineMA.saveEx();
|
||||
if (log.isLoggable(Level.FINE)) log.fine("##: " + lineMA);
|
||||
}
|
||||
} // outgoing Trx
|
||||
} // for all lines
|
||||
|
||||
} // checkMaterialPolicy
|
||||
|
||||
|
||||
/** Reversal Flag */
|
||||
private boolean m_reversal = false;
|
||||
|
||||
/**
|
||||
* Set Reversal
|
||||
* @param reversal reversal
|
||||
*/
|
||||
private void setReversal(boolean reversal)
|
||||
{
|
||||
m_reversal = reversal;
|
||||
} // setReversal
|
||||
/**
|
||||
* Is Reversal
|
||||
* @return reversal
|
||||
*/
|
||||
private boolean isReversal()
|
||||
{
|
||||
return m_reversal;
|
||||
} // isReversal
|
||||
|
||||
|
||||
@Override
|
||||
public String completeIt()
|
||||
{
|
||||
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
|
||||
String docSubTypeInv = dt.getDocSubTypeInv();
|
||||
if (Util.isEmpty(docSubTypeInv)) {
|
||||
m_processMsg = "Document inventory subtype not configured, cannot complete";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
|
||||
// Re-Check
|
||||
if (!m_justPrepared)
|
||||
{
|
||||
String status = prepareIt();
|
||||
m_justPrepared = false;
|
||||
if (!DocAction.STATUS_InProgress.equals(status))
|
||||
return status;
|
||||
}
|
||||
|
||||
// Set the definite document number after completed (if needed)
|
||||
setDefiniteDocumentNo();
|
||||
|
||||
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
|
||||
if (m_processMsg != null)
|
||||
return DocAction.STATUS_Invalid;
|
||||
|
||||
// Implicit Approval
|
||||
if (!isApproved())
|
||||
approveIt();
|
||||
if (log.isLoggable(Level.INFO)) log.info(toString());
|
||||
|
||||
StringBuilder errors = new StringBuilder();
|
||||
MInventoryLine[] lines = getLines(false);
|
||||
for (MInventoryLine line : lines)
|
||||
{
|
||||
if (!line.isActive())
|
||||
continue;
|
||||
|
||||
MProduct product = line.getProduct();
|
||||
try
|
||||
{
|
||||
BigDecimal qtyDiff = Env.ZERO;
|
||||
if (MDocType.DOCSUBTYPEINV_InternalUseInventory.equals(docSubTypeInv))
|
||||
qtyDiff = line.getQtyInternalUse().negate();
|
||||
else if (MDocType.DOCSUBTYPEINV_PhysicalInventory.equals(docSubTypeInv))
|
||||
qtyDiff = line.getQtyCount().subtract(line.getQtyBook());
|
||||
else if (MDocType.DOCSUBTYPEINV_CostAdjustment.equals(docSubTypeInv))
|
||||
{
|
||||
if (!isReversal())
|
||||
{
|
||||
BigDecimal currentCost = line.getCurrentCostPrice();
|
||||
MClient client = MClient.get(getCtx(), getAD_Client_ID());
|
||||
MAcctSchema as = client.getAcctSchema();
|
||||
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(getCtx(), client.get_ID());
|
||||
|
||||
if (as.getC_Currency_ID() != getC_Currency_ID())
|
||||
{
|
||||
for (int i = 0; i < ass.length ; i ++)
|
||||
{
|
||||
MAcctSchema a = ass[i];
|
||||
if (a.getC_Currency_ID() == getC_Currency_ID())
|
||||
as = a ;
|
||||
}
|
||||
}
|
||||
|
||||
MCost cost = product.getCostingRecord(as, getAD_Org_ID(), line.getM_AttributeSetInstance_ID(), getCostingMethod());
|
||||
if (cost != null && cost.getCurrentCostPrice().compareTo(currentCost) != 0)
|
||||
{
|
||||
m_processMsg = "Current Cost for Line " + line.getLine() + " have changed.";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If Quantity Count minus Quantity Book = Zero, then no change in Inventory
|
||||
if (qtyDiff.signum() == 0)
|
||||
continue;
|
||||
|
||||
//Ignore the Material Policy when is Reverse Correction
|
||||
if(!isReversal()){
|
||||
BigDecimal qtyOnLineMA = MID_MInventoryLineMA.getManualQty(line.getM_InventoryLine_ID(), get_TrxName());
|
||||
|
||||
if(qtyDiff.signum()<0){
|
||||
if(qtyOnLineMA.compareTo(qtyDiff)<0){
|
||||
m_processMsg = "@Over_Qty_On_Attribute_Tab@ " + line.getLine();
|
||||
return DOCSTATUS_Invalid;
|
||||
}
|
||||
}else{
|
||||
if(qtyOnLineMA.compareTo(qtyDiff)>0){
|
||||
m_processMsg = "@Over_Qty_On_Attribute_Tab@ " + line.getLine();
|
||||
return DOCSTATUS_Invalid;
|
||||
}
|
||||
}
|
||||
checkMaterialPolicy(line, qtyDiff.subtract(qtyOnLineMA));
|
||||
}
|
||||
// Stock Movement - Counterpart MOrder.reserveStock
|
||||
if (product != null
|
||||
&& product.isStocked() )
|
||||
{
|
||||
log.fine("Material Transaction");
|
||||
MTransaction mtrx = null;
|
||||
|
||||
//If AttributeSetInstance = Zero then create new AttributeSetInstance use Inventory Line MA else use current AttributeSetInstance
|
||||
if (line.getM_AttributeSetInstance_ID() == 0 || qtyDiff.compareTo(Env.ZERO) == 0)
|
||||
{
|
||||
MID_MInventoryLineMA mas[] = MID_MInventoryLineMA.get(getCtx(),
|
||||
line.getM_InventoryLine_ID(), get_TrxName());
|
||||
|
||||
for (int j = 0; j < mas.length; j++)
|
||||
{
|
||||
MID_MInventoryLineMA ma = mas[j];
|
||||
BigDecimal QtyMA = ma.getMovementQty();
|
||||
BigDecimal QtyNew = QtyMA.add(qtyDiff);
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Diff=" + qtyDiff
|
||||
+ " - Instance OnHand=" + QtyMA + "->" + QtyNew);
|
||||
|
||||
if (!MStorageOnHand.add(getCtx(), getM_Warehouse_ID(),
|
||||
line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(),
|
||||
ma.getM_AttributeSetInstance_ID(),
|
||||
QtyMA.negate(),ma.getDateMaterialPolicy(), get_TrxName()))
|
||||
{
|
||||
String lastError = CLogger.retrieveErrorString("");
|
||||
m_processMsg = "Cannot correct Inventory (MA) - " + lastError;
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
|
||||
// Only Update Date Last Inventory if is a Physical Inventory
|
||||
if (MDocType.DOCSUBTYPEINV_PhysicalInventory.equals(docSubTypeInv))
|
||||
{
|
||||
MStorageOnHand storage = MStorageOnHand.get(getCtx(), line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(),ma.getDateMaterialPolicy(),get_TrxName());
|
||||
storage.setDateLastInventory(getMovementDate());
|
||||
if (!storage.save(get_TrxName()))
|
||||
{
|
||||
m_processMsg = "Storage not updated(2)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
String m_MovementType =null;
|
||||
if(QtyMA.negate().compareTo(Env.ZERO) > 0 )
|
||||
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryIn;
|
||||
else
|
||||
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryOut;
|
||||
// Transaction
|
||||
mtrx = new MTransaction (getCtx(), line.getAD_Org_ID(), m_MovementType,
|
||||
line.getM_Locator_ID(), line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(),
|
||||
QtyMA.negate(), getMovementDate(), get_TrxName());
|
||||
|
||||
mtrx.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
|
||||
if (!mtrx.save())
|
||||
{
|
||||
m_processMsg = "Transaction not inserted(2)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
|
||||
qtyDiff = QtyNew;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//sLine.getM_AttributeSetInstance_ID() != 0
|
||||
// Fallback
|
||||
if (mtrx == null)
|
||||
{
|
||||
Timestamp dateMPolicy= qtyDiff.signum() > 0 ? getMovementDate() : null;
|
||||
if (line.getM_AttributeSetInstance_ID() > 0)
|
||||
{
|
||||
Timestamp t = MStorageOnHand.getDateMaterialPolicy(line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), line.getM_Locator_ID(), line.get_TrxName());
|
||||
if (t != null)
|
||||
dateMPolicy = t;
|
||||
}
|
||||
|
||||
//Fallback: Update Storage - see also VMatch.createMatchRecord
|
||||
if (!MStorageOnHand.add(getCtx(), getM_Warehouse_ID(),
|
||||
line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(),
|
||||
line.getM_AttributeSetInstance_ID(),
|
||||
qtyDiff,dateMPolicy,get_TrxName()))
|
||||
{
|
||||
String lastError = CLogger.retrieveErrorString("");
|
||||
m_processMsg = "Cannot correct Inventory OnHand (MA) - " + lastError;
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
|
||||
// Only Update Date Last Inventory if is a Physical Inventory
|
||||
if (MDocType.DOCSUBTYPEINV_PhysicalInventory.equals(docSubTypeInv))
|
||||
{
|
||||
MStorageOnHand storage = MStorageOnHand.get(getCtx(), line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),dateMPolicy, get_TrxName());
|
||||
|
||||
storage.setDateLastInventory(getMovementDate());
|
||||
if (!storage.save(get_TrxName()))
|
||||
{
|
||||
m_processMsg = "Storage not updated(2)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
String m_MovementType = null;
|
||||
if(qtyDiff.compareTo(Env.ZERO) > 0 )
|
||||
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryIn;
|
||||
else
|
||||
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryOut;
|
||||
// Transaction
|
||||
mtrx = new MTransaction (getCtx(), line.getAD_Org_ID(), m_MovementType,
|
||||
line.getM_Locator_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),
|
||||
qtyDiff, getMovementDate(), get_TrxName());
|
||||
mtrx.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
|
||||
if (!mtrx.save())
|
||||
{
|
||||
m_processMsg = "Transaction not inserted(2)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
} // Fallback
|
||||
} // stock movement
|
||||
}
|
||||
catch (NegativeInventoryDisallowedException e)
|
||||
{
|
||||
log.severe(e.getMessage());
|
||||
errors.append(Msg.getElement(getCtx(), "Line")).append(" ").append(line.getLine()).append(": ");
|
||||
errors.append(e.getMessage()).append("\n");
|
||||
}
|
||||
|
||||
} // for all lines
|
||||
|
||||
if (errors.toString().length() > 0)
|
||||
{
|
||||
m_processMsg = errors.toString();
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
|
||||
// User Validation
|
||||
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
|
||||
if (valid != null)
|
||||
{
|
||||
m_processMsg = valid;
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
|
||||
//
|
||||
setProcessed(true);
|
||||
setDocAction(DOCACTION_Close);
|
||||
return DocAction.STATUS_Completed;
|
||||
} // completeIt
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
package andromedia.midsuit.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.I_M_InventoryLineMA;
|
||||
import org.compiere.model.MInventoryLine;
|
||||
import org.compiere.model.MInventoryLineMA;
|
||||
import org.compiere.model.MStorageOnHand;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
public class MID_MInventoryLineMA extends MInventoryLineMA {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2565503002899695974L;
|
||||
private static CLogger s_log = CLogger.getCLogger (MID_MInventoryLineMA.class);
|
||||
|
||||
public MID_MInventoryLineMA(Properties ctx, int M_InventoryLineMA_ID, String trxName) {
|
||||
super(ctx, M_InventoryLineMA_ID, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public MID_MInventoryLineMA(Properties ctx, ResultSet rs, String trxName) {
|
||||
super(ctx, rs, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public MID_MInventoryLineMA(MInventoryLine parent, int M_AttributeSetInstance_ID, BigDecimal MovementQty,
|
||||
Timestamp DateMaterialPolicy) {
|
||||
super(parent, M_AttributeSetInstance_ID, MovementQty, DateMaterialPolicy);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public static MID_MInventoryLineMA addOrCreate(MInventoryLine line, int M_AttributeSetInstance_ID, BigDecimal MovementQty, Timestamp DateMaterialPolicy){
|
||||
return addOrCreate(line, M_AttributeSetInstance_ID, MovementQty,DateMaterialPolicy,true);
|
||||
}
|
||||
|
||||
public static MID_MInventoryLineMA addOrCreate(MInventoryLine line, int M_AttributeSetInstance_ID, BigDecimal MovementQty, Timestamp DateMaterialPolicy,boolean isAutoGenerated)
|
||||
{
|
||||
Query query = new Query(Env.getCtx(), I_M_InventoryLineMA.Table_Name, "M_InventoryLine_ID=? AND M_AttributeSetInstance_ID=? AND DateMaterialPolicy=trunc(cast(? as date))",
|
||||
line.get_TrxName());
|
||||
MID_MInventoryLineMA po = query.setParameters(line.getM_InventoryLine_ID(), M_AttributeSetInstance_ID, DateMaterialPolicy).first();
|
||||
if (po == null)
|
||||
po = new MID_MInventoryLineMA(line, M_AttributeSetInstance_ID, MovementQty, DateMaterialPolicy,isAutoGenerated);
|
||||
else
|
||||
po.setMovementQty(po.getMovementQty().add(MovementQty));
|
||||
return po;
|
||||
}
|
||||
|
||||
public static MID_MInventoryLineMA[] get (Properties ctx, int M_InventoryLine_ID, String trxName)
|
||||
{
|
||||
ArrayList<MInventoryLineMA> list = new ArrayList<MInventoryLineMA>();
|
||||
String sql = "SELECT * FROM M_InventoryLineMA WHERE M_InventoryLine_ID=?";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, trxName);
|
||||
pstmt.setInt (1, M_InventoryLine_ID);
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
list.add (new MInventoryLineMA (ctx, rs, trxName));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log (Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
MID_MInventoryLineMA[] retValue = new MID_MInventoryLineMA[list.size ()];
|
||||
list.toArray (retValue);
|
||||
return retValue;
|
||||
}
|
||||
|
||||
public MID_MInventoryLineMA(MInventoryLine parent, int M_AttributeSetInstance_ID, BigDecimal MovementQty,
|
||||
Timestamp DateMaterialPolicy, boolean isAutoGenerated) {
|
||||
this (parent.getCtx(), 0, parent.get_TrxName());
|
||||
setClientOrg(parent);
|
||||
setM_InventoryLine_ID(parent.getM_InventoryLine_ID());
|
||||
//
|
||||
setM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
|
||||
setMovementQty(MovementQty);
|
||||
if (DateMaterialPolicy == null)
|
||||
{
|
||||
if (M_AttributeSetInstance_ID > 0)
|
||||
{
|
||||
DateMaterialPolicy = MStorageOnHand.getDateMaterialPolicy(parent.getM_Product_ID(), M_AttributeSetInstance_ID, parent.get_TrxName());
|
||||
}
|
||||
if (DateMaterialPolicy == null)
|
||||
{
|
||||
DateMaterialPolicy = parent.getParent().getMovementDate();
|
||||
}
|
||||
}
|
||||
setDateMaterialPolicy(DateMaterialPolicy);
|
||||
setIsAutoGenerated(isAutoGenerated);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void setDateMaterialPolicy(Timestamp DateMaterialPolicy) {
|
||||
set_ValueNoCheck("DateMaterialPolicy", DateMaterialPolicy);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ public class MID_MRequisitionLine extends MRequisitionLine {
|
|||
else
|
||||
tax.delete(false, get_TrxName());
|
||||
}
|
||||
tax = X_M_RequisitionTax.get(this, 2, false, get_TrxName());
|
||||
tax = MID_MRequsitionTax.get(this, 2, false, get_TrxName());
|
||||
tax.calculateTaxFromLines();
|
||||
if (tax.getTaxAmt().signum() != 0)
|
||||
tax.saveEx();
|
||||
|
|
@ -160,7 +160,6 @@ public class MID_MRequisitionLine extends MRequisitionLine {
|
|||
tax = X_M_RequisitionTax.get(this, 2, false, get_TrxName());
|
||||
else
|
||||
tax = X_M_RequisitionTax.get(this, 2, true, get_TrxName());
|
||||
|
||||
tax.calculateTaxFromLines();
|
||||
if (tax.getTaxBaseAmt().signum() == 0 || tax.getTaxAmt().signum() == 0)
|
||||
tax.deleteEx(true, get_TrxName());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,104 @@
|
|||
package andromedia.midsuit.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.model.MOrderTax;
|
||||
import org.compiere.model.MRequisitionLine;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
public class MID_MRequsitionTax extends X_M_RequisitionTax {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4615965451352388497L;
|
||||
|
||||
public MID_MRequsitionTax(Properties ctx, int M_RequisitionTax_ID, String trxName) {
|
||||
super(ctx, M_RequisitionTax_ID, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public MID_MRequsitionTax(Properties ctx, ResultSet M_RequisitionTax_ID, String trxName) {
|
||||
super(ctx, M_RequisitionTax_ID, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean beforeSave(boolean newRecord) {
|
||||
BigDecimal amount = getTaxBaseAmt();
|
||||
BigDecimal ppn2025baseamt = getC_Tax().getRate().multiply(amount).divide(new BigDecimal(12), 2, RoundingMode.HALF_UP);
|
||||
log.warning("bs "+amount+" "+ppn2025baseamt);
|
||||
set_ValueNoCheck("taxbaseamt_reg2025", ppn2025baseamt);
|
||||
return super.beforeSave(newRecord);
|
||||
}
|
||||
|
||||
public static MID_MRequsitionTax get (MRequisitionLine line, int precision,
|
||||
boolean oldTax, String trxName)
|
||||
{
|
||||
MID_MRequsitionTax retValue = null;
|
||||
if (line == null || line.getM_Requisition_ID() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int C_Tax_ID = line.get_ValueAsInt("C_Tax_ID");
|
||||
boolean isOldTax = oldTax && line.is_ValueChanged(MOrderTax.COLUMNNAME_C_Tax_ID);
|
||||
if (isOldTax)
|
||||
{
|
||||
Object old = line.get_ValueOld(MOrderTax.COLUMNNAME_C_Tax_ID);
|
||||
if (old == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
C_Tax_ID = ((Integer)old).intValue();
|
||||
}
|
||||
if (C_Tax_ID == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
String sql = "SELECT * FROM M_RequisitionTax WHERE M_Requisition_ID =? AND C_Tax_ID=?";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, trxName);
|
||||
pstmt.setInt (1, line.getM_Requisition_ID());
|
||||
pstmt.setInt (2, C_Tax_ID);
|
||||
rs = pstmt.executeQuery ();
|
||||
if (rs.next ())
|
||||
retValue = new MID_MRequsitionTax (line.getCtx(), rs, trxName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
if (retValue != null)
|
||||
{
|
||||
return retValue;
|
||||
}
|
||||
// If the old tax was required and there is no MOrderTax for that
|
||||
// return null, and not create another MOrderTax - teo_sarca [ 1583825 ]
|
||||
else {
|
||||
if (isOldTax)
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create New
|
||||
retValue = new MID_MRequsitionTax(line.getCtx(), 0, trxName);
|
||||
retValue.set_TrxName(trxName);
|
||||
retValue.setM_Requisition_ID(line.getM_Requisition_ID());
|
||||
retValue.setC_Tax_ID(line.get_ValueAsInt("C_Tax_ID"));
|
||||
return retValue;
|
||||
} // get
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,232 @@
|
|||
package andromedia.midsuit.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MAllocationHdr;
|
||||
import org.compiere.model.MAllocationLine;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MPeriod;
|
||||
import org.compiere.model.ModelValidationEngine;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
public class MPayment extends org.compiere.model.MPayment{
|
||||
|
||||
public MPayment(Properties ctx, int C_Payment_ID, String trxName) {
|
||||
super(ctx, C_Payment_ID, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public MPayment(Properties ctx, ResultSet rs, String trxName) {
|
||||
super(ctx, rs, trxName);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
private String m_processMsg = "";
|
||||
|
||||
@Override
|
||||
public boolean reverseAccrualIt()
|
||||
{
|
||||
if(log.isLoggable(Level.INFO))
|
||||
log.info(toString());
|
||||
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, 6);
|
||||
if(m_processMsg != null)
|
||||
return false;
|
||||
StringBuilder info = reverse(true);
|
||||
if(info == null)
|
||||
return false;
|
||||
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, 14);
|
||||
if(m_processMsg != null)
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
m_processMsg = info.toString();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reverseCorrectIt()
|
||||
{
|
||||
if(log.isLoggable(Level.INFO))
|
||||
log.info(toString());
|
||||
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, 5);
|
||||
if(m_processMsg != null)
|
||||
return false;
|
||||
StringBuilder info = reverse(false);
|
||||
if(info == null)
|
||||
return false;
|
||||
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, 13);
|
||||
if(m_processMsg != null)
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
m_processMsg = info.toString();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean voidOnlinePayment()
|
||||
{
|
||||
if(getTenderType().equals("C") && isOnline())
|
||||
{
|
||||
setOrig_TrxID(getR_PnRef());
|
||||
setTrxType("V");
|
||||
if(!processOnline())
|
||||
{
|
||||
setTrxType("C");
|
||||
if(!processOnline())
|
||||
{
|
||||
log.log(Level.SEVERE, "Failed to cancel payment online");
|
||||
m_processMsg = Msg.getMsg(getCtx(), "PaymentNotCancelled");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(getC_Invoice_ID() != 0)
|
||||
{
|
||||
MInvoice inv = new MInvoice(getCtx(), getC_Invoice_ID(), get_TrxName());
|
||||
inv.setC_Payment_ID(0);
|
||||
inv.saveEx();
|
||||
}
|
||||
if(getC_Order_ID() != 0)
|
||||
{
|
||||
MOrder ord = new MOrder(getCtx(), getC_Order_ID(), get_TrxName());
|
||||
ord.setC_Payment_ID(0);
|
||||
ord.saveEx();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private StringBuilder reverse(boolean accrual)
|
||||
{
|
||||
if(!voidOnlinePayment())
|
||||
return null;
|
||||
Timestamp dateAcct = accrual ? Env.getContextAsDate(getCtx(), "#Date") : getDateAcct();
|
||||
if(dateAcct == null)
|
||||
dateAcct = new Timestamp(System.currentTimeMillis());
|
||||
MPeriod.testPeriodOpen(getCtx(), dateAcct, getC_DocType_ID(), getAD_Org_ID());
|
||||
MPayment reversal = new MPayment(getCtx(), 0, get_TrxName());
|
||||
copyValues(this, reversal);
|
||||
reversal.setClientOrg(this);
|
||||
reversal.setC_Invoice_ID(0);
|
||||
reversal.setDateAcct(dateAcct);
|
||||
reversal.setDocumentNo((new StringBuilder(String.valueOf(getDocumentNo()))).append(REVERSE_INDICATOR).toString());
|
||||
reversal.setDocStatus("DR");
|
||||
reversal.setDocAction("CO");
|
||||
reversal.setPayAmt(getPayAmt().negate());
|
||||
reversal.setDiscountAmt(getDiscountAmt().negate());
|
||||
reversal.setWriteOffAmt(getWriteOffAmt().negate());
|
||||
reversal.setOverUnderAmt(getOverUnderAmt().negate());
|
||||
reversal.setIsAllocated(true);
|
||||
reversal.setIsReconciled(false);
|
||||
reversal.setIsOnline(false);
|
||||
reversal.setIsApproved(true);
|
||||
reversal.setR_PnRef(null);
|
||||
reversal.setR_Result(null);
|
||||
reversal.setR_RespMsg(null);
|
||||
reversal.setR_AuthCode(null);
|
||||
reversal.setR_Info(null);
|
||||
reversal.setProcessing(false);
|
||||
reversal.setOProcessing("N");
|
||||
reversal.setProcessed(false);
|
||||
reversal.setPosted(false);
|
||||
reversal.setDescription(getDescription());
|
||||
reversal.addDescription((new StringBuilder("{->")).append(getDocumentNo()).append(")").toString());
|
||||
reversal.setReversal_ID(getC_Payment_ID());
|
||||
reversal.saveEx(get_TrxName());
|
||||
if(!reversal.processIt("CO"))
|
||||
{
|
||||
m_processMsg = (new StringBuilder("Reversal ERROR: ")).append(reversal.getProcessMsg()).toString();
|
||||
return null;
|
||||
}
|
||||
reversal.closeIt();
|
||||
reversal.setDocStatus("RE");
|
||||
reversal.setDocAction("--");
|
||||
reversal.saveEx(get_TrxName());
|
||||
deAllocate(accrual);
|
||||
setIsAllocated(true);
|
||||
addDescription((new StringBuilder("(")).append(reversal.getDocumentNo()).append("<-)").toString());
|
||||
setDocStatus("RE");
|
||||
setDocAction("--");
|
||||
setProcessed(true);
|
||||
setReversal_ID(reversal.getC_Payment_ID());
|
||||
StringBuilder info = new StringBuilder(reversal.getDocumentNo());
|
||||
MAllocationHdr alloc = new MAllocationHdr(getCtx(), false, getDateTrx(), getC_Currency_ID(), (new StringBuilder(String.valueOf(Msg.translate(getCtx(), "C_Payment_ID")))).append(": ").append(reversal.getDocumentNo()).toString(), get_TrxName());
|
||||
alloc.setAD_Org_ID(getAD_Org_ID());
|
||||
alloc.setDateAcct(dateAcct);
|
||||
alloc.saveEx(get_TrxName());
|
||||
MAllocationLine aLine = new MAllocationLine(alloc, getPayAmt(true), Env.ZERO, Env.ZERO, Env.ZERO);
|
||||
aLine.setDocInfo(getC_BPartner_ID(), 0, 0);
|
||||
aLine.setPaymentInfo(getC_Payment_ID(), 0);
|
||||
if(!aLine.save(get_TrxName()))
|
||||
log.warning("Automatic allocation - line not saved");
|
||||
aLine = new MAllocationLine(alloc, reversal.getPayAmt(true), Env.ZERO, Env.ZERO, Env.ZERO);
|
||||
aLine.setDocInfo(reversal.getC_BPartner_ID(), 0, 0);
|
||||
aLine.setPaymentInfo(reversal.getC_Payment_ID(), 0);
|
||||
if(!aLine.save(get_TrxName()))
|
||||
log.warning("Automatic allocation - reversal line not saved");
|
||||
if(!alloc.processIt("CO"))
|
||||
throw new AdempiereException((new StringBuilder("Failed when processing document - ")).append(alloc.getProcessMsg()).toString());
|
||||
alloc.saveEx(get_TrxName());
|
||||
info.append(" - @C_AllocationHdr_ID@: ").append(alloc.getDocumentNo());
|
||||
if(getC_BPartner_ID() != 0)
|
||||
{
|
||||
MBPartner bp = new MBPartner(getCtx(), getC_BPartner_ID(), get_TrxName());
|
||||
bp.setTotalOpenBalance();
|
||||
bp.saveEx(get_TrxName());
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private void deAllocate(boolean accrual)
|
||||
{
|
||||
MAllocationHdr allocations[] = MAllocationHdr.getOfPayment(getCtx(), getC_Payment_ID(), get_TrxName());
|
||||
if(log.isLoggable(Level.FINE))
|
||||
log.fine((new StringBuilder("#")).append(allocations.length).toString());
|
||||
for(int i = 0; i < allocations.length; i++)
|
||||
{
|
||||
allocations[i].set_TrxName(get_TrxName());
|
||||
if(!"RE".equals(allocations[i].getDocStatus()) && !"VO".equals(allocations[i].getDocStatus()))
|
||||
{
|
||||
if(accrual)
|
||||
{
|
||||
allocations[i].setDocAction("RA");
|
||||
if(!allocations[i].processIt("RA"))
|
||||
throw new AdempiereException(allocations[i].getProcessMsg());
|
||||
} else
|
||||
{
|
||||
allocations[i].setDocAction("RC");
|
||||
if(!allocations[i].processIt("RC"))
|
||||
throw new AdempiereException(allocations[i].getProcessMsg());
|
||||
}
|
||||
allocations[i].saveEx();
|
||||
}
|
||||
}
|
||||
|
||||
if(getC_Invoice_ID() != 0)
|
||||
{
|
||||
String sql = (new StringBuilder("UPDATE C_Invoice SET C_Payment_ID = NULL, IsPaid='N' WHERE C_Invoice_ID=")).append(getC_Invoice_ID()).append(" AND C_Payment_ID=").append(getC_Payment_ID()).toString();
|
||||
int no = DB.executeUpdate(sql, get_TrxName());
|
||||
if(no != 0 && log.isLoggable(Level.FINE))
|
||||
log.fine((new StringBuilder("Unlink Invoice #")).append(no).toString());
|
||||
sql = (new StringBuilder("UPDATE C_Order o SET C_Payment_ID = NULL WHERE EXISTS (SELECT * FROM C_Invoice i WHERE o.C_Order_ID=i.C_Order_ID AND i.C_Invoice_ID=")).append(getC_Invoice_ID()).append(")").append(" AND C_Payment_ID=").append(getC_Payment_ID()).toString();
|
||||
no = DB.executeUpdate(sql, get_TrxName());
|
||||
if(no != 0 && log.isLoggable(Level.FINE))
|
||||
log.fine((new StringBuilder("Unlink Order #")).append(no).toString());
|
||||
}
|
||||
setC_Invoice_ID(0);
|
||||
setIsAllocated(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package andromedia.midsuit.process;
|
||||
|
||||
import org.compiere.model.MRMA;
|
||||
import org.compiere.process.SvrProcess;
|
||||
|
||||
import andromedia.midsuit.model.MID_MOrder;
|
||||
|
|
@ -18,16 +19,30 @@ public class MID_PEBRevoke extends SvrProcess {
|
|||
protected String doIt() throws Exception {
|
||||
|
||||
|
||||
MID_MOrder order = new MID_MOrder(getCtx(), pebLine.getC_Order_ID(), get_TrxName());
|
||||
order.set_ValueNoCheck("RegisterDate", null);
|
||||
order.set_ValueNoCheck("RegisterNo", null);
|
||||
order.set_ValueNoCheck("NoAju1", null);
|
||||
order.set_ValueNoCheck("MID_AJUDocumentType_ID", null);
|
||||
order.saveEx();
|
||||
if(pebLine.getC_Order_ID() > 0) {
|
||||
MID_MOrder order = new MID_MOrder(getCtx(), pebLine.getC_Order_ID(), get_TrxName());
|
||||
order.set_ValueNoCheck("RegisterDate", null);
|
||||
order.set_ValueNoCheck("RegisterNo", null);
|
||||
order.set_ValueNoCheck("NoAju1", null);
|
||||
order.set_ValueNoCheck("MID_AJUDocumentType_ID", null);
|
||||
order.saveEx();
|
||||
|
||||
pebLine.setProcessed(false);
|
||||
pebLine.setC_Order_ID(0);
|
||||
pebLine.saveEx();
|
||||
}else {
|
||||
MRMA rma = new MRMA(getCtx(), pebLine.getM_RMA_ID(), get_TrxName());
|
||||
rma.set_ValueNoCheck("RegisterDate", null);
|
||||
rma.set_ValueNoCheck("RegisterNo", null);
|
||||
rma.set_ValueNoCheck("NoAju1", null);
|
||||
rma.set_ValueNoCheck("MID_AJUDocumentType_ID", null);
|
||||
rma.saveEx();
|
||||
|
||||
pebLine.setProcessed(false);
|
||||
pebLine.set_ValueNoCheck("M_RMA_ID", null);
|
||||
pebLine.saveEx();
|
||||
}
|
||||
|
||||
pebLine.setProcessed(false);
|
||||
pebLine.setC_Order_ID(0);
|
||||
pebLine.saveEx();
|
||||
return "Revoke Custom Success!";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.process.ProcessInfoParameter;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
|
|
@ -231,23 +233,25 @@ public class MID_UploadCeisa40 extends SvrProcess {
|
|||
if(ajudoctype.getValue().equals("262") || ajudoctype.getValue().equals("261")) {
|
||||
BigDecimal priceCIF = Env.ZERO;
|
||||
try {
|
||||
String currency_iso = "IDR";
|
||||
priceCIF = new BigDecimal(dataRow.getCell(BARANG_HARGACIFRUPIAH_COLUMN).getNumericCellValue());
|
||||
try {
|
||||
currency_iso = dataRow.getCell(HEADER_CURRENCYISO_COLUMN).getStringCellValue();
|
||||
} catch (Exception e) {}
|
||||
if(currency_iso.equals("USD")) {
|
||||
if(order.getC_Currency().getISO_Code().equals("IDR")) {
|
||||
priceCIF = new BigDecimal(dataRow.getCell(BARANG_HARGACIFRUPIAH_COLUMN).getNumericCellValue());
|
||||
}else if (order.getC_Currency().getISO_Code().equals("USD")) {
|
||||
priceCIF = new BigDecimal(dataRow.getCell(BARANG_HARGACIF_COLUMN).getNumericCellValue());
|
||||
}
|
||||
PriceList = priceCIF.divide(Qty);
|
||||
PriceList = priceCIF.divide(Qty,order.getC_Currency().getStdPrecision(),BigDecimal.ROUND_DOWN);
|
||||
}catch(Exception e) {
|
||||
PriceList = Env.ZERO;
|
||||
}
|
||||
}else {
|
||||
try {
|
||||
PriceList = new BigDecimal(dataRow.getCell(BARANG_HARGASATUAN_COLUMN).getNumericCellValue());
|
||||
if(PriceList.compareTo(Env.ZERO) == 0) {
|
||||
BigDecimal HargaPenyerahan = new BigDecimal(dataRow.getCell(BARANG_HARGAPENYERAHAN_COLUMN).getNumericCellValue());
|
||||
PriceList = HargaPenyerahan.divide(Qty,order.getC_Currency().getStdPrecision(),BigDecimal.ROUND_DOWN);
|
||||
}
|
||||
}catch(Exception e) {
|
||||
PriceList = new BigDecimal(dataRow.getCell(BARANG_HARGAPENYERAHAN_COLUMN).getNumericCellValue());
|
||||
BigDecimal HargaPenyerahan = new BigDecimal(dataRow.getCell(BARANG_HARGAPENYERAHAN_COLUMN).getNumericCellValue());
|
||||
PriceList = HargaPenyerahan.divide(Qty,order.getC_Currency().getStdPrecision(),BigDecimal.ROUND_DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,12 @@ public class MID_UploadPEB extends SvrProcess{
|
|||
order.set_ValueNoCheck("RegisterNo", row.getCell(103).getStringCellValue());
|
||||
order.setIsSOTrx(true);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy");
|
||||
Date parsedDate = dateFormat.parse(row.getCell(117).getStringCellValue());
|
||||
Date parsedDate;
|
||||
try {
|
||||
parsedDate = dateFormat.parse(row.getCell(123).getStringCellValue());
|
||||
}catch(Exception e) {
|
||||
parsedDate = dateFormat.parse(row.getCell(117).getStringCellValue());
|
||||
}
|
||||
Timestamp registerDate = new Timestamp(parsedDate.getTime());
|
||||
order.set_ValueNoCheck("RegisterDate", registerDate);
|
||||
order.set_ValueNoCheck("NoAju1", row.getCell(0).getStringCellValue());
|
||||
|
|
|
|||
|
|
@ -77,7 +77,12 @@ public class MID_UploadPEBOrder extends SvrProcess{
|
|||
|
||||
order.set_ValueNoCheck("RegisterNo", row.getCell(103).getStringCellValue());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy");
|
||||
Date parsedDate = dateFormat.parse(row.getCell(117).getStringCellValue());
|
||||
Date parsedDate;
|
||||
try {
|
||||
parsedDate = dateFormat.parse(row.getCell(123).getStringCellValue());
|
||||
}catch(Exception e) {
|
||||
parsedDate = dateFormat.parse(row.getCell(117).getStringCellValue());
|
||||
}
|
||||
Timestamp registerDate = new Timestamp(parsedDate.getTime());
|
||||
order.set_ValueNoCheck("RegisterDate", registerDate);
|
||||
order.set_ValueNoCheck("NoAju1", row.getCell(0).getStringCellValue());
|
||||
|
|
|
|||
|
|
@ -101,7 +101,12 @@ public class MID_UploadPEBWindow extends SvrProcess{
|
|||
line.setRegisterNo(row.getCell(103).getStringCellValue());
|
||||
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy");
|
||||
Date parsedDate = dateFormat.parse(row.getCell(117).getStringCellValue());
|
||||
Date parsedDate;
|
||||
try {
|
||||
parsedDate = dateFormat.parse(row.getCell(123).getStringCellValue());
|
||||
}catch(Exception e) {
|
||||
parsedDate = dateFormat.parse(row.getCell(117).getStringCellValue());
|
||||
}
|
||||
Timestamp registerDate = new Timestamp(parsedDate.getTime());
|
||||
line.setRegisterDate(registerDate);
|
||||
line.setNoAju(row.getCell(0).getStringCellValue());
|
||||
|
|
|
|||
|
|
@ -125,10 +125,11 @@ public class MID_UploadTPB extends SvrProcess{
|
|||
Date parsedDate = null;
|
||||
AJU_DocType_Value = dataRow.getCell(5).getStringCellValue();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy");
|
||||
if(AJU_DocType_Value.equals("40"))
|
||||
try {
|
||||
parsedDate = dateFormat.parse(dataRow.getCell(123).getStringCellValue());
|
||||
else
|
||||
}catch(Exception e) {
|
||||
parsedDate = dateFormat.parse(dataRow.getCell(117).getStringCellValue());
|
||||
}
|
||||
Timestamp registerDate = new Timestamp(parsedDate.getTime());
|
||||
tpbLine.setRegisterDate(registerDate);
|
||||
int MID_AJUDocType_ID = DB.getSQLValue(get_TrxName(), "SELECT MID_AJUDocumentType_ID FROM MID_AJUDocumentType WHERE Value=? AND AD_Client_ID =? AND AD_Org_ID =?", new Object[] { AJU_DocType_Value, getAD_Client_ID(), tpb.getAD_Org_ID() });
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
package andromedia.midsuit.validator;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MInvoiceTax;
|
||||
import org.compiere.model.MOrderTax;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
import andromedia.midsuit.model.MID_MOrder;
|
||||
|
||||
public class MID_InvoiceTaxValidator {
|
||||
|
||||
private static CLogger log = CLogger.getCLogger (MID_InvoiceTaxValidator.class);
|
||||
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
MInvoiceTax tax = (MInvoiceTax) po;
|
||||
if (e.getTopic().equals(IEventTopics.PO_AFTER_NEW))
|
||||
return calculatePpn2025New(tax);
|
||||
if(e.getTopic().equals(IEventTopics.PO_AFTER_CHANGE))
|
||||
return calculatePpn2025Change(tax);
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String calculatePpn2025New(MInvoiceTax tax) {
|
||||
BigDecimal amount = tax.getTaxBaseAmt();//DB.getSQLValueBDEx(null, "SELECT SUM(LineNetAmt) FROM C_OrderLine WHERE C_Order_ID = ? AND C_Tax_ID = ?", new Object[] {tax.getC_Order_ID(), tax.getC_Tax_ID()});
|
||||
BigDecimal ppn2025baseamt = tax.getC_Tax().getRate().multiply(amount).divide(new BigDecimal(12), 2, RoundingMode.HALF_UP);
|
||||
new java.util.Timer().schedule(new java.util.TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
DB.executeUpdateEx("UPDATE C_InvoiceTax SET taxbaseamt_reg2025=? WHERE C_Invoice_ID = ? AND C_Tax_ID = ?", new Object[] {ppn2025baseamt, tax.getC_Invoice_ID(), tax.getC_Tax_ID()},null);
|
||||
}
|
||||
|
||||
}, 1000);
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String calculatePpn2025Change(MInvoiceTax tax) {
|
||||
BigDecimal amount = tax.getTaxBaseAmt();
|
||||
BigDecimal ppn2025baseamt = tax.getC_Tax().getRate().multiply(amount).divide(new BigDecimal(12), 2, RoundingMode.HALF_UP);
|
||||
|
||||
new java.util.Timer().schedule(new java.util.TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
DB.executeUpdateEx("UPDATE C_InvoiceTax SET taxbaseamt_reg2025=? WHERE C_Invoice_ID = ? AND C_Tax_ID = ?", new Object[] {ppn2025baseamt, tax.getC_Invoice_ID(), tax.getC_Tax_ID()},null);
|
||||
}
|
||||
|
||||
}, 1000);
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package andromedia.midsuit.validator;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MOrderTax;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
import andromedia.midsuit.model.MID_MOrder;
|
||||
|
||||
public class MID_OrderTaxValidator {
|
||||
|
||||
private static CLogger log = CLogger.getCLogger (MID_OrderTaxValidator.class);
|
||||
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
MOrderTax orderTax = (MOrderTax) po;
|
||||
if (e.getTopic().equals(IEventTopics.PO_AFTER_NEW))
|
||||
return calculatePpn2025New(orderTax);
|
||||
if(e.getTopic().equals(IEventTopics.PO_AFTER_CHANGE))
|
||||
return calculatePpn2025Change(orderTax);
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String calculatePpn2025New(MOrderTax tax) {
|
||||
BigDecimal amount = tax.getTaxBaseAmt();//DB.getSQLValueBDEx(null, "SELECT SUM(LineNetAmt) FROM C_OrderLine WHERE C_Order_ID = ? AND C_Tax_ID = ?", new Object[] {tax.getC_Order_ID(), tax.getC_Tax_ID()});
|
||||
BigDecimal ppn2025baseamt = tax.getC_Tax().getRate().multiply(amount).divide(new BigDecimal(12), 2, RoundingMode.HALF_UP);
|
||||
new java.util.Timer().schedule(new java.util.TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
DB.executeUpdateEx("UPDATE C_OrderTax SET taxbaseamt_reg2025=? WHERE C_Order_ID = ? AND C_Tax_ID = ?", new Object[] {ppn2025baseamt, tax.getC_Order_ID(), tax.getC_Tax_ID()},null);
|
||||
}
|
||||
|
||||
}, 1000);
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String calculatePpn2025Change(MOrderTax tax) {
|
||||
BigDecimal amount = tax.getTaxBaseAmt();
|
||||
BigDecimal ppn2025baseamt = tax.getC_Tax().getRate().multiply(amount).divide(new BigDecimal(12), 2, RoundingMode.HALF_UP);
|
||||
|
||||
new java.util.Timer().schedule(new java.util.TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
DB.executeUpdateEx("UPDATE C_OrderTax SET taxbaseamt_reg2025=? WHERE C_Order_ID = ? AND C_Tax_ID = ?", new Object[] {ppn2025baseamt, tax.getC_Order_ID(), tax.getC_Tax_ID()},null);
|
||||
}
|
||||
|
||||
}, 1000);
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package andromedia.midsuit.validator;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MOrderTax;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
import andromedia.midsuit.model.MID_MOrder;
|
||||
import andromedia.midsuit.model.X_M_RequisitionTax;
|
||||
|
||||
public class MID_RequisitionTaxValidator {
|
||||
|
||||
private static CLogger log = CLogger.getCLogger (MID_RequisitionTaxValidator.class);
|
||||
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
X_M_RequisitionTax orderTax = (X_M_RequisitionTax) po;
|
||||
if (e.getTopic().equals(IEventTopics.PO_AFTER_NEW))
|
||||
return calculatePpn2025New(orderTax);
|
||||
if(e.getTopic().equals(IEventTopics.PO_AFTER_CHANGE))
|
||||
return calculatePpn2025Change(orderTax);
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String calculatePpn2025New(X_M_RequisitionTax tax) {
|
||||
// BigDecimal amount = tax.getTaxBaseAmt();//DB.getSQLValueBDEx(null, "SELECT SUM(LineNetAmt) FROM C_OrderLine WHERE C_Order_ID = ? AND C_Tax_ID = ?", new Object[] {tax.getC_Order_ID(), tax.getC_Tax_ID()});
|
||||
// BigDecimal ppn2025baseamt = tax.getC_Tax().getRate().multiply(amount).divide(new BigDecimal(12), 2, RoundingMode.HALF_UP);
|
||||
// new java.util.Timer().schedule(new java.util.TimerTask() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// log.warning("1. amt "+amount+" ppn "+ppn2025baseamt);
|
||||
// DB.executeUpdateEx("UPDATE M_RequisitionTax SET taxbaseamt_reg2025=? WHERE M_Requisition_ID = ? AND C_Tax_ID = ?", new Object[] {ppn2025baseamt, tax.getM_Requisition_ID(), tax.getC_Tax_ID()},null);
|
||||
// }
|
||||
//
|
||||
// }, 1000);
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String calculatePpn2025Change(X_M_RequisitionTax tax) {
|
||||
// BigDecimal amount = tax.getTaxBaseAmt();
|
||||
// BigDecimal ppn2025baseamt = tax.getC_Tax().getRate().multiply(amount).divide(new BigDecimal(12), 2, RoundingMode.HALF_UP);
|
||||
//
|
||||
// new java.util.Timer().schedule(new java.util.TimerTask() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// log.warning("2. amt "+amount+" ppn "+ppn2025baseamt);
|
||||
// DB.executeUpdateEx("UPDATE M_RequisitionTax SET taxbaseamt_reg2025=? WHERE M_Requisition_ID = ? AND C_Tax_ID = ?", new Object[] {ppn2025baseamt, tax.getM_RequisitionTax_ID(), tax.getC_Tax_ID()},null);
|
||||
// }
|
||||
// }, 1000);
|
||||
//
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue