Interrogation des écritures (API)
(Page créée avec « Cet exemple montre comment récupérer les écritures en utilisant l'API SData. ===Utilisation de la classe des écritures=== Dans cet exemple, nous interrogeons la clas... ») |
|||
Ligne 6 : | Ligne 6 : | ||
<pre> | <pre> | ||
− | http://localhost:8080/sdata/gentiers/tecriture?select=edate&where=(edate ge "2015-01-01") &count=1 | + | http://localhost:8080/sdata/gentiers/tecriture?select=edate&where=(edate ge "2015-01-01")&orderBy=eDate&count=1 |
{ | { | ||
"$baseUrl": "http://localhost:8080/sdata/cptmouvement/", | "$baseUrl": "http://localhost:8080/sdata/cptmouvement/", | ||
"$title": "TEcriture - -", | "$title": "TEcriture - -", | ||
− | "$updated": "2021-01-28T10: | + | "$updated": "2021-01-28T10:58:09.438Z", |
"$resources": [ | "$resources": [ | ||
{ | { | ||
− | "$url": "TEcriture(' | + | "$url": "TEcriture('1B28EFFFF1C300020133000000130E2F')", |
− | "$title": " | + | "$title": "18650 - Pièce:AN2012/01-000001", |
− | "$updated": " | + | "$updated": "2013-04-16T09:12:52.000Z", |
− | "$etag": " | + | "$etag": "1B28EFFFF1C300020133000000130E2F-000004640000306F", |
"$shareId": "1B28EFFFF1C30002000300000003000B", | "$shareId": "1B28EFFFF1C30002000300000003000B", | ||
"$shareInfo": "S1", | "$shareInfo": "S1", | ||
"$shareLevel": 2, | "$shareLevel": 2, | ||
− | "$key": " | + | "$key": "1B28EFFFF1C300020133000000130E2F", |
− | "stamp": " | + | "stamp": "000004640000306F", |
− | "eDate": " | + | "eDate": "2014-12-31T23:00:00.000Z" |
} | } | ||
], | ], | ||
− | "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tecriture?select=edate&where=(edate ge \"2015-01-01\") &count=1&startKey=' | + | "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tecriture?select=edate&where=(edate ge \"2015-01-01\") &orderBy=edate&count=1&startKey='1B28EFFFF1C300020133000000130E2F'&keyDirection=gt" |
} | } | ||
</pre> | </pre> | ||
Ligne 36 : | Ligne 36 : | ||
<pre> | <pre> | ||
− | http://localhost:8080/sdata/gentiers/tecriture?select=date as edate&where=(date ge "2015-01-01") &count=1 | + | http://localhost:8080/sdata/gentiers/tecriture?select=date as edate&where=(date ge "2015-01-01")&orderBy=date&count=1 |
{ | { | ||
"$baseUrl": "http://localhost:8080/sdata/cptmouvement/", | "$baseUrl": "http://localhost:8080/sdata/cptmouvement/", | ||
"$title": "TEcriture - -", | "$title": "TEcriture - -", | ||
− | "$updated": "2021-01- | + | "$updated": "2021-01-28T11:00:38.671Z", |
"$resources": [ | "$resources": [ | ||
{ | { | ||
− | "$url": "TEcriture(' | + | "$url": "TEcriture('1B28EFFFF1C300020133000000130E2F')", |
− | "$title": " | + | "$title": "1B28EFFFF1C300020133000000130E2F", |
− | "$updated": " | + | "$updated": "2013-04-16T09:12:52.000Z", |
− | "$etag": " | + | "$etag": "1B28EFFFF1C300020133000000130E2F-000004640000306F", |
"$shareId": "1B28EFFFF1C30002000300000003000B", | "$shareId": "1B28EFFFF1C30002000300000003000B", | ||
"$shareInfo": "S1", | "$shareInfo": "S1", | ||
"$shareLevel": 2, | "$shareLevel": 2, | ||
− | "$key": " | + | "$key": "1B28EFFFF1C300020133000000130E2F", |
− | "stamp": " | + | "stamp": "000004640000306F", |
− | "date": " | + | "date": "2014-12-31T23:00:00.000Z" |
} | } | ||
], | ], | ||
− | "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tecriture?select=date as edate&where=(date ge \"2015-01-01\") &count=1&startKey=' | + | "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tecriture?select=date as edate&where=(date ge \"2015-01-01\")&orderBy=date&count=1&startKey='1B28EFFFF1C300020133000000130E2F'&keyDirection=gt" |
} | } | ||
</pre> | </pre> | ||
Ligne 66 : | Ligne 66 : | ||
<pre> | <pre> | ||
− | http://localhost:8080/sdata/gentiers/tvueecriture?select=montant&where=(dateEcriture ge "2015-01-01") &count=1 | + | http://localhost:8080/sdata/gentiers/tvueecriture?select=dateEcriture,montant&where=(dateEcriture ge "2015-01-01") &orderBy=dateEcriture&count=1 |
{ | { | ||
"$baseUrl": "http://localhost:8080/sdata/cptmouvement/", | "$baseUrl": "http://localhost:8080/sdata/cptmouvement/", | ||
"$title": "TVueEcriture - -", | "$title": "TVueEcriture - -", | ||
− | "$updated": "2021-01-28T10: | + | "$updated": "2021-01-28T10:59:29.269Z", |
"$resources": [ | "$resources": [ | ||
{ | { | ||
− | "$url": "TVueEcriture(' | + | "$url": "TVueEcriture('1B28EFFFF1C300020133000000130E2F')", |
− | "$title": " | + | "$title": "1B28EFFFF1C300020133000000130E2F", |
− | "$updated": " | + | "$updated": "2013-04-16T09:12:52.000Z", |
− | "$etag": " | + | "$etag": "1B28EFFFF1C300020133000000130E2F-000004640000306F", |
"$shareId": "1B28EFFFF1C30002000300000003000B", | "$shareId": "1B28EFFFF1C30002000300000003000B", | ||
"$shareInfo": "S1", | "$shareInfo": "S1", | ||
"$shareLevel": 2, | "$shareLevel": 2, | ||
− | "$key": " | + | "$key": "1B28EFFFF1C300020133000000130E2F", |
− | "stamp": " | + | "stamp": "000004640000306F", |
+ | "dateEcriture": "2014-12-31T23:00:00.000Z", | ||
"montant": { | "montant": { | ||
− | "value": | + | "value": 360000, |
"CodeDevise": "EUR", | "CodeDevise": "EUR", | ||
− | "Date": " | + | "Date": "2014-12-31T23:00:00.000Z", |
"TCConv": "", | "TCConv": "", | ||
− | "TCValue": | + | "TCValue": 360000, |
"RPConv": "", | "RPConv": "", | ||
− | "RPValue": | + | "RPValue": 323676 |
} | } | ||
} | } | ||
], | ], | ||
− | "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tvueecriture?select=montant&where=(dateEcriture ge \"2015-01-01\") &count=1&startKey=' | + | "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tvueecriture?select=dateEcriture,montant&where=(dateEcriture ge \"2015-01-01\") &orderBy=dateEcriture&count=1&startKey='1B28EFFFF1C300020133000000130E2F'&keyDirection=gt" |
} | } | ||
</pre> | </pre> | ||
Ligne 108 : | Ligne 109 : | ||
"$baseUrl": "http://localhost:8080/sdata/cptmouvement/", | "$baseUrl": "http://localhost:8080/sdata/cptmouvement/", | ||
"$title": "TVueEcriture - -", | "$title": "TVueEcriture - -", | ||
− | "$updated": "2021-01- | + | "$updated": "2021-01-28T11:03:14.490Z", |
"$resources": [ | "$resources": [ | ||
{ | { | ||
− | "$url": "TVueEcriture(' | + | "$url": "TVueEcriture('FFFFFFFFFFFFEEEE0000627300000035')", |
− | "$title": " | + | "$title": "FFFFFFFFFFFFEEEE0000627300000035", |
"$updated": "1899-12-30T00:00:00.000Z", | "$updated": "1899-12-30T00:00:00.000Z", | ||
− | "$etag": " | + | "$etag": "FFFFFFFFFFFFEEEE0000627300000035-0000022C00000005", |
"$shareId": "1B28EFFFF1C30002000300000003000B", | "$shareId": "1B28EFFFF1C30002000300000003000B", | ||
"$shareInfo": "S1", | "$shareInfo": "S1", | ||
"$shareLevel": 2, | "$shareLevel": 2, | ||
− | "$key": " | + | "$key": "FFFFFFFFFFFFEEEE0000627300000035", |
− | "stamp": " | + | "stamp": "0000022C00000005", |
"montant": { | "montant": { | ||
"value": 800000000, | "value": 800000000, | ||
Ligne 131 : | Ligne 132 : | ||
}, | }, | ||
{ | { | ||
− | "$url": "TVueEcriture(' | + | "$url": "TVueEcriture('FFFFFFFFFFFFEEEE0000627300000038')", |
− | "$title": " | + | "$title": "FFFFFFFFFFFFEEEE0000627300000038", |
"$updated": "1899-12-30T00:00:00.000Z", | "$updated": "1899-12-30T00:00:00.000Z", | ||
− | "$etag": " | + | "$etag": "FFFFFFFFFFFFEEEE0000627300000038-0000022C00000005", |
"$shareId": "1B28EFFFF1C30002000300000003000B", | "$shareId": "1B28EFFFF1C30002000300000003000B", | ||
"$shareInfo": "S1", | "$shareInfo": "S1", | ||
"$shareLevel": 2, | "$shareLevel": 2, | ||
− | "$key": " | + | "$key": "FFFFFFFFFFFFEEEE0000627300000038", |
− | "stamp": " | + | "stamp": "0000022C00000005", |
"montant": { | "montant": { | ||
"value": 4000000, | "value": 4000000, | ||
Ligne 151 : | Ligne 152 : | ||
}, | }, | ||
{ | { | ||
− | "$url": "TVueEcriture(' | + | "$url": "TVueEcriture('FFFFFFFFFFFFEEEE000062730000003B')", |
− | "$title": " | + | "$title": "FFFFFFFFFFFFEEEE000062730000003B", |
"$updated": "1899-12-30T00:00:00.000Z", | "$updated": "1899-12-30T00:00:00.000Z", | ||
− | "$etag": " | + | "$etag": "FFFFFFFFFFFFEEEE000062730000003B-0000022C00000005", |
"$shareId": "1B28EFFFF1C30002000300000003000B", | "$shareId": "1B28EFFFF1C30002000300000003000B", | ||
"$shareInfo": "S1", | "$shareInfo": "S1", | ||
"$shareLevel": 2, | "$shareLevel": 2, | ||
− | "$key": " | + | "$key": "FFFFFFFFFFFFEEEE000062730000003B", |
− | "stamp": " | + | "stamp": "0000022C00000005", |
"montant": { | "montant": { | ||
"value": 3686300.24, | "value": 3686300.24, | ||
Ligne 171 : | Ligne 172 : | ||
}, | }, | ||
{ | { | ||
− | "$url": "TVueEcriture(' | + | "$url": "TVueEcriture('FFFFFFFFFFFFEEEE000062730000003E')", |
− | "$title": " | + | "$title": "FFFFFFFFFFFFEEEE000062730000003E", |
"$updated": "1899-12-30T00:00:00.000Z", | "$updated": "1899-12-30T00:00:00.000Z", | ||
− | "$etag": " | + | "$etag": "FFFFFFFFFFFFEEEE000062730000003E-0000022C00000005", |
"$shareId": "1B28EFFFF1C30002000300000003000B", | "$shareId": "1B28EFFFF1C30002000300000003000B", | ||
"$shareInfo": "S1", | "$shareInfo": "S1", | ||
"$shareLevel": 2, | "$shareLevel": 2, | ||
− | "$key": " | + | "$key": "FFFFFFFFFFFFEEEE000062730000003E", |
− | "stamp": " | + | "stamp": "0000022C00000005", |
"montant": { | "montant": { | ||
"value": 1455011361.6, | "value": 1455011361.6, | ||
Ligne 191 : | Ligne 192 : | ||
} | } | ||
], | ], | ||
− | "$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=' | + | "$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='FFFFFFFFFFFFEEEE000062730000003E'&keyDirection=gt" |
} | } | ||
</pre> | </pre> | ||
− | Notez que lorsqu'un opérateur de regroupement est réalisé sur un montant, celui est regroupé par devise. | + | Notez que lorsqu'un opérateur de regroupement est réalisé sur un montant, celui est regroupé par devise et la date du montant est la date du jour. |
[[Category:SData]] | [[Category:SData]] |
Version du 28 janvier 2021 à 12:05
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")&orderBy=eDate&count=1 { "$baseUrl": "http://localhost:8080/sdata/cptmouvement/", "$title": "TEcriture - -", "$updated": "2021-01-28T10:58:09.438Z", "$resources": [ { "$url": "TEcriture('1B28EFFFF1C300020133000000130E2F')", "$title": "18650 - Pièce:AN2012/01-000001", "$updated": "2013-04-16T09:12:52.000Z", "$etag": "1B28EFFFF1C300020133000000130E2F-000004640000306F", "$shareId": "1B28EFFFF1C30002000300000003000B", "$shareInfo": "S1", "$shareLevel": 2, "$key": "1B28EFFFF1C300020133000000130E2F", "stamp": "000004640000306F", "eDate": "2014-12-31T23:00:00.000Z" } ], "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tecriture?select=edate&where=(edate ge \"2015-01-01\") &orderBy=edate&count=1&startKey='1B28EFFFF1C300020133000000130E2F'&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")&orderBy=date&count=1 { "$baseUrl": "http://localhost:8080/sdata/cptmouvement/", "$title": "TEcriture - -", "$updated": "2021-01-28T11:00:38.671Z", "$resources": [ { "$url": "TEcriture('1B28EFFFF1C300020133000000130E2F')", "$title": "1B28EFFFF1C300020133000000130E2F", "$updated": "2013-04-16T09:12:52.000Z", "$etag": "1B28EFFFF1C300020133000000130E2F-000004640000306F", "$shareId": "1B28EFFFF1C30002000300000003000B", "$shareInfo": "S1", "$shareLevel": 2, "$key": "1B28EFFFF1C300020133000000130E2F", "stamp": "000004640000306F", "date": "2014-12-31T23:00:00.000Z" } ], "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tecriture?select=date as edate&where=(date ge \"2015-01-01\")&orderBy=date&count=1&startKey='1B28EFFFF1C300020133000000130E2F'&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=dateEcriture,montant&where=(dateEcriture ge "2015-01-01") &orderBy=dateEcriture&count=1 { "$baseUrl": "http://localhost:8080/sdata/cptmouvement/", "$title": "TVueEcriture - -", "$updated": "2021-01-28T10:59:29.269Z", "$resources": [ { "$url": "TVueEcriture('1B28EFFFF1C300020133000000130E2F')", "$title": "1B28EFFFF1C300020133000000130E2F", "$updated": "2013-04-16T09:12:52.000Z", "$etag": "1B28EFFFF1C300020133000000130E2F-000004640000306F", "$shareId": "1B28EFFFF1C30002000300000003000B", "$shareInfo": "S1", "$shareLevel": 2, "$key": "1B28EFFFF1C300020133000000130E2F", "stamp": "000004640000306F", "dateEcriture": "2014-12-31T23:00:00.000Z", "montant": { "value": 360000, "CodeDevise": "EUR", "Date": "2014-12-31T23:00:00.000Z", "TCConv": "", "TCValue": 360000, "RPConv": "", "RPValue": 323676 } } ], "$nextUrl": "http://localhost:8080/sdata/cptmouvement/tvueecriture?select=dateEcriture,montant&where=(dateEcriture ge \"2015-01-01\") &orderBy=dateEcriture&count=1&startKey='1B28EFFFF1C300020133000000130E2F'&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-28T11:03:14.490Z", "$resources": [ { "$url": "TVueEcriture('FFFFFFFFFFFFEEEE0000627300000035')", "$title": "FFFFFFFFFFFFEEEE0000627300000035", "$updated": "1899-12-30T00:00:00.000Z", "$etag": "FFFFFFFFFFFFEEEE0000627300000035-0000022C00000005", "$shareId": "1B28EFFFF1C30002000300000003000B", "$shareInfo": "S1", "$shareLevel": 2, "$key": "FFFFFFFFFFFFEEEE0000627300000035", "stamp": "0000022C00000005", "montant": { "value": 800000000, "CodeDevise": "PTE", "Date": "2021-01-27T23:00:00.000Z", "TCConv": "", "TCValue": 3990383.16, "RPConv": "", "RPValue": 3551441.04 } }, { "$url": "TVueEcriture('FFFFFFFFFFFFEEEE0000627300000038')", "$title": "FFFFFFFFFFFFEEEE0000627300000038", "$updated": "1899-12-30T00:00:00.000Z", "$etag": "FFFFFFFFFFFFEEEE0000627300000038-0000022C00000005", "$shareId": "1B28EFFFF1C30002000300000003000B", "$shareInfo": "S1", "$shareLevel": 2, "$key": "FFFFFFFFFFFFEEEE0000627300000038", "stamp": "0000022C00000005", "montant": { "value": 4000000, "CodeDevise": "GBP", "Date": "2021-01-27T23:00:00.000Z", "TCConv": "", "TCValue": 6939625.28, "RPConv": "", "RPValue": 4000000 } }, { "$url": "TVueEcriture('FFFFFFFFFFFFEEEE000062730000003B')", "$title": "FFFFFFFFFFFFEEEE000062730000003B", "$updated": "1899-12-30T00:00:00.000Z", "$etag": "FFFFFFFFFFFFEEEE000062730000003B-0000022C00000005", "$shareId": "1B28EFFFF1C30002000300000003000B", "$shareInfo": "S1", "$shareLevel": 2, "$key": "FFFFFFFFFFFFEEEE000062730000003B", "stamp": "0000022C00000005", "montant": { "value": 3686300.24, "CodeDevise": "USD", "Date": "2021-01-27T23:00:00.000Z", "TCConv": "", "TCValue": 4662106.56, "RPConv": "", "RPValue": 2929478.68 } }, { "$url": "TVueEcriture('FFFFFFFFFFFFEEEE000062730000003E')", "$title": "FFFFFFFFFFFFEEEE000062730000003E", "$updated": "1899-12-30T00:00:00.000Z", "$etag": "FFFFFFFFFFFFEEEE000062730000003E-0000022C00000005", "$shareId": "1B28EFFFF1C30002000300000003000B", "$shareInfo": "S1", "$shareLevel": 2, "$key": "FFFFFFFFFFFFEEEE000062730000003E", "stamp": "0000022C00000005", "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='FFFFFFFFFFFFEEEE000062730000003E'&keyDirection=gt" }
Notez que lorsqu'un opérateur de regroupement est réalisé sur un montant, celui est regroupé par devise et la date du montant est la date du jour.