</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
<?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>
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
-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
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>
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
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
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
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
--- /dev/null
+<?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
</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>
</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>
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 {
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;
.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();
+ }
+
}
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;
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 {
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);
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")
@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
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";
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;
@Component
@Log4j2
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class ApproveInvoicesDataModel extends CachedSpringDataModel<JSONObject> implements ApplicationListener<ImportInvoicesEvent> {
+public class ApproveInvoicesDataModel extends CachedSpringDataModel<JSONObject> {
@Autowired
WorkflowManagerService workflowManagerService;
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);
@Component
@Log4j2
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class ImportInvoicesDataModel extends CachedSpringDataModel<JSONObject> {
+public class AssignInvoicesDataModel extends CachedSpringDataModel<JSONObject> {
+
@Autowired
WorkflowManagerService workflowManagerService;
private Treasury selectedTreasury;
@Getter
- @Setter
private String partialAssociateName;
@Init
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);
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)));
}
}
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);
}
}
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;
@Init
public void init() {
super.init();
+ eventBus.registerForProcessEvent(this);
}
@Command
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);
+ }
}
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;
@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
@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();
});
}
public void onEvent(Event event) throws Exception {
if (Constants.REFRESH_INVOICE_IMPORT_TASKS.equals(event.getName())) {
onRefresh();
- log.info("Refreshed by {}", event.getData());
}
}
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;
@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";
//
// 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) {
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
</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">
</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">
-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/>
+++ /dev/null
-package hu.user.lis.workflow.event;
-
-public class ImportInvoicesEvent extends ProcessEvent {
- public ImportInvoicesEvent(Object source) {
- super(source);
- }
-}
@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);
}
}
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;
@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) {
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();
+ }
}