Adds the dashboard side of a customer's wallet (docs/prd-point-coin.md F7, PC-107), under /marketing for admins and managers: - GET /marketing/customers/:id/wallet returns the customer, the ledger and spendable balances, every lot that still holds something (flagged when expired), and a page of history. Unlike the customer's own view, each row carries the real names behind it: the transfer counterparty, the admin or cashier, and the outlet, plus the reason and metadata. - POST /marketing/customers/:id/wallet/adjust takes a signed amount and a required reason. It writes an ADJUSTMENT pointing at the admin through the wallet engine, refuses to take more than the customer can spend, and accepts an optional idempotency key so a retried request adjusts once. Reasons describing a cash-out are refused (K7). The customer must belong to the caller's organization; otherwise both endpoints answer 404. Positive adjustments create non-expiring lots until the expiry model is decided (F12, note N4). The mapping from ledger rows to what the apps show is now shared between the customer and dashboard views. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
86 lines
3.7 KiB
Go
86 lines
3.7 KiB
Go
package constants
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
const (
|
|
InternalServerErrorCode = "900"
|
|
MissingFieldErrorCode = "303"
|
|
MalformedFieldErrorCode = "310"
|
|
ValidationErrorCode = "304"
|
|
InvalidFieldErrorCode = "305"
|
|
NotFoundErrorCode = "404"
|
|
)
|
|
|
|
const (
|
|
RequestEntity = "request"
|
|
UserServiceEntity = "user_service"
|
|
OrganizationServiceEntity = "organization_service"
|
|
CategoryServiceEntity = "category_service"
|
|
ProductServiceEntity = "product_service"
|
|
ProductVariantServiceEntity = "product_variant_service"
|
|
InventoryServiceEntity = "inventory_service"
|
|
OrderServiceEntity = "order_service"
|
|
CustomerServiceEntity = "customer_service"
|
|
UserValidatorEntity = "user_validator"
|
|
AuthHandlerEntity = "auth_handler"
|
|
UserHandlerEntity = "user_handler"
|
|
CategoryHandlerEntity = "category_handler"
|
|
ProductHandlerEntity = "product_handler"
|
|
ProductVariantHandlerEntity = "product_variant_handler"
|
|
InventoryHandlerEntity = "inventory_handler"
|
|
OrderValidatorEntity = "order_validator"
|
|
OrderHandlerEntity = "order_handler"
|
|
OrganizationValidatorEntity = "organization_validator"
|
|
OrgHandlerEntity = "organization_handler"
|
|
PaymentMethodValidatorEntity = "payment_method_validator"
|
|
PaymentMethodHandlerEntity = "payment_method_handler"
|
|
OutletServiceEntity = "outlet_service"
|
|
VendorServiceEntity = "vendor_service"
|
|
PurchaseOrderServiceEntity = "purchase_order_service"
|
|
PurchaseCategoryServiceEntity = "purchase_category_service"
|
|
IngredientUnitConverterServiceEntity = "ingredient_unit_converter_service"
|
|
IngredientCompositionServiceEntity = "ingredient_composition_service"
|
|
TableEntity = "table"
|
|
// Gamification entities
|
|
CustomerPointsEntity = "customer_points"
|
|
CustomerTokensEntity = "customer_tokens"
|
|
TierEntity = "tier"
|
|
GameEntity = "game"
|
|
GamePrizeEntity = "game_prize"
|
|
GamePlayEntity = "game_play"
|
|
OmsetTrackerEntity = "omset_tracker"
|
|
RewardEntity = "reward"
|
|
CampaignEntity = "campaign"
|
|
CampaignRuleEntity = "campaign_rule"
|
|
CustomerEntity = "customer"
|
|
SpinGameHandlerEntity = "spin_game_handler"
|
|
UserDeviceServiceEntity = "user_device_service"
|
|
NotificationServiceEntity = "notification_service"
|
|
NotificationHandlerEntity = "notification_handler"
|
|
ProductOutletPriceServiceEntity = "product_outlet_price_service"
|
|
ExpenseServiceEntity = "expense_service"
|
|
CashAdvanceServiceEntity = "cash_advance_service"
|
|
WalletServiceEntity = "wallet_service"
|
|
)
|
|
|
|
var HttpErrorMap = map[string]int{
|
|
InternalServerErrorCode: http.StatusInternalServerError,
|
|
MissingFieldErrorCode: http.StatusBadRequest,
|
|
MalformedFieldErrorCode: http.StatusBadRequest,
|
|
ValidationErrorCode: http.StatusBadRequest,
|
|
InvalidFieldErrorCode: http.StatusBadRequest,
|
|
NotFoundErrorCode: http.StatusNotFound,
|
|
}
|
|
|
|
// Error messages
|
|
var (
|
|
ErrPaymentMethodNameRequired = fmt.Errorf("payment method name is required")
|
|
ErrPaymentMethodTypeRequired = fmt.Errorf("payment method type is required")
|
|
ErrInvalidPaymentMethodType = fmt.Errorf("invalid payment method type")
|
|
ErrInvalidPageNumber = fmt.Errorf("page number must be greater than 0")
|
|
ErrInvalidLimit = fmt.Errorf("limit must be between 1 and 100")
|
|
)
|