Bug 468036 - Form: NaN in form total (UK IHT 411)
Summary: Form: NaN in form total (UK IHT 411)
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: PDF backend (show other bugs)
Version: 22.12.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-01 14:38 UTC by Dave Gilbert
Modified: 2023-04-09 09:40 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Original IHT411 form unfilled (56.90 KB, application/pdf)
2023-04-01 14:38 UTC, Dave Gilbert
Details
Verison of IHT411 with dummy £1 value filled in (126.37 KB, application/pdf)
2023-04-01 14:38 UTC, Dave Gilbert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Gilbert 2023-04-01 14:38:21 UTC
Created attachment 157768 [details]
Original IHT411 form unfilled

SUMMARY
The UK Gov form IHT411 (copy enclosed), has a pair of 'Totals' columns, while they correctly start out at £0.00, as soon as you enter any value they change into £NaN
The forms come from: https://www.gov.uk/government/publications/inheritance-tax-listed-stocks-and-shares-iht411


STEPS TO REPRODUCE
1. Load the original form, see the 'Total value of stock at date of death' is £0.00 on both pages
2. Enter 1 into amount of stock held, and £1.00 in Market price at death


OBSERVED RESULT
Both 'total value of stock' columns display NaN

EXPECTED RESULT
The actual total of those columns

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Dave Gilbert 2023-04-01 14:38:48 UTC
Created attachment 157769 [details]
Verison of IHT411 with dummy £1 value filled in
Comment 2 Dave Gilbert 2023-04-02 00:03:09 UTC
For anyone desperately looking to work around this, Chromium doesn't NaN
Comment 3 Dave Gilbert 2023-04-07 11:07:46 UTC
I'm seeing a few scripts that run, the two that produce NaN are:

------------------------------------------------------
//set values in boxes to variable\r\nvar tot = this.getField(\"Grand_Total_stock_1\");\r\nvar tot1 = Number(this.getField(\"Total_1\").valueAsString);\r\nvar tot2 = Number(this.getField(\"Total_2\").valueAsString);\r\nvar tot3 = Number(this.getField(\"Total_3\").valueAsString);\r\nvar tot4 = Number(this.getField(\"Total_4\").valueAsString);\r\nvar tot5 = Number(this.getField(\"Total_5\").valueAsString);\r\nvar tot6 = Number(this.getField(\"Total_6\").valueAsString);\r\nvar tot7 = Number(this.getField(\"Total_7\").valueAsString);\r\n\r\n//set an array of above variables\r\nvar arrTotal =[tot1, tot2, tot3, tot4, tot5, tot6, tot7];\r\n\r\n//loop through variables to add\r\nvar result = 0;\r\nfor (i=0; i < arrTotal.length; i++)\r\n    {\r\n        result += arrTotal[i]\r\n    };\r\n\r\n//place total of array loop in total box\r\ntot.value = result;\r\n\r\n//if(tot.value == 0){\r\n//tot.value = \"\";\r\n//};\r\n

