#1002872 Support estimated landed costs. Auto allocate to all order line if none have been enter by user. IDEMPIERE-1285
This commit is contained in:
parent
4d36bcb679
commit
c2554e5a62
|
@ -18,6 +18,7 @@ package org.compiere.model;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -87,6 +88,30 @@ public class MOrderLandedCost extends X_C_OrderLandedCost {
|
||||||
|
|
||||||
public String distributeLandedCost() {
|
public String distributeLandedCost() {
|
||||||
MOrderLandedCostAllocation[] lines = getLines("");
|
MOrderLandedCostAllocation[] lines = getLines("");
|
||||||
|
if (lines.length == 0) {
|
||||||
|
MOrder order = (MOrder) getC_Order();
|
||||||
|
MOrderLine[] orderLines = order.getLines();
|
||||||
|
if (orderLines.length > 0) {
|
||||||
|
List<MOrderLandedCostAllocation> list = new ArrayList<MOrderLandedCostAllocation>();
|
||||||
|
for(MOrderLine line : orderLines) {
|
||||||
|
if (line.getM_Product_ID() > 0) {
|
||||||
|
MOrderLandedCostAllocation allocation = new MOrderLandedCostAllocation(getCtx(), 0, get_TrxName());
|
||||||
|
allocation.setC_OrderLandedCost_ID(getC_OrderLandedCost_ID());
|
||||||
|
allocation.setC_OrderLine_ID(line.getC_OrderLine_ID());
|
||||||
|
allocation.setClientOrg(getAD_Client_ID(), getAD_Org_ID());
|
||||||
|
allocation.setAmt(BigDecimal.ZERO);
|
||||||
|
allocation.setBase(BigDecimal.ZERO);
|
||||||
|
allocation.setQty(BigDecimal.ZERO);
|
||||||
|
allocation.saveEx();
|
||||||
|
list.add(allocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (list.size() > 0) {
|
||||||
|
lines = list.toArray(lines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (lines.length == 1) {
|
if (lines.length == 1) {
|
||||||
MOrderLine orderLine = (MOrderLine) lines[0].getC_OrderLine();
|
MOrderLine orderLine = (MOrderLine) lines[0].getC_OrderLine();
|
||||||
BigDecimal base = orderLine.getBase(getLandedCostDistribution());
|
BigDecimal base = orderLine.getBase(getLandedCostDistribution());
|
||||||
|
|
Loading…
Reference in New Issue