Rest API POST doc from HansaWorld: erinevus redaktsioonide vahel
(ei näidata sama kasutaja üht vahepealset redaktsiooni) | |||
251. rida: | 251. rida: | ||
</data> | </data> | ||
</syntaxhighlight>Nagu näha, on arvele kandunud korrektselt objektid, kliendi kontaktisikud jms, mida me postitasime algsetele kaartidele. | </syntaxhighlight>Nagu näha, on arvele kandunud korrektselt objektid, kliendi kontaktisikud jms, mida me postitasime algsetele kaartidele. | ||
NB: On oluline ka lisatava info järjekord. Näiteks, kui lisate tasumistingimuse koodi, seejärel kontakti koodi ning sellel kontaktil ei ole Müügi Tasumistingimus täidetud, siis saate veateate, et tasumistingimus on tühi. Õige järjekord antud juhul oleks Kontaktikood, peale seda tasumistingimus. Sama reegel on objektidega - need lisada peale kontakti, ridadel peale Kontot või Artiklit. | |||
==== Muudame koostatud arvel kogust ==== | ==== Muudame koostatud arvel kogust ==== | ||
262. rida: | 264. rida: | ||
</syntaxhighlight>Vastuseks on samasugune arve XML, nagu arve postitamisel, vaid kogus on muutunud 3-ks. | </syntaxhighlight>Vastuseks on samasugune arve XML, nagu arve postitamisel, vaid kogus on muutunud 3-ks. | ||
[[Pilt:Kogus 3.png|tühi|pisi|569x569px]] | [[Pilt:Kogus 3.png|tühi|pisi|569x569px]] | ||
==== Muudame Arvel artiklit, kogust, kirjeldust ja hinda ==== | |||
Oletame, et sooime arvel vahetada artiklit, kogust ja hinda ning lisada kaks uut rida kirjeldusega (nö täiendavad kirjeldavad read)<syntaxhighlight lang="text"> | |||
set_row_field.0.ArtCode=0032251100060& | |||
set_row_field.0.Quant=1& | |||
set_row_field.0.Price=4000& | |||
set_row_field.0.Spec=M20 EX stainless steel 316 Maxed Out& | |||
set_row_field.1.Spec=Description here: neti.ee& | |||
set_row_field.2.Spec=Refund, when broken or pieces missing& | |||
</syntaxhighlight>Tulemus on selline: | |||
[[Pilt:Lisatud read.png|tühi|pisi|574x574px]] | |||
==== Kinnitame arve ==== | |||
<syntaxhighlight lang="text"> | |||
Request: https://mars.excellent.ee:4455/api/1/IVVc/2180325 | |||
Method: Patch | |||
Headers: Authorization: Basic [user:pass in base64] example: dXNlcjpwYXNz | |||
Body: | |||
set_field.OKFlag=1& | |||
</syntaxhighlight>tekkis viga, puudu on konto käibemaksukoodi pealt. Kuidas seda tean? Sest sain vastu veateate:<syntaxhighlight lang="xml"> | |||
<?xml version='1.0' encoding='UTF-8' standalone='yes'?> | |||
<message description="TAX Account not found, check VAT Codes"></message> | |||
<error code="20078" description="TAX Account not found, check VAT Codes" row="-1" field="-1"></error> | |||
</syntaxhighlight>Parandasin vea, seejärel sain tulemuseks OK ning tulemus: | |||
[[Pilt:OK tulemus.png|tühi|pisi|549x549px]] |
Viimane redaktsioon: 5. märts 2019, kell 13:48
Writing Data to HansaWorld software, > 8.5
Functionally RecordNew will be called, then each set command will be called in order with it's respective window actions (to fill e.g. customer's name and payment terms). Finally the record will be inserted calling the same record actions as if a user did it with a client. There is no limit to the number of set commands you can issue, they can be either in the url or in post data. Only fields with non-default (non blank) data is returned.
Note the "url" parameter that uniquely identifies the created record. If you have more than one field in the main key these fields will be separated by '/'. If the main key contains special characters they will be url encoded.
In case of any messages that user would receive when entering the data manually, these messages will be returned in following format: <message description='message_text'></message>
In case of error while inserting/updating a record, following will be returned: <error code='error_code' description='error description' row='row_no' field='field_name'></error>
POST
To create new records you POST to the registers. The 'set' commands have the same syntax and functionality as with POST.
Example:
curl -X POST 'http://SJ:@127.0.0.1:8080/api/1/IVVc?set_field.CustCode=001&set_row_field.0.ArtCode=10101&set_row_field.0.Quant=3';
The reply will be in this format:
<data register="IVVc" sequence="9693" url="/api/1/IVVc/10000014" systemversion="8.5.15.5" <IVVc>
<SerNr>10000010</SerNr>
<InvDate>2018-05-30</InvDate>
<CustCode>001</CustCode>
<Math/>
<PayDate>2018-06-29</PayDate>
<Addr0>Against All Odds Trading Co</Addr0> ... <rows>
<row rownumber="0">
<stp>1</stp>
<ArtCode>10101</ArtCode>
<Quant>3</Quant>
<Price>25.00</Price>
<Sum>71.25</Sum>
This will create a new invoice for 001 customer, adding 3 10101 items.
PATCH
To change an existing record you PATCH the url given in the POST command.
Example:
curl -X PATCH 'http://SJ:@127.0.0.1:8080/api/1/IVVc/10000014?set_row_field.0.Quant=100'
The reply will be in the same format:
<data register="IVVc" sequence="9729" url="/api/1/IVVc/10000014" systemversion="8.5.15.6" <IVVc>
<SerNr>10000014</SerNr> ... <rows>
<row rownumber="0">
<stp>1</stp>
<ArtCode>10101</ArtCode>
<Quant>100</Quant>
<Price>25.00</Price>
<Sum>2375.00</Sum>
This will change the quantity to 100.
Lihtsad POSTi näited
POST meetodiga saab tekitada uusi dokumente
PATCH meetodiga saab muuta olemasolevaid kaarte (ei pea kaasa saatma kogu kaardi sisu, muudetava dokumendi nr sisaldub URLis)
Koostame kliendi
Request: https://mars.excellent.ee:4455/api/1/CUVc/
Method: Post
Headers: Authorization: Basic [user:pass in base64] example: dXNlcjpwYXNz
Body:
set_field.Code=&
set_field.Name=Kohvimasina POST OÜ&
set_field.InvAddr0=Saue&
set_field.InvAddr1=Kodu 13/3&
set_field.InvAddr2=Maja&
set_field.Phone=55887744&
set_field.CountryCode=EE&
set_field.ExportFlag=0&
set_field.CustCat=EES&
set_field.PayDeal=7&
set_field.VATNr=EE792919432&
set_field.LangCode=EST
set_field.VATCode=20&
set_field.Fax=6672823&
set_field.Classification=62031,73121,74901,82991&
set_field.ExportFlag=0&
set_field.Person=Mariliis Männik&
Posteri ekraanipilt:
Saame vastuse:
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<data register="CUVc" sequence="252020" url="/api/1/CUVc/1985" systemversion="8.5.28.512">
<CUVc>
<UUID>BC96B2EF-6DDFCA41-D7333126-26FAE7C4-7BCE7A18</UUID>
<SyncFlags>1</SyncFlags>
<Code>1985</Code>
<Name>Kohvimasina POST OÜ</Name>
<Person>Mariliis Männik</Person>
<InvAddr0>Saue</InvAddr0>
<InvAddr1>Kodu 13/3</InvAddr1>
<InvAddr2>Maja</InvAddr2>
<Phone>55887744</Phone>
<Fax>6672823</Fax>
<CustCat>EES</CustCat>
<PayDeal>7</PayDeal>
<InterestFlag>1</InterestFlag>
<VATNr>EE792919432</VATNr>
<CountryCode>EE</CountryCode>
<RemndrFlag>1</RemndrFlag>
<LangCode>EST</LangCode>
<OnAccount>1</OnAccount>
<SalesMan>AA</SalesMan>
<CreditLimit>0.00</CreditLimit>
<VATCode>20</VATCode>
<Classification>62031,73121,74901,82991</Classification>
<DateChanged>2019-02-14</DateChanged>
<Password>0</Password>
<DateCreated>2019-02-14</DateCreated>
<CUType>1</CUType>
<CreditLimitDays>0</CreditLimitDays>
<InvCountryName>Eesti</InvCountryName>
<TaxCondition>2</TaxCondition>
<Sign>AA</Sign>
<eInvPostage>2</eInvPostage>
</CUVc>
</data>
- astuses vaid need read kontaktikaardilt, mis on täidetud.
- täidetud on ka väljad, mis GUIga kontakti luues automaatselt täidetakse
Koostame artikli
Request: https://mars.excellent.ee:4455/api/1/INVc/
Method: Post
Headers: Authorization: Basic [user:pass in base64] example: dXNlcjpwYXNz
Body:
set_field.Code=&
set_field.Name=Trenažöör põlvedele&
set_field.MinLevel=100&
set_field.Objects=NO_PREEMIA&
set_field.UPrice1=1700.00&
set_field.Group=KOHV&
set_field.BarCode=1022154455&
Posteri ekraanipilt:
Vastuse saame sellise:
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<data register="INVc" sequence="252082" url="/api/1/INVc/19.321-127" systemversion="8.5.28.512">
<INVc>
<UUID>215B7710-46C044D2-D464046D-5806B64D-BAC293D8</UUID>
<SyncFlags>1</SyncFlags>
<Code>19.321-127</Code>
<Name>Trenazöör põlvedele</Name>
<MinLevel>100</MinLevel>
<Objects>NO_PREEMIA</Objects>
<UPrice1>1700.00</UPrice1>
<ItemType>1</ItemType>
<Group>KOHV</Group>
<BarCode>1022154455</BarCode>
<UpdateCost>1</UpdateCost>
<LastPriceChange>2019-02-14</LastPriceChange>
<LastBasePriceChange>2019-02-14</LastBasePriceChange>
<colnr>Grey</colnr>
<SRUpdateCost>1</SRUpdateCost>
<rows></rows>
</INVc>
</data>
Meil on nüüd olemas Klient koodiga "1985" (Kohvimasina Post OÜ) ja artikkel "19.321-127"
Müüme postitatud artikli postitatud kliendile maha.
Koostame arve, kasutame loodud artiklit ja klienti
Request: https://mars.excellent.ee:4455/api/1/IVVc/
Method: Post
Headers: Authorization: Basic [user:pass in base64] example: dXNlcjpwYXNz
Body:
set_field.InvDate=2019-02-10&
set_field.CustCode=1985&
set_field.NotUpdStockFlag=1&
set_row_field.0.ArtCode=19.321-127&
set_row_field.0.Quant=1&
Vastuseks saime üherealise arve:
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<data register="IVVc" sequence="252169" url="/api/1/IVVc/2180325" systemversion="8.5.28.512">
<IVVc>
<SerNr>2180325</SerNr>
<InvDate>2019-02-10</InvDate>
<CustCode>1985</CustCode>
<Math></Math>
<PayDate>2019-02-17</PayDate>
<Addr0>Kohvimasina POST OÜ</Addr0>
<Addr1>Saue</Addr1>
<Addr2>Kodu 13/3</Addr2>
<Addr3>Maja</Addr3>
<ClientContact>Mariliis Männik</ClientContact>
<PayDeal>7</PayDeal>
<Prntdf>1</Prntdf>
<pdays>7</pdays>
<pdvrebt>0</pdvrebt>
<pdrdays>0</pdrdays>
<CustCat>EES</CustCat>
<InvType>1</InvType>
<ARAcc>1210</ARAcc>
<SalesMan>AA</SalesMan>
<TransDate>2019-02-10</TransDate>
<CurncyCode>EUR</CurncyCode>
<LangCode>EST</LangCode>
<Sign>AA</Sign>
<FrGP>0.00</FrGP>
<Sum0>0.00</Sum0>
<Sum1>1700.00</Sum1>
<Sum3>340.00</Sum3>
<Sum4>2040.00</Sum4>
<VATNr>EE792919432</VATNr>
<TAX1Sum>340.00</TAX1Sum>
<CustVATCode>20</CustVATCode>
<Phone>55887744</Phone>
<Fax>6672823</Fax>
<IntCode>25.55</IntCode>
<ARonTR>1</ARonTR>
<BaseSum4>2040.00</BaseSum4>
<TotGP>1700.00</TotGP>
<RetValue>-2040.00</RetValue>
<TotQty>1</TotQty>
<SumIncCom>2040.00</SumIncCom>
<RetnValue>-2040.00</RetnValue>
<TransTime>15:47:16</TransTime>
<ServiceDelDate>2019-02-10</ServiceDelDate>
<NoTAXonVAT>1</NoTAXonVAT>
<TotalwoTAX>1</TotalwoTAX>
<RegDate>2019-02-14</RegDate>
<RegTime>15:47:16</RegTime>
<InvCountry>EE</InvCountry>
<InvCountryName>Eesti</InvCountryName>
<GPProc>100.0</GPProc>
<rows>
<row rownumber="0">
<stp>1</stp>
<ArtCode>19.321-127</ArtCode>
<Quant>1</Quant>
<Price>1700.00</Price>
<Sum>1700.00</Sum>
<SalesAcc>3100</SalesAcc>
<Objects>NO_PREEMIA</Objects>
<rowGP>1700.00</rowGP>
<Spec>Trenazöör põlvedele</Spec>
<VATCode>20</VATCode>
<TaxMatrix></TaxMatrix>
</row>
</rows>
</IVVc>
</data>
Nagu näha, on arvele kandunud korrektselt objektid, kliendi kontaktisikud jms, mida me postitasime algsetele kaartidele.
NB: On oluline ka lisatava info järjekord. Näiteks, kui lisate tasumistingimuse koodi, seejärel kontakti koodi ning sellel kontaktil ei ole Müügi Tasumistingimus täidetud, siis saate veateate, et tasumistingimus on tühi. Õige järjekord antud juhul oleks Kontaktikood, peale seda tasumistingimus. Sama reegel on objektidega - need lisada peale kontakti, ridadel peale Kontot või Artiklit.
Muudame koostatud arvel kogust
Request: https://mars.excellent.ee:4455/api/1/IVVc/2180325
Method: Patch
Headers: Authorization: Basic [user:pass in base64] example: dXNlcjpwYXNz
Body:
set_row_field.0.Quant=3'&
Vastuseks on samasugune arve XML, nagu arve postitamisel, vaid kogus on muutunud 3-ks.
Muudame Arvel artiklit, kogust, kirjeldust ja hinda
Oletame, et sooime arvel vahetada artiklit, kogust ja hinda ning lisada kaks uut rida kirjeldusega (nö täiendavad kirjeldavad read)
set_row_field.0.ArtCode=0032251100060&
set_row_field.0.Quant=1&
set_row_field.0.Price=4000&
set_row_field.0.Spec=M20 EX stainless steel 316 Maxed Out&
set_row_field.1.Spec=Description here: neti.ee&
set_row_field.2.Spec=Refund, when broken or pieces missing&
Tulemus on selline:
Kinnitame arve
Request: https://mars.excellent.ee:4455/api/1/IVVc/2180325
Method: Patch
Headers: Authorization: Basic [user:pass in base64] example: dXNlcjpwYXNz
Body:
set_field.OKFlag=1&
tekkis viga, puudu on konto käibemaksukoodi pealt. Kuidas seda tean? Sest sain vastu veateate:
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<message description="TAX Account not found, check VAT Codes"></message>
<error code="20078" description="TAX Account not found, check VAT Codes" row="-1" field="-1"></error>
Parandasin vea, seejärel sain tulemuseks OK ning tulemus: