0

We are trying to build a JasperReport for an estimate via JSON. The header and lines (multiple) are fine. However, there is one more node in the JSON file which requires to be looped in the detail table. We are not able to achieve it using subdataset. Currently, we are using JSONQL to iterate the lines.

We are unable to loop the taxes node via subdataset.

Below is the sample JSON input:


    {
      "taxes": [
        {
          "tax_slab_name": "VAT Exempt",
          "tax_amount": "AED 20.00"
        },
        {
          "tax_slab_name": "VAT 0%",
          "tax_amount": "AED 30.00"
        },
        {
          "tax_slab_name": "VAT 5 %",
          "tax_amount": "AED 50.00"
        }
      ],
      "header": [
        {
          "estimate_no": "EST-000054",
          "bill_to_address": "111 Stamm Cliffs Suite 285, Heaney Ville, Jebel Ali, Dubai, United Arab Emirates (UAE)",
          "ship_to_address": "66015 شارع بلال السهلي, ممر ميسر مدني, Jebel Ali, Dubai, United Arab Emirates (UAE)",
          "estimate_date": "2020-05-08",
          "expiry_date": "2020-05-23",
          "sub_total": 14000,
          "discount": 0,
          "tax_amt": 450,
          "total": 14450,
          "conditions": "All charges are in United States Dollar (USD) unless otherwise stated. E. and O.E.",
          "status": "SAVED",
          "contact_name": "Kerluke, Bartell and Dickinson (مجموعة الداوود وأولاده)"
        }
      ],
      "lines": [
        {
          "item_name": "Enterprise Product Development - Java/JSF/PF",
          "tax_slab": 1,
          "uom": "box",
          "quantity": 1,
          "rate": 1000,
          "amount": 1000
        },
        {
          "item_name": "Server Setup",
          "tax_slab": 2,
          "uom": "cm",
          "quantity": 2,
          "rate": 2000,
          "amount": 4000
        },
        {
          "item_name": "Backup and DR Service",
          "tax_slab": 2,
          "uom": "cm",
          "quantity": 2,
          "rate": 2000,
          "amount": 4000
        }
      ]
    }

Datasource Type: JSONQL

JasperReport Version: 6.12.2 (latest)

Alex K
  • 22,315
  • 19
  • 108
  • 236
Sriram
  • 36
  • 3

1 Answers1

0

Never mind. Got it working with sub-data-set.

   <subDataset name="TaxSDS" uuid="1701ce05-88ab-4435-85c5-3ad38e0b941b">
        <queryString language="jsonql">
            <![CDATA[..taxes]]>
        </queryString>
        <field name="tax_slab_name" class="java.lang.String">
            <property name="net.sf.jasperreports.jsonql.field.expression" value="tax_slab_name"/>
            <fieldDescription><![CDATA[Tax Slabs]]></fieldDescription>
        </field>
        <field name="tax_slab_amt" class="java.lang.String">
            <property name="net.sf.jasperreports.jsonql.field.expression" value="tax_amount"/>
            <fieldDescription><![CDATA[Tax Amount]]></fieldDescription>
        </field>
    </subDataset>
    <subDataset name="LinesSDS" uuid="1701ce05-88ab-4435-85c5-3ad38e0b941b">
        <queryString language="jsonql">
            <![CDATA[..lines]]>
        </queryString>
        <field name="item_name" class="java.lang.String">
            <property name="net.sf.jasperreports.jsonql.field.expression" value="item_name"/>
            <fieldDescription><![CDATA[Item]]></fieldDescription>
        </field>
        <field name="uom" class="java.lang.String">
            <property name="net.sf.jasperreports.jsonql.field.expression" value="uom"/>
            <fieldDescription><![CDATA[UOM]]></fieldDescription>
        </field>
    </subDataset>
    <queryString language="jsonql">
        <![CDATA[]]>
    </queryString>
    <field name="invoiceNo" class="java.lang.String">
        <property name="net.sf.jasperreports.jsonql.field.expression" value="header.estimate_no"/>
        <fieldDescription><![CDATA[Estimate No]]></fieldDescription>
    </field>
Sriram
  • 36
  • 3