use of org.compiere.model.MDocType in project adempiere by adempiere.
the class MPPOrder method approveIt.
// reserveStock
public boolean approveIt() {
log.info("approveIt - " + toString());
MDocType doc = MDocType.get(getCtx(), getC_DocType_ID());
if (MDocType.DOCBASETYPE_QualityOrder.equals(doc.getDocBaseType())) {
String whereClause = COLUMNNAME_PP_Product_BOM_ID + "=? AND " + COLUMNNAME_AD_Workflow_ID + "=?";
MQMSpecification qms = new Query(getCtx(), MQMSpecification.Table_Name, whereClause, get_TrxName()).setParameters(new Object[] { getPP_Product_BOM_ID(), getAD_Workflow_ID() }).firstOnly();
return qms != null ? qms.isValid(getM_AttributeSetInstance_ID()) : true;
} else {
setIsApproved(true);
}
return true;
}
use of org.compiere.model.MDocType in project adempiere by adempiere.
the class VPAttributeDialog method cmd_select.
// actionPerformed
/**
* Instance Selection Button
* @return true if selected
*/
private boolean cmd_select() {
log.config("");
int M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "M_Warehouse_ID");
int C_DocType_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "C_DocType_ID");
if (C_DocType_ID > 0) {
MDocType doctype = new MDocType(Env.getCtx(), C_DocType_ID, null);
String docbase = doctype.getDocBaseType();
// consider also old lot numbers at inventory
if (docbase.equals(MDocType.DOCBASETYPE_MaterialReceipt) || docbase.equals(MDocType.DOCBASETYPE_MaterialPhysicalInventory))
M_Warehouse_ID = 0;
}
// teo_sarca [ 1564520 ] Inventory Move: can't select existing attributes
// Trifon - Always read Locator from Context. There are too many windows to read explicitly one by one.
int M_Locator_ID = 0;
// only window
M_Locator_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, X_M_MovementLine.COLUMNNAME_M_Locator_ID, true);
String title = "";
// Get Text
String sql = "SELECT p.Name, w.Name, w.M_Warehouse_ID FROM M_Product p, M_Warehouse w " + "WHERE p.M_Product_ID=? AND w.M_Warehouse_ID" + // teo_sarca [ 1564520 ]
(M_Locator_ID <= 0 ? "=?" : " IN (SELECT M_Warehouse_ID FROM M_Locator where M_Locator_ID=?)");
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
pstmt.setInt(2, M_Locator_ID <= 0 ? M_Warehouse_ID : M_Locator_ID);
rs = pstmt.executeQuery();
if (rs.next()) {
title = ": " + rs.getString(1) + " - " + rs.getString(2);
// fetch the actual warehouse - teo_sarca [ 1564520 ]
M_Warehouse_ID = rs.getInt(3);
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//
PAttributeInstance pai = new PAttributeInstance(this, title, M_Warehouse_ID, M_Locator_ID, m_M_Product_ID, m_C_BPartner_ID);
//
if (m_M_AttributeSetInstance_ID != pai.getM_AttributeSetInstance_ID() || !(m_M_AttributeSetInstance_ID == 0 && pai.getM_AttributeSetInstance_ID() == -1)) {
m_changed = true;
//
if (pai.getM_AttributeSetInstance_ID() != -1) {
m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID();
m_M_AttributeSetInstanceName = pai.getM_AttributeSetInstanceName();
m_M_Locator_ID = pai.getM_Locator_ID();
} else {
m_M_AttributeSetInstance_ID = 0;
m_M_AttributeSetInstanceName = "";
// Leave the locator alone
}
}
return m_changed;
}
use of org.compiere.model.MDocType in project adempiere by adempiere.
the class WPAttributeDialog method cmd_select.
// actionPerformed
/**
* Instance Selection Button
* @return true if selected
*/
private boolean cmd_select() {
log.config("");
int M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "M_Warehouse_ID");
int C_DocType_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "C_DocType_ID");
if (C_DocType_ID > 0) {
MDocType doctype = new MDocType(Env.getCtx(), C_DocType_ID, null);
String docbase = doctype.getDocBaseType();
if (docbase.equals(MDocType.DOCBASETYPE_MaterialReceipt))
M_Warehouse_ID = 0;
}
// teo_sarca [ 1564520 ] Inventory Move: can't select existing attributes
// Trifon - Always read Locator from Context. There are too many windows to read explicitly one by one.
int M_Locator_ID = 0;
// only window
M_Locator_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, X_M_MovementLine.COLUMNNAME_M_Locator_ID, true);
String title = "";
// Get Text
String sql = "SELECT p.Name, w.Name, w.M_Warehouse_ID FROM M_Product p, M_Warehouse w " + "WHERE p.M_Product_ID=? AND w.M_Warehouse_ID" + // teo_sarca [ 1564520 ]
(M_Locator_ID <= 0 ? "=?" : " IN (SELECT M_Warehouse_ID FROM M_Locator where M_Locator_ID=?)");
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
pstmt.setInt(2, M_Locator_ID <= 0 ? M_Warehouse_ID : M_Locator_ID);
rs = pstmt.executeQuery();
if (rs.next()) {
title = ": " + rs.getString(1) + " - " + rs.getString(2);
// fetch the actual warehouse - teo_sarca [ 1564520 ]
M_Warehouse_ID = rs.getInt(3);
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//
InfoPAttributeInstancePanel pai = new InfoPAttributeInstancePanel(this, title, M_Warehouse_ID, M_Locator_ID, m_M_Product_ID, m_C_BPartner_ID);
//
if (m_M_AttributeSetInstance_ID != pai.getM_AttributeSetInstance_ID() || !(m_M_AttributeSetInstance_ID == 0 && pai.getM_AttributeSetInstance_ID() == -1)) {
m_changed = true;
//
if (pai.getM_AttributeSetInstance_ID() != -1) {
m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID();
m_M_AttributeSetInstanceName = pai.getM_AttributeSetInstanceName();
m_M_Locator_ID = pai.getM_Locator_ID();
} else {
m_M_AttributeSetInstance_ID = 0;
m_M_AttributeSetInstanceName = "";
// Leave the locator alone
}
}
return m_changed;
}
use of org.compiere.model.MDocType in project adempiere by adempiere.
the class AveragePOCostingMethod method setCostingMethod.
/**
* Constructor for Cost Engine
* @param accountSchema
* @param transaction
* @param model
* @param dimension
* @param costThisLevel
* @param costLowLevel
* @param isSalesTransaction
*/
public void setCostingMethod(MAcctSchema accountSchema, MTransaction transaction, IDocumentLine model, MCost dimension, BigDecimal costThisLevel, BigDecimal costLowLevel, Boolean isSalesTransaction) {
if (model instanceof MMatchInv) {
if (costDetail != null && costDetail.get_ID() > 0) {
costDetail.setC_InvoiceLine_ID(((MMatchInv) model).getC_InvoiceLine_ID());
costDetail.saveEx();
}
return;
}
this.accountSchema = accountSchema;
this.transaction = transaction;
this.dimension = dimension;
this.costThisLevel = (costThisLevel == null ? Env.ZERO : costThisLevel);
this.costLowLevel = (costLowLevel == null ? Env.ZERO : costLowLevel);
this.isSalesTransaction = isSalesTransaction;
this.model = model;
this.costingLevel = MProduct.get(this.transaction.getCtx(), this.transaction.getM_Product_ID()).getCostingLevel(accountSchema, transaction.getAD_Org_ID());
// find if this transaction exist into cost detail
this.costDetail = MCostDetail.getByTransaction(this.model, this.transaction, this.accountSchema.getC_AcctSchema_ID(), this.dimension.getM_CostType_ID(), this.dimension.getM_CostElement_ID());
//Setting Accounting period status
MDocType documentType = new MDocType(transaction.getCtx(), transaction.getDocumentLine().getC_DocType_ID(), transaction.get_TrxName());
this.isOpenPeriod = MPeriod.isOpen(transaction.getCtx(), model.getDateAcct(), documentType.getDocBaseType(), transaction.getAD_Org_ID());
//Setting Date Accounting based on Open Period
if (this.isOpenPeriod)
this.dateAccounting = model.getDateAcct();
else
// Is Necessary define that happen in this case when period is close
this.dateAccounting = null;
this.movementQuantity = transaction.getMovementQty();
}
use of org.compiere.model.MDocType in project adempiere by adempiere.
the class AbstractCostingMethod method clearAccounting.
public void clearAccounting(MCostDetail cost) {
// Only can delete if period is open
MTransaction trx = new MTransaction(cost.getCtx(), cost.getM_Transaction_ID(), cost.get_TrxName());
IDocumentLine documentLine = trx.getDocumentLine();
MDocType docType = MDocType.get(cost.getCtx(), documentLine.getC_DocType_ID());
Boolean openPeriod = MPeriod.isOpen(cost.getCtx(), cost.getDateAcct(), docType.getDocBaseType(), cost.getAD_Org_ID());
if (!openPeriod)
return;
String sqldelete = "DELETE FROM Fact_Acct WHERE Record_ID =? AND AD_Table_ID=?";
int tableId = 0;
int recordId = 0;
if (cost.getC_OrderLine_ID() != 0) {
MOrderLine line = (MOrderLine) cost.getC_OrderLine();
line.getParent().setPosted(false);
line.getParent().saveEx();
recordId = line.getParent().get_ID();
tableId = line.getParent().get_Table_ID();
}
if (cost.getM_InOutLine_ID() != 0) {
MInOutLine line = (MInOutLine) cost.getM_InOutLine();
line.getParent().setPosted(false);
line.getParent().saveEx();
recordId = line.getParent().get_ID();
tableId = line.getParent().get_Table_ID();
}
if (cost.getM_InventoryLine_ID() != 0) {
MInventoryLine line = (MInventoryLine) cost.getM_InventoryLine();
line.getParent().setPosted(false);
line.getParent().saveEx();
recordId = line.getParent().get_ID();
tableId = line.getParent().get_Table_ID();
}
if (cost.getM_MovementLine_ID() != 0) {
MMovementLine line = (MMovementLine) cost.getM_MovementLine();
line.getParent().setPosted(false);
line.getParent().saveEx();
recordId = line.getParent().get_ID();
tableId = line.getParent().get_Table_ID();
}
if (cost.getM_ProductionLine_ID() != 0) {
}
if (cost.getPP_Cost_Collector_ID() != 0) {
MPPCostCollector costCollector = (MPPCostCollector) cost.getPP_Cost_Collector();
costCollector.setPosted(false);
costCollector.saveEx();
recordId = costCollector.get_ID();
tableId = costCollector.get_Table_ID();
}
int no = DB.executeUpdateEx(sqldelete, new Object[] { recordId, tableId }, cost.get_TrxName());
}
Aggregations