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());
}
}
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);
}
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);
}
}
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);
}
}
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);
}
}
Aggregations