Search in sources :

Example 1 with TaxLine

use of com.axelor.apps.account.db.TaxLine in project axelor-open-suite by axelor.

the class SaleOrderLineController method updateInTaxPrice.

/**
 * Update the in. tax unit price of an invoice line from its ex. tax unit price.
 *
 * @param request
 * @param response
 */
public void updateInTaxPrice(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
    try {
        BigDecimal exTaxPrice = saleOrderLine.getPrice();
        TaxLine taxLine = saleOrderLine.getTaxLine();
        response.setValue("inTaxPrice", Beans.get(SaleOrderLineService.class).convertUnitPrice(false, taxLine, exTaxPrice));
    } catch (Exception e) {
        response.setFlash(e.getMessage());
    }
}
Also used : Context(com.axelor.rpc.Context) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException) TaxLine(com.axelor.apps.account.db.TaxLine)

Example 2 with TaxLine

use of com.axelor.apps.account.db.TaxLine in project axelor-open-suite by axelor.

the class InvoiceLineServiceImpl method updateProductQty.

@Override
public InvoiceLine updateProductQty(InvoiceLine invoiceLine, Invoice invoice, BigDecimal oldQty, BigDecimal newQty) throws AxelorException {
    BigDecimal qty = invoiceLine.getQty().divide(oldQty, appBaseService.getNbDecimalDigitForQty(), RoundingMode.HALF_EVEN).multiply(newQty).setScale(appBaseService.getNbDecimalDigitForQty(), RoundingMode.HALF_EVEN);
    invoiceLine.setQty(qty);
    if (invoiceLine.getTypeSelect() != InvoiceLineRepository.TYPE_NORMAL || invoiceLine.getProduct() == null) {
        return invoiceLine;
    }
    BigDecimal exTaxTotal;
    BigDecimal inTaxTotal;
    BigDecimal taxRate = BigDecimal.ZERO;
    TaxLine taxLine = invoiceLine.getTaxLine();
    BigDecimal priceDiscounted = this.computeDiscount(invoiceLine, invoice.getInAti());
    if (taxLine != null) {
        taxRate = taxLine.getValue();
        invoiceLine.setTaxRate(taxRate);
        invoiceLine.setTaxCode(taxLine.getTax().getCode());
    }
    if (Boolean.FALSE.equals(invoice.getInAti())) {
        exTaxTotal = InvoiceLineManagement.computeAmount(qty, priceDiscounted);
        inTaxTotal = exTaxTotal.add(exTaxTotal.multiply(taxRate));
    } else {
        inTaxTotal = InvoiceLineManagement.computeAmount(qty, priceDiscounted);
        exTaxTotal = inTaxTotal.divide(taxRate.add(BigDecimal.ONE), 2, BigDecimal.ROUND_HALF_UP);
    }
    invoiceLine.setExTaxTotal(exTaxTotal);
    invoiceLine.setCompanyExTaxTotal(this.getCompanyExTaxTotal(exTaxTotal, invoice));
    invoiceLine.setInTaxTotal(inTaxTotal);
    invoiceLine.setCompanyInTaxTotal(this.getCompanyExTaxTotal(inTaxTotal, invoice));
    invoiceLine.setPriceDiscounted(priceDiscounted);
    return this.computeAnalyticDistributionWithUpdatedQty(invoiceLine);
}
Also used : BigDecimal(java.math.BigDecimal) TaxLine(com.axelor.apps.account.db.TaxLine)

Example 3 with TaxLine

use of com.axelor.apps.account.db.TaxLine in project axelor-open-suite by axelor.

the class TaxInvoiceLine method createInvoiceLineTaxes.

protected void createInvoiceLineTaxes(InvoiceLine invoiceLine, Map<TaxLine, InvoiceLineTax> map) {
    TaxLine taxLine = invoiceLine.getTaxLine();
    TaxEquiv taxEquiv = invoiceLine.getTaxEquiv();
    TaxLine taxLineRC = (taxEquiv != null && taxEquiv.getReverseCharge() && taxEquiv.getReverseChargeTax() != null) ? taxEquiv.getReverseChargeTax().getActiveTaxLine() : null;
    if (taxLine != null) {
        createOrUpdateInvoiceLineTax(invoiceLine, taxLine, map);
    }
    if (taxLineRC != null) {
        createOrUpdateInvoiceLineTaxRc(invoiceLine, taxLineRC, taxEquiv, map);
    }
}
Also used : TaxEquiv(com.axelor.apps.account.db.TaxEquiv) TaxLine(com.axelor.apps.account.db.TaxLine)

Example 4 with TaxLine

use of com.axelor.apps.account.db.TaxLine in project axelor-open-suite by axelor.

the class InvoiceLineController method updatePrice.

/**
 * Update the ex. tax unit price of an invoice line from its in. tax unit price.
 *
 * @param request
 * @param response
 */
public void updatePrice(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    InvoiceLine invoiceLine = context.asType(InvoiceLine.class);
    try {
        BigDecimal inTaxPrice = invoiceLine.getInTaxPrice();
        TaxLine taxLine = invoiceLine.getTaxLine();
        response.setValue("price", Beans.get(InvoiceLineService.class).convertUnitPrice(true, taxLine, inTaxPrice));
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException) TaxLine(com.axelor.apps.account.db.TaxLine)

Example 5 with TaxLine

use of com.axelor.apps.account.db.TaxLine in project axelor-open-suite by axelor.

the class InvoiceLineController method updateInTaxPrice.

/**
 * Update the in. tax unit price of an invoice line from its ex. tax unit price.
 *
 * @param request
 * @param response
 */
public void updateInTaxPrice(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    InvoiceLine invoiceLine = context.asType(InvoiceLine.class);
    try {
        BigDecimal exTaxPrice = invoiceLine.getPrice();
        TaxLine taxLine = invoiceLine.getTaxLine();
        response.setValue("inTaxPrice", Beans.get(InvoiceLineService.class).convertUnitPrice(false, taxLine, exTaxPrice));
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException) TaxLine(com.axelor.apps.account.db.TaxLine)

Aggregations

TaxLine (com.axelor.apps.account.db.TaxLine)28 BigDecimal (java.math.BigDecimal)25 AxelorException (com.axelor.exception.AxelorException)9 Account (com.axelor.apps.account.db.Account)8 MoveLine (com.axelor.apps.account.db.MoveLine)7 TaxEquiv (com.axelor.apps.account.db.TaxEquiv)7 ArrayList (java.util.ArrayList)7 Context (com.axelor.rpc.Context)6 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)5 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)5 Partner (com.axelor.apps.base.db.Partner)5 Product (com.axelor.apps.base.db.Product)5 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)5 Tax (com.axelor.apps.account.db.Tax)4 PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)4 Transactional (com.google.inject.persist.Transactional)4 HashMap (java.util.HashMap)4 FiscalPosition (com.axelor.apps.account.db.FiscalPosition)3 TaxPaymentMoveLine (com.axelor.apps.account.db.TaxPaymentMoveLine)3 Company (com.axelor.apps.base.db.Company)3