public final void makePaymentMatchingReversed(
    final Map<String, Object> pReqVars, final String pPayId,
      final BankStatementLine pBsl, final DateFormat pDateFormat,
        final String pLangDef) throws Exception {
    EBankEntryResultType resultRecordType = null;
    EBankEntryResultAction resultAction = null;
    String resultDescription = null;
    Long resultRecordId = null;
    if (pBsl.getItsAmount().compareTo(BigDecimal.ZERO) > 0) {
      PaymentFrom pay = getSrvOrm().retrieveEntityById(pReqVars,
        PaymentFrom.class, Long.parseLong(pPayId));
      if (!pay.getHasMadeAccEntries() || pBsl.getItsAmount().abs()
        .compareTo(pay.getItsTotal()) != 0
          || pay.getSubaccCashType() != 2002 || !pBsl.getItsOwner()
            .getBankAccount().getItsId().equals(pay.getSubaccCashId())) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "record_is_not_matching");
      }
      resultRecordType = EBankEntryResultType.PAYMENTFROM;
      if (EBankEntryStatus.VOIDED.equals(pBsl.getItsStatus())
        && pay.getReversedId() == null) {
        resultAction = EBankEntryResultAction.CREATE;
        PaymentFrom reversed = pay;
        pay = new PaymentFrom();
        pay.setAccCash(reversed.getAccCash());
        pay.setSubaccCash(reversed.getSubaccCash());
        pay.setSubaccCashId(reversed.getSubaccCashId());
        pay.setSubaccCashType(2002);
        pay.setSalesInvoice(reversed.getSalesInvoice());
        pay.setForeignTotal(reversed.getForeignTotal().negate());
        pay.setDescription(makeDescrForCreated(pBsl, pDateFormat, pLangDef)
          + " " + getSrvI18n().getMsg("reversed_n", pLangDef) + reversed
            .getIdDatabaseBirth() + "-" + reversed.getItsId());
        makeDocReversed(pReqVars, pay, reversed, pLangDef);
      } else {
        resultAction = EBankEntryResultAction.MATCH;
      }
      resultRecordId = pay.getItsId();
      resultDescription = makeBslResDescr(resultAction, pDateFormat, pay,
        pay.getItsDate(), pLangDef);
    } else {
      PaymentTo pay = getSrvOrm().retrieveEntityById(pReqVars,
        PaymentTo.class, Long.parseLong(pPayId));
      if (!pay.getHasMadeAccEntries() || pBsl.getItsAmount().abs()
        .compareTo(pay.getItsTotal()) != 0
          || pay.getSubaccCashType() != 2002 || !pBsl.getItsOwner()
            .getBankAccount().getItsId().equals(pay.getSubaccCashId())) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "record_is_not_matching");
      }
      resultRecordType = EBankEntryResultType.PAYMENTTO;
      if (EBankEntryStatus.VOIDED.equals(pBsl.getItsStatus())
        && pay.getReversedId() == null) {
        resultAction = EBankEntryResultAction.CREATE;
        PaymentTo reversed = pay;
        pay = new PaymentTo();
        pay.setAccCash(reversed.getAccCash());
        pay.setSubaccCash(reversed.getSubaccCash());
        pay.setSubaccCashId(reversed.getSubaccCashId());
        pay.setSubaccCashType(2002);
        pay.setPurchaseInvoice(reversed.getPurchaseInvoice());
        pay.setForeignTotal(reversed.getForeignTotal().negate());
        pay.setDescription(makeDescrForCreated(pBsl, pDateFormat, pLangDef)
          + " " + getSrvI18n().getMsg("reversed_n", pLangDef) + reversed
            .getIdDatabaseBirth() + "-" + reversed.getItsId());
        makeDocReversed(pReqVars, pay, reversed, pLangDef);
      } else {
        resultAction = EBankEntryResultAction.MATCH;
      }
      resultRecordId = pay.getItsId();
      resultDescription = makeBslResDescr(resultAction, pDateFormat, pay,
        pay.getItsDate(), pLangDef);
    }
    pBsl.setResultAction(resultAction);
    pBsl.setResultRecordType(resultRecordType);
    pBsl.setResultRecordId(resultRecordId);
    pBsl.setResultDescription(resultDescription);
    getSrvOrm().updateEntity(pReqVars, pBsl);
  }
