PR Create: Based on Fairmarkit Request

Process Diagram

sequenceDiagram
actor ERP_User as Business User
participant ERP_System as ERP/P2P System
participant ERP_Middleware as ERP Middleware
participant Fairmarkit_API as Fairmarkit Public API
participant Fairmarkit_APP as Fairmarkit System

# note over ERP_User: PR Intercept and Create flows via Public API

rect rgb(125,125,125,.2)
  note over ERP_User,Fairmarkit_APP: PR Create from Request (via API)
    note right of ERP_User: 1. Creates a new Request in the Fairmarkit. 
    ERP_User->>Fairmarkit_APP: -
    Fairmarkit_APP-->>Fairmarkit_APP: -
note over Fairmarkit_APP: 1. Validates the data.<br>2. Creates the request in Fairmarkit’s database. 
note right of ERP_User: 1. Reviews the request and submits.<br>2. Depending on automation rules or manual action,<br>the Purchase Requisition (PR) creation flow starts.
    ERP_User->>Fairmarkit_APP: -
    Fairmarkit_APP-->>Fairmarkit_APP: -
    note over Fairmarkit_APP: 1. Processes the data, changes the status.<br>2. Sends the webhook notification. 
    Fairmarkit_APP ->> Fairmarkit_API: **WEBHOOK** event **AWAITING_PR_CREATE**
    Fairmarkit_API ->> ERP_Middleware: **WEBHOOK** event **AWAITING_PR_CREATE**
    ERP_Middleware-->>ERP_Middleware: -
    note over ERP_Middleware: 1. Parses the payload,<br>2. Logs the data.<br>3. Enriches data if needed.<br>4. Prepares payload needed for<br> the PR creation in the ERP. 
alt successful case
    ERP_Middleware ->> ERP_System: Makes an internal "Create PR" call.
    ERP_System-->>ERP_System: -
    note over ERP_System: 1. Creates new PR locally.<br>2. Triggers Approvals.<br>...<br>n.etc... 
    ERP_System -->> ERP_Middleware: Response: details of the newly created PR
    ERP_Middleware ->> Fairmarkit_API: **POST** /self-service/api/v3/requests/{uuid}/pr/link/
    Fairmarkit_API ->> Fairmarkit_APP: Calls the internal API call to link PR and RFQ
    note over Fairmarkit_APP: 1. Adds the link to the<br>newly created PR. 
    Fairmarkit_APP-->>Fairmarkit_APP: -
else error case
    ERP_Middleware-->>ERP_Middleware: -
    note over ERP_Middleware: 1. Data validation Failed or PR Creation process failed 
    ERP_Middleware ->> Fairmarkit_API: **POST** /self-service/api/v3/requests/{uuid}/pr/mark-as-failed/
    Fairmarkit_API ->> Fairmarkit_APP: Calls the internal API to store Error details
    note over Fairmarkit_APP: 1. Adds errors to the<br>newly created PR. 
    Fairmarkit_APP-->>Fairmarkit_APP: -
    note over Fairmarkit_APP: 1. Changes Request status to draft<br>to allow user to provide changes. 
    Fairmarkit_APP-->>Fairmarkit_APP: -
end
opt
    note right of ERP_User: 1. Works with the PR and do some changes (e.g. status).
    ERP_User->>ERP_System: -
    ERP_System -->> ERP_Middleware: Notify middleware on the PR status update
    ERP_Middleware ->> Fairmarkit_API: **POST** /self-service/api/v3/requests/{uuid}/pr/status/
    Fairmarkit_API ->> Fairmarkit_APP: Calls the internal API to store the Status Update
    note over Fairmarkit_APP: 1. Stores the PR status update 
    Fairmarkit_APP-->>Fairmarkit_APP: -
end
end

Process Flow

  1. User creates a request in the Fairmarkit (FM) application.
  2. Optional: Price-book Automation can identify the product by title. The user can confirm or reject the Price-Book search result
  3. User reviews the request and clicks the Create Purchase Requisition button.
  4. User selects a Supplier from the available list. In the case of the Price-book Automation, the supplier is already selected on the Pop-Up.
  5. Fairmarkit app triggers a webhook and sends the request to the pre-configured endpoint. The event name -REQUEST_AWAITING_PR_CREATE
  6. Fairmarkit is blocking the Request from editing in "Creating PR" status and is waiting for the API Calls from the target ERP System.
  7. Target ERP System or ERP Middleware parses the payload and attempts to create a Purchase Requisition (PR).
  8. If the PR is created successfully:
    1. ERP Middleware should make an API call to Fairmarkit with the details of the newly created PR via /api/v3/requests/:request_id/pr/link/
    2. In this case Request on the Fairmarkit side is changing status to "Completed".
    3. The user continues to work with the PR directly in the ERP system.
    4. Optional: ERP Middleware can detect updates in the ERP system and send these updates to Fairmarkit via /api/v3/requests/:request_id/pr/status/
  9. If an error occurs:
    1. ERP Middleware can make an API call to Fairmarkit with all the error details: /api/v3/requests/:request_id/pr/mark-as-failed/
    2. In this case, the Request on the Fairmarkit side returns to the "Draft" status for editing.
    3. After editing user can try to create a PR one more time (step #3)