/*
Esta es la forma para validar que el usuario no complete una orden de venta sin registrar la cantidad del producto.
*/
package org.compiere.model;
import java.io.File;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.regex.Pattern;
import org.adempiere.exceptions.BPartnerNoBillToAddressException;
import org.adempiere.exceptions.BPartnerNoShipToAddressException;
import org.adempiere.exceptions.FillMandatoryException;
import org.compiere.print.ReportEngine;
import org.compiere.process.DocAction;
import org.compiere.process.DocumentEngine;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.eevolution.model.MPPProductBOM;
import org.eevolution.model.MPPProductBOMLine;
public class MOrder extends X_C_Order implements DocAction
{
/**
*
*/
/**************************************************************************
* Prepare Document
* @return new status (In Progress or Invalid)
*/
public String prepareIt()
{
log.info(toString());
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
MDocType dt = MDocType.get(getCtx(), getC_DocTypeTarget_ID());
// Std Period open?
if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
}
// Lines
MOrderLine[] lines = getLines(true, MOrderLine.COLUMNNAME_M_Product_ID);
if (lines.length == 0)
{
m_processMsg = "@NoLines@";
return DocAction.STATUS_Invalid;
}
// Validar si no se grabo la cantidad de producto en el detalle de la orden
if(this.grabo_cantidad_producto() == false)
{
this.m_processMsg = "Estimado usuario, no grabo la cantidad de producto";
return DocAction.STATUS_Invalid;
}
...
}
public int grabo_cantidad_producto()
{
int num = 0;
StringBuilder sql = new StringBuilder();
sql.append(" SELECT COALESCE((SELECT 1 FROM c_order o");
sql.append(" JOIN c_orderline ol");
sql.append(" ON o.c_order_id = ol.c_order_id");
sql.append(" JOIN m_product p");
sql.append(" ON ol.m_product_id = p.m_product_id");
sql.append(" WHERE o.c_order_id = " + this.get_ID());
sql.append(" AND ol.qtyordered > 0), 0);");
num = DB.getSQLValue(null, sql.toString());
return num;
}
...
No hay comentarios:
Publicar un comentario