Skip to content

Commit

Permalink
Merge pull request #13 from mttrbrts/master
Browse files Browse the repository at this point in the history
(doc) Added extended README files to all templates
  • Loading branch information
dselman committed Feb 18, 2018
2 parents 5d64ac1 + 94e1d02 commit d501e18
Show file tree
Hide file tree
Showing 28 changed files with 902 additions and 50 deletions.
112 changes: 110 additions & 2 deletions acceptance-of-delivery/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,112 @@

# Accord Protocol Template: acceptance-of-delivery
# Acceptance of Delivery

The is an Accord Protocol Template for a clause that allows the receiver of goods to inspect them for a given time period after delivery.
This is a smart legal clause conforms that to the [Accord Protocol Template Specification](https://docs.google.com/document/d/1UacA_r2KGcBA2D4voDgGE8jqid-Uh4Dt09AE-shBKR0), the protocol is managed by the open-source community of the [Accord Project](https://accordproject.org). The clause can be parsed and executed by the [Cicero](https://github.com/accordproject/cicero) engine.

## Description
> This clause allows the receiver of goods to inspect them for a given time period after delivery.
This clause contains:
- *Some sample Clause Text* - [sample.txt](sample.txt)
- *A template* - [grammar/template.tem](grammar/template.tem)
- *A data model* - [models/model.cto](models/model.cto)
- *Contact logic* (in JavaScript) - [logic/logic.js](lib/logic.js)

## Running this clause

### On your own machine

1. [Download the Cicero template library](https://github.com/accordproject/cicero-template-library/archive/master.zip)

2. Unzip the library with your favourite tool

3. Then from the command-line, change the current directory to the folder containing this README.md file.
```
cd acceptance-of-delivery
```
4. With the [Cicero command-line tool](https://github.com/accordproject/cicero#installation):
```
cicero execute --template ./ --dsl ./sample --data ./data.json
```
> Note, all of the command-line flags (like `--template`) are optional.
Alternatively you can use the simpler command below if you want to use all of the default files.
```
cicero execute
```

You should see the following output in your terminal:
```bash
mattmbp:acceptance-of-delivery matt$ cicero execute
21:49:39 - info: Logging initialized. 2018-02-17T21:49:39.676Z
21:49:39 - info: Using current directory as template folder
21:49:39 - info: Loading a default sample.txt file.
21:49:39 - info: Loading a default data.json file.
21:49:40 - info: {"clause":"acceptance-of-delivery@0.0.3-e407ff0a315c5b1c267677edbda49a32d4e9ef890ad21a3e40b3bc110d06c88c","request":{"$class":"org.accordproject.acceptanceofdelivery.InspectDeliverable","deliverableReceivedAt":"January 1, 2018 16:34:00","inspectionPassed":true},"response":{"$class":"org.accordproject.acceptanceofdelivery.InspectionResponse","status":"OUTSIDE_INSPECTION_PERIOD","shipper":"resource:org.hyperledger.composer.system.Participant#Party%20A","receiver":"resource:org.hyperledger.composer.system.Participant#Party%20B","transactionId":"57df30ca-3755-457b-9176-5fae50dd3283","timestamp":"2018-02-17T21:49:40.206Z"}}
```

### Sample Payload Data


Request, as in [data.json](https://github.com/accordproject/cicero-template-library/blob/master/acceptance-of-delivery/data.json)
```json
{
"$class":"org.accordproject.acceptanceofdelivery.InspectDeliverable",
"deliverableReceivedAt": "January 1, 2018 16:34:00",
"inspectionPassed": true
}
```

For the request above, you should see the following response:
```json
{
"$class":"org.accordproject.acceptanceofdelivery.InspectionResponse",
"status":"OUTSIDE_INSPECTION_PERIOD",
"shipper":"resource:org.hyperledger.composer.system.Participant#Party%20A",
"receiver":"resource:org.hyperledger.composer.system.Participant#Party%20B",
"transactionId":"57df30ca-3755-457b-9176-5fae50dd3283",
"timestamp":"2018-02-17T21:49:40.206Z"
}
```


## Testing this clause

This clause comes with an automated test that ensures that it executes correctly under different conditions. To test the clause, complete the following steps.

You need npm and node to test a clause. You can download both from [here](https://nodejs.org/).

> This clause was tested with Node v8.9.3 and NPM v5.6.0
From the `acceptance-of-delivery` directory.

1. Install all of the dependencies.
```
npm install
```

2. Run the tests
```
npm test
```
If successful, you should see the following output
```
mattmbp:acceptance-of-delivery matt$ npm test
> [email protected] test /Users/matt/dev/accordproject/cicero-template-library/acceptance-of-delivery
> mocha
21:57:31 - info: Logging initialized. 2018-02-17T21:57:31.074Z
Logic
#InspectDeliverable
✓ passed inspection within time limit
✓ failed inspection within time limit
✓ inspection outside time limit
✓ inspection before delivable should throw
4 passing (458ms)
```
5 changes: 5 additions & 0 deletions acceptance-of-delivery/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$class":"org.accordproject.acceptanceofdelivery.InspectDeliverable",
"deliverableReceivedAt": "January 1, 2018 16:34:00",
"inspectionPassed": true
}
2 changes: 1 addition & 1 deletion acceptance-of-delivery/lib/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function execute(context) {

res.shipper = factory.newRelationship('org.hyperledger.composer.system', 'Participant', data.shipper);
res.receiver = factory.newRelationship('org.hyperledger.composer.system', 'Participant', data.receiver);
logger.info(context);
// logger.info(context);
}

/* eslint-enable no-unused-vars */
Expand Down
2 changes: 1 addition & 1 deletion acceptance-of-delivery/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions acceptance-of-delivery/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "acceptance-of-delivery",
"version": "0.0.2",
"description": "Acceptance of Delivery. \"Party A\" will be deemed to have completed its delivery obligations if in \"Party B\"'s opinion, the \"Widgets\" satisfies the Acceptance Criteria, and \"Party B\" notifies \"Party A\" in writing that it is accepting the \"Widgets\".\n\nInspection and Notice. \"Party A\" will have 10 Business Days' to inspect and evaluate the \"Widgets\" on the delivery date before notifying \"Party A\" that it is either accepting or rejecting the \"Widgets\".\n\nAcceptance Criteria. The \"Acceptance Criteria\" are the specifications the \"Widgets\" must meet for the \"Party A\" to comply with its requirements and obligations under this agreement, detailed in \"Attachment X\", attached to this agreement.",
"version": "0.0.3",
"description": "This clause allows the receiver of goods to inspect them for a given time period after delivery.",
"author": "clause.io",
"license": "Apache-2.0",
"engines": {
Expand Down
112 changes: 110 additions & 2 deletions fragile-goods/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,112 @@
# Fragile Goods

# Accord Protocol Template: fragile-goods
This is a smart legal clause conforms that to the [Accord Protocol Template Specification](https://docs.google.com/document/d/1UacA_r2KGcBA2D4voDgGE8jqid-Uh4Dt09AE-shBKR0), the protocol is managed by the open-source community of the [Accord Project](https://accordproject.org). The clause can be parsed and executed by the [Cicero](https://github.com/accordproject/cicero) engine.

Stateless clause for shipping fragile goods.
## Description

> This clause specifies penalties for shocks caused to a fragile package in transport.
This clause contains:
- *Some sample Clause Text* - [sample.txt](sample.txt)
- *A template* - [grammar/template.tem](grammar/template.tem)
- *A data model* - [models/model.cto](models/model.cto)
- *Contact logic* (in JavaScript) - [logic/logic.js](lib/logic.js)

## Running this clause

### On your own machine

1. [Download the Cicero template library](https://github.com/accordproject/cicero-template-library/archive/master.zip)

2. Unzip the library with your favourite tool

3. Then from the command-line, change the current directory to the folder containing this README.md file.
```
cd fragile-goods
```
4. With the [Cicero command-line tool](https://github.com/accordproject/cicero#installation):
```
cicero execute --template ./ --dsl ./sample --data ./data.json
```
> Note, all of the command-line flags (like `--template`) are optional.
Alternatively you can use the simpler command below if you want to use all of the default files.
```
cicero execute
```

You should see the following output in your terminal:
```bash
mattmbp:fragile-goods matt$ cicero execute
10:53:14 - info: Logging initialized. 2018-02-18T10:53:14.801Z
10:53:15 - info: Using current directory as template folder
10:53:15 - info: Loading a default sample.txt file.
10:53:15 - info: Loading a default data.json file.
10:53:15 - info: {"clause":"fragile-goods@0.0.3-8f725043d1fe2e64c5bcdefdb5693d65ba37fba60f743ac0f2f8d5e5595fe901","request":{"$class":"io.clause.demo.fragileGoods.DeliveryUpdate","startTime":"January 1, 2018 16:34:00","finishTime":"January 1, 2018 16:34:11","status":"ARRIVED","accelerometerReadings":[0.2,0.6,-0.3,-0.7,0.1]},"response":{"$class":"io.clause.demo.fragileGoods.PayOut","amount":790,"transactionId":"609813f8-e5b4-49f9-86ab-265a4428ee0f","timestamp":"2018-02-18T10:53:15.589Z"}}
```

### Sample Payload Data


Request, as in [data.json](https://github.com/accordproject/cicero-template-library/blob/master/fragile-goods/data.json)
```json
{
"$class": "io.clause.demo.fragileGoods.DeliveryUpdate",
"startTime":"January 1, 2018 16:34:00",
"finishTime":"January 1, 2018 16:34:11",
"status":"ARRIVED",
"accelerometerReadings":[0.2,0.6,-0.3,-0.7,0.1]
}
```

For the request above, you should see the following response:
```json
{
"$class":"io.clause.demo.fragileGoods.PayOut",
"amount":790,
"transactionId":"609813f8-e5b4-49f9-86ab-265a4428ee0f",
"timestamp":"2018-02-18T10:53:15.589Z"
}
```


## Testing this clause

This clause comes with an automated test that ensures that it executes correctly under different conditions. To test the clause, complete the following steps.

You need npm and node to test a clause. You can download both from [here](https://nodejs.org/).

> This clause was tested with Node v8.9.3 and NPM v5.6.0
From the `fragile-goods` directory.

1. Install all of the dependencies.
```
npm install
```

2. Run the tests
```
npm test
```
If successful, you should see the following output
```
mattmbp:fragile-goods matt$ npm test
> [email protected] test /Users/matt/dev/accordproject/cicero-template-library/fragile-goods
> mocha
10:54:35 - info: Logging initialized. 2018-02-18T10:54:35.125Z
Logic
#FragileGoodsDemo
✓ should execute a completed delivery contract with all deductions
✓ should execute an inflight delivery contract
✓ should execute a completed on-time delivery contract with breaches
✓ should execute a completed delivery contact with no deductions
4 passing (468ms)
```
2 changes: 1 addition & 1 deletion fragile-goods/lib/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @AccordClauseLogic
*/
function execute(context) {
logger.info(context);
// logger.info(context);
var req = context.request;
var res = context.response;
var data = context.data;
Expand Down
2 changes: 1 addition & 1 deletion fragile-goods/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions fragile-goods/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "fragile-goods",
"version": "0.0.3",
"description": "6.1.7 Liquidated Damages for Delayed Delivery. \r\nIn the event the EXW delivery date of the Equipment is delayed beyond the delivery schedule as indicated in Annex A, solely through the fault of the Seller, and unless the parties mutually agreed to an extension thereto, the Buyer is entitled to claim liquidated damages in an amount equivalent to $200.00. \r\nPrior to implementing the provisions of Article 16.4 pursuant to this section, Buyer agrees that it shall discuss with Seller alternate remedies in good faith.. . . . \r\n\r\n7.1 The Equipment to be shipped to the Buyer shall be packed and shipped in accordance with the Specifications and if not specified therein.... \r\nAdditionally the Equipment should have proper devices on it to record any shock during transportation as any instance of acceleration outside the bounds of -0.5g and 0.5g. \r\nEach shock shall reduce the Contract Price by $5.00. Packing containing fragile materials should be so marked in bold stout letters. . . . .\r\n\r\nANNEX A\r\nEquipment Description, Contract Price and Delivery Schedule\r\n\r\nContract Price is $1000.00 per unit of Equipment.\r\nDelivery Schedule: no later than 10 seconds after initiation.\r\n",
"version": "0.0.4",
"description": "This clause specifies penalties for shocks caused to a fragile package in transport.",
"author": "Matt Roberts, clause.io",
"license": "Apache-2.0",
"engines": {
"cicero": "^0.2.28"
},
"scripts": {
"test": "mocha",
"parse":"cicero parse --template ./ --dsl sample.txt",
"execute":"cicero execute --template ./ --dsl sample.txt --data data.json"
"parse": "cicero parse --template ./ --dsl sample.txt",
"execute": "cicero execute --template ./ --dsl sample.txt --data data.json"
},
"devDependencies": {
"chai": "^4.1.2",
Expand Down
Loading

0 comments on commit d501e18

Please sign in to comment.