db

package
v9.0.131 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Unlicense Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GroupObjectIDs = []string{
		"orders", "driver", "store",
	}
)
View Source
var OrderObjectIDs = []string{
	"customer", "store",
}

Functions

func CollectionCustomers

func CollectionCustomers(ctx context.Context) (*mongo.Collection, error)

func CollectionGlobalConfig

func CollectionGlobalConfig(ctx context.Context) (*mongo.Collection, error)

func CollectionGroups

func CollectionGroups(ctx context.Context) (*mongo.Collection, error)

func CollectionOrders

func CollectionOrders(ctx context.Context) (*mongo.Collection, error)

func CollectionProducts

func CollectionProducts(ctx context.Context) (*mongo.Collection, error)

func CollectionStores

func CollectionStores(ctx context.Context) (*mongo.Collection, error)

func CollectionTaxes

func CollectionTaxes(ctx context.Context) (*mongo.Collection, error)

func CollectionTickets

func CollectionTickets(ctx context.Context) (*mongo.Collection, error)

func Next

func Next(ctx context.Context, key string) (int64, error)

Types

type Customer

type Customer struct {
	ID           primitive.ObjectID `bson:"_id" json:"id"`
	CustomerRef  string             `bson:"customerRef" json:"customerRef"`
	FirstName    string             `bson:"firstName" json:"firstName"`
	LastName     string             `bson:"lastName" json:"lastName"`
	AddressLine1 string             `bson:"addressLine1" json:"addressLine1"`
	AddressLine2 string             `bson:"addressLine2" json:"addressLine2"`
	Postcode     string             `bson:"postcode" json:"postcode"`
	City         string             `bson:"city" json:"city"`
	Telephone    string             `bson:"telephone" json:"telephone"`
	Email        string             `bson:"email" json:"email"`
	Boxes        []int              `bson:"boxes" json:"boxes"`
	CreatedAt    time.Time          `bson:"createdAt" json:"createdAt"`
	UpdatedAt    time.Time          `bson:"updatedAt" json:"updatedAt"`
}

type Device

type Device struct {
	Name     string `bson:"name" json:"name"`
	DeviceID string `bson:"deviceId" json:"deviceId"`
}

type GlobalConfig

type GlobalConfig struct {
	ID                           primitive.ObjectID `bson:"_id" json:"id"`
	ProductAttributeOutOfStockIn int                `bson:"productAttributeOutOfStockInId" json:"productAttributeOutOfStockInId"`
	ProductAttributePfandId      int                `bson:"productAttributePfandId" json:"productAttributePfandId"`
	PusherAPIKey                 string             `json:"pusherApiKey"`
	DeliverectWebhookSecret      string             `json:"deliverectWebhookSecret"`
}

type Group

type Group struct {
	ID         primitive.ObjectID   `bson:"_id" json:"id"`
	Orders     []primitive.ObjectID `bson:"orders" json:"orders"`
	RouteOrder []int                `bson:"routeOrder" json:"routeOrder"`
	Number     string               `bson:"number" json:"number"`
	Finalized  bool                 `bson:"finalized" json:"finalized"`
	Delivered  bool                 `bson:"delivered" json:"delivered"`
	Driver     primitive.ObjectID   `bson:"driver" json:"driver"`
	DriverName string               `bson:"driverName" json:"driverName"`
	Store      primitive.ObjectID   `bson:"store" json:"store"`
	CreatedAt  time.Time            `bson:"createdAt" json:"createdAt"`
	UpdatedAt  time.Time            `bson:"updatedAt" json:"updatedAt"`
}

type Order

