codebude / QRCoder

A pure C# Open Source QR Code implementation
MIT License
4.59k stars 1.09k forks source link

Unit test error about Swiss bill qr code #96

Closed timoyan closed 6 years ago

timoyan commented 6 years ago

Hi codebude,

I found two unit test error and try to fixed it.

[Fact] [Category("PayloadGenerator/SwissQrCode")] public void swissqrcode_generator_should_generate_swisscode_full_alt()

[Fact] [Category("PayloadGenerator/SwissQrCode")] public void swissqrcode_generator_should_generate_swisscode_full

Error shows there are different amount value “100.25" and " 100,25" which is compared with expected result and actual result.

I notice you do some replacement in the source code. I try to find documents to verify the format which is one correct but not get answer.

Do you have any idea about it, thanks.

codebude commented 6 years ago

Hi @timoyan ,

at first - the expected output is: amount divided by point (.) as separator. (That's what is explained in the Swiss QR Code specification on page 20, first row, right column: https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-de.pdf )

The correlating line should be line 885 in PayloadGenerator.cs: https://github.com/codebude/QRCoder/blob/master/QRCoder/PayloadGenerator.cs#L885

If this line doesn't output the amount, with a point separator (I thought the format rule: $"{amount:0.00}"would do it), then it has to be fixed.

timoyan commented 6 years ago

Hi @codebude ,

Thanks for your detail explanation.

Best regards.

taqabubaker commented 5 years ago

Hi @codebude,

Actually till now the unit tests not yet fixed. I checked the Swiss QR Code specification page 15 https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf which says:

If the amount is included in the Swiss QR Code, then it must be printed after the currency code. A blank (space) should be used as the thousands separator and a full stop "." as the decimal separator. The amount must always include two decimal places.

so the decimal spectator should be dot '.' instead of comma ',' so the unit tests should be changed to be like

but still the logic $"{amount:0.00}" will not fulfill the SwissQR requirements since a blank (space) should be used as the thousands separator so 1234567.89 should be 1 234 567.89

If would like I can work on this.

Best regards,