Skip to main content

Sales invoices

info

Sales invoices that are created by using this web service are created in the Twinfield Classic sales invoicing module. There is no web service available yet to create sales invoices in the new invoicing module.

info

In Twinfield there is a clear distinction between sales invoices and sales transactions. Sales invoices are the invoices, which will be sent to customers. Sales transactions are the related financial transactions that will be posted in the accounting part of Twinfield.

Find

Web service type: Method driven

Resource location: /webservices/finder.asmx?wsdl

Lists unpaid invoices. Sales invoices are only returned in case their status is Final.

Method

public Message[] Search(
string type, // Finder type, See Finder type.
string pattern, // The search pattern. May contain wildcards * and ?
int field, // Fields to search through, see Search fields.
int firstRow, // First row to return, usefull for paging
int maxRows, // Maximum number of rows to return, usefull for paging
string[][] options, // See options below
out FinderData data) // Search results

Finder type

IVT

Search fields

Field IDFields searched
0Customer code, name, outstanding invoice amount and invoicenumber

The method will return an array containing validation messages. If there are no errors, then the data parameter will contain the actual search result.

Options

OptionTypeDescription
dim1codeFilters on the dimension on level 1.
dim2codeFilters on the dimension on level 2.
dim3codeFilters on the dimension on level 3.
dim4codeFilters on the dimension on level 4.
dim5codeFilters on the dimension on level 5.
dim6codeFilters on the dimension on level 6.
valuemoneyFilters on the original invoice value.
openvaluemoneyFilters on the outstanding value.

Read

Web service type: XML Web Services

XML

This example reads the sales invoice of invoice type INVOICE and invoice number 1.

<read>
<type>salesinvoice</type>
<office>001</office>
<code>INVOICE</code>
<invoicenumber>1</invoicenumber>
</read>

If the sales invoice does not exist an empty salesinvoice element is returned containing an error.

Create/Update

If a sales invoice is not found it will be automatically created, otherwise it is updated.

Using the regular one-off item

During processing a sales invoice the values of the sales invoice lines are posted to accounts. The accounts that will be used depends on the items settings. It is possible to create items, link accounts to them and use those items in sales invoices. On the other hand, it is also possible to use the regular one-off item <article>0</article>. Advantage of this one-off item is that it is not needed anymore to maintain a list of items. The one-off item is always available in each company.

As it is not possible to maintain the one-off item, the accounts that will be used during processing depends on several settings. There are three possible scenarios:

Scenario 1: using a fixed ledger account / cost center / project

Within the invoice type settings, it is possible to enter a ledger account and optionally a cost center and project. When using the one-off item while creating and posting a sales invoice, the values of the sales invoice lines will be posted to this account, cost center and project.

Scenario 2: fill ledger account from XML request option 1

Within the invoice type settings, it is possible to enter a ledger account. When within the invoice type settings the option “One-off items > Can adjust general ledger account” is ticked, the account as set in the settings can be overwritten.

To overwrite the default account add the tag <dim1> to the request at the sales invoice lines. Note that only the general ledger account (dim1) can be altered. There is no possibility to change the cost center (dim2) or project (dim3).

Scenario 3: fill ledger account from XML request option 2

Use one or more free text fields in order to fill ledger account, cost center and project. Link the free text fields to e.g. general ledger accounts and cost centers. Also fill the “Item 0 (regular one-off)” settings of the sales invoice type with a reference to the free text fields.

In the XML message, use the free text fields on the sales invoice lines in order to set the ledger account and optionally a cost center.

Root

XML structure
<transaction calculateonly="" raisewarning="">
<header></header>
<lines></lines>
<totals></totals>
<vatlines></vatlines>
<financials></financials>
</transaction>

Element name: salesinvoice

NameDescription
@calculateonlyAttribute to indicate that invoice should not be saved but only checked and calculated. @calculateonly must be true for that.
@raisewarningShould warnings be given true or not false? Default true.
headerContains information general to the sales invoice.
linesContains the sales invoice lines.
totalsContains the totals.
vatlinesContains the taxline (vatline) elements.
financialsOnly present if the invoice has status final. Contains the reference to the sales transaction.
XML structure
<header>
<office></office>
<invoicetype></invoicetype>
<invoicedate></invoicedate>
<duedate></duedate>
<performancedate></performancedate>
<bank></bank>
<customer></customer>
<period raisewarning=""></period>
<currency></currency>
<invoicenumber></invoicenumber>
<status></status>
<paymentmethod></paymentmethod>
<invoiceaddressnumber></invoiceaddressnumber>
<deliveraddressnumber></deliveraddressnumber>
<headertext></headertext>
<footertext></footertext>
</header>

