RT86770 PO print lineitem counts & order date
authorBill Erickson <berickxx@gmail.com>
Fri, 20 Nov 2015 18:59:08 +0000 (13:59 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/sql/schema/deploy/po-print-li-count-and-date.sql [new file with mode: 0644]
KCLS/sql/schema/revert/po-print-li-count-and-date.sql [new file with mode: 0644]
KCLS/sql/schema/sqitch.plan
KCLS/sql/schema/verify/po-print-li-count-and-date.sql [new file with mode: 0644]

diff --git a/KCLS/sql/schema/deploy/po-print-li-count-and-date.sql b/KCLS/sql/schema/deploy/po-print-li-count-and-date.sql
new file mode 100644 (file)
index 0000000..b7384bc
--- /dev/null
@@ -0,0 +1,214 @@
+-- Deploy kcls-evergreen:po-print-li-count-and-date to pg
+-- requires: blanket-po-print-template
+
+BEGIN;
+
+UPDATE action_trigger.event_definition SET template =
+$TMPL$
+[% USE date %]
+[% USE String %]
+[% USE money=format('%.2f') -%]
+[%-
+    # find a lineitem attribute by name and optional type
+    BLOCK get_li_attr;
+        FOR attr IN li.attributes;
+            IF attr.attr_name == attr_name;
+                IF !attr_type OR attr_type == attr.attr_type;
+                    attr.attr_value;
+                    LAST;
+                END;
+            END;
+        END;
+    END
+-%]
+<img src="http://www.kcls.org/images/logo.gif" alt="kcls_brandmark" ALIGN=left width=74 height=150>
+<h2 CLASS="centeralign">Purchase Order [% target.id %]</h2>
+<BR CLEAR=LEFT>
+<br/>
+[% newstring = target.order_date | truncate(10,'')%]
+[% newstring2 = "$newstring 00:00:00" %]
+date <b>[% date.format(newstring2, '%m/%d/%Y') %]</b>
+<br/>
+
+<style>
+    table td { padding:5px; border:1px solid #aaa; font-size: 12px}
+    table { width:95%; border-collapse:collapse; font-size: 10px}
+    #vendor-notes { padding:5px; border:1px solid #aaa; font-size: 14px}
+    #vendor-table { padding:5px; border:1px solid #aaa; font-size: 14px}
+   #vendor-table td { padding:5px; border:1px solid #aaa; font-size: 14px}
+p { font-size: 14px }
+.rightalign {text-align:right}
+.centeralign {text-align:center}
+</style>
+<table id='vendor-table'>
+  <tr>
+    <td valign='top'>Vendor</td>
+    <td>
+      <div>[% target.provider.name %]</div>
+      <div>[% target.provider.addresses.0.street1 %]</div>
+      <div>[% target.provider.addresses.0.street2 %]</div>
+      <div>[% target.provider.addresses.0.city %] [% target.provider.addresses.0.state %] [% target.provider.addresses.0.post_code %]</div>
+    
+      <div>[% target.provider.addresses.0.country %]</div>
+    
+    </td>
+    <td valign='top'>Ship to / Bill to</td>
+    <td>
+      <div>KING COUNTY LIBRARY SYSTEM</div>
+      <div>ATTN: ORDER DEPT</div>
+      <div>960 NEWPORT WAY NW</div>
+      <div>ISSAQUAH WA 98027</div>
+
+    </td>
+  </tr>
+</table>
+
+<br/><br/>
+<fieldset id='vendor-notes'>
+    <legend>Notes to the Vendor</legend>
+    <ul>
+    [% FOR note IN target.notes %]
+        [% IF note.vendor_public == 't' %]
+            <li>[% note.value %]</li>
+        [% END %]
+    [% END %]
+    </ul>
+</fieldset>
+<br/><br/>
+
+<table>
+  <thead>
+    <tr>
+      <th>PO#</th>
+      <th>Line</th>
+      <th>ISBN / Item # / Charge Type</th>
+      <th>Title</th>
+      <th>Author</th>
+      <th>Pub Info</th>
+      <th>Quantity</th>
+      <th>Unit Price</th>
+      <th>Line Total</th>
+      <th>Notes</th>
+    </tr>
+  </thead>
+  <tbody>
+
+  [% subtotal = 0 %]
+  [% FOR li IN target.lineitems %]
+
+  <tr>
+    [% count = li.lineitem_details.size %]
+    [% price = li.estimated_unit_price %]
+    [% litotal = (price * count) %]
+    [% subtotal = subtotal + litotal %]
+    [% isbn = PROCESS get_li_attr attr_name = 'isbn' %]
+    [% ident = PROCESS get_li_attr attr_name = 'identifier' %]
+    [% upc = PROCESS get_li_attr attr_name = 'bupc' %]
+    [% author = PROCESS get_li_attr attr_name = 'author' %]
+    [% publisher = PROCESS get_li_attr attr_name = 'publisher' %]
+    [% pubdate = PROCESS get_li_attr attr_name = 'pubdate' %]
+    [% edition = PROCESS get_li_attr attr_name = 'edition' %]
+    [% vendnum = PROCESS get_li_attr attr_name = 'vendor_num' %]
+[%-
+                idval = '';
+                idqual = 'EN'; # default ISBN/UPC/EAN-13
+                ident_attr = helpers.get_li_order_ident(li.attributes);
+                IF ident_attr;
+                    idname = ident_attr.attr_name;
+                    idval = ident_attr.attr_value;
+                    IF idname == 'isbn' AND idval.length != 13;
+                        idqual = 'IB';
+                    ELSIF idname == 'issn';
+                        idqual = 'IS';
+                    END;
+                 
+                ELSE;
+                    idqual = 'IN';
+                    idval = '';
+                END -%]
+                   
+[%- IF vendnum != '';
+    idval = PROCESS get_li_attr attr_name = 'vendor_num';
+    END;
+-%]
+    <td>[% target.id %]</td>
+    <td>[% li.id %]</td>
+    <td>[% idval %]</td>
+       <td>[% PROCESS get_li_attr attr_name = 'title' %]  </td>
+    <td>[% author %]</td>
+    <td>[% publisher %] , [% pubdate %]</br>Edition: [% edition %]</td>
+    <td>[% count %]</td>
+    <td>[% price %]</td>
+    <td>[% money(litotal) %]</td>
+    <td>
+        <ul>
+        [% FOR note IN li.lineitem_notes %]
+            [% IF note.vendor_public == 't' %]
+                <li>[% note.value %]</li>
+            [% END %]
+        [% END %]
+        </ul>
+    </td>
+  </tr>
+  [% END %]
+  [% total_count = target.lineitems.size %]
+  [% FOR charge IN target.po_items %]
+    [%  subtotal = subtotal + charge.estimated_cost;
+        # a blanket charge is considered a single purchase.
+        IF charge.inv_item_type.blanket == 't';
+            total_count = total_count + 1;
+        END;
+    %]
+    <tr>
+        <td>[% target.id %]</td>
+        <td>[% charge.id %]</td>
+        <td>[% charge.inv_item_type.name %]</td>
+        <td>[% charge.title %]</td>
+        <td>[% charge.author %]</td>
+        <td></td>
+        <td></td>
+        <td>[% money(charge.estimated_cost) %]</td>
+        <td>[% money(charge.estimated_cost) %]</td>
+        [%# po_item.note has no concept of vendor-public, 
+            so avoid displaying it by default %]
+        <td></td>
+    </tr>
+  [% END %]
+  <tr>
+    <td/><td/><td/><td/><td> </td><td> </td><td> </td>
+    <td>Sub Total</td>
+    <td>[% money(subtotal) %]</td>
+<td> </td>
+
+  </tr>
+  </tbody>
+</table>
+
+<br/>
+
+Total Line Item Count:[% total_count %]<br/><br/>
+
+<p CLASS="rightalign">
+_____________________________<br/>
+Authorized By &nbsp; &nbsp;     
+&nbsp; &nbsp; &nbsp; &nbsp;     
+&nbsp; &nbsp; &nbsp; &nbsp;     
+&nbsp; &nbsp; &nbsp; &nbsp;     
+&nbsp; &nbsp; Date
+</p>
+
+<p>
+<b>SHIPPING AND BILLING INSTRUCTIONS</b><br/>
+Use our complete Ship To/Bill To address as given above.<br/>
+Report before sending if part of a numbered series, unless series is noted on this order.<br/>
+Do not send if price is substantially above our estimate.  Please call for confirmation. 425-369-3368<br/>
+Send invoice in duplicate to address given above.<br/>
+Cite our line item and order number with each item on invoices and/or correspondence.<br/>
+Shipments must be insured or sent at agent's risk.<br/>
+No COD shipments.<br/>
+Questions, call (425) 369-3368<br/>
+</p>
+$TMPL$ WHERE id = 4;
+
+
+COMMIT;
diff --git a/KCLS/sql/schema/revert/po-print-li-count-and-date.sql b/KCLS/sql/schema/revert/po-print-li-count-and-date.sql
new file mode 100644 (file)
index 0000000..659c4fb
--- /dev/null
@@ -0,0 +1,210 @@
+-- Revert kcls-evergreen:po-print-li-count-and-date from pg
+
+BEGIN;
+
+UPDATE action_trigger.event_definition SET template =
+$TMPL$
+[% USE String %]
+[% USE money=format('%.2f') -%]
+[%-
+    # find a lineitem attribute by name and optional type
+    BLOCK get_li_attr;
+        FOR attr IN li.attributes;
+            IF attr.attr_name == attr_name;
+                IF !attr_type OR attr_type == attr.attr_type;
+                    attr.attr_value;
+                    LAST;
+                END;
+            END;
+        END;
+    END
+-%]
+<img src="http://www.kcls.org/images/logo.gif" alt="kcls_brandmark" ALIGN=left width=74 height=150>
+<h2 CLASS="centeralign">Purchase Order [% target.id %]</h2>
+<BR CLEAR=LEFT>
+<br/>
+[% newstring = target.order_date | truncate(10,'')%]
+[% newstring2 = "$newstring 00:00:00" %]
+date <b>[% date.format(newstring2, '%m/%d/%Y') %]</b>
+<br/>
+
+<style>
+    table td { padding:5px; border:1px solid #aaa; font-size: 12px}
+    table { width:95%; border-collapse:collapse; font-size: 10px}
+    #vendor-notes { padding:5px; border:1px solid #aaa; font-size: 14px}
+    #vendor-table { padding:5px; border:1px solid #aaa; font-size: 14px}
+   #vendor-table td { padding:5px; border:1px solid #aaa; font-size: 14px}
+p { font-size: 14px }
+.rightalign {text-align:right}
+.centeralign {text-align:center}
+</style>
+<table id='vendor-table'>
+  <tr>
+    <td valign='top'>Vendor</td>
+    <td>
+      <div>[% target.provider.name %]</div>
+      <div>[% target.provider.addresses.0.street1 %]</div>
+      <div>[% target.provider.addresses.0.street2 %]</div>
+      <div>[% target.provider.addresses.0.city %] [% target.provider.addresses.0.state %] [% target.provider.addresses.0.post_code %]</div>
+    
+      <div>[% target.provider.addresses.0.country %]</div>
+    
+    </td>
+    <td valign='top'>Ship to / Bill to</td>
+    <td>
+      <div>KING COUNTY LIBRARY SYSTEM</div>
+      <div>ATTN: ORDER DEPT</div>
+      <div>960 NEWPORT WAY NW</div>
+      <div>ISSAQUAH WA 98027</div>
+
+    </td>
+  </tr>
+</table>
+
+<br/><br/>
+<fieldset id='vendor-notes'>
+    <legend>Notes to the Vendor</legend>
+    <ul>
+    [% FOR note IN target.notes %]
+        [% IF note.vendor_public == 't' %]
+            <li>[% note.value %]</li>
+        [% END %]
+    [% END %]
+    </ul>
+</fieldset>
+<br/><br/>
+
+<table>
+  <thead>
+    <tr>
+      <th>PO#</th>
+      <th>Line</th>
+      <th>ISBN / Item # / Charge Type</th>
+      <th>Title</th>
+      <th>Author</th>
+      <th>Pub Info</th>
+      <th>Quantity</th>
+      <th>Unit Price</th>
+      <th>Line Total</th>
+      <th>Notes</th>
+    </tr>
+  </thead>
+  <tbody>
+
+  [% subtotal = 0 %]
+  [% FOR li IN target.lineitems %]
+
+  <tr>
+    [% count = li.lineitem_details.size %]
+    [% price = li.estimated_unit_price %]
+    [% litotal = (price * count) %]
+    [% subtotal = subtotal + litotal %]
+    [% isbn = PROCESS get_li_attr attr_name = 'isbn' %]
+    [% ident = PROCESS get_li_attr attr_name = 'identifier' %]
+    [% upc = PROCESS get_li_attr attr_name = 'bupc' %]
+    [% author = PROCESS get_li_attr attr_name = 'author' %]
+    [% publisher = PROCESS get_li_attr attr_name = 'publisher' %]
+    [% pubdate = PROCESS get_li_attr attr_name = 'pubdate' %]
+    [% edition = PROCESS get_li_attr attr_name = 'edition' %]
+    [% vendnum = PROCESS get_li_attr attr_name = 'vendor_num' %]
+[%-
+                idval = '';
+                idqual = 'EN'; # default ISBN/UPC/EAN-13
+                ident_attr = helpers.get_li_order_ident(li.attributes);
+                IF ident_attr;
+                    idname = ident_attr.attr_name;
+                    idval = ident_attr.attr_value;
+                    IF idname == 'isbn' AND idval.length != 13;
+                        idqual = 'IB';
+                    ELSIF idname == 'issn';
+                        idqual = 'IS';
+                    END;
+                 
+                ELSE;
+                    idqual = 'IN';
+                    idval = '';
+                END -%]
+                   
+[%- IF vendnum != '';
+    idval = PROCESS get_li_attr attr_name = 'vendor_num';
+    END;
+-%]
+    <td>[% target.id %]</td>
+    <td>[% li.id %]</td>
+    <td>[% idval %]</td>
+       <td>[% PROCESS get_li_attr attr_name = 'title' %]  </td>
+    <td>[% author %]</td>
+    <td>[% publisher %] , [% pubdate %]</br>Edition: [% edition %]</td>
+    <td>[% count %]</td>
+    <td>[% price %]</td>
+    <td>[% money(litotal) %]</td>
+    <td>
+        <ul>
+        [% FOR note IN li.lineitem_notes %]
+            [% IF note.vendor_public == 't' %]
+                <li>[% note.value %]</li>
+            [% END %]
+        [% END %]
+        </ul>
+    </td>
+  </tr>
+  [% END %]
+  [% FOR charge IN target.po_items %]
+    [%  subtotal = subtotal + charge.estimated_cost;
+        # a blanket charge is considered a single purchase.
+        IF charge.inv_item_type.blanket == 't';
+            total_count = total + 1;
+        END;
+    %]
+    <tr>
+        <td>[% target.id %]</td>
+        <td>[% charge.id %]</td>
+        <td>[% charge.inv_item_type.name %]</td>
+        <td>[% charge.title %]</td>
+        <td>[% charge.author %]</td>
+        <td></td>
+        <td></td>
+        <td>[% money(charge.estimated_cost) %]</td>
+        <td>[% money(charge.estimated_cost) %]</td>
+        [%# po_item.note has no concept of vendor-public, 
+            so avoid displaying it by default %]
+        <td></td>
+    </tr>
+  [% END %]
+  <tr>
+    <td/><td/><td/><td/><td> </td><td> </td><td> </td>
+    <td>Sub Total</td>
+    <td>[% money(subtotal) %]</td>
+<td> </td>
+
+  </tr>
+  </tbody>
+</table>
+
+<br/>
+
+Total Line Item Count:[% total_count %]<br/><br/>
+
+<p CLASS="rightalign">
+_____________________________<br/>
+Authorized By &nbsp; &nbsp;     
+&nbsp; &nbsp; &nbsp; &nbsp;     
+&nbsp; &nbsp; &nbsp; &nbsp;     
+&nbsp; &nbsp; &nbsp; &nbsp;     
+&nbsp; &nbsp; Date
+</p>
+
+<p>
+<b>SHIPPING AND BILLING INSTRUCTIONS</b><br/>
+Use our complete Ship To/Bill To address as given above.<br/>
+Report before sending if part of a numbered series, unless series is noted on this order.<br/>
+Do not send if price is substantially above our estimate.  Please call for confirmation. 425-369-3368<br/>
+Send invoice in duplicate to address given above.<br/>
+Cite our line item and order number with each item on invoices and/or correspondence.<br/>
+Shipments must be insured or sent at agent's risk.<br/>
+No COD shipments.<br/>
+Questions, call (425) 369-3368<br/>
+</p>
+$TMPL$ WHERE id = 4;
+
+COMMIT;
index 0ed9546..254a844 100644 (file)
@@ -14,3 +14,4 @@ blanket-po [copy-stat-checkout-ok] 2015-08-14T21:03:02Z Bill Erickson  <berickxx
 collection-hq-floating-case [blanket-po] 2015-09-17T18:42:09Z Bill Erickson <berickxx@gmail.com> # CollectionHQ floating CASE/WHEN fix
 student-groups [blanket-po] 2015-09-16T14:36:00Z Bill Erickson <berickxx@gmail.com> # New groups for student cards
 blanket-po-print-template [student-groups] 2015-10-12T15:38:31Z Bill Erickson <berickxx@gmail.com> # Blanket PO print template
+po-print-li-count-and-date [blanket-po-print-template] 2015-11-20T18:56:33Z Bill Erickson <berickxx@gmail.com> # Minor PO print template repairs
diff --git a/KCLS/sql/schema/verify/po-print-li-count-and-date.sql b/KCLS/sql/schema/verify/po-print-li-count-and-date.sql
new file mode 100644 (file)
index 0000000..616f02c
--- /dev/null
@@ -0,0 +1,7 @@
+-- Verify kcls-evergreen:po-print-li-count-and-date on pg
+
+BEGIN;
+
+-- XXX Add verifications here.
+
+ROLLBACK;