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 %]
[% FOR entry IN invoice.entries %]
-
[% IF entry.lineitem %]
Title: [% helpers.get_li_attr(
"title", "", entry.lineitem.attributes
) %]
Author: [% helpers.get_li_attr(
"author", "", entry.lineitem.attributes
) %]
[% END %]
[% IF entry.purchase_order %]
(PO: [% entry.purchase_order.name %])
[% END %]
Invoice item count: [% entry.inv_item_count %]
[% IF entry.phys_item_count %]
/ Physical item count: [% entry.phys_item_count %]
[% END %]
[% IF entry.cost_billed %]
Cost billed: [% entry.cost_billed %]
[% IF entry.billed_per_item %](per item)[% END %]
[% END %]
[% IF entry.actual_cost %]
Actual cost: [% entry.actual_cost %]
[% END %]
[% IF entry.amount_paid %]
Amount paid: [% entry.amount_paid %]
[% END %]
[% IF entry.note %]Note: [% entry.note %][% END %]
[% END %]
[% FOR item IN invoice.items %]
-
[% IF item.inv_item_type %]
Item Type: [% item.inv_item_type %]
[% END %]
[% IF item.title %]Title/Description:
[% item.title %]
[% END %]
[% IF item.author %]Author: [% item.author %]
[% END %]
[% IF item.purchase_order %]PO: [% item.purchase_order %]
[% END %]
[% IF item.note %]Note: [% item.note %]
[% END %]
[% IF item.cost_billed %]
Cost billed: [% item.cost_billed %]
[% END %]
[% IF item.actual_cost %]
Actual cost: [% item.actual_cost %]
[% END %]
[% IF item.amount_paid %]
Amount paid: [% item.amount_paid %]
[% END %]
[% 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;