From a50e27a329f8464126af9d0cf8f6f7984c445709 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 5 Apr 2010 18:58:48 +0000 Subject: [PATCH] UI for creating a new invoice and attaching a lineitem. Stub invoice viewing interface git-svn-id: svn://svn.open-ils.org/ILS/trunk@16136 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/css/skin/default/acq.css | 7 + Open-ILS/web/js/dojo/openils/acq/nls/acq.js | 1 + Open-ILS/web/js/ui/default/acq/invoice/attach.js | 162 +++++++++++++++++++++ Open-ILS/web/js/ui/default/acq/invoice/common.js | 36 +++++ Open-ILS/web/js/ui/default/acq/invoice/view.js | 30 ++++ .../web/templates/default/acq/invoice/attach.tt2 | 31 ++++ .../web/templates/default/acq/invoice/view.tt2 | 18 +++ Open-ILS/web/templates/default/acq/po/view.tt2 | 6 + 8 files changed, 291 insertions(+) create mode 100644 Open-ILS/web/js/ui/default/acq/invoice/attach.js create mode 100644 Open-ILS/web/js/ui/default/acq/invoice/common.js create mode 100644 Open-ILS/web/js/ui/default/acq/invoice/view.js create mode 100644 Open-ILS/web/templates/default/acq/invoice/attach.tt2 create mode 100644 Open-ILS/web/templates/default/acq/invoice/view.tt2 diff --git a/Open-ILS/web/css/skin/default/acq.css b/Open-ILS/web/css/skin/default/acq.css index be0c83b45..1af210975 100644 --- a/Open-ILS/web/css/skin/default/acq.css +++ b/Open-ILS/web/css/skin/default/acq.css @@ -194,3 +194,10 @@ span[name="notes_alert_flag"] {color: #c00;font-weight: bold;font-size: 110%;mar text-align:center; border:1px solid #888; } + + +/* INVOICING */ +#oils-acq-invoice-table td { padding: 5px; } +#acq-invoice-new-msg { font-weight: bold; margin: 10px;} +#acq-invoice-li-details { padding: 10px; font-weight: bold; border: 1px solid #888; margin: 10px; } +#acq-invoice-create { margin: 10px; } diff --git a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js index e88bdc848..0ae9ffcd8 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -56,4 +56,5 @@ 'PO_FUND_WARNING_CONFIRM': "Are you sure? Did you see the warning about over-encumbering a fund?", 'CONFIRM_FUNDS_AT_STOP': "One or more of the selected funds has a balance below its stop level.\nYou may not be able to activate purchase orders incorporating these copies.\nContinue?", 'CONFIRM_FUNDS_AT_WARNING': "One or more of the selected funds has a balance below its warning level.\nContinue?", + 'INVOICE_ITEM_DETAILS' : "${0}
${1}
${2}.
Estimated Price: $${3}.
Lineitem ID: ${4}
PO: ${5}
Order Date: ${6}", } diff --git a/Open-ILS/web/js/ui/default/acq/invoice/attach.js b/Open-ILS/web/js/ui/default/acq/invoice/attach.js new file mode 100644 index 000000000..1f49ce99b --- /dev/null +++ b/Open-ILS/web/js/ui/default/acq/invoice/attach.js @@ -0,0 +1,162 @@ +dojo.require('dojo.date.locale'); +dojo.require('dojo.date.stamp'); +dojo.require('dijit.layout.ContentPane'); +dojo.require('dijit.form.TextBox'); +dojo.require('dijit.form.NumberTextBox'); +dojo.require('dijit.form.CurrencyTextBox'); +dojo.require('openils.User'); +dojo.require('openils.Util'); +dojo.require('openils.PermaCrud'); +dojo.require('openils.widget.AutoFieldWidget'); + +dojo.requireLocalization('openils.acq', 'acq'); +var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq'); + +var pcrud = new openils.PermaCrud(); +var cgi = new openils.CGI(); +var doCreate = false; +var invoiceId; +var lineitem; +var invoicePane; +var entryPane; + +function init() { + + invoiceId = cgi.param('invoice_id'); + doCreate = cgi.param('create'); + attachLi = cgi.param('attach_li'); + + invoicePane = drawInvoicePane(dojo.byId('acq-view-invoice-div')); + + fieldmapper.standardRequest( + ["open-ils.acq", "open-ils.acq.lineitem.retrieve"], { + async: true, + params: [openils.User.authtoken, attachLi, { + flesh_attrs: true, + flesh_li_details: true, + flesh_cancel_reason: true, + flesh_po : true, + flesh_pl : true + }], + oncomplete: function(r) { + lineitem = openils.Util.readResponse(r); + drawPage(); + } + } + ); + + dojo.connect(createInvoiceButton, 'onClick', function() { createInvoice(); }); +} + +function liMarcAttr(name) { + var attr = lineitem.attributes().filter( + function(attr) { + if( + attr.attr_type() == 'lineitem_marc_attr_definition' && + attr.attr_name() == name) + return attr + } + )[0]; + return (attr) ? attr.attr_value() : ''; +} + +function drawPage() { + + var idents = []; + if(liMarcAttr('isbn')) idents.push(liMarcAttr('isbn')); + if(liMarcAttr('upc')) idents.push(liMarcAttr('upc')); + if(liMarcAttr('issn')) idents.push(liMarcAttr('issn')); + + var orderDate = ''; + var po = lineitem.purchase_order(); + if(po.order_date()) { + var dt = dojo.date.stamp.fromISOString(po.order_date()); + orderDate = dojo.date.locale.format(dt, {selector:'date'}); + } + + dojo.byId('acq-invoice-li-details').innerHTML = + dojo.string.substitute( + localeStrings.INVOICE_ITEM_DETAILS, + [ + liMarcAttr('title'), + liMarcAttr('author'), + idents.join(','), + lineitem.estimated_unit_price() || '', + lineitem.id(), + lineitem.purchase_order().name(), + orderDate + ] + ); + + //invoicePo.attr('value', lineitem.purchase_order().name()); + //invoicePo.attr('disabled', true); + + //numCopiesInvoiced.attr('value', lineitem.lineitem_details().length); + + var numReceived = 0; + dojo.forEach(lineitem.lineitem_details(), function(lid) { if(lid.recv_time) numReceived++ }); + //numCopiesReceived.attr('value', numReceived); + + entryPane = new openils.widget.EditPane({ + fmClass : 'acqie', + mode : 'create', + hideActionButtons : true, + existingTable : invoicePane.table, + overrideWidgetArgs : { + inv_item_count : {widgetValue : numReceived}, + phys_item_count : {widgetValue : numReceived} + }, + fieldOrder : [ + 'purchase_order', + 'inv_item_count', + 'phys_item_count', + 'cost_billed', + 'note' + ], + suppressFields : [ + 'invoice', + 'purchase_order', + 'lineitem', + 'actual_cost' + ] + }); + entryPane.startup(); + +} + + +function createInvoice() { + + var inv = new fieldmapper.acqinv(); + dojo.forEach(invoicePane.fieldList, + function(field) { + inv[field.name]( field.widget.getFormattedValue() ); + } + ); + + var entry = new fieldmapper.acqie(); + dojo.forEach(entryPane.fieldList, + function(field) { + entry[field.name]( field.widget.getFormattedValue() ); + } + ); + entry.purchase_order(lineitem.purchase_order().id()); + entry.lineitem(lineitem.id()); + + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.invoice.create'], + { + params : [openils.User.authtoken, inv, [entry]], + oncomplete : function(r) { + var resp = openils.Util.readResponse(r); + if(resp) { + location.href = + location.href.replace(/invoice\/attach.*/, 'invoice/view/' + resp.id()); + } + } + } + ); +} + +openils.Util.addOnLoad(init); + diff --git a/Open-ILS/web/js/ui/default/acq/invoice/common.js b/Open-ILS/web/js/ui/default/acq/invoice/common.js new file mode 100644 index 000000000..953669127 --- /dev/null +++ b/Open-ILS/web/js/ui/default/acq/invoice/common.js @@ -0,0 +1,36 @@ +dojo.require('dojo.date.stamp'); +dojo.require('openils.User'); +dojo.require('openils.widget.EditPane'); + +function drawInvoicePane(parentNode, inv) { + + var override; + if(!inv) { + override = { + recv_date : {widgetValue : dojo.date.stamp.toISOString(new Date())}, + receiver : {widgetValue : openils.User.user.ws_ou()}, + recv_method : {widgetValue : 'PPR'} + }; + } + + var pane = new openils.widget.EditPane({ + fmObject : inv, + fmClass : 'acqinv', + mode : (inv) ? 'edit' : 'create', + hideActionButtons : true, + overrideWidgetArgs : override, + fieldOrder : [ + 'inv_ident', + 'recv_date', + 'recv_method', + 'inv_type', + 'provider', + 'shipper' + ] + }); + + pane.startup(); + parentNode.appendChild(pane.domNode); + return pane; +} + diff --git a/Open-ILS/web/js/ui/default/acq/invoice/view.js b/Open-ILS/web/js/ui/default/acq/invoice/view.js new file mode 100644 index 000000000..79028a24d --- /dev/null +++ b/Open-ILS/web/js/ui/default/acq/invoice/view.js @@ -0,0 +1,30 @@ +dojo.require('dojo.date.locale'); +dojo.require('dojo.date.stamp'); +dojo.require('openils.User'); +dojo.require('openils.Util'); +dojo.require('openils.PermaCrud'); +dojo.require('openils.widget.EditPane'); + +dojo.requireLocalization('openils.acq', 'acq'); +var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq'); + +var pcrud = new openils.PermaCrud(); +var invoice; + +function init() { + + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.invoice.retrieve'], + { + params : [openils.User.authtoken, invoiceId], + oncomplete : function(r) { + invoice = openils.Util.readResponse(r); + drawInvoicePane(dojo.byId('acq-view-invoice-div'), invoice); + } + } + ); +} + +openils.Util.addOnLoad(init); + + diff --git a/Open-ILS/web/templates/default/acq/invoice/attach.tt2 b/Open-ILS/web/templates/default/acq/invoice/attach.tt2 new file mode 100644 index 000000000..a05ec426a --- /dev/null +++ b/Open-ILS/web/templates/default/acq/invoice/attach.tt2 @@ -0,0 +1,31 @@ +[% WRAPPER 'default/base.tt2' %] +[% ctx.page_title = 'Attach Invoice Entry' %] + + + +
+ +
+
Attach Invoice Entry
+
+
+ +
+
+ +
+ This will create a new invoice. To link this item to an existing invoice, + click here. +
+ +
+ + +
+
+ +
+ +
+
+[% END %] diff --git a/Open-ILS/web/templates/default/acq/invoice/view.tt2 b/Open-ILS/web/templates/default/acq/invoice/view.tt2 new file mode 100644 index 000000000..cd883046c --- /dev/null +++ b/Open-ILS/web/templates/default/acq/invoice/view.tt2 @@ -0,0 +1,18 @@ +[% WRAPPER 'default/base.tt2' %] +[% ctx.page_title = 'Invoice' %] + + + +
+ +
+
Invoice
+
+
+ +
+
+
+ +
+[% END %] diff --git a/Open-ILS/web/templates/default/acq/po/view.tt2 b/Open-ILS/web/templates/default/acq/po/view.tt2 index c4054c6cb..aae3b5374 100644 --- a/Open-ILS/web/templates/default/acq/po/view.tt2 +++ b/Open-ILS/web/templates/default/acq/po/view.tt2 @@ -50,6 +50,12 @@ + + Invoice(s) + + (0) + +
-- 2.11.0