flow

package
v0.0.0-...-3359aa3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DirectionIn  = "IN"
	DirectionOut = "OUT"
)
View Source
const (
	AggTypeYearly  = "YEARLY"
	AggTypeMonthly = "MONTHLY"
	AggTypeWeekly  = "WEEKLY"
)
View Source
const (
	WechatCategory = "WECHAT"
	WechatCurrency = "CNY"
)

Variables

View Source
var (
	RangeFormatMap = map[string]string{
		AggTypeYearly:  `2006`,
		AggTypeMonthly: `200601`,
		AggTypeWeekly:  `20060102`,
	}

	CalcAggStatPipeline = rabbit.NewEventPipeline[CalcCashflowStatsEvent]("acct:cashflow:calc-agg-stat").
						LogPayload().
						Listen(2, OnCalcCashflowStatsEvent).
						MaxRetry(3)
)

Functions

func CalcCashflowStatsAsync

func CalcCashflowStatsAsync(rail miso.Rail, req ApiCalcCashflowStatsReq, userNo string) error

func ImportWechatCashflows

func ImportWechatCashflows(inb *miso.Inbound, db *gorm.DB) error

func ListCashFlows

func ListCashFlows(rail miso.Rail, db *gorm.DB, user common.User, req ListCashFlowReq) (miso.PageRes[ListCashFlowRes], error)

func ListCashflowStatistics

func ListCashflowStatistics(rail miso.Rail, db *gorm.DB, req ApiListStatisticsReq, user common.User) (miso.PageRes[ApiListStatisticsRes], error)

func ListCurrencies

func ListCurrencies(rail miso.Rail, db *gorm.DB, user common.User) ([]string, error)

func LoadCategoryConfs

func LoadCategoryConfs(rail miso.Rail)

func OnCalcCashflowStatsEvent

func OnCalcCashflowStatsEvent(rail miso.Rail, evt CalcCashflowStatsEvent) error

func OnCashflowChanged

func OnCashflowChanged(rail miso.Rail, changes []CashflowChange, userNo string) error

func ParseAggRangeTime

func ParseAggRangeTime(aggType string, aggRange string) (util.ETime, error)

Types

type ApiCalcCashflowStatsReq

type ApiCalcCashflowStatsReq struct {
	AggType  string `desc:"Aggregation Type." valid:"member:YEARLY|MONTHLY|WEEKLY"`
	AggRange string `desc:"Aggregation Range. The corresponding year (YYYY), month (YYYYMM), sunday of the week (YYYYMMDD)." valid:"notEmpty"`
}

type ApiListStatisticsReq

type ApiListStatisticsReq struct {
	Paging   miso.Paging `desc:"Paging Info"`
	AggType  string      `desc:"Aggregation Type." valid:"member:YEARLY|MONTHLY|WEEKLY"`
	AggRange string      `desc:"Aggregation Range. The corresponding year (YYYY), month (YYYYMM), sunday of the week (YYYYMMDD)."`
	Currency string      `desc:"Currency"`
}

type ApiListStatisticsRes

type ApiListStatisticsRes struct {
	AggType  string `desc:"Aggregation Type."`
	AggRange string `desc:"Aggregation Range. The corresponding year (YYYY), month (YYYYMM), sunday of the week (YYYYMMDD)."`
	AggValue string `desc:"Aggregation Value."`
	Currency string `desc:"Currency"`
}

type ApiPlotStatisticsReq

type ApiPlotStatisticsReq struct {
	StartTime util.ETime `desc:"Start time"`
	EndTime   util.ETime `desc:"End time"`
	AggType   string     `desc:"Aggregation Type." valid:"member:YEARLY|MONTHLY|WEEKLY"`
	Currency  string     `desc:"Currency"`
}

type ApiPlotStatisticsRes

type ApiPlotStatisticsRes struct {
	AggRange string `desc:"Aggregation Range. The corresponding year (YYYY), month (YYYYMM), sunday of the week (YYYYMMDD)."`
	AggValue string `desc:"Aggregation Value."`
}

func PlotCashflowStatistics

func PlotCashflowStatistics(rail miso.Rail, db *gorm.DB, req ApiPlotStatisticsReq, user common.User) ([]ApiPlotStatisticsRes, error)

type CalcCashflowStatsEvent

type CalcCashflowStatsEvent struct {
	UserNo   string
	AggType  string
	AggRange string
	AggTime  util.ETime
}

type CashflowChange

type CashflowChange struct {
	TransTime util.ETime
}

type CashflowCurrency

type CashflowCurrency struct {
	UserNo   string
	Currency string
}

type CashflowSum

type CashflowSum struct {
	Currency  string
	AmountSum string
}

type CategoryConf

type CategoryConf struct {
	Code string
	Name string
}

type ListCashFlowReq

type ListCashFlowReq struct {
	Paging         miso.Paging `desc:"Paging"`
	Direction      string      `desc:"Flow Direction: IN / OUT" valid:"member:IN|OUT|"`
	TransTimeStart *util.ETime `desc:"Transaction Time Range Start"`
	TransTimeEnd   *util.ETime `desc:"Transaction Time Range End"`
	TransId        string      `desc:"Transaction ID"`
	Category       string      `desc:"Category Code"`
	MinAmt         *money.Amt  `desc:"Minimum amount"`
}

type ListCashFlowRes

type ListCashFlowRes struct {
	Direction     string     `desc:"Flow Direction: IN / OUT"`
	TransTime     util.ETime `desc:"Transaction Time"`
	TransId       string     `desc:"Transaction ID"`
	Counterparty  string     `desc:"Counterparty of the transaction"`
	PaymentMethod string     `desc:"Payment Method"`
	Amount        string     `desc:"Amount"`
	Currency      string     `desc:"Currency"`
	Extra         string     `desc:"Extra Information"`
	Category      string     `desc:"Category Code"`
	CategoryName  string     `desc:"Category Name"`
	Remark        string     `desc:"Remark"`
	CreatedAt     util.ETime `desc:"Create Time"`
}

type NewCashflow

type NewCashflow struct {
	Direction     string
	TransTime     util.ETime
	TransId       string
	PaymentMethod string
	Counterparty  string
	Amount        string
	Currency      string
	Extra         string
	Remark        string
}

func ParseWechatCashflows

func ParseWechatCashflows(rail miso.Rail, path string) ([]NewCashflow, error)

func SaveCashflows

func SaveCashflows(rail miso.Rail, db *gorm.DB, param SaveCashflowParams) ([]NewCashflow, error)

type SaveCashflowParams

type SaveCashflowParams struct {
	Cashflows []NewCashflow
	Category  string
	User      common.User
}

type SavingCashflow

type SavingCashflow struct {
	UserNo        string
	Direction     string
	TransTime     util.ETime
	TransId       string
	Counterparty  string
	Amount        string
	PaymentMethod string
	Currency      string
	Extra         string
	Category      string
	Remark        string
	CreatedAt     util.ETime
}

type TimeRange

type TimeRange struct {
	Start time.Time
	End   time.Time
}

Jump to

Keyboard shortcuts

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