Fix [2520529] - Error Generating Invoice from Shipment with different UoM
https://sourceforge.net/tracker2/?func=detail&atid=879332&aid=2520529&group_id=176962
This commit is contained in:
parent
f516d38ba5
commit
5fcb693d2b
|
@ -605,6 +605,11 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction
|
|||
}
|
||||
MInvoiceLine line = new MInvoiceLine (m_creditMemo);
|
||||
line.setShipLine(confirm.getLine());
|
||||
if (confirm.getLine().getProduct() != null) {
|
||||
// use product UOM in case the shipment hasn't the same uom than the order
|
||||
line.setC_UOM_ID(confirm.getLine().getProduct().getC_UOM_ID());
|
||||
}
|
||||
// Note: confirmation is always in the qty according to the product UOM
|
||||
line.setQty(confirm.getDifferenceQty()); // Entered/Invoiced
|
||||
if (!line.save(get_TrxName()))
|
||||
{
|
||||
|
|
|
@ -617,4 +617,18 @@ public class MInOutLine extends X_M_InOutLine
|
|||
return Env.ZERO;
|
||||
} // getBase
|
||||
|
||||
public boolean sameOrderLineUOM()
|
||||
{
|
||||
if (getC_OrderLine_ID() <= 0)
|
||||
return false;
|
||||
|
||||
MOrderLine oLine = new MOrderLine(getCtx(), getC_OrderLine_ID(), get_TrxName());
|
||||
|
||||
if (oLine.getC_UOM_ID() != getC_UOM_ID())
|
||||
return false;
|
||||
|
||||
// inout has orderline and both has the same UOM
|
||||
return true;
|
||||
}
|
||||
|
||||
} // MInOutLine
|
||||
|
|
|
@ -242,7 +242,11 @@ public class MInvoiceLine extends X_C_InvoiceLine
|
|||
setDescription(sLine.getDescription());
|
||||
//
|
||||
setM_Product_ID(sLine.getM_Product_ID());
|
||||
setC_UOM_ID(sLine.getC_UOM_ID());
|
||||
if (sLine.sameOrderLineUOM())
|
||||
setC_UOM_ID(sLine.getC_UOM_ID());
|
||||
else
|
||||
// use product UOM if the shipment hasn't the same uom than the order
|
||||
setC_UOM_ID(getProduct().getC_UOM_ID());
|
||||
setM_AttributeSetInstance_ID(sLine.getM_AttributeSetInstance_ID());
|
||||
// setS_ResourceAssignment_ID(sLine.getS_ResourceAssignment_ID());
|
||||
if(getM_Product_ID() == 0)
|
||||
|
@ -254,7 +258,10 @@ public class MInvoiceLine extends X_C_InvoiceLine
|
|||
MOrderLine oLine = new MOrderLine (getCtx(), C_OrderLine_ID, get_TrxName());
|
||||
setS_ResourceAssignment_ID(oLine.getS_ResourceAssignment_ID());
|
||||
//
|
||||
setPriceEntered(oLine.getPriceEntered());
|
||||
if (sLine.sameOrderLineUOM())
|
||||
setPriceEntered(oLine.getPriceEntered());
|
||||
else
|
||||
setPriceEntered(oLine.getPriceActual());
|
||||
setPriceActual(oLine.getPriceActual());
|
||||
setPriceLimit(oLine.getPriceLimit());
|
||||
setPriceList(oLine.getPriceList());
|
||||
|
|
|
@ -1792,7 +1792,10 @@ public class MOrder extends X_C_Order implements DocAction
|
|||
MInvoiceLine iLine = new MInvoiceLine(invoice);
|
||||
iLine.setShipLine(sLine);
|
||||
// Qty = Delivered
|
||||
iLine.setQtyEntered(sLine.getQtyEntered());
|
||||
if (sLine.sameOrderLineUOM())
|
||||
iLine.setQtyEntered(sLine.getQtyEntered());
|
||||
else
|
||||
iLine.setQtyEntered(sLine.getMovementQty());
|
||||
iLine.setQtyInvoiced(sLine.getMovementQty());
|
||||
if (!iLine.save(get_TrxName()))
|
||||
{
|
||||
|
|
|
@ -92,7 +92,10 @@ public class InOutCreateInvoice extends SvrProcess
|
|||
MInOutLine sLine = shipLines[i];
|
||||
MInvoiceLine line = new MInvoiceLine(invoice);
|
||||
line.setShipLine(sLine);
|
||||
line.setQtyEntered(sLine.getQtyEntered());
|
||||
if (sLine.sameOrderLineUOM())
|
||||
line.setQtyEntered(sLine.getQtyEntered());
|
||||
else
|
||||
line.setQtyEntered(sLine.getMovementQty());
|
||||
line.setQtyInvoiced(sLine.getMovementQty());
|
||||
if (!line.save())
|
||||
throw new IllegalArgumentException("Cannot save Invoice Line");
|
||||
|
|
|
@ -415,7 +415,10 @@ public class InvoiceGenerate extends SvrProcess
|
|||
//
|
||||
MInvoiceLine line = new MInvoiceLine (m_invoice);
|
||||
line.setShipLine(sLine);
|
||||
line.setQtyEntered(sLine.getQtyEntered());
|
||||
if (sLine.sameOrderLineUOM())
|
||||
line.setQtyEntered(sLine.getQtyEntered());
|
||||
else
|
||||
line.setQtyEntered(sLine.getMovementQty());
|
||||
line.setQtyInvoiced(sLine.getMovementQty());
|
||||
line.setLine(m_line + sLine.getLine());
|
||||
if (!line.save())
|
||||
|
|
|
@ -590,28 +590,28 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
if (inoutLine != null)
|
||||
{
|
||||
invoiceLine.setShipLine(inoutLine); // overwrites
|
||||
if (inoutLine.getQtyEntered().compareTo(inoutLine.getMovementQty()) != 0)
|
||||
invoiceLine.setQtyInvoiced(QtyEntered
|
||||
.multiply(inoutLine.getMovementQty())
|
||||
.divide(inoutLine.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
|
||||
if (inoutLine.sameOrderLineUOM())
|
||||
invoiceLine.setQtyInvoiced(QtyEntered);
|
||||
else
|
||||
invoiceLine.setQtyInvoiced(inoutLine.getMovementQty());
|
||||
}
|
||||
else
|
||||
else {
|
||||
log.fine("No Receipt Line");
|
||||
|
||||
// Order Info
|
||||
if (orderLine != null)
|
||||
{
|
||||
invoiceLine.setOrderLine(orderLine); // overwrites
|
||||
if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0)
|
||||
invoiceLine.setQtyInvoiced(QtyEntered
|
||||
.multiply(orderLine.getQtyOrdered())
|
||||
.divide(orderLine.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
else
|
||||
{
|
||||
log.fine("No Order Line");
|
||||
invoiceLine.setPrice();
|
||||
invoiceLine.setTax();
|
||||
// Order Info
|
||||
if (orderLine != null)
|
||||
{
|
||||
invoiceLine.setOrderLine(orderLine); // overwrites
|
||||
if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0)
|
||||
invoiceLine.setQtyInvoiced(QtyEntered
|
||||
.multiply(orderLine.getQtyOrdered())
|
||||
.divide(orderLine.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
else
|
||||
{
|
||||
log.fine("No Order Line");
|
||||
invoiceLine.setPrice();
|
||||
invoiceLine.setTax();
|
||||
}
|
||||
}
|
||||
if (!invoiceLine.save())
|
||||
log.log(Level.SEVERE, "Line NOT created #" + i);
|
||||
|
|
|
@ -581,28 +581,28 @@ public class WCreateFromInvoice extends WCreateFrom implements ValueChangeListen
|
|||
if (inoutLine != null)
|
||||
{
|
||||
invoiceLine.setShipLine(inoutLine); // overwrites
|
||||
if (inoutLine.getQtyEntered().compareTo(inoutLine.getMovementQty()) != 0)
|
||||
invoiceLine.setQtyInvoiced(QtyEntered
|
||||
.multiply(inoutLine.getMovementQty())
|
||||
.divide(inoutLine.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
|
||||
if (inoutLine.sameOrderLineUOM())
|
||||
invoiceLine.setQtyInvoiced(QtyEntered);
|
||||
else
|
||||
invoiceLine.setQtyInvoiced(inoutLine.getMovementQty());
|
||||
}
|
||||
else
|
||||
else {
|
||||
log.fine("No Receipt Line");
|
||||
|
||||
// Order Info
|
||||
if (orderLine != null)
|
||||
{
|
||||
invoiceLine.setOrderLine(orderLine); // overwrites
|
||||
if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0)
|
||||
invoiceLine.setQtyInvoiced(QtyEntered
|
||||
.multiply(orderLine.getQtyOrdered())
|
||||
.divide(orderLine.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
else
|
||||
{
|
||||
log.fine("No Order Line");
|
||||
invoiceLine.setPrice();
|
||||
invoiceLine.setTax();
|
||||
// Order Info
|
||||
if (orderLine != null)
|
||||
{
|
||||
invoiceLine.setOrderLine(orderLine); // overwrites
|
||||
if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0)
|
||||
invoiceLine.setQtyInvoiced(QtyEntered
|
||||
.multiply(orderLine.getQtyOrdered())
|
||||
.divide(orderLine.getQtyEntered(), 12, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
else
|
||||
{
|
||||
log.fine("No Order Line");
|
||||
invoiceLine.setPrice();
|
||||
invoiceLine.setTax();
|
||||
}
|
||||
}
|
||||
if (!invoiceLine.save())
|
||||
log.log(Level.SEVERE, "Line NOT created #" + i);
|
||||
|
|
Loading…
Reference in New Issue