EDocument handling completed, project set changed to ordered list
authorVásáry Dániel <vasary@elgekko.net>
Thu, 21 Dec 2023 09:01:33 +0000 (10:01 +0100)
committerVásáry Dániel <vasary@elgekko.net>
Thu, 21 Dec 2023 09:01:33 +0000 (10:01 +0100)
57 files changed:
lis-app/src/test/java/hu/user/lis/ReflectionsIT.java
lis-db/migrations/scripts/018_add_signed_to_service_record.sql [new file with mode: 0644]
lis-db/migrations/scripts/019_add_order_to_treasury.sql [new file with mode: 0644]
lis-db/migrations/scripts/020_add_order_to_invoice.sql [new file with mode: 0644]
lis-db/migrations/scripts/021_add_technical_id_to_invoice.sql [new file with mode: 0644]
lis-db/migrations/scripts/022_add_technical_id_to_treasury.sql [new file with mode: 0644]
lis-db/migrations/scripts/023_remove_file.sql [new file with mode: 0644]
lis-db/src/main/java/hu/user/lis/db/Associate.java
lis-db/src/main/java/hu/user/lis/db/Currency.java
lis-db/src/main/java/hu/user/lis/db/EDocument.java
lis-db/src/main/java/hu/user/lis/db/IdEntity.java [new file with mode: 0644]
lis-db/src/main/java/hu/user/lis/db/IncomingInvoice.java
lis-db/src/main/java/hu/user/lis/db/Invoice.java
lis-db/src/main/java/hu/user/lis/db/InvoiceImport.java
lis-db/src/main/java/hu/user/lis/db/InvoiceStatus.java
lis-db/src/main/java/hu/user/lis/db/Partner.java
lis-db/src/main/java/hu/user/lis/db/Payment.java
lis-db/src/main/java/hu/user/lis/db/Profile.java
lis-db/src/main/java/hu/user/lis/db/Project.java
lis-db/src/main/java/hu/user/lis/db/ProjectAssociate.java
lis-db/src/main/java/hu/user/lis/db/ProjectStatus.java
lis-db/src/main/java/hu/user/lis/db/ServiceRecord.java
lis-db/src/main/java/hu/user/lis/db/Supplier.java [deleted file]
lis-db/src/main/java/hu/user/lis/db/Treasury.java
lis-db/src/main/java/hu/user/lis/db/repository/EDocumentRepository.java
lis-service/src/main/java/hu/user/lis/service/api/ProjectApi.java
lis-service/src/main/java/hu/user/lis/service/data/EDocumentService.java [deleted file]
lis-service/src/main/java/hu/user/lis/service/data/EDocumentServiceImpl.java [deleted file]
lis-service/src/main/java/hu/user/lis/service/data/EntityDocumentAction.java [new file with mode: 0644]
lis-service/src/main/java/hu/user/lis/service/data/EntityDocumentService.java [new file with mode: 0644]
lis-service/src/main/java/hu/user/lis/service/data/ProjectServiceImpl.java
lis-service/src/main/java/hu/user/lis/service/data/SupplierService.java [deleted file]
lis-service/src/main/java/hu/user/lis/service/data/SupplierServiceImpl.java [deleted file]
lis-service/src/main/java/hu/user/lis/service/nav/mapper/InvoiceMapper.java
lis-ui/src/main/java/hu/user/lis/ui/converter/SupplierToNameConverter.java [deleted file]
lis-ui/src/main/java/hu/user/lis/ui/data/EntityDocumentDataModel.java
lis-ui/src/main/java/hu/user/lis/ui/data/IncomeMarginsDataModel.java
lis-ui/src/main/java/hu/user/lis/ui/data/InvoiceDataModel.java
lis-ui/src/main/java/hu/user/lis/ui/data/ProjectsDataModel.java
lis-ui/src/main/java/hu/user/lis/ui/data/SuppliersDataModel.java [deleted file]
lis-ui/src/main/java/hu/user/lis/ui/data/SuppliersSimpleDataModel.java [deleted file]
lis-ui/src/main/java/hu/user/lis/ui/editor/InvoiceEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/editor/ProjectEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/editor/ServiceRecordEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/editor/TreasuryEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/editor/common/Editors.java
lis-ui/src/main/java/hu/user/lis/ui/editor/common/EntityAttachmentEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/editor/common/EntityEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/editor/validator/ImportInvoiceApproveFormValidator.java
lis-ui/src/main/java/hu/user/lis/ui/editor/validator/ImportInvoiceAssignFormValidator.java
lis-ui/src/main/java/hu/user/lis/ui/event/SaveEntityWithAttachmentEvent.java
lis-ui/src/main/java/hu/user/lis/ui/view/IndexViewModel.java
lis-ui/src/main/java/hu/user/lis/ui/view/ServiceRecordsViewModel.java
lis-ui/src/main/resources/web/editor/project/project-associates.zul
lis-ui/src/main/resources/web/editor/treasury-editor.zul
lis-ui/src/main/resources/web/form/invoice-form.zul
lis-ui/src/main/resources/web/service-records.zul

index 87d2166d05323946f5810206780b693bca652029..38c7bc49a00ac619b2f7345e441271a22b92c05f 100644 (file)
@@ -5,7 +5,6 @@
 
 package hu.user.lis;
 
-import com.google.common.collect.Sets;
 import hu.user.lis.db.Associate;
 import hu.user.lis.db.Project;
 import hu.user.lis.db.Treasury;