type Order struct {
	ID                   primitive.ObjectID  `bson:"_id" json:"id"`
	OrderID              string              `bson:"orderId" json:"orderId"`
	OrderNumber          string              `bson:"orderNumber" json:"orderNumber"`
	InvoiceNumber        string              `bson:"invoiceNumber" json:"invoiceNumber"`
	ValidAddress         bool                `bson:"validAddress" json:"validAddress"`
	Address              string              `bson:"address" json:"address"`
	AddressLine2         string              `bson:"addressLine2" json:"addressLine2"`
	Email                string              `bson:"email" json:"email"`
	Telephone            string              `bson:"telephone" json:"telephone"`
	CustomerNote         string              `bson:"customerNote" json:"customerNote"`
	DeliveryDate         string              `bson:"deliveryDate" json:"deliveryDate"`
	DeliveryTime         string              `bson:"deliveryTime" json:"deliveryTime"`
	ShippingMethod       OrderShippingMethod `bson:"shippingMethod" json:"shippingMethod"`
	Customer             primitive.ObjectID  `bson:"customer" json:"customer"`
	Status               OrderStatus         `bson:"status" json:"status"`
	Secret               string              `bson:"secret" json:"secret"`
	Items                []OrderItem         `bson:"items" json:"items"`
	Net                  string              `bson:"net" json:"net"`
	Tax                  string              `bson:"tax" json:"tax"`
	Total                string              `bson:"total" json:"total"`
	PaidTotal            string              `bson:"paidTotal" json:"paidTotal"`
	CouponCode           string              `bson:"couponCode" json:"couponCode"`
	AppliedCouponNet     string              `bson:"appliedCouponNet" json:"appliedCouponNet"`
	AppliedCouponTax     string              `bson:"appliedCouponTax" json:"appliedCouponTax"`
	AppliedCouponTotal   string              `bson:"appliedCouponTotal" json:"appliedCouponTotal"`
	AppliedCoupon7Net    string              `bson:"appliedCoupon7Net" json:"appliedCoupon7Net"`
	AppliedCoupon7Tax    string              `bson:"appliedCoupon7Tax" json:"appliedCoupon7Tax"`
	AppliedCoupon7Total  string              `bson:"appliedCoupon7Total" json:"appliedCoupon7Total"`
	AppliedCoupon19Net   string              `bson:"appliedCoupon19Net" json:"appliedCoupon19Net"`
	AppliedCoupon19Tax   string              `bson:"appliedCoupon19Tax" json:"appliedCoupon19Tax"`
	AppliedCoupon19Total string              `bson:"appliedCoupon19Total" json:"appliedCoupon19Total"`
	Tip                  string              `bson:"tip" json:"tip"`
	Printed              bool                `bson:"printed" json:"printed"`
	LocalPickupNotified  bool                `bson:"localPickupNotified" json:"localPickupNotified"`
	ReadyIn              string              `bson:"readyIn" json:"readyIn"`
	Store                primitive.ObjectID  `bson:"store" json:"store"`
	CompanyKey           string              `bson:"companyKey" json:"companyKey"`
	PaymentEvents        []interface{}       `bson:"paymentEvents" json:"paymentEvents"`
	LastSessionId        string              `bson:"lastSessionId" json:"lastSessionId"` // for corporate page
	NewBoxes             int                 `bson:"newBoxes" json:"newBoxes"`
	ReturnBoxes          int                 `bson:"returnBoxes" json:"returnBoxes"`
	CreatedAt            time.Time           `bson:"createdAt" json:"createdAt"`
	UpdatedAt            time.Time           `bson:"updatedAt" json:"updatedAt"`
}

type OrderItem

type OrderItem struct {
	Name       string           `bson:"name" json:"name"`
	Quantity   int              `bson:"quantity" json:"quantity"`
	SKU        string           `bson:"sku" json:"sku"`
	Categories []string         `bson:"categories" json:"categories"`
	Extra      []OrderItemExtra `bson:"extra" json:"extra"`
	Net        string           `bson:"net" json:"net"`
	Tax        string           `bson:"tax" json:"tax"`
	TaxClass   TaxClass         `bson:"taxClass" json:"taxClass"`
	TaxRate    string           `bson:"taxRate" json:"taxRate"`
	Total      string           `bson:"total" json:"total"`
}

type OrderItemExtra

type OrderItemExtra struct {
	Key   string `bson:"key" json:"key"`
	Value string `bson:"value" json:"value"`
}

type OrderShippingMethod

