use of com.axelor.apps.account.db.FiscalPosition in project axelor-open-suite by axelor.
the class SaleOrderLineServiceImpl method fillTaxInformation.
protected void fillTaxInformation(SaleOrderLine saleOrderLine, SaleOrder saleOrder) throws AxelorException {
if (saleOrder.getClientPartner() != null) {
TaxLine taxLine = this.getTaxLine(saleOrder, saleOrderLine);
saleOrderLine.setTaxLine(taxLine);
FiscalPosition fiscalPosition = saleOrder.getClientPartner().getFiscalPosition();
TaxEquiv taxEquiv = accountManagementService.getProductTaxEquiv(saleOrderLine.getProduct(), saleOrder.getCompany(), fiscalPosition, false);
saleOrderLine.setTaxEquiv(taxEquiv);
} else {
saleOrderLine.setTaxLine(null);
saleOrderLine.setTaxEquiv(null);
}
}
use of com.axelor.apps.account.db.FiscalPosition in project axelor-open-suite by axelor.
the class ContractServiceImpl method generate.
public InvoiceLine generate(Invoice invoice, ContractLine line) throws AxelorException {
BigDecimal inTaxPriceComputed = invoiceLineService.convertUnitPrice(false, line.getTaxLine(), line.getPrice());
InvoiceLineGenerator invoiceLineGenerator = new InvoiceLineGenerator(invoice, line.getProduct(), line.getProductName(), line.getPrice(), inTaxPriceComputed, invoice.getInAti() ? inTaxPriceComputed : line.getPrice(), line.getDescription(), line.getQty(), line.getUnit(), line.getTaxLine(), line.getSequence(), BigDecimal.ZERO, PriceListLineRepository.AMOUNT_TYPE_NONE, line.getExTaxTotal(), line.getInTaxTotal(), false) {
@Override
public List<InvoiceLine> creates() throws AxelorException {
InvoiceLine invoiceLine = this.createInvoiceLine();
List<InvoiceLine> invoiceLines = new ArrayList<>();
invoiceLines.add(invoiceLine);
return invoiceLines;
}
};
InvoiceLine invoiceLine = invoiceLineGenerator.creates().get(0);
FiscalPositionAccountService fiscalPositionAccountService = Beans.get(FiscalPositionAccountService.class);
FiscalPosition fiscalPosition = line.getFiscalPosition();
Account currentAccount = invoiceLine.getAccount();
Account replacedAccount = fiscalPositionAccountService.getAccount(fiscalPosition, currentAccount);
boolean isPurchase = Beans.get(InvoiceService.class).getPurchaseTypeOrSaleType(invoice) == PriceListRepository.TYPE_PURCHASE;
TaxLine taxLine = Beans.get(AccountManagementService.class).getTaxLine(appBaseService.getTodayDate(invoice.getCompany()), invoiceLine.getProduct(), invoice.getCompany(), fiscalPosition, isPurchase);
invoiceLine.setTaxLine(taxLine);
invoiceLine.setAccount(replacedAccount);
if (line.getAnalyticDistributionTemplate() != null) {
invoiceLine.setAnalyticDistributionTemplate(line.getAnalyticDistributionTemplate());
this.copyAnalyticMoveLines(line.getAnalyticMoveLineList(), invoiceLine);
}
invoice.addInvoiceLineListItem(invoiceLine);
return Beans.get(InvoiceLineRepository.class).save(invoiceLine);
}
use of com.axelor.apps.account.db.FiscalPosition 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;
}
Aggregations