> For the complete documentation index, see [llms.txt](https://docs.pagopa.it/centrostella-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pagopa.it/centrostella-1/centro-stella/instructions-for-agenzia-delle-entrate-mandate/appendixes/appendix-11-list-of-output-and-log-files.md).

# Appendix 11 - List of output and log files

### Input files

Once the input files are processed they are moved to a subdirectory named `success` (`ACQ_BATCH_SUCCESS_PATH`) or `error` (`ACQ_BATCH_ERROR_PATH`) by default, depending on the  processing result.

There are 2 scenarios where a file remains inside the input folder

* the naming convention is not complaint: the files are ignored and the batch service does not process them
* the sender code check (between the sender code in file name and the sender code in the file records)  fails: this may happen if the sender code is not set correctly or if every rows inside the file is discarded during the process.\
  In this scenario the file will remain in the input folder and has to be removed or fixed manually.

### AdE Output files

AdE output files are sent to Centro Stella APIs, a copy of the file may be saved locally according to the value of the variable `ACQ_BATCH_DELETE_OUTPUT_FILE` that defines the policy applied to the output files:

* with the value `ALWAYS` the files will be deleted at the end of the batch execution
* with the value `ERROR` the files will be deleted only if the batch ended with an error status
* with the value `KEEP` the files will be kept inside the `ACQ_BATCH_OUTPUT_PATH` folder

### Log files

The log files generated by the batch service, inside the folder `ACQ_BATCH_TRX_LOGS_PATH`, are:

<table><thead><tr><th width="273.97977008220425">Naming</th><th width="165.98322483583985">Description</th><th data-hidden></th><th data-hidden></th></tr></thead><tbody><tr><td>[timestamp]_<strong>Ade_FilteredRecords</strong>_[input_filename]</td><td>records discarded for parsing* errors in ade flow</td><td></td><td></td></tr><tr><td>[timestamp]_<strong>Rtd_ErrorRecords</strong>_[input_filename]</td><td>records discarded for validation* errors in RTD and ADE flows</td><td></td><td></td></tr><tr><td>application.log</td><td>application logs</td><td></td><td></td></tr></tbody></table>

*\* Please note the difference between the two steps: the parsing occur when the file is loaded and the rows are read, the validation step looks inside the fields and evaluates the content*

By default the batch service deletes the empty log files at the end of the batch.

### Pending files

When a file upload fails the batch service moves the file into the `pending` directory. By default the directory is located in `output/pending` but the position is customizable with the env var `ACQ_BATCH_PENDING_PATH`.

The files will be send with an automatic retry in the next runs of the batch service and will be deleted once the upload is completed. It is recommended to not remove these files or the folder manually.

### File Reports

The report contains the list of the files recently uploaded (last 15 days) with some related information in `json` format.

The fields in the report are:&#x20;

| Field            | Format                                  | Description                                        |
| ---------------- | --------------------------------------- | -------------------------------------------------- |
| fileName         | Alphanumeric                            | The output AdE file name sent (with pgp extension) |
| status           | Alphanumeric                            | Status of the file                                 |
| size             | Numeric                                 | Dimension of the pgp file in byte                  |
| transmissionDate | ISO Date (e.g. 2022-12-02T15:35:55.586) | Transmission date of the pgp file                  |
| dataSummary      | Object                                  | Summary about the file content                     |

The possible `status` values are:

<table><thead><tr><th width="355">Value</th><th>Description</th></tr></thead><tbody><tr><td>RECEIVED_BY_PAGOPA</td><td>The file has been sent and received by PagoPA</td></tr><tr><td>VALIDATED_BY_PAGOPA</td><td>The file is formally correct and validated</td></tr><tr><td>SENT_TO_AGENZIA_DELLE_ENTRATE</td><td>The file has been sent to AdE</td></tr></tbody></table>

The field `dataSummary` is composed by:

| Field                         | Format                     | Description                                                                    |
| ----------------------------- | -------------------------- | ------------------------------------------------------------------------------ |
| minAccountingDate             | ISO Date (e.g. 2022-12-02) | Value of the oldest `operation_date`                                           |
| maxAccountingDate             | ISO Date (e.g. 2022-12-02) | Value of the latest `operation_date`                                           |
| numberOfMerchants             | Numeric                    | Count distinct of the field `merchantId`                                       |
| countNegativeTransactions     | Numeric                    | Sum of all `transaction_number` of negative transactions (operation type 01)   |
| countPositiveTransactions     | Numeric                    | Sum of all `transaction_number` of positive transactions (operation type 00)   |
| sumAmountNegativeTransactions | Numeric                    | Sum of `amount` of the negative transactions in cents                          |
| sumAmountPositiveTransactions | Numeric                    | Sum of `amount` of the positive transactions  in cents                         |
| sha256OriginFile              | Alphanumeric               | sha256 of the input file with transactions with the format "#sha256sum:xxxxxx" |

An example of a report containing one file:

```json
{
    "filesRecentlyUploaded": [
        {
            "name": "ADE.12345.TRNLOG.20240510.150000.001.01.csv.pgp",
            "size": 104000,
            "status": "SENT_TO_AGENZIA_DELLE_ENTRATE",
            "transmissionDate": "2024-05-03T13:31:17.587",
            "dataSummary": {
                "minAccountingDate": "2024-04-30", 
                "maxAccountingDate": "2024-05-03",
                "numberOfMerchants": 8,
                "countNegativeTransactions": 7,
                "countPositiveTransactions": 27,
                "sumAmountNegativeTransactions": 1825110,
                "sumAmountPositiveTransactions": 4642246,
                "sha256OriginFile": "#sha256sum:xxxxxx"
            }
        }
    ]
}
```