type OrderShippingMethod string
const (
	OrderShippingMethodFreeShipping OrderShippingMethod = "free_shipping"
	OrderShippingMethodLocalPickup  OrderShippingMethod = "local_pickup"
	OrderShippingMethodNoShipping   OrderShippingMethod = "no_shipping"
)

type OrderStatus

type OrderStatus string
const (
	OrderStatusPending        OrderStatus = "PENDING"
	OrderStatusNew            OrderStatus = "NEW"
	OrderStatusNotPossible    OrderStatus = "NOT_POSSIBLE"
	OrderStatusCancelled      OrderStatus = "CANCELLED"
	OrderStatusAddedToGroup   OrderStatus = "ADDED_TO_GROUP"
	OrderStatusGroupFinalized OrderStatus = "GROUP_FINALIZED"
	OrderStatusDelivered      OrderStatus = "DELIVERED"
)

type Product

type Product struct {
	ID           primitive.ObjectID `bson:"_id" json:"id"`
	WPID         int                `bson:"id" json:"wpId"` // it's ok in patch request because we won't change this
	Name         string             `bson:"name" json:"name"`
	Permalink    string             `bson:"permalink" json:"permalink"`
	Type         ProductType        `bson:"type" json:"type"`
	SKU          string             `bson:"sku" json:"sku"`
	Price        string             `bson:"price" json:"price"`
	RegularPrice string             `bson:"regularPrice" json:"regularPrice"`
	SalePrice    string             `bson:"salePrice" json:"salePrice"`
	// TaxClass is deprecated
	TaxClass          string             `bson:"taxClass" json:"taxClass"`
	TaxClassImHaus    TaxClass           `bson:"taxClassImHaus" json:"taxClassImHaus"`
	TaxClassMitnehmen TaxClass           `bson:"taxClassMitnehmen" json:"taxClassMitnehmen"`
	Categories        []string           `bson:"categories" json:"categories"`
	Images            []string           `bson:"images" json:"images"`
	Attributes        []ProductAttribute `bson:"attributes" json:"attributes"`
	Variations        []ProductVariation `bson:"variations" json:"variations"`
	OutOfStockIn      []string           `bson:"outOfStockIn" json:"outOfStockIn"`
	Pfand             string             `bson:"pfand" json:"pfand"`
	CreatedAt         time.Time          `bson:"createdAt" json:"createdAt"`
	UpdatedAt         time.Time          `bson:"updatedAt" json:"updatedAt"`
}

type ProductAttribute

type ProductAttribute struct {
	WPID      int      `bson:"id" json:"wpId"` // it's ok in patch request because we won't change this
	Name      string   `bson:"name" json:"name"`
	Position  int      `bson:"position" json:"position"`
	Variation bool     `bson:"variation" json:"variation"`
	Visible   bool     `bson:"visible" json:"visible"`
	Options   []string `bson:"options" json:"options"`
}

type ProductType

type ProductType string
const (
	ProductTypeSimple   ProductType = "simple"
	ProductTypeVariable ProductType = "variable"
)

type ProductVariation

type ProductVariation struct {
	WPID         int                         `bson:"id" json:"wpId"` // it's ok in patch request because we won't change this
	Price        string                      `bson:"price" json:"price"`
	RegularPrice string                      `bson:"regularPrice" json:"regularPrice"`
	SalePrice    string                      `bson:"salePrice" json:"salePrice"`
	Attributes   []ProductVariationAttribute `bson:"attributes" json:"attributes"`
}

type ProductVariationAttribute

type ProductVariationAttribute struct {
	WPID   int    `bson:"id" json:"wpId"` // it's ok in patch request because we won't change this
	Name   string `bson:"name" json:"name"`
	Option string `bson:"option" json:"option"`
}

type Store

