Interrogation des écritures (API)

De Wiki1000
Version du 28 janvier 2021 à 11:57 par Syfre (discuter | contributions)
(diff) ← Version précédente | Voir la version courante (diff) | Version suivante → (diff)

Cet exemple montre comment récupérer les écritures en utilisant l'API SData.

Sommaire

Utilisation de la classe des écritures

Dans cet exemple, nous interrogeons la classe des écritures.

http://localhost:8080/sdata/gentiers/tecriture?select=edate&where=(edate ge "2015-01-01") &count=1
{
    "$baseUrl": "http://localhost:8080/sdata/cptmouvement/",
    "$title": "TEcriture - -",
    "$updated": "2021-01-28T10:51:56.959Z",
    "$resources": [
        {
            "$url": "TEcriture('1B28EFFFF1C3000201330000000B0151')",
            "$title": "5027 - Pièce:AC2020/02-000002",
            "$updated": "2020-11-13T12:42:27.000Z",
            "$etag": "1B28EFFFF1C3000201330000000B0151-0000017400000277",
            "$shareId": "1B28EFFFF1C30002000300000003000B",
            "$shareInfo": "S1",
            "$shareLevel": 2,
            "$key": "1B28EFFFF1C3000201330000000B0151",
            "stamp": "0000017400000277",
            "eDate": "2020-02-25T23:00:00.000Z"
        }
    ],
    "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tecriture?select=edate&where=(edate ge \"2015-01-01\") &count=1&startKey='1B28EFFFF1C3000201330000000B0151'&keyDirection=gt"
}

Utilisation d'une vue sur les écritures

Dans cet exemple, nous interrogeons la classe des écritures en définissant un alias sur l'attribut retourné.

Le fait d'utiliser un alias provoque l'utilisation d'une vue.

http://localhost:8080/sdata/gentiers/tecriture?select=date as edate&where=(date ge "2015-01-01") &count=1
{
    "$baseUrl": "http://localhost:8080/sdata/cptmouvement/",
    "$title": "TEcriture - -",
    "$updated": "2021-01-28T10:48:56.583Z",
    "$resources": [
        {
            "$url": "TEcriture('1B28EFFFF1C3000201330000000B0151')",
            "$title": "1B28EFFFF1C3000201330000000B0151",
            "$updated": "2020-11-13T12:42:27.000Z",
            "$etag": "1B28EFFFF1C3000201330000000B0151-0000017400000277",
            "$shareId": "1B28EFFFF1C30002000300000003000B",
            "$shareInfo": "S1",
            "$shareLevel": 2,
            "$key": "1B28EFFFF1C3000201330000000B0151",
            "stamp": "0000017400000277",
            "date": "2020-02-25T23:00:00.000Z"
        }
    ],
    "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tecriture?select=date as edate&where=(date ge \"2015-01-01\") &count=1&startKey='1B28EFFFF1C3000201330000000B0151'&keyDirection=gt"
}

Notez la définition du filtre utilisant l'alias de l'attribut dans la requête.

Utilisation d'une vue standard sur les écritures

Dans cet exemple, nous interrogeons une vue standard des écritures :

http://localhost:8080/sdata/gentiers/tvueecriture?select=montant&where=(dateEcriture ge "2015-01-01") &count=1
{
    "$baseUrl": "http://localhost:8080/sdata/cptmouvement/",
    "$title": "TVueEcriture - -",
    "$updated": "2021-01-28T10:46:14.827Z",
    "$resources": [
        {
            "$url": "TVueEcriture('1B28EFFFF1C3000201330000000B0151')",
            "$title": "1B28EFFFF1C3000201330000000B0151",
            "$updated": "2020-11-13T12:42:27.000Z",
            "$etag": "1B28EFFFF1C3000201330000000B0151-0000017400000277",
            "$shareId": "1B28EFFFF1C30002000300000003000B",
            "$shareInfo": "S1",
            "$shareLevel": 2,
            "$key": "1B28EFFFF1C3000201330000000B0151",
            "stamp": "0000017400000277",
            "montant": {
                "value": 1968,
                "CodeDevise": "EUR",
                "Date": "2020-02-25T23:00:00.000Z",
                "TCConv": "",
                "TCValue": 1968,
                "RPConv": "",
                "RPValue": 1768.25
            }
        }
    ],
    "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tvueecriture?select=montant&where=(dateEcriture ge \"2015-01-01\") &count=1&startKey='1B28EFFFF1C3000201330000000B0151'&keyDirection=gt"
}

Interrogation de cumul d'écritures