@@ -21,6 +20,7 @@ import org.springframework.context.annotation.ComponentScan;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -76,7 +76,7 @@ public class ReflectionsIT {
                 .build();
         Project project = Project.builder()
                 .id(1L)
-                .treasuries(Sets.newHashSet(treasury))
+                .treasuries(Collections.singletonList(treasury))
                 .build();
         Project clone = SerializationUtils.clone(project);
         Treasury cloneTreasury = (Treasury) clone.getTreasuries().toArray()[0];
@@ -96,7 +96,7 @@ public class ReflectionsIT {
                 .build();
         Project project = Project.builder()
                 .id(1L)
-                .treasuries(Sets.newHashSet(treasury1, treasury2))
+                .treasuries(Arrays.asList(treasury1, treasury2))
                 .build();
         Project clone = SerializationUtils.clone(project);
         Treasury treasury3 = Treasury.builder()
@@ -107,7 +107,7 @@ public class ReflectionsIT {
                 .id(2L)
                 .humanId("Test2")
                 .build();
-        clone.setTreasuries(Sets.newHashSet(treasury4, treasury3));
+        clone.setTreasuries(Arrays.asList(treasury4, treasury3));
         assertTrue(entityDataService.areEquals(project, clone));
     }
 }
diff --git a/lis-db/migrations/scripts/018_add_signed_to_service_record.sql b/lis-db/migrations/scripts/018_add_signed_to_service_record.sql
new file mode 100644 (file)
index 0000000..9d1a07c
--- /dev/null
@@ -0,0 +1,10 @@
+-- // add signed to service_record
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE service_record ADD COLUMN signed SMALLINT NOT NULL DEFAULT 0;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+ALTER TABLE service_record DROP COLUMN signed;
+CALL SYSPROC.ADMIN_CMD('REORG TABLE service_record');
diff --git a/lis-db/migrations/scripts/019_add_order_to_treasury.sql b/lis-db/migrations/scripts/019_add_order_to_treasury.sql
new file mode 100644 (file)
index 0000000..c46fefa
--- /dev/null
@@ -0,0 +1,10 @@
+-- // add order to treasury
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE treasury ADD COLUMN pos SMALLINT NOT NULL DEFAULT 0;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+ALTER TABLE treasury DROP COLUMN pos;
+CALL SYSPROC.ADMIN_CMD('REORG TABLE treasury');
diff --git a/lis-db/migrations/scripts/020_add_order_to_invoice.sql b/lis-db/migrations/scripts/020_add_order_to_invoice.sql
new file mode 100644 (file)
index 0000000..05a6d6c
--- /dev/null
@@ -0,0 +1,10 @@
+-- // add order to invoice
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE invoice ADD COLUMN pos SMALLINT NOT NULL DEFAULT 0;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+ALTER TABLE invoice DROP COLUMN pos;
+CALL SYSPROC.ADMIN_CMD('REORG TABLE invoice');
diff --git a/lis-db/migrations/scripts/021_add_technical_id_to_invoice.sql b/lis-db/migrations/scripts/021_add_technical_id_to_invoice.sql
new file mode 100644 (file)
index 0000000..d3fc241
--- /dev/null
@@ -0,0 +1,10 @@
+-- // add order to invoice
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE invoice ADD COLUMN technical_id VARCHAR(8);
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+ALTER TABLE invoice DROP COLUMN technical_id;
+CALL SYSPROC.ADMIN_CMD('REORG TABLE invoice');
diff --git a/lis-db/migrations/scripts/022_add_technical_id_to_treasury.sql b/lis-db/migrations/scripts/022_add_technical_id_to_treasury.sql
new file mode 100644 (file)
index 0000000..9fbf255
--- /dev/null
@@ -0,0 +1,10 @@
+-- // add order to treasury
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE treasury ADD COLUMN technical_id VARCHAR(8);
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+ALTER TABLE treasury DROP COLUMN technical_id;
+CALL SYSPROC.ADMIN_CMD('REORG TABLE treasury');
diff --git a/lis-db/migrations/scripts/023_remove_file.sql b/lis-db/migrations/scripts/023_remove_file.sql
new file mode 100644 (file)
index 0000000..411e61d
--- /dev/null
@@ -0,0 +1,23 @@
+-- // remove file
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE treasury DROP COLUMN file;
+CALL SYSPROC.ADMIN_CMD('REORG TABLE treasury');
+
+ALTER TABLE invoice DROP COLUMN file;
+CALL SYSPROC.ADMIN_CMD('REORG TABLE invoice');
+
+ALTER TABLE service_record DROP COLUMN file;
+CALL SYSPROC.ADMIN_CMD('REORG TABLE service_record');
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+ALTER TABLE treasury ADD COLUMN file BLOB;
+CALL SYSPROC.ADMIN_CMD('REORG TABLE treasury');
+
+ALTER TABLE invoice ADD COLUMN file BLOB;
+CALL SYSPROC.ADMIN_CMD('REORG TABLE invoice');
+
+ALTER TABLE service_record ADD COLUMN file BLOB;
+CALL SYSPROC.ADMIN_CMD('REORG TABLE service_record');
index 6a679bf135be4314c7e0c53bf2be6451776c68ac..2ead6ae8da23687e99c1ba324846fc5331ab25d1 100644 (file)
@@ -1,27 +1,30 @@
 package hu.user.lis.db;
 
-import lombok.*;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.SuperBuilder;
 
 import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import java.io.Serializable;
 
 @Getter
 @Setter
 @Entity
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-public class Associate implements Serializable {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    Long id;
-    String name;
-    String login;
-    String password;
-    double monthlyCost;
-    boolean active;
-    boolean remotelyAuthenticated;
+public class Associate extends IdEntity {
+
+    private String name;
+
+    private String login;
+
+    private String password;
+
+    private double monthlyCost;
+
+    private boolean active;
+
+    private boolean remotelyAuthenticated;
 }
index 1b30c931e3cfedc8013a149f2547e5afdea453e4..4c3d50974e4bbd32737c92a4de2118a67e5abf90 100644 (file)
@@ -11,6 +11,4 @@ public enum Currency {
     Currency(int val) {
         this.val = val;
     }
-
-
 }
index 06a36accad75ba58adb66ee000dce81cfaddc379..c3456026d2d997e9e5138d2037b03e8ec480c777 100644 (file)
@@ -1,22 +1,23 @@
 package hu.user.lis.db;
 
-import lombok.*;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.SuperBuilder;
 import org.hibernate.annotations.CreationTimestamp;
 
-import javax.persistence.*;
-import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
 import java.util.Date;
 
 @Getter
 @Setter
 @Entity
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-public class EDocument implements Serializable {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    private Long id;
+public class EDocument extends IdEntity {
 
     @Column(nullable = false)
     private Long referenceId;
diff --git a/lis-db/src/main/java/hu/user/lis/db/IdEntity.java b/lis-db/src/main/java/hu/user/lis/db/IdEntity.java
new file mode 100644 (file)
index 0000000..ed6cc07
--- /dev/null
@@ -0,0 +1,27 @@
+package hu.user.lis.db;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.SuperBuilder;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import java.io.Serializable;
+
+@Getter
+@Setter
+@SuperBuilder
+@MappedSuperclass
+@NoArgsConstructor
+@AllArgsConstructor
+public class IdEntity implements Serializable {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+}
index eb53cc150013e5a7f09f8cf5fb4a9be84420f370..8c1ba48f4b31ed1d8bd9ef08f8cfffdb563461cd 100644 (file)
@@ -1,5 +1,6 @@
 package hu.user.lis.db;
 
+import lombok.NoArgsConstructor;
 import lombok.experimental.SuperBuilder;
 
 import javax.persistence.DiscriminatorValue;
@@ -7,9 +8,7 @@ import javax.persistence.Entity;
 
 @Entity
 @SuperBuilder
+@NoArgsConstructor
 @DiscriminatorValue("1")
 public class IncomingInvoice extends Invoice {
-    public IncomingInvoice() {
-        incoming = true;
-    }
 }
index 3be87a4b7840f3766994edbb164040ec59c10217..8c5fe92172fcbbffd7f72227c95a4f810d7b3500 100644 (file)
@@ -7,7 +7,6 @@ import lombok.Setter;
 import lombok.experimental.SuperBuilder;
 
 import javax.persistence.*;
-import java.io.Serializable;
 import java.util.Date;
 
 @Getter
@@ -17,47 +16,45 @@ import java.util.Date;
 @NoArgsConstructor
 @DiscriminatorColumn(name = "incoming", discriminatorType = DiscriminatorType.INTEGER)
 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-public class Invoice implements Serializable {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    Long id;
+public class Invoice extends IdEntity {
 
-    String humanId;
+    @OneToOne
+    @JoinColumn(name = "partner_id")
+    @JsonIncludeProperties({"id"})
+    private Partner partner;
 
-    String title;
+    @ManyToOne
+    @JoinColumn(name = "project_id")
+    @JsonIncludeProperties({"id"})
+    private Project project;
 
-    Currency currency;
+    private String humanId;
 
-    double netAmount;
+    private String title;
 
-    double grossAmount;
+    private Currency currency;
 
-    double vatAmount;
+    private double netAmount;
 
-    Date completionDate;
+    private double grossAmount;
 
-    Date createDate;
+    private double vatAmount;
 
-    Date paymentDeadline;
+    private Date completionDate;
 
-    @Column(nullable = false, insertable = false, updatable = false)
-    boolean incoming;
+    private Date createDate;
 
-    InvoiceStatus status;
+    private Date paymentDeadline;
 
-    boolean paid;
+    private InvoiceStatus status;
 
-    boolean planned;
+    @Column(nullable = false, insertable = false, updatable = false)
+    private boolean incoming;
 
-    byte[] file;
+    private boolean planned;
 
-    @OneToOne
-    @JoinColumn(name = "partner_id")
-    @JsonIncludeProperties({"id"})
-    Partner partner;
+    private boolean paid;
+
+    private String technicalId;
 
-    @ManyToOne
-    @JoinColumn(name = "project_id")
-    @JsonIncludeProperties({"id"})
-    Project project;
 }
index 9ade1548225867dc37d334dee9b022c7c0b140c3..6d1df7a90e0a92e6edea2b5f107e6e576ab90104 100644 (file)
@@ -2,24 +2,24 @@ package hu.user.lis.db;
 
 import com.fasterxml.jackson.annotation.JsonIncludeProperties;
 import hu.user.lis.db.converter.StringListConverter;
-import lombok.*;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.SuperBuilder;
 import org.hibernate.annotations.CreationTimestamp;
 
 import javax.persistence.*;
-import java.io.Serializable;
 import java.util.Date;
 import java.util.List;
 
 @Getter
 @Setter
 @Entity
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-public class InvoiceImport implements Serializable {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    private Long id;
+public class InvoiceImport extends IdEntity {
 
     @ManyToOne
     @JoinColumn(name = "invoice_id")
index c7387c0cb6634c7f358037b88c2d5a297ddc74d1..c6eb7e74a40e4ef4afdacb71cf9d5d1899b5509c 100644 (file)
@@ -5,12 +5,13 @@ import lombok.Getter;
 
 @Getter
 public enum InvoiceStatus {
+
     INACTIVE(0), ACTIVE(1), SUSPENDED(2);
-    final int val;
+
+    private final int val;
 
     InvoiceStatus(int val) {
         this.val = val;
     }
 
-
 }
index 8b09f36947faffc8bdd01ab275ab6ff46b3c7476..a69bf52f017725ad0cf8236cabfe74403e0c74f0 100644 (file)
@@ -1,34 +1,35 @@
 package hu.user.lis.db;
 
-import lombok.*;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.SuperBuilder;
 
-import javax.persistence.*;
-import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
 
 @Getter
 @Setter
 @Entity
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-public class Partner implements Serializable {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    Long id;
+public class Partner extends IdEntity {
 
-    String name;
+    private String name;
 
     @Column(nullable = false)
-    String shortName;
+    private String shortName;
 
     @Column(unique = true)
-    String vatNr;
+    private String vatNr;
 
-    String address;
+    private String address;
 
-    String orderDescription;
+    private String orderDescription;
 
-    boolean active;
+    private boolean active;
 
-    boolean createdByImport;
+    private boolean createdByImport;
 }
index 0937d61cdb0843aa01aef4f7168092daf3cb0d37..cb0df9579463a5e82324ee27cd248599e9cbb60b 100644 (file)
@@ -1,28 +1,35 @@
 package hu.user.lis.db;
 
 import com.fasterxml.jackson.annotation.JsonIncludeProperties;
-import lombok.*;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.SuperBuilder;
 
-import javax.persistence.*;
-import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
 import java.util.Date;
 
 @Getter
 @Setter
 @Entity
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-public class Payment implements Serializable {
+public class Payment extends IdEntity {
+
     @ManyToOne
     @JoinColumn(name = "invoice_id")
     @JsonIncludeProperties({"id"})
-    Invoice invoice;
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    Long id;
-    double netAmount;
-    double grossAmount;
-    double vatAmount;
-    Date paymentDate;
+    private Invoice invoice;
+
+    private double netAmount;
+
+    private double grossAmount;
+
+    private double vatAmount;
+
+    private Date paymentDate;
 }
index 1e800a8ddd921413ef83a7608077a3c83ccae6df..ed008ff0c2dd939af68c2e8fe98db83294233ac8 100644 (file)
@@ -1,24 +1,24 @@
 package hu.user.lis.db;
 
-import lombok.*;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.SuperBuilder;
 
 import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import java.io.Serializable;
 
 @Getter
 @Setter
 @Entity
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-public class Profile implements Serializable {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    Long id;
-    String login;
-    String type;
-    String setting;
+public class Profile extends IdEntity {
+
+    private String login;
+
+    private String type;
+
+    private String setting;
 }
index bb2b0c23c35a83a29db97ec9d1667e6666bccf23..daab3ae5bdd28a4098254f02a5565de53ad99d21 100644 (file)
@@ -1,60 +1,63 @@
 package hu.user.lis.db;
 
 import com.fasterxml.jackson.annotation.JsonIncludeProperties;
-import lombok.*;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.SuperBuilder;
 import org.hibernate.annotations.Fetch;
 import org.hibernate.annotations.FetchMode;
 import org.hibernate.annotations.Where;
 
 import javax.persistence.*;
-import java.io.Serializable;
-import java.util.Set;
+import java.util.List;
 
 @Getter
 @Setter
 @Entity
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-public class Project implements Serializable {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    Long id;
+public class Project extends IdEntity {
 
     @ManyToOne
     @JoinColumn(name = "project_status_id")
-    ProjectStatus projectStatus;
+    private ProjectStatus projectStatus;
 
     @ManyToOne
     @Fetch(FetchMode.JOIN)
     @JsonIncludeProperties({"id"})
-    Partner partner;
+    private Partner partner;
 
     @OneToMany(targetEntity = IncomingInvoice.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
     @JoinColumn(name = "project_id", referencedColumnName = "id")
     @Where(clause = "incoming=1")
     @Fetch(FetchMode.JOIN)
+    @OrderColumn(name = "pos")
     @JsonIncludeProperties({"id"})
-    Set<IncomingInvoice> incomingInvoices;
+    private List<IncomingInvoice> incomingInvoices;
 
     @OneToMany(targetEntity = OutgoingInvoice.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
     @JoinColumn(name = "project_id", referencedColumnName = "id")
     @Where(clause = "incoming=0")
     @Fetch(FetchMode.JOIN)
+    @OrderColumn(name = "pos")
     @JsonIncludeProperties({"id"})
-    Set<OutgoingInvoice> outgoingInvoices;
+    private List<OutgoingInvoice> outgoingInvoices;
 
     @OneToMany(targetEntity = Treasury.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
     @JoinColumn(name = "project_id", referencedColumnName = "id")
     @Fetch(FetchMode.JOIN)
+    @OrderColumn(name = "pos")
     @JsonIncludeProperties({"id"})
-    Set<Treasury> treasuries;
+    private List<Treasury> treasuries;
 
-    String name;
+    private String name;
 
-    String humanId;
+    private String humanId;
 
-    String contactName;
+    private String contactName;
 
-    boolean active;
+    private boolean active;
 }
index 8cf69ce39e3684f0fd3ccbb3558fb18d6324b124..d231d32bd0f4f044b41fe2f8c1f50fa6c50056d4 100644 (file)
@@ -1,23 +1,23 @@
 package hu.user.lis.db;
 
-import lombok.*;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.SuperBuilder;
 
 import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import java.io.Serializable;
 
 @Getter
 @Setter
 @Entity
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-public class ProjectAssociate implements Serializable {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    Long id;
-    Long projectId;
-    Long associateId;
+public class ProjectAssociate extends IdEntity {
+
+    private Long projectId;
+
+    private Long associateId;
+
 }
index 759cc6a19df63f5ee06605d6d0761fdde58cf1c7..3ccdc94e9b73d04da5b8a8323580727fbd26cabc 100644 (file)
@@ -1,24 +1,24 @@
 package hu.user.lis.db;
 
-import lombok.*;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.SuperBuilder;
 
 import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import java.io.Serializable;
 
 @Getter
 @Setter
 @Entity
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-public class ProjectStatus implements Serializable {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    Long id;
-    String name;
-    boolean active;
-    int order;
+public class ProjectStatus extends IdEntity {
+
+    private String name;
+
+    private boolean active;
+
+    private int order;
 }
index 44d9d27852d924e732bf51b6663b407ef2d5a6c6..cd17d2722162a16df1832869ae8ce7955dbcf2b0 100644 (file)
@@ -1,22 +1,24 @@
 package hu.user.lis.db;
 
 import com.fasterxml.jackson.annotation.JsonIncludeProperties;
-import lombok.*;
-
-import javax.persistence.*;
-import java.io.Serializable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.SuperBuilder;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
 import java.util.Date;
 
 @Getter
 @Setter
 @Entity
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-public class ServiceRecord implements Serializable {
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    private Long id;
+public class ServiceRecord extends IdEntity {
 
     @ManyToOne
     @JoinColumn(name = "project_id")
@@ -37,6 +39,7 @@ public class ServiceRecord implements Serializable {
     private int workHours;
 
     private double cost;
-    
-    private byte[] file;
+
+    private boolean signed;
+
 }
diff --git a/lis-db/src/main/java/hu/user/lis/db/Supplier.java b/lis-db/src/main/java/hu/user/lis/db/Supplier.java
deleted file mode 100644 (file)
index 11e6ded..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package hu.user.lis.db;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter;
-import lombok.Setter;
-
-@Getter
-@Setter
-@Builder
-@AllArgsConstructor
-public class Supplier {
-    String id;
-    String name;
-    String zipCode;
-}
index acf1836d84c4994729bed66dfb96831221481fba..a0adcd729913d039b4df0599396b310d61a6407b 100644 (file)
@@ -1,45 +1,44 @@
 package hu.user.lis.db;
 
-import lombok.*;
+import com.fasterxml.jackson.annotation.JsonIncludeProperties;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.SuperBuilder;
 
 import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import java.io.Serializable;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
 import java.util.Date;
 
 @Getter
 @Setter
 @Entity
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
-public class Treasury implements Serializable {
+public class Treasury extends IdEntity {
 
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    Long id;
+    @ManyToOne
+    @JoinColumn(name = "project_id")
+    @JsonIncludeProperties({"id"})
+    private Project project;
 
-    String humanId;
+    private String humanId;
 
-    double buyAmount;
+    private double buyAmount;
 
-    Currency buyCurrency;
+    private Currency buyCurrency;
 
-    double sellAmount;
+    private double sellAmount;
 
-    Currency sellCurrency;
+    private Currency sellCurrency;
 
-    Date transactionDate;
+    private Date transactionDate;
 
-    Date valueDate;
+    private Date valueDate;
 
-    byte[] file;
-
-//    @ManyToOne(fetch = FetchType.LAZY)
-//    @JoinColumn(name = "project_id")
-//    @JsonIncludeProperties({"id"})
-//    Project project;
+    private String technicalId;
 
 }
index 7b913e3d596068ea1ad9e9267c62f8e5cde205f8..35697da4e959f7c1df1a303f20e9ff318ce41bbc 100644 (file)
@@ -2,10 +2,15 @@ package hu.user.lis.db.repository;
 
 import hu.user.lis.db.EDocument;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
 
 import java.util.List;
 
 public interface EDocumentRepository extends JpaRepository<EDocument, Long> {
     List<EDocument> findByReferenceIdAndDocumentType(Long referenceId, String documentType);
 
+    @Modifying
+    @Query("UPDATE EDocument e SET e.referenceId = :referenceId WHERE e.id IN (:ids)")
+    void attach(Long referenceId, List<Long> ids);
 }
index ec1767fdd71b8cc26a8b42e2df40f6cf99560f75..e1827beb1abd396981e48be90570f11c79a98019 100644 (file)
@@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
 import java.util.Objects;
-import java.util.Set;
 
 @Log4j2
 @RestController
@@ -43,7 +42,7 @@ public class ProjectApi extends DbApi<Project, ProjectRepository, ProjectService
     @Override
     protected void afterSave(List<Project> entities) {
         entities.forEach(p -> {
-            Set<IncomingInvoice> incomingInvoices = p.getIncomingInvoices();
+            List<IncomingInvoice> incomingInvoices = p.getIncomingInvoices();
             if (Objects.nonNull(incomingInvoices)) {
                 incomingInvoices.forEach(i -> {
 //                    i.setProject(p);
@@ -51,7 +50,7 @@ public class ProjectApi extends DbApi<Project, ProjectRepository, ProjectService
                 });
             }
 
-            Set<OutgoingInvoice> outgoingInvoices = p.getOutgoingInvoices();
+            List<OutgoingInvoice> outgoingInvoices = p.getOutgoingInvoices();
             if (Objects.nonNull(outgoingInvoices)) {
                 outgoingInvoices.forEach(i -> {
 //                    i.setProject(p);
@@ -59,7 +58,7 @@ public class ProjectApi extends DbApi<Project, ProjectRepository, ProjectService
                 });
             }
 
-            Set<Treasury> treasuries = p.getTreasuries();
+            List<Treasury> treasuries = p.getTreasuries();
             treasuries.forEach(t -> {
 //                t.setProject(p);
                 treasuryRepository.save(t);
diff --git a/lis-service/src/main/java/hu/user/lis/service/data/EDocumentService.java b/lis-service/src/main/java/hu/user/lis/service/data/EDocumentService.java
deleted file mode 100644 (file)
index 975169a..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package hu.user.lis.service.data;
-
-import hu.user.lis.db.EDocument;
-
-public interface EDocumentService extends DataService<EDocument> {
-    EDocument createNew();
-
-    void add(EDocument entity);
-}
diff --git a/lis-service/src/main/java/hu/user/lis/service/data/EDocumentServiceImpl.java b/lis-service/src/main/java/hu/user/lis/service/data/EDocumentServiceImpl.java
deleted file mode 100644 (file)
index 3fd291a..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package hu.user.lis.service.data;
-
-import hu.user.lis.db.EDocument;
-import lombok.extern.log4j.Log4j2;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Service
-@Log4j2
-public class EDocumentServiceImpl extends DataServiceImpl<EDocument> implements EDocumentService {
-    @Autowired
-    DataGeneratorService dataGeneratorService;
-    private List<EDocument> entities;
-
-    @Override
-    public List<EDocument> getAll() {
-        if (entities == null) {
-            entities = new ArrayList<>();
-        }
-        return entities;
-    }
-
-    @Override
-    public EDocument createNew() {
-        return EDocument.builder().build();
-    }
-
-    @Override
-    public void add(EDocument entity) {
-        entities.add(entity);
-    }
-
-}
diff --git a/lis-service/src/main/java/hu/user/lis/service/data/EntityDocumentAction.java b/lis-service/src/main/java/hu/user/lis/service/data/EntityDocumentAction.java
new file mode 100644 (file)
index 0000000..e0984c0
--- /dev/null
@@ -0,0 +1,19 @@
+package hu.user.lis.service.data;
+
+import lombok.*;
+
+@Getter
+@Setter
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class EntityDocumentAction {
+
+    private boolean attach;
+
+    private Long documentId;
+
+    public boolean isDetach() {
+        return !attach;
+    }
+}
diff --git a/lis-service/src/main/java/hu/user/lis/service/data/EntityDocumentService.java b/lis-service/src/main/java/hu/user/lis/service/data/EntityDocumentService.java
new file mode 100644 (file)
index 0000000..4e344a4
--- /dev/null
@@ -0,0 +1,26 @@
+package hu.user.lis.service.data;
+
+import hu.user.lis.db.repository.EDocumentRepository;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+@Log4j2
+public class EntityDocumentService {
+    @Autowired
+    private EDocumentRepository eDocumentRepository;
+
+    @Transactional
+    public void executeActions(Long referenceId, List<EntityDocumentAction> actions) {
+        List<Long> idsToAttach = actions.stream().filter(EntityDocumentAction::isAttach).map(EntityDocumentAction::getDocumentId).collect(Collectors.toList());
+        eDocumentRepository.attach(referenceId, idsToAttach);
+        List<Long> idsToRemove = actions.stream().filter(EntityDocumentAction::isDetach).map(EntityDocumentAction::getDocumentId).collect(Collectors.toList());
+        eDocumentRepository.deleteAllById(idsToRemove);
+    }
+
+}
index 39e5b14615c53fe177e83a6082d200fdd3403508..e6518b3f822e9651ddfc59e06bd3c31c4baf2230 100644 (file)
@@ -12,7 +12,6 @@ import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashSet;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
@@ -63,9 +62,9 @@ public class ProjectServiceImpl extends DataServiceImpl<Project> implements Proj
         ProjectStatus projectStatus = projectStatusService.getAll().get(0);
         return Project.builder()
                 .projectStatus(projectStatus)
-                .incomingInvoices(new HashSet<>())
-                .outgoingInvoices(new HashSet<>())
-                .treasuries(new HashSet<>())
+//                .incomingInvoices(new HashSet<>())
+//                .outgoingInvoices(new HashSet<>())
+                .treasuries(new ArrayList<>())
                 .active(true)
                 .build();
     }
@@ -106,7 +105,7 @@ public class ProjectServiceImpl extends DataServiceImpl<Project> implements Proj
                     .partner(partner)
 //                    .incomingInvoices(invoiceService.getRandom(true))
 //                    .outgoingInvoices(invoiceService.getRandom(false))
-                    .treasuries(new HashSet<>())
+                    .treasuries(new ArrayList<>())
                     .build();
             result.add(entity);
         }
@@ -131,7 +130,7 @@ public class ProjectServiceImpl extends DataServiceImpl<Project> implements Proj
                 .partner(partner)
 //                .incomingInvoices(invoiceService.getByHumanIds(new String[]{"VSz-2023/00070-"}))   // VSz-2023/00070-
 //                .outgoingInvoices(invoiceService.getByHumanIds(new String[]{"USER-2023-7"}))  // USER-2023-7
-                .treasuries(new HashSet<>())
+//                .treasuries(new HashSet<>())
                 .build();
         result.add(entity);
 
@@ -148,7 +147,7 @@ public class ProjectServiceImpl extends DataServiceImpl<Project> implements Proj
                 .partner(partner)
 //                .incomingInvoices(invoiceService.getByHumanIds(new String[]{"582-SPI1003006-3021", "582-SPI003118", "582-SPI003680", "582-SPI003681", "582-SPI004090", "9090010764", "VSz-2021/00091"}))   // 582-SPI1003006-3021, 582-SPI003118, 582-SPI003680, 582-SPI003681, 582-SPI004090, 9090010764, VSz-2021/00091
 //                .outgoingInvoices(invoiceService.getByHumanIds(new String[]{"2021/0001", "2021/0069"}))  // 2021/0001, 2021/0069
-                .treasuries(treasuryService.getByHumanIds(new String[]{"014", "015"}))
+//                .treasuries(treasuryService.getByHumanIds(new String[]{"014", "015"}))
                 .build();
         result.add(entity);
 
@@ -165,7 +164,7 @@ public class ProjectServiceImpl extends DataServiceImpl<Project> implements Proj
                 .partner(partner)
 //                .incomingInvoices(invoiceService.getByHumanIds(new String[]{"EURSZLA0177/2022", "19044", "9171058452", "9171058628", "2022-SOV/000495", "2022-SOV/000496", "E-SYMPR-2022-105"}))   // EURSZLA0177/2022, 19044, 9171058452, 9171058628, V-SZ3-2022/00001, 2022-SOV/000495, 2022-SOV/000496, E-SYMPR-2022-105
 //                .outgoingInvoices(invoiceService.getByHumanIds(new String[]{"E-USER-2023-12", "E-USER-2023-13"}))  // E-USER-2023-12, E-USER-2023-13
-                .treasuries(treasuryService.getByHumanIds(new String[]{"001", "002", "003", "004", "005", "006", "007", "008", "009", "010", "011"}))
+//                .treasuries(treasuryService.getByHumanIds(new String[]{"001", "002", "003", "004", "005", "006", "007", "008", "009", "010", "011"}))
                 .build();
         result.add(entity);
 
@@ -182,7 +181,7 @@ public class ProjectServiceImpl extends DataServiceImpl<Project> implements Proj
                 .partner(partner)
 //                .incomingInvoices(invoiceService.getByHumanIds(new String[]{"17356/23"}))   // 17356/23
 //                .outgoingInvoices(invoiceService.getByHumanIds(new String[]{"E-USER-2023-53"}))  // E-USER-2023-53
-                .treasuries(new HashSet<>())
+//                .treasuries(new HashSet<>())
                 .build();
         result.add(entity);
 
@@ -199,7 +198,7 @@ public class ProjectServiceImpl extends DataServiceImpl<Project> implements Proj
                 .partner(partner)
 //                .incomingInvoices(invoiceService.getByHumanIds(new String[]{"2023-SOV/000123"}))   // 2023-SOV/000123
 //                .outgoingInvoices(invoiceService.getByHumanIds(new String[]{"E-USER-2023-95"}))  // E-USER-2023-95
-                .treasuries(treasuryService.getByHumanIds(new String[]{"012", "013"}))
+//                .treasuries(treasuryService.getByHumanIds(new String[]{"012", "013"}))
                 .build();
         result.add(entity);
 
diff --git a/lis-service/src/main/java/hu/user/lis/service/data/SupplierService.java b/lis-service/src/main/java/hu/user/lis/service/data/SupplierService.java
deleted file mode 100644 (file)
index 2365833..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package hu.user.lis.service.data;
-
-import hu.user.lis.db.Supplier;
-
-public interface SupplierService extends DataService<Supplier> {
-}
diff --git a/lis-service/src/main/java/hu/user/lis/service/data/SupplierServiceImpl.java b/lis-service/src/main/java/hu/user/lis/service/data/SupplierServiceImpl.java
deleted file mode 100644 (file)
index 57b6cc5..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-package hu.user.lis.service.data;
-
-import hu.user.lis.db.Supplier;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Service
-public class SupplierServiceImpl extends DataServiceImpl<Supplier> implements SupplierService {
-    @Autowired
-    DataGeneratorService dataGeneratorService;
-    private List<Supplier> suppliers;
-
-    @Override
-    public List<Supplier> getAll() {
-        if (suppliers == null) {
-            suppliers = generate();
-        }
-        return suppliers;
-    }
-
-    private List<Supplier> generate() {
-        List<Supplier> result = new ArrayList<>();
-        for (int i = 0; i < 100; i++) {
-            String name = dataGeneratorService.faker().name().fullName();
-            String zipCode = RandomStringUtils.random(4, "0123456789");
-            Supplier supplier = Supplier.builder().name(name).zipCode(zipCode).build();
-            result.add(supplier);
-        }
-        return result;
-    }
-}
index 949adbfcaa4bba0e232a2c1cf605ca9ddc060d2c..2b23b1182ff5449d6740d6acd0ffa3328a3a659b 100644 (file)
@@ -25,7 +25,6 @@ public interface InvoiceMapper {
     @Mapping(target = "id", ignore = true)
     @Mapping(target = "title", ignore = true)
     @Mapping(target = "planned", ignore = true)
-    @Mapping(target = "file", ignore = true)
     @Mapping(target = "partner", ignore = true)
     @Mapping(target = "project", ignore = true)
     IncomingInvoice toEntity(InvoiceData source);
diff --git a/lis-ui/src/main/java/hu/user/lis/ui/converter/SupplierToNameConverter.java b/lis-ui/src/main/java/hu/user/lis/ui/converter/SupplierToNameConverter.java
deleted file mode 100644 (file)
index 1087c38..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-package hu.user.lis.ui.converter;
-
-import hu.user.lis.db.Supplier;
-import org.zkoss.bind.BindContext;
-import org.zkoss.bind.Converter;
-import org.zkoss.zul.Bandbox;
-
-public class SupplierToNameConverter implements Converter<String, Supplier, Bandbox> {
-
-    @Override
-    public String coerceToUi(Supplier supplier, Bandbox bandbox, BindContext bindContext) {
-        return supplier == null ? null : supplier.getName();
-    }
-
-    @Override
-    public Supplier coerceToBean(String s, Bandbox bandbox, BindContext bindContext) {
-        return null;
-    }
-}
\ No newline at end of file
index dbf8f122df81d7d38662215fa9edb66fa92dcca9..13815b5e24dfd2dbf824b651dc0affdde3076bba 100644 (file)
@@ -1,7 +1,10 @@
 package hu.user.lis.ui.data;
 
 import hu.user.lis.db.EDocument;
+import hu.user.lis.db.IdEntity;
 import hu.user.lis.db.repository.EDocumentRepository;
+import hu.user.lis.service.data.EntityDocumentAction;
+import lombok.Getter;
 import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@@ -10,19 +13,22 @@ import org.springframework.stereotype.Component;
 import org.zkoss.bind.BindUtils;
 import org.zkoss.bind.annotation.Command;
 import org.zkoss.zul.ListModelList;
+import org.zkoss.zul.Messagebox;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Log4j2
 @Component
 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 public class EntityDocumentDataModel extends ListModelList<EDocument> {
-    private final List<EDocument> added = new ArrayList<>();
-    private final List<EDocument> removed = new ArrayList<>();
+
+    @Getter
+    private final List<EntityDocumentAction> actions = new ArrayList<>();
+
     @Autowired
     private EDocumentRepository eDocumentRepository;
 
-
     public EDocument getSelectedDocument() {
         EDocument result = null;
         Set<EDocument> documents = getSelection();
@@ -33,7 +39,6 @@ public class EntityDocumentDataModel extends ListModelList<EDocument> {
         return result;
     }
 
-
     public void setSelectedDocument(EDocument document) {
         clearSelection();
         if (Objects.nonNull(document)) {
@@ -42,36 +47,53 @@ public class EntityDocumentDataModel extends ListModelList<EDocument> {
         BindUtils.postNotifyChange(this, "selectedDocument");
     }
 
-    public void refresh(Long referenceId, String documentType) {
+    public void refresh(IdEntity formDocument, String documentType, List<EntityDocumentAction> actions) {
         clear();
-        List<EDocument> documents = eDocumentRepository.findByReferenceIdAndDocumentType(referenceId, documentType);
-        addAll(documents);
-        if (!documents.isEmpty()) {
-            setSelectedDocument(documents.stream().findFirst().get());
+        if (Objects.nonNull(formDocument.getId())) {
+            if (Objects.nonNull(actions)) {
+                List<Long> ids = actions.stream().filter(EntityDocumentAction::isAttach).map(EntityDocumentAction::getDocumentId).collect(Collectors.toList());
+                if (!ids.isEmpty()) {
+                    List<EDocument> allById = eDocumentRepository.findAllById(ids);
+                    addAll(allById);
+                }
+            }
+
+            List<EDocument> documents = eDocumentRepository.findByReferenceIdAndDocumentType(formDocument.getId(), documentType);
+            addAll(documents);
+
+            if (!getInnerList().isEmpty()) {
+                setSelectedDocument(getInnerList().get(0));
+            }
         }
     }
 
     public void addNew(EDocument document) {
-        added.add(document);
+        long count = getInnerList().stream().filter(d -> d.getName().equals(document.getName()) && d.getSize() == document.getSize()).count();
+        if (count > 0) {
+            Messagebox.show("A fájl már csatolva van.");
+            return;
+        }
+        eDocumentRepository.save(document);
         add(document);
         setSelectedDocument(document);
+        actions.add(EntityDocumentAction.builder().attach(true).documentId(document.getId()).build());
     }
 
     public void remove() {
-        EDocument selectedDocument = getSelectedDocument();
-        removed.add(selectedDocument);
-        setSelectedDocument(null);
-        remove(selectedDocument);
+        EDocument document = getSelectedDocument();
+        if (Objects.nonNull(document)) {
+            actions.add(EntityDocumentAction.builder().documentId(document.getId()).build());
+            setSelectedDocument(null);
+            remove(document);
+        }
     }
 
-    public void save(Long entityId) {
-        eDocumentRepository.deleteAll(removed);
-        added.forEach(d -> d.setReferenceId(entityId));
-        eDocumentRepository.saveAll(added);
+    public boolean hasFiles() {
+        return !getInnerList().isEmpty();
     }
 
     public boolean isChanged() {
-        return !added.isEmpty() || !removed.isEmpty();
+        return !actions.isEmpty();
     }
 
     @Command
index 4e8ef176adacc7a2c51a9c3c9ab0cb29c4a82e5a..78c4c2032276b949805a5545716a281d4db31e22 100644 (file)
@@ -18,21 +18,21 @@ public class IncomeMarginsDataModel extends ArrayList<IncomeMargin> {
     public void recalculate(Project project, ServiceRecordsDataModel serviceRecordsDataModel) {
         clear();
         Map<Currency, Double> balances = new HashMap<>();
-        Set<OutgoingInvoice> outgoingInvoices = project.getOutgoingInvoices();
+        List<OutgoingInvoice> outgoingInvoices = project.getOutgoingInvoices();
         if (Objects.nonNull(outgoingInvoices)) {
             for (Invoice invoice : outgoingInvoices) {
                 addBalance(balances, invoice.getCurrency(), invoice.getNetAmount());
             }
         }
 
-        Set<IncomingInvoice> incomingInvoices = project.getIncomingInvoices();
+        List<IncomingInvoice> incomingInvoices = project.getIncomingInvoices();
         if (Objects.nonNull(incomingInvoices)) {
             for (Invoice invoice : incomingInvoices) {
                 substractBalance(balances, invoice.getCurrency(), invoice.getNetAmount());
             }
         }
 
-        Set<Treasury> treasuries = project.getTreasuries();
+        List<Treasury> treasuries = project.getTreasuries();
         if (Objects.nonNull(treasuries)) {
             for (Treasury treasury : treasuries) {
                 substractBalance(balances, treasury.getSellCurrency(), treasury.getSellAmount());
@@ -51,7 +51,7 @@ public class IncomeMarginsDataModel extends ArrayList<IncomeMargin> {
                 .sorted(Comparator.comparing(IncomeMargin::getCurrency))
                 .collect(Collectors.toCollection(() -> this));
 
-        BindUtils.postNotifyChange(null, null, this, "*");
+        BindUtils.postNotifyChange(this, "*");
     }
 
 
index 90cb340bcf325588d5a6427eb0c179c04587b9b9..bddfd37cc2ce945b5f7a6702e68c92a6abb8c82e 100644 (file)
@@ -8,6 +8,7 @@ import hu.user.lis.db.repository.InvoiceRepository;
 import hu.user.lis.service.data.EntityDataService;
 import hu.user.lis.service.data.InvoiceService;
 import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.RandomStringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -35,11 +36,13 @@ public class InvoiceDataModel {
     }
 
     public IncomingInvoice createNewIncomingInvoice() {
-        return IncomingInvoice.builder().incoming(true).status(InvoiceStatus.ACTIVE).build();
+        String technicalId = RandomStringUtils.random(8, "0123456789abcdef");
+        return IncomingInvoice.builder().incoming(true).technicalId(technicalId).status(InvoiceStatus.ACTIVE).build();
     }
 
     public OutgoingInvoice createNewOutgoingInvoice() {
-        return OutgoingInvoice.builder().status(InvoiceStatus.ACTIVE).build();
+        String technicalId = RandomStringUtils.random(8, "0123456789abcdef");
+        return OutgoingInvoice.builder().technicalId(technicalId).status(InvoiceStatus.ACTIVE).build();
     }
 
     public void save(Invoice modifiedEntity) {
index 09498c7f5fe3f966c5d3926fd77ec54ae8950ad3..1fbd6e32a9cb3ddf954a6f949a0fc8a4c72b598a 100644 (file)
@@ -2,6 +2,7 @@ package hu.user.lis.ui.data;
 
 import hu.user.lis.db.Project;
 import hu.user.lis.db.ProjectStatus;
+import hu.user.lis.db.repository.InvoiceRepository;
 import hu.user.lis.db.repository.ProjectRepository;
 import hu.user.lis.service.data.EntityDataService;
 import hu.user.lis.ui.data.common.CachedSpringDataModel;
@@ -16,7 +17,7 @@ import org.zkoss.zul.FieldComparator;
 import javax.persistence.EntityNotFoundException;
 import java.text.DecimalFormat;
 import java.time.Year;
-import java.util.HashSet;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 
@@ -27,6 +28,9 @@ public class ProjectsDataModel extends CachedSpringDataModel<Project> {
     @Autowired
     ProjectRepository projectRepository;
 
+    @Autowired
+    InvoiceRepository invoiceRepository;
+
     @Autowired
     ProjectStatusDataModel projectStatusDataModel;
 
@@ -83,9 +87,9 @@ public class ProjectsDataModel extends CachedSpringDataModel<Project> {
         ProjectStatus projectStatus = projectStatusDataModel.getDefault();
         return Project.builder()
                 .projectStatus(projectStatus)
-                .incomingInvoices(new HashSet<>())
-                .outgoingInvoices(new HashSet<>())
-                .treasuries(new HashSet<>())
+                .incomingInvoices(new ArrayList<>())
+                .outgoingInvoices(new ArrayList<>())
+                .treasuries(new ArrayList<>())
                 .active(true)
                 .build();
     }
diff --git a/lis-ui/src/main/java/hu/user/lis/ui/data/SuppliersDataModel.java b/lis-ui/src/main/java/hu/user/lis/ui/data/SuppliersDataModel.java
deleted file mode 100644 (file)
index f2813d7..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-package hu.user.lis.ui.data;
-
-import hu.user.lis.db.Supplier;
-import hu.user.lis.service.data.SupplierService;
-import hu.user.lis.ui.data.common.CachedDataModel;
-import lombok.extern.log4j.Log4j2;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.zkoss.bind.BindUtils;
-import org.zkoss.zul.FieldComparator;
-
-import java.util.Comparator;
-import java.util.List;
-import java.util.stream.Collectors;
-
-@Component
-@Log4j2
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class SuppliersDataModel extends CachedDataModel<Supplier> {
-    @Autowired
-    SupplierService supplierService;
-    private String partialName;
-    private String partialZipCode;
-    private boolean listAll;
-
-    private boolean canExecuteSearch() {
-        boolean result = StringUtils.isNotBlank(partialName) || StringUtils.isNotBlank(partialZipCode) || listAll;
-        log.info("Can execute searchByProject: {}", result);
-        return result;
-    }
-
-    private boolean filter(Supplier supplier) {
-        if (listAll) {
-            return true;
-        }
-
-        boolean result = true;
-        if (StringUtils.isNotBlank(partialName)) {
-            if (!supplier.getName().toLowerCase().startsWith(partialName.toLowerCase())) {
-                result = false;
-            }
-        }
-        if (StringUtils.isNotBlank(partialZipCode)) {
-            if (!supplier.getZipCode().toLowerCase().startsWith(partialZipCode.toLowerCase())) {
-                result = false;
-            }
-        }
-        return result;
-    }
-
-    @Override
-    public List<Supplier> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
-        List<Supplier> result = null;
-        if (canExecuteSearch()) {
-            result = supplierService.getAll().stream()
-                    .sorted(Comparator.comparing(Supplier::getName))
-                    .filter(s -> filter(s))
-                    .collect(Collectors.toList());
-        }
-        return result;
-    }
-
-    @Override
-    public int getResultSetCount() {
-        int result = 0;
-        if (canExecuteSearch()) {
-            result = (int) supplierService.getAll().stream()
-                    .filter(s -> filter(s))
-                    .count();
-        }
-        return result;
-    }
-
-    public void search(String partialName, String partialZipCode) {
-        log.info("Searching supplier using filters: name LIKE {}, ZIP code LIKE {}", partialName, partialZipCode);
-        listAll = false;
-        this.partialName = partialName;
-        this.partialZipCode = partialZipCode;
-        super.reset();
-        BindUtils.postNotifyChange(null, null, this, "*");
-    }
-
-    public void listAll() {
-        log.info("List all suppliers");
-        listAll = true;
-        super.reset();
-        BindUtils.postNotifyChange(null, null, this, "*");
-    }
-}
diff --git a/lis-ui/src/main/java/hu/user/lis/ui/data/SuppliersSimpleDataModel.java b/lis-ui/src/main/java/hu/user/lis/ui/data/SuppliersSimpleDataModel.java
deleted file mode 100644 (file)
index b8f6784..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-package hu.user.lis.ui.data;
-
-import hu.user.lis.db.Supplier;
-import hu.user.lis.service.data.SupplierService;
-import hu.user.lis.ui.data.common.CachedDataModel;
-import lombok.extern.log4j.Log4j2;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.zkoss.bind.BindUtils;
-import org.zkoss.zul.FieldComparator;
-
-import java.util.Comparator;
-import java.util.List;
-import java.util.stream.Collectors;
-
-@Component
-@Log4j2
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class SuppliersSimpleDataModel extends CachedDataModel<Supplier> {
-    static private final int SEARCH_LIMIT = 10;
-    @Autowired
-    SupplierService supplierService;
-    private String partialName;
-
-    private boolean filter(Supplier supplier) {
-        if (StringUtils.isBlank(partialName)) {
-            return true;
-        } else {
-            if (supplier.getName().toLowerCase().startsWith(partialName.toLowerCase())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public List<Supplier> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
-        List<Supplier> result = supplierService.getAll().stream()
-                .sorted(Comparator.comparing(Supplier::getName))
-                .filter(s -> filter(s))
-                .limit(SEARCH_LIMIT)
-                .collect(Collectors.toList());
-        return result;
-    }
-
-    @Override
-    public int getResultSetCount() {
-        int result = (int) supplierService.getAll().stream()
-                .filter(s -> filter(s))
-                .limit(SEARCH_LIMIT)
-                .count();
-        return result;
-    }
-
-    public void search(String partialName) {
-        log.info("Searching supplier using filter {}", partialName);
-        this.partialName = partialName;
-        super.reset();
-        BindUtils.postNotifyChange(null, null, this, "*");
-    }
-}
index 8105bebc30c58b46d7dcaa364f6696ea32ae82ad..8bc013230d039f3eac5c4c6e2672047df1a95852 100644 (file)
@@ -3,25 +3,22 @@ package hu.user.lis.ui.editor;
 import hu.user.lis.db.Currency;
 import hu.user.lis.db.Invoice;
 import hu.user.lis.db.Partner;
-import hu.user.lis.ui.editor.common.EntityEditorModel;
+import hu.user.lis.ui.editor.common.EntityAttachmentEditorModel;
 import hu.user.lis.ui.editor.validator.FormValidator;
 import hu.user.lis.ui.editor.validator.InvoiceFormValidator;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.extern.log4j.Log4j2;
-import org.zkoss.bind.BindContext;
 import org.zkoss.bind.BindUtils;
 import org.zkoss.bind.annotation.*;
 import org.zkoss.zk.ui.Component;
 import org.zkoss.zk.ui.event.Event;
-import org.zkoss.zk.ui.event.UploadEvent;
 import org.zkoss.zk.ui.select.annotation.WireVariable;
-import org.zkoss.zul.Messagebox;
 
 @Log4j2
 @Getter
 @Setter
-public class InvoiceEditorModel extends EntityEditorModel<Invoice> {
+public class InvoiceEditorModel extends EntityAttachmentEditorModel<Invoice> {
 
     private boolean vatCalculated;
 
@@ -66,25 +63,6 @@ public class InvoiceEditorModel extends EntityEditorModel<Invoice> {
         return invoiceFormValidator.validate(entity);
     }
 
-    @Command
-    public void onUploadFile(@ContextParam(ContextType.BIND_CONTEXT) BindContext ctx) {
-        UploadEvent evt = (UploadEvent) ctx.getTriggerEvent();
-        if (!evt.getMedia().getName().toLowerCase().endsWith(".pdf")) {
-            Messagebox.show("Csak PDF állomány feltöltése támogatott.", "Error", Messagebox.OK, Messagebox.ERROR);
-            return;
-        }
-        getFormDocument().setFile(evt.getMedia().getByteData());
-        BindUtils.postNotifyChange(getFormDocument(), "file");
-        validate();
-    }
-
-    @Command
-    public void onRemoveFile() {
-        getFormDocument().setFile(null);
-        BindUtils.postNotifyChange(getFormDocument(), "file");
-        validate();
-    }
-
     @Override
     public void onEvent(Event evt) {
         if (isEventForCurrentDocument(evt)) {
index 992ef5ea724085dba3b15600d5ef8e74500611b5..4d642c00d3479ee1de33938c9ff6519700129682 100644 (file)
@@ -2,6 +2,8 @@ package hu.user.lis.ui.editor;
 
 import com.google.common.collect.ImmutableMap;
 import hu.user.lis.db.*;
+import hu.user.lis.service.data.EntityDocumentAction;
+import hu.user.lis.service.data.EntityDocumentService;
 import hu.user.lis.ui.Constants;
 import hu.user.lis.ui.converter.ProjectStatusConverter;
 import hu.user.lis.ui.data.*;
@@ -24,71 +26,65 @@ import org.zkoss.zk.ui.util.Notification;
 import org.zkoss.zul.Panel;
 import org.zkoss.zul.Window;
 
-import java.util.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 @Log4j2
 public class ProjectEditorModel extends EntityEditorModel<Project> {
+    private final Map<String, List<EntityDocumentAction>> invoiceDocumentActions = new HashMap<>();
+    private final Map<String, List<EntityDocumentAction>> treasuryDocumentActions = new HashMap<>();
+
     @Getter
     @Setter
     @WireVariable
     AssociatesDataModel associatesDataModel;
-
     @WireVariable
     ProjectsDataModel projectsDataModel;
-
     @WireVariable
     private InvoiceDataModel invoiceDataModel;
-
     @WireVariable
     private TreasuryDataModel treasuryDataModel;
-
     @Getter
     @Setter
     @WireVariable
     private ServiceRecordsDataModel serviceRecordsDataModel;
-
     @Getter
     @Setter
     @WireVariable
     private ProjectStatusDataModel projectStatusDataModel;
-
     @Getter
     @Setter
     @WireVariable
     private IncomeMarginsDataModel incomeMarginsDataModel;
-
     @WireVariable
     private ProjectAssociatesDataModel projectAssociatesDataModel;
-
     @Getter
     @Setter
     @WireVariable
     private ProjectStatusConverter projectStatusConverter;
-
     private Map<Long, Boolean> origAssociates;
-
     @Getter
     @Setter
     private Map<Long, Boolean> formAssociates;
-
     @Getter
     @Setter
     private IncomingInvoice selectedIncomingInvoice;
-
     @Getter
     @Setter
     private OutgoingInvoice selectedOutgoingInvoice;
-
     @Getter
     @Setter
     private Treasury selectedTreasury;
-
     @Getter
     private String partialAssociateName;
-
     @WireVariable
     private ProjectFormValidator projectFormValidator;
 
+    @WireVariable
+    private EntityDocumentService entityDocumentService;
+
     @Override
     public FormValidator<Project> getFormValidator() {
         return projectFormValidator;
@@ -135,29 +131,32 @@ public class ProjectEditorModel extends EntityEditorModel<Project> {
         BindUtils.postNotifyChange(this, "formDocument");
     }
 
-    @NotifyChange("associatesDataModel")
-    public void setPartialAssociateName(String partialAssociateName) {
-        this.partialAssociateName = partialAssociateName;
-        log.info("Filter assosiates: {}", partialAssociateName);
-        associatesDataModel.search(partialAssociateName);
-    }
-
-    @Command
-    @NotifyChange({"associatesDataModel", "partialAssociateName"})
-    public void onResetAssociateFilter() {
-        this.partialAssociateName = null;
-        associatesDataModel.listAll();
-    }
-
     public void saveProject(Component notif) {
         boolean notify = Objects.isNull(getFormDocument().getId());
-        projectsDataModel.save(getFormDocument());
+        Project project = projectsDataModel.save(getFormDocument());
+        project.getIncomingInvoices().forEach(this::updateInvoiceFileChanges);
+        project.getOutgoingInvoices().forEach(this::updateInvoiceFileChanges);
+        project.getTreasuries().forEach(this::updateTreasuryFileChanges);
         if (notify) {
             String msg = String.format("Sikeres projekt létrehozás %s azonosítóval.", getFormDocument().getHumanId());
             Notification.show(msg, "info", notif, "after_start", 3000, true);
         }
     }
 
+    private void updateInvoiceFileChanges(Invoice invoice) {
+        List<EntityDocumentAction> actions = invoiceDocumentActions.get(invoice.getTechnicalId());
+        if (!actions.isEmpty()) {
+            entityDocumentService.executeActions(invoice.getId(), actions);
+        }
+    }
+
+    private void updateTreasuryFileChanges(Treasury treasury) {
+        List<EntityDocumentAction> actions = treasuryDocumentActions.get(treasury.getTechnicalId());
+        if (!actions.isEmpty()) {
+            entityDocumentService.executeActions(treasury.getId(), actions);
+        }
+    }
+
     @Command
     @Transactional
     public void onEndEdit(@BindingParam("target") Window target, @BindingParam("save") boolean save, @BindingParam("notif") Component notif) {
@@ -184,14 +183,17 @@ public class ProjectEditorModel extends EntityEditorModel<Project> {
     @Command
     public void onEditIncoming() {
         IncomingInvoice entity = invoiceDataModel.clone(selectedIncomingInvoice);
-        Editors.doEdit(Editors.INCOMING_INVOICE, entity, selectedIncomingInvoice, this::incomingModified);
+        Map<String, Object> extraArg = ImmutableMap.of("actions", invoiceDocumentActions.get(selectedIncomingInvoice.getTechnicalId()));
+        Editors.doEdit(Editors.INCOMING_INVOICE, entity, selectedIncomingInvoice, extraArg, this::incomingModified);
     }
 
+
     private void incomingAdded(SaveEntityEvent<IncomingInvoice> event) {
         if (!event.isCanceled()) {
             IncomingInvoice modifiedEntity = event.getData();
             getFormDocument().getIncomingInvoices().add(modifiedEntity);
             selectedIncomingInvoice = modifiedEntity;
+            invoiceDocumentActions.put(modifiedEntity.getTechnicalId(), event.withAttachment().getActions());
             validate();
             BindUtils.postNotifyChange(this, "selectedIncomingInvoice");
             BindUtils.postNotifyChange(getFormDocument(), "incomingInvoices");
@@ -200,11 +202,12 @@ public class ProjectEditorModel extends EntityEditorModel<Project> {
 
     private void incomingModified(SaveEntityEvent<IncomingInvoice> event) {
         if (!event.isCanceled()) {
-            Set<IncomingInvoice> incomingInvoices = getFormDocument().getIncomingInvoices();
+            List<IncomingInvoice> incomingInvoices = getFormDocument().getIncomingInvoices();
             incomingInvoices.remove(selectedIncomingInvoice);
             IncomingInvoice modifiedEntity = event.getData();
             incomingInvoices.add(modifiedEntity);
             selectedIncomingInvoice = modifiedEntity;
+            invoiceDocumentActions.put(modifiedEntity.getTechnicalId(), event.withAttachment().getActions());
             validate();
             BindUtils.postNotifyChange(this, "selectedIncomingInvoice");
             BindUtils.postNotifyChange(getFormDocument(), "incomingInvoices");
@@ -214,6 +217,7 @@ public class ProjectEditorModel extends EntityEditorModel<Project> {
     @Command
     public void onRemoveIncoming() {
         if (Objects.nonNull(selectedIncomingInvoice)) {
+            invoiceDocumentActions.remove(selectedIncomingInvoice.getTechnicalId());
             getFormDocument().getIncomingInvoices().remove(selectedIncomingInvoice);
             selectedIncomingInvoice = null;
             validate();
@@ -231,7 +235,12 @@ public class ProjectEditorModel extends EntityEditorModel<Project> {
     @Command
     public void onEditOutgoing() {
         OutgoingInvoice entity = invoiceDataModel.clone(selectedOutgoingInvoice);
-        Editors.doEdit(Editors.OUTGOING_INVOICE, entity, this::outgoingModified);
+        if (invoiceDocumentActions.containsKey(selectedOutgoingInvoice.getTechnicalId())) {
+            Map<String, Object> extraArg = ImmutableMap.of("actions", invoiceDocumentActions.get(selectedOutgoingInvoice.getTechnicalId()));
+            Editors.doEdit(Editors.OUTGOING_INVOICE, entity, selectedOutgoingInvoice, extraArg, this::outgoingModified);
+        } else {
+            Editors.doEdit(Editors.OUTGOING_INVOICE, entity, selectedOutgoingInvoice, this::outgoingModified);
+        }
     }
 
     private void outgoingAdded(SaveEntityEvent<OutgoingInvoice> event) {
@@ -239,6 +248,7 @@ public class ProjectEditorModel extends EntityEditorModel<Project> {
             OutgoingInvoice modifiedEntity = event.getData();
             getFormDocument().getOutgoingInvoices().add(modifiedEntity);
             selectedOutgoingInvoice = modifiedEntity;
+            invoiceDocumentActions.put(modifiedEntity.getTechnicalId(), event.withAttachment().getActions());
             validate();
             BindUtils.postNotifyChange(this, "selectedOutgoingInvoice");
             BindUtils.postNotifyChange(getFormDocument(), "outgoingInvoices");
@@ -248,10 +258,11 @@ public class ProjectEditorModel extends EntityEditorModel<Project> {
     private void outgoingModified(SaveEntityEvent<OutgoingInvoice> event) {
         if (!event.isCanceled()) {
             OutgoingInvoice modifiedEntity = event.getData();
-            Set<OutgoingInvoice> outgoingInvoices = getFormDocument().getOutgoingInvoices();
+            List<OutgoingInvoice> outgoingInvoices = getFormDocument().getOutgoingInvoices();
             outgoingInvoices.remove(selectedOutgoingInvoice);
             outgoingInvoices.add(modifiedEntity);
             selectedOutgoingInvoice = modifiedEntity;
+            invoiceDocumentActions.put(modifiedEntity.getTechnicalId(), event.withAttachment().getActions());
             validate();
             BindUtils.postNotifyChange(this, "selectedOutgoingInvoice");
             BindUtils.postNotifyChange(getFormDocument(), "outgoingInvoices");
@@ -261,11 +272,12 @@ public class ProjectEditorModel extends EntityEditorModel<Project> {
     @Command
     public void onRemoveOutgoing() {
         if (Objects.nonNull(selectedOutgoingInvoice)) {
+            invoiceDocumentActions.remove(selectedOutgoingInvoice.getTechnicalId());
             getFormDocument().getOutgoingInvoices().remove(selectedOutgoingInvoice);
             selectedOutgoingInvoice = null;
             validate();
             BindUtils.postNotifyChange(this, "selectedOutgoingInvoice");
-            BindUtils.postNotifyChange(getFormDocument(), "outgoingInvoice");
+            BindUtils.postNotifyChange(getFormDocument(), "outgoingInvoices");
         }
     }
 
@@ -295,10 +307,11 @@ public class ProjectEditorModel extends EntityEditorModel<Project> {
     private void treasuryModified(SaveEntityEvent<Treasury> event) {
         if (!event.isCanceled()) {
             Treasury modifiedEntity = event.getData();
-            Set<Treasury> treasuries = getFormDocument().getTreasuries();
+            List<Treasury> treasuries = getFormDocument().getTreasuries();
             treasuries.remove(selectedTreasury);
             treasuries.add(modifiedEntity);
             selectedTreasury = modifiedEntity;
+            treasuryDocumentActions.put(modifiedEntity.getTechnicalId(), event.withAttachment().getActions());
             validate();
             BindUtils.postNotifyChange(this, "selectedTreasury");
             BindUtils.postNotifyChange(getFormDocument(), "treasuries");
@@ -308,6 +321,7 @@ public class ProjectEditorModel extends EntityEditorModel<Project> {
     @Command
     public void onRemoveTreasury() {
         if (Objects.nonNull(selectedTreasury)) {
+            treasuryDocumentActions.remove(selectedTreasury.getTechnicalId());
             getFormDocument().getTreasuries().remove(selectedTreasury);
             selectedTreasury = null;
             validate();
@@ -371,8 +385,9 @@ public class ProjectEditorModel extends EntityEditorModel<Project> {
                 .anyMatch(e -> !e.getValue().equals(origAssociates.get(e.getKey())));
     }
 
+    @Override
     protected boolean areDifferent(Project entity) {
-        return super.areDifferent(entity) || isAssociatesChanged();
+        return super.areDifferent(entity) || isAssociatesChanged() || !invoiceDocumentActions.isEmpty() || !treasuryDocumentActions.isEmpty();
     }
 
     @Command
index f3a598f20f67f5b67c4e81d173d829ea84fd76c4..81c8860ab2da87088f6713b130a6de13f3cf6912 100644 (file)
@@ -4,6 +4,7 @@ import hu.user.lis.db.Associate;
 import hu.user.lis.db.Project;
 import hu.user.lis.db.ProjectAssociate;
 import hu.user.lis.db.ServiceRecord;
+import hu.user.lis.service.data.EntityDocumentAction;
 import hu.user.lis.ui.auth.CurrentProfile;
 import hu.user.lis.ui.data.ProjectAssociatesDataModel;
 import hu.user.lis.ui.editor.common.EntityAttachmentEditorModel;
@@ -53,7 +54,6 @@ public class ServiceRecordEditorModel extends EntityAttachmentEditorModel<Servic
     @Override
     public void init() {
         super.init();
-        getEntityDocumentDataModel().refresh(getFormDocument().getId(), ServiceRecord.class.getSimpleName());
     }
 
     @AfterCompose
@@ -87,14 +87,17 @@ public class ServiceRecordEditorModel extends EntityAttachmentEditorModel<Servic
             if (isSaveEnabled()) {
                 Optional<ProjectAssociate> opProjectAssociate = projectAssociatesDataModel.searchByAssociateAndProject(getFormDocument().getAssociate().getId(),
                         getFormDocument().getProject().getId());
+
+
+                List<EntityDocumentAction> actions = getEntityDocumentDataModel().getActions();
                 if (opProjectAssociate.isPresent()) {
-                    Events.postEvent(new SaveEntityWithAttachmentEvent<>(getFormDocument(), getEntityDocumentDataModel(), target));
+                    Events.postEvent(new SaveEntityWithAttachmentEvent<>(getFormDocument(), actions, target));
                 } else {
                     Messagebox.show("A munkatárs a kiválasztott projekt résztvevője lesz.", "Megerősítés",
                             Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION, e -> {
                                 if (!e.getName().equals("onCancel")) {
                                     projectAssociatesDataModel.addProjectAssociate(getFormDocument().getProject(), getFormDocument().getAssociate());
-                                    Events.postEvent(new SaveEntityWithAttachmentEvent<>(getFormDocument(), getEntityDocumentDataModel(), target));
+                                    Events.postEvent(new SaveEntityWithAttachmentEvent<>(getFormDocument(), actions, target));
                                 }
                             });
                 }
index 814f9754484e4f380b0feac2dd0d009ee05b1d04..b8dd97d860f1b1b379d3c1a031f3595d59e6b906 100644 (file)
@@ -1,22 +1,15 @@
 package hu.user.lis.ui.editor;
 
 import hu.user.lis.db.Treasury;
-import hu.user.lis.ui.editor.common.EntityEditorModel;
+import hu.user.lis.ui.editor.common.EntityAttachmentEditorModel;
 import hu.user.lis.ui.editor.validator.FormValidator;
 import hu.user.lis.ui.editor.validator.TreasuryFormValidator;
 import lombok.extern.log4j.Log4j2;
-import org.zkoss.bind.BindContext;
-import org.zkoss.bind.BindUtils;
-import org.zkoss.bind.annotation.Command;
-import org.zkoss.bind.annotation.ContextParam;
-import org.zkoss.bind.annotation.ContextType;
 import org.zkoss.bind.annotation.Init;
-import org.zkoss.zk.ui.event.UploadEvent;
 import org.zkoss.zk.ui.select.annotation.WireVariable;
-import org.zkoss.zul.Messagebox;
 
 @Log4j2
-public class TreasuryEditorModel extends EntityEditorModel<Treasury> {
+public class TreasuryEditorModel extends EntityAttachmentEditorModel<Treasury> {
 
     @WireVariable
     private TreasuryFormValidator treasuryFormValidator;
@@ -37,22 +30,4 @@ public class TreasuryEditorModel extends EntityEditorModel<Treasury> {
         return treasuryFormValidator.validate(entity);
     }
 
-    @Command
-    public void onUploadFile(@ContextParam(ContextType.BIND_CONTEXT) BindContext ctx) {
-        UploadEvent evt = (UploadEvent) ctx.getTriggerEvent();
-        if (!evt.getMedia().getName().toLowerCase().endsWith(".pdf")) {
-            Messagebox.show("Csak PDF állomány feltöltése támogatott.", "Error", Messagebox.OK, Messagebox.ERROR);
-            return;
-        }
-        getFormDocument().setFile(evt.getMedia().getByteData());
-        BindUtils.postNotifyChange(getFormDocument(), "file");
-        validate();
-    }
-
-    @Command
-    public void onRemoveFile() {
-        getFormDocument().setFile(null);
-        BindUtils.postNotifyChange(getFormDocument(), "file");
-        validate();
-    }
 }
index 7c9ef941679538d787599c8b1066df0a8b6762e6..a38e24614b9422615b5fefe28a1fbd73dd0d32f4 100644 (file)
@@ -6,6 +6,7 @@ import lombok.extern.log4j.Log4j2;
 import org.zkoss.zk.ui.Executions;
 import org.zkoss.zul.Window;
 
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 
@@ -17,7 +18,7 @@ public class Editors {
     public static final String TREASURY = "~./editor/treasury-editor.zul";
     public static final String ASSOCIATE = "~./editor/associate-editor.zul";
     public static final String PARTNER = "~./editor/partner-editor.zul";
-    public static final String PROJECT_ATTACH = "~./editor/project-attach.zul";
+    public static final String PROJECT_ATTACH = "~./editor/project-executeActions.zul";
     public static final String IMPORT_INVOICE_ASSIGN = "~./editor/import-invoice-assign-editor.zul";
     public static final String IMPORT_INVOICE_APPROVE = "~./editor/import-invoice-approve-editor.zul";
     public static final String PROJECT = "~./editor/project-editor.zul";
@@ -44,6 +45,20 @@ public class Editors {
         doShowEdit(page, arg, editCompleted);
     }
 
+    public static <E> void doEdit(String page, E entity, E original, Map<String, Object> extraArg, EditCompletedListener<E> editCompleted) {
+        if (Objects.isNull(entity)) {
+            //header double click
+            return;
+        }
+        Map<String, Object> arg = new HashMap<>(extraArg);
+
+        arg.put("formDocument", entity);
+        if (Objects.nonNull(original)) {
+            arg.put("origDocument", original);
+        }
+        doShowEdit(page, arg, editCompleted);
+    }
+
     public static <E> void doShowEdit(String page, Map<String, Object> arg, EditCompletedListener<E> editCompleted) {
         Window editorWindow = (Window) Executions.createComponents(page, null, arg);
         editorWindow.addEventListener("onClose", e -> {
index 02e8e1649c4a6282440c69f60bcc1b90f3f3af8d..bc659b5ef27bebbd933875ca4524f5050e539abd 100644 (file)
@@ -1,30 +1,50 @@
 package hu.user.lis.ui.editor.common;
 
 import hu.user.lis.db.EDocument;
+import hu.user.lis.db.IdEntity;
+import hu.user.lis.service.data.EntityDocumentAction;
 import hu.user.lis.ui.data.EntityDocumentDataModel;
+import hu.user.lis.ui.event.CancelEntityEditEvent;
+import hu.user.lis.ui.event.SaveEntityWithAttachmentEvent;
 import lombok.Getter;
 import lombok.extern.log4j.Log4j2;
 import org.zkoss.bind.BindContext;
 import org.zkoss.bind.BindUtils;
+import org.zkoss.bind.annotation.BindingParam;
 import org.zkoss.bind.annotation.Command;
 import org.zkoss.bind.annotation.ContextParam;
 import org.zkoss.bind.annotation.ContextType;
 import org.zkoss.lang.Strings;
+import org.zkoss.zk.ui.Executions;
+import org.zkoss.zk.ui.event.Events;
 import org.zkoss.zk.ui.event.UploadEvent;
 import org.zkoss.zk.ui.select.annotation.WireVariable;
 import org.zkoss.zul.Messagebox;
+import org.zkoss.zul.Window;
 
 import java.io.Serializable;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.util.List;
 
+@Getter
 @Log4j2
 public class EntityAttachmentEditorModel<T extends Serializable> extends EntityEditorModel<T> {
 
-    @Getter
     @WireVariable
     private EntityDocumentDataModel entityDocumentDataModel;
 
+    @Override
+    public void init() {
+        super.init();
+
+        List<EntityDocumentAction> actions = (List<EntityDocumentAction>) Executions.getCurrent().getArg().get("actions");
+        log.info(actions);
+
+        entityDocumentDataModel.refresh((IdEntity) getFormDocument(), getDocumentType(), actions);
+    }
+
+    @Override
     protected boolean canSave(T entity) {
         return true;
     }
@@ -36,13 +56,8 @@ public class EntityAttachmentEditorModel<T extends Serializable> extends EntityE
             Messagebox.show("Csak PDF állomány feltöltése támogatott.", "Error", Messagebox.OK, Messagebox.ERROR);
             return;
         }
-        String documentType = Strings.EMPTY;
-        Type[] actualTypeArguments = ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments();
-        if (actualTypeArguments.length > 0) {
-            documentType = ((Class<?>) actualTypeArguments[0]).getSimpleName();
-        }
         EDocument document = EDocument.builder()
-                .documentType(documentType)
+                .documentType(getDocumentType())
                 .file(evt.getMedia().getByteData())
                 .size(evt.getMedia().getByteData().length)
                 .name(evt.getMedia().getName())
@@ -52,6 +67,27 @@ public class EntityAttachmentEditorModel<T extends Serializable> extends EntityE
         validate();
     }
 
+    @Command
+    @Override
+    public void onCloseWindow(@BindingParam("target") Window target, @BindingParam("save") boolean save) {
+        if (save) {
+            if (saveEnabled) {
+                Events.postEvent(new SaveEntityWithAttachmentEvent<>(formDocument, entityDocumentDataModel.getActions(), target));
+            }
+        } else {
+            Events.postEvent(new CancelEntityEditEvent<>(target));
+        }
+    }
+
+    private String getDocumentType() {
+        String documentType = Strings.EMPTY;
+        Type[] actualTypeArguments = ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments();
+        if (actualTypeArguments.length > 0) {
+            documentType = ((Class<?>) actualTypeArguments[0]).getSimpleName();
+        }
+        return documentType;
+    }
+
     @Command
     public void onRemoveFile() {
         entityDocumentDataModel.remove();
index 0b0cb2f3ec64b3ad5501acb1f79aa61c7ab12a53..4827a280d06a512e3f1955ed140e909507239bd2 100644 (file)
@@ -82,7 +82,10 @@ public abstract class EntityEditorModel<T extends Serializable> extends Abstract
         eventBus.registerForBinding(this);
         origDocument = (T) Executions.getCurrent().getArg().get("origDocument");
         formDocument = (T) Executions.getCurrent().getArg().get("formDocument");
-        validate(formDocument);
+        if (Objects.nonNull(formDocument)) {
+            //special pages like ProjectEditorModel validates later
+            validate(formDocument);
+        }
     }
 
     @Override
index cbd950f9fef7a24db59bfda99145e3120342d7f6..d567c2a4046283714e0080d0ae42fff47e2612a5 100644 (file)
@@ -10,7 +10,7 @@ public class ImportInvoiceApproveFormValidator extends InvoiceFormValidator {
     protected FieldValidation[] getValidators(Invoice entity) {
         FieldValidation[] validators = new FieldValidation[]{
                 validator(entity.getProject(), this::validateNotNull, "A 'Projekt' kitöltése kötelező."),
-                validator(entity.getFile(), this::validateNotNull, "A 'Számlakép' feltöltése kötelező.")
+                //validator(entity.getFile(), this::validateNotNull, "A 'Számlakép' feltöltése kötelező.")
         };
         return ArrayUtils.addAll(super.getValidators(entity), validators);
     }
index f7cfb9c2a8c9c2dd93b3ada0b1df0879ef57b63c..f1a4334774e602890b6abe75f37705b7fb06d63a 100644 (file)
@@ -11,7 +11,7 @@ public class ImportInvoiceAssignFormValidator extends InvoiceFormValidator {
     protected FieldValidation[] getValidators(Invoice entity) {
         FieldValidation[] validators = new FieldValidation[]{
                 validator(entity.getProject(), this::validateNotNull, "A 'Projekt' kitöltése kötelező."),
-                validator(entity.getFile(), this::validateNotNull, "A 'Számlakép' feltöltése kötelező.")
+                //validator(entity.getFile(), this::validateNotNull, "A 'Számlakép' feltöltése kötelező.")
         };
         return ArrayUtils.addAll(super.getValidators(entity), validators);
     }
index a526d63f42bb15c7bb136274e10f77eeff5f69ac..fc0efd46dcd67f3df98fbbe48b1ff290888b3047 100644 (file)
@@ -1,16 +1,18 @@
 package hu.user.lis.ui.event;
 
-import hu.user.lis.ui.data.EntityDocumentDataModel;
+import hu.user.lis.service.data.EntityDocumentAction;
 import lombok.Getter;
 import org.zkoss.zul.Window;
 
+import java.util.List;
+
 @Getter
 public class SaveEntityWithAttachmentEvent<T> extends SaveEntityEvent<T> {
 
-    private final EntityDocumentDataModel entityDocumentDataModel;
+    private final List<EntityDocumentAction> actions;
 
-    public SaveEntityWithAttachmentEvent(T data, EntityDocumentDataModel entityDocumentDataModel, Window target) {
+    public SaveEntityWithAttachmentEvent(T data, List<EntityDocumentAction> actions, Window target) {
         super(data, target);
-        this.entityDocumentDataModel = entityDocumentDataModel;
+        this.actions = actions;
     }
 }
index 4ab406b9c314347be577fd1e38e4be8935014a4d..0e5117015261f85278741dcc1b8e4337df3fb093 100644 (file)
@@ -70,7 +70,7 @@ public class IndexViewModel implements EventListener<Event> {
     private String searchPhrase;
     private String page;
     private final Map<String, SpecialRoute> specialRoutes = ImmutableMap.of(
-            Constants.NAV_PROJECTS, this::showProjectEditor,
+            Constants.NAV_PROJECT, this::showProjectEditor,
             Constants.NAV_INVOICE_PAYMENT, this::showInvoicePayment
     );
     private String importInvoiceMenuClassName;
@@ -103,7 +103,7 @@ public class IndexViewModel implements EventListener<Event> {
         String[] pathTokens = path.split("/");
         if (pathTokens.length > 2) {
             Long id = Long.parseLong(pathTokens[2]);
-            specialRoutes.get(path).route(id);
+            specialRoutes.get("/" + pathTokens[1]).route(id);
         } else {
             setPage("~." + path + ".zul");
         }
index c82bd699cfe5254e0dc98194ea49e95279bb3a18..74960aa606ef474371966fe540c7a4c85df9e9f6 100644 (file)
@@ -4,8 +4,9 @@ import com.google.common.collect.ImmutableMap;
 import hu.user.lis.db.Associate;
 import hu.user.lis.db.Project;
 import hu.user.lis.db.ServiceRecord;
+import hu.user.lis.service.data.EntityDocumentAction;
+import hu.user.lis.service.data.EntityDocumentService;
 import hu.user.lis.ui.Constants;
-import hu.user.lis.ui.data.EntityDocumentDataModel;
 import hu.user.lis.ui.data.ServiceRecordsDataModel;
 import hu.user.lis.ui.data.common.CachedSpringDataModel;
 import hu.user.lis.ui.editor.common.Editors;
@@ -27,6 +28,7 @@ import org.zkoss.zk.ui.select.annotation.VariableResolver;
 import org.zkoss.zk.ui.select.annotation.WireVariable;
 import org.zkoss.zkplus.spring.DelegatingVariableResolver;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
@@ -45,14 +47,18 @@ public class ServiceRecordsViewModel extends EntityViewModel<ServiceRecord> impl
     @WireVariable
     EntitySelectorRouter entitySelectorRouter;
 
+    @WireVariable
+    private EntityDocumentService entityDocumentService;
+
+    @WireVariable
+    private EventBus eventBus;
+
     @Getter
     private Project filterProject;
 
     @Getter
     private Associate filterAssociate;
 
-    @WireVariable
-    private EventBus eventBus;
 
     @Override
     protected CachedSpringDataModel<ServiceRecord> getDataModel() {
@@ -112,9 +118,10 @@ public class ServiceRecordsViewModel extends EntityViewModel<ServiceRecord> impl
     public void saveServiceRecord(SaveEntityEvent<ServiceRecord> event) {
         if (!event.isCanceled()) {
             ServiceRecord modifiedEntity = event.getData();
+            List<EntityDocumentAction> actions = event.withAttachment().getActions();
+            modifiedEntity.setSigned(!actions.isEmpty());
             serviceRecordsDataModel.save(modifiedEntity);
-            EntityDocumentDataModel entityDocumentDataModel = event.withAttachment().getEntityDocumentDataModel();
-            entityDocumentDataModel.save(modifiedEntity.getId());
+            entityDocumentService.executeActions(modifiedEntity.getId(), actions);
             refresh();
             serviceRecordsDataModel.addToSelection(modifiedEntity);
         }
index 89ff7fb069f49fa3de8a8c81bb06ad18f2ef4260..fdc3733f6801ac3f42096b305f83af6c0474f614 100644 (file)
@@ -3,13 +3,6 @@
            onOpen="@command('onOpenFormPanel', parentPanel=centerPanel)">
         <caption label="Résztvevők" style="cursor: pointer"
                  onClick="@command('onClickFormPanel', parentPanel=centerPanel, panel=self.parent)"/>
-        <!--                                    <north flex="true">-->
-        <!--                                        <toolbar>-->
-        <!--                                            <textbox instant="true" value="@bind(vm.partialAssociateName)"/>-->
-        <!--                                            <toolbarbutton iconSclass="z-icon-remove"-->
-        <!--                                                           onClick="@command('onResetAssociateFilter')"/>-->
-        <!--                                        </toolbar>-->
-        <!--                                    </north>-->
         <panelchildren>
             <listbox model="@load(vm.associatesDataModel)"
                      multiple="false">
index bdbda1774a898fd73fcf971fcb8868ee5b1a811c..777734fa4a1154f52d8a0868e261c170207d8274 100644 (file)
                             </vlayout>
                         </tabpanel>
                         <tabpanel>
-                            <borderlayout>
-                                <north flex="true">
-                                    <toolbar>
-                                        <toolbarbutton label="Feltöltés" iconSclass="z-icon-plus" upload="true"
-                                                       onUpload="@command('onUploadFile')"/>
-                                        <toolbarbutton label="Törlés" iconSclass="z-icon-remove"
-                                                       onClick="@command('onRemoveFile')"
-                                                       disabled="@load(empty vm.formDocument.file)"/>
-                                    </toolbar>
-                                </north>
-                                <center border="none" flex="true">
-                                    <iframe hflex="true" vflex="true"
-                                            content="@load(vm.formDocument.file) @converter('hu.user.lis.ui.converter.ByteArrayToAMediaConverter')"/>
-                                </center>
-                            </borderlayout>
+                            <include src="~./form/attachment-form.zul" hflex="true" vflex="true"/>
                         </tabpanel>
                     </tabpanels>
                 </tabbox>
index c77f9aaf8a650ee7cb01bc45fa72571124cc1b47..708a52f138b4b8c9a94a747902624a9553e189fa 100644 (file)
                 </vlayout>
             </tabpanel>
             <tabpanel>
-                <borderlayout>
-                    <north flex="true">
-                        <toolbar>
-                            <toolbarbutton label="Feltöltés" iconSclass="z-icon-plus" upload="true"
-                                           onUpload="@command('onUploadFile')" disabled="@bind(vm.readonlyForm)"/>
-                            <toolbarbutton label="Törlés" iconSclass="z-icon-remove"
-                                           onClick="@command('onRemoveFile')"
-                                           disabled="@load(empty vm.formDocument.file or vm.readonlyForm)"/>
-                        </toolbar>
-                    </north>
-                    <center border="none" flex="true">
-                        <iframe hflex="true" vflex="true"
-                                content="@load(vm.formDocument.file) @converter('hu.user.lis.ui.converter.ByteArrayToAMediaConverter')"/>
-                    </center>
-                </borderlayout>
+                <include src="~./form/attachment-form.zul" hflex="true" vflex="true"/>
             </tabpanel>
         </tabpanels>
     </tabbox>
index 9dc4a6acf4d918bce535acf376fde7571cc91779..0076d2347c1bae0a0fb6ef4afdea3838f2591dfe 100644 (file)
@@ -58,8 +58,8 @@
                                 <label value="@load(each.workHours)"/>
                             </listcell>
                             <listcell>
-                                <a iconSclass="z-icon-check" visible="@load(not empty each.file)"/>
-                                <a iconSclass="z-icon-ban" visible="@load(empty each.file)"/>
+                                <a iconSclass="z-icon-check" visible="@load(each.signed)"/>
+                                <a iconSclass="z-icon-ban" visible="@load(not each.signed)"/>
                             </listcell>
                         </listitem>
                     </template>