Invoice import assign/approve editor modifications
authorVásáry Dániel <vasary@elgekko.net>
Wed, 15 Nov 2023 11:00:29 +0000 (12:00 +0100)
committerVásáry Dániel <vasary@elgekko.net>
Wed, 15 Nov 2023 11:00:29 +0000 (12:00 +0100)
13 files changed:
TODO.txt
lis-service/src/main/java/hu/user/lis/service/data/EntityDataService.java
lis-ui/src/main/java/hu/user/lis/ui/editor/ImportInvoiceApproveEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/editor/ImportInvoiceAssignEditorModel.java
lis-ui/src/main/java/hu/user/lis/ui/editor/common/EntityEditorModel.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/InvoicePaymentViewModel.java
lis-ui/src/main/java/hu/user/lis/ui/view/InvoicesViewModel.java
lis-ui/src/main/resources/web/editor/import-invoice-assign-editor.zul
lis-ui/src/main/resources/web/form/invoice-form.zul
lis-ui/src/main/resources/web/index.zul
lis-ui/src/main/resources/web/invoice-payment.zul

index 17104bd25ab2c0d322580619cf31e5f0f7902efb..2f0a3f05950d08a8bc226310cc3e8c2cb78b3079 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -2,6 +2,37 @@
 - távlati: dokumentum kezelés szétválasztása
 - távlati: utalás előkészítése
 - távlati: banki integráció
+- távlati: táblák exportja
+
+Számla import
+-------------
+Javításra váró számlák lista kezelése: az elvetett vagy meg nem érkezett számlákat egy külön listába kell tenni.
+
+Az import folyamat számlái és a tervezett számlák hogyan kapcsolódjanak össze?
+Projektszámok: 2023-0013
+
+
+Számla kiegyenlítés
+-------------
+teszt: 9090010764
+
+
+Összes számla
+-------------
+A kiegyenlítés hogyan kezelje a különböző devizákat?
+
+
+
+F: egy számlához több fájl csatolása
+*F: a számla assign esetén ki kell választani a tervezett számlát, ha van
+*BUG: a rendezés elromlik a lista megnyitásakor
+*F: "Összes számla" szűrőnél lehessen kiválasztani a dátum típusát
+*F: A számla listán a funkciók: szerkesztés, másik projekthez csatolás, kiegyenlítés
+*F: számla kiegyenlítés bal oldala legyen olvashatóbb
+*F: a számla kiegyenlítés a számla listában is jelenjen meg
+*F: a számla kiegyenlítés: csak a bruttó legyen, csak akkor oké ha egyenlő, ha nagyobb akkor szól
+*F: a parkolóból lehessen eldobni végleg
+
 
 0.1.8
 - A "Számla kiegyenlítés" számla sorszám alapú kereséssel indul, találat esetén megjelenik egy űrlap:
     * mivel tartozhat egy sorszám több számlához is, ezt kezelni kell
 - A "Szállítói követelés követés" funkció a számlák listáját mutatja szűrve, azokat tartalmazza amik még nincsenek kiegyenlítve (külön a bejövö külön a kimenő)
 - munkalap hiba javítása
+- NAV 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?
 * 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
-- NAV 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?
 
 0.1.7
 * A számla importhoz tartozó menüpontok jelezzék, ha van feladat
index d7de60d3fd9534fc9d6c7a9ad8ad707e9a194206..75ff85f41b9f13ac270043063525ce88778783e1 100644 (file)
@@ -90,7 +90,7 @@ public class EntityDataService<T extends Serializable> extends EntityDataService
                 JSONAssert.assertEquals(json1, json2, JSONCompareMode.LENIENT);
             } catch (Throwable e) {
                 result = true;
-                log.error(e);
+                //log.error(e);
             }
         }
         return result;
