Interrogation des fournisseurs (API)
Cet exemple montre comment récupérer les fournisseurs avec l'API SData.
L'objectif est de récupérer une liste des fournisseurs comportant :
- Le code fournisseur
- Le libellé du fournisseur
- Le code tiers correspondant
- L'adresse principale du fournisseur
- l'IBAN principal du fournisseur
Les ressources SData correspondent aux classes persistantes du modèle de donnée.
Voici le modèle représentant les fournisseurs dans Sage FRP 1000 :
TODO
Plusieurs solutions sont possibles :
- Récupérer les ressources TRoleTiers et filtrer sur la classe de la ressource
- Récupérer les ressources TFournisseur
- Récupérer les ressources de la vue TvueListeFournisseur
- Récupérer les ressources TFournisseur en incluant des informations liées par le tiers, son site et son compte bancaire privilégié
Les deux premières solutions obligeraient a effectuer un ensemble d'interrogation car les informations liées ne sont pas directement retournées par les ressources de base, de toutes les solutions cela serait les moins performantes.
La solution basée sur la vue serait idéale, malheureusement la vue standard ne fourni pas toutes les informations nécessaires.
La meilleur solution reste l'interrogation de TFournisseur en incluant des informations liées, ce qui revient à utiliser une vue temporaire.
La ressoource TFournisseur retourne :
http://localhost:8080/sdata/gentiers/tfournisseur?count=1 { "$baseUrl": "http://localhost:8080/sdata/gentiers/", "$title": "TFournisseur - -", "$updated": "2021-01-27T16:38:42.307Z", "$resources": [ { "$url": "TFournisseur('1B28EFFFF1C3000201030000000903C1')", "$title": "F-DUCREDIT", "$updated": "2009-12-23T15:03:15.000Z", "$etag": "1B28EFFFF1C3000201030000000903C1-0000023A000004A0", "$shareId": "1B28EFFFF1C300020002000000420002", "$shareInfo": "Dossier", "$shareLevel": 0, "$key": "1B28EFFFF1C3000201030000000903C1", "stamp": "0000023A000004A0", "assujetiTaxe": false, "Caption": "F-DUCREDIT", "CategorieComptaTiers": { "$key": "1B28EFFFF1C300020041000000380037", "$url": "TCategorieComptaTiers('1B28EFFFF1C300020041000000380037')" }, "commentaire": "", "cumulQte": false, "dateCreation": "2012-12-22T23:00:00.000Z", "dateFacturation": { "value": 0, "title": "Date du traitement" }, "decouvertLimite": { "value": 0, "CodeDevise": "EUR" }, "devise": { "$key": "1B28EFFFF1C300020005000000700005", "$url": "TdbfCurrency('1B28EFFFF1C300020005000000700005')" }, "disabled": false, "enActivite": true, "escompte": { "value": 0, "Decimales": 4 }, "estRoleTiersSociete": false, "montantFrancoDePort": { "value": 999999999, "CodeDevise": "EUR" }, "natureTiers": { "value": 0, "title": "Client" }, "pourcentageAcompte": { "value": 0, "Decimales": 4 }, "regroupFacture": { "value": 0, "title": "1 facture par commande" }, "RoleTiersPayeur": { "$key": "1B28EFFFF1C3000201030000000903C1", "$url": "TRoleTiers('1B28EFFFF1C3000201030000000903C1')" }, "sensible": false, "siteFacturation": { "$key": "1B28EFFFF1C3000200F80000000903BA", "$url": "TSite('1B28EFFFF1C3000200F80000000903BA')" }, "siteLivraisonPrivilegie": { "$key": "1B28EFFFF1C3000200FC00000067006F", "$url": "TSiteCommerciale('1B28EFFFF1C3000200FC00000067006F')" }, "sitePrivilegie": { "$key": "1B28EFFFF1C3000200F80000000903BA", "$url": "TSite('1B28EFFFF1C3000200F80000000903BA')" }, "Tiers": { "$key": "1B28EFFFF1C3000200F60000000903B6", "$url": "TTiers('1B28EFFFF1C3000200F60000000903B6')" }, "typeFacturation": { "value": 0, "title": "HT" }, "CategorieCollectif": { "$key": "1B28EFFFF1C3000202010000000903C6", "$url": "TCategorieCollectif('1B28EFFFF1C3000202010000000903C6')" }, "comptePrivilegie": { "$key": "1B28EFFFF1C30002001E0000007F05FB", "$url": "TCompteGeneral('1B28EFFFF1C30002001E0000007F05FB')" }, "detailAnalyseReglements": "obj://TDetailAnalyseReglements/", "nbJMReglement": 0, "nbJMRetFactNonReglees": 0, "nbJMRetFactReglees": 0, "nbJMRetToutesFact": 0, "retenueALaSource": { "value": 0, "title": "Non Soumis" }, "retenueTVA": false, "tauxRetenueALaSource": { "value": 0, "Decimales": 2 }, "tauxRetenueTVA": { "value": 0, "Decimales": 2 }, "validationObligatoire": false, "existProduitTiers": false, "ChiffreAffaires": { "value": 0, "CodeDevise": "" }, "AccesAPayer": false, "fournisseurAPayer": { "$key": "1B28EFFFF1C3000201030000000903C1", "$url": "TFournisseur('1B28EFFFF1C3000201030000000903C1')" }, "fournisseurFacturant": { "$key": "1B28EFFFF1C3000201030000000903C1", "$url": "TFournisseur('1B28EFFFF1C3000201030000000903C1')" }, "ndxFournisseurFacturant": 0, "regimeFournisseur": { "value": 0, "title": "Général" }, "RegroupFact": { "value": 0, "title": "Selon le paramétrage du tiers" } } ], "$nextUrl": "http://localhost:8080/sdata/gentiers/tfournisseur?count=1&startKey='1B28EFFFF1C3000201030000000903C1'&keyDirection=gt" }
Et le tiers correspondant :
http://localhost:8080/sdata/gentiers/ttiers('1B28EFFFF1C3000200F60000000903B6')?count=1 { "$baseUrl": "http://localhost:8080/sdata/gentiers/", "$title": "TTiers - -", "$updated": "2021-01-27T16:44:22.209Z", "$resources": [ { "$url": "TTiers('1B28EFFFF1C3000200F60000000903B6')", "$title": "DUCREDIT Sa", "$updated": "2010-03-19T12:42:13.000Z", "$etag": "1B28EFFFF1C3000200F60000000903B6-000002B500004B64", "$shareId": "1B28EFFFF1C300020002000000420002", "$shareInfo": "Dossier", "$shareLevel": 0, "$key": "1B28EFFFF1C3000200F60000000903B6", "$baseUrl": "http://localhost:8080/sdata/GenTiers/-/", "stamp": "000002B500004B64", "Activite": { "$key": "1B28EFFFF1C30002000600000010003A", "$url": "TActivite('1B28EFFFF1C30002000600000010003A')" }, "assujettiTVA": { "value": 0, "title": "Taxable" }, "BlocageReglement": false, "capital": { "value": 1000000, "CodeDevise": "EUR" }, "Caption": "DUCREDIT Sa", "chiffreAffaires": { "value": 0, "CodeDevise": "EUR" }, "code": "DUCREDIT", "codeSIRET": "101 001 010 10101", "CodificationAPE": { "$key": "1B28EFFFF1C30002000B00000010028C", "$url": "TCodificationAPE('1B28EFFFF1C30002000B00000010028C')" }, "commentaire": "Société financière DUCREDITRole de FournisseurPartagé pour toutes les sociétés du Dossier", "Compensable": false, "CorrespondanceGroupe": { "$key": "1B28EFFFF1C3000200F70000000903B9", "$url": "TCorrespondanceGroupeTiers('1B28EFFFF1C3000200F70000000903B9')" }, "dateCapital": "2012-12-22T23:00:00.000Z", "dateCreation": "2012-12-22T23:00:00.000Z", "disabled": false, "disabledDupli": false, "echeancementDecaissement": { "$key": "1B28EFFFF1C30002000F0000001A017E", "$url": "TEcheancement('1B28EFFFF1C30002000F0000001A017E')" }, "echeancementEncaissement": { "$key": "1B28EFFFF1C30002000F000000C30013", "$url": "TEcheancement('1B28EFFFF1C30002000F000000C30013')" }, "effectif": 0, "estClient": false, "estCodeSIRETRequis": false, "estCodeSIRETValide": false, "estContactVisible": false, "estFournisseur": false, "EstGroupe": false, "estIntraGroupe": false, "estMajInfoSolvabilite": false, "estSalarie": false, "estTiersConfiance": true, "estTiersDivers": false, "EstTiersSociete": false, "estTransporteur": false, "FlagModificationList": "", "FormeJuridique": { "$key": "1B28EFFFF1C3000200110000011E0001", "$url": "TFormeJuridique('1B28EFFFF1C3000200110000011E0001')" }, "garanties": false, "immatriculationRegistre": "009918888888", "incidentPaiement": false, "invocableCreerClient": false, "invocableCreerDivers": false, "invocableCreerFourni": false, "invocableCreerSalarie": false, "invocableCreerTransporteur": false, "invocableModifClient": false, "invocableModifCompteBq": false, "invocableModifDivers": false, "invocableModifFourni": false, "invocableModifSalar": false, "invocableModifTransporteur": false, "modeReglementDecaissement": { "$key": "1B28EFFFF1C300020014000000710003", "$url": "TModeReglement('1B28EFFFF1C300020014000000710003')" }, "modeReglementEncaissement": { "$key": "1B28EFFFF1C300020014000000710000", "$url": "TModeReglement('1B28EFFFF1C300020014000000710000')" }, "Modifiable": false, "numeroTraitement": 0, "numeroTVACEE": "FR 66516166666", "Pays": { "$key": "1B28EFFFF1C3000200150000001700FD", "$url": "TPays('1B28EFFFF1C3000200150000001700FD')" }, "raisonSociale": "DUCREDIT Sa", "resultat": { "value": 0, "CodeDevise": "EUR" }, "RoleTiersList": [ { "$key": "1B28EFFFF1C3000201030000000903C1", "assujetiTaxe": false, "Caption": "F-DUCREDIT", "CategorieComptaTiers": { "$key": "1B28EFFFF1C300020041000000380037", "$url": "TCategorieComptaTiers('1B28EFFFF1C300020041000000380037')" }, "commentaire": "", "cumulQte": false, "dateCreation": "2012-12-22T23:00:00.000Z", "dateFacturation": { "value": 0, "title": "Date du traitement" }, "decouvertLimite": { "value": 0, "CodeDevise": "EUR" }, "devise": { "$key": "1B28EFFFF1C300020005000000700005", "$url": "TdbfCurrency('1B28EFFFF1C300020005000000700005')" }, "disabled": false, "enActivite": true, "escompte": { "value": 0, "Decimales": 4 }, "estRoleTiersSociete": false, "montantFrancoDePort": { "value": 999999999, "CodeDevise": "EUR" }, "natureTiers": { "value": 0, "title": "Client" }, "pourcentageAcompte": { "value": 0, "Decimales": 4 }, "regroupFacture": { "value": 0, "title": "1 facture par commande" }, "RoleTiersPayeur": { "$key": "1B28EFFFF1C3000201030000000903C1", "$url": "TRoleTiers('1B28EFFFF1C3000201030000000903C1')" }, "sensible": false, "siteFacturation": { "$key": "1B28EFFFF1C3000200F80000000903BA", "$url": "TSite('1B28EFFFF1C3000200F80000000903BA')" }, "siteLivraisonPrivilegie": { "$key": "1B28EFFFF1C3000200FC00000067006F", "$url": "TSiteCommerciale('1B28EFFFF1C3000200FC00000067006F')" }, "sitePrivilegie": { "$key": "1B28EFFFF1C3000200F80000000903BA", "$url": "TSite('1B28EFFFF1C3000200F80000000903BA')" }, "typeFacturation": { "value": 0, "title": "HT" }, "CategorieCollectif": { "$key": "1B28EFFFF1C3000202010000000903C6", "$url": "TCategorieCollectif('1B28EFFFF1C3000202010000000903C6')" }, "comptePrivilegie": { "$key": "1B28EFFFF1C30002001E0000007F05FB", "$url": "TCompteGeneral('1B28EFFFF1C30002001E0000007F05FB')" }, "detailAnalyseReglements": "obj://TDetailAnalyseReglements/", "nbJMReglement": 0, "nbJMRetFactNonReglees": 0, "nbJMRetFactReglees": 0, "nbJMRetToutesFact": 0, "retenueALaSource": { "value": 0, "title": "Non Soumis" }, "retenueTVA": false, "tauxRetenueALaSource": { "value": 0, "Decimales": 2 }, "tauxRetenueTVA": { "value": 0, "Decimales": 2 }, "validationObligatoire": false, "existProduitTiers": false, "ChiffreAffaires": { "value": 0, "CodeDevise": "" }, "AccesAPayer": false, "fournisseurAPayer": { "$key": "1B28EFFFF1C3000201030000000903C1", "$url": "TFournisseur('1B28EFFFF1C3000201030000000903C1')" }, "fournisseurFacturant": { "$key": "1B28EFFFF1C3000201030000000903C1", "$url": "TFournisseur('1B28EFFFF1C3000201030000000903C1')" }, "ndxFournisseurFacturant": 0, "regimeFournisseur": { "value": 0, "title": "Général" }, "RegroupFact": { "value": 0, "title": "Selon le paramétrage du tiers" } } ], "SiteCommercialeList": [ { "$key": "1B28EFFFF1C3000200FC00000067006F", "actif": true, "Adresse": { "$key": "1B28EFFFF1C3000200FB0000000903BC", "$url": "TAdresse('1B28EFFFF1C3000200FB0000000903BC')" }, "Caption": "SIEGE DUCREDIT SA", "code": "SITE01", "conserverReliquat": true, "livraisonPartielleAcceptee": true, "livraisonPartielleReliquat": false, "PourcentAccepteReliquat": 0, "RegroupementLivraison": { "value": 0, "title": "Aucun" }, "Site": { "$key": "1B28EFFFF1C3000200F80000000903BA", "$url": "TSite('1B28EFFFF1C3000200F80000000903BA')" } } ], "sitesList": [ { "$key": "1B28EFFFF1C3000200F80000000903BA", "Adresse": { "$key": "1B28EFFFF1C3000200FB0000000903BC", "$url": "TAdresse('1B28EFFFF1C3000200FB0000000903BC')", "adresseNormalisee": "", "codePostal": "920000", "complementAdresse": "La Défense", "estValide": true, "geoloc": { "value": "", "lat": 0, "long": 0 }, "nomRueVoie": "Rue de la Finance", "NPAI": false, "Pays": { "$key": "1B28EFFFF1C3000200150000001700FD", "$url": "TPays('1B28EFFFF1C3000200150000001700FD')" }, "siteInternet": "www", "telephone1": "0178271717", "typePersonne": { "value": 0, "title": "Personne morale" }, "varNoErreurGeoloc": false, "ville": "NANTERRE" }, "assujettiTaxeSalaire": false, "Caption": "SIEGE DUCREDIT SA", "code": "SITE01", "commentaire": "", "estAdministratif": true, "estLivraison": true, "estLocalisation": false, "estSiteSociete": false, "idxDepot": 0, "interlocuteurPrivilegie": { "$key": "1B28EFFFF1C30002010F0000000903C9", "$url": "TInterlocuteur('1B28EFFFF1C30002010F0000000903C9')" }, "interlocuteursList": [ { "$key": "1B28EFFFF1C30002010F0000000903C9", "actif": true, "Caption": "DUCREDIT Denis", "Civilite": { "$key": "1B28EFFFF1C3000200D20000003628AB", "$url": "TCivilite('1B28EFFFF1C3000200D20000003628AB')" }, "commentaire": "", "Fonction": { "$key": "1B28EFFFF1C3000200100000003A00F9", "$url": "TFonction('1B28EFFFF1C3000200100000003A00F9')" }, "identiteNormalisee": "", "nom": "DUCREDIT", "prenom": "Denis" } ], "Langue": { "$key": "1B28EFFFF1C3000200130000003A024E", "$url": "TLangue('1B28EFFFF1C3000200130000003A024E')" }, "SiteCommerciale": { "$key": "1B28EFFFF1C3000200FC00000067006F", "$url": "TSiteCommerciale('1B28EFFFF1C3000200FC00000067006F')" }, "TerritorialiteTaxe": { "$key": "1B28EFFFF1C3000200C0000000362816", "$url": "TTerritorialiteTaxe('1B28EFFFF1C3000200C0000000362816')" }, "gestionBudgetaire": { "value": 0, "title": "Aucune" }, "depotPrivilegieEtablissement": false, "complementLigne": false, "complementPiece": false, "invocableMajDemat": false } ], "SiteSociete": { "$key": "1B28EFFFF1C3000200F80000000903BA", "$url": "TSite('1B28EFFFF1C3000200F80000000903BA')" }, "socialData": "", "Supprimable": false, "surveillance": false, "typeAcceptation": { "value": 0, "title": "Accepté" }, "typePersonne": { "value": 0, "title": "Personne morale" }, "varModeConfirmation": false, "estMouvementeCpt": true, "invocableMiseAJour": false, "CodeImputationFrais": { "value": 1, "title": "Partagé" }, "modeReglement": { "value": 0, "title": "Autre" } } ] }