Search in sources :

Example 21 with Invoice

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

the class CfonbExportService method exportCFONB.

/**
 * Méthode permettant d'exporter les prélèvements de facture et d'échéance de paiement au format
 * CFONB
 *
 * @param paymentScheduleExport
 * @param paymentScheduleLineList
 * @param invoiceList
 * @param company
 * @throws AxelorException
 */
public void exportCFONB(ZonedDateTime processingDateTime, LocalDate scheduleDate, List<PaymentScheduleLine> paymentScheduleLineList, List<Invoice> invoiceList, Company company, BankDetails bankDetails) throws AxelorException {
    if ((paymentScheduleLineList == null || paymentScheduleLineList.isEmpty()) && (invoiceList == null || invoiceList.isEmpty())) {
        return;
    }
    this.testCompanyExportCFONBField(company);
    // paramètre obligatoire : au minimum
    // un enregistrement emetteur par date de règlement (code 03)
    // un enregistrement destinataire (code 06)
    // un enregistrement total (code 08)
    String senderCFONB = this.createSenderMonthlyExportCFONB(scheduleDate, bankDetails);
    List<String> multiRecipientCFONB = new ArrayList<String>();
    // Echéanciers
    for (PaymentScheduleLine paymentScheduleLine : paymentScheduleLineList) {
        paymentScheduleLine = paymentScheduleLineRepo.find(paymentScheduleLine.getId());
        multiRecipientCFONB.add(this.createRecipientCFONB(paymentScheduleLine, false));
    }
    // Factures
    for (Invoice invoice : invoiceList) {
        invoice = invoiceRepo.find(invoice.getId());
        multiRecipientCFONB.add(this.createRecipientCFONB(company, invoice));
    }
    BigDecimal amount = this.getTotalAmountPaymentSchedule(paymentScheduleLineList).add(this.getTotalAmountInvoice(invoiceList));
    String totalCFONB = this.createPaymentScheduleTotalCFONB(company, amount);
// cfonbToolService.testLength(senderCFONB, totalCFONB, multiRecipientCFONB, company);
// List<String> cFONB = this.createCFONBExport(senderCFONB, multiRecipientCFONB, totalCFONB);
// Mise en majuscule des enregistrement
// cFONB = this.toUpperCase(cFONB);
// this.createCFONBFile(cFONB, processingDateTime,
// company.getAccountConfig().getPaymentScheduleExportFolderPathCFONB(), "prelevement");
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal)

Example 22 with Invoice

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

the class CfonbExportService method exportInvoiceCFONB.

/**
 * Méthode permettant d'exporter les prélèvements de facture au format CFONB
 *
 * @param paymentScheduleExport
 * @param paymentScheduleLineList
 * @param invoiceList
 * @param company
 * @throws AxelorException
 */
public void exportInvoiceCFONB(ZonedDateTime processingDateTime, LocalDate scheduleDate, List<Invoice> invoiceList, Company company, BankDetails bankDetails) throws AxelorException {
    if ((invoiceList == null || invoiceList.isEmpty())) {
        return;
    }
    this.testCompanyExportCFONBField(company);
    // paramètre obligatoire : au minimum
    // un enregistrement emetteur par date de règlement (code 03)
    // un enregistrement destinataire (code 06)
    // un enregistrement total (code 08)
    String senderCFONB = this.createSenderMonthlyExportCFONB(scheduleDate, bankDetails);
    List<String> multiRecipientCFONB = new ArrayList<String>();
    for (Invoice invoice : invoiceList) {
        invoice = invoiceRepo.find(invoice.getId());
        multiRecipientCFONB.add(this.createRecipientCFONB(company, invoice));
    }
    BigDecimal amount = this.getTotalAmountInvoice(invoiceList);
    String totalCFONB = this.createPaymentScheduleTotalCFONB(company, amount);
// cfonbToolService.testLength(senderCFONB, totalCFONB, multiRecipientCFONB, company);
// List<String> cFONB = this.createCFONBExport(senderCFONB, multiRecipientCFONB, totalCFONB);
// Mise en majuscule des enregistrement
// cFONB = this.toUpperCase(cFONB);
// this.createCFONBFile(cFONB, processingDateTime,
// company.getAccountConfig().getPaymentScheduleExportFolderPathCFONB(), "prelevement");
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal)

Example 23 with Invoice

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

the class InvoiceController method fillPaymentModeAndCondition.

/**
 * Function returning both the paymentMode and the paymentCondition
 *
 * @param request
 * @param response
 */
public void fillPaymentModeAndCondition(ActionRequest request, ActionResponse response) {
    Invoice invoice = request.getContext().asType(Invoice.class);
    try {
        if (invoice.getOperationTypeSelect() == null) {
            return;
        }
        PaymentMode paymentMode = InvoiceToolService.getPaymentMode(invoice);
        PaymentCondition paymentCondition = InvoiceToolService.getPaymentCondition(invoice);
        response.setValue("paymentMode", paymentMode);
        response.setValue("paymentCondition", paymentCondition);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PaymentCondition(com.axelor.apps.account.db.PaymentCondition) Invoice(com.axelor.apps.account.db.Invoice) AxelorException(com.axelor.exception.AxelorException) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 24 with Invoice

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

the class InvoiceController method refusalToPay.

public void refusalToPay(ActionRequest request, ActionResponse response) {
    Invoice invoice = request.getContext().asType(Invoice.class);
    Beans.get(InvoiceService.class).refusalToPay(Beans.get(InvoiceRepository.class).find(invoice.getId()), invoice.getReasonOfRefusalToPay(), invoice.getReasonOfRefusalToPayStr());
    response.setCanClose(true);
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService)

Example 25 with Invoice

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

the class InvoiceController method validateAndVentilate.

/**
 * Called by the validate button, if the ventilation is skipped in invoice config
 *
 * @param request
 * @param response
 */
public void validateAndVentilate(ActionRequest request, ActionResponse response) {
    Invoice invoice = request.getContext().asType(Invoice.class);
    invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
    try {
        // we have to inject TraceBackService to use non static methods
        TraceBackService traceBackService = Beans.get(TraceBackService.class);
        long tracebackCount = traceBackService.countMessageTraceBack(invoice);
        Beans.get(InvoiceService.class).validateAndVentilate(invoice);
        response.setReload(true);
        if (traceBackService.countMessageTraceBack(invoice) > tracebackCount) {
            traceBackService.findLastMessageTraceBack(invoice).ifPresent(traceback -> response.setNotify(String.format(I18n.get(com.axelor.apps.message.exception.IExceptionMessage.SEND_EMAIL_EXCEPTION), traceback.getMessage())));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : TraceBackService(com.axelor.exception.service.TraceBackService) Invoice(com.axelor.apps.account.db.Invoice) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService) 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