index a3f5bda32811a8bda92810a2cc48c2c578f92633..47b5ecb6f9a2467537ebdfd02b86fa41a70ef62d 100644 (file)
@@ -28,6 +28,7 @@ public class ImportInvoiceApproveEditorModel extends InvoiceEditorModel {
     boolean canEditPartner;
 
     @Init
+    @Override
     public void init() {
         super.init();
         canEditPartner = Objects.isNull(getFormDocument().getPartner().getId());
@@ -40,6 +41,7 @@ public class ImportInvoiceApproveEditorModel extends InvoiceEditorModel {
                 && Objects.nonNull(entity.getFile());
     }
 
+    @Override
     @AfterCompose
     public void onAfterCompose(@ContextParam(ContextType.VIEW) Component view) {
         getEntitySelectorRouter().configureSelector(Project.class, getFormDocument(), "project");
@@ -50,9 +52,7 @@ public class ImportInvoiceApproveEditorModel extends InvoiceEditorModel {
     @Command
     public void onEditPartner() {
         Partner entity = partnersDataModel.clone(getFormDocument().getPartner());
-        Editors.doEdit(Editors.PARTNER, entity, modifiedEntity -> {
-            getFormDocument().setPartner(modifiedEntity);
-        });
+        Editors.doEdit(Editors.PARTNER, entity, modifiedEntity -> getFormDocument().setPartner(modifiedEntity));
     }
 
     @Command
@@ -61,13 +61,11 @@ public class ImportInvoiceApproveEditorModel extends InvoiceEditorModel {
             Events.postEvent(new Event("onClose", target, null));
             return;
         }
-        ImmutableMap<String, Object> args = ImmutableMap.of("approved", save == 2, "modifiedEntity", getFormDocument());
         if (save == 1) {
             Events.postEvent(new Event("onClose", target,
                     ImmutableMap.of("approved", false)));
             return;
         }
-
         if (isSaveEnabled()) {
             Events.postEvent(new Event("onClose", target,
                     ImmutableMap.of("approved", true, "modifiedEntity", getFormDocument())));
index ee7ac4c2d9c148f99bdaee366fd8afb2ec9f2746..5de60be798361e4e281184d9e9a7f4e94c4cde30 100644 (file)
@@ -1,5 +1,6 @@
 package hu.user.lis.ui.editor;
 
+import com.google.common.collect.ImmutableMap;
 import hu.user.lis.db.Invoice;
 import hu.user.lis.db.Partner;
 import hu.user.lis.db.Project;
@@ -12,8 +13,11 @@ import lombok.extern.log4j.Log4j2;
 import org.zkoss.bind.annotation.*;
 import org.zkoss.zk.ui.Component;
 import org.zkoss.zk.ui.Executions;
+import org.zkoss.zk.ui.event.Event;
+import org.zkoss.zk.ui.event.Events;
 import org.zkoss.zk.ui.select.annotation.WireVariable;
 import org.zkoss.zk.ui.util.Notification;
+import org.zkoss.zul.Window;
 
 import java.util.List;
 import java.util.Objects;
@@ -71,8 +75,24 @@ public class ImportInvoiceAssignEditorModel extends InvoiceEditorModel {
             getEntitySelectorRouter().configureSelector(Project.class, getFormDocument(), "project");
             validate();
         } else {
-            Notification.show("Nincs projekt ezen a számon: " + humanId, true);
+            Notification.show("Nincs projekt ezen a számon: " + humanId, null, null, null, 3000, true);
         }
     }
 
+    @Command
+    public void onCloseApproveWindow(@BindingParam("target") Window target, @BindingParam("save") int save) {
+        if (save == 0) {
+            Events.postEvent(new Event("onClose", target, null));
+            return;
+        }
+        if (save == 1) {
+            Events.postEvent(new Event("onClose", target, ImmutableMap.of("invalid", true)));
+            return;
+        }
+        if (isSaveEnabled()) {
+            Events.postEvent(new Event("onClose", target, ImmutableMap.of("modifiedEntity", getFormDocument())));
+        }
+    }
+
+
 }
index 02d9f8f285f5de7efe5e9586d8619fa290577891..56ef03407cb81eb305282d4b670d3d25e96eadd6 100644 (file)
@@ -52,6 +52,8 @@ public abstract class EntityEditorModel<T extends Serializable> extends Abstract
     @WireVariable
     EntitySelectorRouter entitySelectorRouter;
 
+    @Getter
+    @Setter
     private boolean readonlyForm;
 
     @Command
index 6e99299a97656a3c849c84de68ff448ab02755ee..197f85284f8e50a212536f60ee7cf02450438558 100644 (file)
@@ -87,7 +87,6 @@ public class ApproveInvoicesViewModel extends EntityViewModel<JSONObject> implem
                 Map<String, Object> results = (Map<String, Object>) e.getData();
                 boolean approved = (boolean) results.get("approved");
                 Invoice modifiedEntity = (Invoice) results.get("modifiedEntity");
-                //TODO move entity persistance to BPMN
                 if (approved) {
                     Partner partner = modifiedEntity.getPartner();
                     if (Objects.isNull(partner.getId())) {
index 2af175eb162ad3b5b98f425fb6a3dce09c05bd29..f175f110e5cddf1a4e168679da3d5c5a961cb60d 100644 (file)
@@ -5,7 +5,6 @@ import hu.user.lis.db.Invoice;
 import hu.user.lis.ui.Constants;
 import hu.user.lis.ui.data.AssignInvoicesDataModel;
 import hu.user.lis.ui.data.common.CachedSpringDataModel;
-import hu.user.lis.ui.editor.common.EditCompleted;
 import hu.user.lis.ui.editor.common.Editors;
 import hu.user.lis.ui.event.EventBus;
 import hu.user.lis.ui.event.ProcessEventRouter;
@@ -18,14 +17,17 @@ import org.zkoss.bind.annotation.Command;
 import org.zkoss.bind.annotation.Destroy;
 import org.zkoss.bind.annotation.Init;
 import org.zkoss.json.JSONObject;
+import org.zkoss.zk.ui.Executions;
 import org.zkoss.zk.ui.event.Event;
 import org.zkoss.zk.ui.event.EventListener;
 import org.zkoss.zk.ui.select.annotation.VariableResolver;
 import org.zkoss.zk.ui.select.annotation.WireVariable;
 import org.zkoss.zkplus.spring.DelegatingVariableResolver;
+import org.zkoss.zul.Window;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 @Getter
 @Log4j2
@@ -72,11 +74,29 @@ public class AssignInvoicesViewModel extends EntityViewModel<JSONObject> impleme
     public void onHandleTask() {
         Invoice entity = (Invoice) getSelectedEntity().get("invoiceEntity");
         List<String> projectSuggestions = (List<String>) getSelectedEntity().get("projectSuggestions");
-        Map<String, Object> arg = ImmutableMap.of("formDocument", entity, "projectSuggestions", projectSuggestions);
-        Editors.doShowEdit(Editors.IMPORT_INVOICE_ASSIGN, arg, (EditCompleted<Invoice>) modifiedEntity -> {
-            assignInvoicesDataModel.completeTask(getSelectedEntity(), ImmutableMap.of("invoiceEntity", modifiedEntity));
-            onRefresh();
+        Map<String, Object> args = ImmutableMap.of("formDocument", entity, "projectSuggestions", projectSuggestions);
+//        Editors.doShowEdit(Editors.IMPORT_INVOICE_ASSIGN, args, (EditCompleted<Invoice>) modifiedEntity -> {
+//            assignInvoicesDataModel.completeTask(getSelectedEntity(), ImmutableMap.of("invoiceEntity", modifiedEntity));
+//            onRefresh();
+//        });
+
+        Window editorWindow = (Window) Executions.createComponents(Editors.IMPORT_INVOICE_ASSIGN, null, args);
+        editorWindow.addEventListener("onClose", e -> {
+            if (Objects.nonNull(e.getData())) {
+                Map<String, Object> results = (Map<String, Object>) e.getData();
+                boolean invalid = (boolean) results.get("invalid");
+                Invoice modifiedEntity = (Invoice) results.get("modifiedEntity");
+                if (invalid) {
+                    assignInvoicesDataModel.completeTask(getSelectedEntity(), ImmutableMap.of("invalid", true));
+                } else {
+                    assignInvoicesDataModel.completeTask(getSelectedEntity(), ImmutableMap.of("invoiceEntity", modifiedEntity));
+                }
+                onRefresh();
+            }
         });
+        editorWindow.doModal();
+        editorWindow.setFocus(true);
+
     }
 
     @Override
index 0eb16fbc124adc03004867472fca44a77cc1bfe7..fb882dd22ee4a3b7eaf48d5fb2847e16357725c0 100644 (file)
@@ -75,6 +75,7 @@ public class InvoicePaymentViewModel extends EntityViewModel<Payment> {
     @Setter
     private boolean newPaymentDisabled;
 
+
     @Init
     @Override
     public void init() {
@@ -105,6 +106,10 @@ public class InvoicePaymentViewModel extends EntityViewModel<Payment> {
     @NotifyChange("partnerRequired")
     public void search() {
         log.info("Searching for invoice {}", invoiceNumber);
+        if (formDocument != null && !formDocument.getHumanId().equals(invoiceNumber)) {
+            filterPartner = null;
+            setPartnerRequired(false);
+        }
         hideEditor();
         if (Objects.isNull(filterPartner)) {
             List<Invoice> invoices = invoiceRepository.findByHumanId(invoiceNumber);
index e9538d43fcfba872c218c2d7d5d18e142a6a40db..97e5c7b74a92a36c960acf17a7b93c713c3eb932 100644 (file)
@@ -1,13 +1,13 @@
 package hu.user.lis.ui.view;
 
 import com.google.common.collect.ImmutableMap;
-import hu.user.lis.db.Invoice;
-import hu.user.lis.db.Partner;
-import hu.user.lis.db.Project;
+import hu.user.lis.db.*;
 import hu.user.lis.db.repository.filter.InvoiceFilter;
 import hu.user.lis.ui.Constants;
+import hu.user.lis.ui.data.InvoiceDataModel;
 import hu.user.lis.ui.data.InvoicesDataModel;
 import hu.user.lis.ui.data.common.CachedSpringDataModel;
+import hu.user.lis.ui.editor.common.Editors;
 import hu.user.lis.ui.editor.selector.EntitySelectorRouter;
 import hu.user.lis.ui.event.EventBus;
 import hu.user.lis.ui.view.common.EntityViewModel;
@@ -28,22 +28,27 @@ import static hu.user.lis.ui.data.common.CachedDataModel.NATURAL;
 public class InvoicesViewModel extends EntityViewModel<Invoice> implements EventListener<Event> {
     @Getter
     private final InvoiceFilter invoiceFilter = InvoiceFilter.builder().incoming(true).build();
+
     @WireVariable
     private EventBus eventBus;
+
     @Getter
     @WireVariable
     private EntitySelectorRouter entitySelectorRouter;
+
     @Getter
     @WireVariable
     private InvoicesDataModel invoicesDataModel;
 
+    @WireVariable
+    private InvoiceDataModel invoiceDataModel;
+
     @Init
     @Override
     public void init() {
         super.init();
         eventBus.register(this);
         eventBus.registerForBinding(this);
-        refresh();
         addColumns(ImmutableMap.of(
                 "partner.humanId", NATURAL,
                 "partner.name", NATURAL,
@@ -54,6 +59,7 @@ public class InvoicesViewModel extends EntityViewModel<Invoice> implements Event
                 "currency", NATURAL,
                 "incoming", NATURAL
         ));
+        refresh();
     }
 
     @Override
@@ -97,6 +103,7 @@ public class InvoicesViewModel extends EntityViewModel<Invoice> implements Event
 //           (this.equals(propertyEvent.getBase()) && propertyEvent.getProperty().startsWith("invoiceFilter")))
             if (invoiceFilter.equals(propertyEvent.getBase())) {
                 log.info("Refresh needed, {} changed", propertyEvent.getProperty());
+
                 refresh();
             }
         }
@@ -107,4 +114,33 @@ public class InvoicesViewModel extends EntityViewModel<Invoice> implements Event
         log.info("Destroy {}", getClass().getSimpleName());
         eventBus.unregister(this);
     }
+
+    @Command
+    public void onEdit() {
+        Invoice invoice = getSelectedEntity();
+        if (invoice.isIncoming()) {
+            onEditIncoming();
+        } else {
+            onEditOutgoing();
+        }
+    }
+
+    public void onEditIncoming() {
+        IncomingInvoice selectedIncomingInvoice = (IncomingInvoice) getSelectedEntity();
+        IncomingInvoice entity = invoiceDataModel.clone(selectedIncomingInvoice);
+        Editors.doEdit(Editors.INCOMING_INVOICE, entity, selectedIncomingInvoice, modifiedEntity -> {
+            invoiceDataModel.save(modifiedEntity);
+            refresh();
+        });
+    }
+
+    public void onEditOutgoing() {
+        OutgoingInvoice selectedOutgoingInvoice = (OutgoingInvoice) getSelectedEntity();
+        OutgoingInvoice entity = invoiceDataModel.clone((OutgoingInvoice) getSelectedEntity());
+        Editors.doEdit(Editors.OUTGOING_INVOICE, entity, selectedOutgoingInvoice, modifiedEntity -> {
+            invoiceDataModel.save(modifiedEntity);
+            refresh();
+        });
+    }
+
 }
index 381c5865a349fc33e38611c6b9ec90defb86b11c..6406278539fb687722f375678ced2d0bad2c2b23 100644 (file)
             <south border="none" flex="true" style="text-align: right; padding: 10px;">
                 <hlayout>
                     <button id="cancel" label="Bezár"
-                            onClick="@command('onCloseWindow', target=invoiceAssignPopup, save=false)"/>
-                    <button id="submit" label="Mentés"
-                            onClick="@command('onCloseWindow', target=invoiceAssignPopup, save=true)"
+                            onClick="@command('onCloseApproveWindow', target=invoiceAssignPopup, save=0)"/>
+                    <button id="reject" label="Hibás" style="border-color: red"
+                            onClick="@command('onCloseApproveWindow', target=invoiceAssignPopup, save=1)"/>
+                    <button id="submit" label="Mentés" style="border-color: green"
+                            onClick="@command('onCloseApproveWindow', target=invoiceAssignPopup, save=2)"
                             disabled="@bind(not vm.saveEnabled)"/>
                 </hlayout>
             </south>
index bbbe3755ec1b381e4bddf08ef531ff9ce2587b9a..c91342f20faf5e36d20df8f2d5ccd752dd4c5b9a 100644 (file)
@@ -83,7 +83,7 @@
                     </hlayout>
                     <label value="Tervezett"/>
                     <checkbox mold="switch" checked="@bind(vm.formDocument.planned)" disabled="@bind(vm.readonlyForm)"/>
-                    <label value="Rendezve"/>
+                    <label value="Fizetve"/>
                     <checkbox mold="switch" checked="@bind(vm.formDocument.paid)" disabled="@bind(vm.readonlyForm)"/>
                 </vlayout>
             </tabpanel>
index fc94b280879eeeda2d955cf631463aa816bec71c..59175849062bf7dc99fb99d18c36474ad4401266 100644 (file)
                                               onClick="@command(vm.selectPage('~./invoices.zul'))"/>
                                     <menuitem iconSclass="z-icon-credit-card" label="Számla kiegyenlítés"
                                               onClick="@command(vm.selectPage('~./invoice-payment.zul'))"/>
-                                    <menuitem iconSclass="z-icon-exchange" label="Követelés követés"
-                                              onClick="@command('onInvoiceDues')"/>
+                                    <menu iconSclass="z-icon-exchange" label="Követelés követés">
+                                        <menupopup>
+                                            <menuitem label="Vevő"/>
+                                            <menuitem label="Szállító"/>
+                                        </menupopup>
+                                    </menu>
                                     <menuseparator/>
                                     <menu iconSclass="z-icon-tasks" label="Számla iktatás"
                                           sclass="@bind(vm.importInvoiceMenuClassName)">
index eeca249c52c4af4f1c1f2ea6cd0d059d6275cd77..6e93ea30536ba7b1e103d5d7f904e39ba03f681b 100644 (file)
@@ -6,18 +6,19 @@
                 <toolbar>
                     <label value="Számla sorszáma"/>
                     <separator orient="vertical"/>
-                    <textbox value="@bind(vm.invoiceNumber)" onChange="@command('search')" onOK="@command('search')"/>
+                    <textbox value="@bind(vm.invoiceNumber)"/>
 
                     <label value="Partner" visible="@bind(vm.partnerRequired)"/>
                     <separator orient="vertical" visible="@bind(vm.partnerRequired)"/>
                     <selectbox model="@bind(vm.partners)"
                                selectedIndex="@bind(vm.filterPartner) @converter(vm.partnerConverter)"
-                               onSelect="@command('search')"
                                visible="@bind(vm.partnerRequired)">
                         <template name="model">
                             ${each.name}
                         </template>
                     </selectbox>
+
+                    <button iconSclass="z-icon-search" onClick="@command('search')"/>
                 </toolbar>
             </north>
             <center border="none" hflex="true" vflex="true">