Purchase Invoice POST

URI

https://{DATACENTER}.brightpearl.com/public-api/{ACCOUNT}
/accounting-service/invoice/purchase-invoice/

Refer to our documentation on URI syntax for more information on how to construct URIs.

Description

Transforms the sent Purchase Invoice resource into the corresponding journal lines. This endpoint uses specific logic to validate the invoice representation, but then delegates to the journal entry logic to validate and create the lines in the database. Note that creating the PI journal does not connect the order with that invoice transaction - the order will not be marked as invoiced. This would only happen if Purchase Order Close POST is used.

Purchase Invoice POST Validation

Mandatory elements are the header, the invoice identifier inside the header, and at least one line

The fields that are mandatory are:

  • contactId
  • invoiceRef
  • taxDate
  • currencyId
  • exchangeRate (not mandatory for base currency)
  • Each line must have a net amount and a tax amount (values of the transaction in the currency stated), a tax code and a nominal code

Other validations are:

  • The order id must be in the system
  • The order must be of type purchase Order and belong to the customer
  • The contact must be of type supplier
  • Nominal code can neither be Debtors Control Account ("1100", accounts receivable) nor Creditors Control Account ("2100", accounts payable)

The journal-entry POST is then validating additional accounting rules, if applicable.

Currency Conversions:

If PI is in foreign currency and previous journals are in base currency/multi currency feature toggle is off, we convert the PI values to base currency using the specified exchange rate and create the PI in base currency.

Prepayments and invoice clearing

If the posted PI has an order id the system searches for eventual prepayments for the same order id. If it finds any such prepayments it will update them with the invoice reference generated for the posted PI. If the prepayments value is enough to clear the invoice the invoice clearing (and eventual exchange variance calculation) is triggered. For further information please refer to the paragraph "invoice clearing" of the Purchase Payment POST.

Example

Creating a purchase invoice journal for supplier 203 with three lines, first and last refer to order id 8, the second line has no order id reference. Returns the journal id if successful. (Note that creating the PI journal does not yet connect the order with that invoice transaction - the order will not be marked as invoiced.)

Request URI

/invoice/purchase-invoice/

Request body

{
	"header": {
		"invoiceIdentifier": {
			"invoiceRef": "invoice-reference",
			"contactId": 203
		},
		"taxDate": "2015-10-12",
		"dueDate": "2015-10-12",
		"description": "a purchase invoice description",
		"currencyId": 1,
		"exchangeRate": 1
	},
	"lines": [
		{
			"net": 10,
			"tax": 2,
			"nominalCode": "5000",
			"taxClassId": 8,
			"orderId": 2,
			"projectId": 1,
			"leadSourceId": 1,
			"channelId": 1
		},
		{
			"net": 5,
			"tax": 0,
			"nominalCode": "5005",
			"taxClassId": 1,
			"projectId": 1,
			"leadSourceId": 1,
			"channelId": 1
		}
	]
}

Response

{
	"response": 20
}