</list>
</option>
</component>
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="semeru-1.8" project-jdk-type="JavaSDK" />
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
DOCKER
-docker pull ibmcom/db2
-docker run -itd --name ibmdb2 --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INSTANCE=db2admin -e DB2INST1_PASSWORD=password -e DBNAME=lis -e PERSISTENT_HOME=false -v /docker/ibmdb2:/database ibmcom/db2
+# docker pull ibmcom/db2
+mkdir -R /data/db2
+chmod -R 777 /data/db2
+docker run -itd --name ibmdb2 --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INSTANCE=db2admin -e DB2INST1_PASSWORD=password -e DBNAME=lis -e PERSISTENT_HOME=false -v /data/db2:/database ibmcom/db2
docker logs -f lis
docker exec -it lis bash
docker stop lis
-- // reset partner index
-- Migration SQL that makes the change goes here.
-ALTER TABLE PARTNER ALTER COLUMN id RESTART WITH 4;
+ALTER TABLE partner ALTER COLUMN id RESTART WITH 4;
-- //@UNDO
-- SQL to undo the change goes here.
-- // reset project index
-- Migration SQL that makes the change goes here.
-ALTER TABLE PROJECT ALTER COLUMN id RESTART WITH 2;
+ALTER TABLE project ALTER COLUMN id RESTART WITH 2;
-- //@UNDO
-- SQL to undo the change goes here.
--- /dev/null
+-- // reset project index
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE project_status ALTER COLUMN id RESTART WITH 2;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+
package hu.user.lis.db.repository;
import hu.user.lis.db.Invoice;
+import hu.user.lis.db.Partner;
import org.springframework.data.jpa.repository.JpaRepository;
+import java.util.List;
+import java.util.Optional;
+
public interface InvoiceRepository extends JpaRepository<Invoice, Long>, InvoiceRepositorySearch {
+ List<Invoice> findByHumanId(String humanId);
+
+ Optional<Invoice> findByHumanIdAndPartner(String humanId, Partner partner);
+
}
public interface PaymentRepository extends JpaRepository<Payment, Long> {
- List<Payment> findAllByInvoice(Invoice invoice);
+ List<Payment> findAllByInvoiceOrderByPaymentDateDesc(Invoice invoice);
+ long countByInvoice(Invoice invoice);
}
package hu.user.lis.ui;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class Constants {
public static final String BINDING_QUEUE = "$ZKBIND_DEFQUE$";
public static final String PROJECT_EDITOR_QUEUE = "PROJECT_EDITOR_QUEUE";
public static final String NAV_LOGIN = "/login";
public static final String NAV_LOGOUT = "/logout";
public static final String NAV_ROOT = "/";
-
public static final String NAV_API = "/api";
-
public static final String WIDGET_ENTITY_SELECTOR = "~./widget/entity-selector.zul";
}
--- /dev/null
+package hu.user.lis.ui.converter;
+
+import hu.user.lis.db.Partner;
+import org.springframework.stereotype.Component;
+import org.zkoss.bind.BindContext;
+import org.zkoss.bind.Converter;
+import org.zkoss.zul.ListModel;
+import org.zkoss.zul.Selectbox;
+import org.zkoss.zul.ext.Selectable;
+
+import java.util.Objects;
+
+@Component
+public class PartnerConverter implements Converter<Object, Partner, Selectbox> {
+ @Override
+ public Object coerceToUi(Partner entity, Selectbox bandbox, BindContext bindContext) {
+ if (Objects.isNull(entity)) {
+ return IGNORED_VALUE;
+ }
+ ListModel<?> model = bandbox.getModel();
+ ((Selectable<Object>) model).clearSelection();
+ for (int i = 0; i < model.getSize(); i++) {
+ Partner status = (Partner) model.getElementAt(i);
+ if (status.getId().equals(entity.getId())) {
+ return i;
+ }
+ }
+ return IGNORED_VALUE;
+ }
+
+ @Override
+ public Partner coerceToBean(Object order, Selectbox bandbox, BindContext bindContext) {
+ ListModel<Partner> model = bandbox.getModel();
+ return model.getElementAt((int) order);
+ }
+}
\ No newline at end of file
package hu.user.lis.ui.converter;
import hu.user.lis.db.ProjectStatus;
-import hu.user.lis.db.repository.ProjectStatusRepository;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.zkoss.bind.BindContext;
import org.zkoss.bind.Converter;
@Component
public class ProjectStatusConverter implements Converter<Object, ProjectStatus, Selectbox> {
- @Autowired
- ProjectStatusRepository projectStatusRepository;
+// @Autowired
+// ProjectStatusRepository projectStatusRepository;
@Override
public Object coerceToUi(ProjectStatus projectStatus, Selectbox box, BindContext bindContext) {
@Override
public ProjectStatus coerceToBean(Object order, Selectbox bandbox, BindContext bindContext) {
- return projectStatusRepository.findByOrder((Integer) order + 1);
+ ListModel<ProjectStatus> model = bandbox.getModel();
+ return model.getElementAt((int) order);
+// return projectStatusRepository.findByOrder((Integer) order + 1);
}
}
\ No newline at end of file
import java.util.Objects;
import java.util.Optional;
-@Component
@Log4j2
+@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class InvoicesDataModel extends CachedSpringDataModel<Invoice> {
@Autowired
--- /dev/null
+package hu.user.lis.ui.data;
+
+import hu.user.lis.db.Invoice;
+import hu.user.lis.db.Payment;
+import hu.user.lis.db.repository.PaymentRepository;
+import hu.user.lis.service.data.EntityDataService;
+import hu.user.lis.ui.data.common.CachedSpringDataModel;
+import lombok.extern.log4j.Log4j2;
+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.zul.FieldComparator;
+
+import java.util.List;
+
+@Log4j2
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class PaymentsDataModel extends CachedSpringDataModel<Payment> {
+
+ @Autowired
+ private PaymentRepository paymentRepository;
+
+ @Autowired
+ private EntityDataService<Payment> paymenssDataService;
+
+ private Invoice invoice;
+
+ public void save(Payment modifiedEntity) {
+ paymentRepository.save(modifiedEntity);
+ }
+
+ public void delete(Payment selectedPayment) {
+ paymentRepository.delete(selectedPayment);
+ }
+
+ @Override
+ public List<Payment> getResultSet(int page, int pageSize, FieldComparator sortComparator) {
+ return paymentRepository.findAllByInvoiceOrderByPaymentDateDesc(invoice);
+ }
+
+ @Override
+ public int getResultSetCount() {
+ return (int) paymentRepository.countByInvoice(invoice);
+ }
+
+ public void search(Invoice invoice) {
+ this.invoice = invoice;
+ super.reset();
+ }
+}
--- /dev/null
+package hu.user.lis.ui.view;
+
+import hu.user.lis.db.Invoice;
+import hu.user.lis.db.Partner;
+import hu.user.lis.db.Payment;
+import hu.user.lis.db.repository.InvoiceRepository;
+import hu.user.lis.ui.Constants;
+import hu.user.lis.ui.converter.PartnerConverter;
+import hu.user.lis.ui.data.PaymentsDataModel;
+import hu.user.lis.ui.data.common.CachedSpringDataModel;
+import hu.user.lis.ui.editor.selector.EntitySelectorRouter;
+import hu.user.lis.ui.event.EventBus;
+import hu.user.lis.ui.view.common.EntityViewModel;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.extern.log4j.Log4j2;
+import org.zkoss.bind.annotation.Command;
+import org.zkoss.bind.annotation.Init;
+import org.zkoss.bind.annotation.NotifyChange;
+import org.zkoss.zk.ui.select.annotation.WireVariable;
+import org.zkoss.zul.ListModelList;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+@Log4j2
+public class InvoicePaymentViewModel extends EntityViewModel<Payment> {
+
+ @Getter
+ private final ListModelList<Partner> partners = new ListModelList<>();
+
+ @Getter
+ @WireVariable
+ EntitySelectorRouter entitySelectorRouter;
+
+ @WireVariable
+ private EventBus eventBus;
+
+ @Getter
+ @Setter
+ private Partner filterPartner;
+
+ @Getter
+ @Setter
+ private Invoice selectedInvoice;
+
+ @Getter
+ @Setter
+ private String invoiceNumber;
+
+ @WireVariable
+ private InvoiceRepository invoiceRepository;
+
+ @Getter
+ @WireVariable
+ private PaymentsDataModel paymentsDataModel;
+
+ @Getter
+ @WireVariable
+ private PartnerConverter partnerConverter;
+
+ @Getter
+ @Setter
+ private boolean partnerRequired;
+
+ @Init
+ @Override
+ public void init() {
+ super.init();
+// addColumns(ImmutableMap.of(
+// "partner.name", ASCENDING,
+// "partner.vatNr", NATURAL,
+// "project.name", NATURAL,
+// "paymentDeadline", NATURAL,
+// "grossAmount", NATURAL,
+// "currency", NATURAL,
+// "incoming", NATURAL
+// ));
+ }
+
+ @Override
+ protected CachedSpringDataModel<Payment> getDataModel() {
+ return paymentsDataModel;
+ }
+
+ @Override
+ protected String getNavigation() {
+ return Constants.NAV_INVOICE_PAYMENT;
+ }
+
+ @Command
+ @NotifyChange("partnerRequired")
+ public void search() {
+ paymentsDataModel.clearSelection();
+ paymentsDataModel.clear();
+ if (Objects.isNull(filterPartner)) {
+ List<Invoice> invoices = invoiceRepository.findByHumanId(invoiceNumber);
+ if (invoices.isEmpty()) {
+ setPartnerRequired(false);
+ //show message
+ } else {
+ if (invoices.size() == 1) {
+ setPartnerRequired(false);
+ showEditor(invoices.get(0));
+ } else {
+ setPartnerRequired(true);
+ partners.clear();
+ invoices.forEach(invoice -> partners.add(invoice.getPartner()));
+ }
+ }
+ } else {
+ Optional<Invoice> opInvoice = invoiceRepository.findByHumanIdAndPartner(invoiceNumber, filterPartner);
+ opInvoice.ifPresent(this::showEditor);
+ }
+ }
+
+ private void showEditor(Invoice invoice) {
+ paymentsDataModel.search(invoice);
+ }
+}
public class InvoicesViewModel extends EntityViewModel<Invoice> implements EventListener<Event> {
@Getter
private final InvoiceFilter invoiceFilter = InvoiceFilter.builder().incoming(true).build();
-
- @Getter
- @WireVariable
- EntitySelectorRouter entitySelectorRouter;
-
@WireVariable
private EventBus eventBus;
-
- // private boolean filterShowIncoming;
-// private boolean filterShowOutgoing;
+ @Getter
+ @WireVariable
+ private EntitySelectorRouter entitySelectorRouter;
@Getter
@WireVariable
private InvoicesDataModel invoicesDataModel;
<menuitem iconSclass="z-icon-money" label="Összes számla"
onClick="@command(vm.selectPage('~./invoices.zul'))"/>
<menuitem iconSclass="z-icon-credit-card" label="Számla kiegyenlítés"
- onClick="@command(vm.selectPage('~./invoice-settle.zul'))"/>
+ onClick="@command(vm.selectPage('~./invoice-payment.zul'))"/>
<menuitem iconSclass="z-icon-exchange" label="Követelés követés"
onClick="@command('onInvoiceDues')"/>
<menuseparator/>
<zk>
- <window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.InvoicesViewModel')">
+ <window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.InvoicePaymentViewModel')">
<caption label="Számla kiegyenlítés"/>
<borderlayout>
<north flex="true">
<toolbar>
- <toolbarbutton label="Hozzáadás" iconSclass="z-icon-plus" onClick="@command('onAdd')"/>
- <toolbarbutton label="Szerkesztés" iconSclass="z-icon-edit" onClick="@command('onEdit')"
- disabled="@load(empty vm.selectedEntity)"/>
- <toolbarbutton label="Törlés" iconSclass="z-icon-remove" onClick="@command('onDelete')"
- disabled="@load(empty vm.selectedEntity)"/>
+ <label value="Számla sorszáma"/>
<separator orient="vertical"/>
- <toolbarbutton mode="toggle" iconSclass="z-icon-check" label="Aktív"
- checked="@bind(vm.filterShowActive)"/>
- <toolbarbutton mode="toggle" iconSclass="z-icon-ban" label="Inaktív"
- checked="@bind(vm.filterShowInActive)"/>
- <toolbarbutton mode="toggle" iconSclass="z-icon-adjust" label="Mind"
- checked="@bind(vm.filterShowBoth)"/>
+ <textbox value="@bind(vm.invoiceNumber)" onChange="@command('search')"/>
+
+ <space bar="true"/>
+
+ <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>
</toolbar>
</north>
<center border="none" flex="true">
- <listbox id="partnersList" vflex="true" model="@load(vm.partnersDataModel)"
- autopaging="true" mold="paging" pagingPosition="top" multiple="false"
- onSelect="@command('onListSelection')" onDoubleClick="@command('onEdit')">
+ <listbox vflex="true" model="@load(vm.paymentsDataModel)" multiple="false">
<listhead sizable="true">
- <listheader label="Név" sort="auto(name)" align="left"
- sortDirection="@load(vm.cols['name'].sortDirection)"/>
- <listheader label="Adószám" sort="auto(vatNr)" align="left"
- sortDirection="@load(vm.cols['vatNr'].sortDirection)"/>
- <listheader label="Cím" sort="auto(address)" align="left"
- sortDirection="@load(vm.cols['address'].sortDirection)"/>
- <listheader label="Aktív" sort="auto(active)" align="left"
- sortDirection="@load(vm.cols['active'].sortDirection)"/>
-
+ <listheader label="Dátum" align="left"/>
+ <listheader label="Nettó összeg" align="right"/>
+ <listheader label="Bruttó összeg" align="right"/>
+ <listheader label="ÁFA összeg" align="right"/>
</listhead>
<template name="model">
<listitem>
- <listcell label="@load(each.name)"/>
- <listcell label="@load(each.vatNr)"/>
- <listcell label="@load(each.address)"/>
- <listcell>
- <a iconSclass="z-icon-check" visible="@load(each.active)"/>
- <a iconSclass="z-icon-ban" visible="@load(!each.active)"/>
- </listcell>
+ <listcell label="@load(each.paymentDate)"/>
+ <listcell label="@load(each.netAmount)"/>
+ <listcell label="@load(each.grossAmount)"/>
+ <listcell label="@load(each.vatAmount)"/>
</listitem>
</template>
</listbox>
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="server-dev" type="Application" factoryName="Application">
- <option name="ALTERNATIVE_JRE_PATH" value="semeru-1.8" />
+ <option name="ALTERNATIVE_JRE_PATH" value="1.8" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<envs>
<env name="spring.profiles.active" value="dev" />