type Store struct {
	ID            primitive.ObjectID `bson:"_id" json:"id"`
	Email         string             `bson:"email" json:"email"`
	Telephone     string             `bson:"telephone" json:"telephone"`
	Name          string             `bson:"name" json:"name"`
	Address       string             `bson:"address" json:"address"`
	Company       string             `bson:"company" json:"company"`
	Owner         string             `bson:"owner" json:"owner"`
	Register      string             `bson:"register" json:"register"`
	Tax           string             `bson:"tax" json:"tax"`
	Configuration StoreConfiguration `bson:"configuration" json:"configuration"`
	Drivers       []string           `bson:"drivers" json:"drivers"`
	Devices       []Device           `bson:"devices" json:"devices"`
	CreatedAt     time.Time          `bson:"createdAt" json:"createdAt"`
	UpdatedAt     time.Time          `bson:"updatedAt" json:"updatedAt"`
}

type StoreConfiguration

type StoreConfiguration struct {
	EnablePrinterAddress      bool   `bson:"enablePrinterAddress" json:"enablePrinterAddress"`
	EnablePrinterInternal     bool   `bson:"enablePrinterInternal" json:"enablePrinterInternal"`
	EnablePrinterPositions    bool   `bson:"enablePrinterPositions" json:"enablePrinterPositions"`
	POSID                     string `bson:"posId" json:"posId"`
	EnableAutomaticPosPayment bool   `bson:"enableAutomaticPosPayment" json:"enableAutomaticPosPayment"`
	WPStoreKey                string `bson:"wpStoreKey" json:"wpStoreKey"`
	DeliverectLocationID      string `bson:"deliverectLocationId" json:"deliverectLocationId"`
	EPSONReceiptPrinterIP     string `bson:"epsonReceiptPrinterIp" json:"epsonReceiptPrinterIp"`
	EPSONAddressPrinterIP     string `bson:"epsonAddressPrinterIp" json:"epsonAddressPrinterIp"`
}

type Tax

type Tax struct {
	ID        primitive.ObjectID `bson:"_id" json:"id"`
	WPID      int                `bson:"id" json:"wpId"`
	Rate      string             `bson:"rate" json:"rate"`
	Name      string             `bson:"name" json:"name"`
	TaxClass  string             `bson:"class" json:"taxClass"` // it's ok to have different names here because we don't provide PATCH request for this entity.
	CreatedAt time.Time          `bson:"createdAt" json:"createdAt"`
	UpdatedAt time.Time          `bson:"updatedAt" json:"updatedAt"`
}

type TaxClass

type TaxClass string
const (
	TaxClassStandard TaxClass = "standard"
	TaxClassReduced  TaxClass = "mitnehmen"
	TaxClassZero     TaxClass = "steuerfreie"
)

type Ticket

type Ticket struct {
	ID           primitive.ObjectID `bson:"_id" json:"id"`
	TicketNumber string             `bson:"ticketNumber" json:"ticketNumber"`
	Status       TicketStatus       `bson:"status" json:"status"`
	StoreKey     string             `bson:"storeKey" json:"storeKey"`
	Customer     TicketCustomer     `bson:"customer" json:"customer"`
	CreatedAt    time.Time          `bson:"createdAt" json:"createdAt"`
	UpdatedAt    time.Time          `bson:"updatedAt" json:"updatedAt"`
	Messages     []TicketMessage    `bson:"messages" json:"messages"`
}

type TicketCustomer

type TicketCustomer struct {
	FirstName      string `bson:"firstName" json:"firstName"`
	LastName       string `bson:"lastName" json:"lastName"`
	Telephone      string `bson:"telephone" json:"telephone"`
	Email          string `bson:"email" json:"email"`
	OrderReference string `bson:"orderReference" json:"orderReference"`
}

type TicketMessage

type TicketMessage struct {
	From      string    `bson:"from" json:"from"`
	Role      string    `bson:"role" json:"role"`
	Text      string    `bson:"text" json:"text"`
	CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
}

type TicketStatus

type TicketStatus string
const (
	TicketStatusNew        TicketStatus = "NEW"
	TicketStatusClosed     TicketStatus = "CLOSED"
	TicketStatusInProgress TicketStatus = "IN_PROGRESS" // TicketStatusInProgress admin must process it
	TicketStatusPending    TicketStatus = "PENDING"     // TicketStatusPending service worker must process it
)

Jump to

Keyboard shortcuts

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