Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested loop not working as expected #240

Open
junwen-k opened this issue Aug 28, 2024 · 1 comment
Open

Nested loop not working as expected #240

junwen-k opened this issue Aug 28, 2024 · 1 comment

Comments

@junwen-k
Copy link

Greetings, thank you for this amazing library.

I am currently facing some issue defining nested loop (loop within loop), which I think is pretty common in reporting.

Template:

image

With the example view model:

{
  "transactionGroups": [
    {
      "title": "My Group",
      "transactions": [
        {
          "transactionNo": "Transaction No 1",
          "referenceNo": "Reference No 1",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 2",
          "referenceNo": "Reference No 2",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 3",
          "referenceNo": "Reference No 3",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 4",
          "referenceNo": "Reference No 4",
          "amount": 1000
        }
      ]
    },
    {
      "title": "My Second Group",
      "transactions": [
        {
          "transactionNo": "Transaction No 5",
          "referenceNo": "Reference No 5",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 6",
          "referenceNo": "Reference No 6",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 7",
          "referenceNo": "Reference No 7",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 8",
          "referenceNo": "Reference No 8",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 9",
          "referenceNo": "Reference No 9",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 10",
          "referenceNo": "Reference No 10",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 11",
          "referenceNo": "Reference No 11",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 12",
          "referenceNo": "Reference No 12",
          "amount": 1000
        }
      ]
    }
  ]
}

Output

image

Expected

image

I am just experimenting around and if this works, I would also need to add in the grand total which takes the SUM of all Subtotal cell etc. However I couldn't get this first step working, suspect there is something wrong with nested loop. (The second group loop begins with transaction 10 which is odd, seems like it is "continueing" from the first group iteration or something)

Thank you and hope to hear from you soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@junwen-k and others