examples/create-new-order.js
function(params) {
    const order = this;

    if (!params) {
        params = {};
    }

    // the standards attributes
    this.id = params.id;
    this.dateCreated = params.dateCreated;
    this.lastUpdated = params.lastUpdated;
    this.version = params.version;

    this.customer = params.customer;
    this.orderDate = params.orderDate;
    this.total = params.total;

    this.items = params.items;

    this.calcTotal = function() {
        order.total = 0;

        order.items.forEach(function(item) {
            order.total += item.price;
        });

        return order.total;
    };
}
function(params) {
    const order = this;

    if (!params) {
        params = {};
    }

    // the standards attributes
    this.id = params.id;
    this.dateCreated = params.dateCreated;
    this.lastUpdated = params.lastUpdated;
    this.version = params.version;

    this.customer = params.customer;
    this.orderDate = params.orderDate;
    this.total = params.total;

    this.items = params.items;

    this.calcTotal = function() {
        order.total = 0;

        order.items.forEach(function(item) {
            order.total += item.price;
        });

        return order.total;
    };
}
function ( params ) { const order = this ; if ( ! params ) { params = { } ; } // the standards attributes this . id = params . id ; this . dateCreated = params . dateCreated ; this . lastUpdated = params . lastUpdated ; this . version = params . version ; this . customer = params . customer ; this . orderDate = params . orderDate ; this . total = params . total ; this . items = params . items ; this . calcTotal = function ( ) { order . total = 0 ; order . items . forEach ( function ( item ) { order . total += item . price ; } ) ; return order . total ; } ; }
define the Order and Order Item objects
define the Order and Order Item objects