Platform 6 Demo App¶
Supported scenario¶
The P6 Demo App simulates a buyer-supplier relationship with a set of transaction types (Requests for Quotation, Quotes and Purchase Orders) being exchanged via an Ethereum smart contract. Behind the scenes, the App plays the role of the Buyer; the logged-in user plays the role of the Supplier.
Step-by-step details¶
Step 1 (Buyer side) – A Request for Quotation (RFQ) is created every 10 minutes and stored in a smart contract
P6 service items leveraged to perform this step:
Service item name (Type) | What it does |
---|---|
SchedulerForRFQCreation (Route Deployment Script) | - Calls the CreateRFQTransaction script every 10 minutes |
CreateRFQTransaction (Script) | - Generates a UBL RFQ containing 1 to n lines (n being the number of different categories in the Items table) with requested quantity on each line being randomly generated (1 to 10) - Writes the UBL RFQ in the blockchain smart contract leveraging the RFQSmartContractHelper script |
RFQSmartContractHelper (Script) |
Step 2 (Supplier side) – The UBL RFQ is retrieved from the smart contract and an RFQ Transaction is created on P6
P6 service items leveraged to perform this step:
Service item name (Type) | What it does |
---|---|
BlockchainEventHandler (Route Deployment Script) | - Creates a route that listens to a specific smart contract, on a specific Ethereum node (both being defined in the AppConfig table) - Submits Ethereum logs to the BlockchainEventHandler script |
BlockchainEventHandler (Script) | - Handles logs retrieved from the smart contract and if the event relates to a received RFQ, calls the ReceiveRFQTransaction script |
ReceiveRFQTransaction (Script) | - Handles the reception of the RFQ (creation of the RFQ TransactionInfo item with a “Received” technical status code, storage of the UBL RFQ on the file system…) - Saves the TransactionInfo item and sends it to the Routing Rules Dispatcher route endpoint (p6router.p6_demo_Dispatcher) |
RoutingRuleDispatcher (Route Deployment Script) | - Submits to the appropriate route based on the Transaction type – so in this case, to the Routing Rules for RFQs route endpoint (p6router.p6_demo_RequestForQuotation) |
Step 3 (Supplier Side) - The received RFQ triggers a P6 workflow, which offers two options to the supplier user: either (a) provide a Quote or (b) decline the RFQ
P6 service items leveraged to perform this step:
Service item name (Type) | What it does |
---|---|
RoutingRulesForRFQs (Route Deployment Script) | - Triggers the HandleRequestForQuotation workflow step because the value of the technical status code of the routed RFQ Transaction equals “Received” |
HandleRequestForQuotation (Workflow Step) | - Creates a workflow task with two possible actions, either “Provide Quote” (which will trigger the WFHandleRFQ-ProvideFormForQuoteCreation script to create the custom form and execute the WFHandleRFQ-HandleActionProvideQuote script after submission) or “Decline” (which will execute the WFHandleRFQ-HandleActionDecline script after submission) - Assigns the workflow task to all users with a *=* scope that are assigned at the root of the instance organization |
Step 4.a (Supplier Side) - The Supplier user decides to provide a Quote in reply to the received RFQ
P6 service items leveraged to perform this step:
Service item name (Type) | What it does |
---|---|
WFHandleRFQ-ProvideFormForQuoteCreation (Script) | - Displays a custom form allowing the supplier user to (i) select items from the mini catalog hosted in the Items table (ii) enter discount on each line item (iii) submit the Quote |
WFHandleRFQ-HandleActionProvideQuote (Script) | - Updates the RFQ TransactionInfo item statuses (technical status to ‘Handled’ and function status to ‘Quote provided’), creates the UBL Quote based on elements provided by the user, creates the Quote TransactionInfo, saves and routes it (calling the Dispatcher endpoint) |
RoutingRuleDispatcher (Route Deployment Script) | - Submits to the appropriate route based on the Transaction type – so in this case, to the Routing Rules for Quotes route endpoint (p6router.p6_demo_Quote) |
RoutingRulesForQuotes (Route Deployment Script) | - Triggers the SendQuoteToBlockchain script because the value of the technical status code of the routed Quote Transaction equals “Created” |
SendQuoteToBlockchain (Script) | - Sends the Quote to the blockchain smart contract and updates the Quote status on the TransactionInfo item to “Sent” |
Step 4.b (Supplier Side) - The Supplier user decides to decline the RFQ and can enter a reason
P6 service items leveraged to perform this step:
Service item name (Type) | What it does |
---|---|
WFHandleRFQ-HandleActionDecline (Script) | - Updates the RFQ TransactionInfo item statuses (technical status to ‘Handled’ and function status to ‘Declined’) and declines the RFQ on the Ethereum smart contract |
Step 5 (Buyer Side) - The Buyer generates a Purchase Order matching the Quote provided by the Supplier
P6 service items leveraged to perform this step:
Service item name (Type) | What it does |
---|---|
BlockchainEventHandler (Route Deployment Script) | - Creates a route that listens to a specific smart contract, on a specific Ethereum node (both being defined in the AppConfig table) - Submits Ethereum logs to the BlockchainEventHandler script |
BlockchainEventHandler (Script) | - Handles logs retrieved from the smart contract and if the event relates to a received Quote, calls the HandleQuoteTransaction script |
HandleQuoteTransaction (Script) | - Handles the creation of the UBL PO by flipping the Quote and its storage on the file system - Creates the PO TransactionInfo item, then saves and sends it to the Routing Rules Dispatcher route endpoint (p6router.p6_demo_Dispatcher) |
Step 6 (Supplier Side) - The received PO triggers a P6 workflow, which offers two options to the supplier user: either (a) accept the Order or (b) reject it
P6 service items leveraged to perform this step:
Service item name (Type) | What it does |
---|---|
RoutingRulesForPurchaseOrders (Route Deployment Script) | - Creates a route that triggers the HandlePurchaseOrder workflow step because the value of the technical status code of the routed PO Transaction equals “Received” |
HandlePurchaseOrder (Workflow Step) | - Creates a workflow task with two possible actions, either “Accept Order” (which lets the user enter a Sales Order Number and then executes the WFHandlePO-HandleActionAcceptOrder script after submission) or “Reject” (which lets the user enter a rejection reason and the execute the WFHandlePO-HandleActionRejectOrder script after submission) - Assigns the workflow task to all users with a *=* scope that are assigned at the root of the instance organization- Notifies the assignees via email (leveraging the WFHandlePO-BuildEmail script and the POReview email html template from the bundled resources) |
WFHandlePO-BuildEmail (Script) | - Customizes the email notification sent to the user |
POReview (Bundled Resource) | - Provides the html template for the email notification |
Step 7.a (Supplier Side) - The Supplier user decides to accept the PO and can enter a Sales Order Number
P6 service items leveraged to perform this step:
Service item name (Type) | What it does |
---|---|
WFHandlePO-HandleActionAcceptOrder (Script) | - Updates the PO TransactionInfo item statuses (technical status to ‘Handled’ and function status to ‘Accepted’), adds the Sales Order Number as a Key Value in the PO TransactionInfo item, then saves and routes |
Step 7.b (Supplier Side) - The Supplier user decides to reject the PO and can enter a rejection reason
P6 service items leveraged to perform this step:
Service item name (Type) | What it does |
---|---|
WFHandlePO-HandleActionRejectOrder (Script) | - Updates the PO TransactionInfo item statuses (technical status to ‘Handled’ and function status to ‘Rejected’), then saves and routes |
Installation & uninstallation¶
When creating an app, you can define scripts that will be executed before or after installation (‘Pre-install script’ and ‘Post-install script’) and a script that will be executed if and when the app is uninstalled (‘Uninstall script’). For the P6 Demo App, the ‘InitializeApplication’ script is set as the ‘Post-install script’ and handles the following tasks:
- Copy all bundled resources to the local file system
- Populate the ‘Items’ table with records from a CSV file (p6_demo_items.csv)
- Save a demo wallet to interact with the smart contract
- Deploy a smart contract to the local Ethereum node
- Define a custom transaction manager with a polling frequency of 2 seconds
- Save the Ethereum contract address and Ethereum client URL in the ‘AppConfig’ table
- Notify Platform 6 that the installation was successful
The ‘UninstallApplication’ script performs the following tasks:
- Execute the ‘DeleteP6DemoTransactions’ store procedure, which will delete all transactions and workflow tasks created by the Demo App
- Destroy all routes (routing rules, scheduled tasks, blockchain event listener…)
- Undeploy bundled resources
- Notify Platform 6 that the uninstallation was successful