From: Bill Erickson Date: Wed, 16 Dec 2015 16:05:17 +0000 (-0500) Subject: JBAS-1038 Add LI notes on print/invoice X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4a0b9d7de472d60602cf1d19b6ada1f842236364;p=working%2FEvergreen.git JBAS-1038 Add LI notes on print/invoice 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 --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Financials.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Financials.pm index e66e648563..f203f48d33 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Financials.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Financials.pm @@ -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); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Invoice.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Invoice.pm index 78765c62c4..7fae3880bd 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Invoice.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Invoice.pm @@ -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 {