compile validated
authortjwebb <travis@traviswebb.com>
Thu, 7 Nov 2013 17:15:46 +0000 (12:15 -0500)
committertjwebb <travis@traviswebb.com>
Thu, 7 Nov 2013 17:15:46 +0000 (12:15 -0500)
enyo-client/extensions/source/billing/client/models/cash_receipt.js
enyo-client/extensions/source/billing/database/orm/models/cash_receipt.json
enyo-client/extensions/source/billing/database/orm/models/receivable.json
lib/backbone-x/source/model.js

index 376c06b..5cd2d57 100644 (file)
@@ -23,7 +23,6 @@ XT.extensions.billing.initCashReceipt = function () {
         currency: XM.baseCurrency,
         currencyRate: 1,
         applicationDate: new Date(),
-        lineItems: new XM.CashReceiptLineCollection(),
         appliedAmount: 0,
         balance: 0
       };
@@ -363,8 +362,6 @@ XT.extensions.billing.initCashReceipt = function () {
    */
   XM.CashReceiptLine = XM.Info.extend({
     recordType: 'XM.CashReceiptLine',
-    editableModel: 'XM.CashReceiptReceivable',
-    idAttribute: 'uuid',
 
     defaults: {
       amount: 0,
@@ -451,14 +448,6 @@ XT.extensions.billing.initCashReceipt = function () {
     model: XM.CashReceipt
   });
 
-  /**
-   * @class XM.CashReceiptLineCollection
-   * @extends XM.Collection
-   */
-  XM.CashReceiptLineCollection = XM.Collection.extend({
-    model: XM.CashReceiptLine
-  });
-
   /**
    * @class XM.CashReceiptListItemCollection
    * @extends XM.Collection
index ba8e043..498df0a 100644 (file)
         "toOne": {
           "type": "BankAccountRelation",
           "column": "bankaccnt_id",
-          "isNested": true
+          "required": true
         }
       },
       {
         }
       },
       {
-        "name": "owner",
+        "name": "cashReceipt",
         "attr": {
           "type": "Number",
           "column": "cashrcptitem_cashrcpt_id"
         "name": "receivable",
         "toOne": {
           "isNested": true,
-          "type": "ReceivableRelation",
+          "type": "CashReceiptReceivable",
           "column": "cashrcptitem_aropen_id"
         }
       },
     "idSequenceName": "cashrcptitem_cashrcptitem_id_seq",
     "isRest": true,
     "lockable": true,
-    "isNestedOnly": true,
     "isSystem": true,
     "comment": "Pending Cash Receipt Line Item",
     "privileges": {
     "isRest": true,
     "lockable": true,
     "comment": "Cash Receipt Relation",
-    "isNestedOnly": true,
     "isSystem": true,
     "privileges": {
       "all": {
       {
         "name": "bankAccount",
         "toOne": {
+          "isNested": true,
           "type": "BankAccountRelation",
-          "column": "bankaccnt_id",
-          "isNested": true
+          "column": "bankaccnt_id"
         }
       },
       {
index 1d7452a..49eb845 100644 (file)
     "table": "xt.aropeninfo",
     "idSequenceName": "aropen_aropen_id_seq",
     "isRest": true,
-    "isNestedOnly": true,
     "isSystem": true,
     "comment": "Receivable Map",
     "privileges": {
index 73e200c..61d168a 100644 (file)
@@ -1,11 +1,24 @@
-/*jshint unused:false */
-/* global XG:true */
+// Contributions of status related functionality borrowed from SproutCore:
+// https://github.com/sproutcore/sproutcore
+
+/*jshint indent:2, curly:true, eqeqeq:true, immed:true, latedef:true,
+newcap:true, noarg:true, regexp:true, undef:true, strict:true, trailing:true,
+white:true, expr:true*/
+/*global XT:true, XM:true, Backbone:true, _:true, setInterval:true,
+  clearInterval:true, jsonpatch:true, Globalize:true, XG:true*/
 
 (function () {
-  'use strict';
+  "use strict";
 
   XM.Tuplespace = _.clone(Backbone.Events);
 
+
+  /*
+  XG.Tuplespace.on('all', function () {
+    //console.log(arguments);
+  });
+  */
+
   /**
     @class `XM.Model` is an abstract class designed to operate with `XT.DataSource`.
     It should be subclassed for any specific implementation. Subclasses should
         callback();
       }
     },
-
+      
     /**
       A function that binds events to functions. It can and should only be called
       once by initialize. Any attempt to call it a second time will throw an error.
     */
     bindEvents: function () {
-      var that = this;
       // Bind events, but only if we haven't already been here before.
       // We could silently skip, but then that means any overload done
       // by anyone else has to do that check too. That's too error prone
       // are not immediatley apparent and insidiously hard to pin down.
       if (this._eventsBound) { throw "Events have already been bound."; }
 
-      /**
-       * Bind all events in the optional 'handlers' hash
-       */
-      _.each(this.handlers, function (handler, event) {
-        if (!_.isFunction(that[handler])) {
-          console.warn('Handler '+ handler + 'not found: not binding');
-          return;
-        }
-        that.on(event, that[handler]);
-      });
-
       this.on('change', this.didChange);
       this.on('error', this.didError);
       this.on('destroy', this.didDestroy);
       _.each(
         _.where(this.relations, { type: Backbone.HasMany, includeInJSON: true }),
         function (relation) {
-          that.on('add:' + relation.key, that.didChange);
-          if (!that.isReadOnly()) {
-            that.on('add:' + relation.key, that.relationAdded);
+          this.on('add:' + relation.key, this.didChange);
+          if (!this.isReadOnly()) {
+            this.on('add:' + relation.key, this.relationAdded);
           }
-        });
+        }, this);
 
       this._idx = {};
       this._eventsBound = true;
     initialize: function (attributes, options) {
       attributes = attributes || {};
       options = options || {};
-      var that = this,
-        klass,
+      var klass,
         K = XM.Model,
         status = this.getStatus(),
         idAttribute = this.idAttribute;
       }
 
       /**
-       * Enable ability to listen for events in a global tuple-space, if
-       * required.
-       */
+      * Enable ability to listen for events in a global tuple-space, if
+      * required.
+      */
       XM.Tuplespace.listenTo(this, 'all', XM.Tuplespace.trigger);
     },
 
         parentRelation = _.find(this.relations, function (relation) {
           return relation.isAutoRelation;
         });
-        // #refactor XXX if this is a bona fide Backbone Relational relation,
-        // events will propagate automatically from child to parent.
         parent.changed[parentRelation.reverseRelation.key] = true;
         parent.trigger('change', parent, options);
       }
     if (options && options.isFetching) { this.status = XM.Model.BUSY_FETCHING; }
   };
 
-})();
+}());