use of org.compiere.model.MAttributeSetInstance in project adempiere by adempiere.
the class OrderReceiptIssue method generateSummaryTable.
// executeQuery
public String generateSummaryTable(IMiniTable issue, String productField, String uomField, String attribute, String toDeliverQty, String deliveredQtyField, String scrapQtyField, boolean isBackflush, boolean isOnlyIssue, boolean isOnlyReceipt) {
StringBuffer iText = new StringBuffer();
iText.append("<b>");
iText.append(Msg.parseTranslation(Env.getCtx(), "@IsShipConfirm@"));
iText.append("</b>");
iText.append("<br />");
if (isOnlyReceipt || isBackflush) {
String[][] table = { { Msg.translate(Env.getCtx(), "Name"), Msg.translate(Env.getCtx(), "C_UOM_ID"), Msg.translate(Env.getCtx(), "M_AttributeSetInstance_ID"), Msg.translate(Env.getCtx(), "QtyToDeliver"), Msg.translate(Env.getCtx(), "QtyDelivered"), Msg.translate(Env.getCtx(), "QtyScrap") }, { productField, uomField, attribute, toDeliverQty, deliveredQtyField, scrapQtyField } };
iText.append(createHTMLTable(table));
}
if (isBackflush || isOnlyIssue) {
iText.append("<br /><br />");
ArrayList<String[]> table = new ArrayList<String[]>();
table.add(new String[] { // 0
Msg.translate(Env.getCtx(), "Value"), // 1
Msg.translate(Env.getCtx(), "Name"), // 2
Msg.translate(Env.getCtx(), "C_UOM_ID"), // 3
Msg.translate(Env.getCtx(), "M_AttributeSetInstance_ID"), // 4
Msg.translate(Env.getCtx(), "QtyToDeliver"), // 5
Msg.translate(Env.getCtx(), "QtyDelivered"), // 6
Msg.translate(Env.getCtx(), "QtyScrap") });
// check available on hand
for (int i = 0; i < issue.getRowCount(); i++) {
IDColumn id = (IDColumn) issue.getValueAt(i, 0);
if (id != null && id.isSelected()) {
KeyNamePair m_productkey = (KeyNamePair) issue.getValueAt(i, 3);
int m_M_Product_ID = m_productkey.getKey();
KeyNamePair m_uomkey = (KeyNamePair) issue.getValueAt(i, 4);
if (// M_AttributeSetInstance_ID
issue.getValueAt(i, 5) == null) // is null
{
Timestamp m_movementDate = getMovementDate();
Timestamp minGuaranteeDate = m_movementDate;
MStorage[] storages = MPPOrder.getStorages(Env.getCtx(), m_M_Product_ID, getPP_Order().getM_Warehouse_ID(), 0, minGuaranteeDate, null);
// Qty Delivered
BigDecimal qtyDelivered = getValueBigDecimal(issue, i, 7);
// QtyOpen
BigDecimal toDelivery = getValueBigDecimal(issue, i, 8);
// QtyScrap
BigDecimal scrap = getValueBigDecimal(issue, i, 9);
BigDecimal toIssue = toDelivery.add(scrap);
//allow return quantity order line
if (storages == null || storages.length == 0) {
if (toIssue.signum() < 0 && qtyDelivered.signum() > 0 && qtyDelivered.add(toIssue).signum() >= 0) {
String[] row = { "", "", "", "", "0.00", "0.00", "0.00" };
row[0] = issue.getValueAt(i, 2) != null ? issue.getValueAt(i, 2).toString() : "";
row[1] = m_productkey.toString();
row[2] = m_uomkey != null ? m_uomkey.toString() : "";
String desc = null;
row[3] = desc != null ? desc : "";
row[4] = toIssue.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
row[5] = getValueBigDecimal(issue, i, 7).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
row[6] = getValueBigDecimal(issue, i, 9).toString();
table.add(row);
}
continue;
}
for (MStorage storage : storages) {
if (storage.getQtyOnHand().signum() == 0)
continue;
BigDecimal issueact = toIssue;
if (issueact.compareTo(storage.getQtyOnHand()) > 0)
issueact = storage.getQtyOnHand();
toIssue = toIssue.subtract(issueact);
String desc = new MAttributeSetInstance(Env.getCtx(), storage.getM_AttributeSetInstance_ID(), null).getDescription();
String[] row = { "", "", "", "", "0.00", "0.00", "0.00" };
row[0] = issue.getValueAt(i, 2) != null ? issue.getValueAt(i, 2).toString() : "";
row[1] = m_productkey.toString();
row[2] = m_uomkey != null ? m_uomkey.toString() : "";
row[3] = desc != null ? desc : "";
row[4] = issueact.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
row[5] = getValueBigDecimal(issue, i, 7).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
row[6] = getValueBigDecimal(issue, i, 9).toString();
table.add(row);
if (toIssue.signum() <= 0)
break;
}
} else // if M_AttributeSetInstance_ID isn't null
{
String[] row = { "", "", "", "", "0.00", "0.00", "0.00" };
row[0] = issue.getValueAt(i, 2) != null ? issue.getValueAt(i, 2).toString() : "";
row[1] = m_productkey.toString();
row[2] = m_uomkey != null ? m_uomkey.toString() : "";
row[3] = issue.getValueAt(i, 5) != null ? issue.getValueAt(i, 5).toString() : "";
row[4] = getValueBigDecimal(issue, i, 8).toString();
row[5] = getValueBigDecimal(issue, i, 7).toString();
row[6] = getValueBigDecimal(issue, i, 9).toString();
table.add(row);
}
}
}
String[][] tableArray = table.toArray(new String[table.size()][]);
iText.append(createHTMLTable(tableArray));
}
return iText.toString();
}
use of org.compiere.model.MAttributeSetInstance in project adempiere by adempiere.
the class ExpressReceiptScanBar method loadData.
protected void loadData() {
data = new LinkedHashMap<String, Vector>();
for (MWMInOutBoundLine inBoundline : getInOutBoundLines()) {
inBoundline.setMovementQty(Env.ZERO);
inBoundline.saveEx();
}
for (MWMInOutBoundLineMA inBoundlineMA : getDocumentLines()) {
MProduct product = null;
MAttributeSetInstance asi = null;
String lotNo = null;
String serNo = null;
Integer referenceId = null;
BigDecimal qty = null;
boolean reset = false;
MWMInOutBoundLine inBoundline = (MWMInOutBoundLine) inBoundlineMA.getWM_InOutBoundLine();
// inBoundline.setMovementQty(Env.ZERO);
// inBoundline.saveEx();
int M_Product_ID = inBoundline.getM_Product_ID();
int M_AttributeSetInstance_ID = inBoundlineMA.getM_AttributeSetInstance_ID();
if (M_Product_ID > 0)
product = MProduct.get(Env.getCtx(), M_Product_ID);
else
continue;
if (M_AttributeSetInstance_ID > 0) {
asi = new MAttributeSetInstance(Env.getCtx(), M_AttributeSetInstance_ID, null);
lotNo = asi.getLot();
serNo = asi.getSerNo();
} else {
M_AttributeSetInstance_ID = 0;
reset = true;
}
//referenceId = inBoundline.getC_OrderLine_ID();
qty = inBoundlineMA.getMovementQty();
ArrayList<Object> values = null;
while (qty.signum() != 0) {
if (getSource() != null && source.size() > 0) {
values = checkProduct(product, qty, reset);
if (values == null)
throw new AdempiereException("@M_Product_ID@ ; " + product.getName() + " @InValid@");
}
referenceId = (Integer) values.get(ID);
String key = product.getValue();
if (lotNo != null && lotNo.length() > 0)
key = key + lotNo;
if (serNo != null && serNo.length() > 0)
key = key + serNo;
if (serNo == null)
key = key + "#" + referenceId;
Vector<Object> line = new Vector<Object>(6);
line.add(product.getValue());
line.add(product.getName());
line.add(lotNo);
line.add(serNo);
BigDecimal qtyDelivered = (BigDecimal) values.get(QTY_DELIVERED);
qty = qty.subtract(qtyDelivered);
line.add(qtyDelivered);
line.add(inBoundline.get_ID());
line.add(referenceId != null ? referenceId.intValue() : 0);
data.put(key, line);
}
}
}
use of org.compiere.model.MAttributeSetInstance in project adempiere by adempiere.
the class ExpressReceiptScanBar method createLines.
public void createLines() {
for (Vector<Object> line : getData().values()) {
int id = (Integer) line.get(5);
MWMInOutBoundLine ioBoundLine = new MWMInOutBoundLine(Env.getCtx(), id, null);
for (MWMInOutBoundLineMA ioBoundLineMA : getLinesMA(ioBoundLine)) {
ioBoundLineMA.deleteEx(true);
}
}
for (Vector<Object> line : getData().values()) {
String value = (String) line.get(0);
String lotNo = (String) line.get(2);
String serNo = (String) line.get(3);
Boolean isASI = (lotNo != null && lotNo.length() > 0) || (serNo != null && serNo.length() > 0) ? true : false;
BigDecimal qty = (BigDecimal) line.get(4);
int id = (Integer) line.get(5);
Integer referenceId = (Integer) line.get(6);
MWMInOutBoundLine boundLine = null;
MAttributeSetInstance asi = null;
MProduct product = new Query(Env.getCtx(), I_M_Product.Table_Name, "Value = ? ", null).setClient_ID().setParameters(value).firstOnly();
String desc = null;
if (referenceId > 0)
boundLine = getMWMInOutBoundLine(referenceId, product.get_ID());
if (product.getM_AttributeSet_ID() > 0 && isASI) {
asi = getASI(product, lotNo, serNo);
if (asi == null)
asi = getAttributeSetInstance(product, lotNo, serNo, getM_Locater_ID(), null);
}
MWMInOutBoundLineMA boundLineMA = new MWMInOutBoundLineMA(Env.getCtx(), 0, null);
if (asi == null && isASI) {
asi = new MAttributeSetInstance(Env.getCtx(), 0, product.getM_AttributeSet_ID(), null);
if (lotNo != null) {
asi.setLot(lotNo);
desc = lotNo;
}
if (serNo != null) {
asi.setSerNo(serNo);
if (desc != null)
desc = desc + " - " + serNo;
else
desc = serNo;
}
asi.setDescription(desc);
asi.saveEx();
}
boundLineMA.setWM_InOutBoundLine_ID(boundLine.get_ID());
boundLineMA.setM_AttributeSetInstance_ID(asi == null ? 0 : asi.getM_AttributeSetInstance_ID());
boundLineMA.setMovementQty(qty);
boundLineMA.saveEx();
boundLine.setMovementQty(boundLine.getMovementQty().add(qty));
boundLine.saveEx();
}
}
use of org.compiere.model.MAttributeSetInstance in project adempiere by adempiere.
the class ChangeASIAction method changeASI.
private void changeASI(DefaultMutableTreeNode node) {
BOMLineWrapper line = (BOMLineWrapper) node.getUserObject();
int selectedASI = selectASIID(line);
if (selectedASI == -1) {
setIgnoreChange(true);
return;
}
MAttributeSetInstance asi = new MAttributeSetInstance(Env.getCtx(), selectedASI, null);
MProduct p = new MProduct(Env.getCtx(), line.getM_Product_ID(), null);
changeBOMLine(line, p, asi);
}
Aggregations