My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Implementasjonsguide  

SendRegning Web Services implementation guide

Table of content

The following functionality is exposed via SWS:

Sending

  • Send n invoices/credit notes on paper/e-mail.
  • Send dunning with/without dunning fee/interest.

Queries

Examples

See our website for examples: http://www.sendregning.no/integrasjon/api.html

Overview of changes in the implementation guide

November 1, 2011

  • Added documentation describing the new batchId attribute on the <invoices> element to prevent double submit.
  • Added a section about client timeout

May 9, 2011

  • Translated this guide to English

September 20, 2010

March 10, 2009

  • Removed sample code from the implementation guide, since we have created a source code file with Google Code
  • Moved the implementation guide to Google Code
  • Wrote a PHP client that is available from Google Code

January 14, 2009

  • Removed <finalPayment> element from the response you get after you have sent invoice(s). This can be retrieved using SELECT -> INVOICE-STATUS

November 2, 2007

  • Added <eventParams> element under the <invoice-status><invoice><history><entry> element.

August 28, 2008

  • Added more information about the <recipientNo> element.

May 3, 2007

  • Added description of query of invoice status.
  • Updated code samples under programming tips
  • Described the procedure for reporting errors
  • Described the procedure for reporting requests for new featureRequest functionality

April 30, 2007

  • Updated the description of XML in requests and responses.

April 25, 2007

  • Updated the description of sending dunnings.

April 20, 2007

  • Described sending of dunnings.

April 11, 2007

  • Described the response when calling constants.

March 29, 2007

  • Specified image size when retrieving JPG.

March 28, 2007

  • Added HTTP response code 204
  • Removed the condition draft from possible conditions. The reason for this is that it is not possible to save invoices as drafts via SWS.

March 26, 2007

  • Changed the element description for the <email> element under the <optional> element.

March 12, 2007

  • Added the <shipment> element under the <invoice> element.

Technical

Login

SendRegning Web Services supports BASIC authentication, so you add a user name and password in the query. Since there is forced https for SWS, all traffic is encrypted between your client and server.

HTTP commands

HTTP command matrix

url action type xml HTTP method
https://www.sendregning.no/ws/butler.do send invoice
dunning
XML-file POST
https://www.sendregning.no/ws/butler.do select invoice
invoice-status
recipient
product
XML-file POST
https://www.sendregning.no/ws/butler.do select constant - GET
https://www.sendregning.no/ws/butler.do insert recipient
product
XML-file POST
https://www.sendregning.no/ws/butler.do update invoice
recipient
product
XML-file POST
https://www.sendregning.no/ws/butler.do delete recipient
product
XML-file POST

A valid HTTP command may therefore look like this: https://www.sendregning.no/ws/butler.do?action=select&type=constant

- to get all constants back in xml format.

Explanation for HTTP parameters

action

This parameter must ALWAYS be specified.

  • send
    • Sends n instances of chosen type.
  • select
    • Returns n instances of chosen type.
  • insert
    • Creates n instances of chosen type.
  • update
    • Updates n instances of chosen type.
  • delete
    • Deletes one instance of chosen type.

type

This parameter must ALWAYS be specified.

  • invoice
    • Invoice
  • dunning
    • Dunning
  • invoice-status
    • Invoice status - payments, state, dunnings, etc..
  • recipient
    • Recipient
  • product
    • Product
  • constant
    • Constants - (VAT rates, default interest, dunning fee, etc.)

test

  • true
    • If test=true, the server will respond by validating the HTTP command and returning real test data and response codes.
    • This parameter is only used during the implementation phase and testing, when you go into production, you cannot send test=false for each HTTP command.

HTTP response codes

SWS returns the following response codes on an HTTP command:

  • 200 Ok
    • The HTTP command was performed. The server will also return the result of the processing, usually in XML.
  • 204 No response
    • The HTTP command was performed, but there was no return data. May occur, for example, when you run a query that does not contain any return data.
  • 400 Invalid HTTP command
    • The HTTP parameters are incomplete and/or not in accordance with the HTTP command matrix. You can usually easily find out what the problem is by reading the error message that follows the response.
  • 409 Conflict
    • Conflict - The provided batchId on the <invoices> element has already been processed. Used for preventing double HTTP POST requests.
  • 500 Internal error
    • The server failed unexpectedly and the HTTP command was interrupted (not conducted).
  • 501 Not implemented
    • The HTTP command is not implemented on the server side.

You can read more about it here HTTP respons codes.

HTTP response types (Content Type)

SWS returns the following response content types:

  • text/html
    • A response that returns text/html has failed, and a human must interpret the error message that follows.
  • text/xml
    • The response contains XML.
  • application/json
    • The response contains JSON.
  • application/pdf
    • The response contains a PDF document.
  • image/jpeg
    • The response contains an JPG image.

XML

When you are going to send out invoices via SWS, you send us a XML document over HTTPS, when you are sending us an HTTP command about account-related data, you get XML back that your client program must interpret correctly.

PLEASE READ VERY CAREFULLY!

There is NO official or unofficial DTD that you can use to validate a XML document that you receive from SWS. The reason for this is that we have designed our XML documents in such a way that changes in the XML documents do not require changes in the SWS clients, i.e. your data program. This is a great help to both you and us.
We reserve the right to add new elements and attributes to all XML, independent of the delivery time and without notice. However, we will NOT remove existing elements or attributes without notice. There is no guarantee that all elements or attributes are present for all XML formats that SWS returns. When information is delivered in XML format, there is no guarantee that XML elements of the same level are always returned in the same order, the order may even be different for two equal HTTP commands. This is not unique to our service. This is because the XML format does not set requirements for the properties mentioned, the same thing basically applies to Web Services in all programming languages.
Please be aware of this, and do NOT perform strict validation on received XML. Do not expect elements or attributes to come in a particular order, always check the contents of these. All elements have a label that tells what kind of information it contains. If you come across an unknown element/attribute in an XML file, you must ignore this in your data program.
We take no responsibility for external systems that crash, freeze up, or fail because we added a new XML element and/or attribute, or have changed the order of these.

