Method
The method to be called is:
Parameters
In the request headers the Authorization header must have the Access Token:
- Authorization: {{accessToken}}
JSON body
In the body of the POST a JSON structure like this one has to be passed:
{
"customer":{
"number": 1,
"name": "Test"
},
"requestOptions": {
"option": 3,
"requestedFields": [
"fno",
"avencastamp",
"etotal",
"ettiva"
],
"reportName":"Avenca"
},
"document":{
"docType": 1,
"resume":"Resume of Avenca",
"inicialValidity":"2020-02-25 00:00:00Z",
"finalValidity":"2021-02-25 00:00:00Z",
"frequency": 2,
"inactive": false,
"advanceBill": true,
"payCondition": "Recebimento por Transferência Bancária",
"occurrenceNum": 5,
"refInt": "Referencia interna",
"documentObservations": "This is an observation"
},
"products":[
{
"reference": "C021",
"designation": "Test2",
"unitCode": "M",
"unitPrice": 15.55,
"discount1": 20,
"discount2": 0,
"quantity": 1,
"taxIncluded": true,
"taxPercentage": 23,
"taxRegion": "PT"
}
]
}
Return Information
Any call made to this method will return a JSON information with this structure:
-
If the option value is “0”:
{
"code": 0,
"message": "Information saved with success and mail sent to client",
"requestedFields": {} /** OBJECT CONTAINING THE REQUESTED FIELDS FROM requestOptions **/
}
-
If the option value is “1”:
{
"code": 1,
"message": "Information saved with success",
"pdf": "LINK FOR THE DOCUMENT PDF",
"requestedFields": {} /** OBJECT CONTAINING THE REQUESTED FIELDS FROM requestOptions **/
}
-
If the option value is “2”:
{
"code": 2,
"message": "Information saved with success",
"requestedFields": {} /** OBJECT CONTAINING THE REQUESTED FIELDS FROM requestOptions **/
}
-
In case of error:
{
"code": 100,
"message": "Error message"
}
-
In case of success but with printing error:
{
"code": 50,
"message": "Information saved with success. Error printing the document."
}
JSON Specification for Create Avença
Request Options
Name | Type | PHC GO Entity | PHC GO Field | Observations |
option1 | Integer | – | – | 0 – Send document by email
1 – Return document pdf link to print
2 – Create document without signing (WARNING: For this to work the Document Type must allow drafts. If the document type does not allow drafts the document WILL BE SIGNED)
3 – Create document with signing but does not produce pdf and email with pdf for client |
requestedFields | String Array | – | – | The PHC GO entity fields to be returned on Success |
reportName | String | – | – | Name of the report type the document should have. If not defined will use one of the reports the user has access to
Ex. “Impressão Minimal Simples” |
Customer2
Name | Type | PHC GO Entity | PHC GO Field | Observations |
number2 | Integer | Cl | no | |
estab | Integer | Cl | estab | By default it goes 0 |
name2 | String | Cl | nome | |
address2 | String | Cl | morada | |
postalCode2 | String | Cl | codpost | |
city2 | String | Cl | local | |
country2 | String | Cl | pais | Can be set with the full name or the alpha-2 letter ISO3166 format
Ex. “PT”, “ES”,”US” (See here) |
email2 | String | Cl | email | |
taxNumber2 | String | Cl | ncont | |
abbreviatedName2 | String | Cl | nome2 | |
Document
Name | Type | PHC GO Entity | PHC GO Field | Observations |
docType1 | Integer | – | – | Serie of document to ceate. Defaults: 1 - Avenca |
resume1 | String | Avenca | resumo | Resume of Avenca |
inactive1 | Boolean | Avenca | inactiva | |
inicialValidity1 | Date | Avenca | validi | Inicial Data |
finalValidity | Date | Avenca | validf | Final Data |
frequency1 | Integer | Avenca | periodicidadeid | Options: 1 - Weekly 2 - Monthly 3 - Annual |
occurrenceNum | Integer | Avenca | periodo | |
advanceBill | Boolean | Avenca | usaavencaantecipada | |
payCondition | String | Avenca | tpdesc | Payment Tems. Defaults options: - Multi-pagamento - Pagamento por Débito em Conta - Recebimento por Transferência Bancária |
refInt | String | Avenca | refInt | Some internal reference, at the user´s choice |
documentObservations | String | Avenca | obs | |
Footnotes
1 - Required
2 - Customer can be referenced in two ways:
- As an object (passing this object will also create/update the customer on PHC GO
- On the Document’s customerNumber field (referencing an existent Customer)