/**
   * Reverse current allocation (another allocation is produced) NOTE: this method is not saving
   * current object's modifications
   *
   * @see
   *     http://dewiki908/mediawiki/index.php/02181:_Verbuchungsfehler_bei_Zuordnungen_%282011092910000015%29
   */
  private void reverseCorrectIt0() {
    MAllocationHdr reversal = new MAllocationHdr(getCtx(), 0, get_TrxName());
    copyValues(this, reversal);

    //
    // 07570: Keep AD_Org of original document
    reversal.setAD_Org_ID(this.getAD_Org_ID());

    reversal.setDocumentNo(""); // let it generate a new document#
    reversal.setProcessing(false);
    reversal.setProcessed(false);
    reversal.setDocStatus(DOCSTATUS_Drafted);
    reversal.setDocAction(DOCACTION_Complete);
    reversal.setPosted(false);
    reversal.setReversal_ID(this.getC_AllocationHdr_ID());
    reversal.saveEx();

    this.setReversal_ID(reversal.getC_AllocationHdr_ID());
    saveEx();

    for (MAllocationLine line : this.getLines(true)) {
      MAllocationLine reversalLine = new MAllocationLine(reversal);
      MAllocationLine.copyValues(line, reversalLine);

      //
      // 07570: Keep AD_Org of original document
      reversalLine.setAD_Org_ID(line.getAD_Org_ID());

      reversalLine.setC_AllocationHdr_ID(reversal.getC_AllocationHdr_ID());
      reversalLine.setAmount(reversalLine.getAmount().negate());
      reversalLine.setDiscountAmt(reversalLine.getDiscountAmt().negate());
      reversalLine.setOverUnderAmt(reversalLine.getOverUnderAmt().negate());
      reversalLine.setWriteOffAmt(reversalLine.getWriteOffAmt().negate());
      reversalLine.setReversalLine_ID(line.getC_AllocationLine_ID());
      reversalLine.saveEx();

      line.setReversalLine_ID(reversalLine.getC_AllocationLine_ID());
      line.saveEx();
    }

    if (!reversal.processIt(DOCACTION_Complete)) {
      throw new AdempiereException(reversal.getProcessMsg());
    }
    reversal.setDocStatus(DOCSTATUS_Reversed);
    reversal.setDocAction(DOCACTION_None);
    reversal.saveEx();

    this.setDocStatus(DOCSTATUS_Reversed);
    this.setDocAction(DOCACTION_None);
  }