Table of Contents

Registering a new external invoice

You register external invoices if another system creates the documentation used for accounting. One example is a webshop that issues receipts to customers when they shop. Then you should register it as an external invoice, and supply the receipt to Fiken for accounting purposes.

At this point we have found the company we are using the API as, and we have found or created a customer as a Contact. That customer has the following URL: https://.../url-1. We will set this URL as the customer of the sale we are registering.

Exchange #1

Request
POST https://.../url-2
Accept: application/hal+json, application/vnd.error+json
Content-Type: application/hal+json

{
  "date": "2015-01-02",
  "identifier": "abc123",
  "kind": "EXTERNAL_INVOICE",
  "paymentDate": "2015-02-03",
  "paymentAccount": "1920:10001",
  "lines": [
    {
      "netPrice": 100,
      "vat": 25,
      "vatType": "HIGH",
      "description": "Description"
    }
  ],
  "customer": "https://.../url-1"
}
Response
201 Created
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Length: ...
Date: ...
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Location: https://.../url-3
X-Request-ID: <random UUID>

Exchange #2

Request
GET https://.../url-3
Accept: application/hal+json, application/vnd.error+json
Response
200 OK
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Length: ...
Content-Type: application/hal+json;charset=UTF-8
Date: ...
Expires: Thu, 01 Jan 1970 00:00:00 GMT
X-Request-ID: <random UUID>

{
  "_links": {
    "self": {
      "href": "https://.../url-3"
    },
    "https://fiken.no/api/v1/rel/payments": {
      "href": "https://.../url-4"
    },
    "https://fiken.no/api/v1/rel/attachments": {
      "href": "https://.../url-5"
    },
    "alternate": {
      "href": "https://.../url-6",
      "type": "text/html"
    }
  },
  "_embedded": {
    "https://fiken.no/api/v1/rel/payments": [
      {
        "_links": {
          "self": {
            "href": "https://.../url-7"
          }
        },
        "amount": 125,
        "account": "1920:10001"
      }
    ]
  },
  "date": "2015-01-02",
  "kind": "EXTERNAL_INVOICE",
  "identifier": "abc123",
  "paid": true,
  "lines": [
    {
      "description": "Description",
      "netPrice": 100,
      "vat": 25,
      "account": "3000",
      "vatType": "HIGH"
    }
  ],
  "customer": "https://.../url-1"
}

And our new sale got https://.../url-3 as its new URL