v0.1.7
authorelgekko <vasary@elgekko.net>
Fri, 6 Oct 2023 10:59:34 +0000 (12:59 +0200)
committerelgekko <vasary@elgekko.net>
Fri, 6 Oct 2023 10:59:34 +0000 (12:59 +0200)
29 files changed:
.idea/compiler.xml
.idea/misc.xml
KB.md
TODO.txt
lis-app/pom.xml
lis-app/src/main/resources/application-dev.yaml
lis-app/src/main/resources/application.yaml
lis-app/src/main/resources/logback-prod.xml [new file with mode: 0644]
lis-app/src/main/resources/logback-spring.xml
lis-service/pom.xml
lis-service/src/main/java/hu/user/lis/service/data/EntityDataService.java
lis-service/src/main/java/hu/user/lis/service/nav/TaxOfficeConnector.java
lis-service/src/main/java/hu/user/lis/service/nav/TaxOfficeInvoiceService.java
lis-service/src/main/java/hu/user/lis/service/nav/mapper/InvoiceMapper.java
lis-service/src/main/java/hu/user/lis/service/nav/mapper/PartnerMapper.java
lis-ui/src/main/java/hu/user/lis/ui/data/ApproveInvoicesDataModel.java
lis-ui/src/main/java/hu/user/lis/ui/data/AssignInvoicesDataModel.java [moved from lis-ui/src/main/java/hu/user/lis/ui/data/ImportInvoicesDataModel.java with 96% similarity]
lis-ui/src/main/java/hu/user/lis/ui/editor/ProjectEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/event/EventBus.java
lis-ui/src/main/java/hu/user/lis/ui/event/ProcessEventRouter.java
lis-ui/src/main/java/hu/user/lis/ui/view/ApproveInvoicesViewModel.java
lis-ui/src/main/java/hu/user/lis/ui/view/AssignInvoicesViewModel.java
lis-ui/src/main/java/hu/user/lis/ui/view/IndexViewModel.java
lis-ui/src/main/resources/web/import-invoices-approve.zul
lis-ui/src/main/resources/web/import-invoices-assign.zul
lis-ui/src/main/resources/web/index.zul
lis-workflow/src/main/java/hu/user/lis/workflow/event/ImportInvoicesEvent.java [deleted file]
lis-workflow/src/main/java/hu/user/lis/workflow/event/WorkflowProcessEvent.java [moved from lis-workflow/src/main/java/hu/user/lis/workflow/event/ProcessEvent.java with 72% similarity]
lis-workflow/src/main/java/hu/user/lis/workflow/invoice/service/WorkflowManagerService.java

index bd0c65356256905131fc2ba4a48ae6571433cbaa..ae77cc075f05a4d82dfd98765fef512188505eba 100644 (file)
   </component>
   <component name="JavacSettings">
     <option name="ADDITIONAL_OPTIONS_OVERRIDE">
-      <module name="lis" options="-parameters -Amapstruct.defaultComponentModel=spring" />
-      <module name="lis-app" options="-parameters -Amapstruct.defaultComponentModel=spring" />
-      <module name="lis-db" options="-parameters -Amapstruct.defaultComponentModel=spring" />
-      <module name="lis-service" options="-parameters -Amapstruct.defaultComponentModel=spring" />
-      <module name="lis-ui" options="-parameters -Amapstruct.defaultComponentModel=spring" />
-      <module name="lis-workflow" options="-parameters -Amapstruct.defaultComponentModel=spring" />
+      <module name="lis" options="-parameters" />
+      <module name="lis-app" options="-parameters" />
+      <module name="lis-db" options="-parameters" />
+      <module name="lis-service" options="-parameters" />
+      <module name="lis-ui" options="-parameters" />
+      <module name="lis-workflow" options="-parameters" />
     </option>
   </component>
 </project>
\ No newline at end of file
index 9899816095379d15f109745fd01649fafa594c32..12d840abacf938e0a8a48c2942b7fe754703dcc6 100644 (file)
@@ -1,6 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ExternalStorageConfigurationManager" enabled="true" />
+  <component name="MavenCompilerTasksManager">
+    <option name="beforeCompileTasks">
+      <set>
+        <MavenCompilerTask>
+          <option name="goal" value="org.codehaus.mojo:jaxb2-maven-plugin:3.1.0:xjc" />
+          <option name="projectPath" value="$PROJECT_DIR$/lis-service/pom.xml" />
+        </MavenCompilerTask>
+      </set>
+    </option>
+  </component>
   <component name="MavenProjectsManager">
     <option name="originalFiles">
       <list>
diff --git a/KB.md b/KB.md
index c081b9be6019e4a52f1a60799948c7d7e77b8197..43f25b398fe6a83b25cae988cf294833a376fe95 100644 (file)
--- a/KB.md
+++ b/KB.md
@@ -79,6 +79,10 @@ https://fontawesomelib.com/releases/4.0.1/list/all/index.html
 
 A típussal eggyező változó nevet kell adni, különben nem találja meg!!!
 
+##### ZK WebClient
+
+https://www.baeldung.com/spring-5-webclient
+
 ##### Regexp
 
 adószám
index 4d0d96bd995b92614ebcbf5c92c0fc17ee4e3cdd..1b0e9a5071541b4b49d9b4555eddf081b439a951 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,27 +1,32 @@
-0.1.7
-
+0.1.8
+- munkalap hiba javítása
+- ömlesztve: kimenő számlák: mi nem lett kifizetve, partner
+- számla ki lett e fizetve (bejövő, kimenő)
 
