use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceLineController method getDiscount.
public void getDiscount(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
InvoiceLine invoiceLine = context.asType(InvoiceLine.class);
Invoice invoice = this.getInvoice(context);
if (invoice == null || invoiceLine.getProduct() == null) {
return;
}
try {
Map<String, Object> discounts = Beans.get(InvoiceLineService.class).getDiscount(invoice, invoiceLine, invoiceLine.getProduct().getInAti() ? Beans.get(InvoiceLineService.class).getInTaxUnitPrice(invoice, invoiceLine, invoiceLine.getTaxLine(), InvoiceToolService.isPurchase(invoice)) : Beans.get(InvoiceLineService.class).getExTaxUnitPrice(invoice, invoiceLine, invoiceLine.getTaxLine(), InvoiceToolService.isPurchase(invoice)));
for (Entry<String, Object> entry : discounts.entrySet()) {
response.setValue(entry.getKey(), entry.getValue());
}
} catch (Exception e) {
response.setFlash(e.getMessage());
}
}
use of com.axelor.apps.account.db.InvoiceLine 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);
}
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceLineController method emptyLine.
public void emptyLine(ActionRequest request, ActionResponse response) {
InvoiceLine invoiceLine = request.getContext().asType(InvoiceLine.class);
if (invoiceLine.getTypeSelect() != InvoiceLineRepository.TYPE_NORMAL) {
Map<String, Object> newInvoiceLine = Mapper.toMap(new InvoiceLine());
newInvoiceLine.put("qty", BigDecimal.ZERO);
newInvoiceLine.put("id", invoiceLine.getId());
newInvoiceLine.put("version", invoiceLine.getVersion());
newInvoiceLine.put("typeSelect", invoiceLine.getTypeSelect());
if (invoiceLine.getTypeSelect() == InvoiceLineRepository.TYPE_END_OF_PACK) {
newInvoiceLine.put("productName", I18n.get(ITranslation.INVOICE_LINE_END_OF_PACK));
}
response.setValues(newInvoiceLine);
}
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceLineController method getProductInformation.
public void getProductInformation(ActionRequest request, ActionResponse response) throws AxelorException {
Context context = request.getContext();
InvoiceLine invoiceLine = context.asType(InvoiceLine.class);
Invoice invoice = this.getInvoice(context);
Product product = invoiceLine.getProduct();
Map<String, Object> productInformation = new HashMap<>();
if (invoice != null && product != null) {
try {
productInformation = Beans.get(InvoiceLineService.class).fillProductInformation(invoice, invoiceLine);
String errorMsg = (String) productInformation.get("error");
if (!Strings.isNullOrEmpty(errorMsg)) {
response.setFlash(errorMsg);
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
} else {
productInformation = Beans.get(InvoiceLineService.class).resetProductInformation(invoice);
}
response.setValues(productInformation);
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class ExpenseServiceImpl method createInvoiceLine.
@Override
public List<InvoiceLine> createInvoiceLine(Invoice invoice, ExpenseLine expenseLine, int priority) throws AxelorException {
Product product = expenseLine.getExpenseProduct();
InvoiceLineGenerator invoiceLineGenerator = null;
Integer atiChoice = invoice.getCompany().getAccountConfig().getInvoiceInAtiSelect();
if (atiChoice == AccountConfigRepository.INVOICE_WT_ALWAYS || atiChoice == AccountConfigRepository.INVOICE_WT_DEFAULT) {
invoiceLineGenerator = new InvoiceLineGenerator(invoice, product, product.getName(), expenseLine.getUntaxedAmount(), expenseLine.getTotalAmount(), expenseLine.getUntaxedAmount(), expenseLine.getComments(), BigDecimal.ONE, product.getUnit(), null, priority, BigDecimal.ZERO, PriceListLineRepository.AMOUNT_TYPE_NONE, expenseLine.getUntaxedAmount(), expenseLine.getTotalAmount(), false) {
@Override
public List<InvoiceLine> creates() throws AxelorException {
InvoiceLine invoiceLine = this.createInvoiceLine();
List<InvoiceLine> invoiceLines = new ArrayList<>();
invoiceLines.add(invoiceLine);
return invoiceLines;
}
};
} else {
invoiceLineGenerator = new InvoiceLineGenerator(invoice, product, product.getName(), expenseLine.getUntaxedAmount(), expenseLine.getTotalAmount(), expenseLine.getTotalAmount(), expenseLine.getComments(), BigDecimal.ONE, product.getUnit(), null, priority, BigDecimal.ZERO, PriceListLineRepository.AMOUNT_TYPE_NONE, expenseLine.getUntaxedAmount(), expenseLine.getTotalAmount(), false) {
@Override
public List<InvoiceLine> creates() throws AxelorException {
InvoiceLine invoiceLine = this.createInvoiceLine();
List<InvoiceLine> invoiceLines = new ArrayList<>();
invoiceLines.add(invoiceLine);
return invoiceLines;
}
};
}
return invoiceLineGenerator.creates();
}
Aggregations