billing

package
v0.0.0-...-cef23b5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAccessor

func NewAccessor(request *tools.APIRequest) *billMongoAccessor

func PricedByType

func PricedByType(dt tools.DataType) pricing.PricedItemITF

Types

type Bill

type Bill struct {
	utils.AbstractObject
	OrderID   string                `json:"order_id" bson:"order_id" validate:"required"`
	Status    enum.CompletionStatus `json:"status" bson:"status" default:"0"`
	SubOrders map[string]*PeerOrder `json:"sub_orders" bson:"sub_orders"`
	Total     float64               `json:"total" bson:"total" validate:"required"`
}

func DraftFirstBill

func DraftFirstBill(ord *order.Order, request *tools.APIRequest) (*Bill, error)

DraftFirstBill crée le premier brouillon de facture pour un order. Règle :

  • Calcul total indépendant du mode de paiement (photo du coût réel).
  • Les purchases sont toujours BILL_ONCE / PAY_ONCE → réglées immédiatement.
  • Les bookings avec BillingStrategy != BILL_ONCE génèrent des Subscription.
  • Chaque ligne reçoit un ItemID unique pour le suivi de règlement.

func GenerateBill

func GenerateBill(ord *order.Order, request *tools.APIRequest) (*Bill, error)

func (*Bill) CanDelete

func (r *Bill) CanDelete() bool

func (*Bill) CanUpdate

func (r *Bill) CanUpdate(set utils.DBObject) (bool, utils.DBObject)

func (*Bill) Extend

func (ri *Bill) Extend(typ ...string) map[string][]tools.DataType

func (*Bill) GetAccessor

func (d *Bill) GetAccessor(request *tools.APIRequest) utils.Accessor

func (*Bill) IsFullySettled

func (b *Bill) IsFullySettled() bool

IsFullySettled retourne vrai quand chaque ligne de chaque peer-order est réglée.

func (*Bill) MarkItemSettled

func (b *Bill) MarkItemSettled(itemID string) bool

MarkItemSettled marque une ligne comme réglée d'après son itemID et propage le statut PAID sur le PeerOrder si toutes ses lignes sont réglées.

func (*Bill) SettledTotal

func (b *Bill) SettledTotal() float64

SettledTotal retourne le montant total des lignes déjà réglées.

func (*Bill) StoreDraftDefault

func (r *Bill) StoreDraftDefault()

func (*Bill) SumUpBill

func (d *Bill) SumUpBill(request *tools.APIRequest) (*Bill, error)

type PeerItemOrder

type PeerItemOrder struct {
	// ItemID identifie de manière unique cette ligne pour le suivi de règlement.
	ItemID       string                              `json:"item_id,omitempty" bson:"item_id,omitempty"`
	ResourceType tools.DataType                      `json:"datatype,omitempty" bson:"datatype,omitempty"`
	Quantity     int                                 `json:"quantity,omitempty" bson:"quantity,omitempty"`
	Purchase     *purchase_resource.PurchaseResource `json:"purchase,omitempty" bson:"purchase,omitempty"`
	Item         map[string]interface{}              `json:"item,omitempty" bson:"item,omitempty"`

	BillingStrategy pricing.BillingStrategy `json:"billing_strategy" bson:"billing_strategy"`
	PaymentType     pricing.PaymentType     `json:"payment_type" bson:"payment_type"`

	// UnitPriceHT est le prix unitaire HT calculé par SumUpBill/GetPriceHT.
	// Utilisé pour la création des subscriptions sans recalcul.
	UnitPriceHT float64 `json:"unit_price_ht,omitempty" bson:"unit_price_ht,omitempty"`

	// SubscriptionID référence la Subscription créée pour les lignes récurrentes.
	// Vide pour les lignes BILL_ONCE.
	SubscriptionID string `json:"subscription_id,omitempty" bson:"subscription_id,omitempty"`

	// Settled indique si cette ligne a été réglée (paiement confirmé).
	Settled   bool       `json:"settled" bson:"settled"`
	SettledAt *time.Time `json:"settled_at,omitempty" bson:"settled_at,omitempty"`
}

PeerItemOrder est une ligne de facture pour un peer donné.

func (*PeerItemOrder) GetPriceHT

func (d *PeerItemOrder) GetPriceHT(request *tools.APIRequest) (float64, error)

type PeerOrder

type PeerOrder struct {
	Error          string                `json:"error,omitempty" bson:"error,omitempty"`
	PeerID         string                `json:"peer_id,omitempty" bson:"peer_id,omitempty"`
	Status         enum.CompletionStatus `json:"status" bson:"status" default:"0"`
	BillingAddress string                `json:"billing_address,omitempty" bson:"billing_address,omitempty"`
	Items          []*PeerItemOrder      `json:"items,omitempty" bson:"items,omitempty"`
	Total          float64               `json:"total,omitempty" bson:"total,omitempty"`
}

func (*PeerOrder) IsFullySettled

func (po *PeerOrder) IsFullySettled() bool

IsFullySettled retourne vrai si toutes les lignes de ce peer sont réglées.

func (*PeerOrder) Pay

func (d *PeerOrder) Pay(request *tools.APIRequest, response chan *PeerOrder, wg *sync.WaitGroup)

func (*PeerOrder) SumUpBill

func (d *PeerOrder) SumUpBill(request *tools.APIRequest) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址