From 8ccd38230a56e68d584a61215b7c948cb72e461b Mon Sep 17 00:00:00 2001 From: j-dimension Date: Sun, 13 Oct 2024 18:49:02 +0200 Subject: [PATCH] no e-invoice creation for specific invoice types (e.g. offer). issue #2165 --- .../client/editors/files/InvoiceDialog.java | 45 +++++++++++-------- .../jlawyer/client/utils/FileConverter.java | 3 +- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoiceDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoiceDialog.java index 7df687d91..b8ac14fb1 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoiceDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/InvoiceDialog.java @@ -2483,26 +2483,35 @@ private void cmdCreateInvoiceDocumentActionPerformed(java.awt.event.ActionEvent JOptionPane.showMessageDialog(this, "Es ist kein Rechnungssender definiert, E-Rechnung kann nicht erstellt werden.", com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_WARNING, JOptionPane.WARNING_MESSAGE); return; } - - // Options to display - String[] options = {"Elektronische Rechnung (an Unternehmen)", "XRechnung (an öffentliche Auftraggeber)"}; - - // Show option dialog - int choice = JOptionPane.showOptionDialog( - this, // Parent component (null for no parent) - "Rechnung erstellen als:", // Message to display - "Rechnungsdokument erstellen", // Title of the dialog - JOptionPane.DEFAULT_OPTION, // Option type (default for custom buttons) - JOptionPane.QUESTION_MESSAGE, // Message type (question icon) - null, // Icon (null for default icon) - options, // Options array - options[0] // Initial value (default selection) - ); - - if (choice < 0) { - return; + + + // by default, create document from document template + int choice=0; + + // if the invoice type indicates a real invoice where there is a turnover, we need to create an electronic invoice + if(this.currentEntry.getInvoiceType().isTurnOver()) { + // Options to display + String[] options = {"Elektronische Rechnung (an Unternehmen)", "XRechnung (an öffentliche Auftraggeber)"}; + + // Show option dialog + choice = JOptionPane.showOptionDialog( + this, // Parent component (null for no parent) + "Rechnung erstellen als:", // Message to display + "Rechnungsdokument erstellen", // Title of the dialog + JOptionPane.DEFAULT_OPTION, // Option type (default for custom buttons) + JOptionPane.QUESTION_MESSAGE, // Message type (question icon) + null, // Icon (null for default icon) + options, // Options array + options[0] // Initial value (default selection) + ); + + if (choice < 0) { + return; + } } + + AppUserBean senderUser = null; try { JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(ClientSettings.getInstance().getLookupProperties()); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileConverter.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileConverter.java index 24e758a09..558a912b1 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileConverter.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileConverter.java @@ -736,7 +736,8 @@ public String convertToPDF(String file, ArchiveFileDocumentsBean doc) throws Exc throw new Exception("Diesem Dokument ist mit mehreren Rechnungen verknüpft, elektronische Rechnung kann nicht erstellt werden."); } - if (invoices.size() == 1) { + // only create e-invoice if the invoice type indicates a turnover / flow of money + if (invoices.size() == 1 && invoices.get(0).getInvoiceType()!=null && invoices.get(0).getInvoiceType().isTurnOver()) { // generate electronic invoice Invoice sourceInvoice = invoices.get(0); if (StringUtils.isEmpty(sourceInvoice.getSender())) {