JBAS-1038 Add LI notes on print/invoice
authorBill Erickson <berickxx@gmail.com>
Wed, 16 Dec 2015 16:05:17 +0000 (11:05 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Adds a lineitem note when a lineitem is printed, during a PO print
opereration, and when a lineitem is added to an invoice.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Financials.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Invoice.pm

index e66e648..f203f48 100644 (file)
@@ -1081,6 +1081,22 @@ sub format_po {
     my $po = $e->retrieve_acq_purchase_order($po_id) or return $e->event;
     return $e->event unless $e->allowed('VIEW_PURCHASE_ORDER', $po->ordering_agency);
 
+    # KCLS ---
+    # Add a note to each printed lineitem.
+    $e->xact_begin;
+    my $li_ids = $e->search_acq_lineitem(
+        {purchase_order => $po_id}, {idlist => 1});
+    for my $li_id (@$li_ids) {
+        my $note = Fieldmapper::acq::lineitem_note->new;
+        $note->lineitem($li_id);
+        $note->creator($e->requestor->id);
+        $note->editor($e->requestor->id);
+        $note->value('printed: ' . $e->requestor->usrname);
+        $e->create_acq_lineitem_note($note) or return $e->die_event;
+    }
+    $e->commit;
+    # ---
+
     my $hook = "format.po.$format";
     return $U->fire_object_event(undef, $hook, $po, $po->ordering_agency);
 }
index 78765c6..7fae388 100644 (file)
@@ -87,6 +87,7 @@ sub build_invoice_impl {
 
             if ($entry->isnew) {
                 $e->create_acq_invoice_entry($entry) or return $e->die_event;
+                return $evt if $evt = create_li_invoice_note($e, $entry);
                 return $evt if $evt = uncancel_copies_as_needed($e, $entry);
                 return $evt if $evt = update_entry_debits(
                     $e, $entry, 'unlinked', $inv_closing, $inv_reopening);
@@ -424,6 +425,19 @@ sub update_entry_debits {
     return undef;
 }
 
+# adds a note to the lineitem linked to the selected entry 
+# indicating the lineitem was invoiced.
+sub create_li_invoice_note {
+    my ($e, $entry) = @_;
+    my $note = Fieldmapper::acq::lineitem_note->new;
+    $note->lineitem($entry->lineitem);
+    $note->creator($e->requestor->id);
+    $note->editor($e->requestor->id);
+    $note->value('invoiced: ' . $e->requestor->usrname);
+    $e->create_acq_lineitem_note($note) or return $e->die_event;
+    return undef;
+}
+
 # This was originally done only for EDI invoices, but needs added to the
 # manual invoice-entering process for consistency's sake.
 sub uncancel_copies_as_needed {