Element name: header

NameTypeDescription
officecodeOffice code.
invoicetypecodeInvoice type code.
invoicenumberintegerDuring the creation of a new sales invoice, the invoice number will be generated based on the next invoice number as set on the invoicing type. So when a new sales invoice is created, do not fill the invoicenumber.
If the invoicenumber is filled, the corresponding sales invoice will be changed. If no sales invoice with a corresponding invoicenumber can be found, an error will be returned. Note that only provisional sales invoices can be changed.
invoicedatedateOptional; when the invoicedate is not supplied Twinfield uses the system date as the invoice date.
duedatedateDue date.
performancedatedatePerformance date, when set-up on the invoice header.
bankcodeBank code.
invoiceaddressnumberintegerIf you want the default address, omit the tag or leave it empty.
deliveraddressnumberintegerIf you want the default address, omit the tag or leave it empty.
customercodeCustomer code.
periodperiodPeriod in YYYY/PP format.
Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. This overwrites the value of the raisewarning attribute as set on the root element.
currencycodeCurrency code.
statusdefault
concept
final
default can only be returned when retrieving a sales invoice. You cannot use this status when creating or updating an invoice.
concept saves the invoice as provisional.
After saving as final, no changes can be made anymore. When posting an invoice final, a financial transaction is generated and posted automatically.
paymentmethodcash
bank
cheque
cashondelivery
da
The payment method.
DA: see documents against acceptance
headertexttextHeader text on the invoice.
footertexttextFooter text on the invoice.

Sales invoice lines

XML structure
<lines>
<line id="">
<article></article>
<subarticle></subarticle>
<quantity></quantity>
<units></units>
<unitspriceexcl></unitspriceexcl>
<vatcode></vatcode>
<allowdiscountorpremium></allowdiscountorpremium>
<description></description>
<performancedate></performancedate>
<performancetype></performancetype>
<freetext1></freetext1>
<freetext2></freetext2>
<freetext3></freetext3>
<dim1></dim1>
</line>
</lines>

Element name: lines

NameTypeDescription
@idintegerLine ID.
articlecodeArticle code.
subarticlecodeSub-article code.
quantityintegerThe quantity on the sales invoice line.
unitsintegerThe number of units per quantity.
allowdiscountorpremiumtrue
false
Calculate discount on this line.
descriptionstring(110)Invoice line description, only on the lines with article ‘0’ or ‘-‘.
valueexclmoneyCalculated element.
Read-only attribute.
vatvaluemoneyCalculated element.
Read-only attribute.
valueincmoneyCalculated element.
Read-only attribute.
unitspriceexclmoneyOnly valid for invoice types with VAT exclusive units prices. Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system.
unitspriceincmoneyOnly valid for invoice types with VAT inclusive units prices. Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system.
freetext1string(36)Free text field 1 as entered on the invoice type.
freetext2string(36)Free text field 2 as entered on the invoice type.
freetext3string(36)Free text field 3 as entered on the invoice type.
dim1codeBalance account.
vatcodecodeVAT code.
performancetypeservices
goods
The performance type in case of an ICT sales invoice.
performancedatedatePerformance date, when set-up on invoice lines.

Totals line

XML structure

Not allowed in the XML request.

Element name: totals

NameTypeDescription
valueexclmoneyValue without VAT.
Read-only attribute.
valueincmoneyValue with VAT.
Read-only attribute.

VAT lines

XML structure

Not allowed in the XML request.

Element name: vatlines

NameTypeDescription
vatlinenodeVAT line.

VAT line

Element name: vatline

NameTypeDescription
vatcodecodeVAT code.
Read-only attribute.
vatvaluemoneyVAT amount.
Read-only attribute.
performancetypeservices
goods
The performance type.
Read-only attribute.
performancedatedateThe performance date. Only in case performancetype = services
Read-only attribute.

Financials

XML structure

Not allowed in the XML request.

Element name: financials

NameTypeDescription
codecodeThe transaction type code.
Read-only attribute.
numberintegerThe transaction number.
Read-only attribute.

XML Example

<salesinvoice>
<header>
<office>001</office>
<invoicetype>FACTUUR</invoicetype>
<invoicedate>20210425</invoicedate>
<duedate>20210429</duedate>
<bank>BNK</bank>
<customer>1000</customer>
<period>2021/4</period>
<currency>EUR</currency>
<status>concept</status>
<paymentmethod>cash</paymentmethod>
</header>
<lines>
<line id="1">
<article>510</article>
<subarticle>501.01</subarticle>
<quantity>2.00</quantity>
<units>1</units>
<unitspriceexcl>83.94</unitspriceexcl>
</line>
</lines>
</salesinvoice>