Documentation
¶
Index ¶
- func AccountTransactionListPresenter(ctx context.Context, resp *pb.ListAccountTransactionsResponse) *apiresource.List[apiresource.TransactionDetail]
- func TransactionAllocationPresenter(a *pb.TransactionAllocationInfo) apiresource.TransactionAllocation
- func TransactionDetailPresenter(ctx context.Context, d *pb.TransactionInfo) apiresource.TransactionDetail
- func TransactionListPresenter(ctx context.Context, resp *pb.ListTransactionsResponse) *apiresource.List[apiresource.TransactionSummary]
- func TransactionSummaryPresenter(d *pb.TransactionSummaryInfo) apiresource.TransactionSummary
- type CreateTransactionEndpoint
- type CreateTransactionRequest
- type DeleteTransactionEndpoint
- type DeleteTransactionRequest
- type ListAccountTransactionsEndpoint
- type ListAccountTransactionsRequest
- type ListAdjustmentTypesEndpoint
- type ListAdjustmentTypesRequest
- type ListTransactionMethodsEndpoint
- type ListTransactionMethodsRequest
- type ListTransactionTypesEndpoint
- type ListTransactionTypesRequest
- type ListTransactionsEndpoint
- type ListTransactionsRequest
- type RetrieveTransactionEndpoint
- type RetrieveTransactionRequest
- type TransactionSvc
- type TransactionSvcConfig
- type UpdateTransactionEndpoint
- type UpdateTransactionRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccountTransactionListPresenter ¶
func AccountTransactionListPresenter(ctx context.Context, resp *pb.ListAccountTransactionsResponse) *apiresource.List[apiresource.TransactionDetail]
func TransactionAllocationPresenter ¶
func TransactionAllocationPresenter(a *pb.TransactionAllocationInfo) apiresource.TransactionAllocation
func TransactionDetailPresenter ¶
func TransactionDetailPresenter(ctx context.Context, d *pb.TransactionInfo) apiresource.TransactionDetail
TransactionDetailPresenter builds the transaction detail resource and stashes the expandable sub-resource data (customer FK, responsible_user FK, allocations) in the request-scoped LoadMeta so the include resolver can populate them when requested. Expandable fields stay nil here — never fabricated.
func TransactionListPresenter ¶
func TransactionListPresenter(ctx context.Context, resp *pb.ListTransactionsResponse) *apiresource.List[apiresource.TransactionSummary]
func TransactionSummaryPresenter ¶
func TransactionSummaryPresenter(d *pb.TransactionSummaryInfo) apiresource.TransactionSummary
Types ¶
type CreateTransactionEndpoint ¶
type CreateTransactionEndpoint struct{}
Records a financial transaction against a customer, such as a payment received, a credit memo, an adjustment, or a rebate.
The transaction number is assigned automatically from the account's transaction sequence. The new transaction starts out unapplied, so it shows up as an open credit until it is applied to invoices by recording a settlement.
func (*CreateTransactionEndpoint) Materialize ¶
func (e *CreateTransactionEndpoint) Materialize() *apiendpoint.APIEndpoint[*CreateTransactionRequest, *apiresource.TransactionDetail]
type CreateTransactionRequest ¶
type CreateTransactionRequest struct {
// ID of the customer the transaction is recorded against.
CustomerID string `json:"customer_id" validate:"required"`
// Transaction type code.
//
// - `payment`: money received from the customer.
// - `credit_memo`: a credit issued to the customer.
// - `adjustment`: a manual correction (also provide `adjustment_type`).
// - `rebate`: a rebate granted to the customer.
TransactionTypeCode string `json:"type" validate:"required,max=255"`
// Transaction amount as a decimal string, in US dollars.
Amount string `json:"amount" validate:"required"`
// How the money moved: one of `cash`, `check`, `credit_card`, `gift_card`, or `ach`.
//
// Typically provided for payment transactions.
TransactionMethodCode field.Optional[string] `json:"method,omitzero" validate:"omitempty,max=255"`
// The kind of correction this transaction represents (see List Adjustment Types for available values).
//
// Typically provided when `type` is `adjustment`.
AdjustmentTypeCode field.Optional[string] `json:"adjustment_type,omitzero" validate:"omitempty,max=255"`
// ID of the account user responsible for the transaction.
//
// When omitted, the account user making the request is recorded as responsible.
ResponsibleUserID field.Optional[string] `json:"responsible_user_id,omitzero" validate:"omitempty"`
// Free-form note attached to the transaction.
Note field.Optional[string] `json:"note,omitzero"`
}
Request to create a transaction.
func (*CreateTransactionRequest) SchemaExample ¶
func (*CreateTransactionRequest) SchemaExample() any
type DeleteTransactionEndpoint ¶
type DeleteTransactionEndpoint struct{}
Deletes a transaction along with every allocation that applied it to an invoice, and returns the deleted transaction.
Invoice payment status is not recomputed, so an invoice this transaction had paid off stays marked paid in full until the next settlement against it recalculates the flag. Deleting a transaction that was already deleted returns an already-deleted error rather than a not-found error.
func (*DeleteTransactionEndpoint) Materialize ¶
func (e *DeleteTransactionEndpoint) Materialize() *apiendpoint.APIEndpoint[*DeleteTransactionRequest, *apiresource.TransactionDetail]
type DeleteTransactionRequest ¶
type DeleteTransactionRequest struct {
// Transaction ID.
TransactionID string `path:"id" validate:"required"`
}
Request to delete a transaction.
type ListAccountTransactionsEndpoint ¶
type ListAccountTransactionsEndpoint struct{}
Returns a paginated list of the transactions recorded against one customer account, newest first.
Transactions recorded against that customer's child accounts are included by default. Free-text search matches the transaction number and note.
func (*ListAccountTransactionsEndpoint) Materialize ¶
func (e *ListAccountTransactionsEndpoint) Materialize() *apiendpoint.APIEndpoint[*ListAccountTransactionsRequest, *apiresource.List[apiresource.TransactionDetail]]
type ListAccountTransactionsRequest ¶
type ListAccountTransactionsRequest struct {
apiresource.PaginationRequest
// Customer account ID.
CustomerAccountID string `path:"account_id" validate:"required"`
// Filter by allocation status: `allocated` (marked fully applied to invoices) or `unallocated` (still counted as an open credit).
Status *string `query:"status"`
// Filter by transaction type code (`payment`, `credit_memo`, `adjustment`, or `rebate`).
Type *string `query:"type"`
}
Request to list transactions for a customer account.
type ListAdjustmentTypesEndpoint ¶
type ListAdjustmentTypesEndpoint struct{}
Returns a paginated list of the adjustment categories that can be recorded on an adjustment transaction, such as discounts, fees, and write-offs.
Adjustment types are platform-provided and identical for every account. Free-text search matches the display name.
func (*ListAdjustmentTypesEndpoint) Materialize ¶
func (e *ListAdjustmentTypesEndpoint) Materialize() *apiendpoint.APIEndpoint[*ListAdjustmentTypesRequest, *apiresource.List[apiresource.AdjustmentType]]
type ListAdjustmentTypesRequest ¶
type ListAdjustmentTypesRequest struct {
apiresource.PaginationRequest
}
Request to list adjustment types.
type ListTransactionMethodsEndpoint ¶
type ListTransactionMethodsEndpoint struct{}
Returns the payment methods that can be recorded on a transaction, such as cash, check, and ACH.
The set is fixed by the platform and identical for every account, so the results come back in one page; supplying a pagination cursor returns a validation error. Free-text search matches the display name.
func (*ListTransactionMethodsEndpoint) Materialize ¶
func (e *ListTransactionMethodsEndpoint) Materialize() *apiendpoint.APIEndpoint[*ListTransactionMethodsRequest, *apiresource.List[apiresource.TransactionMethod]]
type ListTransactionMethodsRequest ¶
type ListTransactionMethodsRequest struct {
apiresource.PaginationRequest
}
Request to list transaction methods.
type ListTransactionTypesEndpoint ¶
type ListTransactionTypesEndpoint struct{}
Returns the transaction types that can be recorded against a customer: payments, credit memos, adjustments, and rebates.
The set is fixed by the platform and identical for every account, so the results come back in one page; supplying a pagination cursor returns a validation error. Free-text search matches the display name.
func (*ListTransactionTypesEndpoint) Materialize ¶
func (e *ListTransactionTypesEndpoint) Materialize() *apiendpoint.APIEndpoint[*ListTransactionTypesRequest, *apiresource.List[apiresource.TransactionType]]
type ListTransactionTypesRequest ¶
type ListTransactionTypesRequest struct {
apiresource.PaginationRequest
}
Request to list transaction types.
type ListTransactionsEndpoint ¶
type ListTransactionsEndpoint struct{}
Returns a paginated list of transactions for the current account, newest first.
Free-text search matches the transaction number and note.
func (*ListTransactionsEndpoint) Materialize ¶
func (e *ListTransactionsEndpoint) Materialize() *apiendpoint.APIEndpoint[*ListTransactionsRequest, *apiresource.List[apiresource.TransactionSummary]]
type ListTransactionsRequest ¶
type ListTransactionsRequest struct {
apiresource.PaginationRequest
// Filter by allocation status: `allocated` (marked fully applied to invoices) or `unallocated` (still counted as an open credit).
Status *string `query:"status"`
// Filter by transaction type codes (`payment`, `credit_memo`, `adjustment`, `rebate`).
TypeCodes []string `query:"types"`
// Filter by adjustment type codes (see List Adjustment Types for available values).
AdjustmentTypeCodes []string `query:"adjustment_types"`
// Filter by payment method codes (`cash`, `check`, `credit_card`, `gift_card`, `ach`).
MethodCodes []string `query:"methods"`
// Filter by customer IDs.
CustomerIDs []string `query:"customer_ids"`
// Filter by the account group each customer belongs to.
CustomerGroupIDs []string `query:"customer_group_ids"`
// Only include transactions created on or after this date (`YYYY-MM-DD`).
StartDate *string `query:"starts_at"`
// Only include transactions created on or before this date (`YYYY-MM-DD`), covering that whole day.
EndDate *string `query:"ends_at"`
}
Request to list transactions.
type RetrieveTransactionEndpoint ¶
type RetrieveTransactionEndpoint struct{}
Returns a transaction by ID.
func (*RetrieveTransactionEndpoint) Materialize ¶
func (e *RetrieveTransactionEndpoint) Materialize() *apiendpoint.APIEndpoint[*RetrieveTransactionRequest, *apiresource.TransactionDetail]
type RetrieveTransactionRequest ¶
type RetrieveTransactionRequest struct {
// Transaction ID.
TransactionID string `path:"id" validate:"required"`
// Sub-resources to include in the response.
Includes []string `include:"true"`
}
Request to get a transaction.
type TransactionSvc ¶
type TransactionSvc interface {
ListTransactions(ctx context.Context, req *ListTransactionsRequest) (*apiresource.List[apiresource.TransactionSummary], *apierror.APIError)
GetTransaction(ctx context.Context, req *RetrieveTransactionRequest) (*apiresource.TransactionDetail, *apierror.APIError)
CreateTransaction(ctx context.Context, req *CreateTransactionRequest) (*apiresource.TransactionDetail, *apierror.APIError)
UpdateTransaction(ctx context.Context, req *UpdateTransactionRequest) (*apiresource.TransactionDetail, *apierror.APIError)
DeleteTransaction(ctx context.Context, req *DeleteTransactionRequest) (*apiresource.TransactionDetail, *apierror.APIError)
ListAccountTransactions(ctx context.Context, req *ListAccountTransactionsRequest) (*apiresource.List[apiresource.TransactionDetail], *apierror.APIError)
ListTransactionTypes(ctx context.Context, req *ListTransactionTypesRequest) (*apiresource.List[apiresource.TransactionType], *apierror.APIError)
ListTransactionMethods(ctx context.Context, req *ListTransactionMethodsRequest) (*apiresource.List[apiresource.TransactionMethod], *apierror.APIError)
ListAdjustmentTypes(ctx context.Context, req *ListAdjustmentTypesRequest) (*apiresource.List[apiresource.AdjustmentType], *apierror.APIError)
}
func NewTransactionSvc ¶
func NewTransactionSvc(config *TransactionSvcConfig) TransactionSvc
type TransactionSvcConfig ¶
type TransactionSvcConfig struct {
// CoreClient (required) is the core-service gRPC client.
CoreClient pb.CoreServiceClient
}
type UpdateTransactionEndpoint ¶
type UpdateTransactionEndpoint struct{}
Updates a transaction, changing only the fields present in the request body.
Changing the amount does not re-apply the transaction to invoices: existing allocations keep their amounts, and neither the transaction's `is_fully_allocated` flag nor the paid-in-full status of any settled invoice is recomputed.
func (*UpdateTransactionEndpoint) Materialize ¶
func (e *UpdateTransactionEndpoint) Materialize() *apiendpoint.APIEndpoint[*UpdateTransactionRequest, *apiresource.TransactionDetail]
type UpdateTransactionRequest ¶
type UpdateTransactionRequest struct {
// Transaction ID.
TransactionID string `path:"id" validate:"required"`
// New transaction number.
//
// Must be unique within the account; the request fails with a conflict error if another transaction already uses it.
Number field.Optional[string] `json:"number,omitzero" validate:"omitempty,max=255"`
// Free-form note attached to the transaction.
Note field.Optional[string] `json:"note,omitzero"`
// New transaction amount as a decimal string, in US dollars.
Amount field.Optional[string] `json:"amount,omitzero"`
// How the money moved: one of `cash`, `check`, `credit_card`, `gift_card`, or `ach`.
TransactionMethodCode field.Optional[string] `json:"method,omitzero" validate:"omitempty,max=255"`
// The kind of correction this transaction represents (see List Adjustment Types for available values).
AdjustmentTypeCode field.Optional[string] `json:"adjustment_type,omitzero" validate:"omitempty,max=255"`
// ID of the account user responsible for the transaction.
//
// A user ID is also accepted; the value is resolved to an account user in the current account.
ResponsibleUserID field.Optional[string] `json:"responsible_user_id,omitzero" validate:"omitempty"`
// Set to true to clear the responsible user.
//
// Takes precedence over `responsible_user_id` if both are provided.
ClearResponsibleUser bool `json:"clear_responsible_user"`
// Set to true to clear the transaction method.
//
// Takes precedence over `method` if both are provided.
ClearTransactionMethod bool `json:"clear_transaction_method"`
// Set to true to clear the adjustment type.
//
// Takes precedence over `adjustment_type` if both are provided.
ClearAdjustmentType bool `json:"clear_adjustment_type"`
// Whether the full transaction amount has been applied to invoices.
//
// Set this to correct the flag by hand: editing or deleting individual allocations never recomputes it. While it is `false`, the transaction is returned by List Open Credits.
IsFullyAllocated field.Optional[bool] `json:"is_fully_allocated,omitzero"`
}
Request to update a transaction.
func (*UpdateTransactionRequest) SchemaExample ¶
func (*UpdateTransactionRequest) SchemaExample() any
Source Files
¶
- endpoint_create_transaction.go
- endpoint_delete_transaction.go
- endpoint_list_account_transactions.go
- endpoint_list_adjustment_types.go
- endpoint_list_transaction_methods.go
- endpoint_list_transaction_types.go
- endpoint_list_transactions.go
- endpoint_retrieve_transaction.go
- endpoint_update_transaction.go
- presenter.go
- service.go