# Finance and Payments

The financial industry is an industry where an organization needs to know about any good or positive event related to customers' accounts as fast as possible. Therefore receiving such information is a real-time mode is vital for many departments from BI to risk, operations, or compliance. And that's what Ylem is good at.

## Schedule generation of commercial reports and send them to BI software or directly to stakeholders

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2FIge7vgLlAkcxzTNSrRPy%2FScreenshot%202022-10-02%20at%2000.10.03.png?alt=media&#x26;token=65b218f7-42c4-454c-bd0c-80df8a433d71" alt=""><figcaption><p>Possible pipeline</p></figcaption></figure>

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2FCoEHR6JGPyywxbtdF946%2FScreenshot%202022-10-02%20at%2000.10.25.png?alt=media&#x26;token=239addcb-fd3e-47e6-951c-50916bd83cdd" alt=""><figcaption><p>An SQL example how to retrieve financial data</p></figcaption></figure>

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2Fwrk1DHOT6K41RtUAP6CD%2FScreenshot%202022-10-02%20at%2000.11.07.png?alt=media&#x26;token=223f55ad-8673-43cc-9154-40d39995e050" alt=""><figcaption><p>Generated CSV report</p></figcaption></figure>

## Streaming monitoring information about failed payments

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2F5MzBGUXDBh0VV8lFRODB%2FScreenshot%202022-10-06%20at%2017.35.12.png?alt=media&#x26;token=c6a80cc0-6c85-457d-9c54-9e64929681b6" alt=""><figcaption><p>Possible pipeline</p></figcaption></figure>

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2Faw43TR1kuyxPGkW9gywm%2FScreenshot%202022-10-06%20at%2017.35.31.png?alt=media&#x26;token=8fce4cb5-df87-4d5d-9bf5-9625784cd09d" alt=""><figcaption><p>Possible data query</p></figcaption></figure>

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2FU5EVNOmWuXOYBXoUENzD%2FScreenshot%202022-10-06%20at%2017.36.10.png?alt=media&#x26;token=25097f7c-0b05-4348-874a-43cc74c34399" alt=""><figcaption><p>Slack notifications</p></figcaption></figure>

## Streaming monitoring information about overpaid orders

In case an organization accepts payments from customers with direct bank transfers, it opens a potential for mistakes made in the references or amount.

The following pipeline can help to control and find overpaid orders or invoices.

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2F2eyl9u9UuSx79bcqG5Z7%2FScreenshot%202022-10-07%20at%2017.38.00.png?alt=media&#x26;token=2381f105-3aeb-415a-a25a-20d26d6c0870" alt=""><figcaption><p>Potential pipeline</p></figcaption></figure>

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2FvvYpSdv12ecjEV3aTRat%2FScreenshot%202022-10-07%20at%2017.38.18.png?alt=media&#x26;token=1bc0df99-274f-46e0-9fc3-bc5be227ff35" alt=""><figcaption><p>Potential SQL query to retrieve data</p></figcaption></figure>

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2FlRx3hDg15e2Hmc3AVbK4%2FScreenshot%202022-10-07%20at%2017.38.43.png?alt=media&#x26;token=79358e17-10b5-4231-bbab-f623dad68c14" alt=""><figcaption><p>Potential message to send to stakeholders</p></figcaption></figure>

## Streaming monitoring information about unallocated bank transfers

Another popular modification of the previous two pipelines is to monitor unallocated bank transfers. This means bank transfers made by customers that the system was not able to allocate to any order, invoice, or any other purchased item.

In this case, it is up to you to decide what to do with this transfer. Either return it, try allocating it manually, or contact the customer and ask about it.

That's how the typical pipeline may look like:

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2FgUGgxsNmHEYWFkVy4Ixr%2FScreenshot%202022-10-09%20at%2023.13.52.png?alt=media&#x26;token=d231dfa4-59f8-4868-80a9-a15f93ea453c" alt=""><figcaption></figcaption></figure>

## Filtering data sets by various factors on the fly

