commit
4a0c6df077
|
|
@ -333,7 +333,7 @@ public class MID_CreateFromOrder extends CreateFrom {
|
|||
String desc = "";
|
||||
int C_Order_ID = Env.getContextAsInt(Env.getCtx(), getGridTab().getWindowNo(), "C_Order_ID");
|
||||
MOrder order = new MOrder(Env.getCtx(), C_Order_ID, null);
|
||||
|
||||
MRequisition requisition = null;
|
||||
|
||||
//Add by @solrizal Line Number
|
||||
for (int i = 0; i < miniTable.getRowCount(); i++)
|
||||
|
|
@ -469,15 +469,15 @@ public class MID_CreateFromOrder extends CreateFrom {
|
|||
desc = desc + reqLine.getM_Requisition().getDescription() +"; ";
|
||||
|
||||
|
||||
MRequisition req = (MRequisition) reqLine.getM_Requisition();
|
||||
if(req.get_ValueAsInt("C_BPartner_ID")>0)
|
||||
order.setC_BPartner_ID(req.get_ValueAsInt("C_BPartner_ID"));
|
||||
order.setPaymentRule(req.get_ValueAsString("PaymentRule"));
|
||||
order.setC_PaymentTerm_ID(req.get_ValueAsInt("C_PaymentTerm_ID"));
|
||||
requisition = (MRequisition) reqLine.getM_Requisition();
|
||||
if(requisition.get_ValueAsInt("C_BPartner_ID")>0)
|
||||
order.setC_BPartner_ID(requisition.get_ValueAsInt("C_BPartner_ID"));
|
||||
}
|
||||
}
|
||||
}
|
||||
// order.setDescription(order.getDescription()==null? desc : order.getDescription()+";"+desc);
|
||||
order.setC_PaymentTerm_ID(requisition.get_ValueAsInt("C_PaymentTerm_ID"));
|
||||
order.setPaymentRule(requisition.get_ValueAsString("PaymentRule"));
|
||||
order.saveEx();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,8 @@ public class MID_TPBUpdateOrder extends SvrProcess{
|
|||
retValue.set_ValueNoCheck("MID_AJUDocumentType_ID", line.getMID_AJUDocumentType_ID());
|
||||
retValue.setC_BPartner_ID(line.getC_BPartner_ID());
|
||||
retValue.setC_BPartner_Location_ID(line.getC_BPartner_Location_ID());
|
||||
retValue.setDateOrdered(line.getRegisterDate());
|
||||
retValue.setDatePromised(line.getRegisterDate());
|
||||
retValue.setC_Currency_ID(line.getC_Currency_ID());
|
||||
retValue.setSalesRep_ID(line.getSalesRep_ID());
|
||||
retValue.setPOReference(line.getM_Requisition().getDocumentNo());
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ public class MID_TPBUpdateOrderLine extends SvrProcess{
|
|||
retValue.set_ValueNoCheck("RegisterDate", line.getRegisterDate());
|
||||
retValue.set_ValueNoCheck("RegisterNo", line.getRegisterNo());
|
||||
retValue.set_ValueNoCheck("MID_AJUDocumentType_ID", line.getMID_AJUDocumentType_ID());
|
||||
retValue.setDateOrdered(line.getRegisterDate());
|
||||
retValue.setDatePromised(line.getRegisterDate());
|
||||
retValue.setPOReference(line.getM_Requisition().getDocumentNo());
|
||||
retValue.setC_BPartner_ID(line.getC_BPartner_ID());
|
||||
retValue.setC_BPartner_Location_ID(line.getC_BPartner_Location_ID());
|
||||
|
|
|
|||
|
|
@ -135,10 +135,10 @@ public class MID_UploadTPB extends SvrProcess{
|
|||
int C_BPartner_ID = 0;
|
||||
int C_Currency_ID = 0;
|
||||
if(AJU_DocType_Value.equals("40")) {
|
||||
C_BPartner_ID = DB.getSQLValue(get_TrxName(), "SELECT C_BPartner_ID FROM C_Bpartner WHERE Name =? AND AD_Client_ID =? ", new Object[] { dataRow.getCell(93).getStringCellValue(), getAD_Client_ID()});
|
||||
C_BPartner_ID = DB.getSQLValue(get_TrxName(), "SELECT C_BPartner_ID FROM C_Bpartner WHERE Name =? AND AD_Client_ID =? AND ISVendor='Y' ", new Object[] { dataRow.getCell(93).getStringCellValue(), getAD_Client_ID()});
|
||||
C_Currency_ID = DB.getSQLValue(get_TrxName(), "SELECT C_Currency_ID FROM C_Currency WHERE ISO_Code =? ", new Object[] { "IDR" });
|
||||
}else {
|
||||
C_BPartner_ID = DB.getSQLValue(get_TrxName(), "SELECT C_BPartner_ID FROM C_Bpartner WHERE Name =? AND AD_Client_ID =? ", new Object[] { dataRow.getCell(3).getStringCellValue(), getAD_Client_ID()});
|
||||
C_BPartner_ID = DB.getSQLValue(get_TrxName(), "SELECT C_BPartner_ID FROM C_Bpartner WHERE Name =? AND AD_Client_ID =? AND ISVendor='Y' ", new Object[] { dataRow.getCell(3).getStringCellValue(), getAD_Client_ID()});
|
||||
C_Currency_ID = DB.getSQLValue(get_TrxName(), "SELECT C_Currency_ID FROM C_Currency WHERE ISO_Code =? ", new Object[] { dataRow.getCell(88).getStringCellValue()});
|
||||
}
|
||||
|
||||
|
|
@ -177,25 +177,31 @@ public class MID_UploadTPB extends SvrProcess{
|
|||
BigDecimal PriceActual = Env.ZERO;
|
||||
if(AJU_DocType_Value.equals("23") || AJU_DocType_Value.equals("40") || AJU_DocType_Value.equals("41")){
|
||||
M_Product_ID = DB.getSQLValue(get_TrxName(), "SELECT M_Product_ID FROM M_Product WHERE Value =? AND AD_Client_ID =?", new Object[] { rowBarang.getCell(20).getStringCellValue(), getAD_Client_ID() });
|
||||
C_UOM_ID = DB.getSQLValue(get_TrxName(), " SELECT C_UOM_ID FROM C_UOM WHERE UOMSymbol =?", new Object[] { rowBarang.getCell(27).getStringCellValue()});
|
||||
C_UOM_ID = DB.getSQLValue(get_TrxName(), " SELECT C_UOM_ID FROM C_UOM WHERE UOMSymbol =? AND AD_Client_ID =?", new Object[] { rowBarang.getCell(27).getStringCellValue(), getAD_Client_ID()});
|
||||
|
||||
if(M_Product_ID <=0)
|
||||
throw new AdempiereException("Product Not Found "+rowBarang.getCell(20).getStringCellValue()+" !!!");
|
||||
|
||||
|
||||
if(C_UOM_ID <=0)
|
||||
C_UOM_ID = DB.getSQLValue(get_TrxName(), " SELECT C_UOM_ID FROM C_UOM WHERE UOMSymbol =? AND AD_Client_ID =?", new Object[] { rowBarang.getCell(27).getStringCellValue(), 0});
|
||||
|
||||
if(C_UOM_ID <=0)
|
||||
throw new AdempiereException("UOM Not Found "+rowBarang.getCell(27).getStringCellValue()+" !!!");
|
||||
|
||||
}else{
|
||||
M_Product_ID = DB.getSQLValue(get_TrxName(), "SELECT M_Product_ID FROM M_Product WHERE Value =? AND AD_Client_ID =?", new Object[] { rowBarang.getCell(10).getStringCellValue(), getAD_Client_ID() });
|
||||
C_UOM_ID = DB.getSQLValue(get_TrxName(), " SELECT C_UOM_ID FROM C_UOM WHERE UOMSymbol =?", new Object[] { rowBarang.getCell(7).getStringCellValue()});
|
||||
|
||||
C_UOM_ID = DB.getSQLValue(get_TrxName(), " SELECT C_UOM_ID FROM C_UOM WHERE UOMSymbol =? AND AD_Client_ID =?", new Object[] { rowBarang.getCell(7).getStringCellValue(), getAD_Client_ID()});
|
||||
if(M_Product_ID <=0)
|
||||
throw new AdempiereException("Product Not Found "+rowBarang.getCell(10).getStringCellValue()+" !!!");
|
||||
|
||||
if(C_UOM_ID <=0)
|
||||
C_UOM_ID = DB.getSQLValue(get_TrxName(), " SELECT C_UOM_ID FROM C_UOM WHERE UOMSymbol =?", new Object[] { rowBarang.getCell(7).getStringCellValue(), 0});
|
||||
|
||||
if(C_UOM_ID <=0)
|
||||
throw new AdempiereException("UOM Not Found "+rowBarang.getCell(7).getStringCellValue()+" !!!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(AJU_DocType_Value.equals("23")){
|
||||
Qty = new BigDecimal(rowBarang.getCell(16).getStringCellValue());
|
||||
PriceList = new BigDecimal(rowBarang.getCell(12).getStringCellValue());
|
||||
|
|
@ -222,18 +228,15 @@ public class MID_UploadTPB extends SvrProcess{
|
|||
else
|
||||
PriceList = PriceActual;
|
||||
}
|
||||
|
||||
if(AJU_DocType_Value.equals("27")){
|
||||
Discount = new BigDecimal(rowBarang.getCell(22).getStringCellValue());
|
||||
}
|
||||
|
||||
tpbDetail.setM_Product_ID(M_Product_ID);
|
||||
tpbDetail.setC_UOM_ID(C_UOM_ID);
|
||||
tpbDetail.setQty(Qty);
|
||||
tpbDetail.setPriceList(PriceList);
|
||||
tpbDetail.setDiscount(Discount);
|
||||
tpbDetail.setPriceActual(PriceActual);
|
||||
|
||||
tpbDetail.saveEx();
|
||||
return tpbDetail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.osgi.service.event.Event;
|
|||
public class MID_InventoryValidator {
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
MInventory inv = (MInventory) po;
|
||||
|
||||
if (e.getTopic().equals(IEventTopics.DOC_BEFORE_COMPLETE))
|
||||
return beforeComplete(inv);
|
||||
else if (e.getTopic().equals(IEventTopics.DOC_BEFORE_PREPARE))
|
||||
|
|
@ -29,9 +30,11 @@ public class MID_InventoryValidator {
|
|||
}
|
||||
|
||||
private static String beforeReverse(MInventory inv) {
|
||||
int ppo_Id = inv.get_ValueAsInt("ps_ppo_ID");
|
||||
if(ppo_Id>0)
|
||||
if(inv.getC_DocType().getName().equals("Inventory Receipt") ||
|
||||
inv.getC_DocType().getName().equals("Inventory Issue")) {
|
||||
String docStatus = DB.getSQLValueStringEx(inv.get_TrxName(), "SELECT DocStatus FROM ps_ppo WHERE ps_ppo_ID =?", new Object[] {inv.get_ValueAsInt("ps_ppo_ID")});
|
||||
String docStatus = DB.getSQLValueStringEx(inv.get_TrxName(), "SELECT DocStatus FROM ps_ppo WHERE ps_ppo_ID =?", new Object[] { ppo_Id });
|
||||
if(docStatus.equals(DocAction.STATUS_Completed))
|
||||
throw new AdempiereException("Production berstatus Completed !!! silahkan di aktifkan terlebih dahulu !!!");
|
||||
}
|
||||
|
|
@ -69,6 +72,7 @@ public class MID_InventoryValidator {
|
|||
return "";
|
||||
}
|
||||
private static String beforeComplete(MInventory inv){
|
||||
if(inv.getReversal_ID()>0) return "";
|
||||
MDocType dt = (MDocType) inv.getC_DocType();
|
||||
boolean isReceipt = dt.get_ValueAsBoolean("IsReceipt");
|
||||
if(isReceipt) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package andromedia.midsuit.validator;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
|
|
@ -28,116 +31,105 @@ import andromedia.midsuit.model.X_C_OrderLineMA;
|
|||
public class MID_OrderValidator {
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
MOrder Order = (MOrder) po;
|
||||
|
||||
// if (e.getTopic().equals(IEventTopics.DOC_AFTER_COMPLETE))
|
||||
// return afterComplete(Order);
|
||||
|
||||
// if (e.getTopic().equals(IEventTopics.DOC_AFTER_COMPLETE))
|
||||
// return afterComplete(Order);
|
||||
if (e.getTopic().equals(IEventTopics.DOC_BEFORE_COMPLETE))
|
||||
return beforeComplete(Order);
|
||||
else if (e.getTopic().equals(IEventTopics.PO_BEFORE_CHANGE))
|
||||
return beforeChange(Order);
|
||||
else if (e.getTopic().equals(IEventTopics.DOC_BEFORE_PREPARE))
|
||||
return beforePrepare(Order);
|
||||
else if (e.getTopic().equals(IEventTopics.DOC_BEFORE_CLOSE))
|
||||
return beforeClose(Order);
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String beforeClose(MOrder order) {
|
||||
for (MOrderLine line : order.getLines()) {
|
||||
if (line.getQtyInvoiced().signum() != 0 || line.getQtyDelivered().signum() != 0) {
|
||||
throw new AdempiereException("Product "+line.getM_Product().getName()+" sudah terkirim/tertagih");
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
private static String beforePrepare(MOrder order) {
|
||||
for (MOrderLine line : order.getLines()) {
|
||||
int countAttLines = new Query(order.getCtx(), X_C_OrderLineMA.Table_Name, "C_OrderLine_ID =?",
|
||||
order.get_TrxName()).setParameters(new Object[] { line.getC_OrderLine_ID() })
|
||||
.setOnlyActiveRecords(true).count();
|
||||
if (countAttLines > 0) {
|
||||
BigDecimal totalQtyOrdered = DB.getSQLValueBD(order.get_TrxName(),
|
||||
"SELECT COALESCE(SUM(MovementQty),0) FROM C_OrderLineMA WHERE C_OrderLine_ID =?",
|
||||
new Object[] { line.getC_OrderLine_ID() });
|
||||
if (line.getQtyOrdered().compareTo(totalQtyOrdered) != 0)
|
||||
throw new AdempiereException(
|
||||
"Cek kembali jumlah lot untuk produk " + line.getM_Product().getName());
|
||||
for(MOrderLine line : order.getLines()) {
|
||||
int countAttLines = new Query(order.getCtx(), X_C_OrderLineMA.Table_Name, "C_OrderLine_ID =?", order.get_TrxName())
|
||||
.setParameters(new Object[] { line.getC_OrderLine_ID() })
|
||||
.setOnlyActiveRecords(true)
|
||||
.count();
|
||||
if(countAttLines>0){
|
||||
BigDecimal totalQtyOrdered = DB.getSQLValueBD(order.get_TrxName(), "SELECT COALESCE(SUM(MovementQty),0) FROM C_OrderLineMA WHERE C_OrderLine_ID =?", new Object[] { line.getC_OrderLine_ID() });
|
||||
if(line.getQtyOrdered().compareTo(totalQtyOrdered)!=0)
|
||||
throw new AdempiereException("Cek kembali jumlah lot untuk produk "+line.getM_Product().getName());
|
||||
}
|
||||
}
|
||||
if (order.isSOTrx())
|
||||
return "";
|
||||
if (order.isSOTrx()) return "";
|
||||
MOrderLine[] lines = order.getLines();
|
||||
if (order.get_ValueAsInt("MID_AJUDocumentType_ID") == 0)
|
||||
if(order.get_ValueAsInt("MID_AJUDocumentType_ID")==0)
|
||||
return "";
|
||||
|
||||
int M_AttributeSetInstance_ID = DB.getSQLValue(order.get_TrxName(),
|
||||
"SELECT M_AttributeSetInstance_ID FROM M_AttributeSetInstance WHERE SerNo=?",
|
||||
new Object[] { order.get_ValueAsString("NoAju1") });
|
||||
int M_AttributeSet_ID = DB.getSQLValue(order.get_TrxName(),
|
||||
"SELECT M_AttributeSet_ID FROM M_AttributeSet WHERE IsActive=? AND AD_Client_ID =? ",
|
||||
new Object[] { true, order.getAD_Client_ID() });
|
||||
|
||||
int M_AttributeSetInstance_ID = DB.getSQLValue(order.get_TrxName(), "SELECT M_AttributeSetInstance_ID FROM M_AttributeSetInstance WHERE SerNo=?", new Object[] { order.get_ValueAsString("NoAju1") });
|
||||
int M_AttributeSet_ID = DB.getSQLValue(order.get_TrxName(), "SELECT M_AttributeSet_ID FROM M_AttributeSet WHERE IsActive=? AND AD_Client_ID =? ", new Object[] { true, order.getAD_Client_ID() });
|
||||
MAttributeSet aSet = new MAttributeSet(order.getCtx(), M_AttributeSet_ID, order.get_TrxName());
|
||||
if (M_AttributeSetInstance_ID <= 0) {
|
||||
if(M_AttributeSetInstance_ID <=0) {
|
||||
MAttributeSetInstance ASI = new MAttributeSetInstance(order.getCtx(), 0, order.get_TrxName());
|
||||
ASI.setSerNo(order.get_ValueAsString("NoAju1"));
|
||||
ASI.setMAttributeSet(aSet);
|
||||
ASI.setDescription();
|
||||
ASI.saveEx();
|
||||
|
||||
|
||||
M_AttributeSetInstance_ID = ASI.get_ID();
|
||||
}
|
||||
|
||||
for (MOrderLine line : lines) {
|
||||
|
||||
for(MOrderLine line : lines) {
|
||||
String noAju = line.get_ValueAsString("NoAju");
|
||||
if (order.get_ValueAsInt("MID_AJUDocumentType_ID") > 0 && noAju == null)
|
||||
if(order.get_ValueAsInt("MID_AJUDocumentType_ID")>0 && noAju==null)
|
||||
return "Silahkan isi dokumen AJU terlebih dahulu !!!";
|
||||
List<X_C_OrderLineMA> attLines = new Query(order.getCtx(), X_C_OrderLineMA.Table_Name, "C_OrderLine_ID =?",
|
||||
order.get_TrxName()).setParameters(new Object[] { line.getC_OrderLine_ID() })
|
||||
.setOnlyActiveRecords(true).list();
|
||||
if (attLines.size() <= 0)
|
||||
if (line.getM_AttributeSetInstance_ID() > 0) {
|
||||
MAttributeSetInstance ASI = new MAttributeSetInstance(order.getCtx(),
|
||||
line.getM_AttributeSetInstance_ID(), order.get_TrxName());
|
||||
ASI.setSerNo(line.get_ValueAsString("NoAju"));
|
||||
List<X_C_OrderLineMA> attLines = new Query(order.getCtx(), X_C_OrderLineMA.Table_Name, "C_OrderLine_ID =?", order.get_TrxName())
|
||||
.setParameters(new Object[] { line.getC_OrderLine_ID() })
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
if(attLines.size()<=0)
|
||||
if(line.getM_AttributeSetInstance_ID()>0) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
|
||||
Timestamp regDate = (Timestamp) line.get_Value("RegisterDate");
|
||||
dateFormat.format(new Date(regDate.getTime()));
|
||||
|
||||
MAttributeSetInstance ASI = new MAttributeSetInstance(order.getCtx(), line.getM_AttributeSetInstance_ID(), order.get_TrxName());
|
||||
ASI.setSerNo(line.get_ValueAsString("RegisterNo")+"-"+dateFormat.format(new Date(regDate.getTime())));
|
||||
ASI.setDescription();
|
||||
ASI.saveEx();
|
||||
} else {
|
||||
}else {
|
||||
order.get_Logger().severe("MASUK SINI");
|
||||
line.setM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
|
||||
line.saveEx();
|
||||
}
|
||||
|
||||
for (X_C_OrderLineMA attLine : attLines) {
|
||||
MAttributeSetInstance ASI = new MAttributeSetInstance(order.getCtx(),
|
||||
attLine.getM_AttributeSetInstance_ID(), order.get_TrxName());
|
||||
ASI.setSerNo(line.get_ValueAsString("NoAju"));
|
||||
ASI.setDescription();
|
||||
|
||||
for(X_C_OrderLineMA attLine : attLines) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
|
||||
Timestamp regDate = (Timestamp) line.get_Value("RegisterDate");
|
||||
dateFormat.format(new Date(regDate.getTime()));
|
||||
|
||||
MAttributeSetInstance ASI = new MAttributeSetInstance(order.getCtx(), attLine.getM_AttributeSetInstance_ID(), order.get_TrxName());
|
||||
ASI.setSerNo(line.get_ValueAsString("RegisterNo")+"-"+dateFormat.format(new Date(regDate.getTime())));
|
||||
ASI.setDescription();
|
||||
ASI.saveEx();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String afterComplete(MOrder Order) {
|
||||
if (Order.isSOTrx())
|
||||
return "";
|
||||
|
||||
private static String afterComplete(MOrder Order){
|
||||
if (Order.isSOTrx()) return "";
|
||||
MDocType docTypeOfOrder = (MDocType) Order.getC_DocType();
|
||||
if (docTypeOfOrder.get_ValueAsBoolean("isPOS")) {
|
||||
// Create Shipment
|
||||
if(docTypeOfOrder.get_ValueAsBoolean("isPOS")){
|
||||
//Create Shipment
|
||||
MInOut Shipment = new MInOut(Order, docTypeOfOrder.getC_DocTypeShipment_ID(), Order.getDateOrdered());
|
||||
Shipment.saveEx();
|
||||
|
||||
for (MOrderLine OrderLine : Order.getLines()) {
|
||||
|
||||
for(MOrderLine OrderLine : Order.getLines()){
|
||||
MInOutLine ShipmentLine = new MInOutLine(Shipment);
|
||||
// Qty = Ordered - Delivered
|
||||
BigDecimal MovementQty = OrderLine.getQtyOrdered().subtract(OrderLine.getQtyDelivered());
|
||||
// Location
|
||||
int M_Locator_ID = MStorageOnHand.getM_Locator_ID(OrderLine.getM_Warehouse_ID(),
|
||||
OrderLine.getM_Product_ID(), OrderLine.getM_AttributeSetInstance_ID(), MovementQty,
|
||||
OrderLine.get_TrxName());
|
||||
if (M_Locator_ID == 0) // Get default Location
|
||||
// Qty = Ordered - Delivered
|
||||
BigDecimal MovementQty = OrderLine.getQtyOrdered().subtract(OrderLine.getQtyDelivered());
|
||||
// Location
|
||||
int M_Locator_ID = MStorageOnHand.getM_Locator_ID (OrderLine.getM_Warehouse_ID(),
|
||||
OrderLine.getM_Product_ID(), OrderLine.getM_AttributeSetInstance_ID(),
|
||||
MovementQty, OrderLine.get_TrxName());
|
||||
if (M_Locator_ID == 0) // Get default Location
|
||||
{
|
||||
MWarehouse wh = MWarehouse.get(OrderLine.getCtx(), OrderLine.getM_Warehouse_ID());
|
||||
M_Locator_ID = wh.getDefaultLocator().getM_Locator_ID();
|
||||
|
|
@ -146,29 +138,32 @@ public class MID_OrderValidator {
|
|||
ShipmentLine.setOrderLine(OrderLine, M_Locator_ID, MovementQty);
|
||||
ShipmentLine.setQty(MovementQty);
|
||||
if (OrderLine.getQtyEntered().compareTo(OrderLine.getQtyOrdered()) != 0)
|
||||
OrderLine.setQtyEntered(MovementQty.multiply(OrderLine.getQtyEntered())
|
||||
.divide(OrderLine.getQtyOrdered(), 6, BigDecimal.ROUND_HALF_UP));
|
||||
OrderLine.setQtyEntered(MovementQty
|
||||
.multiply(OrderLine.getQtyEntered())
|
||||
.divide(OrderLine.getQtyOrdered(), 6, BigDecimal.ROUND_HALF_UP));
|
||||
ShipmentLine.saveEx();
|
||||
}
|
||||
|
||||
|
||||
if (!Shipment.processIt(DocAction.ACTION_Complete))
|
||||
throw new AdempiereException("Failed when processing document - " + Shipment.getProcessMsg());
|
||||
Shipment.saveEx();
|
||||
|
||||
// Create Invoice
|
||||
MInvoice invoice = new MInvoice(Order, docTypeOfOrder.getC_DocTypeInvoice_ID(), Order.getDateOrdered());
|
||||
|
||||
//Create Invoice
|
||||
MInvoice invoice = new MInvoice (Order, docTypeOfOrder.getC_DocTypeInvoice_ID(), Order.getDateOrdered());
|
||||
invoice.setPaymentRule(Order.getPaymentRule());
|
||||
invoice.saveEx();
|
||||
|
||||
// If we have a Shipment - use that as a base
|
||||
if (Shipment != null) {
|
||||
|
||||
// If we have a Shipment - use that as a base
|
||||
if (Shipment != null)
|
||||
{
|
||||
MInOutLine[] sLines = Shipment.getLines(true);
|
||||
for (int i = 0; i < sLines.length; i++) {
|
||||
for (int i = 0; i < sLines.length; i++)
|
||||
{
|
||||
MInOutLine sLine = sLines[i];
|
||||
//
|
||||
MInvoiceLine iLine = new MInvoiceLine(invoice);
|
||||
iLine.setShipLine(sLine);
|
||||
// Qty = Delivered
|
||||
// Qty = Delivered
|
||||
if (sLine.sameOrderLineUOM())
|
||||
iLine.setQtyEntered(sLine.getQtyEntered());
|
||||
else
|
||||
|
|
@ -179,47 +174,48 @@ public class MID_OrderValidator {
|
|||
sLine.saveEx();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!invoice.processIt(DocAction.ACTION_Complete))
|
||||
throw new AdempiereException("Failed when processing document - " + invoice.getProcessMsg());
|
||||
invoice.saveEx();
|
||||
|
||||
|
||||
Order.setC_CashLine_ID(invoice.getC_CashLine_ID());
|
||||
Order.saveEx();
|
||||
|
||||
// MPayment payment = new MPayment(Order.getCtx(), 0, Order.get_TrxName());
|
||||
// payment.setAD_Org_ID(Order.getAD_Org_ID());
|
||||
//
|
||||
// payment.setTenderType(MPayment.TENDERTYPE_Cash);
|
||||
// payment.setC_BankAccount_ID(ba.getC_BankAccount_ID());
|
||||
// payment.setIsPrepayment(false);
|
||||
//
|
||||
// payment.setDateAcct(Order.getDateAcct());
|
||||
// payment.setDateTrx(Order.getDateOrdered());
|
||||
// //
|
||||
// payment.setC_BPartner_ID(Order.getC_BPartner_ID());
|
||||
// payment.setC_Invoice_ID(invoice.getC_Invoice_ID());
|
||||
// payment.setC_DocType_ID(119);
|
||||
// payment.setC_Currency_ID(Order.getC_Currency_ID());
|
||||
//
|
||||
// payment.setPayAmt(invoice.getGrandTotal());
|
||||
// // Save payment
|
||||
// payment.saveEx();
|
||||
// payment.processIt(DocAction.ACTION_Complete);
|
||||
// payment.saveEx();
|
||||
|
||||
|
||||
// MPayment payment = new MPayment(Order.getCtx(), 0, Order.get_TrxName());
|
||||
// payment.setAD_Org_ID(Order.getAD_Org_ID());
|
||||
//
|
||||
// payment.setTenderType(MPayment.TENDERTYPE_Cash);
|
||||
// payment.setC_BankAccount_ID(ba.getC_BankAccount_ID());
|
||||
// payment.setIsPrepayment(false);
|
||||
//
|
||||
// payment.setDateAcct(Order.getDateAcct());
|
||||
// payment.setDateTrx(Order.getDateOrdered());
|
||||
// //
|
||||
// payment.setC_BPartner_ID(Order.getC_BPartner_ID());
|
||||
// payment.setC_Invoice_ID(invoice.getC_Invoice_ID());
|
||||
// payment.setC_DocType_ID(119);
|
||||
// payment.setC_Currency_ID(Order.getC_Currency_ID());
|
||||
//
|
||||
// payment.setPayAmt(invoice.getGrandTotal());
|
||||
// // Save payment
|
||||
// payment.saveEx();
|
||||
// payment.processIt(DocAction.ACTION_Complete);
|
||||
// payment.saveEx();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
private static String beforeChange(MOrder order) {
|
||||
if (order.isSOTrx())
|
||||
return "";
|
||||
if (order.get_ValueAsString("NoAju1").equals("")) {
|
||||
DB.executeUpdateEx("UPDATE C_OrderLine SET NoAju = ? WHERE C_Order_ID = ?",
|
||||
if (order.isSOTrx()) return "";
|
||||
if(order.get_ValueAsString("NoAju1").equals("")) {
|
||||
DB.executeUpdateEx("UPDATE C_OrderLine SET NoAju = ? WHERE C_Order_ID = ?",
|
||||
new Object[] { "", order.getC_Order_ID() }, order.get_TrxName());
|
||||
} else if (order.is_ValueChanged("NoAju1")) {
|
||||
}
|
||||
else if(order.is_ValueChanged("NoAju1")) {
|
||||
String noAju = order.get_ValueAsString("NoAju1");
|
||||
DB.executeUpdateEx("UPDATE C_OrderLine SET NoAju = ? WHERE C_Order_ID = ?",
|
||||
DB.executeUpdateEx("UPDATE C_OrderLine SET NoAju = ? WHERE C_Order_ID = ?",
|
||||
new Object[] { noAju, order.getC_Order_ID() }, order.get_TrxName());
|
||||
}
|
||||
return "";
|
||||
|
|
|
|||
Loading…
Reference in New Issue