//set values in boxes to variable
var tot = this.getField(\"Grand_Total_stock_1\");
var tot1 = Number(this.getField(\"Total_1\").valueAsString);
var tot2 = Number(this.getField(\"Total_2\").valueAsString);
var tot3 = Number(this.getField(\"Total_3\").valueAsString);
var tot4 = Number(this.getField(\"Total_4\").valueAsString);
var tot5 = Number(this.getField(\"Total_5\").valueAsString);
var tot6 = Number(this.getField(\"Total_6\").valueAsString);
var tot7 = Number(this.getField(\"Total_7\").valueAsString);

//set an array of above variables
var arrTotal =[tot1, tot2, tot3, tot4, tot5, tot6, tot7];
//loop through variables to add
var result = 0;
for (i=0; i < arrTotal.length; i++)
    {
        result += arrTotal[i]
    };
//place total of array loop in total box
tot.value = result;
//if(tot.value == 0){
//tot.value = \"\";
//};

------------------------------------------------------
//set values in boxes to variable\r\nvar totStk = this.getField(\"Grand_total_stock_2\");\r\nvar totStk1 = Number(this.getField(\"Total_stock_1\").valueAsString);\r\nvar totStk2 = Number(this.getField(\"Total_stock_2\").valueAsString);\r\nvar totStk3 = Number(this.getField(\"Total_stock_3\").valueAsString);\r\nvar totStk4 = Number(this.getField(\"Total_stock_4\").valueAsString);\r\nvar totStk5 = Number(this.getField(\"Total_stock_5\").valueAsString);\r\nvar totStk6 = Number(this.getField(\"Total_stock_6\").valueAsString);\r\nvar totStk7 = Number(this.getField(\"Total_stock_7\").valueAsString);\r\nvar totStk8 = Number(this.getField(\"Total_stock_8\").valueAsString);\r\nvar totStk9 = Number(this.getField(\"Total_stock_9\").valueAsString);\r\nvar totStk10 = Number(this.getField(\"Total_stock_10\").valueAsString);\r\nvar totStk11 = Number(this.getField(\"Total_stock_11\").valueAsString);\r\nvar totStk12 = Number(this.getField(\"Total_stock_12\").valueAsString);\r\nvar totStk13 = Number(this.getField(\"Total_stock_13\").valueAsString);\r\nvar totStk14 = Number(this.getField(\"Total_stock_14\").valueAsString);\r\n\r\n//set an array of above variables\r\nvar arrTotalStk =[totStk1, totStk2, totStk3, totStk4, totStk5, totStk6, totStk7, totStk8, totStk9, totStk10, totStk11, totStk12, totStk13, totStk14];\r\n\r\n//loop through variables to add\r\nvar resultStk = 0;\r\nfor (i=0; i < arrTotalStk.length; i++)\r\n    {\r\n        resultStk += arrTotalStk[i]\r\n    }\r\n\r\n//place total of array loop in total box\r\ntotStk.value = resultStk;\r\n\r\n//if(totStk.value == 0){\r\n//totStk.value = \"\";\r\n//};

//set values in boxes to variable
var totStk = this.getField(\"Grand_total_stock_2\");
var totStk1 = Number(this.getField(\"Total_stock_1\").valueAsString);
var totStk2 = Number(this.getField(\"Total_stock_2\").valueAsString);
var totStk3 = Number(this.getField(\"Total_stock_3\").valueAsString);
var totStk4 = Number(this.getField(\"Total_stock_4\").valueAsString);
var totStk5 = Number(this.getField(\"Total_stock_5\").valueAsString);
var totStk6 = Number(this.getField(\"Total_stock_6\").valueAsString);
var totStk7 = Number(this.getField(\"Total_stock_7\").valueAsString);
var totStk8 = Number(this.getField(\"Total_stock_8\").valueAsString);
var totStk9 = Number(this.getField(\"Total_stock_9\").valueAsString);
var totStk10 = Number(this.getField(\"Total_stock_10\").valueAsString);
var totStk11 = Number(this.getField(\"Total_stock_11\").valueAsString);
var totStk12 = Number(this.getField(\"Total_stock_12\").valueAsString);
var totStk13 = Number(this.getField(\"Total_stock_13\").valueAsString);
var totStk14 = Number(this.getField(\"Total_stock_14\").valueAsString);

//set an array of above variables
var arrTotalStk =[totStk1, totStk2, totStk3, totStk4, totStk5, totStk6, totStk7, totStk8, totStk9, totStk10, totStk11, totStk12, totStk13, totStk14];

//loop through variables to add
var resultStk = 0;
for (i=0; i < arrTotalStk.length; i++)
    {
        resultStk += arrTotalStk[i]
    }

//place total of array loop in total box
totStk.value = resultStk;

//if(totStk.value == 0){
//totStk.value = \"\";
//};
Comment 4 Dave Gilbert 2023-04-07 19:48:04 UTC
OK, fix incoming; it's just that we're missing a definition of valueAsString
Comment 5 Albert Astals Cid 2023-04-09 09:35:15 UTC
Git commit 24a9d097d7be00128d4d65903f5c013730be1c2c by Albert Astals Cid, on behalf of Dr. David Alan Gilbert.
Committed on 09/04/2023 at 09:21.
Pushed by aacid into branch 'master'.

JS: Implement field.valueAsString

Adobe's docs say:
  For example, for a field with a value of “020”, value returns the integer 20,
   while valueAsString returns the string “020”.

Share most of the fieldGetValue code by splitting it out into a 'Core'
variant and then using it in both GetValue and GetValueAsString.

M  +16   -4    core/script/kjs_field.cpp

https://invent.kde.org/graphics/okular/commit/24a9d097d7be00128d4d65903f5c013730be1c2c
Comment 6 Albert Astals Cid 2023-04-09 09:40:01 UTC
Git commit a747625c79dbebb3e0fbf6cc44143f4f26b82371 by Albert Astals Cid, on behalf of Dr. David Alan Gilbert.
Committed on 09/04/2023 at 09:38.
Pushed by aacid into branch 'release/23.04'.

JS: Implement field.valueAsString

Adobe's docs say:
  For example, for a field with a value of “020”, value returns the integer 20,
   while valueAsString returns the string “020”.

Share most of the fieldGetValue code by splitting it out into a 'Core'
variant and then using it in both GetValue and GetValueAsString.
(cherry picked from commit 24a9d097d7be00128d4d65903f5c013730be1c2c)

M  +16   -4    core/script/kjs_field.cpp

https://invent.kde.org/graphics/okular/commit/a747625c79dbebb3e0fbf6cc44143f4f26b82371