Perishable Goods

Author: Accord Project

perishable-goods@0.14.0 Contract ^0.21.0 191e0862a002c4f39e787e4d3c40870b7c6023d3e6f0a2cb3b6bb7387b1361f9

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

Download Archive Download Compiled 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",
    "grower": {
        "$class": "org.accordproject.cicero.contract.AccordParty",
        "partyId": "PETER"
    },
    "importer": {
        "$class": "org.accordproject.cicero.contract.AccordParty",
        "partyId": "DAN"
    },
    "shipment": "resource:org.accordproject.perishablegoods.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,
    "contractId": "aedd193b-0356-4f72-8ac1-f03313c03a4d"
}

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": "907c43b1-cd1d-11ea-920c-ade26666d144"
}

Request Types

Type Sample JSON
org.accordproject.perishablegoods.ShipmentReceived
{
    "$class": "org.accordproject.perishablegoods.ShipmentReceived",
    "unitCount": 57053,
    "shipment": "resource:org.accordproject.perishablegoods.Shipment#0681",
    "transactionId": "907c1ca0-cd1d-11ea-920c-ade26666d144",
    "timestamp": "2020-07-23T15:49:05.002-04:00"
}

Response Types

Type Sample JSON
org.accordproject.perishablegoods.PriceCalculation
{
    "$class": "org.accordproject.perishablegoods.PriceCalculation",
    "totalPrice": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 112.406,
        "currencyCode": "PYG"
    },
    "penalty": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 219.693,
        "currencyCode": "ETB"
    },
    "late": true,
    "shipment": "resource:org.accordproject.perishablegoods.Shipment#5326",
    "transactionId": "907c43b0-cd1d-11ea-920c-ade26666d144",
    "timestamp": "2020-07-23T15:49:05.003-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": 157.159,
        "currencyCode": "COP"
    },
    "description": "Cupidatat mollit veniam aute.",
    "contract": "resource:org.accordproject.perishablegoods.PerishableGoodsContract#3556",
    "promisor": "resource:org.accordproject.cicero.contract.AccordParty#6859",
    "promisee": "resource:org.accordproject.cicero.contract.AccordParty#8249",
    "deadline": "2020-07-23T15:49:05.004-04:00",
    "eventId": "907c6ac0-cd1d-11ea-920c-ade26666d144",
    "timestamp": "2020-07-23T15:49:05.004-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.