Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreditNote ¶
type CreditNote struct {
// id is the unique identifier for the credit note
ID string `json:"id"`
// credit_note_number is the unique identifier for credit notes
CreditNoteNumber string `json:"credit_note_number"`
// invoice_id is the id of the invoice resource that this credit note is applied to
InvoiceID string `json:"invoice_id"`
// customer_id is the unique identifier of the customer who owns this credit note
CustomerID string `json:"customer_id"`
// subscription_id is the optional unique identifier of the subscription related to this credit note
SubscriptionID *string `json:"subscription_id,omitempty"`
// credit_note_status represents the current status of the credit note (e.g., draft, finalized, voided)
CreditNoteStatus types.CreditNoteStatus `json:"credit_note_status"`
// credit_note_type indicates the type of credit note (refund, adjustment)
CreditNoteType types.CreditNoteType `json:"credit_note_type"`
// refund_status represents the status of any refund associated with this credit note
RefundStatus *types.PaymentStatus `json:"refund_status"`
// reason specifies the reason for creating this credit note (duplicate, fraudulent, order_change, product_unsatisfactory)
Reason types.CreditNoteReason `json:"reason"`
// memo is an optional memo supplied on the credit note
Memo string `json:"memo"`
// currency is the three-letter ISO currency code (e.g., USD, EUR) for the credit note
Currency string `json:"currency"`
// metadata contains additional custom key-value pairs for storing extra information
Metadata types.Metadata `json:"metadata"`
// line_items contains all of the line items associated with this credit note
LineItems []*CreditNoteLineItem `json:"line_items"`
// environment_id is the unique identifier of the environment this credit note belongs to
EnvironmentID string `json:"environment_id"`
// total_amount is the total including creditable invoice-level discounts or minimums, and tax
TotalAmount decimal.Decimal `json:"total_amount"`
// voided_at is the timestamp when the credit note was voided
VoidedAt *time.Time `json:"voided_at,omitempty"`
// finalized_at is the timestamp when the credit note was finalized
FinalizedAt *time.Time `json:"finalized_at,omitempty"`
// idempotency_key is an optional key used to prevent duplicate credit note creation
IdempotencyKey *string `json:"idempotency_key"`
types.BaseModel
}
CreditNote is the model entity for the CreditNote schema.
func FromEnt ¶
func FromEnt(e *ent.CreditNote) *CreditNote
FromEnt converts an ent credit note to domain credit note
func FromEntList ¶
func FromEntList(creditNotes []*ent.CreditNote) []*CreditNote
FromEntList converts a list of ent credit notes to domain credit notes
type CreditNoteLineItem ¶
type CreditNoteLineItem struct {
ID string `json:"id"`
CreditNoteID string `json:"credit_note_id"`
InvoiceLineItemID string `json:"invoice_line_item_id"`
DisplayName string `json:"display_name"`
Amount decimal.Decimal `json:"amount"`
Currency string `json:"currency"`
Metadata types.Metadata `json:"metadata"`
EnvironmentID string `json:"environment_id"`
types.BaseModel
}
CreditNoteLineItem is the model entity for the CreditNoteLineItem schema.
func (*CreditNoteLineItem) FromEnt ¶
func (c *CreditNoteLineItem) FromEnt(e *ent.CreditNoteLineItem)
FromEnt converts an ent.CreditNoteLineItem to domain CreditNoteLineItem
func (*CreditNoteLineItem) FromEntList ¶
func (c *CreditNoteLineItem) FromEntList(creditNoteLineItems []*ent.CreditNoteLineItem) []*CreditNoteLineItem
type CreditNoteLineItemRepository ¶
type CreditNoteLineItemRepository interface {
Create(ctx context.Context, lineItem *CreditNoteLineItem) error
Get(ctx context.Context, id string) (*CreditNoteLineItem, error)
Update(ctx context.Context, lineItem *CreditNoteLineItem) error
Delete(ctx context.Context, id string) error
List(ctx context.Context, filter *types.CreditNoteLineItemFilter) ([]*CreditNoteLineItem, error)
Count(ctx context.Context, filter *types.CreditNoteLineItemFilter) (int, error)
ListByCreditNote(ctx context.Context, creditNoteID string) ([]*CreditNoteLineItem, error)
ListByInvoiceLineItem(ctx context.Context, invoiceLineItemID string) ([]*CreditNoteLineItem, error)
CreateBulk(ctx context.Context, lineItems []*CreditNoteLineItem) error
}
type Repository ¶
type Repository interface {
// Core invoice operations
Create(ctx context.Context, inv *CreditNote) error
Get(ctx context.Context, id string) (*CreditNote, error)
Update(ctx context.Context, inv *CreditNote) error
Delete(ctx context.Context, id string) error
List(ctx context.Context, filter *types.CreditNoteFilter) ([]*CreditNote, error)
Count(ctx context.Context, filter *types.CreditNoteFilter) (int, error)
// Edge-specific operations
AddLineItems(ctx context.Context, creditNoteID string, items []*CreditNoteLineItem) error
RemoveLineItems(ctx context.Context, creditNoteID string, itemIDs []string) error
// Bulk operations with edges
CreateWithLineItems(ctx context.Context, inv *CreditNote) error
// Idempotency operations
GetByIdempotencyKey(ctx context.Context, key string) (*CreditNote, error)
}
Repository defines the interface for invoice persistence operations
Click to show internal directories.
Click to hide internal directories.