Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
Updated vehicle lifecycle network and removed es6 syntax (#36)
Browse files Browse the repository at this point in the history
* Updated transaction processor function

* Added permissions.acl to vehicle-lifecycle-network

* Changed required repository name

* Set model dependency to unstable

* Fixed tp functions and added unit tests

* Updated setup script and added tests

* Rename dvla and setup changes

* Merge fixes

* Removed es6 syntax
  • Loading branch information
Liam Grace committed May 3, 2017
1 parent 170b081 commit fd38c13
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
3 changes: 1 addition & 2 deletions packages/perishable-network/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
env:
es6: true
es6: false
node: true
mocha: true
extends: 'eslint:recommended'
Expand Down Expand Up @@ -28,7 +28,6 @@ rules:
eqeqeq: error
no-throw-literal: error
strict: error
no-var: error
dot-notation: error
no-tabs: error
no-trailing-spaces: error
Expand Down
36 changes: 18 additions & 18 deletions packages/perishable-network/lib/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
*/
function payOut(shipmentReceived) {

let contract = shipmentReceived.shipment.contract;
let shipment = shipmentReceived.shipment;
let payOut = contract.unitPrice * shipment.unitCount;
var contract = shipmentReceived.shipment.contract;
var shipment = shipmentReceived.shipment;
var payOut = contract.unitPrice * shipment.unitCount;

console.log('Received at: ' + shipmentReceived.timestamp);
console.log('Contract arrivalDateTime: ' + contract.arrivalDateTime);
Expand All @@ -40,9 +40,9 @@ function payOut(shipmentReceived) {
shipment.temperatureReadings.sort(function (a, b) {
return (a.centigrade - b.centigrade);
});
let lowestReading = shipment.temperatureReadings[0];
let highestReading = shipment.temperatureReadings[shipment.temperatureReadings.length - 1];
let penalty = 0;
var lowestReading = shipment.temperatureReadings[0];
var highestReading = shipment.temperatureReadings[shipment.temperatureReadings.length - 1];
var penalty = 0;
console.log('Lowest temp reading: ' + lowestReading.centigrade);
console.log('Highest temp reading: ' + highestReading.centigrade);

Expand Down Expand Up @@ -102,7 +102,7 @@ function payOut(shipmentReceived) {
*/
function temperatureReading(temperatureReading) {

let shipment = temperatureReading.shipment;
var shipment = temperatureReading.shipment;

console.log('Adding temperature ' + temperatureReading.centigrade + ' to shipment ' + shipment.$identifier);

Expand All @@ -126,36 +126,36 @@ function temperatureReading(temperatureReading) {
*/
function setupDemo(setupDemo) {

let factory = getFactory();
let NS = 'org.acme.shipping.perishable';
var factory = getFactory();
var NS = 'org.acme.shipping.perishable';

// create the grower
let grower = factory.newResource(NS, 'Grower', 'farmer@email.com');
let growerAddress = factory.newConcept(NS, 'Address');
var grower = factory.newResource(NS, 'Grower', 'farmer@email.com');
var growerAddress = factory.newConcept(NS, 'Address');
growerAddress.country = 'USA';
grower.address = growerAddress;
grower.accountBalance = 0;

// create the importer
let importer = factory.newResource(NS, 'Importer', 'supermarket@email.com');
let importerAddress = factory.newConcept(NS, 'Address');
var importer = factory.newResource(NS, 'Importer', 'supermarket@email.com');
var importerAddress = factory.newConcept(NS, 'Address');
importerAddress.country = 'UK';
importer.address = importerAddress;
importer.accountBalance = 0;

// create the shipper
let shipper = factory.newResource(NS, 'Shipper', 'shipper@email.com');
let shipperAddress = factory.newConcept(NS, 'Address');
var shipper = factory.newResource(NS, 'Shipper', 'shipper@email.com');
var shipperAddress = factory.newConcept(NS, 'Address');
shipperAddress.country = 'Panama';
shipper.address = shipperAddress;
shipper.accountBalance = 0;

// create the contract
let contract = factory.newResource(NS, 'Contract', 'CON_001');
var contract = factory.newResource(NS, 'Contract', 'CON_001');
contract.grower = factory.newRelationship(NS, 'Grower', 'farmer@email.com');
contract.importer = factory.newRelationship(NS, 'Importer', 'supermarket@email.com');
contract.shipper = factory.newRelationship(NS, 'Shipper', 'shipper@email.com');
let tomorrow = setupDemo.timestamp;
var tomorrow = setupDemo.timestamp;
tomorrow.setDate(tomorrow.getDate() + 1);
contract.arrivalDateTime = tomorrow; // the shipment has to arrive tomorrow
contract.unitPrice = 0.5; // pay 50 cents per unit
Expand All @@ -165,7 +165,7 @@ function setupDemo(setupDemo) {
contract.maxPenaltyFactor = 0.1; // we reduce the price by 10 cents for every degree above the max temp

// create the shipment
let shipment = factory.newResource(NS, 'Shipment', 'SHIP_001');
var shipment = factory.newResource(NS, 'Shipment', 'SHIP_001');
shipment.type = 'BANANAS';
shipment.status = 'IN_TRANSIT';
shipment.unitCount = 5000;
Expand Down

0 comments on commit fd38c13

Please sign in to comment.