XML in in requests and responses

All xml that SWS returns will be UTF-8: <?xml version="1.0" encoding="UTF-8"?>

All xml that is sent in to SWS will be interpreted in UTF-8

The maximum file size for transfer of xml files to SWS is set to 2MB (2097152 bytes)

Actions

Send invoices

In order to send n number of invoices via SWS, the XML document may look like this:

<?xml version="1.0" encoding="UTF-8"?>
<invoices batchId="yourUniqueBatchId>
    <invoice>
        <name>Ola Nordmann</name>
        <zip>0010</zip>
        <city>OSLO</city>
        <lines>
            <line>
                <itemNo>1</itemNo>
                <qty>100.00</qty>
                <prodCode>1</prodCode>
                <desc>Description</desc>
                <unitPrice>100.00</unitPrice>
                <discount>0.00</discount>
                <tax>25</tax>
            <line>
        <lines>
        <optional>
            <orderNo>Order number</orderNo>
            <invoiceDate>29.11.06</invoiceDate>
            <dueDate>13.12.06</dueDate>
            <orderDate>29.11.06</orderDate>
            <recipientNo>10</recipientNo>
            <address1>Drammensveien 1</address1>
            <country>NORGE</country>
            <email>ola@nordmann.no</email>
            <ourRef>Our reference</ourRef>
            <yourRef>Your reference</yourRef>
            <comment>Comment</comment>
            <invoiceText>Invoice Text</invoiceText>
        </optional>
    </invoice>
    <invoice>
        <name>Kari Nordmann</name>
        <zip>0010</zip>
        <city>OSLO</city>
        <lines>
            <line>
                <itemNo>1</itemNo>
                <qty>100.00</qty>
                <prodCode>1</prodCode>
                <desc>Description</desc>
                <unitPrice>100.00</unitPrice>
                <discount>0.00</discount>
                <tax>25</tax>
            <line>
        <lines>
        <optional>
            <orderNo>Order number</orderNo>
            <invoiceDate>29.11.06</invoiceDate>
            <dueDate>13.12.06</dueDate>
            <orderDate>29.11.06</orderDate>
            <recipientNo>10</recipientNo>
            <address1>Drammensveien 1</address1>
            <country>NORGE</country>
            <email>kari@nordmann.no</email>
            <ourRef>Our reference</ourRef>
            <yourRef>Your reference</yourRef>
            <comment>Comment</comment>
            <invoiceText>Invoice Text</invoiceText>
        </optional>
    </invoice>
</invoices>

batchId

To prevent double submits from the client, the client must provide us with an unique batchId when sending invoices. This is an attribute on the <invoices> element, e.g. <invoices batchId="yourUniqueBatchId">

It is crucial that your unique batch id is created once before doing the HTTP request, so you don't retry with another batchId if the client fails after the HTTP POST request.

The provided batchId will be present in the xml response.

If the given batchId has already been processed, SWS will return HTTP status code 409 - conflict.

Description of the various XML elements when you are sending invoices via SWS

  • <invoices batchId="yourUniqueBatchId>
  • <invoice>
  • <lines>
  • <line>
  • <optional>
  • <shipment>

Element name The element's parent Element description Data type Standard value
<invoices batchId="yourUniqueBatchId">
<invoices batchId="yourUniqueBatchId"> - Root element
This is the root element that contains all the <invoice> elements. All other element children will be ignored.

attribute
<invoices> elements CAN have ONE, and only ONE, attribute: batchId
This value must be an unique id created by the client and is used on the server side to check whether or not this is used before. This to prevent double submit from the client.

Example <invoices batchId="yourUniqueBatchIdThatCanBe256LettersAndCharactersLong">
batchId - Text - Maximum 256 characters -
<invoice>
<invoice> <invoices> Main element
This specifies an invoice, you can have n number of<invoice> elements as children of the <invoices> element in an XML document.
Note that the <invoice> element is the only child of the <invoices> element, all other elements will be ignored.

attribute
<invoice> elements CAN have ONE, and only ONE, attribute: clientId
This value can be set by the client and will in that case be present in the response such that the client can distinguish between the various <invoice> elements when interpreting the response in order to get the invoice numbers of the various invoices received when transferring.
Example: <invoice clientId="00100">

NOTE: If this attribute is omitted, the response will not contain this attribute.
clientId - Text -
<name> <invoice> Invoice recipient's name Text - maximum 42 characters -
<zip> <invoice> Invoice recipient's zip code Text - maximum 8 characters -
<city> <invoice> Invoice recipient's city Text - maximum 36 characters -
<lines>
<lines> <invoice> Contains all the <line> elements for the current <invoice> element - -
<line>
<line> <lines> Contains all the line elements an invoice line consists of. This can be a maximum of 18 <line> elements for each <invoice> element. - -
<itemNo> <line> Line number
The first line has the number 1, the last line has the number 18. This is simply the line's placement on the invoice. If this is omitted, the lines will be in the order that they appear in the XML document. Either all are set, or none are set. You will get an error code in return if this is not met.
Unique Intergers - must be >= 1 and <= 18 1 --> 18
<qty> <line> Quantity
An invoice line consists of number, product code, description, discount, VAT, and unit price.

F.eks:
Quantity Product code Description Discount VAT Unit price
7.5 kt Consulting services 10 25 250.00

Quantity is used together with the unit price to find the line total, which means that (quantity * unit price) - discount + VAT is equal to the line total, which in this case is 2109.38.

