parent
dcceecae85
commit
8e55b712b7
|
|
@ -0,0 +1,36 @@
|
||||||
|
package andromedia.midsuit.callout;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.adempiere.base.IColumnCallout;
|
||||||
|
import org.compiere.model.CalloutEngine;
|
||||||
|
import org.compiere.model.GridField;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.MRequisitionLine;
|
||||||
|
import org.compiere.model.MTax;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
|
||||||
|
public class MID_CalloutRequisitionLine extends CalloutEngine implements IColumnCallout{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String start(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) {
|
||||||
|
if(mField.getColumnName().equals(MRequisitionLine.COLUMNNAME_Qty)
|
||||||
|
|| mField.getColumnName().equals(MRequisitionLine.COLUMNNAME_PriceActual))
|
||||||
|
setTax(ctx, WindowNo, mTab, mField, value, oldValue);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String setTax(Properties ctx, int windowNo, GridTab mTab, GridField mField, Object value, Object oldValue) {
|
||||||
|
int C_Tax_ID = (int) mTab.getValue("C_Tax_ID");
|
||||||
|
if(C_Tax_ID==0) return "";
|
||||||
|
MTax tax = MTax.get(ctx, C_Tax_ID);
|
||||||
|
|
||||||
|
BigDecimal calculatedTax = (BigDecimal) mTab.getValue(MRequisitionLine.COLUMNNAME_LineNetAmt);
|
||||||
|
calculatedTax = calculatedTax.multiply(tax.getRate()).divide(Env.ONEHUNDRED, 2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
|
||||||
|
mTab.setValue("TaxAmt", calculatedTax);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,7 @@ import org.compiere.model.MOrder;
|
||||||
import org.compiere.model.MProduction;
|
import org.compiere.model.MProduction;
|
||||||
import org.compiere.model.MProductionLine;
|
import org.compiere.model.MProductionLine;
|
||||||
import org.compiere.model.X_C_OrderLine;
|
import org.compiere.model.X_C_OrderLine;
|
||||||
|
import org.compiere.model.X_M_RequisitionLine;
|
||||||
|
|
||||||
import andromedia.midsuit.callout.MID_CalloutAnalysisQC;
|
import andromedia.midsuit.callout.MID_CalloutAnalysisQC;
|
||||||
import andromedia.midsuit.callout.MID_CalloutInOut;
|
import andromedia.midsuit.callout.MID_CalloutInOut;
|
||||||
|
|
@ -25,6 +26,7 @@ import andromedia.midsuit.callout.MID_CalloutOrder;
|
||||||
import andromedia.midsuit.callout.MID_CalloutOrderLineMA;
|
import andromedia.midsuit.callout.MID_CalloutOrderLineMA;
|
||||||
import andromedia.midsuit.callout.MID_CalloutProduction;
|
import andromedia.midsuit.callout.MID_CalloutProduction;
|
||||||
import andromedia.midsuit.callout.MID_CalloutProductionLine;
|
import andromedia.midsuit.callout.MID_CalloutProductionLine;
|
||||||
|
import andromedia.midsuit.callout.MID_CalloutRequisitionLine;
|
||||||
import andromedia.midsuit.callout.MID_CalloutRequisitionTrxLine;
|
import andromedia.midsuit.callout.MID_CalloutRequisitionTrxLine;
|
||||||
import andromedia.midsuit.model.MID_Analysis;
|
import andromedia.midsuit.model.MID_Analysis;
|
||||||
import andromedia.midsuit.model.X_C_OrderLineMA;
|
import andromedia.midsuit.model.X_C_OrderLineMA;
|
||||||
|
|
@ -58,6 +60,8 @@ public class MID_CalloutFactory implements IColumnCalloutFactory{
|
||||||
list.add(new MID_CalloutInventoryLineMA());
|
list.add(new MID_CalloutInventoryLineMA());
|
||||||
if(tableName.equals(X_C_OrderLineMA.Table_Name))
|
if(tableName.equals(X_C_OrderLineMA.Table_Name))
|
||||||
list.add(new MID_CalloutOrderLineMA());
|
list.add(new MID_CalloutOrderLineMA());
|
||||||
|
if(tableName.equals(X_M_RequisitionLine.Table_Name))
|
||||||
|
list.add(new MID_CalloutRequisitionLine());
|
||||||
|
|
||||||
return list != null ? list.toArray(new IColumnCallout[0]) : new IColumnCallout[0];
|
return list != null ? list.toArray(new IColumnCallout[0]) : new IColumnCallout[0];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,10 @@ import andromedia.midsuit.model.MID_MBillingList;
|
||||||
import andromedia.midsuit.model.MID_MBillingListLine;
|
import andromedia.midsuit.model.MID_MBillingListLine;
|
||||||
import andromedia.midsuit.model.MID_MDDOrder;
|
import andromedia.midsuit.model.MID_MDDOrder;
|
||||||
import andromedia.midsuit.model.MID_MDDOrderLine;
|
import andromedia.midsuit.model.MID_MDDOrderLine;
|
||||||
|
import andromedia.midsuit.model.MID_MDepreciationEntry;
|
||||||
import andromedia.midsuit.model.MID_MProductionConfirm;
|
import andromedia.midsuit.model.MID_MProductionConfirm;
|
||||||
import andromedia.midsuit.model.MID_MRequisition;
|
import andromedia.midsuit.model.MID_MRequisition;
|
||||||
|
import andromedia.midsuit.model.MID_MRequisitionLine;
|
||||||
import andromedia.midsuit.model.MID_MRequisitionTrx;
|
import andromedia.midsuit.model.MID_MRequisitionTrx;
|
||||||
import andromedia.midsuit.model.MID_MRequisitionTrxLine;
|
import andromedia.midsuit.model.MID_MRequisitionTrxLine;
|
||||||
import andromedia.midsuit.model.MID_PPO;
|
import andromedia.midsuit.model.MID_PPO;
|
||||||
|
|
@ -46,6 +48,8 @@ public class MID_ModelFactory implements IModelFactory{
|
||||||
mapTableModels.put(MID_PPOLine.Table_Name, "andromedia.midsuit.model.MID_PPOLine");
|
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_C_OrderLineMA.Table_Name, "andromedia.midsuit.model.X_C_OrderLineMA");
|
||||||
mapTableModels.put(MID_MRequisition.Table_Name, "andromedia.midsuit.model.MID_MRequisition");
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
package andromedia.midsuit.model;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.compiere.model.MDepreciationEntry;
|
||||||
|
import org.compiere.process.DocAction;
|
||||||
|
import org.compiere.process.DocOptions;
|
||||||
|
|
||||||
|
public class MID_MDepreciationEntry extends MDepreciationEntry implements DocOptions{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -1013070483426302942L;
|
||||||
|
|
||||||
|
public MID_MDepreciationEntry(Properties ctx, int A_Depreciation_Entry_ID, String trxName) {
|
||||||
|
super(ctx, A_Depreciation_Entry_ID, trxName);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
public MID_MDepreciationEntry(Properties ctx, ResultSet rs, String trxName) {
|
||||||
|
super(ctx, rs, trxName);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean voidIt() {
|
||||||
|
if(getDocStatus().equals(DocAction.STATUS_Completed)){
|
||||||
|
reActivateIt();
|
||||||
|
}
|
||||||
|
|
||||||
|
setProcessed(true);
|
||||||
|
setDocStatus(DocAction.STATUS_Voided);
|
||||||
|
setDocAction(DocAction.ACTION_None);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int customizeValidActions(String docStatus, Object processing,
|
||||||
|
String orderType, String isSOTrx, int AD_Table_ID,
|
||||||
|
String[] docAction, String[] options, int index) {
|
||||||
|
for (int i = 0; i < options.length; i++) {
|
||||||
|
options[i] = null;
|
||||||
|
}
|
||||||
|
index = 0;
|
||||||
|
if (docStatus.equals(DocAction.STATUS_Drafted)) {
|
||||||
|
options[index++] = DocAction.ACTION_Complete;
|
||||||
|
options[index++] = DocAction.ACTION_Void;
|
||||||
|
} else if (docStatus.equals(DocAction.STATUS_InProgress)) {
|
||||||
|
options[index++] = DocAction.ACTION_Complete;
|
||||||
|
options[index++] = DocAction.ACTION_Void;
|
||||||
|
} else if (docStatus.equals(DocAction.STATUS_Completed)) {
|
||||||
|
options[index++] = DocAction.ACTION_ReActivate;
|
||||||
|
options[index++] = DocAction.ACTION_Void;
|
||||||
|
} else if (docStatus.equals(DocAction.STATUS_Invalid)) {
|
||||||
|
options[index++] = DocAction.ACTION_Complete;
|
||||||
|
options[index++] = DocAction.ACTION_Void;
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
package andromedia.midsuit.model;
|
package andromedia.midsuit.model;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.model.MRequisition;
|
import org.compiere.model.MRequisition;
|
||||||
import org.compiere.process.DocAction;
|
import org.compiere.process.DocAction;
|
||||||
import org.compiere.process.DocOptions;
|
import org.compiere.process.DocOptions;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
|
||||||
public class MID_MRequisition extends MRequisition implements DocOptions{
|
public class MID_MRequisition extends MRequisition implements DocOptions{
|
||||||
|
|
||||||
|
|
@ -23,6 +25,16 @@ public class MID_MRequisition extends MRequisition implements DocOptions{
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean recalculateTax() {
|
||||||
|
BigDecimal totalTaxAmt = DB.getSQLValueBD(get_TrxName(), "SELECT COALESCE(SUM(TaxAmt),0) FROM M_RequisitionLine WHERE M_Requisition_ID =?", new Object[] { getM_Requisition_ID() });
|
||||||
|
BigDecimal totalLines = DB.getSQLValueBD(get_TrxName(), "SELECT COALESCE(SUM(LineNetAmt),0) FROM M_RequisitionLine WHERE M_Requisition_ID =?", new Object[] { getM_Requisition_ID() });
|
||||||
|
setTotalLines(totalLines);
|
||||||
|
set_Value("TaxAmt", totalTaxAmt);
|
||||||
|
set_Value("GrandTotal", totalLines.add(totalTaxAmt));
|
||||||
|
saveEx();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean reActivateIt() {
|
public boolean reActivateIt() {
|
||||||
setDocStatus(DocAction.STATUS_InProgress);
|
setDocStatus(DocAction.STATUS_InProgress);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package andromedia.midsuit.model;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.compiere.model.MRequisition;
|
||||||
|
import org.compiere.model.MRequisitionLine;
|
||||||
|
|
||||||
|
public class MID_MRequisitionLine extends MRequisitionLine{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 978479235069420619L;
|
||||||
|
public MID_MRequisitionLine(MRequisition req) {
|
||||||
|
super(req);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
public MID_MRequisitionLine(Properties ctx, int M_RequisitionLine_ID, String trxName) {
|
||||||
|
super(ctx, M_RequisitionLine_ID, trxName);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
public MID_MRequisitionLine(Properties ctx, ResultSet rs, String trxName) {
|
||||||
|
super(ctx, rs, trxName);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean afterSave(boolean newRecord, boolean success) {
|
||||||
|
MID_MRequisition requisition = new MID_MRequisition(getCtx(), getM_Requisition_ID(), get_TrxName());
|
||||||
|
// super.afterSave(newRecord, success);
|
||||||
|
return requisition.recalculateTax();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue