@Override
  public final PurchaseReturnTaxLine process(
    final Map<String, Object> pReqVars,
      final PurchaseReturnTaxLine pEntity,
        final IRequestData pRequestData) throws Exception {
    if (pEntity.getItsTotal().compareTo(BigDecimal.ZERO) <= 0) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "total_less_or_eq_zero");
    }
    // Beige-Orm refresh:
    pReqVars.put("PurchaseInvoicevendordeepLevel", 3);
    Set<String> ndFlDc = new HashSet<String>();
    ndFlDc.add("itsId");
    ndFlDc.add("isForeigner");
    ndFlDc.add("taxDestination");
    pReqVars.put("DebtorCreditorneededFields", ndFlDc);
    Set<String> ndFlInv = new HashSet<String>();
    ndFlInv.add("itsId");
    ndFlInv.add("vendor");
    ndFlInv.add("omitTaxes");
    ndFlInv.add("priceIncTax");
    ndFlInv.add("exchangeRate");
    ndFlInv.add("foreignCurrency");
    ndFlInv.add("hasMadeAccEntries");
    pReqVars.put("PurchaseInvoiceneededFields", ndFlInv);
    pEntity.setItsOwner(getSrvOrm()
      .retrieveEntity(pReqVars, pEntity.getItsOwner()));
    pReqVars.remove("DebtorCreditorneededFields");
    pReqVars.remove("PurchaseInvoiceneededFields");
    pReqVars.remove("PurchaseInvoicevendordeepLevel");
    AccSettings as = getSrvAccSettings().lazyGetAccSettings(pReqVars);
    TaxDestination txRules = this.utlInvLine.revealTaxRules(pReqVars,
      pEntity.getItsOwner(), as, as.getIsExtractSalesTaxFromPurchase());
    if (txRules == null) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "non_taxable");
    }
    if (!txRules.getSalTaxIsInvoiceBase()) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "cant_edit_item_basis_tax");
    }
    PurchaseReturnTaxLine oldEntity = getSrvOrm()
      .retrieveEntity(pReqVars, pEntity);
    pEntity.setTax(oldEntity.getTax());
    pEntity.setTaxableInvBas(oldEntity.getTaxableInvBas());
    pEntity.setTaxableInvBasFc(oldEntity.getTaxableInvBasFc());
    //rounding:
    pEntity.setItsTotal(pEntity.getItsTotal().setScale(as
      .getPricePrecision(), txRules.getSalTaxRoundMode()));
    if (pEntity.getItsOwner().getForeignCurrency() != null) {
      BigDecimal exchRate = pEntity.getItsOwner().getExchangeRate();
      if (exchRate.compareTo(BigDecimal.ZERO) == -1) {
        exchRate = BigDecimal.ONE.divide(exchRate.negate(), 15,
          RoundingMode.HALF_UP);
      }
      pEntity.setForeignTotalTaxes(pEntity.getItsTotal()
        .divide(exchRate, as.getPricePrecision(), as.getRoundingMode()));
    }
    if (pEntity.getItsTotal().compareTo(oldEntity.getItsTotal()) != 0) {
      if (pEntity.getItsOwner().getDescription() == null) {
        pEntity.getItsOwner().setDescription(pEntity.getTax().getItsName()
         + ": " + oldEntity.getItsTotal() + "->" + pEntity.getItsTotal() + "!");
      } else {
        pEntity.getItsOwner().setDescription(pEntity.getItsOwner()
          .getDescription() + " " + pEntity.getTax().getItsName()
            + ": " + oldEntity.getItsTotal() + "->"
              + pEntity.getItsTotal() + "!");
      }
    }
    getSrvOrm().updateEntity(pReqVars, pEntity);
    // optimistic locking (dirty check):
    Long ownerVersion = Long.valueOf(pRequestData.getParameter(pEntity
      .getItsOwner().getClass().getSimpleName() + ".ownerVersion"));
    pEntity.getItsOwner().setItsVersion(ownerVersion);
    this.utlInvLine.adjInvLnsUpdTots(pReqVars, pEntity.getItsOwner(), as,
      txRules);
    pReqVars.put("nextEntity", pEntity.getItsOwner());
    pReqVars.put("nameOwnerEntity", pEntity.getItsOwner().getClass()
      .getSimpleName());
    return null;
  }
