importer

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package importer turns files from other tools into Exhale import items: a Wallos database or export, a spreadsheet saved as CSV, or Exhale's own export. It only reads; the app decides what to create (the user reviews the list first).

Index

Constants

View Source
const MaxFileSize = 20 << 20

MaxFileSize bounds an uploaded file.

View Source
const MaxPDFPages = 60

MaxPDFPages bounds how much of a PDF is read.

View Source
const MaxTransactions = 50_000

MaxTransactions bounds a bank export.

Variables

View Source
var ErrNoText = errors.New("this PDF has no text (it is probably a scan)")

ErrNoText is returned for a PDF without text, such as a scan.

View Source
var ErrUnknownFormat = errors.New("this file is not a Wallos database, a Wallos export, an Exhale export or a CSV with a name and a price column")

ErrUnknownFormat is returned when a file is none of the supported kinds.

Functions

func AnyDate

func AnyDate(s string) string

AnyDate reads the date formats spreadsheets produce; ambiguous numeric dates are read day first (31/12/2026), the more common order worldwide.

func PDFText

func PDFText(data []byte) (text string, err error)

PDFText returns the text of a PDF, one line per line of the page. It fails for a damaged or password-protected file and returns ErrNoText for a PDF without text.

func SplitPrice

func SplitPrice(s, fallback string) (amount, currency string)

SplitPrice separates "€12.99", "12,99 EUR" or "$5" into amount and currency.

Types

type FileKind

type FileKind int

FileKind is what an upload looks like from its first bytes.

const (
	FileUnknown FileKind = iota
	FileSQLite
	FileJSON
	FilePDF
	FileImage
	FileText
)

Kinds of upload.

func Sniff

func Sniff(data []byte) (FileKind, string)

Sniff says what data is and, for pictures and PDFs, its media type.

type Result

type Result struct {
	Source string           `` /* 156-byte string literal not displayed */
	Items  []app.ImportItem `json:"items"`
	Notes  []string         `json:"notes" jsonschema:"things the reviewer should know about the file as a whole"`
	// Model is the model that proposed or tidied the items, when one did.
	Model string `json:"model,omitempty" jsonschema:"the model that read the file or tidied the names; empty when Exhale read it by itself"`
	// Transactions are the outgoing payments of a statement, for matching
	// with the expected charges. They stay on the server.
	Transactions []app.StatementLine `json:"-"`
	// Match says which expected charges the statement confirms, when it
	// listed transactions.
	Match *app.StatementMatch `json:"match,omitempty"`
}

Result is what a file contained.

func Parse

func Parse(ctx context.Context, data []byte, defaultCurrency string) (Result, error)

Parse detects the format of data and returns its subscriptions. defaultCurrency fills items whose currency the file does not say.

func TextTransactions

func TextTransactions(text, defaultCurrency string, today engine.Date, source string) (res Result, shaped bool)

TextTransactions reads the transactions of a statement written as text, one per line. shaped is false when fewer than three lines look like a transaction.

func Transactions

func Transactions(data []byte, defaultCurrency string, today engine.Date) (res Result, shaped bool)

Transactions reads a bank or card export and returns the charges that recur, and every outgoing payment for matching with the expected charges. shaped is false when data is not a list of transactions at all; when it is, the result may still have no items (nothing recurs).

Jump to

Keyboard shortcuts

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