Create Avença
Texto

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:

  1. 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 **/
    }


  2. 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 **/
    }


  3. If the option value is “2”:


    {
    "code": 2,
    "message": "Information saved with success",
    "requestedFields": {} /** OBJECT CONTAINING THE REQUESTED FIELDS FROM requestOptions **/
    }


  4. In case of error:


    {
    "code": 100,
    "message": "Error message"
    }



JSON Specification for Create Avença



Request Options


 
NameTypePHC GO EntityPHC GO FieldObservations
option1Integer0 – 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
requestedFieldsString ArrayThe PHC GO entity fields to be returned on Success
reportNameStringName 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


 
NameTypePHC GO EntityPHC GO FieldObservations
number2IntegerClno
estabIntegerClestabBy default it goes 0
name2StringClnome
address2StringClmorada
postalCode2StringClcodpost
city2StringCllocal
country2StringClpaisCan be set with the full name or the alpha-2 letter ISO3166 format

Ex. “PT”, “ES”,”US” (See here)
email2StringClemail
taxNumber2StringClncont
abbreviatedName2StringClnome2

 

Document


 
NameTypePHC GO EntityPHC GO FieldObservations
docType1IntegerSerie of document to ceate. Defaults:
1 - Avenca
resume1StringAvencaresumoResume of Avenca
inactive1BooleanAvencainactiva
inicialValidity1DateAvencavalidiInicial Data
finalValidityDateAvencavalidfFinal Data
frequency1IntegerAvencaperiodicidadeidOptions:
1 - Weekly
2 - Monthly
3 - Annual
occurrenceNumIntegerAvencaperiodo
advanceBillBooleanAvencausaavencaantecipada
payConditionStringAvencatpdescPayment Tems. Defaults options:
- Multi-pagamento
- Pagamento por Débito em Conta
- Recebimento por Transferência Bancária
refIntStringAvencarefIntSome internal reference, at the user's choice
documentObservationsStringAvencaobs

 


Footnotes


1 - Required

2 - Customer can be referenced in two ways:
 
  1. As an object (passing this object will also create/update the customer on PHC GO
  2. On the Document’s customerNumber field (referencing an existent Customer)