Search in sources :

Example 11 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class IrrecoverableService method notPassInIrrecoverable.

/**
 * Procédure permettant d'annuler le passage en irrécouvrable d'une échéancier de lissage de
 * paiement La procédure annulera aussi le passage en irrécouvrable des lignes d'écriture de rejet
 * d'échéance en irrécouvrable, ainsi que des factures pas complètement payée selectionnées sur
 * l'échéancier
 *
 * @param paymentSchedule Un échéancier de paiement
 * @throws AxelorException
 */
@Transactional(rollbackOn = { Exception.class })
public void notPassInIrrecoverable(PaymentSchedule paymentSchedule) throws AxelorException {
    paymentSchedule.setIrrecoverableStatusSelect(PaymentScheduleRepository.IRRECOVERABLE_STATUS_NOT_IRRECOUVRABLE);
    List<MoveLine> paymentScheduleLineRejectMoveLineList = new ArrayList<MoveLine>();
    for (PaymentScheduleLine paymentScheduleLine : paymentSchedule.getPaymentScheduleLineList()) {
        if (paymentScheduleLine.getRejectMoveLine() != null && paymentScheduleLine.getRejectMoveLine().getAmountRemaining().compareTo(BigDecimal.ZERO) > 0) {
            paymentScheduleLineRejectMoveLineList.add(paymentScheduleLine.getRejectMoveLine());
        }
    }
    for (MoveLine moveLine : paymentScheduleLineRejectMoveLineList) {
        this.notPassInIrrecoverable(moveLine, false);
    }
    for (Invoice invoice : paymentSchedule.getInvoiceSet()) {
        this.notPassInIrrecoverable(invoice);
    }
    paymentScheduleRepo.save(paymentSchedule);
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine) MoveLine(com.axelor.apps.account.db.MoveLine) ArrayList(java.util.ArrayList) Transactional(com.google.inject.persist.Transactional)

Example 12 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class ReconcileServiceImpl method udpatePaymentTax.

protected void udpatePaymentTax(Reconcile reconcile) throws AxelorException {
    Move debitMove = reconcile.getDebitMoveLine().getMove();
    Move creditMove = reconcile.getCreditMoveLine().getMove();
    Invoice debitInvoice = debitMove.getInvoice();
    Invoice creditInvoice = creditMove.getInvoice();
    if (debitInvoice != null && creditInvoice == null) {
        moveLineService.generateTaxPaymentMoveLineList(reconcile.getCreditMoveLine(), debitInvoice, reconcile);
    }
    if (creditInvoice != null && debitInvoice == null) {
        moveLineService.generateTaxPaymentMoveLineList(reconcile.getDebitMoveLine(), creditInvoice, reconcile);
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) Move(com.axelor.apps.account.db.Move)

Example 13 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class ReconcileServiceImpl method reverseTaxPaymentMoveLines.

protected void reverseTaxPaymentMoveLines(Reconcile reconcile) throws AxelorException {
    Move debitMove = reconcile.getDebitMoveLine().getMove();
    Move creditMove = reconcile.getCreditMoveLine().getMove();
    Invoice debitInvoice = debitMove.getInvoice();
    Invoice creditInvoice = creditMove.getInvoice();
    if (debitInvoice == null) {
        moveLineService.reverseTaxPaymentMoveLines(reconcile.getDebitMoveLine(), reconcile);
    }
    if (creditInvoice == null) {
        moveLineService.reverseTaxPaymentMoveLines(reconcile.getCreditMoveLine(), reconcile);
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) Move(com.axelor.apps.account.db.Move)

Example 14 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class ReconcileServiceImpl method updateInvoicePayments.

public void updateInvoicePayments(Reconcile reconcile) throws AxelorException {
    MoveLine debitMoveLine = reconcile.getDebitMoveLine();
    MoveLine creditMoveLine = reconcile.getCreditMoveLine();
    Move debitMove = debitMoveLine.getMove();
    Move creditMove = creditMoveLine.getMove();
    Invoice debitInvoice = debitMove.getInvoice();
    Invoice creditInvoice = creditMove.getInvoice();
    BigDecimal amount = reconcile.getAmount();
    if (debitInvoice != null && debitMoveLine.getAccount().getUseForPartnerBalance() && creditMoveLine.getAccount().getUseForPartnerBalance()) {
        InvoicePayment debitInvoicePayment = invoicePaymentCreateService.createInvoicePayment(debitInvoice, amount, creditMove);
        debitInvoicePayment.setReconcile(reconcile);
    }
    if (creditInvoice != null && debitMoveLine.getAccount().getUseForPartnerBalance() && creditMoveLine.getAccount().getUseForPartnerBalance()) {
        InvoicePayment creditInvoicePayment = invoicePaymentCreateService.createInvoicePayment(creditInvoice, amount, debitMove);
        creditInvoicePayment.setReconcile(reconcile);
    }
}
Also used : InvoicePayment(com.axelor.apps.account.db.InvoicePayment) Invoice(com.axelor.apps.account.db.Invoice) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) BigDecimal(java.math.BigDecimal)

Example 15 with Invoice

use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.

the class BudgetService method getDate.

/**
 * @param budgetDistribution
 * @return returns an {@code Optional} because in some cases the child implementations can return
 *     a null value.
 */
protected Optional<LocalDate> getDate(BudgetDistribution budgetDistribution) {
    Invoice invoice = budgetDistribution.getInvoiceLine().getInvoice();
    LocalDate invoiceDate = invoice.getInvoiceDate();
    if (invoiceDate != null) {
        return Optional.of(invoiceDate);
    }
    return Optional.of(invoice.getValidatedDate());
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) LocalDate(java.time.LocalDate)

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