Creation d'un fournisseur (API)
De Wiki1000
Cet exemple montre comment créer un fournisseur avec l'API SData.
Création du fournisseur
Pour créer un fournisseur il faut :
- Créer un tiers en renseignant au moins un site et son adresse
- Appeler la méthode creerFournisseur du Tiers
Pour cela on utilise une opération $batch qui combine les deux opérations :
POST http://localhost:8080/sdata/S1/$batch { "$": {"$transaction":["atomic"]}, "$resources": [ { "$httpMethod":"POST", "$url":"gentiers/TTiers", "$uuid":"newTiers", "$shareLevel":2, "code":"NV-TIERS-1", "caption":"Société générale des Anges", "sitesList":[ { "code":"SITE-1", "caption":"Site principal", "adresse":{ "nomRueVoie":"17 rue des anges", "ville":"Clichy", "codePostal":"92100", "pays":{"$url":"TPays(code eq 'FRF')"} } } ] }, { "$httpMethod":"EXEC", "$url":"gentiers/TTiers(newTiers)/creerFournisseur", } ] } Response : 200 OK { "$baseUrl": "http://localhost:8080/sdata/l1000/-/-/", "$title": "$batch - -", "$resources": [ { "$httpStatus": 201, "$httpMethod": "POST", "$httpMessage": "Created", "$etag": "1B28EFFFF1C3000200F6000002550001-000001E000000002", "$location": "http://localhost:8080/sdata/l1000/gentiers/-/TTiers('1B28EFFFF1C3000200F6000002550001')", "$milliseconds": "176,2632" }, { "$httpStatus": 200, "$httpMethod": "EXEC", "$httpMessage": "Executed", "$url": "gentiers/TTiers(newTiers)/creerFournisseur", "$uuid": "", "$milliseconds": "10809,8219" } ], "$batch": { "$httpStatus": 200, "$httpMessage": "OK", "$milliseconds": "10986,3663" } }
Récupération du fournisseur
Pour retrouver le fournisseur d'un tiers :
GET http://localhost:8080/sdata/S1/gentiers/TFournisseur(tiers.code eq 'NV-TIERS-1') Response : 200 OK { "$baseUrl": "http://localhost:8080/sdata/l1000/gentiers/-/", "$title": "TFournisseur - -", "$updated": "2021-01-04T13:52:25.909Z", "$resources": [ { "$url": "TFournisseur('1B28EFFFF1C30002010300000255000A')", "$title": "F-NV-TIERS-1", "$updated": "2021-01-04T13:30:33.000Z", "$etag": "1B28EFFFF1C30002010300000255000A-000001E000000008", "$shareId": "1B28EFFFF1C30002000300000003000B", "$shareInfo": "S1", "$shareLevel": 2, "$key": "1B28EFFFF1C30002010300000255000A", "stamp": "000001E000000008", "assujetiTaxe": false, "Caption": "F-NV-TIERS-1", "CategPrixTiers": { "$key": "1B28EFFFF1C30002004700000255000F", "$url": "TCategPrixTiers('1B28EFFFF1C30002004700000255000F')" }, "commentaire": "", "cumulQte": false, "dateCreation": "2021-01-03T23: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": 0, "CodeDevise": "EUR" }, "natureTiers": { "value": 0, "title": "Client" }, "pourcentageAcompte": { "value": 0, "Decimales": 4 }, "regroupFacture": { "value": 0, "title": "1 facture par commande" }, "RoleTiersPayeur": { "$key": "1B28EFFFF1C30002010300000255000A", "$url": "TRoleTiers('1B28EFFFF1C30002010300000255000A')" }, "sensible": false, "siteFacturation": { "$key": "1B28EFFFF1C3000200F8000002550004", "$url": "TSite('1B28EFFFF1C3000200F8000002550004')" }, "siteLivraisonPrivilegie": { "$key": "1B28EFFFF1C3000200FC000002550008", "$url": "TSiteCommerciale('1B28EFFFF1C3000200FC000002550008')" }, "sitePrivilegie": { "$key": "1B28EFFFF1C3000200F8000002550004", "$url": "TSite('1B28EFFFF1C3000200F8000002550004')" }, "Tiers": { "$key": "1B28EFFFF1C3000200F6000002550001", "$url": "TTiers('1B28EFFFF1C3000200F6000002550001')" }, "typeFacturation": { "value": 0, "title": "HT" }, "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 }, "GroupeRTValidation": { "$key": "1B28EFFFF1C3000202D30000002B0055", "$url": "TGroupeRTValidation('1B28EFFFF1C3000202D30000002B0055')" }, "validationObligatoire": false, "existProduitTiers": false, "ChiffreAffaires": { "value": 0, "CodeDevise": "" }, "AccesAPayer": false, "fournisseurAPayer": { "$key": "1B28EFFFF1C30002010300000255000A", "$url": "TFournisseur('1B28EFFFF1C30002010300000255000A')" }, "fournisseurFacturant": { "$key": "1B28EFFFF1C30002010300000255000A", "$url": "TFournisseur('1B28EFFFF1C30002010300000255000A')" }, "ndxFournisseurFacturant": 0, "regimeFournisseur": { "value": 0, "title": "Général" }, "RegroupFact": { "value": 0, "title": "Selon le paramétrage du tiers" } } ] }