Chaincode and rest/json based node.js application
Chaincode and rest/json based node.js application
Creating Invoice using Hyperledger Fabric | Mandatory
GO Version: go version go1.11.5 linux/amd64
OS: Ubuntu 18.04 LTS
Installing the prerequisites
Step 1
Step 2
Output
fabric-samples/
|-Fabcar
|- openFabric.sh
|--enrollAdmin.js
|---mainregisteruser.js
|---1stparticipantUser.js
|---2ndparticipantUser.js
|--- OEM.js
|---bankuser.js
|---appmain.js
|---app1stparticipant.js
|---appOEM.js
|---appBank.js
Output
fabric-samples/
|- chaincode
|-fabcar
|--go
|---scm.go
Step 3.
Open terminal and go to this directory fabric-samples/Fabcar/
Start the fabric ./openFabric.sh
Run npm install to create the modules
Run enrollAdmin.js
Run node mainregisteruser.js
Run node appmain.js
Output
Step 4
Test the endpoints using Insomnia REST Client. [Download Insomnia REST Client here: https://insomnia.rest/download/ ]
Raise Invoice
Parameters
invoiceNumber
billedTo
invoiceDate
invoiceAmount
itemDescription
gr
isPaid
paidAmount
repaid
repaymentAmount
Note: gr, isPaid, paidAmount, repaid, repaymentAmount, default values are as follows:
gr = N
isPaid = N
paidAmount = 0
repaid = N
repaymentAmount = 0
Goods Received
Parameters
invoiceNumber
gr
Bank Payment to Supplier
Parameters
invoiceNumber
paidAmount
Note: Paid Amount must be less than Invoice Amount
OEM repays to Bank
Parameters
invoiceNumber
repaymentAmount
Note: Repayment Amount must be greater than the value of Paid Amount.
Creating Invoice using Hyperledger Fabric | Optional
Step 1 | Raise Invoice (only supplier can create Invoice)
Open a new terminal and open the folder fabric-samples/Fabcar/
Enroll a new user node enrollAdmin.js
Run node 1stparticipantUser.js
Run node app1stparticipant.js
Choose the function GET and enter the localhost:3001/invoice
invoiceNumber
billedTo
invoiceDate
invoiceAmount
itemDescription
gr
isPaid
paidAmount
repaid
repaymentAmount
Step 2 | Goods received (only OEM can do GR)
Open a new terminal and open the folder fabric-samples/Fabcar/
Enroll a new user node enrollAdmin.js
Run node OEM.js
Run node appOEM.js
Open the Insomnia REST Client
invoiceNumber
gr
Step 3 | Goods received (only bank can pay to supplier)
Open a new terminal and open the folder fabric-samples/Fabcar/
Enroll a new user node enrollAdmin.js
Run node bankuser.js
Run node appBank.js
Open the Insomnia REST Client
invoiceNumber
paidAmount
Step 4 | Transaction Log
Open the Insomnia Rest Client. Choose the function GET and enter the localhost:3000
Step 5 | Display Invoices
Open the Insomnia Rest Client, choose the function GET and enter the localhost:3000
Display invoices per Supplier
Type the user1 in supplier to get the invoices per supplier
Display invoices per OEM
Type the Lenovo in oem to get the invoices per oem