use of com.axelor.apps.account.service.invoice.generator.invoice.RefundInvoice in project axelor-open-suite by axelor.
the class InvoiceServiceImpl method createRefund.
/**
* Créer un avoir.
*
* <p>Un avoir est une facture "inversée". Tout le montant sont opposés à la facture originale.
*
* @param invoice
* @return
* @throws AxelorException
*/
@Override
@Transactional(rollbackOn = { Exception.class })
public Invoice createRefund(Invoice invoice) throws AxelorException {
Invoice refund = new RefundInvoice(invoice).generate();
invoice.addRefundInvoiceListItem(refund);
invoiceRepo.save(invoice);
return refund;
}
use of com.axelor.apps.account.service.invoice.generator.invoice.RefundInvoice in project axelor-open-suite by axelor.
the class StockMoveMultiInvoiceServiceImpl method transformToRefund.
/**
* Change the operation type and invert all prices in the invoice.
*
* @param invoice an invoice
* @return the refund invoice
*/
protected Invoice transformToRefund(Invoice invoice) throws AxelorException {
Invoice refund = new RefundInvoice(invoice).generate();
if (refund.getInvoiceLineList() != null) {
for (InvoiceLine invoiceLine : refund.getInvoiceLineList()) {
invoiceLine.setPrice(invoiceLine.getPrice().negate());
invoiceLine.setPriceDiscounted(invoiceLine.getPriceDiscounted().negate());
invoiceLine.setInTaxPrice(invoiceLine.getInTaxPrice().negate());
invoiceLine.setExTaxTotal(invoiceLine.getExTaxTotal().negate());
invoiceLine.setInTaxTotal(invoiceLine.getInTaxTotal().negate());
invoiceLine.setCompanyExTaxTotal(invoiceLine.getCompanyExTaxTotal().negate());
invoiceLine.setCompanyInTaxTotal(invoiceLine.getCompanyInTaxTotal().negate());
}
}
if (refund.getInvoiceLineTaxList() != null) {
for (InvoiceLineTax invoiceLineTax : refund.getInvoiceLineTaxList()) {
invoiceLineTax.setExTaxBase(invoiceLineTax.getExTaxBase().negate());
invoiceLineTax.setTaxTotal(invoiceLineTax.getTaxTotal().negate());
invoiceLineTax.setCompanyExTaxBase(invoiceLineTax.getCompanyExTaxBase().negate());
invoiceLineTax.setInTaxTotal(invoiceLineTax.getInTaxTotal().negate());
invoiceLineTax.setCompanyInTaxTotal(invoiceLineTax.getCompanyInTaxTotal().negate());
}
}
refund.setExTaxTotal(refund.getExTaxTotal().negate());
refund.setInTaxTotal(refund.getInTaxTotal().negate());
refund.setCompanyExTaxTotal(refund.getCompanyExTaxTotal().negate());
refund.setCompanyInTaxTotal(refund.getCompanyInTaxTotal().negate());
refund.setTaxTotal(refund.getTaxTotal().negate());
refund.setAmountRemaining(refund.getAmountRemaining().negate());
refund.setCompanyTaxTotal(refund.getCompanyTaxTotal().negate());
refund.setPaymentMode(InvoiceToolService.getPaymentMode(refund));
return invoiceRepository.save(refund);
}
Aggregations