public final void makePaymentMatchingReversed ( final Map < String , Object > pReqVars , final String pPayId , final BankStatementLine pBsl , final DateFormat pDateFormat , final String pLangDef ) throws Exception { EBankEntryResultType resultRecordType = null ; EBankEntryResultAction resultAction = null ; String resultDescription = null ; Long resultRecordId = null ; if ( pBsl . getItsAmount ( ) . compareTo ( BigDecimal . ZERO ) > 0 ) { PaymentFrom pay = getSrvOrm ( ) . retrieveEntityById ( pReqVars , PaymentFrom . class , Long . parseLong ( pPayId ) ) ; if ( ! pay . getHasMadeAccEntries ( ) || pBsl . getItsAmount ( ) . abs ( ) . compareTo ( pay . getItsTotal ( ) ) != 0 || pay . getSubaccCashType ( ) != 2002 || ! pBsl . getItsOwner ( ) . getBankAccount ( ) . getItsId ( ) . equals ( pay . getSubaccCashId ( ) ) ) { throw new ExceptionWithCode ( ExceptionWithCode . WRONG_PARAMETER , "record_is_not_matching" ) ; } resultRecordType = EBankEntryResultType . PAYMENTFROM ; if ( EBankEntryStatus . VOIDED . equals ( pBsl . getItsStatus ( ) ) && pay . getReversedId ( ) == null ) { resultAction = EBankEntryResultAction . CREATE ; PaymentFrom reversed = pay ; pay = new PaymentFrom ( ) ; pay . setAccCash ( reversed . getAccCash ( ) ) ; pay . setSubaccCash ( reversed . getSubaccCash ( ) ) ; pay . setSubaccCashId ( reversed . getSubaccCashId ( ) ) ; pay . setSubaccCashType ( 2002 ) ; pay . setSalesInvoice ( reversed . getSalesInvoice ( ) ) ; pay . setForeignTotal ( reversed . getForeignTotal ( ) . negate ( ) ) ; pay . setDescription ( makeDescrForCreated ( pBsl , pDateFormat , pLangDef ) + " " + getSrvI18n ( ) . getMsg ( "reversed_n" , pLangDef ) + reversed . getIdDatabaseBirth ( ) + "-" + reversed . getItsId ( ) ) ; makeDocReversed ( pReqVars , pay , reversed , pLangDef ) ; } else { resultAction = EBankEntryResultAction . MATCH ; } resultRecordId = pay . getItsId ( ) ; resultDescription = makeBslResDescr ( resultAction , pDateFormat , pay , pay . getItsDate ( ) , pLangDef ) ; } else { PaymentTo pay = getSrvOrm ( ) . retrieveEntityById ( pReqVars , PaymentTo . class , Long . parseLong ( pPayId ) ) ; if ( ! pay . getHasMadeAccEntries ( ) || pBsl . getItsAmount ( ) . abs ( ) . compareTo ( pay . getItsTotal ( ) ) != 0 || pay . getSubaccCashType ( ) != 2002 || ! pBsl . getItsOwner ( ) . getBankAccount ( ) . getItsId ( ) . equals ( pay . getSubaccCashId ( ) ) ) { throw new ExceptionWithCode ( ExceptionWithCode . WRONG_PARAMETER , "record_is_not_matching" ) ; } resultRecordType = EBankEntryResultType . PAYMENTTO ; if ( EBankEntryStatus . VOIDED . equals ( pBsl . getItsStatus ( ) ) && pay . getReversedId ( ) == null ) { resultAction = EBankEntryResultAction . CREATE ; PaymentTo reversed = pay ; pay = new PaymentTo ( ) ; pay . setAccCash ( reversed . getAccCash ( ) ) ; pay . setSubaccCash ( reversed . getSubaccCash ( ) ) ; pay . setSubaccCashId ( reversed . getSubaccCashId ( ) ) ; pay . setSubaccCashType ( 2002 ) ; pay . setPurchaseInvoice ( reversed . getPurchaseInvoice ( ) ) ; pay . setForeignTotal ( reversed . getForeignTotal ( ) . negate ( ) ) ; pay . setDescription ( makeDescrForCreated ( pBsl , pDateFormat , pLangDef ) + " " + getSrvI18n ( ) . getMsg ( "reversed_n" , pLangDef ) + reversed . getIdDatabaseBirth ( ) + "-" + reversed . getItsId ( ) ) ; makeDocReversed ( pReqVars , pay , reversed , pLangDef ) ; } else { resultAction = EBankEntryResultAction . MATCH ; } resultRecordId = pay . getItsId ( ) ; resultDescription = makeBslResDescr ( resultAction , pDateFormat , pay , pay . getItsDate ( ) , pLangDef ) ; } pBsl . setResultAction ( resultAction ) ; pBsl . setResultRecordType ( resultRecordType ) ; pBsl . setResultRecordId ( resultRecordId ) ; pBsl . setResultDescription ( resultDescription ) ; getSrvOrm ( ) . updateEntity ( pReqVars , pBsl ) ; }
<p>Makes payment matching or reversed.</p>
@param pReqVars additional param
@param pPayId Payment Id
@param pBsl BSL
@param pDateFormat Date Formatter
@param pLangDef language
@throws Exception - an exception