use of com.axelor.apps.account.db.TaxLine in project axelor-open-suite by axelor.
the class SaleOrderStockServiceImpl method createStockMoveLine.
@Override
public StockMoveLine createStockMoveLine(StockMove stockMove, SaleOrderLine saleOrderLine, BigDecimal qty) throws AxelorException {
if (this.isStockMoveProduct(saleOrderLine)) {
Unit unit = saleOrderLine.getProduct().getUnit();
BigDecimal priceDiscounted = saleOrderLine.getPriceDiscounted();
BigDecimal requestedReservedQty = saleOrderLine.getRequestedReservedQty().subtract(saleOrderLine.getDeliveredQty());
BigDecimal companyUnitPriceUntaxed = (BigDecimal) productCompanyService.get(saleOrderLine.getProduct(), "costPrice", saleOrderLine.getSaleOrder() != null ? saleOrderLine.getSaleOrder().getCompany() : null);
if (unit != null && !unit.equals(saleOrderLine.getUnit())) {
qty = unitConversionService.convert(saleOrderLine.getUnit(), unit, qty, qty.scale(), saleOrderLine.getProduct());
priceDiscounted = unitConversionService.convert(unit, saleOrderLine.getUnit(), priceDiscounted, appBaseService.getNbDecimalDigitForUnitPrice(), saleOrderLine.getProduct());
requestedReservedQty = unitConversionService.convert(saleOrderLine.getUnit(), unit, requestedReservedQty, requestedReservedQty.scale(), saleOrderLine.getProduct());
}
BigDecimal taxRate = BigDecimal.ZERO;
TaxLine taxLine = saleOrderLine.getTaxLine();
if (taxLine != null) {
taxRate = taxLine.getValue();
}
if (saleOrderLine.getQty().signum() != 0) {
companyUnitPriceUntaxed = saleOrderLine.getCompanyExTaxTotal().divide(saleOrderLine.getQty(), Beans.get(AppBaseService.class).getNbDecimalDigitForUnitPrice(), RoundingMode.HALF_UP);
}
StockMoveLine stockMoveLine = stockMoveLineSupplychainService.createStockMoveLine(saleOrderLine.getProduct(), saleOrderLine.getProductName(), saleOrderLine.getDescription(), qty, requestedReservedQty, priceDiscounted, companyUnitPriceUntaxed, null, unit, stockMove, StockMoveLineService.TYPE_SALES, saleOrderLine.getSaleOrder().getInAti(), taxRate, saleOrderLine, null);
if (saleOrderLine.getDeliveryState() == 0) {
saleOrderLine.setDeliveryState(SaleOrderLineRepository.DELIVERY_STATE_NOT_DELIVERED);
}
return stockMoveLine;
}
return null;
}
use of com.axelor.apps.account.db.TaxLine in project axelor-open-suite by axelor.
the class InvoiceLineServiceImpl method fillPriceAndAccount.
@Override
public Map<String, Object> fillPriceAndAccount(Invoice invoice, InvoiceLine invoiceLine, boolean isPurchase) throws AxelorException {
Map<String, Object> productInformation = resetProductInformation(invoice);
Product product = invoiceLine.getProduct();
TaxLine taxLine = null;
Company company = invoice.getCompany();
FiscalPosition fiscalPosition = invoice.getPartner().getFiscalPosition();
try {
taxLine = this.getTaxLine(invoice, invoiceLine, isPurchase);
invoiceLine.setTaxLine(taxLine);
productInformation.put("taxLine", taxLine);
productInformation.put("taxRate", taxLine.getValue());
productInformation.put("taxCode", taxLine.getTax().getCode());
TaxEquiv taxEquiv = accountManagementAccountService.getProductTaxEquiv(product, company, fiscalPosition, isPurchase);
productInformation.put("taxEquiv", taxEquiv);
Account account = accountManagementAccountService.getProductAccount(product, company, fiscalPosition, isPurchase, invoiceLine.getFixedAssets());
productInformation.put("account", account);
} catch (AxelorException e) {
productInformation.put("error", e.getMessage());
}
BigDecimal price = this.getExTaxUnitPrice(invoice, invoiceLine, taxLine, isPurchase);
BigDecimal inTaxPrice = this.getInTaxUnitPrice(invoice, invoiceLine, taxLine, isPurchase);
productInformation.put("price", price);
productInformation.put("inTaxPrice", inTaxPrice);
productInformation.putAll(this.getDiscount(invoice, invoiceLine, product.getInAti() ? inTaxPrice : price));
productInformation.put("productName", invoiceLine.getProduct().getName());
return productInformation;
}
use of com.axelor.apps.account.db.TaxLine in project axelor-open-suite by axelor.
the class MoveLineServiceImpl method generateTaxPaymentMoveLineList.
@Override
@Transactional(rollbackOn = { Exception.class })
public MoveLine generateTaxPaymentMoveLineList(MoveLine customerMoveLine, Invoice invoice, Reconcile reconcile) throws AxelorException {
BigDecimal paymentAmount = reconcile.getAmount();
BigDecimal invoiceTotalAmount = invoice.getCompanyInTaxTotal();
for (InvoiceLineTax invoiceLineTax : invoice.getInvoiceLineTaxList()) {
TaxLine taxLine = invoiceLineTax.getTaxLine();
BigDecimal vatRate = taxLine.getValue();
BigDecimal baseAmount = invoiceLineTax.getCompanyExTaxBase();
BigDecimal detailPaymentAmount = baseAmount.multiply(paymentAmount).divide(invoiceTotalAmount, 6, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP);
TaxPaymentMoveLine taxPaymentMoveLine = new TaxPaymentMoveLine(customerMoveLine, taxLine, reconcile, vatRate, detailPaymentAmount, Beans.get(AppBaseService.class).getTodayDate(reconcile.getCompany()));
taxPaymentMoveLine = taxPaymentMoveLineService.computeTaxAmount(taxPaymentMoveLine);
customerMoveLine.addTaxPaymentMoveLineListItem(taxPaymentMoveLine);
}
this.computeTaxAmount(customerMoveLine);
return Beans.get(MoveLineRepository.class).save(customerMoveLine);
}
Aggregations