Bug 35044: Update: Invoices

Added fixme comment to invoices.tt, the search works so nothing to do
here, but the code is not DRY

Test plan, k-t-d:

Preparation: Create additional fields for table 'aqinvoices':
2 text fields, one repeatable, one not-repeatable
2 AV fields, one repeatable, one not-repeatable

1) Add a new invoice for an existing vendor, visit:
/cgi-bin/koha/acqui/parcels.pl?booksellerid=1
2) Input something in the mandatory "Vendor invoice" field.
3) Fill in all additional fields, click the '+New' and 'Clear' links,
   hit 'Save'
4) Search for invoices, visit:
http://localhost:8081/cgi-bin/koha/acqui/invoices.pl
5) Click "Search" on the left column of the page
6) Click the invoice we just created. Verify all the fields show
   correctly.
7) Go back to the additional fields configuration, set all additional
   fields as "searchable"
8) Return to http://localhost:8081/cgi-bin/koha/acqui/invoices.pl
9) Perform some searches using the additional fields values.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Pedro Amorim 2023-10-16 14:34:51 +00:00 committed by Katrin Fischer
parent 1c7c2a260c
commit e3787c157f
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
5 changed files with 14 additions and 11 deletions

View file

@ -131,11 +131,13 @@ elsif ( $op && $op eq 'cud-mod' ) {
my @additional_fields;
my $invoice_fields = Koha::AdditionalFields->search({ tablename => 'aqinvoices' });
while ( my $field = $invoice_fields->next ) {
my $value = $input->param('additional_field_' . $field->id);
push @additional_fields, {
id => $field->id,
value => $value,
};
my @field_values = $input->param( 'additional_field_' . $field->id );
foreach my $value (@field_values) {
push @additional_fields, {
id => $field->id,
value => $value,
} if $value;
}
}
Koha::Acquisition::Invoices->find($invoiceid)->set_additional_fields(\@additional_fields);
@ -320,9 +322,7 @@ if ( $adjustments ) { $template->param( adjustments => $adjustments ); }
my $invoice = Koha::Acquisition::Invoices->find($invoiceid);
$template->param(
available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqinvoices' } ),
additional_field_values => { map {
$_->field->id => $_->value
} $invoice->additional_field_values->as_list },
additional_field_values => $invoice->get_additional_field_values_for_template,
);
$template->param(

View file

@ -134,12 +134,12 @@ if ($op and $op eq 'cud-confirm') {
my @additional_fields;
my $invoice_fields = Koha::AdditionalFields->search({ tablename => 'aqinvoices' });
while ( my $field = $invoice_fields->next ) {
my $value = $input->param('additional_field_' . $field->id);
if (defined $value) {
my @field_values = $input->param( 'additional_field_' . $field->id );
foreach my $value (@field_values) {
push @additional_fields, {
id => $field->id,
value => $value,
};
} if $value;
}
}
if (@additional_fields) {

View file

@ -544,6 +544,7 @@
[% Asset.js("js/form-submit.js") | $raw %]
[% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
[% Asset.js("js/acq.js") | $raw %]
[% Asset.js("js/additional-fields-entry.js") | $raw %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
<script>

View file

@ -385,6 +385,7 @@
[% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
</select>
</li>
[%# FIXME additional-fields.entry.inc should/could be considered here %]
[% FOR field IN additional_fields_for_invoice %]
<li>
<label for="additional_field_[% field.id | html %]ID"> [% field.name | html %]: </label>

View file

@ -244,6 +244,7 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/acquisitions-menu.js") | $raw %]
[% Asset.js("js/additional-fields-entry.js") | $raw %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
<script>