NOTE: If this value is omitted, the unit price is multiplied by 0.
Decimal - maximum 6 characters, including punctuation marks and signs -
<prodCode> <line> Product code
Used to distinguish between the various products that are invoiced, this means that you can run reports in the meantime that tell how much you have invoiced of a given product. A product will be created in the product list when specifying a product code. If it already exists a product with this product code, the product will NOT be updated.
Text - maximum 9 characters null
<desc> <line> Description
Here you can describe the service/goods you are invoicing. This element can also be used for extra information that there isn't space for elsewhere. If this is the only element in a line that contains data, only this text will be printed out on the line.
Text - maximum 75 characters null
<unitPrice> <line> Unit price
See <qty> (quantity) for further explanation.
Decimal - maximum 9 characters, including punctuation marks and signs -
<discount> <line> Discount
If this element is omitted, the line rebate is not set at all. In order to specify a 0% discount, this element must be set to 0. A valid value for this element is a decimal number from 0 to 100. Note that the % sign must NOT be included and will generate an error message. See <qty> (quantity) for further explanation.
Decimal - maximum 5 characters, including punctuation marks. Must be >= 0 or >= 100 null
<tax> <line> VAT rate
If this is omitted, then the current VAT rate will be used, which is 25% as of today's date (9.05.11). This rate can be changed by the authorities and will be automatically updated by SendRegning.no. See <qty> (quantity) for further explanation.
Integer - maximum 2 figures. Valid values as of 9.05.11 are: 0, 8, 13 and 25. 25
<optional>
<optional> <invoice> Contains elements that are optional. - -
<invoiceType> <optional> Invoice type
This element defines whether the invoice is a normal invoice, or if it is a credit note. If this element is omitted, ordinary is used as a standard value. Possible values for this element are: ordinary or credit

NOTE: If this element is set to credit the element creditedId MUST also be set.
Text - ordinary or credit ordinary
<creditedId> <optional> Invoice number to be credited
This element MUST be set when the invoiceType element is set to credit
Integers - valid invoice number null
<orderNo> <optional> Order number
Text field on the invoice that specifies the originator's order number
Text - maximum 30 characters null
<invoiceDate> <optional> Invoice date
If this element is omitted, today's date will be used.
Date - dd.mm.yy Today's date
<dueDate> <optional> Due date
If this element is omitted, today's date + 14 days will be used.
Date - dd.mm.yy Today's date + 14 days
<orderDate> <optional> Order date
Specifies when the order took place. Usually the same date as the invoice date, but then it is common to omit this element.
Date - dd.mm.yy null
<recipientNo> <optional> Recipient number
The recipient's client number.

Note: This field must be present in order for SendRegning.no to be able to link the invoice to an existing recipient.
If the recipient number is not specified, a new recipient is created in SendRegning.no, even if there is one with the same name. This also reduces the usefullness of the balance list function that is built in to SendRegning.no, because the invoices will be connected to different recipients.
Text - maximum 32 characters null
<address1> <optional> The recipient's address (first line)

Ola Nordmann
address line (first line)
address line (second line)
0010 OSLO
NORGE
Text - maximum 42 characters null
<address2> <optional> The recipient's address (second line)

Ola Nordmann
address line (first line)
address line (second line)
0010 OSLO
NORGE
Text - maximum 42 characters null
<country> <optional> Recipient's country
If this element is omitted, NORGE will be used.
Text - maximum 42 characters NORGE
<email> <optional> Recipient's e-mail address
This e-mail address will be validated upon receipt to determine if the e-mail address is syntactically correct. The first time you send e-mail to a new recipient, SendRegning.no will create a recipient in the client list, the value in this element will be used as the e-mail address for the recipient, together with <name>, <address1>, <address2>, <zip>, <city> and <country>

NOTE: This e-mail address will not be the e-mail address used when sending the invoice, that is defined in the <shipment> element.
Text - maximum 64 characters null
<ourRef> <optional> Our reference
Originator's reference.
text Text - maximum 30 characters null
<yourRef> <optional> Your reference
Recipient's reference.
Text - maximum 30 characters null
<comment> <optional> Comments
This text will not be printed out on the invoice itself, can be used as needed. This text is also not shown in the GUI.
text Text - maximum 254 characters null
<invoiceText> <optional> Invoice text
This is a line that will be printed out on the invoice right over the invoice lines. If this is omitted, and permanent invoice text is set on the account, that text will be used.
Text - maximum 105 characters Permanent invoice text, otherwise null
<printDunningInfo> <optional> Interest and dunning information on the invoice
This specifies whether two lines of interest and dunning information will be printed out on the invoice right over the invoice lines. In order to be able to send a dunning with demand for interest and dunning fee, the law requires that this information is printed on the original invoice.

Ved for sen betaling beregnes 10% forsinkelsesrente pr. år.
Ved betalingspåminnelse påløper gebyr kr. 59.

These rates (10% and NOK 59) are determined twice a year by the authorities and automatically updated by SendRegning.no

If this element is set with the value false, 0 or off, interest and dunning information is NOT printed on the invoice.
Boolean value true
<itemTaxInclude> <optional> VAT calculation per line
This specifies whether the line total will include the VAT amount or not. If this element is set to the value false, 0 or off, the VAT amount is NOT included in the line total.

For example: <itemTaxInclude>true</itemTaxInclude>
Quantity Product code Description Discount VAT Unit price Calculated line total
1 Hours 25 100.00 125.00

<itemTaxInclude>false</itemTaxInclude>
Quantity Product code Description Discount VAT Unit price Calculated line total
1 Hours 25 100.00 100.00

NOTE: This has nothing to do with the total sum of the invoice, the total sum of the invoice will always include the VAT amount.
Boolean value true
<shipment>
<shipment> <invoice> Delivery method
You can specify a <shipment> element for each <invoice> element. The following values can be specified:
PAPER, EMAIL, PAPER_AND_EMAIL

If the <shipment> element is omitted, the invoice is printed out on paper.

