financeengine

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: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableIDMetaSummary              = "meta_summary"
	TableIDOverviewByMonth          = "overview_by_statement_month"
	TableIDOverviewMetricsByMonth   = "overview_metrics_by_statement_month"
	TableIDDebtMaturitySchedule     = "debt_maturity_schedule_by_month_v1"
	TableIDSpendByOwner             = "spend_by_owner"
	TableIDSpendByCategory          = "spend_by_category"
	TableIDCategoryBreakdownByMonth = "category_breakdown_by_month"
	TableIDRawExplorerRows          = "raw_explorer_rows_v1"
	TableIDDQIssues                 = "dq_issues"
	TableIDDQSummaryByRule          = "dq_summary_by_rule"
)
View Source
const (
	DQRuleMissingCategoryMappingForCardMovement = "DQ003"
	DQRuleMissingOwnerMappingForCardMovement    = "DQ004"
)

Variables

This section is empty.

Functions

func ExportTableCSV

func ExportTableCSV(table Table) (string, error)

Types

type ColumnType

type ColumnType string
const (
	ColumnTypeString   ColumnType = "string"
	ColumnTypeNumber   ColumnType = "number"
	ColumnTypeDate     ColumnType = "date"
	ColumnTypeMoneyARS ColumnType = "money_ars"
	ColumnTypeMoneyUSD ColumnType = "money_usd"
	ColumnTypeShare    ColumnType = "share" // percentage (0–100), display with % suffix
)

type ComputeResult

type ComputeResult struct {
	Tables []Table
}

type DQIssue

type DQIssue struct {
	RuleID       string
	Message      string
	MovementType pdfcardsummary.MovementType
	CloseDate    time.Time
	Detail       string
	CardOwner    string
	CardNumber   *string
}

type DQSummaryByRuleRow

type DQSummaryByRuleRow struct {
	RuleID string
	Count  int
}

type DebtMaturityScheduleByMonthRow

type DebtMaturityScheduleByMonthRow struct {
	BaseStatementMonthDate time.Time
	MaturityMonthDate      time.Time
	MonthOffset            int
	InstallmentCount       int
	MaturityTotalARS       decimal.Decimal
	MaturityTotalUSD       decimal.Decimal
}

type Engine

type Engine struct{}

func New

func New() *Engine

func (*Engine) Compute

func (*Engine) DataQuality

func (e *Engine) DataQuality(rows []pdfcardsummary.MovementWithCardContext, mappings Mappings) ([]DQIssue, []DQSummaryByRuleRow)

func (*Engine) DebtMaturityScheduleByMonth

func (e *Engine) DebtMaturityScheduleByMonth(rows []pdfcardsummary.MovementWithCardContext) []DebtMaturityScheduleByMonthRow

func (*Engine) MetaSummary

func (*Engine) OverviewByStatementMonth

func (e *Engine) OverviewByStatementMonth(rows []pdfcardsummary.MovementWithCardContext) []OverviewByStatementMonthRow

func (*Engine) OverviewMetricsByStatementMonth

func (e *Engine) OverviewMetricsByStatementMonth(rows []pdfcardsummary.MovementWithCardContext) []OverviewMetricsByStatementMonthRow

func (*Engine) RawExplorerRows

func (e *Engine) RawExplorerRows(rows []pdfcardsummary.MovementWithCardContext) []RawExplorerRow

func (*Engine) SpendByCategory

func (e *Engine) SpendByCategory(rows []pdfcardsummary.MovementWithCardContext) []SpendByCategoryRow

func (*Engine) SpendByOwner

type Mappings

type Mappings struct {
	OwnersByCardOwner  map[string]string `json:"ownersByCardOwner"`
	OwnersByCardNumber map[string]string `json:"ownersByCardNumber"`
	CategoryByDetail   map[string]string `json:"categoryByDetail"`
}

type MetaSummary

type MetaSummary struct {
	RowCount            int
	StatementMonthMin   time.Time
	StatementMonthMax   time.Time
	StatementMonthCount int
}

type OverviewByStatementMonthRow

type OverviewByStatementMonthRow struct {
	StatementMonthDate   time.Time
	CardMovementTotalARS decimal.Decimal
	CardMovementTotalUSD decimal.Decimal
}

type OverviewMetricsByStatementMonthRow

type OverviewMetricsByStatementMonthRow struct {
	StatementMonthDate time.Time

	NetStatementARS  decimal.Decimal
	NetStatementUSD  decimal.Decimal
	CardMovementsARS decimal.Decimal
	CardMovementsUSD decimal.Decimal

	NewDebtARS       decimal.Decimal
	NewDebtUSD       decimal.Decimal
	CarryOverDebtARS decimal.Decimal
	CarryOverDebtUSD decimal.Decimal
	NextMonthDebtARS decimal.Decimal
	NextMonthDebtUSD decimal.Decimal
	RemainingDebtARS decimal.Decimal
	RemainingDebtUSD decimal.Decimal
	TaxesARS         decimal.Decimal
	TaxesUSD         decimal.Decimal
	PastPaymentsARS  decimal.Decimal
	PastPaymentsUSD  decimal.Decimal
}

type RawExplorerRow

type RawExplorerRow struct {
	CardStatementCloseDate time.Time
	CardStatementDueDate   time.Time
	Bank                   string
	CardCompany            string
	MovementDate           *time.Time
	CardNumber             string
	CardOwner              string
	MovementType           string
	ReceiptNumber          string
	Detail                 string
	InstallmentCurrent     *int
	InstallmentTotal       *int
	AmountARS              decimal.Decimal
	AmountUSD              decimal.Decimal
}

type SpendByCategoryRow

type SpendByCategoryRow struct {
	Month                time.Time
	Category             string
	CardMovementTotalARS decimal.Decimal
	CardMovementTotalUSD decimal.Decimal
}

v0a note: without mappings yet, this uses raw Detail as the category key.

type SpendByOwnerRow

type SpendByOwnerRow struct {
	Owner                string
	Month                time.Time
	CardMovementTotalARS decimal.Decimal
	CardMovementTotalUSD decimal.Decimal
}

type Table

type Table struct {
	TableID     string
	Title       string
	Description string // Human-readable explanation. If you change the rows, update this.
	Columns     []TableColumn
	Rows        [][]string
}

func FindTableByID

func FindTableByID(tables []Table, tableID string) (Table, error)

type TableColumn

type TableColumn struct {
	Key   string
	Label string
	Type  ColumnType
}

Jump to

Keyboard shortcuts

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