Perishable Goods

Author: Accord Project

perishable-goods@0.13.1 Contract ^0.20.10 64155c0b6a0624137e160dbc8be9782caa8f4957bb9b7b0e74bfec61cc728459

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

Download Archive Open in Template Studio

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": "c46ce521-01ec-49f5-8a46-986e1ffbc721",
    "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-04: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": "06e29b20-7b6c-11ea-b280-c173749a9e96"
}

Request Types

Type Sample JSON
org.accordproject.perishablegoods.ShipmentReceived
{
    "$class": "org.accordproject.perishablegoods.ShipmentReceived",
    "unitCount": 54300,
    "shipment": "resource:org.accordproject.perishablegoods.Shipment#4332",
    "transactionId": "06e27410-7b6c-11ea-b280-c173749a9e96",
    "timestamp": "2020-04-10T16:44:09.041-04:00"
}

Response Types

Type Sample JSON
org.accordproject.perishablegoods.PriceCalculation
{
    "$class": "org.accordproject.perishablegoods.PriceCalculation",
    "totalPrice": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 131.907,
        "currencyCode": "XPT"
    },
    "penalty": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 148.074,
        "currencyCode": "GYD"
    },
    "late": false,
    "shipment": "resource:org.accordproject.perishablegoods.Shipment#3437",
    "transactionId": "06e27411-7b6c-11ea-b280-c173749a9e96",
    "timestamp": "2020-04-10T16:44:09.041-04:00"
}

Events Types

Type Sample JSON
org.accordproject.cicero.runtime.PaymentObligation
{
    "$class": "org.accordproject.cicero.runtime.PaymentObligation",
    "amount": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 230.523,
        "currencyCode": "JMD"
    },
    "description": "Proident officia.",
    "contract": "resource:org.accordproject.perishablegoods.PerishableGoodsContract#9273",
    "promisor": "resource:org.accordproject.cicero.contract.AccordParty#3855",
    "promisee": "resource:org.accordproject.cicero.contract.AccordParty#4795",
    "deadline": "2020-04-10T16:44:09.042-04:00",
    "eventId": "06e29b21-7b6c-11ea-b280-c173749a9e96",
    "timestamp": "2020-04-10T16:44:09.042-04: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.