Filtering data from large data sets is one of the most common and important tasks for payment operations. One of the powerful instruments Ylem offers for that is [Transformer](https://docs.ylem.co/pipelines/tasks-ip/transformers) with GJSON query language.

Let's imagine we have the following dataset and we need to filter it in various ways:

```json
[
   {
      "amount":250,
      "created_at":"2022-10-01 16:01:11",
      "currency":"USD",
      "id":1,
      "organization_id":1,
      "status":"dispatched",
      "updated_at":"2022-10-01 16:01:11"
   },
   {
      "amount":250,
      "created_at":"2022-10-01 16:01:11",
      "currency":"USD",
      "id":2,
      "organization_id":1,
      "status":"paid",
      "updated_at":"2022-10-01 16:01:11"
   },
   {
      "amount":3677.2,
      "created_at":"2022-10-01 16:01:11",
      "currency":"USD",
      "id":3,
      "organization_id":2,
      "status":"completed",
      "updated_at":"2022-10-01 16:01:11"
   },
   {
      "amount":21.87,
      "created_at":"2022-10-01 16:01:11",
      "currency":"EUR",
      "id":4,
      "organization_id":1,
      "status":"assembled",
      "updated_at":"2022-10-01 16:01:11"
   },
   {
      "amount":21.87,
      "created_at":"2022-10-01 16:01:11",
      "currency":"EUR",
      "id":5,
      "organization_id":4,
      "status":"assembled",
      "updated_at":"2022-10-01 16:01:11"
   },
   {
      "amount":341.76,
      "created_at":"2022-10-01 16:01:11",
      "currency":"EUR",
      "id":6,
      "organization_id":1,
      "status":"complete",
      "updated_at":"2022-10-01 16:01:11"
   },
   {
      "amount":2110.76,
      "created_at":"2022-10-01 16:01:11",
      "currency":"USD",
      "id":7,
      "organization_id":3,
      "status":"new",
      "updated_at":"2022-10-01 16:01:11"
   },
   {
      "amount":127.89,
      "created_at":"2022-10-01 16:01:11",
      "currency":"USD",
      "id":8,
      "organization_id":3,
      "status":"new",
      "updated_at":"2022-10-01 16:01:11"
   },
   {
      "amount":127.9,
      "created_at":"2022-10-01 16:01:11",
      "currency":"EUR",
      "id":9,
      "organization_id":4,
      "status":"new",
      "updated_at":"2022-10-01 16:01:11"
   },
   {
      "amount":344.44,
      "created_at":"2022-10-01 16:01:11",
      "currency":"USD",
      "id":10,
      "organization_id":5,
      "status":"paid",
      "updated_at":"2022-10-01 16:01:11"
   }
]
```

Let's look at the following 4 examples:

<figure><img src="https://3180830455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0FT8l3QzMrw546vOdHU%2Fuploads%2F2CysMVL26F0CMXTjl75h%2FScreenshot%202022-10-06%20at%2014.12.18.png?alt=media&#x26;token=6a627170-dcf3-4c35-a779-8b0142f3c496" alt=""><figcaption></figcaption></figure>

```json
Filter: 
#(status == "assembled")#

Result:
[
   {
      "amount":21.87,
      "created_at":"2022-10-01 16:01:11",
      "currency":"EUR",
      "id":4,
      "organization_id":1,
      "status":"assembled",
      "updated_at":"2022-10-01 16:01:11"
   },
   {
      "amount":21.87,
      "created_at":"2022-10-01 16:01:11",
      "currency":"EUR",
      "id":5,
      "organization_id":4,
      "status":"assembled",
      "updated_at":"2022-10-01 16:01:11"
   },
   {
      "amount":67.01,
      "created_at":"2022-10-01 16:01:11",
      "currency":"EUR",
      "id":12,
      "organization_id":2,
      "status":"assembled",
      "updated_at":"2022-10-01 16:01:11"
   }
]

Filter:
#(status == "assembled")#.amount

Result:
[
   21.87,
   21.87,
   67.01
]

Filter:
#(status == "assembled").amount

Result: 21.87

Filter: 
#(amount < 30)#

Result: 
[
   {
      "amount":21.87,
      "created_at":"2022-10-01 16:01:11",
      "currency":"EUR",
      "id":4,
      "organization_id":1,
      "status":"assembled",
      "updated_at":"2022-10-01 16:01:11"
   },
   {
      "amount":21.87,
      "created_at":"2022-10-01 16:01:11",
      "currency":"EUR",
      "id":5,
      "organization_id":4,
      "status":"assembled",
      "updated_at":"2022-10-01 16:01:11"
   }
]
```