NOTE: If you specify EMAIL or PAPER_AND_EMAIL, you must specify the e-mail addresses using the emailaddresses element.
Text PAPER
<emailaddresses> <shipment> E-mail addresses
Contains one or more email elements.
- -
<email> <emailaddresses> E-mail address
Contains e-mail address for recipient of invoice
Text -
<copyaddresses> <shipment> E-mail addresses (copy)
Contains one or more email elements.
- -
<email> <copyaddresses> E-mail address (copy)
Contains e-mail address for recipient of invoice copy
Text -

Example of absolutely the smallest XML document that can be transferred for sending out an invoice on paper

In this case, an invoice will be printed out on paper and sent to Ola Nordmann, where most of the standard values are used.

<?xml version="1.0" encoding="UTF-8"?>
<invoices batchId="yourUniqueBatchId>
    <invoice>
        <name>Ola Nordmann</name>
        <zip>0010</zip>
        <city>OSLO</city>
        <lines>
            <line>
                <qty>1</qty>
                <desc>Description</desc>
                <unitPrice>100.00</unitPrice>
            </line>
        </lines>
    </invoice>
</invoices>

Example of absolutely the smallest XML document that can be transferred for sending out an invoice through e-mail

In this case, an invoice will be sent through e-mail to ola@nordmann.no, with a copy to kari@nordmann.no, where most of the standard values are used.

<?xml version="1.0" encoding="UTF-8"?>
<invoices batchId="yourUniqueBatchId>
    <invoice>
        <name>Ola Nordmann</name>
        <zip>0010</zip>
        <city>OSLO</city>
        <lines>
            <line>
                <qty>1</qty>
                <desc>Description</desc>
                <unitPrice>100.00</unitPrice>
            </line>
        </lines>
	<shipment>
		EMAIL
		<emailaddresses>
			<email>ola@nordmann.no</email>
		</emailaddresses>
		<copyaddresses>
			<email>kari@nordmann.no</email>
		</copyaddresses>
	</shipment>
    </invoice>
</invoices>

Response

When you retrieve one or more invoices from SWS, you may get the following XML back as a response:

<?xml version="1.0" encoding="UTF-8"?>
<invoices batchId="yourUniqueBatchId>
    <invoice>
        <name>Ola Nordmann</name>
        <zip>0010</zip>
        <city>OSLO</city>
        <lines>
            <line>
                <itemNo>1</itemNo>
                <qty>100.00</qty>
                <prodCode>1</prodCode>
                <desc>Description</desc>
                <unitPrice>100.00</unitPrice>
                <discount>0.00</discount>
                <tax>25</tax>
                <lineTaxAmount>2500.00</lineTaxAmount>
                <lineTotal>12500.00</lineTotal>
            </line>
        </lines>
        <optional>
            <invoiceType>ordinary</invoiceType>
            <invoiceNo>82</invoiceNo>
            <orderNo>Order number</orderNo>
            <invoiceDate>29.11.06</invoiceDate>
            <dueDate>13.12.06</dueDate>
            <orderDate>29.11.06</orderDate>
            <state>sent</state>
            <recipientNo>10</recipientNo>
            <address1>Drammensveien 1</address1>
            <country>NORGE</country>
            <email>ola@nordmann.no</email>
            <ourRef>Our reference</ourRef>
            <yourRef>Your reference</yourRef>
            <tax>2500.00</tax>
            <total>12500.00</total>
            <comment>Comments</comment>
            <invoiceText>Invoice Text</invoiceText>
            <orgNrSuffix>false</orgNrSuffix>
            <accountNo>16071990021</accountNo>
            <orgNo>980489698</orgNo>
            <dunningFee>55.00</dunningFee>
            <interestRate>9.75</interestRate>
        </optional>
    </invoice>
    <invoice>
        <name>Kari Nordmann</name>
        <zip>0010</zip>
        <city>OSLO</city>
        <lines>
            <line>
                <itemNo>1</itemNo>
                <qty>100.00</qty>
                <prodCode>1</prodCode>
                <desc>Description</desc>
                <unitPrice>100.00</unitPrice>
                <discount>0.00</discount>
                <tax>25</tax>
                <lineTaxAmount>2500.00</lineTaxAmount>
                <lineTotal>12500.00</lineTotal>
            </line>
        </lines>
        <optional>
            <invoiceType>ordinary</invoiceType>
            <invoiceNo>83</invoiceNo>
            <orderNo>Order number</orderNo>
            <invoiceDate>29.11.06</invoiceDate>
            <dueDate>13.12.06</dueDate>
            <orderDate>29.11.06</orderDate>
            <state>sent</state>
            <recipientNo>10</recipientNo>
            <address1>Drammensveien 1</address1>
            <country>NORGE</country>
            <email>kari@nordmann.no</email>
            <ourRef>Our reference</ourRef>
            <yourRef>Your reference</yourRef>
            <tax>2500.00</tax>
            <total>12500.00</total>
            <comment>Comments</comment>
            <invoiceText>Invoice Text</invoiceText>
            <orgNrSuffix>false</orgNrSuffix>
            <accountNo>16071990021</accountNo>
            <orgNo>980489698</orgNo>
            <dunningFee>55.00</dunningFee>
            <interestRate>9.75</interestRate>
        </optional>
    </invoice>
</invoices>

Description of the various XML elements in a response from SWS when you have sent out invoices

These elements may come as additional elements in the response from the server after you have sent invoice(s).

NOTE: These elements are only readable for the client, which means that they will be ignored when transferring XML from client to server.

Element name The element's parent Element description Data type Standard value
<state> <optional> The invoice's state
An invoice can have the following states:

