Fork me on GitHub

Template volumediscount@0.1.0

A sample volume discount clause.

Usage

Volume Discount

This is a smart legal clause that conforms to the Accord Protocol Template Specification, the protocol is managed by the open-source community of the Accord Project. The clause can be parsed and executed by the Cicero engine.

Description

A sample volume discount clause.

This clause contains:

Running this clause

On your own machine

  1. Download the Cicero template library

  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 volumediscount
  1. With the Cicero command-line tool:
cicero execute --template ./ --sample ./sample.txt --request ./request.json --state ./state.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:

mattmbp:volumediscount matt$ cicero execute
18:33:10 - info: Logging initialized. 2018-05-15T22:33:10.712Z
18:33:11 - info: Using current directory as template folder
18:33:11 - info: Loading a default sample.txt file.
18:33:11 - info: Loading a single default request.json file.
18:33:11 - info: Loading a default state.json file.
18:33:11 - info: CICERO-ENGINE {"request":{"$class":"org.accordproject.volumediscount.VolumeDiscountRequest","netAnnualChargeVolume":0.4,"transactionId":"bd964fa1-042e-46ad-b7c4-9c755205dbf4","timestamp":"2018-05-15T22:33:11.435Z"},"state":{"$class":"org.accordproject.common.ContractState","stateId":"org.accordproject.common.ContractState#1"},"contract":{"$class":"org.accordproject.volumediscount.TemplateModel","firstVolume":1,"secondVolume":10,"firstRate":3,"secondRate":2.9,"thirdRate":2.8},"response":{"$class":"org.accordproject.volumediscount.VolumeDiscountResponse","transactionId":"f2a060e1-792e-40cc-a055-fd0faeb25aa9","timestamp":"2018-05-15T22:33:11.446Z"},"emit":[],"now":"2018-05-15T22:33:11.445Z"}
18:33:11 - info: {"clause":"volumediscount@0.0.6-e6b68c35598afb65ddf51bfc40ada8cb482cb441605eb0285d46e708f8654d58","request":{"$class":"org.accordproject.volumediscount.VolumeDiscountRequest","netAnnualChargeVolume":0.4},"response":{"$class":"org.accordproject.volumediscount.VolumeDiscountResponse","discountRate":3,"transactionId":"f2a060e1-792e-40cc-a055-fd0faeb25aa9","timestamp":"2018-05-15T22:33:11.446Z"},"state":{"$class":"org.accordproject.common.ContractState","stateId":"org.accordproject.common.ContractState#1"},"emit":[]}

Sample Payload Data

Request, as in request.json

{
    "$class": "org.accordproject.volumediscount.VolumeDiscountRequest",
    "netAnnualChargeVolume": 0.4
}

For the request above, you should see the following response:

{
    "$class":"org.accordproject.volumediscount.VolumeDiscountResponse",
    "discountRate":3,
    "transactionId":"5f448219-851a-4b10-8fb9-14f979951ebd",
    "timestamp":"2018-02-18T11:36:40.353Z"
}

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.

This clause was tested with Node v8.9.3 and NPM v5.6.0

From the volumediscount directory.

  1. Install all of the dependencies.
npm install
  1. Run the tests
npm test

If successful, you should see the following output

mattmbp:volumediscount matt$ npm test

> volumediscount@0.0.6 test /Users/matt/dev/mttrbrts/cicero-template-library/volumediscount
> mocha

11:37:53 - info: Logging initialized. 2018-02-18T11:37:53.706Z


  Logic
    #VolumeDiscount
...
      ✓ should execute a smart clause


  1 passing (326ms)

Output above is abbreviated for clarity at ...

Download Archive

Model Dependencies

Sample

Volume-Based Card Acceptance Agreement [Abbreviated]

This Agreement is by and between Card, Inc., a New York corporation, and you, the Merchant. By accepting the Card, you agree to be bound by the Agreement. 
Discount means an amount that we charge you for accepting the Card, which amount is: 
(i) a percentage (Discount Rate) of the face amount of the Charge that you submit, or a flat per-
Transaction fee, or a combination of both; and/or 
(ii) a Monthly Flat Fee (if you meet our requirements).

Transaction Processing and Payments. Our Card acceptance, processing, and payment requirements are set forth in the Merchant Regulations. Some requirements are summarized here for ease of reference, but do not supersede the provisions in the Merchant Regulations.
Payment for Charges. We will pay you, through our agent, according to your payment plan in US dollars for the face amount of Charges submitted from your Establishments less all applicable deductions, rejections, and withholdings, which include: 
(i) the Discount, 
(ii) any amounts you owe us or our Affiliates, 
(iii) any amounts for which we have Chargebacks and 
(iv) any Credits you submit. Your initial Discount is indicated in the Agreement or otherwise provided to you in writing by us. In addition to your Discount we may charge you additional fees and assessments, as listed in the Merchant Regulations or as otherwise provided to you in writing by us. We may adjust any of these amounts and may change any other amount we charge you for accepting the Card.

SETTLEMENT
a) Settlement Amount. Our agent will pay you according to your payment plan, as described below, in US dollars for the face amount of Charges submitted from your Establishments less all applicable deductions, rejections, and withholdings, which include: 
    (i) the Discount, 
    (ii) any amounts you owe us or our Affiliates, 
    (iii) any amounts for which we have Chargebacks, and (iv) any Credits you submit. Our agent will subtract the full amount of all applicable deductions, rejections, and withholdings, from this payment to you (or debit your Bank Account), but if it cannot, then you must pay it promptly upon demand.
b) Discount. The Discount is determined according to the following table:

| Annual Dollar Volume      | Discount             |
| Less than $1 million      | 3.00%                |
| $1 million to $10 million | 2.90%                |
| Greater than $10 million  | 2.80%                |

_______________________					_____________________
 Card, Inc.								Merchant
                
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 ./ --sample ./sample.txt --request ./request.json --state ./state.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 18:22:38 - info: Logging initialized. 2018-05-15T22:22:38.131Z 18:22:38 - info: Using current directory as template folder 18:22:38 - info: Loading a default sample.txt file. 18:22:38 - info: Loading a single default request.json file. 18:22:38 - info: Loading a default state.json file. 18:22:38 - 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":"faacef8f-c0b2-4d9f-911f-007aa98a1c1d","timestamp":"2018-05-15T22:22:38.869Z"},"state":{"$class":"org.accordproject.common.ContractState","stateId":"org.accordproject.common.ContractState#1"},"emit":[]} ``` ### Sample Payload Data Request, as in [request.json](https://github.com/accordproject/cicero-template-library/blob/master/acceptance-of-delivery/request.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 > acceptance-of-delivery@0.0.3 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) ```