-0.1.6
-*Számla import = Számlák (dinamikus, jelezzen ha van feladat bárhol)
-       -Számla iktatás
-               -Iktatandó számlák (dinamikus, jelezzen ha van feladat)
-               -Jóváhagyandó számlák (dinamikus, jelezzen ha van feladat)
-
-*NAV xml mit tartalmaz?
-*XML-ből jöjjenek létre a tesztadatok
-*Kiállító adószám=partner: ha nincs ilyen, akkor egy partner rögzítésre menjen (előre kitölve)
-???? NAV adatok nem átírhatóak: datumok, osszegek, partner, pénznem
-*Először 3.1.3 végszámlák kezelődjenek: Online-Invoice\sample\Data sample\2020-12-07-Példaszámlák_v3.0-hoz.pdf"
-*HUF, EUR, USD számla legyen, ebből egy amihez nincs partner
-???? Megjegyzésben mi található (projekt ID kellene), csinálni egyet amiben van projektszám (Lauratol pelda)
+- projekt ID-t regexp-el ki kell szedni, ha több van egy listát feldobni
     invoiceHead/invoiceDetail/additionalInvoiceData
     invoiceHead/invoiceDetail/conventionalInvoiceInfo/orderNumbers
     invoiceHead/invoiceDetail/conventionalInvoiceInfo/contractNumbers
     invoiceHead/invoiceDetail/conventionalInvoiceInfo/customerCompanyCodes
     invoiceHead/invoiceDetail/conventionalInvoiceInfo/projectNumbers
+- számla lekérdezés folytatólagossága (meg kell jegyezni, mi volt az utolsó elem), a kezdő dátum (napok száma) konfigurálható legyen?
+- autorizáció
+- dokumentum kezelés szétválasztása
 
-    Bejövő számla listázása: invoiceDirection=INBOUND
+0.1.7
+* A számla importhoz tartozó menüpontok jelezzék, ha van feladat
+* NAV adatok nem átírhatóak: datumok, osszegek, partner, pénznem
+* Számla import = Számlák
+       Számla iktatás
+           Iktatandó számlák
+           Jóváhagyandó számlák
 
+0.1.6
+* NAV xml mit tartalmaz?
+* XML-ből jöjjenek létre a tesztadatok
+* Kiállító adószám=partner: ha nincs ilyen, akkor egy partner rögzítésre menjen (előre kitölve)
+* Először 3.1.3 végszámlák kezelődjenek: Online-Invoice\sample\Data sample\2020-12-07-Példaszámlák_v3.0-hoz.pdf"
+* HUF, EUR, USD számla legyen, ebből egy amihez nincs partner
 
 0.1.5
 
index 8c88274a23faf8907791498011521932f60ff7c3..21ea56a5dc6526c80d4c1b7fba78c00f2dda3f93 100644 (file)
@@ -3,7 +3,7 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <artifactId>lis-app</artifactId>
-    <version>0.1.5-SNAPSHOT</version>
+    <version>0.1.7-SNAPSHOT</version>
     <parent>
         <groupId>hu.user</groupId>
         <artifactId>lis</artifactId>
index de876da4e3f7fdfd773d80fec1b0077859fb3d10..48fd8cb72bde449053f194f57437511f072586b2 100644 (file)
@@ -51,6 +51,10 @@ logging:
     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
@@ -70,7 +74,3 @@ service:
       sign-key: fe-9d8b-971c878376204BQEWTHH2HI6
       exchange-key: 3af24BQEWTHH4TSX
       sender-tax-number: 13364937
-#    org.springframework.security.web: INFO
-#  pattern:
-#    console: "%d %-5level %logger : %msg%n"
-#    file: "%d %-5level [%thread] %logger : %msg%n"
\ No newline at end of file
index 58fe1037c851907385df28a5be1029b15f2e6a0b..d8e8ba84d838f24f39b9822da2c5ec18ae8b219f 100644 (file)
@@ -8,8 +8,8 @@ zk:
 spring:
   jpa:
     #    hibernate:
-    #      use-new-id-generator-mappings: true
-    show-sql: true
+    #      use-new-id-generator-mappings: false
+    show-sql: false
     properties:
       hibernate:
         format_sql: true
@@ -46,11 +46,28 @@ camunda.bpm:
     create: All tasks
   job-execution.enabled: true
 logging:
-  #  config: classpath:log4j2.xml
+  config: logback.xml
   level:
     org.hibernate.engine.jdbc.spi.SqlExceptionHelper: ERROR
-#    org.springframework.security: DEBUG
-#    org.springframework.security.web: INFO
-#  pattern:
-#    console: "%d %-5level %logger : %msg%n"
-#    file: "%d %-5level [%thread] %logger : %msg%n"
\ No newline at end of file
+    org.springframework.web.clientRestTemplate: ERROR
+    logging.level.org.apache.http: ERROR
+    logging.level.httpclient.wire: ERROR
+application:
+  ui:
+    user-name: user
+    password: password
+  workflow:
+    import-invoice:
+      input-path: /temp/invoice-import
+service:
+  nav:
+    trust:
+      store: classpath:keystore/lis-keystore.jks
+      store.password: password
+    api:
+      url: https://api-test.onlineszamla.nav.gov.hu/invoiceService/v3
+      user: vkvyibj5xgqpbp0
+      password: Salabakt3r
+      sign-key: fe-9d8b-971c878376204BQEWTHH2HI6
+      exchange-key: 3af24BQEWTHH4TSX
+      sender-tax-number: 13364937
diff --git a/lis-app/src/main/resources/logback-prod.xml b/lis-app/src/main/resources/logback-prod.xml
new file mode 100644 (file)
index 0000000..3b3eb7d
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+    <property name="LOGS" value="./logs"/>
+
+    <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>
+
+    <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">
+            <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">
+                <maxFileSize>10MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+    </appender>
+
+    <!-- LOG everything at INFO level -->
+    <root level="info">
+        <!--        <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>
+
+</configuration>
\ No newline at end of file
index 99f82ffc55906517ea57d3060ef8db7b9ef5bdc3..01da73de9907bdf50ccb90f511410d6f70ea4234 100644 (file)
         </layout>
     </appender>
 
