From 2004f95f850f71803464b1745d0beaa886fce4d5 Mon Sep 17 00:00:00 2001 From: senator Date: Mon, 26 Apr 2010 19:58:03 +0000 Subject: [PATCH] Acq: invoices are now printable from search results git-svn-id: svn://svn.open-ils.org/ILS/trunk@16313 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Acq/Invoice.pm | 45 ++++++ Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 155 ++++++++++++++++++++ .../sql/Pg/upgrade/0240.data.invoice_voucher.sql | 159 +++++++++++++++++++++ Open-ILS/web/css/skin/default/acq.css | 1 + Open-ILS/web/js/dojo/openils/acq/nls/acq.js | 3 +- .../web/templates/default/acq/search/unified.tt2 | 49 ++++++- 7 files changed, 410 insertions(+), 4 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0240.data.invoice_voucher.sql diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm index f0f08e1668..e435c4700d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm @@ -399,4 +399,49 @@ sub prorate_invoice { } +__PACKAGE__->register_method( + method => "print_html_invoice", + api_name => "open-ils.acq.invoice.print.html", + stream => 1, + signature => { + desc => "Retrieve printable HTML vouchers for each given invoice", + params => [ + {desc => "Authentication token", type => "string"}, + {desc => "Invoice ID or a list of them", type => "mixed"}, + ], + return => { + desc => q{One A/T event containing a printable HTML voucher for + each given invoice}, + type => "object", class => "atev"} + } +); + + +sub print_html_invoice { + my ($self, $conn, $auth, $id_list) = @_; + + my $e = new_editor("authtoken" => $auth); + return $e->die_event unless $e->checkauth; + + $id_list = [$id_list] unless ref $id_list; + + my $invoices = $e->search_acq_invoice({"id" => $id_list}) or + return $e->die_event; + + foreach my $invoice (@$invoices) { + return $e->die_event unless + $e->allowed("VIEW_INVOICE", $invoice->receiver); + + $conn->respond( + $U->fire_object_event( + undef, "format.acqinv.html", $invoice, $invoice->receiver, + "print-on-demand" + ) + ); + } + + $e->disconnect; + undef; +} + 1; diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 64d0007509..d06bb6d685 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -60,7 +60,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0239'); -- phasefx +INSERT INTO config.upgrade_log (version) VALUES ('0240'); -- senator CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 6da856dfc6..533fa8516f 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -3766,6 +3766,161 @@ INSERT INTO action_trigger.environment (event_def, path) VALUES (21, 'type') ; + +INSERT INTO action_trigger.hook (key, core_type, description, passive) + VALUES ( + 'format.acqinv.html', + 'acqinv', + 'Formats invoices into a voucher', + TRUE + ); + +INSERT INTO action_trigger.event_definition ( + id, active, owner, name, hook, + validator, reactor, granularity, template + ) VALUES ( + 22, + TRUE, + 1, + 'Invoice', + 'format.acqinv.html', + 'NOOP_True', + 'ProcessTemplate', + 'print-on-demand', +$$ +[% FILTER collapse %] +[%- SET invoice = target -%] + +
+

Invoice

+
+ No. [% invoice.inv_ident %] + [% IF invoice.inv_type %] + / Type:[% invoice.inv_type %] + [% END %] +
+
+
+ [% BLOCK ent_with_address %] +
[% ent_label %]: [% ent.name %] ([% ent.code %])
+
+ [% IF ent.addresses.0 %] + [% SET addr = ent.addresses.0 %] + [% addr.street1 %]
+ [% IF addr.street2 %][% addr.street2 %]
[% END %] + [% addr.city %], + [% IF addr.county %] [% addr.county %], [% END %] + [% IF addr.state %] [% addr.state %] [% END %] + [% IF addr.post_code %][% addr.post_code %][% END %]
+ [% IF addr.country %] [% addr.country %] [% END %] + [% END %] +

+ [% IF ent.phone %] Phone: [% ent.phone %]
[% END %] + [% IF ent.fax_phone %] Fax: [% ent.fax_phone %]
[% END %] + [% IF ent.url %] URL: [% ent.url %]
[% END %] + [% IF ent.email %] E-mail: [% ent.email %] [% END %] +