sent - The invoice is sent to the recipient.
dueSr - The invoice is overdue, reminder letter to originator is not sent.
dueDecide - The invoice is overdue, demands an action from the originator.
dunnedNotDue - The invoice has been dunned, but the dunning is not overdue.
collectionDue - The invoice has been sent out as debt collection notice and is overdue.
collection - The invoice has been sent to a collection agency.
lost - The invoice is marked as lost.
paid - The invoice is marked as paid. Note that an invoice that has received a partial payment will remain in the state it was in before the partial payment.
Text - maximum 20 characters -
<kid> <optional> The invoice's generated KID number
This element is omitted in the response from SWS if the KID number is not generated for this invoice. In order for SendRegning.no to automatically generate KID numbers on the invoices, the originator must sign an eGiro Payment Agreement with their bank. You can find more information at her.
Integer -
<tax> <optional> The invoice's VAT amount
This element will show the invoice's total VAT amount.
Decimal -
<total> <optional> The invoice's total amount
This element will show the invoice's total amount.
Decimal -
<accountNo> <optional> The originator's account number
This element shows the originator's account number.
Integer -
<orgNo> <optional> The originator's organization number
This element shows the originator's organization number.
Integer -
<dunningFee> <optional> Dunning fee value
In order to be able to demand a dunning fee when dunning, it is legally required to disclose this in the original invoice. This element contains the value of the dunning fee that was printed out on the invoice. See the element <printDunningInfo> for more information.
Decimal -
<interestRate> <optional> Interest rate
In order to be able to demand interest when dunning, it is legally required to disclose this in the original invoice. This element contains the value of the interest that was printed out on the invoice. See the element <printDunningInfo> for more information.
Decimal -
<invoiceNo> <optional> Invoice number
The invoice's generated invoice number. This is a serial number that SendRegning.no increases by one for each transfer.

NOTE: It is not possible to set this manually.
Text -
<orgNrSuffix> <optional> Prints the word "MVA" after the organization number
This element is only added when the value is false.
Boolean value -
<dunningType> <optional> Dunning number
This element shows the dunning number for the invoice.

1Dunning - 1st DUNNING
2Dunning - 2nd DUNNING
3Dunning - 3rd DUNNING
4Dunning - 4th DUNNING
5Dunning - 5th DUNNING
6Dunning - 6th DUNNING
7Dunning - 7th DUNNING
8Dunning - 8th DUNNING
9Dunning - 9th DUNNING
deptCollectionNotice - DEBT COLLECTION NOTICE
Text -
<lineTaxAmount> <line> VAT amount for invoice line
This element will show the invoice line's VAT amount.
Decimal -
<lineTotal> <line> Amount for invoice line
This element will show the invoice line's amount.
Decimal -

Queries - (Invoice)

In order to run a query on registered invoices, you post an XML file to SWS that interprets the query and returns the result in XML/JSON.

Description of the various XML elements when you are running a query on registered invoices

Element name The element's parents Element description Data type Standard value
<select> - Root element
This is the root element that contains the query. This element may contain the following text.

ALL - Select all invoices
FIRST _n_ - Selects the first n invoices
LAST _n_ - Selects the last n invoices.

If n is omitted then it is the same as 1.
Text - maximum 10 characters. -
<invoiceNumbers> <select> Invoice numbers
The <invoiceNumbers> element may contain n <invoiceNumber> elements.

NOTE: You can not use the <invoiceNumbers> element together with ALL, FIRST and LAST.
- -
<invoiceNumber> <invoiceNumbers> Invoice number
Contains an invoice number to be included in the query.
Integer -
<format> <select> Format
Specifies the format in which you want to receive the invoice(s) in the query.

XML
PDF
JPG

NOTE: When <format> is set to JPG you can only ask for one invoice.

NOTE: If you get a JPG, then the image size is 833x1179 pixels (width/height).
Text - maximum 3 characters XML
<dunningType> <select> Dunning number
Selects dunning with the following dunning number.

NOTE: Only works together with the <invoiceNumber>element
Text - maximum 20 characters. 1Dunning
<where> <select> Element for narrowing the query
Contains elements that narrow the query. As of today, there is support for these restrictions: <recipientNumbers> <states>
- -
<recipientNumbers> <where> Recipient numbers
The <recipientNumbers> element may contain n <recipientNumber> elements. Only works together with ALL, FIRST and LAST.
- -
<recipientNumber> <recipientNumbers> Recipient number
Contains a recipient number that narrows the query. Duplicate elements will be ignored
Text - maximum 32 characters -
<states> <where> States
The <states> element may contain n <state> elements. Only works together with ALL, FIRST and LAST.
- -
<state> <states> State
Contains a state that narrows the query. Duplicate elements will be ignored
Text - maximum 20 characters -

Matrix for queries (invoices)

<select> ALL FIRST _n_ LAST _n_ N/A N/A
<invoiceNumbers>
<invoiceNumber>Integer</invoiceNumber> N/A N/A N/A x n
</invoiceNumbers>
<format>Text<format> XML/PDF XML/PDF XML/PDF XML/PDF/JPG XML/PDF
<dunningType> N/A N/A N/A x N/A
<where>
<recipientNumbers>
<recipientNumber>Text</recipientNumber> n n n N/A N/A
</recipientNumbers>
<states>
<state>Text<state> n n n N/A N/A
</states>
<where>
</select>

x = one instance n = multiple instances

Examples of queries (invoice)

Get all paid invoices:

<?xml version="1.0" encoding="UTF-8"?>
<select>
    ALL
    <where>
        <states>
            <state>paid</state>
        </states>
    </where>
</select>

Get the last 10 invoices sent to recipient with recipient number 1

<?xml version="1.0" encoding="UTF-8"?>
<select>
    LAST 10
    <where>
        <recipientNumbers>
            <recipientNumber>1</recipientNumber>
        </recipientNumbers>
    </where>
</select>

Get invoice numbers 1, 2, and 5 in a PDF file

<?xml version="1.0" encoding="UTF-8"?>
<select>
    <invoiceNumbers>
        <invoiceNumber>1</invoiceNumber>
        <invoiceNumber>2</invoiceNumber>
        <invoiceNumber>5</invoiceNumber>
    </invoiceNumbers>
    <format>pdf</format>
