Files
zeekay 1943f1c093 Hanzo Commerce
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans,
usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0.

Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
2026-09-23 21:52:16 -07:00

24 lines
700 B
Go

package order
import (
"github.com/zap-proto/zip"
"github.com/hanzoai/commerce/datastore"
"github.com/hanzoai/commerce/middleware"
return_ "github.com/hanzoai/commerce/models/return"
"github.com/hanzoai/commerce/util/json/http"
)
func Returns(c *zip.Ctx) error {
id := c.Param("orderid")
// Per-org store (Red MED-1): returns are children of the order in the caller
// org's store; systemDB (datastore.New) would list nothing once the resolver
// is installed.
org := middleware.GetOrganization(c)
db := datastore.NewNamespaced(org.Namespaced(c.Context()))
rtns := make([]*return_.Return, 0)
return_.Query(db).Filter("OrderId=", id).GetAll(&rtns)
return http.Render(c, 200, rtns)
}