Order Flow Payment Draft

This commit is contained in:
mr
2025-01-13 11:24:07 +01:00
parent be3b09b683
commit 21a7ff9010
22 changed files with 436 additions and 490 deletions

View File

@@ -115,10 +115,10 @@ func (o *Order) draftStoreFromModel(scheduler *workflow_execution.WorkflowSchedu
// set the name of the order
resourcesByPeer := map[string][]pricing.PricedItemITF{} // create a map of resources by peer
processings := scheduler.Workflow.GetPricedItem(scheduler.Workflow.IsProcessing) // get the processing items
datas := scheduler.Workflow.GetPricedItem(scheduler.Workflow.IsData) // get the data items
storages := scheduler.Workflow.GetPricedItem(scheduler.Workflow.IsStorage) // get the storage items
workflows := scheduler.Workflow.GetPricedItem(scheduler.Workflow.IsWorkflow) // get the workflow items
processings := scheduler.Workflow.GetPricedItem(scheduler.Workflow.IsProcessing, request) // get the processing items
datas := scheduler.Workflow.GetPricedItem(scheduler.Workflow.IsData, request) // get the data items
storages := scheduler.Workflow.GetPricedItem(scheduler.Workflow.IsStorage, request) // get the storage items
workflows := scheduler.Workflow.GetPricedItem(scheduler.Workflow.IsWorkflow, request) // get the workflow items
for _, items := range []map[string]pricing.PricedItemITF{processings, datas, storages, workflows} {
for _, item := range items {
if _, ok := resourcesByPeer[item.GetCreatorID()]; !ok {
@@ -134,7 +134,7 @@ func (o *Order) draftStoreFromModel(scheduler *workflow_execution.WorkflowSchedu
}
peerOrder.GenerateID()
for _, resource := range resources {
peerOrder.AddItem(resource, len(scheduler.WorkflowExecutions)) // TODO SPECIALS REF ADDITIONALS NOTES
peerOrder.AddItem(resource, len(resources)) // TODO SPECIALS REF ADDITIONALS NOTES
}
o.SubOrders[peerOrder.GetID()] = peerOrder
}
@@ -172,7 +172,11 @@ func (o *Order) draftBookOrder(scheduler *workflow_execution.WorkflowSchedule, r
return draftedBookings, errors.New("no request found")
}
for _, exec := range scheduler.WorkflowExecutions {
bookings := exec.Book(scheduler.Workflow)
_, priceds, _, err := scheduler.Workflow.Planify(exec.ExecDate, exec.EndDate, request)
if err != nil {
return draftedBookings, errors.New("could not planify the workflow" + fmt.Sprintf("%v", err))
}
bookings := exec.Book(priceds)
for _, booking := range bookings {
_, err := (&peer.Peer{}).LaunchPeerExecution(booking.DestPeerID, "",
tools.BOOKING, tools.POST, booking.Serialize(booking), request.Caller)
@@ -261,7 +265,7 @@ func (d *PeerOrder) Pay(request *tools.APIRequest, response chan *PeerOrder, wg
d.Status = PAID // TO REMOVE LATER IT'S A MOCK
if d.Status == PAID {
for _, b := range d.Items {
if !b.Item.IsPurchased(request) {
if !b.Item.IsPurchased() {
continue
}
accessor := purchase_resource.NewAccessor(request)
@@ -322,7 +326,7 @@ func (d *PeerItemOrder) GetPrice(request *tools.APIRequest) (float64, error) {
}
}
}
p, err := d.Item.GetPrice(request)
p, err := d.Item.GetPrice()
if err != nil {
return 0, err
}