Help us shape the future of Go! Take the 2026 Go Developer Survey

db

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SettlementStatusApplied            = "applied"
	SettlementStatusPending            = "pending"
	SettlementStatusIgnoredShiftClosed = "ignored_shift_closed"
)

Settlement lifecycle -- see db/migrations/000075.

View Source
const UnknownItemBarcode = "UNKNOWN"

UnknownItemBarcode is the barcode a till gives its "Unknown item" placeholder product (kashi-pos's unknownProductBarcode). A sold line with this barcode is stored unresolved and flagged, until an admin says what it was (ResolveUnknownItemsTx).

Variables

View Source
var ErrUnknownItemNotResolvable = errors.New("unknown item can't be resolved")

ErrUnknownItemNotResolvable is returned for a slot whose invoice line can't be found any more (already relabelled, or the invoice was never received).

Functions

This section is empty.

Types

type AcknowledgeSecurityAlertsParams added in v1.1.0

type AcknowledgeSecurityAlertsParams struct {
	AcknowledgedBy string   `json:"acknowledged_by"`
	Ids            []int64  `json:"ids"`
	KeptKinds      []string `json:"kept_kinds"`
}

type AddBatchItemParams

type AddBatchItemParams struct {
	BatchID        int64 `json:"batch_id"`
	VariantID      int64 `json:"variant_id"`
	QuantityBought int64 `json:"quantity_bought"`
	UnitCost       int64 `json:"unit_cost"`
}

type AddCashboxAccountBalanceParams

type AddCashboxAccountBalanceParams struct {
	AccountID int64 `json:"account_id"`
	ShiftID   int64 `json:"shift_id"`
	Balance   int64 `json:"balance"`
}

type AddClientLoyaltyPointsParams

type AddClientLoyaltyPointsParams struct {
	ID                 int64 `json:"id"`
	TotalLoyaltyPoints int64 `json:"total_loyalty_points"`
	ValidLoyaltyPoints int64 `json:"valid_loyalty_points"`
}

type AddInventoryStockQuantityParams

type AddInventoryStockQuantityParams struct {
	InventoryID int64 `json:"inventory_id"`
	VariantID   int64 `json:"variant_id"`
	Quantity    int64 `json:"quantity"`
}

type AddInvoiceDiscountBranchParams added in v1.1.8

type AddInvoiceDiscountBranchParams struct {
	InvoiceDiscountID int64 `json:"invoice_discount_id"`
	BranchID          int64 `json:"branch_id"`
}

type AddInvoiceProductParams

type AddInvoiceProductParams struct {
	InvoiceID int64         `json:"invoice_id"`
	ProductID int64         `json:"product_id"`
	VariantID sql.NullInt64 `json:"variant_id"`
	UnitPrice int64         `json:"unit_price"`
	LineTotal int64         `json:"line_total"`
	Discount  int16         `json:"discount"`
	Quantity  int64         `json:"quantity"`
	UnitCost  int64         `json:"unit_cost"`
}

type AddProductSaleOptionsForEntriesParams added in v1.1.6

type AddProductSaleOptionsForEntriesParams struct {
	SaleOptionIds []int64  `json:"sale_option_ids"`
	Entries       []string `json:"entries"`
}

type AddPurchaseItemParams

type AddPurchaseItemParams struct {
	PurchaseID   sql.NullInt64 `json:"purchase_id"`
	VariantID    sql.NullInt64 `json:"variant_id"`
	AssetID      sql.NullInt64 `json:"asset_id"`
	Quantity     int64         `json:"quantity"`
	UnitPrice    int64         `json:"unit_price"`
	CurrencyCode string        `json:"currency_code"`
}

type AddPurchasedProductCostParams

type AddPurchasedProductCostParams struct {
	ProductSupplierID int64  `json:"product_supplier_id"`
	UnitCost          int64  `json:"unit_cost"`
	CurrencyCode      string `json:"currency_code"`
}

type AddPurchasedProductParams

type AddPurchasedProductParams struct {
	ProductID  int64 `json:"product_id"`
	SupplierID int64 `json:"supplier_id"`
}

type AddStockCountItemParams

type AddStockCountItemParams struct {
	StockCountID    int64 `json:"stock_count_id"`
	VariantID       int64 `json:"variant_id"`
	SystemQuantity  int64 `json:"system_quantity"`
	CountedQuantity int64 `json:"counted_quantity"`
	Difference      int64 `json:"difference"`
}

type AddVariantTxParams

type AddVariantTxParams struct {
	ProductID int64  `json:"product_id"`
	ColorID   *int64 `json:"color_id"`
	SizeID    *int64 `json:"size_id"`
	// Barcode is optional -- a unique EAN-13 is generated when it's nil.
	Barcode *int64 `json:"barcode"`
}

type AddWhatsAppChatMessageParams added in v1.1.1

type AddWhatsAppChatMessageParams struct {
	Instance    string    `json:"instance"`
	WaID        string    `json:"wa_id"`
	ChatJid     string    `json:"chat_jid"`
	ChatPhone   string    `json:"chat_phone"`
	ContactName string    `json:"contact_name"`
	FromMe      bool      `json:"from_me"`
	Kind        string    `json:"kind"`
	Body        string    `json:"body"`
	MediaType   string    `json:"media_type"`
	SentAt      time.Time `json:"sent_at"`
}

type AddWhatsAppPollReplyParams added in v1.1.0

type AddWhatsAppPollReplyParams struct {
	WaID       string    `json:"wa_id"`
	Body       string    `json:"body"`
	Kind       string    `json:"kind"`
	ReceivedAt time.Time `json:"received_at"`
	MediaType  string    `json:"media_type"`
	PollRef    string    `json:"poll_ref"`
}

type AdjustBatchItemRemainingQuantityParams

type AdjustBatchItemRemainingQuantityParams struct {
	Delta int64 `json:"delta"`
	ID    int64 `json:"id"`
}

type AdminActivity

type AdminActivity struct {
	ID          int64         `json:"id"`
	UserID      sql.NullInt64 `json:"user_id"`
	Method      string        `json:"method"`
	Route       string        `json:"route"`
	EntityID    sql.NullInt64 `json:"entity_id"`
	Summary     string        `json:"summary"`
	Detail      string        `json:"detail"`
	CreatedAt   time.Time     `json:"created_at"`
	RepeatCount int32         `json:"repeat_count"`
	ReleaseType string        `json:"release_type"`
}

type AdoptSalespersonAttendanceIDParams added in v1.1.0

type AdoptSalespersonAttendanceIDParams struct {
	ID               int64         `json:"id"`
	BranchID         sql.NullInt64 `json:"branch_id"`
	AttendanceUserID string        `json:"attendance_user_id"`
}

type AppRelease

type AppRelease struct {
	ID         int64         `json:"id"`
	Version    string        `json:"version"`
	Flavor     string        `json:"flavor"`
	FileName   string        `json:"file_name"`
	FilePath   string        `json:"file_path"`
	SizeBytes  int64         `json:"size_bytes"`
	Sha256     string        `json:"sha256"`
	Signature  string        `json:"signature"`
	Notes      string        `json:"notes"`
	UploadedBy sql.NullInt64 `json:"uploaded_by"`
	CreatedAt  time.Time     `json:"created_at"`
}

type AppSetting

type AppSetting struct {
	ID                         int16           `json:"id"`
	FinancialsHighSeasonMonths json.RawMessage `json:"financials_high_season_months"`
	UpdatedAt                  time.Time       `json:"updated_at"`
	ActivityMessageSeconds     int16           `json:"activity_message_seconds"`
	ActivityDisplayMode        string          `json:"activity_display_mode"`
	BarcodeLabelWidth          float32         `json:"barcode_label_width"`
	BarcodeLabelHeight         float32         `json:"barcode_label_height"`
	UpcomingEventsDays         int16           `json:"upcoming_events_days"`
	UpcomingEventsMenuDays     int16           `json:"upcoming_events_menu_days"`
	HiddenBuiltinEvents        json.RawMessage `json:"hidden_builtin_events"`
	DefaultLowStockThreshold   int64           `json:"default_low_stock_threshold"`
	WhatsappEnabled            bool            `json:"whatsapp_enabled"`
	WhatsappPhoneNumberID      string          `json:"whatsapp_phone_number_id"`
	WhatsappAccessToken        string          `json:"whatsapp_access_token"`
	WhatsappTemplateName       string          `json:"whatsapp_template_name"`
	WhatsappTemplateLang       string          `json:"whatsapp_template_lang"`
	WhatsappTemplateParams     string          `json:"whatsapp_template_params"`
	ProductAutofillEnabled     bool            `json:"product_autofill_enabled"`
	ProductAutofillRules       json.RawMessage `json:"product_autofill_rules"`
	ProductAutofillCodeLayout  string          `json:"product_autofill_code_layout"`
	WhatsappMessageCostMicros  int64           `json:"whatsapp_message_cost_micros"`
	WhatsappWebhookVerifyToken string          `json:"whatsapp_webhook_verify_token"`
	WhatsappAppSecret          string          `json:"whatsapp_app_secret"`
	EmailResendApiKey          string          `json:"email_resend_api_key"`
	EmailSenderName            string          `json:"email_sender_name"`
	EmailSenderAddress         string          `json:"email_sender_address"`
	EmailReplyTo               string          `json:"email_reply_to"`
	EmailDefaultRecipients     string          `json:"email_default_recipients"`
	EmailBusinessName          string          `json:"email_business_name"`
	EmailCsvColumns            json.RawMessage `json:"email_csv_columns"`
	EmailAttachmentFormat      string          `json:"email_attachment_format"`
	EmailGroupByRegister       bool            `json:"email_group_by_register"`
	EmailOldestFirst           bool            `json:"email_oldest_first"`
	ReviewPlaceID              string          `json:"review_place_id"`
	ReviewBaseUrl              string          `json:"review_base_url"`
	ReviewTitle                string          `json:"review_title"`
	ReviewDescription          string          `json:"review_description"`
	GooglePlacesApiKey         string          `json:"google_places_api_key"`
	WhatsappSender             string          `json:"whatsapp_sender"`
	WhatsappBridgeUrl          string          `json:"whatsapp_bridge_url"`
	WhatsappBridgeKey          string          `json:"whatsapp_bridge_key"`
	WhatsappBridgeMessage      string          `json:"whatsapp_bridge_message"`
	WhatsappPollQuestion       string          `json:"whatsapp_poll_question"`
	WhatsappPollOptions        string          `json:"whatsapp_poll_options"`
	WhatsappFeedbackMode       string          `json:"whatsapp_feedback_mode"`
	WhatsappBridgeLinkMessage  string          `json:"whatsapp_bridge_link_message"`
	WhatsappChannelUrl         string          `json:"whatsapp_channel_url"`
	WhatsappFollowup           bool            `json:"whatsapp_followup"`
	WhatsappFollowupGood       string          `json:"whatsapp_followup_good"`
	WhatsappFollowupOkay       string          `json:"whatsapp_followup_okay"`
	WhatsappFollowupBad        string          `json:"whatsapp_followup_bad"`
	GoogleReviewsEnabled       bool            `json:"google_reviews_enabled"`
	WhatsappHiddenFields       string          `json:"whatsapp_hidden_fields"`
	WhatsappChannelFirst       bool            `json:"whatsapp_channel_first"`
	WhatsappDeleteForMe        bool            `json:"whatsapp_delete_for_me"`
	WhatsappDeletePollForMe    bool            `json:"whatsapp_delete_poll_for_me"`
	UploadPagesFollowSystem    bool            `json:"upload_pages_follow_system"`
	UnknownImagesAutoDelete    bool            `json:"unknown_images_auto_delete"`
	TablePageSize              int16           `json:"table_page_size"`
	WhatsappWelcomeEarly       bool            `json:"whatsapp_welcome_early"`
	BarcodeLabelDesign         json.RawMessage `json:"barcode_label_design"`
	WhatsappMessageNew         bool            `json:"whatsapp_message_new"`
	WhatsappMessageReturning   bool            `json:"whatsapp_message_returning"`
	WhatsappPollNew            bool            `json:"whatsapp_poll_new"`
	WhatsappPollReturning      bool            `json:"whatsapp_poll_returning"`
	WhatsappFollowupReturning  bool            `json:"whatsapp_followup_returning"`
}

type AppUpdateEvent

type AppUpdateEvent struct {
	ID         int64         `json:"id"`
	RegisterID int64         `json:"register_id"`
	ReleaseID  sql.NullInt64 `json:"release_id"`
	AppVersion string        `json:"app_version"`
	State      string        `json:"state"`
	Detail     string        `json:"detail"`
	CreatedAt  time.Time     `json:"created_at"`
}

type ApplyBranchSettlementTxParams

type ApplyBranchSettlementTxParams struct {
	BranchID      int64
	ClientRef     string
	SaleClientRef string
	GrandTotal    int64
	OccurredAt    time.Time
	Payments      []BranchInvoicePaymentParams
}

type ApplyBranchSettlementTxResult

type ApplyBranchSettlementTxResult struct {
	Settlement     BranchInvoiceSettlement
	Payments       []BranchInvoiceSettlementPayment
	InvoiceUpdated bool
	// Status is the resolved lifecycle of this settlement (one of the
	// SettlementStatus* constants). Frozen is the shorthand the caller
	// reacts to: the sale's shift was already closed, so nothing was
	// replayed and the change is deliberately not surfaced.
	Status string
	Frozen bool
}

type ApplyWhatsAppBridgeTickParams added in v1.1.0

type ApplyWhatsAppBridgeTickParams struct {
	DeliveryStatus string    `json:"delivery_status"`
	At             time.Time `json:"at"`
	BridgeRef      string    `json:"bridge_ref"`
}

type ApplyWhatsAppBridgeTickRow added in v1.1.0

type ApplyWhatsAppBridgeTickRow struct {
	ID       int64         `json:"id"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ApplyWhatsAppDeliveryStatusParams added in v1.1.0

type ApplyWhatsAppDeliveryStatusParams struct {
	DeliveryStatus  string       `json:"delivery_status"`
	At              time.Time    `json:"at"`
	DeliveryError   string       `json:"delivery_error"`
	Billable        sql.NullBool `json:"billable"`
	PricingCategory string       `json:"pricing_category"`
	Wamid           string       `json:"wamid"`
}

type Asset

type Asset struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Code       string    `json:"code"`
	CategoryID int64     `json:"category_id"`
	Version    int32     `json:"version"`
	BoughtAt   time.Time `json:"bought_at"`
	CreatedAt  time.Time `json:"created_at"`
	Cost       int64     `json:"cost"`
}

type AssetCategory

type AssetCategory struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	IsActive  bool      `json:"is_active"`
	Icon      string    `json:"icon"`
	Color     string    `json:"color"`
	CreatedAt time.Time `json:"created_at"`
}

type AttachWhatsAppPollParams added in v1.1.6

type AttachWhatsAppPollParams struct {
	PollRef      string `json:"poll_ref"`
	PollQuestion string `json:"poll_question"`
	PollOptions  string `json:"poll_options"`
	ID           int64  `json:"id"`
}

type Attribute

type Attribute struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

type AttributesValue

type AttributesValue struct {
	ID          int64     `json:"id"`
	AttributeID int64     `json:"attribute_id"`
	Value       string    `json:"value"`
	CreatedAt   time.Time `json:"created_at"`
}

type AuditAction

type AuditAction string
const (
	AuditActionCreate AuditAction = "create"
	AuditActionUpdate AuditAction = "update"
	AuditActionDelete AuditAction = "delete"
)

func (*AuditAction) Scan

func (e *AuditAction) Scan(src interface{}) error

type AuditLog

type AuditLog struct {
	ID         int64                 `json:"id"`
	EntityType string                `json:"entity_type"`
	EntityID   int64                 `json:"entity_id"`
	Action     AuditAction           `json:"action"`
	Before     pqtype.NullRawMessage `json:"before"`
	After      pqtype.NullRawMessage `json:"after"`
	ActorID    sql.NullInt64         `json:"actor_id"`
	Source     string                `json:"source"`
	CreatedAt  time.Time             `json:"created_at"`
}

type Batch

type Batch struct {
	ID          int64         `json:"id"`
	Code        string        `json:"code"`
	PurchaseID  sql.NullInt64 `json:"purchase_id"`
	InventoryID sql.NullInt64 `json:"inventory_id"`
	Note        string        `json:"note"`
	CreatedAt   time.Time     `json:"created_at"`
}

type BatchItem

type BatchItem struct {
	ID                int64 `json:"id"`
	BatchID           int64 `json:"batch_id"`
	VariantID         int64 `json:"variant_id"`
	QuantityBought    int64 `json:"quantity_bought"`
	UnitCost          int64 `json:"unit_cost"`
	RemainingQuantity int64 `json:"remaining_quantity"`
}

type BatchSetClientPhoneFlagsParams added in v1.1.6

type BatchSetClientPhoneFlagsParams struct {
	Ids            []int64  `json:"ids"`
	PhoneValids    []bool   `json:"phone_valids"`
	PhoneCountries []string `json:"phone_countries"`
}

type BatchUpdateClientPhonesParams added in v1.1.3

type BatchUpdateClientPhonesParams struct {
	Ids            []int64  `json:"ids"`
	Phones         []string `json:"phones"`
	PhoneValids    []bool   `json:"phone_valids"`
	PhoneCountries []string `json:"phone_countries"`
}

type Branch

type Branch struct {
	ID                       int64          `json:"id"`
	Name                     string         `json:"name"`
	Code                     string         `json:"code"`
	IsActive                 bool           `json:"is_active"`
	LastSeenAt               sql.NullTime   `json:"last_seen_at"`
	CreatedAt                time.Time      `json:"created_at"`
	InventoryID              sql.NullInt64  `json:"inventory_id"`
	Timezone                 string         `json:"timezone"`
	QuickAccessInitializedAt sql.NullTime   `json:"quick_access_initialized_at"`
	HiddenFromReports        bool           `json:"hidden_from_reports"`
	GooglePlaceID            string         `json:"google_place_id"`
	WhatsappNumberID         sql.NullInt64  `json:"whatsapp_number_id"`
	WhatsappEnabled          bool           `json:"whatsapp_enabled"`
	WhatsappHiddenFields     sql.NullString `json:"whatsapp_hidden_fields"`
}

type BranchAttendanceChange

type BranchAttendanceChange struct {
	ID              int64     `json:"id"`
	BranchID        int64     `json:"branch_id"`
	ClientRef       string    `json:"client_ref"`
	Kind            string    `json:"kind"`
	SalespersonName string    `json:"salesperson_name"`
	AttendanceDate  string    `json:"attendance_date"`
	OriginalTime    string    `json:"original_time"`
	RequestedTime   string    `json:"requested_time"`
	RequestedType   string    `json:"requested_type"`
	Action          string    `json:"action"`
	Status          string    `json:"status"`
	Note            string    `json:"note"`
	Actor           string    `json:"actor"`
	OccurredAt      time.Time `json:"occurred_at"`
	ReceivedAt      time.Time `json:"received_at"`
	RegisterID      int64     `json:"register_id"`
}

type BranchAttendanceChangeRefsPresentParams

type BranchAttendanceChangeRefsPresentParams struct {
	RegisterID int64    `json:"register_id"`
	Column2    []string `json:"column_2"`
}

type BranchAttendanceEvent

type BranchAttendanceEvent struct {
	ID               int64        `json:"id"`
	BranchID         int64        `json:"branch_id"`
	ClientRef        string       `json:"client_ref"`
	SalespersonName  string       `json:"salesperson_name"`
	AttendanceUserID string       `json:"attendance_user_id"`
	EventDate        string       `json:"event_date"`
	EventTime        string       `json:"event_time"`
	EventAt          string       `json:"event_at"`
	Type             string       `json:"type"`
	Status           string       `json:"status"`
	ReceivedAt       time.Time    `json:"received_at"`
	ChangedBy        string       `json:"changed_by"`
	ChangeNote       string       `json:"change_note"`
	RemovedAt        sql.NullTime `json:"removed_at"`
	RemovedBy        string       `json:"removed_by"`
}

type BranchAttendanceEventRefsPresentParams

type BranchAttendanceEventRefsPresentParams struct {
	BranchID int64    `json:"branch_id"`
	Column2  []string `json:"column_2"`
}

type BranchCashboxAccount

type BranchCashboxAccount struct {
	BranchID         int64          `json:"branch_id"`
	CashboxAccountID int64          `json:"cashbox_account_id"`
	IsEnabled        bool           `json:"is_enabled"`
	SortOrder        sql.NullInt32  `json:"sort_order"`
	Color            sql.NullString `json:"color"`
	CurrencyCode     sql.NullString `json:"currency_code"`
	UpdatedAt        time.Time      `json:"updated_at"`
}

type BranchClientLinksPresentParams

type BranchClientLinksPresentParams struct {
	RegisterID int64   `json:"register_id"`
	Column2    []int64 `json:"column_2"`
}

type BranchCommand

type BranchCommand struct {
	ID          int64                 `json:"id"`
	BranchID    int64                 `json:"branch_id"`
	Type        string                `json:"type"`
	Payload     json.RawMessage       `json:"payload"`
	Status      string                `json:"status"`
	Result      pqtype.NullRawMessage `json:"result"`
	Error       sql.NullString        `json:"error"`
	IssuedBy    int64                 `json:"issued_by"`
	CreatedAt   time.Time             `json:"created_at"`
	CompletedAt sql.NullTime          `json:"completed_at"`
	RegisterID  int64                 `json:"register_id"`
}

type BranchCommandSummaryRow

type BranchCommandSummaryRow struct {
	BranchID        int64       `json:"branch_id"`
	Pending         int64       `json:"pending"`
	FailedRecent    int64       `json:"failed_recent"`
	OldestPendingAt interface{} `json:"oldest_pending_at"`
	LastIssuedAt    interface{} `json:"last_issued_at"`
}

type BranchExpense

type BranchExpense struct {
	ID                       int64          `json:"id"`
	BranchID                 int64          `json:"branch_id"`
	ClientRef                string         `json:"client_ref"`
	Description              string         `json:"description"`
	Amount                   int64          `json:"amount"`
	CurrencyCode             string         `json:"currency_code"`
	BranchCashboxAccountID   int64          `json:"branch_cashbox_account_id"`
	BranchShiftID            sql.NullInt64  `json:"branch_shift_id"`
	OccurredAt               time.Time      `json:"occurred_at"`
	ReceivedAt               time.Time      `json:"received_at"`
	CategoryID               sql.NullInt64  `json:"category_id"`
	BranchCashboxAccountName sql.NullString `json:"branch_cashbox_account_name"`
	CancelledAt              sql.NullTime   `json:"cancelled_at"`
	FromCentral              bool           `json:"from_central"`
}

type BranchExpenseImage

type BranchExpenseImage struct {
	ID              int64     `json:"id"`
	BranchExpenseID int64     `json:"branch_expense_id"`
	FilePath        string    `json:"file_path"`
	ContentType     string    `json:"content_type"`
	SizeBytes       int64     `json:"size_bytes"`
	CreatedAt       time.Time `json:"created_at"`
	Rotation        int16     `json:"rotation"`
}

type BranchExpenseRefsPresentParams

type BranchExpenseRefsPresentParams struct {
	BranchID int64    `json:"branch_id"`
	Column2  []string `json:"column_2"`
}

type BranchExpenseUploadToken

type BranchExpenseUploadToken struct {
	ID              int64        `json:"id"`
	BranchExpenseID int64        `json:"branch_expense_id"`
	Token           string       `json:"token"`
	ExpiresAt       time.Time    `json:"expires_at"`
	UsedAt          sql.NullTime `json:"used_at"`
	CreatedAt       time.Time    `json:"created_at"`
}

type BranchInvoice

type BranchInvoice struct {
	ID                     int64          `json:"id"`
	BranchID               int64          `json:"branch_id"`
	ClientRef              string         `json:"client_ref"`
	Kind                   string         `json:"kind"`
	BranchInvoiceCode      string         `json:"branch_invoice_code"`
	BranchCashboxAccountID int64          `json:"branch_cashbox_account_id"`
	BranchShiftID          int64          `json:"branch_shift_id"`
	BranchInventoryID      int64          `json:"branch_inventory_id"`
	BranchClientID         sql.NullInt64  `json:"branch_client_id"`
	RelatedClientRef       sql.NullString `json:"related_client_ref"`
	Discount               int16          `json:"discount"`
	Subtotal               int64          `json:"subtotal"`
	DiscountedTotal        int64          `json:"discounted_total"`
	GrandTotal             int64          `json:"grand_total"`
	LoyaltyPointsDelta     int64          `json:"loyalty_points_delta"`
	OccurredAt             time.Time      `json:"occurred_at"`
	ReceivedAt             time.Time      `json:"received_at"`
	SalespersonName        string         `json:"salesperson_name"`
	Historical             bool           `json:"historical"`
	ClientUid              uuid.NullUUID  `json:"client_uid"`
	RegisterID             int64          `json:"register_id"`
	CancelledAt            sql.NullTime   `json:"cancelled_at"`
	SalespersonID          sql.NullInt64  `json:"salesperson_id"`
	LbpTotal               sql.NullInt64  `json:"lbp_total"`
	LbpRate                sql.NullInt64  `json:"lbp_rate"`
	InvoiceDiscount        int64          `json:"invoice_discount"`
	InvoiceDiscountName    string         `json:"invoice_discount_name"`
}

type BranchInvoiceItem

type BranchInvoiceItem struct {
	ID              int64         `json:"id"`
	BranchInvoiceID int64         `json:"branch_invoice_id"`
	BranchProductID int64         `json:"branch_product_id"`
	UnitPrice       int64         `json:"unit_price"`
	LineTotal       int64         `json:"line_total"`
	Discount        int16         `json:"discount"`
	Quantity        int64         `json:"quantity"`
	ProductUid      uuid.NullUUID `json:"product_uid"`
	Unknown         bool          `json:"unknown"`
	Deal            string        `json:"deal"`
	DealDiscount    int64         `json:"deal_discount"`
	InvoiceDiscount int64         `json:"invoice_discount"`
}

type BranchInvoiceItemParams

type BranchInvoiceItemParams struct {
	BranchProductID int64 `json:"branch_product_id"`
	// Barcode is the SKU's globally-unique barcode -- the only identifier
	// that resolves a branch line to a central product_variants row (see
	// applySyncedProductVariant in kashi-pos). Empty from older kashi-pos
	// builds; such lines are recorded but skip the central stock decrement.
	Barcode string `json:"barcode"`
	// ProductUID is the variant's shared identity (see 000093_sync_uid).
	// When set it wins over Barcode for resolving the central variant;
	// older tills leave it empty and fall back to the barcode.
	ProductUID uuid.NullUUID `json:"product_uid"`
	UnitPrice  int64         `json:"unit_price"`
	LineTotal  int64         `json:"line_total"`
	// A deal line (000202): the deal's name and what it took off the line.
	Deal         string `json:"deal"`
	DealDiscount int64  `json:"deal_discount"`
	// The line's share of the sale's invoice discount (000212), cents;
	// LineTotal already has it off.
	InvoiceDiscount int64 `json:"invoice_discount"`
	// Unknown: the till rang this up as an "Unknown item" (its placeholder
	// barcode, or the product the branch named for it). Such a line is stored
	// unresolved and moves no stock until it is matched to a real product.
	Unknown  bool  `json:"unknown"`
	Discount int16 `json:"discount"`
	Quantity int64 `json:"quantity"`
}

type BranchInvoicePayment

type BranchInvoicePayment struct {
	ID              int64  `json:"id"`
	BranchInvoiceID int64  `json:"branch_invoice_id"`
	AccountName     string `json:"account_name"`
	Amount          int64  `json:"amount"`
}

type BranchInvoicePaymentParams

type BranchInvoicePaymentParams struct {
	AccountName string `json:"account_name"`
	Amount      int64  `json:"amount"`
	// CouponCode is set only when this payment line was a coupon redeemed
	// at checkout -- empty for every ordinary cash/card/account payment.
	// See RedeemCoupon.
	CouponCode string `json:"coupon_code"`
}

type BranchInvoiceRefsPresentParams

type BranchInvoiceRefsPresentParams struct {
	BranchID int64    `json:"branch_id"`
	Column2  []string `json:"column_2"`
}

type BranchInvoiceSettlement

type BranchInvoiceSettlement struct {
	ID            int64     `json:"id"`
	BranchID      int64     `json:"branch_id"`
	ClientRef     string    `json:"client_ref"`
	SaleClientRef string    `json:"sale_client_ref"`
	GrandTotal    int64     `json:"grand_total"`
	OccurredAt    time.Time `json:"occurred_at"`
	ReceivedAt    time.Time `json:"received_at"`
	Status        string    `json:"status"`
}

type BranchInvoiceSettlementPayment

type BranchInvoiceSettlementPayment struct {
	ID                        int64  `json:"id"`
	BranchInvoiceSettlementID int64  `json:"branch_invoice_settlement_id"`
	AccountName               string `json:"account_name"`
	Amount                    int64  `json:"amount"`
}

type BranchLoanRefsPresentParams

type BranchLoanRefsPresentParams struct {
	BranchID sql.NullInt64 `json:"branch_id"`
	Column2  []string      `json:"column_2"`
}

type BranchQuickAccessItem

type BranchQuickAccessItem struct {
	BranchID         int64  `json:"branch_id"`
	ProductVariantID int64  `json:"product_variant_id"`
	Position         int32  `json:"position"`
	Color            string `json:"color"`
	TextColor        string `json:"text_color"`
}

type BranchRegister

type BranchRegister struct {
	ID                       int64                 `json:"id"`
	BranchID                 int64                 `json:"branch_id"`
	Code                     string                `json:"code"`
	Name                     string                `json:"name"`
	ApiKeyHash               string                `json:"api_key_hash"`
	IsActive                 bool                  `json:"is_active"`
	LastSeenAt               sql.NullTime          `json:"last_seen_at"`
	ReportedSettings         pqtype.NullRawMessage `json:"reported_settings"`
	ReportedSettingsAt       sql.NullTime          `json:"reported_settings_at"`
	CreatedAt                time.Time             `json:"created_at"`
	QuickAccessMode          string                `json:"quick_access_mode"`
	QuickAccessModeChangedAt time.Time             `json:"quick_access_mode_changed_at"`
	TargetReleaseID          sql.NullInt64         `json:"target_release_id"`
	AppVersion               string                `json:"app_version"`
	AppFlavor                string                `json:"app_flavor"`
	UpdateState              string                `json:"update_state"`
	UpdateDetail             string                `json:"update_detail"`
	UpdateProgress           int32                 `json:"update_progress"`
	UpdateReportedAt         sql.NullTime          `json:"update_reported_at"`
	HiddenFromReports        bool                  `json:"hidden_from_reports"`
	TargetForce              bool                  `json:"target_force"`
}

type BranchSalespersonExistsParams added in v1.1.0

type BranchSalespersonExistsParams struct {
	ID       int64         `json:"id"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type BranchSetting

type BranchSetting struct {
	BranchID                           int64           `json:"branch_id"`
	BranchName                         string          `json:"branch_name"`
	TaxRate                            float64         `json:"tax_rate"`
	RoundingMode                       string          `json:"rounding_mode"`
	RoundingCurrency                   string          `json:"rounding_currency"`
	ExchangeRate                       int64           `json:"exchange_rate"`
	ExchangeWindowHours                int64           `json:"exchange_window_hours"`
	MarketName                         string          `json:"market_name"`
	MarketPhone                        string          `json:"market_phone"`
	MarketDescription                  string          `json:"market_description"`
	ReturnPolicy                       string          `json:"return_policy"`
	Website                            string          `json:"website"`
	Instagram                          string          `json:"instagram"`
	SocialPlatforms                    json.RawMessage `json:"social_platforms"`
	SocialHandles                      json.RawMessage `json:"social_handles"`
	UpdatedAt                          time.Time       `json:"updated_at"`
	SearchButtonEnabled                bool            `json:"search_button_enabled"`
	CustomItemDiscountsEnabled         bool            `json:"custom_item_discounts_enabled"`
	CustomItemPricesEnabled            bool            `json:"custom_item_prices_enabled"`
	PerUnitItemPricesEnabled           bool            `json:"per_unit_item_prices_enabled"`
	PriceChangeManualOverrideMode      bool            `json:"price_change_manual_override_mode"`
	InvoiceKeyboardMode                bool            `json:"invoice_keyboard_mode"`
	ClientRequired                     bool            `json:"client_required"`
	PageUnlockClients                  bool            `json:"page_unlock_clients"`
	PageUnlockInventory                bool            `json:"page_unlock_inventory"`
	PageUnlockTransfers                bool            `json:"page_unlock_transfers"`
	PageUnlockAttendance               bool            `json:"page_unlock_attendance"`
	PageUnlockSalespersons             bool            `json:"page_unlock_salespersons"`
	PrinterSize                        string          `json:"printer_size"`
	ReceiptWidth                       int64           `json:"receipt_width"`
	ReceiptHeight                      int64           `json:"receipt_height"`
	ReceiptEnabled                     bool            `json:"receipt_enabled"`
	ReceiptFont                        string          `json:"receipt_font"`
	ReceiptBodyFont                    string          `json:"receipt_body_font"`
	ReceiptTitleSize                   float64         `json:"receipt_title_size"`
	ReceiptBodySize                    float64         `json:"receipt_body_size"`
	ReceiptCutoff                      bool            `json:"receipt_cutoff"`
	PrinterID                          string          `json:"printer_id"`
	ReceiptPrinter                     string          `json:"receipt_printer"`
	ScreenPort                         string          `json:"screen_port"`
	AkuvoxIp                           string          `json:"akuvox_ip"`
	AkuvoxUsername                     string          `json:"akuvox_username"`
	AttendanceEnabled                  bool            `json:"attendance_enabled"`
	AttendanceDuplicateIntervalSeconds int64           `json:"attendance_duplicate_interval_seconds"`
	AttendanceCashierHistory           bool            `json:"attendance_cashier_history"`
	ManagedLocally                     []string        `json:"managed_locally"`
	SplitPrimaryCurrency               string          `json:"split_primary_currency"`
	SplitPrimaryFirst                  bool            `json:"split_primary_first"`
	SplitPrimaryStep                   int64           `json:"split_primary_step"`
	OversellMode                       string          `json:"oversell_mode"`
	CloseShiftRequiresSync             bool            `json:"close_shift_requires_sync"`
	SalespersonPerInvoiceRequired      bool            `json:"salesperson_per_invoice_required"`
	NonAdminMonthNavEnabled            bool            `json:"non_admin_month_nav_enabled"`
	OpeningFloatEnabled                bool            `json:"opening_float_enabled"`
	CountOpeningCashOnClose            bool            `json:"count_opening_cash_on_close"`
	OverchangeConfirmation             bool            `json:"overchange_confirmation"`
	PageUnlockProducts                 bool            `json:"page_unlock_products"`
	HidePaymentMethodCurrency          bool            `json:"hide_payment_method_currency"`
	AutoAppendLbpZeros                 bool            `json:"auto_append_lbp_zeros"`
	AutoCloseStaleShifts               bool            `json:"auto_close_stale_shifts"`
	VisitorCounterEnabled              bool            `json:"visitor_counter_enabled"`
	ShiftReceiptUploadMode             int64           `json:"shift_receipt_upload_mode"`
	BranchPhone                        string          `json:"branch_phone"`
	MaxOverpaymentCents                int64           `json:"max_overpayment_cents"`
	DefaultOpeningFloatUsd             int64           `json:"default_opening_float_usd"`
	DefaultOpeningFloatLbp             int64           `json:"default_opening_float_lbp"`
	DisplayPrefs                       json.RawMessage `json:"display_prefs"`
	ScanByCodeEnabled                  bool            `json:"scan_by_code_enabled"`
	SoundsEnabled                      bool            `json:"sounds_enabled"`
	AttendanceManagerApprovalEnabled   bool            `json:"attendance_manager_approval_enabled"`
	ShiftReportSignatures              bool            `json:"shift_report_signatures"`
	ShiftReportUppercaseHeader         bool            `json:"shift_report_uppercase_header"`
	AutoCoverNegativeLbp               bool            `json:"auto_cover_negative_lbp"`
	ProductSearchCodeOnly              bool            `json:"product_search_code_only"`
	PriceEditRestricted                bool            `json:"price_edit_restricted"`
	PriceEditCodes                     string          `json:"price_edit_codes"`
	UnknownProductBarcode              string          `json:"unknown_product_barcode"`
	ProductSearchHiddenFields          string          `json:"product_search_hidden_fields"`
	ReceiptTheme                       string          `json:"receipt_theme"`
	ReceiptLayout                      string          `json:"receipt_layout"`
	DiscountToggle                     bool            `json:"discount_toggle"`
	DiscountToggleDefaultOff           bool            `json:"discount_toggle_default_off"`
	DealToggle                         bool            `json:"deal_toggle"`
}

type BranchShift

type BranchShift struct {
	ID                int64        `json:"id"`
	BranchID          int64        `json:"branch_id"`
	ClientRef         string       `json:"client_ref"`
	BranchShiftID     int64        `json:"branch_shift_id"`
	OpenedAt          sql.NullTime `json:"opened_at"`
	ClosedAt          sql.NullTime `json:"closed_at"`
	ClosingPersonName string       `json:"closing_person_name"`
	OpeningFloatUsd   int64        `json:"opening_float_usd"`
	OpeningFloatLbp   int64        `json:"opening_float_lbp"`
	ExpectedUsd       int64        `json:"expected_usd"`
	ExpectedLbp       int64        `json:"expected_lbp"`
	ExpectedVisa      int64        `json:"expected_visa"`
	ExpectedWhish     int64        `json:"expected_whish"`
	CountedUsd        int64        `json:"counted_usd"`
	CountedLbp        int64        `json:"counted_lbp"`
	CountedVisa       int64        `json:"counted_visa"`
	CountedWhish      int64        `json:"counted_whish"`
	VarianceUsd       int64        `json:"variance_usd"`
	VarianceLbp       int64        `json:"variance_lbp"`
	VarianceVisa      int64        `json:"variance_visa"`
	VarianceWhish     int64        `json:"variance_whish"`
	OccurredAt        time.Time    `json:"occurred_at"`
	ReceivedAt        time.Time    `json:"received_at"`
	RegisterID        int64        `json:"register_id"`
	LbpRate           int64        `json:"lbp_rate"`
}

type BranchShiftIsClosedParams

type BranchShiftIsClosedParams struct {
	RegisterID    int64 `json:"register_id"`
	BranchShiftID int64 `json:"branch_shift_id"`
}

type BranchShiftReceiptImage

type BranchShiftReceiptImage struct {
	ID            int64     `json:"id"`
	BranchShiftID int64     `json:"branch_shift_id"`
	FilePath      string    `json:"file_path"`
	ContentType   string    `json:"content_type"`
	SizeBytes     int64     `json:"size_bytes"`
	CreatedAt     time.Time `json:"created_at"`
	Rotation      int16     `json:"rotation"`
}

type BranchShiftRefsPresentParams

type BranchShiftRefsPresentParams struct {
	RegisterID int64    `json:"register_id"`
	Column2    []string `json:"column_2"`
}

type BranchShiftUploadToken

type BranchShiftUploadToken struct {
	ID            int64        `json:"id"`
	BranchShiftID int64        `json:"branch_shift_id"`
	Token         string       `json:"token"`
	ExpiresAt     time.Time    `json:"expires_at"`
	UsedAt        sql.NullTime `json:"used_at"`
	CreatedAt     time.Time    `json:"created_at"`
}

type BranchSyncConflict

type BranchSyncConflict struct {
	ID              int64                 `json:"id"`
	BranchID        int64                 `json:"branch_id"`
	Entity          string                `json:"entity"`
	Ref             string                `json:"ref"`
	Kind            string                `json:"kind"`
	BranchPayload   json.RawMessage       `json:"branch_payload"`
	CentralClientID sql.NullInt64         `json:"central_client_id"`
	Status          string                `json:"status"`
	Resolution      pqtype.NullRawMessage `json:"resolution"`
	ResolvedBy      sql.NullInt64         `json:"resolved_by"`
	CreatedAt       time.Time             `json:"created_at"`
	UpdatedAt       time.Time             `json:"updated_at"`
}

type BranchSyncConflictSummaryRow

type BranchSyncConflictSummaryRow struct {
	BranchID     int64       `json:"branch_id"`
	Open         int64       `json:"open"`
	OpenOversold int64       `json:"open_oversold"`
	OldestOpenAt interface{} `json:"oldest_open_at"`
}

type BranchTarget

type BranchTarget struct {
	ID           int64         `json:"id"`
	BranchID     int64         `json:"branch_id"`
	DateFrom     time.Time     `json:"date_from"`
	DateTo       time.Time     `json:"date_to"`
	TargetAmount int64         `json:"target_amount"`
	Color        string        `json:"color"`
	CreatedAt    time.Time     `json:"created_at"`
	UpdatedAt    time.Time     `json:"updated_at"`
	SeriesID     sql.NullInt64 `json:"series_id"`
	IsActive     bool          `json:"is_active"`
}

type BranchTargetSeries

type BranchTargetSeries struct {
	ID            int64     `json:"id"`
	BranchID      int64     `json:"branch_id"`
	TargetAmount  int64     `json:"target_amount"`
	Color         string    `json:"color"`
	StartDay      int32     `json:"start_day"`
	IntervalCount int32     `json:"interval_count"`
	Active        bool      `json:"active"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

type BranchTransferItemParams

type BranchTransferItemParams struct {
	Barcode    string        `json:"barcode"`
	ProductUID uuid.NullUUID `json:"product_uid"`
	Quantity   int64         `json:"quantity"`
}

type BranchTransferUploadToken

type BranchTransferUploadToken struct {
	ID         int64        `json:"id"`
	TransferID int64        `json:"transfer_id"`
	Token      string       `json:"token"`
	ExpiresAt  time.Time    `json:"expires_at"`
	UsedAt     sql.NullTime `json:"used_at"`
	CreatedAt  time.Time    `json:"created_at"`
}

type BranchUser

type BranchUser struct {
	ID           int64     `json:"id"`
	BranchID     int64     `json:"branch_id"`
	Username     string    `json:"username"`
	Role         string    `json:"role"`
	AkuvoxUserID string    `json:"akuvox_user_id"`
	IsActive     bool      `json:"is_active"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type BranchVisitorEvent

type BranchVisitorEvent struct {
	ID         int64     `json:"id"`
	BranchID   int64     `json:"branch_id"`
	ClientRef  string    `json:"client_ref"`
	Day        string    `json:"day"`
	Direction  string    `json:"direction"`
	OccurredAt time.Time `json:"occurred_at"`
	ReceivedAt time.Time `json:"received_at"`
}

type BranchVisitorEventRefsPresentParams

type BranchVisitorEventRefsPresentParams struct {
	BranchID int64    `json:"branch_id"`
	Column2  []string `json:"column_2"`
}

type BulkSetDiscountListItemsParams added in v1.1.1

type BulkSetDiscountListItemsParams struct {
	DiscountListID int64         `json:"discount_list_id"`
	Discount       int16         `json:"discount"`
	DealID         sql.NullInt64 `json:"deal_id"`
	Entries        []string      `json:"entries"`
}

type BulkSetDiscountListOptionItemsParams added in v1.1.6

type BulkSetDiscountListOptionItemsParams struct {
	DiscountListID int64    `json:"discount_list_id"`
	SaleOptionID   int64    `json:"sale_option_id"`
	Discount       int16    `json:"discount"`
	Entries        []string `json:"entries"`
}

type BumpAdminActivityParams added in v1.1.0

type BumpAdminActivityParams struct {
	UserID   sql.NullInt64 `json:"user_id"`
	Method   string        `json:"method"`
	Route    string        `json:"route"`
	EntityID sql.NullInt64 `json:"entity_id"`
	Summary  string        `json:"summary"`
	Detail   string        `json:"detail"`
}

type BusyHoursSalesParams added in v1.1.0

type BusyHoursSalesParams struct {
	FromDay   time.Time `json:"from_day"`
	ToDay     time.Time `json:"to_day"`
	BranchIds []int64   `json:"branch_ids"`
}

type BusyHoursSalesRow added in v1.1.0

type BusyHoursSalesRow struct {
	Weekday      int32 `json:"weekday"`
	Hour         int32 `json:"hour"`
	Invoices     int64 `json:"invoices"`
	RevenueCents int64 `json:"revenue_cents"`
}

type BusyHoursVisitorsParams added in v1.1.0

type BusyHoursVisitorsParams struct {
	FromDay   time.Time `json:"from_day"`
	ToDay     time.Time `json:"to_day"`
	BranchIds []int64   `json:"branch_ids"`
}

type BusyHoursVisitorsRow added in v1.1.0

type BusyHoursVisitorsRow struct {
	Weekday  int32 `json:"weekday"`
	Hour     int32 `json:"hour"`
	Visitors int64 `json:"visitors"`
}

type CalendarEvent

type CalendarEvent struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	Icon      string    `json:"icon"`
	Color     string    `json:"color"`
	StartDate time.Time `json:"start_date"`
	EndDate   time.Time `json:"end_date"`
	CreatedAt time.Time `json:"created_at"`
}

type Cashbox

type Cashbox struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	Code      string    `json:"code"`
	IsActive  bool      `json:"is_active"`
	CreatedAt time.Time `json:"created_at"`
}

type CashboxAccount

type CashboxAccount struct {
	ID           int64     `json:"id"`
	Name         string    `json:"name"`
	CurrencyCode string    `json:"currency_code"`
	SortOrder    int32     `json:"sort_order"`
	Color        string    `json:"color"`
	UpdatedAt    time.Time `json:"updated_at"`
	IsActive     bool      `json:"is_active"`
}

type ClaimEmailScheduleRunParams added in v1.1.0

type ClaimEmailScheduleRunParams struct {
	NextRunAt sql.NullTime `json:"next_run_at"`
	ID        int64        `json:"id"`
	DueAt     sql.NullTime `json:"due_at"`
}

type ClaimWhatsAppPollFollowupParams added in v1.1.0

type ClaimWhatsAppPollFollowupParams struct {
	FollowupBody string `json:"followup_body"`
	ID           int64  `json:"id"`
	ForReturning bool   `json:"for_returning"`
	ForNew       bool   `json:"for_new"`
}

type ClaimWhatsAppPollFollowupRow added in v1.1.0

type ClaimWhatsAppPollFollowupRow struct {
	ClientPhone string `json:"client_phone"`
	Instance    string `json:"instance"`
}

type ClaimWhatsAppWelcomeParams added in v1.1.1

type ClaimWhatsAppWelcomeParams struct {
	Invoice    string        `json:"invoice"`
	TotalCents int64         `json:"total_cents"`
	Items      int32         `json:"items"`
	Phone      string        `json:"phone"`
	Branch     sql.NullInt64 `json:"branch"`
}

type Client

type Client struct {
	ID                 int64         `json:"id"`
	Name               string        `json:"name"`
	Phone              string        `json:"phone"`
	TotalLoyaltyPoints int64         `json:"total_loyalty_points"`
	ValidLoyaltyPoints int64         `json:"valid_loyalty_points"`
	CreatedAt          time.Time     `json:"created_at"`
	UpdatedAt          time.Time     `json:"updated_at"`
	ClientType         string        `json:"client_type"`
	Uid                uuid.UUID     `json:"uid"`
	IsActive           bool          `json:"is_active"`
	BranchID           sql.NullInt64 `json:"branch_id"`
	PhoneValid         bool          `json:"phone_valid"`
	PhoneCountry       string        `json:"phone_country"`
}
type ClientLink struct {
	BranchID       int64 `json:"branch_id"`
	BranchClientID int64 `json:"branch_client_id"`
	ClientID       int64 `json:"client_id"`
	RegisterID     int64 `json:"register_id"`
}

type ClientMonthlySpendRow

type ClientMonthlySpendRow struct {
	Month      string // "YYYY-MM"
	TotalCents int64
}

ClientMonthlySpendRow is one month of the spend series.

type ClientPaymentMixRow

type ClientPaymentMixRow struct {
	AccountName string
	TotalCents  int64
}

ClientPaymentMixRow is one slice of the payment-mix breakdown.

type ClientProfileStats

type ClientProfileStats struct {
	TotalSpentCents int64
	ItemsBought     int64
	FirstPurchaseAt *time.Time
}

ClientProfileStats holds aggregate purchase stats for one client.

type ClientRecentInvoiceRow

type ClientRecentInvoiceRow struct {
	ID             int64
	InvoiceCode    string
	GrandTotal     int64
	OccurredAt     time.Time
	BranchName     string
	ItemCount      int64
	PaymentMethods string // comma-separated
}

ClientRecentInvoiceRow is one row in the recent-purchases table.

type ClientSpend added in v1.1.6

type ClientSpend struct {
	ClientID        int64        `json:"client_id"`
	TotalSpent      int64        `json:"total_spent"`
	GrossSpent      int64        `json:"gross_spent"`
	InvoiceCount    int64        `json:"invoice_count"`
	ItemCount       int64        `json:"item_count"`
	RefreshedAt     time.Time    `json:"refreshed_at"`
	FirstPurchaseAt sql.NullTime `json:"first_purchase_at"`
}

type Color

type Color struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	HexValue  string    `json:"hex_value"`
	Version   int32     `json:"version"`
	CreatedAt time.Time `json:"created_at"`
}

type CompleteBranchCommandParams

type CompleteBranchCommandParams struct {
	ID     int64                 `json:"id"`
	Status string                `json:"status"`
	Result pqtype.NullRawMessage `json:"result"`
	Error  sql.NullString        `json:"error"`
}

type ConfirmBranchTransferItemParams

type ConfirmBranchTransferItemParams struct {
	Barcode          string        `json:"barcode"`
	ProductUID       uuid.NullUUID `json:"product_uid"`
	ReceivedQuantity int64         `json:"received_quantity"`
}

type ConfirmBranchTransferTxParams

type ConfirmBranchTransferTxParams struct {
	BranchID   int64                             `json:"branch_id"`
	TransferID int64                             `json:"transfer_id"`
	Note       string                            `json:"note"`
	Items      []ConfirmBranchTransferItemParams `json:"items"`
}

type CountAssetsParams

type CountAssetsParams struct {
	CategoryID sql.NullInt64 `json:"category_id"`
	Search     string        `json:"search"`
}

type CountAttributeValuesParams

type CountAttributeValuesParams struct {
	AttributeName string `json:"attribute_name"`
	Search        string `json:"search"`
}

type CountAuditLogsParams

type CountAuditLogsParams struct {
	EntityType sql.NullString  `json:"entity_type"`
	EntityID   sql.NullInt64   `json:"entity_id"`
	Action     NullAuditAction `json:"action"`
	ActorID    sql.NullInt64   `json:"actor_id"`
	FromDate   sql.NullTime    `json:"from_date"`
	ToDate     sql.NullTime    `json:"to_date"`
}

type CountBranchCommandsParams

type CountBranchCommandsParams struct {
	BranchID   int64  `json:"branch_id"`
	RegisterID int64  `json:"register_id"`
	Status     string `json:"status"`
	Type       string `json:"type"`
}

type CountBranchExpensesParams

type CountBranchExpensesParams struct {
	BranchID sql.NullInt64 `json:"branch_id"`
	Search   string        `json:"search"`
}

type CountBranchInvoicesFilteredParams

type CountBranchInvoicesFilteredParams struct {
	BranchID   sql.NullInt64  `json:"branch_id"`
	Search     string         `json:"search"`
	RegisterID sql.NullInt64  `json:"register_id"`
	Kind       sql.NullString `json:"kind"`
	Status     sql.NullString `json:"status"`
	DateFrom   sql.NullTime   `json:"date_from"`
	DateTo     sql.NullTime   `json:"date_to"`
}

type CountBranchSyncConflictsParams

type CountBranchSyncConflictsParams struct {
	Column1 int64  `json:"column_1"`
	Column2 string `json:"column_2"`
	Column3 string `json:"column_3"`
	Column4 string `json:"column_4"`
}

type CountBranchVisitorDayByDirectionParams

type CountBranchVisitorDayByDirectionParams struct {
	BranchID  int64  `json:"branch_id"`
	Day       string `json:"day"`
	Direction string `json:"direction"`
}

type CountClientsBySpendingCachedParams added in v1.1.6

type CountClientsBySpendingCachedParams struct {
	ClientType   sql.NullString `json:"client_type"`
	Search       sql.NullString `json:"search"`
	PhoneValid   sql.NullBool   `json:"phone_valid"`
	PhoneCountry sql.NullString `json:"phone_country"`
}

type CountClientsBySpendingParams

type CountClientsBySpendingParams struct {
	ClientType   sql.NullString `json:"client_type"`
	Search       sql.NullString `json:"search"`
	PhoneValid   sql.NullBool   `json:"phone_valid"`
	PhoneCountry sql.NullString `json:"phone_country"`
	BranchIds    []int64        `json:"branch_ids"`
	DateFrom     sql.NullTime   `json:"date_from"`
	DateTo       sql.NullTime   `json:"date_to"`
	Visit        string         `json:"visit"`
}

type CountCouponsParams

type CountCouponsParams struct {
	Search     string           `json:"search"`
	Status     NullCouponStatus `json:"status"`
	CategoryID sql.NullInt64    `json:"category_id"`
	ListID     sql.NullInt64    `json:"list_id"`
}

type CountDashboardExpensesParams

type CountDashboardExpensesParams struct {
	Scope    string        `json:"scope"`
	DateFrom time.Time     `json:"date_from"`
	DateTo   time.Time     `json:"date_to"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type CountDashboardPurchasesParams

type CountDashboardPurchasesParams struct {
	Scope    string    `json:"scope"`
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type CountDashboardSalesParams

type CountDashboardSalesParams struct {
	Scope    string        `json:"scope"`
	DateFrom time.Time     `json:"date_from"`
	DateTo   time.Time     `json:"date_to"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type CountDiscountListItemsWithProductParams

type CountDiscountListItemsWithProductParams struct {
	Search         string `json:"search"`
	DiscountListID int64  `json:"discount_list_id"`
}

type CountDiscountListRuleDecidedRow added in v1.1.7

type CountDiscountListRuleDecidedRow struct {
	RuleID   int64 `json:"rule_id"`
	Variants int64 `json:"variants"`
}

type CountEmployeesParams

type CountEmployeesParams struct {
	Search   string        `json:"search"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type CountExpensesParams

type CountExpensesParams struct {
	CategoryID sql.NullInt64  `json:"category_id"`
	Search     sql.NullString `json:"search"`
}

type CountInventoryStockParams

type CountInventoryStockParams struct {
	InventoryID int64  `json:"inventory_id"`
	Search      string `json:"search"`
}

type CountLatestAdditionsSinceParams added in v1.1.0

type CountLatestAdditionsSinceParams struct {
	IncludeAccounting bool      `json:"include_accounting"`
	Since             time.Time `json:"since"`
	IncludeHr         bool      `json:"include_hr"`
	IncludeInventory  bool      `json:"include_inventory"`
}

type CountLoanPaymentsParams

type CountLoanPaymentsParams struct {
	LoanID     sql.NullInt64  `json:"loan_id"`
	CategoryID sql.NullInt64  `json:"category_id"`
	Search     sql.NullString `json:"search"`
}

type CountLoansParams

type CountLoansParams struct {
	BranchID   sql.NullInt64  `json:"branch_id"`
	Origin     sql.NullString `json:"origin"`
	CategoryID sql.NullInt64  `json:"category_id"`
	Search     sql.NullString `json:"search"`
	Status     sql.NullString `json:"status"`
}

type CountLowStockProductsParams

type CountLowStockProductsParams struct {
	Status sql.NullString `json:"status"`
	Search string         `json:"search"`
}

type CountPriceListItemsWithProductParams

type CountPriceListItemsWithProductParams struct {
	PriceListID int64  `json:"price_list_id"`
	Search      string `json:"search"`
}

type CountShiftsParams

type CountShiftsParams struct {
	Status    string        `json:"status"`
	CashboxID sql.NullInt64 `json:"cashbox_id"`
	Search    string        `json:"search"`
}

type CountSlowMovingProductsParams

type CountSlowMovingProductsParams struct {
	Category sql.NullString `json:"category"`
	Search   string         `json:"search"`
}

type CountStockCountsParams

type CountStockCountsParams struct {
	InventoryID sql.NullInt64        `json:"inventory_id"`
	Status      NullStockCountStatus `json:"status"`
}

type CountStockMovementsParams

type CountStockMovementsParams struct {
	InventoryID   sql.NullInt64           `json:"inventory_id"`
	VariantID     sql.NullInt64           `json:"variant_id"`
	Reason        NullStockMovementReason `json:"reason"`
	ReferenceType sql.NullString          `json:"reference_type"`
	CreatedBy     sql.NullInt64           `json:"created_by"`
	FromDate      sql.NullTime            `json:"from_date"`
	ToDate        sql.NullTime            `json:"to_date"`
}

type CountVisitorIPsParams added in v1.1.0

type CountVisitorIPsParams struct {
	Search      string `json:"search"`
	CountryCode string `json:"country_code"`
}

type CountWhatsAppMessagesParams added in v1.1.0

type CountWhatsAppMessagesParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
	Status   string    `json:"status"`
	Search   string    `json:"search"`
}

type CountWhatsAppRepliesParams added in v1.1.0

type CountWhatsAppRepliesParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
	Search   string    `json:"search"`
}

type Coupon

type Coupon struct {
	Code               string         `json:"code"`
	Status             CouponStatus   `json:"status"`
	ClientID           sql.NullInt64  `json:"client_id"`
	ValidUntil         sql.NullTime   `json:"valid_until"`
	CreatedAt          time.Time      `json:"created_at"`
	CategoryID         sql.NullInt64  `json:"category_id"`
	TypeID             sql.NullInt64  `json:"type_id"`
	ListID             sql.NullInt64  `json:"list_id"`
	ValueCents         int64          `json:"value_cents"`
	RedeemedBranchID   sql.NullInt64  `json:"redeemed_branch_id"`
	RedeemedInvoiceRef sql.NullString `json:"redeemed_invoice_ref"`
	RedeemedAt         sql.NullTime   `json:"redeemed_at"`
	UpdatedAt          time.Time      `json:"updated_at"`
}

type CouponCategory

type CouponCategory struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	IsActive  bool      `json:"is_active"`
	Icon      string    `json:"icon"`
	Color     string    `json:"color"`
	Scope     string    `json:"scope"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type CouponList

type CouponList struct {
	ID           int64     `json:"id"`
	Name         string    `json:"name"`
	CouponTypeID int64     `json:"coupon_type_id"`
	IsActive     bool      `json:"is_active"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type CouponStatus

type CouponStatus string
const (
	CouponStatusActive   CouponStatus = "active"
	CouponStatusInactive CouponStatus = "inactive"
	CouponStatusRedeemed CouponStatus = "redeemed"
)

func (*CouponStatus) Scan

func (e *CouponStatus) Scan(src interface{}) error

type CouponType

type CouponType struct {
	ID                  int64         `json:"id"`
	Name                string        `json:"name"`
	ValueCents          int64         `json:"value_cents"`
	CurrencyCode        string        `json:"currency_code"`
	IsActive            bool          `json:"is_active"`
	ReferenceOnly       bool          `json:"reference_only"`
	CalculateOnCheckout bool          `json:"calculate_on_checkout"`
	CodeOptional        bool          `json:"code_optional"`
	CategoryID          sql.NullInt64 `json:"category_id"`
	CreatedAt           time.Time     `json:"created_at"`
	UpdatedAt           time.Time     `json:"updated_at"`
}

type CreateAdminActivityParams

type CreateAdminActivityParams struct {
	UserID   sql.NullInt64 `json:"user_id"`
	Method   string        `json:"method"`
	Route    string        `json:"route"`
	EntityID sql.NullInt64 `json:"entity_id"`
	Summary  string        `json:"summary"`
	Detail   string        `json:"detail"`
}

type CreateAppReleaseParams

type CreateAppReleaseParams struct {
	Version    string        `json:"version"`
	Flavor     string        `json:"flavor"`
	FileName   string        `json:"file_name"`
	FilePath   string        `json:"file_path"`
	SizeBytes  int64         `json:"size_bytes"`
	Sha256     string        `json:"sha256"`
	Signature  string        `json:"signature"`
	Notes      string        `json:"notes"`
	UploadedBy sql.NullInt64 `json:"uploaded_by"`
}

type CreateAppUpdateEventParams

type CreateAppUpdateEventParams struct {
	RegisterID int64         `json:"register_id"`
	ReleaseID  sql.NullInt64 `json:"release_id"`
	AppVersion string        `json:"app_version"`
	State      string        `json:"state"`
	Detail     string        `json:"detail"`
}

type CreateAssetCategoryParams

type CreateAssetCategoryParams struct {
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
	Icon     string `json:"icon"`
	Color    string `json:"color"`
}

type CreateAssetParams

type CreateAssetParams struct {
	Name       string    `json:"name"`
	Code       string    `json:"code"`
	CategoryID int64     `json:"category_id"`
	BoughtAt   time.Time `json:"bought_at"`
}

type CreateAuditLogParams

type CreateAuditLogParams struct {
	EntityType string                `json:"entity_type"`
	EntityID   int64                 `json:"entity_id"`
	Action     AuditAction           `json:"action"`
	Before     pqtype.NullRawMessage `json:"before"`
	After      pqtype.NullRawMessage `json:"after"`
	ActorID    sql.NullInt64         `json:"actor_id"`
	Source     string                `json:"source"`
}

type CreateBatchParams

type CreateBatchParams struct {
	Code        string        `json:"code"`
	PurchaseID  sql.NullInt64 `json:"purchase_id"`
	InventoryID sql.NullInt64 `json:"inventory_id"`
	Note        string        `json:"note"`
}

type CreateBatchTxParams

type CreateBatchTxParams struct {
	Code       string `json:"code"`
	PurchaseID int64  `json:"purchase_id"`
	Note       string `json:"note"`
}

type CreateBatchTxResult

type CreateBatchTxResult struct {
	Batch Batch       `json:"batch"`
	Items []BatchItem `json:"items"`
}

type CreateBranchAttendanceChangeParams

type CreateBranchAttendanceChangeParams struct {
	BranchID        int64     `json:"branch_id"`
	ClientRef       string    `json:"client_ref"`
	Kind            string    `json:"kind"`
	SalespersonName string    `json:"salesperson_name"`
	AttendanceDate  string    `json:"attendance_date"`
	OriginalTime    string    `json:"original_time"`
	RequestedTime   string    `json:"requested_time"`
	RequestedType   string    `json:"requested_type"`
	Action          string    `json:"action"`
	Status          string    `json:"status"`
	Note            string    `json:"note"`
	Actor           string    `json:"actor"`
	OccurredAt      time.Time `json:"occurred_at"`
	RegisterID      int64     `json:"register_id"`
}

type CreateBranchAttendanceEventParams

type CreateBranchAttendanceEventParams struct {
	BranchID         int64  `json:"branch_id"`
	ClientRef        string `json:"client_ref"`
	SalespersonName  string `json:"salesperson_name"`
	AttendanceUserID string `json:"attendance_user_id"`
	EventDate        string `json:"event_date"`
	EventTime        string `json:"event_time"`
	EventAt          string `json:"event_at"`
	Type             string `json:"type"`
	Status           string `json:"status"`
	ChangedBy        string `json:"changed_by"`
	ChangeNote       string `json:"change_note"`
}

type CreateBranchCommandParams

type CreateBranchCommandParams struct {
	BranchID   int64           `json:"branch_id"`
	RegisterID int64           `json:"register_id"`
	Type       string          `json:"type"`
	Payload    json.RawMessage `json:"payload"`
	IssuedBy   int64           `json:"issued_by"`
}

type CreateBranchExpenseImageParams

type CreateBranchExpenseImageParams struct {
	BranchExpenseID int64  `json:"branch_expense_id"`
	FilePath        string `json:"file_path"`
	ContentType     string `json:"content_type"`
	SizeBytes       int64  `json:"size_bytes"`
}

type CreateBranchExpenseParams

type CreateBranchExpenseParams struct {
	BranchID                 int64          `json:"branch_id"`
	ClientRef                string         `json:"client_ref"`
	Description              string         `json:"description"`
	CategoryID               sql.NullInt64  `json:"category_id"`
	Amount                   int64          `json:"amount"`
	CurrencyCode             string         `json:"currency_code"`
	BranchCashboxAccountID   int64          `json:"branch_cashbox_account_id"`
	BranchCashboxAccountName sql.NullString `json:"branch_cashbox_account_name"`
	BranchShiftID            sql.NullInt64  `json:"branch_shift_id"`
	OccurredAt               time.Time      `json:"occurred_at"`
	FromCentral              bool           `json:"from_central"`
}

type CreateBranchExpenseUploadTokenParams

type CreateBranchExpenseUploadTokenParams struct {
	BranchExpenseID int64     `json:"branch_expense_id"`
	Token           string    `json:"token"`
	ExpiresAt       time.Time `json:"expires_at"`
}

type CreateBranchInvoiceItemParams

type CreateBranchInvoiceItemParams struct {
	BranchInvoiceID int64         `json:"branch_invoice_id"`
	BranchProductID int64         `json:"branch_product_id"`
	UnitPrice       int64         `json:"unit_price"`
	LineTotal       int64         `json:"line_total"`
	Discount        int16         `json:"discount"`
	Quantity        int64         `json:"quantity"`
	ProductUid      uuid.NullUUID `json:"product_uid"`
	Unknown         bool          `json:"unknown"`
	Deal            string        `json:"deal"`
	DealDiscount    int64         `json:"deal_discount"`
}

type CreateBranchInvoiceParams

type CreateBranchInvoiceParams struct {
	BranchID               int64          `json:"branch_id"`
	ClientRef              string         `json:"client_ref"`
	Kind                   string         `json:"kind"`
	BranchInvoiceCode      string         `json:"branch_invoice_code"`
	BranchCashboxAccountID int64          `json:"branch_cashbox_account_id"`
	BranchShiftID          int64          `json:"branch_shift_id"`
	BranchInventoryID      int64          `json:"branch_inventory_id"`
	BranchClientID         sql.NullInt64  `json:"branch_client_id"`
	RelatedClientRef       sql.NullString `json:"related_client_ref"`
	Discount               int16          `json:"discount"`
	Subtotal               int64          `json:"subtotal"`
	DiscountedTotal        int64          `json:"discounted_total"`
	GrandTotal             int64          `json:"grand_total"`
	LoyaltyPointsDelta     int64          `json:"loyalty_points_delta"`
	OccurredAt             time.Time      `json:"occurred_at"`
	SalespersonName        string         `json:"salesperson_name"`
	Historical             bool           `json:"historical"`
	ClientUid              uuid.NullUUID  `json:"client_uid"`
	RegisterID             int64          `json:"register_id"`
	SalespersonID          sql.NullInt64  `json:"salesperson_id"`
	LbpTotal               sql.NullInt64  `json:"lbp_total"`
	LbpRate                sql.NullInt64  `json:"lbp_rate"`
}

type CreateBranchInvoicePaymentParams

type CreateBranchInvoicePaymentParams struct {
	BranchInvoiceID int64  `json:"branch_invoice_id"`
	AccountName     string `json:"account_name"`
	Amount          int64  `json:"amount"`
}

type CreateBranchInvoiceSettlementParams

type CreateBranchInvoiceSettlementParams struct {
	BranchID      int64     `json:"branch_id"`
	ClientRef     string    `json:"client_ref"`
	SaleClientRef string    `json:"sale_client_ref"`
	GrandTotal    int64     `json:"grand_total"`
	OccurredAt    time.Time `json:"occurred_at"`
	Status        string    `json:"status"`
}

type CreateBranchInvoiceSettlementPaymentParams

type CreateBranchInvoiceSettlementPaymentParams struct {
	BranchInvoiceSettlementID int64  `json:"branch_invoice_settlement_id"`
	AccountName               string `json:"account_name"`
	Amount                    int64  `json:"amount"`
}

type CreateBranchInvoiceTxParams

type CreateBranchInvoiceTxParams struct {
	CreateBranchInvoiceParams
	Items    []BranchInvoiceItemParams    `json:"items"`
	Payments []BranchInvoicePaymentParams `json:"payments"`
	// The sale's invoice discount (000212): what it took off, and the
	// rule's name. 0 / "" for none.
	InvoiceDiscount     int64  `json:"invoice_discount"`
	InvoiceDiscountName string `json:"invoice_discount_name"`
}

type CreateBranchInvoiceTxResult

type CreateBranchInvoiceTxResult struct {
	Invoice  BranchInvoice          `json:"invoice"`
	Items    []BranchInvoiceItem    `json:"items"`
	Payments []BranchInvoicePayment `json:"payments"`
	// StockSkippedItems counts line items whose barcode did not resolve to
	// a central variant (or whose branch has no linked inventory); those
	// lines are stored but did not move central stock.
	StockSkippedItems int `json:"stock_skipped_items"`
	// Oversold lists the "oversold" alerts this sale opened or refreshed:
	// lines that left central on-hand below zero.
	Oversold []BranchSyncConflict `json:"oversold"`
}

type CreateBranchLoanParams

type CreateBranchLoanParams struct {
	BranchID                 sql.NullInt64  `json:"branch_id"`
	ClientRef                sql.NullString `json:"client_ref"`
	Description              string         `json:"description"`
	CategoryID               int64          `json:"category_id"`
	Amount                   int64          `json:"amount"`
	CurrencyCode             string         `json:"currency_code"`
	BranchCashboxAccountID   sql.NullInt64  `json:"branch_cashbox_account_id"`
	BranchCashboxAccountName sql.NullString `json:"branch_cashbox_account_name"`
	BranchShiftID            sql.NullInt64  `json:"branch_shift_id"`
	OccurredAt               time.Time      `json:"occurred_at"`
}

type CreateBranchParams

type CreateBranchParams struct {
	Name string `json:"name"`
	Code string `json:"code"`
}

type CreateBranchRegisterParams

type CreateBranchRegisterParams struct {
	BranchID   int64  `json:"branch_id"`
	Code       string `json:"code"`
	Name       string `json:"name"`
	ApiKeyHash string `json:"api_key_hash"`
}

type CreateBranchSalespersonParams

type CreateBranchSalespersonParams struct {
	Name          string        `json:"name"`
	BranchID      sql.NullInt64 `json:"branch_id"`
	IsSalesperson bool          `json:"is_salesperson"`
}

type CreateBranchShiftParams

type CreateBranchShiftParams struct {
	BranchID          int64        `json:"branch_id"`
	ClientRef         string       `json:"client_ref"`
	BranchShiftID     int64        `json:"branch_shift_id"`
	OpenedAt          sql.NullTime `json:"opened_at"`
	ClosedAt          sql.NullTime `json:"closed_at"`
	ClosingPersonName string       `json:"closing_person_name"`
	OpeningFloatUsd   int64        `json:"opening_float_usd"`
	OpeningFloatLbp   int64        `json:"opening_float_lbp"`
	ExpectedUsd       int64        `json:"expected_usd"`
	ExpectedLbp       int64        `json:"expected_lbp"`
	ExpectedVisa      int64        `json:"expected_visa"`
	ExpectedWhish     int64        `json:"expected_whish"`
	CountedUsd        int64        `json:"counted_usd"`
	CountedLbp        int64        `json:"counted_lbp"`
	CountedVisa       int64        `json:"counted_visa"`
	CountedWhish      int64        `json:"counted_whish"`
	VarianceUsd       int64        `json:"variance_usd"`
	VarianceLbp       int64        `json:"variance_lbp"`
	VarianceVisa      int64        `json:"variance_visa"`
	VarianceWhish     int64        `json:"variance_whish"`
	OccurredAt        time.Time    `json:"occurred_at"`
	RegisterID        int64        `json:"register_id"`
	LbpRate           int64        `json:"lbp_rate"`
}

type CreateBranchShiftReceiptImageParams

type CreateBranchShiftReceiptImageParams struct {
	BranchShiftID int64  `json:"branch_shift_id"`
	FilePath      string `json:"file_path"`
	ContentType   string `json:"content_type"`
	SizeBytes     int64  `json:"size_bytes"`
}

type CreateBranchShiftUploadTokenParams

type CreateBranchShiftUploadTokenParams struct {
	BranchShiftID int64     `json:"branch_shift_id"`
	Token         string    `json:"token"`
	ExpiresAt     time.Time `json:"expires_at"`
}

type CreateBranchTargetParams

type CreateBranchTargetParams struct {
	BranchID     int64     `json:"branch_id"`
	DateFrom     time.Time `json:"date_from"`
	DateTo       time.Time `json:"date_to"`
	TargetAmount int64     `json:"target_amount"`
	Color        string    `json:"color"`
}

type CreateBranchTargetSeriesParams

type CreateBranchTargetSeriesParams struct {
	BranchID      int64  `json:"branch_id"`
	TargetAmount  int64  `json:"target_amount"`
	Color         string `json:"color"`
	StartDay      int32  `json:"start_day"`
	IntervalCount int32  `json:"interval_count"`
}

type CreateBranchTransferRequestParams

type CreateBranchTransferRequestParams struct {
	FromInventoryID int64          `json:"from_inventory_id"`
	ToInventoryID   int64          `json:"to_inventory_id"`
	Type            TransferType   `json:"type"`
	Note            string         `json:"note"`
	BranchID        sql.NullInt64  `json:"branch_id"`
	ClientRef       sql.NullString `json:"client_ref"`
	RegisterID      sql.NullInt64  `json:"register_id"`
}

type CreateBranchTransferRequestTxParams

type CreateBranchTransferRequestTxParams struct {
	BranchID      int64                      `json:"branch_id"`
	RegisterID    int64                      `json:"register_id"`
	ClientRef     string                     `json:"client_ref"`
	ToInventoryID int64                      `json:"to_inventory_id"`
	Note          string                     `json:"note"`
	Items         []BranchTransferItemParams `json:"items"`
}

type CreateBranchTransferRequestTxResult

type CreateBranchTransferRequestTxResult struct {
	Transfer Transfer       `json:"transfer"`
	Items    []TransferItem `json:"items"`
}

type CreateBranchTransferUploadTokenParams

type CreateBranchTransferUploadTokenParams struct {
	TransferID int64     `json:"transfer_id"`
	Token      string    `json:"token"`
	ExpiresAt  time.Time `json:"expires_at"`
}

type CreateBranchTxParams

type CreateBranchTxParams struct {
	Name string `json:"name"`
	Code string `json:"code"`
	// The branch's first register takes the branch code, so a single-till
	// branch keeps logging in with the code it was created with.
	RegisterAPIKeyHash string `json:"register_api_key_hash"`
}

type CreateBranchTxResult

type CreateBranchTxResult struct {
	Branch    Branch         `json:"branch"`
	Register  BranchRegister `json:"register"`
	Inventory Inventory      `json:"inventory"`
}

type CreateBranchUserParams

type CreateBranchUserParams struct {
	BranchID     int64  `json:"branch_id"`
	Username     string `json:"username"`
	Role         string `json:"role"`
	AkuvoxUserID string `json:"akuvox_user_id"`
	IsActive     bool   `json:"is_active"`
}

type CreateBranchVisitorEventParams

type CreateBranchVisitorEventParams struct {
	BranchID   int64     `json:"branch_id"`
	ClientRef  string    `json:"client_ref"`
	Day        string    `json:"day"`
	Direction  string    `json:"direction"`
	OccurredAt time.Time `json:"occurred_at"`
}

type CreateCalendarEventParams

type CreateCalendarEventParams struct {
	Name      string    `json:"name"`
	Icon      string    `json:"icon"`
	Color     string    `json:"color"`
	StartDate time.Time `json:"start_date"`
	EndDate   time.Time `json:"end_date"`
}

type CreateCashboxAccountParams

type CreateCashboxAccountParams struct {
	Name         string `json:"name"`
	CurrencyCode string `json:"currency_code"`
	SortOrder    int32  `json:"sort_order"`
	Color        string `json:"color"`
}

type CreateCashboxParams

type CreateCashboxParams struct {
	Code     string `json:"code"`
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
}

type CreateCentralLoanParams

type CreateCentralLoanParams struct {
	Description  string `json:"description"`
	CategoryID   int64  `json:"category_id"`
	Amount       int64  `json:"amount"`
	CurrencyCode string `json:"currency_code"`
}

type CreateClientParams

type CreateClientParams struct {
	Name         string `json:"name"`
	Phone        string `json:"phone"`
	ClientType   string `json:"client_type"`
	PhoneValid   bool   `json:"phone_valid"`
	PhoneCountry string `json:"phone_country"`
}

type CreateClientWithUIDParams

type CreateClientWithUIDParams struct {
	Uid   uuid.UUID `json:"uid"`
	Name  string    `json:"name"`
	Phone string    `json:"phone"`
}

type CreateColorParams

type CreateColorParams struct {
	Name     string `json:"name"`
	HexValue string `json:"hex_value"`
}

type CreateCouponCategoryParams

type CreateCouponCategoryParams struct {
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
	Icon     string `json:"icon"`
	Color    string `json:"color"`
	Scope    string `json:"scope"`
}

type CreateCouponListParams

type CreateCouponListParams struct {
	Name         string `json:"name"`
	CouponTypeID int64  `json:"coupon_type_id"`
}

type CreateCouponParams

type CreateCouponParams struct {
	Code       string        `json:"code"`
	Status     CouponStatus  `json:"status"`
	TypeID     sql.NullInt64 `json:"type_id"`
	ValueCents int64         `json:"value_cents"`
	ClientID   sql.NullInt64 `json:"client_id"`
	ValidUntil sql.NullTime  `json:"valid_until"`
	CategoryID sql.NullInt64 `json:"category_id"`
}

type CreateCouponTypeParams

type CreateCouponTypeParams struct {
	Name                string        `json:"name"`
	ValueCents          int64         `json:"value_cents"`
	CurrencyCode        string        `json:"currency_code"`
	ReferenceOnly       bool          `json:"reference_only"`
	CalculateOnCheckout bool          `json:"calculate_on_checkout"`
	CodeOptional        bool          `json:"code_optional"`
	CategoryID          sql.NullInt64 `json:"category_id"`
}

type CreateCurrencyParams

type CreateCurrencyParams struct {
	Name                   string `json:"name"`
	Code                   string `json:"code"`
	Symbol                 string `json:"symbol"`
	ValueInDefaultCurrency int64  `json:"value_in_default_currency"`
	UnitsPerUsdMicros      int64  `json:"units_per_usd_micros"`
	CashRoundingUnit       int64  `json:"cash_rounding_unit"`
}

type CreateDealParams added in v1.1.6

type CreateDealParams struct {
	Name                   string `json:"name"`
	Kind                   string `json:"kind"`
	BuyQty                 int32  `json:"buy_qty"`
	GetQty                 int32  `json:"get_qty"`
	Percent                int16  `json:"percent"`
	BundlePrice            int64  `json:"bundle_price"`
	FallbackPercent        int16  `json:"fallback_percent"`
	FallbackOnlyWithoutSet bool   `json:"fallback_only_without_set"`
}

type CreateDiscountListItemParams

type CreateDiscountListItemParams struct {
	DiscountListID   int64         `json:"discount_list_id"`
	ProductVariantID int64         `json:"product_variant_id"`
	Discount         int16         `json:"discount"`
	DealID           sql.NullInt64 `json:"deal_id"`
}

type CreateDiscountListParams

type CreateDiscountListParams struct {
	Name      string    `json:"name"`
	IsActive  bool      `json:"is_active"`
	IsDefault bool      `json:"is_default"`
	ValidFrom time.Time `json:"valid_from"`
	ValidTo   time.Time `json:"valid_to"`
	IsSpecial bool      `json:"is_special"`
}

type CreateDiscountListRuleGroupParams added in v1.1.6

type CreateDiscountListRuleGroupParams struct {
	DiscountListID int64  `json:"discount_list_id"`
	Position       int32  `json:"position"`
	Name           string `json:"name"`
	IsEnabled      bool   `json:"is_enabled"`
}

type CreateDiscountListRuleOptionParams added in v1.1.6

type CreateDiscountListRuleOptionParams struct {
	RuleID       int64 `json:"rule_id"`
	SaleOptionID int64 `json:"sale_option_id"`
	Discount     int16 `json:"discount"`
}

type CreateDiscountListRuleParams added in v1.1.6

type CreateDiscountListRuleParams struct {
	DiscountListID     int64         `json:"discount_list_id"`
	Position           int32         `json:"position"`
	Name               string        `json:"name"`
	CodePrefixes       []string      `json:"code_prefixes"`
	ExceptCodePrefixes []string      `json:"except_code_prefixes"`
	Kinds              []string      `json:"kinds"`
	Categories         []string      `json:"categories"`
	SubCategories      []string      `json:"sub_categories"`
	Origins            []string      `json:"origins"`
	Brands             []string      `json:"brands"`
	Discount           int16         `json:"discount"`
	DealID             sql.NullInt64 `json:"deal_id"`
	GroupID            int64         `json:"group_id"`
	IsEnabled          bool          `json:"is_enabled"`
	MaxPrice           sql.NullInt64 `json:"max_price"`
}

type CreateEmailReportParams added in v1.1.0

type CreateEmailReportParams struct {
	SentBy        string        `json:"sent_by"`
	Scope         string        `json:"scope"`
	FromDay       sql.NullTime  `json:"from_day"`
	ToDay         sql.NullTime  `json:"to_day"`
	BranchID      sql.NullInt64 `json:"branch_id"`
	BranchShiftID sql.NullInt64 `json:"branch_shift_id"`
	Label         string        `json:"label"`
	Recipients    string        `json:"recipients"`
	Bcc           string        `json:"bcc"`
	Subject       string        `json:"subject"`
	Filename      string        `json:"filename"`
	InvoiceCount  int32         `json:"invoice_count"`
	TotalCents    int64         `json:"total_cents"`
	Status        string        `json:"status"`
	Error         string        `json:"error"`
	ProviderID    string        `json:"provider_id"`
	Note          string        `json:"note"`
	ScheduleID    sql.NullInt64 `json:"schedule_id"`
}

type CreateEmailScheduleParams added in v1.1.0

type CreateEmailScheduleParams struct {
	Name        string       `json:"name"`
	Enabled     bool         `json:"enabled"`
	Period      string       `json:"period"`
	RegisterIds []int64      `json:"register_ids"`
	Recipients  string       `json:"recipients"`
	Bcc         string       `json:"bcc"`
	Format      string       `json:"format"`
	Note        string       `json:"note"`
	SkipEmpty   bool         `json:"skip_empty"`
	Frequency   string       `json:"frequency"`
	AtMinute    int32        `json:"at_minute"`
	Weekdays    []int32      `json:"weekdays"`
	MonthDay    int32        `json:"month_day"`
	NextRunAt   sql.NullTime `json:"next_run_at"`
	CreatedBy   string       `json:"created_by"`
}

type CreateEmployeeParams

type CreateEmployeeParams struct {
	BranchID               sql.NullInt64 `json:"branch_id"`
	Name                   string        `json:"name"`
	Role                   string        `json:"role"`
	Status                 string        `json:"status"`
	HiredOn                sql.NullTime  `json:"hired_on"`
	BaseSalaryCents        int64         `json:"base_salary_cents"`
	CommissionCents        int64         `json:"commission_cents"`
	LateDeductionRateCents int64         `json:"late_deduction_rate_cents"`
	LateDeductionUnit      string        `json:"late_deduction_unit"`
	LateUnitsCenti         int64         `json:"late_units_centi"`
}

type CreateEntryItemParams

type CreateEntryItemParams struct {
	CashboxID     int64              `json:"cashbox_id"`
	InventoryID   int64              `json:"inventory_id"`
	ReferenceType EntryReferenceType `json:"reference_type"`
	ReferenceID   int64              `json:"reference_id"`
	Amount        int64              `json:"amount"`
}

type CreateExpenseCategoryParams

type CreateExpenseCategoryParams struct {
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
	Icon     string `json:"icon"`
	Color    string `json:"color"`
	Scope    string `json:"scope"`
}

type CreateExpenseParams

type CreateExpenseParams struct {
	Description        string        `json:"description"`
	CategoryID         sql.NullInt64 `json:"category_id"`
	Amount             int64         `json:"amount"`
	CurrencyCode       string        `json:"currency_code"`
	RecurringExpenseID sql.NullInt64 `json:"recurring_expense_id"`
}

type CreateGeneratedBranchTargetParams

type CreateGeneratedBranchTargetParams struct {
	BranchID     int64         `json:"branch_id"`
	DateFrom     time.Time     `json:"date_from"`
	DateTo       time.Time     `json:"date_to"`
	TargetAmount int64         `json:"target_amount"`
	Color        string        `json:"color"`
	SeriesID     sql.NullInt64 `json:"series_id"`
}

type CreateGooglePlaceSnapshotParams added in v1.1.0

type CreateGooglePlaceSnapshotParams struct {
	PlaceID     string  `json:"place_id"`
	Name        string  `json:"name"`
	Rating      float64 `json:"rating"`
	ReviewCount int32   `json:"review_count"`
}

type CreateInventoryParams

type CreateInventoryParams struct {
	Name      string          `json:"name"`
	Type      InventoryType   `json:"type"`
	Code      string          `json:"code"`
	Longitude sql.NullFloat64 `json:"longitude"`
	Latitude  sql.NullFloat64 `json:"latitude"`
}

type CreateInvoiceDiscountParams added in v1.1.8

type CreateInvoiceDiscountParams struct {
	Name        string       `json:"name"`
	MinTotal    int64        `json:"min_total"`
	Kind        string       `json:"kind"`
	Percent     int16        `json:"percent"`
	Amount      int64        `json:"amount"`
	AllBranches bool         `json:"all_branches"`
	ValidFrom   sql.NullTime `json:"valid_from"`
	ValidTo     sql.NullTime `json:"valid_to"`
	IsActive    bool         `json:"is_active"`
}

type CreateInvoiceParams

type CreateInvoiceParams struct {
	CashboxID          int64         `json:"cashbox_id"`
	ShiftID            int64         `json:"shift_id"`
	InvoiceCode        string        `json:"invoice_code"`
	InvoiceIndex       int64         `json:"invoice_index"`
	Year               int32         `json:"year"`
	ClientID           int64         `json:"client_id"`
	InventoryID        int64         `json:"inventory_id"`
	Discount           int16         `json:"discount"`
	Subtotal           int64         `json:"subtotal"`
	DiscountedTotal    int64         `json:"discounted_total"`
	GrandTotal         int64         `json:"grand_total"`
	InvoiceTypeID      int64         `json:"invoice_type_id"`
	SalespersonID      sql.NullInt64 `json:"salesperson_id"`
	LoyaltyPointsDelta int64         `json:"loyalty_points_delta"`
}

type CreateInvoicePaymentParams

type CreateInvoicePaymentParams struct {
	InvoiceID        int64 `json:"invoice_id"`
	CashboxAccountID int64 `json:"cashbox_account_id"`
	Amount           int64 `json:"amount"`
}

type CreateInvoiceTypeParams

type CreateInvoiceTypeParams struct {
	Name      string `json:"name"`
	Code      string `json:"code"`
	IsDefault bool   `json:"is_default"`
	IsActive  bool   `json:"is_active"`
}

type CreateListCouponParams

type CreateListCouponParams struct {
	Code       string        `json:"code"`
	TypeID     sql.NullInt64 `json:"type_id"`
	ListID     sql.NullInt64 `json:"list_id"`
	ValueCents int64         `json:"value_cents"`
	ValidUntil sql.NullTime  `json:"valid_until"`
}

type CreateLoanCategoryParams

type CreateLoanCategoryParams struct {
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
	Icon     string `json:"icon"`
	Color    string `json:"color"`
	Scope    string `json:"scope"`
}

type CreateLoanImageParams added in v1.1.0

type CreateLoanImageParams struct {
	LoanID      int64  `json:"loan_id"`
	FilePath    string `json:"file_path"`
	ContentType string `json:"content_type"`
	SizeBytes   int64  `json:"size_bytes"`
}

type CreateLoanPaymentParams

type CreateLoanPaymentParams struct {
	LoanID       int64  `json:"loan_id"`
	Amount       int64  `json:"amount"`
	CurrencyCode string `json:"currency_code"`
	Note         string `json:"note"`
}

type CreateLoanUploadTokenParams added in v1.1.0

type CreateLoanUploadTokenParams struct {
	LoanID    int64     `json:"loan_id"`
	Token     string    `json:"token"`
	ExpiresAt time.Time `json:"expires_at"`
}

type CreatePriceListItemParams

type CreatePriceListItemParams struct {
	PriceListID      int64 `json:"price_list_id"`
	ProductVariantID int64 `json:"product_variant_id"`
	Price            int64 `json:"price"`
}

type CreatePriceListParams

type CreatePriceListParams struct {
	Name      string    `json:"name"`
	IsActive  bool      `json:"is_active"`
	IsDefault bool      `json:"is_default"`
	ValidFrom time.Time `json:"valid_from"`
	ValidTo   time.Time `json:"valid_to"`
	IsSpecial bool      `json:"is_special"`
}

type CreateProductAttributeParams

type CreateProductAttributeParams struct {
	ProductID        int64 `json:"product_id"`
	AttributeID      int64 `json:"attribute_id"`
	AttributeValueID int64 `json:"attribute_value_id"`
}

type CreateProductCategoryParams

type CreateProductCategoryParams struct {
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
	Icon     string `json:"icon"`
	Color    string `json:"color"`
}

type CreateProductParams

type CreateProductParams struct {
	Code        string `json:"code"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type CreateProductTxParams

type CreateProductTxParams struct {
	Code            string            `json:"code"`
	Name            string            `json:"name"`
	Description     string            `json:"description"`
	Discount        int16             `json:"discount"`
	AttributeValues []AttributesValue `json:"attribute_values"`
	ColorID         *int64            `json:"color_id"`
	SizeID          *int64            `json:"size_id"`
	// ColorIDs/SizeIDs let one product be created with several variants at
	// once -- one per colour x size combination. When both are empty the
	// single ColorID/SizeID (or neither) is used, keeping the old
	// one-variant behaviour.
	ColorIDs []int64 `json:"color_ids"`
	SizeIDs  []int64 `json:"size_ids"`
	Barcode  *int64  `json:"barcode"`
	// Price, when set, is written (in cents) to PriceListID for every
	// variant created, so a new product can be sellable straight away.
	// PriceListID nil means the default list.
	Price       *int64 `json:"price"`
	PriceListID *int64 `json:"price_list_id"`
}

type CreateProductTxResult

type CreateProductTxResult struct {
	Product           Product             `json:"product"`
	ProductAttributes []ProductsAttribute `json:"product_attributes"`
	// Variant is the first created variant, kept for existing callers.
	Variant  ProductVariant   `json:"variant"`
	Variants []ProductVariant `json:"variants"`
}

type CreateProductVariantParams

type CreateProductVariantParams struct {
	ProductID int64         `json:"product_id"`
	ColorID   sql.NullInt64 `json:"color_id"`
	SizeID    sql.NullInt64 `json:"size_id"`
	Barcode   string        `json:"barcode"`
}

type CreatePurchaseParams

type CreatePurchaseParams struct {
	SupplierID   int64         `json:"supplier_id"`
	InventoryID  sql.NullInt64 `json:"inventory_id"`
	Code         string        `json:"code"`
	CurrencyCode string        `json:"currency_code"`
	PurchasedAt  time.Time     `json:"purchased_at"`
	Note         string        `json:"note"`
}

type CreatePurchaseTxParams

type CreatePurchaseTxParams struct {
	SupplierID   int64                `json:"supplier_id"`
	InventoryID  int64                `json:"inventory_id"`
	Code         string               `json:"code"`
	CurrencyCode string               `json:"currency_code"`
	PurchasedAt  sql.NullTime         `json:"purchased_at"`
	Note         string               `json:"note"`
	Items        []PurchaseItemParams `json:"items"`
}

type CreatePurchaseTxResult

type CreatePurchaseTxResult struct {
	Purchase Purchase       `json:"purchase"`
	Items    []PurchaseItem `json:"items"`
}

type CreateRecurringExpenseParams

type CreateRecurringExpenseParams struct {
	Description   string        `json:"description"`
	CategoryID    sql.NullInt64 `json:"category_id"`
	Amount        int64         `json:"amount"`
	CurrencyCode  string        `json:"currency_code"`
	IntervalUnit  string        `json:"interval_unit"`
	IntervalCount int32         `json:"interval_count"`
	NextDueAt     time.Time     `json:"next_due_at"`
}

type CreateResolvedBranchInvoiceItemParams added in v1.1.1

type CreateResolvedBranchInvoiceItemParams struct {
	BranchInvoiceID int64         `json:"branch_invoice_id"`
	BranchProductID int64         `json:"branch_product_id"`
	UnitPrice       int64         `json:"unit_price"`
	LineTotal       int64         `json:"line_total"`
	Discount        int16         `json:"discount"`
	ProductUid      uuid.NullUUID `json:"product_uid"`
}

type CreateReturnInvoiceParams

type CreateReturnInvoiceParams struct {
	InvoiceID      int64 `json:"invoice_id"`
	SalesInvoiceID int64 `json:"sales_invoice_id"`
}

type CreateReviewLinkClickParams added in v1.1.0

type CreateReviewLinkClickParams struct {
	MessageID sql.NullInt64 `json:"message_id"`
	BranchID  sql.NullInt64 `json:"branch_id"`
	PlaceID   string        `json:"place_id"`
	UserAgent string        `json:"user_agent"`
}

type CreateSaleOptionParams added in v1.1.6

type CreateSaleOptionParams struct {
	Name      string `json:"name"`
	SortOrder int32  `json:"sort_order"`
}

type CreateSalespersonParams

type CreateSalespersonParams struct {
	Name      string        `json:"name"`
	CashboxID sql.NullInt64 `json:"cashbox_id"`
}

type CreateSessionParams

type CreateSessionParams struct {
	ID           uuid.UUID `json:"id"`
	Username     string    `json:"username"`
	RefreshToken string    `json:"refresh_token"`
	UserAgent    string    `json:"user_agent"`
	ClientIp     string    `json:"client_ip"`
	IsBlocked    bool      `json:"is_blocked"`
	ExpiresAt    time.Time `json:"expires_at"`
}

type CreateSizeParams

type CreateSizeParams struct {
	Name  string `json:"name"`
	Type  string `json:"type"`
	Order string `json:"order"`
}

type CreateStockCountParams

type CreateStockCountParams struct {
	InventoryID int64         `json:"inventory_id"`
	Code        string        `json:"code"`
	Note        string        `json:"note"`
	CreatedBy   sql.NullInt64 `json:"created_by"`
}

type CreateStockMovementParams

type CreateStockMovementParams struct {
	InventoryID    int64               `json:"inventory_id"`
	VariantID      int64               `json:"variant_id"`
	Quantity       int64               `json:"quantity"`
	Reason         StockMovementReason `json:"reason"`
	ReferenceType  sql.NullString      `json:"reference_type"`
	ReferenceID    sql.NullInt64       `json:"reference_id"`
	UnitCost       sql.NullInt64       `json:"unit_cost"`
	Note           string              `json:"note"`
	CreatedBy      sql.NullInt64       `json:"created_by"`
	QuantityBefore int64               `json:"quantity_before"`
	QuantityAfter  int64               `json:"quantity_after"`
	Metadata       json.RawMessage     `json:"metadata"`
	BatchID        sql.NullInt64       `json:"batch_id"`
}

type CreateSupplierParams

type CreateSupplierParams struct {
	Name             string          `json:"name"`
	Phone            string          `json:"phone"`
	Country          string          `json:"country"`
	Address          string          `json:"address"`
	AddressLatitude  sql.NullFloat64 `json:"address_latitude"`
	AddressLongitude sql.NullFloat64 `json:"address_longitude"`
}

type CreateTransferItemParams

type CreateTransferItemParams struct {
	TransferID int64         `json:"transfer_id"`
	VariantID  sql.NullInt64 `json:"variant_id"`
	AssetID    sql.NullInt64 `json:"asset_id"`
	Quantity   int64         `json:"quantity"`
}

type CreateTransferParams

type CreateTransferParams struct {
	FromInventoryID int64        `json:"from_inventory_id"`
	ToInventoryID   int64        `json:"to_inventory_id"`
	Type            TransferType `json:"type"`
	Code            string       `json:"code"`
	Note            string       `json:"note"`
}

type CreateTransferTxParams

type CreateTransferTxParams struct {
	FromInventoryID int64                `json:"from_inventory_id"`
	ToInventoryID   int64                `json:"to_inventory_id"`
	Type            TransferType         `json:"type"`
	Code            string               `json:"code"`
	Note            string               `json:"note"`
	Items           []TransferItemParams `json:"items"`
}

type CreateTransferTxResult

type CreateTransferTxResult struct {
	Transfer Transfer       `json:"transfer"`
	Items    []TransferItem `json:"items"`
}

type CreateUnknownItemImageParams added in v1.1.1

type CreateUnknownItemImageParams struct {
	SessionID   int64  `json:"session_id"`
	FilePath    string `json:"file_path"`
	ContentType string `json:"content_type"`
	SizeBytes   int64  `json:"size_bytes"`
}

type CreateUnknownItemSessionParams added in v1.1.1

type CreateUnknownItemSessionParams struct {
	BranchID   int64     `json:"branch_id"`
	RegisterID int64     `json:"register_id"`
	ClientRef  string    `json:"client_ref"`
	Token      string    `json:"token"`
	ExpiresAt  time.Time `json:"expires_at"`
}

type CreateUnknownItemSlotParams added in v1.1.1

type CreateUnknownItemSlotParams struct {
	SessionID int64  `json:"session_id"`
	SlotRef   string `json:"slot_ref"`
	Position  int32  `json:"position"`
	Label     string `json:"label"`
	UnitPrice int64  `json:"unit_price"`
	Discount  int16  `json:"discount"`
	LineRef   string `json:"line_ref"`
}

type CreateUserParams

type CreateUserParams struct {
	Username     string `json:"username"`
	Name         string `json:"name"`
	Email        string `json:"email"`
	PasswordHash string `json:"password_hash"`
	Activated    bool   `json:"activated"`
	RoleID       int64  `json:"role_id"`
}

type CreateWhatsAppMessageParams added in v1.1.0

type CreateWhatsAppMessageParams struct {
	BranchID         sql.NullInt64 `json:"branch_id"`
	InvoiceCode      string        `json:"invoice_code"`
	ClientName       string        `json:"client_name"`
	ClientPhone      string        `json:"client_phone"`
	GrandTotalCents  int64         `json:"grand_total_cents"`
	ItemCount        int32         `json:"item_count"`
	RuleID           sql.NullInt64 `json:"rule_id"`
	RuleName         string        `json:"rule_name"`
	TemplateName     string        `json:"template_name"`
	Status           string        `json:"status"`
	Reason           string        `json:"reason"`
	Wamid            string        `json:"wamid"`
	CostMicros       int64         `json:"cost_micros"`
	ReviewCode       string        `json:"review_code"`
	Sender           string        `json:"sender"`
	WhatsappNumberID sql.NullInt64 `json:"whatsapp_number_id"`
	PollRef          string        `json:"poll_ref"`
	BridgeRef        string        `json:"bridge_ref"`
	IsTest           bool          `json:"is_test"`
	Body             string        `json:"body"`
	PollQuestion     string        `json:"poll_question"`
	PollOptions      string        `json:"poll_options"`
}

type CreateWhatsAppNumberParams added in v1.1.0

type CreateWhatsAppNumberParams struct {
	Instance string `json:"instance"`
	Label    string `json:"label"`
}

type CreateWhatsAppReplyParams added in v1.1.0

type CreateWhatsAppReplyParams struct {
	Wamid        string    `json:"wamid"`
	ReceivedAt   time.Time `json:"received_at"`
	ClientPhone  string    `json:"client_phone"`
	ClientName   string    `json:"client_name"`
	Kind         string    `json:"kind"`
	Body         string    `json:"body"`
	ContextWamid string    `json:"context_wamid"`
}

type CreateWhatsAppRuleParams added in v1.1.0

type CreateWhatsAppRuleParams struct {
	Position       int32           `json:"position"`
	Name           string          `json:"name"`
	Enabled        bool            `json:"enabled"`
	Action         string          `json:"action"`
	Conditions     json.RawMessage `json:"conditions"`
	TemplateName   string          `json:"template_name"`
	TemplateLang   string          `json:"template_lang"`
	TemplateParams string          `json:"template_params"`
}

type Currency

type Currency struct {
	Code                   string    `json:"code"`
	Name                   string    `json:"name"`
	Symbol                 string    `json:"symbol"`
	IsDefault              bool      `json:"is_default"`
	ValueInDefaultCurrency int64     `json:"value_in_default_currency"`
	IsActive               bool      `json:"is_active"`
	UnitsPerUsdMicros      int64     `json:"units_per_usd_micros"`
	CashRoundingUnit       int64     `json:"cash_rounding_unit"`
	UpdatedAt              time.Time `json:"updated_at"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DashboardActivitiesListParams

type DashboardActivitiesListParams struct {
	PageID   int32         `json:"page_id"`
	PageSize int32         `json:"page_size"`
	Scope    string        `json:"scope"`
	DateFrom time.Time     `json:"date_from"`
	DateTo   time.Time     `json:"date_to"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type DashboardActivitiesListRow

type DashboardActivitiesListRow struct {
	Activity     string    `json:"activity"`
	BranchID     int64     `json:"branch_id"`
	BranchName   string    `json:"branch_name"`
	Details      string    `json:"details"`
	Amount       int64     `json:"amount"`
	CurrencyCode string    `json:"currency_code"`
	SyncedAt     time.Time `json:"synced_at"`
	Person       string    `json:"person"`
	PersonColor  string    `json:"person_color"`
	TotalCount   int64     `json:"total_count"`
}

type DashboardAdminExpenseSeriesParams

type DashboardAdminExpenseSeriesParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type DashboardAdminExpenseSeriesRow

type DashboardAdminExpenseSeriesRow struct {
	Day   time.Time `json:"day"`
	Total int64     `json:"total"`
}

type DashboardAdminExpensesTotalParams

type DashboardAdminExpensesTotalParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type DashboardAdminNewClientsParams

type DashboardAdminNewClientsParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type DashboardAdminRevenueSeriesParams

type DashboardAdminRevenueSeriesParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type DashboardAdminRevenueSeriesRow

type DashboardAdminRevenueSeriesRow struct {
	Day   time.Time `json:"day"`
	Total int64     `json:"total"`
}

type DashboardAdminSummaryParams

type DashboardAdminSummaryParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type DashboardAdminSummaryRow

type DashboardAdminSummaryRow struct {
	ItemsSold int64 `json:"items_sold"`
	Revenue   int64 `json:"revenue"`
	Invoices  int64 `json:"invoices"`
}

type DashboardBranchExpenseSeriesParams

type DashboardBranchExpenseSeriesParams struct {
	DateFrom time.Time     `json:"date_from"`
	DateTo   time.Time     `json:"date_to"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type DashboardBranchExpenseSeriesRow

type DashboardBranchExpenseSeriesRow struct {
	Day   time.Time `json:"day"`
	Total int64     `json:"total"`
}

type DashboardBranchExpensesTotalParams

type DashboardBranchExpensesTotalParams struct {
	DateFrom time.Time     `json:"date_from"`
	DateTo   time.Time     `json:"date_to"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type DashboardBranchNewClientsParams

type DashboardBranchNewClientsParams struct {
	DateFrom time.Time     `json:"date_from"`
	DateTo   time.Time     `json:"date_to"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type DashboardBranchRevenueSeriesParams

type DashboardBranchRevenueSeriesParams struct {
	DateFrom time.Time     `json:"date_from"`
	DateTo   time.Time     `json:"date_to"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type DashboardBranchRevenueSeriesRow

type DashboardBranchRevenueSeriesRow struct {
	Day   time.Time `json:"day"`
	Total int64     `json:"total"`
}

type DashboardBranchSummaryParams

type DashboardBranchSummaryParams struct {
	DateFrom time.Time     `json:"date_from"`
	DateTo   time.Time     `json:"date_to"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type DashboardBranchSummaryRow

type DashboardBranchSummaryRow struct {
	ItemsSold int64 `json:"items_sold"`
	Revenue   int64 `json:"revenue"`
	Invoices  int64 `json:"invoices"`
}

type DashboardDueLoansParams

type DashboardDueLoansParams struct {
	Scope    string        `json:"scope"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type DashboardExpensesListParams

type DashboardExpensesListParams struct {
	Limit    int32         `json:"limit"`
	Offset   int32         `json:"offset"`
	Scope    string        `json:"scope"`
	DateFrom time.Time     `json:"date_from"`
	DateTo   time.Time     `json:"date_to"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type DashboardExpensesListRow

type DashboardExpensesListRow struct {
	Source      string    `json:"source"`
	Description string    `json:"description"`
	Category    string    `json:"category"`
	Amount      int64     `json:"amount"`
	Currency    string    `json:"currency"`
	OccurredAt  time.Time `json:"occurred_at"`
	ImageID     int64     `json:"image_id"`
}

type DashboardPurchaseSeriesParams

type DashboardPurchaseSeriesParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type DashboardPurchaseSeriesRow

type DashboardPurchaseSeriesRow struct {
	Day   time.Time `json:"day"`
	Total int64     `json:"total"`
}

type DashboardPurchasesListParams

type DashboardPurchasesListParams struct {
	Limit    int32     `json:"limit"`
	Offset   int32     `json:"offset"`
	Scope    string    `json:"scope"`
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type DashboardPurchasesListRow

type DashboardPurchasesListRow struct {
	ID          int64     `json:"id"`
	Supplier    string    `json:"supplier"`
	Total       int64     `json:"total"`
	Items       int64     `json:"items"`
	Currency    string    `json:"currency"`
	PurchasedAt time.Time `json:"purchased_at"`
}

type DashboardPurchasesTotalParams

type DashboardPurchasesTotalParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type DashboardSalesListParams

type DashboardSalesListParams struct {
	Limit    int32         `json:"limit"`
	Offset   int32         `json:"offset"`
	Scope    string        `json:"scope"`
	DateFrom time.Time     `json:"date_from"`
	DateTo   time.Time     `json:"date_to"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type DashboardSalesListRow

type DashboardSalesListRow struct {
	Source     string    `json:"source"`
	Client     string    `json:"client"`
	Total      int64     `json:"total"`
	Currency   string    `json:"currency"`
	OccurredAt time.Time `json:"occurred_at"`
}

type DashboardTargetListParams

type DashboardTargetListParams struct {
	AsOf     time.Time     `json:"as_of"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type DashboardTargetListRow

type DashboardTargetListRow struct {
	ID           int64     `json:"id"`
	BranchID     int64     `json:"branch_id"`
	BranchName   string    `json:"branch_name"`
	DateFrom     time.Time `json:"date_from"`
	DateTo       time.Time `json:"date_to"`
	TargetAmount int64     `json:"target_amount"`
	Color        string    `json:"color"`
	Revenue      int64     `json:"revenue"`
}

type DashboardTopDueLoansParams

type DashboardTopDueLoansParams struct {
	Scope    string        `json:"scope"`
	BranchID sql.NullInt64 `json:"branch_id"`
	TopN     int32         `json:"top_n"`
}

type DashboardTopDueLoansRow

type DashboardTopDueLoansRow struct {
	ID          int64  `json:"id"`
	Description string `json:"description"`
	Origin      string `json:"origin"`
	BranchName  string `json:"branch_name"`
	Amount      int64  `json:"amount"`
	Outstanding int64  `json:"outstanding"`
}

type Deal added in v1.1.6

type Deal struct {
	ID                     int64     `json:"id"`
	Uid                    uuid.UUID `json:"uid"`
	Name                   string    `json:"name"`
	Kind                   string    `json:"kind"`
	BuyQty                 int32     `json:"buy_qty"`
	GetQty                 int32     `json:"get_qty"`
	Percent                int16     `json:"percent"`
	BundlePrice            int64     `json:"bundle_price"`
	CreatedAt              time.Time `json:"created_at"`
	UpdatedAt              time.Time `json:"updated_at"`
	FallbackPercent        int16     `json:"fallback_percent"`
	FallbackOnlyWithoutSet bool      `json:"fallback_only_without_set"`
}

type DecrementInvoicesIndexParams

type DecrementInvoicesIndexParams struct {
	Year          int32     `json:"year"`
	CashboxID     int64     `json:"cashbox_id"`
	Type          IndexType `json:"type"`
	InvoiceTypeID int64     `json:"invoice_type_id"`
}

type DefaultBranchSetting

type DefaultBranchSetting struct {
	ID        int16           `json:"id"`
	Settings  json.RawMessage `json:"settings"`
	UpdatedAt time.Time       `json:"updated_at"`
}

type DeleteCashboxAccountOverrideParams

type DeleteCashboxAccountOverrideParams struct {
	BranchID         int64 `json:"branch_id"`
	CashboxAccountID int64 `json:"cashbox_account_id"`
}

type DeleteDiscountListItemParams

type DeleteDiscountListItemParams struct {
	DiscountListID   int64 `json:"discount_list_id"`
	ProductVariantID int64 `json:"product_variant_id"`
}

type DeleteDiscountListItemsParams

type DeleteDiscountListItemsParams struct {
	DiscountListID    int64   `json:"discount_list_id"`
	ProductVariantIds []int64 `json:"product_variant_ids"`
}

type DeleteDiscountListOptionItemParams added in v1.1.6

type DeleteDiscountListOptionItemParams struct {
	DiscountListID   int64 `json:"discount_list_id"`
	ProductVariantID int64 `json:"product_variant_id"`
	SaleOptionID     int64 `json:"sale_option_id"`
}

type DeleteDiscountListOptionItemsParams added in v1.1.6

type DeleteDiscountListOptionItemsParams struct {
	DiscountListID    int64   `json:"discount_list_id"`
	ProductVariantIds []int64 `json:"product_variant_ids"`
	SaleOptionIds     []int64 `json:"sale_option_ids"`
}

type DeleteDiscountListRuleGroupsExceptParams added in v1.1.7

type DeleteDiscountListRuleGroupsExceptParams struct {
	DiscountListID int64   `json:"discount_list_id"`
	Keep           []int64 `json:"keep"`
}

type DeleteDiscountListRulesExceptParams added in v1.1.7

type DeleteDiscountListRulesExceptParams struct {
	DiscountListID int64   `json:"discount_list_id"`
	Keep           []int64 `json:"keep"`
}

type DeleteFailedWhatsAppMessagesForInvoiceParams added in v1.1.1

type DeleteFailedWhatsAppMessagesForInvoiceParams struct {
	BranchID    sql.NullInt64 `json:"branch_id"`
	InvoiceCode string        `json:"invoice_code"`
}

type DeletePriceListItemParams

type DeletePriceListItemParams struct {
	PriceListID      int64 `json:"price_list_id"`
	ProductVariantID int64 `json:"product_variant_id"`
}

type DeletePriceListItemsParams

type DeletePriceListItemsParams struct {
	PriceListID       int64   `json:"price_list_id"`
	ProductVariantIds []int64 `json:"product_variant_ids"`
}

type DeletePurchaseItemParams

type DeletePurchaseItemParams struct {
	ID   int64 `json:"id"`
	ID_2 int64 `json:"id_2"`
}

type DeleteTransferItemParams

type DeleteTransferItemParams struct {
	ID   int64 `json:"id"`
	ID_2 int64 `json:"id_2"`
}

type DeleteUnknownItemSlotsNotInParams added in v1.1.8

type DeleteUnknownItemSlotsNotInParams struct {
	SessionID int64    `json:"session_id"`
	SlotRefs  []string `json:"slot_refs"`
}

type DiscountList

type DiscountList struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	IsActive  bool      `json:"is_active"`
	IsDefault bool      `json:"is_default"`
	ValidFrom time.Time `json:"valid_from"`
	ValidTo   time.Time `json:"valid_to"`
	CreatedAt time.Time `json:"created_at"`
	Uid       uuid.UUID `json:"uid"`
	UpdatedAt time.Time `json:"updated_at"`
	IsSpecial bool      `json:"is_special"`
}

type DiscountListBranch

type DiscountListBranch struct {
	BranchID       int64     `json:"branch_id"`
	DiscountListID int64     `json:"discount_list_id"`
	CreatedAt      time.Time `json:"created_at"`
}

type DiscountListBranchRemoval added in v1.1.7

type DiscountListBranchRemoval struct {
	BranchID       int64     `json:"branch_id"`
	DiscountListID int64     `json:"discount_list_id"`
	RemovedAt      time.Time `json:"removed_at"`
}

type DiscountListItem

type DiscountListItem struct {
	DiscountListID   int64         `json:"discount_list_id"`
	Discount         int16         `json:"discount"`
	ProductVariantID int64         `json:"product_variant_id"`
	RuleID           sql.NullInt64 `json:"rule_id"`
	DealID           sql.NullInt64 `json:"deal_id"`
}

type DiscountListOptionItem added in v1.1.6

type DiscountListOptionItem struct {
	DiscountListID   int64         `json:"discount_list_id"`
	ProductVariantID int64         `json:"product_variant_id"`
	SaleOptionID     int64         `json:"sale_option_id"`
	Discount         int16         `json:"discount"`
	RuleID           sql.NullInt64 `json:"rule_id"`
}

type DiscountListRule added in v1.1.6

type DiscountListRule struct {
	ID                 int64         `json:"id"`
	DiscountListID     int64         `json:"discount_list_id"`
	Position           int32         `json:"position"`
	Name               string        `json:"name"`
	CodePrefixes       []string      `json:"code_prefixes"`
	ExceptCodePrefixes []string      `json:"except_code_prefixes"`
	Kinds              []string      `json:"kinds"`
	Categories         []string      `json:"categories"`
	SubCategories      []string      `json:"sub_categories"`
	Origins            []string      `json:"origins"`
	Brands             []string      `json:"brands"`
	Discount           int16         `json:"discount"`
	CreatedAt          time.Time     `json:"created_at"`
	DealID             sql.NullInt64 `json:"deal_id"`
	IsEnabled          bool          `json:"is_enabled"`
	GroupID            int64         `json:"group_id"`
	MaxPrice           sql.NullInt64 `json:"max_price"`
}

type DiscountListRuleGroup added in v1.1.6

type DiscountListRuleGroup struct {
	ID             int64     `json:"id"`
	DiscountListID int64     `json:"discount_list_id"`
	Position       int32     `json:"position"`
	Name           string    `json:"name"`
	IsEnabled      bool      `json:"is_enabled"`
	CreatedAt      time.Time `json:"created_at"`
}

type DiscountListRuleGroupInput added in v1.1.6

type DiscountListRuleGroupInput struct {
	// ID is the saved group this is, 0 for a new one.
	ID      int64
	Name    string
	Enabled bool
	Rules   []DiscountListRuleInput
}

DiscountListRuleGroupInput is one named set of rules (000203), switched on and off as one.

type DiscountListRuleInput added in v1.1.6

type DiscountListRuleInput struct {
	// ID is the saved rule this is, 0 for a new one.
	ID      int64
	Rule    CreateDiscountListRuleParams
	Options map[int64]int16
}

DiscountListRuleInput is one rule as the list page sends it: the rule and its option discounts (sale option id -> discount).

type DiscountListRuleOption added in v1.1.6

type DiscountListRuleOption struct {
	RuleID       int64 `json:"rule_id"`
	SaleOptionID int64 `json:"sale_option_id"`
	Discount     int16 `json:"discount"`
}

type DiscountRuleFact added in v1.1.6

type DiscountRuleFact struct {
	ProductVariantID int64       `json:"product_variant_id"`
	ProductID        int64       `json:"product_id"`
	Code             interface{} `json:"code"`
	Kind             string      `json:"kind"`
	Category         string      `json:"category"`
	SubCategory      string      `json:"sub_category"`
	Origin           string      `json:"origin"`
	Brand            string      `json:"brand"`
}

type DiscountRulesDirty added in v1.1.6

type DiscountRulesDirty struct {
	ProductID int64 `json:"product_id"`
}

type EmailReport added in v1.1.0

type EmailReport struct {
	ID            int64         `json:"id"`
	CreatedAt     time.Time     `json:"created_at"`
	SentBy        string        `json:"sent_by"`
	Scope         string        `json:"scope"`
	FromDay       sql.NullTime  `json:"from_day"`
	ToDay         sql.NullTime  `json:"to_day"`
	BranchID      sql.NullInt64 `json:"branch_id"`
	BranchShiftID sql.NullInt64 `json:"branch_shift_id"`
	Label         string        `json:"label"`
	Recipients    string        `json:"recipients"`
	Subject       string        `json:"subject"`
	Filename      string        `json:"filename"`
	InvoiceCount  int32         `json:"invoice_count"`
	TotalCents    int64         `json:"total_cents"`
	Status        string        `json:"status"`
	Error         string        `json:"error"`
	ProviderID    string        `json:"provider_id"`
	Note          string        `json:"note"`
	ScheduleID    sql.NullInt64 `json:"schedule_id"`
	Bcc           string        `json:"bcc"`
}

type EmailSchedule added in v1.1.0

type EmailSchedule struct {
	ID          int64        `json:"id"`
	Name        string       `json:"name"`
	Enabled     bool         `json:"enabled"`
	Period      string       `json:"period"`
	RegisterIds []int64      `json:"register_ids"`
	Recipients  string       `json:"recipients"`
	Format      string       `json:"format"`
	Note        string       `json:"note"`
	SkipEmpty   bool         `json:"skip_empty"`
	Frequency   string       `json:"frequency"`
	AtMinute    int32        `json:"at_minute"`
	Weekdays    []int32      `json:"weekdays"`
	MonthDay    int32        `json:"month_day"`
	NextRunAt   sql.NullTime `json:"next_run_at"`
	LastRunAt   sql.NullTime `json:"last_run_at"`
	LastStatus  string       `json:"last_status"`
	LastError   string       `json:"last_error"`
	CreatedBy   string       `json:"created_by"`
	CreatedAt   time.Time    `json:"created_at"`
	UpdatedAt   time.Time    `json:"updated_at"`
	Bcc         string       `json:"bcc"`
}

type Employee

type Employee struct {
	ID                     int64         `json:"id"`
	BranchID               sql.NullInt64 `json:"branch_id"`
	Name                   string        `json:"name"`
	Role                   string        `json:"role"`
	Status                 string        `json:"status"`
	HiredOn                sql.NullTime  `json:"hired_on"`
	BaseSalaryCents        int64         `json:"base_salary_cents"`
	CommissionCents        int64         `json:"commission_cents"`
	LateDeductionRateCents int64         `json:"late_deduction_rate_cents"`
	LateDeductionUnit      string        `json:"late_deduction_unit"`
	LateUnitsCenti         int64         `json:"late_units_centi"`
	CreatedAt              time.Time     `json:"created_at"`
	UpdatedAt              time.Time     `json:"updated_at"`
}

type Entry

type Entry struct {
	ID            int64              `json:"id"`
	CashboxID     int64              `json:"cashbox_id"`
	InventoryID   int64              `json:"inventory_id"`
	ReferenceType EntryReferenceType `json:"reference_type"`
	ReferenceID   int64              `json:"reference_id"`
	Amount        int64              `json:"amount"`
	CreatedAt     time.Time          `json:"created_at"`
}

type EntryReferenceType

type EntryReferenceType string
const (
	EntryReferenceTypeSalesInvoice  EntryReferenceType = "sales_invoice"
	EntryReferenceTypeReturnInvoice EntryReferenceType = "return_invoice"
	EntryReferenceTypeExpense       EntryReferenceType = "expense"
	EntryReferenceTypePurchase      EntryReferenceType = "purchase"
)

func (*EntryReferenceType) Scan

func (e *EntryReferenceType) Scan(src interface{}) error

type Expense

type Expense struct {
	ID                 int64         `json:"id"`
	Description        string        `json:"description"`
	Amount             int64         `json:"amount"`
	CurrencyCode       string        `json:"currency_code"`
	CreatedAt          time.Time     `json:"created_at"`
	RecurringExpenseID sql.NullInt64 `json:"recurring_expense_id"`
	CategoryID         sql.NullInt64 `json:"category_id"`
}

type ExpenseCategory

type ExpenseCategory struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	IsActive  bool      `json:"is_active"`
	CreatedAt time.Time `json:"created_at"`
	Icon      string    `json:"icon"`
	Color     string    `json:"color"`
	Scope     string    `json:"scope"`
	UpdatedAt time.Time `json:"updated_at"`
}

type FindUnknownInvoiceItemParams added in v1.1.1

type FindUnknownInvoiceItemParams struct {
	BranchInvoiceID int64 `json:"branch_invoice_id"`
	UnitPrice       int64 `json:"unit_price"`
	Discount        int16 `json:"discount"`
}

type GetAssetTreemapDataRow

type GetAssetTreemapDataRow struct {
	InventoryID   int64  `json:"inventory_id"`
	InventoryName string `json:"inventory_name"`
	CategoryID    int64  `json:"category_id"`
	CategoryName  string `json:"category_name"`
	CategoryColor string `json:"category_color"`
	AssetID       int64  `json:"asset_id"`
	AssetName     string `json:"asset_name"`
	AssetCode     string `json:"asset_code"`
	AssetCost     int64  `json:"asset_cost"`
	Quantity      int64  `json:"quantity"`
}

type GetBatchItemByBatchVariantParams

type GetBatchItemByBatchVariantParams struct {
	BatchID   int64 `json:"batch_id"`
	VariantID int64 `json:"variant_id"`
}

type GetBatchRow

type GetBatchRow struct {
	ID            int64          `json:"id"`
	Code          string         `json:"code"`
	PurchaseID    sql.NullInt64  `json:"purchase_id"`
	InventoryID   sql.NullInt64  `json:"inventory_id"`
	Note          string         `json:"note"`
	CreatedAt     time.Time      `json:"created_at"`
	PurchaseCode  sql.NullString `json:"purchase_code"`
	SupplierName  sql.NullString `json:"supplier_name"`
	InventoryName sql.NullString `json:"inventory_name"`
	ItemCount     int64          `json:"item_count"`
}

type GetBranchAttendanceChangeByClientRefParams

type GetBranchAttendanceChangeByClientRefParams struct {
	RegisterID int64  `json:"register_id"`
	ClientRef  string `json:"client_ref"`
}

type GetBranchAttendanceEventByClientRefParams

type GetBranchAttendanceEventByClientRefParams struct {
	BranchID  int64  `json:"branch_id"`
	ClientRef string `json:"client_ref"`
}

type GetBranchByCodeExcludingParams

type GetBranchByCodeExcludingParams struct {
	Code string `json:"code"`
	ID   int64  `json:"id"`
}

type GetBranchExpenseByClientRefParams

type GetBranchExpenseByClientRefParams struct {
	BranchID  int64  `json:"branch_id"`
	ClientRef string `json:"client_ref"`
}

type GetBranchInvoiceByClientRefParams

type GetBranchInvoiceByClientRefParams struct {
	BranchID  int64  `json:"branch_id"`
	ClientRef string `json:"client_ref"`
}

type GetBranchInvoiceByCodeParams added in v1.1.0

type GetBranchInvoiceByCodeParams struct {
	BranchID int64  `json:"branch_id"`
	Code     string `json:"code"`
}

type GetBranchInvoiceSettlementByClientRefParams

type GetBranchInvoiceSettlementByClientRefParams struct {
	BranchID  int64  `json:"branch_id"`
	ClientRef string `json:"client_ref"`
}

type GetBranchLoanByClientRefParams

type GetBranchLoanByClientRefParams struct {
	BranchID  sql.NullInt64  `json:"branch_id"`
	ClientRef sql.NullString `json:"client_ref"`
}

type GetBranchShiftByClientRefParams

type GetBranchShiftByClientRefParams struct {
	RegisterID int64  `json:"register_id"`
	ClientRef  string `json:"client_ref"`
}

type GetBranchTargetBySeriesAndStartParams

type GetBranchTargetBySeriesAndStartParams struct {
	SeriesID sql.NullInt64 `json:"series_id"`
	DateFrom time.Time     `json:"date_from"`
}

type GetBranchTransferByClientRefParams

type GetBranchTransferByClientRefParams struct {
	BranchID  sql.NullInt64  `json:"branch_id"`
	ClientRef sql.NullString `json:"client_ref"`
}

type GetBranchVisitorEventByClientRefParams

type GetBranchVisitorEventByClientRefParams struct {
	BranchID  int64  `json:"branch_id"`
	ClientRef string `json:"client_ref"`
}

type GetCashboxAccountBalanceParams

type GetCashboxAccountBalanceParams struct {
	AccountID int64 `json:"account_id"`
	ShiftID   int64 `json:"shift_id"`
}

type GetClientLinkParams

type GetClientLinkParams struct {
	RegisterID     int64 `json:"register_id"`
	BranchClientID int64 `json:"branch_client_id"`
}

type GetEmailSettingsRow added in v1.1.0

type GetEmailSettingsRow struct {
	EmailSenderName        string          `json:"email_sender_name"`
	EmailSenderAddress     string          `json:"email_sender_address"`
	EmailReplyTo           string          `json:"email_reply_to"`
	EmailDefaultRecipients string          `json:"email_default_recipients"`
	EmailBusinessName      string          `json:"email_business_name"`
	EmailCsvColumns        json.RawMessage `json:"email_csv_columns"`
	EmailAttachmentFormat  string          `json:"email_attachment_format"`
	EmailGroupByRegister   bool            `json:"email_group_by_register"`
	EmailOldestFirst       bool            `json:"email_oldest_first"`
}

type GetFirstActiveVariantBarcodeByCodeRow added in v1.1.3

type GetFirstActiveVariantBarcodeByCodeRow struct {
	Barcode   string `json:"barcode"`
	ProductID int64  `json:"product_id"`
}

type GetInventoryStockParams

type GetInventoryStockParams struct {
	InventoryID int64 `json:"inventory_id"`
	VariantID   int64 `json:"variant_id"`
}

type GetLowStockSummaryRow

type GetLowStockSummaryRow struct {
	LowStockCount   int64 `json:"low_stock_count"`
	OutOfStockCount int64 `json:"out_of_stock_count"`
	TotalProducts   int64 `json:"total_products"`
}

type GetProductAttributeValueParams

type GetProductAttributeValueParams struct {
	ProductID   int64 `json:"product_id"`
	AttributeID int64 `json:"attribute_id"`
}

type GetProductSupplierParams

type GetProductSupplierParams struct {
	ProductID  int64 `json:"product_id"`
	SupplierID int64 `json:"supplier_id"`
}

type GetPurchaseRow

type GetPurchaseRow struct {
	ID            int64          `json:"id"`
	SupplierID    int64          `json:"supplier_id"`
	PurchasedAt   time.Time      `json:"purchased_at"`
	InventoryID   sql.NullInt64  `json:"inventory_id"`
	Code          string         `json:"code"`
	CurrencyCode  string         `json:"currency_code"`
	Subtotal      int64          `json:"subtotal"`
	GrandTotal    int64          `json:"grand_total"`
	Status        PurchaseStatus `json:"status"`
	ReceivedAt    sql.NullTime   `json:"received_at"`
	Note          string         `json:"note"`
	SupplierName  string         `json:"supplier_name"`
	InventoryName sql.NullString `json:"inventory_name"`
}

type GetRegisterTargetReleaseRow added in v1.1.0

type GetRegisterTargetReleaseRow struct {
	ID          int64         `json:"id"`
	Version     string        `json:"version"`
	Flavor      string        `json:"flavor"`
	FileName    string        `json:"file_name"`
	FilePath    string        `json:"file_path"`
	SizeBytes   int64         `json:"size_bytes"`
	Sha256      string        `json:"sha256"`
	Signature   string        `json:"signature"`
	Notes       string        `json:"notes"`
	UploadedBy  sql.NullInt64 `json:"uploaded_by"`
	CreatedAt   time.Time     `json:"created_at"`
	TargetForce bool          `json:"target_force"`
}

type GetReviewSettingsRow added in v1.1.0

type GetReviewSettingsRow struct {
	ReviewPlaceID        string `json:"review_place_id"`
	ReviewBaseUrl        string `json:"review_base_url"`
	ReviewTitle          string `json:"review_title"`
	ReviewDescription    string `json:"review_description"`
	GooglePlacesApiKey   string `json:"google_places_api_key"`
	GoogleReviewsEnabled bool   `json:"google_reviews_enabled"`
}

type GetSalespersonByAttendanceIDParams added in v1.1.0

type GetSalespersonByAttendanceIDParams struct {
	BranchID         sql.NullInt64 `json:"branch_id"`
	AttendanceUserID string        `json:"attendance_user_id"`
	ID               int64         `json:"id"`
}

type GetSlowMoverSummaryRow

type GetSlowMoverSummaryRow struct {
	DeadStockCount      int64 `json:"dead_stock_count"`
	OverstockedCount    int64 `json:"overstocked_count"`
	TotalActiveProducts int64 `json:"total_active_products"`
}

type GetStockHealthOverviewRow

type GetStockHealthOverviewRow struct {
	TotalUnits      int64       `json:"total_units"`
	InventoryValue  int64       `json:"inventory_value"`
	UnitsSold30d    int64       `json:"units_sold_30d"`
	DaysOfInventory interface{} `json:"days_of_inventory"`
}

type GetUnknownItemSessionByRefParams added in v1.1.1

type GetUnknownItemSessionByRefParams struct {
	BranchID  int64  `json:"branch_id"`
	ClientRef string `json:"client_ref"`
}

type GetUnknownItemSlotByRefParams added in v1.1.1

type GetUnknownItemSlotByRefParams struct {
	SessionID int64  `json:"session_id"`
	SlotRef   string `json:"slot_ref"`
}

type GetUnknownItemSlotForResolveRow added in v1.1.1

type GetUnknownItemSlotForResolveRow struct {
	ID                int64         `json:"id"`
	SessionID         int64         `json:"session_id"`
	SlotRef           string        `json:"slot_ref"`
	Position          int32         `json:"position"`
	Label             string        `json:"label"`
	UnitPrice         int64         `json:"unit_price"`
	Discount          int16         `json:"discount"`
	ImageID           sql.NullInt64 `json:"image_id"`
	ResolvedVariantID sql.NullInt64 `json:"resolved_variant_id"`
	ResolvedAt        sql.NullTime  `json:"resolved_at"`
	WaivedAt          sql.NullTime  `json:"waived_at"`
	WaivedBy          string        `json:"waived_by"`
	LineRef           string        `json:"line_ref"`
	BranchID          int64         `json:"branch_id"`
	BranchInvoiceID   sql.NullInt64 `json:"branch_invoice_id"`
}

type GetUserAccessRow

type GetUserAccessRow struct {
	RoleID   int64          `json:"role_id"`
	RoleName string         `json:"role_name"`
	IsAdmin  bool           `json:"is_admin"`
	Section  sql.NullString `json:"section"`
	Page     sql.NullString `json:"page"`
	CanView  sql.NullBool   `json:"can_view"`
	CanEdit  sql.NullBool   `json:"can_edit"`
}

type GetVariantDiscountFromListParams

type GetVariantDiscountFromListParams struct {
	DiscountListID   int64 `json:"discount_list_id"`
	ProductVariantID int64 `json:"product_variant_id"`
}

type GetVariantForLabelRow

type GetVariantForLabelRow struct {
	ID          int64         `json:"id"`
	Barcode     string        `json:"barcode"`
	Price       sql.NullInt64 `json:"price"`
	ProductCode string        `json:"product_code"`
	ProductName string        `json:"product_name"`
	ColorName   string        `json:"color_name"`
	SizeName    string        `json:"size_name"`
	Brand       string        `json:"brand"`
}

type GetVariantPriceFromListParams

type GetVariantPriceFromListParams struct {
	PriceListID      int64 `json:"price_list_id"`
	ProductVariantID int64 `json:"product_variant_id"`
}

type GetWarehouseTreemapDataRow

type GetWarehouseTreemapDataRow struct {
	InventoryID   int64  `json:"inventory_id"`
	InventoryName string `json:"inventory_name"`
	CategoryID    int64  `json:"category_id"`
	CategoryName  string `json:"category_name"`
	CategoryColor string `json:"category_color"`
	ProductID     int64  `json:"product_id"`
	ProductName   string `json:"product_name"`
	ProductCode   string `json:"product_code"`
	VariantID     int64  `json:"variant_id"`
	Barcode       string `json:"barcode"`
	VariantCost   int64  `json:"variant_cost"`
	ColorName     string `json:"color_name"`
	ColorHex      string `json:"color_hex"`
	Quantity      int64  `json:"quantity"`
}

type GetWhatsAppChatMessageMediaRow added in v1.1.1

type GetWhatsAppChatMessageMediaRow struct {
	Instance  string `json:"instance"`
	WaID      string `json:"wa_id"`
	MediaType string `json:"media_type"`
}

type GetWhatsAppMessageByReviewCodeRow added in v1.1.0

type GetWhatsAppMessageByReviewCodeRow struct {
	ID       int64         `json:"id"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type GetWhatsAppMessageWithBranchRow added in v1.1.0

type GetWhatsAppMessageWithBranchRow struct {
	ID                 int64          `json:"id"`
	CreatedAt          time.Time      `json:"created_at"`
	BranchID           sql.NullInt64  `json:"branch_id"`
	InvoiceCode        string         `json:"invoice_code"`
	ClientName         string         `json:"client_name"`
	ClientPhone        string         `json:"client_phone"`
	GrandTotalCents    int64          `json:"grand_total_cents"`
	ItemCount          int32          `json:"item_count"`
	RuleID             sql.NullInt64  `json:"rule_id"`
	RuleName           string         `json:"rule_name"`
	TemplateName       string         `json:"template_name"`
	Status             string         `json:"status"`
	Reason             string         `json:"reason"`
	Wamid              string         `json:"wamid"`
	CostMicros         int64          `json:"cost_micros"`
	DeliveryStatus     string         `json:"delivery_status"`
	DeliveredAt        sql.NullTime   `json:"delivered_at"`
	ReadAt             sql.NullTime   `json:"read_at"`
	DeliveryError      string         `json:"delivery_error"`
	Billable           sql.NullBool   `json:"billable"`
	PricingCategory    string         `json:"pricing_category"`
	ReviewCode         string         `json:"review_code"`
	ReviewClickedAt    sql.NullTime   `json:"review_clicked_at"`
	Sender             string         `json:"sender"`
	WhatsappNumberID   sql.NullInt64  `json:"whatsapp_number_id"`
	PollRef            string         `json:"poll_ref"`
	PollRating         sql.NullInt16  `json:"poll_rating"`
	PollAnswer         string         `json:"poll_answer"`
	PollVotedAt        sql.NullTime   `json:"poll_voted_at"`
	PollFollowupAt     sql.NullTime   `json:"poll_followup_at"`
	BridgeRef          string         `json:"bridge_ref"`
	IsTest             bool           `json:"is_test"`
	Body               string         `json:"body"`
	PollQuestion       string         `json:"poll_question"`
	PollOptions        string         `json:"poll_options"`
	FollowupBody       string         `json:"followup_body"`
	BranchName         string         `json:"branch_name"`
	BranchHiddenFields sql.NullString `json:"branch_hidden_fields"`
}

type GetWhatsAppPollReplyMediaRow added in v1.1.0

type GetWhatsAppPollReplyMediaRow struct {
	WaID      string `json:"wa_id"`
	MediaType string `json:"media_type"`
	Instance  string `json:"instance"`
}

type GetWhatsAppSenderSettingsRow added in v1.1.0

type GetWhatsAppSenderSettingsRow struct {
	WhatsappSender            string `json:"whatsapp_sender"`
	WhatsappBridgeUrl         string `json:"whatsapp_bridge_url"`
	WhatsappBridgeKey         string `json:"whatsapp_bridge_key"`
	WhatsappBridgeMessage     string `json:"whatsapp_bridge_message"`
	WhatsappFeedbackMode      string `json:"whatsapp_feedback_mode"`
	WhatsappBridgeLinkMessage string `json:"whatsapp_bridge_link_message"`
	WhatsappChannelUrl        string `json:"whatsapp_channel_url"`
	WhatsappPollQuestion      string `json:"whatsapp_poll_question"`
	WhatsappPollOptions       string `json:"whatsapp_poll_options"`
	WhatsappFollowup          bool   `json:"whatsapp_followup"`
	WhatsappFollowupGood      string `json:"whatsapp_followup_good"`
	WhatsappFollowupOkay      string `json:"whatsapp_followup_okay"`
	WhatsappFollowupBad       string `json:"whatsapp_followup_bad"`
	WhatsappHiddenFields      string `json:"whatsapp_hidden_fields"`
	WhatsappChannelFirst      bool   `json:"whatsapp_channel_first"`
	WhatsappWelcomeEarly      bool   `json:"whatsapp_welcome_early"`
	WhatsappDeleteForMe       bool   `json:"whatsapp_delete_for_me"`
	WhatsappDeletePollForMe   bool   `json:"whatsapp_delete_poll_for_me"`
	WhatsappFollowupReturning bool   `json:"whatsapp_followup_returning"`
	WhatsappMessageNew        bool   `json:"whatsapp_message_new"`
	WhatsappMessageReturning  bool   `json:"whatsapp_message_returning"`
	WhatsappPollNew           bool   `json:"whatsapp_poll_new"`
	WhatsappPollReturning     bool   `json:"whatsapp_poll_returning"`
}

type GetWhatsAppSettingsRow

type GetWhatsAppSettingsRow struct {
	WhatsappEnabled            bool   `json:"whatsapp_enabled"`
	WhatsappPhoneNumberID      string `json:"whatsapp_phone_number_id"`
	WhatsappAccessToken        string `json:"whatsapp_access_token"`
	WhatsappTemplateName       string `json:"whatsapp_template_name"`
	WhatsappTemplateLang       string `json:"whatsapp_template_lang"`
	WhatsappTemplateParams     string `json:"whatsapp_template_params"`
	WhatsappWebhookVerifyToken string `json:"whatsapp_webhook_verify_token"`
	WhatsappAppSecret          string `json:"whatsapp_app_secret"`
}

type GooglePlaceSnapshot added in v1.1.0

type GooglePlaceSnapshot struct {
	ID          int64     `json:"id"`
	PlaceID     string    `json:"place_id"`
	TakenAt     time.Time `json:"taken_at"`
	Name        string    `json:"name"`
	Rating      float64   `json:"rating"`
	ReviewCount int32     `json:"review_count"`
}

type GooglePlaceSnapshotBeforeParams added in v1.1.0

type GooglePlaceSnapshotBeforeParams struct {
	PlaceID string    `json:"place_id"`
	At      time.Time `json:"at"`
}

type GoogleReview added in v1.1.0

type GoogleReview struct {
	PlaceID     string       `json:"place_id"`
	ReviewName  string       `json:"review_name"`
	Author      string       `json:"author"`
	AuthorPhoto string       `json:"author_photo"`
	Rating      int32        `json:"rating"`
	Body        string       `json:"body"`
	PublishedAt sql.NullTime `json:"published_at"`
	FetchedAt   time.Time    `json:"fetched_at"`
}

type HomeActivityFeedParams added in v1.1.0

type HomeActivityFeedParams struct {
	BeforeAt       sql.NullTime   `json:"before_at"`
	BeforeActivity sql.NullString `json:"before_activity"`
	BeforeID       sql.NullInt64  `json:"before_id"`
	PageSize       int32          `json:"page_size"`
}

type HomeActivityFeedRow added in v1.1.0

type HomeActivityFeedRow struct {
	Activity     string    `json:"activity"`
	ID           int64     `json:"id"`
	BranchID     int64     `json:"branch_id"`
	BranchName   string    `json:"branch_name"`
	Details      string    `json:"details"`
	Amount       int64     `json:"amount"`
	CurrencyCode string    `json:"currency_code"`
	SyncedAt     time.Time `json:"synced_at"`
	Person       string    `json:"person"`
	PersonColor  string    `json:"person_color"`
}

type HomeActivityResolution added in v1.1.0

type HomeActivityResolution struct {
	Activity   string    `json:"activity"`
	SourceID   int64     `json:"source_id"`
	ResolvedBy string    `json:"resolved_by"`
	ResolvedAt time.Time `json:"resolved_at"`
}

type IncrementInvoicesIndexParams

type IncrementInvoicesIndexParams struct {
	Year          int32     `json:"year"`
	CashboxID     int64     `json:"cashbox_id"`
	Type          IndexType `json:"type"`
	InvoiceTypeID int64     `json:"invoice_type_id"`
}

type IndexType

type IndexType string
const (
	IndexTypeSales  IndexType = "sales"
	IndexTypeReturn IndexType = "return"
)

func (*IndexType) Scan

func (e *IndexType) Scan(src interface{}) error

type InsertBranchQuickAccessItemParams

type InsertBranchQuickAccessItemParams struct {
	BranchID         int64  `json:"branch_id"`
	ProductVariantID int64  `json:"product_variant_id"`
	Position         int32  `json:"position"`
	Color            string `json:"color"`
	TextColor        string `json:"text_color"`
}

type InventoriesAsset

type InventoriesAsset struct {
	AssetID     int64 `json:"asset_id"`
	InventoryID int64 `json:"inventory_id"`
	Quantity    int64 `json:"quantity"`
}

type Inventory

type Inventory struct {
	ID        int64           `json:"id"`
	Name      string          `json:"name"`
	Type      InventoryType   `json:"type"`
	Code      string          `json:"code"`
	Longitude sql.NullFloat64 `json:"longitude"`
	Latitude  sql.NullFloat64 `json:"latitude"`
	CreatedAt time.Time       `json:"created_at"`
}

type InventoryStock

type InventoryStock struct {
	InventoryID int64         `json:"inventory_id"`
	VariantID   int64         `json:"variant_id"`
	Quantity    int64         `json:"quantity"`
	AvgCost     int64         `json:"avg_cost"`
	UpdatedAt   time.Time     `json:"updated_at"`
	ID          sql.NullInt64 `json:"id"`
}

type InventoryType

type InventoryType string
const (
	InventoryTypeWarehouse InventoryType = "warehouse"
	InventoryTypeStore     InventoryType = "store"
)

func (*InventoryType) Scan

func (e *InventoryType) Scan(src interface{}) error

type Invoice

type Invoice struct {
	ID                 int64         `json:"id"`
	CashboxID          int64         `json:"cashbox_id"`
	ShiftID            int64         `json:"shift_id"`
	InvoiceCode        string        `json:"invoice_code"`
	InvoiceIndex       int64         `json:"invoice_index"`
	Year               int32         `json:"year"`
	ClientID           int64         `json:"client_id"`
	InventoryID        int64         `json:"inventory_id"`
	Discount           int16         `json:"discount"`
	Subtotal           int64         `json:"subtotal"`
	DiscountedTotal    int64         `json:"discounted_total"`
	GrandTotal         int64         `json:"grand_total"`
	CreatedAt          time.Time     `json:"created_at"`
	InvoiceTypeID      int64         `json:"invoice_type_id"`
	SalespersonID      sql.NullInt64 `json:"salesperson_id"`
	LoyaltyPointsDelta int64         `json:"loyalty_points_delta"`
}

type InvoiceDiscount added in v1.1.8

type InvoiceDiscount struct {
	ID          int64        `json:"id"`
	Uid         uuid.UUID    `json:"uid"`
	Name        string       `json:"name"`
	MinTotal    int64        `json:"min_total"`
	Kind        string       `json:"kind"`
	Percent     int16        `json:"percent"`
	Amount      int64        `json:"amount"`
	AllBranches bool         `json:"all_branches"`
	ValidFrom   sql.NullTime `json:"valid_from"`
	ValidTo     sql.NullTime `json:"valid_to"`
	IsActive    bool         `json:"is_active"`
	DeletedAt   sql.NullTime `json:"deleted_at"`
	CreatedAt   time.Time    `json:"created_at"`
	UpdatedAt   time.Time    `json:"updated_at"`
}

type InvoiceDiscountBranch added in v1.1.8

type InvoiceDiscountBranch struct {
	InvoiceDiscountID int64 `json:"invoice_discount_id"`
	BranchID          int64 `json:"branch_id"`
}

type InvoiceIndex

type InvoiceIndex struct {
	Year          int32     `json:"year"`
	CashboxID     int64     `json:"cashbox_id"`
	LastIndex     int64     `json:"last_index"`
	Type          IndexType `json:"type"`
	InvoiceTypeID int64     `json:"invoice_type_id"`
}

type InvoicePayment

type InvoicePayment struct {
	ID               int64 `json:"id"`
	InvoiceID        int64 `json:"invoice_id"`
	CashboxAccountID int64 `json:"cashbox_account_id"`
	Amount           int64 `json:"amount"`
}

type InvoiceProduct

type InvoiceProduct struct {
	InvoiceID int64         `json:"invoice_id"`
	ProductID int64         `json:"product_id"`
	UnitPrice int64         `json:"unit_price"`
	LineTotal int64         `json:"line_total"`
	Discount  int16         `json:"discount"`
	Quantity  int64         `json:"quantity"`
	VariantID sql.NullInt64 `json:"variant_id"`
	UnitCost  int64         `json:"unit_cost"`
}

type InvoiceType

type InvoiceType struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	Code      string    `json:"code"`
	IsDefault bool      `json:"is_default"`
	IsActive  bool      `json:"is_active"`
	CreatedAt time.Time `json:"created_at"`
}

type IpBan added in v1.1.0

type IpBan struct {
	Ip        string       `json:"ip"`
	Reason    string       `json:"reason"`
	Until     sql.NullTime `json:"until"`
	CreatedAt time.Time    `json:"created_at"`
	CreatedBy string       `json:"created_by"`
}

type LinkUnknownItemSessionParams added in v1.1.1

type LinkUnknownItemSessionParams struct {
	BranchID        int64         `json:"branch_id"`
	ClientRef       string        `json:"client_ref"`
	BranchInvoiceID sql.NullInt64 `json:"branch_invoice_id"`
}

type ListAdminActivitiesParams

type ListAdminActivitiesParams struct {
	BeforeAt sql.NullTime  `json:"before_at"`
	BeforeID sql.NullInt64 `json:"before_id"`
	PageSize int32         `json:"page_size"`
}

type ListAdminActivitiesRow

type ListAdminActivitiesRow struct {
	ID              int64         `json:"id"`
	Method          string        `json:"method"`
	Route           string        `json:"route"`
	EntityID        sql.NullInt64 `json:"entity_id"`
	Summary         string        `json:"summary"`
	Detail          string        `json:"detail"`
	CreatedAt       time.Time     `json:"created_at"`
	RepeatCount     int32         `json:"repeat_count"`
	ReleaseType     string        `json:"release_type"`
	UserID          sql.NullInt64 `json:"user_id"`
	UserName        string        `json:"user_name"`
	UserAvatarColor string        `json:"user_avatar_color"`
}

type ListAllAttributeValuesRow

type ListAllAttributeValuesRow struct {
	ID            int64     `json:"id"`
	AttributeID   int64     `json:"attribute_id"`
	Value         string    `json:"value"`
	CreatedAt     time.Time `json:"created_at"`
	AttributeName string    `json:"attribute_name"`
}

type ListAllClientPhonesRow added in v1.1.3

type ListAllClientPhonesRow struct {
	ID    int64  `json:"id"`
	Phone string `json:"phone"`
}

type ListAppReleasesRow

type ListAppReleasesRow struct {
	ID           int64         `json:"id"`
	Version      string        `json:"version"`
	Flavor       string        `json:"flavor"`
	FileName     string        `json:"file_name"`
	FilePath     string        `json:"file_path"`
	SizeBytes    int64         `json:"size_bytes"`
	Sha256       string        `json:"sha256"`
	Signature    string        `json:"signature"`
	Notes        string        `json:"notes"`
	UploadedBy   sql.NullInt64 `json:"uploaded_by"`
	CreatedAt    time.Time     `json:"created_at"`
	RunningCount int64         `json:"running_count"`
	TargetCount  int64         `json:"target_count"`
}

type ListAppUpdateEventsRow

type ListAppUpdateEventsRow struct {
	ID             int64          `json:"id"`
	RegisterID     int64          `json:"register_id"`
	ReleaseID      sql.NullInt64  `json:"release_id"`
	AppVersion     string         `json:"app_version"`
	State          string         `json:"state"`
	Detail         string         `json:"detail"`
	CreatedAt      time.Time      `json:"created_at"`
	RegisterCode   string         `json:"register_code"`
	RegisterName   string         `json:"register_name"`
	BranchName     string         `json:"branch_name"`
	ReleaseVersion sql.NullString `json:"release_version"`
}

type ListAssetsPageParams

type ListAssetsPageParams struct {
	CategoryID sql.NullInt64 `json:"category_id"`
	Search     string        `json:"search"`
	SortBy     string        `json:"sort_by"`
	SortOrder  string        `json:"sort_order"`
	PageOffset int32         `json:"page_offset"`
	PageSize   int32         `json:"page_size"`
}

type ListAttributeValuesPageParams

type ListAttributeValuesPageParams struct {
	AttributeName string `json:"attribute_name"`
	Search        string `json:"search"`
	SortBy        string `json:"sort_by"`
	SortOrder     string `json:"sort_order"`
	PageOffset    int32  `json:"page_offset"`
	PageSize      int32  `json:"page_size"`
}

type ListAttributeValuesPageRow

type ListAttributeValuesPageRow struct {
	ID            int64     `json:"id"`
	AttributeID   int64     `json:"attribute_id"`
	Value         string    `json:"value"`
	CreatedAt     time.Time `json:"created_at"`
	AttributeName string    `json:"attribute_name"`
}

type ListAuditLogsParams

type ListAuditLogsParams struct {
	EntityType sql.NullString  `json:"entity_type"`
	EntityID   sql.NullInt64   `json:"entity_id"`
	Action     NullAuditAction `json:"action"`
	ActorID    sql.NullInt64   `json:"actor_id"`
	FromDate   sql.NullTime    `json:"from_date"`
	ToDate     sql.NullTime    `json:"to_date"`
	PageOffset int32           `json:"page_offset"`
	PageLimit  int32           `json:"page_limit"`
}

type ListAuditLogsRow

type ListAuditLogsRow struct {
	ID         int64                 `json:"id"`
	EntityType string                `json:"entity_type"`
	EntityID   int64                 `json:"entity_id"`
	Action     AuditAction           `json:"action"`
	Before     pqtype.NullRawMessage `json:"before"`
	After      pqtype.NullRawMessage `json:"after"`
	ActorID    sql.NullInt64         `json:"actor_id"`
	Source     string                `json:"source"`
	CreatedAt  time.Time             `json:"created_at"`
	ActorName  string                `json:"actor_name"`
}

type ListAutoDeletableUnknownItemImagesParams added in v1.1.1

type ListAutoDeletableUnknownItemImagesParams struct {
	ResolvedBefore  time.Time `json:"resolved_before"`
	AbandonedBefore time.Time `json:"abandoned_before"`
}

type ListAutoDeletableUnknownItemImagesRow added in v1.1.1

type ListAutoDeletableUnknownItemImagesRow struct {
	ID       int64  `json:"id"`
	FilePath string `json:"file_path"`
}

type ListBatchItemsStatsRow

type ListBatchItemsStatsRow struct {
	BatchItemID       int64  `json:"batch_item_id"`
	BatchID           int64  `json:"batch_id"`
	VariantID         int64  `json:"variant_id"`
	QuantityBought    int64  `json:"quantity_bought"`
	RemainingQuantity int64  `json:"remaining_quantity"`
	UnitCost          int64  `json:"unit_cost"`
	ProductID         int64  `json:"product_id"`
	ProductName       string `json:"product_name"`
	ProductCode       string `json:"product_code"`
	VariantBarcode    string `json:"variant_barcode"`
	LowStockThreshold int64  `json:"low_stock_threshold"`
	QuantitySold      int64  `json:"quantity_sold"`
	Revenue           int64  `json:"revenue"`
}

type ListBatchesParams

type ListBatchesParams struct {
	Search     string `json:"search"`
	PageOffset int32  `json:"page_offset"`
	PageSize   int32  `json:"page_size"`
}

type ListBatchesRow

type ListBatchesRow struct {
	ID            int64          `json:"id"`
	Code          string         `json:"code"`
	PurchaseID    sql.NullInt64  `json:"purchase_id"`
	InventoryID   sql.NullInt64  `json:"inventory_id"`
	Note          string         `json:"note"`
	CreatedAt     time.Time      `json:"created_at"`
	PurchaseCode  sql.NullString `json:"purchase_code"`
	SupplierName  sql.NullString `json:"supplier_name"`
	InventoryName sql.NullString `json:"inventory_name"`
	ItemCount     int64          `json:"item_count"`
}

type ListBranchAttendanceChangesParams

type ListBranchAttendanceChangesParams struct {
	Limit    int32         `json:"limit"`
	Offset   int32         `json:"offset"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListBranchAttendanceEventsInRangeParams added in v1.1.0

type ListBranchAttendanceEventsInRangeParams struct {
	BranchID sql.NullInt64 `json:"branch_id"`
	FromDate string        `json:"from_date"`
	ToDate   string        `json:"to_date"`
}

type ListBranchAttendanceEventsParams

type ListBranchAttendanceEventsParams struct {
	Limit    int32         `json:"limit"`
	Offset   int32         `json:"offset"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListBranchClientUIDsRow

type ListBranchClientUIDsRow struct {
	BranchClientID int64     `json:"branch_client_id"`
	Uid            uuid.UUID `json:"uid"`
}

type ListBranchCommandsPageParams

type ListBranchCommandsPageParams struct {
	BranchID   int64  `json:"branch_id"`
	RegisterID int64  `json:"register_id"`
	Status     string `json:"status"`
	Type       string `json:"type"`
	PageOffset int32  `json:"page_offset"`
	PageSize   int32  `json:"page_size"`
}

type ListBranchCommandsPageRow

type ListBranchCommandsPageRow struct {
	ID           int64                 `json:"id"`
	BranchID     int64                 `json:"branch_id"`
	Type         string                `json:"type"`
	Payload      json.RawMessage       `json:"payload"`
	Status       string                `json:"status"`
	Result       pqtype.NullRawMessage `json:"result"`
	Error        sql.NullString        `json:"error"`
	IssuedBy     int64                 `json:"issued_by"`
	CreatedAt    time.Time             `json:"created_at"`
	CompletedAt  sql.NullTime          `json:"completed_at"`
	RegisterID   int64                 `json:"register_id"`
	RegisterCode string                `json:"register_code"`
	BranchName   string                `json:"branch_name"`
	IssuedByName sql.NullString        `json:"issued_by_name"`
}

type ListBranchCommandsParams

type ListBranchCommandsParams struct {
	BranchID int64 `json:"branch_id"`
	Limit    int32 `json:"limit"`
	Offset   int32 `json:"offset"`
}

type ListBranchCommandsRow

type ListBranchCommandsRow struct {
	ID           int64                 `json:"id"`
	BranchID     int64                 `json:"branch_id"`
	Type         string                `json:"type"`
	Payload      json.RawMessage       `json:"payload"`
	Status       string                `json:"status"`
	Result       pqtype.NullRawMessage `json:"result"`
	Error        sql.NullString        `json:"error"`
	IssuedBy     int64                 `json:"issued_by"`
	CreatedAt    time.Time             `json:"created_at"`
	CompletedAt  sql.NullTime          `json:"completed_at"`
	RegisterID   int64                 `json:"register_id"`
	RegisterCode string                `json:"register_code"`
}

type ListBranchExpenseHistoryForSyncParams

type ListBranchExpenseHistoryForSyncParams struct {
	BranchID        int64     `json:"branch_id"`
	AfterReceivedAt time.Time `json:"after_received_at"`
	AfterID         int64     `json:"after_id"`
	RowLimit        int32     `json:"row_limit"`
}

type ListBranchExpenseHistoryForSyncRow

type ListBranchExpenseHistoryForSyncRow struct {
	ID                       int64          `json:"id"`
	BranchID                 int64          `json:"branch_id"`
	ClientRef                string         `json:"client_ref"`
	Description              string         `json:"description"`
	Amount                   int64          `json:"amount"`
	CurrencyCode             string         `json:"currency_code"`
	BranchCashboxAccountID   int64          `json:"branch_cashbox_account_id"`
	BranchShiftID            sql.NullInt64  `json:"branch_shift_id"`
	OccurredAt               time.Time      `json:"occurred_at"`
	ReceivedAt               time.Time      `json:"received_at"`
	CategoryID               sql.NullInt64  `json:"category_id"`
	BranchCashboxAccountName sql.NullString `json:"branch_cashbox_account_name"`
	CancelledAt              sql.NullTime   `json:"cancelled_at"`
	FromCentral              bool           `json:"from_central"`
	CategoryName             string         `json:"category_name"`
}

type ListBranchExpenseImagesParams

type ListBranchExpenseImagesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListBranchExpenseImagesRow

type ListBranchExpenseImagesRow struct {
	ID                 int64     `json:"id"`
	BranchExpenseID    int64     `json:"branch_expense_id"`
	FilePath           string    `json:"file_path"`
	ContentType        string    `json:"content_type"`
	SizeBytes          int64     `json:"size_bytes"`
	CreatedAt          time.Time `json:"created_at"`
	Rotation           int16     `json:"rotation"`
	ExpenseDescription string    `json:"expense_description"`
	ExpenseBranchID    int64     `json:"expense_branch_id"`
	BranchName         string    `json:"branch_name"`
}

type ListBranchExpensesParams

type ListBranchExpensesParams struct {
	Limit    int32         `json:"limit"`
	Offset   int32         `json:"offset"`
	BranchID sql.NullInt64 `json:"branch_id"`
	Search   string        `json:"search"`
}

type ListBranchInvoiceCouponCodesForHistoryParams

type ListBranchInvoiceCouponCodesForHistoryParams struct {
	BranchID          sql.NullInt64 `json:"branch_id"`
	InvoiceClientRefs []string      `json:"invoice_client_refs"`
}

type ListBranchInvoiceCouponCodesForHistoryRow

type ListBranchInvoiceCouponCodesForHistoryRow struct {
	RedeemedInvoiceRef sql.NullString `json:"redeemed_invoice_ref"`
	Code               string         `json:"code"`
}

type ListBranchInvoiceHistoryForSyncParams

type ListBranchInvoiceHistoryForSyncParams struct {
	RegisterID      int64     `json:"register_id"`
	AfterReceivedAt time.Time `json:"after_received_at"`
	AfterID         int64     `json:"after_id"`
	RowLimit        int32     `json:"row_limit"`
}

type ListBranchInvoiceItemsForHistoryRow

type ListBranchInvoiceItemsForHistoryRow struct {
	ID              int64          `json:"id"`
	BranchInvoiceID int64          `json:"branch_invoice_id"`
	BranchProductID int64          `json:"branch_product_id"`
	UnitPrice       int64          `json:"unit_price"`
	LineTotal       int64          `json:"line_total"`
	Discount        int16          `json:"discount"`
	Quantity        int64          `json:"quantity"`
	ProductUid      uuid.NullUUID  `json:"product_uid"`
	Unknown         bool           `json:"unknown"`
	Deal            string         `json:"deal"`
	DealDiscount    int64          `json:"deal_discount"`
	InvoiceDiscount int64          `json:"invoice_discount"`
	ResolvedBarcode sql.NullString `json:"resolved_barcode"`
}

type ListBranchInvoiceItemsNamedRow added in v1.1.0

type ListBranchInvoiceItemsNamedRow struct {
	ID          int64  `json:"id"`
	Quantity    int64  `json:"quantity"`
	UnitPrice   int64  `json:"unit_price"`
	LineTotal   int64  `json:"line_total"`
	Discount    int16  `json:"discount"`
	ProductName string `json:"product_name"`
	ProductCode string `json:"product_code"`
}

type ListBranchInvoiceItemsRow added in v1.1.0

type ListBranchInvoiceItemsRow struct {
	ID              int64         `json:"id"`
	BranchInvoiceID int64         `json:"branch_invoice_id"`
	BranchProductID int64         `json:"branch_product_id"`
	UnitPrice       int64         `json:"unit_price"`
	LineTotal       int64         `json:"line_total"`
	Discount        int16         `json:"discount"`
	Quantity        int64         `json:"quantity"`
	ProductUid      uuid.NullUUID `json:"product_uid"`
	Unknown         bool          `json:"unknown"`
	Deal            string        `json:"deal"`
	DealDiscount    int64         `json:"deal_discount"`
	InvoiceDiscount int64         `json:"invoice_discount"`
	ProductName     string        `json:"product_name"`
	ProductCode     string        `json:"product_code"`
	Barcode         string        `json:"barcode"`
	ColorName       string        `json:"color_name"`
	SizeName        string        `json:"size_name"`
}

type ListBranchInvoiceSettlementsParams

type ListBranchInvoiceSettlementsParams struct {
	Limit    int32         `json:"limit"`
	Offset   int32         `json:"offset"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListBranchInvoicesPageParams

type ListBranchInvoicesPageParams struct {
	BranchID   sql.NullInt64  `json:"branch_id"`
	Search     string         `json:"search"`
	RegisterID sql.NullInt64  `json:"register_id"`
	Kind       sql.NullString `json:"kind"`
	Status     sql.NullString `json:"status"`
	DateFrom   sql.NullTime   `json:"date_from"`
	DateTo     sql.NullTime   `json:"date_to"`
	PageOffset int32          `json:"page_offset"`
	PageSize   int32          `json:"page_size"`
}

type ListBranchInvoicesParams

type ListBranchInvoicesParams struct {
	Limit    int32         `json:"limit"`
	Offset   int32         `json:"offset"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListBranchLoanHistoryForSyncParams

type ListBranchLoanHistoryForSyncParams struct {
	BranchID        sql.NullInt64 `json:"branch_id"`
	AfterReceivedAt time.Time     `json:"after_received_at"`
	AfterID         int64         `json:"after_id"`
	RowLimit        int32         `json:"row_limit"`
}

type ListBranchLoanHistoryForSyncRow

type ListBranchLoanHistoryForSyncRow struct {
	ID                       int64          `json:"id"`
	Origin                   string         `json:"origin"`
	Description              string         `json:"description"`
	CategoryID               int64          `json:"category_id"`
	Amount                   int64          `json:"amount"`
	CurrencyCode             string         `json:"currency_code"`
	BranchID                 sql.NullInt64  `json:"branch_id"`
	ClientRef                sql.NullString `json:"client_ref"`
	BranchCashboxAccountID   sql.NullInt64  `json:"branch_cashbox_account_id"`
	BranchShiftID            sql.NullInt64  `json:"branch_shift_id"`
	OccurredAt               time.Time      `json:"occurred_at"`
	ReceivedAt               time.Time      `json:"received_at"`
	BranchCashboxAccountName sql.NullString `json:"branch_cashbox_account_name"`
	CancelledAt              sql.NullTime   `json:"cancelled_at"`
	CategoryName             string         `json:"category_name"`
}

type ListBranchPlaceIDsRow added in v1.1.0

type ListBranchPlaceIDsRow struct {
	ID            int64  `json:"id"`
	Name          string `json:"name"`
	GooglePlaceID string `json:"google_place_id"`
}

type ListBranchProductRevenueDailyParams

type ListBranchProductRevenueDailyParams struct {
	DateFrom           time.Time     `json:"date_from"`
	DateTo             time.Time     `json:"date_to"`
	BranchID           sql.NullInt64 `json:"branch_id"`
	CategoryValueID    sql.NullInt64 `json:"category_value_id"`
	SubcategoryValueID sql.NullInt64 `json:"subcategory_value_id"`
	BrandValueID       sql.NullInt64 `json:"brand_value_id"`
}

type ListBranchProductRevenueDailyRow

type ListBranchProductRevenueDailyRow struct {
	Day      time.Time `json:"day"`
	Revenue  int64     `json:"revenue"`
	Quantity int64     `json:"quantity"`
}

type ListBranchProductRevenueParams

type ListBranchProductRevenueParams struct {
	DateFrom           time.Time     `json:"date_from"`
	DateTo             time.Time     `json:"date_to"`
	BranchID           sql.NullInt64 `json:"branch_id"`
	CategoryValueID    sql.NullInt64 `json:"category_value_id"`
	SubcategoryValueID sql.NullInt64 `json:"subcategory_value_id"`
	BrandValueID       sql.NullInt64 `json:"brand_value_id"`
}

type ListBranchProductRevenueRow

type ListBranchProductRevenueRow struct {
	ProductID    int64  `json:"product_id"`
	ProductName  string `json:"product_name"`
	ProductCode  string `json:"product_code"`
	Category     string `json:"category"`
	Subcategory  string `json:"subcategory"`
	Brand        string `json:"brand"`
	Quantity     int64  `json:"quantity"`
	Revenue      int64  `json:"revenue"`
	InvoiceCount int64  `json:"invoice_count"`
}

type ListBranchQuickAccessItemsRow

type ListBranchQuickAccessItemsRow struct {
	ProductVariantID int64          `json:"product_variant_id"`
	Position         int32          `json:"position"`
	Color            string         `json:"color"`
	TextColor        string         `json:"text_color"`
	Uid              uuid.UUID      `json:"uid"`
	Barcode          string         `json:"barcode"`
	IsActive         bool           `json:"is_active"`
	Code             string         `json:"code"`
	Name             string         `json:"name"`
	ColorName        sql.NullString `json:"color_name"`
	SizeName         sql.NullString `json:"size_name"`
}

type ListBranchRevenueByBranchParams

type ListBranchRevenueByBranchParams struct {
	DateFrom           time.Time     `json:"date_from"`
	DateTo             time.Time     `json:"date_to"`
	CategoryValueID    sql.NullInt64 `json:"category_value_id"`
	SubcategoryValueID sql.NullInt64 `json:"subcategory_value_id"`
	BrandValueID       sql.NullInt64 `json:"brand_value_id"`
}

type ListBranchRevenueByBranchRow

type ListBranchRevenueByBranchRow struct {
	BranchID   int64  `json:"branch_id"`
	BranchName string `json:"branch_name"`
	Quantity   int64  `json:"quantity"`
	Revenue    int64  `json:"revenue"`
}

type ListBranchSalesDaysRangeParams

type ListBranchSalesDaysRangeParams struct {
	FromDay  time.Time     `json:"from_day"`
	ToDay    time.Time     `json:"to_day"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListBranchSalesDaysRangeRow

type ListBranchSalesDaysRangeRow struct {
	BranchID     int64     `json:"branch_id"`
	Day          time.Time `json:"day"`
	InvoiceCount int64     `json:"invoice_count"`
	Revenue      int64     `json:"revenue"`
}

type ListBranchShiftHistoryForSyncParams

type ListBranchShiftHistoryForSyncParams struct {
	RegisterID      int64     `json:"register_id"`
	AfterReceivedAt time.Time `json:"after_received_at"`
	AfterID         int64     `json:"after_id"`
	RowLimit        int32     `json:"row_limit"`
}

type ListBranchShiftReceiptImagesParams

type ListBranchShiftReceiptImagesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListBranchShiftReceiptImagesRow

type ListBranchShiftReceiptImagesRow struct {
	ID                int64        `json:"id"`
	BranchShiftID     int64        `json:"branch_shift_id"`
	FilePath          string       `json:"file_path"`
	ContentType       string       `json:"content_type"`
	SizeBytes         int64        `json:"size_bytes"`
	CreatedAt         time.Time    `json:"created_at"`
	Rotation          int16        `json:"rotation"`
	ShiftLocalID      int64        `json:"shift_local_id"`
	ClosingPersonName string       `json:"closing_person_name"`
	ShiftClosedAt     sql.NullTime `json:"shift_closed_at"`
	ShiftBranchID     int64        `json:"shift_branch_id"`
	BranchName        string       `json:"branch_name"`
}

type ListBranchShiftsParams

type ListBranchShiftsParams struct {
	Limit    int32         `json:"limit"`
	Offset   int32         `json:"offset"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListBranchShiftsRow

type ListBranchShiftsRow struct {
	ID                int64        `json:"id"`
	BranchID          int64        `json:"branch_id"`
	ClientRef         string       `json:"client_ref"`
	BranchShiftID     int64        `json:"branch_shift_id"`
	OpenedAt          sql.NullTime `json:"opened_at"`
	ClosedAt          sql.NullTime `json:"closed_at"`
	ClosingPersonName string       `json:"closing_person_name"`
	OpeningFloatUsd   int64        `json:"opening_float_usd"`
	OpeningFloatLbp   int64        `json:"opening_float_lbp"`
	ExpectedUsd       int64        `json:"expected_usd"`
	ExpectedLbp       int64        `json:"expected_lbp"`
	ExpectedVisa      int64        `json:"expected_visa"`
	ExpectedWhish     int64        `json:"expected_whish"`
	CountedUsd        int64        `json:"counted_usd"`
	CountedLbp        int64        `json:"counted_lbp"`
	CountedVisa       int64        `json:"counted_visa"`
	CountedWhish      int64        `json:"counted_whish"`
	VarianceUsd       int64        `json:"variance_usd"`
	VarianceLbp       int64        `json:"variance_lbp"`
	VarianceVisa      int64        `json:"variance_visa"`
	VarianceWhish     int64        `json:"variance_whish"`
	OccurredAt        time.Time    `json:"occurred_at"`
	ReceivedAt        time.Time    `json:"received_at"`
	RegisterID        int64        `json:"register_id"`
	LbpRate           int64        `json:"lbp_rate"`
	HasReceiptImage   bool         `json:"has_receipt_image"`
}

type ListBranchStockForSyncParams

type ListBranchStockForSyncParams struct {
	BranchID       int64     `json:"branch_id"`
	AfterUpdatedAt time.Time `json:"after_updated_at"`
	AfterID        int64     `json:"after_id"`
	RowLimit       int32     `json:"row_limit"`
}

type ListBranchStockForSyncRow

type ListBranchStockForSyncRow struct {
	BranchCode string        `json:"branch_code"`
	VariantUid uuid.UUID     `json:"variant_uid"`
	Barcode    string        `json:"barcode"`
	Quantity   int64         `json:"quantity"`
	Price      int64         `json:"price"`
	UpdatedAt  time.Time     `json:"updated_at"`
	ID         sql.NullInt64 `json:"id"`
}

type ListBranchSyncConflictsPageParams

type ListBranchSyncConflictsPageParams struct {
	Column1 int64  `json:"column_1"`
	Column2 string `json:"column_2"`
	Column3 string `json:"column_3"`
	Column4 string `json:"column_4"`
	Column5 string `json:"column_5"`
	Column6 string `json:"column_6"`
	Limit   int32  `json:"limit"`
	Offset  int32  `json:"offset"`
}

type ListBranchSyncConflictsPageRow

type ListBranchSyncConflictsPageRow struct {
	ID              int64                 `json:"id"`
	BranchID        int64                 `json:"branch_id"`
	Entity          string                `json:"entity"`
	Ref             string                `json:"ref"`
	Kind            string                `json:"kind"`
	BranchPayload   json.RawMessage       `json:"branch_payload"`
	CentralClientID sql.NullInt64         `json:"central_client_id"`
	Status          string                `json:"status"`
	Resolution      pqtype.NullRawMessage `json:"resolution"`
	ResolvedBy      sql.NullInt64         `json:"resolved_by"`
	CreatedAt       time.Time             `json:"created_at"`
	UpdatedAt       time.Time             `json:"updated_at"`
	CentralName     sql.NullString        `json:"central_name"`
	CentralPhone    sql.NullString        `json:"central_phone"`
}

type ListBranchTargetsProgressParams

type ListBranchTargetsProgressParams struct {
	BranchID int64     `json:"branch_id"`
	Since    time.Time `json:"since"`
}

type ListBranchTargetsProgressRow

type ListBranchTargetsProgressRow struct {
	ID       int64 `json:"id"`
	Achieved int64 `json:"achieved"`
}

type ListBranchTargetsUpdatedSinceParams

type ListBranchTargetsUpdatedSinceParams struct {
	BranchID  int64     `json:"branch_id"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ListBranchTransfersUpdatedSinceParams

type ListBranchTransfersUpdatedSinceParams struct {
	BranchID  sql.NullInt64 `json:"branch_id"`
	UpdatedAt time.Time     `json:"updated_at"`
}

type ListBranchUsersUpdatedSinceParams

type ListBranchUsersUpdatedSinceParams struct {
	BranchID  int64     `json:"branch_id"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ListBranchVisitorDaysParams

type ListBranchVisitorDaysParams struct {
	Limit    int32         `json:"limit"`
	Offset   int32         `json:"offset"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListBranchVisitorDaysRangeParams

type ListBranchVisitorDaysRangeParams struct {
	FromDay  string        `json:"from_day"`
	ToDay    string        `json:"to_day"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListBranchVisitorDaysRangeRow

type ListBranchVisitorDaysRangeRow struct {
	BranchID int64  `json:"branch_id"`
	Day      string `json:"day"`
	InCount  int64  `json:"in_count"`
	OutCount int64  `json:"out_count"`
}

type ListBranchVisitorDaysRow

type ListBranchVisitorDaysRow struct {
	BranchID int64  `json:"branch_id"`
	Day      string `json:"day"`
	InCount  int64  `json:"in_count"`
	OutCount int64  `json:"out_count"`
}

type ListBranchWhatsAppNumbersRow added in v1.1.0

type ListBranchWhatsAppNumbersRow struct {
	ID                   int64          `json:"id"`
	Name                 string         `json:"name"`
	WhatsappNumberID     sql.NullInt64  `json:"whatsapp_number_id"`
	WhatsappEnabled      bool           `json:"whatsapp_enabled"`
	WhatsappHiddenFields sql.NullString `json:"whatsapp_hidden_fields"`
}

type ListBranchesForDiscountListRow

type ListBranchesForDiscountListRow struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
	Code string `json:"code"`
}

type ListBranchesForPriceListRow

type ListBranchesForPriceListRow struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
	Code string `json:"code"`
}

type ListBranchesForSyncRow

type ListBranchesForSyncRow struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	Code     string `json:"code"`
	IsActive bool   `json:"is_active"`
}

type ListCashboxAccountOverridesForBranchRow

type ListCashboxAccountOverridesForBranchRow struct {
	ID                   int64          `json:"id"`
	Name                 string         `json:"name"`
	CurrencyCode         string         `json:"currency_code"`
	SortOrder            int32          `json:"sort_order"`
	Color                string         `json:"color"`
	IsEnabled            bool           `json:"is_enabled"`
	OverrideSortOrder    sql.NullInt32  `json:"override_sort_order"`
	OverrideColor        sql.NullString `json:"override_color"`
	OverrideCurrencyCode sql.NullString `json:"override_currency_code"`
}

type ListCashboxAccountsForBranchSyncRow

type ListCashboxAccountsForBranchSyncRow struct {
	ID           int64     `json:"id"`
	Name         string    `json:"name"`
	CurrencyCode string    `json:"currency_code"`
	SortOrder    int32     `json:"sort_order"`
	Color        string    `json:"color"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type ListCashboxAccountsParams

type ListCashboxAccountsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListCashboxesParams

type ListCashboxesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListClientPhoneCountriesRow added in v1.1.3

type ListClientPhoneCountriesRow struct {
	PhoneCountry string `json:"phone_country"`
	ClientCount  int64  `json:"client_count"`
}

type ListClientSyncIDsParams

type ListClientSyncIDsParams struct {
	AfterUid uuid.UUID `json:"after_uid"`
	RowLimit int32     `json:"row_limit"`
}

type ListClientSyncIDsRow

type ListClientSyncIDsRow struct {
	Uid       uuid.UUID `json:"uid"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ListClientsByInvoiceCountCachedParams added in v1.1.6

type ListClientsByInvoiceCountCachedParams struct {
	Limit        int32          `json:"limit"`
	Offset       int32          `json:"offset"`
	ClientType   sql.NullString `json:"client_type"`
	Search       sql.NullString `json:"search"`
	PhoneValid   sql.NullBool   `json:"phone_valid"`
	PhoneCountry sql.NullString `json:"phone_country"`
}

type ListClientsByInvoiceCountCachedRow added in v1.1.6

type ListClientsByInvoiceCountCachedRow struct {
	ID                 int64         `json:"id"`
	Name               string        `json:"name"`
	Phone              string        `json:"phone"`
	TotalLoyaltyPoints int64         `json:"total_loyalty_points"`
	ValidLoyaltyPoints int64         `json:"valid_loyalty_points"`
	CreatedAt          time.Time     `json:"created_at"`
	UpdatedAt          time.Time     `json:"updated_at"`
	ClientType         string        `json:"client_type"`
	Uid                uuid.UUID     `json:"uid"`
	IsActive           bool          `json:"is_active"`
	BranchID           sql.NullInt64 `json:"branch_id"`
	PhoneValid         bool          `json:"phone_valid"`
	PhoneCountry       string        `json:"phone_country"`
	TotalSpent         int64         `json:"total_spent"`
	InvoiceCount       int64         `json:"invoice_count"`
	ItemCount          int64         `json:"item_count"`
}

type ListClientsByItemCountCachedParams added in v1.1.6

type ListClientsByItemCountCachedParams struct {
	Limit        int32          `json:"limit"`
	Offset       int32          `json:"offset"`
	ClientType   sql.NullString `json:"client_type"`
	Search       sql.NullString `json:"search"`
	PhoneValid   sql.NullBool   `json:"phone_valid"`
	PhoneCountry sql.NullString `json:"phone_country"`
}

type ListClientsByItemCountCachedRow added in v1.1.6

type ListClientsByItemCountCachedRow struct {
	ID                 int64         `json:"id"`
	Name               string        `json:"name"`
	Phone              string        `json:"phone"`
	TotalLoyaltyPoints int64         `json:"total_loyalty_points"`
	ValidLoyaltyPoints int64         `json:"valid_loyalty_points"`
	CreatedAt          time.Time     `json:"created_at"`
	UpdatedAt          time.Time     `json:"updated_at"`
	ClientType         string        `json:"client_type"`
	Uid                uuid.UUID     `json:"uid"`
	IsActive           bool          `json:"is_active"`
	BranchID           sql.NullInt64 `json:"branch_id"`
	PhoneValid         bool          `json:"phone_valid"`
	PhoneCountry       string        `json:"phone_country"`
	TotalSpent         int64         `json:"total_spent"`
	InvoiceCount       int64         `json:"invoice_count"`
	ItemCount          int64         `json:"item_count"`
}

type ListClientsBySpendingCachedParams added in v1.1.6

type ListClientsBySpendingCachedParams struct {
	Limit        int32          `json:"limit"`
	Offset       int32          `json:"offset"`
	ClientType   sql.NullString `json:"client_type"`
	Search       sql.NullString `json:"search"`
	PhoneValid   sql.NullBool   `json:"phone_valid"`
	PhoneCountry sql.NullString `json:"phone_country"`
}

type ListClientsBySpendingCachedRow added in v1.1.6

type ListClientsBySpendingCachedRow struct {
	ID                 int64         `json:"id"`
	Name               string        `json:"name"`
	Phone              string        `json:"phone"`
	TotalLoyaltyPoints int64         `json:"total_loyalty_points"`
	ValidLoyaltyPoints int64         `json:"valid_loyalty_points"`
	CreatedAt          time.Time     `json:"created_at"`
	UpdatedAt          time.Time     `json:"updated_at"`
	ClientType         string        `json:"client_type"`
	Uid                uuid.UUID     `json:"uid"`
	IsActive           bool          `json:"is_active"`
	BranchID           sql.NullInt64 `json:"branch_id"`
	PhoneValid         bool          `json:"phone_valid"`
	PhoneCountry       string        `json:"phone_country"`
	TotalSpent         int64         `json:"total_spent"`
	InvoiceCount       int64         `json:"invoice_count"`
	ItemCount          int64         `json:"item_count"`
}

type ListClientsBySpendingParams

type ListClientsBySpendingParams struct {
	Limit        int32          `json:"limit"`
	Offset       int32          `json:"offset"`
	SortBy       string         `json:"sort_by"`
	Visit        string         `json:"visit"`
	BranchIds    []int64        `json:"branch_ids"`
	DateFrom     sql.NullTime   `json:"date_from"`
	DateTo       sql.NullTime   `json:"date_to"`
	ClientType   sql.NullString `json:"client_type"`
	Search       sql.NullString `json:"search"`
	PhoneValid   sql.NullBool   `json:"phone_valid"`
	PhoneCountry sql.NullString `json:"phone_country"`
}

type ListClientsBySpendingRow

type ListClientsBySpendingRow struct {
	ID                 int64         `json:"id"`
	Name               string        `json:"name"`
	Phone              string        `json:"phone"`
	TotalLoyaltyPoints int64         `json:"total_loyalty_points"`
	ValidLoyaltyPoints int64         `json:"valid_loyalty_points"`
	CreatedAt          time.Time     `json:"created_at"`
	UpdatedAt          time.Time     `json:"updated_at"`
	ClientType         string        `json:"client_type"`
	Uid                uuid.UUID     `json:"uid"`
	IsActive           bool          `json:"is_active"`
	BranchID           sql.NullInt64 `json:"branch_id"`
	PhoneValid         bool          `json:"phone_valid"`
	PhoneCountry       string        `json:"phone_country"`
	TotalSpent         int64         `json:"total_spent"`
	InvoiceCount       int64         `json:"invoice_count"`
	ItemCount          int64         `json:"item_count"`
}

type ListClientsForExportParams added in v1.1.1

type ListClientsForExportParams struct {
	BranchIds       []int64        `json:"branch_ids"`
	DateFrom        sql.NullTime   `json:"date_from"`
	DateTo          sql.NullTime   `json:"date_to"`
	IncludeExcluded bool           `json:"include_excluded"`
	ClientType      sql.NullString `json:"client_type"`
}

type ListClientsForExportRow added in v1.1.1

type ListClientsForExportRow struct {
	ID                 int64     `json:"id"`
	Name               string    `json:"name"`
	Phone              string    `json:"phone"`
	ClientType         string    `json:"client_type"`
	IsActive           bool      `json:"is_active"`
	CreatedAt          time.Time `json:"created_at"`
	ValidLoyaltyPoints int64     `json:"valid_loyalty_points"`
	BranchID           int64     `json:"branch_id"`
	TotalSpent         int64     `json:"total_spent"`
	InvoiceCount       int64     `json:"invoice_count"`
	LastVisit          time.Time `json:"last_visit"`
}

type ListClientsMissingPhoneCountryRow added in v1.1.6

type ListClientsMissingPhoneCountryRow struct {
	ID         int64  `json:"id"`
	Phone      string `json:"phone"`
	PhoneValid bool   `json:"phone_valid"`
}

type ListClientsParams

type ListClientsParams struct {
	Limit      int32          `json:"limit"`
	Offset     int32          `json:"offset"`
	ClientType sql.NullString `json:"client_type"`
}

type ListClientsUpdatedSincePagedParams

type ListClientsUpdatedSincePagedParams struct {
	AfterUpdatedAt time.Time `json:"after_updated_at"`
	AfterID        int64     `json:"after_id"`
	RowLimit       int32     `json:"row_limit"`
}

type ListClientsWithLoyaltyParams

type ListClientsWithLoyaltyParams struct {
	Limit      int32          `json:"limit"`
	Offset     int32          `json:"offset"`
	ClientType sql.NullString `json:"client_type"`
}

type ListClientsWithLoyaltyRow

type ListClientsWithLoyaltyRow struct {
	ID                  int64         `json:"id"`
	Name                string        `json:"name"`
	Phone               string        `json:"phone"`
	TotalLoyaltyPoints  int64         `json:"total_loyalty_points"`
	ValidLoyaltyPoints  int64         `json:"valid_loyalty_points"`
	CreatedAt           time.Time     `json:"created_at"`
	UpdatedAt           time.Time     `json:"updated_at"`
	ClientType          string        `json:"client_type"`
	Uid                 uuid.UUID     `json:"uid"`
	IsActive            bool          `json:"is_active"`
	BranchID            sql.NullInt64 `json:"branch_id"`
	PhoneValid          bool          `json:"phone_valid"`
	PhoneCountry        string        `json:"phone_country"`
	BranchLoyaltyPoints int64         `json:"branch_loyalty_points"`
}

type ListColorsPageParams

type ListColorsPageParams struct {
	Search     string `json:"search"`
	SortBy     string `json:"sort_by"`
	SortOrder  string `json:"sort_order"`
	PageOffset int32  `json:"page_offset"`
	PageSize   int32  `json:"page_size"`
}

type ListCouponListsRow

type ListCouponListsRow struct {
	ID             int64     `json:"id"`
	Name           string    `json:"name"`
	CouponTypeID   int64     `json:"coupon_type_id"`
	IsActive       bool      `json:"is_active"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	CouponTypeName string    `json:"coupon_type_name"`
	CouponCount    int64     `json:"coupon_count"`
	RedeemedCount  int64     `json:"redeemed_count"`
}

type ListCouponsParams

type ListCouponsParams struct {
	Search     string           `json:"search"`
	Status     NullCouponStatus `json:"status"`
	CategoryID sql.NullInt64    `json:"category_id"`
	ListID     sql.NullInt64    `json:"list_id"`
	PageOffset int32            `json:"page_offset"`
	PageSize   int32            `json:"page_size"`
}

type ListCouponsRow

type ListCouponsRow struct {
	Code               string         `json:"code"`
	Status             CouponStatus   `json:"status"`
	ClientID           sql.NullInt64  `json:"client_id"`
	ValidUntil         sql.NullTime   `json:"valid_until"`
	CreatedAt          time.Time      `json:"created_at"`
	CategoryID         sql.NullInt64  `json:"category_id"`
	TypeID             sql.NullInt64  `json:"type_id"`
	ListID             sql.NullInt64  `json:"list_id"`
	ValueCents         int64          `json:"value_cents"`
	RedeemedBranchID   sql.NullInt64  `json:"redeemed_branch_id"`
	RedeemedInvoiceRef sql.NullString `json:"redeemed_invoice_ref"`
	RedeemedAt         sql.NullTime   `json:"redeemed_at"`
	UpdatedAt          time.Time      `json:"updated_at"`
	TypeName           sql.NullString `json:"type_name"`
}

type ListCurrenciesParams

type ListCurrenciesParams struct {
	PageOffset int32 `json:"page_offset"`
	PageSize   int32 `json:"page_size"`
}

type ListDailyIncomeParams

type ListDailyIncomeParams struct {
	Year        int32         `json:"year"`
	BranchID    sql.NullInt64 `json:"branch_id"`
	BranchIds   []int64       `json:"branch_ids"`
	RegisterIds []int64       `json:"register_ids"`
}

type ListDailyIncomeRow

type ListDailyIncomeRow struct {
	Day   time.Time `json:"day"`
	Total int64     `json:"total"`
}

type ListDayBranchExpensesParams

type ListDayBranchExpensesParams struct {
	Day      time.Time     `json:"day"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListDayBranchExpensesRow

type ListDayBranchExpensesRow struct {
	ID           int64     `json:"id"`
	BranchID     int64     `json:"branch_id"`
	BranchName   string    `json:"branch_name"`
	Description  string    `json:"description"`
	Amount       int64     `json:"amount"`
	CurrencyCode string    `json:"currency_code"`
	OccurredAt   time.Time `json:"occurred_at"`
	CategoryName string    `json:"category_name"`
}

type ListDayBranchShiftsParams

type ListDayBranchShiftsParams struct {
	Day      time.Time     `json:"day"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListDayBranchShiftsRow

type ListDayBranchShiftsRow struct {
	ID                int64        `json:"id"`
	BranchID          int64        `json:"branch_id"`
	BranchName        string       `json:"branch_name"`
	RegisterID        int64        `json:"register_id"`
	ClosingPersonName string       `json:"closing_person_name"`
	OpenedAt          sql.NullTime `json:"opened_at"`
	ClosedAt          sql.NullTime `json:"closed_at"`
	ExpectedUsd       int64        `json:"expected_usd"`
	CountedUsd        int64        `json:"counted_usd"`
	VarianceUsd       int64        `json:"variance_usd"`
	VarianceLbp       int64        `json:"variance_lbp"`
	VarianceVisa      int64        `json:"variance_visa"`
	VarianceWhish     int64        `json:"variance_whish"`
}

type ListDayInvoicesParams

type ListDayInvoicesParams struct {
	Day      time.Time     `json:"day"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListDayInvoicesRow

type ListDayInvoicesRow struct {
	ID                int64        `json:"id"`
	BranchID          int64        `json:"branch_id"`
	BranchName        string       `json:"branch_name"`
	Kind              string       `json:"kind"`
	BranchInvoiceCode string       `json:"branch_invoice_code"`
	GrandTotal        int64        `json:"grand_total"`
	Discount          int16        `json:"discount"`
	SalespersonName   string       `json:"salesperson_name"`
	OccurredAt        time.Time    `json:"occurred_at"`
	CancelledAt       sql.NullTime `json:"cancelled_at"`
	ItemCount         int64        `json:"item_count"`
}

type ListDayPaymentsByAccountParams

type ListDayPaymentsByAccountParams struct {
	Day      time.Time     `json:"day"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListDayPaymentsByAccountRow

type ListDayPaymentsByAccountRow struct {
	AccountName  string `json:"account_name"`
	Total        int64  `json:"total"`
	InvoiceCount int64  `json:"invoice_count"`
}

type ListDaySalesByBranchParams

type ListDaySalesByBranchParams struct {
	Day      time.Time     `json:"day"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListDaySalesByBranchRow

type ListDaySalesByBranchRow struct {
	BranchID    int64  `json:"branch_id"`
	BranchName  string `json:"branch_name"`
	SalesCount  int64  `json:"sales_count"`
	SalesTotal  int64  `json:"sales_total"`
	ReturnCount int64  `json:"return_count"`
	ReturnTotal int64  `json:"return_total"`
	NetTotal    int64  `json:"net_total"`
	ItemsSold   int64  `json:"items_sold"`
	ClientCount int64  `json:"client_count"`
}

type ListDaySalesByHourParams

type ListDaySalesByHourParams struct {
	Day      time.Time     `json:"day"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListDaySalesByHourRow

type ListDaySalesByHourRow struct {
	Hour       int32 `json:"hour"`
	SalesCount int64 `json:"sales_count"`
	NetTotal   int64 `json:"net_total"`
}

type ListDaySalesBySalespersonParams

type ListDaySalesBySalespersonParams struct {
	Day      time.Time     `json:"day"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListDaySalesBySalespersonRow

type ListDaySalesBySalespersonRow struct {
	SalespersonName string `json:"salesperson_name"`
	SalesCount      int64  `json:"sales_count"`
	NetTotal        int64  `json:"net_total"`
}

type ListDayTopProductsParams

type ListDayTopProductsParams struct {
	Day      time.Time     `json:"day"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListDayTopProductsRow

type ListDayTopProductsRow struct {
	ProductID   int64  `json:"product_id"`
	ProductName string `json:"product_name"`
	ProductCode string `json:"product_code"`
	Quantity    int64  `json:"quantity"`
	Revenue     int64  `json:"revenue"`
}

type ListDayVisitorsByHourParams

type ListDayVisitorsByHourParams struct {
	Day      string        `json:"day"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListDayVisitorsByHourRow

type ListDayVisitorsByHourRow struct {
	Hour     int32 `json:"hour"`
	InCount  int64 `json:"in_count"`
	OutCount int64 `json:"out_count"`
}

type ListDealsRow added in v1.1.6

type ListDealsRow struct {
	ID                     int64     `json:"id"`
	Uid                    uuid.UUID `json:"uid"`
	Name                   string    `json:"name"`
	Kind                   string    `json:"kind"`
	BuyQty                 int32     `json:"buy_qty"`
	GetQty                 int32     `json:"get_qty"`
	Percent                int16     `json:"percent"`
	BundlePrice            int64     `json:"bundle_price"`
	CreatedAt              time.Time `json:"created_at"`
	UpdatedAt              time.Time `json:"updated_at"`
	FallbackPercent        int16     `json:"fallback_percent"`
	FallbackOnlyWithoutSet bool      `json:"fallback_only_without_set"`
	Variants               int64     `json:"variants"`
	Rules                  int64     `json:"rules"`
}

type ListDeletableUnknownItemImagesRow added in v1.1.1

type ListDeletableUnknownItemImagesRow struct {
	ID       int64  `json:"id"`
	FilePath string `json:"file_path"`
}

type ListDiscountListItemsForSyncRow

type ListDiscountListItemsForSyncRow struct {
	ProductVariantUid uuid.UUID     `json:"product_variant_uid"`
	Discount          int16         `json:"discount"`
	DealUid           uuid.NullUUID `json:"deal_uid"`
}

type ListDiscountListItemsWithProductParams

type ListDiscountListItemsWithProductParams struct {
	Search         string `json:"search"`
	PageOffset     int32  `json:"page_offset"`
	PageSize       int32  `json:"page_size"`
	DiscountListID int64  `json:"discount_list_id"`
}

type ListDiscountListItemsWithProductRow

type ListDiscountListItemsWithProductRow struct {
	DiscountListID    int64     `json:"discount_list_id"`
	ProductVariantID  int64     `json:"product_variant_id"`
	Discount          int16     `json:"discount"`
	SaleOptionID      int64     `json:"sale_option_id"`
	SaleOption        string    `json:"sale_option"`
	RowKey            string    `json:"row_key"`
	ProductVariantUid uuid.UUID `json:"product_variant_uid"`
	Barcode           string    `json:"barcode"`
	ProductCode       string    `json:"product_code"`
	ProductName       string    `json:"product_name"`
	ColorName         string    `json:"color_name"`
	SizeName          string    `json:"size_name"`
	RuleName          string    `json:"rule_name"`
	FromRule          bool      `json:"from_rule"`
	DealID            int64     `json:"deal_id"`
	DealName          string    `json:"deal_name"`
}

type ListDiscountListOptionItemsForSyncRow added in v1.1.6

type ListDiscountListOptionItemsForSyncRow struct {
	ProductVariantUid uuid.UUID `json:"product_variant_uid"`
	SaleOption        string    `json:"sale_option"`
	Discount          int16     `json:"discount"`
}

type ListDiscountListRuleOptionsRow added in v1.1.6

type ListDiscountListRuleOptionsRow struct {
	RuleID       int64  `json:"rule_id"`
	SaleOptionID int64  `json:"sale_option_id"`
	SaleOption   string `json:"sale_option"`
	Discount     int16  `json:"discount"`
}

type ListDiscountListRulesRow added in v1.1.6

type ListDiscountListRulesRow struct {
	ID                 int64         `json:"id"`
	DiscountListID     int64         `json:"discount_list_id"`
	Position           int32         `json:"position"`
	Name               string        `json:"name"`
	CodePrefixes       []string      `json:"code_prefixes"`
	ExceptCodePrefixes []string      `json:"except_code_prefixes"`
	Kinds              []string      `json:"kinds"`
	Categories         []string      `json:"categories"`
	SubCategories      []string      `json:"sub_categories"`
	Origins            []string      `json:"origins"`
	Brands             []string      `json:"brands"`
	Discount           int16         `json:"discount"`
	CreatedAt          time.Time     `json:"created_at"`
	DealID             sql.NullInt64 `json:"deal_id"`
	IsEnabled          bool          `json:"is_enabled"`
	GroupID            int64         `json:"group_id"`
	MaxPrice           sql.NullInt64 `json:"max_price"`
	Variants           int64         `json:"variants"`
}

type ListDiscountListsForBranchSyncParams

type ListDiscountListsForBranchSyncParams struct {
	BranchID  int64     `json:"branch_id"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ListDiscountListsParams

type ListDiscountListsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListDiscountListsRemovedFromBranchParams added in v1.1.7

type ListDiscountListsRemovedFromBranchParams struct {
	BranchID int64     `json:"branch_id"`
	Since    time.Time `json:"since"`
}

type ListDiscountListsRemovedFromBranchRow added in v1.1.7

type ListDiscountListsRemovedFromBranchRow struct {
	Uid       uuid.UUID `json:"uid"`
	Name      string    `json:"name"`
	RemovedAt time.Time `json:"removed_at"`
}

type ListEmailReportInvoicesParams added in v1.1.0

type ListEmailReportInvoicesParams struct {
	FromDay     time.Time     `json:"from_day"`
	ToDay       time.Time     `json:"to_day"`
	BranchID    sql.NullInt64 `json:"branch_id"`
	RegisterIds []int64       `json:"register_ids"`
}

type ListEmailReportInvoicesRow added in v1.1.0

type ListEmailReportInvoicesRow struct {
	ID                   int64         `json:"id"`
	Kind                 string        `json:"kind"`
	BranchInvoiceCode    string        `json:"branch_invoice_code"`
	GrandTotal           int64         `json:"grand_total"`
	Subtotal             int64         `json:"subtotal"`
	Discount             int16         `json:"discount"`
	SalespersonName      string        `json:"salesperson_name"`
	LocalAt              time.Time     `json:"local_at"`
	BranchName           string        `json:"branch_name"`
	RegisterCode         string        `json:"register_code"`
	CustomerName         string        `json:"customer_name"`
	CustomerPhone        string        `json:"customer_phone"`
	ExchangeRate         int64         `json:"exchange_rate"`
	RoundingMode         string        `json:"rounding_mode"`
	LbpUnitsPerUsdMicros int64         `json:"lbp_units_per_usd_micros"`
	LbpCashRoundingUnit  int64         `json:"lbp_cash_rounding_unit"`
	SoldLbpTotal         sql.NullInt64 `json:"sold_lbp_total"`
	SoldLbpRate          sql.NullInt64 `json:"sold_lbp_rate"`
	ItemCount            int64         `json:"item_count"`
	PaymentMethods       string        `json:"payment_methods"`
}

type ListEmailReportRecipientsRow added in v1.1.0

type ListEmailReportRecipientsRow struct {
	Address    string    `json:"address"`
	LastSentAt time.Time `json:"last_sent_at"`
}

type ListEmailReportRegistersRow added in v1.1.0

type ListEmailReportRegistersRow struct {
	ID         int64  `json:"id"`
	BranchID   int64  `json:"branch_id"`
	BranchName string `json:"branch_name"`
	Code       string `json:"code"`
	Name       string `json:"name"`
}

type ListEmailReportShiftInvoicesRow added in v1.1.0

type ListEmailReportShiftInvoicesRow struct {
	ID                   int64         `json:"id"`
	Kind                 string        `json:"kind"`
	BranchInvoiceCode    string        `json:"branch_invoice_code"`
	GrandTotal           int64         `json:"grand_total"`
	Subtotal             int64         `json:"subtotal"`
	Discount             int16         `json:"discount"`
	SalespersonName      string        `json:"salesperson_name"`
	LocalAt              time.Time     `json:"local_at"`
	BranchName           string        `json:"branch_name"`
	RegisterCode         string        `json:"register_code"`
	CustomerName         string        `json:"customer_name"`
	CustomerPhone        string        `json:"customer_phone"`
	ExchangeRate         int64         `json:"exchange_rate"`
	RoundingMode         string        `json:"rounding_mode"`
	LbpUnitsPerUsdMicros int64         `json:"lbp_units_per_usd_micros"`
	LbpCashRoundingUnit  int64         `json:"lbp_cash_rounding_unit"`
	SoldLbpTotal         sql.NullInt64 `json:"sold_lbp_total"`
	SoldLbpRate          sql.NullInt64 `json:"sold_lbp_rate"`
	ItemCount            int64         `json:"item_count"`
	PaymentMethods       string        `json:"payment_methods"`
}

type ListEmailReportShiftsParams added in v1.1.0

type ListEmailReportShiftsParams struct {
	FromDay  time.Time     `json:"from_day"`
	ToDay    time.Time     `json:"to_day"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type ListEmailReportShiftsRow added in v1.1.0

type ListEmailReportShiftsRow struct {
	ID                int64        `json:"id"`
	BranchID          int64        `json:"branch_id"`
	BranchName        string       `json:"branch_name"`
	RegisterCode      string       `json:"register_code"`
	ClosingPersonName string       `json:"closing_person_name"`
	OpenedAt          sql.NullTime `json:"opened_at"`
	ClosedAt          sql.NullTime `json:"closed_at"`
	OccurredAt        time.Time    `json:"occurred_at"`
}

type ListEmailReportsParams added in v1.1.0

type ListEmailReportsParams struct {
	Status     sql.NullString `json:"status"`
	PageOffset int32          `json:"page_offset"`
	PageSize   int32          `json:"page_size"`
}

type ListEmployeesParams

type ListEmployeesParams struct {
	Search     string        `json:"search"`
	BranchID   sql.NullInt64 `json:"branch_id"`
	PageOffset int32         `json:"page_offset"`
	PageSize   int32         `json:"page_size"`
}

type ListEntriesParams

type ListEntriesParams struct {
	InventoryID int64 `json:"inventory_id"`
	Limit       int32 `json:"limit"`
	Offset      int32 `json:"offset"`
}

type ListExpensesParams

type ListExpensesParams struct {
	Limit      int32          `json:"limit"`
	Offset     int32          `json:"offset"`
	CategoryID sql.NullInt64  `json:"category_id"`
	Search     sql.NullString `json:"search"`
}

type ListGooglePlaceSnapshotsParams added in v1.1.0

type ListGooglePlaceSnapshotsParams struct {
	PlaceID string    `json:"place_id"`
	FromAt  time.Time `json:"from_at"`
	ToAt    time.Time `json:"to_at"`
}

type ListGoogleReviewsParams added in v1.1.0

type ListGoogleReviewsParams struct {
	PlaceIds []string `json:"place_ids"`
	RowLimit int32    `json:"row_limit"`
}

type ListHomeActivityResolutionsParams added in v1.1.0

type ListHomeActivityResolutionsParams struct {
	Activity  string  `json:"activity"`
	SourceIds []int64 `json:"source_ids"`
}

type ListHomeActivityResolutionsRow added in v1.1.0

type ListHomeActivityResolutionsRow struct {
	SourceID   int64     `json:"source_id"`
	ResolvedBy string    `json:"resolved_by"`
	ResolvedAt time.Time `json:"resolved_at"`
}

type ListIgnoredLowStockProductsParams

type ListIgnoredLowStockProductsParams struct {
	Search     string `json:"search"`
	PageOffset int32  `json:"page_offset"`
	PageLimit  int32  `json:"page_limit"`
}

type ListIgnoredLowStockProductsRow

type ListIgnoredLowStockProductsRow struct {
	ID                 int64         `json:"id"`
	Code               string        `json:"code"`
	Name               string        `json:"name"`
	LowStockThreshold  sql.NullInt64 `json:"low_stock_threshold"`
	OnHand             int64         `json:"on_hand"`
	EffectiveThreshold int64         `json:"effective_threshold"`
}

type ListIncomingBranchTransfersUpdatedSinceParams

type ListIncomingBranchTransfersUpdatedSinceParams struct {
	ToInventoryID int64     `json:"to_inventory_id"`
	UpdatedAt     time.Time `json:"updated_at"`
}

type ListInventoriesParams

type ListInventoriesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListInventoryStockParams

type ListInventoryStockParams struct {
	InventoryID int64  `json:"inventory_id"`
	Search      string `json:"search"`
	PageOffset  int32  `json:"page_offset"`
	PageLimit   int32  `json:"page_limit"`
}

type ListInventoryStockRow

type ListInventoryStockRow struct {
	InventoryID int64         `json:"inventory_id"`
	VariantID   int64         `json:"variant_id"`
	Quantity    int64         `json:"quantity"`
	AvgCost     int64         `json:"avg_cost"`
	UpdatedAt   time.Time     `json:"updated_at"`
	Barcode     string        `json:"barcode"`
	Price       sql.NullInt64 `json:"price"`
	ProductID   int64         `json:"product_id"`
	ProductCode string        `json:"product_code"`
	ProductName string        `json:"product_name"`
	ColorName   string        `json:"color_name"`
	SizeName    string        `json:"size_name"`
}

type ListInvoiceDiscountsForBranchSyncParams added in v1.1.8

type ListInvoiceDiscountsForBranchSyncParams struct {
	BranchID int64     `json:"branch_id"`
	Since    time.Time `json:"since"`
}

type ListInvoiceDiscountsForBranchSyncRow added in v1.1.8

type ListInvoiceDiscountsForBranchSyncRow struct {
	Uid       uuid.UUID    `json:"uid"`
	Name      string       `json:"name"`
	MinTotal  int64        `json:"min_total"`
	Kind      string       `json:"kind"`
	Percent   int16        `json:"percent"`
	Amount    int64        `json:"amount"`
	ValidFrom sql.NullTime `json:"valid_from"`
	ValidTo   sql.NullTime `json:"valid_to"`
	UpdatedAt time.Time    `json:"updated_at"`
	Applies   bool         `json:"applies"`
}

type ListInvoicePaymentsByInvoiceRow

type ListInvoicePaymentsByInvoiceRow struct {
	ID               int64  `json:"id"`
	InvoiceID        int64  `json:"invoice_id"`
	CashboxAccountID int64  `json:"cashbox_account_id"`
	Amount           int64  `json:"amount"`
	AccountName      string `json:"account_name"`
}

type ListInvoiceProductsByInvoiceRow

type ListInvoiceProductsByInvoiceRow struct {
	InvoiceID      int64         `json:"invoice_id"`
	ProductID      int64         `json:"product_id"`
	UnitPrice      int64         `json:"unit_price"`
	LineTotal      int64         `json:"line_total"`
	Discount       int16         `json:"discount"`
	Quantity       int64         `json:"quantity"`
	VariantID      sql.NullInt64 `json:"variant_id"`
	UnitCost       int64         `json:"unit_cost"`
	ProductName    string        `json:"product_name"`
	ProductCode    string        `json:"product_code"`
	VariantBarcode string        `json:"variant_barcode"`
	ColorName      string        `json:"color_name"`
	SizeName       string        `json:"size_name"`
}

type ListInvoicesPageParams

type ListInvoicesPageParams struct {
	Search     string `json:"search"`
	PageOffset int32  `json:"page_offset"`
	PageSize   int32  `json:"page_size"`
}

type ListInvoicesParams

type ListInvoicesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListLatestAdditionsParams

type ListLatestAdditionsParams struct {
	IncludeAccounting bool           `json:"include_accounting"`
	IncludeHr         bool           `json:"include_hr"`
	IncludeInventory  bool           `json:"include_inventory"`
	BeforeAt          sql.NullTime   `json:"before_at"`
	BeforeKind        sql.NullString `json:"before_kind"`
	BeforeID          sql.NullInt64  `json:"before_id"`
	PageSize          int32          `json:"page_size"`
}

type ListLatestAdditionsRow

type ListLatestAdditionsRow struct {
	Kind         string    `json:"kind"`
	ID           int64     `json:"id"`
	AddedAt      time.Time `json:"added_at"`
	Title        string    `json:"title"`
	Subtitle     string    `json:"subtitle"`
	Amount       int64     `json:"amount"`
	CurrencyCode string    `json:"currency_code"`
	HasImage     bool      `json:"has_image"`
	RefID        int64     `json:"ref_id"`
	BranchID     int64     `json:"branch_id"`
	RefDay       string    `json:"ref_day"`
}

type ListLoanPaymentsParams

type ListLoanPaymentsParams struct {
	Limit      int32          `json:"limit"`
	Offset     int32          `json:"offset"`
	LoanID     sql.NullInt64  `json:"loan_id"`
	CategoryID sql.NullInt64  `json:"category_id"`
	Search     sql.NullString `json:"search"`
}

type ListLoansParams

type ListLoansParams struct {
	Limit      int32          `json:"limit"`
	Offset     int32          `json:"offset"`
	BranchID   sql.NullInt64  `json:"branch_id"`
	Origin     sql.NullString `json:"origin"`
	CategoryID sql.NullInt64  `json:"category_id"`
	Search     sql.NullString `json:"search"`
	Status     sql.NullString `json:"status"`
}

type ListLoansRow

type ListLoansRow struct {
	ID                       int64          `json:"id"`
	Origin                   string         `json:"origin"`
	Description              string         `json:"description"`
	CategoryID               int64          `json:"category_id"`
	Amount                   int64          `json:"amount"`
	CurrencyCode             string         `json:"currency_code"`
	BranchID                 sql.NullInt64  `json:"branch_id"`
	ClientRef                sql.NullString `json:"client_ref"`
	BranchCashboxAccountID   sql.NullInt64  `json:"branch_cashbox_account_id"`
	BranchShiftID            sql.NullInt64  `json:"branch_shift_id"`
	OccurredAt               time.Time      `json:"occurred_at"`
	ReceivedAt               time.Time      `json:"received_at"`
	BranchCashboxAccountName sql.NullString `json:"branch_cashbox_account_name"`
	CancelledAt              sql.NullTime   `json:"cancelled_at"`
	PaidAmount               int64          `json:"paid_amount"`
	Status                   string         `json:"status"`
}

type ListLowStockProductsParams

type ListLowStockProductsParams struct {
	Status     sql.NullString `json:"status"`
	Search     string         `json:"search"`
	PageOffset int32          `json:"page_offset"`
	PageLimit  int32          `json:"page_limit"`
}

type ListLowStockProductsRow

type ListLowStockProductsRow struct {
	ID                 int64         `json:"id"`
	Code               string        `json:"code"`
	Name               string        `json:"name"`
	LowStockThreshold  sql.NullInt64 `json:"low_stock_threshold"`
	OnHand             int64         `json:"on_hand"`
	EffectiveThreshold int64         `json:"effective_threshold"`
}

type ListPriceListItemsForSyncRow

type ListPriceListItemsForSyncRow struct {
	ProductVariantUid uuid.UUID `json:"product_variant_uid"`
	Price             int64     `json:"price"`
}

type ListPriceListItemsWithProductParams

type ListPriceListItemsWithProductParams struct {
	PriceListID int64  `json:"price_list_id"`
	Search      string `json:"search"`
	PageOffset  int32  `json:"page_offset"`
	PageSize    int32  `json:"page_size"`
}

type ListPriceListItemsWithProductRow

type ListPriceListItemsWithProductRow struct {
	PriceListID       int64     `json:"price_list_id"`
	ProductVariantID  int64     `json:"product_variant_id"`
	Price             int64     `json:"price"`
	ProductVariantUid uuid.UUID `json:"product_variant_uid"`
	Barcode           string    `json:"barcode"`
	ProductCode       string    `json:"product_code"`
	ProductName       string    `json:"product_name"`
	ColorName         string    `json:"color_name"`
	SizeName          string    `json:"size_name"`
}

type ListPriceListsForBranchSyncParams

type ListPriceListsForBranchSyncParams struct {
	BranchID  int64     `json:"branch_id"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ListPriceListsParams

type ListPriceListsParams struct {
	Search     string `json:"search"`
	PageOffset int32  `json:"page_offset"`
	PageSize   int32  `json:"page_size"`
}

type ListPriceListsRemovedFromBranchParams added in v1.1.7

type ListPriceListsRemovedFromBranchParams struct {
	BranchID int64     `json:"branch_id"`
	Since    time.Time `json:"since"`
}

type ListPriceListsRemovedFromBranchRow added in v1.1.7

type ListPriceListsRemovedFromBranchRow struct {
	Uid       uuid.UUID `json:"uid"`
	Name      string    `json:"name"`
	RemovedAt time.Time `json:"removed_at"`
}

type ListProductAttributesParams

type ListProductAttributesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListProductRevenueDailyParams

type ListProductRevenueDailyParams struct {
	DateFrom           time.Time     `json:"date_from"`
	DateTo             time.Time     `json:"date_to"`
	CategoryValueID    sql.NullInt64 `json:"category_value_id"`
	SubcategoryValueID sql.NullInt64 `json:"subcategory_value_id"`
	BrandValueID       sql.NullInt64 `json:"brand_value_id"`
}

type ListProductRevenueDailyRow

type ListProductRevenueDailyRow struct {
	Day      time.Time `json:"day"`
	Revenue  int64     `json:"revenue"`
	Quantity int64     `json:"quantity"`
}

type ListProductRevenueParams

type ListProductRevenueParams struct {
	DateFrom           time.Time     `json:"date_from"`
	DateTo             time.Time     `json:"date_to"`
	CategoryValueID    sql.NullInt64 `json:"category_value_id"`
	SubcategoryValueID sql.NullInt64 `json:"subcategory_value_id"`
	BrandValueID       sql.NullInt64 `json:"brand_value_id"`
}

type ListProductRevenueRow

type ListProductRevenueRow struct {
	ProductID    int64  `json:"product_id"`
	ProductName  string `json:"product_name"`
	ProductCode  string `json:"product_code"`
	Category     string `json:"category"`
	Subcategory  string `json:"subcategory"`
	Brand        string `json:"brand"`
	Quantity     int64  `json:"quantity"`
	Revenue      int64  `json:"revenue"`
	InvoiceCount int64  `json:"invoice_count"`
}

type ListProductSaleOptionNamesRow added in v1.1.6

type ListProductSaleOptionNamesRow struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

type ListProductVariantIDsByUIDsRow

type ListProductVariantIDsByUIDsRow struct {
	ID  int64     `json:"id"`
	Uid uuid.UUID `json:"uid"`
}

type ListProductVariantsForSyncByUIDsRow

type ListProductVariantsForSyncByUIDsRow struct {
	Uid         uuid.UUID      `json:"uid"`
	ID          int64          `json:"id"`
	Barcode     string         `json:"barcode"`
	IsActive    bool           `json:"is_active"`
	UpdatedAt   time.Time      `json:"updated_at"`
	Code        string         `json:"code"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
	ColorName   sql.NullString `json:"color_name"`
	SizeName    sql.NullString `json:"size_name"`
	Brand       sql.NullString `json:"brand"`
	SubCategory sql.NullString `json:"sub_category"`
	Kind        sql.NullString `json:"kind"`
	Season      sql.NullString `json:"season"`
	Year        sql.NullString `json:"year"`
	SaleOptions []string       `json:"sale_options"`
}

type ListProductVariantsForSyncPagedParams

type ListProductVariantsForSyncPagedParams struct {
	AfterUpdatedAt time.Time `json:"after_updated_at"`
	AfterID        int64     `json:"after_id"`
	RowLimit       int32     `json:"row_limit"`
}

type ListProductVariantsForSyncPagedRow

type ListProductVariantsForSyncPagedRow struct {
	Uid         uuid.UUID      `json:"uid"`
	ID          int64          `json:"id"`
	Barcode     string         `json:"barcode"`
	IsActive    bool           `json:"is_active"`
	UpdatedAt   time.Time      `json:"updated_at"`
	Code        string         `json:"code"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
	ColorName   sql.NullString `json:"color_name"`
	SizeName    sql.NullString `json:"size_name"`
	Brand       sql.NullString `json:"brand"`
	SubCategory sql.NullString `json:"sub_category"`
	Kind        sql.NullString `json:"kind"`
	Season      sql.NullString `json:"season"`
	Year        sql.NullString `json:"year"`
	SaleOptions []string       `json:"sale_options"`
}

type ListProductVariantsForSyncRow

type ListProductVariantsForSyncRow struct {
	Uid         uuid.UUID      `json:"uid"`
	ID          int64          `json:"id"`
	Barcode     string         `json:"barcode"`
	IsActive    bool           `json:"is_active"`
	UpdatedAt   time.Time      `json:"updated_at"`
	Code        string         `json:"code"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
	ColorName   sql.NullString `json:"color_name"`
	SizeName    sql.NullString `json:"size_name"`
	Brand       sql.NullString `json:"brand"`
	SubCategory sql.NullString `json:"sub_category"`
	Kind        sql.NullString `json:"kind"`
	Season      sql.NullString `json:"season"`
	Year        sql.NullString `json:"year"`
	SaleOptions []string       `json:"sale_options"`
}

type ListProductVariantsParams

type ListProductVariantsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListProductVariantsRow

type ListProductVariantsRow struct {
	ProductVariant ProductVariant `json:"product_variant"`
	Product        Product        `json:"product"`
}

type ListProductsParams

type ListProductsParams struct {
	Search            string       `json:"search"`
	IsActive          sql.NullBool `json:"is_active"`
	CreatedFrom       sql.NullTime `json:"created_from"`
	CreatedTo         sql.NullTime `json:"created_to"`
	HasVariants       sql.NullBool `json:"has_variants"`
	AttributeValueIds []int64      `json:"attribute_value_ids"`
	PageOffset        int32        `json:"page_offset"`
	PageLimit         int32        `json:"page_limit"`
}

type ListProductsRow

type ListProductsRow struct {
	ID          int64     `json:"id"`
	Code        string    `json:"code"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	IsActive    bool      `json:"is_active"`
	CreatedAt   time.Time `json:"created_at"`
	TotalCount  int64     `json:"total_count"`
}

type ListPurchaseItemsRow

type ListPurchaseItemsRow struct {
	ID             int64          `json:"id"`
	PurchaseID     sql.NullInt64  `json:"purchase_id"`
	AssetID        sql.NullInt64  `json:"asset_id"`
	Quantity       int64          `json:"quantity"`
	UnitPrice      int64          `json:"unit_price"`
	CurrencyCode   string         `json:"currency_code"`
	VariantID      sql.NullInt64  `json:"variant_id"`
	ProductName    sql.NullString `json:"product_name"`
	ProductCode    sql.NullString `json:"product_code"`
	VariantBarcode sql.NullString `json:"variant_barcode"`
	AssetName      sql.NullString `json:"asset_name"`
}

type ListPurchasesParams

type ListPurchasesParams struct {
	Search     string `json:"search"`
	PageOffset int32  `json:"page_offset"`
	PageSize   int32  `json:"page_size"`
}

type ListPurchasesRow

type ListPurchasesRow struct {
	ID            int64          `json:"id"`
	SupplierID    int64          `json:"supplier_id"`
	PurchasedAt   time.Time      `json:"purchased_at"`
	InventoryID   sql.NullInt64  `json:"inventory_id"`
	Code          string         `json:"code"`
	CurrencyCode  string         `json:"currency_code"`
	Subtotal      int64          `json:"subtotal"`
	GrandTotal    int64          `json:"grand_total"`
	Status        PurchaseStatus `json:"status"`
	ReceivedAt    sql.NullTime   `json:"received_at"`
	Note          string         `json:"note"`
	SupplierName  string         `json:"supplier_name"`
	InventoryName sql.NullString `json:"inventory_name"`
	ItemCount     int64          `json:"item_count"`
}

type ListRegisterUpdateStatusesRow

type ListRegisterUpdateStatusesRow struct {
	ID               int64          `json:"id"`
	BranchID         int64          `json:"branch_id"`
	BranchName       string         `json:"branch_name"`
	BranchCode       string         `json:"branch_code"`
	Code             string         `json:"code"`
	Name             string         `json:"name"`
	IsActive         bool           `json:"is_active"`
	LastSeenAt       sql.NullTime   `json:"last_seen_at"`
	AppVersion       string         `json:"app_version"`
	AppFlavor        string         `json:"app_flavor"`
	UpdateState      string         `json:"update_state"`
	UpdateDetail     string         `json:"update_detail"`
	UpdateProgress   int32          `json:"update_progress"`
	UpdateReportedAt sql.NullTime   `json:"update_reported_at"`
	TargetReleaseID  sql.NullInt64  `json:"target_release_id"`
	TargetVersion    sql.NullString `json:"target_version"`
}

type ListRolesRow

type ListRolesRow struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	IsAdmin   bool      `json:"is_admin"`
	CreatedAt time.Time `json:"created_at"`
	UserCount int64     `json:"user_count"`
}

type ListSaleMovementsForInvoiceVariantParams

type ListSaleMovementsForInvoiceVariantParams struct {
	ReferenceID sql.NullInt64 `json:"reference_id"`
	VariantID   int64         `json:"variant_id"`
}

type ListSaleMovementsForInvoiceVariantRow

type ListSaleMovementsForInvoiceVariantRow struct {
	BatchID  sql.NullInt64 `json:"batch_id"`
	Quantity int64         `json:"quantity"`
}

type ListSalespersonsParams

type ListSalespersonsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListSalespersonsUpdatedSinceParams

type ListSalespersonsUpdatedSinceParams struct {
	BranchID  sql.NullInt64 `json:"branch_id"`
	UpdatedAt time.Time     `json:"updated_at"`
}

type ListSecurityAlertsParams added in v1.1.0

type ListSecurityAlertsParams struct {
	OpenOnly    bool     `json:"open_only"`
	PinnedKinds []string `json:"pinned_kinds"`
	PageSize    int32    `json:"page_size"`
}

type ListShiftsParams

type ListShiftsParams struct {
	Status     string        `json:"status"`
	CashboxID  sql.NullInt64 `json:"cashbox_id"`
	Search     string        `json:"search"`
	SortBy     string        `json:"sort_by"`
	SortOrder  string        `json:"sort_order"`
	PageOffset int32         `json:"page_offset"`
	PageSize   int32         `json:"page_size"`
}

type ListShiftsRow

type ListShiftsRow struct {
	ID          int64        `json:"id"`
	IsClosed    bool         `json:"is_closed"`
	CashboxID   int64        `json:"cashbox_id"`
	CreatedAt   time.Time    `json:"created_at"`
	ClosedAt    sql.NullTime `json:"closed_at"`
	CashboxName string       `json:"cashbox_name"`
	CashboxCode string       `json:"cashbox_code"`
}

type ListSizesPageParams

type ListSizesPageParams struct {
	Search     string `json:"search"`
	SortBy     string `json:"sort_by"`
	SortOrder  string `json:"sort_order"`
	PageOffset int32  `json:"page_offset"`
	PageSize   int32  `json:"page_size"`
}

type ListSlowMovingProductsParams

type ListSlowMovingProductsParams struct {
	Category   sql.NullString `json:"category"`
	Search     string         `json:"search"`
	PageOffset int32          `json:"page_offset"`
	PageLimit  int32          `json:"page_limit"`
}

type ListSlowMovingProductsRow

type ListSlowMovingProductsRow struct {
	ID              int64       `json:"id"`
	Code            string      `json:"code"`
	Name            string      `json:"name"`
	OnHand          int64       `json:"on_hand"`
	UnitsSold90d    int64       `json:"units_sold_90d"`
	DaysOfInventory interface{} `json:"days_of_inventory"`
	Category        string      `json:"category"`
}

type ListStockCountItemsRow

type ListStockCountItemsRow struct {
	ID              int64  `json:"id"`
	StockCountID    int64  `json:"stock_count_id"`
	VariantID       int64  `json:"variant_id"`
	SystemQuantity  int64  `json:"system_quantity"`
	CountedQuantity int64  `json:"counted_quantity"`
	Difference      int64  `json:"difference"`
	Barcode         string `json:"barcode"`
	ProductCode     string `json:"product_code"`
	ProductName     string `json:"product_name"`
	ColorName       string `json:"color_name"`
	SizeName        string `json:"size_name"`
}

type ListStockCountsParams

type ListStockCountsParams struct {
	InventoryID sql.NullInt64        `json:"inventory_id"`
	Status      NullStockCountStatus `json:"status"`
	PageOffset  int32                `json:"page_offset"`
	PageLimit   int32                `json:"page_limit"`
}

type ListStockCountsRow

type ListStockCountsRow struct {
	ID            int64            `json:"id"`
	InventoryID   int64            `json:"inventory_id"`
	Code          string           `json:"code"`
	Status        StockCountStatus `json:"status"`
	Note          string           `json:"note"`
	CountedAt     time.Time        `json:"counted_at"`
	PostedAt      sql.NullTime     `json:"posted_at"`
	CreatedBy     sql.NullInt64    `json:"created_by"`
	PostedBy      sql.NullInt64    `json:"posted_by"`
	CreatedAt     time.Time        `json:"created_at"`
	InventoryName string           `json:"inventory_name"`
}

type ListStockHealthByInventoryParams

type ListStockHealthByInventoryParams struct {
	Search     string `json:"search"`
	PageOffset int32  `json:"page_offset"`
	PageLimit  int32  `json:"page_limit"`
}

type ListStockHealthByInventoryRow

type ListStockHealthByInventoryRow struct {
	ID              int64         `json:"id"`
	Name            string        `json:"name"`
	Type            InventoryType `json:"type"`
	TotalUnits      int64         `json:"total_units"`
	InventoryValue  int64         `json:"inventory_value"`
	UnitsSold30d    int64         `json:"units_sold_30d"`
	DaysOfInventory interface{}   `json:"days_of_inventory"`
}

type ListStockMovementsParams

type ListStockMovementsParams struct {
	InventoryID   sql.NullInt64           `json:"inventory_id"`
	VariantID     sql.NullInt64           `json:"variant_id"`
	Reason        NullStockMovementReason `json:"reason"`
	ReferenceType sql.NullString          `json:"reference_type"`
	CreatedBy     sql.NullInt64           `json:"created_by"`
	FromDate      sql.NullTime            `json:"from_date"`
	ToDate        sql.NullTime            `json:"to_date"`
	PageOffset    int32                   `json:"page_offset"`
	PageLimit     int32                   `json:"page_limit"`
}

type ListStockMovementsRow

type ListStockMovementsRow struct {
	ID             int64               `json:"id"`
	InventoryID    int64               `json:"inventory_id"`
	VariantID      int64               `json:"variant_id"`
	Quantity       int64               `json:"quantity"`
	Reason         StockMovementReason `json:"reason"`
	ReferenceType  sql.NullString      `json:"reference_type"`
	ReferenceID    sql.NullInt64       `json:"reference_id"`
	UnitCost       sql.NullInt64       `json:"unit_cost"`
	Note           string              `json:"note"`
	CreatedBy      sql.NullInt64       `json:"created_by"`
	CreatedAt      time.Time           `json:"created_at"`
	QuantityBefore int64               `json:"quantity_before"`
	QuantityAfter  int64               `json:"quantity_after"`
	Metadata       json.RawMessage     `json:"metadata"`
	BatchID        sql.NullInt64       `json:"batch_id"`
	InventoryName  string              `json:"inventory_name"`
	Barcode        string              `json:"barcode"`
	ProductCode    string              `json:"product_code"`
	ProductName    string              `json:"product_name"`
	ColorName      string              `json:"color_name"`
	SizeName       string              `json:"size_name"`
	CreatedByName  string              `json:"created_by_name"`
	BatchCode      string              `json:"batch_code"`
}

type ListSuppliersParams

type ListSuppliersParams struct {
	Search     string `json:"search"`
	PageOffset int32  `json:"page_offset"`
	PageSize   int32  `json:"page_size"`
}

type ListTransferAttachmentsParams added in v1.1.0

type ListTransferAttachmentsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListTransferAttachmentsRow added in v1.1.0

type ListTransferAttachmentsRow struct {
	ID                int64     `json:"id"`
	Code              string    `json:"code"`
	CreatedAt         time.Time `json:"created_at"`
	FromInventoryName string    `json:"from_inventory_name"`
	ToInventoryName   string    `json:"to_inventory_name"`
	BranchName        string    `json:"branch_name"`
}

type ListTransferItemsRow

type ListTransferItemsRow struct {
	ID               int64         `json:"id"`
	TransferID       int64         `json:"transfer_id"`
	AssetID          sql.NullInt64 `json:"asset_id"`
	Quantity         int64         `json:"quantity"`
	VariantID        sql.NullInt64 `json:"variant_id"`
	ReceivedQuantity sql.NullInt64 `json:"received_quantity"`
	ProductName      string        `json:"product_name"`
	ProductCode      string        `json:"product_code"`
	VariantBarcode   string        `json:"variant_barcode"`
	VariantUid       uuid.NullUUID `json:"variant_uid"`
	AssetName        string        `json:"asset_name"`
}

type ListTransfersParams

type ListTransfersParams struct {
	Limit  int32              `json:"limit"`
	Offset int32              `json:"offset"`
	Status NullTransferStatus `json:"status"`
}

type ListTransfersRow

type ListTransfersRow struct {
	ID                 int64          `json:"id"`
	FromInventoryID    int64          `json:"from_inventory_id"`
	ToInventoryID      int64          `json:"to_inventory_id"`
	Type               TransferType   `json:"type"`
	CreatedAt          time.Time      `json:"created_at"`
	Code               string         `json:"code"`
	Status             TransferStatus `json:"status"`
	DispatchedAt       sql.NullTime   `json:"dispatched_at"`
	ReceivedAt         sql.NullTime   `json:"received_at"`
	Note               string         `json:"note"`
	BranchID           sql.NullInt64  `json:"branch_id"`
	ClientRef          sql.NullString `json:"client_ref"`
	AttachmentPath     string         `json:"attachment_path"`
	UpdatedAt          time.Time      `json:"updated_at"`
	ConfirmedAt        sql.NullTime   `json:"confirmed_at"`
	ConfirmedNote      string         `json:"confirmed_note"`
	RegisterID         sql.NullInt64  `json:"register_id"`
	AttachmentRotation int16          `json:"attachment_rotation"`
	FromInventoryName  string         `json:"from_inventory_name"`
	ToInventoryName    string         `json:"to_inventory_name"`
	BranchName         string         `json:"branch_name"`
	ItemCount          int64          `json:"item_count"`
}

type ListUnknownItemImagesParams added in v1.1.1

type ListUnknownItemImagesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListUnknownItemImagesRow added in v1.1.1

type ListUnknownItemImagesRow struct {
	ID                int64     `json:"id"`
	CreatedAt         time.Time `json:"created_at"`
	BranchName        string    `json:"branch_name"`
	BranchInvoiceCode string    `json:"branch_invoice_code"`
	Units             int32     `json:"units"`
	UnitPrice         int64     `json:"unit_price"`
}

type ListUnknownItemsParams added in v1.1.1

type ListUnknownItemsParams struct {
	Limit    int32 `json:"limit"`
	Offset   int32 `json:"offset"`
	Resolved bool  `json:"resolved"`
}

type ListUnknownItemsRow added in v1.1.1

type ListUnknownItemsRow struct {
	ID                int64         `json:"id"`
	SlotRef           string        `json:"slot_ref"`
	Position          int32         `json:"position"`
	Label             string        `json:"label"`
	UnitPrice         int64         `json:"unit_price"`
	Discount          int16         `json:"discount"`
	ImageID           sql.NullInt64 `json:"image_id"`
	ResolvedVariantID sql.NullInt64 `json:"resolved_variant_id"`
	ResolvedAt        sql.NullTime  `json:"resolved_at"`
	WaivedAt          sql.NullTime  `json:"waived_at"`
	WaivedBy          string        `json:"waived_by"`
	SessionID         int64         `json:"session_id"`
	BranchID          int64         `json:"branch_id"`
	BranchName        string        `json:"branch_name"`
	BranchInvoiceID   sql.NullInt64 `json:"branch_invoice_id"`
	BranchInvoiceCode string        `json:"branch_invoice_code"`
	OccurredAt        time.Time     `json:"occurred_at"`
	ResolvedName      string        `json:"resolved_name"`
	ResolvedBarcode   string        `json:"resolved_barcode"`
}

type ListUnresolvedUrgentHomeActivitiesRow added in v1.1.0

type ListUnresolvedUrgentHomeActivitiesRow struct {
	Activity     string    `json:"activity"`
	ID           int64     `json:"id"`
	BranchID     int64     `json:"branch_id"`
	BranchName   string    `json:"branch_name"`
	Details      string    `json:"details"`
	Amount       int64     `json:"amount"`
	CurrencyCode string    `json:"currency_code"`
	SyncedAt     time.Time `json:"synced_at"`
	Person       string    `json:"person"`
	PersonColor  string    `json:"person_color"`
}

type ListUsersParams

type ListUsersParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListVariantSyncIDsParams

type ListVariantSyncIDsParams struct {
	AfterUid uuid.UUID `json:"after_uid"`
	RowLimit int32     `json:"row_limit"`
}

type ListVariantSyncIDsRow

type ListVariantSyncIDsRow struct {
	Uid       uuid.UUID `json:"uid"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ListVariantsForBarcodesParams

type ListVariantsForBarcodesParams struct {
	Search     string `json:"search"`
	PageOffset int32  `json:"page_offset"`
	PageLimit  int32  `json:"page_limit"`
}

type ListVariantsForBarcodesRow

type ListVariantsForBarcodesRow struct {
	ID          int64         `json:"id"`
	Barcode     string        `json:"barcode"`
	Price       sql.NullInt64 `json:"price"`
	IsActive    bool          `json:"is_active"`
	CreatedAt   time.Time     `json:"created_at"`
	ProductID   int64         `json:"product_id"`
	ProductCode string        `json:"product_code"`
	ProductName string        `json:"product_name"`
	ColorName   string        `json:"color_name"`
	SizeType    string        `json:"size_type"`
	SizeName    string        `json:"size_name"`
	Brand       string        `json:"brand"`
}

type ListVariantsForDiscountEntryRow added in v1.1.6

type ListVariantsForDiscountEntryRow struct {
	ID          int64  `json:"id"`
	Barcode     string `json:"barcode"`
	ProductCode string `json:"product_code"`
	ProductName string `json:"product_name"`
	ColorName   string `json:"color_name"`
	SizeName    string `json:"size_name"`
}

type ListVisitorIPsParams added in v1.1.0

type ListVisitorIPsParams struct {
	Search      string `json:"search"`
	CountryCode string `json:"country_code"`
	PageOffset  int32  `json:"page_offset"`
	PageSize    int32  `json:"page_size"`
}

type ListWaitingUnknownItemsRow added in v1.1.1

type ListWaitingUnknownItemsRow struct {
	ID              int64         `json:"id"`
	SlotRef         string        `json:"slot_ref"`
	Position        int32         `json:"position"`
	Label           string        `json:"label"`
	UnitPrice       int64         `json:"unit_price"`
	Discount        int16         `json:"discount"`
	ImageID         sql.NullInt64 `json:"image_id"`
	WaivedAt        sql.NullTime  `json:"waived_at"`
	SessionID       int64         `json:"session_id"`
	BranchID        int64         `json:"branch_id"`
	BranchName      string        `json:"branch_name"`
	HelpRequestedAt sql.NullTime  `json:"help_requested_at"`
	CreatedAt       time.Time     `json:"created_at"`
}

type ListWhatsAppChatMessagesParams added in v1.1.1

type ListWhatsAppChatMessagesParams struct {
	ChatPhone string `json:"chat_phone"`
	BeforeID  int64  `json:"before_id"`
	PageSize  int32  `json:"page_size"`
}

type ListWhatsAppChatMessagesRow added in v1.1.1

type ListWhatsAppChatMessagesRow struct {
	ID               int64         `json:"id"`
	Instance         string        `json:"instance"`
	WhatsappNumberID sql.NullInt64 `json:"whatsapp_number_id"`
	WaID             string        `json:"wa_id"`
	ChatJid          string        `json:"chat_jid"`
	ChatPhone        string        `json:"chat_phone"`
	ContactName      string        `json:"contact_name"`
	FromMe           bool          `json:"from_me"`
	Kind             string        `json:"kind"`
	Body             string        `json:"body"`
	MediaType        string        `json:"media_type"`
	SentAt           time.Time     `json:"sent_at"`
	CreatedAt        time.Time     `json:"created_at"`
	NumberLabel      string        `json:"number_label"`
}

type ListWhatsAppChatsParams added in v1.1.1

type ListWhatsAppChatsParams struct {
	Search     string `json:"search"`
	PageOffset int32  `json:"page_offset"`
	PageSize   int32  `json:"page_size"`
}

type ListWhatsAppChatsRow added in v1.1.1

type ListWhatsAppChatsRow struct {
	ChatPhone   string    `json:"chat_phone"`
	Instance    string    `json:"instance"`
	FromMe      bool      `json:"from_me"`
	Kind        string    `json:"kind"`
	Body        string    `json:"body"`
	SentAt      time.Time `json:"sent_at"`
	Total       int64     `json:"total"`
	ContactName string    `json:"contact_name"`
	NumberLabel string    `json:"number_label"`
}

type ListWhatsAppMessageRepliesRow added in v1.1.0

type ListWhatsAppMessageRepliesRow struct {
	ID         int64     `json:"id"`
	Body       string    `json:"body"`
	Kind       string    `json:"kind"`
	ReceivedAt time.Time `json:"received_at"`
	MediaType  string    `json:"media_type"`
}

type ListWhatsAppMessagesParams added in v1.1.0

type ListWhatsAppMessagesParams struct {
	FromAt     time.Time `json:"from_at"`
	ToAt       time.Time `json:"to_at"`
	BranchID   int64     `json:"branch_id"`
	Status     string    `json:"status"`
	Search     string    `json:"search"`
	PageOffset int32     `json:"page_offset"`
	PageSize   int32     `json:"page_size"`
}

type ListWhatsAppMessagesRow added in v1.1.0

type ListWhatsAppMessagesRow struct {
	ID               int64         `json:"id"`
	CreatedAt        time.Time     `json:"created_at"`
	BranchID         sql.NullInt64 `json:"branch_id"`
	InvoiceCode      string        `json:"invoice_code"`
	ClientName       string        `json:"client_name"`
	ClientPhone      string        `json:"client_phone"`
	GrandTotalCents  int64         `json:"grand_total_cents"`
	ItemCount        int32         `json:"item_count"`
	RuleID           sql.NullInt64 `json:"rule_id"`
	RuleName         string        `json:"rule_name"`
	TemplateName     string        `json:"template_name"`
	Status           string        `json:"status"`
	Reason           string        `json:"reason"`
	Wamid            string        `json:"wamid"`
	CostMicros       int64         `json:"cost_micros"`
	DeliveryStatus   string        `json:"delivery_status"`
	DeliveredAt      sql.NullTime  `json:"delivered_at"`
	ReadAt           sql.NullTime  `json:"read_at"`
	DeliveryError    string        `json:"delivery_error"`
	Billable         sql.NullBool  `json:"billable"`
	PricingCategory  string        `json:"pricing_category"`
	ReviewCode       string        `json:"review_code"`
	ReviewClickedAt  sql.NullTime  `json:"review_clicked_at"`
	Sender           string        `json:"sender"`
	WhatsappNumberID sql.NullInt64 `json:"whatsapp_number_id"`
	PollRef          string        `json:"poll_ref"`
	PollRating       sql.NullInt16 `json:"poll_rating"`
	PollAnswer       string        `json:"poll_answer"`
	PollVotedAt      sql.NullTime  `json:"poll_voted_at"`
	PollFollowupAt   sql.NullTime  `json:"poll_followup_at"`
	BridgeRef        string        `json:"bridge_ref"`
	IsTest           bool          `json:"is_test"`
	Body             string        `json:"body"`
	PollQuestion     string        `json:"poll_question"`
	PollOptions      string        `json:"poll_options"`
	FollowupBody     string        `json:"followup_body"`
	BranchName       string        `json:"branch_name"`
}

type ListWhatsAppRepliesParams added in v1.1.0

type ListWhatsAppRepliesParams struct {
	FromAt     time.Time `json:"from_at"`
	ToAt       time.Time `json:"to_at"`
	BranchID   int64     `json:"branch_id"`
	Search     string    `json:"search"`
	PageOffset int32     `json:"page_offset"`
	PageSize   int32     `json:"page_size"`
}

type ListWhatsAppRepliesRow added in v1.1.0

type ListWhatsAppRepliesRow struct {
	ID           int64         `json:"id"`
	Wamid        string        `json:"wamid"`
	ReceivedAt   time.Time     `json:"received_at"`
	ClientPhone  string        `json:"client_phone"`
	ClientName   string        `json:"client_name"`
	Kind         string        `json:"kind"`
	Body         string        `json:"body"`
	MessageID    sql.NullInt64 `json:"message_id"`
	InvoiceCode  string        `json:"invoice_code"`
	RuleName     string        `json:"rule_name"`
	TemplateName string        `json:"template_name"`
	BranchName   string        `json:"branch_name"`
}

type Loan

type Loan struct {
	ID                       int64          `json:"id"`
	Origin                   string         `json:"origin"`
	Description              string         `json:"description"`
	CategoryID               int64          `json:"category_id"`
	Amount                   int64          `json:"amount"`
	CurrencyCode             string         `json:"currency_code"`
	BranchID                 sql.NullInt64  `json:"branch_id"`
	ClientRef                sql.NullString `json:"client_ref"`
	BranchCashboxAccountID   sql.NullInt64  `json:"branch_cashbox_account_id"`
	BranchShiftID            sql.NullInt64  `json:"branch_shift_id"`
	OccurredAt               time.Time      `json:"occurred_at"`
	ReceivedAt               time.Time      `json:"received_at"`
	BranchCashboxAccountName sql.NullString `json:"branch_cashbox_account_name"`
	CancelledAt              sql.NullTime   `json:"cancelled_at"`
}

type LoanCategory

type LoanCategory struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	IsActive  bool      `json:"is_active"`
	CreatedAt time.Time `json:"created_at"`
	Icon      string    `json:"icon"`
	Color     string    `json:"color"`
	Scope     string    `json:"scope"`
	UpdatedAt time.Time `json:"updated_at"`
}

type LoanImage added in v1.1.0

type LoanImage struct {
	ID          int64     `json:"id"`
	LoanID      int64     `json:"loan_id"`
	FilePath    string    `json:"file_path"`
	ContentType string    `json:"content_type"`
	SizeBytes   int64     `json:"size_bytes"`
	CreatedAt   time.Time `json:"created_at"`
}

type LoanPayment

type LoanPayment struct {
	ID           int64     `json:"id"`
	LoanID       int64     `json:"loan_id"`
	Amount       int64     `json:"amount"`
	CurrencyCode string    `json:"currency_code"`
	Note         string    `json:"note"`
	PaidAt       time.Time `json:"paid_at"`
}

type LoanUploadToken added in v1.1.0

type LoanUploadToken struct {
	ID        int64        `json:"id"`
	LoanID    int64        `json:"loan_id"`
	Token     string       `json:"token"`
	ExpiresAt time.Time    `json:"expires_at"`
	UsedAt    sql.NullTime `json:"used_at"`
	CreatedAt time.Time    `json:"created_at"`
}

type LowPollRatingsParams added in v1.1.0

type LowPollRatingsParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type LowPollRatingsRow added in v1.1.0

type LowPollRatingsRow struct {
	ID              int64         `json:"id"`
	PollVotedAt     sql.NullTime  `json:"poll_voted_at"`
	PollRating      sql.NullInt16 `json:"poll_rating"`
	PollAnswer      string        `json:"poll_answer"`
	ClientName      string        `json:"client_name"`
	ClientPhone     string        `json:"client_phone"`
	InvoiceCode     string        `json:"invoice_code"`
	GrandTotalCents int64         `json:"grand_total_cents"`
	BranchName      string        `json:"branch_name"`
	Replies         string        `json:"replies"`
}

type LoyaltyMonthlyJoinsRow added in v1.1.6

type LoyaltyMonthlyJoinsRow struct {
	Month  string `json:"month"`
	Joined int64  `json:"joined"`
}

type LoyaltyRisingClientsParams added in v1.1.6

type LoyaltyRisingClientsParams struct {
	TierMins   []int64        `json:"tier_mins"`
	ClientType sql.NullString `json:"client_type"`
}

type LoyaltyRisingClientsRow added in v1.1.6

type LoyaltyRisingClientsRow struct {
	ID        int64  `json:"id"`
	Name      string `json:"name"`
	Spent     int64  `json:"spent"`
	TierIndex int32  `json:"tier_index"`
	NextMin   int64  `json:"next_min"`
}

type LoyaltyTierStatsParams added in v1.1.6

type LoyaltyTierStatsParams struct {
	TierMins   []int64        `json:"tier_mins"`
	DateFrom   sql.NullTime   `json:"date_from"`
	DateTo     sql.NullTime   `json:"date_to"`
	ClientType sql.NullString `json:"client_type"`
}

type LoyaltyTierStatsRow added in v1.1.6

type LoyaltyTierStatsRow struct {
	TierIndex int32 `json:"tier_index"`
	Members   int64 `json:"members"`
	Active    int64 `json:"active"`
	Revenue   int64 `json:"revenue"`
	Points    int64 `json:"points"`
}

type MarkBranchAttendanceEventRemovedParams added in v1.1.0

type MarkBranchAttendanceEventRemovedParams struct {
	BranchID  int64  `json:"branch_id"`
	ClientRef string `json:"client_ref"`
	RemovedBy string `json:"removed_by"`
}

type MarkBranchInvoicesCancelledParams added in v1.1.0

type MarkBranchInvoicesCancelledParams struct {
	BranchID   int64    `json:"branch_id"`
	ClientRefs []string `json:"client_refs"`
}

type MarkUnknownItemSlotResolvedParams added in v1.1.1

type MarkUnknownItemSlotResolvedParams struct {
	ID                int64         `json:"id"`
	ResolvedVariantID sql.NullInt64 `json:"resolved_variant_id"`
}

type NullAuditAction

type NullAuditAction struct {
	AuditAction AuditAction `json:"audit_action"`
	Valid       bool        `json:"valid"` // Valid is true if AuditAction is not NULL
}

func (*NullAuditAction) Scan

func (ns *NullAuditAction) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullAuditAction) Value

func (ns NullAuditAction) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullCouponStatus

type NullCouponStatus struct {
	CouponStatus CouponStatus `json:"coupon_status"`
	Valid        bool         `json:"valid"` // Valid is true if CouponStatus is not NULL
}

func (*NullCouponStatus) Scan

func (ns *NullCouponStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullCouponStatus) Value

func (ns NullCouponStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullEntryReferenceType

type NullEntryReferenceType struct {
	EntryReferenceType EntryReferenceType `json:"entry_reference_type"`
	Valid              bool               `json:"valid"` // Valid is true if EntryReferenceType is not NULL
}

func (*NullEntryReferenceType) Scan

func (ns *NullEntryReferenceType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullEntryReferenceType) Value

func (ns NullEntryReferenceType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullIndexType

type NullIndexType struct {
	IndexType IndexType `json:"index_type"`
	Valid     bool      `json:"valid"` // Valid is true if IndexType is not NULL
}

func (*NullIndexType) Scan

func (ns *NullIndexType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullIndexType) Value

func (ns NullIndexType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullInventoryType

type NullInventoryType struct {
	InventoryType InventoryType `json:"inventory_type"`
	Valid         bool          `json:"valid"` // Valid is true if InventoryType is not NULL
}

func (*NullInventoryType) Scan

func (ns *NullInventoryType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullInventoryType) Value

func (ns NullInventoryType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullPurchaseStatus

type NullPurchaseStatus struct {
	PurchaseStatus PurchaseStatus `json:"purchase_status"`
	Valid          bool           `json:"valid"` // Valid is true if PurchaseStatus is not NULL
}

func (*NullPurchaseStatus) Scan

func (ns *NullPurchaseStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullPurchaseStatus) Value

func (ns NullPurchaseStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullStockCountStatus

type NullStockCountStatus struct {
	StockCountStatus StockCountStatus `json:"stock_count_status"`
	Valid            bool             `json:"valid"` // Valid is true if StockCountStatus is not NULL
}

func (*NullStockCountStatus) Scan

func (ns *NullStockCountStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullStockCountStatus) Value

func (ns NullStockCountStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullStockMovementReason

type NullStockMovementReason struct {
	StockMovementReason StockMovementReason `json:"stock_movement_reason"`
	Valid               bool                `json:"valid"` // Valid is true if StockMovementReason is not NULL
}

func (*NullStockMovementReason) Scan

func (ns *NullStockMovementReason) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullStockMovementReason) Value

func (ns NullStockMovementReason) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullTransferStatus

type NullTransferStatus struct {
	TransferStatus TransferStatus `json:"transfer_status"`
	Valid          bool           `json:"valid"` // Valid is true if TransferStatus is not NULL
}

func (*NullTransferStatus) Scan

func (ns *NullTransferStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTransferStatus) Value

func (ns NullTransferStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullTransferType

type NullTransferType struct {
	TransferType TransferType `json:"transfer_type"`
	Valid        bool         `json:"valid"` // Valid is true if TransferType is not NULL
}

func (*NullTransferType) Scan

func (ns *NullTransferType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTransferType) Value

func (ns NullTransferType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type OversoldPayload

type OversoldPayload struct {
	VariantID     int64  `json:"variant_id"`
	Barcode       string `json:"barcode"`
	OnHand        int64  `json:"on_hand"`
	RegisterID    int64  `json:"register_id"`
	InvoiceID     int64  `json:"invoice_id"`
	InvoiceCode   string `json:"invoice_code"`
	InvoiceRef    string `json:"invoice_ref"`
	QuantitySold  int64  `json:"quantity_sold"`
	OccurredAtUTC string `json:"occurred_at"`
}

OversoldPayload is the branch_payload of an "oversold" stock alert.

type Permission

type Permission struct {
	ID   int64  `json:"id"`
	Code string `json:"code"`
}

type PollRatingTotalsParams added in v1.1.0

type PollRatingTotalsParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type PollRatingTotalsRow added in v1.1.0

type PollRatingTotalsRow struct {
	Polls   int64   `json:"polls"`
	Answers int64   `json:"answers"`
	Average float64 `json:"average"`
	Stars5  int64   `json:"stars5"`
	Stars4  int64   `json:"stars4"`
	Stars3  int64   `json:"stars3"`
	Stars2  int64   `json:"stars2"`
	Stars1  int64   `json:"stars1"`
}

type PollRatingsByBranchParams added in v1.1.0

type PollRatingsByBranchParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type PollRatingsByBranchRow added in v1.1.0

type PollRatingsByBranchRow struct {
	BranchID   int64   `json:"branch_id"`
	BranchName string  `json:"branch_name"`
	Polls      int64   `json:"polls"`
	Answers    int64   `json:"answers"`
	Average    float64 `json:"average"`
	Stars5     int64   `json:"stars5"`
	Stars4     int64   `json:"stars4"`
	Stars3     int64   `json:"stars3"`
	Stars2     int64   `json:"stars2"`
	Stars1     int64   `json:"stars1"`
}

type PollRatingsByDayParams added in v1.1.0

type PollRatingsByDayParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type PollRatingsByDayRow added in v1.1.0

type PollRatingsByDayRow struct {
	Day     time.Time `json:"day"`
	Answers int64     `json:"answers"`
	Average float64   `json:"average"`
	Stars5  int64     `json:"stars5"`
	Stars4  int64     `json:"stars4"`
	Stars3  int64     `json:"stars3"`
	Stars2  int64     `json:"stars2"`
	Stars1  int64     `json:"stars1"`
}

type PollRepliesParams added in v1.1.0

type PollRepliesParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type PollRepliesRow added in v1.1.0

type PollRepliesRow struct {
	ID          int64         `json:"id"`
	Body        string        `json:"body"`
	Kind        string        `json:"kind"`
	ReceivedAt  time.Time     `json:"received_at"`
	PollRating  sql.NullInt16 `json:"poll_rating"`
	PollAnswer  string        `json:"poll_answer"`
	ClientName  string        `json:"client_name"`
	ClientPhone string        `json:"client_phone"`
	InvoiceCode string        `json:"invoice_code"`
	BranchName  string        `json:"branch_name"`
}

type PostStockCountTxResult

type PostStockCountTxResult struct {
	StockCount StockCount      `json:"stock_count"`
	Movements  []StockMovement `json:"movements"`
}

type PriceList

type PriceList struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	IsActive  bool      `json:"is_active"`
	IsDefault bool      `json:"is_default"`
	ValidFrom time.Time `json:"valid_from"`
	ValidTo   time.Time `json:"valid_to"`
	CreatedAt time.Time `json:"created_at"`
	Uid       uuid.UUID `json:"uid"`
	UpdatedAt time.Time `json:"updated_at"`
	IsSpecial bool      `json:"is_special"`
}

type PriceListBranch

type PriceListBranch struct {
	BranchID    int64     `json:"branch_id"`
	PriceListID int64     `json:"price_list_id"`
	CreatedAt   time.Time `json:"created_at"`
}

type PriceListBranchRemoval added in v1.1.7

type PriceListBranchRemoval struct {
	BranchID    int64     `json:"branch_id"`
	PriceListID int64     `json:"price_list_id"`
	RemovedAt   time.Time `json:"removed_at"`
}

type PriceListItem

type PriceListItem struct {
	PriceListID      int64 `json:"price_list_id"`
	Price            int64 `json:"price"`
	ProductVariantID int64 `json:"product_variant_id"`
}

type Product

type Product struct {
	ID                    int64         `json:"id"`
	Code                  string        `json:"code"`
	Name                  string        `json:"name"`
	Description           string        `json:"description"`
	IsActive              bool          `json:"is_active"`
	CreatedAt             time.Time     `json:"created_at"`
	LowStockThreshold     sql.NullInt64 `json:"low_stock_threshold"`
	LowStockAlertsEnabled bool          `json:"low_stock_alerts_enabled"`
	CategoryID            sql.NullInt64 `json:"category_id"`
}

type ProductCategory

type ProductCategory struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	IsActive  bool      `json:"is_active"`
	Icon      string    `json:"icon"`
	Color     string    `json:"color"`
	CreatedAt time.Time `json:"created_at"`
}

type ProductSaleOption added in v1.1.6

type ProductSaleOption struct {
	ProductID    int64 `json:"product_id"`
	SaleOptionID int64 `json:"sale_option_id"`
}

type ProductSupplier

type ProductSupplier struct {
	ID         int64 `json:"id"`
	ProductID  int64 `json:"product_id"`
	SupplierID int64 `json:"supplier_id"`
}

type ProductSupplierCost

type ProductSupplierCost struct {
	ProductSupplierID int64     `json:"product_supplier_id"`
	UnitCost          int64     `json:"unit_cost"`
	CurrencyCode      string    `json:"currency_code"`
	CreatedAt         time.Time `json:"created_at"`
}

type ProductVariant

type ProductVariant struct {
	ID        int64         `json:"id"`
	ProductID int64         `json:"product_id"`
	ColorID   sql.NullInt64 `json:"color_id"`
	SizeID    sql.NullInt64 `json:"size_id"`
	Barcode   string        `json:"barcode"`
	Price     sql.NullInt64 `json:"price"`
	IsActive  bool          `json:"is_active"`
	CreatedAt time.Time     `json:"created_at"`
	UpdatedAt time.Time     `json:"updated_at"`
	AvgCost   int64         `json:"avg_cost"`
	Uid       uuid.UUID     `json:"uid"`
}

type ProductsAttribute

type ProductsAttribute struct {
	AttributeID      int64 `json:"attribute_id"`
	AttributeValueID int64 `json:"attribute_value_id"`
	ProductID        int64 `json:"product_id"`
}

type Purchase

type Purchase struct {
	ID           int64          `json:"id"`
	SupplierID   int64          `json:"supplier_id"`
	PurchasedAt  time.Time      `json:"purchased_at"`
	InventoryID  sql.NullInt64  `json:"inventory_id"`
	Code         string         `json:"code"`
	CurrencyCode string         `json:"currency_code"`
	Subtotal     int64          `json:"subtotal"`
	GrandTotal   int64          `json:"grand_total"`
	Status       PurchaseStatus `json:"status"`
	ReceivedAt   sql.NullTime   `json:"received_at"`
	Note         string         `json:"note"`
}

type PurchaseItem

type PurchaseItem struct {
	ID           int64         `json:"id"`
	PurchaseID   sql.NullInt64 `json:"purchase_id"`
	AssetID      sql.NullInt64 `json:"asset_id"`
	Quantity     int64         `json:"quantity"`
	UnitPrice    int64         `json:"unit_price"`
	CurrencyCode string        `json:"currency_code"`
	VariantID    sql.NullInt64 `json:"variant_id"`
}

type PurchaseItemParams

type PurchaseItemParams struct {
	VariantID sql.NullInt64 `json:"variant_id"`
	AssetID   sql.NullInt64 `json:"asset_id"`
	Quantity  int64         `json:"quantity"`
	UnitPrice int64         `json:"unit_price"`
}

PurchaseItemParams is one line on a draft purchase invoice. A line is either a product variant (variant_id set) or an asset (asset_id set).

type PurchaseReceiveTxParams

type PurchaseReceiveTxParams struct {
	PurchaseID int64         `json:"purchase_id"`
	CreatedBy  sql.NullInt64 `json:"created_by"`
}

type PurchaseReceiveTxResult

type PurchaseReceiveTxResult struct {
	Purchase  Purchase        `json:"purchase"`
	Movements []StockMovement `json:"movements"`
}

type PurchaseStatus

type PurchaseStatus string
const (
	PurchaseStatusDraft     PurchaseStatus = "draft"
	PurchaseStatusReceived  PurchaseStatus = "received"
	PurchaseStatusCancelled PurchaseStatus = "cancelled"
)

func (*PurchaseStatus) Scan

func (e *PurchaseStatus) Scan(src interface{}) error

type Querier

type Querier interface {
	// Marks the given alerts seen; an empty list marks every open one except
	// those of kept_kinds (critical ones, resolved only one by one).
	AcknowledgeSecurityAlerts(ctx context.Context, arg AcknowledgeSecurityAlertsParams) error
	// The list a branch is discounted from: its own assigned list when that one
	// is active and in date, otherwise the default -- the same choice
	// ResolveVariantDiscount makes, and the till makes from what it's sent.
	ActiveDiscountListForBranch(ctx context.Context, branchID int64) (DiscountList, error)
	// remaining_quantity starts equal to quantity_bought -- FIFO consumption
	// (applyStockMovement) draws it down as sales are attributed to this
	// batch, and returns of those sales put it back.
	AddBatchItem(ctx context.Context, arg AddBatchItemParams) (BatchItem, error)
	AddCashboxAccountBalance(ctx context.Context, arg AddCashboxAccountBalanceParams) (ShiftsAccountsBalance, error)
	AddClientLoyaltyPoints(ctx context.Context, arg AddClientLoyaltyPointsParams) error
	// Apply a signed quantity delta to one SKU's on-hand in one inventory,
	// creating the row if this SKU has never been stocked there. Cost is left
	// untouched (used for sales, returns, transfers, adjustments).
	AddInventoryStockQuantity(ctx context.Context, arg AddInventoryStockQuantityParams) (InventoryStock, error)
	AddInvoiceDiscountBranch(ctx context.Context, arg AddInvoiceDiscountBranchParams) error
	AddInvoiceProduct(ctx context.Context, arg AddInvoiceProductParams) (InvoiceProduct, error)
	// Gives every product named by entries each of the options; returns the
	// product ids it matched.
	AddProductSaleOptionsForEntries(ctx context.Context, arg AddProductSaleOptionsForEntriesParams) ([]int64, error)
	AddPurchaseItem(ctx context.Context, arg AddPurchaseItemParams) (PurchaseItem, error)
	AddPurchasedProduct(ctx context.Context, arg AddPurchasedProductParams) (ProductSupplier, error)
	AddPurchasedProductCost(ctx context.Context, arg AddPurchasedProductCostParams) (ProductSupplierCost, error)
	AddStockCountItem(ctx context.Context, arg AddStockCountItemParams) (StockCountItem, error)
	// The Inbox tab: every message on our own WhatsApp numbers (api/whatsapp_chat.go).
	// ErrNoRows when the bridge already reported this message.
	AddWhatsAppChatMessage(ctx context.Context, arg AddWhatsAppChatMessageParams) (int64, error)
	// A client's message after the poll, reported by the bridge. No rows when the
	// poll is unknown or the bridge already reported this message.
	AddWhatsAppPollReply(ctx context.Context, arg AddWhatsAppPollReplyParams) (int64, error)
	// Signed delta: negative consumes (a sale), positive replenishes (a return
	// of that sale). No floor at zero -- same "ledger stays authoritative, UI
	// surfaces negatives" rule as inventory_stock.
	AdjustBatchItemRemainingQuantity(ctx context.Context, arg AdjustBatchItemRemainingQuantityParams) (BatchItem, error)
	// A till's own value, reported up, for a salesperson kashi hasn't set one
	// for. updated_at is left alone: nothing about it needs to go back down.
	AdoptSalespersonAttendanceID(ctx context.Context, arg AdoptSalespersonAttendanceIDParams) error
	// A tick the bridge saw on one of our own messages. Like Meta's statuses it
	// only moves forward (sent -> delivered -> read), so a late one changes nothing.
	ApplyWhatsAppBridgeTick(ctx context.Context, arg ApplyWhatsAppBridgeTickParams) (ApplyWhatsAppBridgeTickRow, error)
	// Meta's WhatsApp webhook (api/whatsapp_webhook.go).
	// Delivery only moves forward (sent -> delivered -> read), so an update that
	// arrives late doesn't undo a newer one; 'failed' always wins. A message Meta
	// couldn't deliver, or says it doesn't charge for, costs nothing.
	ApplyWhatsAppDeliveryStatus(ctx context.Context, arg ApplyWhatsAppDeliveryStatusParams) ([]int64, error)
	// The rating poll a new client gets at checkout, recorded on the welcome row
	// that checkout claimed, so one client's welcome and poll are one row (its
	// ticks are the welcome's; votes find it by poll_ref).
	AttachWhatsAppPoll(ctx context.Context, arg AttachWhatsAppPollParams) error
	// Sets only phone_valid/phone_country, leaving the phone text and updated_at
	// alone: bumping updated_at would make every till re-download the client on
	// its next catch-up.
	BatchSetClientPhoneFlags(ctx context.Context, arg BatchSetClientPhoneFlagsParams) error
	// Bulk counterpart to UpdateClientPhone for normalizeClientPhones: one
	// round trip for a whole chunk instead of one per row, which is what made
	// the first version of this job time out at Cloudflare's gateway on 60k+
	// individual updates. Also backfills phone_valid/phone_country for every
	// row the job passes (even one whose phone text didn't change), since
	// those columns start out at their just-migrated-in defaults until this
	// runs once.
	BatchUpdateClientPhones(ctx context.Context, arg BatchUpdateClientPhonesParams) error
	BranchAttendanceChangeRefsPresent(ctx context.Context, arg BranchAttendanceChangeRefsPresentParams) ([]string, error)
	BranchAttendanceEventRefsPresent(ctx context.Context, arg BranchAttendanceEventRefsPresentParams) ([]string, error)
	BranchClientLinksPresent(ctx context.Context, arg BranchClientLinksPresentParams) ([]int64, error)
	// One row per branch: what's still queued and what failed in the last day,
	// for the Commands page sidebar and its nav dot.
	BranchCommandSummary(ctx context.Context) ([]BranchCommandSummaryRow, error)
	BranchExpenseRefsPresent(ctx context.Context, arg BranchExpenseRefsPresentParams) ([]string, error)
	// Reconcile queries: given the refs a branch believes it has pushed, return
	// the subset kashi actually holds. The branch diffs its own list against
	// this to decide what still needs (re)queuing -- the basis of "sync
	// everything to a (possibly new) central server". Each is a single indexed
	// `= ANY` lookup; the handler caps the input array size.
	BranchInvoiceRefsPresent(ctx context.Context, arg BranchInvoiceRefsPresentParams) ([]string, error)
	BranchInvoicesReferenceClient(ctx context.Context, id int64) (bool, error)
	BranchInvoicesReferenceVariant(ctx context.Context, id int64) (bool, error)
	BranchLoanRefsPresent(ctx context.Context, arg BranchLoanRefsPresentParams) ([]sql.NullString, error)
	BranchSalespersonExists(ctx context.Context, arg BranchSalespersonExistsParams) (bool, error)
	// A branch_shifts row exists only once kashi-pos has reported that shift's
	// close, so its mere presence is the "this shift is closed" signal --
	// closed_at itself can be NULL for an older till build that omitted it.
	BranchShiftIsClosed(ctx context.Context, arg BranchShiftIsClosedParams) (bool, error)
	BranchShiftRefsPresent(ctx context.Context, arg BranchShiftRefsPresentParams) ([]string, error)
	// One row per branch: open conflicts, and how many of those are oversold
	// stock (the kind that needs a stock fix), for the Conflicts page sidebar
	// and its nav dot.
	BranchSyncConflictSummary(ctx context.Context) ([]BranchSyncConflictSummaryRow, error)
	BranchVisitorEventRefsPresent(ctx context.Context, arg BranchVisitorEventRefsPresentParams) ([]string, error)
	// Puts every variant whose barcode, or whose product's code, is in entries on
	// the list at one discount (adding it or changing it). A code names all of its
	// product's variants. deal_id, when set, puts them on that deal instead
	// (discount 0). Returns the variant ids it set.
	BulkSetDiscountListItems(ctx context.Context, arg BulkSetDiscountListItemsParams) ([]int64, error)
	// BulkSetDiscountListItems for one option: the discount applies to the
	// matched variants only when they are sold as that option.
	BulkSetDiscountListOptionItems(ctx context.Context, arg BulkSetDiscountListOptionItemsParams) ([]int64, error)
	// Folds a repeat into the feed's newest entry when it's the same change by
	// the same person, made less than an hour after it: the count goes up and
	// the time moves to now. No row back (sql.ErrNoRows) means it wasn't a
	// repeat, and the caller adds a new entry.
	BumpAdminActivity(ctx context.Context, arg BumpAdminActivityParams) (int64, error)
	// Sales (not returns or exchanges): how many, and what they came to.
	BusyHoursSales(ctx context.Context, arg BusyHoursSalesParams) ([]BusyHoursSalesRow, error)
	// The Busy Hours page (api/busy_hours.go): when people come in and buy, by
	// weekday (ISO: 1 Monday .. 7 Sunday) and hour, in each branch's own time
	// zone. Hidden branches/registers and cancelled sales are left out, like the
	// other reports. Empty branch_ids = every branch.
	// Presses of the till's people counter (customers in).
	BusyHoursVisitors(ctx context.Context, arg BusyHoursVisitorsParams) ([]BusyHoursVisitorsRow, error)
	// Only a command no till has acked yet can be withdrawn.
	CancelBranchCommand(ctx context.Context, id int64) (BranchCommand, error)
	// Stamps cancelled_at once; a second cancel matches no row (the handler
	// reads the row first, so that's an idempotent no-op, not an error).
	CancelBranchExpense(ctx context.Context, id int64) (BranchExpense, error)
	// Branch-reported loans only: a central loan is deleted, there's no till to
	// tell. Stamps cancelled_at once, like CancelBranchExpense.
	CancelBranchLoan(ctx context.Context, id int64) (Loan, error)
	// The once-only gate on a branch's list: 1 row the first time it's set up
	// (by a till's import or an admin save), 0 ever after.
	ClaimBranchQuickAccessInit(ctx context.Context, id int64) (int64, error)
	// Moves a due schedule on to its next run before it sends, and only if no
	// one else already did -- so a run is never sent twice.
	ClaimEmailScheduleRun(ctx context.Context, arg ClaimEmailScheduleRunParams) (int64, error)
	// Marks the poll's follow-up as sent and says where to send it; no rows when
	// it already went (a changed vote) or the number is gone. Also none when the
	// follow-up is off for this client: for_new / for_returning, a returning client
	// being one messaged before this message.
	ClaimWhatsAppPollFollowup(ctx context.Context, arg ClaimWhatsAppPollFollowupParams) (ClaimWhatsAppPollFollowupRow, error)
	// A sale's checkout finds the welcome sent to its client earlier (no invoice
	// yet, within the last 12 hours) and takes it over, so it isn't messaged twice.
	ClaimWhatsAppWelcome(ctx context.Context, arg ClaimWhatsAppWelcomeParams) (int64, error)
	ClearDefaultWhatsAppNumber(ctx context.Context) error
	// Entries are matched the way BulkSetDiscountListItems matches them: a
	// variant barcode names its product, a code names the product directly.
	ClearProductSaleOptionsForEntries(ctx context.Context, entries []string) error
	ClientPhonesPresent(ctx context.Context, dollar_1 []string) ([]string, error)
	CloseShift(ctx context.Context, id int64) error
	CompleteBranchCommand(ctx context.Context, arg CompleteBranchCommandParams) (BranchCommand, error)
	// The home page's "today" count next to the IT Management feed.
	CountAdminActivitiesSince(ctx context.Context, since time.Time) (int64, error)
	CountAssets(ctx context.Context, arg CountAssetsParams) (int64, error)
	CountAttributeValues(ctx context.Context, arg CountAttributeValuesParams) (int64, error)
	CountAuditLogs(ctx context.Context, arg CountAuditLogsParams) (int64, error)
	CountBatchesFiltered(ctx context.Context, search string) (int64, error)
	CountBranchAttendanceChanges(ctx context.Context, branchID sql.NullInt64) (int64, error)
	CountBranchAttendanceEvents(ctx context.Context, branchID sql.NullInt64) (int64, error)
	CountBranchCommands(ctx context.Context, arg CountBranchCommandsParams) (int64, error)
	CountBranchExpenseImages(ctx context.Context) (int64, error)
	CountBranchExpenseImagesForExpense(ctx context.Context, branchExpenseID int64) (int64, error)
	CountBranchExpenses(ctx context.Context, arg CountBranchExpensesParams) (int64, error)
	CountBranchInvoiceSettlements(ctx context.Context, branchID sql.NullInt64) (int64, error)
	CountBranchInvoices(ctx context.Context, branchID sql.NullInt64) (int64, error)
	CountBranchInvoicesFiltered(ctx context.Context, arg CountBranchInvoicesFilteredParams) (int64, error)
	CountBranchShiftReceiptImages(ctx context.Context) (int64, error)
	CountBranchShifts(ctx context.Context, branchID sql.NullInt64) (int64, error)
	CountBranchSyncConflicts(ctx context.Context, arg CountBranchSyncConflictsParams) (int64, error)
	// Running gross tally for one branch, one local day, one direction -- used
	// to tell the admin toast "customer in -- 42 in today".
	CountBranchVisitorDayByDirection(ctx context.Context, arg CountBranchVisitorDayByDirectionParams) (int64, error)
	CountBranchVisitorDays(ctx context.Context, branchID sql.NullInt64) (int64, error)
	// Branches with no active list of their own, i.e. discounted from the default.
	CountBranchesOnDefaultDiscountList(ctx context.Context) (int64, error)
	// How many branches reference this method, either via an explicit override
	// row or by inheriting it as-is. A payment method that any branch still
	// overrides can't be hard-deleted without leaving that override dangling
	// (or silently cascading it away), so the delete handler blocks on this and
	// points the admin at deactivating instead.
	CountCashboxAccountOverrides(ctx context.Context, cashboxAccountID int64) (int64, error)
	CountClients(ctx context.Context, clientType sql.NullString) (int64, error)
	// Same filters as ListClientsBySpending, minus the spend computation --
	// used for the rest-of-clients table's pagination total. With a branch
	// picked it counts that branch's clients: home branch, or a branch invoice
	// there (same cancelled/hidden rules as the list).
	CountClientsBySpending(ctx context.Context, arg CountClientsBySpendingParams) (int64, error)
	// Count for ListClientsBySpendingCached.
	CountClientsBySpendingCached(ctx context.Context, arg CountClientsBySpendingCachedParams) (int64, error)
	CountColors(ctx context.Context, search string) (int64, error)
	CountCoupons(ctx context.Context, arg CountCouponsParams) (int64, error)
	CountCouponsByTypeID(ctx context.Context, typeID sql.NullInt64) (int64, error)
	CountCurrencies(ctx context.Context) (int64, error)
	// Whether anything in kashi's own tables still points at this currency --
	// a payment method priced in it, or a branch override that prices one in it.
	// A currency that's still referenced can't be hard-deleted (it would either
	// violate the FK or silently orphan those rows); the delete handler blocks
	// on this and points the admin at deactivating instead.
	CountCurrencyUsage(ctx context.Context, code string) (int32, error)
	CountDashboardExpenses(ctx context.Context, arg CountDashboardExpensesParams) (int64, error)
	CountDashboardPurchases(ctx context.Context, arg CountDashboardPurchasesParams) (int64, error)
	CountDashboardSales(ctx context.Context, arg CountDashboardSalesParams) (int64, error)
	CountDiscountListItemsWithProduct(ctx context.Context, arg CountDiscountListItemsWithProductParams) (int64, error)
	// How many variants each rule of a list decides, first match wins, the way
	// refresh_discount_rules (000208) picks them. A rule giving no discount and
	// no deal writes no rows, so ListDiscountListRules counts it as 0; this is
	// what it keeps out (or gives) all the same.
	CountDiscountListRuleDecided(ctx context.Context, discountListID int64) ([]CountDiscountListRuleDecidedRow, error)
	CountDiscountLists(ctx context.Context) (int64, error)
	CountEmailReports(ctx context.Context, status sql.NullString) (int64, error)
	CountEmployees(ctx context.Context, arg CountEmployeesParams) (int64, error)
	CountExpenses(ctx context.Context, arg CountExpensesParams) (int64, error)
	// The "N synced" count beside the Recent activity feed: the same rows as
	// HomeActivityFeed received from `since` on. A plain count per table rides
	// the received_at indexes; it used to come from the feed query's windowed
	// total, which built (and coloured) every row of the week to count them.
	CountHomeActivitiesSince(ctx context.Context, since time.Time) (int64, error)
	CountIgnoredLowStockProducts(ctx context.Context, search string) (int64, error)
	CountInventories(ctx context.Context) (int64, error)
	CountInventoryStock(ctx context.Context, arg CountInventoryStockParams) (int64, error)
	CountInvoices(ctx context.Context) (int64, error)
	CountInvoicesFiltered(ctx context.Context, search string) (int64, error)
	// The home page's "today" count next to the Latest added feed: the same
	// kinds, access flags and timestamps as ListLatestAdditions, counted from
	// `since` on.
	CountLatestAdditionsSince(ctx context.Context, arg CountLatestAdditionsSinceParams) (int64, error)
	CountLoanImagesForLoan(ctx context.Context, loanID int64) (int64, error)
	CountLoanPayments(ctx context.Context, arg CountLoanPaymentsParams) (int64, error)
	CountLoans(ctx context.Context, arg CountLoansParams) (int64, error)
	CountLowStockProducts(ctx context.Context, arg CountLowStockProductsParams) (int64, error)
	CountOpenBranchSyncConflicts(ctx context.Context, branchID int64) (int64, error)
	CountOpenSecurityAlerts(ctx context.Context) (int64, error)
	// Admin users besides $1, so the last admin can't be deleted or demoted.
	CountOtherAdmins(ctx context.Context, id int64) (int64, error)
	CountPriceListItemsWithProduct(ctx context.Context, arg CountPriceListItemsWithProductParams) (int64, error)
	CountPriceListsFiltered(ctx context.Context, search string) (int64, error)
	CountProductVariants(ctx context.Context) (int64, error)
	CountPurchasesFiltered(ctx context.Context, search string) (int64, error)
	CountRegistersTargetingRelease(ctx context.Context, targetReleaseID sql.NullInt64) (int64, error)
	CountShifts(ctx context.Context, arg CountShiftsParams) (int64, error)
	CountSizes(ctx context.Context, search string) (int64, error)
	CountSlowMovingProducts(ctx context.Context, arg CountSlowMovingProductsParams) (int64, error)
	CountStockCounts(ctx context.Context, arg CountStockCountsParams) (int64, error)
	CountStockHealthByInventory(ctx context.Context, search string) (int64, error)
	CountStockMovements(ctx context.Context, arg CountStockMovementsParams) (int64, error)
	CountSuppliersFiltered(ctx context.Context, search string) (int64, error)
	CountTransferAttachments(ctx context.Context) (int64, error)
	CountTransfers(ctx context.Context, status NullTransferStatus) (int64, error)
	CountUnknownItemImages(ctx context.Context) (int64, error)
	CountUnknownItems(ctx context.Context, resolved bool) (int64, error)
	CountVariantsForBarcodes(ctx context.Context, search string) (int64, error)
	CountVisitorIPs(ctx context.Context, arg CountVisitorIPsParams) (int64, error)
	CountWhatsAppMessages(ctx context.Context, arg CountWhatsAppMessagesParams) (int64, error)
	CountWhatsAppReplies(ctx context.Context, arg CountWhatsAppRepliesParams) (int64, error)
	CreateAdminActivity(ctx context.Context, arg CreateAdminActivityParams) (AdminActivity, error)
	CreateAppRelease(ctx context.Context, arg CreateAppReleaseParams) (AppRelease, error)
	CreateAppUpdateEvent(ctx context.Context, arg CreateAppUpdateEventParams) error
	CreateAsset(ctx context.Context, arg CreateAssetParams) (Asset, error)
	CreateAssetCategory(ctx context.Context, arg CreateAssetCategoryParams) (AssetCategory, error)
	CreateAuditLog(ctx context.Context, arg CreateAuditLogParams) (AuditLog, error)
	CreateBatch(ctx context.Context, arg CreateBatchParams) (Batch, error)
	CreateBranch(ctx context.Context, arg CreateBranchParams) (Branch, error)
	CreateBranchAttendanceChange(ctx context.Context, arg CreateBranchAttendanceChangeParams) (BranchAttendanceChange, error)
	CreateBranchAttendanceEvent(ctx context.Context, arg CreateBranchAttendanceEventParams) (BranchAttendanceEvent, error)
	CreateBranchCommand(ctx context.Context, arg CreateBranchCommandParams) (BranchCommand, error)
	CreateBranchExpense(ctx context.Context, arg CreateBranchExpenseParams) (BranchExpense, error)
	CreateBranchExpenseImage(ctx context.Context, arg CreateBranchExpenseImageParams) (BranchExpenseImage, error)
	CreateBranchExpenseUploadToken(ctx context.Context, arg CreateBranchExpenseUploadTokenParams) (BranchExpenseUploadToken, error)
	CreateBranchInvoice(ctx context.Context, arg CreateBranchInvoiceParams) (BranchInvoice, error)
	CreateBranchInvoiceItem(ctx context.Context, arg CreateBranchInvoiceItemParams) (BranchInvoiceItem, error)
	CreateBranchInvoicePayment(ctx context.Context, arg CreateBranchInvoicePaymentParams) (BranchInvoicePayment, error)
	CreateBranchInvoiceSettlement(ctx context.Context, arg CreateBranchInvoiceSettlementParams) (BranchInvoiceSettlement, error)
	CreateBranchInvoiceSettlementPayment(ctx context.Context, arg CreateBranchInvoiceSettlementPaymentParams) (BranchInvoiceSettlementPayment, error)
	CreateBranchLoan(ctx context.Context, arg CreateBranchLoanParams) (Loan, error)
	CreateBranchRegister(ctx context.Context, arg CreateBranchRegisterParams) (BranchRegister, error)
	CreateBranchSalesperson(ctx context.Context, arg CreateBranchSalespersonParams) (Salesperson, error)
	CreateBranchShift(ctx context.Context, arg CreateBranchShiftParams) (BranchShift, error)
	CreateBranchShiftReceiptImage(ctx context.Context, arg CreateBranchShiftReceiptImageParams) (BranchShiftReceiptImage, error)
	CreateBranchShiftUploadToken(ctx context.Context, arg CreateBranchShiftUploadTokenParams) (BranchShiftUploadToken, error)
	CreateBranchTarget(ctx context.Context, arg CreateBranchTargetParams) (BranchTarget, error)
	CreateBranchTargetSeries(ctx context.Context, arg CreateBranchTargetSeriesParams) (BranchTargetSeries, error)
	// A branch's own proposed transfer: always starts 'requested', always
	// carries branch_id + client_ref (the idempotency key -- see
	// idx_transfers_branch_client_ref).
	CreateBranchTransferRequest(ctx context.Context, arg CreateBranchTransferRequestParams) (Transfer, error)
	CreateBranchTransferUploadToken(ctx context.Context, arg CreateBranchTransferUploadTokenParams) (BranchTransferUploadToken, error)
	CreateBranchUser(ctx context.Context, arg CreateBranchUserParams) (BranchUser, error)
	CreateBranchVisitorEvent(ctx context.Context, arg CreateBranchVisitorEventParams) (BranchVisitorEvent, error)
	CreateCalendarEvent(ctx context.Context, arg CreateCalendarEventParams) (CalendarEvent, error)
	CreateCashbox(ctx context.Context, arg CreateCashboxParams) (Cashbox, error)
	CreateCashboxAccount(ctx context.Context, arg CreateCashboxAccountParams) (CashboxAccount, error)
	CreateCentralLoan(ctx context.Context, arg CreateCentralLoanParams) (Loan, error)
	CreateClient(ctx context.Context, arg CreateClientParams) (Client, error)
	// A till-created client keeps the uid the till minted, so the till never
	// has to rewrite anything once kashi accepts it.
	CreateClientWithUID(ctx context.Context, arg CreateClientWithUIDParams) (Client, error)
	CreateColor(ctx context.Context, arg CreateColorParams) (Color, error)
	// A one-off coupon, not part of a list -- list_id stays NULL.
	CreateCoupon(ctx context.Context, arg CreateCouponParams) (Coupon, error)
	CreateCouponCategory(ctx context.Context, arg CreateCouponCategoryParams) (CouponCategory, error)
	CreateCouponList(ctx context.Context, arg CreateCouponListParams) (CouponList, error)
	CreateCouponType(ctx context.Context, arg CreateCouponTypeParams) (CouponType, error)
	CreateCurrency(ctx context.Context, arg CreateCurrencyParams) (Currency, error)
	CreateDeal(ctx context.Context, arg CreateDealParams) (Deal, error)
	CreateDiscountList(ctx context.Context, arg CreateDiscountListParams) (DiscountList, error)
	// A row written here is set by hand: it takes the row over from the rules
	// (000200), which then leave the variant alone. deal_id puts the variant on a
	// deal (000201) instead of a discount.
	CreateDiscountListItem(ctx context.Context, arg CreateDiscountListItemParams) (DiscountListItem, error)
	CreateDiscountListRule(ctx context.Context, arg CreateDiscountListRuleParams) (DiscountListRule, error)
	CreateDiscountListRuleGroup(ctx context.Context, arg CreateDiscountListRuleGroupParams) (DiscountListRuleGroup, error)
	CreateDiscountListRuleOption(ctx context.Context, arg CreateDiscountListRuleOptionParams) error
	CreateEmailReport(ctx context.Context, arg CreateEmailReportParams) (EmailReport, error)
	CreateEmailSchedule(ctx context.Context, arg CreateEmailScheduleParams) (EmailSchedule, error)
	CreateEmployee(ctx context.Context, arg CreateEmployeeParams) (Employee, error)
	CreateEntryItem(ctx context.Context, arg CreateEntryItemParams) (Entry, error)
	CreateExpense(ctx context.Context, arg CreateExpenseParams) (Expense, error)
	CreateExpenseCategory(ctx context.Context, arg CreateExpenseCategoryParams) (ExpenseCategory, error)
	// Fires one period for a recurring series -- target_amount/color are
	// passed in (a snapshot of the series at generation time) rather than
	// joined live, so a later edit to the series template never rewrites a
	// period that's already in progress or past, same as recurring_expenses'
	// FireRecurringExpenseTx snapshotting its template's amount into the
	// created expense row.
	CreateGeneratedBranchTarget(ctx context.Context, arg CreateGeneratedBranchTargetParams) (BranchTarget, error)
	CreateGooglePlaceSnapshot(ctx context.Context, arg CreateGooglePlaceSnapshotParams) error
	CreateInventory(ctx context.Context, arg CreateInventoryParams) (Inventory, error)
	CreateInvoice(ctx context.Context, arg CreateInvoiceParams) (Invoice, error)
	CreateInvoiceDiscount(ctx context.Context, arg CreateInvoiceDiscountParams) (InvoiceDiscount, error)
	CreateInvoicePayment(ctx context.Context, arg CreateInvoicePaymentParams) (InvoicePayment, error)
	CreateInvoiceType(ctx context.Context, arg CreateInvoiceTypeParams) (InvoiceType, error)
	// One code minted as part of a coupon_lists batch (see coupon_list.sql).
	// Not pre-assigned to a client -- whoever redeems it first claims it.
	CreateListCoupon(ctx context.Context, arg CreateListCouponParams) (Coupon, error)
	CreateLoanCategory(ctx context.Context, arg CreateLoanCategoryParams) (LoanCategory, error)
	CreateLoanImage(ctx context.Context, arg CreateLoanImageParams) (LoanImage, error)
	CreateLoanPayment(ctx context.Context, arg CreateLoanPaymentParams) (LoanPayment, error)
	CreateLoanUploadToken(ctx context.Context, arg CreateLoanUploadTokenParams) (LoanUploadToken, error)
	CreatePriceList(ctx context.Context, arg CreatePriceListParams) (PriceList, error)
	CreatePriceListItem(ctx context.Context, arg CreatePriceListItemParams) (PriceListItem, error)
	CreateProduct(ctx context.Context, arg CreateProductParams) (Product, error)
	CreateProductAttribute(ctx context.Context, arg CreateProductAttributeParams) (ProductsAttribute, error)
	CreateProductCategory(ctx context.Context, arg CreateProductCategoryParams) (ProductCategory, error)
	// No price column: since 000094 a variant's price is an entry in a price
	// list, not a property of the variant, so a newly created variant starts with
	// no price and is unsellable until it is added to one.
	CreateProductVariant(ctx context.Context, arg CreateProductVariantParams) (ProductVariant, error)
	CreatePurchase(ctx context.Context, arg CreatePurchaseParams) (Purchase, error)
	CreateRecurringExpense(ctx context.Context, arg CreateRecurringExpenseParams) (RecurringExpense, error)
	CreateResolvedBranchInvoiceItem(ctx context.Context, arg CreateResolvedBranchInvoiceItemParams) error
	CreateReturnInvoice(ctx context.Context, arg CreateReturnInvoiceParams) (ReturnInvoice, error)
	CreateReviewLinkClick(ctx context.Context, arg CreateReviewLinkClickParams) error
	CreateRole(ctx context.Context, name string) (Role, error)
	CreateSaleOption(ctx context.Context, arg CreateSaleOptionParams) (SaleOption, error)
	CreateSalesInvoice(ctx context.Context, invoiceID int64) (int64, error)
	CreateSalesperson(ctx context.Context, arg CreateSalespersonParams) (Salesperson, error)
	CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
	CreateShift(ctx context.Context, cashboxID int64) (Shift, error)
	CreateSize(ctx context.Context, arg CreateSizeParams) (Size, error)
	CreateStockCount(ctx context.Context, arg CreateStockCountParams) (StockCount, error)
	// ---------------------------------------------------------------------------
	// Stock movement ledger (append-only).
	// ---------------------------------------------------------------------------
	CreateStockMovement(ctx context.Context, arg CreateStockMovementParams) (StockMovement, error)
	CreateSupplier(ctx context.Context, arg CreateSupplierParams) (Supplier, error)
	CreateTransfer(ctx context.Context, arg CreateTransferParams) (Transfer, error)
	CreateTransferItem(ctx context.Context, arg CreateTransferItemParams) (TransferItem, error)
	CreateUnknownItemImage(ctx context.Context, arg CreateUnknownItemImageParams) (UnknownItemImage, error)
	CreateUnknownItemSession(ctx context.Context, arg CreateUnknownItemSessionParams) (UnknownItemSession, error)
	// A till re-sending its session as the cart changes moves and relabels the
	// units it already sent; their pictures stay.
	CreateUnknownItemSlot(ctx context.Context, arg CreateUnknownItemSlotParams) error
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	CreateWhatsAppMessage(ctx context.Context, arg CreateWhatsAppMessageParams) (WhatsappMessage, error)
	// The first number becomes the default.
	CreateWhatsAppNumber(ctx context.Context, arg CreateWhatsAppNumberParams) (WhatsappNumber, error)
	// Linked to the message it answers: the one the client replied to, else the
	// last one sent to that number in the week before. Meta can deliver the same
	// webhook twice; the wamid keeps it to one row.
	CreateWhatsAppReply(ctx context.Context, arg CreateWhatsAppReplyParams) error
	CreateWhatsAppRule(ctx context.Context, arg CreateWhatsAppRuleParams) (WhatsappRule, error)
	// Queries behind the home dashboard's Overview tab: the summary cards, the
	// revenue/expense trend charts, and the aggregated Sales / Purchases /
	// Recent Expenses tables. Every query takes a half-open [date_from,
	// date_to) timestamptz range (the handler passes start-of-next-day as
	// date_to) and, where a branch dimension exists, a nullable branch_id
	// (NULL = all branches, same convention as ListBranchInvoices).
	//
	// "branch" data is what the POS branches sync up (branch_invoices,
	// branch_expenses); "admin" data is kashi's own centrally-entered records
	// (invoices/sales_invoices, expenses). The dashboard's scope filter picks
	// one or both; the list queries take that as an explicit `scope` arg so a
	// single UNION ALL can serve all three modes, while the scalar summary
	// queries are split per source and the handler adds up whichever apply.
	// One chronological feed across every kind of persisted branch sync. The
	// union happens before LIMIT/OFFSET so pagination is correct globally, not
	// independently per source table. received_at is used deliberately: this
	// table answers "what synced recently", even when a branch catches up an
	// older occurred_at record.
	// person is who did it on the till (salesperson / closing cashier), ” when
	// the till doesn't record one; person_color is that salesperson's own
	// colour, ” when they have none.
	DashboardActivitiesList(ctx context.Context, arg DashboardActivitiesListParams) ([]DashboardActivitiesListRow, error)
	DashboardAdminExpenseSeries(ctx context.Context, arg DashboardAdminExpenseSeriesParams) ([]DashboardAdminExpenseSeriesRow, error)
	DashboardAdminExpensesTotal(ctx context.Context, arg DashboardAdminExpensesTotalParams) (int64, error)
	DashboardAdminNewClients(ctx context.Context, arg DashboardAdminNewClientsParams) (int64, error)
	DashboardAdminRevenueSeries(ctx context.Context, arg DashboardAdminRevenueSeriesParams) ([]DashboardAdminRevenueSeriesRow, error)
	DashboardAdminSummary(ctx context.Context, arg DashboardAdminSummaryParams) (DashboardAdminSummaryRow, error)
	DashboardBranchExpenseSeries(ctx context.Context, arg DashboardBranchExpenseSeriesParams) ([]DashboardBranchExpenseSeriesRow, error)
	DashboardBranchExpensesTotal(ctx context.Context, arg DashboardBranchExpensesTotalParams) (int64, error)
	// Clients first seen at a branch in the range. With a branch selected,
	// count distinct linked clients whose central row was created in-range;
	// with no branch, every client created in-range.
	DashboardBranchNewClients(ctx context.Context, arg DashboardBranchNewClientsParams) (int64, error)
	DashboardBranchRevenueSeries(ctx context.Context, arg DashboardBranchRevenueSeriesParams) ([]DashboardBranchRevenueSeriesRow, error)
	// items_sold / revenue / invoice count for branch sales in the range.
	// Returns are excluded from items_sold and the count (they aren't sales),
	// but revenue sums every kind so refunds net out, matching ListDailyIncome.
	DashboardBranchSummary(ctx context.Context, arg DashboardBranchSummaryParams) (DashboardBranchSummaryRow, error)
	// Outstanding loan balance = disbursed - repaid. loans has no due date, so
	// "due" here just means still owed. Branch arm = origin 'branch_loan'
	// (scoped by branch_id when set); admin arm = origin 'central_loan'.
	// loan_payments carry no branch dimension of their own, so they follow
	// their parent loan's arm. Not date-range bound -- a balance, not a flow.
	DashboardDueLoans(ctx context.Context, arg DashboardDueLoansParams) (int64, error)
	// image_id is 0, not NULL, when an expense has no receipt photo (admin
	// expenses never do): keeps the generated column a plain int64 and lets
	// the frontend treat 0 as "no image".
	DashboardExpensesList(ctx context.Context, arg DashboardExpensesListParams) ([]DashboardExpensesListRow, error)
	DashboardPurchaseSeries(ctx context.Context, arg DashboardPurchaseSeriesParams) ([]DashboardPurchaseSeriesRow, error)
	// Purchases are admin-only -- there is no branch purchase concept -- so the
	// scope arg only ever excludes them (scope = 'branch'), never adds a second
	// source. total is summed from purchase_items since purchases carries no
	// amount column of its own.
	DashboardPurchasesList(ctx context.Context, arg DashboardPurchasesListParams) ([]DashboardPurchasesListRow, error)
	// Cost of goods bought in the range. Admin-only (no branch purchase
	// concept); total is summed from purchase_items since purchases carries no
	// amount column of its own, matching DashboardPurchasesList.
	DashboardPurchasesTotal(ctx context.Context, arg DashboardPurchasesTotalParams) (int64, error)
	// currency is the app's single default currency code (every amount in the
	// schema is stored in its minor unit -- see 000009_create_currencies).
	// The branch-invoice client name is resolved through client_links; when
	// the branch never synced a client link it comes back empty.
	DashboardSalesList(ctx context.Context, arg DashboardSalesListParams) ([]DashboardSalesListRow, error)
	// Every branch_target that is active and spans `as_of` (today), with its
	// live revenue (the target's own [date_from, date_to] window against its
	// own branch). One progress bar per row on the dashboard; the handler also
	// sums these for the overall attainment percentage. branch_targets are
	// branch-only, so the handler skips this under admin scope.
	DashboardTargetList(ctx context.Context, arg DashboardTargetListParams) ([]DashboardTargetListRow, error)
	// The loans with the largest outstanding balance, for the dashboard's
	// "Due Loans" list. Same scope/branch gating as DashboardDueLoans; fully
	// repaid loans (outstanding <= 0) are dropped.
	DashboardTopDueLoans(ctx context.Context, arg DashboardTopDueLoansParams) ([]DashboardTopDueLoansRow, error)
	// Part of deleting a whole recurring series (see DeleteBranchTargetSeriesTx
	// in tx_branch_target_series.go) -- every period it ever generated needs
	// to disappear the same way a single deleted target does, not just stop
	// getting new ones.
	DeactivateBranchTargetsBySeries(ctx context.Context, seriesID sql.NullInt64) error
	DeactivateCoupon(ctx context.Context, code string) error
	// Deactivating the list itself just stops it appearing as "open" in the
	// admin UI; the codes it already minted are deactivated separately below
	// so an in-flight redemption on a disconnected till isn't silently
	// resurrected once it reconnects.
	DeactivateCouponList(ctx context.Context, id int64) error
	DeactivateCouponsForList(ctx context.Context, listID sql.NullInt64) (int64, error)
	DecrementInvoicesIndex(ctx context.Context, arg DecrementInvoicesIndexParams) (int64, error)
	DeleteAllWhatsAppRules(ctx context.Context) error
	DeleteAppRelease(ctx context.Context, id int64) error
	DeleteAsset(ctx context.Context, id int64) error
	DeleteAssetCategory(ctx context.Context, id int64) error
	DeleteAssets(ctx context.Context, ids []int64) (int64, error)
	DeleteAttributeValue(ctx context.Context, id int64) error
	DeleteAttributeValues(ctx context.Context, ids []int64) (int64, error)
	DeleteBatch(ctx context.Context, id int64) error
	DeleteBranchAttendanceEvent(ctx context.Context, id int64) error
	DeleteBranchInvoicePaymentsForInvoice(ctx context.Context, branchInvoiceID int64) error
	DeleteBranchQuickAccessItems(ctx context.Context, branchID int64) error
	DeleteBranchTargetSeries(ctx context.Context, id int64) (BranchTargetSeries, error)
	DeleteBranchUser(ctx context.Context, id int64) error
	DeleteCalendarEvent(ctx context.Context, id int64) error
	DeleteCashboxAccount(ctx context.Context, id int64) error
	// Back to inheriting central. Deleting the row rather than writing one full
	// of NULLs keeps "no override" a single state instead of two.
	DeleteCashboxAccountOverride(ctx context.Context, arg DeleteCashboxAccountOverrideParams) error
	DeleteClient(ctx context.Context, id int64) error
	DeleteColor(ctx context.Context, id int64) error
	DeleteColors(ctx context.Context, ids []int64) (int64, error)
	DeleteCouponCategory(ctx context.Context, id int64) error
	DeleteCouponType(ctx context.Context, id int64) error
	DeleteCoupons(ctx context.Context, codes []string) (int64, error)
	DeleteCurrencies(ctx context.Context, codes []string) (int64, error)
	DeleteCurrency(ctx context.Context, code string) error
	DeleteDeal(ctx context.Context, id int64) error
	DeleteDiscountList(ctx context.Context, id int64) error
	DeleteDiscountListBranch(ctx context.Context, branchID int64) error
	DeleteDiscountListBranchesForList(ctx context.Context, discountListID int64) error
	DeleteDiscountListItem(ctx context.Context, arg DeleteDiscountListItemParams) error
	DeleteDiscountListItems(ctx context.Context, arg DeleteDiscountListItemsParams) (int64, error)
	DeleteDiscountListOptionItem(ctx context.Context, arg DeleteDiscountListOptionItemParams) error
	// Rows are named by (variant, option) pairs, given as two parallel arrays;
	// two unnests in one select list zip them pairwise.
	DeleteDiscountListOptionItems(ctx context.Context, arg DeleteDiscountListOptionItemsParams) (int64, error)
	// Their rules go with them (ON DELETE CASCADE).
	DeleteDiscountListRuleGroups(ctx context.Context, discountListID int64) error
	DeleteDiscountListRuleGroupsExcept(ctx context.Context, arg DeleteDiscountListRuleGroupsExceptParams) error
	DeleteDiscountListRuleOptions(ctx context.Context, ruleID int64) error
	DeleteDiscountListRules(ctx context.Context, discountListID int64) error
	DeleteDiscountListRulesExcept(ctx context.Context, arg DeleteDiscountListRulesExceptParams) error
	DeleteEmailSchedule(ctx context.Context, id int64) error
	DeleteEmployee(ctx context.Context, id int64) error
	DeleteExpense(ctx context.Context, id int64) error
	DeleteExpenseCategory(ctx context.Context, id int64) error
	DeleteExpenses(ctx context.Context, ids []int64) (int64, error)
	// A till retrying a thank-you after a temporary failure: its earlier failed
	// rows go, so the log keeps one row per sale showing how it ended.
	DeleteFailedWhatsAppMessagesForInvoice(ctx context.Context, arg DeleteFailedWhatsAppMessagesForInvoiceParams) error
	// Deletes a historical backfill invoice (and, via ON DELETE CASCADE, its
	// items and payments) so it can be re-imported with corrected data. The
	// historical=true guard means this can never remove a real till's sale,
	// even given a wrong id -- see deleteBranchInvoice in api/branch_invoice.go.
	DeleteHistoricalBranchInvoice(ctx context.Context, id int64) (int64, error)
	DeleteIPBan(ctx context.Context, ip string) error
	DeleteInventories(ctx context.Context, ids []int64) (int64, error)
	DeleteInventory(ctx context.Context, id int64) error
	// Kept, marked deleted: the tills drop it when it comes down as not
	// applying to them (000212).
	DeleteInvoiceDiscount(ctx context.Context, id int64) error
	DeleteInvoiceDiscountBranches(ctx context.Context, invoiceDiscountID int64) error
	DeleteLoan(ctx context.Context, id int64) error
	DeleteLoanCategory(ctx context.Context, id int64) error
	DeleteLoanPayment(ctx context.Context, id int64) error
	// Central loans only, same read-only guard as DeleteLoan.
	DeleteLoans(ctx context.Context, ids []int64) (int64, error)
	DeletePriceList(ctx context.Context, id int64) error
	DeletePriceListBranch(ctx context.Context, branchID int64) error
	DeletePriceListBranchesForList(ctx context.Context, priceListID int64) error
	DeletePriceListItem(ctx context.Context, arg DeletePriceListItemParams) error
	DeletePriceListItems(ctx context.Context, arg DeletePriceListItemsParams) (int64, error)
	DeleteProduct(ctx context.Context, id int64) error
	DeleteProductCategory(ctx context.Context, id int64) error
	DeleteProductVariant(ctx context.Context, id int64) error
	DeletePurchaseItem(ctx context.Context, arg DeletePurchaseItemParams) error
	DeleteRole(ctx context.Context, id int64) error
	DeleteRolePermissions(ctx context.Context, roleID int64) error
	DeleteSalesperson(ctx context.Context, id int64) error
	DeleteSize(ctx context.Context, id int64) error
	DeleteSizes(ctx context.Context, ids []int64) (int64, error)
	DeleteStockCountItems(ctx context.Context, stockCountID int64) error
	DeleteTransferItem(ctx context.Context, arg DeleteTransferItemParams) error
	DeleteUnknownItemImages(ctx context.Context, dollar_1 []int64) error
	// Units taken off the cart since the session was last sent.
	DeleteUnknownItemSlotsNotIn(ctx context.Context, arg DeleteUnknownItemSlotsNotInParams) error
	DeleteUser(ctx context.Context, id int64) error
	DeleteWhatsAppNumber(ctx context.Context, id int64) error
	FindUnknownInvoiceItem(ctx context.Context, arg FindUnknownInvoiceItemParams) (BranchInvoiceItem, error)
	GetAppRelease(ctx context.Context, id int64) (AppRelease, error)
	GetAppSettings(ctx context.Context) (AppSetting, error)
	GetAsset(ctx context.Context, id int64) (Asset, error)
	GetAssetByName(ctx context.Context, name string) (Asset, error)
	GetAssetCategory(ctx context.Context, id int64) (AssetCategory, error)
	GetAssetCategoryByName(ctx context.Context, name string) (AssetCategory, error)
	GetAssetTreemapData(ctx context.Context, inventoryID sql.NullInt64) ([]GetAssetTreemapDataRow, error)
	GetAttribute(ctx context.Context, name string) (Attribute, error)
	// upserting instead of inserting makes product creation with attributes easier
	GetAttributeValue(ctx context.Context, id int64) (AttributesValue, error)
	GetBatch(ctx context.Context, id int64) (GetBatchRow, error)
	GetBatchItemByBatchVariant(ctx context.Context, arg GetBatchItemByBatchVariantParams) (BatchItem, error)
	GetBranch(ctx context.Context, id int64) (Branch, error)
	GetBranchAttendanceChange(ctx context.Context, id int64) (BranchAttendanceChange, error)
	GetBranchAttendanceChangeByClientRef(ctx context.Context, arg GetBranchAttendanceChangeByClientRefParams) (BranchAttendanceChange, error)
	GetBranchAttendanceEvent(ctx context.Context, id int64) (BranchAttendanceEvent, error)
	GetBranchAttendanceEventByClientRef(ctx context.Context, arg GetBranchAttendanceEventByClientRefParams) (BranchAttendanceEvent, error)
	GetBranchByCode(ctx context.Context, code string) (Branch, error)
	// Resolves a till's chosen transfer destination by branch code, refusing
	// a branch naming itself as its own destination.
	GetBranchByCodeExcluding(ctx context.Context, arg GetBranchByCodeExcludingParams) (Branch, error)
	GetBranchCommand(ctx context.Context, id int64) (BranchCommand, error)
	GetBranchExpense(ctx context.Context, id int64) (BranchExpense, error)
	GetBranchExpenseByClientRef(ctx context.Context, arg GetBranchExpenseByClientRefParams) (BranchExpense, error)
	GetBranchExpenseImage(ctx context.Context, id int64) (BranchExpenseImage, error)
	GetBranchExpenseUploadTokenByToken(ctx context.Context, token string) (BranchExpenseUploadToken, error)
	GetBranchInvoice(ctx context.Context, id int64) (BranchInvoice, error)
	GetBranchInvoiceByClientRef(ctx context.Context, arg GetBranchInvoiceByClientRefParams) (BranchInvoice, error)
	// The sale a WhatsApp message was about (whatsapp_conversation.go).
	GetBranchInvoiceByCode(ctx context.Context, arg GetBranchInvoiceByCodeParams) (BranchInvoice, error)
	GetBranchInvoiceSettlement(ctx context.Context, id int64) (BranchInvoiceSettlement, error)
	GetBranchInvoiceSettlementByClientRef(ctx context.Context, arg GetBranchInvoiceSettlementByClientRefParams) (BranchInvoiceSettlement, error)
	GetBranchLoanByClientRef(ctx context.Context, arg GetBranchLoanByClientRefParams) (Loan, error)
	GetBranchRegister(ctx context.Context, id int64) (BranchRegister, error)
	GetBranchRegisterByCode(ctx context.Context, code string) (BranchRegister, error)
	GetBranchSettings(ctx context.Context, branchID int64) (BranchSetting, error)
	GetBranchShift(ctx context.Context, id int64) (BranchShift, error)
	GetBranchShiftByClientRef(ctx context.Context, arg GetBranchShiftByClientRefParams) (BranchShift, error)
	GetBranchShiftReceiptImage(ctx context.Context, id int64) (BranchShiftReceiptImage, error)
	GetBranchShiftReceiptImageForShift(ctx context.Context, branchShiftID int64) (BranchShiftReceiptImage, error)
	GetBranchShiftUploadTokenByToken(ctx context.Context, token string) (BranchShiftUploadToken, error)
	GetBranchSyncConflict(ctx context.Context, id int64) (BranchSyncConflict, error)
	GetBranchTarget(ctx context.Context, id int64) (BranchTarget, error)
	GetBranchTargetBySeriesAndStart(ctx context.Context, arg GetBranchTargetBySeriesAndStartParams) (BranchTarget, error)
	GetBranchTargetSeries(ctx context.Context, id int64) (BranchTargetSeries, error)
	GetBranchTransferByClientRef(ctx context.Context, arg GetBranchTransferByClientRefParams) (Transfer, error)
	GetBranchTransferUploadTokenByToken(ctx context.Context, token string) (BranchTransferUploadToken, error)
	GetBranchUser(ctx context.Context, id int64) (BranchUser, error)
	GetBranchVisitorEventByClientRef(ctx context.Context, arg GetBranchVisitorEventByClientRefParams) (BranchVisitorEvent, error)
	GetCashbox(ctx context.Context, id int64) (Cashbox, error)
	GetCashboxAccount(ctx context.Context, id int64) (CashboxAccount, error)
	GetCashboxAccountBalance(ctx context.Context, arg GetCashboxAccountBalanceParams) (ShiftsAccountsBalance, error)
	GetClient(ctx context.Context, id int64) (Client, error)
	GetClientByPhone(ctx context.Context, phone string) (Client, error)
	// Shared-identity (uid) queries for branch sync. See 000093_sync_uid.up.sql.
	GetClientByUID(ctx context.Context, uid uuid.UUID) (Client, error)
	GetClientLink(ctx context.Context, arg GetClientLinkParams) (int64, error)
	GetColorByName(ctx context.Context, name string) (Color, error)
	GetCoupon(ctx context.Context, code string) (Coupon, error)
	GetCouponCategory(ctx context.Context, id int64) (CouponCategory, error)
	GetCouponList(ctx context.Context, id int64) (CouponList, error)
	GetCouponType(ctx context.Context, id int64) (CouponType, error)
	GetCurrency(ctx context.Context, code string) (Currency, error)
	GetDeal(ctx context.Context, id int64) (Deal, error)
	GetDefaultBranchSettings(ctx context.Context) (DefaultBranchSetting, error)
	GetDefaultCurrency(ctx context.Context) (Currency, error)
	GetDefaultDiscountForVariant(ctx context.Context, productVariantID int64) (int16, error)
	GetDefaultDiscountList(ctx context.Context) (DiscountList, error)
	GetDefaultInvoiceType(ctx context.Context) (InvoiceType, error)
	// Branch-independent price, for the contexts that have no branch to speak of:
	// printed labels, stock listings, head-office reporting.
	GetDefaultPriceForVariant(ctx context.Context, productVariantID int64) (int64, error)
	GetDefaultPriceList(ctx context.Context) (PriceList, error)
	GetDiscountList(ctx context.Context, id int64) (DiscountList, error)
	GetDiscountListBranch(ctx context.Context, branchID int64) (DiscountListBranch, error)
	GetDiscountListByUID(ctx context.Context, uid uuid.UUID) (DiscountList, error)
	GetEmailResendAPIKey(ctx context.Context) (string, error)
	GetEmailSchedule(ctx context.Context, id int64) (EmailSchedule, error)
	GetEmailSettings(ctx context.Context) (GetEmailSettingsRow, error)
	GetEmployee(ctx context.Context, id int64) (Employee, error)
	GetEntry(ctx context.Context, id int64) (Entry, error)
	GetExpense(ctx context.Context, id int64) (Expense, error)
	GetExpenseCategory(ctx context.Context, id int64) (ExpenseCategory, error)
	// One representative barcode per product code, for linking an external
	// sales import's line (which only ever has the product code, not a
	// specific color/size) to a real product_variants row -- see
	// api/product_cost_import.go's sibling, the invoice line-linking script.
	// Picks the lowest-id active variant; which exact variant doesn't matter
	// for revenue/cost attribution, only that the line resolves to the right
	// product instead of staying an unlinked placeholder.
	GetFirstActiveVariantBarcodeByCode(ctx context.Context, code string) (GetFirstActiveVariantBarcodeByCodeRow, error)
	GetInventory(ctx context.Context, id int64) (Inventory, error)
	GetInventoryByName(ctx context.Context, name string) (Inventory, error)
	// ---------------------------------------------------------------------------
	// Per-variant stock: cached on-hand quantity + moving-average cost.
	// ---------------------------------------------------------------------------
	GetInventoryStock(ctx context.Context, arg GetInventoryStockParams) (InventoryStock, error)
	GetInvoice(ctx context.Context, id int64) (Invoice, error)
	GetInvoiceType(ctx context.Context, id int64) (InvoiceType, error)
	GetLoan(ctx context.Context, id int64) (Loan, error)
	GetLoanCategory(ctx context.Context, id int64) (LoanCategory, error)
	GetLoanImage(ctx context.Context, id int64) (LoanImage, error)
	GetLoanPayment(ctx context.Context, id int64) (LoanPayment, error)
	GetLoanUploadTokenByToken(ctx context.Context, token string) (LoanUploadToken, error)
	// Counts across all active, alert-enabled products, ignoring search --
	// backs the summary cards, which should reflect the whole picture even
	// while the table below is filtered.
	GetLowStockSummary(ctx context.Context) (GetLowStockSummaryRow, error)
	GetNextBarcodeItemValue(ctx context.Context) (int64, error)
	GetPriceList(ctx context.Context, id int64) (PriceList, error)
	GetPriceListBranch(ctx context.Context, branchID int64) (PriceListBranch, error)
	GetPriceListByUID(ctx context.Context, uid uuid.UUID) (PriceList, error)
	GetProduct(ctx context.Context, id int64) (Product, error)
	GetProductAttributeValue(ctx context.Context, arg GetProductAttributeValueParams) (ProductsAttribute, error)
	GetProductAttributes(ctx context.Context, productID int64) ([]ProductsAttribute, error)
	// -- name: CreatePriceList :one
	// INSERT INTO price_lists (
	//   name,
	//   is_active,
	//   is_default,
	//   valid_from,
	//   valid_to
	// ) VALUES (
	//     $1, $2, $3, $4, $5
	// ) RETURNING *;
	// -- name: ListPriceLists :many
	// SELECT * FROM price_lists
	// ORDER BY name
	// LIMIT $1
	// OFFSET $2;
	// -- name: UpdatePriceList :exec
	// UPDATE price_lists
	//   SET name = $2,
	//   is_active = $3,
	//   is_default = $4,
	//   valid_from = $5,
	//   valid_to = $6
	// WHERE id = $1;
	// -- name: CreateProductPrice :one
	// INSERT INTO price_list_items (
	//   price_list_id,
	//   product_id,
	//   price
	// ) VALUES (
	//     $1, $2, $3
	// ) RETURNING *;
	// -- name: UpdateProductPrice :exec
	// UPDATE price_list_items
	//   SET price = $3
	// WHERE product_id = $1 AND price_list_id = $2;
	// -- name: CreateDiscountList :one
	// INSERT INTO discount_lists (
	//   name,
	//   is_active,
	//   is_default,
	//   valid_from,
	//   valid_to
	// ) VALUES (
	//     $1, $2, $3, $4, $5
	// ) RETURNING *;
	// -- name: ListDiscountLists :many
	// SELECT * FROM discount_lists
	// ORDER BY name
	// LIMIT $1
	// OFFSET $2;
	// -- name: UpdateDiscountList :exec
	// UPDATE price_lists
	//   SET name = $2,
	//   is_active = $3,
	//   is_default = $4,
	//   valid_from = $5,
	//   valid_to = $6
	// WHERE id = $1;
	// -- name: UnsetDefaultPriceList :exec
	// UPDATE price_lists
	//   SET is_default = false
	// WHERE is_default = true;
	// -- name: CreateProductDiscount :one
	// INSERT INTO discount_list_items (
	//   discount_list_id,
	//   product_id,
	//   discount
	// ) VALUES (
	//     $1, $2, $3
	// ) RETURNING *;
	// -- name: UpdateProductDiscount :exec
	// UPDATE discount_list_items
	//   SET discount = $3
	// WHERE product_id = $1 AND discount_list_id = $2;
	GetProductByCode(ctx context.Context, code string) (Product, error)
	GetProductByName(ctx context.Context, name string) (Product, error)
	GetProductCategory(ctx context.Context, id int64) (ProductCategory, error)
	GetProductCategoryByName(ctx context.Context, name string) (ProductCategory, error)
	GetProductSupplier(ctx context.Context, arg GetProductSupplierParams) (ProductSupplier, error)
	GetProductVariant(ctx context.Context, id int64) (ProductVariant, error)
	GetProductVariantByBarcode(ctx context.Context, barcode string) (ProductVariant, error)
	GetProductVariantByUID(ctx context.Context, uid uuid.UUID) (ProductVariant, error)
	GetPurchase(ctx context.Context, id int64) (GetPurchaseRow, error)
	GetRecurringExpense(ctx context.Context, id int64) (RecurringExpense, error)
	GetRegisterTargetRelease(ctx context.Context, id int64) (GetRegisterTargetReleaseRow, error)
	GetReturnInvoice(ctx context.Context, invoiceID int64) (ReturnInvoice, error)
	// Review links in the post-sale WhatsApp message and the Google data behind
	// the Reviews page (api/review_link.go, api/google_places.go).
	GetReviewSettings(ctx context.Context) (GetReviewSettingsRow, error)
	GetRole(ctx context.Context, id int64) (Role, error)
	GetSaleOption(ctx context.Context, id int64) (SaleOption, error)
	GetSalesInvoice(ctx context.Context, invoiceID int64) (int64, error)
	GetSalesperson(ctx context.Context, id int64) (Salesperson, error)
	// Another salesperson of the same branch already using this device number.
	GetSalespersonByAttendanceID(ctx context.Context, arg GetSalespersonByAttendanceIDParams) (Salesperson, error)
	GetSecuritySettings(ctx context.Context) (SecuritySetting, error)
	GetSession(ctx context.Context, id uuid.UUID) (Session, error)
	GetShift(ctx context.Context, id int64) (Shift, error)
	GetSizeByName(ctx context.Context, name string) (Size, error)
	GetSlowMoverSummary(ctx context.Context) (GetSlowMoverSummaryRow, error)
	GetStockCount(ctx context.Context, id int64) (StockCount, error)
	// Inventory health: overall days-of-inventory (on-hand / trailing daily
	// sell-through), total inventory value at moving-average cost, and the
	// same breakdown per inventory location.
	GetStockHealthOverview(ctx context.Context) (GetStockHealthOverviewRow, error)
	GetSupplier(ctx context.Context, id int64) (Supplier, error)
	GetTransfer(ctx context.Context, id int64) (Transfer, error)
	GetUnknownItemImage(ctx context.Context, id int64) (UnknownItemImage, error)
	GetUnknownItemSessionByRef(ctx context.Context, arg GetUnknownItemSessionByRefParams) (UnknownItemSession, error)
	GetUnknownItemSessionByToken(ctx context.Context, token string) (UnknownItemSession, error)
	GetUnknownItemSlotByRef(ctx context.Context, arg GetUnknownItemSlotByRefParams) (UnknownItemSlot, error)
	GetUnknownItemSlotForResolve(ctx context.Context, id int64) (GetUnknownItemSlotForResolveRow, error)
	GetUser(ctx context.Context, id int64) (User, error)
	// One row per permission of the user's role, or a single row with NULL
	// section for a role that has none (an admin, or a brand-new role). No rows
	// at all means the user no longer exists.
	GetUserAccess(ctx context.Context, id int64) ([]GetUserAccessRow, error)
	GetUserByUsername(ctx context.Context, username string) (User, error)
	GetVariantDiscountFromList(ctx context.Context, arg GetVariantDiscountFromListParams) (DiscountListItem, error)
	GetVariantForLabel(ctx context.Context, id int64) (GetVariantForLabelRow, error)
	GetVariantPriceFromList(ctx context.Context, arg GetVariantPriceFromListParams) (PriceListItem, error)
	GetVariantTotalOnHand(ctx context.Context, variantID int64) (int64, error)
	// Feeds the Warehouses Treemap: on-hand quantity per product, grouped by
	// product_categories and by inventory. The inner join on product_categories
	// means only products we've explicitly categorized show up here -- ordinary
	// POS-sellable products with no category_id are never pulled into this view.
	GetWarehouseTreemapData(ctx context.Context, inventoryID sql.NullInt64) ([]GetWarehouseTreemapDataRow, error)
	GetWhatsAppChatMessageMedia(ctx context.Context, id int64) (GetWhatsAppChatMessageMediaRow, error)
	GetWhatsAppMessageByReviewCode(ctx context.Context, reviewCode string) (GetWhatsAppMessageByReviewCodeRow, error)
	GetWhatsAppMessageCost(ctx context.Context) (int64, error)
	GetWhatsAppMessageWithBranch(ctx context.Context, id int64) (GetWhatsAppMessageWithBranchRow, error)
	GetWhatsAppNumber(ctx context.Context, id int64) (WhatsappNumber, error)
	// Where a reply's media is kept: the bridge number that got it, and its id.
	GetWhatsAppPollReplyMedia(ctx context.Context, id int64) (GetWhatsAppPollReplyMediaRow, error)
	// Sending post-sale messages from our own numbers through the WhatsApp
	// bridge (api/whatsapp_bridge.go).
	GetWhatsAppSenderSettings(ctx context.Context) (GetWhatsAppSenderSettingsRow, error)
	GetWhatsAppSettings(ctx context.Context) (GetWhatsAppSettingsRow, error)
	// The place as it stood at `at`: its last snapshot taken before then.
	GooglePlaceSnapshotBefore(ctx context.Context, arg GooglePlaceSnapshotBeforeParams) (GooglePlaceSnapshot, error)
	// The home page's "Recent activity" feed: the same rows as
	// DashboardActivitiesList (every kind of branch sync, newest received
	// first, hidden branches and registers left out), but paged by a keyset
	// cursor instead of a date window and an offset, and without the windowed
	// total. Each page is the next page_size rows after (before_at,
	// before_activity, before_id) -- the last row the feed already has -- so
	// the per-table received_at indexes do the work and a page costs the same
	// however far down the feed is scrolled. The salesperson colour is looked
	// up for the page's rows only.
	HomeActivityFeed(ctx context.Context, arg HomeActivityFeedParams) ([]HomeActivityFeedRow, error)
	IncrementInvoicesIndex(ctx context.Context, arg IncrementInvoicesIndexParams) (int64, error)
	// A sale can reach kashi after the return that cancelled it (a resync pushes
	// whatever kashi is missing, in no guaranteed order); it picks up the mark the
	// cancellation already left waiting for it.
	InheritBranchInvoiceCancellation(ctx context.Context, id int64) error
	InsertBranchQuickAccessItem(ctx context.Context, arg InsertBranchQuickAccessItemParams) error
	// When this phone was last actually messaged; no rows when never.
	LastWhatsAppSentAt(ctx context.Context, clientPhone string) (time.Time, error)
	LatestGooglePlaceSnapshot(ctx context.Context, placeID string) (GooglePlaceSnapshot, error)
	LinkUnknownItemSession(ctx context.Context, arg LinkUnknownItemSessionParams) error
	ListActiveBranchRegisterIDs(ctx context.Context, branchID int64) ([]int64, error)
	ListActiveBranchTargetSeries(ctx context.Context) ([]BranchTargetSeries, error)
	ListActiveIPBans(ctx context.Context) ([]IpBan, error)
	// User and role changes are admin housekeeping, kept out of the feed.
	ListAdminActivities(ctx context.Context, arg ListAdminActivitiesParams) ([]ListAdminActivitiesRow, error)
	ListAllAttributeValues(ctx context.Context) ([]ListAllAttributeValuesRow, error)
	ListAllBranchRegisters(ctx context.Context) ([]BranchRegister, error)
	ListAllCashboxAccounts(ctx context.Context) ([]CashboxAccount, error)
	// Every client's raw stored phone, for the one-off admin normalize job
	// (api/client_phone_cleanup.go) -- unlike ListClients this is never paged,
	// since the job needs every row in one pass to detect collisions.
	ListAllClientPhones(ctx context.Context) ([]ListAllClientPhonesRow, error)
	// Newest first, with how many active registers run each release and how
	// many are told to.
	ListAppReleases(ctx context.Context) ([]ListAppReleasesRow, error)
	ListAppUpdateEvents(ctx context.Context, limit int32) ([]ListAppUpdateEventsRow, error)
	ListAssetCategories(ctx context.Context) ([]AssetCategory, error)
	ListAssetsPage(ctx context.Context, arg ListAssetsPageParams) ([]Asset, error)
	ListAttributeValuesPage(ctx context.Context, arg ListAttributeValuesPageParams) ([]ListAttributeValuesPageRow, error)
	ListAttributes(ctx context.Context) ([]Attribute, error)
	ListAuditLogs(ctx context.Context, arg ListAuditLogsParams) ([]ListAuditLogsRow, error)
	// What the daily clean-up removes: pictures whose units were all matched
	// before resolved_before, and pictures of checkouts that never became a sale
	// and whose link expired before abandoned_before.
	ListAutoDeletableUnknownItemImages(ctx context.Context, arg ListAutoDeletableUnknownItemImagesParams) ([]ListAutoDeletableUnknownItemImagesRow, error)
	// FIFO order: oldest batch (by receipt/creation date) first. Walked by
	// applyStockMovement to decide which batch(es) a sold unit debits.
	// FOR UPDATE so two sales racing on the same variant can't both allocate
	// the same remaining units.
	ListAvailableBatchItemsForVariant(ctx context.Context, variantID int64) ([]BatchItem, error)
	// Per-item numbers for the batch's "Products" tab, scoped to this batch's
	// own units via FIFO-tagged stock_movements: remaining_quantity is exactly
	// what's left of this batch unsold, and quantity_sold/revenue are summed
	// only from sale movements this batch's FIFO consumption actually
	// produced (revenue prorated off the source invoice line's price/unit).
	ListBatchItemsStats(ctx context.Context, batchID int64) ([]ListBatchItemsStatsRow, error)
	ListBatches(ctx context.Context, arg ListBatchesParams) ([]ListBatchesRow, error)
	ListBranchAttendanceChanges(ctx context.Context, arg ListBranchAttendanceChangesParams) ([]BranchAttendanceChange, error)
	// Newest punch first by its own local date/time, not insertion order: a
	// backfilled import gets the newest ids but holds the oldest punches.
	// A punch an approved change replaced or deleted (removed_at) is left out;
	// it stays in the table for the audit trail.
	ListBranchAttendanceEvents(ctx context.Context, arg ListBranchAttendanceEventsParams) ([]BranchAttendanceEvent, error)
	// Every live punch between two dates (inclusive) for the timesheet views,
	// which pair each person's IN/OUT punches per day. event_date is the
	// device's own YYYY-MM-DD text, so a plain text comparison orders it.
	// Capped as a guard against an all-branches, all-time request.
	ListBranchAttendanceEventsInRange(ctx context.Context, arg ListBranchAttendanceEventsInRangeParams) ([]BranchAttendanceEvent, error)
	// Adoption: which central client each of this register's local client ids
	// is linked to, so a till can stamp the right uid without guessing by phone.
	ListBranchClientUIDs(ctx context.Context, registerID int64) ([]ListBranchClientUIDsRow, error)
	ListBranchCommands(ctx context.Context, arg ListBranchCommandsParams) ([]ListBranchCommandsRow, error)
	// The Commands page: every branch (branch_id 0) or one, optionally one
	// register / status / type, newest first.
	ListBranchCommandsPage(ctx context.Context, arg ListBranchCommandsPageParams) ([]ListBranchCommandsPageRow, error)
	ListBranchExpenseHistoryForSync(ctx context.Context, arg ListBranchExpenseHistoryForSyncParams) ([]ListBranchExpenseHistoryForSyncRow, error)
	// Storage-explorer feed: every uploaded image, newest first, joined with
	// its expense and branch so the admin UI never needs a second round trip
	// per row.
	ListBranchExpenseImages(ctx context.Context, arg ListBranchExpenseImagesParams) ([]ListBranchExpenseImagesRow, error)
	ListBranchExpenseImagesForExpense(ctx context.Context, branchExpenseID int64) ([]BranchExpenseImage, error)
	// sqlc.narg(branch_id) is nullable: NULL means "all branches", matching
	// ListBranchInvoices' admin-filter convention. search ” means no filter.
	ListBranchExpenses(ctx context.Context, arg ListBranchExpensesParams) ([]BranchExpense, error)
	// At most one coupon redemption per invoice (see CreateBranchInvoiceTx's own
	// comment) -- the code a redeemed coupon carries for the given invoices'
	// client_refs, so the branch can reattach it to whichever payment line it
	// recognizes as its own coupon-settlement placeholder account. Coupon codes
	// are never persisted on branch_invoice_payments itself (see
	// CreateBranchInvoiceTx: a coupon payment only ever calls RedeemCoupon), so
	// this is the only way to recover which line was the coupon.
	ListBranchInvoiceCouponCodesForHistory(ctx context.Context, arg ListBranchInvoiceCouponCodesForHistoryParams) ([]ListBranchInvoiceCouponCodesForHistoryRow, error)
	// ---------------------------------------------------------------------------
	// Branch-scoped historical read-back (see api/branch_catchup.go's
	// branchSyncChanges "branch_invoice_history"/"branch_expense_history"/
	// "branch_loan_history"/"branch_shift_history" cases). Lets a branch pull
	// its OWN previously-submitted invoices/expenses/loans/shift-closes back
	// down -- e.g. re-provisioning a wiped till for a branch that already has
	// real history on kashi. branch_id always comes from the authenticated
	// branch (ctx.MustGet(branchIDKey)), never a request parameter, so a
	// branch can only ever pull its own data. Keyset-paginated on
	// (received_at, id), same cursor shape as ListBranchStockForSync.
	//
	// Invoices and shift closes are per register: a re-provisioned till gets
	// back only what it itself sold and closed, so its invoice numbering and
	// local shift ids carry on without colliding with its branch's other tills.
	// Expenses and loans aren't tracked per register and stay branch-wide.
	// ---------------------------------------------------------------------------
	ListBranchInvoiceHistoryForSync(ctx context.Context, arg ListBranchInvoiceHistoryForSyncParams) ([]BranchInvoice, error)
	// With the product each line is, for the admin views: the till only sends
	// its own local product id, which means nothing here, so the name comes
	// from the variant product_uid resolves to (blank for an old line that
	// never resolved -- see resolveVariantByUIDOrBarcode).
	ListBranchInvoiceItems(ctx context.Context, branchInvoiceID int64) ([]ListBranchInvoiceItemsRow, error)
	// Items for a whole page of invoices at once, batched by id -- distinct
	// from ListBranchInvoiceItems (branch_invoice.sql), which is the
	// single-invoice admin detail view. resolved_barcode comes from
	// product_variants via product_uid (nullable: an item pushed before
	// product_uid existed, and whose barcode never resolved to a variant at
	// push time either, has neither -- see resolveVariantByUIDOrBarcode in
	// tx_branch_invoice.go).
	ListBranchInvoiceItemsForHistory(ctx context.Context, branchInvoiceIds []int64) ([]ListBranchInvoiceItemsForHistoryRow, error)
	// An invoice's lines with the product each one sold, for the Recent
	// activity details dialog. A line whose product_uid never resolved to a
	// variant keeps an empty name.
	ListBranchInvoiceItemsNamed(ctx context.Context, branchInvoiceID int64) ([]ListBranchInvoiceItemsNamedRow, error)
	ListBranchInvoicePayments(ctx context.Context, branchInvoiceID int64) ([]BranchInvoicePayment, error)
	ListBranchInvoicePaymentsForHistory(ctx context.Context, branchInvoiceIds []int64) ([]BranchInvoicePayment, error)
	ListBranchInvoiceSettlementPayments(ctx context.Context, branchInvoiceSettlementID int64) ([]BranchInvoiceSettlementPayment, error)
	ListBranchInvoiceSettlements(ctx context.Context, arg ListBranchInvoiceSettlementsParams) ([]BranchInvoiceSettlement, error)
	// sqlc.narg(branch_id) is nullable: NULL means "all branches", matching how
	// the admin UI's branch filter works (a dropdown with an "All branches"
	// option, not a required selection).
	ListBranchInvoices(ctx context.Context, arg ListBranchInvoicesParams) ([]BranchInvoice, error)
	ListBranchInvoicesPage(ctx context.Context, arg ListBranchInvoicesPageParams) ([]BranchInvoice, error)
	ListBranchLoanHistoryForSync(ctx context.Context, arg ListBranchLoanHistoryForSyncParams) ([]ListBranchLoanHistoryForSyncRow, error)
	ListBranchPlaceIDs(ctx context.Context) ([]ListBranchPlaceIDsRow, error)
	// ---------------------------------------------------------------------------
	// Branch (kashi-pos) sales. branch_invoice_items itself carries no product
	// link (branch_product_id is a branch-local id, not an FK -- see
	// 000025_create_branch_invoices.up.sql), so it can't be the source. But
	// CreateBranchInvoiceTx (tx_branch_invoice.go) already resolves each line's
	// barcode to a real product_variants row at sync time and records the sale
	// as a stock_movements row (reason='sale', reference_type='branch_invoice',
	// inventory_id = the branch's own store inventory) purely to decrement
	// central stock -- that ledger is the only place a branch sale is linked to
	// a real product. It carries quantity but no transaction price, so revenue
	// here is an ESTIMATE: each unit priced at the variant's *current* catalog
	// price (its entry in the default price list -- see the variant_default_prices
	// view in 000094), not whatever kashi-pos actually charged
	// at checkout (which may have included a since-changed price or a
	// branch-side discount neither table records at this granularity). A line
	// whose barcode never resolved (old kashi-pos build, unknown barcode, or a
	// historical backfill -- see CreateBranchInvoiceTx's Historical branch)
	// never got a stock_movements row at all and so is silently absent here,
	// same as it's absent from central stock.
	// ---------------------------------------------------------------------------
	ListBranchProductRevenue(ctx context.Context, arg ListBranchProductRevenueParams) ([]ListBranchProductRevenueRow, error)
	// Same scope/filters/estimate caveat as ListBranchProductRevenue, rolled up
	// by local calendar day -- the trend line for the kashi-pos tab.
	ListBranchProductRevenueDaily(ctx context.Context, arg ListBranchProductRevenueDailyParams) ([]ListBranchProductRevenueDailyRow, error)
	// A branch's central Quick Access list, in card order, with enough of each
	// product to show it in the admin editor; tills only use uid/position/colours.
	ListBranchQuickAccessItems(ctx context.Context, branchID int64) ([]ListBranchQuickAccessItemsRow, error)
	ListBranchRegisters(ctx context.Context, branchID int64) ([]BranchRegister, error)
	ListBranchRegistersByIDs(ctx context.Context, ids []int64) ([]BranchRegister, error)
	// Same scope/filters/estimate caveat as ListBranchProductRevenue, rolled up
	// by branch instead of by product -- backs the "revenue by branch" chart,
	// deliberately with no branch_id filter of its own (that would defeat the
	// point of a per-branch breakdown).
	ListBranchRevenueByBranch(ctx context.Context, arg ListBranchRevenueByBranchParams) ([]ListBranchRevenueByBranchRow, error)
	// Per (branch, local day) sales-invoice count and gross sales revenue in an
	// inclusive "YYYY-MM-DD" range, oldest first. Deliberately shaped like
	// ListBranchVisitorDaysRange so the Footfall page can line footfall up
	// against sales for the same window -- conversion rate, average ticket --
	// with one extra request and no per-day query.
	//
	// Only kind = 'sales' counts: a return or exchange isn't a walk-in turning
	// into a buyer, and its grand_total carries the branch's own signed
	// refund/top-up convention (see ListDailyIncome) which would distort an
	// "average sale" figure. The occurred_at range is compared against plain
	// date bounds (not AT TIME ZONE per row) so idx_branch_invoices_occurred_at
	// stays usable, same reasoning as ListDailyIncome.
	ListBranchSalesDaysRange(ctx context.Context, arg ListBranchSalesDaysRangeParams) ([]ListBranchSalesDaysRangeRow, error)
	ListBranchShiftHistoryForSync(ctx context.Context, arg ListBranchShiftHistoryForSyncParams) ([]BranchShift, error)
	// Storage-explorer feed: every uploaded close-shift receipt photo, newest
	// first, joined with its shift and branch so the admin UI never needs a
	// second round trip per row. Mirrors ListBranchExpenseImages.
	ListBranchShiftReceiptImages(ctx context.Context, arg ListBranchShiftReceiptImagesParams) ([]ListBranchShiftReceiptImagesRow, error)
	// sqlc.narg(branch_id) is nullable: NULL means "all branches", matching
	// ListBranchExpenses' admin-filter convention. has_receipt_image lets the
	// admin Shifts page show a per-row indicator without an extra request per
	// shift (see branch_shift_receipt_images / api/branch_shift_receipt_image.go).
	ListBranchShifts(ctx context.Context, arg ListBranchShiftsParams) ([]ListBranchShiftsRow, error)
	// ---------------------------------------------------------------------------
	// Cross-branch stock visibility: every OTHER branch's on-hand quantity and
	// resolved selling price for a variant, so a till can search what a
	// different branch is carrying. Keyset-paginated on inventory_stock's
	// surrogate id (000101 -- the table's real key, (inventory_id,
	// variant_id), has no single ordering column), same cursor shape as
	// ListProductVariantsForSyncPaged.
	// ---------------------------------------------------------------------------
	ListBranchStockForSync(ctx context.Context, arg ListBranchStockForSyncParams) ([]ListBranchStockForSyncRow, error)
	ListBranchSyncConflictsPage(ctx context.Context, arg ListBranchSyncConflictsPageParams) ([]ListBranchSyncConflictsPageRow, error)
	ListBranchTargetSeriesForBranch(ctx context.Context, branchID int64) ([]BranchTargetSeries, error)
	ListBranchTargetsForBranch(ctx context.Context, branchID int64) ([]BranchTarget, error)
	// Branch-wide progress for a till's target bars: what every register of
	// this branch has sold in each live target's range, as kashi has received
	// it. The till adds its own not-yet-synced sales on top.
	ListBranchTargetsProgress(ctx context.Context, arg ListBranchTargetsProgressParams) ([]ListBranchTargetsProgressRow, error)
	ListBranchTargetsUpdatedSince(ctx context.Context, arg ListBranchTargetsUpdatedSinceParams) ([]BranchTarget, error)
	// The till's own poll: what happened to the requests it made -- see
	// approveTransfer/rejectTransfer, which both bump updated_at.
	ListBranchTransfersUpdatedSince(ctx context.Context, arg ListBranchTransfersUpdatedSinceParams) ([]Transfer, error)
	ListBranchUsersForBranch(ctx context.Context, branchID int64) ([]BranchUser, error)
	// Branch-scoped catch-up feed, same contract as ListSalespersonsUpdatedSince.
	ListBranchUsersUpdatedSince(ctx context.Context, arg ListBranchUsersUpdatedSinceParams) ([]BranchUser, error)
	// One row per (branch, local day): gross customers-in vs customers-out,
	// newest day first. sqlc.narg(branch_id) NULL means "all branches",
	// matching ListBranchShifts' admin-filter convention.
	ListBranchVisitorDays(ctx context.Context, arg ListBranchVisitorDaysParams) ([]ListBranchVisitorDaysRow, error)
	// Every (branch, day) rollup within an inclusive "YYYY-MM-DD" day range,
	// oldest first. No pagination: footfall data is one row per branch per day,
	// so even a year across every branch is a small result the Footfall page
	// slices into months / branch comparisons / weekday profiles client-side.
	ListBranchVisitorDaysRange(ctx context.Context, arg ListBranchVisitorDaysRangeParams) ([]ListBranchVisitorDaysRangeRow, error)
	ListBranchWhatsAppNumbers(ctx context.Context) ([]ListBranchWhatsAppNumbersRow, error)
	ListBranches(ctx context.Context) ([]Branch, error)
	ListBranchesForDiscountList(ctx context.Context, discountListID int64) ([]ListBranchesForDiscountListRow, error)
	ListBranchesForPriceList(ctx context.Context, priceListID int64) ([]ListBranchesForPriceListRow, error)
	// Whole set, small table like currencies -- a till needs to see a branch
	// go inactive (and so disappear from its destination picker), which an
	// updated-since delta can't express. Excludes the requesting branch
	// itself: it can't transfer to itself.
	ListBranchesForSync(ctx context.Context, id int64) ([]ListBranchesForSyncRow, error)
	ListCalendarEvents(ctx context.Context) ([]CalendarEvent, error)
	// The admin view: every central method with this branch's override state, so
	// the UI can show what is inherited and what is explicitly set. Unlike the
	// sync query this keeps disabled rows -- switching one back on is the whole
	// point of the screen.
	ListCashboxAccountOverridesForBranch(ctx context.Context, branchID int64) ([]ListCashboxAccountOverridesForBranchRow, error)
	ListCashboxAccounts(ctx context.Context, arg ListCashboxAccountsParams) ([]CashboxAccount, error)
	// What one branch's tills should actually show: the central set with that
	// branch's overrides folded in, and the methods it switched off left out
	// entirely. Absence is the signal kashi-pos reconciles on, so an excluded
	// method needs no flag of its own -- not sending it is what deactivates it
	// at the till (see reconcileCashboxAccounts in kashi-pos).
	//
	// COALESCE per column rather than per row: an override that only sets
	// sort_order keeps inheriting central's color and currency, so a later
	// central color change still reaches a branch that reordered its buttons.
	ListCashboxAccountsForBranchSync(ctx context.Context, branchID int64) ([]ListCashboxAccountsForBranchSyncRow, error)
	// The whole set, not a "changed since" delta. A branch has to be able to tell
	// that kashi no longer has a payment method at all, and an incremental feed
	// can only say what changed -- it has no way to say what is gone. Sending
	// every row lets the till reconcile by absence, the same shape the price and
	// discount lists use. The table is a handful of rows, so the cost is nil.
	//
	// Inactive methods are left out on purpose: absence is what the till
	// reconciles a deactivation on (see ListCashboxAccountsForBranchSync and
	// reconcileCashboxAccounts in kashi-pos), so a centrally deactivated method
	// reaches every branch the same way a deleted one would, without kashi-pos
	// ever needing to know about is_active at all.
	ListCashboxAccountsForSync(ctx context.Context) ([]CashboxAccount, error)
	ListCashboxAccountsUpdatedSince(ctx context.Context, updatedAt time.Time) ([]CashboxAccount, error)
	ListCashboxes(ctx context.Context, arg ListCashboxesParams) ([]Cashbox, error)
	// Distinct countries actually present among clients' phones, for the
	// clients page's country filter dropdown -- so it only ever offers a
	// country that would return at least one result, instead of the full
	// ~240-country ISO list.
	ListClientPhoneCountries(ctx context.Context) ([]ListClientPhoneCountriesRow, error)
	// Completeness check: every retail client's uid + updated_at, keyset-paged
	// by uid. Inactive clients are included -- a till must learn they're
	// inactive, not just stop hearing about them.
	ListClientSyncIDs(ctx context.Context, arg ListClientSyncIDsParams) ([]ListClientSyncIDsRow, error)
	// sqlc.narg(client_type) is nullable: NULL means "all types" -- the admin
	// clients page passes it when a Retail/Wholesale tab is selected, and
	// omits it for a combined view if one is ever added.
	ListClients(ctx context.Context, arg ListClientsParams) ([]Client, error)
	// ListClientsBySpendingCached, ranked by invoice count.
	ListClientsByInvoiceCountCached(ctx context.Context, arg ListClientsByInvoiceCountCachedParams) ([]ListClientsByInvoiceCountCachedRow, error)
	// ListClientsBySpendingCached, ranked by item count.
	ListClientsByItemCountCached(ctx context.Context, arg ListClientsByItemCountCachedParams) ([]ListClientsByItemCountCachedRow, error)
	// Powers the clients "loyalty pyramid" + rest-of-clients table: every
	// client ranked by total_spent, invoice_count, or item_count (chosen via
	// sort_by -- see the ORDER BY at the bottom). Two sources feed each metric:
	// kashi's own admin invoices (sales positive, returns negative --
	// invoices.grand_total is always stored as a positive magnitude regardless
	// of kind, see ReturnInvoiceTx) and branch-reported sales
	// (branch_invoices.grand_total, which already carries the correct net sign
	// -- see ListDailyIncome). sqlc.arg(branch_ids) scopes to one branch's
	// till (or several, via the branch_ids array; empty means every branch);
	// central admin invoices aren't attributed to any branch, so they're
	// excluded entirely once any branch is selected (an "All Branches"
	// view is the only one where they belong). invoice_count/item_count follow
	// the same all-or-selected-branches rule for consistency with total_spent.
	// invoice_count/item_count are computed in the `ranked` CTE rather than as
	// plain SELECT-list aliases so the ORDER BY's CASE expression can actually
	// reference them: Postgres only resolves an output alias in ORDER BY when
	// it's used bare, not when it's embedded in a larger expression (there it's
	// looked up as an ordinary column instead, which fails since it isn't one
	// of the FROM clause's columns). Wrapping in a CTE turns them into real
	// columns of the derived table, so the CASE inside ORDER BY resolves fine.
	ListClientsBySpending(ctx context.Context, arg ListClientsBySpendingParams) ([]ListClientsBySpendingRow, error)
	// ListClientsBySpending for the unfiltered case (no branch, no dates, no
	// first/returning): reads the client_spend cache instead of aggregating every
	// invoice, so a page costs an index scan. Same ordering and the other filters
	// (type, search, phone) as the live query. One query per sort, rather than a
	// CASE in ORDER BY, so Postgres can read the top rows straight off that
	// column's index. Every client has a client_spend row (see migration 197).
	ListClientsBySpendingCached(ctx context.Context, arg ListClientsBySpendingCachedParams) ([]ListClientsBySpendingCachedRow, error)
	ListClientsByUIDs(ctx context.Context, uids []uuid.UUID) ([]Client, error)
	// Feeds the clients CSV export: one row per (client, branch) for every
	// client who bought something, so the caller can write a file per branch.
	// A client "belongs" to a branch because a non-cancelled invoice there is
	// theirs. The invoice's client is resolved by either identity a till has
	// used: the shared client_uid (current), or the older (register,
	// branch_client_id) client_links entry -- an invoice carrying only one of
	// them still counts. branch_ids (empty = every branch) and the
	// [date_from, date_to) window (either bound optional) narrow which
	// invoices count; spend/invoice figures are for that same scope, not
	// lifetime. Central admin invoices have no branch (branch_id 0) and are only
	// included when no branch is selected, the same rule as
	// ListClientsBySpending. With no branch and no date set, clients who never
	// bought anything are listed too (branch_id 0, zero spend). A client is
	// listed under every branch they bought from, not only their home branch
	// (clients.branch_id, the first one); the home branch adds a zero-spend row
	// when they have no purchases there. Cancelled and
	// hidden-from-reports branch invoices are skipped as everywhere else, unless
	// include_excluded is set.
	// Home branch (clients.branch_id): a client is also listed under it when
	// they haven't bought there in this scope, e.g. one imported with a branch
	// and no sales yet. Only for an explicit branch pick and no dates, since
	// zero spend can't match a date window; the same hidden-branch rule as
	// purchases applies.
	ListClientsForExport(ctx context.Context, arg ListClientsForExportParams) ([]ListClientsForExportRow, error)
	// Clients with no phone_country yet: ones a till created or edited before the
	// sync path started filling it in. "nophone-..." placeholders aren't phone
	// numbers, so they're left alone.
	ListClientsMissingPhoneCountry(ctx context.Context) ([]ListClientsMissingPhoneCountryRow, error)
	// Feeds the branch catch-up endpoint (see branch_catchup.go), same pattern
	// as currencies/cashbox_accounts/products. Wholesale clients never appear
	// here -- they're a central-office concept, not something a branch till
	// should ever see in its client search. Converting an already-synced
	// retail client to wholesale won't retract it from branches that already
	// have it locally (no delete propagation exists for any synced entity
	// today); acceptable since that conversion is expected to be rare.
	ListClientsUpdatedSince(ctx context.Context, updatedAt time.Time) ([]Client, error)
	// Keyset-paginated form of ListClientsUpdatedSince for a branch doing a
	// full catch-up (cursor reset): ordered by (updated_at, id) so a page
	// boundary that falls between two rows sharing an updated_at can't drop or
	// repeat one. after_updated_at/after_id are the last row of the previous
	// page (zero-time / 0 for the first page).
	ListClientsUpdatedSincePaged(ctx context.Context, arg ListClientsUpdatedSincePagedParams) ([]Client, error)
	// Same rows as ListClients, but with each branch's reported loyalty points
	// (branch_invoices.loyalty_points_delta, via client_links) summed in
	// alongside kashi's own admin-invoice points. Used by the admin clients
	// page so the displayed balance isn't missing everything earned at a
	// branch till.
	ListClientsWithLoyalty(ctx context.Context, arg ListClientsWithLoyaltyParams) ([]ListClientsWithLoyaltyRow, error)
	ListColors(ctx context.Context) ([]Color, error)
	ListColorsPage(ctx context.Context, arg ListColorsPageParams) ([]Color, error)
	ListCouponCategories(ctx context.Context, scope sql.NullString) ([]CouponCategory, error)
	ListCouponLists(ctx context.Context) ([]ListCouponListsRow, error)
	ListCouponTypes(ctx context.Context) ([]CouponType, error)
	ListCouponTypesUpdatedSince(ctx context.Context, updatedAt time.Time) ([]CouponType, error)
	ListCoupons(ctx context.Context, arg ListCouponsParams) ([]ListCouponsRow, error)
	// Sent whole (every status, not just active): absence can't express
	// "redeemed elsewhere" or "deactivated" to a till that already has the
	// row, so the row itself carries the new status down. See
	// ListPriceListsForBranchSync's comment in branch_sync_lists.go for the
	// same reasoning.
	ListCouponsUpdatedSince(ctx context.Context, updatedAt time.Time) ([]Coupon, error)
	// page_size = 0 returns every currency (the CurrencySelect picker needs the
	// whole list); any positive value pages. Order is always by code, so the
	// picker and the paged table agree.
	ListCurrencies(ctx context.Context, arg ListCurrenciesParams) ([]Currency, error)
	// The whole set -- see ListCashboxAccountsForSync for why this is not a delta.
	ListCurrenciesForSync(ctx context.Context) ([]Currency, error)
	ListCurrenciesUpdatedSince(ctx context.Context, updatedAt time.Time) ([]Currency, error)
	// Sums grand_total across both kinds ('sales' and 'return') rather than
	// treating them separately: a branch's return/exchange grand_total is
	// already the net signed cash effect it reported (negative for a refund,
	// positive for an even-or-up exchange -- see tx_exchange.go's netDifference
	// in kashi-pos), so a plain sum already nets returns against sales
	// correctly without this query needing to know or guess that sign
	// convention itself.
	// The year filter is a >=/< range against a fixed pair of dates rather than
	// EXTRACT(YEAR FROM occurred_at) = $1 -- EXTRACT on every row can't use a
	// plain btree index on occurred_at (idx_branch_invoices_occurred_at), while
	// a range comparison can.
	ListDailyIncome(ctx context.Context, arg ListDailyIncomeParams) ([]ListDailyIncomeRow, error)
	ListDayBranchExpenses(ctx context.Context, arg ListDayBranchExpensesParams) ([]ListDayBranchExpensesRow, error)
	// Shifts closed on the day (a shift belongs to the day its till was
	// counted, which is what the variance figures describe).
	ListDayBranchShifts(ctx context.Context, arg ListDayBranchShiftsParams) ([]ListDayBranchShiftsRow, error)
	// Every invoice of the day, newest first. Capped well above a real day's
	// volume; the page only lists them.
	ListDayInvoices(ctx context.Context, arg ListDayInvoicesParams) ([]ListDayInvoicesRow, error)
	// How the day's money came in, by the branch-reported account display name
	// (cashbox accounts aren't shared across the branch boundary -- see
	// migration 000054).
	ListDayPaymentsByAccount(ctx context.Context, arg ListDayPaymentsByAccountParams) ([]ListDayPaymentsByAccountRow, error)
	// Queries backing the Daily Income heatmap's per-day drill-down page
	// (GET /branch_invoices/day_summary). Every query scopes to one *local*
	// calendar day: occurred_at converted to the owning branch's timezone, the
	// same rule ListDailyIncome uses to bucket the heatmap cell that was
	// clicked, so the page's totals always agree with that cell.
	//
	// The occurred_at range against day-1 .. day+2 is a coarse prefilter that
	// keeps idx_branch_invoices_occurred_at usable (a per-row AT TIME ZONE
	// can't use the index on its own); two days of slack on either side covers
	// every real timezone offset, and the AT TIME ZONE equality does the exact
	// cut.
	// Per-branch totals for the day. net_total is the plain grand_total sum
	// across sales and returns, same signed-return convention as
	// ListDailyIncome, so the page's headline matches the heatmap cell.
	ListDaySalesByBranch(ctx context.Context, arg ListDaySalesByBranchParams) ([]ListDaySalesByBranchRow, error)
	// Local-hour buckets (0-23); hours with no invoices are absent and the
	// frontend fills zeros.
	ListDaySalesByHour(ctx context.Context, arg ListDaySalesByHourParams) ([]ListDaySalesByHourRow, error)
	ListDaySalesBySalesperson(ctx context.Context, arg ListDaySalesBySalespersonParams) ([]ListDaySalesBySalespersonRow, error)
	// Best sellers of the day by line revenue, sales invoices only. Items whose
	// product_uid never resolved to a variant (see resolveVariantByUIDOrBarcode)
	// fold into one "unknown" row rather than disappearing from the totals.
	ListDayTopProducts(ctx context.Context, arg ListDayTopProductsParams) ([]ListDayTopProductsRow, error)
	// branch_visitor_events.day is already the branch's local day (stamped by
	// the till), so it's matched directly; only the hour needs the timezone.
	ListDayVisitorsByHour(ctx context.Context, arg ListDayVisitorsByHourParams) ([]ListDayVisitorsByHourRow, error)
	// Every deal, with how many list rows and rules put it on products, so the
	// page can say where a deal is used before it is changed or deleted.
	ListDeals(ctx context.Context) ([]ListDealsRow, error)
	// The deals a list's rows name: they travel with the list, so the till
	// always has the terms of every deal it can price.
	ListDealsForDiscountListSync(ctx context.Context, discountListID int64) ([]Deal, error)
	// Of the given pictures, the ones that can go: not the picture of a unit still
	// waiting to be matched on a sale that has arrived. A checkout whose sale never
	// came (the till or kashi was down) is not waiting on anyone, so it can go.
	ListDeletableUnknownItemImages(ctx context.Context, ids []int64) ([]ListDeletableUnknownItemImagesRow, error)
	ListDiscountListBranchIDs(ctx context.Context, discountListID int64) ([]int64, error)
	ListDiscountListItems(ctx context.Context, discountListID int64) ([]DiscountListItem, error)
	ListDiscountListItemsForSync(ctx context.Context, discountListID int64) ([]ListDiscountListItemsForSyncRow, error)
	// See ListPriceListItemsWithProduct: rows are variant-level, so the label needs
	// the barcode and color/size to be identifiable. Option rows (000199) are
	// listed alongside the plain ones; sale_option_id 0 / sale_option ” marks a
	// plain row. Only a plain row can name a deal (000201).
	ListDiscountListItemsWithProduct(ctx context.Context, arg ListDiscountListItemsWithProductParams) ([]ListDiscountListItemsWithProductRow, error)
	// Options travel by name, like colors and attributes: a till has no copy of
	// kashi's sale_options ids.
	ListDiscountListOptionItemsForSync(ctx context.Context, discountListID int64) ([]ListDiscountListOptionItemsForSyncRow, error)
	// A list's rule groups in order (000203).
	ListDiscountListRuleGroups(ctx context.Context, discountListID int64) ([]DiscountListRuleGroup, error)
	// Option discounts of a list's rules; options travel by name, as on the tills.
	ListDiscountListRuleOptions(ctx context.Context, discountListID int64) ([]ListDiscountListRuleOptionsRow, error)
	// A list's rules in the order they run, with how many variants each one
	// decides now (counted from the rows it wrote: a rule giving 0 writes none).
	ListDiscountListRules(ctx context.Context, discountListID int64) ([]ListDiscountListRulesRow, error)
	ListDiscountLists(ctx context.Context, arg ListDiscountListsParams) ([]DiscountList, error)
	// See ListPriceListsForBranchSync -- same scoping and same reason for
	// carrying is_active rather than filtering on it.
	ListDiscountListsForBranchSync(ctx context.Context, arg ListDiscountListsForBranchSyncParams) ([]DiscountList, error)
	// Lists the branch was taken off since the till's cursor (000206), which it
	// is sent as inactive so it drops its copy. Not the default list, which
	// every branch keeps, nor one the branch is back on.
	ListDiscountListsRemovedFromBranch(ctx context.Context, arg ListDiscountListsRemovedFromBranchParams) ([]ListDiscountListsRemovedFromBranchRow, error)
	ListDueEmailSchedules(ctx context.Context) ([]EmailSchedule, error)
	ListDueRecurringExpenses(ctx context.Context, nextDueAt time.Time) ([]RecurringExpense, error)
	// Every non-cancelled invoice on local days from_day..to_day, newest first
	// (the order kashi-admin's CSV used), optionally one branch. Days are cut
	// per branch timezone exactly like ListDayInvoices; the occurred_at range
	// with a day of slack each side keeps idx_branch_invoices_occurred_at
	// usable. Carries more than the default CSV needs so extra columns picked
	// in Settings need no new query. ListEmailReportShiftInvoices returns the
	// same columns for one shift.
	// One grouped pass over the picked invoices' items and payments rather than
	// a subquery per invoice.
	ListEmailReportInvoices(ctx context.Context, arg ListEmailReportInvoicesParams) ([]ListEmailReportInvoicesRow, error)
	// Everyone a report went out to, most recently used first, for the send
	// dialog's suggestions.
	ListEmailReportRecipients(ctx context.Context) ([]ListEmailReportRecipientsRow, error)
	// The registers the send dialog can pick, by branch.
	ListEmailReportRegisters(ctx context.Context) ([]ListEmailReportRegistersRow, error)
	// A closed shift's invoices, matched the way settlements match a till's
	// shift: register plus the till's own shift id.
	// One grouped pass over the picked invoices' items and payments rather than
	// a subquery per invoice.
	ListEmailReportShiftInvoices(ctx context.Context, shiftID int64) ([]ListEmailReportShiftInvoicesRow, error)
	// Closed shifts to pick from in the send dialog: those counted on local
	// days from_day..to_day, optionally one branch, newest first.
	ListEmailReportShifts(ctx context.Context, arg ListEmailReportShiftsParams) ([]ListEmailReportShiftsRow, error)
	ListEmailReports(ctx context.Context, arg ListEmailReportsParams) ([]EmailReport, error)
	ListEmailSchedules(ctx context.Context) ([]EmailSchedule, error)
	ListEmployees(ctx context.Context, arg ListEmployeesParams) ([]Employee, error)
	ListEntries(ctx context.Context, arg ListEntriesParams) ([]Entry, error)
	ListExpenseCategories(ctx context.Context, scope sql.NullString) ([]ExpenseCategory, error)
	// Only branch-scoped categories are synced down to kashi-pos.
	ListExpenseCategoriesUpdatedSince(ctx context.Context, updatedAt time.Time) ([]ExpenseCategory, error)
	ListExpenses(ctx context.Context, arg ListExpensesParams) ([]Expense, error)
	ListGooglePlaceSnapshots(ctx context.Context, arg ListGooglePlaceSnapshotsParams) ([]GooglePlaceSnapshot, error)
	// Newest first, for the given places.
	ListGoogleReviews(ctx context.Context, arg ListGoogleReviewsParams) ([]GoogleReview, error)
	// Which of a page's rows of one kind are resolved, and by whom.
	ListHomeActivityResolutions(ctx context.Context, arg ListHomeActivityResolutionsParams) ([]ListHomeActivityResolutionsRow, error)
	// Products that have opted out of low-stock alerting entirely, regardless
	// of on-hand or threshold -- lets the muted list be reviewed and reversed.
	ListIgnoredLowStockProducts(ctx context.Context, arg ListIgnoredLowStockProductsParams) ([]ListIgnoredLowStockProductsRow, error)
	// The destination branch's own poll: transfers addressed to it, whoever
	// sent them. Matched by to_inventory_id, not branch_id -- that column is
	// always the sender's.
	ListIncomingBranchTransfersUpdatedSince(ctx context.Context, arg ListIncomingBranchTransfersUpdatedSinceParams) ([]Transfer, error)
	ListInventories(ctx context.Context, arg ListInventoriesParams) ([]Inventory, error)
	ListInventoryStock(ctx context.Context, arg ListInventoryStockParams) ([]ListInventoryStockRow, error)
	ListInvoiceDiscountBranchIDs(ctx context.Context) ([]InvoiceDiscountBranch, error)
	ListInvoiceDiscounts(ctx context.Context) ([]InvoiceDiscount, error)
	// Every rule changed since the branch last asked, deleted ones included,
	// with whether it applies to the branch: a rule that doesn't (deleted,
	// switched off, or the branch taken off it) tells the till to drop it.
	ListInvoiceDiscountsForBranchSync(ctx context.Context, arg ListInvoiceDiscountsForBranchSyncParams) ([]ListInvoiceDiscountsForBranchSyncRow, error)
	ListInvoicePaymentsByInvoice(ctx context.Context, invoiceID int64) ([]ListInvoicePaymentsByInvoiceRow, error)
	ListInvoiceProductsByInvoice(ctx context.Context, invoiceID int64) ([]ListInvoiceProductsByInvoiceRow, error)
	ListInvoiceTypes(ctx context.Context) ([]InvoiceType, error)
	ListInvoices(ctx context.Context, arg ListInvoicesParams) ([]Invoice, error)
	ListInvoicesPage(ctx context.Context, arg ListInvoicesPageParams) ([]Invoice, error)
	// The home page's "Latest added" feed: the newest photos (expense,
	// close-shift receipt), transfers, central expenses and purchases, merged
	// newest first. Each include_* flag is the caller's view access to that
	// section, so a kind the user can't open never appears.
	//
	// ref_id is the record a row belongs to (the expense or shift a photo was
	// attached to, or the transfer/expense/purchase itself), and for a branch
	// photo branch_id + ref_day (the branch's local day) say which day page
	// shows it, so the feed can open "the thing it was attached to".
	// Keyset paging: the next page starts after the last row the feed has. ids
	// come from five tables, so kind breaks a tie between two rows added at the
	// same instant with the same id.
	ListLatestAdditions(ctx context.Context, arg ListLatestAdditionsParams) ([]ListLatestAdditionsRow, error)
	ListLoanCategories(ctx context.Context, scope sql.NullString) ([]LoanCategory, error)
	// Only branch-scoped categories are synced down to kashi-pos -- central
	// ones are managed in kashi only.
	ListLoanCategoriesUpdatedSince(ctx context.Context, updatedAt time.Time) ([]LoanCategory, error)
	ListLoanImagesForLoan(ctx context.Context, loanID int64) ([]LoanImage, error)
	// sqlc.narg(loan_id) is nullable: NULL means "all loans". sqlc.narg(category_id)
	// filters by the parent loan's lender-source category.
	ListLoanPayments(ctx context.Context, arg ListLoanPaymentsParams) ([]LoanPayment, error)
	// sqlc.narg(branch_id)/sqlc.narg(origin) are nullable: NULL means "no
	// filter", matching ListBranchExpenses' admin-filter convention.
	// paid_amount is the running total of loan_payments against the loan;
	// status is derived from it (never stored) -- 'paid' once payments cover
	// the loan amount, 'partial' while some but not all is covered, else
	// 'unpaid' -- or 'cancelled' once cancelled_at is stamped. sqlc.narg(status) filters on that same derived value.
	ListLoans(ctx context.Context, arg ListLoansParams) ([]ListLoansRow, error)
	// Low stock alerts. A product's on-hand is the sum of inventory_stock
	// across every SKU (variant) and every inventory it's stocked in; its
	// effective threshold is its own override if set, else the single global
	// app_settings.default_low_stock_threshold.
	// status narrows to one bucket: 'out_of_stock' (on_hand <= 0) or
	// 'low_stock' (on_hand > 0, i.e. low but not yet out); NULL keeps both,
	// matching the "at or below threshold" definition used everywhere else.
	ListLowStockProducts(ctx context.Context, arg ListLowStockProductsParams) ([]ListLowStockProductsRow, error)
	// Requests a till filed ("acr-<id>-complaint") that no review has answered
	// yet ("acr-<id>-review" from the same register -- each till numbers its own
	// requests). These are the ones an admin can approve or reject from kashi.
	ListPendingBranchAttendanceRequests(ctx context.Context, branchID sql.NullInt64) ([]BranchAttendanceChange, error)
	ListPendingBranchCommands(ctx context.Context, registerID int64) ([]BranchCommand, error)
	ListPriceListBranchIDs(ctx context.Context, priceListID int64) ([]int64, error)
	ListPriceListItems(ctx context.Context, priceListID int64) ([]PriceListItem, error)
	// Items of one list, keyed by the variant's uid -- the till's own row ids are
	// a different number space, so nothing crosses the boundary by integer id.
	ListPriceListItemsForSync(ctx context.Context, priceListID int64) ([]ListPriceListItemsForSyncRow, error)
	// Rows are variant-level now, so the display label needs the variant's own
	// barcode and its color/size -- a product code and name alone no longer
	// identify which row a price belongs to.
	ListPriceListItemsWithProduct(ctx context.Context, arg ListPriceListItemsWithProductParams) ([]ListPriceListItemsWithProductRow, error)
	ListPriceLists(ctx context.Context, arg ListPriceListsParams) ([]PriceList, error)
	// The only price lists a branch is allowed to know about: the default one
	// (its fallback) and the one it is assigned, if any. Deliberately not every
	// list -- a till has no business holding another branch's pricing.
	//
	// is_active is carried rather than filtered on, because a list going inactive
	// is exactly the event the till needs in order to drop its local copy; filter
	// it out here and the till would keep pricing from a list kashi has retired.
	ListPriceListsForBranchSync(ctx context.Context, arg ListPriceListsForBranchSyncParams) ([]PriceList, error)
	// See ListDiscountListsRemovedFromBranch.
	ListPriceListsRemovedFromBranch(ctx context.Context, arg ListPriceListsRemovedFromBranchParams) ([]ListPriceListsRemovedFromBranchRow, error)
	ListProductAttributes(ctx context.Context, arg ListProductAttributesParams) ([]ProductsAttribute, error)
	ListProductCategories(ctx context.Context) ([]ProductCategory, error)
	// Revenue per product from kashi's own admin sales invoices (invoice_products
	// joined through sales_invoices, so returns don't count as revenue). Branch
	// (POS) sales are deliberately excluded here -- see ListBranchProductRevenue
	// below for those; branch_invoice_items itself still isn't linkable to a
	// product (its branch_product_id has no FK), so the two sources stay
	// separate rather than merged into one figure. category/subcategory/brand
	// are the EAV attributes seeded in 000005_create_products_attributes_table
	// (ids 0/1/2), joined once per attribute the same way
	// ListProductVariantsForSync does.
	ListProductRevenue(ctx context.Context, arg ListProductRevenueParams) ([]ListProductRevenueRow, error)
	// Same scope and filters as ListProductRevenue, rolled up by local calendar
	// day instead of by product -- the trend line for the Product Revenues page.
	ListProductRevenueDaily(ctx context.Context, arg ListProductRevenueDailyParams) ([]ListProductRevenueDailyRow, error)
	ListProductSaleOptionNames(ctx context.Context, productID int64) ([]ListProductSaleOptionNamesRow, error)
	ListProductVariantIDsByUIDs(ctx context.Context, uids []uuid.UUID) ([]ListProductVariantIDsByUIDsRow, error)
	ListProductVariants(ctx context.Context, arg ListProductVariantsParams) ([]ListProductVariantsRow, error)
	ListProductVariantsByProduct(ctx context.Context, productID int64) ([]ProductVariant, error)
	// Flattened for kashi-pos, which has no separate "product" row -- each
	// variant carries everything a branch needs to create or update its own
	// flat product row. Colors/sizes/attributes are resolved to their name
	// here (not sent as ids) since kashi-pos matches everything by name, not
	// by kashi's internal ids.
	//
	// Price is deliberately absent: since 000094 a variant has no price of its
	// own, it has an entry in a price list, and those sync down as their own
	// entities (see the price_lists/discount_lists cases in branch_catchup.go).
	// A till receiving no price here keeps whatever the lists last told it,
	// which is what applySyncedProductVariant already does for an absent price.
	//
	// Attribute ids (2=brand, 1=sub-category, 3=kind, 7=season, 6=year) match
	// the fixed seed in 000005_create_products_attributes_table.up.sql.
	// Editing a product's attributes doesn't currently bump
	// product_variants.updated_at (no endpoint does that edit yet -- see
	// api/product.go), so an attribute-only change wouldn't be picked up by
	// this filter if one ever existed; today attributes are only ever set at
	// creation time, in the same moment the variant's own updated_at is set,
	// so this doesn't miss anything in practice yet.
	ListProductVariantsForSync(ctx context.Context, updatedAt time.Time) ([]ListProductVariantsForSyncRow, error)
	// Same flattened row as ListProductVariantsForSyncPaged, for the uids a
	// till's completeness check found missing or stale.
	ListProductVariantsForSyncByUIDs(ctx context.Context, uids []uuid.UUID) ([]ListProductVariantsForSyncByUIDsRow, error)
	// Keyset-paginated ListProductVariantsForSync -- same flattened row, same
	// joins, ordered by (product_variants.updated_at, product_variants.id) for
	// a stable page boundary during a branch's full catch-up.
	ListProductVariantsForSyncPaged(ctx context.Context, arg ListProductVariantsForSyncPagedParams) ([]ListProductVariantsForSyncPagedRow, error)
	ListProductVariantsUpdatedSince(ctx context.Context, updatedAt time.Time) ([]ProductVariant, error)
	// Search matches code/name/description (case-insensitive). Every filter is
	// optional: empty search string, NULL narg, or empty attribute_value_ids
	// array all mean "don't filter on this". attribute_value_ids is an AND --
	// the product must carry every selected value.
	//
	// total_count is carried alongside each row via a window function so the
	// caller doesn't need a second CountProducts round-trip that re-scans the
	// same filtered set again.
	ListProducts(ctx context.Context, arg ListProductsParams) ([]ListProductsRow, error)
	ListPurchaseItems(ctx context.Context, purchaseID sql.NullInt64) ([]ListPurchaseItemsRow, error)
	ListPurchases(ctx context.Context, arg ListPurchasesParams) ([]ListPurchasesRow, error)
	ListRecurringExpenses(ctx context.Context) ([]RecurringExpense, error)
	ListRegisterUpdateStatuses(ctx context.Context) ([]ListRegisterUpdateStatusesRow, error)
	ListRolePermissions(ctx context.Context) ([]RolePermission, error)
	ListRoles(ctx context.Context) ([]ListRolesRow, error)
	// Which batch(es) a specific sales-invoice line actually drew from, so a
	// return of that line can replenish the same batches instead of going
	// untracked. quantity is negative (sale); batch_id is null for the
	// unattributed remainder, if the sale outran every tracked batch.
	ListSaleMovementsForInvoiceVariant(ctx context.Context, arg ListSaleMovementsForInvoiceVariantParams) ([]ListSaleMovementsForInvoiceVariantRow, error)
	ListSaleOptions(ctx context.Context) ([]SaleOption, error)
	ListSalespersons(ctx context.Context, arg ListSalespersonsParams) ([]Salesperson, error)
	ListSalespersonsByCashbox(ctx context.Context, cashboxID sql.NullInt64) ([]Salesperson, error)
	ListSalespersonsForBranch(ctx context.Context, branchID sql.NullInt64) ([]Salesperson, error)
	ListSalespersonsUpdatedSince(ctx context.Context, arg ListSalespersonsUpdatedSinceParams) ([]Salesperson, error)
	// Open alerts of the pinned (critical) kinds come first, so the page limit
	// never pushes one off the list before someone resolves it.
	ListSecurityAlerts(ctx context.Context, arg ListSecurityAlertsParams) ([]SecurityAlert, error)
	ListShifts(ctx context.Context, arg ListShiftsParams) ([]ListShiftsRow, error)
	ListSizes(ctx context.Context) ([]Size, error)
	ListSizesPage(ctx context.Context, arg ListSizesPageParams) ([]Size, error)
	// ---------------------------------------------------------------------------
	// Slow movers: money tied up in stock that isn't selling. Deliberately
	// separate from the low-stock alerts (too little stock) -- this is the
	// opposite problem, too much. A product qualifies when it's carrying stock
	// (on_hand > 0) and either never sold in the last 90 days ("dead": put it
	// on clearance) or would take unreasonably long to sell through at its
	// current pace ("overstocked": more than 90 days on hand).
	// ---------------------------------------------------------------------------
	ListSlowMovingProducts(ctx context.Context, arg ListSlowMovingProductsParams) ([]ListSlowMovingProductsRow, error)
	ListStockCountItems(ctx context.Context, stockCountID int64) ([]ListStockCountItemsRow, error)
	ListStockCounts(ctx context.Context, arg ListStockCountsParams) ([]ListStockCountsRow, error)
	ListStockHealthByInventory(ctx context.Context, arg ListStockHealthByInventoryParams) ([]ListStockHealthByInventoryRow, error)
	ListStockMovements(ctx context.Context, arg ListStockMovementsParams) ([]ListStockMovementsRow, error)
	// TOOD: add UpdateSupplier
	ListSuppliers(ctx context.Context, arg ListSuppliersParams) ([]Supplier, error)
	// Storage page feed: transfers that have a photo, newest first. The photo
	// itself is served by GET /transfers/:id/attachment.
	ListTransferAttachments(ctx context.Context, arg ListTransferAttachmentsParams) ([]ListTransferAttachmentsRow, error)
	ListTransferItems(ctx context.Context, transferID int64) ([]ListTransferItemsRow, error)
	ListTransfers(ctx context.Context, arg ListTransfersParams) ([]ListTransfersRow, error)
	// Every stored unknown-item picture, newest first, for the Attachments page.
	ListUnknownItemImages(ctx context.Context, arg ListUnknownItemImagesParams) ([]ListUnknownItemImagesRow, error)
	ListUnknownItemSlotsForSession(ctx context.Context, sessionID int64) ([]UnknownItemSlot, error)
	// Pictured units of sold invoices, pending or resolved, newest first.
	ListUnknownItems(ctx context.Context, arg ListUnknownItemsParams) ([]ListUnknownItemsRow, error)
	// The entries that name no variant barcode and no product code.
	ListUnmatchedDiscountEntries(ctx context.Context, entries []string) ([]string, error)
	// The urgent Recent activity rows nobody has resolved yet, pinned above the
	// feed: a shift closed short (negative USD variance) -- the rows the feed
	// tints red. Same columns as HomeActivityFeed, so the feed draws them with
	// the same row, newest received first, like the feed.
	ListUnresolvedUrgentHomeActivities(ctx context.Context) ([]ListUnresolvedUrgentHomeActivitiesRow, error)
	ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)
	ListVariantSyncIDs(ctx context.Context, arg ListVariantSyncIDsParams) ([]ListVariantSyncIDsRow, error)
	ListVariantsForBarcodes(ctx context.Context, arg ListVariantsForBarcodesParams) ([]ListVariantsForBarcodesRow, error)
	// What one typed or scanned entry names, matched like
	// BulkSetDiscountListItems: a barcode names its variant, a code all of its
	// product's variants.
	ListVariantsForDiscountEntry(ctx context.Context, entry string) ([]ListVariantsForDiscountEntryRow, error)
	// Most recently seen first. search matches the IP, place, network, user or
	// branch; country narrows to one country code.
	ListVisitorIPs(ctx context.Context, arg ListVisitorIPsParams) ([]VisitorIp, error)
	// Every unit of the checkouts still in progress that are missing at least one
	// picture or pass, for the "Waiting" tab: pictured units come along so the
	// manager sees what has already been taken. Cashiers who asked for help first.
	ListWaitingUnknownItems(ctx context.Context) ([]ListWaitingUnknownItemsRow, error)
	// Newest first, a page at a time: before_id 0 is the latest page.
	ListWhatsAppChatMessages(ctx context.Context, arg ListWhatsAppChatMessagesParams) ([]ListWhatsAppChatMessagesRow, error)
	// One row per customer phone, the most recently active first.
	ListWhatsAppChats(ctx context.Context, arg ListWhatsAppChatsParams) ([]ListWhatsAppChatsRow, error)
	// What the client sent back to one message: after its poll (the bridge) or
	// answering it (Meta's webhook), oldest first.
	// id and media_type: a bridge reply's media (GET /whatsapp/poll_replies/:id/media).
	ListWhatsAppMessageReplies(ctx context.Context, id int64) ([]ListWhatsAppMessageRepliesRow, error)
	// Newest first. branch_id 0 = every branch, status ” = any; search matches
	// the client's name or phone, the invoice code or the rule.
	ListWhatsAppMessages(ctx context.Context, arg ListWhatsAppMessagesParams) ([]ListWhatsAppMessagesRow, error)
	ListWhatsAppNumbers(ctx context.Context) ([]WhatsappNumber, error)
	// Newest first. A reply not linked to one of our messages only shows under
	// every branch.
	ListWhatsAppReplies(ctx context.Context, arg ListWhatsAppRepliesParams) ([]ListWhatsAppRepliesRow, error)
	// The WhatsApp page: post-sale message rules and the message log
	// (api/whatsapp_rules.go).
	ListWhatsAppRules(ctx context.Context) ([]WhatsappRule, error)
	// Clients who answered 1 or 2 stars, newest first: the ones to call back.
	LowPollRatings(ctx context.Context, arg LowPollRatingsParams) ([]LowPollRatingsRow, error)
	// Loyalty page: new clients per calendar month (UTC) over the last 12 months.
	LoyaltyMonthlyJoins(ctx context.Context, clientType sql.NullString) ([]LoyaltyMonthlyJoinsRow, error)
	// Loyalty page, "close to leveling up": the clients (up to 25) within 30% of
	// the next tier's minimum, closest first. tier_mins as in LoyaltyTierStats.
	LoyaltyRisingClients(ctx context.Context, arg LoyaltyRisingClientsParams) ([]LoyaltyRisingClientsRow, error)
	// Loyalty page: one row per tier that has members. tier_mins is the tiers'
	// minimum spends in cents, ascending; a client's tier index is the highest
	// minimum their lifetime spend clears (the lowest tier if none), counted from
	// 0 at the entry tier -- the same rule as the page's tierFor. Lifetime spend
	// (gross_spent, before the On Account deduction) and points come from the
	// client_spend cache; the period figures (revenue, active members) cover
	// [date_from, date_to), either bound optional, and are computed live from just
	// the invoices inside the window. With no bound the period is all time, so the
	// cached figures are used as is.
	//
	// Same two sources and sign conventions as RefreshClientSpend: central
	// invoices (sales positive, returns negative) plus non-cancelled branch
	// invoices of reported-on branches/registers.
	LoyaltyTierStats(ctx context.Context, arg LoyaltyTierStatsParams) ([]LoyaltyTierStatsRow, error)
	// The original punch of an approved replace/delete on the till. Kept, not
	// deleted, so the audit trail shows what was there and who took it away.
	MarkBranchAttendanceEventRemoved(ctx context.Context, arg MarkBranchAttendanceEventRemovedParams) error
	MarkBranchExpenseUploadTokenUsed(ctx context.Context, id int64) error
	// A till's cancellation return names the sale it cancels (related_client_ref);
	// both rows get the mark. COALESCE keeps the first stamp on a replayed push.
	MarkBranchInvoicesCancelled(ctx context.Context, arg MarkBranchInvoicesCancelledParams) error
	MarkBranchShiftUploadTokenUsed(ctx context.Context, id int64) error
	MarkBranchTransferUploadTokenUsed(ctx context.Context, id int64) error
	MarkLoanUploadTokenUsed(ctx context.Context, id int64) error
	MarkUnknownItemSlotResolved(ctx context.Context, arg MarkUnknownItemSlotResolvedParams) error
	MarkWhatsAppReviewClicked(ctx context.Context, id int64) error
	// The WhatsApp rating poll over the range: polls sent, answers, and how many
	// of each star.
	PollRatingTotals(ctx context.Context, arg PollRatingTotalsParams) (PollRatingTotalsRow, error)
	PollRatingsByBranch(ctx context.Context, arg PollRatingsByBranchParams) ([]PollRatingsByBranchRow, error)
	PollRatingsByDay(ctx context.Context, arg PollRatingsByDayParams) ([]PollRatingsByDayRow, error)
	// What clients wrote back after the rating poll, newest first, with their
	// answer: why it wasn't great, and what they looked for and didn't find.
	PollReplies(ctx context.Context, arg PollRepliesParams) ([]PollRepliesRow, error)
	ProductBarcodesPresent(ctx context.Context, dollar_1 []string) ([]string, error)
	// Apply an inbound quantity delta and roll the per-location moving-average
	// cost forward. When existing on-hand is <= 0 the average is just reset to
	// the incoming cost (no meaningful prior average to blend).
	ReceiveInventoryStock(ctx context.Context, arg ReceiveInventoryStockParams) (InventoryStock, error)
	RecordEmailScheduleRun(ctx context.Context, arg RecordEmailScheduleRunParams) error
	// Opens an alert, or bumps the open one of the same kind for the same IP
	// seen within the last hour.
	RecordSecurityAlert(ctx context.Context, arg RecordSecurityAlertParams) error
	// A client's answer to the rating poll; a NULL rating is a vote taken back.
	RecordWhatsAppPollVote(ctx context.Context, arg RecordWhatsAppPollVoteParams) (RecordWhatsAppPollVoteRow, error)
	// Idempotent: a retried invoice post that already redeemed this code just
	// returns the row unchanged rather than erroring (matches
	// CreateBranchInvoice's own idempotent-retry shape). Only actually moves
	// an 'active' coupon to 'redeemed' -- an inactive/already-redeemed code is
	// left alone so a stale retry never resurrects it.
	RedeemCoupon(ctx context.Context, arg RedeemCouponParams) (Coupon, error)
	// Rebuilds client_spend for every client from all invoices. Same two sources
	// and sign conventions as ListClientsBySpending (see the comment there):
	// central invoices (sales positive, returns negative; grand_total is always
	// a positive magnitude) and non-cancelled branch invoices of reported-on
	// branches/registers, whose grand_total already carries its sign. total_spent
	// drops what was paid "On Account"; gross_spent keeps it. Line items are
	// pre-aggregated per invoice so they can't multiply grand_total.
	RefreshClientSpend(ctx context.Context) error
	RenameRole(ctx context.Context, arg RenameRoleParams) error
	// Points the row at a replacement photo (api/photo_replace.go); the new
	// photo starts upright.
	ReplaceBranchExpenseImageFile(ctx context.Context, arg ReplaceBranchExpenseImageFileParams) (BranchExpenseImage, error)
	// Same as ReplaceBranchExpenseImageFile.
	ReplaceBranchShiftReceiptImageFile(ctx context.Context, arg ReplaceBranchShiftReceiptImageFileParams) (BranchShiftReceiptImage, error)
	// A till's client turned out to be an existing central client (same phone):
	// invoices the till already sent under its own uid now point at the
	// canonical one.
	RepointBranchInvoicesClientUID(ctx context.Context, arg RepointBranchInvoicesClientUIDParams) error
	// Sales per branch; sales entered in kashi come back with branch_id 0 and
	// an empty name.
	ReportBranchSales(ctx context.Context, arg ReportBranchSalesParams) ([]ReportBranchSalesRow, error)
	// Revenue per product category. Lines without a product or whose product
	// has no category come back with an empty name.
	ReportCategorySales(ctx context.Context, arg ReportCategorySalesParams) ([]ReportCategorySalesRow, error)
	// Sales reports over report_sale_invoices / report_sale_lines (migration
	// 000134): the Dashboard's cost of goods and the Sales Dashboard
	// (api/sales_dashboard.go). Ranges are half-open [date_from, date_to), days
	// are Beirut calendar days (businessZone in api/business_zone.go) like the
	// rest of the dashboard.
	// Cost of goods sold for the Dashboard, scoped like its other figures:
	// till sales (optionally one branch) and/or sales entered in kashi. Only
	// lines with a known cost count; costed_revenue is what those lines sold
	// for, so the caller can say how much of revenue the cost covers.
	ReportCostOfGoods(ctx context.Context, arg ReportCostOfGoodsParams) (ReportCostOfGoodsRow, error)
	// ReportCostOfGoods per day.
	ReportCostOfGoodsSeries(ctx context.Context, arg ReportCostOfGoodsSeriesParams) ([]ReportCostOfGoodsSeriesRow, error)
	// Per day, what lines with a known cost sold for and what they cost --
	// the Sales Dashboard's profit is the difference.
	ReportDailyCosted(ctx context.Context, arg ReportDailyCostedParams) ([]ReportDailyCostedRow, error)
	// Sales (net of returns) per day.
	ReportDailySales(ctx context.Context, arg ReportDailySalesParams) ([]ReportDailySalesRow, error)
	// Sales by day of week (0 = Sunday) and hour, in each branch's own time
	// zone (Beirut for sales entered in kashi), for the Financials heatmap.
	ReportHourlySales(ctx context.Context, arg ReportHourlySalesParams) ([]ReportHourlySalesRow, error)
	// What the stock on hand cost, across every inventory: each stock row at
	// its own average cost, or the variant's when the row has none (stock
	// counts set only the variant's).
	ReportInventoryValue(ctx context.Context) (int64, error)
	// What sales were paid with: the till's payment accounts by name ("Cash
	// $$", "Visa", ...) plus kashi's own cashbox accounts, merged by name.
	ReportPaymentMethods(ctx context.Context, arg ReportPaymentMethodsParams) ([]ReportPaymentMethodsRow, error)
	// What customers still owe on till sales put "On Account". Settling a sale
	// later rewrites its payment lines (createBranchInvoiceSettlement), so the
	// On Account lines left are exactly what's outstanding.
	ReportReceivables(ctx context.Context) (int64, error)
	// Every year that has a sale, newest first, for the Sales Dashboard's
	// year picker.
	ReportSaleYears(ctx context.Context) ([]int32, error)
	// Active branch sales targets overlapping [date_from, date_to), for the
	// Sales Analysis page, which spreads each one over its days to get the
	// target for any month (api/sales_analysis.go). date_to is inclusive.
	ReportTargetsInRange(ctx context.Context, arg ReportTargetsInRangeParams) ([]ReportTargetsInRangeRow, error)
	// Best-selling products by revenue. Till lines whose product never
	// resolved to a kashi variant have no product and are left out.
	ReportTopProducts(ctx context.Context, arg ReportTopProductsParams) ([]ReportTopProductsRow, error)
	RequestUnknownItemHelp(ctx context.Context, arg RequestUnknownItemHelpParams) error
	ResolveBranchSyncConflict(ctx context.Context, arg ResolveBranchSyncConflictParams) (BranchSyncConflict, error)
	// Idempotent: resolving a row twice keeps who resolved it first.
	ResolveHomeActivity(ctx context.Context, arg ResolveHomeActivityParams) error
	// Mirrors ResolveVariantPrice: a branch assigned a discount list is discounted
	// from it, everyone else from the default list. Unlike price, no row here means
	// no discount (i.e. zero), not "unsellable" -- a product with no discount is a
	// product sold at full price.
	ResolveVariantDiscount(ctx context.Context, arg ResolveVariantDiscountParams) (int16, error)
	ResolveVariantDiscounts(ctx context.Context, arg ResolveVariantDiscountsParams) ([]ResolveVariantDiscountsRow, error)
	// The one place that answers "what does this variant cost at this branch".
	// A branch assigned a list via price_list_branches is priced from it; every
	// other branch, and any variant the assigned list doesn't mention, falls back
	// to the default list. No row means no price, which callers must treat as
	// "not sellable" rather than as zero.
	ResolveVariantPrice(ctx context.Context, arg ResolveVariantPriceParams) (int64, error)
	// Batch form of ResolveVariantPrice, for listings and the branch sync payload,
	// so pricing N variants costs one query rather than N. DISTINCT ON keeps the
	// branch list's row ahead of the default list's for the same variant.
	ResolveVariantPrices(ctx context.Context, arg ResolveVariantPricesParams) ([]ResolveVariantPricesRow, error)
	// Every open of a review link in the range, the plain link included.
	ReviewClicksTotal(ctx context.Context, arg ReviewClicksTotalParams) (int64, error)
	// Messages sent in the range and how far they got: delivered/read come from
	// Meta's webhook, clicked from the review link.
	ReviewFunnel(ctx context.Context, arg ReviewFunnelParams) (ReviewFunnelRow, error)
	ReviewFunnelByBranch(ctx context.Context, arg ReviewFunnelByBranchParams) ([]ReviewFunnelByBranchRow, error)
	// Per Beirut day: messages sent with a link, and link opens.
	ReviewFunnelByDay(ctx context.Context, arg ReviewFunnelByDayParams) ([]ReviewFunnelByDayRow, error)
	// Turns the photo by delta degrees (a multiple of 90, either sign) on top
	// of its saved rotation.
	RotateBranchExpenseImage(ctx context.Context, arg RotateBranchExpenseImageParams) (int16, error)
	// Same as RotateBranchExpenseImage.
	RotateBranchShiftReceiptImage(ctx context.Context, arg RotateBranchShiftReceiptImageParams) (int16, error)
	// Turns the photo by delta degrees (a multiple of 90, either sign) on top
	// of its saved rotation. Not a change to the transfer itself, so
	// updated_at is left alone.
	RotateTransferAttachment(ctx context.Context, arg RotateTransferAttachmentParams) (int16, error)
	// Sales in [from_at, to_at), not cancelled. A linked invoice shows its
	// salesperson's current name, so a renamed salesperson stays one person.
	SalespersonPerformanceInvoices(ctx context.Context, arg SalespersonPerformanceInvoicesParams) ([]SalespersonPerformanceInvoicesRow, error)
	SalespersonPerformanceItems(ctx context.Context, arg SalespersonPerformanceItemsParams) ([]BranchInvoiceItem, error)
	// The picker an admin matches a pictured item with: active variants whose
	// product name, code or barcode contains the text.
	SearchVariantsForUnknownItems(ctx context.Context, search string) ([]SearchVariantsForUnknownItemsRow, error)
	// Clients with a phone, for picking in a rule.
	SearchWhatsAppClients(ctx context.Context, search string) ([]SearchWhatsAppClientsRow, error)
	// Fills in avg_cost for every variant of one product, but only where it is
	// still at the 0 default -- i.e. never seeded by an actual stock receipt
	// (UpdateProductVariantAvgCost above). Used to backfill a starting cost
	// basis from an external cost list (cmd/import_costs-style one-off); it
	// never overwrites a real moving-average cost built from real receipts.
	SeedProductVariantsCostByCode(ctx context.Context, arg SeedProductVariantsCostByCodeParams) (int64, error)
	SetAssetCost(ctx context.Context, arg SetAssetCostParams) error
	SetBarcodeLabelDesign(ctx context.Context, barcodeLabelDesign json.RawMessage) (AppSetting, error)
	SetBranchActive(ctx context.Context, arg SetBranchActiveParams) error
	// A till re-categorising one of its own expenses (kashi-pos expense
	// detail). NULL category_id is "no category".
	SetBranchExpenseCategory(ctx context.Context, arg SetBranchExpenseCategoryParams) (BranchExpense, error)
	// A till marking one of its own expenses as paid by central, or not.
	SetBranchExpenseFromCentral(ctx context.Context, arg SetBranchExpenseFromCentralParams) (BranchExpense, error)
	// The same, from kashi's expenses page.
	SetBranchExpenseFromCentralByID(ctx context.Context, arg SetBranchExpenseFromCentralByIDParams) (BranchExpense, error)
	SetBranchHiddenFromReports(ctx context.Context, arg SetBranchHiddenFromReportsParams) error
	SetBranchInventory(ctx context.Context, arg SetBranchInventoryParams) error
	SetBranchInvoiceDiscount(ctx context.Context, arg SetBranchInvoiceDiscountParams) error
	SetBranchInvoiceItemDiscount(ctx context.Context, arg SetBranchInvoiceItemDiscountParams) error
	SetBranchInvoiceItemResolved(ctx context.Context, arg SetBranchInvoiceItemResolvedParams) error
	// Salesperson Performance (api/salesperson_performance.go) and the tills'
	// one-time report of who made their past sales.
	// Only a salesperson of the invoice's own branch is accepted.
	SetBranchInvoiceSalesperson(ctx context.Context, arg SetBranchInvoiceSalespersonParams) (int64, error)
	// A till re-categorising one of its own loans (kashi-pos loan detail).
	// Only the category: the rest of a branch loan stays as reported.
	SetBranchLoanCategory(ctx context.Context, arg SetBranchLoanCategoryParams) (Loan, error)
	SetBranchPlaceID(ctx context.Context, arg SetBranchPlaceIDParams) error
	SetBranchRegisterActive(ctx context.Context, arg SetBranchRegisterActiveParams) error
	SetBranchRegisterHiddenFromReports(ctx context.Context, arg SetBranchRegisterHiddenFromReportsParams) error
	// Later flip wins: a flip only applies if it's newer than the one stored, so
	// a till's offline flip that arrives late can't undo a more recent one made
	// in kashi (or vice versa). 0 rows = this flip was older, ignored.
	SetBranchRegisterQuickAccessMode(ctx context.Context, arg SetBranchRegisterQuickAccessModeParams) (int64, error)
	SetBranchRegisterReportedSettings(ctx context.Context, arg SetBranchRegisterReportedSettingsParams) error
	// managed_locally is admin-owned, not branch-reported: a branch's settings
	// push (UpsertBranchSettings) never touches it. Only the admin UI sets it.
	SetBranchSettingsManagedLocally(ctx context.Context, arg SetBranchSettingsManagedLocallyParams) (BranchSetting, error)
	// The sync-facing "delete" -- see 000046_branch_target_soft_delete.up.sql
	// for why this flips a flag instead of removing the row.
	SetBranchTargetActive(ctx context.Context, arg SetBranchTargetActiveParams) (BranchTarget, error)
	SetBranchTargetSeriesActive(ctx context.Context, arg SetBranchTargetSeriesActiveParams) (BranchTargetSeries, error)
	SetBranchUserActive(ctx context.Context, arg SetBranchUserActiveParams) (BranchUser, error)
	SetBranchWhatsAppNumber(ctx context.Context, arg SetBranchWhatsAppNumberParams) error
	SetCashboxAccountActive(ctx context.Context, arg SetCashboxAccountActiveParams) (CashboxAccount, error)
	SetClientActive(ctx context.Context, arg SetClientActiveParams) error
	// A client's home branch is the first branch they bought from, so a branch
	// invoice only sets it when none is set yet. The client is resolved by
	// either identity a till has used (client_uid, else the register's local
	// client id), as in ListClientsForExport. updated_at is left alone: the
	// column isn't synced to tills, so this mustn't make them re-pull the client.
	SetClientBranchIfNull(ctx context.Context, arg SetClientBranchIfNullParams) error
	SetDefaultLowStockThreshold(ctx context.Context, defaultLowStockThreshold int64) (AppSetting, error)
	SetDefaultWhatsAppNumber(ctx context.Context, id int64) error
	SetEmailResendAPIKey(ctx context.Context, emailResendApiKey string) error
	SetEmailSettings(ctx context.Context, arg SetEmailSettingsParams) error
	SetProductAutofillRules(ctx context.Context, arg SetProductAutofillRulesParams) (AppSetting, error)
	SetProductCategory(ctx context.Context, arg SetProductCategoryParams) error
	SetProductLowStockAlertsEnabled(ctx context.Context, arg SetProductLowStockAlertsEnabledParams) error
	SetProductVariantActive(ctx context.Context, arg SetProductVariantActiveParams) error
	SetPurchaseStatus(ctx context.Context, arg SetPurchaseStatusParams) (Purchase, error)
	SetPurchaseTotals(ctx context.Context, arg SetPurchaseTotalsParams) error
	SetRecurringExpenseActive(ctx context.Context, arg SetRecurringExpenseActiveParams) (RecurringExpense, error)
	SetRegisterUpdateStatus(ctx context.Context, arg SetRegisterUpdateStatusParams) error
	SetRegistersTargetRelease(ctx context.Context, arg SetRegistersTargetReleaseParams) error
	SetReviewSettings(ctx context.Context, arg SetReviewSettingsParams) error
	SetSalespersonActive(ctx context.Context, arg SetSalespersonActiveParams) (Salesperson, error)
	// Set from kashi: from now on the till takes this value (see 000127).
	SetSalespersonAttendanceID(ctx context.Context, arg SetSalespersonAttendanceIDParams) (Salesperson, error)
	SetSalespersonColor(ctx context.Context, arg SetSalespersonColorParams) (Salesperson, error)
	// Whether the till offers this person at checkout; attendance applies to
	// everyone on the roster either way.
	SetSalespersonIsSalesperson(ctx context.Context, arg SetSalespersonIsSalespersonParams) (Salesperson, error)
	SetStockCountNote(ctx context.Context, arg SetStockCountNoteParams) error
	SetStockCountStatus(ctx context.Context, arg SetStockCountStatusParams) (StockCount, error)
	// A new photo starts upright, whatever the previous one was turned to.
	SetTransferAttachmentPath(ctx context.Context, arg SetTransferAttachmentPathParams) error
	SetTransferConfirmed(ctx context.Context, arg SetTransferConfirmedParams) (Transfer, error)
	// The admin's own edit, keyed by transfer_item id directly (unlike the
	// branch's own confirm, which only ever knows an item by variant) --
	// lets kashi correct a destination's count, or fill one in before it
	// ever arrives, from the transfer detail dialog.
	SetTransferItemReceivedQuantity(ctx context.Context, arg SetTransferItemReceivedQuantityParams) (TransferItem, error)
	// The destination branch reporting what it actually counted for one line.
	// Keyed by variant, not transfer_item id -- the till only ever knows an
	// item by barcode/uid, resolved to variant_id the same way
	// CreateBranchTransferRequestTx resolves an outgoing line.
	SetTransferItemReceivedQuantityByVariant(ctx context.Context, arg SetTransferItemReceivedQuantityByVariantParams) (int64, error)
	SetTransferStatus(ctx context.Context, arg SetTransferStatusParams) (Transfer, error)
	// The picture goes to the slot and to every other unit of its cart line. A
	// slot already matched to a product keeps the picture it was matched with.
	SetUnknownItemSlotImage(ctx context.Context, arg SetUnknownItemSlotImageParams) error
	SetUserAvatarColor(ctx context.Context, arg SetUserAvatarColorParams) error
	SetVariantBarcode(ctx context.Context, arg SetVariantBarcodeParams) (ProductVariant, error)
	SetWhatsAppMessageCost(ctx context.Context, costMicros int64) error
	SetWhatsAppNumberPhone(ctx context.Context, arg SetWhatsAppNumberPhoneParams) error
	SetWhatsAppSenderSettings(ctx context.Context, arg SetWhatsAppSenderSettingsParams) error
	SetWhatsAppSettings(ctx context.Context, arg SetWhatsAppSettingsParams) error
	// A unit added to a cart line that already has its picture shares it.
	ShareUnknownLineImages(ctx context.Context, sessionID int64) error
	// Messages the bridge dropped from a paused number's queue on resume (refs
	// from POST /instance/resume): logged as sent when queued, they never went.
	SkipDroppedWhatsAppMessages(ctx context.Context, arg SkipDroppedWhatsAppMessagesParams) error
	SplitUnknownInvoiceItem(ctx context.Context, arg SplitUnknownInvoiceItemParams) error
	// Net sales revenue: same grand_total-sum convention as ListDailyIncome in
	// branch_invoice.sql (returns already net out via their signed grand_total).
	SumBranchRevenueForRange(ctx context.Context, arg SumBranchRevenueForRangeParams) (int64, error)
	// The redemption-time query: every branch's contribution to this client's
	// loyalty balance, added up. Each branch is decisive for what it reports
	// (loyalty_points_delta on branch_invoices) -- this never recomputes that
	// number, only sums what's already been reported.
	SumClientLoyaltyPoints(ctx context.Context, clientID int64) (int64, error)
	// Bumps both the register's and its branch's last_seen_at: the branch is
	// "seen" whenever any of its registers is.
	TouchBranchRegister(ctx context.Context, id int64) error
	// Reopens a resolved urgent row, pinning it on Home again.
	UnresolveHomeActivity(ctx context.Context, arg UnresolveHomeActivityParams) error
	UnsetDefaultDiscountList(ctx context.Context, id int64) error
	UnsetDefaultPriceList(ctx context.Context, id int64) error
	UpdateAppReleaseNotes(ctx context.Context, arg UpdateAppReleaseNotesParams) (AppRelease, error)
	UpdateAppSettings(ctx context.Context, arg UpdateAppSettingsParams) (AppSetting, error)
	UpdateAsset(ctx context.Context, arg UpdateAssetParams) (Asset, error)
	UpdateAssetCategory(ctx context.Context, arg UpdateAssetCategoryParams) (AssetCategory, error)
	UpdateAttributeValue(ctx context.Context, arg UpdateAttributeValueParams) (AttributesValue, error)
	UpdateBranchAttendanceEvent(ctx context.Context, arg UpdateBranchAttendanceEventParams) (BranchAttendanceEvent, error)
	UpdateBranchRegister(ctx context.Context, arg UpdateBranchRegisterParams) (BranchRegister, error)
	UpdateBranchRegisterAPIKeyHash(ctx context.Context, arg UpdateBranchRegisterAPIKeyHashParams) error
	UpdateBranchSalespersonName(ctx context.Context, arg UpdateBranchSalespersonNameParams) (Salesperson, error)
	UpdateBranchTarget(ctx context.Context, arg UpdateBranchTargetParams) (BranchTarget, error)
	// Only affects future periods -- see CreateGeneratedBranchTarget's note on
	// generation snapshotting a series' fields, never joining them live.
	UpdateBranchTargetSeries(ctx context.Context, arg UpdateBranchTargetSeriesParams) (BranchTargetSeries, error)
	UpdateBranchUser(ctx context.Context, arg UpdateBranchUserParams) (BranchUser, error)
	UpdateCashbox(ctx context.Context, arg UpdateCashboxParams) (Cashbox, error)
	UpdateCashboxAccount(ctx context.Context, arg UpdateCashboxAccountParams) (CashboxAccount, error)
	UpdateClient(ctx context.Context, arg UpdateClientParams) (Client, error)
	UpdateClientPhone(ctx context.Context, arg UpdateClientPhoneParams) error
	UpdateColor(ctx context.Context, arg UpdateColorParams) (Color, error)
	UpdateCoupon(ctx context.Context, arg UpdateCouponParams) (Coupon, error)
	UpdateCouponCategory(ctx context.Context, arg UpdateCouponCategoryParams) (CouponCategory, error)
	UpdateCouponType(ctx context.Context, arg UpdateCouponTypeParams) (CouponType, error)
	UpdateCurrency(ctx context.Context, arg UpdateCurrencyParams) (Currency, error)
	UpdateDeal(ctx context.Context, arg UpdateDealParams) (Deal, error)
	UpdateDiscountList(ctx context.Context, arg UpdateDiscountListParams) error
	UpdateDiscountListItem(ctx context.Context, arg UpdateDiscountListItemParams) error
	// Saved in place: the rows a rule wrote carry its id (rule_id), so a rule
	// re-created with a new id would have every one of them rewritten.
	UpdateDiscountListRule(ctx context.Context, arg UpdateDiscountListRuleParams) (int64, error)
	// Saved in place, so a group (and its rules) keeps its id.
	UpdateDiscountListRuleGroup(ctx context.Context, arg UpdateDiscountListRuleGroupParams) (int64, error)
	UpdateEmailSchedule(ctx context.Context, arg UpdateEmailScheduleParams) (EmailSchedule, error)
	UpdateEmployee(ctx context.Context, arg UpdateEmployeeParams) (Employee, error)
	UpdateEmployeeSalary(ctx context.Context, arg UpdateEmployeeSalaryParams) (Employee, error)
	UpdateExpense(ctx context.Context, arg UpdateExpenseParams) (Expense, error)
	UpdateExpenseCategory(ctx context.Context, arg UpdateExpenseCategoryParams) (ExpenseCategory, error)
	UpdateInventory(ctx context.Context, arg UpdateInventoryParams) error
	UpdateInvoiceDiscount(ctx context.Context, arg UpdateInvoiceDiscountParams) (InvoiceDiscount, error)
	UpdateInvoiceType(ctx context.Context, arg UpdateInvoiceTypeParams) (InvoiceType, error)
	// Central loans only -- branch-origin loans are a synced record of what a
	// branch reported and stay read-only here (WHERE origin filter makes a
	// branch-loan id return no rows, surfaced as a 404 by the handler).
	UpdateLoan(ctx context.Context, arg UpdateLoanParams) (Loan, error)
	UpdateLoanCategory(ctx context.Context, arg UpdateLoanCategoryParams) (LoanCategory, error)
	UpdatePriceList(ctx context.Context, arg UpdatePriceListParams) error
	UpdatePriceListItem(ctx context.Context, arg UpdatePriceListItemParams) error
	UpdateProduct(ctx context.Context, arg UpdateProductParams) error
	UpdateProductAttribute(ctx context.Context, arg UpdateProductAttributeParams) error
	UpdateProductCategory(ctx context.Context, arg UpdateProductCategoryParams) (ProductCategory, error)
	// A null threshold clears the override, falling back to the app-wide default.
	UpdateProductLowStockThreshold(ctx context.Context, arg UpdateProductLowStockThresholdParams) error
	// price is deliberately not settable here -- see CreateProductVariant.
	UpdateProductVariant(ctx context.Context, arg UpdateProductVariantParams) (ProductVariant, error)
	// Roll the variant's global moving-average cost forward on a stock receipt.
	// current_qty is the on-hand across all locations before this receipt.
	UpdateProductVariantAvgCost(ctx context.Context, arg UpdateProductVariantAvgCostParams) error
	UpdateRecurringExpenseNextDue(ctx context.Context, arg UpdateRecurringExpenseNextDueParams) (RecurringExpense, error)
	UpdateSalesperson(ctx context.Context, arg UpdateSalespersonParams) (Salesperson, error)
	UpdateSecuritySettings(ctx context.Context, arg UpdateSecuritySettingsParams) (SecuritySetting, error)
	UpdateSize(ctx context.Context, arg UpdateSizeParams) (Size, error)
	UpdateTransfer(ctx context.Context, arg UpdateTransferParams) error
	UpdateUser(ctx context.Context, arg UpdateUserParams) error
	UpdateWhatsAppNumberLabel(ctx context.Context, arg UpdateWhatsAppNumberLabelParams) (WhatsappNumber, error)
	UpsertAttributeValue(ctx context.Context, arg UpsertAttributeValueParams) (AttributesValue, error)
	UpsertBranchSettings(ctx context.Context, arg UpsertBranchSettingsParams) (BranchSetting, error)
	// Idempotent on (branch_id, entity, ref): a retried outbox push re-reports
	// the same conflict. A row an admin already resolved/dismissed is left
	// alone (nothing to re-open).
	UpsertBranchSyncConflict(ctx context.Context, arg UpsertBranchSyncConflictParams) (BranchSyncConflict, error)
	UpsertCashboxAccountOverride(ctx context.Context, arg UpsertCashboxAccountOverrideParams) (BranchCashboxAccount, error)
	UpsertClientLink(ctx context.Context, arg UpsertClientLinkParams) error
	UpsertDefaultBranchSettings(ctx context.Context, settings json.RawMessage) (DefaultBranchSetting, error)
	UpsertDiscountListBranch(ctx context.Context, arg UpsertDiscountListBranchParams) error
	UpsertDiscountListOptionItem(ctx context.Context, arg UpsertDiscountListOptionItemParams) error
	UpsertGoogleReview(ctx context.Context, arg UpsertGoogleReviewParams) error
	UpsertIPBan(ctx context.Context, arg UpsertIPBanParams) error
	// Reactivates inventories_assets (created 000012, never wired up until now):
	// per-location unit counts for fixed assets, feeding the Assets Treemap.
	// One assets row is a distinct item *type*; the same asset can sit in more
	// than one location, each with its own counted quantity here.
	UpsertInventoryAssetQuantity(ctx context.Context, arg UpsertInventoryAssetQuantityParams) (InventoriesAsset, error)
	// One open "oversold" alert per (branch, variant). Unlike
	// UpsertBranchSyncConflict, an alert an admin already resolved is reopened:
	// going negative again after a fix is a new problem.
	UpsertOversoldConflict(ctx context.Context, arg UpsertOversoldConflictParams) (BranchSyncConflict, error)
	UpsertPriceListBranch(ctx context.Context, arg UpsertPriceListBranchParams) error
	UpsertProductAttribute(ctx context.Context, arg UpsertProductAttributeParams) error
	UpsertRolePermission(ctx context.Context, arg UpsertRolePermissionParams) error
	// The Security page and its request middleware (api/security.go).
	// Folds one flush's worth of requests from an IP into its row: counters
	// add up, the "last" columns and the location are overwritten.
	UpsertVisitorIP(ctx context.Context, arg UpsertVisitorIPParams) error
	// IPs and requests per country, busiest first.
	VisitorCountries(ctx context.Context) ([]VisitorCountriesRow, error)
	// Lets units through with no picture. A unit that already has one is left alone.
	WaiveUnknownItemSlots(ctx context.Context, arg WaiveUnknownItemSlotsParams) (int64, error)
	// Names for a rule's phones, matched on their last 8 digits (whatsAppSamePhone).
	WhatsAppClientsByPhoneTail(ctx context.Context, tails []string) ([]WhatsAppClientsByPhoneTailRow, error)
	// Both kashi's failures (Meta refused the send) and Meta's own (accepted,
	// then couldn't deliver).
	WhatsAppFailureReasons(ctx context.Context, arg WhatsAppFailureReasonsParams) ([]WhatsAppFailureReasonsRow, error)
	// Sale messages that failed lately (a retried one that then went out is no
	// longer counted, see DeleteFailedWhatsAppMessagesForInvoice), and the
	// latest failure's reason.
	WhatsAppFailureWatch(ctx context.Context) (WhatsAppFailureWatchRow, error)
	// delivered/read/undelivered come from Meta's webhook (delivery_status).
	WhatsAppMessageTotals(ctx context.Context, arg WhatsAppMessageTotalsParams) (WhatsAppMessageTotalsRow, error)
	WhatsAppMessagesByBranch(ctx context.Context, arg WhatsAppMessagesByBranchParams) ([]WhatsAppMessagesByBranchRow, error)
	// Days are Beirut calendar days, like the rest of the business.
	WhatsAppMessagesByDay(ctx context.Context, arg WhatsAppMessagesByDayParams) ([]WhatsAppMessagesByDayRow, error)
	WhatsAppMessagesByHour(ctx context.Context, arg WhatsAppMessagesByHourParams) ([]WhatsAppMessagesByHourRow, error)
	// ” rule_name is "no rule matched" (the default template).
	WhatsAppMessagesByRule(ctx context.Context, arg WhatsAppMessagesByRuleParams) ([]WhatsAppMessagesByRuleRow, error)
	// The number a branch's sale goes out from: its own, else the default, else
	// (no default, as when the first number was removed) the oldest one. A number
	// whose minimum invoice the sale is under is passed over for the next one.
	WhatsAppNumberForBranch(ctx context.Context, arg WhatsAppNumberForBranchParams) (WhatsappNumber, error)
	// A till that reports the same sale twice doesn't message the client twice.
	WhatsAppSentForInvoice(ctx context.Context, arg WhatsAppSentForInvoiceParams) (bool, error)
	WhatsAppTopRecipients(ctx context.Context, arg WhatsAppTopRecipientsParams) ([]WhatsAppTopRecipientsRow, error)
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) AcknowledgeSecurityAlerts added in v1.1.0

func (q *Queries) AcknowledgeSecurityAlerts(ctx context.Context, arg AcknowledgeSecurityAlertsParams) error

Marks the given alerts seen; an empty list marks every open one except those of kept_kinds (critical ones, resolved only one by one).

func (*Queries) ActiveDiscountListForBranch added in v1.1.6

func (q *Queries) ActiveDiscountListForBranch(ctx context.Context, branchID int64) (DiscountList, error)

The list a branch is discounted from: its own assigned list when that one is active and in date, otherwise the default -- the same choice ResolveVariantDiscount makes, and the till makes from what it's sent.

func (*Queries) AddBatchItem

func (q *Queries) AddBatchItem(ctx context.Context, arg AddBatchItemParams) (BatchItem, error)

remaining_quantity starts equal to quantity_bought -- FIFO consumption (applyStockMovement) draws it down as sales are attributed to this batch, and returns of those sales put it back.

func (*Queries) AddCashboxAccountBalance

func (q *Queries) AddCashboxAccountBalance(ctx context.Context, arg AddCashboxAccountBalanceParams) (ShiftsAccountsBalance, error)

func (*Queries) AddClientLoyaltyPoints

func (q *Queries) AddClientLoyaltyPoints(ctx context.Context, arg AddClientLoyaltyPointsParams) error

func (*Queries) AddInventoryStockQuantity

func (q *Queries) AddInventoryStockQuantity(ctx context.Context, arg AddInventoryStockQuantityParams) (InventoryStock, error)

Apply a signed quantity delta to one SKU's on-hand in one inventory, creating the row if this SKU has never been stocked there. Cost is left untouched (used for sales, returns, transfers, adjustments).

func (*Queries) AddInvoiceDiscountBranch added in v1.1.8

func (q *Queries) AddInvoiceDiscountBranch(ctx context.Context, arg AddInvoiceDiscountBranchParams) error

func (*Queries) AddInvoiceProduct

func (q *Queries) AddInvoiceProduct(ctx context.Context, arg AddInvoiceProductParams) (InvoiceProduct, error)

func (*Queries) AddProductSaleOptionsForEntries added in v1.1.6

func (q *Queries) AddProductSaleOptionsForEntries(ctx context.Context, arg AddProductSaleOptionsForEntriesParams) ([]int64, error)

Gives every product named by entries each of the options; returns the product ids it matched.

func (*Queries) AddPurchaseItem

func (q *Queries) AddPurchaseItem(ctx context.Context, arg AddPurchaseItemParams) (PurchaseItem, error)

func (*Queries) AddPurchasedProduct

func (q *Queries) AddPurchasedProduct(ctx context.Context, arg AddPurchasedProductParams) (ProductSupplier, error)

func (*Queries) AddPurchasedProductCost

func (q *Queries) AddPurchasedProductCost(ctx context.Context, arg AddPurchasedProductCostParams) (ProductSupplierCost, error)

func (*Queries) AddStockCountItem

func (q *Queries) AddStockCountItem(ctx context.Context, arg AddStockCountItemParams) (StockCountItem, error)

func (*Queries) AddWhatsAppChatMessage added in v1.1.1

func (q *Queries) AddWhatsAppChatMessage(ctx context.Context, arg AddWhatsAppChatMessageParams) (int64, error)

The Inbox tab: every message on our own WhatsApp numbers (api/whatsapp_chat.go). ErrNoRows when the bridge already reported this message.

func (*Queries) AddWhatsAppPollReply added in v1.1.0

func (q *Queries) AddWhatsAppPollReply(ctx context.Context, arg AddWhatsAppPollReplyParams) (int64, error)

A client's message after the poll, reported by the bridge. No rows when the poll is unknown or the bridge already reported this message.

func (*Queries) AdjustBatchItemRemainingQuantity

func (q *Queries) AdjustBatchItemRemainingQuantity(ctx context.Context, arg AdjustBatchItemRemainingQuantityParams) (BatchItem, error)

Signed delta: negative consumes (a sale), positive replenishes (a return of that sale). No floor at zero -- same "ledger stays authoritative, UI surfaces negatives" rule as inventory_stock.

func (*Queries) AdoptSalespersonAttendanceID added in v1.1.0

func (q *Queries) AdoptSalespersonAttendanceID(ctx context.Context, arg AdoptSalespersonAttendanceIDParams) error

A till's own value, reported up, for a salesperson kashi hasn't set one for. updated_at is left alone: nothing about it needs to go back down.

func (*Queries) ApplyWhatsAppBridgeTick added in v1.1.0

func (q *Queries) ApplyWhatsAppBridgeTick(ctx context.Context, arg ApplyWhatsAppBridgeTickParams) (ApplyWhatsAppBridgeTickRow, error)

A tick the bridge saw on one of our own messages. Like Meta's statuses it only moves forward (sent -> delivered -> read), so a late one changes nothing.

func (*Queries) ApplyWhatsAppDeliveryStatus added in v1.1.0

func (q *Queries) ApplyWhatsAppDeliveryStatus(ctx context.Context, arg ApplyWhatsAppDeliveryStatusParams) ([]int64, error)

Meta's WhatsApp webhook (api/whatsapp_webhook.go). Delivery only moves forward (sent -> delivered -> read), so an update that arrives late doesn't undo a newer one; 'failed' always wins. A message Meta couldn't deliver, or says it doesn't charge for, costs nothing.

func (*Queries) AttachWhatsAppPoll added in v1.1.6

func (q *Queries) AttachWhatsAppPoll(ctx context.Context, arg AttachWhatsAppPollParams) error

The rating poll a new client gets at checkout, recorded on the welcome row that checkout claimed, so one client's welcome and poll are one row (its ticks are the welcome's; votes find it by poll_ref).

func (*Queries) BatchSetClientPhoneFlags added in v1.1.6

func (q *Queries) BatchSetClientPhoneFlags(ctx context.Context, arg BatchSetClientPhoneFlagsParams) error

Sets only phone_valid/phone_country, leaving the phone text and updated_at alone: bumping updated_at would make every till re-download the client on its next catch-up.

func (*Queries) BatchUpdateClientPhones added in v1.1.3

func (q *Queries) BatchUpdateClientPhones(ctx context.Context, arg BatchUpdateClientPhonesParams) error

Bulk counterpart to UpdateClientPhone for normalizeClientPhones: one round trip for a whole chunk instead of one per row, which is what made the first version of this job time out at Cloudflare's gateway on 60k+ individual updates. Also backfills phone_valid/phone_country for every row the job passes (even one whose phone text didn't change), since those columns start out at their just-migrated-in defaults until this runs once.

func (*Queries) BranchAttendanceChangeRefsPresent

func (q *Queries) BranchAttendanceChangeRefsPresent(ctx context.Context, arg BranchAttendanceChangeRefsPresentParams) ([]string, error)

func (*Queries) BranchAttendanceEventRefsPresent

func (q *Queries) BranchAttendanceEventRefsPresent(ctx context.Context, arg BranchAttendanceEventRefsPresentParams) ([]string, error)

func (*Queries) BranchClientLinksPresent

func (q *Queries) BranchClientLinksPresent(ctx context.Context, arg BranchClientLinksPresentParams) ([]int64, error)

func (*Queries) BranchCommandSummary

func (q *Queries) BranchCommandSummary(ctx context.Context) ([]BranchCommandSummaryRow, error)

One row per branch: what's still queued and what failed in the last day, for the Commands page sidebar and its nav dot.

func (*Queries) BranchExpenseRefsPresent

func (q *Queries) BranchExpenseRefsPresent(ctx context.Context, arg BranchExpenseRefsPresentParams) ([]string, error)

func (*Queries) BranchInvoiceRefsPresent

func (q *Queries) BranchInvoiceRefsPresent(ctx context.Context, arg BranchInvoiceRefsPresentParams) ([]string, error)

Reconcile queries: given the refs a branch believes it has pushed, return the subset kashi actually holds. The branch diffs its own list against this to decide what still needs (re)queuing -- the basis of "sync everything to a (possibly new) central server". Each is a single indexed `= ANY` lookup; the handler caps the input array size.

func (*Queries) BranchInvoicesReferenceClient

func (q *Queries) BranchInvoicesReferenceClient(ctx context.Context, id int64) (bool, error)

func (*Queries) BranchInvoicesReferenceVariant

func (q *Queries) BranchInvoicesReferenceVariant(ctx context.Context, id int64) (bool, error)

func (*Queries) BranchLoanRefsPresent

func (q *Queries) BranchLoanRefsPresent(ctx context.Context, arg BranchLoanRefsPresentParams) ([]sql.NullString, error)

func (*Queries) BranchSalespersonExists added in v1.1.0

func (q *Queries) BranchSalespersonExists(ctx context.Context, arg BranchSalespersonExistsParams) (bool, error)

func (*Queries) BranchShiftIsClosed

func (q *Queries) BranchShiftIsClosed(ctx context.Context, arg BranchShiftIsClosedParams) (bool, error)

A branch_shifts row exists only once kashi-pos has reported that shift's close, so its mere presence is the "this shift is closed" signal -- closed_at itself can be NULL for an older till build that omitted it.

func (*Queries) BranchShiftRefsPresent

func (q *Queries) BranchShiftRefsPresent(ctx context.Context, arg BranchShiftRefsPresentParams) ([]string, error)

func (*Queries) BranchSyncConflictSummary

func (q *Queries) BranchSyncConflictSummary(ctx context.Context) ([]BranchSyncConflictSummaryRow, error)

One row per branch: open conflicts, and how many of those are oversold stock (the kind that needs a stock fix), for the Conflicts page sidebar and its nav dot.

func (*Queries) BranchVisitorEventRefsPresent

func (q *Queries) BranchVisitorEventRefsPresent(ctx context.Context, arg BranchVisitorEventRefsPresentParams) ([]string, error)

func (*Queries) BulkSetDiscountListItems added in v1.1.1

func (q *Queries) BulkSetDiscountListItems(ctx context.Context, arg BulkSetDiscountListItemsParams) ([]int64, error)

Puts every variant whose barcode, or whose product's code, is in entries on the list at one discount (adding it or changing it). A code names all of its product's variants. deal_id, when set, puts them on that deal instead (discount 0). Returns the variant ids it set.

func (*Queries) BulkSetDiscountListOptionItems added in v1.1.6

func (q *Queries) BulkSetDiscountListOptionItems(ctx context.Context, arg BulkSetDiscountListOptionItemsParams) ([]int64, error)

BulkSetDiscountListItems for one option: the discount applies to the matched variants only when they are sold as that option.

func (*Queries) BumpAdminActivity added in v1.1.0

func (q *Queries) BumpAdminActivity(ctx context.Context, arg BumpAdminActivityParams) (int64, error)

Folds a repeat into the feed's newest entry when it's the same change by the same person, made less than an hour after it: the count goes up and the time moves to now. No row back (sql.ErrNoRows) means it wasn't a repeat, and the caller adds a new entry.

func (*Queries) BusyHoursSales added in v1.1.0

func (q *Queries) BusyHoursSales(ctx context.Context, arg BusyHoursSalesParams) ([]BusyHoursSalesRow, error)

Sales (not returns or exchanges): how many, and what they came to.

func (*Queries) BusyHoursVisitors added in v1.1.0

func (q *Queries) BusyHoursVisitors(ctx context.Context, arg BusyHoursVisitorsParams) ([]BusyHoursVisitorsRow, error)

The Busy Hours page (api/busy_hours.go): when people come in and buy, by weekday (ISO: 1 Monday .. 7 Sunday) and hour, in each branch's own time zone. Hidden branches/registers and cancelled sales are left out, like the other reports. Empty branch_ids = every branch. Presses of the till's people counter (customers in).

func (*Queries) CancelBranchCommand

func (q *Queries) CancelBranchCommand(ctx context.Context, id int64) (BranchCommand, error)

Only a command no till has acked yet can be withdrawn.

func (*Queries) CancelBranchExpense added in v1.1.2

func (q *Queries) CancelBranchExpense(ctx context.Context, id int64) (BranchExpense, error)

Stamps cancelled_at once; a second cancel matches no row (the handler reads the row first, so that's an idempotent no-op, not an error).

func (*Queries) CancelBranchLoan added in v1.1.2

func (q *Queries) CancelBranchLoan(ctx context.Context, id int64) (Loan, error)

Branch-reported loans only: a central loan is deleted, there's no till to tell. Stamps cancelled_at once, like CancelBranchExpense.

func (*Queries) ClaimBranchQuickAccessInit

func (q *Queries) ClaimBranchQuickAccessInit(ctx context.Context, id int64) (int64, error)

The once-only gate on a branch's list: 1 row the first time it's set up (by a till's import or an admin save), 0 ever after.

func (*Queries) ClaimEmailScheduleRun added in v1.1.0

func (q *Queries) ClaimEmailScheduleRun(ctx context.Context, arg ClaimEmailScheduleRunParams) (int64, error)

Moves a due schedule on to its next run before it sends, and only if no one else already did -- so a run is never sent twice.

func (*Queries) ClaimWhatsAppPollFollowup added in v1.1.0

Marks the poll's follow-up as sent and says where to send it; no rows when it already went (a changed vote) or the number is gone. Also none when the follow-up is off for this client: for_new / for_returning, a returning client being one messaged before this message.

func (*Queries) ClaimWhatsAppWelcome added in v1.1.1

func (q *Queries) ClaimWhatsAppWelcome(ctx context.Context, arg ClaimWhatsAppWelcomeParams) (int64, error)

A sale's checkout finds the welcome sent to its client earlier (no invoice yet, within the last 12 hours) and takes it over, so it isn't messaged twice.

func (*Queries) ClearDefaultWhatsAppNumber added in v1.1.0

func (q *Queries) ClearDefaultWhatsAppNumber(ctx context.Context) error

func (*Queries) ClearProductSaleOptionsForEntries added in v1.1.6

func (q *Queries) ClearProductSaleOptionsForEntries(ctx context.Context, entries []string) error

Entries are matched the way BulkSetDiscountListItems matches them: a variant barcode names its product, a code names the product directly.

func (*Queries) ClientPhonesPresent

func (q *Queries) ClientPhonesPresent(ctx context.Context, dollar_1 []string) ([]string, error)

func (*Queries) CloseShift

func (q *Queries) CloseShift(ctx context.Context, id int64) error

func (*Queries) CompleteBranchCommand

func (q *Queries) CompleteBranchCommand(ctx context.Context, arg CompleteBranchCommandParams) (BranchCommand, error)

func (*Queries) CountAdminActivitiesSince added in v1.1.0

func (q *Queries) CountAdminActivitiesSince(ctx context.Context, since time.Time) (int64, error)

The home page's "today" count next to the IT Management feed.

func (*Queries) CountAssets

func (q *Queries) CountAssets(ctx context.Context, arg CountAssetsParams) (int64, error)

func (*Queries) CountAttributeValues

func (q *Queries) CountAttributeValues(ctx context.Context, arg CountAttributeValuesParams) (int64, error)

func (*Queries) CountAuditLogs

func (q *Queries) CountAuditLogs(ctx context.Context, arg CountAuditLogsParams) (int64, error)

func (*Queries) CountBatchesFiltered

func (q *Queries) CountBatchesFiltered(ctx context.Context, search string) (int64, error)

func (*Queries) CountBranchAttendanceChanges

func (q *Queries) CountBranchAttendanceChanges(ctx context.Context, branchID sql.NullInt64) (int64, error)

func (*Queries) CountBranchAttendanceEvents

func (q *Queries) CountBranchAttendanceEvents(ctx context.Context, branchID sql.NullInt64) (int64, error)

func (*Queries) CountBranchCommands

func (q *Queries) CountBranchCommands(ctx context.Context, arg CountBranchCommandsParams) (int64, error)

func (*Queries) CountBranchExpenseImages

func (q *Queries) CountBranchExpenseImages(ctx context.Context) (int64, error)

func (*Queries) CountBranchExpenseImagesForExpense added in v1.1.0

func (q *Queries) CountBranchExpenseImagesForExpense(ctx context.Context, branchExpenseID int64) (int64, error)

func (*Queries) CountBranchExpenses

func (q *Queries) CountBranchExpenses(ctx context.Context, arg CountBranchExpensesParams) (int64, error)

func (*Queries) CountBranchInvoiceSettlements

func (q *Queries) CountBranchInvoiceSettlements(ctx context.Context, branchID sql.NullInt64) (int64, error)

func (*Queries) CountBranchInvoices

func (q *Queries) CountBranchInvoices(ctx context.Context, branchID sql.NullInt64) (int64, error)

func (*Queries) CountBranchInvoicesFiltered

func (q *Queries) CountBranchInvoicesFiltered(ctx context.Context, arg CountBranchInvoicesFilteredParams) (int64, error)

func (*Queries) CountBranchShiftReceiptImages

func (q *Queries) CountBranchShiftReceiptImages(ctx context.Context) (int64, error)

func (*Queries) CountBranchShifts

func (q *Queries) CountBranchShifts(ctx context.Context, branchID sql.NullInt64) (int64, error)

func (*Queries) CountBranchSyncConflicts

func (q *Queries) CountBranchSyncConflicts(ctx context.Context, arg CountBranchSyncConflictsParams) (int64, error)

func (*Queries) CountBranchVisitorDayByDirection

func (q *Queries) CountBranchVisitorDayByDirection(ctx context.Context, arg CountBranchVisitorDayByDirectionParams) (int64, error)

Running gross tally for one branch, one local day, one direction -- used to tell the admin toast "customer in -- 42 in today".

func (*Queries) CountBranchVisitorDays

func (q *Queries) CountBranchVisitorDays(ctx context.Context, branchID sql.NullInt64) (int64, error)

func (*Queries) CountBranchesOnDefaultDiscountList added in v1.1.6

func (q *Queries) CountBranchesOnDefaultDiscountList(ctx context.Context) (int64, error)

Branches with no active list of their own, i.e. discounted from the default.

func (*Queries) CountCashboxAccountOverrides

func (q *Queries) CountCashboxAccountOverrides(ctx context.Context, cashboxAccountID int64) (int64, error)

How many branches reference this method, either via an explicit override row or by inheriting it as-is. A payment method that any branch still overrides can't be hard-deleted without leaving that override dangling (or silently cascading it away), so the delete handler blocks on this and points the admin at deactivating instead.

func (*Queries) CountClients

func (q *Queries) CountClients(ctx context.Context, clientType sql.NullString) (int64, error)

func (*Queries) CountClientsBySpending

func (q *Queries) CountClientsBySpending(ctx context.Context, arg CountClientsBySpendingParams) (int64, error)

Same filters as ListClientsBySpending, minus the spend computation -- used for the rest-of-clients table's pagination total. With a branch picked it counts that branch's clients: home branch, or a branch invoice there (same cancelled/hidden rules as the list).

func (*Queries) CountClientsBySpendingCached added in v1.1.6

func (q *Queries) CountClientsBySpendingCached(ctx context.Context, arg CountClientsBySpendingCachedParams) (int64, error)

Count for ListClientsBySpendingCached.

func (*Queries) CountColors

func (q *Queries) CountColors(ctx context.Context, search string) (int64, error)

func (*Queries) CountCoupons

func (q *Queries) CountCoupons(ctx context.Context, arg CountCouponsParams) (int64, error)

func (*Queries) CountCouponsByTypeID

func (q *Queries) CountCouponsByTypeID(ctx context.Context, typeID sql.NullInt64) (int64, error)

func (*Queries) CountCurrencies

func (q *Queries) CountCurrencies(ctx context.Context) (int64, error)

func (*Queries) CountCurrencyUsage

func (q *Queries) CountCurrencyUsage(ctx context.Context, code string) (int32, error)

Whether anything in kashi's own tables still points at this currency -- a payment method priced in it, or a branch override that prices one in it. A currency that's still referenced can't be hard-deleted (it would either violate the FK or silently orphan those rows); the delete handler blocks on this and points the admin at deactivating instead.

func (*Queries) CountDashboardExpenses

func (q *Queries) CountDashboardExpenses(ctx context.Context, arg CountDashboardExpensesParams) (int64, error)

func (*Queries) CountDashboardPurchases

func (q *Queries) CountDashboardPurchases(ctx context.Context, arg CountDashboardPurchasesParams) (int64, error)

func (*Queries) CountDashboardSales

func (q *Queries) CountDashboardSales(ctx context.Context, arg CountDashboardSalesParams) (int64, error)

func (*Queries) CountDiscountListItemsWithProduct

func (q *Queries) CountDiscountListItemsWithProduct(ctx context.Context, arg CountDiscountListItemsWithProductParams) (int64, error)

func (*Queries) CountDiscountListRuleDecided added in v1.1.7

func (q *Queries) CountDiscountListRuleDecided(ctx context.Context, discountListID int64) ([]CountDiscountListRuleDecidedRow, error)

How many variants each rule of a list decides, first match wins, the way refresh_discount_rules (000208) picks them. A rule giving no discount and no deal writes no rows, so ListDiscountListRules counts it as 0; this is what it keeps out (or gives) all the same.

func (*Queries) CountDiscountLists

func (q *Queries) CountDiscountLists(ctx context.Context) (int64, error)

func (*Queries) CountEmailReports added in v1.1.0

func (q *Queries) CountEmailReports(ctx context.Context, status sql.NullString) (int64, error)

func (*Queries) CountEmployees

func (q *Queries) CountEmployees(ctx context.Context, arg CountEmployeesParams) (int64, error)

func (*Queries) CountExpenses

func (q *Queries) CountExpenses(ctx context.Context, arg CountExpensesParams) (int64, error)

func (*Queries) CountHomeActivitiesSince added in v1.1.0

func (q *Queries) CountHomeActivitiesSince(ctx context.Context, since time.Time) (int64, error)

The "N synced" count beside the Recent activity feed: the same rows as HomeActivityFeed received from `since` on. A plain count per table rides the received_at indexes; it used to come from the feed query's windowed total, which built (and coloured) every row of the week to count them.

func (*Queries) CountIgnoredLowStockProducts

func (q *Queries) CountIgnoredLowStockProducts(ctx context.Context, search string) (int64, error)

func (*Queries) CountInventories

func (q *Queries) CountInventories(ctx context.Context) (int64, error)

func (*Queries) CountInventoryStock

func (q *Queries) CountInventoryStock(ctx context.Context, arg CountInventoryStockParams) (int64, error)

func (*Queries) CountInvoices

func (q *Queries) CountInvoices(ctx context.Context) (int64, error)

func (*Queries) CountInvoicesFiltered

func (q *Queries) CountInvoicesFiltered(ctx context.Context, search string) (int64, error)

func (*Queries) CountLatestAdditionsSince added in v1.1.0

func (q *Queries) CountLatestAdditionsSince(ctx context.Context, arg CountLatestAdditionsSinceParams) (int64, error)

The home page's "today" count next to the Latest added feed: the same kinds, access flags and timestamps as ListLatestAdditions, counted from `since` on.

func (*Queries) CountLoanImagesForLoan added in v1.1.0

func (q *Queries) CountLoanImagesForLoan(ctx context.Context, loanID int64) (int64, error)

func (*Queries) CountLoanPayments

func (q *Queries) CountLoanPayments(ctx context.Context, arg CountLoanPaymentsParams) (int64, error)

func (*Queries) CountLoans

func (q *Queries) CountLoans(ctx context.Context, arg CountLoansParams) (int64, error)

func (*Queries) CountLowStockProducts

func (q *Queries) CountLowStockProducts(ctx context.Context, arg CountLowStockProductsParams) (int64, error)

func (*Queries) CountOpenBranchSyncConflicts

func (q *Queries) CountOpenBranchSyncConflicts(ctx context.Context, branchID int64) (int64, error)

func (*Queries) CountOpenSecurityAlerts added in v1.1.0

func (q *Queries) CountOpenSecurityAlerts(ctx context.Context) (int64, error)

func (*Queries) CountOtherAdmins

func (q *Queries) CountOtherAdmins(ctx context.Context, id int64) (int64, error)

Admin users besides $1, so the last admin can't be deleted or demoted.

func (*Queries) CountPriceListItemsWithProduct

func (q *Queries) CountPriceListItemsWithProduct(ctx context.Context, arg CountPriceListItemsWithProductParams) (int64, error)

func (*Queries) CountPriceListsFiltered

func (q *Queries) CountPriceListsFiltered(ctx context.Context, search string) (int64, error)

func (*Queries) CountProductVariants

func (q *Queries) CountProductVariants(ctx context.Context) (int64, error)

func (*Queries) CountPurchasesFiltered

func (q *Queries) CountPurchasesFiltered(ctx context.Context, search string) (int64, error)

func (*Queries) CountRegistersTargetingRelease

func (q *Queries) CountRegistersTargetingRelease(ctx context.Context, targetReleaseID sql.NullInt64) (int64, error)

func (*Queries) CountShifts

func (q *Queries) CountShifts(ctx context.Context, arg CountShiftsParams) (int64, error)

func (*Queries) CountSizes

func (q *Queries) CountSizes(ctx context.Context, search string) (int64, error)

func (*Queries) CountSlowMovingProducts

func (q *Queries) CountSlowMovingProducts(ctx context.Context, arg CountSlowMovingProductsParams) (int64, error)

func (*Queries) CountStockCounts

func (q *Queries) CountStockCounts(ctx context.Context, arg CountStockCountsParams) (int64, error)

func (*Queries) CountStockHealthByInventory

func (q *Queries) CountStockHealthByInventory(ctx context.Context, search string) (int64, error)

func (*Queries) CountStockMovements

func (q *Queries) CountStockMovements(ctx context.Context, arg CountStockMovementsParams) (int64, error)

func (*Queries) CountSuppliersFiltered

func (q *Queries) CountSuppliersFiltered(ctx context.Context, search string) (int64, error)

func (*Queries) CountTransferAttachments added in v1.1.0

func (q *Queries) CountTransferAttachments(ctx context.Context) (int64, error)

func (*Queries) CountTransfers

func (q *Queries) CountTransfers(ctx context.Context, status NullTransferStatus) (int64, error)

func (*Queries) CountUnknownItemImages added in v1.1.1

func (q *Queries) CountUnknownItemImages(ctx context.Context) (int64, error)

func (*Queries) CountUnknownItems added in v1.1.1

func (q *Queries) CountUnknownItems(ctx context.Context, resolved bool) (int64, error)

func (*Queries) CountVariantsForBarcodes

func (q *Queries) CountVariantsForBarcodes(ctx context.Context, search string) (int64, error)

func (*Queries) CountVisitorIPs added in v1.1.0

func (q *Queries) CountVisitorIPs(ctx context.Context, arg CountVisitorIPsParams) (int64, error)

func (*Queries) CountWhatsAppMessages added in v1.1.0

func (q *Queries) CountWhatsAppMessages(ctx context.Context, arg CountWhatsAppMessagesParams) (int64, error)

func (*Queries) CountWhatsAppReplies added in v1.1.0

func (q *Queries) CountWhatsAppReplies(ctx context.Context, arg CountWhatsAppRepliesParams) (int64, error)

func (*Queries) CreateAdminActivity

func (q *Queries) CreateAdminActivity(ctx context.Context, arg CreateAdminActivityParams) (AdminActivity, error)

func (*Queries) CreateAppRelease

func (q *Queries) CreateAppRelease(ctx context.Context, arg CreateAppReleaseParams) (AppRelease, error)

func (*Queries) CreateAppUpdateEvent

func (q *Queries) CreateAppUpdateEvent(ctx context.Context, arg CreateAppUpdateEventParams) error

func (*Queries) CreateAsset

func (q *Queries) CreateAsset(ctx context.Context, arg CreateAssetParams) (Asset, error)

func (*Queries) CreateAssetCategory

func (q *Queries) CreateAssetCategory(ctx context.Context, arg CreateAssetCategoryParams) (AssetCategory, error)

func (*Queries) CreateAuditLog

func (q *Queries) CreateAuditLog(ctx context.Context, arg CreateAuditLogParams) (AuditLog, error)

func (*Queries) CreateBatch

func (q *Queries) CreateBatch(ctx context.Context, arg CreateBatchParams) (Batch, error)

func (*Queries) CreateBranch

func (q *Queries) CreateBranch(ctx context.Context, arg CreateBranchParams) (Branch, error)

func (*Queries) CreateBranchAttendanceChange

func (q *Queries) CreateBranchAttendanceChange(ctx context.Context, arg CreateBranchAttendanceChangeParams) (BranchAttendanceChange, error)

func (*Queries) CreateBranchAttendanceEvent

func (q *Queries) CreateBranchAttendanceEvent(ctx context.Context, arg CreateBranchAttendanceEventParams) (BranchAttendanceEvent, error)

func (*Queries) CreateBranchCommand

func (q *Queries) CreateBranchCommand(ctx context.Context, arg CreateBranchCommandParams) (BranchCommand, error)

func (*Queries) CreateBranchExpense

func (q *Queries) CreateBranchExpense(ctx context.Context, arg CreateBranchExpenseParams) (BranchExpense, error)

func (*Queries) CreateBranchExpenseImage

func (q *Queries) CreateBranchExpenseImage(ctx context.Context, arg CreateBranchExpenseImageParams) (BranchExpenseImage, error)

func (*Queries) CreateBranchExpenseUploadToken

func (q *Queries) CreateBranchExpenseUploadToken(ctx context.Context, arg CreateBranchExpenseUploadTokenParams) (BranchExpenseUploadToken, error)

func (*Queries) CreateBranchInvoice

func (q *Queries) CreateBranchInvoice(ctx context.Context, arg CreateBranchInvoiceParams) (BranchInvoice, error)

func (*Queries) CreateBranchInvoiceItem

func (q *Queries) CreateBranchInvoiceItem(ctx context.Context, arg CreateBranchInvoiceItemParams) (BranchInvoiceItem, error)

func (*Queries) CreateBranchInvoicePayment

func (q *Queries) CreateBranchInvoicePayment(ctx context.Context, arg CreateBranchInvoicePaymentParams) (BranchInvoicePayment, error)

func (*Queries) CreateBranchInvoiceSettlement

func (q *Queries) CreateBranchInvoiceSettlement(ctx context.Context, arg CreateBranchInvoiceSettlementParams) (BranchInvoiceSettlement, error)

func (*Queries) CreateBranchLoan

func (q *Queries) CreateBranchLoan(ctx context.Context, arg CreateBranchLoanParams) (Loan, error)

func (*Queries) CreateBranchRegister

func (q *Queries) CreateBranchRegister(ctx context.Context, arg CreateBranchRegisterParams) (BranchRegister, error)

func (*Queries) CreateBranchSalesperson

func (q *Queries) CreateBranchSalesperson(ctx context.Context, arg CreateBranchSalespersonParams) (Salesperson, error)

func (*Queries) CreateBranchShift

func (q *Queries) CreateBranchShift(ctx context.Context, arg CreateBranchShiftParams) (BranchShift, error)

func (*Queries) CreateBranchShiftReceiptImage

func (q *Queries) CreateBranchShiftReceiptImage(ctx context.Context, arg CreateBranchShiftReceiptImageParams) (BranchShiftReceiptImage, error)

func (*Queries) CreateBranchShiftUploadToken

func (q *Queries) CreateBranchShiftUploadToken(ctx context.Context, arg CreateBranchShiftUploadTokenParams) (BranchShiftUploadToken, error)

func (*Queries) CreateBranchTarget

func (q *Queries) CreateBranchTarget(ctx context.Context, arg CreateBranchTargetParams) (BranchTarget, error)

func (*Queries) CreateBranchTargetSeries

func (q *Queries) CreateBranchTargetSeries(ctx context.Context, arg CreateBranchTargetSeriesParams) (BranchTargetSeries, error)

func (*Queries) CreateBranchTransferRequest

func (q *Queries) CreateBranchTransferRequest(ctx context.Context, arg CreateBranchTransferRequestParams) (Transfer, error)

A branch's own proposed transfer: always starts 'requested', always carries branch_id + client_ref (the idempotency key -- see idx_transfers_branch_client_ref).

func (*Queries) CreateBranchUser

func (q *Queries) CreateBranchUser(ctx context.Context, arg CreateBranchUserParams) (BranchUser, error)

func (*Queries) CreateBranchVisitorEvent

func (q *Queries) CreateBranchVisitorEvent(ctx context.Context, arg CreateBranchVisitorEventParams) (BranchVisitorEvent, error)

func (*Queries) CreateCalendarEvent

func (q *Queries) CreateCalendarEvent(ctx context.Context, arg CreateCalendarEventParams) (CalendarEvent, error)

func (*Queries) CreateCashbox

func (q *Queries) CreateCashbox(ctx context.Context, arg CreateCashboxParams) (Cashbox, error)

func (*Queries) CreateCashboxAccount

func (q *Queries) CreateCashboxAccount(ctx context.Context, arg CreateCashboxAccountParams) (CashboxAccount, error)

func (*Queries) CreateCentralLoan

func (q *Queries) CreateCentralLoan(ctx context.Context, arg CreateCentralLoanParams) (Loan, error)

func (*Queries) CreateClient

func (q *Queries) CreateClient(ctx context.Context, arg CreateClientParams) (Client, error)

func (*Queries) CreateClientWithUID

func (q *Queries) CreateClientWithUID(ctx context.Context, arg CreateClientWithUIDParams) (Client, error)

A till-created client keeps the uid the till minted, so the till never has to rewrite anything once kashi accepts it.

func (*Queries) CreateColor

func (q *Queries) CreateColor(ctx context.Context, arg CreateColorParams) (Color, error)

func (*Queries) CreateCoupon

func (q *Queries) CreateCoupon(ctx context.Context, arg CreateCouponParams) (Coupon, error)

A one-off coupon, not part of a list -- list_id stays NULL.

func (*Queries) CreateCouponCategory

func (q *Queries) CreateCouponCategory(ctx context.Context, arg CreateCouponCategoryParams) (CouponCategory, error)

func (*Queries) CreateCouponList

func (q *Queries) CreateCouponList(ctx context.Context, arg CreateCouponListParams) (CouponList, error)

func (*Queries) CreateCouponType

func (q *Queries) CreateCouponType(ctx context.Context, arg CreateCouponTypeParams) (CouponType, error)

func (*Queries) CreateCurrency

func (q *Queries) CreateCurrency(ctx context.Context, arg CreateCurrencyParams) (Currency, error)

func (*Queries) CreateDeal added in v1.1.6

func (q *Queries) CreateDeal(ctx context.Context, arg CreateDealParams) (Deal, error)

func (*Queries) CreateDiscountList

func (q *Queries) CreateDiscountList(ctx context.Context, arg CreateDiscountListParams) (DiscountList, error)

func (*Queries) CreateDiscountListItem

func (q *Queries) CreateDiscountListItem(ctx context.Context, arg CreateDiscountListItemParams) (DiscountListItem, error)

A row written here is set by hand: it takes the row over from the rules (000200), which then leave the variant alone. deal_id puts the variant on a deal (000201) instead of a discount.

func (*Queries) CreateDiscountListRule added in v1.1.6

func (q *Queries) CreateDiscountListRule(ctx context.Context, arg CreateDiscountListRuleParams) (DiscountListRule, error)

func (*Queries) CreateDiscountListRuleGroup added in v1.1.6

func (q *Queries) CreateDiscountListRuleGroup(ctx context.Context, arg CreateDiscountListRuleGroupParams) (DiscountListRuleGroup, error)

func (*Queries) CreateDiscountListRuleOption added in v1.1.6

func (q *Queries) CreateDiscountListRuleOption(ctx context.Context, arg CreateDiscountListRuleOptionParams) error

func (*Queries) CreateEmailReport added in v1.1.0

func (q *Queries) CreateEmailReport(ctx context.Context, arg CreateEmailReportParams) (EmailReport, error)

func (*Queries) CreateEmailSchedule added in v1.1.0

func (q *Queries) CreateEmailSchedule(ctx context.Context, arg CreateEmailScheduleParams) (EmailSchedule, error)

func (*Queries) CreateEmployee

func (q *Queries) CreateEmployee(ctx context.Context, arg CreateEmployeeParams) (Employee, error)

func (*Queries) CreateEntryItem

func (q *Queries) CreateEntryItem(ctx context.Context, arg CreateEntryItemParams) (Entry, error)

func (*Queries) CreateExpense

func (q *Queries) CreateExpense(ctx context.Context, arg CreateExpenseParams) (Expense, error)

func (*Queries) CreateExpenseCategory

func (q *Queries) CreateExpenseCategory(ctx context.Context, arg CreateExpenseCategoryParams) (ExpenseCategory, error)

func (*Queries) CreateGeneratedBranchTarget

func (q *Queries) CreateGeneratedBranchTarget(ctx context.Context, arg CreateGeneratedBranchTargetParams) (BranchTarget, error)

Fires one period for a recurring series -- target_amount/color are passed in (a snapshot of the series at generation time) rather than joined live, so a later edit to the series template never rewrites a period that's already in progress or past, same as recurring_expenses' FireRecurringExpenseTx snapshotting its template's amount into the created expense row.

func (*Queries) CreateGooglePlaceSnapshot added in v1.1.0

func (q *Queries) CreateGooglePlaceSnapshot(ctx context.Context, arg CreateGooglePlaceSnapshotParams) error

func (*Queries) CreateInventory

func (q *Queries) CreateInventory(ctx context.Context, arg CreateInventoryParams) (Inventory, error)

func (*Queries) CreateInvoice

func (q *Queries) CreateInvoice(ctx context.Context, arg CreateInvoiceParams) (Invoice, error)

func (*Queries) CreateInvoiceDiscount added in v1.1.8

func (q *Queries) CreateInvoiceDiscount(ctx context.Context, arg CreateInvoiceDiscountParams) (InvoiceDiscount, error)

func (*Queries) CreateInvoicePayment

func (q *Queries) CreateInvoicePayment(ctx context.Context, arg CreateInvoicePaymentParams) (InvoicePayment, error)

func (*Queries) CreateInvoiceType

func (q *Queries) CreateInvoiceType(ctx context.Context, arg CreateInvoiceTypeParams) (InvoiceType, error)

func (*Queries) CreateListCoupon

func (q *Queries) CreateListCoupon(ctx context.Context, arg CreateListCouponParams) (Coupon, error)

One code minted as part of a coupon_lists batch (see coupon_list.sql). Not pre-assigned to a client -- whoever redeems it first claims it.

func (*Queries) CreateLoanCategory

func (q *Queries) CreateLoanCategory(ctx context.Context, arg CreateLoanCategoryParams) (LoanCategory, error)

func (*Queries) CreateLoanImage added in v1.1.0

func (q *Queries) CreateLoanImage(ctx context.Context, arg CreateLoanImageParams) (LoanImage, error)

func (*Queries) CreateLoanPayment

func (q *Queries) CreateLoanPayment(ctx context.Context, arg CreateLoanPaymentParams) (LoanPayment, error)

func (*Queries) CreateLoanUploadToken added in v1.1.0

func (q *Queries) CreateLoanUploadToken(ctx context.Context, arg CreateLoanUploadTokenParams) (LoanUploadToken, error)

func (*Queries) CreatePriceList

func (q *Queries) CreatePriceList(ctx context.Context, arg CreatePriceListParams) (PriceList, error)

func (*Queries) CreatePriceListItem

func (q *Queries) CreatePriceListItem(ctx context.Context, arg CreatePriceListItemParams) (PriceListItem, error)

func (*Queries) CreateProduct

func (q *Queries) CreateProduct(ctx context.Context, arg CreateProductParams) (Product, error)

func (*Queries) CreateProductAttribute

func (q *Queries) CreateProductAttribute(ctx context.Context, arg CreateProductAttributeParams) (ProductsAttribute, error)

func (*Queries) CreateProductCategory

func (q *Queries) CreateProductCategory(ctx context.Context, arg CreateProductCategoryParams) (ProductCategory, error)

func (*Queries) CreateProductVariant

func (q *Queries) CreateProductVariant(ctx context.Context, arg CreateProductVariantParams) (ProductVariant, error)

No price column: since 000094 a variant's price is an entry in a price list, not a property of the variant, so a newly created variant starts with no price and is unsellable until it is added to one.

func (*Queries) CreatePurchase

func (q *Queries) CreatePurchase(ctx context.Context, arg CreatePurchaseParams) (Purchase, error)

func (*Queries) CreateRecurringExpense

func (q *Queries) CreateRecurringExpense(ctx context.Context, arg CreateRecurringExpenseParams) (RecurringExpense, error)

func (*Queries) CreateResolvedBranchInvoiceItem added in v1.1.1

func (q *Queries) CreateResolvedBranchInvoiceItem(ctx context.Context, arg CreateResolvedBranchInvoiceItemParams) error

func (*Queries) CreateReturnInvoice

func (q *Queries) CreateReturnInvoice(ctx context.Context, arg CreateReturnInvoiceParams) (ReturnInvoice, error)

func (*Queries) CreateReviewLinkClick added in v1.1.0

func (q *Queries) CreateReviewLinkClick(ctx context.Context, arg CreateReviewLinkClickParams) error

func (*Queries) CreateRole

func (q *Queries) CreateRole(ctx context.Context, name string) (Role, error)

func (*Queries) CreateSaleOption added in v1.1.6

func (q *Queries) CreateSaleOption(ctx context.Context, arg CreateSaleOptionParams) (SaleOption, error)

func (*Queries) CreateSalesInvoice

func (q *Queries) CreateSalesInvoice(ctx context.Context, invoiceID int64) (int64, error)

func (*Queries) CreateSalesperson

func (q *Queries) CreateSalesperson(ctx context.Context, arg CreateSalespersonParams) (Salesperson, error)

func (*Queries) CreateSession

func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)

func (*Queries) CreateShift

func (q *Queries) CreateShift(ctx context.Context, cashboxID int64) (Shift, error)

func (*Queries) CreateSize

func (q *Queries) CreateSize(ctx context.Context, arg CreateSizeParams) (Size, error)

func (*Queries) CreateStockCount

func (q *Queries) CreateStockCount(ctx context.Context, arg CreateStockCountParams) (StockCount, error)

func (*Queries) CreateStockMovement

func (q *Queries) CreateStockMovement(ctx context.Context, arg CreateStockMovementParams) (StockMovement, error)

--------------------------------------------------------------------------- Stock movement ledger (append-only). ---------------------------------------------------------------------------

func (*Queries) CreateSupplier

func (q *Queries) CreateSupplier(ctx context.Context, arg CreateSupplierParams) (Supplier, error)

func (*Queries) CreateTransfer

func (q *Queries) CreateTransfer(ctx context.Context, arg CreateTransferParams) (Transfer, error)

func (*Queries) CreateTransferItem

func (q *Queries) CreateTransferItem(ctx context.Context, arg CreateTransferItemParams) (TransferItem, error)

func (*Queries) CreateUnknownItemImage added in v1.1.1

func (q *Queries) CreateUnknownItemImage(ctx context.Context, arg CreateUnknownItemImageParams) (UnknownItemImage, error)

func (*Queries) CreateUnknownItemSession added in v1.1.1

func (q *Queries) CreateUnknownItemSession(ctx context.Context, arg CreateUnknownItemSessionParams) (UnknownItemSession, error)

func (*Queries) CreateUnknownItemSlot added in v1.1.1

func (q *Queries) CreateUnknownItemSlot(ctx context.Context, arg CreateUnknownItemSlotParams) error

A till re-sending its session as the cart changes moves and relabels the units it already sent; their pictures stay.

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)

func (*Queries) CreateWhatsAppMessage added in v1.1.0

func (q *Queries) CreateWhatsAppMessage(ctx context.Context, arg CreateWhatsAppMessageParams) (WhatsappMessage, error)

func (*Queries) CreateWhatsAppNumber added in v1.1.0

func (q *Queries) CreateWhatsAppNumber(ctx context.Context, arg CreateWhatsAppNumberParams) (WhatsappNumber, error)

The first number becomes the default.

func (*Queries) CreateWhatsAppReply added in v1.1.0

func (q *Queries) CreateWhatsAppReply(ctx context.Context, arg CreateWhatsAppReplyParams) error

Linked to the message it answers: the one the client replied to, else the last one sent to that number in the week before. Meta can deliver the same webhook twice; the wamid keeps it to one row.

func (*Queries) CreateWhatsAppRule added in v1.1.0

func (q *Queries) CreateWhatsAppRule(ctx context.Context, arg CreateWhatsAppRuleParams) (WhatsappRule, error)

func (*Queries) DashboardActivitiesList

func (q *Queries) DashboardActivitiesList(ctx context.Context, arg DashboardActivitiesListParams) ([]DashboardActivitiesListRow, error)

Queries behind the home dashboard's Overview tab: the summary cards, the revenue/expense trend charts, and the aggregated Sales / Purchases / Recent Expenses tables. Every query takes a half-open [date_from, date_to) timestamptz range (the handler passes start-of-next-day as date_to) and, where a branch dimension exists, a nullable branch_id (NULL = all branches, same convention as ListBranchInvoices).

"branch" data is what the POS branches sync up (branch_invoices, branch_expenses); "admin" data is kashi's own centrally-entered records (invoices/sales_invoices, expenses). The dashboard's scope filter picks one or both; the list queries take that as an explicit `scope` arg so a single UNION ALL can serve all three modes, while the scalar summary queries are split per source and the handler adds up whichever apply. One chronological feed across every kind of persisted branch sync. The union happens before LIMIT/OFFSET so pagination is correct globally, not independently per source table. received_at is used deliberately: this table answers "what synced recently", even when a branch catches up an older occurred_at record. person is who did it on the till (salesperson / closing cashier), ” when the till doesn't record one; person_color is that salesperson's own colour, ” when they have none.

func (*Queries) DashboardAdminExpensesTotal

func (q *Queries) DashboardAdminExpensesTotal(ctx context.Context, arg DashboardAdminExpensesTotalParams) (int64, error)

func (*Queries) DashboardAdminNewClients

func (q *Queries) DashboardAdminNewClients(ctx context.Context, arg DashboardAdminNewClientsParams) (int64, error)

func (*Queries) DashboardAdminSummary

func (q *Queries) DashboardAdminSummary(ctx context.Context, arg DashboardAdminSummaryParams) (DashboardAdminSummaryRow, error)

func (*Queries) DashboardBranchExpensesTotal

func (q *Queries) DashboardBranchExpensesTotal(ctx context.Context, arg DashboardBranchExpensesTotalParams) (int64, error)

func (*Queries) DashboardBranchNewClients

func (q *Queries) DashboardBranchNewClients(ctx context.Context, arg DashboardBranchNewClientsParams) (int64, error)

Clients first seen at a branch in the range. With a branch selected, count distinct linked clients whose central row was created in-range; with no branch, every client created in-range.

func (*Queries) DashboardBranchSummary

func (q *Queries) DashboardBranchSummary(ctx context.Context, arg DashboardBranchSummaryParams) (DashboardBranchSummaryRow, error)

items_sold / revenue / invoice count for branch sales in the range. Returns are excluded from items_sold and the count (they aren't sales), but revenue sums every kind so refunds net out, matching ListDailyIncome.

func (*Queries) DashboardDueLoans

func (q *Queries) DashboardDueLoans(ctx context.Context, arg DashboardDueLoansParams) (int64, error)

Outstanding loan balance = disbursed - repaid. loans has no due date, so "due" here just means still owed. Branch arm = origin 'branch_loan' (scoped by branch_id when set); admin arm = origin 'central_loan'. loan_payments carry no branch dimension of their own, so they follow their parent loan's arm. Not date-range bound -- a balance, not a flow.

func (*Queries) DashboardExpensesList

func (q *Queries) DashboardExpensesList(ctx context.Context, arg DashboardExpensesListParams) ([]DashboardExpensesListRow, error)

image_id is 0, not NULL, when an expense has no receipt photo (admin expenses never do): keeps the generated column a plain int64 and lets the frontend treat 0 as "no image".

func (*Queries) DashboardPurchaseSeries

func (q *Queries) DashboardPurchaseSeries(ctx context.Context, arg DashboardPurchaseSeriesParams) ([]DashboardPurchaseSeriesRow, error)

func (*Queries) DashboardPurchasesList

func (q *Queries) DashboardPurchasesList(ctx context.Context, arg DashboardPurchasesListParams) ([]DashboardPurchasesListRow, error)

Purchases are admin-only -- there is no branch purchase concept -- so the scope arg only ever excludes them (scope = 'branch'), never adds a second source. total is summed from purchase_items since purchases carries no amount column of its own.

func (*Queries) DashboardPurchasesTotal

func (q *Queries) DashboardPurchasesTotal(ctx context.Context, arg DashboardPurchasesTotalParams) (int64, error)

Cost of goods bought in the range. Admin-only (no branch purchase concept); total is summed from purchase_items since purchases carries no amount column of its own, matching DashboardPurchasesList.

func (*Queries) DashboardSalesList

func (q *Queries) DashboardSalesList(ctx context.Context, arg DashboardSalesListParams) ([]DashboardSalesListRow, error)

currency is the app's single default currency code (every amount in the schema is stored in its minor unit -- see 000009_create_currencies). The branch-invoice client name is resolved through client_links; when the branch never synced a client link it comes back empty.

func (*Queries) DashboardTargetList

func (q *Queries) DashboardTargetList(ctx context.Context, arg DashboardTargetListParams) ([]DashboardTargetListRow, error)

Every branch_target that is active and spans `as_of` (today), with its live revenue (the target's own [date_from, date_to] window against its own branch). One progress bar per row on the dashboard; the handler also sums these for the overall attainment percentage. branch_targets are branch-only, so the handler skips this under admin scope.

func (*Queries) DashboardTopDueLoans

func (q *Queries) DashboardTopDueLoans(ctx context.Context, arg DashboardTopDueLoansParams) ([]DashboardTopDueLoansRow, error)

The loans with the largest outstanding balance, for the dashboard's "Due Loans" list. Same scope/branch gating as DashboardDueLoans; fully repaid loans (outstanding <= 0) are dropped.

func (*Queries) DeactivateBranchTargetsBySeries

func (q *Queries) DeactivateBranchTargetsBySeries(ctx context.Context, seriesID sql.NullInt64) error

Part of deleting a whole recurring series (see DeleteBranchTargetSeriesTx in tx_branch_target_series.go) -- every period it ever generated needs to disappear the same way a single deleted target does, not just stop getting new ones.

func (*Queries) DeactivateCoupon

func (q *Queries) DeactivateCoupon(ctx context.Context, code string) error

func (*Queries) DeactivateCouponList

func (q *Queries) DeactivateCouponList(ctx context.Context, id int64) error

Deactivating the list itself just stops it appearing as "open" in the admin UI; the codes it already minted are deactivated separately below so an in-flight redemption on a disconnected till isn't silently resurrected once it reconnects.

func (*Queries) DeactivateCouponsForList

func (q *Queries) DeactivateCouponsForList(ctx context.Context, listID sql.NullInt64) (int64, error)

func (*Queries) DecrementInvoicesIndex

func (q *Queries) DecrementInvoicesIndex(ctx context.Context, arg DecrementInvoicesIndexParams) (int64, error)

func (*Queries) DeleteAllWhatsAppRules added in v1.1.0

func (q *Queries) DeleteAllWhatsAppRules(ctx context.Context) error

func (*Queries) DeleteAppRelease

func (q *Queries) DeleteAppRelease(ctx context.Context, id int64) error

func (*Queries) DeleteAsset

func (q *Queries) DeleteAsset(ctx context.Context, id int64) error

func (*Queries) DeleteAssetCategory

func (q *Queries) DeleteAssetCategory(ctx context.Context, id int64) error

func (*Queries) DeleteAssets

func (q *Queries) DeleteAssets(ctx context.Context, ids []int64) (int64, error)

func (*Queries) DeleteAttributeValue

func (q *Queries) DeleteAttributeValue(ctx context.Context, id int64) error

func (*Queries) DeleteAttributeValues

func (q *Queries) DeleteAttributeValues(ctx context.Context, ids []int64) (int64, error)

func (*Queries) DeleteBatch

func (q *Queries) DeleteBatch(ctx context.Context, id int64) error

func (*Queries) DeleteBranchAttendanceEvent

func (q *Queries) DeleteBranchAttendanceEvent(ctx context.Context, id int64) error

func (*Queries) DeleteBranchInvoicePaymentsForInvoice

func (q *Queries) DeleteBranchInvoicePaymentsForInvoice(ctx context.Context, branchInvoiceID int64) error

func (*Queries) DeleteBranchQuickAccessItems

func (q *Queries) DeleteBranchQuickAccessItems(ctx context.Context, branchID int64) error

func (*Queries) DeleteBranchTargetSeries

func (q *Queries) DeleteBranchTargetSeries(ctx context.Context, id int64) (BranchTargetSeries, error)

func (*Queries) DeleteBranchUser

func (q *Queries) DeleteBranchUser(ctx context.Context, id int64) error

func (*Queries) DeleteCalendarEvent

func (q *Queries) DeleteCalendarEvent(ctx context.Context, id int64) error

func (*Queries) DeleteCashboxAccount

func (q *Queries) DeleteCashboxAccount(ctx context.Context, id int64) error

func (*Queries) DeleteCashboxAccountOverride

func (q *Queries) DeleteCashboxAccountOverride(ctx context.Context, arg DeleteCashboxAccountOverrideParams) error

Back to inheriting central. Deleting the row rather than writing one full of NULLs keeps "no override" a single state instead of two.

func (*Queries) DeleteClient

func (q *Queries) DeleteClient(ctx context.Context, id int64) error

func (*Queries) DeleteColor

func (q *Queries) DeleteColor(ctx context.Context, id int64) error

func (*Queries) DeleteColors

func (q *Queries) DeleteColors(ctx context.Context, ids []int64) (int64, error)

func (*Queries) DeleteCouponCategory

func (q *Queries) DeleteCouponCategory(ctx context.Context, id int64) error

func (*Queries) DeleteCouponType

func (q *Queries) DeleteCouponType(ctx context.Context, id int64) error

func (*Queries) DeleteCoupons

func (q *Queries) DeleteCoupons(ctx context.Context, codes []string) (int64, error)

func (*Queries) DeleteCurrencies

func (q *Queries) DeleteCurrencies(ctx context.Context, codes []string) (int64, error)

func (*Queries) DeleteCurrency

func (q *Queries) DeleteCurrency(ctx context.Context, code string) error

func (*Queries) DeleteDeal added in v1.1.6

func (q *Queries) DeleteDeal(ctx context.Context, id int64) error

func (*Queries) DeleteDiscountList

func (q *Queries) DeleteDiscountList(ctx context.Context, id int64) error

func (*Queries) DeleteDiscountListBranch

func (q *Queries) DeleteDiscountListBranch(ctx context.Context, branchID int64) error

func (*Queries) DeleteDiscountListBranchesForList

func (q *Queries) DeleteDiscountListBranchesForList(ctx context.Context, discountListID int64) error

func (*Queries) DeleteDiscountListItem

func (q *Queries) DeleteDiscountListItem(ctx context.Context, arg DeleteDiscountListItemParams) error

func (*Queries) DeleteDiscountListItems

func (q *Queries) DeleteDiscountListItems(ctx context.Context, arg DeleteDiscountListItemsParams) (int64, error)

func (*Queries) DeleteDiscountListOptionItem added in v1.1.6

func (q *Queries) DeleteDiscountListOptionItem(ctx context.Context, arg DeleteDiscountListOptionItemParams) error

func (*Queries) DeleteDiscountListOptionItems added in v1.1.6

func (q *Queries) DeleteDiscountListOptionItems(ctx context.Context, arg DeleteDiscountListOptionItemsParams) (int64, error)

Rows are named by (variant, option) pairs, given as two parallel arrays; two unnests in one select list zip them pairwise.

func (*Queries) DeleteDiscountListRuleGroups added in v1.1.6

func (q *Queries) DeleteDiscountListRuleGroups(ctx context.Context, discountListID int64) error

Their rules go with them (ON DELETE CASCADE).

func (*Queries) DeleteDiscountListRuleGroupsExcept added in v1.1.7

func (q *Queries) DeleteDiscountListRuleGroupsExcept(ctx context.Context, arg DeleteDiscountListRuleGroupsExceptParams) error

func (*Queries) DeleteDiscountListRuleOptions added in v1.1.7

func (q *Queries) DeleteDiscountListRuleOptions(ctx context.Context, ruleID int64) error

func (*Queries) DeleteDiscountListRules added in v1.1.6

func (q *Queries) DeleteDiscountListRules(ctx context.Context, discountListID int64) error

func (*Queries) DeleteDiscountListRulesExcept added in v1.1.7

func (q *Queries) DeleteDiscountListRulesExcept(ctx context.Context, arg DeleteDiscountListRulesExceptParams) error

func (*Queries) DeleteEmailSchedule added in v1.1.0

func (q *Queries) DeleteEmailSchedule(ctx context.Context, id int64) error

func (*Queries) DeleteEmployee

func (q *Queries) DeleteEmployee(ctx context.Context, id int64) error

func (*Queries) DeleteExpense

func (q *Queries) DeleteExpense(ctx context.Context, id int64) error

func (*Queries) DeleteExpenseCategory

func (q *Queries) DeleteExpenseCategory(ctx context.Context, id int64) error

func (*Queries) DeleteExpenses

func (q *Queries) DeleteExpenses(ctx context.Context, ids []int64) (int64, error)

func (*Queries) DeleteFailedWhatsAppMessagesForInvoice added in v1.1.1

func (q *Queries) DeleteFailedWhatsAppMessagesForInvoice(ctx context.Context, arg DeleteFailedWhatsAppMessagesForInvoiceParams) error

A till retrying a thank-you after a temporary failure: its earlier failed rows go, so the log keeps one row per sale showing how it ended.

func (*Queries) DeleteHistoricalBranchInvoice added in v1.1.3

func (q *Queries) DeleteHistoricalBranchInvoice(ctx context.Context, id int64) (int64, error)

Deletes a historical backfill invoice (and, via ON DELETE CASCADE, its items and payments) so it can be re-imported with corrected data. The historical=true guard means this can never remove a real till's sale, even given a wrong id -- see deleteBranchInvoice in api/branch_invoice.go.

func (*Queries) DeleteIPBan added in v1.1.0

func (q *Queries) DeleteIPBan(ctx context.Context, ip string) error

func (*Queries) DeleteInventories

func (q *Queries) DeleteInventories(ctx context.Context, ids []int64) (int64, error)

func (*Queries) DeleteInventory

func (q *Queries) DeleteInventory(ctx context.Context, id int64) error

func (*Queries) DeleteInvoiceDiscount added in v1.1.8

func (q *Queries) DeleteInvoiceDiscount(ctx context.Context, id int64) error

Kept, marked deleted: the tills drop it when it comes down as not applying to them (000212).

func (*Queries) DeleteInvoiceDiscountBranches added in v1.1.8

func (q *Queries) DeleteInvoiceDiscountBranches(ctx context.Context, invoiceDiscountID int64) error

func (*Queries) DeleteLoan

func (q *Queries) DeleteLoan(ctx context.Context, id int64) error

func (*Queries) DeleteLoanCategory

func (q *Queries) DeleteLoanCategory(ctx context.Context, id int64) error

func (*Queries) DeleteLoanPayment

func (q *Queries) DeleteLoanPayment(ctx context.Context, id int64) error

func (*Queries) DeleteLoans

func (q *Queries) DeleteLoans(ctx context.Context, ids []int64) (int64, error)

Central loans only, same read-only guard as DeleteLoan.

func (*Queries) DeletePriceList

func (q *Queries) DeletePriceList(ctx context.Context, id int64) error

func (*Queries) DeletePriceListBranch

func (q *Queries) DeletePriceListBranch(ctx context.Context, branchID int64) error

func (*Queries) DeletePriceListBranchesForList

func (q *Queries) DeletePriceListBranchesForList(ctx context.Context, priceListID int64) error

func (*Queries) DeletePriceListItem

func (q *Queries) DeletePriceListItem(ctx context.Context, arg DeletePriceListItemParams) error

func (*Queries) DeletePriceListItems

func (q *Queries) DeletePriceListItems(ctx context.Context, arg DeletePriceListItemsParams) (int64, error)

func (*Queries) DeleteProduct

func (q *Queries) DeleteProduct(ctx context.Context, id int64) error

func (*Queries) DeleteProductCategory

func (q *Queries) DeleteProductCategory(ctx context.Context, id int64) error

func (*Queries) DeleteProductVariant

func (q *Queries) DeleteProductVariant(ctx context.Context, id int64) error

func (*Queries) DeletePurchaseItem

func (q *Queries) DeletePurchaseItem(ctx context.Context, arg DeletePurchaseItemParams) error

func (*Queries) DeleteRole

func (q *Queries) DeleteRole(ctx context.Context, id int64) error

func (*Queries) DeleteRolePermissions

func (q *Queries) DeleteRolePermissions(ctx context.Context, roleID int64) error

func (*Queries) DeleteSalesperson

func (q *Queries) DeleteSalesperson(ctx context.Context, id int64) error

func (*Queries) DeleteSize

func (q *Queries) DeleteSize(ctx context.Context, id int64) error

func (*Queries) DeleteSizes

func (q *Queries) DeleteSizes(ctx context.Context, ids []int64) (int64, error)

func (*Queries) DeleteStockCountItems

func (q *Queries) DeleteStockCountItems(ctx context.Context, stockCountID int64) error

func (*Queries) DeleteTransferItem

func (q *Queries) DeleteTransferItem(ctx context.Context, arg DeleteTransferItemParams) error

func (*Queries) DeleteUnknownItemImages added in v1.1.1

func (q *Queries) DeleteUnknownItemImages(ctx context.Context, dollar_1 []int64) error

func (*Queries) DeleteUnknownItemSlotsNotIn added in v1.1.8

func (q *Queries) DeleteUnknownItemSlotsNotIn(ctx context.Context, arg DeleteUnknownItemSlotsNotInParams) error

Units taken off the cart since the session was last sent.

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, id int64) error

func (*Queries) DeleteWhatsAppNumber added in v1.1.0

func (q *Queries) DeleteWhatsAppNumber(ctx context.Context, id int64) error

func (*Queries) FindUnknownInvoiceItem added in v1.1.1

func (q *Queries) FindUnknownInvoiceItem(ctx context.Context, arg FindUnknownInvoiceItemParams) (BranchInvoiceItem, error)

func (*Queries) GetAppRelease

func (q *Queries) GetAppRelease(ctx context.Context, id int64) (AppRelease, error)

func (*Queries) GetAppSettings

func (q *Queries) GetAppSettings(ctx context.Context) (AppSetting, error)

func (*Queries) GetAsset

func (q *Queries) GetAsset(ctx context.Context, id int64) (Asset, error)

func (*Queries) GetAssetByName

func (q *Queries) GetAssetByName(ctx context.Context, name string) (Asset, error)

func (*Queries) GetAssetCategory

func (q *Queries) GetAssetCategory(ctx context.Context, id int64) (AssetCategory, error)

func (*Queries) GetAssetCategoryByName

func (q *Queries) GetAssetCategoryByName(ctx context.Context, name string) (AssetCategory, error)

func (*Queries) GetAssetTreemapData

func (q *Queries) GetAssetTreemapData(ctx context.Context, inventoryID sql.NullInt64) ([]GetAssetTreemapDataRow, error)

func (*Queries) GetAttribute

func (q *Queries) GetAttribute(ctx context.Context, name string) (Attribute, error)

func (*Queries) GetAttributeValue

func (q *Queries) GetAttributeValue(ctx context.Context, id int64) (AttributesValue, error)

upserting instead of inserting makes product creation with attributes easier

func (*Queries) GetBatch

func (q *Queries) GetBatch(ctx context.Context, id int64) (GetBatchRow, error)

func (*Queries) GetBatchItemByBatchVariant

func (q *Queries) GetBatchItemByBatchVariant(ctx context.Context, arg GetBatchItemByBatchVariantParams) (BatchItem, error)

func (*Queries) GetBranch

func (q *Queries) GetBranch(ctx context.Context, id int64) (Branch, error)

func (*Queries) GetBranchAttendanceChange added in v1.1.0

func (q *Queries) GetBranchAttendanceChange(ctx context.Context, id int64) (BranchAttendanceChange, error)

func (*Queries) GetBranchAttendanceEvent

func (q *Queries) GetBranchAttendanceEvent(ctx context.Context, id int64) (BranchAttendanceEvent, error)

func (*Queries) GetBranchAttendanceEventByClientRef

func (q *Queries) GetBranchAttendanceEventByClientRef(ctx context.Context, arg GetBranchAttendanceEventByClientRefParams) (BranchAttendanceEvent, error)

func (*Queries) GetBranchByCode

func (q *Queries) GetBranchByCode(ctx context.Context, code string) (Branch, error)

func (*Queries) GetBranchByCodeExcluding

func (q *Queries) GetBranchByCodeExcluding(ctx context.Context, arg GetBranchByCodeExcludingParams) (Branch, error)

Resolves a till's chosen transfer destination by branch code, refusing a branch naming itself as its own destination.

func (*Queries) GetBranchCommand

func (q *Queries) GetBranchCommand(ctx context.Context, id int64) (BranchCommand, error)

func (*Queries) GetBranchExpense

func (q *Queries) GetBranchExpense(ctx context.Context, id int64) (BranchExpense, error)

func (*Queries) GetBranchExpenseByClientRef

func (q *Queries) GetBranchExpenseByClientRef(ctx context.Context, arg GetBranchExpenseByClientRefParams) (BranchExpense, error)

func (*Queries) GetBranchExpenseImage

func (q *Queries) GetBranchExpenseImage(ctx context.Context, id int64) (BranchExpenseImage, error)

func (*Queries) GetBranchExpenseUploadTokenByToken

func (q *Queries) GetBranchExpenseUploadTokenByToken(ctx context.Context, token string) (BranchExpenseUploadToken, error)

func (*Queries) GetBranchInvoice

func (q *Queries) GetBranchInvoice(ctx context.Context, id int64) (BranchInvoice, error)

func (*Queries) GetBranchInvoiceByClientRef

func (q *Queries) GetBranchInvoiceByClientRef(ctx context.Context, arg GetBranchInvoiceByClientRefParams) (BranchInvoice, error)

func (*Queries) GetBranchInvoiceByCode added in v1.1.0

func (q *Queries) GetBranchInvoiceByCode(ctx context.Context, arg GetBranchInvoiceByCodeParams) (BranchInvoice, error)

The sale a WhatsApp message was about (whatsapp_conversation.go).

func (*Queries) GetBranchInvoiceSettlement added in v1.1.0

func (q *Queries) GetBranchInvoiceSettlement(ctx context.Context, id int64) (BranchInvoiceSettlement, error)

func (*Queries) GetBranchLoanByClientRef

func (q *Queries) GetBranchLoanByClientRef(ctx context.Context, arg GetBranchLoanByClientRefParams) (Loan, error)

func (*Queries) GetBranchRegister

func (q *Queries) GetBranchRegister(ctx context.Context, id int64) (BranchRegister, error)

func (*Queries) GetBranchRegisterByCode

func (q *Queries) GetBranchRegisterByCode(ctx context.Context, code string) (BranchRegister, error)

func (*Queries) GetBranchSettings

func (q *Queries) GetBranchSettings(ctx context.Context, branchID int64) (BranchSetting, error)

func (*Queries) GetBranchShift

func (q *Queries) GetBranchShift(ctx context.Context, id int64) (BranchShift, error)

func (*Queries) GetBranchShiftByClientRef

func (q *Queries) GetBranchShiftByClientRef(ctx context.Context, arg GetBranchShiftByClientRefParams) (BranchShift, error)

func (*Queries) GetBranchShiftReceiptImage

func (q *Queries) GetBranchShiftReceiptImage(ctx context.Context, id int64) (BranchShiftReceiptImage, error)

func (*Queries) GetBranchShiftReceiptImageForShift

func (q *Queries) GetBranchShiftReceiptImageForShift(ctx context.Context, branchShiftID int64) (BranchShiftReceiptImage, error)

func (*Queries) GetBranchShiftUploadTokenByToken

func (q *Queries) GetBranchShiftUploadTokenByToken(ctx context.Context, token string) (BranchShiftUploadToken, error)

func (*Queries) GetBranchSyncConflict

func (q *Queries) GetBranchSyncConflict(ctx context.Context, id int64) (BranchSyncConflict, error)

func (*Queries) GetBranchTarget

func (q *Queries) GetBranchTarget(ctx context.Context, id int64) (BranchTarget, error)

func (*Queries) GetBranchTargetBySeriesAndStart

func (q *Queries) GetBranchTargetBySeriesAndStart(ctx context.Context, arg GetBranchTargetBySeriesAndStartParams) (BranchTarget, error)

func (*Queries) GetBranchTargetSeries

func (q *Queries) GetBranchTargetSeries(ctx context.Context, id int64) (BranchTargetSeries, error)

func (*Queries) GetBranchTransferByClientRef

func (q *Queries) GetBranchTransferByClientRef(ctx context.Context, arg GetBranchTransferByClientRefParams) (Transfer, error)

func (*Queries) GetBranchTransferUploadTokenByToken

func (q *Queries) GetBranchTransferUploadTokenByToken(ctx context.Context, token string) (BranchTransferUploadToken, error)

func (*Queries) GetBranchUser

func (q *Queries) GetBranchUser(ctx context.Context, id int64) (BranchUser, error)

func (*Queries) GetBranchVisitorEventByClientRef

func (q *Queries) GetBranchVisitorEventByClientRef(ctx context.Context, arg GetBranchVisitorEventByClientRefParams) (BranchVisitorEvent, error)

func (*Queries) GetCashbox

func (q *Queries) GetCashbox(ctx context.Context, id int64) (Cashbox, error)

func (*Queries) GetCashboxAccount

func (q *Queries) GetCashboxAccount(ctx context.Context, id int64) (CashboxAccount, error)

func (*Queries) GetCashboxAccountBalance

func (q *Queries) GetCashboxAccountBalance(ctx context.Context, arg GetCashboxAccountBalanceParams) (ShiftsAccountsBalance, error)

func (*Queries) GetClient

func (q *Queries) GetClient(ctx context.Context, id int64) (Client, error)

func (*Queries) GetClientByPhone

func (q *Queries) GetClientByPhone(ctx context.Context, phone string) (Client, error)

func (*Queries) GetClientByUID

func (q *Queries) GetClientByUID(ctx context.Context, uid uuid.UUID) (Client, error)

Shared-identity (uid) queries for branch sync. See 000093_sync_uid.up.sql.

func (*Queries) GetClientHomeBranch

func (q *Queries) GetClientHomeBranch(ctx context.Context, clientID int64) (string, error)
func (q *Queries) GetClientLink(ctx context.Context, arg GetClientLinkParams) (int64, error)

func (*Queries) GetClientProfileStats

func (q *Queries) GetClientProfileStats(ctx context.Context, clientID int64) (ClientProfileStats, error)

func (*Queries) GetColorByName

func (q *Queries) GetColorByName(ctx context.Context, name string) (Color, error)

func (*Queries) GetCoupon

func (q *Queries) GetCoupon(ctx context.Context, code string) (Coupon, error)

func (*Queries) GetCouponCategory

func (q *Queries) GetCouponCategory(ctx context.Context, id int64) (CouponCategory, error)

func (*Queries) GetCouponList

func (q *Queries) GetCouponList(ctx context.Context, id int64) (CouponList, error)

func (*Queries) GetCouponType

func (q *Queries) GetCouponType(ctx context.Context, id int64) (CouponType, error)

func (*Queries) GetCurrency

func (q *Queries) GetCurrency(ctx context.Context, code string) (Currency, error)

func (*Queries) GetDeal added in v1.1.6

func (q *Queries) GetDeal(ctx context.Context, id int64) (Deal, error)

func (*Queries) GetDefaultBranchSettings

func (q *Queries) GetDefaultBranchSettings(ctx context.Context) (DefaultBranchSetting, error)

func (*Queries) GetDefaultCurrency

func (q *Queries) GetDefaultCurrency(ctx context.Context) (Currency, error)

func (*Queries) GetDefaultDiscountForVariant

func (q *Queries) GetDefaultDiscountForVariant(ctx context.Context, productVariantID int64) (int16, error)

func (*Queries) GetDefaultDiscountList

func (q *Queries) GetDefaultDiscountList(ctx context.Context) (DiscountList, error)

func (*Queries) GetDefaultInvoiceType

func (q *Queries) GetDefaultInvoiceType(ctx context.Context) (InvoiceType, error)

func (*Queries) GetDefaultPriceForVariant

func (q *Queries) GetDefaultPriceForVariant(ctx context.Context, productVariantID int64) (int64, error)

Branch-independent price, for the contexts that have no branch to speak of: printed labels, stock listings, head-office reporting.

func (*Queries) GetDefaultPriceList

func (q *Queries) GetDefaultPriceList(ctx context.Context) (PriceList, error)

func (*Queries) GetDiscountList

func (q *Queries) GetDiscountList(ctx context.Context, id int64) (DiscountList, error)

func (*Queries) GetDiscountListBranch

func (q *Queries) GetDiscountListBranch(ctx context.Context, branchID int64) (DiscountListBranch, error)

func (*Queries) GetDiscountListByUID

func (q *Queries) GetDiscountListByUID(ctx context.Context, uid uuid.UUID) (DiscountList, error)

func (*Queries) GetEmailResendAPIKey added in v1.1.0

func (q *Queries) GetEmailResendAPIKey(ctx context.Context) (string, error)

func (*Queries) GetEmailSchedule added in v1.1.0

func (q *Queries) GetEmailSchedule(ctx context.Context, id int64) (EmailSchedule, error)

func (*Queries) GetEmailSettings added in v1.1.0

func (q *Queries) GetEmailSettings(ctx context.Context) (GetEmailSettingsRow, error)

func (*Queries) GetEmployee

func (q *Queries) GetEmployee(ctx context.Context, id int64) (Employee, error)

func (*Queries) GetEntry

func (q *Queries) GetEntry(ctx context.Context, id int64) (Entry, error)

func (*Queries) GetExpense

func (q *Queries) GetExpense(ctx context.Context, id int64) (Expense, error)

func (*Queries) GetExpenseCategory

func (q *Queries) GetExpenseCategory(ctx context.Context, id int64) (ExpenseCategory, error)

func (*Queries) GetFirstActiveVariantBarcodeByCode added in v1.1.3

func (q *Queries) GetFirstActiveVariantBarcodeByCode(ctx context.Context, code string) (GetFirstActiveVariantBarcodeByCodeRow, error)

One representative barcode per product code, for linking an external sales import's line (which only ever has the product code, not a specific color/size) to a real product_variants row -- see api/product_cost_import.go's sibling, the invoice line-linking script. Picks the lowest-id active variant; which exact variant doesn't matter for revenue/cost attribution, only that the line resolves to the right product instead of staying an unlinked placeholder.

func (*Queries) GetInventory

func (q *Queries) GetInventory(ctx context.Context, id int64) (Inventory, error)

func (*Queries) GetInventoryByName

func (q *Queries) GetInventoryByName(ctx context.Context, name string) (Inventory, error)

func (*Queries) GetInventoryStock

func (q *Queries) GetInventoryStock(ctx context.Context, arg GetInventoryStockParams) (InventoryStock, error)

--------------------------------------------------------------------------- Per-variant stock: cached on-hand quantity + moving-average cost. ---------------------------------------------------------------------------

func (*Queries) GetInvoice

func (q *Queries) GetInvoice(ctx context.Context, id int64) (Invoice, error)

func (*Queries) GetInvoiceType

func (q *Queries) GetInvoiceType(ctx context.Context, id int64) (InvoiceType, error)

func (*Queries) GetLoan

func (q *Queries) GetLoan(ctx context.Context, id int64) (Loan, error)

func (*Queries) GetLoanCategory

func (q *Queries) GetLoanCategory(ctx context.Context, id int64) (LoanCategory, error)

func (*Queries) GetLoanImage added in v1.1.0

func (q *Queries) GetLoanImage(ctx context.Context, id int64) (LoanImage, error)

func (*Queries) GetLoanPayment

func (q *Queries) GetLoanPayment(ctx context.Context, id int64) (LoanPayment, error)

func (*Queries) GetLoanUploadTokenByToken added in v1.1.0

func (q *Queries) GetLoanUploadTokenByToken(ctx context.Context, token string) (LoanUploadToken, error)

func (*Queries) GetLowStockSummary

func (q *Queries) GetLowStockSummary(ctx context.Context) (GetLowStockSummaryRow, error)

Counts across all active, alert-enabled products, ignoring search -- backs the summary cards, which should reflect the whole picture even while the table below is filtered.

func (*Queries) GetNextBarcodeItemValue

func (q *Queries) GetNextBarcodeItemValue(ctx context.Context) (int64, error)

func (*Queries) GetPriceList

func (q *Queries) GetPriceList(ctx context.Context, id int64) (PriceList, error)

func (*Queries) GetPriceListBranch

func (q *Queries) GetPriceListBranch(ctx context.Context, branchID int64) (PriceListBranch, error)

func (*Queries) GetPriceListByUID

func (q *Queries) GetPriceListByUID(ctx context.Context, uid uuid.UUID) (PriceList, error)

func (*Queries) GetProduct

func (q *Queries) GetProduct(ctx context.Context, id int64) (Product, error)

func (*Queries) GetProductAttributeValue

func (q *Queries) GetProductAttributeValue(ctx context.Context, arg GetProductAttributeValueParams) (ProductsAttribute, error)

func (*Queries) GetProductAttributes

func (q *Queries) GetProductAttributes(ctx context.Context, productID int64) ([]ProductsAttribute, error)

func (*Queries) GetProductByCode

func (q *Queries) GetProductByCode(ctx context.Context, code string) (Product, error)

-- name: CreatePriceList :one INSERT INTO price_lists (

name,
is_active,
is_default,
valid_from,
valid_to

) VALUES (

$1, $2, $3, $4, $5

) RETURNING *; -- name: ListPriceLists :many SELECT * FROM price_lists ORDER BY name LIMIT $1 OFFSET $2; -- name: UpdatePriceList :exec UPDATE price_lists

SET name = $2,
is_active = $3,
is_default = $4,
valid_from = $5,
valid_to = $6

WHERE id = $1; -- name: CreateProductPrice :one INSERT INTO price_list_items (

price_list_id,
product_id,
price

) VALUES (

$1, $2, $3

) RETURNING *; -- name: UpdateProductPrice :exec UPDATE price_list_items

SET price = $3

WHERE product_id = $1 AND price_list_id = $2; -- name: CreateDiscountList :one INSERT INTO discount_lists (

name,
is_active,
is_default,
valid_from,
valid_to

) VALUES (

$1, $2, $3, $4, $5

) RETURNING *; -- name: ListDiscountLists :many SELECT * FROM discount_lists ORDER BY name LIMIT $1 OFFSET $2; -- name: UpdateDiscountList :exec UPDATE price_lists

SET name = $2,
is_active = $3,
is_default = $4,
valid_from = $5,
valid_to = $6

WHERE id = $1; -- name: UnsetDefaultPriceList :exec UPDATE price_lists

SET is_default = false

WHERE is_default = true; -- name: CreateProductDiscount :one INSERT INTO discount_list_items (

discount_list_id,
product_id,
discount

) VALUES (

$1, $2, $3

) RETURNING *; -- name: UpdateProductDiscount :exec UPDATE discount_list_items

SET discount = $3

WHERE product_id = $1 AND discount_list_id = $2;

func (*Queries) GetProductByName

func (q *Queries) GetProductByName(ctx context.Context, name string) (Product, error)

func (*Queries) GetProductCategory

func (q *Queries) GetProductCategory(ctx context.Context, id int64) (ProductCategory, error)

func (*Queries) GetProductCategoryByName

func (q *Queries) GetProductCategoryByName(ctx context.Context, name string) (ProductCategory, error)

func (*Queries) GetProductSupplier

func (q *Queries) GetProductSupplier(ctx context.Context, arg GetProductSupplierParams) (ProductSupplier, error)

func (*Queries) GetProductVariant

func (q *Queries) GetProductVariant(ctx context.Context, id int64) (ProductVariant, error)

func (*Queries) GetProductVariantByBarcode

func (q *Queries) GetProductVariantByBarcode(ctx context.Context, barcode string) (ProductVariant, error)

func (*Queries) GetProductVariantByUID

func (q *Queries) GetProductVariantByUID(ctx context.Context, uid uuid.UUID) (ProductVariant, error)

func (*Queries) GetPurchase

func (q *Queries) GetPurchase(ctx context.Context, id int64) (GetPurchaseRow, error)

func (*Queries) GetRecurringExpense

func (q *Queries) GetRecurringExpense(ctx context.Context, id int64) (RecurringExpense, error)

func (*Queries) GetRegisterTargetRelease

func (q *Queries) GetRegisterTargetRelease(ctx context.Context, id int64) (GetRegisterTargetReleaseRow, error)

func (*Queries) GetReturnInvoice

func (q *Queries) GetReturnInvoice(ctx context.Context, invoiceID int64) (ReturnInvoice, error)

func (*Queries) GetReviewSettings added in v1.1.0

func (q *Queries) GetReviewSettings(ctx context.Context) (GetReviewSettingsRow, error)

Review links in the post-sale WhatsApp message and the Google data behind the Reviews page (api/review_link.go, api/google_places.go).

func (*Queries) GetRole

func (q *Queries) GetRole(ctx context.Context, id int64) (Role, error)

func (*Queries) GetSaleOption added in v1.1.6

func (q *Queries) GetSaleOption(ctx context.Context, id int64) (SaleOption, error)

func (*Queries) GetSalesInvoice

func (q *Queries) GetSalesInvoice(ctx context.Context, invoiceID int64) (int64, error)

func (*Queries) GetSalesperson

func (q *Queries) GetSalesperson(ctx context.Context, id int64) (Salesperson, error)

func (*Queries) GetSalespersonByAttendanceID added in v1.1.0

func (q *Queries) GetSalespersonByAttendanceID(ctx context.Context, arg GetSalespersonByAttendanceIDParams) (Salesperson, error)

Another salesperson of the same branch already using this device number.

func (*Queries) GetSecuritySettings added in v1.1.0

func (q *Queries) GetSecuritySettings(ctx context.Context) (SecuritySetting, error)

func (*Queries) GetSession

func (q *Queries) GetSession(ctx context.Context, id uuid.UUID) (Session, error)

func (*Queries) GetShift

func (q *Queries) GetShift(ctx context.Context, id int64) (Shift, error)

func (*Queries) GetSizeByName

func (q *Queries) GetSizeByName(ctx context.Context, name string) (Size, error)

func (*Queries) GetSlowMoverSummary

func (q *Queries) GetSlowMoverSummary(ctx context.Context) (GetSlowMoverSummaryRow, error)

func (*Queries) GetStockCount

func (q *Queries) GetStockCount(ctx context.Context, id int64) (StockCount, error)

func (*Queries) GetStockHealthOverview

func (q *Queries) GetStockHealthOverview(ctx context.Context) (GetStockHealthOverviewRow, error)

Inventory health: overall days-of-inventory (on-hand / trailing daily sell-through), total inventory value at moving-average cost, and the same breakdown per inventory location.

func (*Queries) GetSupplier

func (q *Queries) GetSupplier(ctx context.Context, id int64) (Supplier, error)

func (*Queries) GetTransfer

func (q *Queries) GetTransfer(ctx context.Context, id int64) (Transfer, error)

func (*Queries) GetUnknownItemImage added in v1.1.1

func (q *Queries) GetUnknownItemImage(ctx context.Context, id int64) (UnknownItemImage, error)

func (*Queries) GetUnknownItemSessionByRef added in v1.1.1

func (q *Queries) GetUnknownItemSessionByRef(ctx context.Context, arg GetUnknownItemSessionByRefParams) (UnknownItemSession, error)

func (*Queries) GetUnknownItemSessionByToken added in v1.1.1

func (q *Queries) GetUnknownItemSessionByToken(ctx context.Context, token string) (UnknownItemSession, error)

func (*Queries) GetUnknownItemSlotByRef added in v1.1.1

func (q *Queries) GetUnknownItemSlotByRef(ctx context.Context, arg GetUnknownItemSlotByRefParams) (UnknownItemSlot, error)

func (*Queries) GetUnknownItemSlotForResolve added in v1.1.1

func (q *Queries) GetUnknownItemSlotForResolve(ctx context.Context, id int64) (GetUnknownItemSlotForResolveRow, error)

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, id int64) (User, error)

func (*Queries) GetUserAccess

func (q *Queries) GetUserAccess(ctx context.Context, id int64) ([]GetUserAccessRow, error)

One row per permission of the user's role, or a single row with NULL section for a role that has none (an admin, or a brand-new role). No rows at all means the user no longer exists.

func (*Queries) GetUserByUsername

func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error)

func (*Queries) GetVariantDiscountFromList

func (q *Queries) GetVariantDiscountFromList(ctx context.Context, arg GetVariantDiscountFromListParams) (DiscountListItem, error)

func (*Queries) GetVariantForLabel

func (q *Queries) GetVariantForLabel(ctx context.Context, id int64) (GetVariantForLabelRow, error)

func (*Queries) GetVariantPriceFromList

func (q *Queries) GetVariantPriceFromList(ctx context.Context, arg GetVariantPriceFromListParams) (PriceListItem, error)

func (*Queries) GetVariantTotalOnHand

func (q *Queries) GetVariantTotalOnHand(ctx context.Context, variantID int64) (int64, error)

func (*Queries) GetWarehouseTreemapData

func (q *Queries) GetWarehouseTreemapData(ctx context.Context, inventoryID sql.NullInt64) ([]GetWarehouseTreemapDataRow, error)

Feeds the Warehouses Treemap: on-hand quantity per product, grouped by product_categories and by inventory. The inner join on product_categories means only products we've explicitly categorized show up here -- ordinary POS-sellable products with no category_id are never pulled into this view.

func (*Queries) GetWhatsAppChatMessageMedia added in v1.1.1

func (q *Queries) GetWhatsAppChatMessageMedia(ctx context.Context, id int64) (GetWhatsAppChatMessageMediaRow, error)

func (*Queries) GetWhatsAppMessageByReviewCode added in v1.1.0

func (q *Queries) GetWhatsAppMessageByReviewCode(ctx context.Context, reviewCode string) (GetWhatsAppMessageByReviewCodeRow, error)

func (*Queries) GetWhatsAppMessageCost added in v1.1.0

func (q *Queries) GetWhatsAppMessageCost(ctx context.Context) (int64, error)

func (*Queries) GetWhatsAppMessageWithBranch added in v1.1.0

func (q *Queries) GetWhatsAppMessageWithBranch(ctx context.Context, id int64) (GetWhatsAppMessageWithBranchRow, error)

func (*Queries) GetWhatsAppNumber added in v1.1.0

func (q *Queries) GetWhatsAppNumber(ctx context.Context, id int64) (WhatsappNumber, error)

func (*Queries) GetWhatsAppPollReplyMedia added in v1.1.0

func (q *Queries) GetWhatsAppPollReplyMedia(ctx context.Context, id int64) (GetWhatsAppPollReplyMediaRow, error)

Where a reply's media is kept: the bridge number that got it, and its id.

func (*Queries) GetWhatsAppSenderSettings added in v1.1.0

func (q *Queries) GetWhatsAppSenderSettings(ctx context.Context) (GetWhatsAppSenderSettingsRow, error)

Sending post-sale messages from our own numbers through the WhatsApp bridge (api/whatsapp_bridge.go).

func (*Queries) GetWhatsAppSettings

func (q *Queries) GetWhatsAppSettings(ctx context.Context) (GetWhatsAppSettingsRow, error)

func (*Queries) GooglePlaceSnapshotBefore added in v1.1.0

func (q *Queries) GooglePlaceSnapshotBefore(ctx context.Context, arg GooglePlaceSnapshotBeforeParams) (GooglePlaceSnapshot, error)

The place as it stood at `at`: its last snapshot taken before then.

func (*Queries) HomeActivityFeed added in v1.1.0

func (q *Queries) HomeActivityFeed(ctx context.Context, arg HomeActivityFeedParams) ([]HomeActivityFeedRow, error)

The home page's "Recent activity" feed: the same rows as DashboardActivitiesList (every kind of branch sync, newest received first, hidden branches and registers left out), but paged by a keyset cursor instead of a date window and an offset, and without the windowed total. Each page is the next page_size rows after (before_at, before_activity, before_id) -- the last row the feed already has -- so the per-table received_at indexes do the work and a page costs the same however far down the feed is scrolled. The salesperson colour is looked up for the page's rows only.

func (*Queries) IncrementInvoicesIndex

func (q *Queries) IncrementInvoicesIndex(ctx context.Context, arg IncrementInvoicesIndexParams) (int64, error)

func (*Queries) InheritBranchInvoiceCancellation added in v1.1.0

func (q *Queries) InheritBranchInvoiceCancellation(ctx context.Context, id int64) error

A sale can reach kashi after the return that cancelled it (a resync pushes whatever kashi is missing, in no guaranteed order); it picks up the mark the cancellation already left waiting for it.

func (*Queries) InsertBranchQuickAccessItem

func (q *Queries) InsertBranchQuickAccessItem(ctx context.Context, arg InsertBranchQuickAccessItemParams) error

func (*Queries) LastWhatsAppSentAt added in v1.1.0

func (q *Queries) LastWhatsAppSentAt(ctx context.Context, clientPhone string) (time.Time, error)

When this phone was last actually messaged; no rows when never.

func (*Queries) LatestGooglePlaceSnapshot added in v1.1.0

func (q *Queries) LatestGooglePlaceSnapshot(ctx context.Context, placeID string) (GooglePlaceSnapshot, error)

func (*Queries) LinkUnknownItemSession added in v1.1.1

func (q *Queries) LinkUnknownItemSession(ctx context.Context, arg LinkUnknownItemSessionParams) error

func (*Queries) ListActiveBranchRegisterIDs

func (q *Queries) ListActiveBranchRegisterIDs(ctx context.Context, branchID int64) ([]int64, error)

func (*Queries) ListActiveBranchTargetSeries

func (q *Queries) ListActiveBranchTargetSeries(ctx context.Context) ([]BranchTargetSeries, error)

func (*Queries) ListActiveIPBans added in v1.1.0

func (q *Queries) ListActiveIPBans(ctx context.Context) ([]IpBan, error)

func (*Queries) ListAdminActivities

func (q *Queries) ListAdminActivities(ctx context.Context, arg ListAdminActivitiesParams) ([]ListAdminActivitiesRow, error)

User and role changes are admin housekeeping, kept out of the feed.

func (*Queries) ListAllAttributeValues

func (q *Queries) ListAllAttributeValues(ctx context.Context) ([]ListAllAttributeValuesRow, error)

func (*Queries) ListAllBranchRegisters

func (q *Queries) ListAllBranchRegisters(ctx context.Context) ([]BranchRegister, error)

func (*Queries) ListAllCashboxAccounts

func (q *Queries) ListAllCashboxAccounts(ctx context.Context) ([]CashboxAccount, error)

func (*Queries) ListAllClientPhones added in v1.1.3

func (q *Queries) ListAllClientPhones(ctx context.Context) ([]ListAllClientPhonesRow, error)

Every client's raw stored phone, for the one-off admin normalize job (api/client_phone_cleanup.go) -- unlike ListClients this is never paged, since the job needs every row in one pass to detect collisions.

func (*Queries) ListAppReleases

func (q *Queries) ListAppReleases(ctx context.Context) ([]ListAppReleasesRow, error)

Newest first, with how many active registers run each release and how many are told to.

func (*Queries) ListAppUpdateEvents

func (q *Queries) ListAppUpdateEvents(ctx context.Context, limit int32) ([]ListAppUpdateEventsRow, error)

func (*Queries) ListAssetCategories

func (q *Queries) ListAssetCategories(ctx context.Context) ([]AssetCategory, error)

func (*Queries) ListAssetsPage

func (q *Queries) ListAssetsPage(ctx context.Context, arg ListAssetsPageParams) ([]Asset, error)

func (*Queries) ListAttributeValuesPage

func (q *Queries) ListAttributeValuesPage(ctx context.Context, arg ListAttributeValuesPageParams) ([]ListAttributeValuesPageRow, error)

func (*Queries) ListAttributes

func (q *Queries) ListAttributes(ctx context.Context) ([]Attribute, error)

func (*Queries) ListAuditLogs

func (q *Queries) ListAuditLogs(ctx context.Context, arg ListAuditLogsParams) ([]ListAuditLogsRow, error)

func (*Queries) ListAutoDeletableUnknownItemImages added in v1.1.1

What the daily clean-up removes: pictures whose units were all matched before resolved_before, and pictures of checkouts that never became a sale and whose link expired before abandoned_before.

func (*Queries) ListAvailableBatchItemsForVariant

func (q *Queries) ListAvailableBatchItemsForVariant(ctx context.Context, variantID int64) ([]BatchItem, error)

FIFO order: oldest batch (by receipt/creation date) first. Walked by applyStockMovement to decide which batch(es) a sold unit debits. FOR UPDATE so two sales racing on the same variant can't both allocate the same remaining units.

func (*Queries) ListBatchItemsStats

func (q *Queries) ListBatchItemsStats(ctx context.Context, batchID int64) ([]ListBatchItemsStatsRow, error)

Per-item numbers for the batch's "Products" tab, scoped to this batch's own units via FIFO-tagged stock_movements: remaining_quantity is exactly what's left of this batch unsold, and quantity_sold/revenue are summed only from sale movements this batch's FIFO consumption actually produced (revenue prorated off the source invoice line's price/unit).

func (*Queries) ListBatches

func (q *Queries) ListBatches(ctx context.Context, arg ListBatchesParams) ([]ListBatchesRow, error)

func (*Queries) ListBranchAttendanceChanges

func (q *Queries) ListBranchAttendanceChanges(ctx context.Context, arg ListBranchAttendanceChangesParams) ([]BranchAttendanceChange, error)

func (*Queries) ListBranchAttendanceEvents

func (q *Queries) ListBranchAttendanceEvents(ctx context.Context, arg ListBranchAttendanceEventsParams) ([]BranchAttendanceEvent, error)

Newest punch first by its own local date/time, not insertion order: a backfilled import gets the newest ids but holds the oldest punches. A punch an approved change replaced or deleted (removed_at) is left out; it stays in the table for the audit trail.

func (*Queries) ListBranchAttendanceEventsInRange added in v1.1.0

func (q *Queries) ListBranchAttendanceEventsInRange(ctx context.Context, arg ListBranchAttendanceEventsInRangeParams) ([]BranchAttendanceEvent, error)

Every live punch between two dates (inclusive) for the timesheet views, which pair each person's IN/OUT punches per day. event_date is the device's own YYYY-MM-DD text, so a plain text comparison orders it. Capped as a guard against an all-branches, all-time request.

func (*Queries) ListBranchClientUIDs

func (q *Queries) ListBranchClientUIDs(ctx context.Context, registerID int64) ([]ListBranchClientUIDsRow, error)

Adoption: which central client each of this register's local client ids is linked to, so a till can stamp the right uid without guessing by phone.

func (*Queries) ListBranchCommands

func (q *Queries) ListBranchCommands(ctx context.Context, arg ListBranchCommandsParams) ([]ListBranchCommandsRow, error)

func (*Queries) ListBranchCommandsPage

func (q *Queries) ListBranchCommandsPage(ctx context.Context, arg ListBranchCommandsPageParams) ([]ListBranchCommandsPageRow, error)

The Commands page: every branch (branch_id 0) or one, optionally one register / status / type, newest first.

func (*Queries) ListBranchExpenseImages

func (q *Queries) ListBranchExpenseImages(ctx context.Context, arg ListBranchExpenseImagesParams) ([]ListBranchExpenseImagesRow, error)

Storage-explorer feed: every uploaded image, newest first, joined with its expense and branch so the admin UI never needs a second round trip per row.

func (*Queries) ListBranchExpenseImagesForExpense

func (q *Queries) ListBranchExpenseImagesForExpense(ctx context.Context, branchExpenseID int64) ([]BranchExpenseImage, error)

func (*Queries) ListBranchExpenses

func (q *Queries) ListBranchExpenses(ctx context.Context, arg ListBranchExpensesParams) ([]BranchExpense, error)

sqlc.narg(branch_id) is nullable: NULL means "all branches", matching ListBranchInvoices' admin-filter convention. search ” means no filter.

func (*Queries) ListBranchInvoiceCouponCodesForHistory

At most one coupon redemption per invoice (see CreateBranchInvoiceTx's own comment) -- the code a redeemed coupon carries for the given invoices' client_refs, so the branch can reattach it to whichever payment line it recognizes as its own coupon-settlement placeholder account. Coupon codes are never persisted on branch_invoice_payments itself (see CreateBranchInvoiceTx: a coupon payment only ever calls RedeemCoupon), so this is the only way to recover which line was the coupon.

func (*Queries) ListBranchInvoiceHistoryForSync

func (q *Queries) ListBranchInvoiceHistoryForSync(ctx context.Context, arg ListBranchInvoiceHistoryForSyncParams) ([]BranchInvoice, error)

--------------------------------------------------------------------------- Branch-scoped historical read-back (see api/branch_catchup.go's branchSyncChanges "branch_invoice_history"/"branch_expense_history"/ "branch_loan_history"/"branch_shift_history" cases). Lets a branch pull its OWN previously-submitted invoices/expenses/loans/shift-closes back down -- e.g. re-provisioning a wiped till for a branch that already has real history on kashi. branch_id always comes from the authenticated branch (ctx.MustGet(branchIDKey)), never a request parameter, so a branch can only ever pull its own data. Keyset-paginated on (received_at, id), same cursor shape as ListBranchStockForSync.

Invoices and shift closes are per register: a re-provisioned till gets back only what it itself sold and closed, so its invoice numbering and local shift ids carry on without colliding with its branch's other tills. Expenses and loans aren't tracked per register and stay branch-wide. ---------------------------------------------------------------------------

func (*Queries) ListBranchInvoiceItems

func (q *Queries) ListBranchInvoiceItems(ctx context.Context, branchInvoiceID int64) ([]ListBranchInvoiceItemsRow, error)

With the product each line is, for the admin views: the till only sends its own local product id, which means nothing here, so the name comes from the variant product_uid resolves to (blank for an old line that never resolved -- see resolveVariantByUIDOrBarcode).

func (*Queries) ListBranchInvoiceItemsForHistory

func (q *Queries) ListBranchInvoiceItemsForHistory(ctx context.Context, branchInvoiceIds []int64) ([]ListBranchInvoiceItemsForHistoryRow, error)

Items for a whole page of invoices at once, batched by id -- distinct from ListBranchInvoiceItems (branch_invoice.sql), which is the single-invoice admin detail view. resolved_barcode comes from product_variants via product_uid (nullable: an item pushed before product_uid existed, and whose barcode never resolved to a variant at push time either, has neither -- see resolveVariantByUIDOrBarcode in tx_branch_invoice.go).

func (*Queries) ListBranchInvoiceItemsNamed added in v1.1.0

func (q *Queries) ListBranchInvoiceItemsNamed(ctx context.Context, branchInvoiceID int64) ([]ListBranchInvoiceItemsNamedRow, error)

An invoice's lines with the product each one sold, for the Recent activity details dialog. A line whose product_uid never resolved to a variant keeps an empty name.

func (*Queries) ListBranchInvoicePayments

func (q *Queries) ListBranchInvoicePayments(ctx context.Context, branchInvoiceID int64) ([]BranchInvoicePayment, error)

func (*Queries) ListBranchInvoicePaymentsForHistory

func (q *Queries) ListBranchInvoicePaymentsForHistory(ctx context.Context, branchInvoiceIds []int64) ([]BranchInvoicePayment, error)

func (*Queries) ListBranchInvoiceSettlementPayments

func (q *Queries) ListBranchInvoiceSettlementPayments(ctx context.Context, branchInvoiceSettlementID int64) ([]BranchInvoiceSettlementPayment, error)

func (*Queries) ListBranchInvoiceSettlements

func (q *Queries) ListBranchInvoiceSettlements(ctx context.Context, arg ListBranchInvoiceSettlementsParams) ([]BranchInvoiceSettlement, error)

func (*Queries) ListBranchInvoices

func (q *Queries) ListBranchInvoices(ctx context.Context, arg ListBranchInvoicesParams) ([]BranchInvoice, error)

sqlc.narg(branch_id) is nullable: NULL means "all branches", matching how the admin UI's branch filter works (a dropdown with an "All branches" option, not a required selection).

func (*Queries) ListBranchInvoicesPage

func (q *Queries) ListBranchInvoicesPage(ctx context.Context, arg ListBranchInvoicesPageParams) ([]BranchInvoice, error)

func (*Queries) ListBranchPlaceIDs added in v1.1.0

func (q *Queries) ListBranchPlaceIDs(ctx context.Context) ([]ListBranchPlaceIDsRow, error)

func (*Queries) ListBranchProductRevenue

func (q *Queries) ListBranchProductRevenue(ctx context.Context, arg ListBranchProductRevenueParams) ([]ListBranchProductRevenueRow, error)

--------------------------------------------------------------------------- Branch (kashi-pos) sales. branch_invoice_items itself carries no product link (branch_product_id is a branch-local id, not an FK -- see 000025_create_branch_invoices.up.sql), so it can't be the source. But CreateBranchInvoiceTx (tx_branch_invoice.go) already resolves each line's barcode to a real product_variants row at sync time and records the sale as a stock_movements row (reason='sale', reference_type='branch_invoice', inventory_id = the branch's own store inventory) purely to decrement central stock -- that ledger is the only place a branch sale is linked to a real product. It carries quantity but no transaction price, so revenue here is an ESTIMATE: each unit priced at the variant's *current* catalog price (its entry in the default price list -- see the variant_default_prices view in 000094), not whatever kashi-pos actually charged at checkout (which may have included a since-changed price or a branch-side discount neither table records at this granularity). A line whose barcode never resolved (old kashi-pos build, unknown barcode, or a historical backfill -- see CreateBranchInvoiceTx's Historical branch) never got a stock_movements row at all and so is silently absent here, same as it's absent from central stock. ---------------------------------------------------------------------------

func (*Queries) ListBranchProductRevenueDaily

func (q *Queries) ListBranchProductRevenueDaily(ctx context.Context, arg ListBranchProductRevenueDailyParams) ([]ListBranchProductRevenueDailyRow, error)

Same scope/filters/estimate caveat as ListBranchProductRevenue, rolled up by local calendar day -- the trend line for the kashi-pos tab.

func (*Queries) ListBranchQuickAccessItems

func (q *Queries) ListBranchQuickAccessItems(ctx context.Context, branchID int64) ([]ListBranchQuickAccessItemsRow, error)

A branch's central Quick Access list, in card order, with enough of each product to show it in the admin editor; tills only use uid/position/colours.

func (*Queries) ListBranchRegisters

func (q *Queries) ListBranchRegisters(ctx context.Context, branchID int64) ([]BranchRegister, error)

func (*Queries) ListBranchRegistersByIDs

func (q *Queries) ListBranchRegistersByIDs(ctx context.Context, ids []int64) ([]BranchRegister, error)

func (*Queries) ListBranchRevenueByBranch

func (q *Queries) ListBranchRevenueByBranch(ctx context.Context, arg ListBranchRevenueByBranchParams) ([]ListBranchRevenueByBranchRow, error)

Same scope/filters/estimate caveat as ListBranchProductRevenue, rolled up by branch instead of by product -- backs the "revenue by branch" chart, deliberately with no branch_id filter of its own (that would defeat the point of a per-branch breakdown).

func (*Queries) ListBranchSalesDaysRange

func (q *Queries) ListBranchSalesDaysRange(ctx context.Context, arg ListBranchSalesDaysRangeParams) ([]ListBranchSalesDaysRangeRow, error)

Per (branch, local day) sales-invoice count and gross sales revenue in an inclusive "YYYY-MM-DD" range, oldest first. Deliberately shaped like ListBranchVisitorDaysRange so the Footfall page can line footfall up against sales for the same window -- conversion rate, average ticket -- with one extra request and no per-day query.

Only kind = 'sales' counts: a return or exchange isn't a walk-in turning into a buyer, and its grand_total carries the branch's own signed refund/top-up convention (see ListDailyIncome) which would distort an "average sale" figure. The occurred_at range is compared against plain date bounds (not AT TIME ZONE per row) so idx_branch_invoices_occurred_at stays usable, same reasoning as ListDailyIncome.

func (*Queries) ListBranchShiftHistoryForSync

func (q *Queries) ListBranchShiftHistoryForSync(ctx context.Context, arg ListBranchShiftHistoryForSyncParams) ([]BranchShift, error)

func (*Queries) ListBranchShiftReceiptImages

func (q *Queries) ListBranchShiftReceiptImages(ctx context.Context, arg ListBranchShiftReceiptImagesParams) ([]ListBranchShiftReceiptImagesRow, error)

Storage-explorer feed: every uploaded close-shift receipt photo, newest first, joined with its shift and branch so the admin UI never needs a second round trip per row. Mirrors ListBranchExpenseImages.

func (*Queries) ListBranchShifts

func (q *Queries) ListBranchShifts(ctx context.Context, arg ListBranchShiftsParams) ([]ListBranchShiftsRow, error)

sqlc.narg(branch_id) is nullable: NULL means "all branches", matching ListBranchExpenses' admin-filter convention. has_receipt_image lets the admin Shifts page show a per-row indicator without an extra request per shift (see branch_shift_receipt_images / api/branch_shift_receipt_image.go).

func (*Queries) ListBranchStockForSync

func (q *Queries) ListBranchStockForSync(ctx context.Context, arg ListBranchStockForSyncParams) ([]ListBranchStockForSyncRow, error)

--------------------------------------------------------------------------- Cross-branch stock visibility: every OTHER branch's on-hand quantity and resolved selling price for a variant, so a till can search what a different branch is carrying. Keyset-paginated on inventory_stock's surrogate id (000101 -- the table's real key, (inventory_id, variant_id), has no single ordering column), same cursor shape as ListProductVariantsForSyncPaged. ---------------------------------------------------------------------------

func (*Queries) ListBranchTargetSeriesForBranch

func (q *Queries) ListBranchTargetSeriesForBranch(ctx context.Context, branchID int64) ([]BranchTargetSeries, error)

func (*Queries) ListBranchTargetsForBranch

func (q *Queries) ListBranchTargetsForBranch(ctx context.Context, branchID int64) ([]BranchTarget, error)

func (*Queries) ListBranchTargetsProgress

func (q *Queries) ListBranchTargetsProgress(ctx context.Context, arg ListBranchTargetsProgressParams) ([]ListBranchTargetsProgressRow, error)

Branch-wide progress for a till's target bars: what every register of this branch has sold in each live target's range, as kashi has received it. The till adds its own not-yet-synced sales on top.

func (*Queries) ListBranchTargetsUpdatedSince

func (q *Queries) ListBranchTargetsUpdatedSince(ctx context.Context, arg ListBranchTargetsUpdatedSinceParams) ([]BranchTarget, error)

func (*Queries) ListBranchTransfersUpdatedSince

func (q *Queries) ListBranchTransfersUpdatedSince(ctx context.Context, arg ListBranchTransfersUpdatedSinceParams) ([]Transfer, error)

The till's own poll: what happened to the requests it made -- see approveTransfer/rejectTransfer, which both bump updated_at.

func (*Queries) ListBranchUsersForBranch

func (q *Queries) ListBranchUsersForBranch(ctx context.Context, branchID int64) ([]BranchUser, error)

func (*Queries) ListBranchUsersUpdatedSince

func (q *Queries) ListBranchUsersUpdatedSince(ctx context.Context, arg ListBranchUsersUpdatedSinceParams) ([]BranchUser, error)

Branch-scoped catch-up feed, same contract as ListSalespersonsUpdatedSince.

func (*Queries) ListBranchVisitorDays

func (q *Queries) ListBranchVisitorDays(ctx context.Context, arg ListBranchVisitorDaysParams) ([]ListBranchVisitorDaysRow, error)

One row per (branch, local day): gross customers-in vs customers-out, newest day first. sqlc.narg(branch_id) NULL means "all branches", matching ListBranchShifts' admin-filter convention.

func (*Queries) ListBranchVisitorDaysRange

func (q *Queries) ListBranchVisitorDaysRange(ctx context.Context, arg ListBranchVisitorDaysRangeParams) ([]ListBranchVisitorDaysRangeRow, error)

Every (branch, day) rollup within an inclusive "YYYY-MM-DD" day range, oldest first. No pagination: footfall data is one row per branch per day, so even a year across every branch is a small result the Footfall page slices into months / branch comparisons / weekday profiles client-side.

func (*Queries) ListBranchWhatsAppNumbers added in v1.1.0

func (q *Queries) ListBranchWhatsAppNumbers(ctx context.Context) ([]ListBranchWhatsAppNumbersRow, error)

func (*Queries) ListBranches

func (q *Queries) ListBranches(ctx context.Context) ([]Branch, error)

func (*Queries) ListBranchesForDiscountList

func (q *Queries) ListBranchesForDiscountList(ctx context.Context, discountListID int64) ([]ListBranchesForDiscountListRow, error)

func (*Queries) ListBranchesForPriceList

func (q *Queries) ListBranchesForPriceList(ctx context.Context, priceListID int64) ([]ListBranchesForPriceListRow, error)

func (*Queries) ListBranchesForSync

func (q *Queries) ListBranchesForSync(ctx context.Context, id int64) ([]ListBranchesForSyncRow, error)

Whole set, small table like currencies -- a till needs to see a branch go inactive (and so disappear from its destination picker), which an updated-since delta can't express. Excludes the requesting branch itself: it can't transfer to itself.

func (*Queries) ListCalendarEvents

func (q *Queries) ListCalendarEvents(ctx context.Context) ([]CalendarEvent, error)

func (*Queries) ListCashboxAccountOverridesForBranch

func (q *Queries) ListCashboxAccountOverridesForBranch(ctx context.Context, branchID int64) ([]ListCashboxAccountOverridesForBranchRow, error)

The admin view: every central method with this branch's override state, so the UI can show what is inherited and what is explicitly set. Unlike the sync query this keeps disabled rows -- switching one back on is the whole point of the screen.

func (*Queries) ListCashboxAccounts

func (q *Queries) ListCashboxAccounts(ctx context.Context, arg ListCashboxAccountsParams) ([]CashboxAccount, error)

func (*Queries) ListCashboxAccountsForBranchSync

func (q *Queries) ListCashboxAccountsForBranchSync(ctx context.Context, branchID int64) ([]ListCashboxAccountsForBranchSyncRow, error)

What one branch's tills should actually show: the central set with that branch's overrides folded in, and the methods it switched off left out entirely. Absence is the signal kashi-pos reconciles on, so an excluded method needs no flag of its own -- not sending it is what deactivates it at the till (see reconcileCashboxAccounts in kashi-pos).

COALESCE per column rather than per row: an override that only sets sort_order keeps inheriting central's color and currency, so a later central color change still reaches a branch that reordered its buttons.

func (*Queries) ListCashboxAccountsForSync

func (q *Queries) ListCashboxAccountsForSync(ctx context.Context) ([]CashboxAccount, error)

The whole set, not a "changed since" delta. A branch has to be able to tell that kashi no longer has a payment method at all, and an incremental feed can only say what changed -- it has no way to say what is gone. Sending every row lets the till reconcile by absence, the same shape the price and discount lists use. The table is a handful of rows, so the cost is nil.

Inactive methods are left out on purpose: absence is what the till reconciles a deactivation on (see ListCashboxAccountsForBranchSync and reconcileCashboxAccounts in kashi-pos), so a centrally deactivated method reaches every branch the same way a deleted one would, without kashi-pos ever needing to know about is_active at all.

func (*Queries) ListCashboxAccountsUpdatedSince

func (q *Queries) ListCashboxAccountsUpdatedSince(ctx context.Context, updatedAt time.Time) ([]CashboxAccount, error)

func (*Queries) ListCashboxes

func (q *Queries) ListCashboxes(ctx context.Context, arg ListCashboxesParams) ([]Cashbox, error)

func (*Queries) ListClientMonthlySpend

func (q *Queries) ListClientMonthlySpend(ctx context.Context, clientID int64) ([]ClientMonthlySpendRow, error)

func (*Queries) ListClientPaymentMix

func (q *Queries) ListClientPaymentMix(ctx context.Context, clientID int64) ([]ClientPaymentMixRow, error)

func (*Queries) ListClientPhoneCountries added in v1.1.3

func (q *Queries) ListClientPhoneCountries(ctx context.Context) ([]ListClientPhoneCountriesRow, error)

Distinct countries actually present among clients' phones, for the clients page's country filter dropdown -- so it only ever offers a country that would return at least one result, instead of the full ~240-country ISO list.

func (*Queries) ListClientRecentInvoices

func (q *Queries) ListClientRecentInvoices(ctx context.Context, clientID int64) ([]ClientRecentInvoiceRow, error)

func (*Queries) ListClientSyncIDs

func (q *Queries) ListClientSyncIDs(ctx context.Context, arg ListClientSyncIDsParams) ([]ListClientSyncIDsRow, error)

Completeness check: every retail client's uid + updated_at, keyset-paged by uid. Inactive clients are included -- a till must learn they're inactive, not just stop hearing about them.

func (*Queries) ListClients

func (q *Queries) ListClients(ctx context.Context, arg ListClientsParams) ([]Client, error)

sqlc.narg(client_type) is nullable: NULL means "all types" -- the admin clients page passes it when a Retail/Wholesale tab is selected, and omits it for a combined view if one is ever added.

func (*Queries) ListClientsByInvoiceCountCached added in v1.1.6

ListClientsBySpendingCached, ranked by invoice count.

func (*Queries) ListClientsByItemCountCached added in v1.1.6

func (q *Queries) ListClientsByItemCountCached(ctx context.Context, arg ListClientsByItemCountCachedParams) ([]ListClientsByItemCountCachedRow, error)

ListClientsBySpendingCached, ranked by item count.

func (*Queries) ListClientsBySpending

func (q *Queries) ListClientsBySpending(ctx context.Context, arg ListClientsBySpendingParams) ([]ListClientsBySpendingRow, error)

Powers the clients "loyalty pyramid" + rest-of-clients table: every client ranked by total_spent, invoice_count, or item_count (chosen via sort_by -- see the ORDER BY at the bottom). Two sources feed each metric: kashi's own admin invoices (sales positive, returns negative -- invoices.grand_total is always stored as a positive magnitude regardless of kind, see ReturnInvoiceTx) and branch-reported sales (branch_invoices.grand_total, which already carries the correct net sign -- see ListDailyIncome). sqlc.arg(branch_ids) scopes to one branch's till (or several, via the branch_ids array; empty means every branch); central admin invoices aren't attributed to any branch, so they're excluded entirely once any branch is selected (an "All Branches" view is the only one where they belong). invoice_count/item_count follow the same all-or-selected-branches rule for consistency with total_spent. invoice_count/item_count are computed in the `ranked` CTE rather than as plain SELECT-list aliases so the ORDER BY's CASE expression can actually reference them: Postgres only resolves an output alias in ORDER BY when it's used bare, not when it's embedded in a larger expression (there it's looked up as an ordinary column instead, which fails since it isn't one of the FROM clause's columns). Wrapping in a CTE turns them into real columns of the derived table, so the CASE inside ORDER BY resolves fine.

func (*Queries) ListClientsBySpendingCached added in v1.1.6

func (q *Queries) ListClientsBySpendingCached(ctx context.Context, arg ListClientsBySpendingCachedParams) ([]ListClientsBySpendingCachedRow, error)

ListClientsBySpending for the unfiltered case (no branch, no dates, no first/returning): reads the client_spend cache instead of aggregating every invoice, so a page costs an index scan. Same ordering and the other filters (type, search, phone) as the live query. One query per sort, rather than a CASE in ORDER BY, so Postgres can read the top rows straight off that column's index. Every client has a client_spend row (see migration 197).

func (*Queries) ListClientsByUIDs

func (q *Queries) ListClientsByUIDs(ctx context.Context, uids []uuid.UUID) ([]Client, error)

func (*Queries) ListClientsForExport added in v1.1.1

func (q *Queries) ListClientsForExport(ctx context.Context, arg ListClientsForExportParams) ([]ListClientsForExportRow, error)

Feeds the clients CSV export: one row per (client, branch) for every client who bought something, so the caller can write a file per branch. A client "belongs" to a branch because a non-cancelled invoice there is theirs. The invoice's client is resolved by either identity a till has used: the shared client_uid (current), or the older (register, branch_client_id) client_links entry -- an invoice carrying only one of them still counts. branch_ids (empty = every branch) and the [date_from, date_to) window (either bound optional) narrow which invoices count; spend/invoice figures are for that same scope, not lifetime. Central admin invoices have no branch (branch_id 0) and are only included when no branch is selected, the same rule as ListClientsBySpending. With no branch and no date set, clients who never bought anything are listed too (branch_id 0, zero spend). A client is listed under every branch they bought from, not only their home branch (clients.branch_id, the first one); the home branch adds a zero-spend row when they have no purchases there. Cancelled and hidden-from-reports branch invoices are skipped as everywhere else, unless include_excluded is set. Home branch (clients.branch_id): a client is also listed under it when they haven't bought there in this scope, e.g. one imported with a branch and no sales yet. Only for an explicit branch pick and no dates, since zero spend can't match a date window; the same hidden-branch rule as purchases applies.

func (*Queries) ListClientsMissingPhoneCountry added in v1.1.6

func (q *Queries) ListClientsMissingPhoneCountry(ctx context.Context) ([]ListClientsMissingPhoneCountryRow, error)

Clients with no phone_country yet: ones a till created or edited before the sync path started filling it in. "nophone-..." placeholders aren't phone numbers, so they're left alone.

func (*Queries) ListClientsUpdatedSince

func (q *Queries) ListClientsUpdatedSince(ctx context.Context, updatedAt time.Time) ([]Client, error)

Feeds the branch catch-up endpoint (see branch_catchup.go), same pattern as currencies/cashbox_accounts/products. Wholesale clients never appear here -- they're a central-office concept, not something a branch till should ever see in its client search. Converting an already-synced retail client to wholesale won't retract it from branches that already have it locally (no delete propagation exists for any synced entity today); acceptable since that conversion is expected to be rare.

func (*Queries) ListClientsUpdatedSincePaged

func (q *Queries) ListClientsUpdatedSincePaged(ctx context.Context, arg ListClientsUpdatedSincePagedParams) ([]Client, error)

Keyset-paginated form of ListClientsUpdatedSince for a branch doing a full catch-up (cursor reset): ordered by (updated_at, id) so a page boundary that falls between two rows sharing an updated_at can't drop or repeat one. after_updated_at/after_id are the last row of the previous page (zero-time / 0 for the first page).

func (*Queries) ListClientsWithLoyalty

func (q *Queries) ListClientsWithLoyalty(ctx context.Context, arg ListClientsWithLoyaltyParams) ([]ListClientsWithLoyaltyRow, error)

Same rows as ListClients, but with each branch's reported loyalty points (branch_invoices.loyalty_points_delta, via client_links) summed in alongside kashi's own admin-invoice points. Used by the admin clients page so the displayed balance isn't missing everything earned at a branch till.

func (*Queries) ListColors

func (q *Queries) ListColors(ctx context.Context) ([]Color, error)

func (*Queries) ListColorsPage

func (q *Queries) ListColorsPage(ctx context.Context, arg ListColorsPageParams) ([]Color, error)

func (*Queries) ListCouponCategories

func (q *Queries) ListCouponCategories(ctx context.Context, scope sql.NullString) ([]CouponCategory, error)

func (*Queries) ListCouponLists

func (q *Queries) ListCouponLists(ctx context.Context) ([]ListCouponListsRow, error)

func (*Queries) ListCouponTypes

func (q *Queries) ListCouponTypes(ctx context.Context) ([]CouponType, error)

func (*Queries) ListCouponTypesUpdatedSince

func (q *Queries) ListCouponTypesUpdatedSince(ctx context.Context, updatedAt time.Time) ([]CouponType, error)

func (*Queries) ListCoupons

func (q *Queries) ListCoupons(ctx context.Context, arg ListCouponsParams) ([]ListCouponsRow, error)

func (*Queries) ListCouponsUpdatedSince

func (q *Queries) ListCouponsUpdatedSince(ctx context.Context, updatedAt time.Time) ([]Coupon, error)

Sent whole (every status, not just active): absence can't express "redeemed elsewhere" or "deactivated" to a till that already has the row, so the row itself carries the new status down. See ListPriceListsForBranchSync's comment in branch_sync_lists.go for the same reasoning.

func (*Queries) ListCurrencies

func (q *Queries) ListCurrencies(ctx context.Context, arg ListCurrenciesParams) ([]Currency, error)

page_size = 0 returns every currency (the CurrencySelect picker needs the whole list); any positive value pages. Order is always by code, so the picker and the paged table agree.

func (*Queries) ListCurrenciesForSync

func (q *Queries) ListCurrenciesForSync(ctx context.Context) ([]Currency, error)

The whole set -- see ListCashboxAccountsForSync for why this is not a delta.

func (*Queries) ListCurrenciesUpdatedSince

func (q *Queries) ListCurrenciesUpdatedSince(ctx context.Context, updatedAt time.Time) ([]Currency, error)

func (*Queries) ListDailyIncome

func (q *Queries) ListDailyIncome(ctx context.Context, arg ListDailyIncomeParams) ([]ListDailyIncomeRow, error)

Sums grand_total across both kinds ('sales' and 'return') rather than treating them separately: a branch's return/exchange grand_total is already the net signed cash effect it reported (negative for a refund, positive for an even-or-up exchange -- see tx_exchange.go's netDifference in kashi-pos), so a plain sum already nets returns against sales correctly without this query needing to know or guess that sign convention itself. The year filter is a >=/< range against a fixed pair of dates rather than EXTRACT(YEAR FROM occurred_at) = $1 -- EXTRACT on every row can't use a plain btree index on occurred_at (idx_branch_invoices_occurred_at), while a range comparison can.

func (*Queries) ListDayBranchExpenses

func (q *Queries) ListDayBranchExpenses(ctx context.Context, arg ListDayBranchExpensesParams) ([]ListDayBranchExpensesRow, error)

func (*Queries) ListDayBranchShifts

func (q *Queries) ListDayBranchShifts(ctx context.Context, arg ListDayBranchShiftsParams) ([]ListDayBranchShiftsRow, error)

Shifts closed on the day (a shift belongs to the day its till was counted, which is what the variance figures describe).

func (*Queries) ListDayInvoices

func (q *Queries) ListDayInvoices(ctx context.Context, arg ListDayInvoicesParams) ([]ListDayInvoicesRow, error)

Every invoice of the day, newest first. Capped well above a real day's volume; the page only lists them.

func (*Queries) ListDayPaymentsByAccount

func (q *Queries) ListDayPaymentsByAccount(ctx context.Context, arg ListDayPaymentsByAccountParams) ([]ListDayPaymentsByAccountRow, error)

How the day's money came in, by the branch-reported account display name (cashbox accounts aren't shared across the branch boundary -- see migration 000054).

func (*Queries) ListDaySalesByBranch

func (q *Queries) ListDaySalesByBranch(ctx context.Context, arg ListDaySalesByBranchParams) ([]ListDaySalesByBranchRow, error)

Queries backing the Daily Income heatmap's per-day drill-down page (GET /branch_invoices/day_summary). Every query scopes to one *local* calendar day: occurred_at converted to the owning branch's timezone, the same rule ListDailyIncome uses to bucket the heatmap cell that was clicked, so the page's totals always agree with that cell.

The occurred_at range against day-1 .. day+2 is a coarse prefilter that keeps idx_branch_invoices_occurred_at usable (a per-row AT TIME ZONE can't use the index on its own); two days of slack on either side covers every real timezone offset, and the AT TIME ZONE equality does the exact cut. Per-branch totals for the day. net_total is the plain grand_total sum across sales and returns, same signed-return convention as ListDailyIncome, so the page's headline matches the heatmap cell.

func (*Queries) ListDaySalesByHour

func (q *Queries) ListDaySalesByHour(ctx context.Context, arg ListDaySalesByHourParams) ([]ListDaySalesByHourRow, error)

Local-hour buckets (0-23); hours with no invoices are absent and the frontend fills zeros.

func (*Queries) ListDaySalesBySalesperson

func (q *Queries) ListDaySalesBySalesperson(ctx context.Context, arg ListDaySalesBySalespersonParams) ([]ListDaySalesBySalespersonRow, error)

func (*Queries) ListDayTopProducts

func (q *Queries) ListDayTopProducts(ctx context.Context, arg ListDayTopProductsParams) ([]ListDayTopProductsRow, error)

Best sellers of the day by line revenue, sales invoices only. Items whose product_uid never resolved to a variant (see resolveVariantByUIDOrBarcode) fold into one "unknown" row rather than disappearing from the totals.

func (*Queries) ListDayVisitorsByHour

func (q *Queries) ListDayVisitorsByHour(ctx context.Context, arg ListDayVisitorsByHourParams) ([]ListDayVisitorsByHourRow, error)

branch_visitor_events.day is already the branch's local day (stamped by the till), so it's matched directly; only the hour needs the timezone.

func (*Queries) ListDeals added in v1.1.6

func (q *Queries) ListDeals(ctx context.Context) ([]ListDealsRow, error)

Every deal, with how many list rows and rules put it on products, so the page can say where a deal is used before it is changed or deleted.

func (*Queries) ListDealsForDiscountListSync added in v1.1.6

func (q *Queries) ListDealsForDiscountListSync(ctx context.Context, discountListID int64) ([]Deal, error)

The deals a list's rows name: they travel with the list, so the till always has the terms of every deal it can price.

func (*Queries) ListDeletableUnknownItemImages added in v1.1.1

func (q *Queries) ListDeletableUnknownItemImages(ctx context.Context, ids []int64) ([]ListDeletableUnknownItemImagesRow, error)

Of the given pictures, the ones that can go: not the picture of a unit still waiting to be matched on a sale that has arrived. A checkout whose sale never came (the till or kashi was down) is not waiting on anyone, so it can go.

func (*Queries) ListDiscountListBranchIDs

func (q *Queries) ListDiscountListBranchIDs(ctx context.Context, discountListID int64) ([]int64, error)

func (*Queries) ListDiscountListItems

func (q *Queries) ListDiscountListItems(ctx context.Context, discountListID int64) ([]DiscountListItem, error)

func (*Queries) ListDiscountListItemsForSync

func (q *Queries) ListDiscountListItemsForSync(ctx context.Context, discountListID int64) ([]ListDiscountListItemsForSyncRow, error)

func (*Queries) ListDiscountListItemsWithProduct

See ListPriceListItemsWithProduct: rows are variant-level, so the label needs the barcode and color/size to be identifiable. Option rows (000199) are listed alongside the plain ones; sale_option_id 0 / sale_option ” marks a plain row. Only a plain row can name a deal (000201).

func (*Queries) ListDiscountListOptionItemsForSync added in v1.1.6

func (q *Queries) ListDiscountListOptionItemsForSync(ctx context.Context, discountListID int64) ([]ListDiscountListOptionItemsForSyncRow, error)

Options travel by name, like colors and attributes: a till has no copy of kashi's sale_options ids.

func (*Queries) ListDiscountListRuleGroups added in v1.1.6

func (q *Queries) ListDiscountListRuleGroups(ctx context.Context, discountListID int64) ([]DiscountListRuleGroup, error)

A list's rule groups in order (000203).

func (*Queries) ListDiscountListRuleOptions added in v1.1.6

func (q *Queries) ListDiscountListRuleOptions(ctx context.Context, discountListID int64) ([]ListDiscountListRuleOptionsRow, error)

Option discounts of a list's rules; options travel by name, as on the tills.

func (*Queries) ListDiscountListRules added in v1.1.6

func (q *Queries) ListDiscountListRules(ctx context.Context, discountListID int64) ([]ListDiscountListRulesRow, error)

A list's rules in the order they run, with how many variants each one decides now (counted from the rows it wrote: a rule giving 0 writes none).

func (*Queries) ListDiscountLists

func (q *Queries) ListDiscountLists(ctx context.Context, arg ListDiscountListsParams) ([]DiscountList, error)

func (*Queries) ListDiscountListsForBranchSync

func (q *Queries) ListDiscountListsForBranchSync(ctx context.Context, arg ListDiscountListsForBranchSyncParams) ([]DiscountList, error)

See ListPriceListsForBranchSync -- same scoping and same reason for carrying is_active rather than filtering on it.

func (*Queries) ListDiscountListsRemovedFromBranch added in v1.1.7

Lists the branch was taken off since the till's cursor (000206), which it is sent as inactive so it drops its copy. Not the default list, which every branch keeps, nor one the branch is back on.

func (*Queries) ListDueEmailSchedules added in v1.1.0

func (q *Queries) ListDueEmailSchedules(ctx context.Context) ([]EmailSchedule, error)

func (*Queries) ListDueRecurringExpenses

func (q *Queries) ListDueRecurringExpenses(ctx context.Context, nextDueAt time.Time) ([]RecurringExpense, error)

func (*Queries) ListEmailReportInvoices added in v1.1.0

func (q *Queries) ListEmailReportInvoices(ctx context.Context, arg ListEmailReportInvoicesParams) ([]ListEmailReportInvoicesRow, error)

Every non-cancelled invoice on local days from_day..to_day, newest first (the order kashi-admin's CSV used), optionally one branch. Days are cut per branch timezone exactly like ListDayInvoices; the occurred_at range with a day of slack each side keeps idx_branch_invoices_occurred_at usable. Carries more than the default CSV needs so extra columns picked in Settings need no new query. ListEmailReportShiftInvoices returns the same columns for one shift. One grouped pass over the picked invoices' items and payments rather than a subquery per invoice.

func (*Queries) ListEmailReportRecipients added in v1.1.0

func (q *Queries) ListEmailReportRecipients(ctx context.Context) ([]ListEmailReportRecipientsRow, error)

Everyone a report went out to, most recently used first, for the send dialog's suggestions.

func (*Queries) ListEmailReportRegisters added in v1.1.0

func (q *Queries) ListEmailReportRegisters(ctx context.Context) ([]ListEmailReportRegistersRow, error)

The registers the send dialog can pick, by branch.

func (*Queries) ListEmailReportShiftInvoices added in v1.1.0

func (q *Queries) ListEmailReportShiftInvoices(ctx context.Context, shiftID int64) ([]ListEmailReportShiftInvoicesRow, error)

A closed shift's invoices, matched the way settlements match a till's shift: register plus the till's own shift id. One grouped pass over the picked invoices' items and payments rather than a subquery per invoice.

func (*Queries) ListEmailReportShifts added in v1.1.0

func (q *Queries) ListEmailReportShifts(ctx context.Context, arg ListEmailReportShiftsParams) ([]ListEmailReportShiftsRow, error)

Closed shifts to pick from in the send dialog: those counted on local days from_day..to_day, optionally one branch, newest first.

func (*Queries) ListEmailReports added in v1.1.0

func (q *Queries) ListEmailReports(ctx context.Context, arg ListEmailReportsParams) ([]EmailReport, error)

func (*Queries) ListEmailSchedules added in v1.1.0

func (q *Queries) ListEmailSchedules(ctx context.Context) ([]EmailSchedule, error)

func (*Queries) ListEmployees

func (q *Queries) ListEmployees(ctx context.Context, arg ListEmployeesParams) ([]Employee, error)

func (*Queries) ListEntries

func (q *Queries) ListEntries(ctx context.Context, arg ListEntriesParams) ([]Entry, error)

func (*Queries) ListExpenseCategories

func (q *Queries) ListExpenseCategories(ctx context.Context, scope sql.NullString) ([]ExpenseCategory, error)

func (*Queries) ListExpenseCategoriesUpdatedSince

func (q *Queries) ListExpenseCategoriesUpdatedSince(ctx context.Context, updatedAt time.Time) ([]ExpenseCategory, error)

Only branch-scoped categories are synced down to kashi-pos.

func (*Queries) ListExpenses

func (q *Queries) ListExpenses(ctx context.Context, arg ListExpensesParams) ([]Expense, error)

func (*Queries) ListGooglePlaceSnapshots added in v1.1.0

func (q *Queries) ListGooglePlaceSnapshots(ctx context.Context, arg ListGooglePlaceSnapshotsParams) ([]GooglePlaceSnapshot, error)

func (*Queries) ListGoogleReviews added in v1.1.0

func (q *Queries) ListGoogleReviews(ctx context.Context, arg ListGoogleReviewsParams) ([]GoogleReview, error)

Newest first, for the given places.

func (*Queries) ListHomeActivityResolutions added in v1.1.0

func (q *Queries) ListHomeActivityResolutions(ctx context.Context, arg ListHomeActivityResolutionsParams) ([]ListHomeActivityResolutionsRow, error)

Which of a page's rows of one kind are resolved, and by whom.

func (*Queries) ListIgnoredLowStockProducts

func (q *Queries) ListIgnoredLowStockProducts(ctx context.Context, arg ListIgnoredLowStockProductsParams) ([]ListIgnoredLowStockProductsRow, error)

Products that have opted out of low-stock alerting entirely, regardless of on-hand or threshold -- lets the muted list be reviewed and reversed.

func (*Queries) ListIncomingBranchTransfersUpdatedSince

func (q *Queries) ListIncomingBranchTransfersUpdatedSince(ctx context.Context, arg ListIncomingBranchTransfersUpdatedSinceParams) ([]Transfer, error)

The destination branch's own poll: transfers addressed to it, whoever sent them. Matched by to_inventory_id, not branch_id -- that column is always the sender's.

func (*Queries) ListInventories

func (q *Queries) ListInventories(ctx context.Context, arg ListInventoriesParams) ([]Inventory, error)

func (*Queries) ListInventoryStock

func (q *Queries) ListInventoryStock(ctx context.Context, arg ListInventoryStockParams) ([]ListInventoryStockRow, error)

func (*Queries) ListInvoiceDiscountBranchIDs added in v1.1.8

func (q *Queries) ListInvoiceDiscountBranchIDs(ctx context.Context) ([]InvoiceDiscountBranch, error)

func (*Queries) ListInvoiceDiscounts added in v1.1.8

func (q *Queries) ListInvoiceDiscounts(ctx context.Context) ([]InvoiceDiscount, error)

func (*Queries) ListInvoiceDiscountsForBranchSync added in v1.1.8

Every rule changed since the branch last asked, deleted ones included, with whether it applies to the branch: a rule that doesn't (deleted, switched off, or the branch taken off it) tells the till to drop it.

func (*Queries) ListInvoicePaymentsByInvoice

func (q *Queries) ListInvoicePaymentsByInvoice(ctx context.Context, invoiceID int64) ([]ListInvoicePaymentsByInvoiceRow, error)

func (*Queries) ListInvoiceProductsByInvoice

func (q *Queries) ListInvoiceProductsByInvoice(ctx context.Context, invoiceID int64) ([]ListInvoiceProductsByInvoiceRow, error)

func (*Queries) ListInvoiceTypes

func (q *Queries) ListInvoiceTypes(ctx context.Context) ([]InvoiceType, error)

func (*Queries) ListInvoices

func (q *Queries) ListInvoices(ctx context.Context, arg ListInvoicesParams) ([]Invoice, error)

func (*Queries) ListInvoicesPage

func (q *Queries) ListInvoicesPage(ctx context.Context, arg ListInvoicesPageParams) ([]Invoice, error)

func (*Queries) ListLatestAdditions

func (q *Queries) ListLatestAdditions(ctx context.Context, arg ListLatestAdditionsParams) ([]ListLatestAdditionsRow, error)

The home page's "Latest added" feed: the newest photos (expense, close-shift receipt), transfers, central expenses and purchases, merged newest first. Each include_* flag is the caller's view access to that section, so a kind the user can't open never appears.

ref_id is the record a row belongs to (the expense or shift a photo was attached to, or the transfer/expense/purchase itself), and for a branch photo branch_id + ref_day (the branch's local day) say which day page shows it, so the feed can open "the thing it was attached to". Keyset paging: the next page starts after the last row the feed has. ids come from five tables, so kind breaks a tie between two rows added at the same instant with the same id.

func (*Queries) ListLoanCategories

func (q *Queries) ListLoanCategories(ctx context.Context, scope sql.NullString) ([]LoanCategory, error)

func (*Queries) ListLoanCategoriesUpdatedSince

func (q *Queries) ListLoanCategoriesUpdatedSince(ctx context.Context, updatedAt time.Time) ([]LoanCategory, error)

Only branch-scoped categories are synced down to kashi-pos -- central ones are managed in kashi only.

func (*Queries) ListLoanImagesForLoan added in v1.1.0

func (q *Queries) ListLoanImagesForLoan(ctx context.Context, loanID int64) ([]LoanImage, error)

func (*Queries) ListLoanPayments

func (q *Queries) ListLoanPayments(ctx context.Context, arg ListLoanPaymentsParams) ([]LoanPayment, error)

sqlc.narg(loan_id) is nullable: NULL means "all loans". sqlc.narg(category_id) filters by the parent loan's lender-source category.

func (*Queries) ListLoans

func (q *Queries) ListLoans(ctx context.Context, arg ListLoansParams) ([]ListLoansRow, error)

sqlc.narg(branch_id)/sqlc.narg(origin) are nullable: NULL means "no filter", matching ListBranchExpenses' admin-filter convention. paid_amount is the running total of loan_payments against the loan; status is derived from it (never stored) -- 'paid' once payments cover the loan amount, 'partial' while some but not all is covered, else 'unpaid' -- or 'cancelled' once cancelled_at is stamped. sqlc.narg(status) filters on that same derived value.

func (*Queries) ListLowStockProducts

func (q *Queries) ListLowStockProducts(ctx context.Context, arg ListLowStockProductsParams) ([]ListLowStockProductsRow, error)

Low stock alerts. A product's on-hand is the sum of inventory_stock across every SKU (variant) and every inventory it's stocked in; its effective threshold is its own override if set, else the single global app_settings.default_low_stock_threshold. status narrows to one bucket: 'out_of_stock' (on_hand <= 0) or 'low_stock' (on_hand > 0, i.e. low but not yet out); NULL keeps both, matching the "at or below threshold" definition used everywhere else.

func (*Queries) ListPendingBranchAttendanceRequests added in v1.1.0

func (q *Queries) ListPendingBranchAttendanceRequests(ctx context.Context, branchID sql.NullInt64) ([]BranchAttendanceChange, error)

Requests a till filed ("acr-<id>-complaint") that no review has answered yet ("acr-<id>-review" from the same register -- each till numbers its own requests). These are the ones an admin can approve or reject from kashi.

func (*Queries) ListPendingBranchCommands

func (q *Queries) ListPendingBranchCommands(ctx context.Context, registerID int64) ([]BranchCommand, error)

func (*Queries) ListPriceListBranchIDs

func (q *Queries) ListPriceListBranchIDs(ctx context.Context, priceListID int64) ([]int64, error)

func (*Queries) ListPriceListItems

func (q *Queries) ListPriceListItems(ctx context.Context, priceListID int64) ([]PriceListItem, error)

func (*Queries) ListPriceListItemsForSync

func (q *Queries) ListPriceListItemsForSync(ctx context.Context, priceListID int64) ([]ListPriceListItemsForSyncRow, error)

Items of one list, keyed by the variant's uid -- the till's own row ids are a different number space, so nothing crosses the boundary by integer id.

func (*Queries) ListPriceListItemsWithProduct

func (q *Queries) ListPriceListItemsWithProduct(ctx context.Context, arg ListPriceListItemsWithProductParams) ([]ListPriceListItemsWithProductRow, error)

Rows are variant-level now, so the display label needs the variant's own barcode and its color/size -- a product code and name alone no longer identify which row a price belongs to.

func (*Queries) ListPriceLists

func (q *Queries) ListPriceLists(ctx context.Context, arg ListPriceListsParams) ([]PriceList, error)

func (*Queries) ListPriceListsForBranchSync

func (q *Queries) ListPriceListsForBranchSync(ctx context.Context, arg ListPriceListsForBranchSyncParams) ([]PriceList, error)

The only price lists a branch is allowed to know about: the default one (its fallback) and the one it is assigned, if any. Deliberately not every list -- a till has no business holding another branch's pricing.

is_active is carried rather than filtered on, because a list going inactive is exactly the event the till needs in order to drop its local copy; filter it out here and the till would keep pricing from a list kashi has retired.

func (*Queries) ListPriceListsRemovedFromBranch added in v1.1.7

See ListDiscountListsRemovedFromBranch.

func (*Queries) ListProductAttributes

func (q *Queries) ListProductAttributes(ctx context.Context, arg ListProductAttributesParams) ([]ProductsAttribute, error)

func (*Queries) ListProductCategories

func (q *Queries) ListProductCategories(ctx context.Context) ([]ProductCategory, error)

func (*Queries) ListProductRevenue

func (q *Queries) ListProductRevenue(ctx context.Context, arg ListProductRevenueParams) ([]ListProductRevenueRow, error)

Revenue per product from kashi's own admin sales invoices (invoice_products joined through sales_invoices, so returns don't count as revenue). Branch (POS) sales are deliberately excluded here -- see ListBranchProductRevenue below for those; branch_invoice_items itself still isn't linkable to a product (its branch_product_id has no FK), so the two sources stay separate rather than merged into one figure. category/subcategory/brand are the EAV attributes seeded in 000005_create_products_attributes_table (ids 0/1/2), joined once per attribute the same way ListProductVariantsForSync does.

func (*Queries) ListProductRevenueDaily

func (q *Queries) ListProductRevenueDaily(ctx context.Context, arg ListProductRevenueDailyParams) ([]ListProductRevenueDailyRow, error)

Same scope and filters as ListProductRevenue, rolled up by local calendar day instead of by product -- the trend line for the Product Revenues page.

func (*Queries) ListProductSaleOptionNames added in v1.1.6

func (q *Queries) ListProductSaleOptionNames(ctx context.Context, productID int64) ([]ListProductSaleOptionNamesRow, error)

func (*Queries) ListProductVariantIDsByUIDs

func (q *Queries) ListProductVariantIDsByUIDs(ctx context.Context, uids []uuid.UUID) ([]ListProductVariantIDsByUIDsRow, error)

func (*Queries) ListProductVariants

func (q *Queries) ListProductVariants(ctx context.Context, arg ListProductVariantsParams) ([]ListProductVariantsRow, error)

func (*Queries) ListProductVariantsByProduct

func (q *Queries) ListProductVariantsByProduct(ctx context.Context, productID int64) ([]ProductVariant, error)

func (*Queries) ListProductVariantsForSync

func (q *Queries) ListProductVariantsForSync(ctx context.Context, updatedAt time.Time) ([]ListProductVariantsForSyncRow, error)

Flattened for kashi-pos, which has no separate "product" row -- each variant carries everything a branch needs to create or update its own flat product row. Colors/sizes/attributes are resolved to their name here (not sent as ids) since kashi-pos matches everything by name, not by kashi's internal ids.

Price is deliberately absent: since 000094 a variant has no price of its own, it has an entry in a price list, and those sync down as their own entities (see the price_lists/discount_lists cases in branch_catchup.go). A till receiving no price here keeps whatever the lists last told it, which is what applySyncedProductVariant already does for an absent price.

Attribute ids (2=brand, 1=sub-category, 3=kind, 7=season, 6=year) match the fixed seed in 000005_create_products_attributes_table.up.sql. Editing a product's attributes doesn't currently bump product_variants.updated_at (no endpoint does that edit yet -- see api/product.go), so an attribute-only change wouldn't be picked up by this filter if one ever existed; today attributes are only ever set at creation time, in the same moment the variant's own updated_at is set, so this doesn't miss anything in practice yet.

func (*Queries) ListProductVariantsForSyncByUIDs

func (q *Queries) ListProductVariantsForSyncByUIDs(ctx context.Context, uids []uuid.UUID) ([]ListProductVariantsForSyncByUIDsRow, error)

Same flattened row as ListProductVariantsForSyncPaged, for the uids a till's completeness check found missing or stale.

func (*Queries) ListProductVariantsForSyncPaged

Keyset-paginated ListProductVariantsForSync -- same flattened row, same joins, ordered by (product_variants.updated_at, product_variants.id) for a stable page boundary during a branch's full catch-up.

func (*Queries) ListProductVariantsUpdatedSince

func (q *Queries) ListProductVariantsUpdatedSince(ctx context.Context, updatedAt time.Time) ([]ProductVariant, error)

func (*Queries) ListProducts

func (q *Queries) ListProducts(ctx context.Context, arg ListProductsParams) ([]ListProductsRow, error)

Search matches code/name/description (case-insensitive). Every filter is optional: empty search string, NULL narg, or empty attribute_value_ids array all mean "don't filter on this". attribute_value_ids is an AND -- the product must carry every selected value.

total_count is carried alongside each row via a window function so the caller doesn't need a second CountProducts round-trip that re-scans the same filtered set again.

func (*Queries) ListPurchaseItems

func (q *Queries) ListPurchaseItems(ctx context.Context, purchaseID sql.NullInt64) ([]ListPurchaseItemsRow, error)

func (*Queries) ListPurchases

func (q *Queries) ListPurchases(ctx context.Context, arg ListPurchasesParams) ([]ListPurchasesRow, error)

func (*Queries) ListRecurringExpenses

func (q *Queries) ListRecurringExpenses(ctx context.Context) ([]RecurringExpense, error)

func (*Queries) ListRegisterUpdateStatuses

func (q *Queries) ListRegisterUpdateStatuses(ctx context.Context) ([]ListRegisterUpdateStatusesRow, error)

func (*Queries) ListRolePermissions

func (q *Queries) ListRolePermissions(ctx context.Context) ([]RolePermission, error)

func (*Queries) ListRoles

func (q *Queries) ListRoles(ctx context.Context) ([]ListRolesRow, error)

func (*Queries) ListSaleMovementsForInvoiceVariant

Which batch(es) a specific sales-invoice line actually drew from, so a return of that line can replenish the same batches instead of going untracked. quantity is negative (sale); batch_id is null for the unattributed remainder, if the sale outran every tracked batch.

func (*Queries) ListSaleOptions added in v1.1.6

func (q *Queries) ListSaleOptions(ctx context.Context) ([]SaleOption, error)

func (*Queries) ListSalespersons

func (q *Queries) ListSalespersons(ctx context.Context, arg ListSalespersonsParams) ([]Salesperson, error)

func (*Queries) ListSalespersonsByCashbox

func (q *Queries) ListSalespersonsByCashbox(ctx context.Context, cashboxID sql.NullInt64) ([]Salesperson, error)

func (*Queries) ListSalespersonsForBranch

func (q *Queries) ListSalespersonsForBranch(ctx context.Context, branchID sql.NullInt64) ([]Salesperson, error)

func (*Queries) ListSalespersonsUpdatedSince

func (q *Queries) ListSalespersonsUpdatedSince(ctx context.Context, arg ListSalespersonsUpdatedSinceParams) ([]Salesperson, error)

func (*Queries) ListSecurityAlerts added in v1.1.0

func (q *Queries) ListSecurityAlerts(ctx context.Context, arg ListSecurityAlertsParams) ([]SecurityAlert, error)

Open alerts of the pinned (critical) kinds come first, so the page limit never pushes one off the list before someone resolves it.

func (*Queries) ListShifts

func (q *Queries) ListShifts(ctx context.Context, arg ListShiftsParams) ([]ListShiftsRow, error)

func (*Queries) ListSizes

func (q *Queries) ListSizes(ctx context.Context) ([]Size, error)

func (*Queries) ListSizesPage

func (q *Queries) ListSizesPage(ctx context.Context, arg ListSizesPageParams) ([]Size, error)

func (*Queries) ListSlowMovingProducts

func (q *Queries) ListSlowMovingProducts(ctx context.Context, arg ListSlowMovingProductsParams) ([]ListSlowMovingProductsRow, error)

--------------------------------------------------------------------------- Slow movers: money tied up in stock that isn't selling. Deliberately separate from the low-stock alerts (too little stock) -- this is the opposite problem, too much. A product qualifies when it's carrying stock (on_hand > 0) and either never sold in the last 90 days ("dead": put it on clearance) or would take unreasonably long to sell through at its current pace ("overstocked": more than 90 days on hand). ---------------------------------------------------------------------------

func (*Queries) ListStockCountItems

func (q *Queries) ListStockCountItems(ctx context.Context, stockCountID int64) ([]ListStockCountItemsRow, error)

func (*Queries) ListStockCounts

func (q *Queries) ListStockCounts(ctx context.Context, arg ListStockCountsParams) ([]ListStockCountsRow, error)

func (*Queries) ListStockHealthByInventory

func (q *Queries) ListStockHealthByInventory(ctx context.Context, arg ListStockHealthByInventoryParams) ([]ListStockHealthByInventoryRow, error)

func (*Queries) ListStockMovements

func (q *Queries) ListStockMovements(ctx context.Context, arg ListStockMovementsParams) ([]ListStockMovementsRow, error)

func (*Queries) ListSuppliers

func (q *Queries) ListSuppliers(ctx context.Context, arg ListSuppliersParams) ([]Supplier, error)

TOOD: add UpdateSupplier

func (*Queries) ListTransferAttachments added in v1.1.0

func (q *Queries) ListTransferAttachments(ctx context.Context, arg ListTransferAttachmentsParams) ([]ListTransferAttachmentsRow, error)

Storage page feed: transfers that have a photo, newest first. The photo itself is served by GET /transfers/:id/attachment.

func (*Queries) ListTransferItems

func (q *Queries) ListTransferItems(ctx context.Context, transferID int64) ([]ListTransferItemsRow, error)

func (*Queries) ListTransfers

func (q *Queries) ListTransfers(ctx context.Context, arg ListTransfersParams) ([]ListTransfersRow, error)

func (*Queries) ListUnknownItemImages added in v1.1.1

func (q *Queries) ListUnknownItemImages(ctx context.Context, arg ListUnknownItemImagesParams) ([]ListUnknownItemImagesRow, error)

Every stored unknown-item picture, newest first, for the Attachments page.

func (*Queries) ListUnknownItemSlotsForSession added in v1.1.1

func (q *Queries) ListUnknownItemSlotsForSession(ctx context.Context, sessionID int64) ([]UnknownItemSlot, error)

func (*Queries) ListUnknownItems added in v1.1.1

func (q *Queries) ListUnknownItems(ctx context.Context, arg ListUnknownItemsParams) ([]ListUnknownItemsRow, error)

Pictured units of sold invoices, pending or resolved, newest first.

func (*Queries) ListUnmatchedDiscountEntries added in v1.1.1

func (q *Queries) ListUnmatchedDiscountEntries(ctx context.Context, entries []string) ([]string, error)

The entries that name no variant barcode and no product code.

func (*Queries) ListUnresolvedUrgentHomeActivities added in v1.1.0

func (q *Queries) ListUnresolvedUrgentHomeActivities(ctx context.Context) ([]ListUnresolvedUrgentHomeActivitiesRow, error)

The urgent Recent activity rows nobody has resolved yet, pinned above the feed: a shift closed short (negative USD variance) -- the rows the feed tints red. Same columns as HomeActivityFeed, so the feed draws them with the same row, newest received first, like the feed.

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)

func (*Queries) ListVariantSyncIDs

func (q *Queries) ListVariantSyncIDs(ctx context.Context, arg ListVariantSyncIDsParams) ([]ListVariantSyncIDsRow, error)

func (*Queries) ListVariantsForBarcodes

func (q *Queries) ListVariantsForBarcodes(ctx context.Context, arg ListVariantsForBarcodesParams) ([]ListVariantsForBarcodesRow, error)

func (*Queries) ListVariantsForDiscountEntry added in v1.1.6

func (q *Queries) ListVariantsForDiscountEntry(ctx context.Context, entry string) ([]ListVariantsForDiscountEntryRow, error)

What one typed or scanned entry names, matched like BulkSetDiscountListItems: a barcode names its variant, a code all of its product's variants.

func (*Queries) ListVisitorIPs added in v1.1.0

func (q *Queries) ListVisitorIPs(ctx context.Context, arg ListVisitorIPsParams) ([]VisitorIp, error)

Most recently seen first. search matches the IP, place, network, user or branch; country narrows to one country code.

func (*Queries) ListWaitingUnknownItems added in v1.1.1

func (q *Queries) ListWaitingUnknownItems(ctx context.Context) ([]ListWaitingUnknownItemsRow, error)

Every unit of the checkouts still in progress that are missing at least one picture or pass, for the "Waiting" tab: pictured units come along so the manager sees what has already been taken. Cashiers who asked for help first.

func (*Queries) ListWhatsAppChatMessages added in v1.1.1

func (q *Queries) ListWhatsAppChatMessages(ctx context.Context, arg ListWhatsAppChatMessagesParams) ([]ListWhatsAppChatMessagesRow, error)

Newest first, a page at a time: before_id 0 is the latest page.

func (*Queries) ListWhatsAppChats added in v1.1.1

func (q *Queries) ListWhatsAppChats(ctx context.Context, arg ListWhatsAppChatsParams) ([]ListWhatsAppChatsRow, error)

One row per customer phone, the most recently active first.

func (*Queries) ListWhatsAppMessageReplies added in v1.1.0

func (q *Queries) ListWhatsAppMessageReplies(ctx context.Context, id int64) ([]ListWhatsAppMessageRepliesRow, error)

What the client sent back to one message: after its poll (the bridge) or answering it (Meta's webhook), oldest first. id and media_type: a bridge reply's media (GET /whatsapp/poll_replies/:id/media).

func (*Queries) ListWhatsAppMessages added in v1.1.0

func (q *Queries) ListWhatsAppMessages(ctx context.Context, arg ListWhatsAppMessagesParams) ([]ListWhatsAppMessagesRow, error)

Newest first. branch_id 0 = every branch, status ” = any; search matches the client's name or phone, the invoice code or the rule.

func (*Queries) ListWhatsAppNumbers added in v1.1.0

func (q *Queries) ListWhatsAppNumbers(ctx context.Context) ([]WhatsappNumber, error)

func (*Queries) ListWhatsAppReplies added in v1.1.0

func (q *Queries) ListWhatsAppReplies(ctx context.Context, arg ListWhatsAppRepliesParams) ([]ListWhatsAppRepliesRow, error)

Newest first. A reply not linked to one of our messages only shows under every branch.

func (*Queries) ListWhatsAppRules added in v1.1.0

func (q *Queries) ListWhatsAppRules(ctx context.Context) ([]WhatsappRule, error)

The WhatsApp page: post-sale message rules and the message log (api/whatsapp_rules.go).

func (*Queries) LowPollRatings added in v1.1.0

func (q *Queries) LowPollRatings(ctx context.Context, arg LowPollRatingsParams) ([]LowPollRatingsRow, error)

Clients who answered 1 or 2 stars, newest first: the ones to call back.

func (*Queries) LoyaltyMonthlyJoins added in v1.1.6

func (q *Queries) LoyaltyMonthlyJoins(ctx context.Context, clientType sql.NullString) ([]LoyaltyMonthlyJoinsRow, error)

Loyalty page: new clients per calendar month (UTC) over the last 12 months.

func (*Queries) LoyaltyRisingClients added in v1.1.6

func (q *Queries) LoyaltyRisingClients(ctx context.Context, arg LoyaltyRisingClientsParams) ([]LoyaltyRisingClientsRow, error)

Loyalty page, "close to leveling up": the clients (up to 25) within 30% of the next tier's minimum, closest first. tier_mins as in LoyaltyTierStats.

func (*Queries) LoyaltyTierStats added in v1.1.6

func (q *Queries) LoyaltyTierStats(ctx context.Context, arg LoyaltyTierStatsParams) ([]LoyaltyTierStatsRow, error)

Loyalty page: one row per tier that has members. tier_mins is the tiers' minimum spends in cents, ascending; a client's tier index is the highest minimum their lifetime spend clears (the lowest tier if none), counted from 0 at the entry tier -- the same rule as the page's tierFor. Lifetime spend (gross_spent, before the On Account deduction) and points come from the client_spend cache; the period figures (revenue, active members) cover [date_from, date_to), either bound optional, and are computed live from just the invoices inside the window. With no bound the period is all time, so the cached figures are used as is.

Same two sources and sign conventions as RefreshClientSpend: central invoices (sales positive, returns negative) plus non-cancelled branch invoices of reported-on branches/registers.

func (*Queries) MarkBranchAttendanceEventRemoved added in v1.1.0

func (q *Queries) MarkBranchAttendanceEventRemoved(ctx context.Context, arg MarkBranchAttendanceEventRemovedParams) error

The original punch of an approved replace/delete on the till. Kept, not deleted, so the audit trail shows what was there and who took it away.

func (*Queries) MarkBranchExpenseUploadTokenUsed

func (q *Queries) MarkBranchExpenseUploadTokenUsed(ctx context.Context, id int64) error

func (*Queries) MarkBranchInvoicesCancelled added in v1.1.0

func (q *Queries) MarkBranchInvoicesCancelled(ctx context.Context, arg MarkBranchInvoicesCancelledParams) error

A till's cancellation return names the sale it cancels (related_client_ref); both rows get the mark. COALESCE keeps the first stamp on a replayed push.

func (*Queries) MarkBranchShiftUploadTokenUsed

func (q *Queries) MarkBranchShiftUploadTokenUsed(ctx context.Context, id int64) error

func (*Queries) MarkBranchTransferUploadTokenUsed

func (q *Queries) MarkBranchTransferUploadTokenUsed(ctx context.Context, id int64) error

func (*Queries) MarkLoanUploadTokenUsed added in v1.1.0

func (q *Queries) MarkLoanUploadTokenUsed(ctx context.Context, id int64) error

func (*Queries) MarkUnknownItemSlotResolved added in v1.1.1

func (q *Queries) MarkUnknownItemSlotResolved(ctx context.Context, arg MarkUnknownItemSlotResolvedParams) error

func (*Queries) MarkWhatsAppReviewClicked added in v1.1.0

func (q *Queries) MarkWhatsAppReviewClicked(ctx context.Context, id int64) error

func (*Queries) PollRatingTotals added in v1.1.0

func (q *Queries) PollRatingTotals(ctx context.Context, arg PollRatingTotalsParams) (PollRatingTotalsRow, error)

The WhatsApp rating poll over the range: polls sent, answers, and how many of each star.

func (*Queries) PollRatingsByBranch added in v1.1.0

func (q *Queries) PollRatingsByBranch(ctx context.Context, arg PollRatingsByBranchParams) ([]PollRatingsByBranchRow, error)

func (*Queries) PollRatingsByDay added in v1.1.0

func (q *Queries) PollRatingsByDay(ctx context.Context, arg PollRatingsByDayParams) ([]PollRatingsByDayRow, error)

func (*Queries) PollReplies added in v1.1.0

func (q *Queries) PollReplies(ctx context.Context, arg PollRepliesParams) ([]PollRepliesRow, error)

What clients wrote back after the rating poll, newest first, with their answer: why it wasn't great, and what they looked for and didn't find.

func (*Queries) ProductBarcodesPresent

func (q *Queries) ProductBarcodesPresent(ctx context.Context, dollar_1 []string) ([]string, error)

func (*Queries) ReceiveInventoryStock

func (q *Queries) ReceiveInventoryStock(ctx context.Context, arg ReceiveInventoryStockParams) (InventoryStock, error)

Apply an inbound quantity delta and roll the per-location moving-average cost forward. When existing on-hand is <= 0 the average is just reset to the incoming cost (no meaningful prior average to blend).

func (*Queries) RecordEmailScheduleRun added in v1.1.0

func (q *Queries) RecordEmailScheduleRun(ctx context.Context, arg RecordEmailScheduleRunParams) error

func (*Queries) RecordSecurityAlert added in v1.1.0

func (q *Queries) RecordSecurityAlert(ctx context.Context, arg RecordSecurityAlertParams) error

Opens an alert, or bumps the open one of the same kind for the same IP seen within the last hour.

func (*Queries) RecordWhatsAppPollVote added in v1.1.0

func (q *Queries) RecordWhatsAppPollVote(ctx context.Context, arg RecordWhatsAppPollVoteParams) (RecordWhatsAppPollVoteRow, error)

A client's answer to the rating poll; a NULL rating is a vote taken back.

func (*Queries) RedeemCoupon

func (q *Queries) RedeemCoupon(ctx context.Context, arg RedeemCouponParams) (Coupon, error)

Idempotent: a retried invoice post that already redeemed this code just returns the row unchanged rather than erroring (matches CreateBranchInvoice's own idempotent-retry shape). Only actually moves an 'active' coupon to 'redeemed' -- an inactive/already-redeemed code is left alone so a stale retry never resurrects it.

func (*Queries) RefreshClientSpend added in v1.1.6

func (q *Queries) RefreshClientSpend(ctx context.Context) error

Rebuilds client_spend for every client from all invoices. Same two sources and sign conventions as ListClientsBySpending (see the comment there): central invoices (sales positive, returns negative; grand_total is always a positive magnitude) and non-cancelled branch invoices of reported-on branches/registers, whose grand_total already carries its sign. total_spent drops what was paid "On Account"; gross_spent keeps it. Line items are pre-aggregated per invoice so they can't multiply grand_total.

func (*Queries) RenameRole

func (q *Queries) RenameRole(ctx context.Context, arg RenameRoleParams) error

func (*Queries) ReplaceBranchExpenseImageFile added in v1.1.0

func (q *Queries) ReplaceBranchExpenseImageFile(ctx context.Context, arg ReplaceBranchExpenseImageFileParams) (BranchExpenseImage, error)

Points the row at a replacement photo (api/photo_replace.go); the new photo starts upright.

func (*Queries) ReplaceBranchShiftReceiptImageFile added in v1.1.0

func (q *Queries) ReplaceBranchShiftReceiptImageFile(ctx context.Context, arg ReplaceBranchShiftReceiptImageFileParams) (BranchShiftReceiptImage, error)

Same as ReplaceBranchExpenseImageFile.

func (*Queries) RepointBranchInvoicesClientUID

func (q *Queries) RepointBranchInvoicesClientUID(ctx context.Context, arg RepointBranchInvoicesClientUIDParams) error

A till's client turned out to be an existing central client (same phone): invoices the till already sent under its own uid now point at the canonical one.

func (*Queries) ReportBranchSales added in v1.1.0

func (q *Queries) ReportBranchSales(ctx context.Context, arg ReportBranchSalesParams) ([]ReportBranchSalesRow, error)

Sales per branch; sales entered in kashi come back with branch_id 0 and an empty name.

func (*Queries) ReportCategorySales added in v1.1.0

func (q *Queries) ReportCategorySales(ctx context.Context, arg ReportCategorySalesParams) ([]ReportCategorySalesRow, error)

Revenue per product category. Lines without a product or whose product has no category come back with an empty name.

func (*Queries) ReportCostOfGoods added in v1.1.0

func (q *Queries) ReportCostOfGoods(ctx context.Context, arg ReportCostOfGoodsParams) (ReportCostOfGoodsRow, error)

Sales reports over report_sale_invoices / report_sale_lines (migration 000134): the Dashboard's cost of goods and the Sales Dashboard (api/sales_dashboard.go). Ranges are half-open [date_from, date_to), days are Beirut calendar days (businessZone in api/business_zone.go) like the rest of the dashboard. Cost of goods sold for the Dashboard, scoped like its other figures: till sales (optionally one branch) and/or sales entered in kashi. Only lines with a known cost count; costed_revenue is what those lines sold for, so the caller can say how much of revenue the cost covers.

func (*Queries) ReportCostOfGoodsSeries added in v1.1.0

func (q *Queries) ReportCostOfGoodsSeries(ctx context.Context, arg ReportCostOfGoodsSeriesParams) ([]ReportCostOfGoodsSeriesRow, error)

ReportCostOfGoods per day.

func (*Queries) ReportDailyCosted added in v1.1.0

func (q *Queries) ReportDailyCosted(ctx context.Context, arg ReportDailyCostedParams) ([]ReportDailyCostedRow, error)

Per day, what lines with a known cost sold for and what they cost -- the Sales Dashboard's profit is the difference.

func (*Queries) ReportDailySales added in v1.1.0

func (q *Queries) ReportDailySales(ctx context.Context, arg ReportDailySalesParams) ([]ReportDailySalesRow, error)

Sales (net of returns) per day.

func (*Queries) ReportHourlySales added in v1.1.0

func (q *Queries) ReportHourlySales(ctx context.Context, arg ReportHourlySalesParams) ([]ReportHourlySalesRow, error)

Sales by day of week (0 = Sunday) and hour, in each branch's own time zone (Beirut for sales entered in kashi), for the Financials heatmap.

func (*Queries) ReportInventoryValue added in v1.1.0

func (q *Queries) ReportInventoryValue(ctx context.Context) (int64, error)

What the stock on hand cost, across every inventory: each stock row at its own average cost, or the variant's when the row has none (stock counts set only the variant's).

func (*Queries) ReportPaymentMethods added in v1.1.0

func (q *Queries) ReportPaymentMethods(ctx context.Context, arg ReportPaymentMethodsParams) ([]ReportPaymentMethodsRow, error)

What sales were paid with: the till's payment accounts by name ("Cash $$", "Visa", ...) plus kashi's own cashbox accounts, merged by name.

func (*Queries) ReportReceivables added in v1.1.0

func (q *Queries) ReportReceivables(ctx context.Context) (int64, error)

What customers still owe on till sales put "On Account". Settling a sale later rewrites its payment lines (createBranchInvoiceSettlement), so the On Account lines left are exactly what's outstanding.

func (*Queries) ReportSaleYears added in v1.1.0

func (q *Queries) ReportSaleYears(ctx context.Context) ([]int32, error)

Every year that has a sale, newest first, for the Sales Dashboard's year picker.

func (*Queries) ReportTargetsInRange added in v1.1.0

func (q *Queries) ReportTargetsInRange(ctx context.Context, arg ReportTargetsInRangeParams) ([]ReportTargetsInRangeRow, error)

Active branch sales targets overlapping [date_from, date_to), for the Sales Analysis page, which spreads each one over its days to get the target for any month (api/sales_analysis.go). date_to is inclusive.

func (*Queries) ReportTopProducts added in v1.1.0

func (q *Queries) ReportTopProducts(ctx context.Context, arg ReportTopProductsParams) ([]ReportTopProductsRow, error)

Best-selling products by revenue. Till lines whose product never resolved to a kashi variant have no product and are left out.

func (*Queries) RequestUnknownItemHelp added in v1.1.1

func (q *Queries) RequestUnknownItemHelp(ctx context.Context, arg RequestUnknownItemHelpParams) error

func (*Queries) ResolveBranchSyncConflict

func (q *Queries) ResolveBranchSyncConflict(ctx context.Context, arg ResolveBranchSyncConflictParams) (BranchSyncConflict, error)

func (*Queries) ResolveHomeActivity added in v1.1.0

func (q *Queries) ResolveHomeActivity(ctx context.Context, arg ResolveHomeActivityParams) error

Idempotent: resolving a row twice keeps who resolved it first.

func (*Queries) ResolveVariantDiscount

func (q *Queries) ResolveVariantDiscount(ctx context.Context, arg ResolveVariantDiscountParams) (int16, error)

Mirrors ResolveVariantPrice: a branch assigned a discount list is discounted from it, everyone else from the default list. Unlike price, no row here means no discount (i.e. zero), not "unsellable" -- a product with no discount is a product sold at full price.

func (*Queries) ResolveVariantDiscounts

func (q *Queries) ResolveVariantDiscounts(ctx context.Context, arg ResolveVariantDiscountsParams) ([]ResolveVariantDiscountsRow, error)

func (*Queries) ResolveVariantPrice

func (q *Queries) ResolveVariantPrice(ctx context.Context, arg ResolveVariantPriceParams) (int64, error)

The one place that answers "what does this variant cost at this branch". A branch assigned a list via price_list_branches is priced from it; every other branch, and any variant the assigned list doesn't mention, falls back to the default list. No row means no price, which callers must treat as "not sellable" rather than as zero.

func (*Queries) ResolveVariantPrices

func (q *Queries) ResolveVariantPrices(ctx context.Context, arg ResolveVariantPricesParams) ([]ResolveVariantPricesRow, error)

Batch form of ResolveVariantPrice, for listings and the branch sync payload, so pricing N variants costs one query rather than N. DISTINCT ON keeps the branch list's row ahead of the default list's for the same variant.

func (*Queries) ReviewClicksTotal added in v1.1.0

func (q *Queries) ReviewClicksTotal(ctx context.Context, arg ReviewClicksTotalParams) (int64, error)

Every open of a review link in the range, the plain link included.

func (*Queries) ReviewFunnel added in v1.1.0

func (q *Queries) ReviewFunnel(ctx context.Context, arg ReviewFunnelParams) (ReviewFunnelRow, error)

Messages sent in the range and how far they got: delivered/read come from Meta's webhook, clicked from the review link.

func (*Queries) ReviewFunnelByBranch added in v1.1.0

func (q *Queries) ReviewFunnelByBranch(ctx context.Context, arg ReviewFunnelByBranchParams) ([]ReviewFunnelByBranchRow, error)

func (*Queries) ReviewFunnelByDay added in v1.1.0

func (q *Queries) ReviewFunnelByDay(ctx context.Context, arg ReviewFunnelByDayParams) ([]ReviewFunnelByDayRow, error)

Per Beirut day: messages sent with a link, and link opens.

func (*Queries) RotateBranchExpenseImage added in v1.1.0

func (q *Queries) RotateBranchExpenseImage(ctx context.Context, arg RotateBranchExpenseImageParams) (int16, error)

Turns the photo by delta degrees (a multiple of 90, either sign) on top of its saved rotation.

func (*Queries) RotateBranchShiftReceiptImage added in v1.1.0

func (q *Queries) RotateBranchShiftReceiptImage(ctx context.Context, arg RotateBranchShiftReceiptImageParams) (int16, error)

Same as RotateBranchExpenseImage.

func (*Queries) RotateTransferAttachment added in v1.1.0

func (q *Queries) RotateTransferAttachment(ctx context.Context, arg RotateTransferAttachmentParams) (int16, error)

Turns the photo by delta degrees (a multiple of 90, either sign) on top of its saved rotation. Not a change to the transfer itself, so updated_at is left alone.

func (*Queries) SalespersonPerformanceInvoices added in v1.1.0

Sales in [from_at, to_at), not cancelled. A linked invoice shows its salesperson's current name, so a renamed salesperson stays one person.

func (*Queries) SalespersonPerformanceItems added in v1.1.0

func (q *Queries) SalespersonPerformanceItems(ctx context.Context, arg SalespersonPerformanceItemsParams) ([]BranchInvoiceItem, error)

func (*Queries) SearchVariantsForUnknownItems added in v1.1.1

func (q *Queries) SearchVariantsForUnknownItems(ctx context.Context, search string) ([]SearchVariantsForUnknownItemsRow, error)

The picker an admin matches a pictured item with: active variants whose product name, code or barcode contains the text.

func (*Queries) SearchWhatsAppClients added in v1.1.0

func (q *Queries) SearchWhatsAppClients(ctx context.Context, search string) ([]SearchWhatsAppClientsRow, error)

Clients with a phone, for picking in a rule.

func (*Queries) SeedProductVariantsCostByCode added in v1.1.3

func (q *Queries) SeedProductVariantsCostByCode(ctx context.Context, arg SeedProductVariantsCostByCodeParams) (int64, error)

Fills in avg_cost for every variant of one product, but only where it is still at the 0 default -- i.e. never seeded by an actual stock receipt (UpdateProductVariantAvgCost above). Used to backfill a starting cost basis from an external cost list (cmd/import_costs-style one-off); it never overwrites a real moving-average cost built from real receipts.

func (*Queries) SetAssetCost

func (q *Queries) SetAssetCost(ctx context.Context, arg SetAssetCostParams) error

func (*Queries) SetBarcodeLabelDesign added in v1.1.2

func (q *Queries) SetBarcodeLabelDesign(ctx context.Context, barcodeLabelDesign json.RawMessage) (AppSetting, error)

func (*Queries) SetBranchActive

func (q *Queries) SetBranchActive(ctx context.Context, arg SetBranchActiveParams) error

func (*Queries) SetBranchExpenseCategory added in v1.1.1

func (q *Queries) SetBranchExpenseCategory(ctx context.Context, arg SetBranchExpenseCategoryParams) (BranchExpense, error)

A till re-categorising one of its own expenses (kashi-pos expense detail). NULL category_id is "no category".

func (*Queries) SetBranchExpenseFromCentral added in v1.1.3

func (q *Queries) SetBranchExpenseFromCentral(ctx context.Context, arg SetBranchExpenseFromCentralParams) (BranchExpense, error)

A till marking one of its own expenses as paid by central, or not.

func (*Queries) SetBranchExpenseFromCentralByID added in v1.1.3

func (q *Queries) SetBranchExpenseFromCentralByID(ctx context.Context, arg SetBranchExpenseFromCentralByIDParams) (BranchExpense, error)

The same, from kashi's expenses page.

func (*Queries) SetBranchHiddenFromReports

func (q *Queries) SetBranchHiddenFromReports(ctx context.Context, arg SetBranchHiddenFromReportsParams) error

func (*Queries) SetBranchInventory

func (q *Queries) SetBranchInventory(ctx context.Context, arg SetBranchInventoryParams) error

func (*Queries) SetBranchInvoiceDiscount added in v1.1.8

func (q *Queries) SetBranchInvoiceDiscount(ctx context.Context, arg SetBranchInvoiceDiscountParams) error

func (*Queries) SetBranchInvoiceItemDiscount added in v1.1.8

func (q *Queries) SetBranchInvoiceItemDiscount(ctx context.Context, arg SetBranchInvoiceItemDiscountParams) error

func (*Queries) SetBranchInvoiceItemResolved added in v1.1.1

func (q *Queries) SetBranchInvoiceItemResolved(ctx context.Context, arg SetBranchInvoiceItemResolvedParams) error

func (*Queries) SetBranchInvoiceSalesperson added in v1.1.0

func (q *Queries) SetBranchInvoiceSalesperson(ctx context.Context, arg SetBranchInvoiceSalespersonParams) (int64, error)

Salesperson Performance (api/salesperson_performance.go) and the tills' one-time report of who made their past sales. Only a salesperson of the invoice's own branch is accepted.

func (*Queries) SetBranchLoanCategory added in v1.1.1

func (q *Queries) SetBranchLoanCategory(ctx context.Context, arg SetBranchLoanCategoryParams) (Loan, error)

A till re-categorising one of its own loans (kashi-pos loan detail). Only the category: the rest of a branch loan stays as reported.

func (*Queries) SetBranchPlaceID added in v1.1.0

func (q *Queries) SetBranchPlaceID(ctx context.Context, arg SetBranchPlaceIDParams) error

func (*Queries) SetBranchRegisterActive

func (q *Queries) SetBranchRegisterActive(ctx context.Context, arg SetBranchRegisterActiveParams) error

func (*Queries) SetBranchRegisterHiddenFromReports

func (q *Queries) SetBranchRegisterHiddenFromReports(ctx context.Context, arg SetBranchRegisterHiddenFromReportsParams) error

func (*Queries) SetBranchRegisterQuickAccessMode

func (q *Queries) SetBranchRegisterQuickAccessMode(ctx context.Context, arg SetBranchRegisterQuickAccessModeParams) (int64, error)

Later flip wins: a flip only applies if it's newer than the one stored, so a till's offline flip that arrives late can't undo a more recent one made in kashi (or vice versa). 0 rows = this flip was older, ignored.

func (*Queries) SetBranchRegisterReportedSettings

func (q *Queries) SetBranchRegisterReportedSettings(ctx context.Context, arg SetBranchRegisterReportedSettingsParams) error

func (*Queries) SetBranchSettingsManagedLocally

func (q *Queries) SetBranchSettingsManagedLocally(ctx context.Context, arg SetBranchSettingsManagedLocallyParams) (BranchSetting, error)

managed_locally is admin-owned, not branch-reported: a branch's settings push (UpsertBranchSettings) never touches it. Only the admin UI sets it.

func (*Queries) SetBranchTargetActive

func (q *Queries) SetBranchTargetActive(ctx context.Context, arg SetBranchTargetActiveParams) (BranchTarget, error)

The sync-facing "delete" -- see 000046_branch_target_soft_delete.up.sql for why this flips a flag instead of removing the row.

func (*Queries) SetBranchTargetSeriesActive

func (q *Queries) SetBranchTargetSeriesActive(ctx context.Context, arg SetBranchTargetSeriesActiveParams) (BranchTargetSeries, error)

func (*Queries) SetBranchUserActive

func (q *Queries) SetBranchUserActive(ctx context.Context, arg SetBranchUserActiveParams) (BranchUser, error)

func (*Queries) SetBranchWhatsAppNumber added in v1.1.0

func (q *Queries) SetBranchWhatsAppNumber(ctx context.Context, arg SetBranchWhatsAppNumberParams) error

func (*Queries) SetCashboxAccountActive

func (q *Queries) SetCashboxAccountActive(ctx context.Context, arg SetCashboxAccountActiveParams) (CashboxAccount, error)

func (*Queries) SetClientActive

func (q *Queries) SetClientActive(ctx context.Context, arg SetClientActiveParams) error

func (*Queries) SetClientBranchIfNull added in v1.1.1

func (q *Queries) SetClientBranchIfNull(ctx context.Context, arg SetClientBranchIfNullParams) error

A client's home branch is the first branch they bought from, so a branch invoice only sets it when none is set yet. The client is resolved by either identity a till has used (client_uid, else the register's local client id), as in ListClientsForExport. updated_at is left alone: the column isn't synced to tills, so this mustn't make them re-pull the client.

func (*Queries) SetDefaultLowStockThreshold

func (q *Queries) SetDefaultLowStockThreshold(ctx context.Context, defaultLowStockThreshold int64) (AppSetting, error)

func (*Queries) SetDefaultWhatsAppNumber added in v1.1.0

func (q *Queries) SetDefaultWhatsAppNumber(ctx context.Context, id int64) error

func (*Queries) SetEmailResendAPIKey added in v1.1.0

func (q *Queries) SetEmailResendAPIKey(ctx context.Context, emailResendApiKey string) error

func (*Queries) SetEmailSettings added in v1.1.0

func (q *Queries) SetEmailSettings(ctx context.Context, arg SetEmailSettingsParams) error

func (*Queries) SetProductAutofillRules

func (q *Queries) SetProductAutofillRules(ctx context.Context, arg SetProductAutofillRulesParams) (AppSetting, error)

func (*Queries) SetProductCategory

func (q *Queries) SetProductCategory(ctx context.Context, arg SetProductCategoryParams) error

func (*Queries) SetProductLowStockAlertsEnabled

func (q *Queries) SetProductLowStockAlertsEnabled(ctx context.Context, arg SetProductLowStockAlertsEnabledParams) error

func (*Queries) SetProductVariantActive

func (q *Queries) SetProductVariantActive(ctx context.Context, arg SetProductVariantActiveParams) error

func (*Queries) SetPurchaseStatus

func (q *Queries) SetPurchaseStatus(ctx context.Context, arg SetPurchaseStatusParams) (Purchase, error)

func (*Queries) SetPurchaseTotals

func (q *Queries) SetPurchaseTotals(ctx context.Context, arg SetPurchaseTotalsParams) error

func (*Queries) SetRecurringExpenseActive

func (q *Queries) SetRecurringExpenseActive(ctx context.Context, arg SetRecurringExpenseActiveParams) (RecurringExpense, error)

func (*Queries) SetRegisterUpdateStatus

func (q *Queries) SetRegisterUpdateStatus(ctx context.Context, arg SetRegisterUpdateStatusParams) error

func (*Queries) SetRegistersTargetRelease

func (q *Queries) SetRegistersTargetRelease(ctx context.Context, arg SetRegistersTargetReleaseParams) error

func (*Queries) SetReviewSettings added in v1.1.0

func (q *Queries) SetReviewSettings(ctx context.Context, arg SetReviewSettingsParams) error

func (*Queries) SetSalespersonActive

func (q *Queries) SetSalespersonActive(ctx context.Context, arg SetSalespersonActiveParams) (Salesperson, error)

func (*Queries) SetSalespersonAttendanceID added in v1.1.0

func (q *Queries) SetSalespersonAttendanceID(ctx context.Context, arg SetSalespersonAttendanceIDParams) (Salesperson, error)

Set from kashi: from now on the till takes this value (see 000127).

func (*Queries) SetSalespersonColor

func (q *Queries) SetSalespersonColor(ctx context.Context, arg SetSalespersonColorParams) (Salesperson, error)

func (*Queries) SetSalespersonIsSalesperson added in v1.1.0

func (q *Queries) SetSalespersonIsSalesperson(ctx context.Context, arg SetSalespersonIsSalespersonParams) (Salesperson, error)

Whether the till offers this person at checkout; attendance applies to everyone on the roster either way.

func (*Queries) SetStockCountNote

func (q *Queries) SetStockCountNote(ctx context.Context, arg SetStockCountNoteParams) error

func (*Queries) SetStockCountStatus

func (q *Queries) SetStockCountStatus(ctx context.Context, arg SetStockCountStatusParams) (StockCount, error)

func (*Queries) SetTransferAttachmentPath

func (q *Queries) SetTransferAttachmentPath(ctx context.Context, arg SetTransferAttachmentPathParams) error

A new photo starts upright, whatever the previous one was turned to.

func (*Queries) SetTransferConfirmed

func (q *Queries) SetTransferConfirmed(ctx context.Context, arg SetTransferConfirmedParams) (Transfer, error)

func (*Queries) SetTransferItemReceivedQuantity

func (q *Queries) SetTransferItemReceivedQuantity(ctx context.Context, arg SetTransferItemReceivedQuantityParams) (TransferItem, error)

The admin's own edit, keyed by transfer_item id directly (unlike the branch's own confirm, which only ever knows an item by variant) -- lets kashi correct a destination's count, or fill one in before it ever arrives, from the transfer detail dialog.

func (*Queries) SetTransferItemReceivedQuantityByVariant

func (q *Queries) SetTransferItemReceivedQuantityByVariant(ctx context.Context, arg SetTransferItemReceivedQuantityByVariantParams) (int64, error)

The destination branch reporting what it actually counted for one line. Keyed by variant, not transfer_item id -- the till only ever knows an item by barcode/uid, resolved to variant_id the same way CreateBranchTransferRequestTx resolves an outgoing line.

func (*Queries) SetTransferStatus

func (q *Queries) SetTransferStatus(ctx context.Context, arg SetTransferStatusParams) (Transfer, error)

func (*Queries) SetUnknownItemSlotImage added in v1.1.1

func (q *Queries) SetUnknownItemSlotImage(ctx context.Context, arg SetUnknownItemSlotImageParams) error

The picture goes to the slot and to every other unit of its cart line. A slot already matched to a product keeps the picture it was matched with.

func (*Queries) SetUserAvatarColor added in v1.1.0

func (q *Queries) SetUserAvatarColor(ctx context.Context, arg SetUserAvatarColorParams) error

func (*Queries) SetVariantBarcode

func (q *Queries) SetVariantBarcode(ctx context.Context, arg SetVariantBarcodeParams) (ProductVariant, error)

func (*Queries) SetWhatsAppMessageCost added in v1.1.0

func (q *Queries) SetWhatsAppMessageCost(ctx context.Context, costMicros int64) error

func (*Queries) SetWhatsAppNumberPhone added in v1.1.0

func (q *Queries) SetWhatsAppNumberPhone(ctx context.Context, arg SetWhatsAppNumberPhoneParams) error

func (*Queries) SetWhatsAppSenderSettings added in v1.1.0

func (q *Queries) SetWhatsAppSenderSettings(ctx context.Context, arg SetWhatsAppSenderSettingsParams) error

func (*Queries) SetWhatsAppSettings

func (q *Queries) SetWhatsAppSettings(ctx context.Context, arg SetWhatsAppSettingsParams) error

func (*Queries) ShareUnknownLineImages added in v1.1.8

func (q *Queries) ShareUnknownLineImages(ctx context.Context, sessionID int64) error

A unit added to a cart line that already has its picture shares it.

func (*Queries) SkipDroppedWhatsAppMessages added in v1.1.9

func (q *Queries) SkipDroppedWhatsAppMessages(ctx context.Context, arg SkipDroppedWhatsAppMessagesParams) error

Messages the bridge dropped from a paused number's queue on resume (refs from POST /instance/resume): logged as sent when queued, they never went.

func (*Queries) SplitUnknownInvoiceItem added in v1.1.1

func (q *Queries) SplitUnknownInvoiceItem(ctx context.Context, arg SplitUnknownInvoiceItemParams) error

func (*Queries) SumBranchRevenueForRange

func (q *Queries) SumBranchRevenueForRange(ctx context.Context, arg SumBranchRevenueForRangeParams) (int64, error)

Net sales revenue: same grand_total-sum convention as ListDailyIncome in branch_invoice.sql (returns already net out via their signed grand_total).

func (*Queries) SumClientLoyaltyPoints

func (q *Queries) SumClientLoyaltyPoints(ctx context.Context, clientID int64) (int64, error)

The redemption-time query: every branch's contribution to this client's loyalty balance, added up. Each branch is decisive for what it reports (loyalty_points_delta on branch_invoices) -- this never recomputes that number, only sums what's already been reported.

func (*Queries) TouchBranchRegister

func (q *Queries) TouchBranchRegister(ctx context.Context, id int64) error

Bumps both the register's and its branch's last_seen_at: the branch is "seen" whenever any of its registers is.

func (*Queries) UnresolveHomeActivity added in v1.1.0

func (q *Queries) UnresolveHomeActivity(ctx context.Context, arg UnresolveHomeActivityParams) error

Reopens a resolved urgent row, pinning it on Home again.

func (*Queries) UnsetDefaultDiscountList

func (q *Queries) UnsetDefaultDiscountList(ctx context.Context, id int64) error

func (*Queries) UnsetDefaultPriceList

func (q *Queries) UnsetDefaultPriceList(ctx context.Context, id int64) error

func (*Queries) UpdateAppReleaseNotes

func (q *Queries) UpdateAppReleaseNotes(ctx context.Context, arg UpdateAppReleaseNotesParams) (AppRelease, error)

func (*Queries) UpdateAppSettings

func (q *Queries) UpdateAppSettings(ctx context.Context, arg UpdateAppSettingsParams) (AppSetting, error)

func (*Queries) UpdateAsset

func (q *Queries) UpdateAsset(ctx context.Context, arg UpdateAssetParams) (Asset, error)

func (*Queries) UpdateAssetCategory

func (q *Queries) UpdateAssetCategory(ctx context.Context, arg UpdateAssetCategoryParams) (AssetCategory, error)

func (*Queries) UpdateAttributeValue

func (q *Queries) UpdateAttributeValue(ctx context.Context, arg UpdateAttributeValueParams) (AttributesValue, error)

func (*Queries) UpdateBranchAttendanceEvent

func (q *Queries) UpdateBranchAttendanceEvent(ctx context.Context, arg UpdateBranchAttendanceEventParams) (BranchAttendanceEvent, error)

func (*Queries) UpdateBranchRegister

func (q *Queries) UpdateBranchRegister(ctx context.Context, arg UpdateBranchRegisterParams) (BranchRegister, error)

func (*Queries) UpdateBranchRegisterAPIKeyHash

func (q *Queries) UpdateBranchRegisterAPIKeyHash(ctx context.Context, arg UpdateBranchRegisterAPIKeyHashParams) error

func (*Queries) UpdateBranchSalespersonName

func (q *Queries) UpdateBranchSalespersonName(ctx context.Context, arg UpdateBranchSalespersonNameParams) (Salesperson, error)

func (*Queries) UpdateBranchTarget

func (q *Queries) UpdateBranchTarget(ctx context.Context, arg UpdateBranchTargetParams) (BranchTarget, error)

func (*Queries) UpdateBranchTargetSeries

func (q *Queries) UpdateBranchTargetSeries(ctx context.Context, arg UpdateBranchTargetSeriesParams) (BranchTargetSeries, error)

Only affects future periods -- see CreateGeneratedBranchTarget's note on generation snapshotting a series' fields, never joining them live.

func (*Queries) UpdateBranchUser

func (q *Queries) UpdateBranchUser(ctx context.Context, arg UpdateBranchUserParams) (BranchUser, error)

func (*Queries) UpdateCashbox

func (q *Queries) UpdateCashbox(ctx context.Context, arg UpdateCashboxParams) (Cashbox, error)

func (*Queries) UpdateCashboxAccount

func (q *Queries) UpdateCashboxAccount(ctx context.Context, arg UpdateCashboxAccountParams) (CashboxAccount, error)

func (*Queries) UpdateClient

func (q *Queries) UpdateClient(ctx context.Context, arg UpdateClientParams) (Client, error)

func (*Queries) UpdateClientPhone added in v1.1.3

func (q *Queries) UpdateClientPhone(ctx context.Context, arg UpdateClientPhoneParams) error

func (*Queries) UpdateColor

func (q *Queries) UpdateColor(ctx context.Context, arg UpdateColorParams) (Color, error)

func (*Queries) UpdateCoupon

func (q *Queries) UpdateCoupon(ctx context.Context, arg UpdateCouponParams) (Coupon, error)

func (*Queries) UpdateCouponCategory

func (q *Queries) UpdateCouponCategory(ctx context.Context, arg UpdateCouponCategoryParams) (CouponCategory, error)

func (*Queries) UpdateCouponType

func (q *Queries) UpdateCouponType(ctx context.Context, arg UpdateCouponTypeParams) (CouponType, error)

func (*Queries) UpdateCurrency

func (q *Queries) UpdateCurrency(ctx context.Context, arg UpdateCurrencyParams) (Currency, error)

func (*Queries) UpdateDeal added in v1.1.6

func (q *Queries) UpdateDeal(ctx context.Context, arg UpdateDealParams) (Deal, error)

func (*Queries) UpdateDiscountList

func (q *Queries) UpdateDiscountList(ctx context.Context, arg UpdateDiscountListParams) error

func (*Queries) UpdateDiscountListItem

func (q *Queries) UpdateDiscountListItem(ctx context.Context, arg UpdateDiscountListItemParams) error

func (*Queries) UpdateDiscountListRule added in v1.1.7

func (q *Queries) UpdateDiscountListRule(ctx context.Context, arg UpdateDiscountListRuleParams) (int64, error)

Saved in place: the rows a rule wrote carry its id (rule_id), so a rule re-created with a new id would have every one of them rewritten.

func (*Queries) UpdateDiscountListRuleGroup added in v1.1.7

func (q *Queries) UpdateDiscountListRuleGroup(ctx context.Context, arg UpdateDiscountListRuleGroupParams) (int64, error)

Saved in place, so a group (and its rules) keeps its id.

func (*Queries) UpdateEmailSchedule added in v1.1.0

func (q *Queries) UpdateEmailSchedule(ctx context.Context, arg UpdateEmailScheduleParams) (EmailSchedule, error)

func (*Queries) UpdateEmployee

func (q *Queries) UpdateEmployee(ctx context.Context, arg UpdateEmployeeParams) (Employee, error)

func (*Queries) UpdateEmployeeSalary

func (q *Queries) UpdateEmployeeSalary(ctx context.Context, arg UpdateEmployeeSalaryParams) (Employee, error)

func (*Queries) UpdateExpense

func (q *Queries) UpdateExpense(ctx context.Context, arg UpdateExpenseParams) (Expense, error)

func (*Queries) UpdateExpenseCategory

func (q *Queries) UpdateExpenseCategory(ctx context.Context, arg UpdateExpenseCategoryParams) (ExpenseCategory, error)

func (*Queries) UpdateInventory

func (q *Queries) UpdateInventory(ctx context.Context, arg UpdateInventoryParams) error

func (*Queries) UpdateInvoiceDiscount added in v1.1.8

func (q *Queries) UpdateInvoiceDiscount(ctx context.Context, arg UpdateInvoiceDiscountParams) (InvoiceDiscount, error)

func (*Queries) UpdateInvoiceType

func (q *Queries) UpdateInvoiceType(ctx context.Context, arg UpdateInvoiceTypeParams) (InvoiceType, error)

func (*Queries) UpdateLoan

func (q *Queries) UpdateLoan(ctx context.Context, arg UpdateLoanParams) (Loan, error)

Central loans only -- branch-origin loans are a synced record of what a branch reported and stay read-only here (WHERE origin filter makes a branch-loan id return no rows, surfaced as a 404 by the handler).

func (*Queries) UpdateLoanCategory

func (q *Queries) UpdateLoanCategory(ctx context.Context, arg UpdateLoanCategoryParams) (LoanCategory, error)

func (*Queries) UpdatePriceList

func (q *Queries) UpdatePriceList(ctx context.Context, arg UpdatePriceListParams) error

func (*Queries) UpdatePriceListItem

func (q *Queries) UpdatePriceListItem(ctx context.Context, arg UpdatePriceListItemParams) error

func (*Queries) UpdateProduct

func (q *Queries) UpdateProduct(ctx context.Context, arg UpdateProductParams) error

func (*Queries) UpdateProductAttribute

func (q *Queries) UpdateProductAttribute(ctx context.Context, arg UpdateProductAttributeParams) error

func (*Queries) UpdateProductCategory

func (q *Queries) UpdateProductCategory(ctx context.Context, arg UpdateProductCategoryParams) (ProductCategory, error)

func (*Queries) UpdateProductLowStockThreshold

func (q *Queries) UpdateProductLowStockThreshold(ctx context.Context, arg UpdateProductLowStockThresholdParams) error

A null threshold clears the override, falling back to the app-wide default.

func (*Queries) UpdateProductVariant

func (q *Queries) UpdateProductVariant(ctx context.Context, arg UpdateProductVariantParams) (ProductVariant, error)

price is deliberately not settable here -- see CreateProductVariant.

func (*Queries) UpdateProductVariantAvgCost

func (q *Queries) UpdateProductVariantAvgCost(ctx context.Context, arg UpdateProductVariantAvgCostParams) error

Roll the variant's global moving-average cost forward on a stock receipt. current_qty is the on-hand across all locations before this receipt.

func (*Queries) UpdateRecurringExpenseNextDue

func (q *Queries) UpdateRecurringExpenseNextDue(ctx context.Context, arg UpdateRecurringExpenseNextDueParams) (RecurringExpense, error)

func (*Queries) UpdateSalesperson

func (q *Queries) UpdateSalesperson(ctx context.Context, arg UpdateSalespersonParams) (Salesperson, error)

func (*Queries) UpdateSecuritySettings added in v1.1.0

func (q *Queries) UpdateSecuritySettings(ctx context.Context, arg UpdateSecuritySettingsParams) (SecuritySetting, error)

func (*Queries) UpdateSize

func (q *Queries) UpdateSize(ctx context.Context, arg UpdateSizeParams) (Size, error)

func (*Queries) UpdateTransfer

func (q *Queries) UpdateTransfer(ctx context.Context, arg UpdateTransferParams) error

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) error

func (*Queries) UpdateWhatsAppNumberLabel added in v1.1.0

func (q *Queries) UpdateWhatsAppNumberLabel(ctx context.Context, arg UpdateWhatsAppNumberLabelParams) (WhatsappNumber, error)

func (*Queries) UpsertAttributeValue

func (q *Queries) UpsertAttributeValue(ctx context.Context, arg UpsertAttributeValueParams) (AttributesValue, error)

func (*Queries) UpsertBranchSettings

func (q *Queries) UpsertBranchSettings(ctx context.Context, arg UpsertBranchSettingsParams) (BranchSetting, error)

func (*Queries) UpsertBranchSyncConflict

func (q *Queries) UpsertBranchSyncConflict(ctx context.Context, arg UpsertBranchSyncConflictParams) (BranchSyncConflict, error)

Idempotent on (branch_id, entity, ref): a retried outbox push re-reports the same conflict. A row an admin already resolved/dismissed is left alone (nothing to re-open).

func (*Queries) UpsertCashboxAccountOverride

func (q *Queries) UpsertCashboxAccountOverride(ctx context.Context, arg UpsertCashboxAccountOverrideParams) (BranchCashboxAccount, error)
func (q *Queries) UpsertClientLink(ctx context.Context, arg UpsertClientLinkParams) error

func (*Queries) UpsertDefaultBranchSettings

func (q *Queries) UpsertDefaultBranchSettings(ctx context.Context, settings json.RawMessage) (DefaultBranchSetting, error)

func (*Queries) UpsertDiscountListBranch

func (q *Queries) UpsertDiscountListBranch(ctx context.Context, arg UpsertDiscountListBranchParams) error

func (*Queries) UpsertDiscountListOptionItem added in v1.1.6

func (q *Queries) UpsertDiscountListOptionItem(ctx context.Context, arg UpsertDiscountListOptionItemParams) error

func (*Queries) UpsertGoogleReview added in v1.1.0

func (q *Queries) UpsertGoogleReview(ctx context.Context, arg UpsertGoogleReviewParams) error

func (*Queries) UpsertIPBan added in v1.1.0

func (q *Queries) UpsertIPBan(ctx context.Context, arg UpsertIPBanParams) error

func (*Queries) UpsertInventoryAssetQuantity

func (q *Queries) UpsertInventoryAssetQuantity(ctx context.Context, arg UpsertInventoryAssetQuantityParams) (InventoriesAsset, error)

Reactivates inventories_assets (created 000012, never wired up until now): per-location unit counts for fixed assets, feeding the Assets Treemap. One assets row is a distinct item *type*; the same asset can sit in more than one location, each with its own counted quantity here.

func (*Queries) UpsertOversoldConflict

func (q *Queries) UpsertOversoldConflict(ctx context.Context, arg UpsertOversoldConflictParams) (BranchSyncConflict, error)

One open "oversold" alert per (branch, variant). Unlike UpsertBranchSyncConflict, an alert an admin already resolved is reopened: going negative again after a fix is a new problem.

func (*Queries) UpsertPriceListBranch

func (q *Queries) UpsertPriceListBranch(ctx context.Context, arg UpsertPriceListBranchParams) error

func (*Queries) UpsertProductAttribute

func (q *Queries) UpsertProductAttribute(ctx context.Context, arg UpsertProductAttributeParams) error

func (*Queries) UpsertRolePermission

func (q *Queries) UpsertRolePermission(ctx context.Context, arg UpsertRolePermissionParams) error

func (*Queries) UpsertVisitorIP added in v1.1.0

func (q *Queries) UpsertVisitorIP(ctx context.Context, arg UpsertVisitorIPParams) error

The Security page and its request middleware (api/security.go). Folds one flush's worth of requests from an IP into its row: counters add up, the "last" columns and the location are overwritten.

func (*Queries) VisitorCountries added in v1.1.0

func (q *Queries) VisitorCountries(ctx context.Context) ([]VisitorCountriesRow, error)

IPs and requests per country, busiest first.

func (*Queries) WaiveUnknownItemSlots added in v1.1.1

func (q *Queries) WaiveUnknownItemSlots(ctx context.Context, arg WaiveUnknownItemSlotsParams) (int64, error)

Lets units through with no picture. A unit that already has one is left alone.

func (*Queries) WhatsAppClientsByPhoneTail added in v1.1.0

func (q *Queries) WhatsAppClientsByPhoneTail(ctx context.Context, tails []string) ([]WhatsAppClientsByPhoneTailRow, error)

Names for a rule's phones, matched on their last 8 digits (whatsAppSamePhone).

func (*Queries) WhatsAppFailureReasons added in v1.1.0

func (q *Queries) WhatsAppFailureReasons(ctx context.Context, arg WhatsAppFailureReasonsParams) ([]WhatsAppFailureReasonsRow, error)

Both kashi's failures (Meta refused the send) and Meta's own (accepted, then couldn't deliver).

func (*Queries) WhatsAppFailureWatch added in v1.1.1

func (q *Queries) WhatsAppFailureWatch(ctx context.Context) (WhatsAppFailureWatchRow, error)

Sale messages that failed lately (a retried one that then went out is no longer counted, see DeleteFailedWhatsAppMessagesForInvoice), and the latest failure's reason.

func (*Queries) WhatsAppMessageTotals added in v1.1.0

func (q *Queries) WhatsAppMessageTotals(ctx context.Context, arg WhatsAppMessageTotalsParams) (WhatsAppMessageTotalsRow, error)

delivered/read/undelivered come from Meta's webhook (delivery_status).

func (*Queries) WhatsAppMessagesByBranch added in v1.1.0

func (q *Queries) WhatsAppMessagesByBranch(ctx context.Context, arg WhatsAppMessagesByBranchParams) ([]WhatsAppMessagesByBranchRow, error)

func (*Queries) WhatsAppMessagesByDay added in v1.1.0

func (q *Queries) WhatsAppMessagesByDay(ctx context.Context, arg WhatsAppMessagesByDayParams) ([]WhatsAppMessagesByDayRow, error)

Days are Beirut calendar days, like the rest of the business.

func (*Queries) WhatsAppMessagesByHour added in v1.1.0

func (q *Queries) WhatsAppMessagesByHour(ctx context.Context, arg WhatsAppMessagesByHourParams) ([]WhatsAppMessagesByHourRow, error)

func (*Queries) WhatsAppMessagesByRule added in v1.1.0

func (q *Queries) WhatsAppMessagesByRule(ctx context.Context, arg WhatsAppMessagesByRuleParams) ([]WhatsAppMessagesByRuleRow, error)

” rule_name is "no rule matched" (the default template).

func (*Queries) WhatsAppNumberForBranch added in v1.1.0

func (q *Queries) WhatsAppNumberForBranch(ctx context.Context, arg WhatsAppNumberForBranchParams) (WhatsappNumber, error)

The number a branch's sale goes out from: its own, else the default, else (no default, as when the first number was removed) the oldest one. A number whose minimum invoice the sale is under is passed over for the next one.

func (*Queries) WhatsAppSentForInvoice added in v1.1.0

func (q *Queries) WhatsAppSentForInvoice(ctx context.Context, arg WhatsAppSentForInvoiceParams) (bool, error)

A till that reports the same sale twice doesn't message the client twice.

func (*Queries) WhatsAppTopRecipients added in v1.1.0

func (q *Queries) WhatsAppTopRecipients(ctx context.Context, arg WhatsAppTopRecipientsParams) ([]WhatsAppTopRecipientsRow, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type QuickAccessItemInput

type QuickAccessItemInput struct {
	ProductVariantID int64
	Color            string
	TextColor        string
}

QuickAccessItemInput is one card of a branch's Quick Access list, in the order the list is given (its index becomes the card's position).

type ReceiveInventoryStockParams

type ReceiveInventoryStockParams struct {
	InventoryID int64 `json:"inventory_id"`
	VariantID   int64 `json:"variant_id"`
	Quantity    int64 `json:"quantity"`
	UnitCost    int64 `json:"unit_cost"`
}

type RecordEmailScheduleRunParams added in v1.1.0

type RecordEmailScheduleRunParams struct {
	Status string `json:"status"`
	Error  string `json:"error"`
	ID     int64  `json:"id"`
}

type RecordSecurityAlertParams added in v1.1.0

type RecordSecurityAlertParams struct {
	Kind        string `json:"kind"`
	Ip          string `json:"ip"`
	CountryCode string `json:"country_code"`
	Detail      string `json:"detail"`
}

type RecordWhatsAppPollVoteParams added in v1.1.0

type RecordWhatsAppPollVoteParams struct {
	PollRating sql.NullInt16 `json:"poll_rating"`
	PollAnswer string        `json:"poll_answer"`
	PollRef    string        `json:"poll_ref"`
}

type RecordWhatsAppPollVoteRow added in v1.1.0

type RecordWhatsAppPollVoteRow struct {
	ID         int64         `json:"id"`
	BranchID   sql.NullInt64 `json:"branch_id"`
	ClientName string        `json:"client_name"`
}

type RecurringExpense

type RecurringExpense struct {
	ID            int64         `json:"id"`
	Description   string        `json:"description"`
	Amount        int64         `json:"amount"`
	CurrencyCode  string        `json:"currency_code"`
	IntervalUnit  string        `json:"interval_unit"`
	IntervalCount int32         `json:"interval_count"`
	NextDueAt     time.Time     `json:"next_due_at"`
	Active        bool          `json:"active"`
	CreatedAt     time.Time     `json:"created_at"`
	CategoryID    sql.NullInt64 `json:"category_id"`
}

type RedeemCouponParams

type RedeemCouponParams struct {
	Code               string         `json:"code"`
	RedeemedBranchID   sql.NullInt64  `json:"redeemed_branch_id"`
	RedeemedInvoiceRef sql.NullString `json:"redeemed_invoice_ref"`
}

type RenameRoleParams

type RenameRoleParams struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

type ReplaceBranchExpenseImageFileParams added in v1.1.0

type ReplaceBranchExpenseImageFileParams struct {
	ID          int64  `json:"id"`
	FilePath    string `json:"file_path"`
	ContentType string `json:"content_type"`
	SizeBytes   int64  `json:"size_bytes"`
}

type ReplaceBranchShiftReceiptImageFileParams added in v1.1.0

type ReplaceBranchShiftReceiptImageFileParams struct {
	ID          int64  `json:"id"`
	FilePath    string `json:"file_path"`
	ContentType string `json:"content_type"`
	SizeBytes   int64  `json:"size_bytes"`
}

type RepointBranchInvoicesClientUIDParams

type RepointBranchInvoicesClientUIDParams struct {
	CanonicalUid uuid.UUID `json:"canonical_uid"`
	BranchID     int64     `json:"branch_id"`
	TillUid      uuid.UUID `json:"till_uid"`
}

type ReportBranchSalesParams added in v1.1.0

type ReportBranchSalesParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type ReportBranchSalesRow added in v1.1.0

type ReportBranchSalesRow struct {
	BranchID   int64  `json:"branch_id"`
	BranchName string `json:"branch_name"`
	Sales      int64  `json:"sales"`
}

type ReportCategorySalesParams added in v1.1.0

type ReportCategorySalesParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type ReportCategorySalesRow added in v1.1.0

type ReportCategorySalesRow struct {
	Category string `json:"category"`
	Color    string `json:"color"`
	Revenue  int64  `json:"revenue"`
}

type ReportCostOfGoodsParams added in v1.1.0

type ReportCostOfGoodsParams struct {
	DateFrom   time.Time     `json:"date_from"`
	DateTo     time.Time     `json:"date_to"`
	WantBranch bool          `json:"want_branch"`
	BranchID   sql.NullInt64 `json:"branch_id"`
	WantAdmin  bool          `json:"want_admin"`
}

type ReportCostOfGoodsRow added in v1.1.0

type ReportCostOfGoodsRow struct {
	Cogs          int64 `json:"cogs"`
	CostedRevenue int64 `json:"costed_revenue"`
}

type ReportCostOfGoodsSeriesParams added in v1.1.0

type ReportCostOfGoodsSeriesParams struct {
	DateFrom   time.Time     `json:"date_from"`
	DateTo     time.Time     `json:"date_to"`
	WantBranch bool          `json:"want_branch"`
	BranchID   sql.NullInt64 `json:"branch_id"`
	WantAdmin  bool          `json:"want_admin"`
}

type ReportCostOfGoodsSeriesRow added in v1.1.0

type ReportCostOfGoodsSeriesRow struct {
	Day  time.Time `json:"day"`
	Cogs int64     `json:"cogs"`
}

type ReportDailyCostedParams added in v1.1.0

type ReportDailyCostedParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type ReportDailyCostedRow added in v1.1.0

type ReportDailyCostedRow struct {
	Day           time.Time `json:"day"`
	CostedRevenue int64     `json:"costed_revenue"`
	Cogs          int64     `json:"cogs"`
}

type ReportDailySalesParams added in v1.1.0

type ReportDailySalesParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type ReportDailySalesRow added in v1.1.0

type ReportDailySalesRow struct {
	Day   time.Time `json:"day"`
	Sales int64     `json:"sales"`
}

type ReportHourlySalesParams added in v1.1.0

type ReportHourlySalesParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type ReportHourlySalesRow added in v1.1.0

type ReportHourlySalesRow struct {
	Dow      int32 `json:"dow"`
	Hour     int32 `json:"hour"`
	Invoices int64 `json:"invoices"`
	Sales    int64 `json:"sales"`
}

type ReportPaymentMethodsParams added in v1.1.0

type ReportPaymentMethodsParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type ReportPaymentMethodsRow added in v1.1.0

type ReportPaymentMethodsRow struct {
	Name   string `json:"name"`
	Amount int64  `json:"amount"`
}

type ReportSaleInvoice added in v1.1.0

type ReportSaleInvoice struct {
	Source     string    `json:"source"`
	InvoiceID  int64     `json:"invoice_id"`
	BranchID   int64     `json:"branch_id"`
	OccurredAt time.Time `json:"occurred_at"`
	GrandTotal int64     `json:"grand_total"`
}

type ReportSaleLine added in v1.1.0

type ReportSaleLine struct {
	Source     string    `json:"source"`
	BranchID   int64     `json:"branch_id"`
	OccurredAt time.Time `json:"occurred_at"`
	ProductID  int64     `json:"product_id"`
	Quantity   int64     `json:"quantity"`
	LineTotal  int64     `json:"line_total"`
	UnitCost   int64     `json:"unit_cost"`
}

type ReportTargetsInRangeParams added in v1.1.0

type ReportTargetsInRangeParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type ReportTargetsInRangeRow added in v1.1.0

type ReportTargetsInRangeRow struct {
	BranchID     int64     `json:"branch_id"`
	BranchName   string    `json:"branch_name"`
	DateFrom     time.Time `json:"date_from"`
	DateTo       time.Time `json:"date_to"`
	TargetAmount int64     `json:"target_amount"`
}

type ReportTopProductsParams added in v1.1.0

type ReportTopProductsParams struct {
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
	TopN     int32     `json:"top_n"`
}

type ReportTopProductsRow added in v1.1.0

type ReportTopProductsRow struct {
	ProductID   int64  `json:"product_id"`
	ProductName string `json:"product_name"`
	ProductCode string `json:"product_code"`
	Quantity    int64  `json:"quantity"`
	Revenue     int64  `json:"revenue"`
}

type RequestUnknownItemHelpParams added in v1.1.1

type RequestUnknownItemHelpParams struct {
	BranchID  int64  `json:"branch_id"`
	ClientRef string `json:"client_ref"`
}

type ResolveBranchSyncConflictParams

type ResolveBranchSyncConflictParams struct {
	ID         int64                 `json:"id"`
	Status     string                `json:"status"`
	Resolution pqtype.NullRawMessage `json:"resolution"`
	ResolvedBy sql.NullInt64         `json:"resolved_by"`
}

type ResolveHomeActivityParams added in v1.1.0

type ResolveHomeActivityParams struct {
	Activity   string `json:"activity"`
	SourceID   int64  `json:"source_id"`
	ResolvedBy string `json:"resolved_by"`
}

type ResolveVariantDiscountParams

type ResolveVariantDiscountParams struct {
	BranchID         int64 `json:"branch_id"`
	ProductVariantID int64 `json:"product_variant_id"`
}

type ResolveVariantDiscountsParams

type ResolveVariantDiscountsParams struct {
	BranchID          int64   `json:"branch_id"`
	ProductVariantIds []int64 `json:"product_variant_ids"`
}

type ResolveVariantDiscountsRow

type ResolveVariantDiscountsRow struct {
	ProductVariantID int64 `json:"product_variant_id"`
	Discount         int16 `json:"discount"`
}

type ResolveVariantPriceParams

type ResolveVariantPriceParams struct {
	BranchID         int64 `json:"branch_id"`
	ProductVariantID int64 `json:"product_variant_id"`
}

type ResolveVariantPricesParams

type ResolveVariantPricesParams struct {
	BranchID          int64   `json:"branch_id"`
	ProductVariantIds []int64 `json:"product_variant_ids"`
}

type ResolveVariantPricesRow

type ResolveVariantPricesRow struct {
	ProductVariantID int64 `json:"product_variant_id"`
	Price            int64 `json:"price"`
}

type ReturnInvoice

type ReturnInvoice struct {
	InvoiceID      int64 `json:"invoice_id"`
	SalesInvoiceID int64 `json:"sales_invoice_id"`
}

type ReturnInvoiceItem

type ReturnInvoiceItem struct {
	VariantID int64 `json:"variant_id"`
	UnitPrice int64 `json:"unit_price"`
	LineTotal int64 `json:"line_total"`
	Discount  int16 `json:"discount"`
	Quantity  int64 `json:"quantity"`
}

type ReturnInvoiceTxParams

type ReturnInvoiceTxParams struct {
	CashboxID        int64         `json:"cashbox_id"`
	ShiftID          int64         `json:"shift_id"`
	Year             int32         `json:"year"`
	ClientID         int64         `json:"client_id"`
	InventoryID      int64         `json:"inventory_id"`
	Discount         int16         `json:"discount"`
	SubTotal         int64         `json:"sub_total"`
	DiscountedTotal  int64         `json:"discounted_total"`
	GrandTotal       int64         `json:"grand_total"`
	SalesInvoiceID   int64         `json:"sales_invoice_id"`
	CashboxAccountID int64         `json:"cashbox_account_id"`
	PriceListID      sql.NullInt64 `json:"price_list_id"`
	SalespersonID    sql.NullInt64 `json:"salesperson_id"`
	CreatedBy        sql.NullInt64 `json:"created_by"`

	Items []ReturnInvoiceItem `json:"items"`
}

type ReturnInvoiceTxResult

type ReturnInvoiceTxResult struct {
	Invoice               Invoice               `json:"invoice"`
	SalesInvoiceID        int64                 `json:"sales_invoice_id"`
	Entry                 Entry                 `json:"entry"`
	ShiftsAccountsBalance ShiftsAccountsBalance `json:"shift_account_balance"`
}

type ReviewClicksTotalParams added in v1.1.0

type ReviewClicksTotalParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type ReviewFunnelByBranchParams added in v1.1.0

type ReviewFunnelByBranchParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type ReviewFunnelByBranchRow added in v1.1.0

type ReviewFunnelByBranchRow struct {
	BranchID   int64  `json:"branch_id"`
	BranchName string `json:"branch_name"`
	Sent       int64  `json:"sent"`
	Read       int64  `json:"read"`
	Clicked    int64  `json:"clicked"`
}

type ReviewFunnelByDayParams added in v1.1.0

type ReviewFunnelByDayParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type ReviewFunnelByDayRow added in v1.1.0

type ReviewFunnelByDayRow struct {
	Day    time.Time `json:"day"`
	Sent   int64     `json:"sent"`
	Clicks int64     `json:"clicks"`
}

type ReviewFunnelParams added in v1.1.0

type ReviewFunnelParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type ReviewFunnelRow added in v1.1.0

type ReviewFunnelRow struct {
	Sent      int64 `json:"sent"`
	WithLink  int64 `json:"with_link"`
	Delivered int64 `json:"delivered"`
	Read      int64 `json:"read"`
	Clicked   int64 `json:"clicked"`
}

type ReviewLinkClick added in v1.1.0

type ReviewLinkClick struct {
	ID        int64         `json:"id"`
	ClickedAt time.Time     `json:"clicked_at"`
	MessageID sql.NullInt64 `json:"message_id"`
	BranchID  sql.NullInt64 `json:"branch_id"`
	PlaceID   string        `json:"place_id"`
	UserAgent string        `json:"user_agent"`
}

type Role

type Role struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	IsAdmin   bool      `json:"is_admin"`
	CreatedAt time.Time `json:"created_at"`
}

type RolePermission

type RolePermission struct {
	RoleID  int64  `json:"role_id"`
	Section string `json:"section"`
	CanView bool   `json:"can_view"`
	CanEdit bool   `json:"can_edit"`
	Page    string `json:"page"`
}

type RotateBranchExpenseImageParams added in v1.1.0

type RotateBranchExpenseImageParams struct {
	Delta int32 `json:"delta"`
	ID    int64 `json:"id"`
}

type RotateBranchShiftReceiptImageParams added in v1.1.0

type RotateBranchShiftReceiptImageParams struct {
	Delta int32 `json:"delta"`
	ID    int64 `json:"id"`
}

type RotateTransferAttachmentParams added in v1.1.0

type RotateTransferAttachmentParams struct {
	Delta int32 `json:"delta"`
	ID    int64 `json:"id"`
}

type SQLStore

type SQLStore struct {
	*Queries
	// contains filtered or unexported fields
}

provides all the functions to execute SQL queries

func (*SQLStore) AddVariantTx

func (store *SQLStore) AddVariantTx(ctx context.Context, arg AddVariantTxParams) (ProductVariant, error)

AddVariantTx adds a single variant to an existing product, reusing the same auto-barcode generation CreateProductTx uses for the first variant.

func (*SQLStore) ApplyBranchSettlementTx

func (store *SQLStore) ApplyBranchSettlementTx(ctx context.Context, arg ApplyBranchSettlementTxParams) (ApplyBranchSettlementTxResult, error)

ApplyBranchSettlementTx records a branch "change settlement" edit and, if the re-settled sale is already on the cloud AND still belongs to the branch's open shift, replays the new per-account split onto that sale's branch_invoice_payments so the admin view stays correct.

Three cases, all recorded (settlement row + its payment lines, for the audit trail) so a retried outbox entry always gets its 200:

  • sale on cloud, its shift still open -> replayed (status "applied")
  • sale not on cloud yet -> not replayed (status "pending")
  • sale on cloud, its shift already closed -> not replayed, and the caller is told Frozen so it doesn't emit a "settlement changed" notification (status "ignored_shift_closed")

The whole thing is one transaction so a partial replay can never leave the sale's payments half-rewritten.

func (*SQLStore) BatchSetEmployeeSalaries

func (store *SQLStore) BatchSetEmployeeSalaries(ctx context.Context, args []UpdateEmployeeSalaryParams) ([]Employee, error)

BatchSetEmployeeSalaries applies a batch of payroll edits from the admin "edit salaries" table in one transaction, so a partial save can never leave half the roster on new figures and half on old ones -- if any row's id is unknown (0 rows updated) or violates a check constraint, the whole batch rolls back. Returns the updated rows in input order.

func (*SQLStore) CancelPurchaseTx

func (store *SQLStore) CancelPurchaseTx(ctx context.Context, purchaseID int64, cancelledBy sql.NullInt64) (PurchaseReceiveTxResult, error)

CancelPurchaseTx moves a purchase to 'cancelled'. A draft purchase never touched stock, so this just flips status. A received purchase already moved stock in, so this unwinds every line with a compensating negative movement before flipping status -- on-hand returns to exactly where it was before the purchase was received.

func (*SQLStore) CancelStockCountTx

func (store *SQLStore) CancelStockCountTx(ctx context.Context, id int64) (StockCount, error)

CancelStockCountTx discards a draft count. A count that has already been posted has moved stock and is not reversible through this path.

func (*SQLStore) CancelTransferTx

func (store *SQLStore) CancelTransferTx(ctx context.Context, transferID int64, cancelledBy sql.NullInt64) (TransferStageTxResult, error)

CancelTransferTx moves a transfer to 'cancelled', unwinding whichever legs already ran: a draft never touched stock; a dispatched transfer returns its lines to the source inventory; a received transfer also removes them again from the destination. Either way on-hand ends up exactly where it was before the transfer started.

func (*SQLStore) ConfirmBranchTransferTx

func (store *SQLStore) ConfirmBranchTransferTx(ctx context.Context, arg ConfirmBranchTransferTxParams) (Transfer, error)

ConfirmBranchTransferTx is the destination branch reporting what it actually counted on physical receipt. It never moves stock itself -- that's still TransferApproveTx's job, reading these counts back via transfer_items.received_quantity -- so a confirmation can arrive (and be re-sent, overwriting the previous one) any time before or after kashi's approval with no ordering requirement between the two.

An item the till reports that doesn't resolve to a known variant, or that doesn't match any line on the transfer, is silently skipped rather than failing the whole confirmation -- kashi's admin sees the gap (that line's received_quantity stays NULL) and can follow up, same tolerance CreateBranchInvoiceTx gives an unresolved barcode.

func (*SQLStore) CreateBatchTx

func (store *SQLStore) CreateBatchTx(ctx context.Context, arg CreateBatchTxParams) (CreateBatchTxResult, error)

CreateBatchTx snapshots a purchase invoice into a batch: one batch_items row per variant line on the purchase, freezing quantity and cost as of right now. Asset lines (no variant_id) are skipped -- batches track SKUs.

func (*SQLStore) CreateBranchInvoiceTx

func (store *SQLStore) CreateBranchInvoiceTx(ctx context.Context, arg CreateBranchInvoiceTxParams) (CreateBranchInvoiceTxResult, error)

CreateBranchInvoiceTx inserts a branch invoice header and its line items together, so a crash mid-write can never leave an idempotency-key row with no items behind (which would make a legitimate retry think the invoice was already fully recorded).

func (*SQLStore) CreateBranchTransferRequestTx

CreateBranchTransferRequestTx records a till-proposed transfer out of its own store inventory. It moves no stock -- that only happens on TransferApproveTx -- so every line must resolve to a real central variant up front (unlike a branch invoice line, which is recorded even unresolved and just skips the stock effect): a transfer with an item kashi can't identify would leave a central admin approving a request they can't actually see the contents of.

func (*SQLStore) CreateBranchTx

func (store *SQLStore) CreateBranchTx(ctx context.Context, arg CreateBranchTxParams) (CreateBranchTxResult, error)

CreateBranchTx creates a branch together with its first register and its own store inventory, so branch (POS) sales can decrement central stock for that location from day one.

func (*SQLStore) CreateProductTx

func (store *SQLStore) CreateProductTx(ctx context.Context, arg CreateProductTxParams) (CreateProductTxResult, error)

CreateProductTx creates a product together with its first variant. A product is never created without at least one sellable variant — a product with zero variants has no barcode a till could ring up, so there'd be nothing to actually sell.

func (*SQLStore) CreatePurchaseTx

func (store *SQLStore) CreatePurchaseTx(ctx context.Context, arg CreatePurchaseTxParams) (CreatePurchaseTxResult, error)

CreatePurchaseTx writes a draft purchase invoice and its lines together, and stamps the header subtotal/grand_total from the lines. It does not touch stock -- that happens on receive.

func (*SQLStore) CreateTransferTx

func (store *SQLStore) CreateTransferTx(ctx context.Context, arg CreateTransferTxParams) (CreateTransferTxResult, error)

CreateTransferTx writes a draft transfer and its lines. No stock moves until the transfer is dispatched.

func (*SQLStore) DeleteBranchTargetSeriesTx

func (store *SQLStore) DeleteBranchTargetSeriesTx(ctx context.Context, seriesID int64) (BranchTargetSeries, error)

DeleteBranchTargetSeriesTx removes a recurring series and every period it generated. Deactivating the occurrences before deleting the series row matters: branch_targets.series_id is ON DELETE SET NULL, so deleting the series first would silently orphan those rows as still-active fixed targets instead of removing them.

func (*SQLStore) FireRecurringExpenseTx

func (store *SQLStore) FireRecurringExpenseTx(ctx context.Context, recurring RecurringExpense) (Expense, error)

FireRecurringExpenseTx creates the real expense row for a due recurring template and advances its next_due_at in the same transaction, so a crash between the two can never leave a template stuck re-firing the same due date on the next scheduler tick (which would create duplicate expenses) or advanced with no expense created (which would silently drop one).

func (*SQLStore) ImportBranchQuickAccessTx

func (store *SQLStore) ImportBranchQuickAccessTx(ctx context.Context, branchID int64, items []QuickAccessItemInput) (bool, error)

ImportBranchQuickAccessTx seeds a branch's list from a till's own list -- only the first time any list is set up for the branch. It reports whether it imported; false means the branch already had a list, left untouched. An empty list imports nothing and doesn't count as setting one up, so the branch's next register (which may have real cards) can still seed it.

func (*SQLStore) PostStockCountTx

func (store *SQLStore) PostStockCountTx(ctx context.Context, id int64, postedBy sql.NullInt64) (PostStockCountTxResult, error)

PostStockCountTx moves a draft count to 'posted'. For each line it compares the counted quantity against *live* on-hand (not the snapshot taken at save time, which may be stale by now) and writes exactly one applyStockMovement covering the difference -- a line whose live on-hand already matches the count writes no movement. Metadata records both figures so drift between counting and posting stays visible.

func (*SQLStore) PurchaseReceiveTx

func (store *SQLStore) PurchaseReceiveTx(ctx context.Context, arg PurchaseReceiveTxParams) (PurchaseReceiveTxResult, error)

PurchaseReceiveTx moves a draft purchase to 'received': every product line lands in the purchase's destination inventory as a 'purchase' stock movement, rolls that SKU's per-location and global moving-average cost forward, and records the supplier's cost for the product. Idempotent -- a purchase that is already received is returned unchanged.

func (*SQLStore) ReplaceBranchQuickAccessTx

func (store *SQLStore) ReplaceBranchQuickAccessTx(ctx context.Context, branchID int64, items []QuickAccessItemInput) error

ReplaceBranchQuickAccessTx saves a branch's whole list, as edited in the admin UI. It also marks the list as set up, so a till reporting its own list afterwards can't overwrite it (see ImportBranchQuickAccessTx).

func (*SQLStore) ReplaceDiscountListRuleGroupsTx added in v1.1.6

func (store *SQLStore) ReplaceDiscountListRuleGroupsTx(ctx context.Context, listID int64, groups []DiscountListRuleGroupInput) error

ReplaceDiscountListRuleGroupsTx makes a list's rule groups exactly groups, in that order. Rules are numbered straight through the groups, so the first rule that is on and matches wins, top to bottom.

Groups and rules that are already saved (their ID) are updated in place and keep their ids; only new ones are inserted and only those left out are deleted. The rows a rule wrote carry its id, so re-creating every rule would have every one of those rows deleted and written again on each save -- most of the 13s a save of the Centro list took. One transaction, so the rows are worked out once (000200, at commit) from the finished set.

func (*SQLStore) ReplaceDiscountListRulesTx added in v1.1.6

func (store *SQLStore) ReplaceDiscountListRulesTx(ctx context.Context, listID int64, rules []DiscountListRuleInput) error

ReplaceDiscountListRulesTx makes a list's rules exactly rules, all on, in one group named "Rules" -- a list's rules as they were before groups.

func (*SQLStore) ReplaceWhatsAppRulesTx added in v1.1.0

func (store *SQLStore) ReplaceWhatsAppRulesTx(ctx context.Context, rules []CreateWhatsAppRuleParams) ([]WhatsappRule, error)

ReplaceWhatsAppRulesTx swaps the whole rule list for rules, in order: the WhatsApp page saves the list as one edit, like the auto-fill rules. Positions are taken from the slice order.

func (*SQLStore) ResolveUnknownItemsTx added in v1.1.1

func (store *SQLStore) ResolveUnknownItemsTx(ctx context.Context, slotIDs []int64, variantID int64) error

ResolveUnknownItemsTx says the given pictured units were really variantID: each unit's sold line is split off the unknown line (or relabelled whole, when it was the line's last unit) with that variant's uid, central stock is reduced by one per unit exactly as a normal sale would have, and the slot is stamped resolved. Prices paid are untouched. All or nothing.

func (*SQLStore) ReturnInvoiceTx

func (store *SQLStore) ReturnInvoiceTx(ctx context.Context, arg ReturnInvoiceTxParams) (ReturnInvoiceTxResult, error)

func (*SQLStore) SalesInvoiceTx

func (store *SQLStore) SalesInvoiceTx(ctx context.Context, arg SalesInvoiceTxParams) (SalesInvoiceTxResult, error)

func (*SQLStore) SaveInvoiceDiscountTx added in v1.1.8

func (store *SQLStore) SaveInvoiceDiscountTx(ctx context.Context, arg SaveInvoiceDiscountTxParams) (InvoiceDiscount, error)

SaveInvoiceDiscountTx writes a rule and the branches it is for together, so a till never pulls a rule whose branch list is half written. Saving moves updated_at, which re-sends the rule to every till -- a branch taken off it learns that way (000212).

func (*SQLStore) SaveReviewSettingsTx added in v1.1.0

func (store *SQLStore) SaveReviewSettingsTx(ctx context.Context, settings SetReviewSettingsParams, branches []SetBranchPlaceIDParams) error

SaveReviewSettingsTx saves the review link settings and every branch's own Google place together, so the Reviews tab never half-saves.

func (*SQLStore) SaveRolePermissionsTx

func (store *SQLStore) SaveRolePermissionsTx(ctx context.Context, roleID int64, perms []RolePermission) error

SaveRolePermissionsTx replaces a role's permission rows wholesale, so the role never briefly has a half-applied mix of old and new access.

func (*SQLStore) SaveStockCountTx

func (store *SQLStore) SaveStockCountTx(ctx context.Context, arg SaveStockCountTxParams) (StockCount, error)

SaveStockCountTx writes (or rewrites) a draft stock count's header and lines. It re-snapshots system_quantity from live on-hand and recomputes difference every time -- saving never touches stock. Editing a count that is no longer a draft is refused.

func (*SQLStore) SaveWhatsAppSenderTx added in v1.1.0

func (store *SQLStore) SaveWhatsAppSenderTx(ctx context.Context, settings SetWhatsAppSenderSettingsParams, branches []SetBranchWhatsAppNumberParams) error

SaveWhatsAppSenderTx saves how messages go out and which number each branch sends from, together.

func (*SQLStore) SetProductSaleOptionsTx added in v1.1.6

func (store *SQLStore) SetProductSaleOptionsTx(ctx context.Context, entries []string, saleOptionIDs []int64) (int, error)

SetProductSaleOptionsTx makes the options of every product named by entries exactly saleOptionIDs: an empty set clears them. One transaction, so a till pulling mid-way never sees a product with its options half replaced. Returns how many products it matched.

func (*SQLStore) StockAdjustmentTx

func (store *SQLStore) StockAdjustmentTx(ctx context.Context, arg StockAdjustmentTxParams) (StockAdjustmentTxResult, error)

func (*SQLStore) TransferApproveTx

func (store *SQLStore) TransferApproveTx(ctx context.Context, arg TransferStageTxParams) (TransferStageTxResult, error)

TransferApproveTx is how a kashi admin approves a branch-requested transfer: dispatch and receive collapsed into one atomic step (a branch's request either lands in full or not at all -- there's no "in transit" state a human approval workflow needs to expose, unlike the manual draft->dispatched->received flow above, which stays separate for that reason). Legal from 'requested' or 'draft', so it also works as a one-click approve for a transfer a kashi operator drafted centrally.

func (*SQLStore) TransferDispatchTx

func (store *SQLStore) TransferDispatchTx(ctx context.Context, arg TransferStageTxParams) (TransferStageTxResult, error)

TransferDispatchTx moves a draft transfer to 'dispatched': every product line leaves the source inventory as a 'transfer_out' movement. Stock in transit is simply absent from both locations until received.

func (*SQLStore) TransferReceiveTx

func (store *SQLStore) TransferReceiveTx(ctx context.Context, arg TransferStageTxParams) (TransferStageTxResult, error)

TransferReceiveTx moves a dispatched transfer to 'received': every product line lands in the destination inventory as a 'transfer_in' movement, carrying the source location's moving-average cost so the destination's average is blended correctly. The variant's global average is untouched -- a transfer moves neither total quantity nor total cost.

func (*SQLStore) UpdateProductTx

func (store *SQLStore) UpdateProductTx(ctx context.Context, arg UpdateProductTxParams) (UpdateProductTxResult, error)

UpdateProductTx edits the shared product fields and upserts its attributes in one transaction -- the write-side mirror of CreateProductTx's attribute handling, for products that already exist.

func (*SQLStore) UpdateWhatsAppNumberTx added in v1.1.0

func (store *SQLStore) UpdateWhatsAppNumberTx(ctx context.Context, id int64, label string, makeDefault bool, minTotalCents int64) (WhatsappNumber, error)

UpdateWhatsAppNumberTx renames a number, sets the smallest invoice it sends for and, when makeDefault, makes it the one number every branch without its own sends from.

type SaleOption added in v1.1.6

type SaleOption struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	SortOrder int32     `json:"sort_order"`
	CreatedAt time.Time `json:"created_at"`
}

type SalesInvoice

type SalesInvoice struct {
	InvoiceID int64 `json:"invoice_id"`
}

type SalesInvoiceItem

type SalesInvoiceItem struct {
	VariantID int64 `json:"variant_id"`
	UnitPrice int64 `json:"unit_price"`
	LineTotal int64 `json:"line_total"`
	Discount  int16 `json:"discount"`
	Quantity  int64 `json:"quantity"`
}

type SalesInvoiceTxParams

type SalesInvoiceTxParams struct {
	CashboxID int64 `json:"cashbox_id"`
	ShiftID   int64 `json:"shift_id"`

	Year            int32 `json:"year"`
	ClientID        int64 `json:"client_id"`
	InventoryID     int64 `json:"inventory_id"`
	Discount        int16 `json:"discount"`
	SubTotal        int64 `json:"sub_total"`
	DiscountedTotal int64 `json:"discounted_total"`
	GrandTotal      int64 `json:"grand_total"`

	Items []SalesInvoiceItem `json:"items"`

	CashboxAccountID int64         `json:"cashbox_account_id"`
	PriceListID      sql.NullInt64 `json:"price_list_id"`
	InvoiceTypeID    int64         `json:"invoice_type_id"`
	SalespersonID    sql.NullInt64 `json:"salesperson_id"`
	CreatedBy        sql.NullInt64 `json:"created_by"`
}

type SalesInvoiceTxResult

type SalesInvoiceTxResult struct {
	Invoice Invoice               `json:"invoice"`
	Entry   Entry                 `json:"entry"`
	Balance ShiftsAccountsBalance `json:"balance"`
}

type Salesperson

type Salesperson struct {
	ID                  int64         `json:"id"`
	Name                string        `json:"name"`
	CashboxID           sql.NullInt64 `json:"cashbox_id"`
	BranchID            sql.NullInt64 `json:"branch_id"`
	IsActive            bool          `json:"is_active"`
	UpdatedAt           time.Time     `json:"updated_at"`
	Color               string        `json:"color"`
	AttendanceUserID    string        `json:"attendance_user_id"`
	AttendanceUserIDSet bool          `json:"attendance_user_id_set"`
	IsSalesperson       bool          `json:"is_salesperson"`
}

type SalespersonPerformanceInvoicesParams added in v1.1.0

type SalespersonPerformanceInvoicesParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type SalespersonPerformanceInvoicesRow added in v1.1.0

type SalespersonPerformanceInvoicesRow struct {
	ID                int64     `json:"id"`
	BranchID          int64     `json:"branch_id"`
	Kind              string    `json:"kind"`
	BranchInvoiceCode string    `json:"branch_invoice_code"`
	GrandTotal        int64     `json:"grand_total"`
	OccurredAt        time.Time `json:"occurred_at"`
	SalespersonID     int64     `json:"salesperson_id"`
	SalespersonName   string    `json:"salesperson_name"`
}

type SalespersonPerformanceItemsParams added in v1.1.0

type SalespersonPerformanceItemsParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type SaveInvoiceDiscountTxParams added in v1.1.8

type SaveInvoiceDiscountTxParams struct {
	// 0 creates a rule.
	ID        int64
	Create    CreateInvoiceDiscountParams
	BranchIDs []int64
}

type SaveStockCountTxParams

type SaveStockCountTxParams struct {
	ID          int64 // 0 => create a new draft
	InventoryID int64
	Note        string
	CreatedBy   sql.NullInt64
	Items       []StockCountLineParams
}

type SearchVariantsForUnknownItemsRow added in v1.1.1

type SearchVariantsForUnknownItemsRow struct {
	ID          int64  `json:"id"`
	Barcode     string `json:"barcode"`
	ProductName string `json:"product_name"`
	ProductCode string `json:"product_code"`
	ColorName   string `json:"color_name"`
	SizeName    string `json:"size_name"`
}

type SearchWhatsAppClientsRow added in v1.1.0

type SearchWhatsAppClientsRow struct {
	ID    int64  `json:"id"`
	Name  string `json:"name"`
	Phone string `json:"phone"`
}

type SecurityAlert added in v1.1.0

type SecurityAlert struct {
	ID             int64        `json:"id"`
	Kind           string       `json:"kind"`
	Ip             string       `json:"ip"`
	CountryCode    string       `json:"country_code"`
	Detail         string       `json:"detail"`
	Count          int64        `json:"count"`
	FirstAt        time.Time    `json:"first_at"`
	LastAt         time.Time    `json:"last_at"`
	AcknowledgedAt sql.NullTime `json:"acknowledged_at"`
	AcknowledgedBy string       `json:"acknowledged_by"`
}

type SecuritySetting added in v1.1.0

type SecuritySetting struct {
	ID                   int32     `json:"id"`
	CountryFilterEnabled bool      `json:"country_filter_enabled"`
	AllowedCountries     []string  `json:"allowed_countries"`
	AlwaysAllowed        []string  `json:"always_allowed"`
	AutoBanEnabled       bool      `json:"auto_ban_enabled"`
	AutoBanFailedLogins  int32     `json:"auto_ban_failed_logins"`
	AutoBanMinutes       int32     `json:"auto_ban_minutes"`
	UpdatedAt            time.Time `json:"updated_at"`
}

type SeedProductVariantsCostByCodeParams added in v1.1.3

type SeedProductVariantsCostByCodeParams struct {
	Cost      int64 `json:"cost"`
	ProductID int64 `json:"product_id"`
}

type Session

type Session struct {
	ID           uuid.UUID `json:"id"`
	Username     string    `json:"username"`
	RefreshToken string    `json:"refresh_token"`
	UserAgent    string    `json:"user_agent"`
	ClientIp     string    `json:"client_ip"`
	IsBlocked    bool      `json:"is_blocked"`
	ExpiresAt    time.Time `json:"expires_at"`
	CreatedAt    time.Time `json:"created_at"`
}

type SetAssetCostParams

type SetAssetCostParams struct {
	ID   int64 `json:"id"`
	Cost int64 `json:"cost"`
}

type SetBranchActiveParams

type SetBranchActiveParams struct {
	ID       int64 `json:"id"`
	IsActive bool  `json:"is_active"`
}

type SetBranchExpenseCategoryParams added in v1.1.1

type SetBranchExpenseCategoryParams struct {
	BranchID   int64         `json:"branch_id"`
	ClientRef  string        `json:"client_ref"`
	CategoryID sql.NullInt64 `json:"category_id"`
}

type SetBranchExpenseFromCentralByIDParams added in v1.1.3

type SetBranchExpenseFromCentralByIDParams struct {
	ID          int64 `json:"id"`
	FromCentral bool  `json:"from_central"`
}

type SetBranchExpenseFromCentralParams added in v1.1.3

type SetBranchExpenseFromCentralParams struct {
	BranchID    int64  `json:"branch_id"`
	ClientRef   string `json:"client_ref"`
	FromCentral bool   `json:"from_central"`
}

type SetBranchHiddenFromReportsParams

type SetBranchHiddenFromReportsParams struct {
	ID                int64 `json:"id"`
	HiddenFromReports bool  `json:"hidden_from_reports"`
}

type SetBranchInventoryParams

type SetBranchInventoryParams struct {
	ID          int64         `json:"id"`
	InventoryID sql.NullInt64 `json:"inventory_id"`
}

type SetBranchInvoiceDiscountParams added in v1.1.8

type SetBranchInvoiceDiscountParams struct {
	ID                  int64  `json:"id"`
	InvoiceDiscount     int64  `json:"invoice_discount"`
	InvoiceDiscountName string `json:"invoice_discount_name"`
}

type SetBranchInvoiceItemDiscountParams added in v1.1.8

type SetBranchInvoiceItemDiscountParams struct {
	ID              int64 `json:"id"`
	InvoiceDiscount int64 `json:"invoice_discount"`
}

type SetBranchInvoiceItemResolvedParams added in v1.1.1

type SetBranchInvoiceItemResolvedParams struct {
	ID         int64         `json:"id"`
	ProductUid uuid.NullUUID `json:"product_uid"`
}

type SetBranchInvoiceSalespersonParams added in v1.1.0

type SetBranchInvoiceSalespersonParams struct {
	BranchID          int64  `json:"branch_id"`
	BranchInvoiceCode string `json:"branch_invoice_code"`
	SalespersonID     int64  `json:"salesperson_id"`
}

type SetBranchLoanCategoryParams added in v1.1.1

type SetBranchLoanCategoryParams struct {
	BranchID   sql.NullInt64  `json:"branch_id"`
	ClientRef  sql.NullString `json:"client_ref"`
	CategoryID int64          `json:"category_id"`
}

type SetBranchPlaceIDParams added in v1.1.0

type SetBranchPlaceIDParams struct {
	GooglePlaceID string `json:"google_place_id"`
	ID            int64  `json:"id"`
}

type SetBranchRegisterActiveParams

type SetBranchRegisterActiveParams struct {
	ID       int64 `json:"id"`
	IsActive bool  `json:"is_active"`
}

type SetBranchRegisterHiddenFromReportsParams

type SetBranchRegisterHiddenFromReportsParams struct {
	ID                int64 `json:"id"`
	HiddenFromReports bool  `json:"hidden_from_reports"`
}

type SetBranchRegisterQuickAccessModeParams

type SetBranchRegisterQuickAccessModeParams struct {
	Mode      string    `json:"mode"`
	ChangedAt time.Time `json:"changed_at"`
	ID        int64     `json:"id"`
}

type SetBranchRegisterReportedSettingsParams

type SetBranchRegisterReportedSettingsParams struct {
	ID               int64                 `json:"id"`
	ReportedSettings pqtype.NullRawMessage `json:"reported_settings"`
}

type SetBranchSettingsManagedLocallyParams

type SetBranchSettingsManagedLocallyParams struct {
	BranchID       int64    `json:"branch_id"`
	ManagedLocally []string `json:"managed_locally"`
}

type SetBranchTargetActiveParams

type SetBranchTargetActiveParams struct {
	ID       int64 `json:"id"`
	IsActive bool  `json:"is_active"`
}

type SetBranchTargetSeriesActiveParams

type SetBranchTargetSeriesActiveParams struct {
	ID     int64 `json:"id"`
	Active bool  `json:"active"`
}

type SetBranchUserActiveParams

type SetBranchUserActiveParams struct {
	ID       int64 `json:"id"`
	IsActive bool  `json:"is_active"`
}

type SetBranchWhatsAppNumberParams added in v1.1.0

type SetBranchWhatsAppNumberParams struct {
	WhatsappNumberID     sql.NullInt64  `json:"whatsapp_number_id"`
	WhatsappEnabled      bool           `json:"whatsapp_enabled"`
	WhatsappHiddenFields sql.NullString `json:"whatsapp_hidden_fields"`
	ID                   int64          `json:"id"`
}

type SetCashboxAccountActiveParams

type SetCashboxAccountActiveParams struct {
	ID       int64 `json:"id"`
	IsActive bool  `json:"is_active"`
}

type SetClientActiveParams

type SetClientActiveParams struct {
	ID       int64 `json:"id"`
	IsActive bool  `json:"is_active"`
}

type SetClientBranchIfNullParams added in v1.1.1

type SetClientBranchIfNullParams struct {
	BranchID       sql.NullInt64 `json:"branch_id"`
	ClientUid      uuid.NullUUID `json:"client_uid"`
	RegisterID     int64         `json:"register_id"`
	BranchClientID sql.NullInt64 `json:"branch_client_id"`
}

type SetEmailSettingsParams added in v1.1.0

type SetEmailSettingsParams struct {
	EmailSenderName        string          `json:"email_sender_name"`
	EmailSenderAddress     string          `json:"email_sender_address"`
	EmailReplyTo           string          `json:"email_reply_to"`
	EmailDefaultRecipients string          `json:"email_default_recipients"`
	EmailBusinessName      string          `json:"email_business_name"`
	EmailCsvColumns        json.RawMessage `json:"email_csv_columns"`
	EmailAttachmentFormat  string          `json:"email_attachment_format"`
	EmailGroupByRegister   bool            `json:"email_group_by_register"`
	EmailOldestFirst       bool            `json:"email_oldest_first"`
}

type SetProductAutofillRulesParams added in v1.1.0

type SetProductAutofillRulesParams struct {
	ProductAutofillRules      json.RawMessage `json:"product_autofill_rules"`
	ProductAutofillCodeLayout string          `json:"product_autofill_code_layout"`
}

type SetProductCategoryParams

type SetProductCategoryParams struct {
	ID         int64         `json:"id"`
	CategoryID sql.NullInt64 `json:"category_id"`
}

type SetProductLowStockAlertsEnabledParams

type SetProductLowStockAlertsEnabledParams struct {
	ID                    int64 `json:"id"`
	LowStockAlertsEnabled bool  `json:"low_stock_alerts_enabled"`
}

type SetProductVariantActiveParams

type SetProductVariantActiveParams struct {
	ID       int64 `json:"id"`
	IsActive bool  `json:"is_active"`
}

type SetPurchaseStatusParams

type SetPurchaseStatusParams struct {
	Status     PurchaseStatus `json:"status"`
	ReceivedAt sql.NullTime   `json:"received_at"`
	ID         int64          `json:"id"`
}

type SetPurchaseTotalsParams

type SetPurchaseTotalsParams struct {
	ID         int64 `json:"id"`
	Subtotal   int64 `json:"subtotal"`
	GrandTotal int64 `json:"grand_total"`
}

type SetRecurringExpenseActiveParams

type SetRecurringExpenseActiveParams struct {
	ID     int64 `json:"id"`
	Active bool  `json:"active"`
}

type SetRegisterUpdateStatusParams

type SetRegisterUpdateStatusParams struct {
	ID             int64  `json:"id"`
	AppVersion     string `json:"app_version"`
	AppFlavor      string `json:"app_flavor"`
	UpdateState    string `json:"update_state"`
	UpdateDetail   string `json:"update_detail"`
	UpdateProgress int32  `json:"update_progress"`
}

type SetRegistersTargetReleaseParams

type SetRegistersTargetReleaseParams struct {
	ReleaseID   sql.NullInt64 `json:"release_id"`
	Force       bool          `json:"force"`
	RegisterIds []int64       `json:"register_ids"`
}

type SetReviewSettingsParams added in v1.1.0

type SetReviewSettingsParams struct {
	ReviewPlaceID        string `json:"review_place_id"`
	ReviewBaseUrl        string `json:"review_base_url"`
	ReviewTitle          string `json:"review_title"`
	ReviewDescription    string `json:"review_description"`
	GooglePlacesApiKey   string `json:"google_places_api_key"`
	GoogleReviewsEnabled bool   `json:"google_reviews_enabled"`
}

type SetSalespersonActiveParams

type SetSalespersonActiveParams struct {
	ID       int64 `json:"id"`
	IsActive bool  `json:"is_active"`
}

type SetSalespersonAttendanceIDParams added in v1.1.0

type SetSalespersonAttendanceIDParams struct {
	ID               int64  `json:"id"`
	AttendanceUserID string `json:"attendance_user_id"`
}

type SetSalespersonColorParams

type SetSalespersonColorParams struct {
	ID    int64  `json:"id"`
	Color string `json:"color"`
}

type SetSalespersonIsSalespersonParams added in v1.1.0

type SetSalespersonIsSalespersonParams struct {
	ID            int64 `json:"id"`
	IsSalesperson bool  `json:"is_salesperson"`
}

type SetStockCountNoteParams

type SetStockCountNoteParams struct {
	ID   int64  `json:"id"`
	Note string `json:"note"`
}

type SetStockCountStatusParams

type SetStockCountStatusParams struct {
	ID       int64            `json:"id"`
	Status   StockCountStatus `json:"status"`
	PostedBy sql.NullInt64    `json:"posted_by"`
}

type SetTransferAttachmentPathParams

type SetTransferAttachmentPathParams struct {
	ID             int64  `json:"id"`
	AttachmentPath string `json:"attachment_path"`
}

type SetTransferConfirmedParams

type SetTransferConfirmedParams struct {
	ConfirmedNote string `json:"confirmed_note"`
	ID            int64  `json:"id"`
}

type SetTransferItemReceivedQuantityByVariantParams

type SetTransferItemReceivedQuantityByVariantParams struct {
	ReceivedQuantity sql.NullInt64 `json:"received_quantity"`
	TransferID       int64         `json:"transfer_id"`
	VariantID        sql.NullInt64 `json:"variant_id"`
}

type SetTransferItemReceivedQuantityParams

type SetTransferItemReceivedQuantityParams struct {
	ReceivedQuantity sql.NullInt64 `json:"received_quantity"`
	ID               int64         `json:"id"`
}

type SetTransferStatusParams

type SetTransferStatusParams struct {
	Status       TransferStatus `json:"status"`
	DispatchedAt sql.NullTime   `json:"dispatched_at"`
	ReceivedAt   sql.NullTime   `json:"received_at"`
	ID           int64          `json:"id"`
}

type SetUnknownItemSlotImageParams added in v1.1.1

type SetUnknownItemSlotImageParams struct {
	SessionID int64         `json:"session_id"`
	SlotRef   string        `json:"slot_ref"`
	ImageID   sql.NullInt64 `json:"image_id"`
}

type SetUserAvatarColorParams added in v1.1.0

type SetUserAvatarColorParams struct {
	ID          int64  `json:"id"`
	AvatarColor string `json:"avatar_color"`
}

type SetVariantBarcodeParams

type SetVariantBarcodeParams struct {
	ID      int64  `json:"id"`
	Barcode string `json:"barcode"`
}

type SetWhatsAppNumberPhoneParams added in v1.1.0

type SetWhatsAppNumberPhoneParams struct {
	Phone string `json:"phone"`
	ID    int64  `json:"id"`
}

type SetWhatsAppSenderSettingsParams added in v1.1.0

type SetWhatsAppSenderSettingsParams struct {
	WhatsappSender            string `json:"whatsapp_sender"`
	WhatsappBridgeUrl         string `json:"whatsapp_bridge_url"`
	WhatsappBridgeKey         string `json:"whatsapp_bridge_key"`
	WhatsappBridgeMessage     string `json:"whatsapp_bridge_message"`
	WhatsappFeedbackMode      string `json:"whatsapp_feedback_mode"`
	WhatsappBridgeLinkMessage string `json:"whatsapp_bridge_link_message"`
	WhatsappChannelUrl        string `json:"whatsapp_channel_url"`
	WhatsappPollQuestion      string `json:"whatsapp_poll_question"`
	WhatsappPollOptions       string `json:"whatsapp_poll_options"`
	WhatsappFollowup          bool   `json:"whatsapp_followup"`
	WhatsappFollowupGood      string `json:"whatsapp_followup_good"`
	WhatsappFollowupOkay      string `json:"whatsapp_followup_okay"`
	WhatsappFollowupBad       string `json:"whatsapp_followup_bad"`
	WhatsappHiddenFields      string `json:"whatsapp_hidden_fields"`
	WhatsappChannelFirst      bool   `json:"whatsapp_channel_first"`
	WhatsappWelcomeEarly      bool   `json:"whatsapp_welcome_early"`
	WhatsappDeleteForMe       bool   `json:"whatsapp_delete_for_me"`
	WhatsappDeletePollForMe   bool   `json:"whatsapp_delete_poll_for_me"`
	WhatsappFollowupReturning bool   `json:"whatsapp_followup_returning"`
	WhatsappMessageNew        bool   `json:"whatsapp_message_new"`
	WhatsappMessageReturning  bool   `json:"whatsapp_message_returning"`
	WhatsappPollNew           bool   `json:"whatsapp_poll_new"`
	WhatsappPollReturning     bool   `json:"whatsapp_poll_returning"`
}

type SetWhatsAppSettingsParams

type SetWhatsAppSettingsParams struct {
	WhatsappEnabled            bool   `json:"whatsapp_enabled"`
	WhatsappPhoneNumberID      string `json:"whatsapp_phone_number_id"`
	WhatsappAccessToken        string `json:"whatsapp_access_token"`
	WhatsappTemplateName       string `json:"whatsapp_template_name"`
	WhatsappTemplateLang       string `json:"whatsapp_template_lang"`
	WhatsappTemplateParams     string `json:"whatsapp_template_params"`
	WhatsappWebhookVerifyToken string `json:"whatsapp_webhook_verify_token"`
	WhatsappAppSecret          string `json:"whatsapp_app_secret"`
}

type Shift

type Shift struct {
	ID        int64        `json:"id"`
	IsClosed  bool         `json:"is_closed"`
	CashboxID int64        `json:"cashbox_id"`
	CreatedAt time.Time    `json:"created_at"`
	ClosedAt  sql.NullTime `json:"closed_at"`
}

type ShiftsAccountsBalance

type ShiftsAccountsBalance struct {
	AccountID int64 `json:"account_id"`
	ShiftID   int64 `json:"shift_id"`
	Balance   int64 `json:"balance"`
}

type Size

type Size struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	Type      string    `json:"type"`
	Order     string    `json:"order"`
	Version   int32     `json:"version"`
	CreatedAt time.Time `json:"created_at"`
}

type SkipDroppedWhatsAppMessagesParams added in v1.1.9

type SkipDroppedWhatsAppMessagesParams struct {
	Reason string   `json:"reason"`
	Refs   []string `json:"refs"`
}

type SplitUnknownInvoiceItemParams added in v1.1.1

type SplitUnknownInvoiceItemParams struct {
	ID        int64 `json:"id"`
	LineTotal int64 `json:"line_total"`
}

type StockAdjustmentMode

type StockAdjustmentMode string
const (
	// StockAdjustmentModeDelta adds a signed quantity to on-hand.
	StockAdjustmentModeDelta StockAdjustmentMode = "delta"
	// StockAdjustmentModeCount sets on-hand to an absolute counted figure.
	StockAdjustmentModeCount StockAdjustmentMode = "count"
)

type StockAdjustmentTxParams

type StockAdjustmentTxParams struct {
	InventoryID int64               `json:"inventory_id"`
	VariantID   int64               `json:"variant_id"`
	Mode        StockAdjustmentMode `json:"mode"`
	Quantity    int64               `json:"quantity"` // delta: signed change; count: target on-hand
	Note        string              `json:"note"`
	CreatedBy   sql.NullInt64       `json:"created_by"`
}

type StockAdjustmentTxResult

type StockAdjustmentTxResult struct {
	Movement StockMovement `json:"movement"`
	OnHand   int64         `json:"on_hand"`
}

type StockCount

type StockCount struct {
	ID          int64            `json:"id"`
	InventoryID int64            `json:"inventory_id"`
	Code        string           `json:"code"`
	Status      StockCountStatus `json:"status"`
	Note        string           `json:"note"`
	CountedAt   time.Time        `json:"counted_at"`
	PostedAt    sql.NullTime     `json:"posted_at"`
	CreatedBy   sql.NullInt64    `json:"created_by"`
	PostedBy    sql.NullInt64    `json:"posted_by"`
	CreatedAt   time.Time        `json:"created_at"`
}

type StockCountItem

type StockCountItem struct {
	ID              int64 `json:"id"`
	StockCountID    int64 `json:"stock_count_id"`
	VariantID       int64 `json:"variant_id"`
	SystemQuantity  int64 `json:"system_quantity"`
	CountedQuantity int64 `json:"counted_quantity"`
	Difference      int64 `json:"difference"`
}

type StockCountLineParams

type StockCountLineParams struct {
	VariantID       int64 `json:"variant_id"`
	CountedQuantity int64 `json:"counted_quantity"`
}

StockCountLineParams is one line on a draft stock count sheet: the SKU and what was physically counted. system_quantity is snapshotted from live on-hand at save time, not supplied by the caller.

type StockCountStatus

type StockCountStatus string
const (
	StockCountStatusDraft     StockCountStatus = "draft"
	StockCountStatusPosted    StockCountStatus = "posted"
	StockCountStatusCancelled StockCountStatus = "cancelled"
)

func (*StockCountStatus) Scan

func (e *StockCountStatus) Scan(src interface{}) error

type StockMovement

type StockMovement struct {
	ID             int64               `json:"id"`
	InventoryID    int64               `json:"inventory_id"`
	VariantID      int64               `json:"variant_id"`
	Quantity       int64               `json:"quantity"`
	Reason         StockMovementReason `json:"reason"`
	ReferenceType  sql.NullString      `json:"reference_type"`
	ReferenceID    sql.NullInt64       `json:"reference_id"`
	UnitCost       sql.NullInt64       `json:"unit_cost"`
	Note           string              `json:"note"`
	CreatedBy      sql.NullInt64       `json:"created_by"`
	CreatedAt      time.Time           `json:"created_at"`
	QuantityBefore int64               `json:"quantity_before"`
	QuantityAfter  int64               `json:"quantity_after"`
	Metadata       json.RawMessage     `json:"metadata"`
	BatchID        sql.NullInt64       `json:"batch_id"`
}

type StockMovementReason

type StockMovementReason string
const (
	StockMovementReasonPurchase    StockMovementReason = "purchase"
	StockMovementReasonSale        StockMovementReason = "sale"
	StockMovementReasonReturn      StockMovementReason = "return"
	StockMovementReasonTransferOut StockMovementReason = "transfer_out"
	StockMovementReasonTransferIn  StockMovementReason = "transfer_in"
	StockMovementReasonAdjustment  StockMovementReason = "adjustment"
	StockMovementReasonCount       StockMovementReason = "count"
)

func (*StockMovementReason) Scan

func (e *StockMovementReason) Scan(src interface{}) error

type Store

type Store interface {
	Querier
	SalesInvoiceTx(ctx context.Context, arg SalesInvoiceTxParams) (SalesInvoiceTxResult, error)
	CreateProductTx(ctx context.Context, arg CreateProductTxParams) (CreateProductTxResult, error)
	UpdateProductTx(ctx context.Context, arg UpdateProductTxParams) (UpdateProductTxResult, error)
	AddVariantTx(ctx context.Context, arg AddVariantTxParams) (ProductVariant, error)
	ReturnInvoiceTx(ctx context.Context, arg ReturnInvoiceTxParams) (ReturnInvoiceTxResult, error)
	CreateBranchTx(ctx context.Context, arg CreateBranchTxParams) (CreateBranchTxResult, error)
	CreatePurchaseTx(ctx context.Context, arg CreatePurchaseTxParams) (CreatePurchaseTxResult, error)
	PurchaseReceiveTx(ctx context.Context, arg PurchaseReceiveTxParams) (PurchaseReceiveTxResult, error)
	CreateTransferTx(ctx context.Context, arg CreateTransferTxParams) (CreateTransferTxResult, error)
	TransferDispatchTx(ctx context.Context, arg TransferStageTxParams) (TransferStageTxResult, error)
	TransferReceiveTx(ctx context.Context, arg TransferStageTxParams) (TransferStageTxResult, error)
	TransferApproveTx(ctx context.Context, arg TransferStageTxParams) (TransferStageTxResult, error)
	StockAdjustmentTx(ctx context.Context, arg StockAdjustmentTxParams) (StockAdjustmentTxResult, error)
	CreateBranchInvoiceTx(ctx context.Context, arg CreateBranchInvoiceTxParams) (CreateBranchInvoiceTxResult, error)
	SaveInvoiceDiscountTx(ctx context.Context, arg SaveInvoiceDiscountTxParams) (InvoiceDiscount, error)
	CreateBranchTransferRequestTx(ctx context.Context, arg CreateBranchTransferRequestTxParams) (CreateBranchTransferRequestTxResult, error)
	ConfirmBranchTransferTx(ctx context.Context, arg ConfirmBranchTransferTxParams) (Transfer, error)
	ApplyBranchSettlementTx(ctx context.Context, arg ApplyBranchSettlementTxParams) (ApplyBranchSettlementTxResult, error)
	FireRecurringExpenseTx(ctx context.Context, recurring RecurringExpense) (Expense, error)
	DeleteBranchTargetSeriesTx(ctx context.Context, seriesID int64) (BranchTargetSeries, error)
	BatchSetEmployeeSalaries(ctx context.Context, args []UpdateEmployeeSalaryParams) ([]Employee, error)
	SaveStockCountTx(ctx context.Context, arg SaveStockCountTxParams) (StockCount, error)
	PostStockCountTx(ctx context.Context, id int64, postedBy sql.NullInt64) (PostStockCountTxResult, error)
	CancelStockCountTx(ctx context.Context, id int64) (StockCount, error)
	CancelPurchaseTx(ctx context.Context, purchaseID int64, cancelledBy sql.NullInt64) (PurchaseReceiveTxResult, error)
	CancelTransferTx(ctx context.Context, transferID int64, cancelledBy sql.NullInt64) (TransferStageTxResult, error)
	CreateBatchTx(ctx context.Context, arg CreateBatchTxParams) (CreateBatchTxResult, error)
	SaveRolePermissionsTx(ctx context.Context, roleID int64, perms []RolePermission) error
	ReplaceBranchQuickAccessTx(ctx context.Context, branchID int64, items []QuickAccessItemInput) error
	ImportBranchQuickAccessTx(ctx context.Context, branchID int64, items []QuickAccessItemInput) (bool, error)
	ReplaceWhatsAppRulesTx(ctx context.Context, rules []CreateWhatsAppRuleParams) ([]WhatsappRule, error)
	SaveReviewSettingsTx(ctx context.Context, settings SetReviewSettingsParams, branches []SetBranchPlaceIDParams) error
	SaveWhatsAppSenderTx(ctx context.Context, settings SetWhatsAppSenderSettingsParams, branches []SetBranchWhatsAppNumberParams) error
	UpdateWhatsAppNumberTx(ctx context.Context, id int64, label string, makeDefault bool, minTotalCents int64) (WhatsappNumber, error)
	ResolveUnknownItemsTx(ctx context.Context, slotIDs []int64, variantID int64) error
	SetProductSaleOptionsTx(ctx context.Context, entries []string, saleOptionIDs []int64) (int, error)
	ReplaceDiscountListRulesTx(ctx context.Context, listID int64, rules []DiscountListRuleInput) error
	ReplaceDiscountListRuleGroupsTx(ctx context.Context, listID int64, groups []DiscountListRuleGroupInput) error
}

func NewStore

func NewStore(db *sql.DB) Store

type SumBranchRevenueForRangeParams

type SumBranchRevenueForRangeParams struct {
	BranchID int64     `json:"branch_id"`
	DateFrom time.Time `json:"date_from"`
	DateTo   time.Time `json:"date_to"`
}

type Supplier

type Supplier struct {
	ID               int64           `json:"id"`
	Name             string          `json:"name"`
	Phone            string          `json:"phone"`
	Country          string          `json:"country"`
	Address          string          `json:"address"`
	AddressLatitude  sql.NullFloat64 `json:"address_latitude"`
	AddressLongitude sql.NullFloat64 `json:"address_longitude"`
	CreatedAt        time.Time       `json:"created_at"`
}

type Token

type Token struct {
	Hash   []byte    `json:"hash"`
	UserID int64     `json:"user_id"`
	Expiry time.Time `json:"expiry"`
	Scope  string    `json:"scope"`
}

type Transfer

type Transfer struct {
	ID                 int64          `json:"id"`
	FromInventoryID    int64          `json:"from_inventory_id"`
	ToInventoryID      int64          `json:"to_inventory_id"`
	Type               TransferType   `json:"type"`
	CreatedAt          time.Time      `json:"created_at"`
	Code               string         `json:"code"`
	Status             TransferStatus `json:"status"`
	DispatchedAt       sql.NullTime   `json:"dispatched_at"`
	ReceivedAt         sql.NullTime   `json:"received_at"`
	Note               string         `json:"note"`
	BranchID           sql.NullInt64  `json:"branch_id"`
	ClientRef          sql.NullString `json:"client_ref"`
	AttachmentPath     string         `json:"attachment_path"`
	UpdatedAt          time.Time      `json:"updated_at"`
	ConfirmedAt        sql.NullTime   `json:"confirmed_at"`
	ConfirmedNote      string         `json:"confirmed_note"`
	RegisterID         sql.NullInt64  `json:"register_id"`
	AttachmentRotation int16          `json:"attachment_rotation"`
}

type TransferItem

type TransferItem struct {
	ID               int64         `json:"id"`
	TransferID       int64         `json:"transfer_id"`
	AssetID          sql.NullInt64 `json:"asset_id"`
	Quantity         int64         `json:"quantity"`
	VariantID        sql.NullInt64 `json:"variant_id"`
	ReceivedQuantity sql.NullInt64 `json:"received_quantity"`
}

Each row references either a product or an asset. Never both.

type TransferItemParams

type TransferItemParams struct {
	VariantID sql.NullInt64 `json:"variant_id"`
	AssetID   sql.NullInt64 `json:"asset_id"`
	Quantity  int64         `json:"quantity"`
}

TransferItemParams is one line on a draft transfer.

type TransferStageTxParams

type TransferStageTxParams struct {
	TransferID int64         `json:"transfer_id"`
	CreatedBy  sql.NullInt64 `json:"created_by"`
}

type TransferStageTxResult

type TransferStageTxResult struct {
	Transfer  Transfer        `json:"transfer"`
	Movements []StockMovement `json:"movements"`
}

type TransferStatus

type TransferStatus string
const (
	TransferStatusDraft      TransferStatus = "draft"
	TransferStatusDispatched TransferStatus = "dispatched"
	TransferStatusReceived   TransferStatus = "received"
	TransferStatusCancelled  TransferStatus = "cancelled"
	TransferStatusRequested  TransferStatus = "requested"
)

func (*TransferStatus) Scan

func (e *TransferStatus) Scan(src interface{}) error

type TransferType

type TransferType string
const (
	TransferTypeAssets   TransferType = "assets"
	TransferTypeProducts TransferType = "products"
)

func (*TransferType) Scan

func (e *TransferType) Scan(src interface{}) error

type UnknownItemImage added in v1.1.1

type UnknownItemImage struct {
	ID          int64     `json:"id"`
	SessionID   int64     `json:"session_id"`
	FilePath    string    `json:"file_path"`
	ContentType string    `json:"content_type"`
	SizeBytes   int64     `json:"size_bytes"`
	Rotation    int16     `json:"rotation"`
	CreatedAt   time.Time `json:"created_at"`
}

type UnknownItemSession added in v1.1.1

type UnknownItemSession struct {
	ID              int64         `json:"id"`
	BranchID        int64         `json:"branch_id"`
	RegisterID      int64         `json:"register_id"`
	ClientRef       string        `json:"client_ref"`
	Token           string        `json:"token"`
	ExpiresAt       time.Time     `json:"expires_at"`
	BranchInvoiceID sql.NullInt64 `json:"branch_invoice_id"`
	HelpRequestedAt sql.NullTime  `json:"help_requested_at"`
	CreatedAt       time.Time     `json:"created_at"`
}

type UnknownItemSlot added in v1.1.1

type UnknownItemSlot struct {
	ID                int64         `json:"id"`
	SessionID         int64         `json:"session_id"`
	SlotRef           string        `json:"slot_ref"`
	Position          int32         `json:"position"`
	Label             string        `json:"label"`
	UnitPrice         int64         `json:"unit_price"`
	Discount          int16         `json:"discount"`
	ImageID           sql.NullInt64 `json:"image_id"`
	ResolvedVariantID sql.NullInt64 `json:"resolved_variant_id"`
	ResolvedAt        sql.NullTime  `json:"resolved_at"`
	WaivedAt          sql.NullTime  `json:"waived_at"`
	WaivedBy          string        `json:"waived_by"`
	LineRef           string        `json:"line_ref"`
}

type UnresolveHomeActivityParams added in v1.1.0

type UnresolveHomeActivityParams struct {
	Activity string `json:"activity"`
	SourceID int64  `json:"source_id"`
}

type UpdateAppReleaseNotesParams

type UpdateAppReleaseNotesParams struct {
	ID    int64  `json:"id"`
	Notes string `json:"notes"`
}

type UpdateAppSettingsParams

type UpdateAppSettingsParams struct {
	FinancialsHighSeasonMonths json.RawMessage `json:"financials_high_season_months"`
	ActivityMessageSeconds     int16           `json:"activity_message_seconds"`
	ActivityDisplayMode        string          `json:"activity_display_mode"`
	BarcodeLabelWidth          float32         `json:"barcode_label_width"`
	BarcodeLabelHeight         float32         `json:"barcode_label_height"`
	UpcomingEventsDays         int16           `json:"upcoming_events_days"`
	UpcomingEventsMenuDays     int16           `json:"upcoming_events_menu_days"`
	HiddenBuiltinEvents        json.RawMessage `json:"hidden_builtin_events"`
	ProductAutofillEnabled     bool            `json:"product_autofill_enabled"`
	UploadPagesFollowSystem    bool            `json:"upload_pages_follow_system"`
	UnknownImagesAutoDelete    bool            `json:"unknown_images_auto_delete"`
	TablePageSize              int16           `json:"table_page_size"`
}

type UpdateAssetCategoryParams

type UpdateAssetCategoryParams struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
	Icon     string `json:"icon"`
	Color    string `json:"color"`
}

type UpdateAssetParams

type UpdateAssetParams struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Code       string    `json:"code"`
	CategoryID int64     `json:"category_id"`
	BoughtAt   time.Time `json:"bought_at"`
}

type UpdateAttributeValueParams

type UpdateAttributeValueParams struct {
	ID    int64  `json:"id"`
	Value string `json:"value"`
}

type UpdateBranchAttendanceEventParams

type UpdateBranchAttendanceEventParams struct {
	ID               int64  `json:"id"`
	SalespersonName  string `json:"salesperson_name"`
	AttendanceUserID string `json:"attendance_user_id"`
	EventDate        string `json:"event_date"`
	EventTime        string `json:"event_time"`
	EventAt          string `json:"event_at"`
	Type             string `json:"type"`
	Status           string `json:"status"`
}

type UpdateBranchRegisterAPIKeyHashParams

type UpdateBranchRegisterAPIKeyHashParams struct {
	ID         int64  `json:"id"`
	ApiKeyHash string `json:"api_key_hash"`
}

type UpdateBranchRegisterParams

type UpdateBranchRegisterParams struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

type UpdateBranchSalespersonNameParams

type UpdateBranchSalespersonNameParams struct {
	ID       int64         `json:"id"`
	Name     string        `json:"name"`
	BranchID sql.NullInt64 `json:"branch_id"`
}

type UpdateBranchTargetParams

type UpdateBranchTargetParams struct {
	ID           int64     `json:"id"`
	DateFrom     time.Time `json:"date_from"`
	DateTo       time.Time `json:"date_to"`
	TargetAmount int64     `json:"target_amount"`
	Color        string    `json:"color"`
}

type UpdateBranchTargetSeriesParams

type UpdateBranchTargetSeriesParams struct {
	ID            int64  `json:"id"`
	TargetAmount  int64  `json:"target_amount"`
	Color         string `json:"color"`
	StartDay      int32  `json:"start_day"`
	IntervalCount int32  `json:"interval_count"`
}

type UpdateBranchUserParams

type UpdateBranchUserParams struct {
	ID           int64  `json:"id"`
	Username     string `json:"username"`
	Role         string `json:"role"`
	AkuvoxUserID string `json:"akuvox_user_id"`
	IsActive     bool   `json:"is_active"`
}

type UpdateCashboxAccountParams

type UpdateCashboxAccountParams struct {
	ID           int64  `json:"id"`
	Name         string `json:"name"`
	CurrencyCode string `json:"currency_code"`
	SortOrder    int32  `json:"sort_order"`
	Color        string `json:"color"`
}

type UpdateCashboxParams

type UpdateCashboxParams struct {
	ID       int64  `json:"id"`
	Code     string `json:"code"`
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
}

type UpdateClientParams

type UpdateClientParams struct {
	ID           int64  `json:"id"`
	Name         string `json:"name"`
	Phone        string `json:"phone"`
	ClientType   string `json:"client_type"`
	PhoneValid   bool   `json:"phone_valid"`
	PhoneCountry string `json:"phone_country"`
}

type UpdateClientPhoneParams added in v1.1.3

type UpdateClientPhoneParams struct {
	ID    int64  `json:"id"`
	Phone string `json:"phone"`
}

type UpdateColorParams

type UpdateColorParams struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	HexValue string `json:"hex_value"`
}

type UpdateCouponCategoryParams

type UpdateCouponCategoryParams struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
	Icon     string `json:"icon"`
	Color    string `json:"color"`
	Scope    string `json:"scope"`
}

type UpdateCouponParams

type UpdateCouponParams struct {
	Code       string        `json:"code"`
	Status     CouponStatus  `json:"status"`
	TypeID     sql.NullInt64 `json:"type_id"`
	ValueCents int64         `json:"value_cents"`
	ClientID   sql.NullInt64 `json:"client_id"`
	ValidUntil sql.NullTime  `json:"valid_until"`
	CategoryID sql.NullInt64 `json:"category_id"`
}

type UpdateCouponTypeParams

type UpdateCouponTypeParams struct {
	ID                  int64         `json:"id"`
	Name                string        `json:"name"`
	ValueCents          int64         `json:"value_cents"`
	CurrencyCode        string        `json:"currency_code"`
	IsActive            bool          `json:"is_active"`
	ReferenceOnly       bool          `json:"reference_only"`
	CalculateOnCheckout bool          `json:"calculate_on_checkout"`
	CodeOptional        bool          `json:"code_optional"`
	CategoryID          sql.NullInt64 `json:"category_id"`
}

type UpdateCurrencyParams

type UpdateCurrencyParams struct {
	Code                   string `json:"code"`
	Name                   string `json:"name"`
	Symbol                 string `json:"symbol"`
	ValueInDefaultCurrency int64  `json:"value_in_default_currency"`
	IsActive               bool   `json:"is_active"`
	UnitsPerUsdMicros      int64  `json:"units_per_usd_micros"`
	CashRoundingUnit       int64  `json:"cash_rounding_unit"`
}

type UpdateDealParams added in v1.1.6

type UpdateDealParams struct {
	ID                     int64  `json:"id"`
	Name                   string `json:"name"`
	Kind                   string `json:"kind"`
	BuyQty                 int32  `json:"buy_qty"`
	GetQty                 int32  `json:"get_qty"`
	Percent                int16  `json:"percent"`
	BundlePrice            int64  `json:"bundle_price"`
	FallbackPercent        int16  `json:"fallback_percent"`
	FallbackOnlyWithoutSet bool   `json:"fallback_only_without_set"`
}

type UpdateDiscountListItemParams

type UpdateDiscountListItemParams struct {
	DiscountListID   int64 `json:"discount_list_id"`
	ProductVariantID int64 `json:"product_variant_id"`
	Discount         int16 `json:"discount"`
}

type UpdateDiscountListParams

type UpdateDiscountListParams struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	IsActive  bool      `json:"is_active"`
	IsDefault bool      `json:"is_default"`
	ValidFrom time.Time `json:"valid_from"`
	ValidTo   time.Time `json:"valid_to"`
	IsSpecial bool      `json:"is_special"`
}

type UpdateDiscountListRuleGroupParams added in v1.1.7

type UpdateDiscountListRuleGroupParams struct {
	ID             int64  `json:"id"`
	DiscountListID int64  `json:"discount_list_id"`
	Position       int32  `json:"position"`
	Name           string `json:"name"`
	IsEnabled      bool   `json:"is_enabled"`
}

type UpdateDiscountListRuleParams added in v1.1.7

type UpdateDiscountListRuleParams struct {
	Position           int32         `json:"position"`
	Name               string        `json:"name"`
	CodePrefixes       []string      `json:"code_prefixes"`
	ExceptCodePrefixes []string      `json:"except_code_prefixes"`
	Kinds              []string      `json:"kinds"`
	Categories         []string      `json:"categories"`
	SubCategories      []string      `json:"sub_categories"`
	Origins            []string      `json:"origins"`
	Brands             []string      `json:"brands"`
	Discount           int16         `json:"discount"`
	DealID             sql.NullInt64 `json:"deal_id"`
	GroupID            int64         `json:"group_id"`
	IsEnabled          bool          `json:"is_enabled"`
	MaxPrice           sql.NullInt64 `json:"max_price"`
	ID                 int64         `json:"id"`
	DiscountListID     int64         `json:"discount_list_id"`
}

type UpdateEmailScheduleParams added in v1.1.0

type UpdateEmailScheduleParams struct {
	ID          int64        `json:"id"`
	Name        string       `json:"name"`
	Enabled     bool         `json:"enabled"`
	Period      string       `json:"period"`
	RegisterIds []int64      `json:"register_ids"`
	Recipients  string       `json:"recipients"`
	Bcc         string       `json:"bcc"`
	Format      string       `json:"format"`
	Note        string       `json:"note"`
	SkipEmpty   bool         `json:"skip_empty"`
	Frequency   string       `json:"frequency"`
	AtMinute    int32        `json:"at_minute"`
	Weekdays    []int32      `json:"weekdays"`
	MonthDay    int32        `json:"month_day"`
	NextRunAt   sql.NullTime `json:"next_run_at"`
}

type UpdateEmployeeParams

type UpdateEmployeeParams struct {
	ID                     int64         `json:"id"`
	BranchID               sql.NullInt64 `json:"branch_id"`
	Name                   string        `json:"name"`
	Role                   string        `json:"role"`
	Status                 string        `json:"status"`
	HiredOn                sql.NullTime  `json:"hired_on"`
	BaseSalaryCents        int64         `json:"base_salary_cents"`
	CommissionCents        int64         `json:"commission_cents"`
	LateDeductionRateCents int64         `json:"late_deduction_rate_cents"`
	LateDeductionUnit      string        `json:"late_deduction_unit"`
	LateUnitsCenti         int64         `json:"late_units_centi"`
}

type UpdateEmployeeSalaryParams

type UpdateEmployeeSalaryParams struct {
	ID                     int64  `json:"id"`
	BaseSalaryCents        int64  `json:"base_salary_cents"`
	CommissionCents        int64  `json:"commission_cents"`
	LateDeductionRateCents int64  `json:"late_deduction_rate_cents"`
	LateDeductionUnit      string `json:"late_deduction_unit"`
	LateUnitsCenti         int64  `json:"late_units_centi"`
}

type UpdateExpenseCategoryParams

type UpdateExpenseCategoryParams struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
	Icon     string `json:"icon"`
	Color    string `json:"color"`
	Scope    string `json:"scope"`
}

type UpdateExpenseParams

type UpdateExpenseParams struct {
	ID           int64         `json:"id"`
	Description  string        `json:"description"`
	CategoryID   sql.NullInt64 `json:"category_id"`
	Amount       int64         `json:"amount"`
	CurrencyCode string        `json:"currency_code"`
}

type UpdateInventoryParams

type UpdateInventoryParams struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

type UpdateInvoiceDiscountParams added in v1.1.8

type UpdateInvoiceDiscountParams struct {
	ID          int64        `json:"id"`
	Name        string       `json:"name"`
	MinTotal    int64        `json:"min_total"`
	Kind        string       `json:"kind"`
	Percent     int16        `json:"percent"`
	Amount      int64        `json:"amount"`
	AllBranches bool         `json:"all_branches"`
	ValidFrom   sql.NullTime `json:"valid_from"`
	ValidTo     sql.NullTime `json:"valid_to"`
	IsActive    bool         `json:"is_active"`
}

type UpdateInvoiceTypeParams

type UpdateInvoiceTypeParams struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	Code     string `json:"code"`
	IsActive bool   `json:"is_active"`
}

type UpdateLoanCategoryParams

type UpdateLoanCategoryParams struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
	Icon     string `json:"icon"`
	Color    string `json:"color"`
	Scope    string `json:"scope"`
}

type UpdateLoanParams

type UpdateLoanParams struct {
	ID           int64  `json:"id"`
	Description  string `json:"description"`
	CategoryID   int64  `json:"category_id"`
	Amount       int64  `json:"amount"`
	CurrencyCode string `json:"currency_code"`
}

type UpdatePriceListItemParams

type UpdatePriceListItemParams struct {
	PriceListID      int64 `json:"price_list_id"`
	ProductVariantID int64 `json:"product_variant_id"`
	Price            int64 `json:"price"`
}

type UpdatePriceListParams

type UpdatePriceListParams struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	IsActive  bool      `json:"is_active"`
	IsDefault bool      `json:"is_default"`
	ValidFrom time.Time `json:"valid_from"`
	ValidTo   time.Time `json:"valid_to"`
	IsSpecial bool      `json:"is_special"`
}

type UpdateProductAttributeParams

type UpdateProductAttributeParams struct {
	ProductID        int64 `json:"product_id"`
	AttributeID      int64 `json:"attribute_id"`
	AttributeValueID int64 `json:"attribute_value_id"`
}

type UpdateProductCategoryParams

type UpdateProductCategoryParams struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
	Icon     string `json:"icon"`
	Color    string `json:"color"`
}

type UpdateProductLowStockThresholdParams

type UpdateProductLowStockThresholdParams struct {
	LowStockThreshold sql.NullInt64 `json:"low_stock_threshold"`
	ID                int64         `json:"id"`
}

type UpdateProductParams

type UpdateProductParams struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Code        string `json:"code"`
	Description string `json:"description"`
	IsActive    bool   `json:"is_active"`
}

type UpdateProductTxParams

type UpdateProductTxParams struct {
	ID          int64  `json:"id"`
	Code        string `json:"code"`
	Name        string `json:"name"`
	Description string `json:"description"`
	IsActive    bool   `json:"is_active"`
	// AttributeValues carries the attribute id (0-8) plus its free-text
	// value; a blank value clears nothing (it's simply skipped) so callers
	// only need to send the attributes they want set.
	AttributeValues []AttributesValue `json:"attribute_values"`
}

type UpdateProductTxResult

type UpdateProductTxResult struct {
	Product           Product             `json:"product"`
	ProductAttributes []ProductsAttribute `json:"product_attributes"`
}

type UpdateProductVariantAvgCostParams

type UpdateProductVariantAvgCostParams struct {
	CurrentQty int64 `json:"current_qty"`
	UnitCost   int64 `json:"unit_cost"`
	InQty      int64 `json:"in_qty"`
	ID         int64 `json:"id"`
}

type UpdateProductVariantParams

type UpdateProductVariantParams struct {
	ID       int64         `json:"id"`
	ColorID  sql.NullInt64 `json:"color_id"`
	SizeID   sql.NullInt64 `json:"size_id"`
	Barcode  string        `json:"barcode"`
	IsActive bool          `json:"is_active"`
}

type UpdateRecurringExpenseNextDueParams

type UpdateRecurringExpenseNextDueParams struct {
	ID        int64     `json:"id"`
	NextDueAt time.Time `json:"next_due_at"`
}

type UpdateSalespersonParams

type UpdateSalespersonParams struct {
	ID        int64         `json:"id"`
	Name      string        `json:"name"`
	CashboxID sql.NullInt64 `json:"cashbox_id"`
}

type UpdateSecuritySettingsParams added in v1.1.0

type UpdateSecuritySettingsParams struct {
	CountryFilterEnabled bool     `json:"country_filter_enabled"`
	AllowedCountries     []string `json:"allowed_countries"`
	AlwaysAllowed        []string `json:"always_allowed"`
	AutoBanEnabled       bool     `json:"auto_ban_enabled"`
	AutoBanFailedLogins  int32    `json:"auto_ban_failed_logins"`
	AutoBanMinutes       int32    `json:"auto_ban_minutes"`
}

type UpdateSizeParams

type UpdateSizeParams struct {
	ID    int64  `json:"id"`
	Name  string `json:"name"`
	Type  string `json:"type"`
	Order string `json:"order"`
}

type UpdateTransferParams

type UpdateTransferParams struct {
	ID              int64        `json:"id"`
	FromInventoryID int64        `json:"from_inventory_id"`
	ToInventoryID   int64        `json:"to_inventory_id"`
	Type            TransferType `json:"type"`
	Note            string       `json:"note"`
}

type UpdateUserParams

type UpdateUserParams struct {
	ID           int64  `json:"id"`
	Username     string `json:"username"`
	Name         string `json:"name"`
	Email        string `json:"email"`
	PasswordHash string `json:"password_hash"`
	Activated    bool   `json:"activated"`
	RoleID       int64  `json:"role_id"`
}

type UpdateWhatsAppNumberLabelParams added in v1.1.0

type UpdateWhatsAppNumberLabelParams struct {
	Label         string `json:"label"`
	MinTotalCents int64  `json:"min_total_cents"`
	ID            int64  `json:"id"`
}

type UpsertAttributeValueParams

type UpsertAttributeValueParams struct {
	AttributeID int64  `json:"attribute_id"`
	Value       string `json:"value"`
}

type UpsertBranchSettingsParams

type UpsertBranchSettingsParams struct {
	BranchID                           int64           `json:"branch_id"`
	BranchName                         string          `json:"branch_name"`
	TaxRate                            float64         `json:"tax_rate"`
	RoundingMode                       string          `json:"rounding_mode"`
	RoundingCurrency                   string          `json:"rounding_currency"`
	ExchangeRate                       int64           `json:"exchange_rate"`
	ExchangeWindowHours                int64           `json:"exchange_window_hours"`
	MarketName                         string          `json:"market_name"`
	MarketPhone                        string          `json:"market_phone"`
	MarketDescription                  string          `json:"market_description"`
	ReturnPolicy                       string          `json:"return_policy"`
	Website                            string          `json:"website"`
	Instagram                          string          `json:"instagram"`
	SocialPlatforms                    json.RawMessage `json:"social_platforms"`
	SocialHandles                      json.RawMessage `json:"social_handles"`
	SearchButtonEnabled                bool            `json:"search_button_enabled"`
	CustomItemDiscountsEnabled         bool            `json:"custom_item_discounts_enabled"`
	CustomItemPricesEnabled            bool            `json:"custom_item_prices_enabled"`
	PerUnitItemPricesEnabled           bool            `json:"per_unit_item_prices_enabled"`
	PriceChangeManualOverrideMode      bool            `json:"price_change_manual_override_mode"`
	InvoiceKeyboardMode                bool            `json:"invoice_keyboard_mode"`
	ClientRequired                     bool            `json:"client_required"`
	PageUnlockClients                  bool            `json:"page_unlock_clients"`
	PageUnlockInventory                bool            `json:"page_unlock_inventory"`
	PageUnlockTransfers                bool            `json:"page_unlock_transfers"`
	PageUnlockAttendance               bool            `json:"page_unlock_attendance"`
	PageUnlockSalespersons             bool            `json:"page_unlock_salespersons"`
	PrinterSize                        string          `json:"printer_size"`
	ReceiptWidth                       int64           `json:"receipt_width"`
	ReceiptHeight                      int64           `json:"receipt_height"`
	ReceiptEnabled                     bool            `json:"receipt_enabled"`
	ReceiptFont                        string          `json:"receipt_font"`
	ReceiptBodyFont                    string          `json:"receipt_body_font"`
	ReceiptTitleSize                   float64         `json:"receipt_title_size"`
	ReceiptBodySize                    float64         `json:"receipt_body_size"`
	ReceiptCutoff                      bool            `json:"receipt_cutoff"`
	PrinterID                          string          `json:"printer_id"`
	ReceiptPrinter                     string          `json:"receipt_printer"`
	ScreenPort                         string          `json:"screen_port"`
	AkuvoxIp                           string          `json:"akuvox_ip"`
	AkuvoxUsername                     string          `json:"akuvox_username"`
	AttendanceEnabled                  bool            `json:"attendance_enabled"`
	AttendanceDuplicateIntervalSeconds int64           `json:"attendance_duplicate_interval_seconds"`
	AttendanceCashierHistory           bool            `json:"attendance_cashier_history"`
	SplitPrimaryCurrency               string          `json:"split_primary_currency"`
	SplitPrimaryFirst                  bool            `json:"split_primary_first"`
	SplitPrimaryStep                   int64           `json:"split_primary_step"`
	OversellMode                       string          `json:"oversell_mode"`
	CloseShiftRequiresSync             bool            `json:"close_shift_requires_sync"`
	SalespersonPerInvoiceRequired      bool            `json:"salesperson_per_invoice_required"`
	NonAdminMonthNavEnabled            bool            `json:"non_admin_month_nav_enabled"`
	OpeningFloatEnabled                bool            `json:"opening_float_enabled"`
	CountOpeningCashOnClose            bool            `json:"count_opening_cash_on_close"`
	OverchangeConfirmation             bool            `json:"overchange_confirmation"`
	PageUnlockProducts                 bool            `json:"page_unlock_products"`
	HidePaymentMethodCurrency          bool            `json:"hide_payment_method_currency"`
	AutoAppendLbpZeros                 bool            `json:"auto_append_lbp_zeros"`
	AutoCloseStaleShifts               bool            `json:"auto_close_stale_shifts"`
	VisitorCounterEnabled              bool            `json:"visitor_counter_enabled"`
	ShiftReceiptUploadMode             int64           `json:"shift_receipt_upload_mode"`
	BranchPhone                        string          `json:"branch_phone"`
	MaxOverpaymentCents                int64           `json:"max_overpayment_cents"`
	DefaultOpeningFloatUsd             int64           `json:"default_opening_float_usd"`
	DefaultOpeningFloatLbp             int64           `json:"default_opening_float_lbp"`
	DisplayPrefs                       json.RawMessage `json:"display_prefs"`
	ScanByCodeEnabled                  bool            `json:"scan_by_code_enabled"`
	SoundsEnabled                      bool            `json:"sounds_enabled"`
	AttendanceManagerApprovalEnabled   bool            `json:"attendance_manager_approval_enabled"`
	ShiftReportSignatures              bool            `json:"shift_report_signatures"`
	ShiftReportUppercaseHeader         bool            `json:"shift_report_uppercase_header"`
	AutoCoverNegativeLbp               bool            `json:"auto_cover_negative_lbp"`
	ProductSearchCodeOnly              bool            `json:"product_search_code_only"`
	PriceEditRestricted                bool            `json:"price_edit_restricted"`
	PriceEditCodes                     string          `json:"price_edit_codes"`
	UnknownProductBarcode              string          `json:"unknown_product_barcode"`
	ProductSearchHiddenFields          string          `json:"product_search_hidden_fields"`
	ReceiptTheme                       string          `json:"receipt_theme"`
	ReceiptLayout                      string          `json:"receipt_layout"`
	DiscountToggle                     bool            `json:"discount_toggle"`
	DiscountToggleDefaultOff           bool            `json:"discount_toggle_default_off"`
	DealToggle                         bool            `json:"deal_toggle"`
}

type UpsertBranchSyncConflictParams

type UpsertBranchSyncConflictParams struct {
	BranchID        int64           `json:"branch_id"`
	Entity          string          `json:"entity"`
	Ref             string          `json:"ref"`
	Kind            string          `json:"kind"`
	BranchPayload   json.RawMessage `json:"branch_payload"`
	CentralClientID sql.NullInt64   `json:"central_client_id"`
}

type UpsertCashboxAccountOverrideParams

type UpsertCashboxAccountOverrideParams struct {
	BranchID         int64          `json:"branch_id"`
	CashboxAccountID int64          `json:"cashbox_account_id"`
	IsEnabled        bool           `json:"is_enabled"`
	SortOrder        sql.NullInt32  `json:"sort_order"`
	Color            sql.NullString `json:"color"`
	CurrencyCode     sql.NullString `json:"currency_code"`
}

type UpsertClientLinkParams

type UpsertClientLinkParams struct {
	BranchID       int64 `json:"branch_id"`
	RegisterID     int64 `json:"register_id"`
	BranchClientID int64 `json:"branch_client_id"`
	ClientID       int64 `json:"client_id"`
}

type UpsertDiscountListBranchParams

type UpsertDiscountListBranchParams struct {
	BranchID       int64 `json:"branch_id"`
	DiscountListID int64 `json:"discount_list_id"`
}

type UpsertDiscountListOptionItemParams added in v1.1.6

type UpsertDiscountListOptionItemParams struct {
	DiscountListID   int64 `json:"discount_list_id"`
	ProductVariantID int64 `json:"product_variant_id"`
	SaleOptionID     int64 `json:"sale_option_id"`
	Discount         int16 `json:"discount"`
}

type UpsertGoogleReviewParams added in v1.1.0

type UpsertGoogleReviewParams struct {
	PlaceID     string       `json:"place_id"`
	ReviewName  string       `json:"review_name"`
	Author      string       `json:"author"`
	AuthorPhoto string       `json:"author_photo"`
	Rating      int32        `json:"rating"`
	Body        string       `json:"body"`
	PublishedAt sql.NullTime `json:"published_at"`
}

type UpsertIPBanParams added in v1.1.0

type UpsertIPBanParams struct {
	Ip        string       `json:"ip"`
	Reason    string       `json:"reason"`
	Until     sql.NullTime `json:"until"`
	CreatedBy string       `json:"created_by"`
}

type UpsertInventoryAssetQuantityParams

type UpsertInventoryAssetQuantityParams struct {
	AssetID     int64 `json:"asset_id"`
	InventoryID int64 `json:"inventory_id"`
	Quantity    int64 `json:"quantity"`
}

type UpsertOversoldConflictParams

type UpsertOversoldConflictParams struct {
	BranchID      int64           `json:"branch_id"`
	Ref           string          `json:"ref"`
	BranchPayload json.RawMessage `json:"branch_payload"`
}

type UpsertPriceListBranchParams

type UpsertPriceListBranchParams struct {
	BranchID    int64 `json:"branch_id"`
	PriceListID int64 `json:"price_list_id"`
}

type UpsertProductAttributeParams

type UpsertProductAttributeParams struct {
	AttributeID      int64 `json:"attribute_id"`
	ProductID        int64 `json:"product_id"`
	AttributeValueID int64 `json:"attribute_value_id"`
}

type UpsertRolePermissionParams

type UpsertRolePermissionParams struct {
	RoleID  int64  `json:"role_id"`
	Section string `json:"section"`
	Page    string `json:"page"`
	CanView bool   `json:"can_view"`
	CanEdit bool   `json:"can_edit"`
}

type UpsertVisitorIPParams added in v1.1.0

type UpsertVisitorIPParams struct {
	Ip             string    `json:"ip"`
	SeenAt         time.Time `json:"seen_at"`
	Requests       int64     `json:"requests"`
	FailedLogins   int64     `json:"failed_logins"`
	Logins         int64     `json:"logins"`
	NotFound       int64     `json:"not_found"`
	Blocked        int64     `json:"blocked"`
	LastKind       string    `json:"last_kind"`
	LastUserName   string    `json:"last_user_name"`
	LastBranchName string    `json:"last_branch_name"`
	LastMethod     string    `json:"last_method"`
	LastPath       string    `json:"last_path"`
	LastStatus     int32     `json:"last_status"`
	UserAgent      string    `json:"user_agent"`
	CountryCode    string    `json:"country_code"`
	Country        string    `json:"country"`
	Region         string    `json:"region"`
	City           string    `json:"city"`
	Asn            int64     `json:"asn"`
	Network        string    `json:"network"`
}

type User

type User struct {
	ID                int64     `json:"id"`
	Name              string    `json:"name"`
	Email             string    `json:"email"`
	PasswordHash      string    `json:"password_hash"`
	PasswordChangedAt time.Time `json:"password_changed_at"`
	Activated         bool      `json:"activated"`
	Version           int32     `json:"version"`
	CreatedAt         time.Time `json:"created_at"`
	RoleID            int64     `json:"role_id"`
	Username          string    `json:"username"`
	AvatarColor       string    `json:"avatar_color"`
}

type UsersPermission

type UsersPermission struct {
	UserID       int64 `json:"user_id"`
	PermissionID int64 `json:"permission_id"`
}

type VariantDefaultDiscount

type VariantDefaultDiscount struct {
	ProductVariantID int64 `json:"product_variant_id"`
	Discount         int16 `json:"discount"`
}

type VariantDefaultPrice

type VariantDefaultPrice struct {
	ProductVariantID int64 `json:"product_variant_id"`
	Price            int64 `json:"price"`
}

type VisitorCountriesRow added in v1.1.0

type VisitorCountriesRow struct {
	CountryCode string    `json:"country_code"`
	Country     string    `json:"country"`
	Ips         int64     `json:"ips"`
	Requests    int64     `json:"requests"`
	Blocked     int64     `json:"blocked"`
	LastSeenAt  time.Time `json:"last_seen_at"`
}

type VisitorIp added in v1.1.0

type VisitorIp struct {
	Ip             string    `json:"ip"`
	FirstSeenAt    time.Time `json:"first_seen_at"`
	LastSeenAt     time.Time `json:"last_seen_at"`
	Requests       int64     `json:"requests"`
	FailedLogins   int64     `json:"failed_logins"`
	Logins         int64     `json:"logins"`
	NotFound       int64     `json:"not_found"`
	Blocked        int64     `json:"blocked"`
	LastKind       string    `json:"last_kind"`
	LastUserName   string    `json:"last_user_name"`
	LastBranchName string    `json:"last_branch_name"`
	LastMethod     string    `json:"last_method"`
	LastPath       string    `json:"last_path"`
	LastStatus     int32     `json:"last_status"`
	UserAgent      string    `json:"user_agent"`
	CountryCode    string    `json:"country_code"`
	Country        string    `json:"country"`
	Region         string    `json:"region"`
	City           string    `json:"city"`
	Asn            int64     `json:"asn"`
	Network        string    `json:"network"`
}

type WaiveUnknownItemSlotsParams added in v1.1.1

type WaiveUnknownItemSlotsParams struct {
	Column1  []int64 `json:"column_1"`
	WaivedBy string  `json:"waived_by"`
}

type WhatsAppClientsByPhoneTailRow added in v1.1.0

type WhatsAppClientsByPhoneTailRow struct {
	ID    int64  `json:"id"`
	Name  string `json:"name"`
	Phone string `json:"phone"`
	Tail  string `json:"tail"`
}

type WhatsAppFailureReasonsParams added in v1.1.0

type WhatsAppFailureReasonsParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type WhatsAppFailureReasonsRow added in v1.1.0

type WhatsAppFailureReasonsRow struct {
	Reason   string `json:"reason"`
	Messages int64  `json:"messages"`
}

type WhatsAppFailureWatchRow added in v1.1.1

type WhatsAppFailureWatchRow struct {
	Failed1h     int32     `json:"failed_1h"`
	Failed24h    int32     `json:"failed_24h"`
	LastReason   string    `json:"last_reason"`
	LastFailedAt time.Time `json:"last_failed_at"`
}

type WhatsAppMessageTotalsParams added in v1.1.0

type WhatsAppMessageTotalsParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type WhatsAppMessageTotalsRow added in v1.1.0

type WhatsAppMessageTotalsRow struct {
	Sent           int64 `json:"sent"`
	Skipped        int64 `json:"skipped"`
	Failed         int64 `json:"failed"`
	Delivered      int64 `json:"delivered"`
	Read           int64 `json:"read"`
	Undelivered    int64 `json:"undelivered"`
	CostMicros     int64 `json:"cost_micros"`
	Recipients     int64 `json:"recipients"`
	SentSalesCents int64 `json:"sent_sales_cents"`
}

type WhatsAppMessagesByBranchParams added in v1.1.0

type WhatsAppMessagesByBranchParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type WhatsAppMessagesByBranchRow added in v1.1.0

type WhatsAppMessagesByBranchRow struct {
	BranchID   int64  `json:"branch_id"`
	BranchName string `json:"branch_name"`
	Sent       int64  `json:"sent"`
	Skipped    int64  `json:"skipped"`
	Failed     int64  `json:"failed"`
	Delivered  int64  `json:"delivered"`
	Read       int64  `json:"read"`
	CostMicros int64  `json:"cost_micros"`
}

type WhatsAppMessagesByDayParams added in v1.1.0

type WhatsAppMessagesByDayParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type WhatsAppMessagesByDayRow added in v1.1.0

type WhatsAppMessagesByDayRow struct {
	Day        time.Time `json:"day"`
	Sent       int64     `json:"sent"`
	Skipped    int64     `json:"skipped"`
	Failed     int64     `json:"failed"`
	CostMicros int64     `json:"cost_micros"`
}

type WhatsAppMessagesByHourParams added in v1.1.0

type WhatsAppMessagesByHourParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type WhatsAppMessagesByHourRow added in v1.1.0

type WhatsAppMessagesByHourRow struct {
	Hour int32 `json:"hour"`
	Sent int64 `json:"sent"`
}

type WhatsAppMessagesByRuleParams added in v1.1.0

type WhatsAppMessagesByRuleParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type WhatsAppMessagesByRuleRow added in v1.1.0

type WhatsAppMessagesByRuleRow struct {
	RuleName     string `json:"rule_name"`
	Status       string `json:"status"`
	TemplateName string `json:"template_name"`
	Messages     int64  `json:"messages"`
}

type WhatsAppNumberForBranchParams added in v1.1.9

type WhatsAppNumberForBranchParams struct {
	BranchID   int64 `json:"branch_id"`
	TotalCents int64 `json:"total_cents"`
}

type WhatsAppSentForInvoiceParams added in v1.1.0

type WhatsAppSentForInvoiceParams struct {
	BranchID    sql.NullInt64 `json:"branch_id"`
	InvoiceCode string        `json:"invoice_code"`
}

type WhatsAppTopRecipientsParams added in v1.1.0

type WhatsAppTopRecipientsParams struct {
	FromAt   time.Time `json:"from_at"`
	ToAt     time.Time `json:"to_at"`
	BranchID int64     `json:"branch_id"`
}

type WhatsAppTopRecipientsRow added in v1.1.0

type WhatsAppTopRecipientsRow struct {
	ClientPhone string    `json:"client_phone"`
	ClientName  string    `json:"client_name"`
	Messages    int64     `json:"messages"`
	CostMicros  int64     `json:"cost_micros"`
	SalesCents  int64     `json:"sales_cents"`
	LastSentAt  time.Time `json:"last_sent_at"`
}

type WhatsappChatMessage added in v1.1.1

type WhatsappChatMessage struct {
	ID               int64         `json:"id"`
	Instance         string        `json:"instance"`
	WhatsappNumberID sql.NullInt64 `json:"whatsapp_number_id"`
	WaID             string        `json:"wa_id"`
	ChatJid          string        `json:"chat_jid"`
	ChatPhone        string        `json:"chat_phone"`
	ContactName      string        `json:"contact_name"`
	FromMe           bool          `json:"from_me"`
	Kind             string        `json:"kind"`
	Body             string        `json:"body"`
	MediaType        string        `json:"media_type"`
	SentAt           time.Time     `json:"sent_at"`
	CreatedAt        time.Time     `json:"created_at"`
}

type WhatsappMessage added in v1.1.0

type WhatsappMessage struct {
	ID               int64         `json:"id"`
	CreatedAt        time.Time     `json:"created_at"`
	BranchID         sql.NullInt64 `json:"branch_id"`
	InvoiceCode      string        `json:"invoice_code"`
	ClientName       string        `json:"client_name"`
	ClientPhone      string        `json:"client_phone"`
	GrandTotalCents  int64         `json:"grand_total_cents"`
	ItemCount        int32         `json:"item_count"`
	RuleID           sql.NullInt64 `json:"rule_id"`
	RuleName         string        `json:"rule_name"`
	TemplateName     string        `json:"template_name"`
	Status           string        `json:"status"`
	Reason           string        `json:"reason"`
	Wamid            string        `json:"wamid"`
	CostMicros       int64         `json:"cost_micros"`
	DeliveryStatus   string        `json:"delivery_status"`
	DeliveredAt      sql.NullTime  `json:"delivered_at"`
	ReadAt           sql.NullTime  `json:"read_at"`
	DeliveryError    string        `json:"delivery_error"`
	Billable         sql.NullBool  `json:"billable"`
	PricingCategory  string        `json:"pricing_category"`
	ReviewCode       string        `json:"review_code"`
	ReviewClickedAt  sql.NullTime  `json:"review_clicked_at"`
	Sender           string        `json:"sender"`
	WhatsappNumberID sql.NullInt64 `json:"whatsapp_number_id"`
	PollRef          string        `json:"poll_ref"`
	PollRating       sql.NullInt16 `json:"poll_rating"`
	PollAnswer       string        `json:"poll_answer"`
	PollVotedAt      sql.NullTime  `json:"poll_voted_at"`
	PollFollowupAt   sql.NullTime  `json:"poll_followup_at"`
	BridgeRef        string        `json:"bridge_ref"`
	IsTest           bool          `json:"is_test"`
	Body             string        `json:"body"`
	PollQuestion     string        `json:"poll_question"`
	PollOptions      string        `json:"poll_options"`
	FollowupBody     string        `json:"followup_body"`
}

type WhatsappNumber added in v1.1.0

type WhatsappNumber struct {
	ID            int64     `json:"id"`
	Instance      string    `json:"instance"`
	Label         string    `json:"label"`
	Phone         string    `json:"phone"`
	IsDefault     bool      `json:"is_default"`
	CreatedAt     time.Time `json:"created_at"`
	MinTotalCents int64     `json:"min_total_cents"`
}

type WhatsappPollReply added in v1.1.0

type WhatsappPollReply struct {
	ID                int64     `json:"id"`
	WhatsappMessageID int64     `json:"whatsapp_message_id"`
	WaID              string    `json:"wa_id"`
	Body              string    `json:"body"`
	Kind              string    `json:"kind"`
	ReceivedAt        time.Time `json:"received_at"`
	MediaType         string    `json:"media_type"`
}

type WhatsappReply added in v1.1.0

type WhatsappReply struct {
	ID          int64         `json:"id"`
	Wamid       string        `json:"wamid"`
	ReceivedAt  time.Time     `json:"received_at"`
	ClientPhone string        `json:"client_phone"`
	ClientName  string        `json:"client_name"`
	Kind        string        `json:"kind"`
	Body        string        `json:"body"`
	MessageID   sql.NullInt64 `json:"message_id"`
}

type WhatsappRule added in v1.1.0

type WhatsappRule struct {
	ID             int64           `json:"id"`
	Position       int32           `json:"position"`
	Name           string          `json:"name"`
	Enabled        bool            `json:"enabled"`
	Action         string          `json:"action"`
	Conditions     json.RawMessage `json:"conditions"`
	TemplateName   string          `json:"template_name"`
	TemplateLang   string          `json:"template_lang"`
	TemplateParams string          `json:"template_params"`
	CreatedAt      time.Time       `json:"created_at"`
	UpdatedAt      time.Time       `json:"updated_at"`
}

Source Files

Jump to

Keyboard shortcuts

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