Dans cet exemple, nous interrogeons une vue standard des écritures en utilisant un opérateur "somme" sur l'attribut montant et en filtrant sur une tranche de date.

L'utilisation d'un opérateur provoque l'utilisation d'une vue sur la vue standard.

http://localhost:8080/sdata/gentiers/tvueecriture?select=sum(montant)&where=(dateEcriture ge "2015-01-01") and (dateEcriture le "2015-12-31")&count=4
{
    "$baseUrl": "http://localhost:8080/sdata/cptmouvement/",
    "$title": "TVueEcriture - -",
    "$updated": "2021-01-28T10:37:33.846Z",
    "$resources": [
        {
            "$url": "TVueEcriture('FFFFFFFFFFFFEEEE0000627300000029')",
            "$title": "FFFFFFFFFFFFEEEE0000627300000029",
            "$updated": "1899-12-30T00:00:00.000Z",
            "$etag": "FFFFFFFFFFFFEEEE0000627300000029-0000022C00000004",
            "$shareId": "1B28EFFFF1C30002000300000003000B",
            "$shareInfo": "S1",
            "$shareLevel": 2,
            "$key": "FFFFFFFFFFFFEEEE0000627300000029",
            "stamp": "0000022C00000004",
            "montant": {
                "value": 800000000,
                "CodeDevise": "PTE",
                "Date": "2021-01-27T23:00:00.000Z",
                "TCConv": "",
                "TCValue": 3990383.16,
                "RPConv": "",
                "RPValue": 3551441.04
            }
        },
        {
            "$url": "TVueEcriture('FFFFFFFFFFFFEEEE000062730000002C')",
            "$title": "FFFFFFFFFFFFEEEE000062730000002C",
            "$updated": "1899-12-30T00:00:00.000Z",
            "$etag": "FFFFFFFFFFFFEEEE000062730000002C-0000022C00000004",
            "$shareId": "1B28EFFFF1C30002000300000003000B",
            "$shareInfo": "S1",
            "$shareLevel": 2,
            "$key": "FFFFFFFFFFFFEEEE000062730000002C",
            "stamp": "0000022C00000004",
            "montant": {
                "value": 4000000,
                "CodeDevise": "GBP",
                "Date": "2021-01-27T23:00:00.000Z",
                "TCConv": "",
                "TCValue": 6939625.28,
                "RPConv": "",
                "RPValue": 4000000
            }
        },
        {
            "$url": "TVueEcriture('FFFFFFFFFFFFEEEE000062730000002F')",
            "$title": "FFFFFFFFFFFFEEEE000062730000002F",
            "$updated": "1899-12-30T00:00:00.000Z",
            "$etag": "FFFFFFFFFFFFEEEE000062730000002F-0000022C00000004",
            "$shareId": "1B28EFFFF1C30002000300000003000B",
            "$shareInfo": "S1",
            "$shareLevel": 2,
            "$key": "FFFFFFFFFFFFEEEE000062730000002F",
            "stamp": "0000022C00000004",
            "montant": {
                "value": 3686300.24,
                "CodeDevise": "USD",
                "Date": "2021-01-27T23:00:00.000Z",
                "TCConv": "",
                "TCValue": 4662106.56,
                "RPConv": "",
                "RPValue": 2929478.68
            }
        },
        {
            "$url": "TVueEcriture('FFFFFFFFFFFFEEEE0000627300000032')",
            "$title": "FFFFFFFFFFFFEEEE0000627300000032",
            "$updated": "1899-12-30T00:00:00.000Z",
            "$etag": "FFFFFFFFFFFFEEEE0000627300000032-0000022C00000004",
            "$shareId": "1B28EFFFF1C30002000300000003000B",
            "$shareInfo": "S1",
            "$shareLevel": 2,
            "$key": "FFFFFFFFFFFFEEEE0000627300000032",
            "stamp": "0000022C00000004",
            "montant": {
                "value": 1455011361.6,
                "CodeDevise": "EUR",
                "Date": "2021-01-27T23:00:00.000Z",
                "TCConv": "",
                "TCValue": 1455011361.6,
                "RPConv": "",
                "RPValue": 1303787971.66
            }
        }
    ],
    "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tvueecriture?select=sum(montant)&where=(dateEcriture ge \"2015-01-01\") and (dateEcriture le \"2015-12-31\")&count=4&startKey='FFFFFFFFFFFFEEEE0000627300000032'&keyDirection=gt"
}

Notez que lorsqu'un opérateur de regroupement est réalisé sur un montant, celui est regroupé par devise.

Outils personnels