From 203c37eea6574b50faf4ff1964869648c3dd0b39 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 13 Mar 2018 16:03:02 -0400 Subject: [PATCH] LP#1750894 Invoice close date/by fields UI WIP Signed-off-by: Bill Erickson --- .../lib/OpenILS/Application/Acq/Invoice.pm | 27 ++++++++++++---------- Open-ILS/web/js/ui/default/acq/invoice/view.js | 18 +++++++-------- 2 files changed, 24 insertions(+), 21 deletions(-) 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 80d8e3c7e4..78765c62c4 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Invoice.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Invoice.pm @@ -56,7 +56,10 @@ sub build_invoice_impl { if ($invoice->isnew) { $invoice->recv_method('PPR') unless $invoice->recv_method; $invoice->recv_date('now') unless $invoice->recv_date; - $inv_closing = $U->is_true($invoice->complete); + if ($invoice->close_date) { + $inv_closing = 1; + $invoice->closed_by($e->requestor->id); + } $e->create_acq_invoice($invoice) or return $e->die_event; } elsif ($invoice->isdeleted) { $e->delete_acq_invoice($invoice) or return $e->die_event; @@ -64,13 +67,14 @@ sub build_invoice_impl { my $orig_inv = $e->retrieve_acq_invoice($invoice->id) or return $e->die_event; - $inv_closing = ( - !$U->is_true($orig_inv->complete) && - $U->is_true($invoice->complete)); + if (!$orig_inv->close_date && $invoice->close_date) { + $inv_closing = 1; + $invoice->closed_by($e->requestor->id); - $inv_reopening = ( - $U->is_true($orig_inv->complete) && - !$U->is_true($invoice->complete)); + } elsif ($orig_inv->close_date && !$invoice->close_date) { + $inv_reopening = 1; + $invoice->clear_closed_by; + } $e->update_acq_invoice($invoice) or return $e->die_event; } @@ -140,8 +144,7 @@ sub build_invoice_impl { # being. if (not $U->is_true($item_type->prorate) and - ($item->po_item or $item->fund or - $U->is_true($invoice->complete))) { + ($item->po_item or $item->fund or $invoice->close_date)) { my $debit; if ($item->po_item) { @@ -381,8 +384,8 @@ sub rollback_entry_debits { } # invoiced -- debits already linked to this invoice -# inv_closing -- invoice is going from complete=f to t. -# inv_reopening -- invoice is going from complete=t to f. +# inv_closing -- invoice is going from close_date=null to now +# inv_reopening -- invoice is going from close_date=date to null sub update_entry_debits { my($e, $entry, $link_state, $inv_closing, $inv_reopening) = @_; @@ -709,7 +712,7 @@ sub fetch_invoice_impl { { "flesh" => 6, "flesh_fields" => { - "acqinv" => ["entries", "items"], + "acqinv" => ["entries", "items", "closed_by"], "acqii" => ["fund_debit", "purchase_order", "po_item"] } } diff --git a/Open-ILS/web/js/ui/default/acq/invoice/view.js b/Open-ILS/web/js/ui/default/acq/invoice/view.js index 9ac5e25a05..8ace4b3b5a 100644 --- a/Open-ILS/web/js/ui/default/acq/invoice/view.js +++ b/Open-ILS/web/js/ui/default/acq/invoice/view.js @@ -138,7 +138,7 @@ function renderInvoice() { updateTotalCost(); - if(invoice && openils.Util.isTrue(invoice.complete())) { + if(invoice && invoice.close_date()) { dojo.forEach( // hide widgets that should not be visible for a completed invoice dojo.query('.hide-complete'), @@ -632,7 +632,7 @@ function addInvoiceItem(item) { fmClass : 'acqii', fmObject : item, fmField : field, - readOnly : invoice && openils.Util.isTrue(invoice.complete()), + readOnly : invoice && invoice.close_date(), dijitArgs : args, parentNode : nodeByName(field, row) }), @@ -660,7 +660,7 @@ function addInvoiceItem(item) { labelFormat : fundLabelFormat, searchFormat : fundSearchFormat, searchFilter : fundSearchFilter, - readOnly : invoice && openils.Util.isTrue(invoice.complete()), + readOnly : invoice && invoice.close_date(), dijitArgs : {required : true}, parentNode : nodeByName('fund', row) } @@ -736,7 +736,7 @@ function addInvoiceItem(item) { fmObject : item, fmField : 'inv_item_type', parentNode : nodeByName('inv_item_type', row), - readOnly : invoice && openils.Util.isTrue(invoice.complete()), + readOnly : invoice && invoice.close_date(), dijitArgs : {required : true} }), function(w, ww) { @@ -932,7 +932,7 @@ function addInvoiceEntry(entry) { fmClass : 'acqie', fmField : field, dijitArgs : dijitArgs, - readOnly : invoice && openils.Util.isTrue(invoice.complete()), + readOnly : invoice && invoice.close_date(), parentNode : nodeByName(field, row) }), function(w) { @@ -1056,7 +1056,7 @@ function saveChangesPartTwo(args) { args = args || {}; if(args.reopen) { - invoice.complete('f'); + invoice.close_date(null); } else { @@ -1075,7 +1075,7 @@ function saveChangesPartTwo(args) { } if(args.close) - invoice.complete('t'); + invoice.close_date('now'); // Prepare any charge items @@ -1293,7 +1293,7 @@ function drawInvoicePane(parentNode, inv, args) { mode : (inv) ? 'edit' : 'create', hideActionButtons : true, overrideWidgetArgs : override, - readOnly : (inv) && openils.Util.isTrue(inv.complete()), + readOnly : (inv) && inv.close_date(), requiredFields : [ 'inv_ident', 'recv_date', @@ -1308,7 +1308,7 @@ function drawInvoicePane(parentNode, inv, args) { 'provider', 'shipper' ], - suppressFields : ['id', 'complete'] + suppressFields : ['id', 'close_date', 'closed_by'] }); pane.startup(); -- 2.11.0