@ Override public final PurchaseReturnTaxLine process ( final Map < String , Object > pReqVars , final PurchaseReturnTaxLine pEntity , final IRequestData pRequestData ) throws Exception { if ( pEntity . getItsTotal ( ) . compareTo ( BigDecimal . ZERO ) <= 0 ) { throw new ExceptionWithCode ( ExceptionWithCode . WRONG_PARAMETER , "total_less_or_eq_zero" ) ; } pReqVars . put ( "PurchaseInvoicevendordeepLevel" , 3 ) ; Set < String > ndFlDc = new HashSet < String > ( ) ; ndFlDc . add ( "itsId" ) ; ndFlDc . add ( "isForeigner" ) ; ndFlDc . add ( "taxDestination" ) ; pReqVars . put ( "DebtorCreditorneededFields" , ndFlDc ) ; Set < String > ndFlInv = new HashSet < String > ( ) ; ndFlInv . add ( "itsId" ) ; ndFlInv . add ( "vendor" ) ; ndFlInv . add ( "omitTaxes" ) ; ndFlInv . add ( "priceIncTax" ) ; ndFlInv . add ( "exchangeRate" ) ; ndFlInv . add ( "foreignCurrency" ) ; ndFlInv . add ( "hasMadeAccEntries" ) ; pReqVars . put ( "PurchaseInvoiceneededFields" , ndFlInv ) ; pEntity . setItsOwner ( getSrvOrm ( ) . retrieveEntity ( pReqVars , pEntity . getItsOwner ( ) ) ) ; pReqVars . remove ( "DebtorCreditorneededFields" ) ; pReqVars . remove ( "PurchaseInvoiceneededFields" ) ; pReqVars . remove ( "PurchaseInvoicevendordeepLevel" ) ; AccSettings as = getSrvAccSettings ( ) . lazyGetAccSettings ( pReqVars ) ; TaxDestination txRules = this . utlInvLine . revealTaxRules ( pReqVars , pEntity . getItsOwner ( ) , as , as . getIsExtractSalesTaxFromPurchase ( ) ) ; if ( txRules == null ) { throw new ExceptionWithCode ( ExceptionWithCode . WRONG_PARAMETER , "non_taxable" ) ; } if ( ! txRules . getSalTaxIsInvoiceBase ( ) ) { throw new ExceptionWithCode ( ExceptionWithCode . WRONG_PARAMETER , "cant_edit_item_basis_tax" ) ; } PurchaseReturnTaxLine oldEntity = getSrvOrm ( ) . retrieveEntity ( pReqVars , pEntity ) ; pEntity . setTax ( oldEntity . getTax ( ) ) ; pEntity . setTaxableInvBas ( oldEntity . getTaxableInvBas ( ) ) ; pEntity . setTaxableInvBasFc ( oldEntity . getTaxableInvBasFc ( ) ) ; pEntity . setItsTotal ( pEntity . getItsTotal ( ) . setScale ( as . getPricePrecision ( ) , txRules . getSalTaxRoundMode ( ) ) ) ; if ( pEntity . getItsOwner ( ) . getForeignCurrency ( ) != null ) { BigDecimal exchRate = pEntity . getItsOwner ( ) . getExchangeRate ( ) ; if ( exchRate . compareTo ( BigDecimal . ZERO ) == - 1 ) { exchRate = BigDecimal . ONE . divide ( exchRate . negate ( ) , 15 , RoundingMode . HALF_UP ) ; } pEntity . setForeignTotalTaxes ( pEntity . getItsTotal ( ) . divide ( exchRate , as . getPricePrecision ( ) , as . getRoundingMode ( ) ) ) ; } if ( pEntity . getItsTotal ( ) . compareTo ( oldEntity . getItsTotal ( ) ) != 0 ) { if ( pEntity . getItsOwner ( ) . getDescription ( ) == null ) { pEntity . getItsOwner ( ) . setDescription ( pEntity . getTax ( ) . getItsName ( ) + ": " + oldEntity . getItsTotal ( ) + "->" + pEntity . getItsTotal ( ) + "!" ) ; } else { pEntity . getItsOwner ( ) . setDescription ( pEntity . getItsOwner ( ) . getDescription ( ) + " " + pEntity . getTax ( ) . getItsName ( ) + ": " + oldEntity . getItsTotal ( ) + "->" + pEntity . getItsTotal ( ) + "!" ) ; } } getSrvOrm ( ) . updateEntity ( pReqVars , pEntity ) ; Long ownerVersion = Long . valueOf ( pRequestData . getParameter ( pEntity . getItsOwner ( ) . getClass ( ) . getSimpleName ( ) + ".ownerVersion" ) ) ; pEntity . getItsOwner ( ) . setItsVersion ( ownerVersion ) ; this . utlInvLine . adjInvLnsUpdTots ( pReqVars , pEntity . getItsOwner ( ) , as , txRules ) ; pReqVars . put ( "nextEntity" , pEntity . getItsOwner ( ) ) ; pReqVars . put ( "nameOwnerEntity" , pEntity . getItsOwner ( ) . getClass ( ) . getSimpleName ( ) ) ; return null ; }
<p>Process entity request.</p>
@param pReqVars additional param, e.g. return this line's
document in "nextEntity" for farther process
@param pRequestData Request Data
@param pEntity Entity to process
@return Entity processed for farther process or null
@throws Exception - an exception