Fork me on GitHub

Template volumediscount@0.1.1

A sample volume discount contract.

Download Archive

Volume Discount

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

Description

A sample volume discount clause.

This contract 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 ...

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
                

Model Dependencies

Technical Integration

Please refer to the Cicero documentation for details and examples of how to integrate a call to a Cicero template into your application.

State

{
    "state": "tbd"
}

Request Types

Type Sample JSON
org.accordproject.volumediscount.VolumeDiscountRequest
{
    "$class": "org.accordproject.volumediscount.VolumeDiscountRequest",
    "netAnnualChargeVolume": 171.532,
    "transactionId": "110b9f60-6b20-11e8-b846-9787b297dffa",
    "timestamp": "2018-06-08T13:30:10.390Z"
}

Response Types

Type Sample JSON
org.accordproject.volumediscount.VolumeDiscountResponse
{
    "$class": "org.accordproject.volumediscount.VolumeDiscountResponse",
    "discountRate": 80.38,
    "transactionId": "110b9f61-6b20-11e8-b846-9787b297dffa",
    "timestamp": "2018-06-08T13:30:10.390Z"
}

Events Types

Type Sample JSON