Skip to content

Commit

Permalink
IDEMPIERE-3040 Invoice Price Variations for Average PO costing method (
Browse files Browse the repository at this point in the history
…idempiere#2428)

* IDEMPIERE-3040 Invoice Price Variations for Average PO costing method

Co-authored-by: dpansheriya <[email protected]>
  • Loading branch information
hengsin and dpansheriya authored Aug 27, 2024
1 parent f2b9382 commit eb0d4c2
Show file tree
Hide file tree
Showing 18 changed files with 5,363 additions and 936 deletions.
18 changes: 18 additions & 0 deletions org.adempiere.base/src/org/compiere/acct/Doc_AllocationHdr.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,24 @@ public ArrayList<Fact> createFacts (MAcctSchema as)
invGainLossFactLines = new ArrayList<FactLine>();
payGainLossFactLines = new ArrayList<FactLine>();

// Do not create fact lines for reversal of invoice
if (p_lines.length == 2)
{
DocLine_Allocation line1 = (DocLine_Allocation)p_lines[0];
DocLine_Allocation line2 = (DocLine_Allocation)p_lines[1];
if (line1.getC_Payment_ID() == 0 && line1.getC_Order_ID() == 0 && line1.getC_CashLine_ID() == 0 && line1.getC_Invoice_ID() > 0
&& line2.getC_Payment_ID() == 0 && line2.getC_Order_ID() == 0 && line2.getC_CashLine_ID() == 0 && line2.getC_Invoice_ID() > 0)
{
MInvoice invoice1 = new MInvoice(Env.getCtx(), line1.getC_Invoice_ID(), getTrxName());
MInvoice invoice2 = new MInvoice(Env.getCtx(), line2.getC_Invoice_ID(), getTrxName());
if (invoice1.getGrandTotal().equals(invoice2.getGrandTotal().negate())
&& invoice2.getReversal_ID() == invoice1.getC_Invoice_ID())
{
return m_facts;
}
}
}

// create Fact Header
Fact fact = new Fact(this, as, Fact.POST_Actual);
Fact factForRGL = new Fact(this, as, Fact.POST_Actual); // dummy fact (not posted) to calculate Realized Gain & Loss
Expand Down
Loading

0 comments on commit eb0d4c2

Please sign in to comment.