We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Swiss-QR-Code without amount

Hello

We are using Aspose.BarCode 19.11.0.0 and are starting to use the Swiss-QR-Code classes. The basics functionality works very well for our purpose. But now we ran into a problem. In Switzerland there is an invoice variant where there is a reference number but no fixed amount. This is a sample of such a case:

ESR-plus.png (98.3 KB)

The amount will be manually entered and the Amount-Property is left empty (or null) and not 0.00 but the Amount-Property on the Bill class is not nullable and the default value is 0.00 which then generates a QR-Code with the amount=0.00. All the other properties are set as with any other SwissQRCodetext object.

Is there a way to accomplished that?

Thank you very much.

@tommoor,
We have understood your requirement and have logged an investigation ticket in our database. You will be notified here once any update is ready for sharing.

This issue is logged as:
BARCODENET-37818 - Swiss QR code having nullable amount property

@tommoor,
Can you provide code that demonstrates an issue? I don’t see an issue here. It should work correctly with Amount set to 0. Zero is not a valid value for an Amount field (valid values are between 0.01 and 999,999,999.99) so it’s encoded as an empty line, not as 0. So it doesn’t affect generated QR code. It just how Amount is represented in the Bill class.

    [Test]
    public void Test_SwissQR_With_Amount_Zero()
    {
        // Read initial bill
        var r = new BarCodeReader("ESR-plus.png", DecodeType.QR);
        var res = r.ReadBarCodes();

        // Create copy bill with Amount set to 0
        var swissQRCodetext = new SwissQRCodetext();
        swissQRCodetext.InitFromString(res[0].CodeText);
        swissQRCodetext.Bill.Amount = 0; // even if we explicitly set Amount to 0
        var gen = new ComplexBarcodeGenerator(swissQRCodetext);
        var r2 = new BarCodeReader(gen.GenerateBarCodeImage(), DecodeType.QR);
        var res2 = r2.ReadBarCodes();

        // Compare actual QR codes data
        Assert.AreEqual(res[0].CodeText, res2[0].CodeText);
    }

Sorry, I didn’t see your answer until today, thank you for your response! This is the code we are using (it’s from a sample) and it will encode 0.00 as the amount in the QR and not a empty line…:

	private void TestQR()
	{
		// Instantiate barcode object and set CodeText
		var swissQRCodetext = new SwissQRCodetext();

		swissQRCodetext.Bill.Version = SwissQRBill.QrBillStandardVersion.V2_0;

		swissQRCodetext.Bill.Account = "CH4431999123000889012";

		swissQRCodetext.Bill.Creditor = new Aspose.BarCode.ComplexBarcode.Address();
		swissQRCodetext.Bill.Creditor.Name = "Robert Schneider AG";
		swissQRCodetext.Bill.Creditor.Street = "Rue du Lac";
		swissQRCodetext.Bill.Creditor.HouseNo = "1269";
		swissQRCodetext.Bill.Creditor.PostalCode = "2501";
		swissQRCodetext.Bill.Creditor.Town = "Biel";
		swissQRCodetext.Bill.Creditor.CountryCode = "CH";

		swissQRCodetext.Bill.Amount = 0;
		swissQRCodetext.Bill.Currency = "CHF";

		swissQRCodetext.Bill.Debtor = new Aspose.BarCode.ComplexBarcode.Address();
		swissQRCodetext.Bill.Debtor.Name = "Pia-Maria Rutschmann-Schnyder";
		swissQRCodetext.Bill.Debtor.Street = "Grosse Marktgasse";
		swissQRCodetext.Bill.Debtor.HouseNo = "28";
		swissQRCodetext.Bill.Debtor.PostalCode = "9400";
		swissQRCodetext.Bill.Debtor.Town = "Rohrschach";
		swissQRCodetext.Bill.Debtor.CountryCode = "CH";

		swissQRCodetext.Bill.Reference = "210000000003139471430009017";
		swissQRCodetext.Bill.UnstructuredMessage = "Auftrag vom 18.06.2020";

		//swissQRCodetext.Bill.BillInformation = "BillInformation";

		var generator = new ComplexBarcodeGenerator(swissQRCodetext);

		// Save the Barcode image in JPEG format
		generator.Save(@"C:\TEMP\save\swissQRCodetext_out.png", BarCodeImageFormat.Png);
	}

@tommoor,
We will analyze this code and share our feedback soon.

@tommoor,
Amount is only displayed as 0.0 in SwissQRCodetext. You can check that actual encoded codetext does have an empty line at the place were amount should be:

    var reader = new BarCodeReader(@"C:\TEMP\save\swissQRCodetext_out.png");

    // Plain text contains an empty line instead of amount 0.0
    var plainText = reader.ReadBarCodes()[0].CodeText;

    // SwissQRCodetext displays empty amount as 0.0
    var swissQrText = new SwissQRCodetext();
    swissQrText.InitFromString(plainText);