adding checkstyle
This commit is contained in:
parent
0afb90c068
commit
383e4d6fe4
54
pom.xml
54
pom.xml
@ -224,11 +224,43 @@
|
|||||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||||
<version>4.0.2</version>
|
<version>4.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-core</artifactId>
|
||||||
|
<version>5.12.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>spring-boot:run</defaultGoal>
|
<defaultGoal>spring-boot:run</defaultGoal>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>src/main/resources/checkstyle.xml</configLocation>
|
||||||
|
<consoleOutput>true</consoleOutput>
|
||||||
|
<failsOnError>true</failsOnError>
|
||||||
|
<sourceDirectories>
|
||||||
|
<directory>${project.build.sourceDirectory}</directory>
|
||||||
|
</sourceDirectories>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>compile</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
@ -351,6 +383,28 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>src/main/resources/checkstyle.xml</configLocation>
|
||||||
|
<failOnViolation>true</failOnViolation>
|
||||||
|
<enableFilesSummary>true</enableFilesSummary>
|
||||||
|
</configuration>
|
||||||
|
<reportSets>
|
||||||
|
<reportSet>
|
||||||
|
<reports>
|
||||||
|
<report>checkstyle-aggregate</report>
|
||||||
|
</reports>
|
||||||
|
</reportSet>
|
||||||
|
</reportSets>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<!-- Production mode is activated using -Pproduction -->
|
<!-- Production mode is activated using -Pproduction -->
|
||||||
|
@ -16,7 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
@Theme(value = "pfs")
|
@Theme(value = "pfs")
|
||||||
public class Application implements AppShellConfigurator {
|
public class Application implements AppShellConfigurator {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(final String[] args) {
|
||||||
SpringApplication.run(Application.class, args);
|
SpringApplication.run(Application.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,45 +17,45 @@ public class CabeceraDTO {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "9999999999999", inclusive = true)
|
@DecimalMax(value = "9999999999999", inclusive = true)
|
||||||
protected long nitEmisor;
|
private long nitEmisor;
|
||||||
@XmlElement(required = true)
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 200)
|
@Size(min = 1, max = 200)
|
||||||
protected String razonSocialEmisor;
|
private String razonSocialEmisor;
|
||||||
@XmlElement(required = true)
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 25)
|
@Size(min = 1, max = 25)
|
||||||
protected String municipio;
|
private String municipio;
|
||||||
@XmlElement(required = true, nillable = true)
|
|
||||||
@Size(min = 1, max = 25)
|
@Size(min = 1, max = 25)
|
||||||
protected String telefono;
|
private String telefono;
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "9999999999", inclusive = true)
|
@DecimalMax(value = "9999999999", inclusive = true)
|
||||||
protected long numeroFactura;
|
private long numeroFactura;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 100)
|
@Size(min = 1, max = 100)
|
||||||
protected String cuf;
|
private String cuf;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 100)
|
@Size(min = 1, max = 100)
|
||||||
protected String cufd;
|
private String cufd;
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "0", inclusive = true)
|
@DecimalMin(value = "0", inclusive = true)
|
||||||
@DecimalMax(value = "9999", inclusive = true)
|
@DecimalMax(value = "9999", inclusive = true)
|
||||||
protected int codigoSucursal;
|
private int codigoSucursal;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 500)
|
@Size(min = 1, max = 500)
|
||||||
protected String direccion;
|
private String direccion;
|
||||||
@XmlElement(required = true, type = Integer.class, nillable = true)
|
@XmlElement(required = true, type = Integer.class, nillable = true)
|
||||||
@DecimalMin(value = "0", inclusive = true)
|
@DecimalMin(value = "0", inclusive = true)
|
||||||
@DecimalMax(value = "9999", inclusive = true)
|
@DecimalMax(value = "9999", inclusive = true)
|
||||||
protected Integer codigoPuntoVenta;
|
private Integer codigoPuntoVenta;
|
||||||
@XmlElement(required = true, type = String.class)
|
@XmlElement(required = true, type = String.class)
|
||||||
@XmlJavaTypeAdapter(DateTimeXmlAdapter.class)
|
@XmlJavaTypeAdapter(DateTimeXmlAdapter.class)
|
||||||
@XmlSchemaType(name = "dateTime")
|
@XmlSchemaType(name = "dateTime")
|
||||||
@NotNull
|
@NotNull
|
||||||
protected LocalDateTime fechaEmision;
|
private LocalDateTime fechaEmision;
|
||||||
}
|
}
|
||||||
|
@ -11,40 +11,40 @@ import lombok.Data;
|
|||||||
public class ClientDTO {
|
public class ClientDTO {
|
||||||
@XmlElement(required = true, nillable = true)
|
@XmlElement(required = true, nillable = true)
|
||||||
@Size(min = 1, max = 500)
|
@Size(min = 1, max = 500)
|
||||||
protected String nombreRazonSocial;
|
private String nombreRazonSocial;
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "5", inclusive = true)
|
@DecimalMax(value = "5", inclusive = true)
|
||||||
protected int codigoTipoDocumentoIdentidad;
|
private int codigoTipoDocumentoIdentidad;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 20)
|
@Size(min = 1, max = 20)
|
||||||
protected String numeroDocumento;
|
private String numeroDocumento;
|
||||||
@XmlElement(required = true, nillable = true)
|
@XmlElement(required = true, nillable = true)
|
||||||
@Size(max = 5)
|
@Size(max = 5)
|
||||||
protected String complemento;
|
private String complemento;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 500)
|
@Size(min = 1, max = 500)
|
||||||
protected String direccionComprador;
|
private String direccionComprador;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 100)
|
@Size(min = 1, max = 100)
|
||||||
protected String codigoCliente;
|
private String codigoCliente;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 500)
|
@Size(min = 1, max = 500)
|
||||||
protected String lugarDestino;
|
private String lugarDestino;
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "212", inclusive = true)
|
@DecimalMax(value = "212", inclusive = true)
|
||||||
protected int codigoPais;
|
private int codigoPais;
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "308", inclusive = true)
|
@DecimalMax(value = "308", inclusive = true)
|
||||||
protected int codigoMetodoPago;
|
private int codigoMetodoPago;
|
||||||
@XmlElement(required = true, type = Long.class, nillable = true)
|
@XmlElement(required = true, type = Long.class, nillable = true)
|
||||||
@DecimalMin(value = "0", inclusive = true)
|
@DecimalMin(value = "0", inclusive = true)
|
||||||
@DecimalMax(value = "9999999999999999", inclusive = true)
|
@DecimalMax(value = "9999999999999999", inclusive = true)
|
||||||
protected Long numeroTarjeta;
|
private Long numeroTarjeta;
|
||||||
}
|
}
|
||||||
|
@ -13,38 +13,38 @@ public class DetalleDTO {
|
|||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 10)
|
@Size(min = 1, max = 10)
|
||||||
protected String actividadEconomica;
|
private String actividadEconomica;
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "99999999", inclusive = true)
|
@DecimalMax(value = "99999999", inclusive = true)
|
||||||
protected int codigoProductoSin;
|
private int codigoProductoSin;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 50)
|
@Size(min = 1, max = 50)
|
||||||
protected String codigoProducto;
|
private String codigoProducto;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 500)
|
@Size(min = 1, max = 500)
|
||||||
protected String descripcion;
|
private String descripcion;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
protected BigInteger cantidad;
|
private BigInteger cantidad;
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "200", inclusive = true)
|
@DecimalMax(value = "200", inclusive = true)
|
||||||
protected int unidadMedida;
|
private int unidadMedida;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "0", inclusive = false)
|
@DecimalMin(value = "0", inclusive = false)
|
||||||
@Digits(integer = 20, fraction = 5)
|
@Digits(integer = 20, fraction = 5)
|
||||||
protected BigDecimal precioUnitario;
|
private BigDecimal precioUnitario;
|
||||||
@XmlElement(required = true, nillable = true)
|
@XmlElement(required = true, nillable = true)
|
||||||
@DecimalMin(value = "0", inclusive = true)
|
@DecimalMin(value = "0", inclusive = true)
|
||||||
@Digits(integer = 20, fraction = 5)
|
@Digits(integer = 20, fraction = 5)
|
||||||
protected BigDecimal montoDescuento;
|
private BigDecimal montoDescuento;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "0", inclusive = false)
|
@DecimalMin(value = "0", inclusive = false)
|
||||||
@Digits(integer = 20, fraction = 5)
|
@Digits(integer = 20, fraction = 5)
|
||||||
protected BigDecimal subTotal;
|
private BigDecimal subTotal;
|
||||||
}
|
}
|
||||||
|
@ -15,20 +15,20 @@ public class TotalesDTO {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "0", inclusive = false)
|
@DecimalMin(value = "0", inclusive = false)
|
||||||
@Digits(integer = 17, fraction = 2)
|
@Digits(integer = 17, fraction = 2)
|
||||||
protected BigDecimal montoTotal;
|
private BigDecimal montoTotal;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
protected BigDecimal montoTotalSujetoIva;
|
private BigDecimal montoTotalSujetoIva;
|
||||||
@XmlElement(required = true)
|
@XmlElement(required = true)
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "0", inclusive = false)
|
@DecimalMin(value = "0", inclusive = false)
|
||||||
@Digits(integer = 17, fraction = 2)
|
@Digits(integer = 17, fraction = 2)
|
||||||
protected BigDecimal montoTotalMoneda;
|
private BigDecimal montoTotalMoneda;
|
||||||
@XmlElement(required = true, nillable = true)
|
@XmlElement(required = true, nillable = true)
|
||||||
@Size(min = 1, max = 10000)
|
@Size(min = 1, max = 10000)
|
||||||
protected String informacionAdicional;
|
private String informacionAdicional;
|
||||||
@XmlElement(required = true, nillable = true)
|
@XmlElement(required = true, nillable = true)
|
||||||
@DecimalMin(value = "0", inclusive = true)
|
@DecimalMin(value = "0", inclusive = true)
|
||||||
@Digits(integer = 17, fraction = 2)
|
@Digits(integer = 17, fraction = 2)
|
||||||
protected BigDecimal descuentoAdicional;
|
private BigDecimal descuentoAdicional;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public class ApplicationReadyListener implements ApplicationListener<Application
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void onApplicationEvent(ApplicationReadyEvent event) {
|
public void onApplicationEvent(final ApplicationReadyEvent event) {
|
||||||
var indexed = new Class[]{Client.class, Product.class};
|
var indexed = new Class[]{Client.class, Product.class};
|
||||||
log.info("Indexing tables {}", Arrays.stream(indexed).toList());
|
log.info("Indexing tables {}", Arrays.stream(indexed).toList());
|
||||||
SearchSession searchSession = Search.session(entityManager);
|
SearchSession searchSession = Search.session(entityManager);
|
||||||
|
@ -17,7 +17,7 @@ import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
|||||||
public class SecurityConfig extends VaadinWebSecurity {
|
public class SecurityConfig extends VaadinWebSecurity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(final HttpSecurity http) throws Exception {
|
||||||
http.authorizeHttpRequests(auth ->
|
http.authorizeHttpRequests(auth ->
|
||||||
auth.requestMatchers(
|
auth.requestMatchers(
|
||||||
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/images/*.png")).permitAll());
|
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/images/*.png")).permitAll());
|
||||||
|
@ -22,7 +22,7 @@ public abstract class AbstractEntity {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(UUID id) {
|
public void setId(final UUID id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public abstract class AbstractEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (!(obj instanceof AbstractEntity that)) {
|
if (!(obj instanceof AbstractEntity that)) {
|
||||||
return false; // null or not an AbstractEntity class
|
return false; // null or not an AbstractEntity class
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,9 @@ public class Branch extends AbstractEntity {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "0", inclusive = true)
|
@DecimalMin(value = "0", inclusive = true)
|
||||||
@DecimalMax(value = "9999", inclusive = true)
|
@DecimalMax(value = "9999", inclusive = true)
|
||||||
protected int codigoSucursal;
|
private int codigoSucursal;
|
||||||
|
|
||||||
protected String cuis;
|
private String cuis;
|
||||||
|
|
||||||
protected String description;
|
private String description;
|
||||||
}
|
}
|
||||||
|
@ -37,37 +37,37 @@ public class Client extends AbstractEntity {
|
|||||||
@XmlElement(required = true, nillable = true)
|
@XmlElement(required = true, nillable = true)
|
||||||
@Size(min = 1, max = 500)
|
@Size(min = 1, max = 500)
|
||||||
@FullTextField
|
@FullTextField
|
||||||
protected String nombreRazonSocial;
|
private String nombreRazonSocial;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "5", inclusive = true)
|
@DecimalMax(value = "5", inclusive = true)
|
||||||
protected int codigoTipoDocumentoIdentidad;
|
private int codigoTipoDocumentoIdentidad;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 20)
|
@Size(min = 1, max = 20)
|
||||||
protected String numeroDocumento;
|
private String numeroDocumento;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 500)
|
@Size(min = 1, max = 500)
|
||||||
protected String direccionComprador;
|
private String direccionComprador;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 100)
|
@Size(min = 1, max = 100)
|
||||||
protected String codigoCliente;
|
private String codigoCliente;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "212", inclusive = true)
|
@DecimalMax(value = "212", inclusive = true)
|
||||||
protected int codigoPais;
|
private int codigoPais;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "308", inclusive = true)
|
@DecimalMax(value = "308", inclusive = true)
|
||||||
protected int codigoMetodoPago;
|
private int codigoMetodoPago;
|
||||||
|
|
||||||
@DecimalMin(value = "0", inclusive = true)
|
@DecimalMin(value = "0", inclusive = true)
|
||||||
@DecimalMax(value = "9999999999999999", inclusive = true)
|
@DecimalMax(value = "9999999999999999", inclusive = true)
|
||||||
protected Long numeroTarjeta;
|
private Long numeroTarjeta;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,22 +17,22 @@ public class Company extends AbstractEntity {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "9999999999999", inclusive = true)
|
@DecimalMax(value = "9999999999999", inclusive = true)
|
||||||
protected long nitEmisor;
|
private long nitEmisor;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 200)
|
@Size(min = 1, max = 200)
|
||||||
protected String razonSocialEmisor;
|
private String razonSocialEmisor;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 25)
|
@Size(min = 1, max = 25)
|
||||||
protected String municipio;
|
private String municipio;
|
||||||
|
|
||||||
@Size(min = 1, max = 25)
|
@Size(min = 1, max = 25)
|
||||||
protected String telefono;
|
private String telefono;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 500)
|
@Size(min = 1, max = 500)
|
||||||
protected String direccion;
|
private String direccion;
|
||||||
|
|
||||||
@Type(JsonType.class)
|
@Type(JsonType.class)
|
||||||
@Column(columnDefinition = "json")
|
@Column(columnDefinition = "json")
|
||||||
|
@ -14,7 +14,7 @@ import java.util.UUID;
|
|||||||
@Entity
|
@Entity
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
public class Event extends AbstractEntity{
|
public class Event extends AbstractEntity {
|
||||||
private UUID userId;
|
private UUID userId;
|
||||||
private UUID entityId;
|
private UUID entityId;
|
||||||
private Instant timestamp;
|
private Instant timestamp;
|
||||||
|
@ -6,7 +6,6 @@ import jakarta.persistence.Entity;
|
|||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.validation.constraints.*;
|
import jakarta.validation.constraints.*;
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.hibernate.annotations.Type;
|
import org.hibernate.annotations.Type;
|
||||||
@ -27,10 +26,10 @@ public class Invoice extends AbstractEntity {
|
|||||||
private InvoiceStatus status;
|
private InvoiceStatus status;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
protected LocalDateTime fechaEmision;
|
private LocalDateTime fechaEmision;
|
||||||
|
|
||||||
@Size(min = 1, max = 500)
|
@Size(min = 1, max = 500)
|
||||||
protected String nombreRazonSocial;
|
private String nombreRazonSocial;
|
||||||
|
|
||||||
@Type(JsonType.class)
|
@Type(JsonType.class)
|
||||||
@Column(columnDefinition = "json")
|
@Column(columnDefinition = "json")
|
||||||
|
@ -4,7 +4,6 @@ import io.hypersistence.utils.hibernate.type.json.JsonType;
|
|||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.hibernate.annotations.Type;
|
import org.hibernate.annotations.Type;
|
||||||
@ -14,7 +13,7 @@ import java.util.Map;
|
|||||||
@Entity
|
@Entity
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
public class Media extends AbstractEntity{
|
public class Media extends AbstractEntity {
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -21,17 +21,17 @@ public class PointOfSale extends AbstractEntity {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "0", inclusive = true)
|
@DecimalMin(value = "0", inclusive = true)
|
||||||
@DecimalMax(value = "9999", inclusive = true)
|
@DecimalMax(value = "9999", inclusive = true)
|
||||||
protected int codigoSucursal;
|
private int codigoSucursal;
|
||||||
|
|
||||||
@DecimalMin(value = "0", inclusive = true)
|
@DecimalMin(value = "0", inclusive = true)
|
||||||
@DecimalMax(value = "9999", inclusive = true)
|
@DecimalMax(value = "9999", inclusive = true)
|
||||||
protected Integer codigoPuntoVenta;
|
private Integer codigoPuntoVenta;
|
||||||
|
|
||||||
protected POSType codigoTipoPuntoVenta;
|
private POSType codigoTipoPuntoVenta;
|
||||||
|
|
||||||
protected String cuis;
|
private String cuis;
|
||||||
|
|
||||||
protected String description;
|
private String description;
|
||||||
|
|
||||||
protected String nombrePuntoVenta;
|
private String nombrePuntoVenta;
|
||||||
}
|
}
|
||||||
|
@ -19,25 +19,25 @@ public class Product extends AbstractEntity {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "99999999", inclusive = true)
|
@DecimalMax(value = "99999999", inclusive = true)
|
||||||
protected int codigoProductoSin;
|
private int codigoProductoSin;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 50)
|
@Size(min = 1, max = 50)
|
||||||
protected String codigoProducto;
|
private String codigoProducto;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = 1, max = 500)
|
@Size(min = 1, max = 500)
|
||||||
protected String descripcion;
|
private String descripcion;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "1", inclusive = true)
|
@DecimalMin(value = "1", inclusive = true)
|
||||||
@DecimalMax(value = "200", inclusive = true)
|
@DecimalMax(value = "200", inclusive = true)
|
||||||
protected int unidadMedida;
|
private int unidadMedida;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@DecimalMin(value = "0", inclusive = false)
|
@DecimalMin(value = "0", inclusive = false)
|
||||||
@Digits(integer = 20, fraction = 5)
|
@Digits(integer = 20, fraction = 5)
|
||||||
protected BigDecimal precioUnitario;
|
private BigDecimal precioUnitario;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "company_id")
|
@JoinColumn(name = "company_id")
|
||||||
|
@ -14,7 +14,7 @@ import java.util.Map;
|
|||||||
@Entity
|
@Entity
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
public class Task extends AbstractEntity{
|
public class Task extends AbstractEntity {
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private BigInteger nitEmisor;
|
private BigInteger nitEmisor;
|
||||||
|
@ -5,10 +5,11 @@ import com.primefactorsolutions.invoices.xsd.FacturaComputarizadaComercialExport
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FacturaComputarizadaComercialExportacionServicioValidator implements InvoiceValidator<FacturaComputarizadaComercialExportacionServicio> {
|
public class FacturaComputarizadaComercialExportacionServicioValidator
|
||||||
|
implements InvoiceValidator<FacturaComputarizadaComercialExportacionServicio> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ValidationError> validate(FacturaComputarizadaComercialExportacionServicio invoice) {
|
public List<ValidationError> validate(final FacturaComputarizadaComercialExportacionServicio invoice) {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ public class SecurityService {
|
|||||||
|
|
||||||
private final AuthenticationContext authenticationContext;
|
private final AuthenticationContext authenticationContext;
|
||||||
|
|
||||||
public SecurityService(AuthenticationContext authenticationContext) {
|
public SecurityService(final AuthenticationContext authenticationContext) {
|
||||||
this.authenticationContext = authenticationContext;
|
this.authenticationContext = authenticationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,12 +26,12 @@ public class ClientService {
|
|||||||
private final CompanyService companyService;
|
private final CompanyService companyService;
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<Client> findAllClients(String code) {
|
public List<Client> findAllClients(final String code) {
|
||||||
return findAllClients(code, PageRequest.of(0, 25));
|
return findAllClients(code, PageRequest.of(0, 25));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<Client> findAllClients(String code, PageRequest of) {
|
public List<Client> findAllClients(final String code, final PageRequest of) {
|
||||||
if (Strings.isBlank(code)) {
|
if (Strings.isBlank(code)) {
|
||||||
return clientRepository.findAll();
|
return clientRepository.findAll();
|
||||||
}
|
}
|
||||||
@ -50,14 +50,14 @@ public class ClientService {
|
|||||||
return result.hits();
|
return result.hits();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveOrUpdateClient(Client updatedClient) {
|
public void saveOrUpdateClient(final Client updatedClient) {
|
||||||
updatedClient.setCompany(companyService.getCompany());
|
updatedClient.setCompany(companyService.getCompany());
|
||||||
updatedClient.setStatus(Status.ACTIVE);
|
updatedClient.setStatus(Status.ACTIVE);
|
||||||
|
|
||||||
clientRepository.save(updatedClient);
|
clientRepository.save(updatedClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Client getClient(UUID uuid) {
|
public Client getClient(final UUID uuid) {
|
||||||
return clientRepository.findById(uuid)
|
return clientRepository.findById(uuid)
|
||||||
.orElseThrow(() -> new IllegalArgumentException("Client not found"));
|
.orElseThrow(() -> new IllegalArgumentException("Client not found"));
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import java.util.Locale;
|
|||||||
public class ComponentBuilder {
|
public class ComponentBuilder {
|
||||||
private final I18NProvider i18NProvider;
|
private final I18NProvider i18NProvider;
|
||||||
|
|
||||||
public ButtonBuilder button(String text) {
|
public ButtonBuilder button(final String text) {
|
||||||
return ButtonBuilder.builder().i18NProvider(i18NProvider).text(text);
|
return ButtonBuilder.builder().i18NProvider(i18NProvider).text(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,12 +42,12 @@ public class ComponentBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ButtonBuilder i18NProvider(I18NProvider i18NProvider) {
|
public ButtonBuilder i18NProvider(final I18NProvider i18NProvider) {
|
||||||
this.setI18NProvider(i18NProvider);
|
this.setI18NProvider(i18NProvider);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ButtonBuilder text(String text) {
|
public ButtonBuilder text(final String text) {
|
||||||
this.setText(text);
|
this.setText(text);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,11 @@ import freemarker.template.Template;
|
|||||||
import freemarker.template.TemplateExceptionHandler;
|
import freemarker.template.TemplateExceptionHandler;
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.apache.pdfbox.io.MemoryUsageSetting;
|
import org.apache.pdfbox.io.MemoryUsageSetting;
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@ -34,6 +36,7 @@ import java.util.TimeZone;
|
|||||||
@Data
|
@Data
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class InvoiceService {
|
public class InvoiceService {
|
||||||
|
@Getter
|
||||||
private final Help help;
|
private final Help help;
|
||||||
private final InvoiceRepository invoiceRepository;
|
private final InvoiceRepository invoiceRepository;
|
||||||
private final MediaRepository mediaRepository;
|
private final MediaRepository mediaRepository;
|
||||||
@ -45,9 +48,9 @@ public class InvoiceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void sendInvoice(FacturaComputarizadaComercialExportacionServicio factura) {
|
public void sendInvoice(final FacturaComputarizadaComercialExportacionServicio factura) {
|
||||||
|
|
||||||
try(var os = new ByteArrayOutputStream()) {
|
try (var os = new ByteArrayOutputStream()) {
|
||||||
writeAsPdf(factura, os);
|
writeAsPdf(factura, os);
|
||||||
var media = new Media();
|
var media = new Media();
|
||||||
media.setName("factura.pdf");
|
media.setName("factura.pdf");
|
||||||
@ -82,19 +85,10 @@ public class InvoiceService {
|
|||||||
return Invoice.class.getResourceAsStream("/pfs-invoice.html");
|
return Invoice.class.getResourceAsStream("/pfs-invoice.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeAsPdf(FacturaComputarizadaComercialExportacionServicio factura, OutputStream out) {
|
public void writeAsPdf(final FacturaComputarizadaComercialExportacionServicio factura, final OutputStream out) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var in = getTemplate();
|
var in = getTemplate();
|
||||||
Configuration cfg = new Configuration(Configuration.VERSION_2_3_32);
|
Configuration cfg = getConfiguration();
|
||||||
// cfg.setDirectoryForTemplateLoading(new File("/where/you/store/templates"));
|
|
||||||
// Recommended settings for new projects:
|
|
||||||
cfg.setDefaultEncoding("UTF-8");
|
|
||||||
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
|
|
||||||
cfg.setLogTemplateExceptions(false);
|
|
||||||
cfg.setWrapUncheckedExceptions(true);
|
|
||||||
cfg.setFallbackOnNullLoopVariable(false);
|
|
||||||
cfg.setSQLDateAndTimeTimeZone(TimeZone.getDefault());
|
|
||||||
|
|
||||||
Reader reader = new InputStreamReader(in);
|
Reader reader = new InputStreamReader(in);
|
||||||
Template temp = new Template("pfs-invoice", reader, cfg);
|
Template temp = new Template("pfs-invoice", reader, cfg);
|
||||||
@ -119,7 +113,17 @@ public class InvoiceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Help getHelp() {
|
@NotNull
|
||||||
return help;
|
private static Configuration getConfiguration() {
|
||||||
|
Configuration cfg = new Configuration(Configuration.VERSION_2_3_32);
|
||||||
|
// cfg.setDirectoryForTemplateLoading(new File("/where/you/store/templates"));
|
||||||
|
// Recommended settings for new projects:
|
||||||
|
cfg.setDefaultEncoding("UTF-8");
|
||||||
|
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
|
||||||
|
cfg.setLogTemplateExceptions(false);
|
||||||
|
cfg.setWrapUncheckedExceptions(true);
|
||||||
|
cfg.setFallbackOnNullLoopVariable(false);
|
||||||
|
cfg.setSQLDateAndTimeTimeZone(TimeZone.getDefault());
|
||||||
|
return cfg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,15 @@ import java.util.List;
|
|||||||
public class MediaService {
|
public class MediaService {
|
||||||
private final MediaRepository mediaRepository;
|
private final MediaRepository mediaRepository;
|
||||||
|
|
||||||
public Media findMedia(String name) {
|
public Media findMedia(final String name) {
|
||||||
return mediaRepository.findAll().stream().findFirst().get();
|
return mediaRepository.findAll().stream().findFirst().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Media> findAllMedia(String name) {
|
public List<Media> findAllMedia(final String name) {
|
||||||
return mediaRepository.findByNameLike(name);
|
return mediaRepository.findByNameLike(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveMedia(Media media) {
|
public void saveMedia(final Media media) {
|
||||||
mediaRepository.save(media);
|
mediaRepository.save(media);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,18 +15,18 @@ public class ProductService {
|
|||||||
private final ProductRepository productRepository;
|
private final ProductRepository productRepository;
|
||||||
private final CompanyService companyService;
|
private final CompanyService companyService;
|
||||||
|
|
||||||
public List<Product> findAllProducts(String name) {
|
public List<Product> findAllProducts(final String name) {
|
||||||
return productRepository.findAll();
|
return productRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveOrUpdateProduct(Product product) {
|
public void saveOrUpdateProduct(final Product product) {
|
||||||
var company = companyService.getCompany();
|
var company = companyService.getCompany();
|
||||||
product.setCompany(company);
|
product.setCompany(company);
|
||||||
product.setStatus(Status.ACTIVE);
|
product.setStatus(Status.ACTIVE);
|
||||||
productRepository.save(product);
|
productRepository.save(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Product getProduct(UUID uuid) {
|
public Product getProduct(final UUID uuid) {
|
||||||
return productRepository.findById(uuid).get();
|
return productRepository.findById(uuid).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,15 +19,15 @@ public class UserService implements UserDetailsService {
|
|||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final CompanyService companyService;
|
private final CompanyService companyService;
|
||||||
|
|
||||||
public List<User> findAllUsers(String code) {
|
public List<User> findAllUsers(final String code) {
|
||||||
return userRepository.findAll();
|
return userRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUser(UUID id) {
|
public User getUser(final UUID id) {
|
||||||
return userRepository.findById(id).get();
|
return userRepository.findById(id).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveOrUpdateUser(User updatedUser) {
|
public void saveOrUpdateUser(final User updatedUser) {
|
||||||
if (updatedUser.getId() == null) {
|
if (updatedUser.getId() == null) {
|
||||||
var company = companyService.getCompany();
|
var company = companyService.getCompany();
|
||||||
updatedUser.setCompany(company);
|
updatedUser.setCompany(company);
|
||||||
@ -39,7 +39,7 @@ public class UserService implements UserDetailsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException {
|
||||||
return userRepository.getByEmail(username);
|
return userRepository.getByEmail(username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import lombok.experimental.UtilityClass;
|
|||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class UiUtils {
|
public class UiUtils {
|
||||||
public static void goTo(Component component, String location) {
|
public static void goTo(final Component component, final String location) {
|
||||||
component.getUI().ifPresent(ui -> ui.navigate(location));
|
component.getUI().ifPresent(ui -> ui.navigate(location));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,18 +30,23 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
|||||||
@PageTitle("Client | PFS Facturacion")
|
@PageTitle("Client | PFS Facturacion")
|
||||||
public class ClientEditView extends VerticalLayout implements HasUrlParameter<String> {
|
public class ClientEditView extends VerticalLayout implements HasUrlParameter<String> {
|
||||||
|
|
||||||
ClientService clientService;
|
private final ClientService clientService;
|
||||||
I18NProvider i18NProvider;
|
private final I18NProvider i18NProvider;
|
||||||
ComponentBuilder componentBuilder;
|
private final ComponentBuilder componentBuilder;
|
||||||
GenericForm<Client> clientGenericForm;
|
private GenericForm<Client> clientGenericForm;
|
||||||
|
|
||||||
public ClientEditView(ClientService clientService, I18NProvider i18NProvider, ComponentBuilder componentBuilder) {
|
public ClientEditView(final ClientService clientService,
|
||||||
|
final I18NProvider i18NProvider,
|
||||||
|
final ComponentBuilder componentBuilder) {
|
||||||
this.clientService = clientService;
|
this.clientService = clientService;
|
||||||
this.i18NProvider = i18NProvider;
|
this.i18NProvider = i18NProvider;
|
||||||
this.componentBuilder = componentBuilder;
|
this.componentBuilder = componentBuilder;
|
||||||
|
|
||||||
var client = new Client();
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
|
var client = new Client();
|
||||||
this.clientGenericForm = new GenericForm<>(Client.class);
|
this.clientGenericForm = new GenericForm<>(Client.class);
|
||||||
this.clientGenericForm.setBean(client);
|
this.clientGenericForm.setBean(client);
|
||||||
|
|
||||||
@ -61,7 +66,7 @@ public class ClientEditView extends VerticalLayout implements HasUrlParameter<St
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParameter(BeforeEvent beforeEvent, String s) {
|
public void setParameter(final BeforeEvent beforeEvent, final String s) {
|
||||||
if (StringUtils.isNotBlank(s) && !"new".equals(s)) {
|
if (StringUtils.isNotBlank(s) && !"new".equals(s)) {
|
||||||
var product = clientService.getClient(UUID.fromString(s));
|
var product = clientService.getClient(UUID.fromString(s));
|
||||||
clientGenericForm.setBean(product);
|
clientGenericForm.setBean(product);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.primefactorsolutions.invoices.views;
|
package com.primefactorsolutions.invoices.views;
|
||||||
|
|
||||||
import com.primefactorsolutions.invoices.model.Client;
|
import com.primefactorsolutions.invoices.model.Client;
|
||||||
import com.primefactorsolutions.invoices.model.InvoiceType;
|
|
||||||
import com.primefactorsolutions.invoices.model.Status;
|
import com.primefactorsolutions.invoices.model.Status;
|
||||||
import com.primefactorsolutions.invoices.services.ClientService;
|
import com.primefactorsolutions.invoices.services.ClientService;
|
||||||
import com.vaadin.flow.component.Component;
|
import com.vaadin.flow.component.Component;
|
||||||
@ -29,12 +28,16 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
|||||||
@Route(value = "clients", layout = MainLayout.class)
|
@Route(value = "clients", layout = MainLayout.class)
|
||||||
@PageTitle("Facturas | PFS Facturacion")
|
@PageTitle("Facturas | PFS Facturacion")
|
||||||
public class ClientListView extends VerticalLayout {
|
public class ClientListView extends VerticalLayout {
|
||||||
PagingGrid<Client> grid = new PagingGrid<>(Client.class);
|
private final ClientService clientService;
|
||||||
TextField filterText = new TextField();
|
private final PagingGrid<Client> grid = new PagingGrid<>(Client.class);
|
||||||
ClientService clientService;
|
private final TextField filterText = new TextField();
|
||||||
|
|
||||||
public ClientListView(ClientService clientService) {
|
public ClientListView(final ClientService clientService) {
|
||||||
this.clientService = clientService;
|
this.clientService = clientService;
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
addClassName("pfs-list-view");
|
addClassName("pfs-list-view");
|
||||||
setSizeFull();
|
setSizeFull();
|
||||||
configureGrid();
|
configureGrid();
|
||||||
|
@ -8,7 +8,6 @@ import com.primefactorsolutions.invoices.views.component.GenericForm;
|
|||||||
import com.vaadin.flow.component.Component;
|
import com.vaadin.flow.component.Component;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.button.ButtonVariant;
|
import com.vaadin.flow.component.button.ButtonVariant;
|
||||||
import com.vaadin.flow.component.formlayout.FormLayout;
|
|
||||||
import com.vaadin.flow.component.html.H4;
|
import com.vaadin.flow.component.html.H4;
|
||||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
@ -18,14 +17,11 @@ import com.vaadin.flow.router.PageTitle;
|
|||||||
import com.vaadin.flow.router.Route;
|
import com.vaadin.flow.router.Route;
|
||||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||||
import jakarta.annotation.security.PermitAll;
|
import jakarta.annotation.security.PermitAll;
|
||||||
import org.checkerframework.checker.units.qual.C;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.vaadin.firitin.components.textfield.VBigDecimalField;
|
|
||||||
import org.vaadin.firitin.fields.ElementCollectionField;
|
import org.vaadin.firitin.fields.ElementCollectionField;
|
||||||
import org.vaadin.firitin.fields.EnumSelect;
|
import org.vaadin.firitin.fields.EnumSelect;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
||||||
@ -37,21 +33,27 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
|||||||
@PageTitle("Compania | PFS Facturacion")
|
@PageTitle("Compania | PFS Facturacion")
|
||||||
public class CompanyEditView extends VerticalLayout {
|
public class CompanyEditView extends VerticalLayout {
|
||||||
|
|
||||||
CompanyService companyService;
|
private CompanyService companyService;
|
||||||
|
private I18NProvider i18NProvider;
|
||||||
|
|
||||||
public CompanyEditView(CompanyService companyService, I18NProvider i18NProvider) {
|
public CompanyEditView(final CompanyService companyService, final I18NProvider i18NProvider) {
|
||||||
this.companyService = companyService;
|
this.companyService = companyService;
|
||||||
|
this.i18NProvider = i18NProvider;
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
var company = this.companyService.getCompany();
|
var company = this.companyService.getCompany();
|
||||||
|
|
||||||
var companyGenericForm = new GenericForm<>(Company.class);
|
var companyGenericForm = new GenericForm<>(Company.class);
|
||||||
companyGenericForm.setBean(company);
|
companyGenericForm.setBean(company);
|
||||||
|
|
||||||
String text = i18NProvider.getTranslation("action.save", Locale.of("es"));
|
String text = this.i18NProvider.getTranslation("action.save", Locale.of("es"));
|
||||||
var saveButton = new Button(text);
|
var saveButton = new Button(text);
|
||||||
saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||||
saveButton.addClickListener(c -> {
|
saveButton.addClickListener(c -> {
|
||||||
var updatedCompany = companyGenericForm.getBean();
|
var updatedCompany = companyGenericForm.getBean();
|
||||||
companyService.saveOrUpdateCompany(updatedCompany);
|
this.companyService.saveOrUpdateCompany(updatedCompany);
|
||||||
});
|
});
|
||||||
var cancelButton = new Button("Cancel");
|
var cancelButton = new Button("Cancel");
|
||||||
cancelButton.addClickListener(c -> goTo(this, ""));
|
cancelButton.addClickListener(c -> goTo(this, ""));
|
||||||
@ -68,19 +70,21 @@ public class CompanyEditView extends VerticalLayout {
|
|||||||
|
|
||||||
|
|
||||||
private Component getCurrencyForm() {
|
private Component getCurrencyForm() {
|
||||||
ElementCollectionField<CurrencyPair> field = new ElementCollectionField<>(CurrencyPair.class, CurrencyEditor.class)
|
ElementCollectionField<CurrencyPair> field =
|
||||||
|
new ElementCollectionField<>(CurrencyPair.class, CurrencyEditor.class)
|
||||||
.withEditorInstantiator(CurrencyEditor::new);
|
.withEditorInstantiator(CurrencyEditor::new);
|
||||||
|
|
||||||
var cp = new CurrencyPair(CurrencyPair.CurrencyType.BOB, CurrencyPair.CurrencyType.USD, BigDecimal.valueOf(7.0), BigDecimal.valueOf(6.97));
|
var cp = new CurrencyPair(CurrencyPair.CurrencyType.BOB, CurrencyPair.CurrencyType.USD,
|
||||||
|
BigDecimal.valueOf(7.0), BigDecimal.valueOf(6.97));
|
||||||
field.setValue(Lists.newArrayList(cp));
|
field.setValue(Lists.newArrayList(cp));
|
||||||
|
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CurrencyEditor {
|
public static class CurrencyEditor {
|
||||||
EnumSelect<CurrencyPair.CurrencyType> base = new EnumSelect<>(CurrencyPair.CurrencyType.class);
|
private final EnumSelect<CurrencyPair.CurrencyType> base = new EnumSelect<>(CurrencyPair.CurrencyType.class);
|
||||||
EnumSelect<CurrencyPair.CurrencyType> quote = new EnumSelect<>(CurrencyPair.CurrencyType.class);
|
private final EnumSelect<CurrencyPair.CurrencyType> quote = new EnumSelect<>(CurrencyPair.CurrencyType.class);
|
||||||
BigDecimalField bid = new BigDecimalField();
|
private final BigDecimalField bid = new BigDecimalField();
|
||||||
BigDecimalField ask = new BigDecimalField();
|
private final BigDecimalField ask = new BigDecimalField();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.primefactorsolutions.invoices.views;
|
package com.primefactorsolutions.invoices.views;
|
||||||
|
|
||||||
|
|
||||||
import com.vaadin.flow.component.ScrollOptions;
|
|
||||||
import com.vaadin.flow.component.Text;
|
import com.vaadin.flow.component.Text;
|
||||||
import com.vaadin.flow.component.UI;
|
import com.vaadin.flow.component.UI;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
@ -14,22 +12,21 @@ import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
|||||||
import com.vaadin.flow.server.ErrorEvent;
|
import com.vaadin.flow.server.ErrorEvent;
|
||||||
import com.vaadin.flow.server.ErrorHandler;
|
import com.vaadin.flow.server.ErrorHandler;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.aspectj.weaver.ast.Not;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class CustomErrorHandler implements ErrorHandler {
|
public class CustomErrorHandler implements ErrorHandler {
|
||||||
@Override
|
@Override
|
||||||
public void error(ErrorEvent errorEvent) {
|
public void error(final ErrorEvent errorEvent) {
|
||||||
log.error("Something wrong happened", errorEvent.getThrowable());
|
log.error("Something wrong happened", errorEvent.getThrowable());
|
||||||
if(UI.getCurrent() != null) {
|
if (UI.getCurrent() != null) {
|
||||||
UI.getCurrent().access(() -> {
|
UI.getCurrent().access(() -> {
|
||||||
var notification = new Notification();
|
var notification = new Notification();
|
||||||
notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
|
notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
|
||||||
notification.setPosition(Notification.Position.TOP_CENTER);
|
notification.setPosition(Notification.Position.TOP_CENTER);
|
||||||
notification.setDuration(0);
|
notification.setDuration(0);
|
||||||
var layout = new HorizontalLayout(new Text("An internal error has occurred." +
|
var layout = new HorizontalLayout(
|
||||||
"Contact support for assistance."), new CloseButton());
|
new Text("An internal error has occurred. Contact support for assistance."),
|
||||||
|
new CloseButton());
|
||||||
layout.setAlignItems(FlexComponent.Alignment.CENTER);
|
layout.setAlignItems(FlexComponent.Alignment.CENTER);
|
||||||
notification.add(layout);
|
notification.add(layout);
|
||||||
notification.open();
|
notification.open();
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.primefactorsolutions.invoices.views;
|
package com.primefactorsolutions.invoices.views;
|
||||||
|
|
||||||
|
|
||||||
import com.vaadin.flow.server.ServiceInitEvent;
|
import com.vaadin.flow.server.ServiceInitEvent;
|
||||||
import com.vaadin.flow.server.VaadinServiceInitListener;
|
import com.vaadin.flow.server.VaadinServiceInitListener;
|
||||||
import com.vaadin.flow.server.VaadinSession;
|
import com.vaadin.flow.server.VaadinSession;
|
||||||
@ -12,7 +11,7 @@ import org.springframework.stereotype.Component;
|
|||||||
public class InitListener implements VaadinServiceInitListener {
|
public class InitListener implements VaadinServiceInitListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serviceInit(ServiceInitEvent event) {
|
public void serviceInit(final ServiceInitEvent event) {
|
||||||
event.getSource().addSessionInitListener(
|
event.getSource().addSessionInitListener(
|
||||||
initEvent -> {
|
initEvent -> {
|
||||||
log.info("A new Session has been initialized!");
|
log.info("A new Session has been initialized!");
|
||||||
|
@ -30,14 +30,16 @@ import java.util.List;
|
|||||||
@Route(value = "", layout = MainLayout.class)
|
@Route(value = "", layout = MainLayout.class)
|
||||||
@PageTitle("Facturas | PFS Facturacion")
|
@PageTitle("Facturas | PFS Facturacion")
|
||||||
public class InvoiceListView extends VerticalLayout {
|
public class InvoiceListView extends VerticalLayout {
|
||||||
PagingGrid<Invoice> grid = new PagingGrid<>(Invoice.class);
|
private final InvoiceService invoiceService;
|
||||||
|
private final PagingGrid<Invoice> grid = new PagingGrid<>(Invoice.class);
|
||||||
|
private final TextField filterText = new TextField();
|
||||||
|
|
||||||
TextField filterText = new TextField();
|
public InvoiceListView(final InvoiceService invoiceService) {
|
||||||
|
|
||||||
InvoiceService invoiceService;
|
|
||||||
|
|
||||||
public InvoiceListView(InvoiceService invoiceService) {
|
|
||||||
this.invoiceService = invoiceService;
|
this.invoiceService = invoiceService;
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
addClassName("list-view");
|
addClassName("list-view");
|
||||||
setSizeFull();
|
setSizeFull();
|
||||||
configureGrid();
|
configureGrid();
|
||||||
|
@ -18,8 +18,14 @@ import java.io.ByteArrayInputStream;
|
|||||||
@Route(value = "invoice-pdf", layout = MainLayout.class)
|
@Route(value = "invoice-pdf", layout = MainLayout.class)
|
||||||
@PageTitle("Vista | PFS Facturacion")
|
@PageTitle("Vista | PFS Facturacion")
|
||||||
public class InvoicePdfView extends Div {
|
public class InvoicePdfView extends Div {
|
||||||
|
private final MediaService mediaService;
|
||||||
|
|
||||||
public InvoicePdfView(MediaService mediaService) {
|
public InvoicePdfView(final MediaService mediaService) {
|
||||||
|
this.mediaService = mediaService;
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
var media = mediaService.findMedia("foo.pdf");
|
var media = mediaService.findMedia("foo.pdf");
|
||||||
var content = media.getContent();
|
var content = media.getContent();
|
||||||
var pdfViewer = new PdfViewer();
|
var pdfViewer = new PdfViewer();
|
||||||
|
@ -16,7 +16,7 @@ public class LoginView extends VerticalLayout implements BeforeEnterObserver {
|
|||||||
|
|
||||||
private final LoginForm login = new LoginForm();
|
private final LoginForm login = new LoginForm();
|
||||||
|
|
||||||
public LoginView(){
|
public LoginView() {
|
||||||
addClassName("login-view");
|
addClassName("login-view");
|
||||||
setSizeFull();
|
setSizeFull();
|
||||||
setAlignItems(Alignment.CENTER);
|
setAlignItems(Alignment.CENTER);
|
||||||
@ -31,7 +31,7 @@ public class LoginView extends VerticalLayout implements BeforeEnterObserver {
|
|||||||
@Override
|
@Override
|
||||||
public void beforeEnter(final BeforeEnterEvent beforeEnterEvent) {
|
public void beforeEnter(final BeforeEnterEvent beforeEnterEvent) {
|
||||||
// inform the user about an authentication error
|
// inform the user about an authentication error
|
||||||
if(beforeEnterEvent.getLocation()
|
if (beforeEnterEvent.getLocation()
|
||||||
.getQueryParameters()
|
.getQueryParameters()
|
||||||
.getParameters()
|
.getParameters()
|
||||||
.containsKey("error")) {
|
.containsKey("error")) {
|
||||||
|
@ -15,7 +15,7 @@ import org.springframework.security.core.userdetails.UserDetails;
|
|||||||
public class MainLayout extends AppLayout {
|
public class MainLayout extends AppLayout {
|
||||||
private final SecurityService securityService;
|
private final SecurityService securityService;
|
||||||
|
|
||||||
public MainLayout(SecurityService securityService) {
|
public MainLayout(final SecurityService securityService) {
|
||||||
this.securityService = securityService;
|
this.securityService = securityService;
|
||||||
createHeader();
|
createHeader();
|
||||||
createDrawer();
|
createDrawer();
|
||||||
|
@ -18,7 +18,6 @@ import jakarta.annotation.security.PermitAll;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.vaadin.firitin.components.button.VButton;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -33,13 +32,17 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
|||||||
@PageTitle("Product | PFS Facturacion")
|
@PageTitle("Product | PFS Facturacion")
|
||||||
public class ProductEditView extends VerticalLayout implements HasUrlParameter<String> {
|
public class ProductEditView extends VerticalLayout implements HasUrlParameter<String> {
|
||||||
|
|
||||||
ProductService productService;
|
private final ProductService productService;
|
||||||
I18NProvider i18NProvider;
|
private final I18NProvider i18NProvider;
|
||||||
GenericForm<Product> productGenericForm;
|
private GenericForm<Product> productGenericForm;
|
||||||
|
|
||||||
public ProductEditView(ProductService productService, I18NProvider i18NProvider) {
|
public ProductEditView(final ProductService productService, final I18NProvider i18NProvider) {
|
||||||
this.productService = productService;
|
this.productService = productService;
|
||||||
this.i18NProvider = i18NProvider;
|
this.i18NProvider = i18NProvider;
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
var product = new Product();
|
var product = new Product();
|
||||||
|
|
||||||
this.productGenericForm = new GenericForm<>(Product.class);
|
this.productGenericForm = new GenericForm<>(Product.class);
|
||||||
@ -49,8 +52,8 @@ public class ProductEditView extends VerticalLayout implements HasUrlParameter<S
|
|||||||
var saveButton = new Button(text);
|
var saveButton = new Button(text);
|
||||||
saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||||
saveButton.addClickListener(c -> {
|
saveButton.addClickListener(c -> {
|
||||||
var updatedProduct = productGenericForm.getBean();
|
var updatedProduct = this.productGenericForm.getBean();
|
||||||
productService.saveOrUpdateProduct(updatedProduct);
|
this.productService.saveOrUpdateProduct(updatedProduct);
|
||||||
goTo(this, "products");
|
goTo(this, "products");
|
||||||
});
|
});
|
||||||
var cancelButton = new Button("Cancel");
|
var cancelButton = new Button("Cancel");
|
||||||
@ -63,7 +66,7 @@ public class ProductEditView extends VerticalLayout implements HasUrlParameter<S
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParameter(BeforeEvent beforeEvent, String s) {
|
public void setParameter(final BeforeEvent beforeEvent, final String s) {
|
||||||
if (StringUtils.isNotBlank(s) && !"new".equals(s)) {
|
if (StringUtils.isNotBlank(s) && !"new".equals(s)) {
|
||||||
var product = productService.getProduct(UUID.fromString(s));
|
var product = productService.getProduct(UUID.fromString(s));
|
||||||
productGenericForm.setBean(product);
|
productGenericForm.setBean(product);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.primefactorsolutions.invoices.views;
|
package com.primefactorsolutions.invoices.views;
|
||||||
|
|
||||||
import com.primefactorsolutions.invoices.model.InvoiceType;
|
|
||||||
import com.primefactorsolutions.invoices.model.Product;
|
import com.primefactorsolutions.invoices.model.Product;
|
||||||
import com.primefactorsolutions.invoices.model.Status;
|
import com.primefactorsolutions.invoices.model.Status;
|
||||||
import com.primefactorsolutions.invoices.services.ProductService;
|
import com.primefactorsolutions.invoices.services.ProductService;
|
||||||
@ -29,12 +28,16 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
|||||||
@Route(value = "products", layout = MainLayout.class)
|
@Route(value = "products", layout = MainLayout.class)
|
||||||
@PageTitle("Facturas | PFS Facturacion")
|
@PageTitle("Facturas | PFS Facturacion")
|
||||||
public class ProductListView extends VerticalLayout {
|
public class ProductListView extends VerticalLayout {
|
||||||
PagingGrid<Product> grid = new PagingGrid<>(Product.class);
|
private final ProductService productService;
|
||||||
TextField filterText = new TextField();
|
private final PagingGrid<Product> grid = new PagingGrid<>(Product.class);
|
||||||
ProductService productService;
|
private final TextField filterText = new TextField();
|
||||||
|
|
||||||
public ProductListView(ProductService productService) {
|
public ProductListView(final ProductService productService) {
|
||||||
this.productService = productService;
|
this.productService = productService;
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
addClassName("list-view");
|
addClassName("list-view");
|
||||||
setSizeFull();
|
setSizeFull();
|
||||||
configureGrid();
|
configureGrid();
|
||||||
|
@ -6,8 +6,6 @@ import com.primefactorsolutions.invoices.views.component.Breadcrumbs;
|
|||||||
import com.primefactorsolutions.invoices.views.component.GenericForm;
|
import com.primefactorsolutions.invoices.views.component.GenericForm;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.button.ButtonVariant;
|
import com.vaadin.flow.component.button.ButtonVariant;
|
||||||
import com.vaadin.flow.component.html.Anchor;
|
|
||||||
import com.vaadin.flow.component.html.Span;
|
|
||||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
import com.vaadin.flow.i18n.I18NProvider;
|
import com.vaadin.flow.i18n.I18NProvider;
|
||||||
@ -34,13 +32,17 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
|||||||
@PageTitle("User | PFS Facturacion")
|
@PageTitle("User | PFS Facturacion")
|
||||||
public class UserEditView extends VerticalLayout implements HasUrlParameter<String> {
|
public class UserEditView extends VerticalLayout implements HasUrlParameter<String> {
|
||||||
|
|
||||||
UserService userService;
|
private final UserService userService;
|
||||||
I18NProvider i18NProvider;
|
private final I18NProvider i18NProvider;
|
||||||
GenericForm<User> userGenericForm;
|
private GenericForm<User> userGenericForm;
|
||||||
|
|
||||||
public UserEditView(UserService userService, I18NProvider i18NProvider) {
|
public UserEditView(final UserService userService, final I18NProvider i18NProvider) {
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.i18NProvider = i18NProvider;
|
this.i18NProvider = i18NProvider;
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
var user = new User();
|
var user = new User();
|
||||||
|
|
||||||
this.userGenericForm = new GenericForm<>(User.class);
|
this.userGenericForm = new GenericForm<>(User.class);
|
||||||
@ -50,8 +52,8 @@ public class UserEditView extends VerticalLayout implements HasUrlParameter<Stri
|
|||||||
var saveButton = new Button(text);
|
var saveButton = new Button(text);
|
||||||
saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||||
saveButton.addClickListener(c -> {
|
saveButton.addClickListener(c -> {
|
||||||
var updatedUser = userGenericForm.getBean();
|
var updatedUser = this.userGenericForm.getBean();
|
||||||
userService.saveOrUpdateUser(updatedUser);
|
this.userService.saveOrUpdateUser(updatedUser);
|
||||||
goTo(this, "users");
|
goTo(this, "users");
|
||||||
});
|
});
|
||||||
var cancelButton = new Button("Cancel");
|
var cancelButton = new Button("Cancel");
|
||||||
@ -66,7 +68,7 @@ public class UserEditView extends VerticalLayout implements HasUrlParameter<Stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParameter(BeforeEvent beforeEvent, String s) {
|
public void setParameter(final BeforeEvent beforeEvent, final String s) {
|
||||||
if (StringUtils.isNotBlank(s) && !"new".equals(s)) {
|
if (StringUtils.isNotBlank(s) && !"new".equals(s)) {
|
||||||
var user = userService.getUser(UUID.fromString(s));
|
var user = userService.getUser(UUID.fromString(s));
|
||||||
userGenericForm.setBean(user);
|
userGenericForm.setBean(user);
|
||||||
|
@ -28,12 +28,16 @@ import java.util.List;
|
|||||||
@Route(value = "users", layout = MainLayout.class)
|
@Route(value = "users", layout = MainLayout.class)
|
||||||
@PageTitle("Facturas | PFS Facturacion")
|
@PageTitle("Facturas | PFS Facturacion")
|
||||||
public class UserListView extends VerticalLayout {
|
public class UserListView extends VerticalLayout {
|
||||||
PagingGrid<User> grid = new PagingGrid<>(User.class);
|
private final PagingGrid<User> grid = new PagingGrid<>(User.class);
|
||||||
TextField filterText = new TextField();
|
private final TextField filterText = new TextField();
|
||||||
UserService userService;
|
private final UserService userService;
|
||||||
|
|
||||||
public UserListView(UserService userService) {
|
public UserListView(final UserService userService) {
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
addClassName("list-view");
|
addClassName("list-view");
|
||||||
setSizeFull();
|
setSizeFull();
|
||||||
configureGrid();
|
configureGrid();
|
||||||
|
@ -43,10 +43,9 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
|||||||
/**
|
/**
|
||||||
* Constructs an empty {@code LongField} with the given label.
|
* Constructs an empty {@code LongField} with the given label.
|
||||||
*
|
*
|
||||||
* @param label
|
* @param label the text to set as the label
|
||||||
* the text to set as the label
|
|
||||||
*/
|
*/
|
||||||
public BigIntegerField(String label) {
|
public BigIntegerField(final String label) {
|
||||||
this();
|
this();
|
||||||
setLabel(label);
|
setLabel(label);
|
||||||
}
|
}
|
||||||
@ -55,12 +54,10 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
|||||||
* Constructs an empty {@code LongField} with the given label and
|
* Constructs an empty {@code LongField} with the given label and
|
||||||
* placeholder text.
|
* placeholder text.
|
||||||
*
|
*
|
||||||
* @param label
|
* @param label the text to set as the label
|
||||||
* the text to set as the label
|
* @param placeholder the placeholder text to set
|
||||||
* @param placeholder
|
|
||||||
* the placeholder text to set
|
|
||||||
*/
|
*/
|
||||||
public BigIntegerField(String label, String placeholder) {
|
public BigIntegerField(final String label, final String placeholder) {
|
||||||
this(label);
|
this(label);
|
||||||
setPlaceholder(placeholder);
|
setPlaceholder(placeholder);
|
||||||
}
|
}
|
||||||
@ -68,13 +65,11 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
|||||||
/**
|
/**
|
||||||
* Constructs an empty {@code LongField} with a value change listener.
|
* Constructs an empty {@code LongField} with a value change listener.
|
||||||
*
|
*
|
||||||
* @param listener
|
* @param listener the value change listener
|
||||||
* the value change listener
|
|
||||||
*
|
|
||||||
* @see #addValueChangeListener(ValueChangeListener)
|
* @see #addValueChangeListener(ValueChangeListener)
|
||||||
*/
|
*/
|
||||||
public BigIntegerField(
|
public BigIntegerField(
|
||||||
ValueChangeListener<? super ComponentValueChangeEvent<BigIntegerField, BigInteger>> listener) {
|
final ValueChangeListener<? super ComponentValueChangeEvent<BigIntegerField, BigInteger>> listener) {
|
||||||
this();
|
this();
|
||||||
addValueChangeListener(listener);
|
addValueChangeListener(listener);
|
||||||
}
|
}
|
||||||
@ -83,16 +78,14 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
|||||||
* Constructs an empty {@code LongField} with a value change listener and
|
* Constructs an empty {@code LongField} with a value change listener and
|
||||||
* a label.
|
* a label.
|
||||||
*
|
*
|
||||||
* @param label
|
* @param label the text to set as the label
|
||||||
* the text to set as the label
|
* @param listener the value change listener
|
||||||
* @param listener
|
|
||||||
* the value change listener
|
|
||||||
*
|
|
||||||
* @see #setLabel(String)
|
* @see #setLabel(String)
|
||||||
* @see #addValueChangeListener(ValueChangeListener)
|
* @see #addValueChangeListener(ValueChangeListener)
|
||||||
*/
|
*/
|
||||||
public BigIntegerField(String label,
|
public BigIntegerField(
|
||||||
ValueChangeListener<? super ComponentValueChangeEvent<BigIntegerField, BigInteger>> listener) {
|
final String label,
|
||||||
|
final ValueChangeListener<? super ComponentValueChangeEvent<BigIntegerField, BigInteger>> listener) {
|
||||||
this(label);
|
this(label);
|
||||||
addValueChangeListener(listener);
|
addValueChangeListener(listener);
|
||||||
}
|
}
|
||||||
@ -101,19 +94,17 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
|||||||
* Constructs a {@code LongField} with a value change listener, a label
|
* Constructs a {@code LongField} with a value change listener, a label
|
||||||
* and an initial value.
|
* and an initial value.
|
||||||
*
|
*
|
||||||
* @param label
|
* @param label the text to set as the label
|
||||||
* the text to set as the label
|
* @param initialValue the initial value
|
||||||
* @param initialValue
|
* @param listener the value change listener
|
||||||
* the initial value
|
|
||||||
* @param listener
|
|
||||||
* the value change listener
|
|
||||||
*
|
|
||||||
* @see #setLabel(String)
|
* @see #setLabel(String)
|
||||||
* @see #setValue(Object)
|
* @see #setValue(Object)
|
||||||
* @see #addValueChangeListener(ValueChangeListener)
|
* @see #addValueChangeListener(ValueChangeListener)
|
||||||
*/
|
*/
|
||||||
public BigIntegerField(String label, BigInteger initialValue,
|
public BigIntegerField(
|
||||||
ValueChangeListener<? super ComponentValueChangeEvent<BigIntegerField, BigInteger>> listener) {
|
final String label,
|
||||||
|
final BigInteger initialValue,
|
||||||
|
final ValueChangeListener<? super ComponentValueChangeEvent<BigIntegerField, BigInteger>> listener) {
|
||||||
this(label);
|
this(label);
|
||||||
setValue(initialValue);
|
setValue(initialValue);
|
||||||
addValueChangeListener(listener);
|
addValueChangeListener(listener);
|
||||||
@ -123,10 +114,9 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
|||||||
* Sets the minimum value of the field. Entering a value which is smaller
|
* Sets the minimum value of the field. Entering a value which is smaller
|
||||||
* than {@code min} invalidates the field.
|
* than {@code min} invalidates the field.
|
||||||
*
|
*
|
||||||
* @param min
|
* @param min the min value to set
|
||||||
* the min value to set
|
|
||||||
*/
|
*/
|
||||||
public void setMin(int min) {
|
public void setMin(final int min) {
|
||||||
super.setMin(min);
|
super.setMin(min);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,10 +134,9 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
|||||||
* Sets the maximum value of the field. Entering a value which is greater
|
* Sets the maximum value of the field. Entering a value which is greater
|
||||||
* than {@code max} invalidates the field.
|
* than {@code max} invalidates the field.
|
||||||
*
|
*
|
||||||
* @param max
|
* @param max the max value to set
|
||||||
* the max value to set
|
|
||||||
*/
|
*/
|
||||||
public void setMax(int max) {
|
public void setMax(final int max) {
|
||||||
super.setMax(max);
|
super.setMax(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,12 +157,10 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
|||||||
* invalidate the field, if the value doesn't align with the specified step
|
* invalidate the field, if the value doesn't align with the specified step
|
||||||
* and {@link #setMin(int) min} (if specified by user).
|
* and {@link #setMin(int) min} (if specified by user).
|
||||||
*
|
*
|
||||||
* @param step
|
* @param step the new step to set
|
||||||
* the new step to set
|
* @throws IllegalArgumentException if the argument is less or equal to zero.
|
||||||
* @throws IllegalArgumentException
|
|
||||||
* if the argument is less or equal to zero.
|
|
||||||
*/
|
*/
|
||||||
public void setStep(int step) {
|
public void setStep(final int step) {
|
||||||
if (step <= 0) {
|
if (step <= 0) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"The step cannot be less or equal to zero.");
|
"The step cannot be less or equal to zero.");
|
||||||
|
@ -10,13 +10,13 @@ import java.util.List;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class Breadcrumbs extends HorizontalLayout {
|
public class Breadcrumbs extends HorizontalLayout {
|
||||||
public Breadcrumbs(List<Pair<String, String>> parts) {
|
public Breadcrumbs(final List<Pair<String, String>> parts) {
|
||||||
var components = parts.stream()
|
var components = parts.stream()
|
||||||
.flatMap(p -> {
|
.flatMap(p -> {
|
||||||
if (p.getValue() == null) {
|
if (p.getValue() == null) {
|
||||||
return Stream.of((Component)new Span(p.getKey()), (Component)new Span(">"));
|
return Stream.of(new Span(p.getKey()), (Component) new Span(">"));
|
||||||
} else {
|
} else {
|
||||||
return Stream.of((Component)new Anchor(p.getValue(), p.getKey()), (Component)new Span(">"));
|
return Stream.of(new Anchor(p.getValue(), p.getKey()), (Component) new Span(">"));
|
||||||
}
|
}
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class CollectionContainer<T> extends VerticalLayout implements Bindable<List<T>> {
|
public class CollectionContainer<T> extends VerticalLayout implements Bindable<List<T>> {
|
||||||
|
|
||||||
private List<Bindable<T>> elements = new ArrayList<>();
|
private final List<Bindable<T>> elements = new ArrayList<>();
|
||||||
|
|
||||||
public CollectionContainer(Class<T> elementClazz) {
|
public CollectionContainer(final Class<T> elementClazz) {
|
||||||
Button button = new Button("Add");
|
Button button = new Button("Add");
|
||||||
button.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> {
|
button.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> {
|
||||||
GenericForm<T> element = new GenericForm<>(elementClazz);
|
GenericForm<T> element = new GenericForm<>(elementClazz);
|
||||||
@ -30,9 +30,9 @@ public class CollectionContainer<T> extends VerticalLayout implements Bindable<L
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBean(Object bean) {
|
public void setBean(final Object bean) {
|
||||||
for (int i = 0; i < elements.size(); i++) {
|
for (int i = 0; i < elements.size(); i++) {
|
||||||
elements.get(i).setBean(((List<T>)bean).get(i));
|
elements.get(i).setBean(((List<T>) bean).get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,20 +33,20 @@ import java.util.stream.Stream;
|
|||||||
import static com.primefactorsolutions.invoices.utils.TextUtils.makeLabel;
|
import static com.primefactorsolutions.invoices.utils.TextUtils.makeLabel;
|
||||||
|
|
||||||
public class GenericForm<T> extends VerticalLayout implements Bindable<T> {
|
public class GenericForm<T> extends VerticalLayout implements Bindable<T> {
|
||||||
Binder<T> binder;
|
private Binder<T> binder;
|
||||||
List<Pair<String, GenericForm<?>>> inner2 = new ArrayList<>();
|
private final List<Pair<String, GenericForm<?>>> inner2 = new ArrayList<>();
|
||||||
List<Pair<String, CollectionContainer<?>>> inner = new ArrayList<>();
|
private final List<Pair<String, CollectionContainer<?>>> inner = new ArrayList<>();
|
||||||
|
|
||||||
@Getter(value = AccessLevel.PUBLIC)
|
@Getter(value = AccessLevel.PUBLIC)
|
||||||
Class<T> tClass;
|
private final Class<T> tClass;
|
||||||
|
|
||||||
boolean recursive;
|
private final boolean recursive;
|
||||||
|
|
||||||
public GenericForm(Class<T> tClass) {
|
public GenericForm(final Class<T> tClass) {
|
||||||
this(tClass, false);
|
this(tClass, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericForm(Class<T> tClass, boolean withDetails) {
|
public GenericForm(final Class<T> tClass, final boolean withDetails) {
|
||||||
this.recursive = false;
|
this.recursive = false;
|
||||||
this.tClass = tClass;
|
this.tClass = tClass;
|
||||||
this.binder = new BeanValidationBinder<>(tClass);
|
this.binder = new BeanValidationBinder<>(tClass);
|
||||||
@ -84,7 +84,7 @@ public class GenericForm<T> extends VerticalLayout implements Bindable<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream<Component> getComponents(Class<?> clazz) {
|
public Stream<Component> getComponents(final Class<?> clazz) {
|
||||||
return Arrays.stream(clazz.getDeclaredFields())
|
return Arrays.stream(clazz.getDeclaredFields())
|
||||||
.sorted(Comparator.comparing(Field::getName))
|
.sorted(Comparator.comparing(Field::getName))
|
||||||
.flatMap(field -> {
|
.flatMap(field -> {
|
||||||
@ -98,14 +98,16 @@ public class GenericForm<T> extends VerticalLayout implements Bindable<T> {
|
|||||||
|
|
||||||
if (field.getType().equals(String.class)) {
|
if (field.getType().equals(String.class)) {
|
||||||
component = new TextField(label);
|
component = new TextField(label);
|
||||||
binder.forField((TextField)component)
|
binder.forField((TextField) component)
|
||||||
.bind(field.getName());
|
.bind(field.getName());
|
||||||
} else if (field.getType().equals(Integer.class) || field.getType().equals(Integer.TYPE)) {
|
} else if (field.getType().equals(Integer.class)
|
||||||
|
|| field.getType().equals(Integer.TYPE)) {
|
||||||
final IntegerField formField = new IntegerField(label);
|
final IntegerField formField = new IntegerField(label);
|
||||||
binder.forField(formField)
|
binder.forField(formField)
|
||||||
.bind(field.getName());
|
.bind(field.getName());
|
||||||
component = formField;
|
component = formField;
|
||||||
} else if (field.getType().equals(Long.class) || field.getType().equals(Long.TYPE)) {
|
} else if (field.getType().equals(Long.class)
|
||||||
|
|| field.getType().equals(Long.TYPE)) {
|
||||||
final LongField formField = new LongField(label);
|
final LongField formField = new LongField(label);
|
||||||
binder.forField(formField)
|
binder.forField(formField)
|
||||||
.bind(field.getName());
|
.bind(field.getName());
|
||||||
@ -115,10 +117,10 @@ public class GenericForm<T> extends VerticalLayout implements Bindable<T> {
|
|||||||
binder.forField(formField)
|
binder.forField(formField)
|
||||||
.bind(field.getName());
|
.bind(field.getName());
|
||||||
component = formField;
|
component = formField;
|
||||||
} else if (field.getType().equals(Double.class) ||
|
} else if (field.getType().equals(Double.class)
|
||||||
field.getType().equals(Double.TYPE) ||
|
|| field.getType().equals(Double.TYPE)
|
||||||
field.getType().equals(Float.class) ||
|
|| field.getType().equals(Float.class)
|
||||||
field.getType().equals(Float.TYPE)) {
|
|| field.getType().equals(Float.TYPE)) {
|
||||||
var formField = new NumberField(label);
|
var formField = new NumberField(label);
|
||||||
binder.forField(formField)
|
binder.forField(formField)
|
||||||
.bind(field.getName());
|
.bind(field.getName());
|
||||||
@ -155,10 +157,10 @@ public class GenericForm<T> extends VerticalLayout implements Bindable<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void setBean(Object bean) {
|
public void setBean(final Object bean) {
|
||||||
binder.setBean((T) bean);
|
binder.setBean((T) bean);
|
||||||
|
|
||||||
for(Pair<String, GenericForm<?>> b: inner2) {
|
for (Pair<String, GenericForm<?>> b : inner2) {
|
||||||
Object foo = tClass.getDeclaredMethod("get" + StringUtils.capitalize(b.getKey())).invoke(bean);
|
Object foo = tClass.getDeclaredMethod("get" + StringUtils.capitalize(b.getKey())).invoke(bean);
|
||||||
if (foo == null) {
|
if (foo == null) {
|
||||||
foo = tClass.getDeclaredField(b.getKey()).getType().getConstructor().newInstance();
|
foo = tClass.getDeclaredField(b.getKey()).getType().getConstructor().newInstance();
|
||||||
@ -172,19 +174,17 @@ public class GenericForm<T> extends VerticalLayout implements Bindable<T> {
|
|||||||
public T getBean() {
|
public T getBean() {
|
||||||
T result = binder.getBean();
|
T result = binder.getBean();
|
||||||
|
|
||||||
for(Pair<String, GenericForm<?>> b: inner2) {
|
for (Pair<String, GenericForm<?>> b : inner2) {
|
||||||
Object foo = b.getValue().getBean();
|
Object foo = b.getValue().getBean();
|
||||||
tClass.getDeclaredMethod("set" + StringUtils.capitalize(b.getKey()), b.getValue().getTClass())
|
tClass.getDeclaredMethod("set" + StringUtils.capitalize(b.getKey()), b.getValue().getTClass())
|
||||||
.invoke(result, foo);
|
.invoke(result, foo);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Pair<String, CollectionContainer<?>> b: inner) {
|
for (Pair<String, CollectionContainer<?>> b : inner) {
|
||||||
List<?> foo = b.getValue().getBean();
|
List<?> foo = b.getValue().getBean();
|
||||||
tClass.getDeclaredMethod("set" + StringUtils.capitalize(b.getKey()), List.class).invoke(result, foo);
|
tClass.getDeclaredMethod("set" + StringUtils.capitalize(b.getKey()), List.class).invoke(result, foo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
|||||||
* @param label
|
* @param label
|
||||||
* the text to set as the label
|
* the text to set as the label
|
||||||
*/
|
*/
|
||||||
public LongField(String label) {
|
public LongField(final String label) {
|
||||||
this();
|
this();
|
||||||
setLabel(label);
|
setLabel(label);
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
|||||||
* @param placeholder
|
* @param placeholder
|
||||||
* the placeholder text to set
|
* the placeholder text to set
|
||||||
*/
|
*/
|
||||||
public LongField(String label, String placeholder) {
|
public LongField(final String label, final String placeholder) {
|
||||||
this(label);
|
this(label);
|
||||||
setPlaceholder(placeholder);
|
setPlaceholder(placeholder);
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
|||||||
* @see #addValueChangeListener(ValueChangeListener)
|
* @see #addValueChangeListener(ValueChangeListener)
|
||||||
*/
|
*/
|
||||||
public LongField(
|
public LongField(
|
||||||
ValueChangeListener<? super ComponentValueChangeEvent<LongField, Long>> listener) {
|
final ValueChangeListener<? super ComponentValueChangeEvent<LongField, Long>> listener) {
|
||||||
this();
|
this();
|
||||||
addValueChangeListener(listener);
|
addValueChangeListener(listener);
|
||||||
}
|
}
|
||||||
@ -89,8 +89,8 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
|||||||
* @see #setLabel(String)
|
* @see #setLabel(String)
|
||||||
* @see #addValueChangeListener(ValueChangeListener)
|
* @see #addValueChangeListener(ValueChangeListener)
|
||||||
*/
|
*/
|
||||||
public LongField(String label,
|
public LongField(final String label,
|
||||||
ValueChangeListener<? super ComponentValueChangeEvent<LongField, Long>> listener) {
|
final ValueChangeListener<? super ComponentValueChangeEvent<LongField, Long>> listener) {
|
||||||
this(label);
|
this(label);
|
||||||
addValueChangeListener(listener);
|
addValueChangeListener(listener);
|
||||||
}
|
}
|
||||||
@ -110,8 +110,8 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
|||||||
* @see #setValue(Object)
|
* @see #setValue(Object)
|
||||||
* @see #addValueChangeListener(ValueChangeListener)
|
* @see #addValueChangeListener(ValueChangeListener)
|
||||||
*/
|
*/
|
||||||
public LongField(String label, Long initialValue,
|
public LongField(final String label, final Long initialValue,
|
||||||
ValueChangeListener<? super ComponentValueChangeEvent<LongField, Long>> listener) {
|
final ValueChangeListener<? super ComponentValueChangeEvent<LongField, Long>> listener) {
|
||||||
this(label);
|
this(label);
|
||||||
setValue(initialValue);
|
setValue(initialValue);
|
||||||
addValueChangeListener(listener);
|
addValueChangeListener(listener);
|
||||||
@ -124,7 +124,7 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
|||||||
* @param min
|
* @param min
|
||||||
* the min value to set
|
* the min value to set
|
||||||
*/
|
*/
|
||||||
public void setMin(int min) {
|
public void setMin(final int min) {
|
||||||
super.setMin(min);
|
super.setMin(min);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
|||||||
* @param max
|
* @param max
|
||||||
* the max value to set
|
* the max value to set
|
||||||
*/
|
*/
|
||||||
public void setMax(int max) {
|
public void setMax(final int max) {
|
||||||
super.setMax(max);
|
super.setMax(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if the argument is less or equal to zero.
|
* if the argument is less or equal to zero.
|
||||||
*/
|
*/
|
||||||
public void setStep(int step) {
|
public void setStep(final int step) {
|
||||||
if (step <= 0) {
|
if (step <= 0) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"The step cannot be less or equal to zero.");
|
"The step cannot be less or equal to zero.");
|
||||||
|
@ -8,22 +8,28 @@ import com.vaadin.flow.component.textfield.IntegerField;
|
|||||||
import com.vaadin.flow.component.textfield.TextField;
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
||||||
import com.vaadin.flow.data.binder.Binder;
|
import com.vaadin.flow.data.binder.Binder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public class CabeceraForm<T> extends FormLayout {
|
public class CabeceraForm<T> extends FormLayout {
|
||||||
public Binder<T> binder;
|
@Getter
|
||||||
|
private Binder<T> binder;
|
||||||
|
|
||||||
LongField nitEmisor = new LongField("nitEmisor");
|
private final LongField nitEmisor = new LongField("nitEmisor");
|
||||||
TextField razonSocialEmisor = new TextField("razonSocialEmisor");
|
private final TextField razonSocialEmisor = new TextField("razonSocialEmisor");
|
||||||
TextField municipio = new TextField("municipio");
|
private final TextField municipio = new TextField("municipio");
|
||||||
TextField telefono = new TextField("telefono");
|
private final TextField telefono = new TextField("telefono");
|
||||||
IntegerField codigoSucursal = new IntegerField("codigoSucursal");
|
private final IntegerField codigoSucursal = new IntegerField("codigoSucursal");
|
||||||
TextField direccion = new TextField("direccion");
|
private final TextField direccion = new TextField("direccion");
|
||||||
IntegerField codigoPuntoVenta = new IntegerField("codigoPuntoVenta");
|
private final IntegerField codigoPuntoVenta = new IntegerField("codigoPuntoVenta");
|
||||||
DateTimePicker fechaEmision = new DateTimePicker("fechaEmision");
|
private final DateTimePicker fechaEmision = new DateTimePicker("fechaEmision");
|
||||||
IntegerField codigoMoneda = new IntegerField("codigoMoneda");
|
private final IntegerField codigoMoneda = new IntegerField("codigoMoneda");
|
||||||
BigDecimalField tipoCambio = new BigDecimalField("tipoCambio");
|
private final BigDecimalField tipoCambio = new BigDecimalField("tipoCambio");
|
||||||
|
|
||||||
public CabeceraForm(Class<T> clazz) {
|
public CabeceraForm(final Class<T> clazz) {
|
||||||
|
initView(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView(final Class<T> clazz) {
|
||||||
binder = new BeanValidationBinder<>(clazz);
|
binder = new BeanValidationBinder<>(clazz);
|
||||||
binder.bindInstanceFields(this);
|
binder.bindInstanceFields(this);
|
||||||
setResponsiveSteps(
|
setResponsiveSteps(
|
||||||
|
@ -6,21 +6,27 @@ import com.vaadin.flow.component.textfield.IntegerField;
|
|||||||
import com.vaadin.flow.component.textfield.TextField;
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
||||||
import com.vaadin.flow.data.binder.Binder;
|
import com.vaadin.flow.data.binder.Binder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public class ClientForm<T> extends FormLayout {
|
public class ClientForm<T> extends FormLayout {
|
||||||
public Binder<T> binder;
|
@Getter
|
||||||
TextField nombreRazonSocial = new TextField("nombreRazonSocial");
|
private Binder<T> binder;
|
||||||
IntegerField codigoTipoDocumentoIdentidad = new IntegerField("codigoTipoDocumentoIdentidad");
|
private final TextField nombreRazonSocial = new TextField("nombreRazonSocial");
|
||||||
TextField numeroDocumento = new TextField("numeroDocumento");
|
private final IntegerField codigoTipoDocumentoIdentidad = new IntegerField("codigoTipoDocumentoIdentidad");
|
||||||
TextField complemento = new TextField("complemento");
|
private final TextField numeroDocumento = new TextField("numeroDocumento");
|
||||||
TextField direccionComprador = new TextField("direccionComprador");
|
private final TextField complemento = new TextField("complemento");
|
||||||
TextField codigoCliente = new TextField("codigoCliente");
|
private final TextField direccionComprador = new TextField("direccionComprador");
|
||||||
TextField lugarDestino = new TextField("lugarDestino");
|
private final TextField codigoCliente = new TextField("codigoCliente");
|
||||||
IntegerField codigoPais = new IntegerField("codigoPais");
|
private final TextField lugarDestino = new TextField("lugarDestino");
|
||||||
IntegerField codigoMetodoPago = new IntegerField("codigoMetodoPago");
|
private final IntegerField codigoPais = new IntegerField("codigoPais");
|
||||||
LongField numeroTarjeta = new LongField("numeroTarjeta");
|
private final IntegerField codigoMetodoPago = new IntegerField("codigoMetodoPago");
|
||||||
|
private final LongField numeroTarjeta = new LongField("numeroTarjeta");
|
||||||
|
|
||||||
public ClientForm(Class<T> clazz) {
|
public ClientForm(final Class<T> clazz) {
|
||||||
|
initView(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView(final Class<T> clazz) {
|
||||||
binder = new BeanValidationBinder<>(clazz);
|
binder = new BeanValidationBinder<>(clazz);
|
||||||
binder.bindInstanceFields(this);
|
binder.bindInstanceFields(this);
|
||||||
setResponsiveSteps(
|
setResponsiveSteps(
|
||||||
|
@ -7,17 +7,25 @@ import com.vaadin.flow.component.combobox.ComboBox;
|
|||||||
import com.vaadin.flow.component.formlayout.FormLayout;
|
import com.vaadin.flow.component.formlayout.FormLayout;
|
||||||
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
||||||
import com.vaadin.flow.data.binder.Binder;
|
import com.vaadin.flow.data.binder.Binder;
|
||||||
|
import lombok.Getter;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class ClientInputForm extends FormLayout {
|
public class ClientInputForm extends FormLayout {
|
||||||
public Binder<Client> binder;
|
@Getter
|
||||||
ComboBox<Client> queryText = new ComboBox<>("correoElectronico o telefono");
|
private Binder<Client> binder;
|
||||||
List<Consumer<Client>> listeners = Lists.newArrayList();
|
private final ClientService clientService;
|
||||||
|
private final ComboBox<Client> queryText = new ComboBox<>("correoElectronico o telefono");
|
||||||
|
private final List<Consumer<Client>> listeners = Lists.newArrayList();
|
||||||
|
|
||||||
public ClientInputForm(ClientService clientService) {
|
public ClientInputForm(final ClientService clientService) {
|
||||||
|
this.clientService = clientService;
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
binder = new BeanValidationBinder<>(Client.class);
|
binder = new BeanValidationBinder<>(Client.class);
|
||||||
|
|
||||||
queryText.setPlaceholder("Buscar ...");
|
queryText.setPlaceholder("Buscar ...");
|
||||||
@ -26,7 +34,7 @@ public class ClientInputForm extends FormLayout {
|
|||||||
query -> {
|
query -> {
|
||||||
var limit = Math.min(query.getPageSize(), query.getLimit());
|
var limit = Math.min(query.getPageSize(), query.getLimit());
|
||||||
var page = Math.min(query.getPage(), query.getOffset());
|
var page = Math.min(query.getPage(), query.getOffset());
|
||||||
return clientService.findAllClients(query.getFilter().orElse(""),
|
return this.clientService.findAllClients(query.getFilter().orElse(""),
|
||||||
PageRequest.of(page, limit)).stream();
|
PageRequest.of(page, limit)).stream();
|
||||||
},
|
},
|
||||||
personSearchTerm -> personSearchTerm
|
personSearchTerm -> personSearchTerm
|
||||||
@ -36,7 +44,7 @@ public class ClientInputForm extends FormLayout {
|
|||||||
add(queryText);
|
add(queryText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(Consumer<Client> listener) {
|
public void addListener(final Consumer<Client> listener) {
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,23 +8,29 @@ import com.vaadin.flow.component.textfield.IntegerField;
|
|||||||
import com.vaadin.flow.component.textfield.TextField;
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
||||||
import com.vaadin.flow.data.binder.Binder;
|
import com.vaadin.flow.data.binder.Binder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import static com.primefactorsolutions.invoices.utils.TextUtils.makeLabel;
|
import static com.primefactorsolutions.invoices.utils.TextUtils.makeLabel;
|
||||||
|
|
||||||
public class DetalleForm<T> extends FormLayout {
|
public class DetalleForm<T> extends FormLayout {
|
||||||
Binder<T> binder;
|
@Getter
|
||||||
|
private Binder<T> binder;
|
||||||
|
|
||||||
TextField actividadEconomica = new TextField(makeLabel("actividadEconomica"));
|
private final TextField actividadEconomica = new TextField(makeLabel("actividadEconomica"));
|
||||||
TextField descripcion = new TextField("descripcion");
|
private final TextField descripcion = new TextField("descripcion");
|
||||||
BigIntegerField cantidad = new BigIntegerField("cantidad");
|
private final BigIntegerField cantidad = new BigIntegerField("cantidad");
|
||||||
IntegerField unidadMedida = new IntegerField("unidadMedida");
|
private final IntegerField unidadMedida = new IntegerField("unidadMedida");
|
||||||
BigDecimalField precioUnitario = new BigDecimalField("precioUnitario");
|
private final BigDecimalField precioUnitario = new BigDecimalField("precioUnitario");
|
||||||
BigDecimalField montoDescuento = new BigDecimalField("montoDescuento");
|
private final BigDecimalField montoDescuento = new BigDecimalField("montoDescuento");
|
||||||
BigDecimalField subTotal = new BigDecimalField("subTotal");
|
private final BigDecimalField subTotal = new BigDecimalField("subTotal");
|
||||||
Hr separator = new Hr();
|
private final Hr separator = new Hr();
|
||||||
|
|
||||||
DetalleForm(Class<T> clazz) {
|
DetalleForm(final Class<T> clazz) {
|
||||||
super();
|
super();
|
||||||
|
initView(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView(final Class<T> clazz) {
|
||||||
binder = new BeanValidationBinder<>(clazz);
|
binder = new BeanValidationBinder<>(clazz);
|
||||||
binder.bindInstanceFields(this);
|
binder.bindInstanceFields(this);
|
||||||
setResponsiveSteps(
|
setResponsiveSteps(
|
||||||
|
@ -13,10 +13,10 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class DetallesForm<T> extends VerticalLayout {
|
public class DetallesForm<T> extends VerticalLayout {
|
||||||
|
|
||||||
Class<T> clazz;
|
private final Class<T> clazz;
|
||||||
Supplier<T> supplier;
|
private final Supplier<T> supplier;
|
||||||
|
|
||||||
public DetallesForm(Class<T> clazz, Supplier<T> supplier) {
|
public DetallesForm(final Class<T> clazz, final Supplier<T> supplier) {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
this.supplier = supplier;
|
this.supplier = supplier;
|
||||||
addDetalle();
|
addDetalle();
|
||||||
@ -26,9 +26,9 @@ public class DetallesForm<T> extends VerticalLayout {
|
|||||||
var content = new VerticalLayout();
|
var content = new VerticalLayout();
|
||||||
var value = supplier.get();
|
var value = supplier.get();
|
||||||
var detalle = new DetalleForm<>(clazz);
|
var detalle = new DetalleForm<>(clazz);
|
||||||
detalle.binder.setBean(value);
|
detalle.getBinder().setBean(value);
|
||||||
|
|
||||||
detalle.binder.addValueChangeListener(v -> {
|
detalle.getBinder().addValueChangeListener(v -> {
|
||||||
fireEvent(new ChangeEvent(this, true));
|
fireEvent(new ChangeEvent(this, true));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -40,15 +40,13 @@ public class DetallesForm<T> extends VerticalLayout {
|
|||||||
add(content);
|
add(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<T> getValues() {
|
public List<T> getValues() {
|
||||||
return getChildren()
|
return getChildren()
|
||||||
.flatMap(d -> {
|
.flatMap(d -> {
|
||||||
return d.getChildren()
|
return d.getChildren()
|
||||||
.map(c -> {
|
.map(c -> {
|
||||||
if (c instanceof DetalleForm) {
|
if (c instanceof DetalleForm) {
|
||||||
return ((DetalleForm<T>) c).binder.getBean();
|
return ((DetalleForm<T>) c).getBinder().getBean();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -59,14 +57,14 @@ public class DetallesForm<T> extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Registration addChangeListener(
|
public Registration addChangeListener(
|
||||||
ComponentEventListener<DetallesForm.ChangeEvent> listener) {
|
final ComponentEventListener<DetallesForm.ChangeEvent> listener) {
|
||||||
return addListener(DetallesForm.ChangeEvent.class, listener);
|
return addListener(DetallesForm.ChangeEvent.class, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ChangeEvent
|
public static class ChangeEvent
|
||||||
extends ComponentEvent<DetallesForm<?>> {
|
extends ComponentEvent<DetallesForm<?>> {
|
||||||
public ChangeEvent(DetallesForm source,
|
public ChangeEvent(final DetallesForm source,
|
||||||
boolean fromClient) {
|
final boolean fromClient) {
|
||||||
super(source, fromClient);
|
super(source, fromClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,22 @@ import com.vaadin.flow.component.textfield.BigDecimalField;
|
|||||||
import com.vaadin.flow.component.textfield.TextField;
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
||||||
import com.vaadin.flow.data.binder.Binder;
|
import com.vaadin.flow.data.binder.Binder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public class TotalesForm<T> extends FormLayout {
|
public class TotalesForm<T> extends FormLayout {
|
||||||
public Binder<T> binder;
|
@Getter
|
||||||
BigDecimalField montoTotal = new BigDecimalField("montoTotal");
|
private Binder<T> binder;
|
||||||
BigDecimalField montoTotalSujetoIva = new BigDecimalField("montoTotalSujetoIva");
|
private final BigDecimalField montoTotal = new BigDecimalField("montoTotal");
|
||||||
BigDecimalField montoTotalMoneda = new BigDecimalField("montoTotalMoneda");
|
private final BigDecimalField montoTotalSujetoIva = new BigDecimalField("montoTotalSujetoIva");
|
||||||
TextField informacionAdicional = new TextField("informacionAdicional");
|
private final BigDecimalField montoTotalMoneda = new BigDecimalField("montoTotalMoneda");
|
||||||
BigDecimalField descuentoAdicional = new BigDecimalField("descuentoAdicional");
|
private final TextField informacionAdicional = new TextField("informacionAdicional");
|
||||||
public TotalesForm(Class<T> clazz) {
|
private final BigDecimalField descuentoAdicional = new BigDecimalField("descuentoAdicional");
|
||||||
|
|
||||||
|
public TotalesForm(final Class<T> clazz) {
|
||||||
|
initView(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView(final Class<T> clazz) {
|
||||||
binder = new BeanValidationBinder<>(clazz);
|
binder = new BeanValidationBinder<>(clazz);
|
||||||
binder.bindInstanceFields(this);
|
binder.bindInstanceFields(this);
|
||||||
|
|
||||||
|
@ -33,8 +33,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import static com.primefactorsolutions.invoices.utils.TextUtils.makeLabel;
|
import static com.primefactorsolutions.invoices.utils.TextUtils.makeLabel;
|
||||||
import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
||||||
@ -45,34 +43,38 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
|||||||
@Route(value = "edit-invoice", layout = MainLayout.class)
|
@Route(value = "edit-invoice", layout = MainLayout.class)
|
||||||
@PageTitle("Factura | Editar")
|
@PageTitle("Factura | Editar")
|
||||||
public class FacturaComputarizadaComercialExportacionesServicioEditView extends VerticalLayout {
|
public class FacturaComputarizadaComercialExportacionesServicioEditView extends VerticalLayout {
|
||||||
private final CabeceraForm<CabeceraDTO> cabeceraForm;
|
|
||||||
private final ClientForm<ClientDTO> clientForm;
|
|
||||||
private final TotalesForm<TotalesDTO> totalesForm;
|
|
||||||
private final DetallesForm<DetalleDTO> detalleForm;
|
|
||||||
private final Button save = new Button("Crear");
|
|
||||||
private final Button close = new Button("Cancelar");
|
|
||||||
private final Dialog dialog = new Dialog();
|
|
||||||
private final InvoiceService invoiceService;
|
private final InvoiceService invoiceService;
|
||||||
private final ClientService clientService;
|
private final ClientService clientService;
|
||||||
private final CompanyService companyService;
|
private final CompanyService companyService;
|
||||||
|
private final Button save = new Button("Crear");
|
||||||
|
private final Button close = new Button("Cancelar");
|
||||||
|
private final Dialog dialog = new Dialog();
|
||||||
|
private CabeceraForm<CabeceraDTO> cabeceraForm;
|
||||||
|
private ClientForm<ClientDTO> clientForm;
|
||||||
|
private TotalesForm<TotalesDTO> totalesForm;
|
||||||
|
private DetallesForm<DetalleDTO> detalleForm;
|
||||||
|
|
||||||
public FacturaComputarizadaComercialExportacionesServicioEditView(
|
public FacturaComputarizadaComercialExportacionesServicioEditView(
|
||||||
InvoiceService invoiceService,
|
final InvoiceService invoiceService,
|
||||||
ClientService clientService,
|
final ClientService clientService,
|
||||||
CompanyService companyService) {
|
final CompanyService companyService) {
|
||||||
this.invoiceService = invoiceService;
|
this.invoiceService = invoiceService;
|
||||||
this.clientService = clientService;
|
this.clientService = clientService;
|
||||||
this.companyService = companyService;
|
this.companyService = companyService;
|
||||||
|
|
||||||
var company = companyService.getCompany();
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
|
var company = this.companyService.getCompany();
|
||||||
var cabeceraDTO = CabeceraMapper.INSTANCE.cabeceraDtoFromCompany(company);
|
var cabeceraDTO = CabeceraMapper.INSTANCE.cabeceraDtoFromCompany(company);
|
||||||
this.cabeceraForm = new CabeceraForm<>(CabeceraDTO.class);
|
this.cabeceraForm = new CabeceraForm<>(CabeceraDTO.class);
|
||||||
this.cabeceraForm.binder.setBean(cabeceraDTO);
|
this.cabeceraForm.getBinder().setBean(cabeceraDTO);
|
||||||
|
|
||||||
var clientDTO = new ClientDTO();
|
var clientDTO = new ClientDTO();
|
||||||
|
|
||||||
this.clientForm = new ClientForm<>(ClientDTO.class);
|
this.clientForm = new ClientForm<>(ClientDTO.class);
|
||||||
this.clientForm.binder.setBean(clientDTO);
|
this.clientForm.getBinder().setBean(clientDTO);
|
||||||
|
|
||||||
this.detalleForm = new DetallesForm<>(DetalleDTO.class, DetalleDTO::new);
|
this.detalleForm = new DetallesForm<>(DetalleDTO.class, DetalleDTO::new);
|
||||||
|
|
||||||
@ -80,7 +82,7 @@ public class FacturaComputarizadaComercialExportacionesServicioEditView extends
|
|||||||
totalesDTO.setInformacionAdicional("Ninguno");
|
totalesDTO.setInformacionAdicional("Ninguno");
|
||||||
totalesDTO.setDescuentoAdicional(BigDecimal.valueOf(0));
|
totalesDTO.setDescuentoAdicional(BigDecimal.valueOf(0));
|
||||||
this.totalesForm = new TotalesForm<>(TotalesDTO.class);
|
this.totalesForm = new TotalesForm<>(TotalesDTO.class);
|
||||||
this.totalesForm.binder.setBean(totalesDTO);
|
this.totalesForm.getBinder().setBean(totalesDTO);
|
||||||
|
|
||||||
var emisorDetails = getEmisorDetails(cabeceraDTO);
|
var emisorDetails = getEmisorDetails(cabeceraDTO);
|
||||||
var clienteDetails = getClienteDetails();
|
var clienteDetails = getClienteDetails();
|
||||||
@ -111,20 +113,20 @@ public class FacturaComputarizadaComercialExportacionesServicioEditView extends
|
|||||||
|
|
||||||
this.detalleForm.addChangeListener(c -> {
|
this.detalleForm.addChangeListener(c -> {
|
||||||
var values = this.detalleForm.getValues();
|
var values = this.detalleForm.getValues();
|
||||||
var currentTotales = this.totalesForm.binder.getBean();
|
var currentTotales = this.totalesForm.getBinder().getBean();
|
||||||
|
|
||||||
var total = values.stream()
|
var total = values.stream()
|
||||||
.map(DetalleDTO::getSubTotal)
|
.map(DetalleDTO::getSubTotal)
|
||||||
.map(b -> b == null ? new BigDecimal(0) : b)
|
.map(b -> b == null ? new BigDecimal(0) : b)
|
||||||
.reduce(BigDecimal::add).orElse(new BigDecimal(0));
|
.reduce(BigDecimal::add).orElse(new BigDecimal(0));
|
||||||
|
|
||||||
System.out.println(">>>>>>>>" + total);
|
|
||||||
currentTotales.setMontoTotalMoneda(total);
|
currentTotales.setMontoTotalMoneda(total);
|
||||||
currentTotales.setMontoTotal((total.subtract(currentTotales.getDescuentoAdicional()))
|
currentTotales.setMontoTotal((total.subtract(currentTotales.getDescuentoAdicional()))
|
||||||
.multiply(BigDecimal.valueOf(7.0)));
|
.multiply(BigDecimal.valueOf(7.0)));
|
||||||
currentTotales.setMontoTotalSujetoIva(currentTotales.getMontoTotal().subtract(currentTotales.getDescuentoAdicional()));
|
currentTotales.setMontoTotalSujetoIva(currentTotales.getMontoTotal()
|
||||||
|
.subtract(currentTotales.getDescuentoAdicional()));
|
||||||
|
|
||||||
this.totalesForm.binder.setBean(currentTotales);
|
this.totalesForm.getBinder().setBean(currentTotales);
|
||||||
});
|
});
|
||||||
|
|
||||||
return detalleDetails;
|
return detalleDetails;
|
||||||
@ -135,7 +137,7 @@ public class FacturaComputarizadaComercialExportacionesServicioEditView extends
|
|||||||
ClientInputForm clientInputForm = new ClientInputForm(clientService);
|
ClientInputForm clientInputForm = new ClientInputForm(clientService);
|
||||||
clientInputForm.addListener(c -> {
|
clientInputForm.addListener(c -> {
|
||||||
var selectedClientDTO = ClientMapper.INSTANCE.clientDtoFromClient(c);
|
var selectedClientDTO = ClientMapper.INSTANCE.clientDtoFromClient(c);
|
||||||
this.clientForm.binder.setBean(selectedClientDTO);
|
this.clientForm.getBinder().setBean(selectedClientDTO);
|
||||||
this.clientForm.setVisible(true);
|
this.clientForm.setVisible(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -154,7 +156,7 @@ public class FacturaComputarizadaComercialExportacionesServicioEditView extends
|
|||||||
if (e.isOpened()) {
|
if (e.isOpened()) {
|
||||||
clienteText.setText("Cliente");
|
clienteText.setText("Cliente");
|
||||||
} else {
|
} else {
|
||||||
var clienteDTO = clientForm.binder.getBean();
|
var clienteDTO = clientForm.getBinder().getBean();
|
||||||
clienteText.setText("Cliente (" + clienteDTO.getNombreRazonSocial() + ")");
|
clienteText.setText("Cliente (" + clienteDTO.getNombreRazonSocial() + ")");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -171,7 +173,7 @@ public class FacturaComputarizadaComercialExportacionesServicioEditView extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Details getEmisorDetails(CabeceraDTO cabeceraDTO) {
|
private Details getEmisorDetails(final CabeceraDTO cabeceraDTO) {
|
||||||
var emisorText = new Text("Emisor");
|
var emisorText = new Text("Emisor");
|
||||||
var emisorSummary = new HorizontalLayout();
|
var emisorSummary = new HorizontalLayout();
|
||||||
emisorSummary.setSpacing(false);
|
emisorSummary.setSpacing(false);
|
||||||
@ -204,9 +206,9 @@ public class FacturaComputarizadaComercialExportacionesServicioEditView extends
|
|||||||
|
|
||||||
this.save.addClickListener(e -> {
|
this.save.addClickListener(e -> {
|
||||||
var factura = new FacturaComputarizadaComercialExportacionServicio();
|
var factura = new FacturaComputarizadaComercialExportacionServicio();
|
||||||
var cabecera = CabeceraMapper.INSTANCE.cabeceraFromDtos(this.cabeceraForm.binder.getBean(),
|
var cabecera = CabeceraMapper.INSTANCE.cabeceraFromDtos(this.cabeceraForm.getBinder().getBean(),
|
||||||
this.clientForm.binder.getBean(),
|
this.clientForm.getBinder().getBean(),
|
||||||
this.totalesForm.binder.getBean());
|
this.totalesForm.getBinder().getBean());
|
||||||
var detalles = detalleForm.getValues().stream()
|
var detalles = detalleForm.getValues().stream()
|
||||||
.map(DetalleMapper.INSTANCE::detalleFromDto)
|
.map(DetalleMapper.INSTANCE::detalleFromDto)
|
||||||
.toList();
|
.toList();
|
||||||
|
@ -11,12 +11,12 @@ import java.time.ZoneOffset;
|
|||||||
public class DateTimeXmlAdapter extends XmlAdapter<String, LocalDateTime> {
|
public class DateTimeXmlAdapter extends XmlAdapter<String, LocalDateTime> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String marshal(LocalDateTime v) throws Exception {
|
public String marshal(final LocalDateTime v) throws Exception {
|
||||||
return v.toInstant(ZoneOffset.UTC).toString();
|
return v.toInstant(ZoneOffset.UTC).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime unmarshal(String v) throws Exception {
|
public LocalDateTime unmarshal(final String v) throws Exception {
|
||||||
return LocalDateTime.ofInstant(Instant.parse(v), ZoneId.of("UTC"));
|
return LocalDateTime.ofInstant(Instant.parse(v), ZoneId.of("UTC"));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,14 +11,14 @@ public class DateXmlAdapter extends XmlAdapter<String, Date> {
|
|||||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String marshal(Date v) throws Exception {
|
public String marshal(final Date v) throws Exception {
|
||||||
synchronized (dateFormat) {
|
synchronized (dateFormat) {
|
||||||
return dateFormat.format(v);
|
return dateFormat.format(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date unmarshal(String v) throws Exception {
|
public Date unmarshal(final String v) throws Exception {
|
||||||
synchronized (dateFormat) {
|
synchronized (dateFormat) {
|
||||||
return dateFormat.parse(v);
|
return dateFormat.parse(v);
|
||||||
}
|
}
|
||||||
|
195
src/main/resources/checkstyle.xml
Normal file
195
src/main/resources/checkstyle.xml
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE module PUBLIC
|
||||||
|
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||||
|
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Checkstyle configuration that checks the sun coding conventions from:
|
||||||
|
|
||||||
|
- the Java Language Specification at
|
||||||
|
https://docs.oracle.com/javase/specs/jls/se11/html/index.html
|
||||||
|
|
||||||
|
- the Sun Code Conventions at https://www.oracle.com/java/technologies/javase/codeconventions-contents.html
|
||||||
|
|
||||||
|
- the Javadoc guidelines at
|
||||||
|
https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html
|
||||||
|
|
||||||
|
- the JDK Api documentation https://docs.oracle.com/en/java/javase/11/
|
||||||
|
|
||||||
|
- some best practices
|
||||||
|
|
||||||
|
Checkstyle is very configurable. Be sure to read the documentation at
|
||||||
|
https://checkstyle.org (or in your downloaded distribution).
|
||||||
|
|
||||||
|
Most Checks are configurable, be sure to consult the documentation.
|
||||||
|
|
||||||
|
To completely disable a check, just comment it out or delete it from the file.
|
||||||
|
To suppress certain violations please review suppression filters.
|
||||||
|
|
||||||
|
Finally, it is worth reading the documentation.
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<module name="Checker">
|
||||||
|
<!--
|
||||||
|
If you set the basedir property below, then all reported file
|
||||||
|
names will be relative to the specified directory. See
|
||||||
|
https://checkstyle.org/config.html#Checker
|
||||||
|
|
||||||
|
<property name="basedir" value="${basedir}"/>
|
||||||
|
-->
|
||||||
|
<property name="severity" value="error"/>
|
||||||
|
|
||||||
|
<property name="fileExtensions" value="java, properties, xml"/>
|
||||||
|
|
||||||
|
<!-- Excludes all 'module-info.java' files -->
|
||||||
|
<!-- See https://checkstyle.org/config_filefilters.html -->
|
||||||
|
<module name="BeforeExecutionExclusionFileFilter">
|
||||||
|
<property name="fileNamePattern" value="module\-info\.java$"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
|
||||||
|
<module name="SuppressionFilter">
|
||||||
|
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}"
|
||||||
|
default="checkstyle-suppressions.xml" />
|
||||||
|
<property name="optional" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Checks that a package-info.java file exists for each package. -->
|
||||||
|
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
|
||||||
|
<!-- <module name="JavadocPackage"/> -->
|
||||||
|
|
||||||
|
<!-- Checks whether files end with a new line. -->
|
||||||
|
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
|
||||||
|
<!-- <module name="NewlineAtEndOfFile"/> -->
|
||||||
|
|
||||||
|
<!-- Checks that property files contain the same keys. -->
|
||||||
|
<!-- See https://checkstyle.org/config_misc.html#Translation -->
|
||||||
|
<module name="Translation"/>
|
||||||
|
|
||||||
|
<!-- Checks for Size Violations. -->
|
||||||
|
<!-- See https://checkstyle.org/config_sizes.html -->
|
||||||
|
<module name="FileLength"/>
|
||||||
|
<module name="LineLength">
|
||||||
|
<property name="max" value="120"/>
|
||||||
|
<property name="fileExtensions" value="java"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Checks for whitespace -->
|
||||||
|
<!-- See https://checkstyle.org/config_whitespace.html -->
|
||||||
|
<module name="FileTabCharacter"/>
|
||||||
|
|
||||||
|
<!-- Miscellaneous other checks. -->
|
||||||
|
<!-- See https://checkstyle.org/config_misc.html -->
|
||||||
|
<module name="RegexpSingleline">
|
||||||
|
<property name="format" value="\s+$"/>
|
||||||
|
<property name="minimum" value="0"/>
|
||||||
|
<property name="maximum" value="0"/>
|
||||||
|
<property name="message" value="Line has trailing spaces."/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Checks for Headers -->
|
||||||
|
<!-- See https://checkstyle.org/config_header.html -->
|
||||||
|
<!-- <module name="Header"> -->
|
||||||
|
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
|
||||||
|
<!-- <property name="fileExtensions" value="java"/> -->
|
||||||
|
<!-- </module> -->
|
||||||
|
|
||||||
|
<module name="TreeWalker">
|
||||||
|
|
||||||
|
<!-- Checks for Javadoc comments. -->
|
||||||
|
<!-- See https://checkstyle.org/config_javadoc.html -->
|
||||||
|
<module name="InvalidJavadocPosition"/>
|
||||||
|
|
||||||
|
<!-- Checks for Naming Conventions. -->
|
||||||
|
<!-- See https://checkstyle.org/config_naming.html -->
|
||||||
|
<module name="ConstantName"/>
|
||||||
|
<module name="LocalFinalVariableName"/>
|
||||||
|
<module name="LocalVariableName"/>
|
||||||
|
<module name="MemberName"/>
|
||||||
|
<module name="MethodName"/>
|
||||||
|
<module name="PackageName"/>
|
||||||
|
<module name="ParameterName"/>
|
||||||
|
<module name="StaticVariableName"/>
|
||||||
|
<module name="TypeName"/>
|
||||||
|
|
||||||
|
<!-- Checks for imports -->
|
||||||
|
<!-- See https://checkstyle.org/config_imports.html -->
|
||||||
|
<!-- <module name="AvoidStarImport"/> -->
|
||||||
|
|
||||||
|
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
|
||||||
|
<module name="RedundantImport"/>
|
||||||
|
<module name="UnusedImports">
|
||||||
|
<property name="processJavadoc" value="false"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Checks for Size Violations. -->
|
||||||
|
<!-- See https://checkstyle.org/config_sizes.html -->
|
||||||
|
<module name="MethodLength"/>
|
||||||
|
<module name="ParameterNumber"/>
|
||||||
|
|
||||||
|
<!-- Checks for whitespace -->
|
||||||
|
<!-- See https://checkstyle.org/config_whitespace.html -->
|
||||||
|
<module name="EmptyForIteratorPad"/>
|
||||||
|
<module name="GenericWhitespace"/>
|
||||||
|
<module name="MethodParamPad"/>
|
||||||
|
<module name="NoWhitespaceAfter"/>
|
||||||
|
<module name="NoWhitespaceBefore"/>
|
||||||
|
<module name="OperatorWrap"/>
|
||||||
|
<module name="ParenPad"/>
|
||||||
|
<module name="TypecastParenPad"/>
|
||||||
|
<module name="WhitespaceAfter"/>
|
||||||
|
<module name="WhitespaceAround"/>
|
||||||
|
|
||||||
|
<!-- Modifier Checks -->
|
||||||
|
<!-- See https://checkstyle.org/config_modifier.html -->
|
||||||
|
<module name="ModifierOrder"/>
|
||||||
|
<module name="RedundantModifier"/>
|
||||||
|
|
||||||
|
<!-- Checks for blocks. You know, those {}'s -->
|
||||||
|
<!-- See https://checkstyle.org/config_blocks.html -->
|
||||||
|
<module name="AvoidNestedBlocks"/>
|
||||||
|
<module name="EmptyBlock"/>
|
||||||
|
<module name="LeftCurly"/>
|
||||||
|
<module name="NeedBraces"/>
|
||||||
|
<module name="RightCurly"/>
|
||||||
|
|
||||||
|
<!-- Checks for common coding problems -->
|
||||||
|
<!-- See https://checkstyle.org/config_coding.html -->
|
||||||
|
<module name="EmptyStatement"/>
|
||||||
|
<module name="EqualsHashCode"/>
|
||||||
|
<!-- <module name="HiddenField"/> -->
|
||||||
|
<module name="IllegalInstantiation"/>
|
||||||
|
<module name="InnerAssignment"/>
|
||||||
|
<!-- <module name="MagicNumber"/> -->
|
||||||
|
<module name="MissingSwitchDefault"/>
|
||||||
|
<module name="MultipleVariableDeclarations"/>
|
||||||
|
<module name="SimplifyBooleanExpression"/>
|
||||||
|
<module name="SimplifyBooleanReturn"/>
|
||||||
|
|
||||||
|
<!-- Checks for class design -->
|
||||||
|
<!-- See https://checkstyle.org/config_design.html -->
|
||||||
|
<!--<module name="DesignForExtension"/>-->
|
||||||
|
<module name="FinalClass"/>
|
||||||
|
<!-- <module name="HideUtilityClassConstructor"/>-->
|
||||||
|
<module name="InterfaceIsType"/>
|
||||||
|
<module name="VisibilityModifier"/>
|
||||||
|
|
||||||
|
<!-- Miscellaneous other checks. -->
|
||||||
|
<!-- See https://checkstyle.org/config_misc.html -->
|
||||||
|
<module name="ArrayTypeStyle"/>
|
||||||
|
<module name="FinalParameters"/>
|
||||||
|
<module name="TodoComment"/>
|
||||||
|
<module name="UpperEll"/>
|
||||||
|
|
||||||
|
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
|
||||||
|
<module name="SuppressionXpathFilter">
|
||||||
|
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}"
|
||||||
|
default="checkstyle-xpath-suppressions.xml" />
|
||||||
|
<property name="optional" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
</module>
|
||||||
|
|
||||||
|
</module>
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.primefactorsolutions.invoices.services;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class ClientServiceTest {
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void tearDown() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getClient() {
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user