boc

package
v2.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Boc

type Boc struct {
	Statistics  Statistics `json:"statistics,omitempty"`
	LineNum     int        `json:"line_num,omitempty"`
	Orders      []Order    `json:"orders,omitempty"`
	HeaderFound bool       `json:"header_found,omitempty"`
	CardName    string     `json:"card_name,omitempty"`
	Mode        CardMode   `json:"mode,omitempty"`
	TitleParsed bool       `json:"title_parsed,omitempty"`
}

func New

func New() *Boc

func (*Boc) Translate

func (boc *Boc) Translate(filename string) (*ir.IR, error)

Translate the boc bill records to IR.

func (*Boc) TranslateToCreditOrders

func (boc *Boc) TranslateToCreditOrders(arr []string) error

func (*Boc) TranslateToDebitOrders

func (boc *Boc) TranslateToDebitOrders(arr []string) error

type CardMode

type CardMode string
const (
	DebitMode  CardMode = "Debit"
	CreditMode CardMode = "Credit"
)

type Config

type Config struct {
	Rules []Rule `mapstructure:"rules,omitempty"`
}

type Order

type Order struct {
	// 记账日期,记账时间,币别,金额,余额,交易名称,渠道,网点名称,附言,对方账户名,对方卡号/账号,对方开户行,借记卡号
	// 这里的 json 控制的是输出的 beancount 的字段
	// CreateTime   time.Time `json:"createTime,omitempty"`
	PayTime    time.Time `json:"payTime,omitempty"`
	Currency   string    `json:"currency,omitempty"`   // 币种
	Money      float64   `json:"money,omitempty"`      // 记账金额(收入/支出)
	Type       OrderType `json:"type,omitempty"`       // 收入/支出(由金额正负推断而来)
	ItemName   string    `json:"itemName,omitempty"`   // 交易名称/交易描述
	Channel    string    `json:"channel,omitempty"`    // 渠道
	Branch     string    `json:"branch,omitempty"`     // 网点
	Postscript string    `json:"postscript,omitempty"` // 附言
	PeerName   string    `json:"peerName,omitempty"`   // 对方账户名
	PeerCard   string    `json:"peerCard,omitempty"`   // 对方卡号
	PeerBank   string    `json:"peerBank,omitempty"`   // 对方开户行
	Method     string    `json:"method,omitempty"`     // 卡号末四位
}

type OrderType

type OrderType string
const (
	TypeSend   OrderType = "支出"
	TypeRecv   OrderType = "收入"
	TypeOthers OrderType = "不计收支"
	TypeEmpty  OrderType = ""
	TypeNil    OrderType = "未知"
)

type Rule

type Rule struct {
	Item           *string  `mapstructure:"item,omitempty"`
	Type           *string  `mapstructure:"type,omitempty"`
	Method         *string  `mapstructure:"method,omitempty"`
	Separator      *string  `mapstructure:"sep,omitempty"` // default: ,
	Time           *string  `mapstructure:"time,omitempty"`
	TimestampRange *string  `mapstructure:"timestamp_range,omitempty"`
	MethodAccount  *string  `mapstructure:"methodAccount,omitempty"`
	TargetAccount  *string  `mapstructure:"targetAccount,omitempty"`
	FullMatch      bool     `mapstructure:"fullMatch,omitempty"`
	Tags           *string  `mapstructure:"tags,omitempty"`
	Ignore         bool     `mapstructure:"ignore,omitempty"` // default: false
	MinPrice       *float64 `mapstructure:"minPrice,omitempty"`
	MaxPrice       *float64 `mapstructure:"maxPrice,omitempty"`
	Peer           *string  `mapstructure:"peer,omitempty"`
}

Rule is the type for match rules.

type Statistics

type Statistics struct {
	UserID          string    `json:"user_id,omitempty"`
	Username        string    `json:"username,omitempty"`
	ParsedItems     int       `json:"parsed_items,omitempty"`
	Start           time.Time `json:"start,omitempty"`
	End             time.Time `json:"end,omitempty"`
	TotalInRecords  int       `json:"total_in_records,omitempty"`
	TotalInMoney    float64   `json:"total_in_money,omitempty"`
	TotalOutRecords int       `json:"total_out_records,omitempty"`
	TotalOutMoney   float64   `json:"total_out_money,omitempty"`
}

Statistics is the Statistics of the bill file.

Jump to

Keyboard shortcuts

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