]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0240.data.invoice_voucher.sql
LP1079041 - making state not required (continued)
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0240.data.invoice_voucher.sql
1 BEGIN;
2
3 INSERT INTO config.upgrade_log (version) VALUES ('0240'); -- senator
4
5 INSERT INTO action_trigger.hook (key, core_type, description, passive)
6     VALUES (
7         'format.acqinv.html',
8         'acqinv',
9         'Formats invoices into a voucher',
10         TRUE
11     );
12
13 INSERT INTO action_trigger.event_definition (
14         id, active, owner, name, hook,
15         validator, reactor, granularity, template
16     ) VALUES (
17         22,
18         TRUE,
19         1,
20         'Invoice',
21         'format.acqinv.html',
22         'NOOP_True',
23         'ProcessTemplate',
24         'print-on-demand',
25 $$
26 [% FILTER collapse %]
27 [%- SET invoice = target -%]
28 <!-- This lacks totals, info about funds (for invoice entries,
29     funds are per-LID!), and general refinement -->
30 <div class="acq-invoice-voucher">
31     <h1>Invoice</h1>
32     <div>
33         <strong>No.</strong> [% invoice.inv_ident %]
34         [% IF invoice.inv_type %]
35             / <strong>Type:</strong>[% invoice.inv_type %]
36         [% END %]
37     </div>
38     <div>
39         <dl>
40             [% BLOCK ent_with_address %]
41             <dt>[% ent_label %]: [% ent.name %] ([% ent.code %])</dt>
42             <dd>
43                 [% IF ent.addresses.0 %]
44                     [% SET addr = ent.addresses.0 %]
45                     [% addr.street1 %]<br />
46                     [% IF addr.street2 %][% addr.street2 %]<br />[% END %]
47                     [% addr.city %],
48                     [% IF addr.county %] [% addr.county %], [% END %]
49                     [% IF addr.state %] [% addr.state %] [% END %]
50                     [% IF addr.post_code %][% addr.post_code %][% END %]<br />
51                     [% IF addr.country %] [% addr.country %] [% END %]
52                 [% END %]
53                 <p>
54                     [% IF ent.phone %] Phone: [% ent.phone %]<br />[% END %]
55                     [% IF ent.fax_phone %] Fax: [% ent.fax_phone %]<br />[% END %]
56                     [% IF ent.url %] URL: [% ent.url %]<br />[% END %]
57                     [% IF ent.email %] E-mail: [% ent.email %] [% END %]
58                 </p>
59             </dd>
60             [% END %]
61             [% INCLUDE ent_with_address
62                 ent = invoice.provider
63                 ent_label = "Provider" %]
64             [% INCLUDE ent_with_address
65                 ent = invoice.shipper
66                 ent_label = "Shipper" %]
67             <dt>Receiver</dt>
68             <dd>
69                 [% invoice.receiver.name %] ([% invoice.receiver.shortname %])
70             </dd>
71             <dt>Received</dt>
72             <dd>
73                 [% helpers.format_date(invoice.recv_date) %] by
74                 [% invoice.recv_method %]
75             </dd>
76             [% IF invoice.note %]
77                 <dt>Note</dt>
78                 <dd>
79                     [% invoice.note %]
80                 </dd>
81             [% END %]
82         </dl>
83     </div>
84     <ul>
85         [% FOR entry IN invoice.entries %]
86             <li>
87                 [% IF entry.lineitem %]
88                     Title: [% helpers.get_li_attr(
89                         "title", "", entry.lineitem.attributes
90                     ) %]<br />
91                     Author: [% helpers.get_li_attr(
92                         "author", "", entry.lineitem.attributes
93                     ) %]
94                 [% END %]
95                 [% IF entry.purchase_order %]
96                     (PO: [% entry.purchase_order.name %])
97                 [% END %]<br />
98                 Invoice item count: [% entry.inv_item_count %]
99                 [% IF entry.phys_item_count %]
100                     / Physical item count: [% entry.phys_item_count %]
101                 [% END %]
102                 <br />
103                 [% IF entry.cost_billed %]
104                     Cost billed: [% entry.cost_billed %]
105                     [% IF entry.billed_per_item %](per item)[% END %]
106                     <br />
107                 [% END %]
108                 [% IF entry.actual_cost %]
109                     Actual cost: [% entry.actual_cost %]<br />
110                 [% END %]
111                 [% IF entry.amount_paid %]
112                     Amount paid: [% entry.amount_paid %]<br />
113                 [% END %]
114                 [% IF entry.note %]Note: [% entry.note %][% END %]
115             </li>
116         [% END %]
117         [% FOR item IN invoice.items %]
118             <li>
119                 [% IF item.inv_item_type %]
120                     Item Type: [% item.inv_item_type %]<br />
121                 [% END %]
122                 [% IF item.title %]Title/Description:
123                     [% item.title %]<br />
124                 [% END %]
125                 [% IF item.author %]Author: [% item.author %]<br />[% END %]
126                 [% IF item.purchase_order %]PO: [% item.purchase_order %]<br />[% END %]
127                 [% IF item.note %]Note: [% item.note %]<br />[% END %]
128                 [% IF item.cost_billed %]
129                     Cost billed: [% item.cost_billed %]<br />
130                 [% END %]
131                 [% IF item.actual_cost %]
132                     Actual cost: [% item.actual_cost %]<br />
133                 [% END %]
134                 [% IF item.amount_paid %]
135                     Amount paid: [% item.amount_paid %]<br />
136                 [% END %]
137             </li>
138         [% END %]
139     </ul>
140 </div>
141 [% END %]
142 $$
143 );
144
145
146 INSERT INTO action_trigger.environment (event_def, path) VALUES
147     (22, 'provider'),
148     (22, 'provider.addresses'),
149     (22, 'shipper'),
150     (22, 'shipper.addresses'),
151     (22, 'receiver'),
152     (22, 'entries'),
153     (22, 'entries.purchase_order'),
154     (22, 'entries.lineitem'),
155     (22, 'entries.lineitem.attributes'),
156     (22, 'items')
157 ;
158
159 COMMIT;