+
+ [% END %] + [% INCLUDE ent_with_address + ent = invoice.provider + ent_label = "Provider" %] + [% INCLUDE ent_with_address + ent = invoice.shipper + ent_label = "Shipper" %] +
Receiver
+
+ [% invoice.receiver.name %] ([% invoice.receiver.shortname %]) +
+
Received
+
+ [% helpers.format_date(invoice.recv_date) %] by + [% invoice.recv_method %] +
+ [% IF invoice.note %] +
Note
+
+ [% invoice.note %] +
+ [% END %] +
+
+ +
+[% END %] +$$ +); + + +INSERT INTO action_trigger.environment (event_def, path) VALUES + (22, 'provider'), + (22, 'provider.addresses'), + (22, 'shipper'), + (22, 'shipper.addresses'), + (22, 'receiver'), + (22, 'entries'), + (22, 'entries.purchase_order'), + (22, 'entries.lineitem'), + (22, 'entries.lineitem.attributes'), + (22, 'items') +; + SELECT SETVAL('action_trigger.event_definition_id_seq'::TEXT, 100); -- Org Unit Settings for configuring org unit weights and org unit max-loops for hold targeting diff --git a/Open-ILS/src/sql/Pg/upgrade/0240.data.invoice_voucher.sql b/Open-ILS/src/sql/Pg/upgrade/0240.data.invoice_voucher.sql new file mode 100644 index 0000000000..2757164373 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0240.data.invoice_voucher.sql @@ -0,0 +1,159 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0240'); -- senator + +INSERT INTO action_trigger.hook (key, core_type, description, passive) + VALUES ( + 'format.acqinv.html', + 'acqinv', + 'Formats invoices into a voucher', + TRUE + ); + +INSERT INTO action_trigger.event_definition ( + id, active, owner, name, hook, + validator, reactor, granularity, template + ) VALUES ( + 22, + TRUE, + 1, + 'Invoice', + 'format.acqinv.html', + 'NOOP_True', + 'ProcessTemplate', + 'print-on-demand', +$$ +[% FILTER collapse %] +[%- SET invoice = target -%] + +
+

Invoice

+
+ No. [% invoice.inv_ident %] + [% IF invoice.inv_type %] + / Type:[% invoice.inv_type %] + [% END %] +
+
+
+ [% BLOCK ent_with_address %] +
[% ent_label %]: [% ent.name %] ([% ent.code %])
+
+ [% IF ent.addresses.0 %] + [% SET addr = ent.addresses.0 %] + [% addr.street1 %]
+ [% IF addr.street2 %][% addr.street2 %]
[% END %] + [% addr.city %], + [% IF addr.county %] [% addr.county %], [% END %] + [% IF addr.state %] [% addr.state %] [% END %] + [% IF addr.post_code %][% addr.post_code %][% END %]
+ [% IF addr.country %] [% addr.country %] [% END %] + [% END %] +

+ [% IF ent.phone %] Phone: [% ent.phone %]
[% END %] + [% IF ent.fax_phone %] Fax: [% ent.fax_phone %]
[% END %] + [% IF ent.url %] URL: [% ent.url %]
[% END %] + [% IF ent.email %] E-mail: [% ent.email %] [% END %] +

+
+ [% END %] + [% INCLUDE ent_with_address + ent = invoice.provider + ent_label = "Provider" %] + [% INCLUDE ent_with_address + ent = invoice.shipper + ent_label = "Shipper" %] +
Receiver
+
+ [% invoice.receiver.name %] ([% invoice.receiver.shortname %]) +
+
Received
+
+ [% helpers.format_date(invoice.recv_date) %] by + [% invoice.recv_method %] +
+ [% IF invoice.note %] +
Note
+
+ [% invoice.note %] +
+ [% END %] +
+
+ +
+[% END %] +$$ +); + + +INSERT INTO action_trigger.environment (event_def, path) VALUES + (22, 'provider'), + (22, 'provider.addresses'), + (22, 'shipper'), + (22, 'shipper.addresses'), + (22, 'receiver'), + (22, 'entries'), + (22, 'entries.purchase_order'), + (22, 'entries.lineitem'), + (22, 'entries.lineitem.attributes'), + (22, 'items') +; + +COMMIT; diff --git a/Open-ILS/web/css/skin/default/acq.css b/Open-ILS/web/css/skin/default/acq.css index 896aa1114a..f55da5643b 100644 --- a/Open-ILS/web/css/skin/default/acq.css +++ b/Open-ILS/web/css/skin/default/acq.css @@ -230,6 +230,7 @@ option[disabled="disabled"] { font-style: italic; } .acq-unified-terms-match { width: 15%; } .acq-unified-terms-remove { width: 5%; text-align: right; } .acq-unified-remover { color: #c00; } +.acq-unified-result-specific-controls { margin-bottom: 8px; } #acq-eligible-li-table { margin: 10px 0; } #acq-eligible-li-table th { background-color: #ccc; border: 1px #333 inset; font-weight: bold; padding: 6px; } 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 f9bb64b31e..3471092c12 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -75,5 +75,6 @@ 'CANCELED': "Canceled", 'RECVD': "Recv'd", 'NOT_RECVD': "Not recv'd", - 'PRINT': "Print" + 'PRINT': "Print", + 'INVOICES': "Invoices" } diff --git a/Open-ILS/web/templates/default/acq/search/unified.tt2 b/Open-ILS/web/templates/default/acq/search/unified.tt2 index f5722e28f1..a09d85d7e0 100644 --- a/Open-ILS/web/templates/default/acq/search/unified.tt2 +++ b/Open-ILS/web/templates/default/acq/search/unified.tt2 @@ -5,8 +5,9 @@