/lis-db/migrations/drivers/jcc-11.5.7.0.jar
./.idea/
target/
-/.jpb/persistence-units.xml
+/.idea/.jpb/persistence-units.xml
create: All tasks
job-execution.enabled: true
logging:
+ config: classpath:logback-dev.xml
level:
org.hibernate.engine.jdbc.spi.SqlExceptionHelper: ERROR
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
+++ /dev/null
-### HTTP server
-server:
- port: 8080
- servlet:
- context-path: /
-
-### ZKoss
-zk:
- homepage: index
- zul-view-resolver-enabled: true
-### Spring
-spring:
- #active: dev
- # profiles:
- #main:
- # banner-mode: off
- output:
- ansi:
- enabled: always
- mail:
- host: smtp.gmail.com
- port: 465
- username: mediacubeserver@gmail.com
- password: salabakter
- protocol: smtps
- properties:
- mail:
- smtp:
- auth: true
- starttls:
- enable: true
- #datasources:
- # maszkaweb:
- # driver-class-name: com.mysql.jdbc.Driver
- # type: com.zaxxer.hikari.HikariDataSource
- # jdbcUrl: jdbc:mysql://localhost:3306/maszkaweb?useUnicode=true&characterEncoding=UTF-8
- # username: root
- # password: password
- # pool-name: pool-maszkaweb
- # maximum-pool-size: 50
- # minimum-idle: 10
- # data:
- # mongodb:
- # # host: dvdev.in.useribm.hu
- # host: localvm
- # port: 27017
- # database: lis
-
- # username: db2admin
- # password: password
-# datasource:
-# # driver-class-name: com.mysql.jdbc.Driver
-# type: com.zaxxer.hikari.HikariDataSource
-# url: jdbc:db2://localvm:50000/testmc
-# username: db2admin
-# password: password
-# hikari:
-# pool-name: testmc
-# maximum-pool-size: 50
-# minimum-idle: 10
-service:
- message: Hello, World
+++ /dev/null
-### HTTP server
-server:
- port: 8080
- servlet:
- context-path: /
-
-### ZKoss
-zk:
- homepage: suppliers
- zul-view-resolver-enabled: true
-### Spring
-spring:
- main:
- banner-mode: off
- output:
- ansi:
- enabled: always
- mail:
- host: smtp.gmail.com
- port: 465
- username: mediacubeserver@gmail.com
- password: salabakter
- protocol: smtps
- properties:
- mail:
- smtp:
- auth: true
- starttls:
- enable: true
- #datasources:
- # maszkaweb:
- # driver-class-name: com.mysql.jdbc.Driver
- # type: com.zaxxer.hikari.HikariDataSource
- # jdbcUrl: jdbc:mysql://localhost:3306/maszkaweb?useUnicode=true&characterEncoding=UTF-8
- # username: root
- # password: password
- # pool-name: pool-maszkaweb
- # maximum-pool-size: 50
- # minimum-idle: 10
- datasource:
- # driver-class-name: com.mysql.jdbc.Driver
- type: com.zaxxer.hikari.HikariDataSource
- url: jdbc:db2://localvm:50000/testmc
- username: db2admin
- password: password
- hikari:
- pool-name: testmc
- maximum-pool-size: 50
- minimum-idle: 10
-service:
- message: Hello, World
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
-
- <property name="LOGS" value="./logs"/>
-
- <appender name="Console"
- class="ch.qos.logback.core.ConsoleAppender">
+ <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>
-
<root level="info">
<appender-ref ref="Console"/>
</root>
-
- <logger name="hu.user.lis" level="trace" additivity="false">
- <appender-ref ref="Console"/>
- </logger>
-
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
-
<property name="LOGS" value="./logs"/>
-
- <appender name="Console"
- class="ch.qos.logback.core.ConsoleAppender">
+ <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
</layout>
</appender>
- <appender name="RollingFile"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <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">
+ <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">
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <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="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>
project.setProjectStatus(null);
IncomingInvoice invoice = IncomingInvoice.builder()
- .income(true)
+ .incoming(true)
.planned(true)
.currency(Currency.HUF)
.netAmount(1)
DB2 SQL
ALTER TABLE "tableName" ALTER COLUMN "columnName" RESTART WITH <new index value>
+ALTER TABLE org RENAME COLUMN deptnumb TO deptnum
\ No newline at end of file
script_char_set=UTF-8
## JDBC connection properties.
driver=com.ibm.db2.jcc.DB2Driver
-url=jdbc:db2://localhost:50000/slycrm
+url=jdbc:db2://localhost:50000/lis
username=db2admin
password=password
#
--- /dev/null
+-- // reset partner index
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE PARTNER ALTER COLUMN id RESTART WITH 4;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+
--- /dev/null
+-- // reset project index
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE PROJECT ALTER COLUMN id RESTART WITH 2;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+
--- /dev/null
+-- // create payment
+-- Migration SQL that makes the change goes here.
+
+CREATE TABLE payment (
+ id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ invoice_id BIGINT,
+ net_amount DOUBLE NOT NULL,
+ gross_amount DOUBLE NOT NULL,
+ vat_amount DOUBLE NOT NULL,
+ payment_date TIMESTAMP,
+ currency INTEGER,
+ CONSTRAINT pk_payment PRIMARY KEY (id)
+);
+ALTER TABLE payment ADD CONSTRAINT FK_PAYMENT_ON_INVOICE FOREIGN KEY (invoice_id) REFERENCES invoice (id);
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+DROP TABLE payment;
--- /dev/null
+-- // modify invoice rename income incoming
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE invoice RENAME COLUMN income TO incoming;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+ALTER TABLE invoice RENAME COLUMN incoming TO income;
--- /dev/null
+-- // add paid to invoice
+-- Migration SQL that makes the change goes here.
+
+ALTER TABLE invoice ADD COLUMN paid SMALLINT NOT NULL DEFAULT 0;
+
+-- //@UNDO
+-- SQL to undo the change goes here.
+
+ALTER TABLE invoice DROP COLUMN paid;
@DiscriminatorValue("1")
public class IncomingInvoice extends Invoice {
public IncomingInvoice() {
- income = true;
+ incoming = true;
}
}
@Entity
@SuperBuilder
@NoArgsConstructor
-@DiscriminatorColumn(name = "income", discriminatorType = DiscriminatorType.INTEGER)
+@DiscriminatorColumn(name = "incoming", discriminatorType = DiscriminatorType.INTEGER)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Invoice implements Serializable {
@Id
Long id;
String humanId;
String title;
- @Column(nullable = false, insertable = false, updatable = false)
- boolean income;
Currency currency;
double netAmount;
double grossAmount;
Date completionDate;
Date createDate;
Date paymentDeadline;
+ @Column(nullable = false, insertable = false, updatable = false)
+ boolean incoming;
+ boolean paid;
boolean planned;
byte[] file;
+
@OneToOne
@JoinColumn(name = "partner_id")
@JsonIncludeProperties({"id"})
--- /dev/null
+package hu.user.lis.db;
+
+import com.fasterxml.jackson.annotation.JsonIncludeProperties;
+import lombok.*;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+@Getter
+@Setter
+@Entity
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class Payment implements Serializable {
+ @ManyToOne
+ @JoinColumn(name = "invoice_id")
+ @JsonIncludeProperties({"id"})
+ Invoice invoice;
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ Long id;
+ double netAmount;
+ double grossAmount;
+ double vatAmount;
+ Date paymentDate;
+}
@OneToMany(targetEntity = IncomingInvoice.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "project_id", referencedColumnName = "id")
- @Where(clause = "income=1")
+ @Where(clause = "incoming=1")
@Fetch(FetchMode.JOIN)
@JsonIncludeProperties({"id"})
Set<IncomingInvoice> incomingInvoices;
@OneToMany(targetEntity = OutgoingInvoice.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "project_id", referencedColumnName = "id")
- @Where(clause = "income=0")
+ @Where(clause = "incoming=0")
@Fetch(FetchMode.JOIN)
@JsonIncludeProperties({"id"})
Set<OutgoingInvoice> outgoingInvoices;
if (filter.isIncoming()) {
predicates.add(cb.isTrue(root.get("incoming")));
+ } else {
+ predicates.add(cb.isFalse(root.get("incoming")));
}
- if (filter.isSettled()) {
- //TODO add field
- predicates.add(cb.isTrue(root.get("settled")));
+ if (filter.isPaid()) {
+ predicates.add(cb.isTrue(root.get("paid")));
}
- if (Objects.nonNull(filter.getPaymentDeadLineFrom()) || Objects.nonNull(filter.getPaymentDeadLineTo())) {
- //TODO check
- predicates.add(cb.between(root.get("deadline"), filter.getPaymentDeadLineFrom(), filter.getPaymentDeadLineTo()));
+ if (Objects.nonNull(filter.getPaymentDeadLineFrom())) {
+ if (Objects.nonNull(filter.getPaymentDeadLineTo())) {
+ predicates.add(cb.between(root.get("paymentDeadline"), filter.getPaymentDeadLineFrom(), filter.getPaymentDeadLineTo()));
+ } else {
+ predicates.add(cb.greaterThanOrEqualTo(root.get("paymentDeadline"), filter.getPaymentDeadLineFrom()));
+ }
+ } else {
+ if (Objects.nonNull(filter.getPaymentDeadLineTo())) {
+ predicates.add(cb.lessThanOrEqualTo(root.get("paymentDeadline"), filter.getPaymentDeadLineTo()));
+ }
}
return predicates.toArray(new Predicate[]{});
--- /dev/null
+package hu.user.lis.db.repository;
+
+import hu.user.lis.db.Invoice;
+import hu.user.lis.db.Payment;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface PaymentRepository extends JpaRepository<Payment, Long> {
+
+ List<Payment> findAllByInvoice(Invoice invoice);
+
+}
import hu.user.lis.db.Partner;
import hu.user.lis.db.Project;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import lombok.ToString;
+import lombok.*;
import java.util.Date;
@Getter
@Setter
-@NoArgsConstructor
+@Builder
@ToString
+@NoArgsConstructor
+@AllArgsConstructor
public class InvoiceFilter extends PageableFilter {
private Partner partner;
private Project project;
- private boolean isIncoming;
+ private boolean incoming;
- private boolean isSettled;
+ private boolean paid;
private Date paymentDeadLineFrom;
import java.lang.reflect.Field;
import java.util.Arrays;
+import java.util.Optional;
@Log4j2
@Service
public class EntityDataServiceBase {
+ private Object getMemberEntity(Object parent, String property) throws IllegalAccessException, NoSuchFieldException {
+ Object result = parent;
+ if (property.contains(".")) {
+ String[] tokens = property.split("\\.");
+ for (int i = 0; i < tokens.length - 1; i++) {
+ String fieldName = tokens[i];
+ Optional<Field> declaredField = Optional.of(result.getClass().getDeclaredField(fieldName));
+ Field field = declaredField.get();
+ field.setAccessible(true);
+ result = field.get(result);
+ }
+ }
+ return result;
+ }
+
+ private String getPropertyName(String property) {
+ String result = property;
+ if (property.contains(".")) {
+ String[] tokens = property.split("\\.");
+ result = tokens[tokens.length - 1];
+ }
+ return result;
+ }
+
+
+ private Field getField(Object entity, String property) throws NoSuchFieldException {
+ Field field;
+ boolean hasField = Arrays.stream(entity.getClass().getDeclaredFields()).anyMatch(f -> f.getName().equals(property));
+ if (hasField) {
+ field = entity.getClass().getDeclaredField(property);
+ } else {
+ field = entity.getClass().getSuperclass().getDeclaredField(property);
+ }
+ return field;
+ }
+
public boolean setFieldValue(Object entity, String property, Object value) {
boolean result = false;
- Field field;
try {
- boolean hasField = Arrays.stream(entity.getClass().getDeclaredFields()).anyMatch(f -> f.getName().equals(property));
- if (hasField) {
- field = entity.getClass().getDeclaredField(property);
- } else {
- field = entity.getClass().getSuperclass().getDeclaredField(property);
- }
+ String memberPropertyName = getPropertyName(property);
+ Object memberEntity = getMemberEntity(entity, property);
+ Field field = getField(memberEntity, memberPropertyName);
field.setAccessible(true);
- field.set(entity, value);
+ field.set(memberEntity, value);
result = true;
} catch (Exception e) {
log.error(e);
public Object getFieldValue(Object entity, String property) {
Object result = null;
- Field field;
try {
- boolean hasField = Arrays.stream(entity.getClass().getDeclaredFields()).anyMatch(f -> f.getName().equals(property));
- if (hasField) {
- field = entity.getClass().getDeclaredField(property);
- } else {
- field = entity.getClass().getSuperclass().getDeclaredField(property);
- }
+ String memberPropertyName = getPropertyName(property);
+ Object memberEntity = getMemberEntity(entity, property);
+ Field field = getField(memberEntity, memberPropertyName);
field.setAccessible(true);
- result = field.get(entity);
+ result = field.get(memberEntity);
} catch (Exception e) {
log.error(e);
}
this.incomingEntities = new ArrayList<>();
this.outgoingEntities = new ArrayList<>();
entities.forEach(e -> {
- if (e.isIncome()) {
+ if (e.isIncoming()) {
incomingEntities.add(e);
} else {
outgoingEntities.add(e);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income)
+ .incoming(income)
.build();
result.add(entity);
}
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // bejovo szamla
+ .incoming(income) // bejovo szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // kimeno szamla
+ .incoming(income) // kimeno szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // kimeno szamla
+ .incoming(income) // kimeno szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // kimeno szamla
+ .incoming(income) // kimeno szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // kimeno szamla
+ .incoming(income) // kimeno szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // kimeno szamla
+ .incoming(income) // kimeno szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // kimeno szamla
+ .incoming(income) // kimeno szamla
.build();
result.add(entity);
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(income) // kimeno szamla
+ .incoming(income) // kimeno szamla
.build();
result.add(entity);
}
@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 = "income", constant = "true")
+ @Mapping(target = "incoming", constant = "true")
@Mapping(target = "id", ignore = true)
@Mapping(target = "title", ignore = true)
@Mapping(target = "planned", ignore = true)
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="SonarLintModuleSettings">
- <option name="uniqueId" value="479a69b7-fe0e-4ae1-bea4-f9c9506ffaff" />
+ <option name="uniqueId" value="28f051fb-5766-4e3e-8837-e81b969fbd4c" />
</component>
</module>
\ No newline at end of file
public static final String REFRESH_INVOICE_IMPORT_TASKS = "REFRESH_INVOICE_IMPORT_TASKS";
public static final String NAV_PARTNERS = "/partners";
public static final String NAV_INVOICES = "/invoices";
-
- public static final String NAV_INVOICE_SETTLE = "/invoice-settle";
+ public static final String NAV_INVOICE_PAYMENT = "/invoice-payment";
public static final String NAV_PROJECTS = "/projects";
public static final String NAV_PROJECT = "/project";
public static final String NAV_PROJECT_WILD_CARD = "/project/**";
return settings.get(type);
}
- public void addSetting(Profile columnProfile) {
+ public void persistSetting(Profile columnProfile) {
Profile existing = settings.get(columnProfile.getType());
if (Objects.nonNull(existing)) {
columnProfile.setId(existing.getId());
Constants.NAV_IMPORT_INVOICES_ASSIGN,
Constants.NAV_IMPORT_INVOICES_APPROVE,
Constants.NAV_INVOICES,
- Constants.NAV_INVOICE_SETTLE,
+ Constants.NAV_INVOICE_PAYMENT,
Constants.NAV_SETTINGS,
Constants.NAV_PROJECT_WILD_CARD
})
public IncomingInvoice createNewIncomingInvoice() {
IncomingInvoice result = IncomingInvoice.builder()
- .income(true)
+ .incoming(true)
.planned(true)
.build();
return result;
this.filter = filter;
super.reset();
}
-
- public void listAll() {
- log.info("List all invoices");
- this.filter = null;
- super.reset();
- }
}
public void addColumns(Map<String, String> columns) {
Profile profile = currentProfile.getSetting(getClass().getSimpleName());
+ columns.keySet().forEach(colName -> addColumn(colName, columns.get(colName)));
if (Objects.isNull(profile)) {
- columns.keySet().forEach(colName -> addColumn(colName, columns.get(colName)));
saveProfileSetting();
} else {
- columnSettings = entityDataService.fromJSON(profile.getSetting(), JSONObject.class);
+ JSONObject savedColumns = entityDataService.fromJSON(profile.getSetting(), JSONObject.class);
+ if (savedColumns.keySet().equals(columns.keySet())) {
+ columnSettings = savedColumns;
+ } else {
+ saveProfileSetting();
+ }
}
}
.type(getClass().getSimpleName())
.setting(entityDataService.toJSON(columnSettings))
.build();
- currentProfile.addSetting(columnProfile);
+ currentProfile.persistSetting(columnProfile);
}
private void addColumn(String name, String direction) {
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.repository.filter.InvoiceFilter;
import hu.user.lis.ui.Constants;
import hu.user.lis.ui.data.InvoicesDataModel;
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.extern.log4j.Log4j2;
-import org.zkoss.bind.annotation.Init;
+import org.zkoss.bind.BindUtils;
+import org.zkoss.bind.PropertyChangeEvent;
+import org.zkoss.bind.annotation.*;
+import org.zkoss.zk.ui.Component;
+import org.zkoss.zk.ui.event.Event;
+import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.select.annotation.WireVariable;
+import java.util.Objects;
+
import static hu.user.lis.ui.data.common.CachedDataModel.ASCENDING;
import static hu.user.lis.ui.data.common.CachedDataModel.NATURAL;
@Log4j2
-public class InvoicesViewModel extends EntityViewModel<Invoice> {
+public class InvoicesViewModel extends EntityViewModel<Invoice> implements EventListener<Event> {
+ @Getter
+ private final InvoiceFilter invoiceFilter = InvoiceFilter.builder().incoming(true).build();
+
@Getter
@WireVariable
- InvoicesDataModel invoicesDataModel;
+ EntitySelectorRouter entitySelectorRouter;
- @Override
- protected CachedSpringDataModel<Invoice> getDataModel() {
- return invoicesDataModel;
- }
+ @WireVariable
+ private EventBus eventBus;
- @Override
- protected String getNavigation() {
- return Constants.NAV_INVOICES;
- }
+ // private boolean filterShowIncoming;
+// private boolean filterShowOutgoing;
+ @Getter
+ @WireVariable
+ private InvoicesDataModel invoicesDataModel;
@Init
+ @Override
public void init() {
super.init();
+ eventBus.register(this);
+ eventBus.registerForBinding(this);
+ refresh();
addColumns(ImmutableMap.of(
"partner.name", ASCENDING,
"partner.vatNr", NATURAL,
"project.name", NATURAL,
- "dueDate", NATURAL,
- "paymentDate", NATURAL,
+ "paymentDeadline", NATURAL,
"grossAmount", NATURAL,
"currency", NATURAL,
- "income", NATURAL
+ "incoming", NATURAL
));
}
- protected void refresh() {
+ @Override
+ @AfterCompose
+ public void onAfterCompose(@ContextParam(ContextType.VIEW) Component view) {
+ entitySelectorRouter.configureSelector(Partner.class, this, "invoiceFilter.partner");
+ entitySelectorRouter.configureSelector(Project.class, this, "invoiceFilter.project");
+ }
+
+ @Override
+ protected CachedSpringDataModel<Invoice> getDataModel() {
+ return invoicesDataModel;
+ }
+
+ @Override
+ protected String getNavigation() {
+ return Constants.NAV_INVOICES;
+ }
+
+ @Command
+ public void refresh() {
invoicesDataModel.clearSelection();
- invoicesDataModel.listAll();
+ invoicesDataModel.search(invoiceFilter);
}
+ @Command
+ public void setIncoming(@BindingParam("incoming") boolean value) {
+ invoiceFilter.setIncoming(value);
+ BindUtils.postNotifyChange(null, null, invoiceFilter, "incoming");
+ refresh();
+ }
+
+ @Command
+ public void search() {
+ refresh();
+ }
+
+ @Override
+ public void onEvent(Event evt) throws Exception {
+ if (evt instanceof PropertyChangeEvent) {
+ PropertyChangeEvent propertyEvent = (PropertyChangeEvent) evt;
+ if (Objects.nonNull(propertyEvent.getBase()) && propertyEvent.getBase().equals(this)) {
+ if ("invoiceFilter.project".equals(propertyEvent.getProperty()) ||
+ "invoiceFilter.partner".equals(propertyEvent.getProperty())) {
+ refresh();
+ }
+ }
+
+ }
+ }
+
+ @Destroy
+ public void onDestroy() {
+ log.info("Destroy {}", getClass().getSimpleName());
+ eventBus.unregister(this);
+ }
}
@Log4j2
@VariableResolver(DelegatingVariableResolver.class)
-public class ServiceRecordsViewModel extends EntityViewModel<ServiceRecord> implements EventListener {
+public class ServiceRecordsViewModel extends EntityViewModel<ServiceRecord> implements EventListener<Event> {
@WireVariable
@Getter
ServiceRecordsDataModel serviceRecordsDataModel;
+<?component name="entity-selector" inline="true" class="hu.user.lis.ui.editor.widget.EntitySelector"?>
<zk>
<window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.InvoicesViewModel')">
<caption label="Számlák"/>
<borderlayout>
- <north flex="true">
+ <north hflex="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)"/>
+ <!-- <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="Partner"/>
<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)"/>
+ <entity-selector entity="Partner" style="display: inline-block;" width="300px"/>
+ <space bar="true"/>
+ <label value="Projekt"/>
+ <separator orient="vertical"/>
+ <entity-selector entity="Project" style="display: inline-block;" width="300px"/>
+ <space bar="true"/>
+ <toolbarbutton mode="toggle" iconSclass="z-icon-external-link" label="Költség"
+ checked="@load(vm.invoiceFilter.incoming)"
+ onClick="@command('setIncoming', incoming=true)"/>
+ <toolbarbutton mode="toggle" iconSclass="z-icon-sign-in" label="Bevétel"
+ checked="@load(!vm.invoiceFilter.incoming)"
+ onClick="@command('setIncoming', incoming=false)"/>
+ <space bar="true"/>
+ <!-- <separator orient="vertical"/>-->
+ <label value="Fizetési határidő"/>
+ <separator orient="vertical"/>
+ <datebox instant="true" format="yyyy. MM. dd."
+ value="@bind(vm.invoiceFilter.paymentDeadLineFrom)"
+ onChange="@command('refresh')"/>
+ <label value="-"/>
+ <datebox instant="true" format="yyyy. MM. dd."
+ value="@bind(vm.invoiceFilter.paymentDeadLineTo)"
+ onChange="@command('refresh')"/>
+
+ <space bar="true"/>
+ <toolbarbutton mode="toggle" iconSclass="z-icon-credit-card" label="Teljesített fizetés"
+ checked="@load(!vm.invoiceFilter.incoming)"
+ onClick="@command('setIncoming', incoming=false)"/>
+
+ <!-- <toolbarbutton iconSclass="z-icon-search" label="Szűrés"-->
+ <!-- onClick="@command('search')"/>-->
</toolbar>
</north>
- <center border="none" flex="true">
- <listbox id="partnersList" vflex="true" model="@load(vm.partnersDataModel)"
+ <center border="none" hflex="true" vflex="true">
+ <listbox id="invoicesList" vflex="true" model="@load(vm.invoicesDataModel)"
autopaging="true" mold="paging" pagingPosition="top" multiple="false"
onSelect="@command('onListSelection')" onDoubleClick="@command('onEdit')">
<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="Partner név" sort="auto(partner.name)" align="left"
+ sortDirection="@load(vm.cols['partner.name'].sortDirection)"/>
+ <listheader label="Partner adószám" sort="auto(partner.vatNr)" align="left"
+ sortDirection="@load(vm.cols['partner.vatNr'].sortDirection)"/>
+ <listheader label="Projekt név" sort="auto(project.name)" align="left"
+ sortDirection="@load(vm.cols['project.name'].sortDirection)"/>
+ <listheader label="Fizetési határidő" sort="auto(paymentDeadline)" align="left"
+ sortDirection="@load(vm.cols['paymentDeadline'].sortDirection)"/>
+ <listheader label="Bruttó összeg" sort="auto(grossAmount)" align="right"
+ style="text-align: center"
+ sortDirection="@load(vm.cols['grossAmount'].sortDirection)"/>
+ <listheader label="Bruttó összeg" sort="auto(currency)" align="left"
+ sortDirection="@load(vm.cols['currency'].sortDirection)"/>
+ <listheader label="Költség/Bevétel" sort="auto(incoming)" align="left"
+ sortDirection="@load(vm.cols['incoming'].sortDirection)"/>
</listhead>
<template name="model">
<listitem>
- <listcell label="@load(each.name)"/>
- <listcell label="@load(each.vatNr)"/>
- <listcell label="@load(each.address)"/>
+ <listcell label="@load(each.partner.name)"/>
+ <listcell label="@load(each.partner.vatNr)"/>
+ <listcell label="@load(each.project.name)"/>
+ <listcell
+ label="@load(each.paymentDeadline) @converter('hu.user.lis.ui.converter.DateToStringConverter')"/>
+ <listcell
+ label="@load(each.grossAmount) @converter('hu.user.lis.ui.converter.DoubleToStringConverter')"/>
+ <listcell label="@load(each.currency)"/>
<listcell>
- <a iconSclass="z-icon-check" visible="@load(each.active)"/>
- <a iconSclass="z-icon-ban" visible="@load(!each.active)"/>
+ <a iconSclass="z-icon-external-link" visible="@load(each.incoming)"/>
+ <a iconSclass="z-icon-sign-in" visible="@load(!each.incoming)"/>
</listcell>
</listitem>
</template>
.netAmount(netAmount)
.grossAmount(grossAmount)
.vatAmount(vatAmount)
- .income(true)
+ .incoming(true)
.build();
}