From a1b89b3f8ef2ee93e7af9aab03272fd07b78e75d Mon Sep 17 00:00:00 2001 From: senator Date: Thu, 18 Feb 2010 17:05:11 +0000 Subject: [PATCH] Acq: Minor bugfixes to PO search interface 1) Avoid a problem with floating point math when summing amount_{encumbered,spent} in the combined PO view. 2) When redirected to the combined PO view after using the "split PO" function, check the "show results as a virtual combined PO" checkbox for interface consistency's sake. git-svn-id: svn://svn.open-ils.org/ILS/trunk@15584 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/ui/default/acq/po/search.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/js/ui/default/acq/po/search.js b/Open-ILS/web/js/ui/default/acq/po/search.js index b4185aee14..5ef4d24e26 100644 --- a/Open-ILS/web/js/ui/default/acq/po/search.js +++ b/Open-ILS/web/js/ui/default/acq/po/search.js @@ -82,6 +82,7 @@ function loadForm() { }).build(); if (poIds && poIds.length > 0) { + dijit.byId("metapo_view").attr("checked", true); doSearch({"id": poIds, "metapo_view": [true] /* [sic] */}); } else { doSearch({"ordering_agency": openils.User.user.ws_ou()}); @@ -129,6 +130,11 @@ function loadMetaPO(fields) { case "po": target.innerHTML = self.working_po_list.length; break; + /* Any numeric fields should be named here. */ + case "amount_encumbered": + case "amount_spent": + target.innerHTML = self.numericFieldTotal(part); + break; default: /* assume a field on the acqpo's themselves */ target.innerHTML = self.anyFieldTotal(part); @@ -141,10 +147,22 @@ function loadMetaPO(fields) { ); } }; + metaPO.numericFieldTotal = function(field) { + var self = this; + var pennies = self.working_po_list.reduce( + /* working_po_list contains unfleshed acqpo's, so we must + * find the same PO in the poCache */ + function(p, c) { + c = self.poCache[c.id()][field](); + return p + Number(c) * 100; + }, 0 + ); + return pennies / 100; + }; metaPO.anyFieldTotal = function(field) { var self = this; return self.working_po_list.reduce( - /* working_po_list contains unfleshed, acqpo's, so we must + /* working_po_list contains unfleshed acqpo's, so we must * find the same PO in the poCache */ function(p, c) { c = self.poCache[c.id()][field](); -- 2.43.2