Perishable Goods

perishable-goods@0.13.0 Contract ^0.20.0 f85ce0ac0d404d0d9596201eac71e52e7561888c7fbc4abbdb38e4c4259baf10

This clause specifies penalties if the transport conditions (temperature and humidity) for a package are breached.

Download Archive Open in Template Studio Open in VSCode Web

Perishable Goods

This clause specifies penalties if the transport conditions (temperature and humidity) for a package are breached.

Template Text

On receipt of the shipment "SHIP_001" the importer "DAN" pays the grower "PETER" 1.50 USD per KG. The shipment must contain between 3000 and 3500 KG of "Grade I, Size 4, Zutano Mexican Avocados".

Shipping containers used must be temperature and humidity controlled, and sensor readings must be logged at least 1 per hours.

Shipments that arrive after 07/02/2018 are to be considered spoiled and must be arranged to be returned to or disposed of by grower at cost to grower.

Temperature readings for the shipment must be between 2 and 13.

Humidity readings for the shipment must be between 70 and 90.

Shipments that have a temperature or humidity reading outside the agreed range have a price penalty applied calculated using the Formula for Breach Penalty Calculation below. The breach penalty factor to be used is 0.2.

Formula for Breach Penalty Calculation: penalty = number of shipment units x difference between sensor reading and agreed range x breach penalty factor

On receipt of the shipment "SHIP_001" the importer "DAN" pays the grower "PETER" 1.50 USD per KG. The shipment must contain between 3000 and 3500 KG of "Grade I, Size 4, Zutano Mexican Avocados".

Shipping containers used must be temperature and humidity controlled, and sensor readings must be logged at least 1 per hours.

Shipments that arrive after 07/02/2018 are to be considered spoiled and must be arranged to be returned to or disposed of by grower at cost to grower.

Temperature readings for the shipment must be between 2 and 13.

Humidity readings for the shipment must be between 70 and 90.

Shipments that have a temperature or humidity reading outside the agreed range have a price penalty applied calculated using the Formula for Breach Penalty Calculation below. The breach penalty factor to be used is 0.2.

Formula for Breach Penalty Calculation:
   penalty = number of shipment units x difference between sensor reading and agreed range x breach penalty factor
On receipt of the shipment {{shipment}} the importer {{importer}} pays the grower {{grower}} {{unitPrice}} per {{unit}}. The shipment must contain between {{minUnits}} and {{maxUnits}} {{unit}} of {{product}}.

Shipping containers used must be temperature and humidity controlled, and sensor readings must be logged at least {{sensorReadingFrequency}} per {{duration}}.

Shipments that arrive after {{dueDate}} are to be considered spoiled and must be arranged to be returned to or disposed of by grower at cost to grower.

Temperature readings for the shipment must be between {{minTemperature}} and {{maxTemperature}}.

Humidity readings for the shipment must be between {{minHumidity}} and {{maxHumidity}}.

Shipments that have a temperature or humidity reading outside the agreed range have a price penalty applied calculated using the Formula for Breach Penalty Calculation below. The breach penalty factor to be used is {{penaltyFactor}}.

Formula for Breach Penalty Calculation:
penalty = number of shipment units x difference between sensor reading and agreed range x breach penalty factor
{
    "$class": "org.accordproject.perishablegoods.PerishableGoodsContract",
    "contractId": "1844ad8b-cb4f-4957-b6bf-36eadb5b6b2b",
    "grower": {
        "$class": "org.accordproject.cicero.contract.AccordParty",
        "partyId": "PETER"
    },
    "importer": {
        "$class": "org.accordproject.cicero.contract.AccordParty",
        "partyId": "DAN"
    },
    "shipment": "SHIP_001",
    "dueDate": "2018-07-02T00:00:00.000-05:00",
    "unitPrice": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 1.5,
        "currencyCode": "USD"
    },
    "unit": "KG",
    "minUnits": 3000,
    "maxUnits": 3500,
    "product": "Grade I, Size 4, Zutano Mexican Avocados",
    "sensorReadingFrequency": 1,
    "duration": "hours",
    "minTemperature": 2,
    "maxTemperature": 13,
    "minHumidity": 70,
    "maxHumidity": 90,
    "penaltyFactor": 0.2
}

Template Model

namespace org.accordproject.perishablegoods

import org.accordproject.cicero.contract.* from https://models.accordproject.org/cicero/contract.cto
import org.accordproject.cicero.runtime.* from https://models.accordproject.org/cicero/runtime.cto
import org.accordproject.time.* from https://models.accordproject.org/v2.0/time.cto
import org.accordproject.address.PostalAddress from https://models.accordproject.org/address.cto
import org.accordproject.organization.Organization from https://models.accordproject.org/organization.cto
import org.accordproject.money.MonetaryAmount from https://models.accordproject.org/money.cto
import org.accordproject.value.* from https://models.accordproject.org/value.cto

