Пример #1
0
  @Override
  public void setTaxAmtInfo(
      final Properties ctx, final I_C_InvoiceLine il, final String getTrxName) {
    final IInvoiceBL invoiceBL = Services.get(IInvoiceBL.class);
    final ITaxBL taxBL = Services.get(ITaxBL.class);

    final int taxId = il.getC_Tax_ID();

    final boolean taxIncluded = invoiceBL.isTaxIncluded(il);
    final BigDecimal lineNetAmt = il.getLineNetAmt();
    final int taxPrecision = invoiceBL.getPrecision(il);

    final I_C_Tax tax = MTax.get(ctx, taxId);
    final BigDecimal taxAmtInfo = taxBL.calculateTax(tax, lineNetAmt, taxIncluded, taxPrecision);

    il.setTaxAmtInfo(taxAmtInfo);
  }
Пример #2
0
  /** Calculate Extended Amt. May or may not include tax */
  public void setLineNetAmt() {
    BigDecimal bd = getPriceActual().multiply(getQtyOrdered());
    // metas: tsa: begin: 01459
    // Line Net Amt shall be zero if the line is not active
    if (!isActive()) {
      bd = Env.ZERO;
    }
    // metas: tsa: end: 01459

    final boolean documentLevel = getTax().isDocumentLevel();
    final boolean isTaxIncluded = Services.get(IOrderLineBL.class).isTaxIncluded(this);
    final int taxPrecision = Services.get(IOrderLineBL.class).getPrecision(this);

    // juddm: Tax Exempt & Tax Included in Price List & not Document Level - Adjust Line Amount
    // http://sourceforge.net/tracker/index.php?func=detail&aid=1733602&group_id=176962&atid=879332
    if (isTaxIncluded && !documentLevel) {
      BigDecimal taxStdAmt = Env.ZERO, taxThisAmt = Env.ZERO;

      MTax orderTax = getTax();
      MTax stdTax = null;

      // get the standard tax
      if (getProduct() == null) {
        if (getCharge() != null) // Charge
        {
          stdTax =
              new MTax(
                  getCtx(),
                  ((MTaxCategory) getCharge().getC_TaxCategory()).getDefaultTax().getC_Tax_ID(),
                  get_TrxName());
        }
      } else
      // Product
      {
        // FIXME metas 05129 need proper concept (link between M_Product and C_TaxCategory_ID was
        // removed!!!!!)
        throw new AdempiereException(
            "Unsupported tax calculation when tax is included, but it's not on document level");
        // stdTax = new MTax (getCtx(),
        // ((MTaxCategory) getProduct().getC_TaxCategory()).getDefaultTax().getC_Tax_ID(),
        // get_TrxName());
      }

      if (stdTax != null) {
        log.debug("stdTax rate is " + stdTax.getRate());
        log.debug("orderTax rate is " + orderTax.getRate());

        final ITaxBL taxBL = Services.get(ITaxBL.class);
        taxThisAmt = taxThisAmt.add(taxBL.calculateTax(orderTax, bd, isTaxIncluded, taxPrecision));
        taxStdAmt = taxStdAmt.add(taxBL.calculateTax(stdTax, bd, isTaxIncluded, taxPrecision));

        bd = bd.subtract(taxStdAmt).add(taxThisAmt);

        log.debug(
            "Price List includes Tax and Tax Changed on Order Line: New Tax Amt: "
                + taxThisAmt
                + " Standard Tax Amt: "
                + taxStdAmt
                + " Line Net Amt: "
                + bd);
      }
    }

    if (bd.scale() > taxPrecision) bd = bd.setScale(taxPrecision, BigDecimal.ROUND_HALF_UP);
    super.setLineNetAmt(bd);
  } // setLineNetAmt