Manuais
PHC GO Create Purchase
 

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:

  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 Purchase



Request Options


 
Name Type PHC GO Entity PHC GO Field Observations
option1Integer0 – Send document by email

1 – Return document pdf link to print
requestedFieldsString ArrayThe PHC Go document 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”
emailBodyStringSend document by email with specific body
emailSubjectStringSend document by email with specific subject

 

Supplier2


 
Name Type PHC GO Entity PHC GO Field Observations
number2IntegerFlno
name2StringFlnome
address2StringFlmorada
postalCode2StringFlcodpost
city2StringFllocal
email2StringFlemail
taxNumber2StringFlncont
abbreviatedName2StringFlnome2

 

Document


 
Name Type PHC GO Entity PHC GO Field Observations
docType1Integercm1cmType of document to create
documentNumber1StringFoadocNumber of document to create
supplierNameStringFonome
supplierNumber2IntegerFono
invoicingAddress1StringFomorada
invoicingAddress2StringFomorada2
invoicingPostalCodeStringFocodpost
invoicingLocalityStringFolocal
documentDateStringFodataFormat: “1900-01-01 00:00:00Z”
financialDiscountDoubleFoefinvFinancial discount (not including tax)

IMPORTANT: When this value is set there is no need to set the financialDiscountInPercentage
financialDiscountInPercentageDoubleFofinPercentage of financial discount (not including tax)

IMPORTANT: When this value is set there is no need to set the financialDiscount
documentTimeStringFohoraFormat: “00:00:00”
dueDateStringFopdataFormat: “1900-01-01 00:00:00Z”
taxExemptionCodeStringFocodmotiseimp
supplierAbbreviatedNameStringFonome2
refintStringForefIntInternal reference

 

Products


 
Name Type PHC GO Entity PHC GO Field Observations
reference1StringFnrefProduct reference
designation1StringFndesign
unitPrice1DoubleFnepv/pvmoedaThe 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
discount1IntegerFndesconto
discount2IntegerFndesc2
discount3IntegerFndesc3Important: In order to see more than 2 discounts it is needed to change the “Number of discounts on purchase documents” parameter
discount4IntegerFndesc4Important: In order to see more than 2 discounts it is needed to change the “Number of discounts on purchase documents” parameter
discount5IntegerFndesc5Important: In order to see more than 2 discounts it is needed to change the “Number of discounts on purchase documents” parameter
discount6IntegerFndesc6Important: In order to see more than 2 discounts it is needed to change the “Number of discounts on purchase documents” parameter
quantity1IntegerFnqtt
taxIncludedBooleanFnivainclIndicates if the unit price includes tax
taxExemptionCodeStringFncodmotiseimp
taxPercentageIntegerPercentage of tax. Used with taxRegion to define the Fn tabiva field
taxRegionStringAccepts one of the following regions: ‘PT’, ‘PT-AC’, ‘PT-MA’. Used with taxPercentage to define the Fn tabiva field
warehouseIntegerFnarmazemNumber of the origin warehouse of the product

 


Footnotes


1 - Required

2 - Supplier can be referenced in two ways:
 
  1. On the Document’s supplierNumber field (referencing an existent Supplier)
  2. 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:
 
  1. Firstly we need to change the docType field from the Document request object to 2 (V/Fatura).

  2. 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
}
]

(…)