</select>

Get 1st dunning for invoice number 1 as JPG

<?xml version="1.0" encoding="UTF-8"?>
<select>
    <invoiceNumbers>
        <invoiceNumber>1</invoiceNumber>
    </invoiceNumbers>
    <format>jpg</format>
    <dunningType>1Dunning</dunningType>
</select>

Queries - (Invoice status)

In order to run a query on invoice status, you post an XML file to SWS that interprets the query and returns the result in XML.

Description of the various XML elements when you are running a query on invoice status

Element name The element's parents Element description Data type Standard value
<select-status> - Root element
This is the root element that contains the query. This element may contain the following text.

ALL - Select all invoices
FIRST _n_ - Selects the first n invoices
LAST _n_ - Selects the last n invoices.

If n is omitted then it is the same as 1.
Text - maximum 10 characters. -
<invoiceNumbers> <select-status> Invoice numbers
The <invoiceNumbers> element may contain n <invoiceNumber> elements.

NOTE: You can not use the <invoiceNumbers> element together with ALL, FIRST and LAST.
- -
<invoiceNumber> <invoiceNumbers> Invoice number
Contains an invoice number to be included in the query.
Integer -
<where> <select-status> Element for narrowing the query
Contains elements that narrow the query. As of today, there is support for these restrictions: <recipientNumbers> <states>
- -
<recipientNumbers> <where> Recipient numbers
The <recipientNumbers> element may contain n <recipientNumber> elements. Only works together with ALL, FIRST and LAST.
- -
<recipientNumber> <recipientNumbers> Recipient number
Contains a recipient number that narrows the query. Duplicate elements will be ignored
Text - maximum 32 characters -
<states> <where> States
The <states> element may contain n <state> elements. Only works together with ALL, FIRST and LAST.
- -
<state> <states> State
Contains a state that narrows the query. Duplicate elements will be ignored
Text - maximum 20 characters -

Matrix for queries (invoice status)

<select-status> ALL FIRST _n_ LAST _n_ N/A
<invoiceNumbers>
<invoiceNumber>Integer</invoiceNumber> N/A N/A N/A n
</invoiceNumbers>
<where>
<recipientNumbers>
<recipientNumber>Text</recipientNumber> n n n N/A
</recipientNumbers>
<states>
<state>Text<state> n n n N/A
</states>
<where>
</select-status>

n = multiple instances

Examples of queries (invoice)

Get status for all paid invoices:

<?xml version="1.0" encoding="UTF-8"?>
<select-status>
    ALL
    <where>
        <states>
            <state>paid</state>
        </states>
    </where>
</select-status>

Get status for the last 10 invoices sent to recipient with recipient number 1

<?xml version="1.0" encoding="UTF-8"?>
<select-status>
    LAST 10
    <where>
        <recipientNumbers>
            <recipientNumber>1</recipientNumber>
        </recipientNumbers>
    </where>
</select-status>

Get status for invoice numbers 1, 2, and 5

<?xml version="1.0" encoding="UTF-8"?>
<select-status>
    <invoiceNumbers>
        <invoiceNumber>1</invoiceNumber>
        <invoiceNumber>2</invoiceNumber>
        <invoiceNumber>5</invoiceNumber>
    </invoiceNumbers>
</select-status>

Responses - invoice status

<invoice-status>
    <invoice number="10">
        <state>dueDecide</state>
        <payments>
            <payment id="1234567">
                <paymentDate>04.20.07</paymentDate>
                <amount>625.00</amount>
                <paymentType>PMTM</paymentType>
            </payment>
        </payments>
        <history>
            <entry>
                <timestamp>01.31.06 09:51:11</timestamp>
                <fromState>start</fromState>
                <toState>sent</toState>
                <event>createComplete</event>
                <eventParams>snailMail,</eventParams>
                <action>send</action>
            </entry>
        </history>
        <dunnings>
            <entry dunningNo="1">
                <dunningDate>04.19.07</dunningDate>
                <dunningType>1Dunning</dunningType>
                <dunningText>We unfortunately do not seem to have received your payment for this invoice.</dunningText>
                <dunningFeeValue>53.00</dunningFeeValue>
                <interestRate>8.75</interestRate>
                <dunningDays>14</dunningDays>
            </entry>
        </dunnings>
    </invoice>
</invoice-status>

Description of the various XML elements in a response from SWS when you have queried the invoice status

Element name The element's parents Element description Data type
<invoices-status> - Root element
This is the root element that contains one or more <invoice> elements.
-
<invoice> <invoice-status> Invoice
The <invoice> element contains status for an invoice. This element has an attribute: number that tells which invoice the information belongs to.
-
<payments> <invoice> Payments
This element may contain one or more payments made on this invoice.

NOTE: This element is omitted if there are no payments for this invoice
-
<payment> <payments> Payment
This element contains information about a payment. The id attribute holds an unique value for this payment.
Integer
<paymentDate> <payment> Payment date
Date the payment was registered.
Date
<amount> <payment> Payment amount
Amount paid.
Decimal
<paymentType> <payment> Payment method
A payment may have been registered in the following ways:

PMTM - Payments of this type are manually registered in the web browser by an user.
PMTA - These are payments that are transferred from Nets as a result of an eGiro-payment-agreement
CRED - Specifies that the payment is a credit note created for this invoice.
Text
<history> <invoice> History
All registered history for the invoice.

NOTE: This element is omitted if there is no history for this invoice

NOTE: Element child of the <history> element, is not uniquely named. All children will be of the type <entry> and the order can be determined using the subelement <timestamp>
-
<entry> <history> History entry
A history entry consists of several elements:

