set up unfonctionnal rework, TODO -> pricing separation

This commit is contained in:
mr
2024-12-17 10:42:00 +01:00
parent 7696f065f8
commit be3b09b683
20 changed files with 199 additions and 174 deletions

View File

@@ -0,0 +1,30 @@
package purchase_resource
import (
"time"
"cloud.o-forge.io/core/oc-lib/models/utils"
"cloud.o-forge.io/core/oc-lib/tools"
)
type PurchaseResource struct {
utils.AbstractObject
EndDate *time.Time `json:"end_buying_date,omitempty" bson:"end_buying_date,omitempty"`
ResourceID string `json:"resource_id" bson:"resource_id" validate:"required"`
ResourceType tools.DataType `json:"resource_type" bson:"resource_type" validate:"required"`
}
func (d *PurchaseResource) GetAccessor(request *tools.APIRequest) utils.Accessor {
return NewAccessor(request) // Create a new instance of the accessor
}
func (r *PurchaseResource) CanUpdate(set utils.DBObject) (bool, utils.DBObject) {
return r.IsDraft, set // only draft buying can be updated
}
func (r *PurchaseResource) CanDelete() bool { // ENDBuyingDate is passed
if r.EndDate != nil {
return time.Now().UTC().After(*r.EndDate)
}
return false // only draft bookings can be deleted
}