-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
111 lines (94 loc) · 3.19 KB
/
Copy pathtypes.go
File metadata and controls
111 lines (94 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package edocuenta
import "time"
// Bank identifies a supported bank.
type Bank string
const (
BankBBVA Bank = "bbva"
BankHSBC Bank = "hsbc"
)
// Currency identifies the statement currency.
type Currency string
const (
CurrencyMXN Currency = "MXN"
CurrencyUSD Currency = "USD"
)
// AccountClass classifies the statement account using accounting terminology.
type AccountClass string
const (
AccountClassUnknown AccountClass = ""
AccountClassAsset AccountClass = "asset"
AccountClassLiability AccountClass = "liability"
)
// TransactionDirection classifies the normalized transaction direction.
type TransactionDirection string
const (
TransactionDirectionDebit TransactionDirection = "debit"
TransactionDirectionCredit TransactionDirection = "credit"
)
// ParseConfidence classifies how trustworthy the selected parse result is.
type ParseConfidence string
const (
ParseConfidenceLow ParseConfidence = "low"
ParseConfidenceMedium ParseConfidence = "medium"
ParseConfidenceHigh ParseConfidence = "high"
)
// Statement contains normalized domain data extracted from a bank statement.
//
// It intentionally excludes extraction and parsing diagnostics so callers can
// treat it as a clean domain model.
type Statement struct {
Bank Bank
AccountNumber string
Currency Currency
PeriodStart time.Time
PeriodEnd time.Time
AccountClass AccountClass `json:",omitempty"`
Summary *StatementSummary `json:",omitempty"`
Transactions []Transaction
}
// StatementSummary contains explicit statement-level balances, totals, and
// payment metadata when the source document exposes them clearly.
type StatementSummary struct {
OpeningBalanceCents *int64 `json:",omitempty"`
ClosingBalanceCents *int64 `json:",omitempty"`
AverageBalanceCents *int64 `json:",omitempty"`
TotalDebitsCents *int64 `json:",omitempty"`
TotalCreditsCents *int64 `json:",omitempty"`
PaymentDueDate *time.Time `json:",omitempty"`
MinimumPaymentCents *int64 `json:",omitempty"`
PaymentToAvoidInterestCents *int64 `json:",omitempty"`
CreditLimitCents *int64 `json:",omitempty"`
AvailableCreditCents *int64 `json:",omitempty"`
}
// Transaction contains a single normalized movement.
type Transaction struct {
PostedAt time.Time
Description string
Reference string
Direction TransactionDirection
AmountCents int64
BalanceCents *int64
}
// ParseResult captures the normalized statement plus best-effort diagnostics.
type ParseResult struct {
Statement Statement
Warnings []string
Extraction ExtractionDiagnostics
Diagnostics ParseDiagnostics
ExtractedText string
}
// ExtractionDiagnostics exposes which extractor candidate won and what other
// extraction attempts were made along the way.
type ExtractionDiagnostics struct {
SelectedExtractor string
UsedRescue bool
Attempts []TextExtractionAttempt
}
// ParseDiagnostics exposes which parser/layout won and how reliable the result looks.
type ParseDiagnostics struct {
SelectedParser string
Layout string
DetectionScore int
Confidence ParseConfidence
Issues []string
}