From 6eeb7ea475246cc843439786ce62efdd35656707 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 23 Jul 2008 17:28:57 +0000 Subject: [PATCH] added getEstimatedPrice, getActualPrice, and getPrice functions git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@10098 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/acq/Lineitems.js | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Open-ILS/web/js/dojo/openils/acq/Lineitems.js b/Open-ILS/web/js/dojo/openils/acq/Lineitems.js index 3cd86b7fd2..ff99054a03 100644 --- a/Open-ILS/web/js/dojo/openils/acq/Lineitems.js +++ b/Open-ILS/web/js/dojo/openils/acq/Lineitems.js @@ -43,6 +43,37 @@ dojo.declare('openils.acq.Lineitems', null, { } }, + // 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'], -- 2.11.0