-    <appender name="RollingFile"
-              class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${LOGS}/spring-boot-logger.log</file>
-        <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/spring-boot-logger-%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="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 dc9c18700a9690beaac909b73233f88a11662802..7f36fada6e1ca3013416c4b98fb28e6ac26aadf4 100644 (file)
     </parent>
     <build>
         <plugins>
-            <!--            <plugin>-->
-            <!--                <groupId>org.apache.cxf</groupId>-->
-            <!--                <artifactId>cxf-wadl2java-plugin</artifactId>-->
-            <!--                <version>3.5.7</version>-->
-            <!--                <executions>-->
-            <!--                    <execution>-->
-            <!--                        <id>generate-sources</id>-->
-            <!--                        <phase>generate-sources</phase>-->
-            <!--                        <configuration>-->
-            <!--                            <sourceRoot>${basedir}/target/generated-sources/jaxb</sourceRoot>-->
-            <!--                            <wadlOptions>-->
-            <!--                                <wadlOption>-->
-            <!--                                    <wadl>${basedir}/src/main/resources/nav-application.wadl</wadl>-->
-            <!--                                    <impl>true</impl>-->
-
-            <!--                                    <packagename>hu.gov.nav.invoice.service</packagename>-->
-            <!--                                    <schemaPackagenames>-->
-            <!--                                        <schemaPackagename>-->
-            <!--                                            http://navinvoice=hu.gov.nav.invoice.schema-->
-            <!--                                        </schemaPackagename>-->
-            <!--                                    </schemaPackagenames>-->
-
-            <!--                                </wadlOption>-->
-            <!--                            </wadlOptions>-->
-            <!--                        </configuration>-->
-            <!--                        <goals>-->
-            <!--                            <goal>wadl2java</goal>-->
-            <!--                        </goals>-->
-            <!--                    </execution>-->
-            <!--                </executions>-->
-            <!--            </plugin>-->
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>jaxb2-maven-plugin</artifactId>
                     </execution>
                 </executions>
                 <configuration>
-                    <!--                    <xjbSources>-->
-                    <!--                        <xjbSource>src/main/resources/global.xjb</xjbSource>-->
-                    <!--                    </xjbSources>-->
-                    <!--                    <catalog>src/main/resources/NAV/schemas/catalog.xml</catalog>-->
                     <sources>
                         <source>src/main/resources/NAV/schemas/</source>
-                        <!--                        <source>src/main/resources/NAV/schemas/common.xsd</source>-->
-                        <!--                        <source>src/main/resources/NAV/schemas/invoiceBase.xsd</source>-->
-                        <!--                        <source>src/main/resources/NAV/schemas/serviceMetrics.xsd</source>-->
-                        <!--                        <source>src/main/resources/NAV/schemas/invoiceAnnulment.xsd</source>-->
-                        <!--                        <source>src/main/resources/NAV/schemas/invoiceData.xsd</source>-->
-                        <!--                        <source>src/main/resources/NAV/schemas/invoiceApi.xsd</source>-->
                     </sources>
-                    <!--                    <outputDirectory>${basedir}/src/main/generated</outputDirectory>-->
-                    <!--                    <clearOutputDir>true</clearOutputDir>-->
                 </configuration>
             </plugin>
         </plugins>
index 83848828cc9fc8fa508b45abcd73da16d6605acd..89d0a6e6bc1264333992984a64adf7b0cc7c904b 100644 (file)
@@ -41,6 +41,16 @@ public class EntityDataService<T extends Serializable> extends EntityDataService
         return result;
     }
 