timestamp - Time of the action
fromState - State of the invoice before the action
toState - State the invoice was changed to after the action
event - What triggered the action
action - What performed the action
-
<timestamp> <entry> Time
Time of the action.
Date-time
<fromState> <entry> State before the action
State of the invoice before the action
Text
<toState> <entry> State after the action
State the invoice was changed to after the action
Text
<event> <entry> Event
What triggered the event
Text
<eventParams> <entry> Parameters for the event
What the event did. For example, whether the transfer occured by e-mail and/or on paper.
Text
<action> <entry> Action
Action that perform the event
Text
<dunnings> <invoice> Dunnings
All dunnings for the invoice.

NOTE: This element is omitted if there are no dunnings for this invoice

NOTE: Element children of the <dunnings> element are not uniquely named. All children will be of the type <entry> and the order can be determined using the attribute dunningNo on the <entry> element.
-
<entry> <dunnings> Dunning
A dunning for the invoice.

A dunning consists of multiple elements:
dunningDate - Dunning date
dunningType - Dunning type
dunningText - Dunning text
dunningFeeValue - Dunning fee
interestRate - Interest rate
dunningDays - Dunning days

This element has an attribute: dunningNo that tells the order of the dunnings.
-
<dunningDate> <entry> Dunning date
Dunning date for this dunning.
Date
<dunningType> <entry> Dunning level
Dunning level for this dunning.
Text
<dunningText> <entry> Dunning text
Dunning text for this dunning
Text
<dunningFeeValue> <entry> Dunning fee
Dunning fee for this dunning.
Decimal
<interestRate> <entry> Interest rate
Interest rate for this dunning
Decimal
<dunningDays> <entry> Dunning days
Number of dunning days for this dunning
Integer

Send dunning(s)

In order to send out a dunning, the original invoice you want to dun must be sent out via SendRegning.no. The original invoice must also be in the state dueDecide.

You can also find more information about when you can add to dunning fee/interest here

Delivery method

A dunning must be printed out and sent to the recipient by paper mail.

The reason for this is the wording in the Act relating to overdue payments, which says:

Demand can be sent electronically if the debtor has expressly accepted the use of such communication.

The Norwegian Consumer Council says the following about this:

The Norwegian Consumer Council is in doubt whether it is desirable that demands can be sent electronically, even if the debtor has expressly accepted this.

The lawyers/auditors we have had contact with regarding this, say quite clearly that if there is to be some weight to the demand, a dunning should be sent on paper.

Description of the various XML elements when sending out dunning(s) ====

Element name The element's parents Element description Data type Standard value
<dunnings> - Dunnings
Contains one or more dunning elements
- -
<dunning> <dunnings> Dunning
Contains a dunning.
- -
<invoiceNo> <dunning> Invoice number
Invoice number for the invoice to be dunned. This is a required element, and the invoice must exist and be in the state dueDecide.
Integer, maximum 15 characters -
<dunningFee> <dunning> Dunning fee
Whether a dunning fee will be added to the dunning or not.

NOTE: This does not specify the size of the dunning fee, which is already established at 1/10 of a collection agency fee. As of today (10.03.09), it is at NOK 59.
If this element is omitted, a dunning fee is not added to this dunning.

Prerequisites for adding a dunning fee
§1 The original invoice must contain information that a dunning fee can be added when dunning. See the element <printDunningInfo> in XML when sending an invoice.
§2 It is only possible to add a dunning fee twice. I.e. if you add a dunning fee to 1st DUNNING and 2nd DUNNING, you are not allowed to add a dunning fee when sending 3rd DUNNING or a DEBT COLLECTION NOTICE.
§3 It must be past at least 14 days overdue for the original invoice or last sent dunning before a dunning with a dunning fee can be sent.

If one or more of these prerequisites are not met, and the value of <dunningFee> is set to true, this value will be ignored. This is done so as not to stop the transfer when the solution is to send the dunning without a dunning fee.
Boolean value false
<interest> <dunning> Interest calculation
Whether interest will be calculated and added to the dunning or not.

NOTE: This does not specify the interest rate, which is already established by the authorities. As of today (10.03.09), the interest rate is 10%.
If this element is omitted, interest will not be calculated for this dunning. Interest will be calculated from the due date of the original invoice to the due date of the dunning.

Prerequisities for adding interest
§1 The original invoice must contain information that interest can be added when dunning.

See the element <printDunningInfo> in XML when sending an invoice.

If this prerequisite is not met, and the value of <dunningFee> is set to true, this value will be ignored.
This is done so as not to stop the transfer when the solution is to send the dunning without interest.
Boolean value false
<dunningType> <dunning> Dunning level
If this element is omitted the invoice will follow this dunning course: 1. DUNNING, 2nd DUNNING, and DEBT COLLECTION NOTICE.

However, you can send out up to 9 dunnings + debt collection notice via SendRegning.no, but you have to follow the sequence. For example, you will not be allowed to send out 2nd DUNNING before you have sent out 1st DUNNING, etc. However, at any time, you can send out a DEBT COLLECTION NOTICE if the invoice is in the state dueDecide. But you can't send out any dunnings after you have sent out a DEBT COLLECTION NOTICE.

The following values can be set in the <dunningType> element:

1Dunning - 1st DUNNING
2Dunning - 2nd DUNNING
3Dunning - 3rd DUNNING
4Dunning - 4th DUNNING
5Dunning - 5th DUNNING
6Dunning - 6th DUNNING
7Dunning - 7th DUNNING
8Dunning - 8th DUNNING
9Dunning - 9th DUNNING
deptCollectionNotice - DEBT COLLECTION NOTICE
Text, maximum 20 characters Next in series (1Dunning, 2Dunning, deptCollectionNotice)
<dunningText> <dunning> Dunning text
Text field with space for a message to the recipient of the dunning. If this element is omitted, and you send out a dunning except for DEBT COLLECTION NOTICE, the following standard text will be used:

Vi kan dessverre ikke se å ha mottatt Deres betaling for denne regning..

If the element is omitted, and you send out a DEBT COLLECTION NOTICE, the following standard text will be used:

