use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class TimetableServiceImpl method generateInvoice.
@Override
@Transactional(rollbackOn = { Exception.class })
public Invoice generateInvoice(Timetable timetable) throws AxelorException {
Invoice invoice = this.createInvoice(timetable);
Beans.get(InvoiceRepository.class).save(invoice);
timetable.setInvoice(invoice);
Beans.get(TimetableRepository.class).save(timetable);
return invoice;
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoicePaymentValidateServiceImpl method createInvoicePaymentMove.
protected void createInvoicePaymentMove(InvoicePayment invoicePayment) throws AxelorException, JAXBException, IOException, DatatypeConfigurationException {
Invoice invoice = invoicePayment.getInvoice();
if (accountConfigService.getAccountConfig(invoice.getCompany()).getGenerateMoveForInvoicePayment()) {
this.createMoveForInvoicePayment(invoicePayment);
} else {
Beans.get(AccountingSituationService.class).updateCustomerCredit(invoice.getPartner());
invoicePaymentRepository.save(invoicePayment);
}
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoicePaymentValidateServiceImpl method validate.
/**
* Method to validate an invoice Payment
*
* <p>Create the eventual move (depending general configuration) and reconcile it with the invoice
* move Compute the amount paid on invoice Change the status to validated
*
* @param invoicePayment An invoice payment
* @throws AxelorException
* @throws DatatypeConfigurationException
* @throws IOException
* @throws JAXBException
*/
@Override
@Transactional(rollbackOn = { Exception.class })
public void validate(InvoicePayment invoicePayment, boolean force) throws AxelorException, JAXBException, IOException, DatatypeConfigurationException {
Invoice invoice = invoicePayment.getInvoice();
validatePartnerAccount(invoice);
if (!force && invoicePayment.getStatusSelect() != InvoicePaymentRepository.STATUS_DRAFT) {
return;
}
setInvoicePaymentStatus(invoicePayment);
createInvoicePaymentMove(invoicePayment);
invoicePaymentToolService.updateAmountPaid(invoicePayment.getInvoice());
if (invoicePayment.getInvoice() != null && invoicePayment.getInvoice().getOperationSubTypeSelect() == InvoiceRepository.OPERATION_SUB_TYPE_ADVANCE) {
invoicePayment.setTypeSelect(InvoicePaymentRepository.TYPE_ADVANCEPAYMENT);
}
invoicePaymentRepository.save(invoicePayment);
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class PaymentVoucherLoadService method mustBeBalanced.
public boolean mustBeBalanced(MoveLine moveLineToPay, PaymentVoucher paymentVoucher, BigDecimal amountToPay) {
Invoice invoice = moveLineToPay.getMove().getInvoice();
Currency invoiceCurrency = invoice.getCurrency();
Currency paymentVoucherCurrency = paymentVoucher.getCurrency();
// Alors on solde la facture
if (paymentVoucherCurrency.equals(invoiceCurrency) && invoice.getAmountPaid().add(amountToPay).compareTo(invoice.getInTaxTotal()) == 0) {
// SOLDER
return true;
}
return false;
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoiceController method passInIrrecoverable.
public void passInIrrecoverable(ActionRequest request, ActionResponse response) {
Invoice invoice = request.getContext().asType(Invoice.class);
invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
try {
Beans.get(IrrecoverableService.class).passInIrrecoverable(invoice, true);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations