Bug 26340

Summary: When printing labels from a barcode range, keep zero padding
Product: Koha Reporter: Ivan Dziuba <ivan.dziuba>
Component: Label/patron card printingAssignee: Ivan Dziuba <ivan.dziuba>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: eric.begin, jonathan.druart, kyle, marjorie.barry-vila, philippe.blouin
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.11.00
Bug Depends on:    
Bug Blocks: 31220    
Attachments: Bug 26340: Printing labels without zero(s) in the start of labels
Bug 26340: Printing labels without zero(s) in the start of labels
Bug 26340: Printing labels without zero(s) in the start of labels
Bug 26340: Keep zero padding when printing barcodes from a range
Bug 26340: (QA follow-up) Rephrase hint on to and from values
Bug 26340: Keep zero padding when printing barcodes from a range
Bug 26340: When printing labels from a barcode range, keep zero padding
Bug 26340: When printing labels from a barcode range, keep zero padding
Bug 26340: When printing labels from a barcode range, keep zero padding
Bug 26340: (QA follow-up) Remove warns and set input fields hidden again
Bug 26340: Code simplification
Bug 26340: Code simplification

Description Ivan Dziuba 2020-09-01 14:20:58 UTC
TO TEST:

1. Go  Tools > Label creator

2. Click +New -> Barcode range

3. Print barcode range with zero(s) in the start (Ex. from 00011881 to 00012000 )

4. 
Select a template to be applied:: Code à barre 48467
Select a layout to be applied: Code à barres

5. Export

6. Open PDF

The prefix is not displayed. We should see 00011881 on the labels, but we see 11881, 11882, ... without zeros in the start of labels.

This patch fix it.
Comment 1 Ivan Dziuba 2020-09-01 14:31:40 UTC
Created attachment 109441 [details] [review]
Bug 26340: Printing labels without zero(s) in the start of labels
Comment 2 Ivan Dziuba 2020-09-01 14:36:22 UTC
Created attachment 109442 [details] [review]
Bug 26340: Printing labels without zero(s) in the start of labels

TO TEST:

1. Go  Tools > Label creator

2. Click +New -> Barcode range

3. Print barcode range with zero(s) in the start (Ex. from 00011881 to 00012000 )

4. 
Select a template to be applied:: Code à barre 48467
Select a layout to be applied: Code à barres

5. Export

6. Open PDF

The prefix is not displayed. We should see 00011881 on the labels, but we see 11881, 11882, ... without zeros in the start of labels.

This patch fix it.
Comment 3 David Nind 2020-10-03 08:19:02 UTC
Created attachment 111190 [details] [review]
Bug 26340: Printing labels without zero(s) in the start of labels

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 Katrin Fischer 2020-10-14 22:23:57 UTC
Hi Ivan,

I think this might be your first patch for Koha, so some hints about bugzilla and our tools:

1) Please make sure you set yourself as "Assignee" once you plan on submitting a patch to a bug.

2) When using git bz -e or git bz edit it might seem like you can edit the commit message, but while this will post here, it's not changing the patch file. In order to include the test plan and patch description in your patch, you will have to do so in the git commit step.

I will upload an updated patch and have already updated bugzilla :)
Comment 5 Katrin Fischer 2020-10-14 22:37:57 UTC
Created attachment 111653 [details] [review]
Bug 26340: Keep zero padding when printing barcodes from a range

When creating barcode labels from a range, the leading zeros of padded
barcodes will be removed. They should be kept instead.

TO TEST:
1. Go to Tools > Label creator
2. Click +New -> Barcode range
3. Print barcode range with zero(s) in the start (Ex. from 00011881 to 00012000 )
4.
Select a template to be applied:: Code à barre 48467
Select a layout to be applied: Code à barres
5. Export
6. Open PDF
The prefix is not displayed. We should see 00011881 on the labels, but we see 11881, 11882, ... without zeros in the start of labels.
7. Apply patch and retest - the zeros should be kept now.

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 Katrin Fischer 2020-10-14 22:38:04 UTC
Created attachment 111654 [details] [review]
Bug 26340: (QA follow-up) Rephrase hint on to and from values
Comment 7 Katrin Fischer 2020-10-14 22:41:32 UTC
Ok, I have a bit of bad news here too - with the patch set it's no longer possible to print unpadded barcodes as it requires the barcodes entered to be of the same length. Example: from 1 to 33 will no longer print. 

