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>
|
||||
<version>4.0.2</version>
|
||||
</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>
|
||||
|
||||
<build>
|
||||
<defaultGoal>spring-boot:run</defaultGoal>
|
||||
<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>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
@ -351,6 +383,28 @@
|
||||
</plugins>
|
||||
</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>
|
||||
<profile>
|
||||
<!-- Production mode is activated using -Pproduction -->
|
||||
|
@ -16,7 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@Theme(value = "pfs")
|
||||
public class Application implements AppShellConfigurator {
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
|
@ -17,45 +17,45 @@ public class CabeceraDTO {
|
||||
@NotNull
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "9999999999999", inclusive = true)
|
||||
protected long nitEmisor;
|
||||
@XmlElement(required = true)
|
||||
private long nitEmisor;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = 200)
|
||||
protected String razonSocialEmisor;
|
||||
@XmlElement(required = true)
|
||||
private String razonSocialEmisor;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = 25)
|
||||
protected String municipio;
|
||||
@XmlElement(required = true, nillable = true)
|
||||
private String municipio;
|
||||
|
||||
@Size(min = 1, max = 25)
|
||||
protected String telefono;
|
||||
private String telefono;
|
||||
@NotNull
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "9999999999", inclusive = true)
|
||||
protected long numeroFactura;
|
||||
private long numeroFactura;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@Size(min = 1, max = 100)
|
||||
protected String cuf;
|
||||
private String cuf;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@Size(min = 1, max = 100)
|
||||
protected String cufd;
|
||||
private String cufd;
|
||||
@NotNull
|
||||
@DecimalMin(value = "0", inclusive = true)
|
||||
@DecimalMax(value = "9999", inclusive = true)
|
||||
protected int codigoSucursal;
|
||||
private int codigoSucursal;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@Size(min = 1, max = 500)
|
||||
protected String direccion;
|
||||
private String direccion;
|
||||
@XmlElement(required = true, type = Integer.class, nillable = true)
|
||||
@DecimalMin(value = "0", inclusive = true)
|
||||
@DecimalMax(value = "9999", inclusive = true)
|
||||
protected Integer codigoPuntoVenta;
|
||||
private Integer codigoPuntoVenta;
|
||||
@XmlElement(required = true, type = String.class)
|
||||
@XmlJavaTypeAdapter(DateTimeXmlAdapter.class)
|
||||
@XmlSchemaType(name = "dateTime")
|
||||
@NotNull
|
||||
protected LocalDateTime fechaEmision;
|
||||
private LocalDateTime fechaEmision;
|
||||
}
|
||||
|
@ -11,40 +11,40 @@ import lombok.Data;
|
||||
public class ClientDTO {
|
||||
@XmlElement(required = true, nillable = true)
|
||||
@Size(min = 1, max = 500)
|
||||
protected String nombreRazonSocial;
|
||||
private String nombreRazonSocial;
|
||||
@NotNull
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "5", inclusive = true)
|
||||
protected int codigoTipoDocumentoIdentidad;
|
||||
private int codigoTipoDocumentoIdentidad;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@Size(min = 1, max = 20)
|
||||
protected String numeroDocumento;
|
||||
private String numeroDocumento;
|
||||
@XmlElement(required = true, nillable = true)
|
||||
@Size(max = 5)
|
||||
protected String complemento;
|
||||
private String complemento;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@Size(min = 1, max = 500)
|
||||
protected String direccionComprador;
|
||||
private String direccionComprador;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@Size(min = 1, max = 100)
|
||||
protected String codigoCliente;
|
||||
private String codigoCliente;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@Size(min = 1, max = 500)
|
||||
protected String lugarDestino;
|
||||
private String lugarDestino;
|
||||
@NotNull
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "212", inclusive = true)
|
||||
protected int codigoPais;
|
||||
private int codigoPais;
|
||||
@NotNull
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "308", inclusive = true)
|
||||
protected int codigoMetodoPago;
|
||||
private int codigoMetodoPago;
|
||||
@XmlElement(required = true, type = Long.class, nillable = true)
|
||||
@DecimalMin(value = "0", inclusive = true)
|
||||
@DecimalMax(value = "9999999999999999", inclusive = true)
|
||||
protected Long numeroTarjeta;
|
||||
private Long numeroTarjeta;
|
||||
}
|
||||
|
@ -13,38 +13,38 @@ public class DetalleDTO {
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@Size(min = 1, max = 10)
|
||||
protected String actividadEconomica;
|
||||
private String actividadEconomica;
|
||||
@NotNull
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "99999999", inclusive = true)
|
||||
protected int codigoProductoSin;
|
||||
private int codigoProductoSin;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@Size(min = 1, max = 50)
|
||||
protected String codigoProducto;
|
||||
private String codigoProducto;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@Size(min = 1, max = 500)
|
||||
protected String descripcion;
|
||||
private String descripcion;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
protected BigInteger cantidad;
|
||||
private BigInteger cantidad;
|
||||
@NotNull
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "200", inclusive = true)
|
||||
protected int unidadMedida;
|
||||
private int unidadMedida;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@DecimalMin(value = "0", inclusive = false)
|
||||
@Digits(integer = 20, fraction = 5)
|
||||
protected BigDecimal precioUnitario;
|
||||
private BigDecimal precioUnitario;
|
||||
@XmlElement(required = true, nillable = true)
|
||||
@DecimalMin(value = "0", inclusive = true)
|
||||
@Digits(integer = 20, fraction = 5)
|
||||
protected BigDecimal montoDescuento;
|
||||
private BigDecimal montoDescuento;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@DecimalMin(value = "0", inclusive = false)
|
||||
@Digits(integer = 20, fraction = 5)
|
||||
protected BigDecimal subTotal;
|
||||
private BigDecimal subTotal;
|
||||
}
|
||||
|
@ -15,20 +15,20 @@ public class TotalesDTO {
|
||||
@NotNull
|
||||
@DecimalMin(value = "0", inclusive = false)
|
||||
@Digits(integer = 17, fraction = 2)
|
||||
protected BigDecimal montoTotal;
|
||||
private BigDecimal montoTotal;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
protected BigDecimal montoTotalSujetoIva;
|
||||
private BigDecimal montoTotalSujetoIva;
|
||||
@XmlElement(required = true)
|
||||
@NotNull
|
||||
@DecimalMin(value = "0", inclusive = false)
|
||||
@Digits(integer = 17, fraction = 2)
|
||||
protected BigDecimal montoTotalMoneda;
|
||||
private BigDecimal montoTotalMoneda;
|
||||
@XmlElement(required = true, nillable = true)
|
||||
@Size(min = 1, max = 10000)
|
||||
protected String informacionAdicional;
|
||||
private String informacionAdicional;
|
||||
@XmlElement(required = true, nillable = true)
|
||||
@DecimalMin(value = "0", inclusive = true)
|
||||
@Digits(integer = 17, fraction = 2)
|
||||
protected BigDecimal descuentoAdicional;
|
||||
private BigDecimal descuentoAdicional;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class ApplicationReadyListener implements ApplicationListener<Application
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void onApplicationEvent(ApplicationReadyEvent event) {
|
||||
public void onApplicationEvent(final ApplicationReadyEvent event) {
|
||||
var indexed = new Class[]{Client.class, Product.class};
|
||||
log.info("Indexing tables {}", Arrays.stream(indexed).toList());
|
||||
SearchSession searchSession = Search.session(entityManager);
|
||||
|
@ -17,7 +17,7 @@ import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
public class SecurityConfig extends VaadinWebSecurity {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
protected void configure(final HttpSecurity http) throws Exception {
|
||||
http.authorizeHttpRequests(auth ->
|
||||
auth.requestMatchers(
|
||||
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/images/*.png")).permitAll());
|
||||
|
@ -22,7 +22,7 @@ public abstract class AbstractEntity {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
public void setId(final UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public abstract class AbstractEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
if (!(obj instanceof AbstractEntity that)) {
|
||||
return false; // null or not an AbstractEntity class
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ public class Branch extends AbstractEntity {
|
||||
@NotNull
|
||||
@DecimalMin(value = "0", 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)
|
||||
@Size(min = 1, max = 500)
|
||||
@FullTextField
|
||||
protected String nombreRazonSocial;
|
||||
private String nombreRazonSocial;
|
||||
|
||||
@NotNull
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "5", inclusive = true)
|
||||
protected int codigoTipoDocumentoIdentidad;
|
||||
private int codigoTipoDocumentoIdentidad;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = 20)
|
||||
protected String numeroDocumento;
|
||||
private String numeroDocumento;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = 500)
|
||||
protected String direccionComprador;
|
||||
private String direccionComprador;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = 100)
|
||||
protected String codigoCliente;
|
||||
private String codigoCliente;
|
||||
|
||||
@NotNull
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "212", inclusive = true)
|
||||
protected int codigoPais;
|
||||
private int codigoPais;
|
||||
|
||||
@NotNull
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "308", inclusive = true)
|
||||
protected int codigoMetodoPago;
|
||||
private int codigoMetodoPago;
|
||||
|
||||
@DecimalMin(value = "0", inclusive = true)
|
||||
@DecimalMax(value = "9999999999999999", inclusive = true)
|
||||
protected Long numeroTarjeta;
|
||||
private Long numeroTarjeta;
|
||||
|
||||
}
|
||||
|
@ -17,22 +17,22 @@ public class Company extends AbstractEntity {
|
||||
@NotNull
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "9999999999999", inclusive = true)
|
||||
protected long nitEmisor;
|
||||
private long nitEmisor;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = 200)
|
||||
protected String razonSocialEmisor;
|
||||
private String razonSocialEmisor;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = 25)
|
||||
protected String municipio;
|
||||
private String municipio;
|
||||
|
||||
@Size(min = 1, max = 25)
|
||||
protected String telefono;
|
||||
private String telefono;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = 500)
|
||||
protected String direccion;
|
||||
private String direccion;
|
||||
|
||||
@Type(JsonType.class)
|
||||
@Column(columnDefinition = "json")
|
||||
|
@ -14,7 +14,7 @@ import java.util.UUID;
|
||||
@Entity
|
||||
@Setter
|
||||
@Getter
|
||||
public class Event extends AbstractEntity{
|
||||
public class Event extends AbstractEntity {
|
||||
private UUID userId;
|
||||
private UUID entityId;
|
||||
private Instant timestamp;
|
||||
|
@ -6,7 +6,6 @@ import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.Type;
|
||||
@ -27,10 +26,10 @@ public class Invoice extends AbstractEntity {
|
||||
private InvoiceStatus status;
|
||||
|
||||
@NotNull
|
||||
protected LocalDateTime fechaEmision;
|
||||
private LocalDateTime fechaEmision;
|
||||
|
||||
@Size(min = 1, max = 500)
|
||||
protected String nombreRazonSocial;
|
||||
private String nombreRazonSocial;
|
||||
|
||||
@Type(JsonType.class)
|
||||
@Column(columnDefinition = "json")
|
||||
|
@ -4,7 +4,6 @@ import io.hypersistence.utils.hibernate.type.json.JsonType;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.Type;
|
||||
@ -14,7 +13,7 @@ import java.util.Map;
|
||||
@Entity
|
||||
@Setter
|
||||
@Getter
|
||||
public class Media extends AbstractEntity{
|
||||
public class Media extends AbstractEntity {
|
||||
|
||||
@NotBlank
|
||||
private String name;
|
||||
|
@ -21,17 +21,17 @@ public class PointOfSale extends AbstractEntity {
|
||||
@NotNull
|
||||
@DecimalMin(value = "0", inclusive = true)
|
||||
@DecimalMax(value = "9999", inclusive = true)
|
||||
protected int codigoSucursal;
|
||||
private int codigoSucursal;
|
||||
|
||||
@DecimalMin(value = "0", 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
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "99999999", inclusive = true)
|
||||
protected int codigoProductoSin;
|
||||
private int codigoProductoSin;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = 50)
|
||||
protected String codigoProducto;
|
||||
private String codigoProducto;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1, max = 500)
|
||||
protected String descripcion;
|
||||
private String descripcion;
|
||||
|
||||
@NotNull
|
||||
@DecimalMin(value = "1", inclusive = true)
|
||||
@DecimalMax(value = "200", inclusive = true)
|
||||
protected int unidadMedida;
|
||||
private int unidadMedida;
|
||||
|
||||
@NotNull
|
||||
@DecimalMin(value = "0", inclusive = false)
|
||||
@Digits(integer = 20, fraction = 5)
|
||||
protected BigDecimal precioUnitario;
|
||||
private BigDecimal precioUnitario;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "company_id")
|
||||
|
@ -14,7 +14,7 @@ import java.util.Map;
|
||||
@Entity
|
||||
@Setter
|
||||
@Getter
|
||||
public class Task extends AbstractEntity{
|
||||
public class Task extends AbstractEntity {
|
||||
|
||||
@NotBlank
|
||||
private BigInteger nitEmisor;
|
||||
|
@ -5,10 +5,11 @@ import com.primefactorsolutions.invoices.xsd.FacturaComputarizadaComercialExport
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FacturaComputarizadaComercialExportacionServicioValidator implements InvoiceValidator<FacturaComputarizadaComercialExportacionServicio> {
|
||||
public class FacturaComputarizadaComercialExportacionServicioValidator
|
||||
implements InvoiceValidator<FacturaComputarizadaComercialExportacionServicio> {
|
||||
|
||||
@Override
|
||||
public List<ValidationError> validate(FacturaComputarizadaComercialExportacionServicio invoice) {
|
||||
public List<ValidationError> validate(final FacturaComputarizadaComercialExportacionServicio invoice) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class SecurityService {
|
||||
|
||||
private final AuthenticationContext authenticationContext;
|
||||
|
||||
public SecurityService(AuthenticationContext authenticationContext) {
|
||||
public SecurityService(final AuthenticationContext authenticationContext) {
|
||||
this.authenticationContext = authenticationContext;
|
||||
}
|
||||
|
||||
|
@ -26,12 +26,12 @@ public class ClientService {
|
||||
private final CompanyService companyService;
|
||||
|
||||
@Transactional
|
||||
public List<Client> findAllClients(String code) {
|
||||
public List<Client> findAllClients(final String code) {
|
||||
return findAllClients(code, PageRequest.of(0, 25));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Client> findAllClients(String code, PageRequest of) {
|
||||
public List<Client> findAllClients(final String code, final PageRequest of) {
|
||||
if (Strings.isBlank(code)) {
|
||||
return clientRepository.findAll();
|
||||
}
|
||||
@ -50,14 +50,14 @@ public class ClientService {
|
||||
return result.hits();
|
||||
}
|
||||
|
||||
public void saveOrUpdateClient(Client updatedClient) {
|
||||
public void saveOrUpdateClient(final Client updatedClient) {
|
||||
updatedClient.setCompany(companyService.getCompany());
|
||||
updatedClient.setStatus(Status.ACTIVE);
|
||||
|
||||
clientRepository.save(updatedClient);
|
||||
}
|
||||
|
||||
public Client getClient(UUID uuid) {
|
||||
public Client getClient(final UUID uuid) {
|
||||
return clientRepository.findById(uuid)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Client not found"));
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import java.util.Locale;
|
||||
public class ComponentBuilder {
|
||||
private final I18NProvider i18NProvider;
|
||||
|
||||
public ButtonBuilder button(String text) {
|
||||
public ButtonBuilder button(final String text) {
|
||||
return ButtonBuilder.builder().i18NProvider(i18NProvider).text(text);
|
||||
}
|
||||
|
||||
@ -42,12 +42,12 @@ public class ComponentBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ButtonBuilder i18NProvider(I18NProvider i18NProvider) {
|
||||
public ButtonBuilder i18NProvider(final I18NProvider i18NProvider) {
|
||||
this.setI18NProvider(i18NProvider);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ButtonBuilder text(String text) {
|
||||
public ButtonBuilder text(final String text) {
|
||||
this.setText(text);
|
||||
return this;
|
||||
}
|
||||
|
@ -17,9 +17,11 @@ import freemarker.template.Template;
|
||||
import freemarker.template.TemplateExceptionHandler;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.pdfbox.io.MemoryUsageSetting;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.*;
|
||||
@ -34,6 +36,7 @@ import java.util.TimeZone;
|
||||
@Data
|
||||
@Log4j2
|
||||
public class InvoiceService {
|
||||
@Getter
|
||||
private final Help help;
|
||||
private final InvoiceRepository invoiceRepository;
|
||||
private final MediaRepository mediaRepository;
|
||||
@ -45,9 +48,9 @@ public class InvoiceService {
|
||||
}
|
||||
|
||||
@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);
|
||||
var media = new Media();
|
||||
media.setName("factura.pdf");
|
||||
@ -82,19 +85,10 @@ public class InvoiceService {
|
||||
return Invoice.class.getResourceAsStream("/pfs-invoice.html");
|
||||
}
|
||||
|
||||
public void writeAsPdf(FacturaComputarizadaComercialExportacionServicio factura, OutputStream out) {
|
||||
|
||||
public void writeAsPdf(final FacturaComputarizadaComercialExportacionServicio factura, final OutputStream out) {
|
||||
try {
|
||||
var in = getTemplate();
|
||||
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());
|
||||
Configuration cfg = getConfiguration();
|
||||
|
||||
Reader reader = new InputStreamReader(in);
|
||||
Template temp = new Template("pfs-invoice", reader, cfg);
|
||||
@ -119,7 +113,17 @@ public class InvoiceService {
|
||||
}
|
||||
}
|
||||
|
||||
public Help getHelp() {
|
||||
return help;
|
||||
@NotNull
|
||||
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 {
|
||||
private final MediaRepository mediaRepository;
|
||||
|
||||
public Media findMedia(String name) {
|
||||
public Media findMedia(final String name) {
|
||||
return mediaRepository.findAll().stream().findFirst().get();
|
||||
}
|
||||
|
||||
public List<Media> findAllMedia(String name) {
|
||||
public List<Media> findAllMedia(final String name) {
|
||||
return mediaRepository.findByNameLike(name);
|
||||
}
|
||||
|
||||
public void saveMedia(Media media) {
|
||||
public void saveMedia(final Media media) {
|
||||
mediaRepository.save(media);
|
||||
}
|
||||
}
|
||||
|
@ -15,18 +15,18 @@ public class ProductService {
|
||||
private final ProductRepository productRepository;
|
||||
private final CompanyService companyService;
|
||||
|
||||
public List<Product> findAllProducts(String name) {
|
||||
public List<Product> findAllProducts(final String name) {
|
||||
return productRepository.findAll();
|
||||
}
|
||||
|
||||
public void saveOrUpdateProduct(Product product) {
|
||||
public void saveOrUpdateProduct(final Product product) {
|
||||
var company = companyService.getCompany();
|
||||
product.setCompany(company);
|
||||
product.setStatus(Status.ACTIVE);
|
||||
productRepository.save(product);
|
||||
}
|
||||
|
||||
public Product getProduct(UUID uuid) {
|
||||
public Product getProduct(final UUID uuid) {
|
||||
return productRepository.findById(uuid).get();
|
||||
}
|
||||
}
|
||||
|
@ -19,15 +19,15 @@ public class UserService implements UserDetailsService {
|
||||
private final UserRepository userRepository;
|
||||
private final CompanyService companyService;
|
||||
|
||||
public List<User> findAllUsers(String code) {
|
||||
public List<User> findAllUsers(final String code) {
|
||||
return userRepository.findAll();
|
||||
}
|
||||
|
||||
public User getUser(UUID id) {
|
||||
public User getUser(final UUID id) {
|
||||
return userRepository.findById(id).get();
|
||||
}
|
||||
|
||||
public void saveOrUpdateUser(User updatedUser) {
|
||||
public void saveOrUpdateUser(final User updatedUser) {
|
||||
if (updatedUser.getId() == null) {
|
||||
var company = companyService.getCompany();
|
||||
updatedUser.setCompany(company);
|
||||
@ -39,7 +39,7 @@ public class UserService implements UserDetailsService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException {
|
||||
return userRepository.getByEmail(username);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import lombok.experimental.UtilityClass;
|
||||
|
||||
@UtilityClass
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -30,26 +30,31 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
||||
@PageTitle("Client | PFS Facturacion")
|
||||
public class ClientEditView extends VerticalLayout implements HasUrlParameter<String> {
|
||||
|
||||
ClientService clientService;
|
||||
I18NProvider i18NProvider;
|
||||
ComponentBuilder componentBuilder;
|
||||
GenericForm<Client> clientGenericForm;
|
||||
private final ClientService clientService;
|
||||
private final I18NProvider i18NProvider;
|
||||
private final ComponentBuilder componentBuilder;
|
||||
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.i18NProvider = i18NProvider;
|
||||
this.componentBuilder = componentBuilder;
|
||||
|
||||
var client = new Client();
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
var client = new Client();
|
||||
this.clientGenericForm = new GenericForm<>(Client.class);
|
||||
this.clientGenericForm.setBean(client);
|
||||
|
||||
var saveButton = this.componentBuilder.button("action.save").primary().build();
|
||||
saveButton.addClickListener(c -> {
|
||||
var updatedClient = clientGenericForm.getBean();
|
||||
clientService.saveOrUpdateClient(updatedClient);
|
||||
goTo(this, "clients");
|
||||
var updatedClient = clientGenericForm.getBean();
|
||||
clientService.saveOrUpdateClient(updatedClient);
|
||||
goTo(this, "clients");
|
||||
});
|
||||
var cancelButton = this.componentBuilder.button("action.cancel").build();
|
||||
cancelButton.addClickListener(c -> goTo(this, "clients"));
|
||||
@ -61,7 +66,7 @@ public class ClientEditView extends VerticalLayout implements HasUrlParameter<St
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(BeforeEvent beforeEvent, String s) {
|
||||
public void setParameter(final BeforeEvent beforeEvent, final String s) {
|
||||
if (StringUtils.isNotBlank(s) && !"new".equals(s)) {
|
||||
var product = clientService.getClient(UUID.fromString(s));
|
||||
clientGenericForm.setBean(product);
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.primefactorsolutions.invoices.views;
|
||||
|
||||
import com.primefactorsolutions.invoices.model.Client;
|
||||
import com.primefactorsolutions.invoices.model.InvoiceType;
|
||||
import com.primefactorsolutions.invoices.model.Status;
|
||||
import com.primefactorsolutions.invoices.services.ClientService;
|
||||
import com.vaadin.flow.component.Component;
|
||||
@ -29,12 +28,16 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
||||
@Route(value = "clients", layout = MainLayout.class)
|
||||
@PageTitle("Facturas | PFS Facturacion")
|
||||
public class ClientListView extends VerticalLayout {
|
||||
PagingGrid<Client> grid = new PagingGrid<>(Client.class);
|
||||
TextField filterText = new TextField();
|
||||
ClientService clientService;
|
||||
private final ClientService clientService;
|
||||
private final PagingGrid<Client> grid = new PagingGrid<>(Client.class);
|
||||
private final TextField filterText = new TextField();
|
||||
|
||||
public ClientListView(ClientService clientService) {
|
||||
public ClientListView(final ClientService clientService) {
|
||||
this.clientService = clientService;
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
addClassName("pfs-list-view");
|
||||
setSizeFull();
|
||||
configureGrid();
|
||||
|
@ -8,7 +8,6 @@ import com.primefactorsolutions.invoices.views.component.GenericForm;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
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.orderedlayout.HorizontalLayout;
|
||||
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.spring.annotation.SpringComponent;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.vaadin.firitin.components.textfield.VBigDecimalField;
|
||||
import org.vaadin.firitin.fields.ElementCollectionField;
|
||||
import org.vaadin.firitin.fields.EnumSelect;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
||||
@ -37,21 +33,27 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
||||
@PageTitle("Compania | PFS Facturacion")
|
||||
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.i18NProvider = i18NProvider;
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
var company = this.companyService.getCompany();
|
||||
|
||||
var companyGenericForm = new GenericForm<>(Company.class);
|
||||
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);
|
||||
saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
saveButton.addClickListener(c -> {
|
||||
var updatedCompany = companyGenericForm.getBean();
|
||||
companyService.saveOrUpdateCompany(updatedCompany);
|
||||
var updatedCompany = companyGenericForm.getBean();
|
||||
this.companyService.saveOrUpdateCompany(updatedCompany);
|
||||
});
|
||||
var cancelButton = new Button("Cancel");
|
||||
cancelButton.addClickListener(c -> goTo(this, ""));
|
||||
@ -68,19 +70,21 @@ public class CompanyEditView extends VerticalLayout {
|
||||
|
||||
|
||||
private Component getCurrencyForm() {
|
||||
ElementCollectionField<CurrencyPair> field = new ElementCollectionField<>(CurrencyPair.class, CurrencyEditor.class)
|
||||
.withEditorInstantiator(CurrencyEditor::new);
|
||||
ElementCollectionField<CurrencyPair> field =
|
||||
new ElementCollectionField<>(CurrencyPair.class, CurrencyEditor.class)
|
||||
.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));
|
||||
|
||||
return field;
|
||||
}
|
||||
|
||||
public static class CurrencyEditor {
|
||||
EnumSelect<CurrencyPair.CurrencyType> base = new EnumSelect<>(CurrencyPair.CurrencyType.class);
|
||||
EnumSelect<CurrencyPair.CurrencyType> quote = new EnumSelect<>(CurrencyPair.CurrencyType.class);
|
||||
BigDecimalField bid = new BigDecimalField();
|
||||
BigDecimalField ask = new BigDecimalField();
|
||||
private final EnumSelect<CurrencyPair.CurrencyType> base = new EnumSelect<>(CurrencyPair.CurrencyType.class);
|
||||
private final EnumSelect<CurrencyPair.CurrencyType> quote = new EnumSelect<>(CurrencyPair.CurrencyType.class);
|
||||
private final BigDecimalField bid = new BigDecimalField();
|
||||
private final BigDecimalField ask = new BigDecimalField();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.primefactorsolutions.invoices.views;
|
||||
|
||||
|
||||
import com.vaadin.flow.component.ScrollOptions;
|
||||
import com.vaadin.flow.component.Text;
|
||||
import com.vaadin.flow.component.UI;
|
||||
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.ErrorHandler;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.aspectj.weaver.ast.Not;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Log4j2
|
||||
public class CustomErrorHandler implements ErrorHandler {
|
||||
@Override
|
||||
public void error(ErrorEvent errorEvent) {
|
||||
public void error(final ErrorEvent errorEvent) {
|
||||
log.error("Something wrong happened", errorEvent.getThrowable());
|
||||
if(UI.getCurrent() != null) {
|
||||
if (UI.getCurrent() != null) {
|
||||
UI.getCurrent().access(() -> {
|
||||
var notification = new Notification();
|
||||
notification.addThemeVariants(NotificationVariant.LUMO_ERROR);
|
||||
notification.setPosition(Notification.Position.TOP_CENTER);
|
||||
notification.setDuration(0);
|
||||
var layout = new HorizontalLayout(new Text("An internal error has occurred." +
|
||||
"Contact support for assistance."), new CloseButton());
|
||||
var layout = new HorizontalLayout(
|
||||
new Text("An internal error has occurred. Contact support for assistance."),
|
||||
new CloseButton());
|
||||
layout.setAlignItems(FlexComponent.Alignment.CENTER);
|
||||
notification.add(layout);
|
||||
notification.open();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.primefactorsolutions.invoices.views;
|
||||
|
||||
|
||||
import com.vaadin.flow.server.ServiceInitEvent;
|
||||
import com.vaadin.flow.server.VaadinServiceInitListener;
|
||||
import com.vaadin.flow.server.VaadinSession;
|
||||
@ -12,7 +11,7 @@ import org.springframework.stereotype.Component;
|
||||
public class InitListener implements VaadinServiceInitListener {
|
||||
|
||||
@Override
|
||||
public void serviceInit(ServiceInitEvent event) {
|
||||
public void serviceInit(final ServiceInitEvent event) {
|
||||
event.getSource().addSessionInitListener(
|
||||
initEvent -> {
|
||||
log.info("A new Session has been initialized!");
|
||||
|
@ -30,14 +30,16 @@ import java.util.List;
|
||||
@Route(value = "", layout = MainLayout.class)
|
||||
@PageTitle("Facturas | PFS Facturacion")
|
||||
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();
|
||||
|
||||
InvoiceService invoiceService;
|
||||
|
||||
public InvoiceListView(InvoiceService invoiceService) {
|
||||
public InvoiceListView(final InvoiceService invoiceService) {
|
||||
this.invoiceService = invoiceService;
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
addClassName("list-view");
|
||||
setSizeFull();
|
||||
configureGrid();
|
||||
|
@ -18,8 +18,14 @@ import java.io.ByteArrayInputStream;
|
||||
@Route(value = "invoice-pdf", layout = MainLayout.class)
|
||||
@PageTitle("Vista | PFS Facturacion")
|
||||
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 content = media.getContent();
|
||||
var pdfViewer = new PdfViewer();
|
||||
|
@ -16,7 +16,7 @@ public class LoginView extends VerticalLayout implements BeforeEnterObserver {
|
||||
|
||||
private final LoginForm login = new LoginForm();
|
||||
|
||||
public LoginView(){
|
||||
public LoginView() {
|
||||
addClassName("login-view");
|
||||
setSizeFull();
|
||||
setAlignItems(Alignment.CENTER);
|
||||
@ -31,7 +31,7 @@ public class LoginView extends VerticalLayout implements BeforeEnterObserver {
|
||||
@Override
|
||||
public void beforeEnter(final BeforeEnterEvent beforeEnterEvent) {
|
||||
// inform the user about an authentication error
|
||||
if(beforeEnterEvent.getLocation()
|
||||
if (beforeEnterEvent.getLocation()
|
||||
.getQueryParameters()
|
||||
.getParameters()
|
||||
.containsKey("error")) {
|
||||
|
@ -15,7 +15,7 @@ import org.springframework.security.core.userdetails.UserDetails;
|
||||
public class MainLayout extends AppLayout {
|
||||
private final SecurityService securityService;
|
||||
|
||||
public MainLayout(SecurityService securityService) {
|
||||
public MainLayout(final SecurityService securityService) {
|
||||
this.securityService = securityService;
|
||||
createHeader();
|
||||
createDrawer();
|
||||
|
@ -18,7 +18,6 @@ import jakarta.annotation.security.PermitAll;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.vaadin.firitin.components.button.VButton;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -33,13 +32,17 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
||||
@PageTitle("Product | PFS Facturacion")
|
||||
public class ProductEditView extends VerticalLayout implements HasUrlParameter<String> {
|
||||
|
||||
ProductService productService;
|
||||
I18NProvider i18NProvider;
|
||||
GenericForm<Product> productGenericForm;
|
||||
private final ProductService productService;
|
||||
private final I18NProvider i18NProvider;
|
||||
private GenericForm<Product> productGenericForm;
|
||||
|
||||
public ProductEditView(ProductService productService, I18NProvider i18NProvider) {
|
||||
public ProductEditView(final ProductService productService, final I18NProvider i18NProvider) {
|
||||
this.productService = productService;
|
||||
this.i18NProvider = i18NProvider;
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
var product = new Product();
|
||||
|
||||
this.productGenericForm = new GenericForm<>(Product.class);
|
||||
@ -49,9 +52,9 @@ public class ProductEditView extends VerticalLayout implements HasUrlParameter<S
|
||||
var saveButton = new Button(text);
|
||||
saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
saveButton.addClickListener(c -> {
|
||||
var updatedProduct = productGenericForm.getBean();
|
||||
productService.saveOrUpdateProduct(updatedProduct);
|
||||
goTo(this, "products");
|
||||
var updatedProduct = this.productGenericForm.getBean();
|
||||
this.productService.saveOrUpdateProduct(updatedProduct);
|
||||
goTo(this, "products");
|
||||
});
|
||||
var cancelButton = new Button("Cancel");
|
||||
cancelButton.addClickListener(c -> goTo(this, "products"));
|
||||
@ -63,7 +66,7 @@ public class ProductEditView extends VerticalLayout implements HasUrlParameter<S
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(BeforeEvent beforeEvent, String s) {
|
||||
public void setParameter(final BeforeEvent beforeEvent, final String s) {
|
||||
if (StringUtils.isNotBlank(s) && !"new".equals(s)) {
|
||||
var product = productService.getProduct(UUID.fromString(s));
|
||||
productGenericForm.setBean(product);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.primefactorsolutions.invoices.views;
|
||||
|
||||
import com.primefactorsolutions.invoices.model.InvoiceType;
|
||||
import com.primefactorsolutions.invoices.model.Product;
|
||||
import com.primefactorsolutions.invoices.model.Status;
|
||||
import com.primefactorsolutions.invoices.services.ProductService;
|
||||
@ -29,12 +28,16 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
||||
@Route(value = "products", layout = MainLayout.class)
|
||||
@PageTitle("Facturas | PFS Facturacion")
|
||||
public class ProductListView extends VerticalLayout {
|
||||
PagingGrid<Product> grid = new PagingGrid<>(Product.class);
|
||||
TextField filterText = new TextField();
|
||||
ProductService productService;
|
||||
private final ProductService productService;
|
||||
private final PagingGrid<Product> grid = new PagingGrid<>(Product.class);
|
||||
private final TextField filterText = new TextField();
|
||||
|
||||
public ProductListView(ProductService productService) {
|
||||
public ProductListView(final ProductService productService) {
|
||||
this.productService = productService;
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
addClassName("list-view");
|
||||
setSizeFull();
|
||||
configureGrid();
|
||||
|
@ -6,8 +6,6 @@ import com.primefactorsolutions.invoices.views.component.Breadcrumbs;
|
||||
import com.primefactorsolutions.invoices.views.component.GenericForm;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
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.VerticalLayout;
|
||||
import com.vaadin.flow.i18n.I18NProvider;
|
||||
@ -34,13 +32,17 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
||||
@PageTitle("User | PFS Facturacion")
|
||||
public class UserEditView extends VerticalLayout implements HasUrlParameter<String> {
|
||||
|
||||
UserService userService;
|
||||
I18NProvider i18NProvider;
|
||||
GenericForm<User> userGenericForm;
|
||||
private final UserService userService;
|
||||
private final I18NProvider i18NProvider;
|
||||
private GenericForm<User> userGenericForm;
|
||||
|
||||
public UserEditView(UserService userService, I18NProvider i18NProvider) {
|
||||
public UserEditView(final UserService userService, final I18NProvider i18NProvider) {
|
||||
this.userService = userService;
|
||||
this.i18NProvider = i18NProvider;
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
var user = new User();
|
||||
|
||||
this.userGenericForm = new GenericForm<>(User.class);
|
||||
@ -50,8 +52,8 @@ public class UserEditView extends VerticalLayout implements HasUrlParameter<Stri
|
||||
var saveButton = new Button(text);
|
||||
saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
saveButton.addClickListener(c -> {
|
||||
var updatedUser = userGenericForm.getBean();
|
||||
userService.saveOrUpdateUser(updatedUser);
|
||||
var updatedUser = this.userGenericForm.getBean();
|
||||
this.userService.saveOrUpdateUser(updatedUser);
|
||||
goTo(this, "users");
|
||||
});
|
||||
var cancelButton = new Button("Cancel");
|
||||
@ -66,7 +68,7 @@ public class UserEditView extends VerticalLayout implements HasUrlParameter<Stri
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(BeforeEvent beforeEvent, String s) {
|
||||
public void setParameter(final BeforeEvent beforeEvent, final String s) {
|
||||
if (StringUtils.isNotBlank(s) && !"new".equals(s)) {
|
||||
var user = userService.getUser(UUID.fromString(s));
|
||||
userGenericForm.setBean(user);
|
||||
|
@ -28,12 +28,16 @@ import java.util.List;
|
||||
@Route(value = "users", layout = MainLayout.class)
|
||||
@PageTitle("Facturas | PFS Facturacion")
|
||||
public class UserListView extends VerticalLayout {
|
||||
PagingGrid<User> grid = new PagingGrid<>(User.class);
|
||||
TextField filterText = new TextField();
|
||||
UserService userService;
|
||||
private final PagingGrid<User> grid = new PagingGrid<>(User.class);
|
||||
private final TextField filterText = new TextField();
|
||||
private final UserService userService;
|
||||
|
||||
public UserListView(UserService userService) {
|
||||
public UserListView(final UserService userService) {
|
||||
this.userService = userService;
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
addClassName("list-view");
|
||||
setSizeFull();
|
||||
configureGrid();
|
||||
|
@ -43,10 +43,9 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
||||
/**
|
||||
* Constructs an empty {@code LongField} with the given label.
|
||||
*
|
||||
* @param label
|
||||
* the text to set as the label
|
||||
* @param label the text to set as the label
|
||||
*/
|
||||
public BigIntegerField(String label) {
|
||||
public BigIntegerField(final String label) {
|
||||
this();
|
||||
setLabel(label);
|
||||
}
|
||||
@ -55,12 +54,10 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
||||
* Constructs an empty {@code LongField} with the given label and
|
||||
* placeholder text.
|
||||
*
|
||||
* @param label
|
||||
* the text to set as the label
|
||||
* @param placeholder
|
||||
* the placeholder text to set
|
||||
* @param label the text to set as the label
|
||||
* @param placeholder the placeholder text to set
|
||||
*/
|
||||
public BigIntegerField(String label, String placeholder) {
|
||||
public BigIntegerField(final String label, final String placeholder) {
|
||||
this(label);
|
||||
setPlaceholder(placeholder);
|
||||
}
|
||||
@ -68,13 +65,11 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
||||
/**
|
||||
* Constructs an empty {@code LongField} with a value change listener.
|
||||
*
|
||||
* @param listener
|
||||
* the value change listener
|
||||
*
|
||||
* @param listener the value change listener
|
||||
* @see #addValueChangeListener(ValueChangeListener)
|
||||
*/
|
||||
public BigIntegerField(
|
||||
ValueChangeListener<? super ComponentValueChangeEvent<BigIntegerField, BigInteger>> listener) {
|
||||
final ValueChangeListener<? super ComponentValueChangeEvent<BigIntegerField, BigInteger>> listener) {
|
||||
this();
|
||||
addValueChangeListener(listener);
|
||||
}
|
||||
@ -83,16 +78,14 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
||||
* Constructs an empty {@code LongField} with a value change listener and
|
||||
* a label.
|
||||
*
|
||||
* @param label
|
||||
* the text to set as the label
|
||||
* @param listener
|
||||
* the value change listener
|
||||
*
|
||||
* @param label the text to set as the label
|
||||
* @param listener the value change listener
|
||||
* @see #setLabel(String)
|
||||
* @see #addValueChangeListener(ValueChangeListener)
|
||||
*/
|
||||
public BigIntegerField(String label,
|
||||
ValueChangeListener<? super ComponentValueChangeEvent<BigIntegerField, BigInteger>> listener) {
|
||||
public BigIntegerField(
|
||||
final String label,
|
||||
final ValueChangeListener<? super ComponentValueChangeEvent<BigIntegerField, BigInteger>> listener) {
|
||||
this(label);
|
||||
addValueChangeListener(listener);
|
||||
}
|
||||
@ -101,19 +94,17 @@ public class BigIntegerField extends AbstractNumberField<BigIntegerField, BigInt
|
||||
* Constructs a {@code LongField} with a value change listener, a label
|
||||
* and an initial value.
|
||||
*
|
||||
* @param label
|
||||
* the text to set as the label
|
||||
* @param initialValue
|
||||
* the initial value
|
||||
* @param listener
|
||||
* the value change listener
|
||||
*
|
||||
* @param label the text to set as the label
|
||||
* @param initialValue the initial value
|
||||
* @param listener the value change listener
|
||||
* @see #setLabel(String)
|
||||
* @see #setValue(Object)
|
||||
* @see #addValueChangeListener(ValueChangeListener)
|
||||
*/
|
||||
public BigIntegerField(String label, BigInteger initialValue,
|
||||
ValueChangeListener<? super ComponentValueChangeEvent<BigIntegerField, BigInteger>> listener) {
|
||||
public BigIntegerField(
|
||||
final String label,
|
||||
final BigInteger initialValue,
|
||||
final ValueChangeListener<? super ComponentValueChangeEvent<BigIntegerField, BigInteger>> listener) {
|
||||
this(label);
|
||||
setValue(initialValue);
|
||||
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
|
||||
* than {@code min} invalidates the field.
|
||||
*
|
||||
* @param min
|
||||
* the min value to set
|
||||
* @param min the min value to set
|
||||
*/
|
||||
public void setMin(int min) {
|
||||
public void setMin(final int 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
|
||||
* than {@code max} invalidates the field.
|
||||
*
|
||||
* @param max
|
||||
* the max value to set
|
||||
* @param max the max value to set
|
||||
*/
|
||||
public void setMax(int max) {
|
||||
public void setMax(final int 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
|
||||
* and {@link #setMin(int) min} (if specified by user).
|
||||
*
|
||||
* @param step
|
||||
* the new step to set
|
||||
* @throws IllegalArgumentException
|
||||
* if the argument is less or equal to zero.
|
||||
* @param step the new step to set
|
||||
* @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) {
|
||||
throw new IllegalArgumentException(
|
||||
"The step cannot be less or equal to zero.");
|
||||
|
@ -10,15 +10,15 @@ import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Breadcrumbs extends HorizontalLayout {
|
||||
public Breadcrumbs(List<Pair<String, String>> parts) {
|
||||
public Breadcrumbs(final List<Pair<String, String>> parts) {
|
||||
var components = parts.stream()
|
||||
.flatMap(p -> {
|
||||
if (p.getValue() == null) {
|
||||
return Stream.of((Component)new Span(p.getKey()), (Component)new Span(">"));
|
||||
} else {
|
||||
return Stream.of((Component)new Anchor(p.getValue(), p.getKey()), (Component)new Span(">"));
|
||||
}
|
||||
}).toList();
|
||||
if (p.getValue() == null) {
|
||||
return Stream.of(new Span(p.getKey()), (Component) new Span(">"));
|
||||
} else {
|
||||
return Stream.of(new Anchor(p.getValue(), p.getKey()), (Component) new Span(">"));
|
||||
}
|
||||
}).toList();
|
||||
|
||||
if (components.size() > 1) {
|
||||
this.add(components.subList(0, components.size() - 1));
|
||||
|
@ -12,9 +12,9 @@ import java.util.stream.Collectors;
|
||||
|
||||
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.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> {
|
||||
GenericForm<T> element = new GenericForm<>(elementClazz);
|
||||
@ -30,10 +30,10 @@ public class CollectionContainer<T> extends VerticalLayout implements Bindable<L
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBean(Object bean) {
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
elements.get(i).setBean(((List<T>)bean).get(i));
|
||||
}
|
||||
public void setBean(final Object bean) {
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
elements.get(i).setBean(((List<T>) bean).get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,29 +33,29 @@ import java.util.stream.Stream;
|
||||
import static com.primefactorsolutions.invoices.utils.TextUtils.makeLabel;
|
||||
|
||||
public class GenericForm<T> extends VerticalLayout implements Bindable<T> {
|
||||
Binder<T> binder;
|
||||
List<Pair<String, GenericForm<?>>> inner2 = new ArrayList<>();
|
||||
List<Pair<String, CollectionContainer<?>>> inner = new ArrayList<>();
|
||||
private Binder<T> binder;
|
||||
private final List<Pair<String, GenericForm<?>>> inner2 = new ArrayList<>();
|
||||
private final List<Pair<String, CollectionContainer<?>>> inner = new ArrayList<>();
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
public GenericForm(Class<T> tClass, boolean withDetails) {
|
||||
public GenericForm(final Class<T> tClass, final boolean withDetails) {
|
||||
this.recursive = false;
|
||||
this.tClass = tClass;
|
||||
this.binder = new BeanValidationBinder<>(tClass);
|
||||
List<Component> content = getComponents(tClass).toList();
|
||||
FormLayout formLayout = new FormLayout();
|
||||
formLayout.setResponsiveSteps(
|
||||
new FormLayout.ResponsiveStep("0", 1),
|
||||
new FormLayout.ResponsiveStep("500px", 1),
|
||||
new FormLayout.ResponsiveStep("800px", 1));
|
||||
new FormLayout.ResponsiveStep("0", 1),
|
||||
new FormLayout.ResponsiveStep("500px", 1),
|
||||
new FormLayout.ResponsiveStep("800px", 1));
|
||||
|
||||
if (withDetails) {
|
||||
Details details = new Details(tClass.getName());
|
||||
@ -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())
|
||||
.sorted(Comparator.comparing(Field::getName))
|
||||
.flatMap(field -> {
|
||||
@ -98,14 +98,16 @@ public class GenericForm<T> extends VerticalLayout implements Bindable<T> {
|
||||
|
||||
if (field.getType().equals(String.class)) {
|
||||
component = new TextField(label);
|
||||
binder.forField((TextField)component)
|
||||
binder.forField((TextField) component)
|
||||
.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);
|
||||
binder.forField(formField)
|
||||
.bind(field.getName());
|
||||
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);
|
||||
binder.forField(formField)
|
||||
.bind(field.getName());
|
||||
@ -115,10 +117,10 @@ public class GenericForm<T> extends VerticalLayout implements Bindable<T> {
|
||||
binder.forField(formField)
|
||||
.bind(field.getName());
|
||||
component = formField;
|
||||
} else if (field.getType().equals(Double.class) ||
|
||||
field.getType().equals(Double.TYPE) ||
|
||||
field.getType().equals(Float.class) ||
|
||||
field.getType().equals(Float.TYPE)) {
|
||||
} else if (field.getType().equals(Double.class)
|
||||
|| field.getType().equals(Double.TYPE)
|
||||
|| field.getType().equals(Float.class)
|
||||
|| field.getType().equals(Float.TYPE)) {
|
||||
var formField = new NumberField(label);
|
||||
binder.forField(formField)
|
||||
.bind(field.getName());
|
||||
@ -155,10 +157,10 @@ public class GenericForm<T> extends VerticalLayout implements Bindable<T> {
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void setBean(Object bean) {
|
||||
public void setBean(final Object 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);
|
||||
if (foo == null) {
|
||||
foo = tClass.getDeclaredField(b.getKey()).getType().getConstructor().newInstance();
|
||||
@ -172,19 +174,17 @@ public class GenericForm<T> extends VerticalLayout implements Bindable<T> {
|
||||
public T getBean() {
|
||||
T result = binder.getBean();
|
||||
|
||||
for(Pair<String, GenericForm<?>> b: inner2) {
|
||||
for (Pair<String, GenericForm<?>> b : inner2) {
|
||||
Object foo = b.getValue().getBean();
|
||||
tClass.getDeclaredMethod("set" + StringUtils.capitalize(b.getKey()), b.getValue().getTClass())
|
||||
.invoke(result, foo);
|
||||
}
|
||||
|
||||
for (Pair<String, CollectionContainer<?>> b: inner) {
|
||||
for (Pair<String, CollectionContainer<?>> b : inner) {
|
||||
List<?> foo = b.getValue().getBean();
|
||||
tClass.getDeclaredMethod("set" + StringUtils.capitalize(b.getKey()), List.class).invoke(result, foo);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
||||
* @param label
|
||||
* the text to set as the label
|
||||
*/
|
||||
public LongField(String label) {
|
||||
public LongField(final String label) {
|
||||
this();
|
||||
setLabel(label);
|
||||
}
|
||||
@ -58,7 +58,7 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
||||
* @param placeholder
|
||||
* the placeholder text to set
|
||||
*/
|
||||
public LongField(String label, String placeholder) {
|
||||
public LongField(final String label, final String placeholder) {
|
||||
this(label);
|
||||
setPlaceholder(placeholder);
|
||||
}
|
||||
@ -72,7 +72,7 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
||||
* @see #addValueChangeListener(ValueChangeListener)
|
||||
*/
|
||||
public LongField(
|
||||
ValueChangeListener<? super ComponentValueChangeEvent<LongField, Long>> listener) {
|
||||
final ValueChangeListener<? super ComponentValueChangeEvent<LongField, Long>> listener) {
|
||||
this();
|
||||
addValueChangeListener(listener);
|
||||
}
|
||||
@ -89,8 +89,8 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
||||
* @see #setLabel(String)
|
||||
* @see #addValueChangeListener(ValueChangeListener)
|
||||
*/
|
||||
public LongField(String label,
|
||||
ValueChangeListener<? super ComponentValueChangeEvent<LongField, Long>> listener) {
|
||||
public LongField(final String label,
|
||||
final ValueChangeListener<? super ComponentValueChangeEvent<LongField, Long>> listener) {
|
||||
this(label);
|
||||
addValueChangeListener(listener);
|
||||
}
|
||||
@ -110,8 +110,8 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
||||
* @see #setValue(Object)
|
||||
* @see #addValueChangeListener(ValueChangeListener)
|
||||
*/
|
||||
public LongField(String label, Long initialValue,
|
||||
ValueChangeListener<? super ComponentValueChangeEvent<LongField, Long>> listener) {
|
||||
public LongField(final String label, final Long initialValue,
|
||||
final ValueChangeListener<? super ComponentValueChangeEvent<LongField, Long>> listener) {
|
||||
this(label);
|
||||
setValue(initialValue);
|
||||
addValueChangeListener(listener);
|
||||
@ -124,7 +124,7 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
||||
* @param min
|
||||
* the min value to set
|
||||
*/
|
||||
public void setMin(int min) {
|
||||
public void setMin(final int min) {
|
||||
super.setMin(min);
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
||||
* @param max
|
||||
* the max value to set
|
||||
*/
|
||||
public void setMax(int max) {
|
||||
public void setMax(final int max) {
|
||||
super.setMax(max);
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ public class LongField extends AbstractNumberField<LongField, Long>
|
||||
* @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) {
|
||||
throw new IllegalArgumentException(
|
||||
"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.data.binder.BeanValidationBinder;
|
||||
import com.vaadin.flow.data.binder.Binder;
|
||||
import lombok.Getter;
|
||||
|
||||
public class CabeceraForm<T> extends FormLayout {
|
||||
public Binder<T> binder;
|
||||
@Getter
|
||||
private Binder<T> binder;
|
||||
|
||||
LongField nitEmisor = new LongField("nitEmisor");
|
||||
TextField razonSocialEmisor = new TextField("razonSocialEmisor");
|
||||
TextField municipio = new TextField("municipio");
|
||||
TextField telefono = new TextField("telefono");
|
||||
IntegerField codigoSucursal = new IntegerField("codigoSucursal");
|
||||
TextField direccion = new TextField("direccion");
|
||||
IntegerField codigoPuntoVenta = new IntegerField("codigoPuntoVenta");
|
||||
DateTimePicker fechaEmision = new DateTimePicker("fechaEmision");
|
||||
IntegerField codigoMoneda = new IntegerField("codigoMoneda");
|
||||
BigDecimalField tipoCambio = new BigDecimalField("tipoCambio");
|
||||
private final LongField nitEmisor = new LongField("nitEmisor");
|
||||
private final TextField razonSocialEmisor = new TextField("razonSocialEmisor");
|
||||
private final TextField municipio = new TextField("municipio");
|
||||
private final TextField telefono = new TextField("telefono");
|
||||
private final IntegerField codigoSucursal = new IntegerField("codigoSucursal");
|
||||
private final TextField direccion = new TextField("direccion");
|
||||
private final IntegerField codigoPuntoVenta = new IntegerField("codigoPuntoVenta");
|
||||
private final DateTimePicker fechaEmision = new DateTimePicker("fechaEmision");
|
||||
private final IntegerField codigoMoneda = new IntegerField("codigoMoneda");
|
||||
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.bindInstanceFields(this);
|
||||
setResponsiveSteps(
|
||||
|
@ -6,21 +6,27 @@ import com.vaadin.flow.component.textfield.IntegerField;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
||||
import com.vaadin.flow.data.binder.Binder;
|
||||
import lombok.Getter;
|
||||
|
||||
public class ClientForm<T> extends FormLayout {
|
||||
public Binder<T> binder;
|
||||
TextField nombreRazonSocial = new TextField("nombreRazonSocial");
|
||||
IntegerField codigoTipoDocumentoIdentidad = new IntegerField("codigoTipoDocumentoIdentidad");
|
||||
TextField numeroDocumento = new TextField("numeroDocumento");
|
||||
TextField complemento = new TextField("complemento");
|
||||
TextField direccionComprador = new TextField("direccionComprador");
|
||||
TextField codigoCliente = new TextField("codigoCliente");
|
||||
TextField lugarDestino = new TextField("lugarDestino");
|
||||
IntegerField codigoPais = new IntegerField("codigoPais");
|
||||
IntegerField codigoMetodoPago = new IntegerField("codigoMetodoPago");
|
||||
LongField numeroTarjeta = new LongField("numeroTarjeta");
|
||||
@Getter
|
||||
private Binder<T> binder;
|
||||
private final TextField nombreRazonSocial = new TextField("nombreRazonSocial");
|
||||
private final IntegerField codigoTipoDocumentoIdentidad = new IntegerField("codigoTipoDocumentoIdentidad");
|
||||
private final TextField numeroDocumento = new TextField("numeroDocumento");
|
||||
private final TextField complemento = new TextField("complemento");
|
||||
private final TextField direccionComprador = new TextField("direccionComprador");
|
||||
private final TextField codigoCliente = new TextField("codigoCliente");
|
||||
private final TextField lugarDestino = new TextField("lugarDestino");
|
||||
private final IntegerField codigoPais = new IntegerField("codigoPais");
|
||||
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.bindInstanceFields(this);
|
||||
setResponsiveSteps(
|
||||
@ -31,15 +37,15 @@ public class ClientForm<T> extends FormLayout {
|
||||
setColspan(direccionComprador, 5);
|
||||
|
||||
add(nombreRazonSocial,
|
||||
direccionComprador,
|
||||
codigoTipoDocumentoIdentidad,
|
||||
numeroDocumento,
|
||||
complemento,
|
||||
codigoCliente,
|
||||
lugarDestino,
|
||||
codigoPais,
|
||||
codigoMetodoPago,
|
||||
numeroTarjeta
|
||||
direccionComprador,
|
||||
codigoTipoDocumentoIdentidad,
|
||||
numeroDocumento,
|
||||
complemento,
|
||||
codigoCliente,
|
||||
lugarDestino,
|
||||
codigoPais,
|
||||
codigoMetodoPago,
|
||||
numeroTarjeta
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,17 +7,25 @@ import com.vaadin.flow.component.combobox.ComboBox;
|
||||
import com.vaadin.flow.component.formlayout.FormLayout;
|
||||
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
||||
import com.vaadin.flow.data.binder.Binder;
|
||||
import lombok.Getter;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ClientInputForm extends FormLayout {
|
||||
public Binder<Client> binder;
|
||||
ComboBox<Client> queryText = new ComboBox<>("correoElectronico o telefono");
|
||||
List<Consumer<Client>> listeners = Lists.newArrayList();
|
||||
@Getter
|
||||
private Binder<Client> binder;
|
||||
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);
|
||||
|
||||
queryText.setPlaceholder("Buscar ...");
|
||||
@ -26,7 +34,7 @@ public class ClientInputForm extends FormLayout {
|
||||
query -> {
|
||||
var limit = Math.min(query.getPageSize(), query.getLimit());
|
||||
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();
|
||||
},
|
||||
personSearchTerm -> personSearchTerm
|
||||
@ -36,7 +44,7 @@ public class ClientInputForm extends FormLayout {
|
||||
add(queryText);
|
||||
}
|
||||
|
||||
public void addListener(Consumer<Client> listener) {
|
||||
public void addListener(final Consumer<Client> 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.data.binder.BeanValidationBinder;
|
||||
import com.vaadin.flow.data.binder.Binder;
|
||||
import lombok.Getter;
|
||||
|
||||
import static com.primefactorsolutions.invoices.utils.TextUtils.makeLabel;
|
||||
|
||||
public class DetalleForm<T> extends FormLayout {
|
||||
Binder<T> binder;
|
||||
@Getter
|
||||
private Binder<T> binder;
|
||||
|
||||
TextField actividadEconomica = new TextField(makeLabel("actividadEconomica"));
|
||||
TextField descripcion = new TextField("descripcion");
|
||||
BigIntegerField cantidad = new BigIntegerField("cantidad");
|
||||
IntegerField unidadMedida = new IntegerField("unidadMedida");
|
||||
BigDecimalField precioUnitario = new BigDecimalField("precioUnitario");
|
||||
BigDecimalField montoDescuento = new BigDecimalField("montoDescuento");
|
||||
BigDecimalField subTotal = new BigDecimalField("subTotal");
|
||||
Hr separator = new Hr();
|
||||
private final TextField actividadEconomica = new TextField(makeLabel("actividadEconomica"));
|
||||
private final TextField descripcion = new TextField("descripcion");
|
||||
private final BigIntegerField cantidad = new BigIntegerField("cantidad");
|
||||
private final IntegerField unidadMedida = new IntegerField("unidadMedida");
|
||||
private final BigDecimalField precioUnitario = new BigDecimalField("precioUnitario");
|
||||
private final BigDecimalField montoDescuento = new BigDecimalField("montoDescuento");
|
||||
private final BigDecimalField subTotal = new BigDecimalField("subTotal");
|
||||
private final Hr separator = new Hr();
|
||||
|
||||
DetalleForm(Class<T> clazz) {
|
||||
DetalleForm(final Class<T> clazz) {
|
||||
super();
|
||||
initView(clazz);
|
||||
}
|
||||
|
||||
private void initView(final Class<T> clazz) {
|
||||
binder = new BeanValidationBinder<>(clazz);
|
||||
binder.bindInstanceFields(this);
|
||||
setResponsiveSteps(
|
||||
@ -35,13 +41,13 @@ public class DetalleForm<T> extends FormLayout {
|
||||
setColspan(separator, 6);
|
||||
|
||||
add(descripcion,
|
||||
actividadEconomica,
|
||||
cantidad,
|
||||
unidadMedida,
|
||||
precioUnitario,
|
||||
montoDescuento,
|
||||
subTotal,
|
||||
separator
|
||||
actividadEconomica,
|
||||
cantidad,
|
||||
unidadMedida,
|
||||
precioUnitario,
|
||||
montoDescuento,
|
||||
subTotal,
|
||||
separator
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,10 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class DetallesForm<T> extends VerticalLayout {
|
||||
|
||||
Class<T> clazz;
|
||||
Supplier<T> supplier;
|
||||
private final Class<T> clazz;
|
||||
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.supplier = supplier;
|
||||
addDetalle();
|
||||
@ -26,9 +26,9 @@ public class DetallesForm<T> extends VerticalLayout {
|
||||
var content = new VerticalLayout();
|
||||
var value = supplier.get();
|
||||
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));
|
||||
});
|
||||
|
||||
@ -40,15 +40,13 @@ public class DetallesForm<T> extends VerticalLayout {
|
||||
add(content);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<T> getValues() {
|
||||
return getChildren()
|
||||
.flatMap(d -> {
|
||||
return d.getChildren()
|
||||
.map(c -> {
|
||||
if (c instanceof DetalleForm) {
|
||||
return ((DetalleForm<T>) c).binder.getBean();
|
||||
return ((DetalleForm<T>) c).getBinder().getBean();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -59,14 +57,14 @@ public class DetallesForm<T> extends VerticalLayout {
|
||||
}
|
||||
|
||||
public Registration addChangeListener(
|
||||
ComponentEventListener<DetallesForm.ChangeEvent> listener) {
|
||||
final ComponentEventListener<DetallesForm.ChangeEvent> listener) {
|
||||
return addListener(DetallesForm.ChangeEvent.class, listener);
|
||||
}
|
||||
|
||||
public static class ChangeEvent
|
||||
extends ComponentEvent<DetallesForm<?>> {
|
||||
public ChangeEvent(DetallesForm source,
|
||||
boolean fromClient) {
|
||||
public ChangeEvent(final DetallesForm source,
|
||||
final boolean 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.data.binder.BeanValidationBinder;
|
||||
import com.vaadin.flow.data.binder.Binder;
|
||||
import lombok.Getter;
|
||||
|
||||
public class TotalesForm<T> extends FormLayout {
|
||||
public Binder<T> binder;
|
||||
BigDecimalField montoTotal = new BigDecimalField("montoTotal");
|
||||
BigDecimalField montoTotalSujetoIva = new BigDecimalField("montoTotalSujetoIva");
|
||||
BigDecimalField montoTotalMoneda = new BigDecimalField("montoTotalMoneda");
|
||||
TextField informacionAdicional = new TextField("informacionAdicional");
|
||||
BigDecimalField descuentoAdicional = new BigDecimalField("descuentoAdicional");
|
||||
public TotalesForm(Class<T> clazz) {
|
||||
@Getter
|
||||
private Binder<T> binder;
|
||||
private final BigDecimalField montoTotal = new BigDecimalField("montoTotal");
|
||||
private final BigDecimalField montoTotalSujetoIva = new BigDecimalField("montoTotalSujetoIva");
|
||||
private final BigDecimalField montoTotalMoneda = new BigDecimalField("montoTotalMoneda");
|
||||
private final TextField informacionAdicional = new TextField("informacionAdicional");
|
||||
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.bindInstanceFields(this);
|
||||
|
||||
|
@ -33,8 +33,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
||||
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.UiUtils.goTo;
|
||||
@ -45,34 +43,38 @@ import static com.primefactorsolutions.invoices.utils.UiUtils.goTo;
|
||||
@Route(value = "edit-invoice", layout = MainLayout.class)
|
||||
@PageTitle("Factura | Editar")
|
||||
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 ClientService clientService;
|
||||
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(
|
||||
InvoiceService invoiceService,
|
||||
ClientService clientService,
|
||||
CompanyService companyService) {
|
||||
final InvoiceService invoiceService,
|
||||
final ClientService clientService,
|
||||
final CompanyService companyService) {
|
||||
this.invoiceService = invoiceService;
|
||||
this.clientService = clientService;
|
||||
this.companyService = companyService;
|
||||
|
||||
var company = companyService.getCompany();
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
var company = this.companyService.getCompany();
|
||||
var cabeceraDTO = CabeceraMapper.INSTANCE.cabeceraDtoFromCompany(company);
|
||||
this.cabeceraForm = new CabeceraForm<>(CabeceraDTO.class);
|
||||
this.cabeceraForm.binder.setBean(cabeceraDTO);
|
||||
this.cabeceraForm.getBinder().setBean(cabeceraDTO);
|
||||
|
||||
var clientDTO = new ClientDTO();
|
||||
|
||||
this.clientForm = new ClientForm<>(ClientDTO.class);
|
||||
this.clientForm.binder.setBean(clientDTO);
|
||||
this.clientForm.getBinder().setBean(clientDTO);
|
||||
|
||||
this.detalleForm = new DetallesForm<>(DetalleDTO.class, DetalleDTO::new);
|
||||
|
||||
@ -80,7 +82,7 @@ public class FacturaComputarizadaComercialExportacionesServicioEditView extends
|
||||
totalesDTO.setInformacionAdicional("Ninguno");
|
||||
totalesDTO.setDescuentoAdicional(BigDecimal.valueOf(0));
|
||||
this.totalesForm = new TotalesForm<>(TotalesDTO.class);
|
||||
this.totalesForm.binder.setBean(totalesDTO);
|
||||
this.totalesForm.getBinder().setBean(totalesDTO);
|
||||
|
||||
var emisorDetails = getEmisorDetails(cabeceraDTO);
|
||||
var clienteDetails = getClienteDetails();
|
||||
@ -111,20 +113,20 @@ public class FacturaComputarizadaComercialExportacionesServicioEditView extends
|
||||
|
||||
this.detalleForm.addChangeListener(c -> {
|
||||
var values = this.detalleForm.getValues();
|
||||
var currentTotales = this.totalesForm.binder.getBean();
|
||||
var currentTotales = this.totalesForm.getBinder().getBean();
|
||||
|
||||
var total = values.stream()
|
||||
.map(DetalleDTO::getSubTotal)
|
||||
.map(b -> b == null ? new BigDecimal(0) : b)
|
||||
.reduce(BigDecimal::add).orElse(new BigDecimal(0));
|
||||
|
||||
System.out.println(">>>>>>>>" + total);
|
||||
currentTotales.setMontoTotalMoneda(total);
|
||||
currentTotales.setMontoTotal((total.subtract(currentTotales.getDescuentoAdicional()))
|
||||
.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;
|
||||
@ -135,7 +137,7 @@ public class FacturaComputarizadaComercialExportacionesServicioEditView extends
|
||||
ClientInputForm clientInputForm = new ClientInputForm(clientService);
|
||||
clientInputForm.addListener(c -> {
|
||||
var selectedClientDTO = ClientMapper.INSTANCE.clientDtoFromClient(c);
|
||||
this.clientForm.binder.setBean(selectedClientDTO);
|
||||
this.clientForm.getBinder().setBean(selectedClientDTO);
|
||||
this.clientForm.setVisible(true);
|
||||
});
|
||||
|
||||
@ -154,7 +156,7 @@ public class FacturaComputarizadaComercialExportacionesServicioEditView extends
|
||||
if (e.isOpened()) {
|
||||
clienteText.setText("Cliente");
|
||||
} else {
|
||||
var clienteDTO = clientForm.binder.getBean();
|
||||
var clienteDTO = clientForm.getBinder().getBean();
|
||||
clienteText.setText("Cliente (" + clienteDTO.getNombreRazonSocial() + ")");
|
||||
}
|
||||
});
|
||||
@ -171,7 +173,7 @@ public class FacturaComputarizadaComercialExportacionesServicioEditView extends
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Details getEmisorDetails(CabeceraDTO cabeceraDTO) {
|
||||
private Details getEmisorDetails(final CabeceraDTO cabeceraDTO) {
|
||||
var emisorText = new Text("Emisor");
|
||||
var emisorSummary = new HorizontalLayout();
|
||||
emisorSummary.setSpacing(false);
|
||||
@ -204,9 +206,9 @@ public class FacturaComputarizadaComercialExportacionesServicioEditView extends
|
||||
|
||||
this.save.addClickListener(e -> {
|
||||
var factura = new FacturaComputarizadaComercialExportacionServicio();
|
||||
var cabecera = CabeceraMapper.INSTANCE.cabeceraFromDtos(this.cabeceraForm.binder.getBean(),
|
||||
this.clientForm.binder.getBean(),
|
||||
this.totalesForm.binder.getBean());
|
||||
var cabecera = CabeceraMapper.INSTANCE.cabeceraFromDtos(this.cabeceraForm.getBinder().getBean(),
|
||||
this.clientForm.getBinder().getBean(),
|
||||
this.totalesForm.getBinder().getBean());
|
||||
var detalles = detalleForm.getValues().stream()
|
||||
.map(DetalleMapper.INSTANCE::detalleFromDto)
|
||||
.toList();
|
||||
|
@ -11,12 +11,12 @@ import java.time.ZoneOffset;
|
||||
public class DateTimeXmlAdapter extends XmlAdapter<String, LocalDateTime> {
|
||||
|
||||
@Override
|
||||
public String marshal(LocalDateTime v) throws Exception {
|
||||
public String marshal(final LocalDateTime v) throws Exception {
|
||||
return v.toInstant(ZoneOffset.UTC).toString();
|
||||
}
|
||||
|
||||
@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"));
|
||||
}
|
||||
}
|
@ -11,14 +11,14 @@ public class DateXmlAdapter extends XmlAdapter<String, Date> {
|
||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Override
|
||||
public String marshal(Date v) throws Exception {
|
||||
public String marshal(final Date v) throws Exception {
|
||||
synchronized (dateFormat) {
|
||||
return dateFormat.format(v);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date unmarshal(String v) throws Exception {
|
||||
public Date unmarshal(final String v) throws Exception {
|
||||
synchronized (dateFormat) {
|
||||
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