Versions updated
authorelgekko <vasary@elgekko.net>
Fri, 28 Apr 2023 10:07:11 +0000 (12:07 +0200)
committerelgekko <vasary@elgekko.net>
Fri, 28 Apr 2023 10:07:11 +0000 (12:07 +0200)
26 files changed:
.idea/jarRepositories.xml
TODO.txt
lis-db/src/main/java/hu/user/lis/db/Associate.java
lis-db/src/main/java/hu/user/lis/db/ProjectAssociate.java [new file with mode: 0644]
lis-services/pom.xml
lis-services/src/main/java/hu/user/lis/services/data/InvoiceServiceImpl.java
lis-services/src/main/java/hu/user/lis/services/data/PartnerServiceImpl.java
lis-services/src/main/java/hu/user/lis/services/data/ProjectAssociateService.java [new file with mode: 0644]
lis-services/src/main/java/hu/user/lis/services/data/ProjectAssociateServiceImpl.java [new file with mode: 0644]
lis-ui/pom.xml
lis-ui/src/main/java/hu/user/lis/ui/config/ResourceConfigurer.java
lis-ui/src/main/java/hu/user/lis/ui/converter/DateToStringConverter.java [new file with mode: 0644]
lis-ui/src/main/java/hu/user/lis/ui/converter/DoubleToStringConverter.java [new file with mode: 0644]
lis-ui/src/main/java/hu/user/lis/ui/data/AssociatesDataModel.java
lis-ui/src/main/java/hu/user/lis/ui/data/ProjectAssociatesDataModel.java [new file with mode: 0644]
lis-ui/src/main/java/hu/user/lis/ui/data/ProjectsDataModel.java
lis-ui/src/main/java/hu/user/lis/ui/editor/AssociateEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/editor/InvoiceEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/editor/ProjectEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/view/IndexViewModel.java
lis-ui/src/main/resources/web/associate-editor.zul
lis-ui/src/main/resources/web/incoming-invoice-editor.zul
lis-ui/src/main/resources/web/index.zul
lis-ui/src/main/resources/web/outgoing-invoice-editor.zul
lis-ui/src/main/resources/web/project-editor.zul
pom.xml

index 1e05b0a57cf0677ff75fbc17ffa2e34464c554a3..b23ffa6213038e36fe831202213a4273e4b6a9bf 100644 (file)
@@ -6,6 +6,16 @@
       <option name="name" value="Central Repository" />
       <option name="url" value="https://repo.maven.apache.org/maven2" />
     </remote-repository>
+    <remote-repository>
+      <option name="id" value="ZK CE" />
+      <option name="name" value="ZK CE Repository" />
+      <option name="url" value="https://mavensync.zkoss.org/maven2" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="ZK EVAL" />
+      <option name="name" value="ZK Evaluation Repository" />
+      <option name="url" value="https://mavensync.zkoss.org/eval" />
+    </remote-repository>
     <remote-repository>
       <option name="id" value="central" />
       <option name="name" value="Maven Central repository" />
index d97a315a75b0d6bd6eaa929be4115230fb235c35..e82c5db1aa3e931aab2ef9d02ecdc9b3079453ed 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,16 +1,27 @@
+0.0.6
 * Projektek táblázat oszlopok sorrendje: Azonosító, Partner (inkább ügyfél), Név (inkább megnevezés), Kapcsolattartó. Értelemszerűen a projekt részletezésben s ügyfél és megnevezés legyen.
 * A projekt részletek képernyőn össze lehetne csukni a be és a kimenő számla táblázatokat.
 * Bejövő számlák: Szállító (ez most a partner), megnevezés (ez most a leírás), nettó összeg, Pénznem (ez most nincs), Fizetési határidő nem kell.
 * Kimenő számlák: Vevő (ez most a partner), megnevezés (ez most a leírás), nettó összeg, pénznem (ez most nincs), fizetési határidő nem kell.
 * A be és kimenő számlák felviteli képernyőjén be lehessen állítani, hogy ez egy tervezett számla-e.
 * Számlakép feltöltés: pdf csatolás
-- A dátumformátum: 2023. 04. 23. Nincs hónapnév és értelemszerűen nincs idő sem.
-- Összegek: két tizedesre igazítva, magyar számformátum: pl: 100,23   1.543.234,00   2800,05
-- Tervezett számla esetén: a határidők nem ismertek, nem kötelező; áfa deviza esetén nem ismert, nem kötelező
-- Munkatárs lista és szerkesztő: név, óradíj?
-- Munkatárs hozzárendelése a projekthez (vagy fordítva)
+* Munkatárs lista és szerkesztő: név, óradíj
+0.0.7
+* Tervezett számla esetén: a határidők nem ismertek, nem kötelező; áfa deviza esetén nem ismert, nem kötelező
+0.0.8
+* Projekt szerkesztőben előbb van a kimenő számlák lista
+* Munkatárs szerkesztőben óradíj helyett havi önköltség legyen
+* Kevesebb tesztadat: 5-10 partner, 3-4 projekt szla
+* Számformátum magyarul, 2 tizedesig
+* Dátumformátum: 2023. 04. 23. nincs hónapnév és értelemszerűen nincs idő sem.
+- Munkatárs hozzárendelése a projekthez a szerkesztőben
+
+- Projekt szerkesztőben treasury műveletek lista: Eladás (aloszlop összeg és deviza), Vétel (aloszlop összeg és deviza),Üzletkötés dátuma, Értéknap
+- A treasury szerkesztőben banki visszaigazolás pdf csatolása
 - Munkalap: külön lista xy hány órát (mindenki önköltség) dolgozott melyik projekten
