Documentation
¶
Index ¶
- func NewAccessor(request *tools.APIRequest) *billMongoAccessor
- func PricedByType(dt tools.DataType) pricing.PricedItemITF
- type Bill
- func (r *Bill) CanDelete() bool
- func (r *Bill) CanUpdate(set utils.DBObject) (bool, utils.DBObject)
- func (ri *Bill) Extend(typ ...string) map[string][]tools.DataType
- func (d *Bill) GetAccessor(request *tools.APIRequest) utils.Accessor
- func (b *Bill) IsFullySettled() bool
- func (b *Bill) MarkItemSettled(itemID string) bool
- func (b *Bill) SettledTotal() float64
- func (r *Bill) StoreDraftDefault()
- func (d *Bill) SumUpBill(request *tools.APIRequest) (*Bill, error)
- type PeerItemOrder
- type PeerOrder
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 ¶
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 (*Bill) GetAccessor ¶
func (d *Bill) GetAccessor(request *tools.APIRequest) utils.Accessor
func (*Bill) IsFullySettled ¶
IsFullySettled retourne vrai quand chaque ligne de chaque peer-order est réglée.
func (*Bill) MarkItemSettled ¶
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 ¶
SettledTotal retourne le montant total des lignes déjà réglées.
func (*Bill) StoreDraftDefault ¶
func (r *Bill) StoreDraftDefault()
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 ¶
IsFullySettled retourne vrai si toutes les lignes de ce peer sont réglées.
Click to show internal directories.
Click to hide internal directories.