Invoice view completed, column settings auto repair added
authorVásáry Dániel <vasary@elgekko.net>
Thu, 19 Oct 2023 19:50:30 +0000 (21:50 +0200)
committerVásáry Dániel <vasary@elgekko.net>
Thu, 19 Oct 2023 19:50:30 +0000 (21:50 +0200)
37 files changed:
.gitignore
.idea/.jpb/jpb-settings.xml [moved from .jpb/jpb-settings.xml with 100% similarity]
lis-app/src/main/resources/application-dev.yaml
lis-app/src/main/resources/application-old.yaml [deleted file]
lis-app/src/main/resources/application-suppliers.yaml [deleted file]
lis-app/src/main/resources/logback-dev.xml [moved from lis-app/src/main/resources/logback-spring.xml with 60% similarity]
lis-app/src/main/resources/logback-prod.xml
lis-app/src/test/java/hu/user/lis/RepositoryIT.java
lis-db/migrations/README
lis-db/migrations/environments/development.properties
lis-db/migrations/scripts/010_reset_partner_index.sql [new file with mode: 0644]
lis-db/migrations/scripts/011_reset_project_index.sql [new file with mode: 0644]
lis-db/migrations/scripts/012_create_payment.sql [new file with mode: 0644]
lis-db/migrations/scripts/013_modify_invoice_rename_income_incoming.sql [new file with mode: 0644]
lis-db/migrations/scripts/014_add_paid_to_invoice.sql [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/Payment.java [new file with mode: 0644]
lis-db/src/main/java/hu/user/lis/db/Project.java
lis-db/src/main/java/hu/user/lis/db/repository/InvoiceRepositorySearchImpl.java
lis-db/src/main/java/hu/user/lis/db/repository/PaymentRepository.java [new file with mode: 0644]
lis-db/src/main/java/hu/user/lis/db/repository/filter/InvoiceFilter.java
lis-service/src/main/java/hu/user/lis/service/data/EntityDataServiceBase.java
lis-service/src/main/java/hu/user/lis/service/data/InvoiceServiceImpl.java
lis-service/src/main/java/hu/user/lis/service/nav/mapper/InvoiceMapper.java
lis-services/lis-service.iml
lis-ui/src/main/java/hu/user/lis/ui/Constants.java
lis-ui/src/main/java/hu/user/lis/ui/auth/CurrentProfile.java
lis-ui/src/main/java/hu/user/lis/ui/config/ResourceConfigurer.java
lis-ui/src/main/java/hu/user/lis/ui/data/InvoiceDataModel.java
lis-ui/src/main/java/hu/user/lis/ui/data/InvoicesDataModel.java
lis-ui/src/main/java/hu/user/lis/ui/data/common/CachedSpringDataModel.java
lis-ui/src/main/java/hu/user/lis/ui/view/InvoicesViewModel.java
lis-ui/src/main/java/hu/user/lis/ui/view/ServiceRecordsViewModel.java
lis-ui/src/main/resources/web/invoice-payment.zul [moved from lis-ui/src/main/resources/web/invoice-settle.zul with 100% similarity]
lis-ui/src/main/resources/web/invoices.zul
lis-workflow/src/main/java/hu/user/lis/workflow/invoice/service/IncomingInvoiceFetcherService.java

index 73490da8fbe451de0627bed5af8e3b10c8617156..171e253e996ef7f578f921392290e65f038a50c1 100644 (file)
@@ -1,4 +1,4 @@
 /lis-db/migrations/drivers/jcc-11.5.7.0.jar
 ./.idea/
 target/
-/.jpb/persistence-units.xml
+/.idea/.jpb/persistence-units.xml
index 48fd8cb72bde449053f194f57437511f072586b2..d6ebf7f86816d33524db88ecb8ea228e50f30092 100644 (file)
@@ -46,15 +46,12 @@ camunda.bpm:
     create: All tasks
   job-execution.enabled: true
 logging:
+  config: classpath:logback-dev.xml
   level:
     org.hibernate.engine.jdbc.spi.SqlExceptionHelper: ERROR
     org.springframework.web.clientRestTemplate: DEBUG
     logging.level.org.apache.http: TRACE
     logging.level.httpclient.wire: TRACE
-  #    org.springframework.security.web: INFO
-  #  pattern:
-  #    console: "%d %-5level %logger : %msg%n"
-  #    file: "%d %-5level [%thread] %logger : %msg%n"
 application:
   ui:
     user-name: user
diff --git a/lis-app/src/main/resources/application-old.yaml b/lis-app/src/main/resources/application-old.yaml
deleted file mode 100644 (file)
index df7e097..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-### HTTP server
-server:
-  port: 8080
-  servlet:
-    context-path: /
-
-### ZKoss
-zk:
-  homepage: index
-  zul-view-resolver-enabled: true
-### Spring
-spring:
-  #active: dev
-  #  profiles:
-  #main:
-  #    banner-mode: off
-  output:
-    ansi:
-      enabled: always
-  mail:
-    host: smtp.gmail.com
-    port: 465
-    username: mediacubeserver@gmail.com
-    password: salabakter
-    protocol: smtps
-    properties:
-      mail:
-        smtp:
-          auth: true
-          starttls:
-            enable: true
-  #datasources:
-  #  maszkaweb:
-  #    driver-class-name: com.mysql.jdbc.Driver
-  #    type: com.zaxxer.hikari.HikariDataSource
-  #    jdbcUrl: jdbc:mysql://localhost:3306/maszkaweb?useUnicode=true&characterEncoding=UTF-8
-  #    username: root
-  #    password: password
-  #    pool-name: pool-maszkaweb
-  #    maximum-pool-size: 50
-  #    minimum-idle: 10
-  #  data:
-  #    mongodb:
-  #      #      host: dvdev.in.useribm.hu
-  #      host: localvm
-  #      port: 27017
-  #      database: lis
-
-  #      username: db2admin
-  #      password: password
-#  datasource:
-#    #    driver-class-name: com.mysql.jdbc.Driver
-#    type: com.zaxxer.hikari.HikariDataSource
-#    url: jdbc:db2://localvm:50000/testmc
-#    username: db2admin
-#    password: password
-#    hikari:
-#      pool-name: testmc
-#      maximum-pool-size: 50
-#      minimum-idle: 10
-service:
-  message: Hello, World
diff --git a/lis-app/src/main/resources/application-suppliers.yaml b/lis-app/src/main/resources/application-suppliers.yaml
deleted file mode 100644 (file)
index aac23fd..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-### HTTP server
-server:
-  port: 8080
-  servlet:
-    context-path: /
-
-### ZKoss
-zk:
-  homepage: suppliers
-  zul-view-resolver-enabled: true
-### Spring
-spring:
-  main:
-    banner-mode: off
-  output:
-    ansi:
-      enabled: always
-  mail:
-    host: smtp.gmail.com
-    port: 465
-    username: mediacubeserver@gmail.com
-    password: salabakter
-    protocol: smtps
-    properties:
-      mail:
-        smtp:
-          auth: true
-          starttls:
-            enable: true
-  #datasources:
-  #  maszkaweb:
-  #    driver-class-name: com.mysql.jdbc.Driver
-  #    type: com.zaxxer.hikari.HikariDataSource
-  #    jdbcUrl: jdbc:mysql://localhost:3306/maszkaweb?useUnicode=true&characterEncoding=UTF-8
-  #    username: root
-  #    password: password
-  #    pool-name: pool-maszkaweb
-  #    maximum-pool-size: 50
-  #    minimum-idle: 10
-  datasource:
-    #    driver-class-name: com.mysql.jdbc.Driver
-    type: com.zaxxer.hikari.HikariDataSource
-    url: jdbc:db2://localvm:50000/testmc
-    username: db2admin
-    password: password
-    hikari:
-      pool-name: testmc
-      maximum-pool-size: 50
-      minimum-idle: 10
-service:
-  message: Hello, World
similarity index 60%
rename from lis-app/src/main/resources/logback-spring.xml
rename to lis-app/src/main/resources/logback-dev.xml
index 01da73de9907bdf50ccb90f511410d6f70ea4234..6cc83afe21f2eb7e8f4e2247baa5808419030f27 100644 (file)
@@ -1,23 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
-
-    <property name="LOGS" value="./logs"/>
-
-    <appender name="Console"
-              class="ch.qos.logback.core.ConsoleAppender">
+    <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
         <layout class="ch.qos.logback.classic.PatternLayout">
             <Pattern>
                 %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable
             </Pattern>
         </layout>
     </appender>
-
     <root level="info">
         <appender-ref ref="Console"/>
     </root>
-
-    <logger name="hu.user.lis" level="trace" additivity="false">
-        <appender-ref ref="Console"/>
-    </logger>
-
 </configuration>
\ No newline at end of file
index 3b3eb7d0162bdbc360ab46902049279fb2182d2f..cafae6f0669e192787d5b3df43d3f699c76c0caf 100644 (file)
@@ -1,10 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
-
     <property name="LOGS" value="./logs"/>
-
-    <appender name="Console"
-              class="ch.qos.logback.core.ConsoleAppender">
+    <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
         <layout class="ch.qos.logback.classic.PatternLayout">
             <Pattern>
                 %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable
         </layout>
     </appender>
 
-    <appender name="RollingFile"
-              class="ch.qos.logback.core.rolling.RollingFileAppender">
+    <appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
         <file>${LOGS}/sly-crm-app-logger.log</file>
-        <encoder
-                class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
             <Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
         </encoder>
-
-        <rollingPolicy
-                class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!-- rollover daily and when the file reaches 10 MegaBytes -->
-            <fileNamePattern>${LOGS}/archived/sly-crm-app-%d{yyyy-MM-dd}.%i.log
-            </fileNamePattern>
-            <timeBasedFileNamingAndTriggeringPolicy
-                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${LOGS}/archived/sly-crm-app-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                 <maxFileSize>10MB</maxFileSize>
             </timeBasedFileNamingAndTriggeringPolicy>
         </rollingPolicy>
     </appender>
 
-    <!-- LOG everything at INFO level -->
     <root level="info">
-        <!--        <appender-ref ref="RollingFile"/>-->
+        <appender-ref ref="RollingFile"/>
         <appender-ref ref="Console"/>
     </root>
 
-    <!-- LOG "com.baeldung*" at TRACE level -->
     <logger name="hu.user.lis" level="trace" additivity="false">
-        <!--        <appender-ref ref="RollingFile"/>-->
         <appender-ref ref="Console"/>
     </logger>
 
index e04f850c839092fa8ddcb7f717cb91051f7e0de6..b00e823d4b8353a3c5474a69d5f4272d9677dc35 100644 (file)
@@ -86,7 +86,7 @@ public class RepositoryIT {
         project.setProjectStatus(null);
 
         IncomingInvoice invoice = IncomingInvoice.builder()
-                .income(true)
+                .incoming(true)
                 .planned(true)
                 .currency(Currency.HUF)
                 .netAmount(1)
index c145ce603fc876f46f60facd63a5e24dbb42b959..70fd38d7e4930d99004027a831be8ac005eb6a2f 100644 (file)
@@ -65,3 +65,4 @@ https://community.ibm.com/community/user/datamanagement/discussion/db2-docker-pe
 
 DB2 SQL
 ALTER TABLE "tableName" ALTER COLUMN "columnName" RESTART WITH <new index value>
+ALTER TABLE org RENAME COLUMN deptnumb TO deptnum
\ No newline at end of file
index 017b8c7c4db3b3c8f67438bc26397aa679764b16..8ca0d80651191b0f9b58cea7077eaca540e754c2 100644 (file)
@@ -4,7 +4,7 @@ time_zone=GMT+0:00
 script_char_set=UTF-8
 ## JDBC connection properties.
 driver=com.ibm.db2.jcc.DB2Driver
-url=jdbc:db2://localhost:50000/slycrm
+url=jdbc:db2://localhost:50000/lis
 username=db2admin
 password=password
 #
diff --git a/lis-db/migrations/scripts/010_reset_partner_index.sql b/lis-db/migrations/scripts/010_reset_partner_index.sql
new file mode 100644 (file)
index 0000000..99f2ed6
--- /dev/null
@@ -0,0 +1,9 @@
+-- // reset partner index
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE PARTNER ALTER COLUMN id RESTART WITH 4;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+
diff --git a/lis-db/migrations/scripts/011_reset_project_index.sql b/lis-db/migrations/scripts/011_reset_project_index.sql
new file mode 100644 (file)
index 0000000..ff882d8
--- /dev/null
@@ -0,0 +1,9 @@
+-- // reset project index
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE PROJECT ALTER COLUMN id RESTART WITH 2;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+
diff --git a/lis-db/migrations/scripts/012_create_payment.sql b/lis-db/migrations/scripts/012_create_payment.sql
new file mode 100644 (file)
index 0000000..07994e1
--- /dev/null
@@ -0,0 +1,19 @@
+-- // create payment
+-- Migration SQL that makes the change goes here.
+
+CREATE TABLE payment (
+    id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+    invoice_id BIGINT,
+    net_amount DOUBLE NOT NULL,
+    gross_amount DOUBLE NOT NULL,
+    vat_amount DOUBLE NOT NULL,
+    payment_date TIMESTAMP,
+    currency INTEGER,
+    CONSTRAINT pk_payment PRIMARY KEY (id)
+);
+ALTER TABLE payment ADD CONSTRAINT FK_PAYMENT_ON_INVOICE FOREIGN KEY (invoice_id) REFERENCES invoice (id);
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+DROP TABLE payment;
diff --git a/lis-db/migrations/scripts/013_modify_invoice_rename_income_incoming.sql b/lis-db/migrations/scripts/013_modify_invoice_rename_income_incoming.sql
new file mode 100644 (file)
index 0000000..40dc129
--- /dev/null
@@ -0,0 +1,9 @@
+-- // modify invoice rename income incoming
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE invoice RENAME COLUMN income TO incoming;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+ALTER TABLE invoice RENAME COLUMN incoming TO income;
diff --git a/lis-db/migrations/scripts/014_add_paid_to_invoice.sql b/lis-db/migrations/scripts/014_add_paid_to_invoice.sql
new file mode 100644 (file)
index 0000000..8b961cb
--- /dev/null
@@ -0,0 +1,9 @@
+-- // add paid to invoice
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE invoice ADD COLUMN paid SMALLINT NOT NULL DEFAULT 0;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+ALTER TABLE invoice DROP COLUMN paid;
index eab1d7d143432993e210cf8ecf81fcc050ea2fcf..eb53cc150013e5a7f09f8cf5fb4a9be84420f370 100644 (file)
@@ -10,6 +10,6 @@ import javax.persistence.Entity;
 @DiscriminatorValue("1")
 public class IncomingInvoice extends Invoice {
     public IncomingInvoice() {
-        income = true;
+        incoming = true;
     }
 }
index abfaf4629d8539113457485981831671f8ef111f..ca94e7ccadc6947c7b7caad54cb8ac87e6493fdf 100644 (file)
@@ -15,7 +15,7 @@ import java.util.Date;
 @Entity
 @SuperBuilder
 @NoArgsConstructor
-@DiscriminatorColumn(name = "income", discriminatorType = DiscriminatorType.INTEGER)
+@DiscriminatorColumn(name = "incoming", discriminatorType = DiscriminatorType.INTEGER)
 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
 public class Invoice implements Serializable {
     @Id
@@ -23,8 +23,6 @@ public class Invoice implements Serializable {
     Long id;
     String humanId;
     String title;
-    @Column(nullable = false, insertable = false, updatable = false)
-    boolean income;
     Currency currency;
     double netAmount;
     double grossAmount;
@@ -32,8 +30,12 @@ public class Invoice implements Serializable {
     Date completionDate;
     Date createDate;
     Date paymentDeadline;
+    @Column(nullable = false, insertable = false, updatable = false)
+    boolean incoming;
+    boolean paid;
     boolean planned;
     byte[] file;
+
     @OneToOne
     @JoinColumn(name = "partner_id")
     @JsonIncludeProperties({"id"})
diff --git a/lis-db/src/main/java/hu/user/lis/db/Payment.java b/lis-db/src/main/java/hu/user/lis/db/Payment.java
new file mode 100644 (file)
index 0000000..0937d61
--- /dev/null
@@ -0,0 +1,28 @@
+package hu.user.lis.db;
+
+import com.fasterxml.jackson.annotation.JsonIncludeProperties;
+import lombok.*;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+@Getter
+@Setter
+@Entity
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class Payment implements Serializable {
+    @ManyToOne
+    @JoinColumn(name = "invoice_id")
+    @JsonIncludeProperties({"id"})
+    Invoice invoice;
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    Long id;
+    double netAmount;
+    double grossAmount;
+    double vatAmount;
+    Date paymentDate;
+}
index e02ac34af175a7098a261ed4839bc9c7c3b8ae96..bb2b0c23c35a83a29db97ec9d1667e6666bccf23 100644 (file)
@@ -32,14 +32,14 @@ public class Project implements Serializable {
 
     @OneToMany(targetEntity = IncomingInvoice.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
     @JoinColumn(name = "project_id", referencedColumnName = "id")
-    @Where(clause = "income=1")
+    @Where(clause = "incoming=1")
     @Fetch(FetchMode.JOIN)
     @JsonIncludeProperties({"id"})
     Set<IncomingInvoice> incomingInvoices;
 
     @OneToMany(targetEntity = OutgoingInvoice.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
     @JoinColumn(name = "project_id", referencedColumnName = "id")
-    @Where(clause = "income=0")
+    @Where(clause = "incoming=0")
     @Fetch(FetchMode.JOIN)
     @JsonIncludeProperties({"id"})
     Set<OutgoingInvoice> outgoingInvoices;
index d60affd25a95a473dcce77f2fb344b265c80a712..14ac83b63b18cee10d38782074f412d9c81034dc 100644 (file)
@@ -35,16 +35,24 @@ public class InvoiceRepositorySearchImpl implements InvoiceRepositorySearch {
 
         if (filter.isIncoming()) {
             predicates.add(cb.isTrue(root.get("incoming")));
+        } else {
+            predicates.add(cb.isFalse(root.get("incoming")));
         }
 
-        if (filter.isSettled()) {
-            //TODO add field
-            predicates.add(cb.isTrue(root.get("settled")));
+        if (filter.isPaid()) {
+            predicates.add(cb.isTrue(root.get("paid")));
         }
 
-        if (Objects.nonNull(filter.getPaymentDeadLineFrom()) || Objects.nonNull(filter.getPaymentDeadLineTo())) {
-            //TODO check
-            predicates.add(cb.between(root.get("deadline"), filter.getPaymentDeadLineFrom(), filter.getPaymentDeadLineTo()));
+        if (Objects.nonNull(filter.getPaymentDeadLineFrom())) {
+            if (Objects.nonNull(filter.getPaymentDeadLineTo())) {
+                predicates.add(cb.between(root.get("paymentDeadline"), filter.getPaymentDeadLineFrom(), filter.getPaymentDeadLineTo()));
+            } else {
+                predicates.add(cb.greaterThanOrEqualTo(root.get("paymentDeadline"), filter.getPaymentDeadLineFrom()));
+            }
+        } else {
+            if (Objects.nonNull(filter.getPaymentDeadLineTo())) {
+                predicates.add(cb.lessThanOrEqualTo(root.get("paymentDeadline"), filter.getPaymentDeadLineTo()));
+            }
         }
 
         return predicates.toArray(new Predicate[]{});
diff --git a/lis-db/src/main/java/hu/user/lis/db/repository/PaymentRepository.java b/lis-db/src/main/java/hu/user/lis/db/repository/PaymentRepository.java
new file mode 100644 (file)
index 0000000..8860d62
--- /dev/null
@@ -0,0 +1,13 @@
+package hu.user.lis.db.repository;
+
+import hu.user.lis.db.Invoice;
+import hu.user.lis.db.Payment;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface PaymentRepository extends JpaRepository<Payment, Long> {
+
+    List<Payment> findAllByInvoice(Invoice invoice);
+
+}
index 5afef129e12f0f7a580e0ebb02f1de17a343b369..f4b1fbd82bdf0e46c8451011caeb4182729fe147 100644 (file)
@@ -2,26 +2,25 @@ package hu.user.lis.db.repository.filter;
 
 import hu.user.lis.db.Partner;
 import hu.user.lis.db.Project;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import lombok.ToString;
+import lombok.*;
 
 import java.util.Date;
 
 @Getter
 @Setter
-@NoArgsConstructor
+@Builder
 @ToString
+@NoArgsConstructor
+@AllArgsConstructor
 public class InvoiceFilter extends PageableFilter {
 
     private Partner partner;
 
     private Project project;
 
-    private boolean isIncoming;
+    private boolean incoming;
 
-    private boolean isSettled;
+    private boolean paid;
 
     private Date paymentDeadLineFrom;
 
index 4e469fbc84a2fa46f3162cea0e03cf0daf705fba..70816393cfda8a993482202554559e679235e241 100644 (file)
@@ -5,23 +5,56 @@ import org.springframework.stereotype.Service;
 
 import java.lang.reflect.Field;
 import java.util.Arrays;
+import java.util.Optional;
 
 @Log4j2
 @Service
 public class EntityDataServiceBase {
 
+    private Object getMemberEntity(Object parent, String property) throws IllegalAccessException, NoSuchFieldException {
+        Object result = parent;
+        if (property.contains(".")) {
+            String[] tokens = property.split("\\.");
+            for (int i = 0; i < tokens.length - 1; i++) {
+                String fieldName = tokens[i];
+                Optional<Field> declaredField = Optional.of(result.getClass().getDeclaredField(fieldName));
+                Field field = declaredField.get();
+                field.setAccessible(true);
+                result = field.get(result);
+            }
+        }
+        return result;
+    }
+
+    private String getPropertyName(String property) {
+        String result = property;
+        if (property.contains(".")) {
+            String[] tokens = property.split("\\.");
+            result = tokens[tokens.length - 1];
+        }
+        return result;
+    }
+
+
+    private Field getField(Object entity, String property) throws NoSuchFieldException {
+        Field field;
+        boolean hasField = Arrays.stream(entity.getClass().getDeclaredFields()).anyMatch(f -> f.getName().equals(property));
+        if (hasField) {
+            field = entity.getClass().getDeclaredField(property);
+        } else {
+            field = entity.getClass().getSuperclass().getDeclaredField(property);
+        }
+        return field;
+    }
+
     public boolean setFieldValue(Object entity, String property, Object value) {
         boolean result = false;
-        Field field;
         try {
-            boolean hasField = Arrays.stream(entity.getClass().getDeclaredFields()).anyMatch(f -> f.getName().equals(property));
-            if (hasField) {
-                field = entity.getClass().getDeclaredField(property);
-            } else {
-                field = entity.getClass().getSuperclass().getDeclaredField(property);
-            }
+            String memberPropertyName = getPropertyName(property);
+            Object memberEntity = getMemberEntity(entity, property);
+            Field field = getField(memberEntity, memberPropertyName);
             field.setAccessible(true);
-            field.set(entity, value);
+            field.set(memberEntity, value);
             result = true;
         } catch (Exception e) {
             log.error(e);
@@ -31,16 +64,12 @@ public class EntityDataServiceBase {
 
     public Object getFieldValue(Object entity, String property) {
         Object result = null;
-        Field field;
         try {
-            boolean hasField = Arrays.stream(entity.getClass().getDeclaredFields()).anyMatch(f -> f.getName().equals(property));
-            if (hasField) {
-                field = entity.getClass().getDeclaredField(property);
-            } else {
-                field = entity.getClass().getSuperclass().getDeclaredField(property);
-            }
+            String memberPropertyName = getPropertyName(property);
+            Object memberEntity = getMemberEntity(entity, property);
+            Field field = getField(memberEntity, memberPropertyName);
             field.setAccessible(true);
-            result = field.get(entity);
+            result = field.get(memberEntity);
         } catch (Exception e) {
             log.error(e);
         }
index 37663fe288e412fc714b9f5ff0c67863b1e8a274..7333b7754e395136d75ea2a6ddab950c9777fd0e 100644 (file)
@@ -52,7 +52,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
         this.incomingEntities = new ArrayList<>();
         this.outgoingEntities = new ArrayList<>();
         entities.forEach(e -> {
-            if (e.isIncome()) {
+            if (e.isIncoming()) {
                 incomingEntities.add(e);
             } else {
                 outgoingEntities.add(e);
@@ -104,7 +104,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)
+                    .incoming(income)
                     .build();
             result.add(entity);
         }
@@ -138,7 +138,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -163,7 +163,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -188,7 +188,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -213,7 +213,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -238,7 +238,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -263,7 +263,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -288,7 +288,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -313,7 +313,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -338,7 +338,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -363,7 +363,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -388,7 +388,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -413,7 +413,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -438,7 +438,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -463,7 +463,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -488,7 +488,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -513,7 +513,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -538,7 +538,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -563,7 +563,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // bejovo szamla
+                    .incoming(income)                     // bejovo szamla
                     .build();
             result.add(entity);
 
@@ -589,7 +589,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // kimeno szamla
+                    .incoming(income)                     // kimeno szamla
                     .build();
             result.add(entity);
 
@@ -614,7 +614,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // kimeno szamla
+                    .incoming(income)                     // kimeno szamla
                     .build();
             result.add(entity);
 
@@ -640,7 +640,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // kimeno szamla
+                    .incoming(income)                     // kimeno szamla
                     .build();
             result.add(entity);
 
@@ -665,7 +665,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // kimeno szamla
+                    .incoming(income)                     // kimeno szamla
                     .build();
             result.add(entity);
 
@@ -691,7 +691,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // kimeno szamla
+                    .incoming(income)                     // kimeno szamla
                     .build();
             result.add(entity);
 
@@ -716,7 +716,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // kimeno szamla
+                    .incoming(income)                     // kimeno szamla
                     .build();
             result.add(entity);
 
@@ -741,7 +741,7 @@ public class InvoiceServiceImpl extends DataServiceImpl<Invoice> implements Invo
                     .netAmount(netAmount)
                     .grossAmount(grossAmount)
                     .vatAmount(vatAmount)
-                    .income(income)                     // kimeno szamla
+                    .incoming(income)                     // kimeno szamla
                     .build();
             result.add(entity);
         }
index b5bf929501be875b5675b23eb19f456bb364a532..949adbfcaa4bba0e232a2c1cf605ca9ddc060d2c 100644 (file)
@@ -21,7 +21,7 @@ public interface InvoiceMapper {
     @Mapping(target = "netAmount", source = "invoiceMain.invoice.invoiceSummary.summaryNormal.invoiceNetAmount")
     @Mapping(target = "vatAmount", source = "invoiceMain.invoice.invoiceSummary.summaryNormal.invoiceVatAmount")
     @Mapping(target = "grossAmount", source = "invoiceMain.invoice.invoiceSummary.summaryGrossData.invoiceGrossAmount")
-    @Mapping(target = "income", constant = "true")
+    @Mapping(target = "incoming", constant = "true")
     @Mapping(target = "id", ignore = true)
     @Mapping(target = "title", ignore = true)
     @Mapping(target = "planned", ignore = true)
index dd16b75b3d43f390ff29dd8e938a756ab7f11098..00b3a5724f7b03f3a3cd068155cc8c0b796532b5 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module version="4">
   <component name="SonarLintModuleSettings">
-    <option name="uniqueId" value="479a69b7-fe0e-4ae1-bea4-f9c9506ffaff" />
+    <option name="uniqueId" value="28f051fb-5766-4e3e-8837-e81b969fbd4c" />
   </component>
 </module>
\ No newline at end of file
index b8e7a0bb5cbdd2fc3a42cea3f662823efc9d8316..83b15cd6de160b274c8a46ca785ab14fa71974e0 100644 (file)
@@ -13,8 +13,7 @@ public class Constants {
     public static final String REFRESH_INVOICE_IMPORT_TASKS = "REFRESH_INVOICE_IMPORT_TASKS";
     public static final String NAV_PARTNERS = "/partners";
     public static final String NAV_INVOICES = "/invoices";
-
-    public static final String NAV_INVOICE_SETTLE = "/invoice-settle";
+    public static final String NAV_INVOICE_PAYMENT = "/invoice-payment";
     public static final String NAV_PROJECTS = "/projects";
     public static final String NAV_PROJECT = "/project";
     public static final String NAV_PROJECT_WILD_CARD = "/project/**";
index 8402070c2bf8b4b3e5ffec6717027a22da32ac42..f9ebf1b70eba2e0e73992a2268070c8a6d4c48e0 100644 (file)
@@ -37,7 +37,7 @@ public class CurrentProfile {
         return settings.get(type);
     }
 
-    public void addSetting(Profile columnProfile) {
+    public void persistSetting(Profile columnProfile) {
         Profile existing = settings.get(columnProfile.getType());
         if (Objects.nonNull(existing)) {
             columnProfile.setId(existing.getId());
index 4e9a79b85240e88a15f179c0ce5d55bac5a1838d..cf7a390cf7648f33d0c83afb2a9b5f01af1f91b6 100644 (file)
@@ -25,7 +25,7 @@ public class ResourceConfigurer {
             Constants.NAV_IMPORT_INVOICES_ASSIGN,
             Constants.NAV_IMPORT_INVOICES_APPROVE,
             Constants.NAV_INVOICES,
-            Constants.NAV_INVOICE_SETTLE,
+            Constants.NAV_INVOICE_PAYMENT,
             Constants.NAV_SETTINGS,
             Constants.NAV_PROJECT_WILD_CARD
     })
index 21e580fdda5d6c578448a29b819aac27d35c997d..57641df3fc4c8e3cdb2a06a8b8dcdc1cc0881d97 100644 (file)
@@ -35,7 +35,7 @@ public class InvoiceDataModel {
 
     public IncomingInvoice createNewIncomingInvoice() {
         IncomingInvoice result = IncomingInvoice.builder()
-                .income(true)
+                .incoming(true)
                 .planned(true)
                 .build();
         return result;
index aa7f7128c5fa10f35a590d545e14e9d62338ad91..3468cdf545080c418bfc84b6128414afea78c37d 100644 (file)
@@ -43,10 +43,4 @@ public class InvoicesDataModel extends CachedSpringDataModel<Invoice> {
         this.filter = filter;
         super.reset();
     }
-
-    public void listAll() {
-        log.info("List all invoices");
-        this.filter = null;
-        super.reset();
-    }
 }
index 4ba8666e7e9b2428cb652fd8b095536d98877ca6..5d8ad8bccd7069c98d75d8a64d3bb6da1fc6e258 100644 (file)
@@ -35,11 +35,16 @@ public abstract class CachedSpringDataModel<T> extends CachedDataModel<T> {
 
     public void addColumns(Map<String, String> columns) {
         Profile profile = currentProfile.getSetting(getClass().getSimpleName());
+        columns.keySet().forEach(colName -> addColumn(colName, columns.get(colName)));
         if (Objects.isNull(profile)) {
-            columns.keySet().forEach(colName -> addColumn(colName, columns.get(colName)));
             saveProfileSetting();
         } else {
-            columnSettings = entityDataService.fromJSON(profile.getSetting(), JSONObject.class);
+            JSONObject savedColumns = entityDataService.fromJSON(profile.getSetting(), JSONObject.class);
+            if (savedColumns.keySet().equals(columns.keySet())) {
+                columnSettings = savedColumns;
+            } else {
+                saveProfileSetting();
+            }
         }
     }
 
@@ -49,7 +54,7 @@ public abstract class CachedSpringDataModel<T> extends CachedDataModel<T> {
                 .type(getClass().getSimpleName())
                 .setting(entityDataService.toJSON(columnSettings))
                 .build();
-        currentProfile.addSetting(columnProfile);
+        currentProfile.persistSetting(columnProfile);
     }
 
     private void addColumn(String name, String direction) {
index f9f529a58b96b974ec2031836a5e3183821ad9b5..61e74d246789501bca66470125ad4dd7e15d03fb 100644 (file)
@@ -2,52 +2,118 @@ package hu.user.lis.ui.view;
 
 import com.google.common.collect.ImmutableMap;
 import hu.user.lis.db.Invoice;
+import hu.user.lis.db.Partner;
+import hu.user.lis.db.Project;
+import hu.user.lis.db.repository.filter.InvoiceFilter;
 import hu.user.lis.ui.Constants;
 import hu.user.lis.ui.data.InvoicesDataModel;
 import hu.user.lis.ui.data.common.CachedSpringDataModel;
+import hu.user.lis.ui.editor.selector.EntitySelectorRouter;
+import hu.user.lis.ui.event.EventBus;
 import hu.user.lis.ui.view.common.EntityViewModel;
 import lombok.Getter;
 import lombok.extern.log4j.Log4j2;
-import org.zkoss.bind.annotation.Init;
+import org.zkoss.bind.BindUtils;
+import org.zkoss.bind.PropertyChangeEvent;
+import org.zkoss.bind.annotation.*;
+import org.zkoss.zk.ui.Component;
+import org.zkoss.zk.ui.event.Event;
+import org.zkoss.zk.ui.event.EventListener;
 import org.zkoss.zk.ui.select.annotation.WireVariable;
 
+import java.util.Objects;
+
 import static hu.user.lis.ui.data.common.CachedDataModel.ASCENDING;
 import static hu.user.lis.ui.data.common.CachedDataModel.NATURAL;
 
 @Log4j2
-public class InvoicesViewModel extends EntityViewModel<Invoice> {
+public class InvoicesViewModel extends EntityViewModel<Invoice> implements EventListener<Event> {
+    @Getter
+    private final InvoiceFilter invoiceFilter = InvoiceFilter.builder().incoming(true).build();
+
     @Getter
     @WireVariable
-    InvoicesDataModel invoicesDataModel;
+    EntitySelectorRouter entitySelectorRouter;
 
-    @Override
-    protected CachedSpringDataModel<Invoice> getDataModel() {
-        return invoicesDataModel;
-    }
+    @WireVariable
+    private EventBus eventBus;
 
-    @Override
-    protected String getNavigation() {
-        return Constants.NAV_INVOICES;
-    }
+    //    private boolean filterShowIncoming;
+//    private boolean filterShowOutgoing;
+    @Getter
+    @WireVariable
+    private InvoicesDataModel invoicesDataModel;
 
     @Init
+    @Override
     public void init() {
         super.init();
+        eventBus.register(this);
+        eventBus.registerForBinding(this);
+        refresh();
         addColumns(ImmutableMap.of(
                 "partner.name", ASCENDING,
                 "partner.vatNr", NATURAL,
                 "project.name", NATURAL,
-                "dueDate", NATURAL,
-                "paymentDate", NATURAL,
+                "paymentDeadline", NATURAL,
                 "grossAmount", NATURAL,
                 "currency", NATURAL,
-                "income", NATURAL
+                "incoming", NATURAL
         ));
     }
 
-    protected void refresh() {
+    @Override
+    @AfterCompose
+    public void onAfterCompose(@ContextParam(ContextType.VIEW) Component view) {
+        entitySelectorRouter.configureSelector(Partner.class, this, "invoiceFilter.partner");
+        entitySelectorRouter.configureSelector(Project.class, this, "invoiceFilter.project");
+    }
+
+    @Override
+    protected CachedSpringDataModel<Invoice> getDataModel() {
+        return invoicesDataModel;
+    }
+
+    @Override
+    protected String getNavigation() {
+        return Constants.NAV_INVOICES;
+    }
+
+    @Command
+    public void refresh() {
         invoicesDataModel.clearSelection();
-        invoicesDataModel.listAll();
+        invoicesDataModel.search(invoiceFilter);
     }
 
+    @Command
+    public void setIncoming(@BindingParam("incoming") boolean value) {
+        invoiceFilter.setIncoming(value);
+        BindUtils.postNotifyChange(null, null, invoiceFilter, "incoming");
+        refresh();
+    }
+
+    @Command
+    public void search() {
+        refresh();
+    }
+
+    @Override
+    public void onEvent(Event evt) throws Exception {
+        if (evt instanceof PropertyChangeEvent) {
+            PropertyChangeEvent propertyEvent = (PropertyChangeEvent) evt;
+            if (Objects.nonNull(propertyEvent.getBase()) && propertyEvent.getBase().equals(this)) {
+                if ("invoiceFilter.project".equals(propertyEvent.getProperty()) ||
+                        "invoiceFilter.partner".equals(propertyEvent.getProperty())) {
+                    refresh();
+                }
+            }
+
+        }
+    }
+
+    @Destroy
+    public void onDestroy() {
+        log.info("Destroy {}", getClass().getSimpleName());
+        eventBus.unregister(this);
+    }
 }
index 6b78af6c1547c6b3ace6387f11b39a0837f2269c..87db3db51f52d0241227193483a012e894e82050 100644 (file)
@@ -33,7 +33,7 @@ import static hu.user.lis.ui.data.common.CachedDataModel.NATURAL;
 
 @Log4j2
 @VariableResolver(DelegatingVariableResolver.class)
-public class ServiceRecordsViewModel extends EntityViewModel<ServiceRecord> implements EventListener {
+public class ServiceRecordsViewModel extends EntityViewModel<ServiceRecord> implements EventListener<Event> {
     @WireVariable
     @Getter
     ServiceRecordsDataModel serviceRecordsDataModel;
index 458953135e240f924162287953e8925e5d2f383c..c5efc7184b613d889fdb489793b881a4c2a04166 100644 (file)
@@ -1,46 +1,84 @@
+<?component name="entity-selector" inline="true" class="hu.user.lis.ui.editor.widget.EntitySelector"?>
 <zk>
     <window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.InvoicesViewModel')">
         <caption label="Számlák"/>
         <borderlayout>
-            <north flex="true">
+            <north hflex="true">
                 <toolbar>
-                    <toolbarbutton label="Hozzáadás" iconSclass="z-icon-plus" onClick="@command('onAdd')"/>
-                    <toolbarbutton label="Szerkesztés" iconSclass="z-icon-edit" onClick="@command('onEdit')"
-                                   disabled="@load(empty vm.selectedEntity)"/>
-                    <toolbarbutton label="Törlés" iconSclass="z-icon-remove" onClick="@command('onDelete')"
-                                   disabled="@load(empty vm.selectedEntity)"/>
+                    <!--                    <toolbarbutton label="Hozzáadás" iconSclass="z-icon-plus" onClick="@command('onAdd')"/>-->
+                    <!--                    <toolbarbutton label="Szerkesztés" iconSclass="z-icon-edit" onClick="@command('onEdit')"-->
+                    <!--                                   disabled="@load(empty vm.selectedEntity)"/>-->
+                    <!--                    <toolbarbutton label="Törlés" iconSclass="z-icon-remove" onClick="@command('onDelete')"-->
+                    <!--                                   disabled="@load(empty vm.selectedEntity)"/>-->
+                    <label value="Partner"/>
                     <separator orient="vertical"/>
-                    <toolbarbutton mode="toggle" iconSclass="z-icon-check" label="Aktív"
-                                   checked="@bind(vm.filterShowActive)"/>
-                    <toolbarbutton mode="toggle" iconSclass="z-icon-ban" label="Inaktív"
-                                   checked="@bind(vm.filterShowInActive)"/>
-                    <toolbarbutton mode="toggle" iconSclass="z-icon-adjust" label="Mind"
-                                   checked="@bind(vm.filterShowBoth)"/>
+                    <entity-selector entity="Partner" style="display: inline-block;" width="300px"/>
+                    <space bar="true"/>
+                    <label value="Projekt"/>
+                    <separator orient="vertical"/>
+                    <entity-selector entity="Project" style="display: inline-block;" width="300px"/>
+                    <space bar="true"/>
+                    <toolbarbutton mode="toggle" iconSclass="z-icon-external-link" label="Költség"
+                                   checked="@load(vm.invoiceFilter.incoming)"
+                                   onClick="@command('setIncoming', incoming=true)"/>
+                    <toolbarbutton mode="toggle" iconSclass="z-icon-sign-in" label="Bevétel"
+                                   checked="@load(!vm.invoiceFilter.incoming)"
+                                   onClick="@command('setIncoming', incoming=false)"/>
+                    <space bar="true"/>
+                    <!--                    <separator orient="vertical"/>-->
+                    <label value="Fizetési határidő"/>
+                    <separator orient="vertical"/>
+                    <datebox instant="true" format="yyyy. MM. dd."
+                             value="@bind(vm.invoiceFilter.paymentDeadLineFrom)"
+                             onChange="@command('refresh')"/>
+                    <label value="-"/>
+                    <datebox instant="true" format="yyyy. MM. dd."
+                             value="@bind(vm.invoiceFilter.paymentDeadLineTo)"
+                             onChange="@command('refresh')"/>
+
+                    <space bar="true"/>
+                    <toolbarbutton mode="toggle" iconSclass="z-icon-credit-card" label="Teljesített fizetés"
+                                   checked="@load(!vm.invoiceFilter.incoming)"
+                                   onClick="@command('setIncoming', incoming=false)"/>
+
+                    <!--                    <toolbarbutton iconSclass="z-icon-search" label="Szűrés"-->
+                    <!--                                   onClick="@command('search')"/>-->
                 </toolbar>
             </north>
-            <center border="none" flex="true">
-                <listbox id="partnersList" vflex="true" model="@load(vm.partnersDataModel)"
+            <center border="none" hflex="true" vflex="true">
+                <listbox id="invoicesList" vflex="true" model="@load(vm.invoicesDataModel)"
                          autopaging="true" mold="paging" pagingPosition="top" multiple="false"
                          onSelect="@command('onListSelection')" onDoubleClick="@command('onEdit')">
                     <listhead sizable="true">
-                        <listheader label="Név" sort="auto(name)" align="left"
-                                    sortDirection="@load(vm.cols['name'].sortDirection)"/>
-                        <listheader label="Adószám" sort="auto(vatNr)" align="left"
-                                    sortDirection="@load(vm.cols['vatNr'].sortDirection)"/>
-                        <listheader label="Cím" sort="auto(address)" align="left"
-                                    sortDirection="@load(vm.cols['address'].sortDirection)"/>
-                        <listheader label="Aktív" sort="auto(active)" align="left"
-                                    sortDirection="@load(vm.cols['active'].sortDirection)"/>
-
+                        <listheader label="Partner név" sort="auto(partner.name)" align="left"
+                                    sortDirection="@load(vm.cols['partner.name'].sortDirection)"/>
+                        <listheader label="Partner adószám" sort="auto(partner.vatNr)" align="left"
+                                    sortDirection="@load(vm.cols['partner.vatNr'].sortDirection)"/>
+                        <listheader label="Projekt név" sort="auto(project.name)" align="left"
+                                    sortDirection="@load(vm.cols['project.name'].sortDirection)"/>
+                        <listheader label="Fizetési határidő" sort="auto(paymentDeadline)" align="left"
+                                    sortDirection="@load(vm.cols['paymentDeadline'].sortDirection)"/>
+                        <listheader label="Bruttó összeg" sort="auto(grossAmount)" align="right"
+                                    style="text-align: center"
+                                    sortDirection="@load(vm.cols['grossAmount'].sortDirection)"/>
+                        <listheader label="Bruttó összeg" sort="auto(currency)" align="left"
+                                    sortDirection="@load(vm.cols['currency'].sortDirection)"/>
+                        <listheader label="Költség/Bevétel" sort="auto(incoming)" align="left"
+                                    sortDirection="@load(vm.cols['incoming'].sortDirection)"/>
                     </listhead>
                     <template name="model">
                         <listitem>
-                            <listcell label="@load(each.name)"/>
-                            <listcell label="@load(each.vatNr)"/>
-                            <listcell label="@load(each.address)"/>
+                            <listcell label="@load(each.partner.name)"/>
+                            <listcell label="@load(each.partner.vatNr)"/>
+                            <listcell label="@load(each.project.name)"/>
+                            <listcell
+                                    label="@load(each.paymentDeadline) @converter('hu.user.lis.ui.converter.DateToStringConverter')"/>
+                            <listcell
+                                    label="@load(each.grossAmount) @converter('hu.user.lis.ui.converter.DoubleToStringConverter')"/>
+                            <listcell label="@load(each.currency)"/>
                             <listcell>
-                                <a iconSclass="z-icon-check" visible="@load(each.active)"/>
-                                <a iconSclass="z-icon-ban" visible="@load(!each.active)"/>
+                                <a iconSclass="z-icon-external-link" visible="@load(each.incoming)"/>
+                                <a iconSclass="z-icon-sign-in" visible="@load(!each.incoming)"/>
                             </listcell>
                         </listitem>
                     </template>
index 20aa9c4e2aa97a6cdf40eaab0b21a74531386af5..d3587c064fdae899925df79461f2ee59db3d6815 100644 (file)
@@ -76,7 +76,7 @@ public class IncomingInvoiceFetcherService {
                 .netAmount(netAmount)
                 .grossAmount(grossAmount)
                 .vatAmount(vatAmount)
-                .income(true)
+                .incoming(true)
                 .build();
     }