+
 - Autentikáció: AD és helyi
 - Authorizáció: SAP S3 authorization objects leírás
 - Munkalap rögzítés úgy, hogy raktáron lévő alkatrészt is fel lehessen vinni a munkalapra.
 - Plugin: lehet egyedi testreszabási igény, de ennek valahogy el kell teljesen különülnie a "core" forráskódtól. Pl. javascript motort be lehetne építeni, a szkriptek pedig meghatározott pontokon lehetnének becsatolva a logikába. Számla részletezés volt a példa (10000EUR számla 3 részletben forintban, kérdés mennyi pl. az utsó számla összege); 10 custom mező, javascripttel futna a custom mezők módosítására.
+- Összegek: két tizedesre igazítva, magyar számformátum: pl: 100,23   1.543.234,00   2800,05
index dcabbe87a8b307dd3b267ff0f47786d04a6ad7ee..0d9fc21f09b6a54d17e25c4d28a91b46c1ae834b 100644 (file)
@@ -12,6 +12,6 @@ public class Associate {
     String name;
     String login;
     String password;
-    double hourlyRate;
+    double monthlyCost;
     boolean active;
 }
diff --git a/lis-db/src/main/java/hu/user/lis/db/ProjectAssociate.java b/lis-db/src/main/java/hu/user/lis/db/ProjectAssociate.java
new file mode 100644 (file)
index 0000000..c66cfd8
--- /dev/null
@@ -0,0 +1,13 @@
+package hu.user.lis.db;
+
+import lombok.*;
+
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class ProjectAssociate {
+    String projectId;
+    String associateId;
+}
index cef056e0aadc1ee08e7116dcc9cb765ead73f244..f500ae64135b9faff9248463af1a8c87e81486fe 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
          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>
     <groupId>hu.user</groupId>
@@ -13,6 +13,7 @@
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-web</artifactId>
+            <version>5.3.24</version>
         </dependency>
         <dependency>
             <groupId>org.apache.commons</groupId>
