calc

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPurchaseHistory

func GetPurchaseHistory(s string) ([]PurchaseHistory, []PurchaseHistory, error)

GetPurchaseHistory gets the monthly purchase history of the member queried member name is matched with fuzzy search (loosely)

func GetTopMembers

func GetTopMembers(nrecords int) (map[int][]MonthlySales, error)

func GetTopProducts

func GetTopProducts(nrecords int) (map[int][]MonthlySales, error)

Types

type MemberRecord

type MemberRecord struct {
	Date       time.Time
	ID         string
	Username   string
	Total      float64
	Average    float64
	GrandTotal float64
}

MemberRecord as sales record for different members

func GetDailyMember

func GetDailyMember(d string, n int) ([]MemberRecord, error)

GetDailyMember returns daily member spendings

func GetMonthlyMember

func GetMonthlyMember(d string, n int) ([]MemberRecord, error)

GetMonthlyMember returns daily member spendings

func GetWeeklyMember

func GetWeeklyMember(d string, n int) ([]MemberRecord, error)

GetWeeklyMember returns weekly member spendings TODO: fix lumpsum

type MonthlySales

type MonthlySales struct {
	Field      string // username, product_id
	Name       string //  productName
	GrandTotal float64
	Month      string
	Total      float64
}

type Product

type Product struct {
	ID          int     // product_id
	Code        string  // code
	Name        string  // Name
	URL         string  // url
	Price       float64 // price
	ListedPrice float64 // tb_list_price
	Discount    float64 // price
	Active      bool
}

Product as the product details of a particular item

func GetProductDetails

func GetProductDetails(id int) ([]Product, error)

GetProductDetails gets product details with the provided product id

type ProductRecord

type ProductRecord struct {
	Date        time.Time
	Category    string
	ProductID   int
	ProductName string
	Total       float64
	Quantity    int
}

ProductRecord as sales record for differernt products

func GetDailyProduct

func GetDailyProduct(start, end string) ([]ProductRecord, error)

GetDailyProduct returns the latest product sales record for the past n days

func GetMonthlyProduct

func GetMonthlyProduct(d string, n int) ([]ProductRecord, error)

GetMonthlyProduct returns the latest product sales record for the past n months

func GetProductSalesRecords

func GetProductSalesRecords(id int) ([]ProductRecord, error)

GetProductSalesRecords gets the historical record (weekly) of a particular product

func GetWeeklyProduct

func GetWeeklyProduct(d string, n int) ([]ProductRecord, error)

GetWeeklyProduct returns the latest product sales record for the past n weeks

type PurchaseHistory

type PurchaseHistory struct {
	Date        time.Time
	Username    string
	ProductID   int
	ProductName string
	Count       int
	Total       float64
}

type SalesRecord

type SalesRecord struct {
	Date  time.Time
	Count int
	Total float64
}

SalesRecord as daily sales for

func GetDailySales

func GetDailySales(start, end string) ([]SalesRecord, error)

GetDailySales returns the latest sales record for the past n days

func GetMonthlySales

func GetMonthlySales(d string, n int) ([]SalesRecord, error)

GetMonthlySales returns the latest sales record for the past n months

func GetWeeklySales

func GetWeeklySales(d string, n int) ([]SalesRecord, error)

GetWeeklySales returns the latest sales record for the past n weeks

Jump to

Keyboard shortcuts

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