Files
efrilmandClaude Opus 5.5 c1ec6a3dfd 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>
2026-09-30 19:21:13 +07:00

50 lines
1.4 KiB
Go

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
}