@@ -32,6 +33,7 @@
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-context</artifactId>
+            <version>5.3.24</version>
         </dependency>
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
index 36816383b52251dfdd77a05a3a60753dc6b3dbb5..9742befa77aba333cdaa52f3bc5bf0a05e41369f 100644 (file)
@@ -107,14 +107,16 @@ public class InvoiceServiceImpl implements InvoiceService {
     @Override
     public List<Invoice> getRandom(boolean income) {
         getAll();
-        int count = RandomUtils.nextInt(10, 20);
+        int count = RandomUtils.nextInt(2, 5);
         List<Invoice> result = new ArrayList<>();
         for (int i = 0; i < count; i++) {
             int index = RandomUtils.nextInt(0, 500);
             if (income) {
                 result.add(incomingEntities.get(index));
+                incomingEntities.remove(index);
             } else {
                 result.add(outgoingEntities.get(index));
+                outgoingEntities.remove(index);
             }
         }
         return result;
index adfba1cf1cb040e83d35a824a6ea4cadb9353445..90ee5a6f2805b8c4d4cea8fd77c732953585ba4d 100644 (file)
@@ -56,7 +56,8 @@ public class PartnerServiceImpl implements PartnerService {
 
     private List<Partner> generate() {
         List<Partner> result = new ArrayList<>();
-        for (int i = 0; i < 100; i++) {
+        int count = RandomUtils.nextInt(5, 10);
+        for (int i = 0; i < count; i++) {
             String id = RandomStringUtils.random(8, "0123456789abcdef");
             String name = dataGeneratorService.faker().name().fullName();
             String vatNr = RandomStringUtils.random(12, "0123456789");
diff --git a/lis-services/src/main/java/hu/user/lis/services/data/ProjectAssociateService.java b/lis-services/src/main/java/hu/user/lis/services/data/ProjectAssociateService.java
new file mode 100644 (file)
index 0000000..5054c13
--- /dev/null
@@ -0,0 +1,17 @@
+package hu.user.lis.services.data;
+
+import hu.user.lis.db.ProjectAssociate;
+
+import java.util.Collection;
+
+public interface ProjectAssociateService {
+    ProjectAssociate createNew(String projectId, String associateId);
+
+    void add(ProjectAssociate entity);
+
+    void remove(ProjectAssociate entity);
+
+    String toString(ProjectAssociate sourceEntity);
+
+    Collection<ProjectAssociate> getAll();
+}
diff --git a/lis-services/src/main/java/hu/user/lis/services/data/ProjectAssociateServiceImpl.java b/lis-services/src/main/java/hu/user/lis/services/data/ProjectAssociateServiceImpl.java
new file mode 100644 (file)
index 0000000..6062437
--- /dev/null
@@ -0,0 +1,75 @@
+package hu.user.lis.services.data;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import hu.user.lis.db.Associate;
+import hu.user.lis.db.Project;
+import hu.user.lis.db.ProjectAssociate;
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.RandomUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+@Log4j2
+public class ProjectAssociateServiceImpl implements ProjectAssociateService {
+    @Autowired
+    ObjectMapper mapper;
+    @Autowired
+    ProjectService projectService;
+    @Autowired
+    AssociateService associateService;
+    private List<ProjectAssociate> entities;
+
+    @Override
+    public List<ProjectAssociate> getAll() {
+        if (entities == null) {
+            entities = generate();
+        }
+        return entities;
+    }
+
+    @Override
+    public ProjectAssociate createNew(String projectId, String associateId) {
+        return ProjectAssociate.builder().projectId(projectId).associateId(associateId).build();
+    }
+
+    @Override
+    public void add(ProjectAssociate entity) {
+        entities.add(entity);
+    }
+
+    @Override
+    public void remove(ProjectAssociate entity) {
+        entities.remove(entity);
+    }
+
+    private List<ProjectAssociate> generate() {
+        List<ProjectAssociate> result = new ArrayList<>();
+        List<Project> projects = projectService.getAll();
+        for (Project project : projects) {
+            int associatesCount = RandomUtils.nextInt(1, 5);
+            for (int i = 0; i < associatesCount; i++) {
+                Associate associate = associateService.getRandom();
+                ProjectAssociate entity = ProjectAssociate.builder().projectId(project.getId()).associateId(associate.getId()).build();
+                result.add(entity);
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public String toString(ProjectAssociate sourceEntity) {
+        String result = null;
+        try {
+            result = mapper.writeValueAsString(sourceEntity);
+        } catch (JsonProcessingException e) {
+            log.catching(e);
+        }
+        return result;
+    }
+
+}
index f5c7e8d59d7d50f5ce0cdc60319bc5d50fbe207f..6a6d746d9d39157bfb65ee0cca297504c2df43b4 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <groupId>hu.user</groupId>
         <repository>
             <id>ZK CE</id>
             <name>ZK CE Repository</name>
-            <url>http://mavensync.zkoss.org/maven2</url>
+            <url>https://mavensync.zkoss.org/maven2</url>
         </repository>
     </repositories>
     <properties>
-        <zkspringboot.version>1.0.4</zkspringboot.version>
+        <zkspringboot.version>2.7.7</zkspringboot.version>
         <zk.version>9.6.0</zk.version>
     </properties>
     <dependencies>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-beans</artifactId>
-            <version>5.2.0.RELEASE</version>
+            <version>5.3.24</version>
         </dependency>
         <dependency>
             <groupId>org.zkoss.zkspringboot</groupId>
             <artifactId>zkspringboot-starter</artifactId>
+            <type>pom</type>
             <version>${zkspringboot.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.zkoss.zk</groupId>
-            <artifactId>zk</artifactId>
-            <version>${zk.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.zkoss.zk</groupId>
-            <artifactId>zul</artifactId>
-            <version>${zk.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.zkoss.zk</groupId>
-            <artifactId>zkbind</artifactId>
-            <version>${zk.version}</version>
-        </dependency>
         <dependency>
             <groupId>org.zkoss.zk</groupId>
             <artifactId>zkplus</artifactId>
             <version>${zk.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.zkoss.zk</groupId>
-            <artifactId>zhtml</artifactId>
-            <version>${zk.version}</version>
-        </dependency>
         <dependency>
             <groupId>org.zkoss.theme</groupId>
             <artifactId>silvertail</artifactId>
index be6d62d56270c93fd563f1e02a317fecb52b5d90..e0dc293f8b1d9667a5867e038f70b87f115d9da1 100644 (file)
@@ -10,7 +10,7 @@ public class ResourceConfigurer {
         return "admin/index";
     }
 
-    @GetMapping({"/projects", "/associates", "/project/**"})
+    @GetMapping({"/projects", "/associates", "/project-associates", "/project/**"})
     public String index() {
         return "index";
     }
diff --git a/lis-ui/src/main/java/hu/user/lis/ui/converter/DateToStringConverter.java b/lis-ui/src/main/java/hu/user/lis/ui/converter/DateToStringConverter.java
new file mode 100644 (file)
index 0000000..0957f28
--- /dev/null
@@ -0,0 +1,22 @@
+package hu.user.lis.ui.converter;
+
+import org.zkoss.bind.BindContext;
+import org.zkoss.bind.Converter;
+import org.zkoss.zul.Listcell;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class DateToStringConverter implements Converter<String, Date, Listcell> {
+    private SimpleDateFormat df = new SimpleDateFormat("yyyy. MM. dd.");
+
+    @Override
+    public String coerceToUi(Date date, Listcell listCell, BindContext bindContext) {
+        return df.format(date);
+    }
+
+    @Override
+    public Date coerceToBean(String data, Listcell listCell, BindContext bindContext) {
+        return null;
+    }
+}
diff --git a/lis-ui/src/main/java/hu/user/lis/ui/converter/DoubleToStringConverter.java b/lis-ui/src/main/java/hu/user/lis/ui/converter/DoubleToStringConverter.java
new file mode 100644 (file)
index 0000000..1656f13
--- /dev/null
@@ -0,0 +1,28 @@
+package hu.user.lis.ui.converter;
+
+import org.zkoss.bind.BindContext;
+import org.zkoss.bind.Converter;
+import org.zkoss.zul.Listcell;
+
+import java.math.RoundingMode;
+import java.text.NumberFormat;
+import java.util.Locale;
+
+public class DoubleToStringConverter implements Converter<String, Double, Listcell> {
+    static private NumberFormat nf = NumberFormat.getInstance(new Locale("hu", "HU"));
+
+    static {
+        nf.setMaximumFractionDigits(2);
+        nf.setRoundingMode(RoundingMode.CEILING);
+    }
+
+    @Override
+    public String coerceToUi(Double date, Listcell listCell, BindContext bindContext) {
+        return nf.format(date);
+    }
+
+    @Override
+    public Double coerceToBean(String data, Listcell listCell, BindContext bindContext) {
+        return null;
+    }
+}
index b5b2616130aea59b56ab4521477ecbe411167921..ce702f78e6d4dc01cb57a42b6a9adc5e4ba20cf9 100644 (file)
@@ -82,8 +82,7 @@ public class AssociatesDataModel extends CachedDataModel<Associate> {
     }
 
     public void search(String partialName) {
-        log.info("Searching ssociate using filters: name LIKE {}",
-                partialName);
+        log.info("Searching associate using filters: name LIKE {}", partialName);
         listAll = false;
         this.partialName = partialName;
         super.reset();
@@ -92,7 +91,7 @@ public class AssociatesDataModel extends CachedDataModel<Associate> {
 
 
     public void search(boolean filterShowActive, boolean filterShowInActive) {
-        log.info("Searching partner using filters: filterShowActive {}, filterShowInActive {}",
+        log.info("Searching associate using filters: filterShowActive {}, filterShowInActive {}",
                 filterShowActive, filterShowInActive);
         this.filterShowActive = filterShowActive;
         this.filterShowInActive = filterShowInActive;
diff --git a/lis-ui/src/main/java/hu/user/lis/ui/data/ProjectAssociatesDataModel.java b/lis-ui/src/main/java/hu/user/lis/ui/data/ProjectAssociatesDataModel.java
new file mode 100644 (file)
index 0000000..854ec0d
--- /dev/null
@@ -0,0 +1,75 @@
+package hu.user.lis.ui.data;
+
+import hu.user.lis.db.ProjectAssociate;
+import hu.user.lis.services.data.ProjectAssociateService;
+import lombok.Getter;
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.zkoss.bind.BindUtils;
+import org.zkoss.zul.FieldComparator;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Component
+@Log4j2
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class ProjectAssociatesDataModel extends CachedDataModel<ProjectAssociate> {
+    @Getter
+    @Autowired
+    ProjectAssociateService projectAssociateService;
+    private String projectId;
+
+
+    private boolean canExecuteSearch() {
+        boolean result = StringUtils.isNotBlank(projectId);
+        log.info("Can execute search: {}", result);
+        return result;
+    }
+
+    private boolean filter(ProjectAssociate projectAssociate) {
+        boolean result = true;
+        if (StringUtils.isNotBlank(projectId)) {
+            if (!projectAssociate.getProjectId().equals(projectId)) {
+                result = false;
+            }
+        }
+        return result;
+    }
+
+    @Override
+    protected List<ProjectAssociate> getResultSet(long offset, int limit, FieldComparator sortComparator) {
+        List<ProjectAssociate> result = null;
+        if (canExecuteSearch()) {
+            result = projectAssociateService.getAll().stream()
+                    .filter(s -> filter(s))
+                    .sorted(Comparator.comparing(ProjectAssociate::getAssociateId))
+                    .collect(Collectors.toList());
+        }
+        return result;
+    }
+
+    @Override
+    public int getResultSetCount() {
+        int result = 0;
+        if (canExecuteSearch()) {
+            result = (int) projectAssociateService.getAll().stream()
+                    .filter(s -> filter(s))
+                    .count();
+        }
+        return result;
+    }
+
+    public void search(String projectId) {
+        log.info("Searching project associate using filters: projectId LIKE {}", projectId);
+        this.projectId = projectId;
+        super.reset();
+        BindUtils.postNotifyChange(null, null, this, "*");
+    }
+
+}
index f75278c15df2095be51b011cb61605238e947e32..b64d739e6e3b2d13d5c9d62472c44a6224584766 100644 (file)
@@ -20,13 +20,12 @@ import java.util.stream.Collectors;
 @Log4j2
 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 public class ProjectsDataModel extends CachedDataModel<Project> {
-    private String partialName;
-    private String partialHumanId;
-    private boolean listAll;
-
     @Getter
     @Autowired
     ProjectService projectService;
+    private String partialName;
+    private String partialHumanId;
+    private boolean listAll;
     private boolean filterShowInActive;
     private boolean filterShowActive;
 
@@ -108,7 +107,7 @@ public class ProjectsDataModel extends CachedDataModel<Project> {
     }
 
     public void listAll() {
-        log.info("List all partners");
+        log.info("List all projects");
         listAll = true;
         super.reset();
         BindUtils.postNotifyChange(null, null, this, "*");
index 08bf5978a7e60d254e9079bcdb86ae3d8c9fbcc6..67f9417d89696129854ea38016710cca64d06d66 100644 (file)
@@ -67,7 +67,7 @@ public class AssociateEditorModel extends AbstractValidator {
             if (StringUtils.isBlank(newData.getName()) ||
                     StringUtils.isBlank(newData.getLogin()) ||
                     StringUtils.isBlank(newData.getPassword()) ||
-                    newData.getHourlyRate() < 1
+                    newData.getMonthlyCost() < 1
             ) {
                 log.info("Document is not valid");
                 updateFormInvalid(true);
index e2a125f48854603bd3dbd4c95ac57c433c0bde03..12ffefe196b9cfcfed062416248865fc6b9db5bb 100644 (file)
@@ -101,17 +101,37 @@ public class InvoiceEditorModel extends AbstractValidator {
             return;
         }
 
-        if (newData.getNetAmount() <= 0 ||
-                newData.getGrossAmount() <= 0 ||
-                newData.getVatAmount() <= 0 ||
-                StringUtils.isBlank(newData.getTitle()) ||
-                Objects.isNull(newData.getPartner()) ||
-                Objects.isNull(newData.getCompletionDate()) ||
-                Objects.isNull(newData.getCreateDate()) ||
-                Objects.isNull(newData.getPaymentDeadline()) ||
-                newData.getCreateDate().after(newData.getCompletionDate()) ||
-                newData.getCompletionDate().after(newData.getPaymentDeadline())
-        ) {
+        boolean invalid = false;
+        if (newData.isPlanned()) {
+            if (newData.getNetAmount() <= 0 ||
+                    StringUtils.isBlank(newData.getTitle()) ||
+                    Objects.isNull(newData.getPartner())
+            ) {
+                invalid = true;
+            }
+
+            if (!Currency.HUF.equals(newData.getCurrency())) {
+                if (newData.getGrossAmount() <= 0 || newData.getVatAmount() <= 0) {
+                    invalid = true;
+                }
+            }
+        } else {
+            if (newData.getNetAmount() <= 0 ||
+                    newData.getGrossAmount() <= 0 ||
+                    newData.getVatAmount() <= 0 ||
+                    StringUtils.isBlank(newData.getTitle()) ||
+                    Objects.isNull(newData.getPartner()) ||
+                    Objects.isNull(newData.getCompletionDate()) ||
+                    Objects.isNull(newData.getCreateDate()) ||
+                    Objects.isNull(newData.getPaymentDeadline()) ||
+                    newData.getCreateDate().after(newData.getCompletionDate()) ||
+                    newData.getCompletionDate().after(newData.getPaymentDeadline())
+            ) {
+                invalid = true;
+            }
+        }
+
+        if (invalid) {
             log.info("Document is not valid");
             updateFormInvalid(true);
         }
index df1e21fadc8a539330686dfcc91394c6d64a99d8..9df6d7860e549e081534531ce0ca52739b72487c 100644 (file)
@@ -2,11 +2,14 @@ package hu.user.lis.ui.editor;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.google.common.collect.ImmutableMap;
+import hu.user.lis.db.Associate;
 import hu.user.lis.db.Invoice;
 import hu.user.lis.db.Project;
 import hu.user.lis.services.data.InvoiceService;
+import hu.user.lis.services.data.ProjectAssociateService;
 import hu.user.lis.services.data.ProjectService;
 import hu.user.lis.ui.Constants;
+import hu.user.lis.ui.data.AssociatesDataModel;
 import hu.user.lis.ui.data.PartnerSelectorDataModel;
 import hu.user.lis.ui.event.EventBus;
 import lombok.Getter;
@@ -38,6 +41,10 @@ import java.util.*;
 @Setter
 @VariableResolver(DelegatingVariableResolver.class)
 public class ProjectEditorModel extends AbstractValidator implements EventListener {
+    @WireVariable
+    AssociatesDataModel associatesDataModel;
+    @WireVariable
+    ProjectAssociateService projectAssociateServiceImpl;
     private Project formDocument;
     private Project origDocument;
     @WireVariable
@@ -52,6 +59,11 @@ public class ProjectEditorModel extends AbstractValidator implements EventListen
     private Invoice selectedIncomingInvoice;
     private Invoice selectedOutgoingInvoice;
 
+    private String partialAssociateName;
+
+    private Map<String, Boolean> origAssociates;
+    private Map<String, Boolean> formAssociates;
+
     public ProjectEditorModel() {
 
     }
@@ -125,9 +137,10 @@ public class ProjectEditorModel extends AbstractValidator implements EventListen
 
     private void validate(Project newData) {
         updateFormInvalid(false);
-        if (!Objects.isNull(origDocument) && projectServiceImpl.toString(origDocument).equals(projectServiceImpl.toString(newData))) {
-            log.info("Document not changed");
-            updateFormInvalid(true);
+        if (!Objects.isNull(origDocument)) {
+            boolean invalid = projectServiceImpl.toString(origDocument).equals(projectServiceImpl.toString(newData))
+                    && !isAssociatesChanged();
+            updateFormInvalid(invalid);
             return;
         }
 
@@ -261,7 +274,7 @@ public class ProjectEditorModel extends AbstractValidator implements EventListen
             origDocument = (Project) data.get("origDocument");
             formDocument = (Project) data.get("formDocument");
             BindUtils.postNotifyChange(this, "formDocument");
-            //Clients.evalJavaScript(String.format("pushNav('/project/%s')", formDocument.getId()));
+            associatesDataModel.listAll();
         }
     }
 
@@ -283,4 +296,33 @@ public class ProjectEditorModel extends AbstractValidator implements EventListen
         panel.setOpen(!panel.isOpen());
         parentPanel.invalidate();
     }
+
+    @Command
+    @NotifyChange("associates")
+    public void onAfterRenderAssociates() {
+        formAssociates = new HashMap<>();
+        for (int i = 1; i < associatesDataModel.getSize() + 1; i++) {
+            Associate associate = associatesDataModel.getElementAt(i);
+            boolean exists = projectAssociateServiceImpl.getAll().stream()
+                    .anyMatch(
+                            pa -> pa.getProjectId().equals(formDocument.getId()) &&
+                                    pa.getAssociateId().equals(associate.getId())
+                    );
+            if (exists) {
+                log.info("{} is on project {}", associate.getName(), formDocument.getName());
+            }
+            formAssociates.put(associate.getId(), exists);
+        }
+    }
+
+    private boolean isAssociatesChanged() {
+        return formAssociates.entrySet().stream()
+                .anyMatch(e -> !e.getValue().equals(origAssociates.get(e.getKey())));
+    }
+
+    @Command
+    public void onAssociateChecked() {
+        log.info("Associate checked");
+        validate(projectServiceImpl.copy(formDocument));
+    }
 }
index 8ba1db01fb8de783ac37fc7735b28829d733b0fb..6bad32b9e739183f540f04a15cd6119b8d26c262 100644 (file)
@@ -26,11 +26,12 @@ import java.util.Map;
 @Getter
 @Setter
 public class IndexViewModel implements EventListener {
-    public static final String PROJECT_EDITOR_PAGE = "~./project-editor.zul";
     private static final String PARTNERS_LIST = "~./partners.zul";
     private static final String PROJECTS_LIST = "~./projects.zul";
     private static final String PROJECT_EDITOR = "~./project-editor.zul";
     private static final String ASSOCIATES_LIST = "~./associates.zul";
+    private static final String PROJECT_ASSOCIATES_LIST = "~./project-associates.zul";
+
     @WireVariable
     BuildProperties buildProperties;
     @WireVariable
@@ -40,7 +41,8 @@ public class IndexViewModel implements EventListener {
     private Map<String, String> navigation = ImmutableMap.of(
             "/projects", PROJECTS_LIST,
             "/project", PROJECT_EDITOR,
-            "/associates", ASSOCIATES_LIST
+            "/associates", ASSOCIATES_LIST,
+            "/project-associates", PROJECT_ASSOCIATES_LIST
     );
 
     @Init
@@ -66,7 +68,7 @@ public class IndexViewModel implements EventListener {
     @Override
     public void onEvent(Event event) {
         if (Constants.SHOW_PROJECT_EDITOR.equals(event.getName())) {
-            selectPage(PROJECT_EDITOR_PAGE);
+            selectPage(PROJECT_EDITOR);
             eventBus.setProjectEditorData(event.getData());
         }
         if (Constants.SHOW_PROJECTS_LIST.equals(event.getName())) {
index e437e94b29e97be71cd9f1e17a95fa87e732cd2e..f4bf4c68d78408e412864c56a84a5c74d90662d4 100644 (file)
@@ -26,9 +26,9 @@
                                              forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     <button iconSclass="z-icon-eye"/>
                                 </hlayout>
-                                <label value="Óradíj"/>
-                                <doublebox value="@bind(vm.formDocument.hourlyRate) @validator(vm)"
-                                           format="#.##" instant="true"
+                                <label value="Havi önköltség"/>
+                                <doublebox value="@bind(vm.formDocument.monthlyCost) @validator(vm)"
+                                           format="locale:hu-HU" instant="true"
                                            forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                 <label value="Aktív"/>
                                 <checkbox mold="switch" checked="@bind(vm.formDocument.active)"/>
index f967e10cca1cbaea89460927e997867e8576d9af..4092f046bbffd2cff024180b4e2585449bfa19d7 100644 (file)
                                     <vlayout>
                                         <label value="Nettó összeg"/>
                                         <doublebox value="@bind(vm.formDocument.netAmount) @validator(vm)"
-                                                   format="#.##" instant="true"
+                                                   format="locale:hu-HU" instant="true"
                                                    onChange="@command('onNetAmountChange')"
                                                    forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="Bruttó összeg"/>
                                         <doublebox value="@bind(vm.formDocument.grossAmount) @validator(vm)"
-                                                   format="#.##" instant="true"
+                                                   format="locale:hu-HU" instant="true"
                                                    forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="ÁFA"/>
                                         <doublebox value="@bind(vm.formDocument.vatAmount) @validator(vm)"
-                                                   format="#.##" instant="true"
+                                                   format="locale:hu-HU" instant="true"
                                                    forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                 </hlayout>
                                 <hlayout>
                                     <vlayout>
                                         <label value="Kiállítás dátuma"/>
-                                        <datebox instant="true" locale="hu"
+                                        <datebox instant="true" format="yyyy. MM. dd."
                                                  value="@bind(vm.formDocument.createDate) @validator(vm)"
                                                  forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="Teljesítés dátuma"/>
-                                        <datebox instant="true" locale="hu"
+                                        <datebox instant="true" format="yyyy. MM. dd."
                                                  value="@bind(vm.formDocument.completionDate) @validator(vm)"
                                                  forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="Fizetési határidő"/>
-                                        <datebox instant="true" locale="hu"
+                                        <datebox instant="true" format="yyyy. MM. dd."
                                                  value="@bind(vm.formDocument.paymentDeadline) @validator(vm)"
                                                  forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
index 75aacb99f0eb1826e4f8e32fbc9df484d0927b91..7c8ca8cd36a8d9608fdf665b0336910befa72f63 100644 (file)
@@ -34,6 +34,8 @@
                         <menuseparator/>
                         <menuitem iconSclass="z-icon-user" label="Munkatársak"
                                   onClick="@command(vm.selectPage('~./associates.zul'))"/>
+                        <menuitem iconSclass="z-icon-user" label="Résztvevők"
+                                  onClick="@command(vm.selectPage('~./project-associates.zul'))"/>
                     </menubar>
                     <hbox hflex="min" pack="right">
                         <textbox value="@bind(vm.searchPhrase)" onOK="@command('search')"></textbox>
index f7b5776b7293c3d735f6ba894f78724a84b36a2f..f1fe7f115526f1a1e2387bb3c193004fd98d9890 100644 (file)
                                     <vlayout>
                                         <label value="Nettó összeg"/>
                                         <doublebox value="@bind(vm.formDocument.netAmount) @validator(vm)"
-                                                   format="#.##" instant="true"
+                                                   format="locale:hu-HU" instant="true"
                                                    onChange="@command('onNetAmountChange')"
                                                    forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="Bruttó összeg"/>
                                         <doublebox value="@bind(vm.formDocument.grossAmount) @validator(vm)"
-                                                   format="#.##" instant="true"
+                                                   format="locale:hu-HU" instant="true"
                                                    forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="ÁFA"/>
                                         <doublebox value="@bind(vm.formDocument.vatAmount) @validator(vm)"
-                                                   format="#.##" instant="true"
+                                                   format="locale:hu-HU" instant="true"
                                                    forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                 </hlayout>
                                 <hlayout>
                                     <vlayout>
                                         <label value="Kiállítás dátuma"/>
-                                        <datebox instant="true" locale="hu"
+                                        <datebox instant="true" format="yyyy. MM. dd."
                                                  value="@bind(vm.formDocument.createDate) @validator(vm)"
                                                  forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="Teljesítés dátuma"/>
-                                        <datebox instant="true" locale="hu"
+                                        <datebox instant="true" format="yyyy. MM. dd."
                                                  value="@bind(vm.formDocument.completionDate) @validator(vm)"
                                                  forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
                                     <vlayout>
                                         <label value="Fizetési határidő"/>
-                                        <datebox instant="true" locale="hu"
+                                        <datebox instant="true" format="yyyy. MM. dd."
                                                  value="@bind(vm.formDocument.paymentDeadline) @validator(vm)"
                                                  forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
                                     </vlayout>
index 418f9fde3c67f45e308fc64417a1af0130c1782a..097dcd5d66edbab41ff2e8b7e98968e985027c53 100644 (file)
                             </tabpanel>
                         </tabpanels>
                     </tabbox>
+                    <panel collapsible="true" open="false" border="rounded"
+                           onOpen="@command('onOpenInvoicePanel', parentPanel=centerPanel)">
+                        <caption label="Kimenő számlák"
+                                 onClick="@command('onClickInvoicePanel', parentPanel=centerPanel, panel=self.parent)"/>
+                        <panelchildren>
+                            <vlayout>
+                                <toolbar>
+                                    <toolbarbutton label="Hozzáadás" iconSclass="z-icon-plus"
+                                                   onClick="@command('onAddOutgoing')"/>
+                                    <toolbarbutton label="Szerkesztés" iconSclass="z-icon-edit"
+                                                   onClick="@command('onEditOutgoing')"
+                                                   disabled="@load(empty vm.selectedOutgoingInvoice)"/>
+                                    <toolbarbutton label="Törlés" iconSclass="z-icon-remove"
+                                                   onClick="@command('onRemoveOutgoing')"
+                                                   disabled="@load(empty vm.selectedOutgoingInvoice)"/>
+                                </toolbar>
+                                <listbox model="@load(vm.formDocument.outgoingInvoices)"
+                                         selectedItem="@bind(vm.selectedOutgoingInvoice)"
+                                         onDoubleClick="@command('onEditOutgoing')"
+                                         forward="onOK=submit.onClick, onCancel=cancel.onClick">
+                                    <listhead>
+                                        <listheader label="Vevő" align="left"/>
+                                        <listheader label="Megnevezés" align="left"/>
+                                        <listheader label="Nettó összeg" align="left"/>
+                                        <listheader label="Pénznem" align="left"/>
+                                        <listheader label="Fizetési határidő" align="left"/>
+                                    </listhead>
+                                    <template name="model">
+                                        <listitem>
+                                            <listcell label="@load(each.partner.name)"/>
+                                            <listcell label="@load(each.title)"/>
+                                            <listcell
+                                                    label="@load(each.netAmount) @converter('hu.user.lis.ui.converter.DoubleToStringConverter')"/>
+                                            <listcell label="@load(each.currency)"/>
+                                            <listcell
+                                                    label="@load(each.paymentDeadline) @converter('hu.user.lis.ui.converter.DateToStringConverter')"/>
+                                        </listitem>
+                                    </template>
+                                </listbox>
+                            </vlayout>
+                        </panelchildren>
+                    </panel>
 
                     <panel collapsible="true" open="false" border="rounded"
                            onOpen="@command('onOpenInvoicePanel', parentPanel=centerPanel)">
                                         <listheader label="Megnevezés" align="left"/>
                                         <listheader label="Nettó összeg" align="left"/>
                                         <listheader label="Pénznem" align="left"/>
+                                        <listheader label="Fizetési határidő" align="left"/>
                                     </listhead>
                                     <template name="model">
                                         <listitem>
                                             <listcell label="@load(each.partner.name)"/>
                                             <listcell label="@load(each.title)"/>
-                                            <listcell label="@load(each.netAmount)"/>
+                                            <listcell
+                                                    label="@load(each.netAmount) @converter('hu.user.lis.ui.converter.DoubleToStringConverter')"/>
                                             <listcell label="@load(each.currency)"/>
+                                            <listcell
+                                                    label="@load(each.paymentDeadline) @converter('hu.user.lis.ui.converter.DateToStringConverter')"/>
                                         </listitem>
                                     </template>
                                 </listbox>
                             </vlayout>
                         </panelchildren>
-
                     </panel>
+
                     <panel collapsible="true" open="false" border="rounded"
                            onOpen="@command('onOpenInvoicePanel', parentPanel=centerPanel)">
-                        <caption label="Kimenő számlák"
+                        <caption label="Treasury műveletek"
                                  onClick="@command('onClickInvoicePanel', parentPanel=centerPanel, panel=self.parent)"/>
                         <panelchildren>
                             <vlayout>
                                 <toolbar>
                                     <toolbarbutton label="Hozzáadás" iconSclass="z-icon-plus"
-                                                   onClick="@command('onAddOutgoing')"/>
+                                                   onClick="@command('onAddIncoming')"/>
                                     <toolbarbutton label="Szerkesztés" iconSclass="z-icon-edit"
-                                                   onClick="@command('onEditOutgoing')"
-                                                   disabled="@load(empty vm.selectedOutgoingInvoice)"/>
+                                                   onClick="@command('onEditIncoming')"
+                                                   disabled="@load(empty vm.selectedIncomingInvoice)"/>
                                     <toolbarbutton label="Törlés" iconSclass="z-icon-remove"
-                                                   onClick="@command('onRemoveOutgoing')"
-                                                   disabled="@load(empty vm.selectedOutgoingInvoice)"/>
+                                                   onClick="@command('onRemoveIncoming')"
+                                                   disabled="@load(empty vm.selectedIncomingInvoice)"/>
                                 </toolbar>
-                                <listbox model="@load(vm.formDocument.outgoingInvoices)"
-                                         selectedItem="@bind(vm.selectedOutgoingInvoice)"
-                                         onDoubleClick="@command('onEditOutgoing')"
+
+                                <listbox model="@load(vm.formDocument.incomingInvoices)"
+                                         selectedItem="@bind(vm.selectedIncomingInvoice)"
+                                         onDoubleClick="@command('onEditIncoming')"
                                          forward="onOK=submit.onClick, onCancel=cancel.onClick">
                                     <listhead>
-                                        <listheader label="Vevő" align="left"/>
+                                        <listheader label="Szállító" align="left"/>
                                         <listheader label="Megnevezés" align="left"/>
                                         <listheader label="Nettó összeg" align="left"/>
                                         <listheader label="Pénznem" align="left"/>
+                                        <listheader label="Fizetési határidő" align="left"/>
                                     </listhead>
                                     <template name="model">
                                         <listitem>
                                             <listcell label="@load(each.partner.name)"/>
                                             <listcell label="@load(each.title)"/>
-                                            <listcell label="@load(each.netAmount)"/>
+                                            <listcell
+                                                    label="@load(each.netAmount) @converter('hu.user.lis.ui.converter.DoubleToStringConverter')"/>
                                             <listcell label="@load(each.currency)"/>
+                                            <listcell
+                                                    label="@load(each.paymentDeadline) @converter('hu.user.lis.ui.converter.DateToStringConverter')"/>
                                         </listitem>
                                     </template>
                                 </listbox>
                             </vlayout>
                         </panelchildren>
+                    </panel>
+
+                    <panel collapsible="true" open="false" border="rounded"
+                           onOpen="@command('onOpenInvoicePanel', parentPanel=centerPanel)">
+                        <caption label="Résztvevők"
+                                 onClick="@command('onClickInvoicePanel', parentPanel=centerPanel, panel=self.parent)"/>
+                        <panelchildren>
+                            <vlayout>
+                                <toolbar>
+                                    <textbox value="@bind(vm.partialAssociateName)" instant="true"
+                                             onChanging="@command('searchAssociate')"/>
+                                </toolbar>
+                                <listbox model="@load(vm.associatesDataModel)"
+                                         autopaging="true" pagingPosition="top" multiple="false"
+                                         onAfterRender="@command('onAfterRenderAssociates')">
+                                    <custom-attributes org.zkoss.zul.listbox.selectOnHighlight.disabled="true"/>
 
+                                    <listhead>
+                                        <listheader hflex="min" label="Tag" align="left"/>
+                                        <listheader label="Név" align="left"/>
+                                        <listheader label="Login" align="left"/>
+                                    </listhead>
+                                    <template name="model">
+                                        <listitem>
+                                            <listcell>
+                                                <checkbox checked="@bind(vm.formAssociates[each.id])"
+                                                          onCheck="@command('onAssociateChecked')"/>
+                                            </listcell>
+                                            <listcell label="@load(each.name)"/>
+                                            <listcell label="@load(each.login)"/>
+                                        </listitem>
+                                    </template>
+                                </listbox>
+                            </vlayout>
+                        </panelchildren>
                     </panel>
+
                 </vlayout>
             </center>
             <south border="none" flex="true" style="text-align: right; padding: 10px;">
diff --git a/pom.xml b/pom.xml
index a955a454cd343dff3ed60274d91275f692384052..da133b8ea1d691801b484090c10d2a3df7611300 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,7 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.2.4.RELEASE</version>
+        <version>2.7.7</version>
         <relativePath/>
     </parent>
     <repositories>