visaprisma

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PDFAmountToDecimal

func PDFAmountToDecimal(rawAmount string) (decimal.Decimal, error)

func VISADotDateToTime

func VISADotDateToTime(s string) (time.Time, error)

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 NewDocumentFromBytes(rawBytes []byte) (Document, error)

func NewDocumentFromFilePath

func NewDocumentFromFilePath(filePath string) (Document, error)

func NewDocumentFromPDFRows

func NewDocumentFromPDFRows(rows []*pdf.Row) (Document, error)

func NewDocumentFromReaderAt

func NewDocumentFromReaderAt(readerAt io.ReaderAt, size int64) (Document, error)

type PDFCard

type PDFCard struct {
	Number    *string
	Owner     string
	Movements []PDFMovement
	TotalARS  decimal.Decimal
	TotalUSD  decimal.Decimal
}

func NewPDFCard

func NewPDFCard(number, owner string, movements []PDFMovement, totalARS, totalUSD decimal.Decimal) (PDFCard, error)

type PDFMovement

type PDFMovement struct {
	OriginalDate       *time.Time
	ReceiptNumber      *string
	Detail             string
	CurrentInstallment *int
	TotalInstallments  *int
	AmountARS          decimal.Decimal
	AmountUSD          decimal.Decimal
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL