Bugzilla – Attachment 78941 Details for
Bug 21262
Do not format numbers for editing if too big
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21262: Do not format numbers for editing if too big
Bug-21262-Do-not-format-numbers-for-editing-if-too.patch (text/plain), 2.96 KB, created by
Jonathan Druart
on 2018-09-16 17:04:21 UTC
(
hide
)
Description:
Bug 21262: Do not format numbers for editing if too big
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-09-16 17:04:21 UTC
Size:
2.96 KB
patch
obsolete
>From a6eae2275f660ab6c9f659ece279a58e398b1bd8 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 23 Aug 2018 14:44:31 +0000 >Subject: [PATCH] Bug 21262: Do not format numbers for editing if too big > >This patch copies the code from bug 15770 to the format_for_editing >sub. > >It also corrects schema issue, listing the purpose for two acq columns >instead of claing unused > >To test: >1 - Edit a fund >2 - Set warning at amount to: 100000000000000 >3 - Save budget >4 - Try to edit - internal server error >5 - Apply patch >6 - Should be able to edit budget >7 - Number should appear unformatted > >Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >2 quick notes: >1. Code must be moved to a subroutine if reused later >2. It would have prefered to have the comment of the 2 DB columns on a separate patch >(even separate bug report). As it's minor and that the patch will certainly backported >I will not block it. >--- > Koha/Number/Price.pm | 5 +++++ > installer/data/mysql/kohastructure.sql | 4 ++-- > 2 files changed, 7 insertions(+), 2 deletions(-) > >diff --git a/Koha/Number/Price.pm b/Koha/Number/Price.pm >index f549d8a243..64c9dfe585 100644 >--- a/Koha/Number/Price.pm >+++ b/Koha/Number/Price.pm >@@ -61,6 +61,11 @@ sub format_for_editing { > mon_decimal_point => '.', > }; > >+ # To avoid the system to crash, we will not format big number >+ # We divide per 100 because we want to keep the default DECIMAL_DIGITS (2) >+ # error - round() overflow. Try smaller precision or use Math::BigFloat >+ return $self->value if $self->value > Number::Format::MAX_INT/100; >+ > return Number::Format->new(%$format_params)->format_price($self->value); > } > >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 60d03ef8e9..d5368d4f0d 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2833,8 +2833,8 @@ CREATE TABLE `aqbudgets` ( -- information related to Funds > `budget_name` varchar(80) default NULL, -- name assigned to the fund by the user > `budget_branchcode` varchar(10) default NULL, -- branch that this fund belongs to (branches.branchcode) > `budget_amount` decimal(28,6) NULL default '0.00', -- total amount for this fund >- `budget_encumb` decimal(28,6) NULL default '0.00', -- not used in the code >- `budget_expend` decimal(28,6) NULL default '0.00', -- not used in the code >+ `budget_encumb` decimal(28,6) NULL default '0.00', -- budget warning at percentage >+ `budget_expend` decimal(28,6) NULL default '0.00', -- budget warning at amount > `budget_notes` LONGTEXT, -- notes related to this fund > `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this fund was last touched (created or modified) > `budget_period_id` int(11) default NULL, -- id of the budget that this fund belongs to (aqbudgetperiods.budget_period_id) >-- >2.11.0
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 21262
:
78098
|
78928
| 78941