[open-ils-commits] r10098 - branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jul 23 13:29:07 EDT 2008


Author: erickson
Date: 2008-07-23 13:28:57 -0400 (Wed, 23 Jul 2008)
New Revision: 10098

Modified:
   branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js
Log:
added getEstimatedPrice, getActualPrice, and getPrice functions

Modified: branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js	2008-07-23 17:16:05 UTC (rev 10097)
+++ branches/acq-experiment/Open-ILS/web/js/dojo/openils/acq/Lineitems.js	2008-07-23 17:28:57 UTC (rev 10098)
@@ -43,6 +43,37 @@
         }
     },
 
+    // returns the actual price if available, otherwise estimated price, otherwise null
+    // priority is given to local attrs, then provider attrs, then MARC attrs
+    getPrice: function() {
+        return this.getActualPrice() || this.getEstimatedPrice();
+    },
+
+    // returns the actual price, null if none
+    getActualPrice : function() {
+        return this._getPriceAttr('actual_price');
+    },
+
+    // returns the estimated price, null if none
+    getEstimatedPrice : function() {
+        return this._getPriceAttr('estimated_price');
+    },
+
+    _getPriceAttr : function(attr) {
+        var types = [
+            'lineitem_local_attr_definition', 
+            'lineitem_provider_attr_definition', 
+            'lineitem_marc_attr_definition'
+        ];
+
+        for(var t in types) {
+            if(price = this.findAttr(attr, types[t]))
+                return {price:price, source_type: attr, source_attr: types[t]};
+        }
+
+        return null;
+    },
+
     update: function(oncomplete) {
         fieldmapper.standardRequest(
             ['open-ils.acq', 'open-ils.acq.lineitem.update'],



More information about the open-ils-commits mailing list