Planned invoice excluded from invoice payment
authorVásáry Dániel <vasary@elgekko.net>
Mon, 11 Dec 2023 14:47:02 +0000 (15:47 +0100)
committerVásáry Dániel <vasary@elgekko.net>
Mon, 11 Dec 2023 14:47:02 +0000 (15:47 +0100)
lis-db/src/main/java/hu/user/lis/db/repository/InvoiceRepository.java
lis-ui/src/main/java/hu/user/lis/ui/view/InvoicePaymentViewModel.java
lis-ui/src/main/resources/web/invoices.zul
lis-workflow/src/main/java/hu/user/lis/workflow/invoice/DownloadInvoiceData.java

index 0c6ef8b1a5626c9a8e1e6603b1b05ca3ed2c7207..979bf995387f0fe6f0b7dec516d415e567afa91f 100644 (file)
@@ -9,8 +9,8 @@ import java.util.Optional;
 
 public interface InvoiceRepository extends JpaRepository<Invoice, Long>, InvoiceRepositorySearch {
 
-    List<Invoice> findByHumanId(String humanId);
+    List<Invoice> findByHumanIdAndPlanned(String humanId, boolean planned);
 
-    Optional<Invoice> findByHumanIdAndPartner(String humanId, Partner partner);
+    Optional<Invoice> findByHumanIdAndPartnerAndPlanned(String humanId, Partner partner, boolean planned);
 
 }
index df2a1a98ca32218a3c399cef1f48d76cb549b0cd..3b84372b09cb5c888c1e047e65bd7fb798d974b5 100644 (file)
@@ -108,7 +108,7 @@ public class InvoicePaymentViewModel extends EntityViewModel<Payment> implements
         }
         hideEditor();
         if (Objects.isNull(filterPartner)) {
-            List<Invoice> invoices = invoiceRepository.findByHumanId(invoiceNumber);
+            List<Invoice> invoices = invoiceRepository.findByHumanIdAndPlanned(invoiceNumber, false);
             if (invoices.isEmpty()) {
                 setPartnerRequired(false);
                 Notification.show("Nem található számla: " + invoiceNumber, null, null, null, 3000, true);
@@ -123,7 +123,7 @@ public class InvoicePaymentViewModel extends EntityViewModel<Payment> implements
                 }
             }
         } else {
-            Optional<Invoice> opInvoice = invoiceRepository.findByHumanIdAndPartner(invoiceNumber, filterPartner);
+            Optional<Invoice> opInvoice = invoiceRepository.findByHumanIdAndPartnerAndPlanned(invoiceNumber, filterPartner, false);
             opInvoice.ifPresent(this::showEditor);
         }
     }
index 8cb02bb709212a8559b8631fef22207fdf4a278e..60fa52e7535c5f017e39635e0bd959e6f35cde5f 100644 (file)
@@ -66,7 +66,7 @@
                                        onClick="@command('onChangeProject')" disabled="@load(empty vm.selectedEntity)"/>
                         <toolbarbutton label="Számla kiegyenlítés" iconSclass="z-icon-credit-card"
                                        onClick="@command('onInvoicePayment')"
-                                       disabled="@load(empty vm.selectedEntity)"/>
+                                       disabled="@load(empty vm.selectedEntity || vm.selectedEntity.planned)"/>
 
                         <!--                        <toolbarbutton label="Hozzáadás" iconSclass="z-icon-plus" onClick="@command('onAdd')"/>-->
                         <!--                        <toolbarbutton label="Törlés" iconSclass="z-icon-remove" onClick="@command('onDelete')"-->
index e926be2477ba85f771aa62306cb22afc136626d1..b618df8c88827bb1308d82b9d10a0cb6044c0f85 100644 (file)
@@ -84,6 +84,6 @@ public class DownloadInvoiceData implements JavaDelegate {
     }
 
     private boolean isInvoiceImported(String humanId, Partner partner) {
-        return invoiceRepository.findByHumanIdAndPartner(humanId, partner).isPresent();
+        return invoiceRepository.findByHumanIdAndPartnerAndPlanned(humanId, partner, false).isPresent();
     }
 }