Search in sources :

Example 91 with Invoice

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;
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository) TimetableRepository(com.axelor.apps.supplychain.db.repo.TimetableRepository) Transactional(com.google.inject.persist.Transactional)

Example 92 with 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);
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) AccountingSituationService(com.axelor.apps.account.service.AccountingSituationService)

Example 93 with Invoice

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);
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) Transactional(com.google.inject.persist.Transactional)

Example 94 with Invoice

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;
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) Currency(com.axelor.apps.base.db.Currency)

Example 95 with Invoice

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);
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) IrrecoverableService(com.axelor.apps.account.service.IrrecoverableService) AxelorException(com.axelor.exception.AxelorException)

Aggregations

Invoice (com.axelor.apps.account.db.Invoice)195 AxelorException (com.axelor.exception.AxelorException)69 ArrayList (java.util.ArrayList)48 Transactional (com.google.inject.persist.Transactional)46 BigDecimal (java.math.BigDecimal)32 Company (com.axelor.apps.base.db.Company)31 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)29 Partner (com.axelor.apps.base.db.Partner)27 InvoiceRepository (com.axelor.apps.account.db.repo.InvoiceRepository)22 InvoiceService (com.axelor.apps.account.service.invoice.InvoiceService)22 PaymentMode (com.axelor.apps.account.db.PaymentMode)21 Map (java.util.Map)21 List (java.util.List)20 StockMove (com.axelor.apps.stock.db.StockMove)19 RefundInvoice (com.axelor.apps.account.service.invoice.generator.invoice.RefundInvoice)18 MoveLine (com.axelor.apps.account.db.MoveLine)17 LocalDate (java.time.LocalDate)17 InvoiceGenerator (com.axelor.apps.account.service.invoice.generator.InvoiceGenerator)16 Context (com.axelor.rpc.Context)15 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)14