-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Parsed and analysis tax documents for validation automation
- Loading branch information
Showing
57 changed files
with
1,403 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...e-common-library/src/main/java/fr/dossierfacile/common/converter/ParsedFileConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package fr.dossierfacile.common.converter; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import fr.dossierfacile.common.entity.ocr.ParsedFile; | ||
import fr.dossierfacile.common.enums.ParsedFileClassification; | ||
|
||
import javax.persistence.AttributeConverter; | ||
import javax.persistence.Converter; | ||
import java.io.IOException; | ||
|
||
@Converter | ||
public class ParsedFileConverter implements AttributeConverter<ParsedFile, String> { | ||
private static final ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
@Override | ||
public String convertToDatabaseColumn(ParsedFile object) { | ||
if (object == null) { | ||
return null; | ||
} | ||
try { | ||
return objectMapper.writeValueAsString(object); | ||
} catch (IOException e) { | ||
throw new IllegalArgumentException("Error converting ParsedFile to JSON", e); | ||
} | ||
} | ||
|
||
@Override | ||
public ParsedFile convertToEntityAttribute(String dbData) { | ||
if (dbData == null) { | ||
return null; | ||
} | ||
try { | ||
// get classification | ||
JsonNode jsonNode = objectMapper.readTree(dbData); | ||
ParsedFileClassification classification = ParsedFileClassification.valueOf(jsonNode.get("classification").asText()); | ||
|
||
return objectMapper.treeToValue(jsonNode, classification.getClassificationClass()); | ||
} catch (IOException e) { | ||
throw new IllegalArgumentException("Error converting JSON to ParsedFile", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...e-common-library/src/main/java/fr/dossierfacile/common/entity/DocumentAnalysisReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package fr.dossierfacile.common.entity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.Type; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.OneToOne; | ||
import javax.persistence.Table; | ||
import java.util.List; | ||
|
||
@Data | ||
@Builder | ||
@Entity | ||
@Table(name = "document_analysis_report") | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class DocumentAnalysisReport { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@OneToOne(targetEntity = Document.class, fetch = FetchType.LAZY) | ||
@JoinColumn(name = "document_id") | ||
private Document document; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private DocumentAnalysisStatus analysisStatus; | ||
|
||
@Type(type = "jsonb") | ||
@Column(columnDefinition = "jsonb") | ||
private List<DocumentBrokenRule> brokenRules; | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...e-common-library/src/main/java/fr/dossierfacile/common/entity/DocumentAnalysisStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package fr.dossierfacile.common.entity; | ||
|
||
public enum DocumentAnalysisStatus { | ||
DENIED, | ||
CHECKED, | ||
UNDEFINED | ||
} |
24 changes: 24 additions & 0 deletions
24
...acile-common-library/src/main/java/fr/dossierfacile/common/entity/DocumentBrokenRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package fr.dossierfacile.common.entity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.Embeddable; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
|
||
@Embeddable | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class DocumentBrokenRule { | ||
|
||
@Enumerated(EnumType.STRING) | ||
private DocumentRule rule; | ||
|
||
private String message; | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
dossierfacile-common-library/src/main/java/fr/dossierfacile/common/entity/DocumentRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package fr.dossierfacile.common.entity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum DocumentRule { | ||
|
||
R_TAX_PARSE(Level.WARN,"La lecture des informations de l'avis a échoué"), | ||
R_TAX_FAKE(Level.CRITICAL,"Les informations sont floues ou corrompues"), | ||
R_TAX_N1( Level.CRITICAL, "L'avis d'imposition sur les revenus N-1 doit etre fournis"), | ||
R_TAX_LEAF( Level.CRITICAL, "Veuillez fournir les feuillets des avis"), | ||
R_TAX_ALL_LEAF( Level.WARN, "Veuillez fournir tous les feuillets des avis"),// feuillet 1 founi | ||
R_TAX_N3( Level.CRITICAL, "Les avis d'imposition antérieur à N-3 ne sont pas autorisé"), | ||
R_TAX_NAMES( Level.WARN, "Les noms et prénoms ne correspondent pas"); | ||
|
||
public enum Level{ | ||
CRITICAL, WARN | ||
} | ||
|
||
private final Level level; | ||
private final String defaultMessage; | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...acile-common-library/src/main/java/fr/dossierfacile/common/entity/ParsedFileAnalysis.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package fr.dossierfacile.common.entity; | ||
|
||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType; | ||
import fr.dossierfacile.common.converter.ParsedFileConverter; | ||
import fr.dossierfacile.common.entity.ocr.ParsedFile; | ||
import fr.dossierfacile.common.enums.ParsedFileAnalysisStatus; | ||
import fr.dossierfacile.common.enums.ParsedFileClassification; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.ColumnTransformer; | ||
import org.hibernate.annotations.Type; | ||
import org.hibernate.annotations.TypeDef; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Convert; | ||
import javax.persistence.Entity; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.OneToOne; | ||
import javax.persistence.Table; | ||
|
||
@Data | ||
@Builder | ||
@Entity | ||
@Table(name = "parsed_file_analysis") | ||
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class) | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ParsedFileAnalysis { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@OneToOne(targetEntity = File.class, fetch = FetchType.LAZY) | ||
@JoinColumn(name = "file_id") | ||
private File file; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private ParsedFileAnalysisStatus analysisStatus; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private ParsedFileClassification classification; | ||
|
||
@Column(columnDefinition = "jsonb") | ||
@Convert(converter = ParsedFileConverter.class) | ||
@ColumnTransformer(write = "?::jsonb") | ||
private ParsedFile parsedFile; | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...ierfacile-common-library/src/main/java/fr/dossierfacile/common/entity/ocr/ParsedFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package fr.dossierfacile.common.entity.ocr; | ||
|
||
public interface ParsedFile { | ||
String getClassification(); | ||
} |
Oops, something went wrong.