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;