Json array of arrays for Craftmypdf

Intro

Hello!
I am trying to set up a scenario that will allow me to create “Complex Invoices” in Craftmypdf. These invoices are grouped by delivery date or delivery number, which is the same.

One level array (previous version)

I had no problem doing it without this grouping, but now I can’t. I followed the craftmypdf documentation, but it’s for a single level of arrays. This is the suggested configuration for a single level (taking into account that it comes from an airtable trigger):

Scenerio view

In this setup what I do is fetch the data with a webhook and then use various “find” modules to fetch the rest of the information.
The one before the aggregator searches for all the detail lines for the invoice, as indicated in the documentation. Like I said, it works perfectly.

Two level array

Now what I need is to group by delivery number, but I can’t make a single JSON to send to craft my pdf.
I’ve tried different structures but none of them work, using the one I showed above for a single level array as a starting point.

Json structure

This is the required JSON structure (with sample data):

full json code

(go down to the “Important”)

{
    "numero-factura": "abc1234",
    "fecha emision": "2023-09-30",
    "Vencimiento": "2023-09-30",
     "punto_venta": [
        {
            "nombre": "Molecule Man",
            "calle_pv": "120st - 2221",
            "provincia_pv": "Mendoza",
            "ciudad_pv": "Capital",
            "CP_pv": "12345"
        }
    ],
    "cliente": [
        {
            "nombre": "Molecule Man",
            "calle-cli": "120st - 2221",
            "provincia-cli": "Mendoza",
            "ciudad-cli": "Capital",
            "CP-cli": "12345",
            "CIF": "b99"
        }
    ],
    "albaranes": [
    {
      "num_pedido": 8902,
      "pedido_cliente":"aa345",
      "fecha_entrega": "2023-08-30",
      "sub_total": 780,
      "item_lines": [
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        }
      ]
    },
    {
      "num_pedido": 8901,
      "pedido_cliente":"aa345",
      "fecha_entrega": "2023-08-30",
      "sub_total": 780,
      "item_lines": [
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        }
      ]
    },
    {
      "num_pedido": 8902,
      "pedido_cliente":"aa345",
      "fecha_entrega": "2023-08-30",
      "sub_total": 780,
      "item_lines": [
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        }
      ]
    },
    {
      "num_pedido": 8901,
      "pedido_cliente":"aa345",
      "fecha_entrega": "2023-08-30",
      "sub_total": 780,
      "item_lines": [
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        }
      ]
    },
    {
      "num_pedido": 8902,
      "pedido_cliente":"aa345",
      "fecha_entrega": "2023-08-30",
      "sub_total": 780,
      "item_lines": [
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        }
      ]
    },
    {
      "num_pedido": 8901,
      "pedido_cliente":"aa345",
      "fecha_entrega": "2023-08-30",
      "sub_total": 780,
      "item_lines": [
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        }
      ]
    },
    {
      "num_pedido": 8905,
      "pedido_cliente":"aa345",
      "fecha_entrega": "2023-08-30",
      "sub_total": 780,
      "item_lines": [
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        }
      ]
    }
  ],
    "subtotales": [
        {
            "suma-subtot": 209.9,
            "tipo iva": 10.00000000000005,
            "importe base": 109.8,
            "suma iva": 108.7,
            "total general": 29.4
        }
    ]
}

Important

This is the part that I can’t put together using the modules. I copy and paste it directly, without the previous keys and brackets.

"albaranes": [
    {
      "num_pedido": 8902,
      "pedido_cliente":"aa345",
      "fecha_entrega": "2023-08-30",
      "sub_total": 780,
      "item_lines": [
        {
          "ref": "AAP3",
          "producto": "producto 1",
          "unidades": 2,
          "precio": 15.2,
          "total": 33.2,
          "lote": "2023-09-30",
          "caducidad": "2023-09-30"
        },

Could you help me to put together the correct scenario?