Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Document ¶
type Document struct {
TotalARS decimal.Decimal
TotalUSD decimal.Decimal
CloseDate time.Time
ExpirationDate time.Time
PastPaymentMovements []PDFMovement
Cards []PDFCard
TablePositions PDFTablePositions
TaxesMovements []PDFMovement
}
func NewDocumentFromBytes ¶
func NewDocumentFromFilePath ¶
type PDFCard ¶
type PDFCard struct {
Number *string
Owner string
Movements []PDFMovement
TotalARS decimal.Decimal
TotalUSD decimal.Decimal
}
func NewPDFCard ¶
type PDFMovement ¶
type PDFTablePositions ¶
type PDFTablePositions struct {
// Dates always have the same length, so we can know the start and end of the date
OriginalDateStart int
OriginalDateEnd int
// Receipts are optional, but even if they are present or not, they are always positioned at the same place
ReceiptStart int
ReceiptEnd int
// Details are the most variable, so we can only know the start of the detail
DetailStart int
// Amounts grow to the left, so we can only know the end of the ARS amount for sure
ARSAmountStart int
ARSAmountEnd int
// We know the end of the ARS amount, so the next character is the start of the USD amount (probably a whitespace)
USDAmountStart int
USDAmountEnd int
}
PDFTablePositions are the known positions of the columns of the table of the PDF. They start at 0, so the first character is at position 0. Left whitespace is not counted, so the first character is the first non-whitespace character. All the positions are inclusive but some starts may point to whitespace.
type VisaprismaExtractor ¶
type VisaprismaExtractor struct{}
VisaprismaExtractor implements the pdfcardsummaryio.Extractor interface
func NewVisaprismaExtractor ¶
func NewVisaprismaExtractor() *VisaprismaExtractor
NewVisaprismaExtractor creates a new VISA PRISMA extractor
func (*VisaprismaExtractor) ExtractFromBytes ¶
func (e *VisaprismaExtractor) ExtractFromBytes(rawBytes []byte) (pdfcardsummary.CardSummary, error)
ExtractFromBytes extracts a CardSummary from raw PDF bytes
func (*VisaprismaExtractor) ExtractFromDocument ¶
func (e *VisaprismaExtractor) ExtractFromDocument(pdfDoc pdfwrapper.Document) (pdfcardsummary.CardSummary, error)
ExtractFromDocument extracts a CardSummary from a pdfwrapper.Document
NOTE: This method is currently NOT IMPLEMENTED and returns an error.
The VISA PRISMA extractor's parsing logic (NewDocumentFromPDFRows) requires []*pdf.Row from github.com/Alechan/pdf directly, not pdfwrapper.Row. The pdfwrapper abstraction only provides simplified Row objects with Position and Texts []string, which loses the detailed formatting/positioning information needed by VISA PRISMA's parsing logic.
TODO: Once VISA PRISMA extractor is migrated to use pdfwrapper abstraction (Phase 2), ExtractFromBytes() should call this method, similar to how SantanderExtractor.ExtractFromBytes() calls SantanderExtractor.ExtractFromDocument(). See pkg/internal/extractor/santander/santander_extractor.go for reference implementation.
For now, use ExtractFromBytes() which works correctly with raw PDF bytes.