+    public String toPrettyJSON(T entity) {
+        String result = null;
+        try {
+            result = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(entity);
+        } catch (JsonProcessingException e) {
+            log.catching(e);
+        }
+        return result;
+    }
+
     public T fromJSON(String data, Class<T> objectClass) {
         T result = null;
         try {
index 992c740becf0298fed458d7c2ca5ed3d54ef7191..32bc81aa5e54d6023726cdd7a53c0f4ed71b3532 100644 (file)
@@ -11,6 +11,7 @@ import org.springframework.http.MediaType;
 import org.springframework.http.client.reactive.ReactorClientHttpConnector;
 import org.springframework.stereotype.Component;
 import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Mono;
 import reactor.netty.http.client.HttpClient;
 
 import java.nio.charset.StandardCharsets;
@@ -42,4 +43,11 @@ public class TaxOfficeConnector {
                 .build();
     }
 
+    public String post(String pathSegment, String body) {
+        WebClient.RequestBodySpec bodySpec = client.post().uri(pathSegment);
+        WebClient.RequestHeadersSpec<?> headersSpec = bodySpec.bodyValue(body);
+        Mono<String> responseMono = headersSpec.retrieve().bodyToMono(String.class);
+        return responseMono.block();
+    }
+
 }
index 2aab0f740af11226bdb270e1b20be03ee38004ec..dc410cc1385b6551a81f07ac6fc7550a51042e63 100644 (file)
@@ -4,8 +4,6 @@ import hu.gov.nav.schemas.osa._3_0.api.*;
 import hu.gov.nav.schemas.osa._3_0.data.InvoiceData;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.web.reactive.function.client.WebClient;
-import reactor.core.publisher.Mono;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -42,11 +40,8 @@ public class TaxOfficeInvoiceService {
         request.setPage(page);
         request.setInvoiceDirection(InvoiceDirectionType.INBOUND);
         request.setInvoiceQueryParams(taxOfficeRequestBuilder.params());
-
-        WebClient.RequestBodySpec bodySpec = taxOfficeConnector.getClient().post().uri("/queryInvoiceDigest");
-        WebClient.RequestHeadersSpec<?> headersSpec = bodySpec.bodyValue(taxOfficeXmlConverter.toXml(request));
-        Mono<String> responseMono = headersSpec.retrieve().bodyToMono(String.class);
-        return taxOfficeXmlConverter.fromXml(responseMono.block(), QueryInvoiceDigestResponse.class);
+        String response = taxOfficeConnector.post("/queryInvoiceDigest", taxOfficeXmlConverter.toXml(request));
+        return taxOfficeXmlConverter.fromXml(response, QueryInvoiceDigestResponse.class);
     }
 
     public Optional<InvoiceData> queryInboundInvoiceData(String invoiceNumber, String supplierTaxNumber) throws Exception {
@@ -58,20 +53,18 @@ public class TaxOfficeInvoiceService {
         QueryInvoiceDataRequest queryRequest = taxOfficeRequestBuilder.requestInvoiceData();
         queryRequest.setInvoiceNumberQuery(query);
 
-        WebClient.RequestBodySpec bodySpec = taxOfficeConnector.getClient().post().uri("/queryInvoiceData");
-        WebClient.RequestHeadersSpec<?> headersSpec = bodySpec.bodyValue(taxOfficeXmlConverter.toXml(queryRequest));
-        Mono<String> responseMono = headersSpec.retrieve().bodyToMono(String.class);
-        Optional<QueryInvoiceDataResponse> response = taxOfficeXmlConverter.fromXml(responseMono.block(), QueryInvoiceDataResponse.class);
+        String response = taxOfficeConnector.post("/queryInvoiceData", taxOfficeXmlConverter.toXml(queryRequest));
+        Optional<QueryInvoiceDataResponse> responseData = taxOfficeXmlConverter.fromXml(response, QueryInvoiceDataResponse.class);
 //        invoiceData: A számla adatai BASE64 kódolásban
 //        compressedContentIndicator: Jelöli, ha az invoiceData tartalmát a BASE64 dekódolást követően még ki kell tömöríteni az olvasáshoz
 //        Base64 base64 = new Base64();
 //        String decodedString = new String(base64.decode(invoiceBytes));
-        byte[] invoiceBytes = response
+        byte[] invoiceBytes = responseData
                 .map(QueryInvoiceDataResponse::getInvoiceDataResult)
                 .map(InvoiceDataResultType::getInvoiceData)
                 .orElseThrow(NullPointerException::new);
 
-        boolean isDataCompressed = response
+        boolean isDataCompressed = responseData
                 .map(QueryInvoiceDataResponse::getInvoiceDataResult)
                 .map(InvoiceDataResultType::isCompressedContentIndicator)
                 .orElse(false);
index 7604b50f0fca7eea69d5369524edc2a3c7ae3698..b5bf929501be875b5675b23eb19f456bb364a532 100644 (file)
@@ -11,9 +11,8 @@ import org.mapstruct.MappingTarget;
 
 import java.util.stream.Collectors;
 
-@Mapper
+@Mapper(componentModel = "spring")
 public interface InvoiceMapper {
-    @Mapping(target = "id", ignore = true)
     @Mapping(target = "humanId", source = "invoiceNumber")
     @Mapping(target = "createDate", source = "invoiceIssueDate")
     @Mapping(target = "completionDate", source = "invoiceMain.invoice.invoiceHead.invoiceDetail.invoiceDeliveryDate")
@@ -22,9 +21,13 @@ 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 = "title", ignore = true)
     @Mapping(target = "income", constant = "true")
+    @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);
 
     @AfterMapping
index 35f4dcbae322d7cce51804e60d62bebb671a7aab..a7e62333ad9c83f91dc8ce7e03065bebe4e6030e 100644 (file)
@@ -9,7 +9,7 @@ import org.mapstruct.Mapper;
 import org.mapstruct.Mapping;
 import org.mapstruct.MappingTarget;
 
-@Mapper
+@Mapper(componentModel = "spring")
 public interface PartnerMapper {
     String ADDRESS_FORMAT = "%s %s, %s %s %s";
     String VATNR_FORMAT = "%s-%s-%s";
index 8176a609e11c371ff0b708ddf01051efa8c76485..b622cf5e1a6c47437e15f918bd7559727db3867c 100644 (file)
@@ -1,18 +1,15 @@
 package hu.user.lis.ui.data;
 
 import hu.user.lis.ui.data.common.CachedSpringDataModel;
-import hu.user.lis.workflow.event.ImportInvoicesEvent;
 import hu.user.lis.workflow.invoice.service.WorkflowManagerService;
 import lombok.extern.log4j.Log4j2;
 import org.camunda.bpm.engine.task.Task;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.ApplicationListener;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 import org.zkoss.json.JSONObject;
 import org.zkoss.zul.FieldComparator;
-import org.zkoss.zul.event.ListDataEvent;
 
 import java.util.List;
 import java.util.Map;
@@ -21,7 +18,7 @@ import java.util.stream.Collectors;
 @Component
 @Log4j2
 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class ApproveInvoicesDataModel extends CachedSpringDataModel<JSONObject> implements ApplicationListener<ImportInvoicesEvent> {
+public class ApproveInvoicesDataModel extends CachedSpringDataModel<JSONObject> {
     @Autowired
     WorkflowManagerService workflowManagerService;
 
@@ -29,11 +26,6 @@ public class ApproveInvoicesDataModel extends CachedSpringDataModel<JSONObject>
         super.reset();
     }
 
-    @Override
-    public void onApplicationEvent(ImportInvoicesEvent event) {
-        fireEvent(ListDataEvent.STRUCTURE_CHANGED, -1, -1);
-    }
-
     public void completeTask(JSONObject selectedEntity, Map<String, Object> vars) {
         String taskId = (String) selectedEntity.get("taskId");
         workflowManagerService.completeTask(taskId, vars);
similarity index 96%
rename from lis-ui/src/main/java/hu/user/lis/ui/data/ImportInvoicesDataModel.java
rename to lis-ui/src/main/java/hu/user/lis/ui/data/AssignInvoicesDataModel.java
index 6ad8f8ed0ddf131c7aa8edc6c5be75ea04c66958..99aa8f6f93d0240399bdbfa2f891c1fdb1923195 100644 (file)
@@ -18,7 +18,8 @@ import java.util.stream.Collectors;
 @Component
 @Log4j2
 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class ImportInvoicesDataModel extends CachedSpringDataModel<JSONObject> {
+public class AssignInvoicesDataModel extends CachedSpringDataModel<JSONObject> {
+
     @Autowired
     WorkflowManagerService workflowManagerService;
 
index 8d1ce0e4c7a1fa2f015f4cd0a99027de1c63c366..1272d0abeaaf6599f59219d1290e4fa8d3ec98c7 100644 (file)
@@ -83,7 +83,6 @@ public class ProjectEditorModel extends EntityEditorModel<Project> {
     private Treasury selectedTreasury;
 
     @Getter
-    @Setter
     private String partialAssociateName;
 
     @Init
index 27fac65b4f8d96a6bd6aa82931467c4b1c99f534..055c38164e99fadbb8961fd7182884d63567262b 100644 (file)
@@ -1,18 +1,27 @@
 package hu.user.lis.ui.event;
 
+import hu.user.lis.service.data.EntityDataService;
 import hu.user.lis.ui.Constants;
+import hu.user.lis.workflow.event.WorkflowProcessEvent;
 import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.zkoss.zk.ui.event.Event;
 import org.zkoss.zk.ui.event.EventListener;
 import org.zkoss.zk.ui.event.EventQueue;
 import org.zkoss.zk.ui.event.EventQueues;
 
+import java.io.Serializable;
 import java.util.Objects;
+import java.util.Optional;
 
 @Service
 @Log4j2
 public class EventBus {
+
+    @Autowired
+    EntityDataService<Serializable> entityDataService;
+
     private EventQueue<Event> getProcessEventQueue() {
         try {
             return EventQueues.lookup(Constants.PROCESS_EVENT_QUEUE, EventQueues.APPLICATION, true);
@@ -77,10 +86,8 @@ public class EventBus {
         getQueue().publish(new Event(Constants.SET_PROJECTS_LIST_DATA, null, data));
     }
 
-    public void refreshImportInvoiceTasks(String eventType) {
-        EventQueue<Event> processEventQueue = getProcessEventQueue();
-        if (Objects.nonNull(processEventQueue)) {
-            processEventQueue.publish(new Event(Constants.REFRESH_INVOICE_IMPORT_TASKS, null, eventType));
-        }
+    public void refreshImportInvoiceTasks(WorkflowProcessEvent data) {
+        Optional.ofNullable(getProcessEventQueue())
+                .ifPresent(q -> q.publish(new Event(Constants.REFRESH_INVOICE_IMPORT_TASKS, null, data)));
     }
 }
index dc43e3b7b8b860089b13c1cfc88f7311c2b50418..fd73e3cba6cb65120c96a8da7ee137eb064d7d0a 100644 (file)
@@ -1,17 +1,17 @@
 package hu.user.lis.ui.event;
 
-import hu.user.lis.workflow.event.ImportInvoicesEvent;
+import hu.user.lis.workflow.event.WorkflowProcessEvent;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationListener;
 import org.springframework.stereotype.Component;
 
 @Component
-public class ProcessEventRouter implements ApplicationListener<ImportInvoicesEvent> {
+public class ProcessEventRouter implements ApplicationListener<WorkflowProcessEvent> {
     @Autowired
     EventBus eventBus;
 
     @Override
-    public void onApplicationEvent(ImportInvoicesEvent event) {
-        eventBus.refreshImportInvoiceTasks(event.getEventType());
+    public void onApplicationEvent(WorkflowProcessEvent event) {
+        eventBus.refreshImportInvoiceTasks(event);
     }
 }
index 5f668b2ade81370e2ccddd4ac97caed35cac8aba..6e99299a97656a3c849c84de68ff448ab02755ee 100644 (file)
@@ -17,6 +17,7 @@ import lombok.extern.log4j.Log4j2;
 import org.springframework.transaction.annotation.Transactional;
 import org.zkoss.bind.BindUtils;
 import org.zkoss.bind.annotation.Command;
+import org.zkoss.bind.annotation.Destroy;
 import org.zkoss.bind.annotation.Init;
 import org.zkoss.bind.annotation.NotifyChange;
 import org.zkoss.json.JSONObject;
@@ -63,6 +64,7 @@ public class ApproveInvoicesViewModel extends EntityViewModel<JSONObject> implem
     @Init
     public void init() {
         super.init();
+        eventBus.registerForProcessEvent(this);
     }
 
     @Command
@@ -105,7 +107,11 @@ public class ApproveInvoicesViewModel extends EntityViewModel<JSONObject> implem
     public void onEvent(Event event) throws Exception {
         if (Constants.REFRESH_INVOICE_IMPORT_TASKS.equals(event.getName())) {
             onRefresh();
-            log.info("Refreshed by {}", event.getData());
         }
     }
+
+    @Destroy
+    public void onDestroy() {
+        eventBus.unregister(this);
+    }
 }
index ae2186ef0be005339095a4236f07d581cf1e0a68..8698df78168967693a245fda9468f7275e46e9ad 100644 (file)
@@ -3,7 +3,7 @@ package hu.user.lis.ui.view;
 import com.google.common.collect.ImmutableMap;
 import hu.user.lis.db.Invoice;
 import hu.user.lis.ui.Constants;
-import hu.user.lis.ui.data.ImportInvoicesDataModel;
+import hu.user.lis.ui.data.AssignInvoicesDataModel;
 import hu.user.lis.ui.data.common.CachedSpringDataModel;
 import hu.user.lis.ui.editor.common.Editors;
 import hu.user.lis.ui.event.EventBus;
@@ -28,20 +28,20 @@ import org.zkoss.zkplus.spring.DelegatingVariableResolver;
 @VariableResolver(DelegatingVariableResolver.class)
 public class AssignInvoicesViewModel extends EntityViewModel<JSONObject> implements EventListener<Event> {
     @WireVariable
-    ImportInvoicesDataModel importInvoicesDataModel;
+    AssignInvoicesDataModel assignInvoicesDataModel;
 
     @WireVariable
     ProcessEventRouter processEventRouter;
 
     @WireVariable
-    EventBus eventBus;
+    WorkflowManagerService workflowManagerService;
 
     @WireVariable
-    WorkflowManagerService workflowManagerService;
+    EventBus eventBus;
 
     @Override
     protected CachedSpringDataModel<JSONObject> getDataModel() {
-        return importInvoicesDataModel;
+        return assignInvoicesDataModel;
     }
 
     @Override
@@ -58,16 +58,16 @@ public class AssignInvoicesViewModel extends EntityViewModel<JSONObject> impleme
     @Command
     public void onRefresh() {
         setSelectedEntity(null);
-        importInvoicesDataModel.refresh();
+        assignInvoicesDataModel.refresh();
         BindUtils.postNotifyChange(this, "selectedEntity");
-        BindUtils.postNotifyChange(this, "importInvoicesDataModel");
+        BindUtils.postNotifyChange(this, "assignInvoicesDataModel");
     }
 
     @Command
     public void onHandleTask() {
         Invoice entity = (Invoice) getSelectedEntity().get("invoiceEntity");
         Editors.doEdit(Editors.IMPORT_INVOICE_ASSIGN, entity, modifiedEntity -> {
-            importInvoicesDataModel.completeTask(getSelectedEntity(), ImmutableMap.of("invoiceEntity", modifiedEntity));
+            assignInvoicesDataModel.completeTask(getSelectedEntity(), ImmutableMap.of("invoiceEntity", modifiedEntity));
             onRefresh();
         });
     }
@@ -76,7 +76,6 @@ public class AssignInvoicesViewModel extends EntityViewModel<JSONObject> impleme
     public void onEvent(Event event) throws Exception {
         if (Constants.REFRESH_INVOICE_IMPORT_TASKS.equals(event.getName())) {
             onRefresh();
-            log.info("Refreshed by {}", event.getData());
         }
     }
 
index d87f5bbf468d0cca21fb320f2624ded2caea86d4..6681f3aa7092a12e1723552bf9286470b3abf100 100644 (file)
@@ -15,6 +15,7 @@ import org.zkoss.bind.annotation.BindingParam;
 import org.zkoss.bind.annotation.Command;
 import org.zkoss.bind.annotation.Destroy;
 import org.zkoss.bind.annotation.Init;
+import org.zkoss.lang.Strings;
 import org.zkoss.zk.ui.event.Event;
 import org.zkoss.zk.ui.event.EventListener;
 import org.zkoss.zk.ui.select.annotation.VariableResolver;
@@ -28,11 +29,13 @@ import org.zkoss.zk.ui.util.Notification;
 @Setter
 public class IndexViewModel implements EventListener<Event> {
     //    private static final String PARTNERS_LIST = "~./partners.zul";
+
     private static final String PROJECTS_LIST = "~./projects.zul";
     //    private static final String ASSOCIATES_LIST = "~./associates.zul";
 //    private static final String PROJECT_ASSOCIATES_LIST = "~./project-associates.zul";
+
     private static final String SERVICE_RECORDS_LIST = "~./service-records.zul";
-//    private static final String SETTINGS_LIST = "~./settings.zul";
+    //    private static final String SETTINGS_LIST = "~./settings.zul";
 //    private static final String IMPORT_INVOICES_LIST = "~./import-invoices-assign.zul";
 //    private static final String APPROVE_INVOICES_LIST = "~./import-invoices-approve.zul";
 //
@@ -47,33 +50,47 @@ public class IndexViewModel implements EventListener<Event> {
 //            Constants.NAV_IMPORT_INVOICES, IMPORT_INVOICES_LIST,
 //            Constants.NAV_APPROVE_INVOICES, IMPORT_INVOICES_LIST
 //    );
+    private static final String DEFAULT_ASSIGN_INVOICES_LABEL = "Iktatandó számlák";
+
+    private static final String DEFAULT_APPROVE_INVOICES_LABEL = "Jóváhagyandó számlák";
 
     @WireVariable
-    EventBus eventBus;
+    private EventBus eventBus;
 
     @WireVariable
-    BuildProperties buildProperties;
+    private BuildProperties buildProperties;
 
     @WireVariable
-    SessionSettings sessionSettings;
+    private SessionSettings sessionSettings;
 
     @WireVariable
-    CurrentProfile currentProfile;
+    private CurrentProfile currentProfile;
 
     @WireVariable
-    WorkflowManagerService workflowManagerService;
+    private WorkflowManagerService workflowManagerService;
+
+    private String searchPhrase;
+
+    private String page;
 
-    String searchPhrase;
+    private String importInvoiceMenuClassName;
 
-    String page;
+    private String assignInvoiceMenuClassName;
+
+    private String approveInvoiceMenuClassName;
+
+    private String assignInvoicesLabel;
+
+    private String approveInvoicesLabel;
 
     @Init
     public void init() {
         eventBus.register(this);
-        log.info("Current session is {}", sessionSettings.getSessionId());
+        eventBus.registerForProcessEvent(this);
         String path = sessionSettings.getCurrentPath();
+//        log.info("Current session is {} path {}", sessionSettings.getSessionId(), path);
         route(path);
-        log.info("Init {}", path);
+        updateImportInvoiceMenus();
     }
 
     private void route(String path) {
@@ -111,6 +128,38 @@ public class IndexViewModel implements EventListener<Event> {
                 eventBus.setProjectsListData(event.getData());
             }
         }
+        if (Constants.REFRESH_INVOICE_IMPORT_TASKS.equals(event.getName())) {
+            updateImportInvoiceMenus();
+        }
+    }
+
+    private void updateImportInvoiceMenus() {
+        long assignInvoiceTaskCount = workflowManagerService.countAssignInvoiceTasks();
+        long approveInvoiceTaskCount = workflowManagerService.countApproveInvoiceTasks();
+        if (assignInvoiceTaskCount > 0) {
+            assignInvoicesLabel = String.format("%s (%d)", DEFAULT_ASSIGN_INVOICES_LABEL, assignInvoiceTaskCount);
+            assignInvoiceMenuClassName = "highlight";
+        } else {
+            assignInvoicesLabel = DEFAULT_ASSIGN_INVOICES_LABEL;
+            assignInvoiceMenuClassName = Strings.EMPTY;
+        }
+        BindUtils.postNotifyChange(this, "assignInvoicesLabel");
+        BindUtils.postNotifyChange(this, "assignInvoiceMenuClassName");
+        if (approveInvoiceTaskCount > 0) {
+            approveInvoicesLabel = String.format("%s (%d)", DEFAULT_APPROVE_INVOICES_LABEL, approveInvoiceTaskCount);
+            approveInvoiceMenuClassName = "highlight";
+        } else {
+            approveInvoicesLabel = DEFAULT_APPROVE_INVOICES_LABEL;
+            approveInvoiceMenuClassName = Strings.EMPTY;
+        }
+        BindUtils.postNotifyChange(this, "approveInvoicesLabel");
+        BindUtils.postNotifyChange(this, "approveInvoiceMenuClassName");
+        if (assignInvoiceTaskCount > 0 || approveInvoiceTaskCount > 0) {
+            importInvoiceMenuClassName = "highlight";
+        } else {
+            importInvoiceMenuClassName = Strings.EMPTY;
+        }
+        BindUtils.postNotifyChange(this, "importInvoiceMenuClassName");
     }
 
     @Destroy
index 68a16234ae156c740bbf5ece4d836c42e3b98039..7e164322a88480ac020cb64685cfef92259b1b58 100644 (file)
@@ -13,7 +13,7 @@
                 </toolbar>
             </north>
             <center border="none" flex="true">
-                <listbox id="importInvoicesList" vflex="true" model="@load(vm.approveInvoicesDataModel)"
+                <listbox vflex="true" model="@load(vm.approveInvoicesDataModel)"
                          autopaging="true" mold="paging" pagingPosition="top" multiple="false"
                          onSelect="@command('onListSelection')" onDoubleClick="@command('onHandleTask')">
                     <listhead sizable="true">
index 0c6996ca6a4e6bce692324faf24abb3033687c0e..b994ce18a54a9cec1cf6778f22bd61e94959e4a7 100644 (file)
@@ -13,7 +13,7 @@
                 </toolbar>
             </north>
             <center border="none" flex="true">
-                <listbox id="importInvoicesList" vflex="true" model="@load(vm.importInvoicesDataModel)"
+                <listbox vflex="true" model="@load(vm.assignInvoicesDataModel)"
                          autopaging="true" mold="paging" pagingPosition="top" multiple="false"
                          onSelect="@command('onListSelection')" onDoubleClick="@command('onHandleTask')">
                     <listhead sizable="true">
index 0a4b37a5bbf7cd02bae179c7ffa2d64f56fd981d..cef68a7983607ff0cf5e641f4476f91bfbfb4db5 100644 (file)
         -moz-user-select: none;
         -webkit-user-select: none;
         }
+        .highlight {
+        background: #FF000020;
+        }
+        .z-menu-text, .z-menuitem-text {
+        text-shadow: none;
+        }
     </style>
     <script>
         function pushNav(nav) {
                             <menuseparator/>
                             <menuitem iconSclass="z-icon-user" label="Munkatársak"
                                       onClick="@command(vm.selectPage('~./associates.zul'))"/>
-                            <menu iconSclass="z-icon-euro" label="Számlák">
+                            <menu iconSclass="z-icon-euro" label="Számlák"
+                                  sclass="@bind(vm.importInvoiceMenuClassName)">
                                 <menupopup>
-                                    <menu iconSclass="z-icon-tasks" label="Számla iktatás">
+                                    <menu iconSclass="z-icon-tasks" label="Számla iktatás"
+                                          sclass="@bind(vm.importInvoiceMenuClassName)">
                                         <menupopup>
-                                            <menuitem iconSclass="z-icon-paperclip" label="Iktatandó számlák"
-                                                      onClick="@command(vm.selectPage('~./import-invoices-assign.zul'))"/>
-                                            <menuitem iconSclass="z-icon-check-square-o" label="Jóváhagyandó számlák"
-                                                      onClick="@command(vm.selectPage('~./import-invoices-approve.zul'))"/>
+                                            <menuitem iconSclass="z-icon-paperclip"
+                                                      label="@bind(vm.assignInvoicesLabel)"
+                                                      onClick="@command(vm.selectPage('~./import-invoices-assign.zul'))"
+                                                      sclass="@bind(vm.assignInvoiceMenuClassName)"/>
+                                            <menuitem iconSclass="z-icon-check-square-o"
+                                                      label="@bind(vm.approveInvoicesLabel)"
+                                                      onClick="@command(vm.selectPage('~./import-invoices-approve.zul'))"
+                                                      sclass="@bind(vm.approveInvoiceMenuClassName)"/>
                                         </menupopup>
                                     </menu>
                                     <menuseparator/>
diff --git a/lis-workflow/src/main/java/hu/user/lis/workflow/event/ImportInvoicesEvent.java b/lis-workflow/src/main/java/hu/user/lis/workflow/event/ImportInvoicesEvent.java
deleted file mode 100644 (file)
index 1a40a0f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package hu.user.lis.workflow.event;
-
-public class ImportInvoicesEvent extends ProcessEvent {
-    public ImportInvoicesEvent(Object source) {
-        super(source);
-    }
-}
similarity index 72%
rename from lis-workflow/src/main/java/hu/user/lis/workflow/event/ProcessEvent.java
rename to lis-workflow/src/main/java/hu/user/lis/workflow/event/WorkflowProcessEvent.java
index ed4350f3ad7c709d15952899f8661b0cf1f9a5c8..67749c84f2e80075369d92a597a088ddf1673fe7 100644 (file)
@@ -6,14 +6,14 @@ import org.springframework.context.ApplicationEvent;
 
 @Getter
 @Setter
-public class ProcessEvent extends ApplicationEvent {
+public class WorkflowProcessEvent extends ApplicationEvent {
 
     private String name;
     private String key;
     private String id;
     private String eventType;
 
-    public ProcessEvent(Object source) {
+    public WorkflowProcessEvent(Object source) {
         super(source);
     }
 }
index 5e175adcbc5f5a11d1fc0ad5ac522a62b576182f..2edb267836ab6f8c99e4b24320b88bb816f72541 100644 (file)
@@ -1,9 +1,10 @@
 package hu.user.lis.workflow.invoice.service;
 
-import hu.user.lis.workflow.event.ImportInvoicesEvent;
+import hu.user.lis.workflow.event.WorkflowProcessEvent;
 import lombok.extern.log4j.Log4j2;
 import org.camunda.bpm.engine.RuntimeService;
 import org.camunda.bpm.engine.TaskService;
+import org.camunda.bpm.engine.impl.history.event.HistoricTaskInstanceEventEntity;
 import org.camunda.bpm.engine.impl.history.event.HistoryEvent;
 import org.camunda.bpm.engine.runtime.ProcessInstance;
 import org.camunda.bpm.engine.task.Task;
@@ -77,17 +78,23 @@ public class WorkflowManagerService {
 
     @EventListener
     public void onHistoryEvent(HistoryEvent historyEvent) {
-        log.info("HistoryEvent {}", historyEvent.getEventType());
+//        log.trace("HistoryEvent: {} {}", historyEvent.getClass().getSimpleName(), historyEvent.getEventType());
         if ("importIncomingInvoices".equals(historyEvent.getProcessDefinitionKey())) {
-            ImportInvoicesEvent event = new ImportInvoicesEvent(this);
-            event.setId(historyEvent.getProcessInstanceId());
-            event.setKey(historyEvent.getProcessDefinitionKey());
-            event.setName(historyEvent.getProcessDefinitionName());
-            event.setEventType(historyEvent.getEventType());
-
-            applicationEventPublisher.publishEvent(event);
+            if (historyEvent instanceof HistoricTaskInstanceEventEntity) {
+                HistoricTaskInstanceEventEntity event = (HistoricTaskInstanceEventEntity) historyEvent;
+                if ("assignProjectAndAttachFile".equals(event.getTaskDefinitionKey()) ||
+                        "approveAssignment".equals(event.getTaskDefinitionKey())) {
+                    if ("create".equals(event.getEventType()) || "complete".equals(event.getEventType())) {
+                        WorkflowProcessEvent appEvent = new WorkflowProcessEvent(historyEvent);
+                        appEvent.setId(historyEvent.getProcessInstanceId());
+                        appEvent.setKey(historyEvent.getProcessDefinitionKey());
+                        appEvent.setName(historyEvent.getProcessDefinitionName());
+                        appEvent.setEventType(historyEvent.getEventType());
+                        applicationEventPublisher.publishEvent(appEvent);
+                    }
+                }
+            }
         }
-
     }
 
     public void completeTask(String taskId) {
@@ -97,4 +104,12 @@ public class WorkflowManagerService {
     public void completeTask(String taskId, Map<String, Object> vars) {
         taskService.complete(taskId, vars);
     }
+
+    public long countAssignInvoiceTasks() {
+        return taskService.createTaskQuery().taskDefinitionKey("assignProjectAndAttachFile").count();
+    }
+
+    public long countApproveInvoiceTasks() {
+        return taskService.createTaskQuery().taskDefinitionKey("approveAssignment").count();
+    }
 }