[Koha-bugs] [Bug 14680] when doing acquisitions from a staged file, MarcFieldsToOrder-syspref discounts are instead added.

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Jun 25 16:39:49 CEST 2019


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14680

--- Comment #5 from M. Tompsett <mtompset at hotmail.com> ---
Comment on attachment 41551
  --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=41551
Bug 14680 - when doing acquisitions from a staged file,
MarcFieldsToOrder-syspref discounts are instead added.

Review of attachment 41551:
 --> (https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=14680&attachment=41551)
-----------------------------------------------------------------

::: acqui/addorderiso2709.pl
@@ +178,5 @@
>          my $c_quantity = shift( @quantities ) || GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour') ) || 1;
>          my $c_budget_id = shift( @budgets_id ) || $input->param('all_budget_id') || $budget_id;
>          my $c_discount = shift ( @discount);
> +        if ($c_discount) {
> +            $c_discount =~ s/%//g; #This screws up number conversion badly

If there is a % sign, then we know it is a percent. Is it possible to have a
non-percent discount? If not, then this okay. If so, then this whole section of
code is messed up.

@@ +179,5 @@
>          my $c_budget_id = shift( @budgets_id ) || $input->param('all_budget_id') || $budget_id;
>          my $c_discount = shift ( @discount);
> +        if ($c_discount) {
> +            $c_discount =~ s/%//g; #This screws up number conversion badly
> +            $c_discount =~ s/,/./g; #Make this an actual digit for Perl

And what if they do something stupid like: 1,000,00?
What if they include 1000's? 1,000,000,000.00?
We need a nice function to guess at an unlocalized number.

@@ +180,5 @@
>          my $c_discount = shift ( @discount);
> +        if ($c_discount) {
> +            $c_discount =~ s/%//g; #This screws up number conversion badly
> +            $c_discount =~ s/,/./g; #Make this an actual digit for Perl
> +            $c_discount = $c_discount / 100 if $c_discount >= 1;

This seems like duplicate and wrong code.

@@ +186,1 @@
>          $c_discount = $c_discount / 100 if $c_discount > 1;

But as noted in the duplicate code above, I think the condition might need
correcting ">= 1" or perhaps "> 0"?

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list