/**
 * Defines a contract between a Grower and an Importer to ship using
 * a Shipper, paying a set unit price. The unit price is multiplied by
 * a penality factor proportional to the deviation from the min and max
 * negociated temperatures for the shipment.
 */
asset PerishableGoodsContract extends AccordContract {
  o AccordParty grower
  o AccordParty importer
  --> Shipment shipment
  o DateTime dueDate
  o MonetaryAmount unitPrice
  o UnitOfMass unit
  o Integer minUnits
  o Integer maxUnits
  o String product
  o Integer sensorReadingFrequency
  o TemporalUnit duration
  o Double minTemperature
  o Double maxTemperature
  o Double minHumidity
  o Double maxHumidity
  o Double penaltyFactor
}

/**
 * The status of a shipment
 */
enum ShipmentStatus {
  o CREATED
  o IN_TRANSIT
  o ARRIVED
}

/**
 * An abstract transaction that is related to a Shipment
 */
abstract transaction ShipmentTransaction extends Request {
    --> Shipment shipment
}

/**
 * An temperature reading for a shipment. E.g. received from a
 * device within a temperature controlled shipping container
 */
transaction SensorReading extends ShipmentTransaction {
  o Double centigrade
  o Double humidity
}

/**
 * A notification that a shipment has been received by the
 * importer and that funds should be transferred from the importer
 * to the grower to pay for the shipment.
 */
transaction ShipmentReceived extends ShipmentTransaction {
    o Integer unitCount
}

/**
 * The calculation of a price
 */
transaction PriceCalculation extends ShipmentTransaction {
  o MonetaryAmount totalPrice
  o MonetaryAmount penalty
  o Boolean late
}

/**
 * A shipment being tracked as an asset on the ledger
 */
asset Shipment identified by shipmentId {
  o String shipmentId
  o ShipmentStatus status
  o AccordParty grower
  o AccordParty importer
  o SensorReading[] sensorReadings optional
  o String smartClause optional
}

/**
 * An abstract participant type in this business network
 */
abstract participant Business extends Organization {
  o MonetaryAmount accountBalance
}

/**
 * A Grower is a type of participant in the network
 */
participant Grower extends Business {
}

/**
 * A Shipper is a type of participant in the network
 */
participant Shipper extends Business {
}

/**
 * An Importer is a type of participant in the network
 */
participant Importer extends Business {
}

/**
 * JUST FOR INITIALIZING A DEMO
 */
transaction SetupDemo {
}

Model Dependencies

Template Logic

Find the full logic for this template on on GitHub.

State Types

Type Sample JSON
org.accordproject.cicero.contract.AccordContractState
{
    "$class": "org.accordproject.cicero.contract.AccordContractState",
    "stateId": "7a5ec5b1-42fa-11ea-8b78-dde257dbceb0"
}

Request Types

Type Sample JSON
org.accordproject.perishablegoods.ShipmentReceived
{
    "$class": "org.accordproject.perishablegoods.ShipmentReceived",
    "unitCount": 55142,
    "shipment": "resource:org.accordproject.perishablegoods.Shipment#4343",
    "transactionId": "7a5e9ea0-42fa-11ea-8b78-dde257dbceb0",
    "timestamp": "2020-01-29T19:50:15.051-05:00"
}

Response Types

Type Sample JSON
org.accordproject.perishablegoods.PriceCalculation
{
    "$class": "org.accordproject.perishablegoods.PriceCalculation",
    "totalPrice": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 9.394,
        "currencyCode": "MKD"
    },
    "penalty": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 110.949,
        "currencyCode": "CHW"
    },
    "late": false,
    "shipment": "resource:org.accordproject.perishablegoods.Shipment#7517",
    "transactionId": "7a5ec5b0-42fa-11ea-8b78-dde257dbceb0",
    "timestamp": "2020-01-29T19:50:15.051-05:00"
}

Events Types

Type Sample JSON
org.accordproject.cicero.runtime.PaymentObligation
{
    "$class": "org.accordproject.cicero.runtime.PaymentObligation",
    "amount": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 38.356,
        "currencyCode": "NOK"
    },
    "description": "Pariatur minim nostrud consectetur.",
    "contract": "resource:org.accordproject.perishablegoods.PerishableGoodsContract#4951",
    "promisor": "resource:org.accordproject.cicero.contract.AccordParty#2720",
    "promisee": "resource:org.accordproject.cicero.contract.AccordParty#9287",
    "deadline": "2020-01-29T19:50:15.052-05:00",
    "eventId": "7a5eecc0-42fa-11ea-8b78-dde257dbceb0",
    "timestamp": "2020-01-29T19:50:15.052-05:00"
}

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.

View the Latest code for this template on GitHub.