Perishable Goods

Author: Accord Project

perishable-goods@0.15.0 Contract ^0.22.0 268544bd46fb3f1ea28ea731b37af69d9f5ad028ee8f62c204a80d2d5f0d30ac

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": "resource:org.accordproject.party.Party#PETER",
    "importer": "resource:org.accordproject.party.Party#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": "0367382d-7f38-49df-b2cd-c8c10b76a5a7",
    "$identifier": "0367382d-7f38-49df-b2cd-c8c10b76a5a7"
}

Template Model

namespace org.accordproject.perishablegoods

import org.accordproject.contract.* from https://models.accordproject.org/accordproject/contract.cto
import org.accordproject.party.* from https://models.accordproject.org/accordproject/party.cto
import org.accordproject.runtime.* from https://models.accordproject.org/accordproject/runtime.cto
import org.accordproject.obligation.* from https://models.accordproject.org/accordproject/obligation.cto
import org.accordproject.time.* from https://models.accordproject.org/time@0.2.0.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@0.2.0.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 Contract {
  --> Party grower
  --> Party 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
  --> Party grower
  --> Party 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.runtime.State
{
    "$class": "org.accordproject.runtime.State",
    "$identifier": "8c3c4c30-a77b-11eb-9770-7ddd576a12c2"
}

Request Types

Type Sample JSON
org.accordproject.perishablegoods.ShipmentReceived
{
    "$class": "org.accordproject.perishablegoods.ShipmentReceived",
    "unitCount": 59947,
    "shipment": "resource:org.accordproject.perishablegoods.Shipment#4977",
    "$timestamp": "2021-04-27T13:11:04.050-04:00"
}

Response Types

Type Sample JSON
org.accordproject.perishablegoods.PriceCalculation
{
    "$class": "org.accordproject.perishablegoods.PriceCalculation",
    "totalPrice": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 239.382,
        "currencyCode": "EGP"
    },
    "penalty": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 116.51,
        "currencyCode": "MDL"
    },
    "late": true,
    "shipment": "resource:org.accordproject.perishablegoods.Shipment#4100",
    "$timestamp": "2021-04-27T13:11:04.050-04:00"
}

Events Types

Type Sample JSON
org.accordproject.obligation.PaymentObligation
{
    "$class": "org.accordproject.obligation.PaymentObligation",
    "amount": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 34.576,
        "currencyCode": "BIF"
    },
    "description": "Cillum reprehenderit deserunt nostrud sint.",
    "$identifier": "8c3c4c31-a77b-11eb-9770-7ddd576a12c2",
    "contract": "resource:org.accordproject.perishablegoods.PerishableGoodsContract#1802",
    "promisor": "resource:org.accordproject.party.Party#9151",
    "promisee": "resource:org.accordproject.party.Party#4781",
    "deadline": "2021-04-27T13:11:04.051-04:00",
    "$timestamp": "2021-04-27T13:11:04.051-04:00"
}

Technical Integration

Please refer to the Accord Project documentation for how to use a template or integrate it within your application.

View the Latest code for this template on GitHub.