Skip to content

Commit

Permalink
Add LawsuitCNJFormat return on DecomposedCNJ
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielFillol committed Apr 3, 2023
1 parent aaa3d00 commit c7e29ac
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 46 deletions.
20 changes: 11 additions & 9 deletions CNJ/cnj.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type AnalysisCNJ struct {
}

//DecomposedCNJ returns the CNJ in decomposed manner:
// lawsuitCNJFormat [NNNNNNN]-[DD].[AAAA].[J].[CT].[0000]
// lawsuitNumber: [NNNNNNN]
// verifyingDigit: [DD]
// protocolYear: [AAAA]
Expand All @@ -32,15 +33,16 @@ type AnalysisCNJ struct {
// district: district where the lawsuit was proposed, frequently a city name
// uf: the uf of the correspondent district
type DecomposedCNJ struct {
LawsuitNumber string `json:"lawsuit_number,omitempty"`
VerifyingDigit string `json:"verifying_digit,omitempty"`
ProtocolYear string `json:"protocol_year,omitempty"`
Segment string `json:"segment,omitempty"`
Court string `json:"court,omitempty"`
SourceUnit string `json:"source_unit,omitempty"`
ArgNumber string `json:"arg_number,omitempty"`
District string `json:"district,omitempty"`
UF string `json:"UF,omitempty"`
LawsuitCNJFormat string `json:"lawsuitCNJFormat,omitempty"`
LawsuitNumber string `json:"lawsuit_number,omitempty"`
VerifyingDigit string `json:"verifying_digit,omitempty"`
ProtocolYear string `json:"protocol_year,omitempty"`
Segment string `json:"segment,omitempty"`
Court string `json:"court,omitempty"`
SourceUnit string `json:"source_unit,omitempty"`
ArgNumber string `json:"arg_number,omitempty"`
District string `json:"district,omitempty"`
UF string `json:"UF,omitempty"`
}

//AnalyzeCNJ returns the complex struct AnalysisCNJ containing all the useful data from this package
Expand Down
78 changes: 41 additions & 37 deletions CNJ/decomposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
const MATH = "00"

// DecomposeCNJ decompose cnj format number into the specifics:
// NNNNNNN-DD.AAAA.J.TR.OOOO
// lawsuitCNJFormat [NNNNNNN]-[DD].[AAAA].[J].[CT].[0000]
// LawsuitNumber = [NNNNNNN]
// VerifyingDigit = [DD]
// ProtocolYear = [AAAA]
Expand Down Expand Up @@ -42,28 +42,30 @@ func DecomposeCNJ(cnj string) (DecomposedCNJ, error) {
dt, err := CNJDatabase.FetchDistrict(semiCNJ)
if err != nil {
return DecomposedCNJ{
LawsuitNumber: lawsuitNumber,
VerifyingDigit: verifyingDigit,
ProtocolYear: yearProtocol,
Segment: segment,
Court: court,
SourceUnit: sourceUnit,
ArgNumber: argNumber,
District: err.Error(),
UF: err.Error(),
LawsuitCNJFormat: lawsuitNumber + "-" + verifyingDigit + "." + yearProtocol + "." + segment + "." + court + "." + sourceUnit,
LawsuitNumber: lawsuitNumber,
VerifyingDigit: verifyingDigit,
ProtocolYear: yearProtocol,
Segment: segment,
Court: court,
SourceUnit: sourceUnit,
ArgNumber: argNumber,
District: err.Error(),
UF: err.Error(),
}, err
}

return DecomposedCNJ{
LawsuitNumber: lawsuitNumber,
VerifyingDigit: verifyingDigit,
ProtocolYear: yearProtocol,
Segment: segment,
Court: court,
SourceUnit: sourceUnit,
ArgNumber: argNumber,
District: dt.SourceUnit,
UF: dt.UF,
LawsuitCNJFormat: lawsuitNumber + "-" + verifyingDigit + "." + yearProtocol + "." + segment + "." + court + "." + sourceUnit,
LawsuitNumber: lawsuitNumber,
VerifyingDigit: verifyingDigit,
ProtocolYear: yearProtocol,
Segment: segment,
Court: court,
SourceUnit: sourceUnit,
ArgNumber: argNumber,
District: dt.SourceUnit,
UF: dt.UF,
}, nil
} else {
lawsuitNumber := cnj[0:7]
Expand All @@ -88,29 +90,31 @@ func DecomposeCNJ(cnj string) (DecomposedCNJ, error) {
if err != nil {
if err != nil {
return DecomposedCNJ{
LawsuitNumber: lawsuitNumber,
VerifyingDigit: verifyingDigit,
ProtocolYear: yearProtocol,
Segment: segment,
Court: court,
SourceUnit: sourceUnit,
ArgNumber: argNumber,
District: err.Error(),
UF: err.Error(),
LawsuitCNJFormat: lawsuitNumber + "-" + verifyingDigit + "." + yearProtocol + "." + segment + "." + court + "." + sourceUnit,
LawsuitNumber: lawsuitNumber,
VerifyingDigit: verifyingDigit,
ProtocolYear: yearProtocol,
Segment: segment,
Court: court,
SourceUnit: sourceUnit,
ArgNumber: argNumber,
District: err.Error(),
UF: err.Error(),
}, err
}
}

return DecomposedCNJ{
LawsuitNumber: lawsuitNumber,
VerifyingDigit: verifyingDigit,
ProtocolYear: yearProtocol,
Segment: segment,
Court: court,
SourceUnit: sourceUnit,
ArgNumber: argNumber,
District: dt.District,
UF: dt.UF,
LawsuitCNJFormat: lawsuitNumber + "-" + verifyingDigit + "." + yearProtocol + "." + segment + "." + court + "." + sourceUnit,
LawsuitNumber: lawsuitNumber,
VerifyingDigit: verifyingDigit,
ProtocolYear: yearProtocol,
Segment: segment,
Court: court,
SourceUnit: sourceUnit,
ArgNumber: argNumber,
District: dt.District,
UF: dt.UF,
}, nil

}
Expand Down

0 comments on commit c7e29ac

Please sign in to comment.