parent
8c37381e56
commit
a6fb38f51d
|
|
@ -4,6 +4,7 @@ import java.math.BigDecimal;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
@ -603,7 +604,9 @@ public abstract class MID_CreateFromInvoice extends CreateFrom {
|
||||||
invoice.validatePaySchedule();
|
invoice.validatePaySchedule();
|
||||||
invoice.saveEx();
|
invoice.saveEx();
|
||||||
}
|
}
|
||||||
|
invoice.set_ValueOfColumn("RegisterDate", (Timestamp) p_order.get_Value("RegisterDate") == null ? null : (Timestamp)p_order.get_Value("RegisterDate"));
|
||||||
|
invoice.set_ValueOfColumn("RegisterNo", p_order.get_ValueAsString("RegisterNo") == null ? null : p_order.get_ValueAsString("RegisterNo"));
|
||||||
|
invoice.set_ValueOfColumn("MID_AJUDocumentType_ID", p_order.get_ValueAsInt("MID_AJUDocumentType_ID"));
|
||||||
invoice.set_ValueOfColumn("noaju1", p_order.get_ValueAsString("noaju1") == null ? null : p_order.get_ValueAsString("noaju1"));
|
invoice.set_ValueOfColumn("noaju1", p_order.get_ValueAsString("noaju1") == null ? null : p_order.get_ValueAsString("noaju1"));
|
||||||
invoice.set_ValueOfColumn("noaju2", p_order.get_ValueAsString("noaju2") == null ? null : p_order.get_ValueAsString("noaju2"));
|
invoice.set_ValueOfColumn("noaju2", p_order.get_ValueAsString("noaju2") == null ? null : p_order.get_ValueAsString("noaju2"));
|
||||||
invoice.set_ValueOfColumn("noaju3", p_order.get_ValueAsString("noaju3") == null ? null : p_order.get_ValueAsString("noaju3"));
|
invoice.set_ValueOfColumn("noaju3", p_order.get_ValueAsString("noaju3") == null ? null : p_order.get_ValueAsString("noaju3"));
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ public class MID_CreateFromOrder extends CreateFrom {
|
||||||
} else if (org.get_ValueAsBoolean("IsProjectBased")) {
|
} else if (org.get_ValueAsBoolean("IsProjectBased")) {
|
||||||
project = new StringBuilder(" AND r.C_Project_ID is null");
|
project = new StringBuilder(" AND r.C_Project_ID is null");
|
||||||
}
|
}
|
||||||
|
String isSOTrxParam = isSOTrx ? "Y":"N";
|
||||||
StringBuilder sql = new StringBuilder("SELECT DISTINCT r.M_Requisition_ID,").append(display)
|
StringBuilder sql = new StringBuilder("SELECT DISTINCT r.M_Requisition_ID,").append(display)
|
||||||
.append(" FROM M_Requisition r ")
|
.append(" FROM M_Requisition r ")
|
||||||
.append(" LEFT JOIN M_RequisitionLine rl ON (rl.M_Requisition_ID=r.M_Requisition_ID)")
|
.append(" LEFT JOIN M_RequisitionLine rl ON (rl.M_Requisition_ID=r.M_Requisition_ID)")
|
||||||
|
|
@ -274,13 +274,13 @@ public class MID_CreateFromOrder extends CreateFrom {
|
||||||
.append(" GROUP BY M_RequisitionLine_ID) ol ON (ol.M_RequisitionLine_ID=rl.M_RequisitionLine_ID)")
|
.append(" GROUP BY M_RequisitionLine_ID) ol ON (ol.M_RequisitionLine_ID=rl.M_RequisitionLine_ID)")
|
||||||
.append(" WHERE EXISTS (SELECT 1 FROM M_RequisitionLine l WHERE r.M_Requisition_ID=l.M_Requisition_ID")
|
.append(" WHERE EXISTS (SELECT 1 FROM M_RequisitionLine l WHERE r.M_Requisition_ID=l.M_Requisition_ID")
|
||||||
//.append(" AND l.AD_Client_ID=? AND r.DocStatus=?) AND r.C_BPartner_ID =?");
|
//.append(" AND l.AD_Client_ID=? AND r.DocStatus=?) AND r.C_BPartner_ID =?");
|
||||||
.append(" AND l.AD_Client_ID=? AND r.DocStatus='CO') AND r.M_Warehouse_ID =?")
|
.append(" AND l.AD_Client_ID=? AND r.DocStatus='CO') AND r.M_Warehouse_ID =? AND r.IsSOTrx=?")
|
||||||
.append(" AND (rl.qty > ol.QtyOrdered OR COALESCE(rl.qty - COALESCE(ol.QtyOrdered,0), 0) > 0)")
|
.append(" AND (rl.qty > ol.QtyOrdered OR COALESCE(rl.qty - COALESCE(ol.QtyOrdered,0), 0) > 0)")
|
||||||
.append(project)
|
.append(project)
|
||||||
.append(" GROUP BY r.M_Requisition_ID");
|
.append(" GROUP BY r.M_Requisition_ID");
|
||||||
|
|
||||||
sql = sql.append(" ORDER BY r.DocumentNo DESC");
|
sql = sql.append(" ORDER BY r.DocumentNo DESC");
|
||||||
|
log.severe(isSOTrxParam);
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
|
|
||||||
|
|
@ -291,7 +291,7 @@ public class MID_CreateFromOrder extends CreateFrom {
|
||||||
pstmt.setInt(++count, AD_Client_ID);
|
pstmt.setInt(++count, AD_Client_ID);
|
||||||
// pstmt.setString(++count, DocAction.STATUS_Completed);
|
// pstmt.setString(++count, DocAction.STATUS_Completed);
|
||||||
pstmt.setInt(++count, M_Warehouse_ID);
|
pstmt.setInt(++count, M_Warehouse_ID);
|
||||||
//pstmt.setInt(++count, C_BPartner_ID);
|
pstmt.setString(++count, isSOTrxParam);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
list.add(new KeyNamePair(rs.getInt(1), rs.getString(2)));
|
list.add(new KeyNamePair(rs.getInt(1), rs.getString(2)));
|
||||||
|
|
@ -346,7 +346,7 @@ public class MID_CreateFromOrder extends CreateFrom {
|
||||||
BigDecimal qtyOrdered = qty;
|
BigDecimal qtyOrdered = qty;
|
||||||
// BigDecimal qtyOrdered = sisapo;
|
// BigDecimal qtyOrdered = sisapo;
|
||||||
KeyNamePair pp = (KeyNamePair)miniTable.getValueAt(i, 1); // 1-Line
|
KeyNamePair pp = (KeyNamePair)miniTable.getValueAt(i, 1); // 1-Line
|
||||||
if(!isSOTrx){
|
if(!isSOTrx || isSOTrx){
|
||||||
|
|
||||||
int requisitionLineID = pp.getKey();
|
int requisitionLineID = pp.getKey();
|
||||||
MRequisitionLine reqLine = new MRequisitionLine(Env.getCtx(), requisitionLineID, null);
|
MRequisitionLine reqLine = new MRequisitionLine(Env.getCtx(), requisitionLineID, null);
|
||||||
|
|
@ -470,114 +470,115 @@ public class MID_CreateFromOrder extends CreateFrom {
|
||||||
MRequisition req = (MRequisition) reqLine.getM_Requisition();
|
MRequisition req = (MRequisition) reqLine.getM_Requisition();
|
||||||
if(req.get_ValueAsInt("C_BPartner_ID")>0)
|
if(req.get_ValueAsInt("C_BPartner_ID")>0)
|
||||||
order.setC_BPartner_ID(req.get_ValueAsInt("C_BPartner_ID"));
|
order.setC_BPartner_ID(req.get_ValueAsInt("C_BPartner_ID"));
|
||||||
} else {
|
}
|
||||||
//Is SO Trx = Y
|
// } else {
|
||||||
int requisitionLineID = pp.getKey();
|
// //Is SO Trx = Y
|
||||||
MID_MRequisitionTrxLine reqLine = new MID_MRequisitionTrxLine(Env.getCtx(), requisitionLineID, null);
|
// int requisitionLineID = pp.getKey();
|
||||||
|
// MID_MRequisitionTrxLine reqLine = new MID_MRequisitionTrxLine(Env.getCtx(), requisitionLineID, null);
|
||||||
StringBuilder sql = new StringBuilder();
|
//
|
||||||
|
// StringBuilder sql = new StringBuilder();
|
||||||
if (reqLine.getC_UOM_ID()>0 && reqLine.getM_Product_ID() > 0) {
|
//
|
||||||
if(reqLine.getC_UOM_ID()!=reqLine.getM_Product().getC_UOM_ID())
|
// if (reqLine.getC_UOM_ID()>0 && reqLine.getM_Product_ID() > 0) {
|
||||||
// qtyOrdered = MUOMConversion.convertProductTo (Env.getCtx(), reqLine.getM_Product_ID(), reqLine.getC_UOM_ID(), qty);
|
// if(reqLine.getC_UOM_ID()!=reqLine.getM_Product().getC_UOM_ID())
|
||||||
qtyOrdered = MUOMConversion.convertProductTo(Env.getCtx(), reqLine.getM_Product_ID(), reqLine.getC_UOM_ID(), qty);
|
//// qtyOrdered = MUOMConversion.convertProductTo (Env.getCtx(), reqLine.getM_Product_ID(), reqLine.getC_UOM_ID(), qty);
|
||||||
if (qtyOrdered == null)
|
// qtyOrdered = MUOMConversion.convertProductTo(Env.getCtx(), reqLine.getM_Product_ID(), reqLine.getC_UOM_ID(), qty);
|
||||||
qtyOrdered = Env.ZERO;
|
// if (qtyOrdered == null)
|
||||||
}
|
// qtyOrdered = Env.ZERO;
|
||||||
|
// }
|
||||||
BigDecimal Qty = reqLine.getQty();
|
//
|
||||||
boolean IsSOTrx = order.isSOTrx();
|
// BigDecimal Qty = reqLine.getQty();
|
||||||
MProductPricing pricing = new MProductPricing (reqLine.getM_Product_ID(), order.getC_BPartner_ID(), Qty, IsSOTrx);
|
// boolean IsSOTrx = order.isSOTrx();
|
||||||
|
// MProductPricing pricing = new MProductPricing (reqLine.getM_Product_ID(), order.getC_BPartner_ID(), Qty, IsSOTrx);
|
||||||
int M_PriceList_ID = order.getM_PriceList_ID();
|
//
|
||||||
pricing.setM_PriceList_ID(M_PriceList_ID);
|
// int M_PriceList_ID = order.getM_PriceList_ID();
|
||||||
|
// pricing.setM_PriceList_ID(M_PriceList_ID);
|
||||||
String sqlString = "SELECT plv.M_PriceList_Version_ID "
|
//
|
||||||
+ "FROM M_PriceList_Version plv "
|
// String sqlString = "SELECT plv.M_PriceList_Version_ID "
|
||||||
+ "WHERE plv.M_PriceList_ID=? " // 1
|
// + "FROM M_PriceList_Version plv "
|
||||||
+ " AND plv.ValidFrom <= ? "
|
// + "WHERE plv.M_PriceList_ID=? " // 1
|
||||||
+ "ORDER BY plv.ValidFrom DESC";
|
// + " AND plv.ValidFrom <= ? "
|
||||||
// Use newest price list - may not be future
|
// + "ORDER BY plv.ValidFrom DESC";
|
||||||
|
// // Use newest price list - may not be future
|
||||||
int M_PriceList_Version_ID = DB.getSQLValueEx(null, sqlString,order.getM_PriceList_ID(), order.getDateOrdered());
|
//
|
||||||
|
// int M_PriceList_Version_ID = DB.getSQLValueEx(null, sqlString,order.getM_PriceList_ID(), order.getDateOrdered());
|
||||||
pricing.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
//
|
||||||
pricing.setPriceDate(order.getDateOrdered());
|
// pricing.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
||||||
|
// pricing.setPriceDate(order.getDateOrdered());
|
||||||
// orderLine.setPriceEntered(pricing.getPriceStd().subtract(pricing.getPriceStd().multiply(orderLine.getDiscount())));
|
//
|
||||||
// orderLine.setPriceActual(pricing.getPriceStd());
|
//// orderLine.setPriceEntered(pricing.getPriceStd().subtract(pricing.getPriceStd().multiply(orderLine.getDiscount())));
|
||||||
// orderLine.setPriceList(pricing.getPriceList());
|
//// orderLine.setPriceActual(pricing.getPriceStd());
|
||||||
// orderLine.setPriceLimit(pricing.getPriceLimit());
|
//// orderLine.setPriceList(pricing.getPriceList());
|
||||||
orderLine.setPrice(reqLine.getPriceActual());
|
//// orderLine.setPriceLimit(pricing.getPriceLimit());
|
||||||
//@Hodianto Change Default Price List
|
// orderLine.setPrice(reqLine.getPriceActual());
|
||||||
MPriceList priceList = new MPriceList(Env.getCtx(), M_PriceList_ID, null);
|
// //@Hodianto Change Default Price List
|
||||||
if(priceList.get_ValueAsBoolean("isLastPriceUsed")){
|
// MPriceList priceList = new MPriceList(Env.getCtx(), M_PriceList_ID, null);
|
||||||
int invoiceLineID = new Query(Env.getCtx(), MInvoiceLine.Table_Name, "C_InvoiceLine.M_Product_ID =?", null)
|
// if(priceList.get_ValueAsBoolean("isLastPriceUsed")){
|
||||||
.addJoinClause("JOIN C_Invoice i ON i.C_Invoice_ID = C_InvoiceLine.C_Invoice_ID ")
|
// int invoiceLineID = new Query(Env.getCtx(), MInvoiceLine.Table_Name, "C_InvoiceLine.M_Product_ID =?", null)
|
||||||
.setParameters(new Object[]{reqLine.getM_Product_ID() })
|
// .addJoinClause("JOIN C_Invoice i ON i.C_Invoice_ID = C_InvoiceLine.C_Invoice_ID ")
|
||||||
.setOrderBy("i.DateInvoiced DESC")
|
// .setParameters(new Object[]{reqLine.getM_Product_ID() })
|
||||||
.setOnlyActiveRecords(true)
|
// .setOrderBy("i.DateInvoiced DESC")
|
||||||
.firstId();
|
// .setOnlyActiveRecords(true)
|
||||||
|
// .firstId();
|
||||||
if(invoiceLineID>0){
|
//
|
||||||
MInvoiceLine invoiceLine = new MInvoiceLine(Env.getCtx(),invoiceLineID,null);
|
// if(invoiceLineID>0){
|
||||||
orderLine.setPriceEntered(invoiceLine.getPriceEntered());
|
// MInvoiceLine invoiceLine = new MInvoiceLine(Env.getCtx(),invoiceLineID,null);
|
||||||
orderLine.setPriceActual(invoiceLine.getPriceEntered());
|
// orderLine.setPriceEntered(invoiceLine.getPriceEntered());
|
||||||
orderLine.setPriceList(invoiceLine.getPriceEntered());
|
// orderLine.setPriceActual(invoiceLine.getPriceEntered());
|
||||||
orderLine.setPriceLimit(invoiceLine.getPriceEntered());
|
// orderLine.setPriceList(invoiceLine.getPriceEntered());
|
||||||
}
|
// orderLine.setPriceLimit(invoiceLine.getPriceEntered());
|
||||||
}
|
// }
|
||||||
orderLine.setLineNetAmt();
|
// }
|
||||||
|
// orderLine.setLineNetAmt();
|
||||||
if(orderLine.getC_Tax_ID()>0){
|
//
|
||||||
MTax tax = (MTax) orderLine.getC_Tax();
|
// if(orderLine.getC_Tax_ID()>0){
|
||||||
orderLine.set_ValueNoCheck("TotalLines", orderLine.getLineNetAmt()
|
// MTax tax = (MTax) orderLine.getC_Tax();
|
||||||
.add(orderLine.getLineNetAmt().multiply(tax.getRate()).divide(Env.ONEHUNDRED)));
|
// orderLine.set_ValueNoCheck("TotalLines", orderLine.getLineNetAmt()
|
||||||
}else{
|
// .add(orderLine.getLineNetAmt().multiply(tax.getRate()).divide(Env.ONEHUNDRED)));
|
||||||
orderLine.set_ValueNoCheck("TotalLines",orderLine.getLineNetAmt());
|
// }else{
|
||||||
}
|
// orderLine.set_ValueNoCheck("TotalLines",orderLine.getLineNetAmt());
|
||||||
|
// }
|
||||||
if(reqLine.getC_Charge_ID()>0)
|
//
|
||||||
orderLine.setC_Charge_ID(reqLine.getC_Charge_ID());
|
// if(reqLine.getC_Charge_ID()>0)
|
||||||
else
|
// orderLine.setC_Charge_ID(reqLine.getC_Charge_ID());
|
||||||
orderLine.setM_Product_ID(reqLine.getM_Product_ID());
|
// else
|
||||||
|
// orderLine.setM_Product_ID(reqLine.getM_Product_ID());
|
||||||
if(reqLine.getC_BPartner_ID()>0)
|
//
|
||||||
orderLine.set_ValueOfColumn("C_BPartner_Requisition_ID",reqLine.getC_BPartner_ID());
|
// if(reqLine.getC_BPartner_ID()>0)
|
||||||
|
// orderLine.set_ValueOfColumn("C_BPartner_Requisition_ID",reqLine.getC_BPartner_ID());
|
||||||
if(reqLine.getC_Charge_ID()>0)
|
//
|
||||||
orderLine.setC_Charge_ID(reqLine.getC_Charge_ID());
|
// if(reqLine.getC_Charge_ID()>0)
|
||||||
else
|
// orderLine.setC_Charge_ID(reqLine.getC_Charge_ID());
|
||||||
orderLine.setM_Product_ID(reqLine.getM_Product_ID());
|
// else
|
||||||
|
// orderLine.setM_Product_ID(reqLine.getM_Product_ID());
|
||||||
int a = reqLine.getC_UOM_ID();
|
//
|
||||||
orderLine.setC_UOM_ID(reqLine.getC_UOM_ID());
|
// int a = reqLine.getC_UOM_ID();
|
||||||
// orderLine.setQtyEntered(qty);
|
// orderLine.setC_UOM_ID(reqLine.getC_UOM_ID());
|
||||||
orderLine.setQtyEntered(qtyOrdered);
|
//// orderLine.setQtyEntered(qty);
|
||||||
//orderLine.setC_Tax_ID(order.getC_Tax_ID());
|
// orderLine.setQtyEntered(qtyOrdered);
|
||||||
orderLine.setQtyOrdered(qtyOrdered);
|
// //orderLine.setC_Tax_ID(order.getC_Tax_ID());
|
||||||
// orderLine.setLine(reqLine.getLine());
|
// orderLine.setQtyOrdered(qtyOrdered);
|
||||||
|
//// orderLine.setLine(reqLine.getLine());
|
||||||
//Add by @solrizal increment LIne Number by 10
|
//
|
||||||
orderLine.set_ValueOfColumn("PriceRequisition", reqLine.getPriceActual());
|
// //Add by @solrizal increment LIne Number by 10
|
||||||
|
// orderLine.set_ValueOfColumn("PriceRequisition", reqLine.getPriceActual());
|
||||||
orderLine.set_ValueOfColumn("DiscAmt", Env.ZERO);
|
//
|
||||||
orderLine.set_ValueOfColumn("MID_Requisition_ID", reqLine.getMID_Requisition_ID());
|
// orderLine.set_ValueOfColumn("DiscAmt", Env.ZERO);
|
||||||
orderLine.set_ValueOfColumn("MID_RequisitionLine_ID", reqLine.getMID_RequisitionLine_ID());
|
// orderLine.set_ValueOfColumn("MID_Requisition_ID", reqLine.getMID_Requisition_ID());
|
||||||
|
// orderLine.set_ValueOfColumn("MID_RequisitionLine_ID", reqLine.getMID_RequisitionLine_ID());
|
||||||
orderLine.set_ValueOfColumn("IsTrackAsAsset", reqLine.get_ValueAsBoolean("IsTrackAsAsset"));
|
//
|
||||||
|
// orderLine.set_ValueOfColumn("IsTrackAsAsset", reqLine.get_ValueAsBoolean("IsTrackAsAsset"));
|
||||||
orderLine.setDescription(reqLine.getDescription()==null? "" : reqLine.getDescription());
|
//
|
||||||
orderLine.set_ValueNoCheck("Comments", reqLine.get_Value("Comments"));
|
// orderLine.setDescription(reqLine.getDescription()==null? "" : reqLine.getDescription());
|
||||||
// orderLine.set_ValueOfColumn("Comments", reqLine.get_Value("Comments"));
|
// orderLine.set_ValueNoCheck("Comments", reqLine.get_Value("Comments"));
|
||||||
|
//// orderLine.set_ValueOfColumn("Comments", reqLine.get_Value("Comments"));
|
||||||
if(!orderLine.save()){
|
//
|
||||||
// String sqlDelete = "DELETE FROM C_OrderLine WHERE C_Order_ID=?";
|
// if(!orderLine.save()){
|
||||||
// int line = DB.executeUpdate(sqlDelete, order.getC_Order_ID(), null);
|
//// String sqlDelete = "DELETE FROM C_OrderLine WHERE C_Order_ID=?";
|
||||||
throw new AdempiereException("Cannot create order line for product "+reqLine.getM_Product().getName());
|
//// int line = DB.executeUpdate(sqlDelete, order.getC_Order_ID(), null);
|
||||||
}
|
// throw new AdempiereException("Cannot create order line for product "+reqLine.getM_Product().getName());
|
||||||
orderLine.saveEx();
|
// }
|
||||||
}
|
// orderLine.saveEx();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// order.setDescription(order.getDescription()==null? desc : order.getDescription()+";"+desc);
|
// order.setDescription(order.getDescription()==null? desc : order.getDescription()+";"+desc);
|
||||||
|
|
|
||||||
|
|
@ -317,15 +317,9 @@ public class MID_WCreateFromOrder extends MID_CreateFromOrder implements EventLi
|
||||||
int C_Order_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_Order_ID");
|
int C_Order_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_Order_ID");
|
||||||
MOrder order = new MOrder(Env.getCtx(),C_Order_ID,null);
|
MOrder order = new MOrder(Env.getCtx(),C_Order_ID,null);
|
||||||
|
|
||||||
if (!order.isSOTrx()){
|
|
||||||
ArrayList<KeyNamePair> list = loadRequisitionData(C_BPartner_ID, M_Warehouse_ID);
|
ArrayList<KeyNamePair> list = loadRequisitionData(C_BPartner_ID, M_Warehouse_ID);
|
||||||
for(KeyNamePair knp : list)
|
for(KeyNamePair knp : list)
|
||||||
requisitionField.addItem(knp);
|
requisitionField.addItem(knp);
|
||||||
}else{
|
|
||||||
ArrayList<KeyNamePair> list = loadRequisitionSOData(C_BPartner_ID, M_Warehouse_ID);
|
|
||||||
for(KeyNamePair knp : list)
|
|
||||||
requisitionField.addItem(knp);
|
|
||||||
}
|
|
||||||
|
|
||||||
requisitionField.setSelectedIndex(0);
|
requisitionField.setSelectedIndex(0);
|
||||||
requisitionField.addActionListener(this);
|
requisitionField.addActionListener(this);
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,8 @@ public class MID_MAssetAddition extends MAssetAddition implements DocOptions{
|
||||||
if(getA_Asset_ID()>0) {
|
if(getA_Asset_ID()>0) {
|
||||||
MAsset asset = new MAsset(getCtx(), getA_Asset_ID(), get_TrxName());
|
MAsset asset = new MAsset(getCtx(), getA_Asset_ID(), get_TrxName());
|
||||||
asset.setIsActive(false);
|
asset.setIsActive(false);
|
||||||
|
asset.setIsDepreciated(false);
|
||||||
|
asset.setA_Asset_Status(MAsset.A_ASSET_STATUS_Retired);
|
||||||
asset.saveEx();
|
asset.saveEx();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,12 @@ public class MID_MRequisition extends MRequisition implements DocOptions{
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean recalculateTax() {
|
public boolean recalculateTax(String trxName) {
|
||||||
BigDecimal totalTaxAmt = DB.getSQLValueBD(get_TrxName(), "SELECT COALESCE(SUM(TaxAmt),0) FROM M_RequisitionLine WHERE M_Requisition_ID =?", new Object[] { getM_Requisition_ID() });
|
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() });
|
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);
|
setTotalLines(totalLines);
|
||||||
set_Value("TaxAmt", totalTaxAmt);
|
set_Value("TaxAmt", totalTaxAmt);
|
||||||
set_Value("GrandTotal", totalLines.add(totalTaxAmt));
|
set_Value("GrandTotal", totalLines.add(totalTaxAmt));
|
||||||
saveEx();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.model.MRequisition;
|
import org.compiere.model.MRequisition;
|
||||||
import org.compiere.model.MRequisitionLine;
|
import org.compiere.model.MRequisitionLine;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
|
||||||
public class MID_MRequisitionLine extends MRequisitionLine{
|
public class MID_MRequisitionLine extends MRequisitionLine{
|
||||||
|
|
||||||
|
|
@ -28,7 +29,19 @@ public class MID_MRequisitionLine extends MRequisitionLine{
|
||||||
@Override
|
@Override
|
||||||
protected boolean afterSave(boolean newRecord, boolean success) {
|
protected boolean afterSave(boolean newRecord, boolean success) {
|
||||||
MID_MRequisition requisition = new MID_MRequisition(getCtx(), getM_Requisition_ID(), get_TrxName());
|
MID_MRequisition requisition = new MID_MRequisition(getCtx(), getM_Requisition_ID(), get_TrxName());
|
||||||
// super.afterSave(newRecord, success);
|
super.afterSave(newRecord, success);
|
||||||
return requisition.recalculateTax();
|
// requisition.recalculateTax(get_TrxName());
|
||||||
|
String sql = "UPDATE M_Requisition SET TaxAmt = "
|
||||||
|
+ "(SELECT COALESCE(SUM(TaxAmt),0) FROM M_RequisitionLine RL WHERE RL.M_Requisition_ID = M_Requisition.M_Requisition_ID) "
|
||||||
|
+ " WHERE M_Requisition_ID ="+getM_Requisition_ID();
|
||||||
|
|
||||||
|
DB.executeUpdateEx(sql, get_TrxName());
|
||||||
|
|
||||||
|
sql = "UPDATE M_Requisition SET GrandTotal = "
|
||||||
|
+ "(SELECT COALESCE(SUM(TaxAmt+LineNetAmt),0) FROM M_RequisitionLine RL WHERE RL.M_Requisition_ID = M_Requisition.M_Requisition_ID) "
|
||||||
|
+ " WHERE M_Requisition_ID ="+getM_Requisition_ID();
|
||||||
|
|
||||||
|
DB.executeUpdateEx(sql, get_TrxName());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue