feat(customer): list the customer's outlets
Adds GET /customer/outlets for the customer app: the active outlets of the customer's organization, where their EnakPoint and EnakCoin can be used, sorted by name. Each carries its name and address, and from the outlet's loyalty settings whether the cashier accepts EnakPoint and whether orders there earn EnakPoint or EnakCoin. Nothing internal (printer settings, tax rate) is exposed. The outlets list under /outlets needs a staff token, so the app had no way to show where the wallet works. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8bf2fe5585
commit
c1ec6a3dfd
@@ -0,0 +1,49 @@
|
||||
package processor
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"apskel-pos-be/internal/models"
|
||||
"apskel-pos-be/internal/repository"
|
||||
)
|
||||
|
||||
// CustomerOutletProcessor lists the outlets the customer app shows: the active
|
||||
// outlets of the customer's organization, where their wallet can be used (K4).
|
||||
type CustomerOutletProcessor struct {
|
||||
repo repository.CustomerOutletRepository
|
||||
settings outletSettingsReader
|
||||
}
|
||||
|
||||
func NewCustomerOutletProcessor(repo repository.CustomerOutletRepository, settings outletSettingsReader) *CustomerOutletProcessor {
|
||||
return &CustomerOutletProcessor{repo: repo, settings: settings}
|
||||
}
|
||||
|
||||
// List is GET /customer/outlets.
|
||||
func (p *CustomerOutletProcessor) List(ctx context.Context, customerID uuid.UUID) ([]models.CustomerOutlet, error) {
|
||||
organizationID, err := p.repo.CustomerOrganizationID(ctx, customerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
outlets, err := p.repo.ListActiveOutlets(ctx, organizationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]models.CustomerOutlet, 0, len(outlets))
|
||||
for _, o := range outlets {
|
||||
settings, err := p.settings.Outlet(ctx, o.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list = append(list, models.CustomerOutlet{
|
||||
ID: o.ID,
|
||||
Name: o.Name,
|
||||
Address: o.Address,
|
||||
AcceptsPointPayment: settings.PointPayment.AcceptPayment,
|
||||
EarnsPoints: settings.Point.Enabled,
|
||||
EarnsCoins: settings.Coin.Enabled,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
Reference in New Issue
Block a user