Bugzilla – Attachment 169442 Details for
Bug 31606
Enhance acquisitions to allow ordering on next year's budget when still in current year.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31606: Add option to ignore the incoming fund on newly staged files
Bug-31606-Add-option-to-ignore-the-incoming-fund-o.patch (text/plain), 11.51 KB, created by
Aleisha Amohia
on 2024-07-23 20:31:10 UTC
(
hide
)
Description:
Bug 31606: Add option to ignore the incoming fund on newly staged files
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2024-07-23 20:31:10 UTC
Size:
11.51 KB
patch
obsolete
>From 6d3097ecf874baa0051659c2b814f38e51b0ea2b Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Mon, 22 Jul 2024 05:13:52 +0000 >Subject: [PATCH] Bug 31606: Add option to ignore the incoming fund on newly > staged files > >This enhancement adds the option to ignore the fund specified in newly staged records when adding orders to a basket. > >To test: > >1) Configure the MarcFieldsToOrder syspref so that Koha knows to map a MARC field in the staged record to a budget. It may look something like this: > >budget_code: 942$e > >2) Make sure you have a MARC file where your configured MARC field contains a fund code that exists in your Koha. You could follow these steps: > a) Create an active budget > b) Attach a fund with code FUND > c) Edit a record > d) If using the mapping configured in MarcFieldsToOrder above, add FUND to the 942$e of your record > e) Download the record in MARCXML format > >3) Go to Acquisitions. Create a vendor and a basket if you don't already have them. > >4) Add an order to the basket > >5) Choose 'From a new file' > >6) Upload the MARCXML you just downloaded and stage for import > >7) In the 'job enqueued' box, notice there is a sceond button to 'Add staged files and ignore incoming fund'. Click the normal button to Add staged files to basket > >8) Open the record you just staged by clicking on it/the checkbox. Confirm the fund pre-selected is the FUND from your budget_code field i.e. 942$e. Go to the Default accounting details tab, there may or may not be a different fund selected there. > >9) Click Cancel, you'll be redirected back to the basket. > >10) Repeat steps 4-7, except this time, check the new second button to 'Add staged files and ignore incoming fund' > >11) Repeat step 8 and confirm there is no fund pre-selected, for both the staged record and under the Default accounting details tab. > >12) Click Cancel, you'll be redirected back to the basket. > >13) Repeat steps 4-7, except this time, click the 'View detail of the enqueued job' link > >14) Confirm both buttons are there to add staged files to basket, with or without incoming fund, and they work as expected. > >Sponsored-by: Friends of Round Rock Library >--- > acqui/addorderiso2709.pl | 70 +++++++++++++------ > .../background_jobs/stage_marc_for_import.inc | 1 + > .../prog/en/modules/acqui/addorderiso2709.tt | 2 +- > .../en/modules/tools/stage-marc-import.tt | 2 +- > 4 files changed, 52 insertions(+), 23 deletions(-) > >diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl >index e777e64c176..695d5eaff96 100755 >--- a/acqui/addorderiso2709.pl >+++ b/acqui/addorderiso2709.pl >@@ -63,11 +63,12 @@ my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({ > flagsrequired => { acquisition => 'order_manage' }, > }); > >-my $cgiparams = $input->Vars; >-my $op = $cgiparams->{'op'} || ''; >-my $booksellerid = $input->param('booksellerid'); >-my $allmatch = $input->param('allmatch'); >-my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid ); >+my $cgiparams = $input->Vars; >+my $op = $cgiparams->{'op'} || ''; >+my $booksellerid = $input->param('booksellerid'); >+my $allmatch = $input->param('allmatch'); >+my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid); >+my $clear_fund = $input->param('clear_fund'); > > $template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl", > booksellerid => $booksellerid, >@@ -104,7 +105,7 @@ if ($op eq ""){ > bookseller => $bookseller, > "allmatch" => $allmatch, > ); >- import_biblios_list($template, $cgiparams->{'import_batch_id'}); >+ import_biblios_list( $template, $cgiparams->{'import_batch_id'}, $clear_fund ); > if ( $basket->effective_create_items eq 'ordering' && !$basket->is_standing ) { > # prepare empty item form > my $cell = PrepareItemrecordDisplay( '', '', undef, 'ACQ' ); >@@ -393,11 +394,11 @@ if ($op eq ""){ > exit; > } > >-my $budgets = GetBudgets(); >-my $budget_id = @$budgets[0]->{'budget_id'}; >+my $budgets = GetBudgets(); >+my $budget_id = $clear_fund ? "" : @$budgets[0]->{'budget_id'}; >+ > # build bookfund list >-my $patron = Koha::Patrons->find( $loggedinuser )->unblessed; >-my $budget = GetBudget($budget_id); >+my $patron = Koha::Patrons->find($loggedinuser)->unblessed; > > # build budget list > my %budget_loops; >@@ -461,7 +462,7 @@ sub import_batches_list { > } > > sub import_biblios_list { >- my ($template, $import_batch_id) = @_; >+ my ( $template, $import_batch_id, $clear_fund ) = @_; > my $batch = GetImportBatch($import_batch_id,'staged'); > return () unless $batch and $batch->{import_status} =~ /^staged$|^reverted$/; > my $import_records = Koha::Import::Records->search({ >@@ -508,23 +509,50 @@ sub import_biblios_list { > ); > my $marcrecord = $import_record->get_marc_record || die "couldn't translate marc information"; > >- my $infos = get_infos_syspref('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2','replacementprice']); >- my $price = looks_like_number($infos->{price}) ? $infos->{price} : GetMarcPrice( $marcrecord, C4::Context->preference('marcflavour') ); >+ my $infos = get_infos_syspref( >+ 'MarcFieldsToOrder', $marcrecord, >+ [ 'price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2', 'replacementprice' ] >+ ); >+ my $price = >+ looks_like_number( $infos->{price} ) >+ ? $infos->{price} >+ : GetMarcPrice( $marcrecord, C4::Context->preference('marcflavour') ); > my $replacementprice = $infos->{replacementprice}; >- my $quantity = $infos->{quantity}; >- my $budget_code = $infos->{budget_code}; >- my $discount = $infos->{discount}; >- my $sort1 = $infos->{sort1}; >- my $sort2 = $infos->{sort2}; >- my $budget_id; >- >- if ($budget_code) { >+ my $quantity = $infos->{quantity}; >+ my $budget_code = $infos->{budget_code}; >+ my $discount = $infos->{discount}; >+ my $sort1 = $infos->{sort1}; >+ my $sort2 = $infos->{sort2}; >+ my $budget_id = ""; >+ >+ if ( $budget_code and not $clear_fund ) { > my $biblio_budget = GetBudgetByCode($budget_code); > if ($biblio_budget) { > $budget_id = $biblio_budget->{budget_id}; > } > } > >+ my %budget_loops; >+ my $budgets_hierarchy = GetBudgetHierarchy; >+ foreach my $r ( @{$budgets_hierarchy} ) { >+ unless ( defined $budget_loops{ $r->{budget_period_id} } ) { >+ $budget_loops{ $r->{budget_period_id} }->{description} = $r->{budget_period_description}; >+ $budget_loops{ $r->{budget_period_id} }->{active} = $r->{budget_period_active}; >+ $budget_loops{ $r->{budget_period_id} }->{funds} = []; >+ } >+ push @{ $budget_loops{ $r->{budget_period_id} }->{funds} }, { >+ b_id => $r->{budget_id}, >+ b_txt => $r->{budget_name}, >+ b_code => $r->{budget_code}, >+ b_sort1_authcat => $r->{'sort1_authcat'}, >+ b_sort2_authcat => $r->{'sort2_authcat'}, >+ b_active => $r->{budget_period_active}, >+ b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0, >+ b_level => $r->{budget_level}, >+ }; >+ } >+ $cellrecord{budget_loop} = \%budget_loops; >+ > # Items > my @itemlist = (); > my $all_items_quantity = 0; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/stage_marc_for_import.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/stage_marc_for_import.inc >index 1ecc6747d7b..e0b743bed00 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/stage_marc_for_import.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/stage_marc_for_import.inc >@@ -41,6 +41,7 @@ > [% IF report.basket_id && report.vendor_id %] > <p> > <a id="addtobasket" class="btn btn-default" href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=[% report.import_batch_id | html %]&basketno=[% report.basket_id | html %]&booksellerid=[% report.vendor_id | html %]">Add staged files to basket</a> >+ <a id="addtobasket_nofund" class="btn btn-default" href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=[% report.import_batch_id | html %]&basketno=[% report.basket_id | html %]&booksellerid=[% report.vendor_id | html %]&clear_fund=1">Add staged files to basket and ignore incoming fund</a> > </p> > [% END %] > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt >index 12abc2f71b9..b7f382d16e5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt >@@ -213,7 +213,7 @@ > <label for="fund_record_[% biblio.import_record_id | html %]">Fund: </label> > <select id="fund_record_[% biblio.import_record_id | html %]" name="budget_id_[% biblio.import_record_id | html %]"> > <option value="">Select a fund (will use default if set)</option> >- [% INCLUDE 'budgets_loop.inc' inactive_class = "b_inactive" %] >+ [% INCLUDE 'budgets_loop.inc' inactive_class = "b_inactive" budget_loop = biblio.budget_loop %] > </select> > <span class="required" style="display:none">Required</span> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt >index 072ce87ff8b..c62dde75af9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt >@@ -437,7 +437,7 @@ > let basket_id = job.data.report.basket_id; > let vendor_id = job.data.report.vendor_id; > if ( basket_id && vendor_id ) { >- $('<p><a id="addtobasket" class="btn btn-default" href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=%s&basketno=%s&booksellerid=%s">%s</a></p>'.format(import_batch_id, basket_id, vendor_id, _("Add staged files to basket"))).appendTo("#job_callback"); >+ $('<p><a id="addtobasket" class="btn btn-default" href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=%s&basketno=%s&booksellerid=%s">%s</a> <a id="addtobasket_nofund" class="btn btn-default" href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=%s&basketno=%s&booksellerid=%s&clear_fund=1">%s</a></p>'.format(import_batch_id, basket_id, vendor_id, _("Add staged files to basket"), import_batch_id, basket_id, vendor_id, _("Add staged files to basket and ignore incoming fund"))).appendTo("#job_callback"); > } > }); > } >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31606
:
140860
|
140958
|
141004
|
148574
|
167427
|
167505
|
167522
|
167908
|
168043
|
168044
|
169264
|
169265
|
169442
|
169521
|
169767
|
169768
|
169769