I am not sure what the best fix here would be - maybe check for the numbers to start with zero and only output the hint if they do?
Comment 8 Ivan Dziuba 2020-10-16 12:41:54 UTC
(In reply to Katrin Fischer from comment #7)
> Ok, I have a bit of bad news here too - with the patch set it's no longer
> possible to print unpadded barcodes as it requires the barcodes entered to
> be of the same length. Example: from 1 to 33 will no longer print. 
> 
> I am not sure what the best fix here would be - maybe check for the numbers
> to start with zero and only output the hint if they do?

Hi Katrin.
Yes, it's my first patch for Koha. I understood your recommendations about 'commit -e' and 'Assignee'. In relation to the same length from and to values. Example from = 0005 and to=10. What we must do? Printing 0005, 0006,...,0010 or 05, 06, ...,10.  Thanks!
Comment 9 Katrin Fischer 2020-10-16 12:44:15 UTC
I think these should be invalid:

001 to 33
22 to 0044

But these should work:

001 to 020
00001 to 00010
1 to 44
4 to 100

Make sense?

Either enter them zero padded or not... print according to what was entered.
Comment 10 Ivan Dziuba 2020-10-16 13:54:56 UTC
(In reply to Katrin Fischer from comment #9)
> I think these should be invalid:
> 
> 001 to 33
> 22 to 0044
> 
> But these should work:
> 
> 001 to 020
> 00001 to 00010
> 1 to 44
> 4 to 100
> 
> Make sense?
> 
> Either enter them zero padded or not... print according to what was entered.

Are you saying that the system should give an error if some field(input from or to) does not contain 0* in the start of number, then the other field must not have 0* in the start of number? Did I understand correctly?
Comment 11 Katrin Fischer 2020-10-20 01:53:07 UTC
> Are you saying that the system should give an error if some field(input from
> or to) does not contain 0* in the start of number, then the other field must
> not have 0* in the start of number? Did I understand correctly?

Hi Ivan, I think that could work. Basically what we want to do is support 2 use cases:
- Printing numbers without zero padding
- Printing numbers with zero padding

So the validation needs to work for both cases.
Comment 12 Ivan Dziuba 2021-05-28 19:59:29 UTC Comment hidden (obsolete)
Comment 13 Ivan Dziuba 2021-06-14 18:42:13 UTC
Created attachment 121923 [details] [review]
Bug 26340: When printing labels from a barcode range, keep zero padding

TEST PLAN:

1. Go  Tools > Label creator
2. Click +New -> Barcode range
3. Print barcode range with zero(s) in the start (Ex. from 00011881 to 00012000 )
4. Select a template to be applied:: Code à barre 48467
Select a layout to be applied: Code à barres
5. Export
6. Open PDF

The prefix is not displayed. We should see 00011881 on the labels, but we see 11881, 11882, ... without zeros in the start of labels.
This patch fix it.
Comment 14 Hakam Almotlak 2021-06-22 19:59:36 UTC
Created attachment 122305 [details] [review]
Bug 26340: When printing labels from a barcode range, keep zero padding

TEST PLAN:

1. Go  Tools > Label creator
2. Click +New -> Barcode range
3. Print barcode range with zero(s) in the start (Ex. from 00011881 to 00012000 )
4. Select a template to be applied:: Code à barre 48467
Select a layout to be applied: Code à barres
5. Export
6. Open PDF

The prefix is not displayed. We should see 00011881 on the labels, but we see 11881, 11882, ... without zeros in the start of labels.
This patch fix it.

Signed-off-by: hakam <hakam@inlibro.com>
Comment 15 Katrin Fischer 2021-07-03 20:23:54 UTC
Created attachment 122575 [details] [review]
Bug 26340: When printing labels from a barcode range, keep zero padding

TEST PLAN:

1. Go  Tools > Label creator
2. Click +New -> Barcode range
3. Print barcode range with zero(s) in the start (Ex. from 00011881 to 00012000 )
4. Select a template to be applied:: Code à barre 48467
Select a layout to be applied: Code à barres
5. Export
6. Open PDF

The prefix is not displayed. We should see 00011881 on the labels, but we see 11881, 11882, ... without zeros in the start of labels.
This patch fix it.

Signed-off-by: hakam <hakam@inlibro.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 16 Katrin Fischer 2021-07-03 20:23:59 UTC
Created attachment 122576 [details] [review]
Bug 26340: (QA follow-up) Remove warns and set input fields hidden again

Removes traces of debugging.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 17 Katrin Fischer 2021-07-03 20:28:26 UTC
Hi Ivan and Hakam,

it appears to be working now for both use cases - zero padded or not. So this is good :) I noticed some code changes made, I assume, when debugging. Please be careful about removing those from your patches before submitting!
Comment 18 Jonathan Druart 2021-07-12 12:55:09 UTC
Created attachment 122777 [details] [review]
Bug 26340: Code simplification

And rename $range with $barcode_length
Comment 19 Jonathan Druart 2021-07-12 13:17:27 UTC
Created attachment 122779 [details] [review]
Bug 26340: Code simplification

And rename $range with $barcode_length
Comment 20 Jonathan Druart 2021-07-12 13:48:35 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 21 Jonathan Druart 2021-07-12 13:50:36 UTC
Congratulations, Ivan, for your first patch pushed!
Comment 22 Kyle M Hall 2021-07-16 12:35:45 UTC
Enhancement not backported to 21.05