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:
{
"supplier": {
"name": "Embaixada",
"address": "Keller,",
"postalCode": "1400-197",
"city": "Lisboa",
"country": "Portugal",
"email": "test@gmail.com",
"taxNumber": "123456789"
},
"requestOptions": {
"option": 1,
"requestedFields": [
"adoc",
"fostamp",
"etotal",
"ettiva"
]
},
"document": {
"docType": 2,
"documentNumber" : "0002"
},
"products": [
{
"reference": "SRV001",
"designation": "Upgrade/Downgrade:test",
"unitPrice": 20.19,
"quantity": 1
}
]
}
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 Purchase
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 |
requestedFields | String Array | – | – | The PHC Go document 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” |
emailBody | String | – | – | Send document by email with specific body |
emailSubject | String | – | – | Send document by email with specific subject |
Supplier2
Name |
Type |
PHC GO Entity |
PHC GO Field |
Observations |
number2 | Integer | Fl | no | |
name2 | String | Fl | nome | |
address2 | String | Fl | morada | |
postalCode2 | String | Fl | codpost | |
city2 | String | Fl | local | |
email2 | String | Fl | email | |
taxNumber2 | String | Fl | ncont | |
abbreviatedName2 | String | Fl | nome2 | |
Document
Name |
Type |
PHC GO Entity |
PHC GO Field |
Observations |
docType1 | Integer | cm1 | cm | Type of document to create |
documentNumber1 | String | Fo | adoc | Number of document to create |
supplierName | String | Fo | nome | |
supplierNumber2 | Integer | Fo | no | |
invoicingAddress1 | String | Fo | morada | |
invoicingAddress2 | String | Fo | morada2 | |
invoicingPostalCode | String | Fo | codpost | |
invoicingLocality | String | Fo | local | |
documentDate | String | Fo | data | Format: “1900-01-01 00:00:00Z” |
financialDiscount | Double | Fo | efinv | Financial discount (not including tax)
IMPORTANT: When this value is set there is no need to set the financialDiscountInPercentage |
financialDiscountInPercentage | Double | Fo | fin | Percentage of financial discount (not including tax)
IMPORTANT: When this value is set there is no need to set the financialDiscount |
documentTime | String | Fo | hora | Format: “00:00:00” |
dueDate | String | Fo | pdata | Format: “1900-01-01 00:00:00Z” |
taxExemptionCode | String | Fo | codmotiseimp | |
supplierAbbreviatedName | String | Fo | nome2 | |
refint | String | Fo | refInt | Internal reference |
Products
Name |
Type |
PHC GO Entity |
PHC GO Field |
Observations |
reference1 | String | Fn | ref | Product reference |
designation1 | String | Fn | design | |
unitPrice1 | Double | Fn | epv/pvmoeda | The unit price of the product.
By default the unitPrice is in Euros
The unitPrice will be set in the currency provided through the Document object Currency field |
discount1 | Integer | Fn | desconto | |
discount2 | Integer | Fn | desc2 | |
discount3 | Integer | Fn | desc3 | Important: In order to see more than 2 discounts it is needed to change the “Number of discounts on purchase documents” parameter |
discount4 | Integer | Fn | desc4 | Important: In order to see more than 2 discounts it is needed to change the “Number of discounts on purchase documents” parameter |
discount5 | Integer | Fn | desc5 | Important: In order to see more than 2 discounts it is needed to change the “Number of discounts on purchase documents” parameter |
discount6 | Integer | Fn | desc6 | Important: In order to see more than 2 discounts it is needed to change the “Number of discounts on purchase documents” parameter |
quantity1 | Integer | Fn | qtt | |
taxIncluded | Boolean | Fn | ivaincl | Indicates if the unit price includes tax |
taxExemptionCode | String | Fn | codmotiseimp | |
taxPercentage | Integer | – | – | Percentage of tax. Used with taxRegion to define the Fn tabiva field |
taxRegion | String | – | – | Accepts one of the following regions: ‘PT’, ‘PT-AC’, ‘PT-MA’. Used with taxPercentage to define the Fn tabiva field |
warehouse | Integer | Fn | armazem | Number of the origin warehouse of the product |
Footnotes
1 - Required
2 - Supplier can be referenced in two ways:
- On the Document’s supplierNumber field (referencing an existent Supplier)
- As an object (passing this object will also create/update the supplier on PHC Go)
Examples
Creating a Purchase
The JSON structure for creating a new purchase:
- Firstly we need to change the docType field from the Document request object to 2 (V/Fatura).
- On Product we only have to pass the following fields:
- reference (required) – Product reference
- quantity(optional) – Product Quantity
- designation(optional) – Product designation
- unitPrice(optional) – Product price
Note: You can find the document type values by going to Company Settings page and selecting Account receivable /payable transaction codes.
(…)
"document": {
"docType": 2,
"documentNumber": "002",
"supplierNumber": "19",
"issuingAddress1": "Invoice Address 1",
"issuingPostalCode": "2010-152",
"issuingLocality": "Purchase Locality",
"dueDate": "2020-01-27 00:00:00Z"
},
"products": [
{
"reference": "C003",
"designation": "A product",
"quantity": 2,
"unitPrice" : 20.19
}
]
(…)