use of org.compiere.model.MOrgInfo in project adempiere by adempiere.
the class DistributionRun method distributionOrders.
// insertDetails
/**************************************************************************
* Create Orders
* @return true if created
*/
private boolean distributionOrders() {
//The Quantity Available is distribute with respect to Distribution Order Demand
if (p_BasedInDamnd) {
int M_Warehouse_ID = 0;
if (p_M_Warehouse_ID <= 0) {
MOrgInfo oi_source = MOrgInfo.get(getCtx(), m_run.getAD_Org_ID(), get_TrxName());
MWarehouse m_source = MWarehouse.get(getCtx(), oi_source.getM_Warehouse_ID());
if (m_source == null)
throw new AdempiereException("Do not exist Defautl Warehouse Source");
M_Warehouse_ID = m_source.getM_Warehouse_ID();
} else
M_Warehouse_ID = p_M_Warehouse_ID;
// For all lines
for (int i = 0; i < m_details.length; i++) {
MDistributionRunDetail detail = m_details[i];
StringBuffer sql = new StringBuffer("SELECT * FROM DD_OrderLine ol INNER JOIN DD_Order o ON (o.DD_Order_ID=ol.DD_Order_ID) INNER JOIN M_Locator l ON (l.M_Locator_ID=ol.M_Locator_ID) ");
//sql.append(" WHERE o.DocStatus IN ('DR','IN') AND o.C_BPartner_ID = ? AND M_Product_ID=? AND l.M_Warehouse_ID=? AND ol.DatePromised BETWEEN ? AND ? ");
sql.append(" WHERE o.DocStatus IN ('DR','IN') AND o.C_BPartner_ID = ? AND M_Product_ID=? AND l.M_Warehouse_ID=? AND ol.DatePromised <=?");
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt.setInt(1, detail.getC_BPartner_ID());
pstmt.setInt(2, detail.getM_Product_ID());
pstmt.setInt(3, M_Warehouse_ID);
pstmt.setTimestamp(4, p_DatePromised);
//pstmt.setTimestamp(5, p_DatePromised_To);
rs = pstmt.executeQuery();
while (rs.next()) {
// Create Order Line
MDDOrderLine line = new MDDOrderLine(getCtx(), rs, get_TrxName());
line.setM_Product_ID(detail.getM_Product_ID());
line.setConfirmedQty(line.getTargetQty().add(detail.getActualAllocation()));
if (p_M_Warehouse_ID > 0)
line.setDescription(Msg.translate(getCtx(), "PlannedQty"));
else
line.setDescription(m_run.getName());
line.saveEx();
break;
//addLog(0,null, detail.getActualAllocation(), order.getDocumentNo()
// + ": " + bp.getName() + " - " + product.getName());
}
} catch (Exception e) {
log.log(Level.SEVERE, "doIt - " + sql, e);
return false;
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
return true;
}
// Get Counter Org/BP
int runAD_Org_ID = m_run.getAD_Org_ID();
if (runAD_Org_ID == 0)
runAD_Org_ID = Env.getAD_Org_ID(getCtx());
MOrg runOrg = MOrg.get(getCtx(), runAD_Org_ID);
int runC_BPartner_ID = runOrg.getLinkedC_BPartner_ID(get_TrxName());
boolean counter = // no single Order
!m_run.isCreateSingleOrder() && // Org linked to BP
runC_BPartner_ID > 0 && // PO
!m_docType.isSOTrx();
MBPartner runBPartner = counter ? new MBPartner(getCtx(), runC_BPartner_ID, get_TrxName()) : null;
if (!counter || runBPartner == null || runBPartner.get_ID() != runC_BPartner_ID)
counter = false;
if (counter)
log.info("RunBP=" + runBPartner + " - " + m_docType);
log.info("Single=" + m_run.isCreateSingleOrder() + " - " + m_docType + ",SO=" + m_docType.isSOTrx());
log.fine("Counter=" + counter + ",C_BPartner_ID=" + runC_BPartner_ID + "," + runBPartner);
//
MBPartner bp = null;
MDDOrder singleOrder = null;
MProduct product = null;
MWarehouse m_source = null;
MLocator m_locator = null;
MWarehouse m_target = null;
MLocator m_locator_to = null;
MWarehouse[] ws = null;
MOrgInfo oi_source = MOrgInfo.get(getCtx(), m_run.getAD_Org_ID(), get_TrxName());
m_source = MWarehouse.get(getCtx(), oi_source.getM_Warehouse_ID());
if (m_source == null)
throw new AdempiereException("Do not exist Defautl Warehouse Source");
m_locator = MLocator.getDefault(m_source);
//get the warehouse in transit
ws = MWarehouse.getInTransitForOrg(getCtx(), m_source.getAD_Org_ID());
if (ws == null)
throw new AdempiereException("Warehouse Intransit do not found");
// Consolidated Single Order
if (m_run.isCreateSingleOrder()) {
bp = new MBPartner(getCtx(), m_run.getC_BPartner_ID(), get_TrxName());
if (bp.get_ID() == 0)
throw new IllegalArgumentException("Business Partner not found - C_BPartner_ID=" + m_run.getC_BPartner_ID());
//
if (!p_IsTest) {
singleOrder = new MDDOrder(getCtx(), 0, get_TrxName());
singleOrder.setC_DocType_ID(m_docType.getC_DocType_ID());
singleOrder.setIsSOTrx(m_docType.isSOTrx());
singleOrder.setBPartner(bp);
if (m_run.getC_BPartner_Location_ID() != 0)
singleOrder.setC_BPartner_Location_ID(m_run.getC_BPartner_Location_ID());
singleOrder.setDateOrdered(m_DateOrdered);
singleOrder.setDatePromised(p_DatePromised);
singleOrder.setM_Warehouse_ID(ws[0].getM_Warehouse_ID());
if (!singleOrder.save()) {
log.log(Level.SEVERE, "Order not saved");
return false;
}
m_counter++;
}
}
int lastC_BPartner_ID = 0;
int lastC_BPartner_Location_ID = 0;
MDDOrder order = null;
// For all lines
for (int i = 0; i < m_details.length; i++) {
MDistributionRunDetail detail = m_details[i];
// Create Order Header
if (m_run.isCreateSingleOrder())
order = singleOrder;
else // New Business Partner
if (lastC_BPartner_ID != detail.getC_BPartner_ID() || lastC_BPartner_Location_ID != detail.getC_BPartner_Location_ID()) {
// finish order
order = null;
}
lastC_BPartner_ID = detail.getC_BPartner_ID();
lastC_BPartner_Location_ID = detail.getC_BPartner_Location_ID();
bp = new MBPartner(getCtx(), detail.getC_BPartner_ID(), get_TrxName());
MOrgInfo oi_target = MOrgInfo.get(getCtx(), bp.getAD_OrgBP_ID_Int(), get_TrxName());
m_target = MWarehouse.get(getCtx(), oi_target.getM_Warehouse_ID());
if (m_target == null)
throw new AdempiereException("Do not exist Default Warehouse Target");
m_locator_to = MLocator.getDefault(m_target);
if (m_locator == null || m_locator_to == null) {
throw new AdempiereException("Do not exist default Locator for Warehouses");
}
if (p_ConsolidateDocument) {
String whereClause = "DocStatus IN ('DR','IN') AND AD_Org_ID=" + bp.getAD_OrgBP_ID_Int() + " AND " + MDDOrder.COLUMNNAME_C_BPartner_ID + "=? AND " + MDDOrder.COLUMNNAME_M_Warehouse_ID + "=? AND " + MDDOrder.COLUMNNAME_DatePromised + "<=? ";
order = new Query(getCtx(), MDDOrder.Table_Name, whereClause, get_TrxName()).setParameters(new Object[] { lastC_BPartner_ID, ws[0].getM_Warehouse_ID(), p_DatePromised }).setOrderBy(MDDOrder.COLUMNNAME_DatePromised + " DESC").first();
}
// New Order
if (order == null) {
if (!p_IsTest) {
order = new MDDOrder(getCtx(), 0, get_TrxName());
order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int());
order.setC_DocType_ID(m_docType.getC_DocType_ID());
order.setIsSOTrx(m_docType.isSOTrx());
// Counter Doc
if (counter && bp.getAD_OrgBP_ID_Int() > 0) {
log.fine("Counter - From_BPOrg=" + bp.getAD_OrgBP_ID_Int() + "-" + bp + ", To_BP=" + runBPartner);
order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int());
if (ws[0].getM_Warehouse_ID() > 0)
order.setM_Warehouse_ID(ws[0].getM_Warehouse_ID());
order.setBPartner(runBPartner);
} else // normal
{
log.fine("From_Org=" + runAD_Org_ID + ", To_BP=" + bp);
order.setAD_Org_ID(bp.getAD_OrgBP_ID_Int());
order.setBPartner(bp);
if (detail.getC_BPartner_Location_ID() != 0)
order.setC_BPartner_Location_ID(detail.getC_BPartner_Location_ID());
}
order.setM_Warehouse_ID(ws[0].getM_Warehouse_ID());
order.setDateOrdered(m_DateOrdered);
order.setDatePromised(p_DatePromised);
order.setIsInDispute(false);
order.setIsInTransit(false);
if (!order.save()) {
log.log(Level.SEVERE, "Order not saved");
return false;
}
}
}
// Line
if (product == null || product.getM_Product_ID() != detail.getM_Product_ID())
product = MProduct.get(getCtx(), detail.getM_Product_ID());
if (p_IsTest) {
addLog(0, null, detail.getActualAllocation(), bp.getName() + " - " + product.getName());
continue;
}
if (p_ConsolidateDocument) {
String sql = "SELECT DD_OrderLine_ID FROM DD_OrderLine ol INNER JOIN DD_Order o ON (o.DD_Order_ID=ol.DD_Order_ID) WHERE o.DocStatus IN ('DR','IN') AND o.C_BPartner_ID = ? AND M_Product_ID=? AND ol.M_Locator_ID=? AND ol.DatePromised <= ?";
int DD_OrderLine_ID = DB.getSQLValueEx(get_TrxName(), sql, new Object[] { detail.getC_BPartner_ID(), product.getM_Product_ID(), m_locator.getM_Locator_ID(), p_DatePromised });
if (DD_OrderLine_ID <= 0) {
MDDOrderLine line = new MDDOrderLine(order);
line.setAD_Org_ID(bp.getAD_OrgBP_ID_Int());
line.setM_Locator_ID(m_locator.getM_Locator_ID());
line.setM_LocatorTo_ID(m_locator_to.getM_Locator_ID());
line.setIsInvoiced(false);
line.setProduct(product);
BigDecimal QtyAllocation = detail.getActualAllocation();
if (QtyAllocation == null)
QtyAllocation = Env.ZERO;
line.setQty(QtyAllocation);
line.setQtyEntered(QtyAllocation);
//line.setTargetQty(detail.getActualAllocation());
line.setTargetQty(Env.ZERO);
String Description = "";
if (m_run.getName() != null)
Description = Description.concat(m_run.getName());
line.setDescription(Description + " " + Msg.translate(getCtx(), "Qty") + " = " + QtyAllocation + " ");
//line.setConfirmedQty(QtyAllocation);
line.saveEx();
} else {
MDDOrderLine line = new MDDOrderLine(getCtx(), DD_OrderLine_ID, get_TrxName());
BigDecimal QtyAllocation = detail.getActualAllocation();
if (QtyAllocation == null)
QtyAllocation = Env.ZERO;
String Description = line.getDescription();
if (Description == null)
Description = "";
if (m_run.getName() != null)
Description = Description.concat(m_run.getName());
line.setDescription(Description + " " + Msg.translate(getCtx(), "Qty") + " = " + QtyAllocation + " ");
line.setQty(line.getQtyEntered().add(QtyAllocation));
//line.setConfirmedQty(line.getConfirmedQty().add( QtyAllocation));
line.saveEx();
}
} else {
// Create Order Line
MDDOrderLine line = new MDDOrderLine(order);
if (counter && bp.getAD_OrgBP_ID_Int() > 0)
// don't overwrite counter doc
;
/*else // normal - optionally overwrite
{
line.setC_BPartner_ID(detail.getC_BPartner_ID());
if (detail.getC_BPartner_Location_ID() != 0)
line.setC_BPartner_Location_ID(detail.getC_BPartner_Location_ID());
}*/
//
line.setAD_Org_ID(bp.getAD_OrgBP_ID_Int());
line.setM_Locator_ID(m_locator.getM_Locator_ID());
line.setM_LocatorTo_ID(m_locator_to.getM_Locator_ID());
line.setIsInvoiced(false);
line.setProduct(product);
line.setQty(detail.getActualAllocation());
line.setQtyEntered(detail.getActualAllocation());
//line.setTargetQty(detail.getActualAllocation());
line.setTargetQty(Env.ZERO);
//line.setConfirmedQty(detail.getActualAllocation());
String Description = "";
if (m_run.getName() != null)
Description = Description.concat(m_run.getName());
line.setDescription(Description + " " + Msg.translate(getCtx(), "Qty") + " = " + detail.getActualAllocation() + " ");
line.saveEx();
}
addLog(0, null, detail.getActualAllocation(), order.getDocumentNo() + ": " + bp.getName() + " - " + product.getName());
}
// finish order
order = null;
return true;
}
use of org.compiere.model.MOrgInfo in project adempiere by adempiere.
the class MWFActivity method sendEMail.
// fillParameter
/*********************************
* Send EMail
*/
private void sendEMail() {
DocAction doc = (DocAction) m_po;
MMailText text = new MMailText(getCtx(), m_node.getR_MailText_ID(), null);
text.setPO(m_po, true);
//
String subject = doc.getDocumentInfo() + ": " + text.getMailHeader();
String message = text.getMailText(true) + "\n-----\n" + doc.getDocumentInfo() + "\n" + doc.getSummary();
File pdf = doc.createPDF();
//
MClient client = MClient.get(doc.getCtx(), doc.getAD_Client_ID());
// Explicit EMail
sendEMail(client, 0, m_node.getEMail(), subject, message, pdf, text.isHtml());
// Recipient Type
String recipient = m_node.getEMailRecipient();
// email to document user
if (recipient == null || recipient.length() == 0)
sendEMail(client, doc.getDoc_User_ID(), null, subject, message, pdf, text.isHtml());
else if (recipient.equals(MWFNode.EMAILRECIPIENT_DocumentBusinessPartner)) {
int index = m_po.get_ColumnIndex("AD_User_ID");
if (index > 0) {
Object oo = m_po.get_Value(index);
if (oo instanceof Integer) {
int AD_User_ID = ((Integer) oo).intValue();
if (AD_User_ID != 0)
sendEMail(client, AD_User_ID, null, subject, message, pdf, text.isHtml());
else
log.fine("No User in Document");
} else
log.fine("Empty User in Document");
} else
log.fine("No User Field in Document");
} else if (recipient.equals(MWFNode.EMAILRECIPIENT_DocumentOwner))
sendEMail(client, doc.getDoc_User_ID(), null, subject, message, pdf, text.isHtml());
else if (recipient.equals(MWFNode.EMAILRECIPIENT_WFResponsible)) {
MWFResponsible resp = getResponsible();
if (resp.isInvoker())
sendEMail(client, doc.getDoc_User_ID(), null, subject, message, pdf, text.isHtml());
else if (resp.isHuman())
sendEMail(client, resp.getAD_User_ID(), null, subject, message, pdf, text.isHtml());
else if (resp.isRole()) {
MRole role = resp.getRole();
if (role != null) {
MUser[] users = MUser.getWithRole(role);
for (int i = 0; i < users.length; i++) sendEMail(client, users[i].getAD_User_ID(), null, subject, message, pdf, text.isHtml());
}
} else if (resp.isOrganization()) {
MOrgInfo org = MOrgInfo.get(getCtx(), m_po.getAD_Org_ID(), get_TrxName());
if (org.getSupervisor_ID() == 0)
log.fine("No Supervisor for AD_Org_ID=" + m_po.getAD_Org_ID());
else
sendEMail(client, org.getSupervisor_ID(), null, subject, message, pdf, text.isHtml());
}
}
}
use of org.compiere.model.MOrgInfo in project adempiere by adempiere.
the class MWFActivity method getApprovalUser.
// isInvoker
/**
* Get Approval User.
* If the returned user is the same, the document is approved.
* @param AD_User_ID starting User
* @param C_Currency_ID currency
* @param amount amount
* @param AD_Org_ID document organization
* @param ownDocument the document is owned by AD_User_ID
* @return AD_User_ID - if -1 no Approver
*/
public int getApprovalUser(int AD_User_ID, int C_Currency_ID, BigDecimal amount, int AD_Org_ID, boolean ownDocument) {
// Nothing to approve
if (amount == null || amount.signum() == 0)
return AD_User_ID;
// Starting user
MUser user = MUser.get(getCtx(), AD_User_ID);
log.info("For User=" + user + ", Amt=" + amount + ", Own=" + ownDocument);
MUser oldUser = null;
while (user != null) {
if (user.equals(oldUser)) {
log.info("Loop - " + user.getName());
return -1;
}
oldUser = user;
log.fine("User=" + user.getName());
// Get Roles of User
MRole[] roles = user.getRoles(AD_Org_ID);
for (int i = 0; i < roles.length; i++) {
MRole role = roles[i];
if (ownDocument && !role.isCanApproveOwnDoc())
// find a role with allows them to approve own
continue;
BigDecimal roleAmt = role.getAmtApproval();
if (roleAmt == null || roleAmt.signum() == 0)
continue;
if (C_Currency_ID != role.getC_Currency_ID() && // No currency = amt only
role.getC_Currency_ID() != 0) {
roleAmt = // today & default rate
MConversionRate.convert(// today & default rate
getCtx(), roleAmt, role.getC_Currency_ID(), C_Currency_ID, getAD_Client_ID(), AD_Org_ID);
if (roleAmt == null || roleAmt.signum() == 0)
continue;
}
boolean approved = amount.compareTo(roleAmt) <= 0;
log.fine("Approved=" + approved + " - User=" + user.getName() + ", Role=" + role.getName() + ", ApprovalAmt=" + roleAmt);
if (approved)
return user.getAD_User_ID();
}
// Get Supervisor
if (user.getSupervisor_ID() != 0) {
user = MUser.get(getCtx(), user.getSupervisor_ID());
log.fine("Supervisor: " + user.getName());
} else {
log.fine("No Supervisor");
MOrg org = MOrg.get(getCtx(), AD_Org_ID);
MOrgInfo orgInfo = org.getInfo();
// Get Org Supervisor
if (orgInfo.getSupervisor_ID() != 0) {
user = MUser.get(getCtx(), orgInfo.getSupervisor_ID());
log.fine("Org=" + org.getName() + ",Supervisor: " + user.getName());
} else {
log.fine("No Org Supervisor");
// Get Parent Org Supervisor
if (orgInfo.getParent_Org_ID() != 0) {
org = MOrg.get(getCtx(), orgInfo.getParent_Org_ID());
orgInfo = org.getInfo();
if (orgInfo.getSupervisor_ID() != 0) {
user = MUser.get(getCtx(), orgInfo.getSupervisor_ID());
log.fine("Parent Org Supervisor: " + user.getName());
}
}
}
}
// No Supervisor
//ownDocument should always be false for the next user
ownDocument = false;
}
// while there is a user to approve
log.fine("No user found");
return -1;
}
use of org.compiere.model.MOrgInfo in project adempiere by adempiere.
the class BPartnerOrgLink method doIt.
// prepare
/**
* Perform process.
* @return Message (text with variables)
* @throws Exception if not successful
*/
protected String doIt() throws Exception {
log.info("C_BPartner_ID=" + p_C_BPartner_ID + ", AD_Org_ID=" + p_AD_Org_ID + ", AD_OrgType_ID=" + p_AD_OrgType_ID + ", AD_Role_ID=" + p_AD_Role_ID);
if (p_C_BPartner_ID == 0)
throw new AdempiereUserError("No Business Partner ID");
MBPartner bp = new MBPartner(getCtx(), p_C_BPartner_ID, get_TrxName());
if (bp.get_ID() == 0)
throw new AdempiereUserError("Business Partner not found - C_BPartner_ID=" + p_C_BPartner_ID);
// BP Location
MBPartnerLocation[] locs = bp.getLocations(false);
if (locs == null || locs.length == 0)
throw new IllegalArgumentException("Business Partner has no Location");
// Location
int C_Location_ID = locs[0].getC_Location_ID();
if (C_Location_ID == 0)
throw new IllegalArgumentException("Business Partner Location has no Address");
// Create Org
boolean newOrg = p_AD_Org_ID == 0;
MOrg org = new MOrg(getCtx(), p_AD_Org_ID, get_TrxName());
if (newOrg) {
org.setValue(bp.getValue());
org.setName(bp.getName());
org.setDescription(bp.getDescription());
if (!org.save())
throw new Exception("Organization not saved");
} else // check if linked to already
{
int C_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName());
if (C_BPartner_ID > 0)
throw new IllegalArgumentException("Organization '" + org.getName() + "' already linked (to C_BPartner_ID=" + C_BPartner_ID + ")");
}
p_AD_Org_ID = org.getAD_Org_ID();
// Update Org Info
MOrgInfo oInfo = org.getInfo();
oInfo.setAD_OrgType_ID(p_AD_OrgType_ID);
if (newOrg)
oInfo.setC_Location_ID(C_Location_ID);
// Create Warehouse
MWarehouse wh = null;
if (!newOrg) {
MWarehouse[] whs = MWarehouse.getForOrg(getCtx(), p_AD_Org_ID);
if (whs != null && whs.length > 0)
// pick first
wh = whs[0];
}
// New Warehouse
if (wh == null) {
wh = new MWarehouse(org);
if (!wh.save(get_TrxName()))
throw new Exception("Warehouse not saved");
}
// Create Locator
MLocator mLoc = wh.getDefaultLocator();
if (mLoc == null) {
mLoc = new MLocator(wh, "Standard");
mLoc.setIsDefault(true);
mLoc.save(get_TrxName());
}
// Update/Save Org Info
oInfo.setM_Warehouse_ID(wh.getM_Warehouse_ID());
if (!oInfo.save(get_TrxName()))
throw new Exception("Organization Info not saved");
// Update BPartner
bp.setAD_OrgBP_ID(p_AD_Org_ID);
if (bp.getAD_Org_ID() != 0)
// Shared BPartner
bp.setClientOrg(bp.getAD_Client_ID(), 0);
// Save BP
if (!bp.save())
throw new Exception("Business Partner not updated");
// Limit to specific Role
if (p_AD_Role_ID != 0) {
boolean found = false;
MRoleOrgAccess[] orgAccesses = MRoleOrgAccess.getOfOrg(getCtx(), p_AD_Org_ID);
// delete all accesses except the specific
for (int i = 0; i < orgAccesses.length; i++) {
if (orgAccesses[i].getAD_Role_ID() == p_AD_Role_ID)
found = true;
else
orgAccesses[i].delete(true);
}
// create access
if (!found) {
MRoleOrgAccess orgAccess = new MRoleOrgAccess(org, p_AD_Role_ID);
orgAccess.save(get_TrxName());
}
}
// Reset Client Role
MRole.getDefault(getCtx(), true);
return "Business Partner - Organization Link created";
}
use of org.compiere.model.MOrgInfo in project adempiere by adempiere.
the class OrderPOCreate method createPOForVendor.
// createPOFromSO
/**
* Create PO for Vendor
* @param C_BPartner_ID vendor
* @param so sales order
*/
public MOrder createPOForVendor(int C_BPartner_ID, MOrder so) {
MOrder po = new MOrder(getCtx(), 0, get_TrxName());
po.setClientOrg(so.getAD_Client_ID(), so.getAD_Org_ID());
po.setLink_Order_ID(so.getC_Order_ID());
po.setIsSOTrx(false);
po.setC_DocTypeTarget_ID();
//
po.setDescription(so.getDescription());
po.setPOReference(so.getDocumentNo());
po.setPriorityRule(so.getPriorityRule());
po.setSalesRep_ID(so.getSalesRep_ID());
po.setM_Warehouse_ID(so.getM_Warehouse_ID());
// Set Vendor
MBPartner vendor = new MBPartner(getCtx(), C_BPartner_ID, get_TrxName());
po.setBPartner(vendor);
// Drop Ship
if (p_IsDropShip) {
po.setIsDropShip(p_IsDropShip);
if (so.isDropShip() && so.getDropShip_BPartner_ID() != 0) {
po.setDropShip_BPartner_ID(so.getDropShip_BPartner_ID());
po.setDropShip_Location_ID(so.getDropShip_Location_ID());
po.setDropShip_User_ID(so.getDropShip_User_ID());
} else {
po.setDropShip_BPartner_ID(so.getC_BPartner_ID());
po.setDropShip_Location_ID(so.getC_BPartner_Location_ID());
po.setDropShip_User_ID(so.getAD_User_ID());
}
// get default drop ship warehouse
MOrgInfo orginfo = MOrgInfo.get(getCtx(), po.getAD_Org_ID(), get_TrxName());
if (orginfo.getDropShip_Warehouse_ID() != 0)
po.setM_Warehouse_ID(orginfo.getDropShip_Warehouse_ID());
else
log.log(Level.SEVERE, "Must specify drop ship warehouse in org info.");
}
// References
po.setC_Activity_ID(so.getC_Activity_ID());
po.setC_Campaign_ID(so.getC_Campaign_ID());
po.setC_Project_ID(so.getC_Project_ID());
po.setUser1_ID(so.getUser1_ID());
po.setUser2_ID(so.getUser2_ID());
po.setUser3_ID(so.getUser3_ID());
po.setUser4_ID(so.getUser4_ID());
//
po.saveEx();
return po;
}
Aggregations