Dersom vi ikke har mottatt Deres betaling innen forfall, overføres regningen til inkasso.

NOTE: This text is printed instead of what you may have specified in the <invoiceText> element when sending the original invoice.
Text - maximum 105 characters Standard text - see description
<dunningDays> <dunning> Dunning days
Number of dunning days for this dunning. If this element is omitted, 14 days is used as the number of dunning days for the dunning.

NOTE: It is legally required that the dunning must have a minimum of 14 days payment deadline.
Integer >= 14 14

You will get the same response from SWS as if you had sent the dunning as a regular invoice.

Sales ledger

Sales ledger

Recipient

Recipient

Product

HTTP command

<<< - Not implemented - >>>

Responses

<<< - Not implemented - >>>

Constants

HTTP command

https://www.sendregning.no/ws/butler.do?action=select&type=constant

Responses

March 17, 2009

<?xml version="1.0" encoding="UTF-8"?>
<constants>
    <dunningFee>59.00</dunningFee>
    <interestRate>10</interesRate>
    <firstInvoiceNo>1</firstInvoiceNo>
    <taxRates>
        <taxRate fromDate="01.01.00" toDate="01.01.99">0</taxRate>
        <taxRate fromDate="01.01.06" toDate="01.01.99">8</taxRate>
        <taxRate fromDate="01.01.07" toDate="01.01.99">14</taxRate>
        <taxRate fromDate="12.15.04" toDate="01.01.99">25</taxRate>
        <defaultTaxRate>25</defaultTaxRate>
    </taxRates>
</constants>

Description of the various XML elements when querying constants

Element name The element's parents Element description Data type Standard value
<constants> - Root element - -
<dunningFee> <constants> Dunning fee
The current dunning fee, this is a rate that can be changed January 1 and July 1 by the authorities. This is always 1/10 of the collection agency fee. SendRegning.no updates this rate automatically.
Decimal -
<interestRate> <constants> Interest rate
The current interest rate, this is a rate that can be changed January 1 by the authorities. SendRegning.no updates this rate automatically.
Decimal -
<firstInvoiceNo> <constants> First invoice number
First invoice number for this account.
Integer -
<taxRates> <constants> VAT rates
Contains the various VAT rates as element children
- -
<taxRate> <taxRates> VAT rate
A VAT rate with date restriction.

fromDate - Start date - First day this rate can be used
toDate - End date - Last day this rate can be used

The reason that a VAT rate has a fromDate and a toDate is so that it will be possible to use the old rate for a transitional period. This transitional period is set to two months by SendRegning.no
Decimal -
<defaultTaxRate> <taxRates> Standard VAT rate
The VAT rate that will be set as the most "common" VAT rate.

As of today (10.03.09) this rate is 25%
Decimal -

Data types

In XML documents that SWS generates, or in XML documents that you send in, the following data types are used.

Data type Description Format Example
Text All characters, letters, and numbers. - This is an example text that contains characters, numbers, and letters (12345)
Integer Integers are numbers without decimal points, thousands separators, etc... # 1 2 3 8 10 185 9987
Decimal Decimals are numbers with decimal points (. or ,) but without thousands separators, etc... Note that regardless of how many decimal points you use, SWS will always round half up to two decimal points. This means that 15.4561212 is rounded up to 15.46 #,## #.## 1,00 2,00 34.50 850.75
Date Note that if you specify, for example 45.01.07, this will be interpreted as 15.02.07, yy is always in the current century dd.MM.yy 05.12.06 31.01.07
Date time Date + time dd.MM.yy hh:mm:ss 05.12.06 16:32:44
Boolean true, 1 or on or false, 0 or off true, 1 or on or false, 0 or off true, 1 or on or false, 0 or off

Miscellaneous

Uptime

www.SendRegning.no does not have guaranteed uptime, which means that you MUST program your client to allow for time out, etc. The connection between client and server due to circumstances outside the area of responsibility of www.SendRegning.no.

www.SendRegning.no takes no responsibility for clients that crash, freeze up, or fail because the connection between the client and SWS is down.

Timeout

A common mistake when implementing SWS is ignoring your HTTP client library timeout setting. In some libraries this is sometimes set as low as a couple of seconds, and when you execute the requests with the test flag set to true that is not a problem since the test response is already generated. Then you go into production and send your first couple of hundred invoices, which can take our server several minutes to process, so you will not get the response since your client has timed out. To avoid this please set your HTTP client library timeout to at least 600 seconds.

If you do get an error you should always check whether the invoices were processed or not before you retry, either by doing another request for select last to see what the last used invoiceNo is, or by logging in manually to SendRegning and having a look at the invoices in the sent state.

Remember that invoices that are sent can't be deleted according to the Norwegian book keeping regulations. If invoices are sent twice you must issue credit invoices for the extra invoices.

Maintenance window

www.SendRegning.no reserves the right to upgrade the server/service, which means that we may stop the service such that is unavailable each night between 2 and 3 a.m. Please respect this, and add a check for this in your client.

Implementation help

For help implementing SWS, you can make direct contact with the developer of SWS at the following e-mail address sws@sendregning.no. We can also provide consulting assistance in the implementation.

Please read this document carefully before you ask the developer directly.

Errors

If you experience errors with SWS, you can register these at her.

New functionality

If you want new functionality in SWS, you can register this at her.

Terms/Glossary

We mean the following when we use these words:

  • SWS
    • SendRegning.no Web Services
  • client
    • Your data program that talks to SWS over the internet
  • invoice
    • An invoice
  • recipient
    • Recipient of invoice
  • originator
    • Originator of invoice

Programming tips

We have collected all source code at Google Code. Here you can download clients written in different languages, including Java, PHP, and Perl.

This document was converted from HTML to Google Wiki-code using http://beavercreekconsulting.com/blog/2008/05/html-to-google-code-wiki-converter/_


Sign in to add a comment
Powered by Google Project Hosting