#K63187. Invoice Summary Report

    ID: 31698 Type: Default 1000ms 256MiB

Invoice Summary Report

Invoice Summary Report

You are given a JSON input representing one or more test cases. Each test case is an object that contains an array clients. Each client object has a client_id string and an array of invoices. Every invoice contains an array items. Each item is described by a description, a quantity (an integer) and a unit_price (a floating-point number).

Your task is to generate a summary for each invoice. For every invoice of each client, output a line in the following format:

client_id Invoice i: Total Quantity: Q, Total Amount Due: A

where i is the 1-indexed invoice number, Q is the sum of quantities of all items in that invoice, and A is the total amount due computed as \[ A = \sum_{j=1}^{n} (\text{quantity}_j \times \text{unit\_price}_j)\] with A formatted to 2 decimal places.

The input will be received from standard input (stdin) and the output should be printed to standard output (stdout), each summary on a new line.

inputFormat

The input is provided as a single JSON string read from stdin. It is a JSON array, where each element (test case) is an object with the following structure:

{
  "clients": [
    {
      "client_id": "",
      "invoices": [
        {
          "items": [
            {"description": "", "quantity": , "unit_price": },
            ...
          ]
        },
        ...
      ]
    },
    ...
  ]
}

outputFormat

For each invoice in each test case, output a single line in the following format:

 Invoice : Total Quantity: , Total Amount Due: 

The total_amount_due must be formatted to 2 decimal places. The output is printed to stdout with each invoice summary on a separate line.

## sample
[
  {
    "clients": [
      {
        "client_id": "Client01",
        "invoices": [
          {
            "items": [
              {"description": "ItemA", "quantity": 1, "unit_price": 10.0},
              {"description": "ItemB", "quantity": 2, "unit_price": 5.0}
            ]
          }
        ]
      }
    ]
  }
]
Client01 Invoice 1: Total Quantity: 3, Total Amount Due: 20.00