use of org.compiere.model.MInOutLine in project adempiere by adempiere.
the class CostResult method createBusinessCaseTest.
/**
* create Business Test Case
* @param trxName
*/
void createBusinessCaseTest(String trxName) {
createDataMaster();
generateHistoryCost();
Timestamp dateAcct;
//First Purchase Receipt
dateAcct = today;
MOrder purchase1 = createPurchaseOrder(dateAcct, new BigDecimal(100), new BigDecimal(36));
MInOut receipt1 = null;
for (MOrderLine line : purchase1.getLines()) {
receipt1 = createMaterialReceipt(dateAcct, new BigDecimal(10), line.getC_OrderLine_ID());
}
for (MInOutLine line : receipt1.getLines()) {
CostResult costResult = new CostResult(product.getM_Product_ID(), //currentCostPrice
new BigDecimal("47.7292"), // cumulateQty
new BigDecimal("30"), //cumulateAmt
new BigDecimal("1431.8748"), //cdAmt
new BigDecimal("477.2920"), //cdAdjutment
new BigDecimal("0"), //cdQty
new BigDecimal("10"), //cdCurrentCostPrice
new BigDecimal("53.5937"), //cdCumulateQty
new BigDecimal("20"), //cdCumulateAmt
new BigDecimal("1071.8748"), dateAcct);
assertCostReceipt(costResult, line.getM_InOutLine_ID(), as, trxName);
}
//Create Sales Order Order Credit by 5
dateAcct = TimeUtil.addDays(today, 15);
MOrder sales1 = createSalesOrder(dateAcct, new BigDecimal(5), new BigDecimal(45));
for (MOrderLine line : sales1.getLines()) {
CostResult costResult = new CostResult(product.getM_Product_ID(), new BigDecimal("47.7292"), new BigDecimal("25"), new BigDecimal("1193.2288"), new BigDecimal("238.6460"), new BigDecimal("0"), new BigDecimal("-5"), new BigDecimal("47.7292"), new BigDecimal("30"), new BigDecimal("1431.8748"), dateAcct);
assertCostShipment(costResult, line.getC_OrderLine_ID(), as, trxName);
}
//Second Purchase Receipt 7 day forward
dateAcct = TimeUtil.addDays(today, 31);
MOrder purchase2 = createPurchaseOrder(dateAcct, new BigDecimal(100), new BigDecimal(34));
MInOut receipt2 = null;
for (MOrderLine line : purchase2.getLines()) {
receipt2 = createMaterialReceipt(dateAcct, new BigDecimal(10), line.getC_OrderLine_ID());
}
for (MInOutLine line : receipt2.getLines()) {
CostResult costResult = new CostResult(product.getM_Product_ID(), //currentCostPrice
new BigDecimal("43.8065"), // cumulateQty
new BigDecimal("35"), //cumulateAmt
new BigDecimal("1533.2288"), //cdAmt
new BigDecimal("438.0650"), //cdAdjutment
new BigDecimal("0"), //cdQty
new BigDecimal("10"), //cdCurrentCostPrice
new BigDecimal("47.7292"), //cdCumulateQty
new BigDecimal("25"), //cdCumulateAmt
new BigDecimal("1193.2288"), dateAcct);
assertCostReceipt(costResult, line.getM_InOutLine_ID(), as, trxName);
}
//Create Sales Order Order Credit by 5
dateAcct = TimeUtil.addDays(today, 60);
MOrder sales2 = createSalesOrder(dateAcct, new BigDecimal(10), new BigDecimal(45));
for (MOrderLine line : sales2.getLines()) {
CostResult costResult = new CostResult(product.getM_Product_ID(), new BigDecimal("43.8065"), new BigDecimal("25"), new BigDecimal("1095.1638"), new BigDecimal("438.0650"), new BigDecimal("0"), new BigDecimal("-10"), new BigDecimal("43.8065"), new BigDecimal("35"), new BigDecimal("1533.2288"), dateAcct);
assertCostShipment(costResult, line.getC_OrderLine_ID(), as, trxName);
}
dateAcct = receipt1.getDateAcct();
int M_InOutLine_ID = 0;
for (MInOutLine line : receipt1.getLines()) {
M_InOutLine_ID = line.getM_InOutLine_ID();
MInvoice invoice = createInvoiceVendor(dateAcct, new BigDecimal(10), new BigDecimal(38), line.getM_InOutLine_ID());
}
CostResult costResult = new CostResult(product.getM_Product_ID(), //currentCostPrice
new BigDecimal("44.2827"), // cumulateQty
new BigDecimal("25"), //cumulateAmt
new BigDecimal("1107.0688"), //cdAmt
new BigDecimal("380.0000"), //cdAdjutment
new BigDecimal("20.0000"), //cdQty
new BigDecimal("10"), //cdCurrentCostPrice
new BigDecimal("53.5937"), //cdCumulateQty
new BigDecimal("20"), //cdCumulateAmt
new BigDecimal("1071.8748"), dateAcct);
assertCostInvoice(costResult, M_InOutLine_ID, as, trxName);
dateAcct = Timestamp.valueOf("2010-01-16 00:00:00.0");
for (MOrderLine line : sales1.getLines()) {
costResult = new CostResult(line.getM_Product_ID(), new BigDecimal("44.2827"), new BigDecimal("25"), new BigDecimal("1107.0688"), new BigDecimal("241.9790"), new BigDecimal("0"), new BigDecimal("-5"), new BigDecimal("48.3958"), new BigDecimal("30"), new BigDecimal("1451.8748"), dateAcct);
assertCostShipmentAdjust(costResult, line.getC_OrderLine_ID(), as, trxName);
}
//Reverse Material Receipt
dateAcct = today;
receipt1.processIt(DocAction.ACTION_Reverse_Correct);
receipt1.saveEx();
for (MInOutLine line : receipt1.getLines(true)) {
costResult = new CostResult(product.getM_Product_ID(), //currentCostPrice
new BigDecimal("44.2827"), // cumulateQty
new BigDecimal("25"), //cumulateAmt
new BigDecimal("1107.0688"), //cdAmt
new BigDecimal("380.0000"), //cdAdjutment
new BigDecimal("20.0000"), //cdQty
new BigDecimal("10"), //cdCurrentCostPrice
new BigDecimal("53.5937"), //cdCumulateQty
new BigDecimal("20"), //cdCumulateAmt
new BigDecimal("1071.8748"), dateAcct);
assertCostReceiptReversal(costResult, line.getM_InOutLine_ID(), as, trxName);
}
MInOut reversal = new MInOut(getCtx(), receipt1.getReversal_ID(), trxName);
for (MInOutLine line : reversal.getLines(true)) {
costResult = new CostResult(product.getM_Product_ID(), //currentCostPrice
new BigDecimal("46.8373"), // cumulateQty
new BigDecimal("19"), //cumulateAmt
new BigDecimal("889.9081"), //cdAmt
new BigDecimal("380"), //cdAdjutment
new BigDecimal("20"), //cdQty
new BigDecimal("-10"), //cdCurrentCostPrice
new BigDecimal("49.0073"), //cdCumulateQty
new BigDecimal("34"), //cdCumulateAmt
new BigDecimal("1666.2496"), dateAcct);
assertCostReceiptReversal(costResult, line.getM_InOutLine_ID(), as, trxName);
}
//Second Purchase Receipt 7 day forward
dateAcct = TimeUtil.addDays(today, 7);
MOrder purchase3 = createPurchaseOrder(dateAcct, new BigDecimal(100), new BigDecimal(37));
MInOut receipt3 = null;
for (MOrderLine line : purchase3.getLines()) {
receipt3 = createMaterialReceipt(dateAcct, new BigDecimal(20), line.getC_OrderLine_ID());
}
for (MInOutLine line : receipt3.getLines()) {
costResult = new CostResult(product.getM_Product_ID(), //currentCostPrice
new BigDecimal("42.0489"), // cumulateQty
new BigDecimal("45"), //cumulateAmt
new BigDecimal("1892.1983"), //cdAmt
new BigDecimal("876.7500"), //cdAdjutment
new BigDecimal("0"), //cdQty
new BigDecimal("20"), //cdCurrentCostPrice
new BigDecimal("48.3958"), //cdCumulateQty
new BigDecimal("30"), //cdCumulateAmt
new BigDecimal("1451.8748"), dateAcct);
assertCostReceipt(costResult, line.getM_InOutLine_ID(), as, trxName);
}
dateAcct = TimeUtil.addDays(today, 65);
MMovement move = createMovement(dateAcct, new BigDecimal("5"));
for (MMovementLine line : move.getLines(true)) {
costResult = new CostResult(product.getM_Product_ID(), //currentCostPrice
new BigDecimal("53.5938"), // cumulateQty
new BigDecimal("9"), //cumulateAmt
new BigDecimal("482.3442"), //cdAmt
new BigDecimal("267.9690"), //cdAdjutment
new BigDecimal("0"), //cdQty
new BigDecimal("5"), //cdCurrentCostPrice
new BigDecimal("53.5938"), //cdCumulateQty
new BigDecimal("4"), //cdCumulateAmt
new BigDecimal("214.3752"), dateAcct);
assertCostMovement(costResult, line.getM_MovementLine_ID(), as, trxName);
}
dateAcct = TimeUtil.addDays(today, 70);
MInventory inventory = createPhisicalInventory(dateAcct, new BigDecimal("20"), costResult.cumulateQty);
for (MInventoryLine line : inventory.getLines(true)) {
costResult = new CostResult(product.getM_Product_ID(), //currentCostPrice
new BigDecimal("42.0488"), // cumulateQty
new BigDecimal("51"), //cumulateAmt
new BigDecimal("2144.4906"), //cdAmt
new BigDecimal("462.5368"), //cdAdjutment
new BigDecimal("0"), //cdQty
new BigDecimal("11"), //cdCurrentCostPrice
new BigDecimal("42.0488"), //cdCumulateQty
new BigDecimal("40"), //cdCumulateAmt
new BigDecimal("1681.9538"), dateAcct);
assertCostPhisicalInventory(costResult, line.getM_InventoryLine_ID(), as, trxName);
break;
}
dateAcct = TimeUtil.addDays(today, 80);
inventory = createInvetoryInternalUse(dateAcct, new BigDecimal("-5"));
for (MInventoryLine line : inventory.getLines(true)) {
costResult = new CostResult(product.getM_Product_ID(), //currentCostPrice
new BigDecimal("42.0488"), // cumulateQty
new BigDecimal("56"), //cumulateAmt
new BigDecimal("2354.7346"), //cdAmt
new BigDecimal("210.2440"), //cdAdjutment
new BigDecimal("0"), //cdQty
new BigDecimal("5"), //cdCurrentCostPrice
new BigDecimal("42.0488"), //cdCumulateQty
new BigDecimal("51"), //cdCumulateAmt
new BigDecimal("2144.4906"), dateAcct);
assertCostPhisicalInventory(costResult, line.getM_InventoryLine_ID(), as, trxName);
;
}
createTrxAndInventoryValuationReport();
}
use of org.compiere.model.MInOutLine in project adempiere by adempiere.
the class InventoryUtil method createInOut.
public static MInOut createInOut(MMDocument doc, String trxName) {
MOrder order;
if (MDocType.DOCBASETYPE_MaterialReceipt.equals(doc.DocBaseType)) {
order = (MOrder) doc.scenario.get(MDocType.DOCBASETYPE_PurchaseOrder, doc.PODocumentNo).document;
} else if (MDocType.DOCBASETYPE_MaterialDelivery.equals(doc.DocBaseType)) {
order = (MOrder) doc.scenario.get(MDocType.DOCBASETYPE_SalesOrder, doc.PODocumentNo).document;
} else {
throw new IllegalArgumentException("DocBaseType not supported - " + doc);
}
// if (trxName != null && trxName.equals(order.get_TrxName()))
// throw new AdempiereException("Internal exception - not same trxName");
MInOut io = new MInOut(order, 0, doc.Date);
setGeneratedTag(io);
io.saveEx();
//
MInOutLine iol = null;
for (MOrderLine oline : order.getLines(true, null)) {
iol = new MInOutLine(io);
iol.setOrderLine(oline, 0, doc.Qty);
iol.setQty(doc.Qty);
iol.saveEx();
break;
}
final boolean checkPrice = (doc.Price != null && doc.Price.signum() != 0);
// Check Receipt Price Match
if (checkPrice && !io.isSOTrx()) {
BigDecimal receiptPrice = iol.getPriceActual();
if (doc.Price.compareTo(receiptPrice) != 0) {
throw new RuntimeException("MMR - Price Not Match - target=" + doc.Price + ", actual=" + iol.getPriceActual());
}
}
//
doc.document = io;
processDocument(doc, MInOut.DOCACTION_Complete, MInOut.DOCSTATUS_Completed);
if (!Util.isEmpty(doc.ASI)) {
iol.load(trxName);
doc.scenario.registerASICode(doc.ASI, iol.getM_AttributeSetInstance_ID(), !io.isSOTrx());
}
checkLineCosts(doc, iol, io.isSOTrx());
return io;
}
use of org.compiere.model.MInOutLine in project adempiere by adempiere.
the class LiberoValidator method updateMPPOrder.
// getAD_Client_ID
private void updateMPPOrder(MInOutLine outline) {
MPPOrder order = null;
BigDecimal qtyShipment = Env.ZERO;
MInOut inout = outline.getParent();
String movementType = inout.getMovementType();
int orderLineId = 0;
if (MInOut.MOVEMENTTYPE_CustomerShipment.equals(movementType)) {
orderLineId = outline.getC_OrderLine_ID();
qtyShipment = outline.getMovementQty();
} else if (MInOut.MOVEMENTTYPE_CustomerReturns.equals(movementType)) {
MRMALine rmaline = new MRMALine(outline.getCtx(), outline.getM_RMALine_ID(), null);
MInOutLine line = (MInOutLine) rmaline.getM_InOutLine();
orderLineId = line.getC_OrderLine_ID();
qtyShipment = outline.getMovementQty().negate();
}
final String whereClause = " C_OrderLine_ID = ? " + " AND DocStatus IN (?,?)" + " AND EXISTS (SELECT 1 FROM PP_Order_BOM " + " WHERE PP_Order_BOM.PP_Order_ID=PP_Order.PP_Order_ID AND PP_Order_BOM.BOMType =? )";
order = new Query(outline.getCtx(), MPPOrder.Table_Name, whereClause, outline.get_TrxName()).setParameters(orderLineId, MPPOrder.DOCSTATUS_InProgress, MPPOrder.DOCSTATUS_Completed, MPPOrderBOM.BOMTYPE_Make_To_Kit).firstOnly();
if (order == null || order.get_ID() <= 0)
return;
if (MPPOrder.DOCSTATUS_InProgress.equals(order.getDocStatus())) {
order.completeIt();
order.setDocStatus(MPPOrder.ACTION_Complete);
order.setDocAction(MPPOrder.DOCACTION_Close);
order.saveEx();
}
if (MPPOrder.DOCSTATUS_Completed.equals(order.getDocStatus())) {
String description = order.getDescription() != null ? order.getDescription() : "" + Msg.translate(inout.getCtx(), MInOut.COLUMNNAME_M_InOut_ID) + " : " + Msg.translate(inout.getCtx(), MInOut.COLUMNNAME_DocumentNo);
order.setDescription(description);
order.updateMakeToKit(qtyShipment);
order.saveEx();
}
if (order.getQtyToDeliver().signum() == 0) {
order.closeIt();
order.setDocStatus(MPPOrder.DOCACTION_Close);
order.setDocAction(MPPOrder.DOCACTION_None);
order.saveEx();
}
return;
}
use of org.compiere.model.MInOutLine in project adempiere by adempiere.
the class CostEngine method createCostDetail.
/**
* Create Cost Detail
* @param accountSchema Account Schema
* @param transaction Material Transaction
* @param model IDocumentLine
* @param costType Cost Type
* @param costElement Cost Element
*/
public void createCostDetail(MAcctSchema accountSchema, MCostType costType, MCostElement costElement, MTransaction transaction, IDocumentLine model, boolean force) {
if (!force)
return;
BigDecimal costThisLevel = Env.ZERO;
BigDecimal costLowLevel = Env.ZERO;
String costingLevel = MProduct.get(transaction.getCtx(), transaction.getM_Product_ID()).getCostingLevel(accountSchema, transaction.getAD_Org_ID());
// adjustment for Average PO Costing method
if (model instanceof MMatchInv && MCostType.COSTINGMETHOD_AveragePO.equals(costType.getCostingMethod()))
return;
// adjustment for Average PO Costing method
if (model instanceof MMatchPO && MCostType.COSTINGMETHOD_AverageInvoice.equals(costType.getCostingMethod()))
return;
if (model instanceof MLandedCostAllocation) {
MLandedCostAllocation allocation = (MLandedCostAllocation) model;
costThisLevel = convertCostToSchemaCurrency(accountSchema, model, model.getPriceActualCurrency());
}
MCost cost = MCost.validateCostForCostType(accountSchema, costType, costElement, transaction.getM_Product_ID(), transaction.getAD_Org_ID(), transaction.getM_Warehouse_ID(), transaction.getM_AttributeSetInstance_ID(), transaction.get_TrxName());
// get the cost for positive transaction
if ((MCostElement.COSTELEMENTTYPE_Material.equals(costElement.getCostElementType()) || MCostElement.COSTELEMENTTYPE_LandedCost.equals(costElement.getCostElementType())) && transaction.getMovementType().contains("+") && !MCostType.COSTINGMETHOD_StandardCosting.equals(costType.getCostingMethod())) {
if (model instanceof MMovementLine || model instanceof MInventoryLine || (model instanceof MInOutLine && MTransaction.MOVEMENTTYPE_CustomerReturns.equals(transaction.getMovementType()))) {
costThisLevel = getCostThisLevel(accountSchema, costType, costElement, transaction, model, costingLevel);
if (model instanceof MInventoryLine) {
MInventoryLine inventoryLine = (MInventoryLine) model;
// try get cost from physical inventory
if (costThisLevel.signum() == 0 && MCostElement.COSTELEMENTTYPE_Material.equals(costElement.getCostElementType())) {
// Use the current cost only for Physical Inventory
if (inventoryLine.getQtyInternalUse().signum() == 0 && inventoryLine.getCurrentCostPrice() != null && inventoryLine.getCurrentCostPrice().signum() > 0) {
costThisLevel = convertCostToSchemaCurrency(accountSchema, model, model.getPriceActualCurrency());
}
if (costThisLevel.signum() == 0)
costThisLevel = getCostThisLevel(accountSchema, costType, costElement, transaction, model, costingLevel);
}
costLowLevel = getCostLowLevel(accountSchema, costType, costElement, transaction, model, costingLevel);
// try get cost low level from physical inventory
if (costLowLevel.signum() == 0 && MCostElement.COSTELEMENTTYPE_Material.equals(costElement.getCostElementType())) {
// Use the current cost only for Physical Inventory
if (inventoryLine.getQtyInternalUse().signum() == 0 && inventoryLine.getCurrentCostPriceLL() != null && inventoryLine.getCurrentCostPriceLL().signum() > 0) {
costLowLevel = convertCostToSchemaCurrency(accountSchema, model, inventoryLine.getCurrentCostPriceLL());
}
if (costLowLevel.signum() == 0)
costLowLevel = getCostLowLevel(accountSchema, costType, costElement, transaction, model, costingLevel);
}
}
//Get cost from movement from if it > that zero replace cost This Level
if (model instanceof MMovementLine) {
MTransaction transactionFrom = MTransaction.getByDocumentLine(model, MTransaction.MOVEMENTTYPE_MovementFrom);
BigDecimal costMovementFrom = getCostThisLevel(accountSchema, costType, costElement, transactionFrom == null ? transaction : transactionFrom, model, costingLevel);
if (costMovementFrom.signum() > 0)
costThisLevel = costMovementFrom;
BigDecimal costMovementFromLL = getCostLowLevel(accountSchema, costType, costElement, transactionFrom == null ? transaction : transactionFrom, model, costingLevel);
if (costMovementFromLL.signum() > 0)
costLowLevel = costMovementFromLL;
}
} else if (MCostElement.COSTELEMENTTYPE_Material.equals(costElement.getCostElementType())) {
costThisLevel = convertCostToSchemaCurrency(accountSchema, model, model.getPriceActualCurrency());
}
}
if (!MCostType.COSTINGMETHOD_StandardCosting.equals(costType.getCostingMethod())) {
if (model instanceof MPPCostCollector) {
MPPCostCollector costCollector = (MPPCostCollector) model;
if (MPPCostCollector.COSTCOLLECTORTYPE_MaterialReceipt.equals(costCollector.getCostCollectorType())) {
// get Actual Cost for Cost Type and Cost Element
costThisLevel = getCostThisLevel(accountSchema, costType, costElement, transaction, model, costingLevel);
costLowLevel = CostEngine.getParentActualCostByCostType(accountSchema, costType.getM_CostType_ID(), costElement.getM_CostElement_ID(), costCollector);
}
}
if (model instanceof MProductionLine) {
MProductionLine productionLine = (MProductionLine) model;
if (productionLine.isParent())
costThisLevel = CostEngine.getParentActualCostByCostType(accountSchema, costType, costElement, productionLine.getM_Production());
if (costThisLevel.signum() == 0)
costThisLevel = cost.getCurrentCostPrice();
if (costThisLevel.signum() == 0 && MCostElement.COSTELEMENTTYPE_Material.equals(costElement.getCostElementType()))
costThisLevel = getSeedCost(transaction.getCtx(), transaction.getM_Product_ID(), transaction.get_TrxName());
// Material Receipt for Production light
if (productionLine.isParent()) {
// if the product is purchase then no use low level
if (!productionLine.getM_Product().isPurchased()) {
costLowLevel = costThisLevel;
costThisLevel = Env.ZERO;
}
} else if (productionLine.getMovementQty().signum() < 0)
costLowLevel = Env.ZERO;
}
} else if (MCostType.COSTINGMETHOD_StandardCosting.equals(costType.getCostingMethod())) {
costThisLevel = cost.getCurrentCostPrice();
costLowLevel = cost.getCurrentCostPriceLL();
//Define Cost Inventory Line
if (model instanceof MInventoryLine) {
MInventoryLine inventoryLine = (MInventoryLine) model;
//Define Current Cost Level
if (costThisLevel.signum() == 0 && MCostElement.COSTELEMENTTYPE_Material.equals(costElement.getCostElementType())) {
// Use the current cost only for Physical Inventory
if (inventoryLine.getQtyInternalUse().signum() == 0 && inventoryLine.getCurrentCostPrice() != null && inventoryLine.getCurrentCostPrice().signum() > 0) {
costThisLevel = convertCostToSchemaCurrency(accountSchema, model, model.getPriceActualCurrency());
cost.setCurrentCostPrice(costThisLevel);
cost.saveEx();
}
if (costThisLevel.signum() == 0)
costThisLevel = getCostThisLevel(accountSchema, costType, costElement, transaction, model, costingLevel);
}
//Define Current Cost Low Level
if (costLowLevel.signum() == 0 && MCostElement.COSTELEMENTTYPE_Material.equals(costElement.getCostElementType())) {
// Use the cost only for Physical Inventory
if (inventoryLine.getQtyInternalUse().signum() == 0 && inventoryLine.getCurrentCostPriceLL() != null && inventoryLine.getCurrentCostPriceLL().signum() > 0) {
costLowLevel = convertCostToSchemaCurrency(accountSchema, model, inventoryLine.getCurrentCostPriceLL());
cost.setCurrentCostPriceLL(costLowLevel);
cost.saveEx();
}
if (costLowLevel.signum() == 0)
costLowLevel = getCostLowLevel(accountSchema, costType, costElement, transaction, model, costingLevel);
}
}
if (model instanceof MMovementLine) {
MTransaction transactionFrom = MTransaction.getByDocumentLine(model, MTransaction.MOVEMENTTYPE_MovementFrom);
BigDecimal costMovementFrom = getCostThisLevel(accountSchema, costType, costElement, transactionFrom == null ? transaction : transactionFrom, model, costingLevel);
if (costThisLevel.signum() == 0 && MCostElement.COSTELEMENTTYPE_Material.equals(costElement.getCostElementType())) {
if (costMovementFrom.signum() > 0)
costThisLevel = costMovementFrom;
}
if (costLowLevel.signum() == 0 && MCostElement.COSTELEMENTTYPE_Material.equals(costElement.getCostElementType())) {
BigDecimal costMovementFromLL = getCostLowLevel(accountSchema, costType, costElement, transactionFrom == null ? transaction : transactionFrom, model, costingLevel);
if (costMovementFromLL.signum() > 0)
costLowLevel = costMovementFromLL;
}
}
if (costThisLevel.signum() == 0 && MCostElement.COSTELEMENTTYPE_Material.equals(costElement.getCostElementType())) {
costThisLevel = getSeedCost(transaction.getCtx(), transaction.getM_Product_ID(), transaction.get_TrxName());
if (costThisLevel.signum() == 0)
if (model instanceof MInOutLine && !model.isSOTrx()) {
costThisLevel = convertCostToSchemaCurrency(accountSchema, model, model.getPriceActualCurrency());
}
if (costThisLevel.signum() != 0) {
cost.setCurrentCostPrice(costThisLevel);
cost.saveEx();
}
}
if (costLowLevel.signum() != 0) {
cost.setCurrentCostPriceLL(costLowLevel);
cost.saveEx();
}
}
final ICostingMethod method = CostingMethodFactory.get().getCostingMethod(costType.getCostingMethod());
method.setCostingMethod(accountSchema, transaction, model, cost, costThisLevel, costLowLevel, model.isSOTrx());
method.process();
}
use of org.compiere.model.MInOutLine in project adempiere by adempiere.
the class CostEngine method createCostDetailForLandedCostAllocation.
//Create cost detail for by document
public void createCostDetailForLandedCostAllocation(MLandedCostAllocation allocation) {
MInOutLine ioLine = (MInOutLine) allocation.getM_InOutLine();
for (MTransaction transaction : MTransaction.getByInOutLine(ioLine)) {
for (MAcctSchema accountSchema : MAcctSchema.getClientAcctSchema(allocation.getCtx(), allocation.getAD_Client_ID())) {
List<MCostType> costTypes = MCostType.get(allocation.getCtx(), allocation.get_TrxName());
for (MCostType costType : costTypes) {
MCostElement costElement = (MCostElement) allocation.getM_CostElement();
CostEngineFactory.getCostEngine(allocation.getAD_Client_ID()).createCostDetail(accountSchema, costType, costElement, transaction, allocation, true);
}
}
}
}
Aggregations