Readme

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

.NET core Transmitter Sample 2020.

05
Swissdec Lohnstandard

Swissdec, 6002 Luzern


www.swissdec.ch
.NET core Transmitter Sample 2020.05
Swissdec Lohnstandard

The guidelines for data transmission were developed in cooperation with the following parties:

• Suva

• eAHV / IV

• Conference of the cantonal equalisation funds

• Association of association compensation funds

• Tax Administration of the Canton of Bern

• Swiss Tax Conference

• Swiss Federal Tax Administration

• Swiss Federal Statistical Office

• Swiss Insurance Association

Publisher
Verein Swissdec
Postfach 4358
6002 Luzern

http://www.swissdec.ch
.NET core Transmitter Sample 2020.05
Swissdec Lohnstandard

Revision History

Version 2020.05 2020-09-24 tko


Version with ELMv5 (20200220), KLEv1 (20180901) and SUAv1 (20190301)

Version 2018.05.1 2018-05-31 tko

Version 2017.05 2017-05-02 tko


.NET core Transmitter Sample 2020.05
Swissdec Lohnstandard

Conventions in this document


The following fonts are used in this document:

Text Documentation

Text Code

<Text> XML-Element

[Text] Reference to another document

The binding nature of requirements is defined as follows:

Binding nature Word


Mandatory must
Wish should (shall)
Intent will be
Proposal can

Table 1. Binding nature of requirements

Caution
Older schematic pictures are often sufficient for the conceptual understanding, i.e. only the
following are always binding the official XML files

SVN $Revision: 27230 $:


$Date: 2020-09-24 17:28:15 +0200 (Do., 24 Sep 2020) $: $Author: koch $:
.NET core Transmitter Sample 2020.05
Swissdec Lohnstandard

Table of Contents
1. Getting started ....................................................................................................................... 1
1.1. Installation Prerequisites .................................................................................................... 1
1.2. Installation ........................................................................................................................ 1
2. Usage .................................................................................................................................... 2
2.1. Binding classes ................................................................................................................. 2
2.2. Saving SOAP-Messages ................................................................................................... 2
3. Remarks ................................................................................................................................ 3
3.1. Redistribution .................................................................................................................... 3
3.2. Password .......................................................................................................................... 3
3.3. Support ............................................................................................................................. 3
3.4. Issues ............................................................................................................................... 3

README.pdf, Version 2020.05 - Ausgabe 2020-09-25 v


.NET core Transmitter Sample 2020.05
Swissdec Lohnstandard

List of Tables
1. Binding nature of requirements ............................................................................................... iv
1.1. Projects in the solution and their usage ................................................................................ 1

README.pdf, Version 2020.05 - Ausgabe 2020-09-25 vi


.NET core Transmitter Sample 2020.05
Swissdec Lohnstandard

1 Getting started
1.1. Installation Prerequisites
The following table lists the software requirements for the sample application

• Windows 10 or above

• .NET core 3.1 or above

• Visual Studio 2019

1.2. Installation
The TransmitterSample comes as a zipped .NET solution. Just unpack the archive to your preferred
folder. Once the application is unpacked, you can open the solution in Visual Studio or any other IDE
that masters .NET core 3.1 . You will find the solution file in the root folder of the unpacked archive.
The structure of the solution is as follows:

Project Usage
Swissdec.Transmitter.Common Common util classes
Swissdec.Transmitter._20130514 Common classes for ELM v4.0; contains ELM v4.0
transmitter
Swissdec.Transmitter._20180901 Common classes for KLE v1.0; contains KLE v1.0
transmitter
Swissdec.Transmitter._20190301 Common classes for SUA v1.0; contains SUA v1.0
transmitter
Swissdec.Transmitter._20200220 Common classes for ELM v5.0; contains ELM v5.0
transmitter
Swissdec.Transmitter._20130514.Test UnitTests for ELM v4.0. Tests show how to call the
transmitter method.
Swissdec.Transmitter._20180901.Test UnitTests for KLE v1.0. Tests show how to call the
transmitter method.
Swissdec.Transmitter._20190301.Test UnitTests for SUA v1.0. Tests show how to call the
transmitter method.
Swissdec.Transmitter._20200220.Test UnitTests for ELM v5.0. Tests show how to call the
transmitter method.
Swissdec.Transmitter Basic transmitter classes

Table 1.1. Projects in the solution and their usage

Please note that you need at least the .NET core 3.1 in order to run the application properly.

README.pdf, Version 2020.05 - Ausgabe 2020-09-25 1


.NET core Transmitter Sample 2020.05
Swissdec Lohnstandard

2 Usage
2.1. Binding classes
As this sample only covers the communication part there is no backing tax accounting software with
different test data. Due to this reason this sample shows how to process a complete ELM-, KLE- or
SUA-XML file only. In your application you typically have to gather all data from your database and put
together the XML. The following code snippet shows how this can be done in ELM with the provided
proxy classes:
...
DeclareSalaryRequest request = new DeclareSalaryRequest();
PersonType person = new PersonType
{
Particulars = new ParticularsType
{
Lastname = -"Schmid",
Firstname ="Peter"
-}
};

AHVAVSSalaryType ahvavsSalaryType = new AHVAVSSalaryType();


TimePeriodType timePeriodType = new TimePeriodType
{
from = new DateTime(2009, 1, 1),
until =new DateTime(2009, 12, 31)
};
ahvavsSalaryType.AccountingTime = timePeriodType;
Decimal myNumber = 124;
ahvavsSalaryType.AHVAVSIncome = Decimal.Parse(myNumber.ToString("0.00"));

person.AHVAVSSalaries = new AHVAVSSalaryType[]{ahvavsSalaryType};

request.SalaryDeclaration = new SalaryDeclarationType();


request.SalaryDeclaration.Company = new CompanyType();
request.SalaryDeclaration.Company.Staff = new PersonType[]{person};
...

Choice types in the XML schema can not be mapped straight forward and might need a second look
on how to use them:
...
if (workingStateType.Item is SuccessResponseType)
{
SuccessResponseType successResponseType = (SuccessResponseType) workingStateType.Item;
}
if (workingStateType.Item is ErrorResponseType)
{
ErrorResponseType errorResponseType = (ErrorResponseType)workingStateType.Item;
}
...

2.2. Saving SOAP-Messages


Due to the Swissdec-requirements in- and outgoing message must be saved at least in the form signed,
but not encrypted. The TransmitterSample shows how to save both "signed only" and "signed and
encrypted" in a very basic way. You probably will have to adapt the location of saving and the filenames
for your final product.

README.pdf, Version 2020.05 - Ausgabe 2020-09-25 2


.NET core Transmitter Sample 2020.05
Swissdec Lohnstandard

3 Remarks
3.1. Redistribution
You are free to redistribute any parts of this sample with your application.

3.2. Password
Password for client test certificate: testZertifikat

3.3. Support
If you need assistance in using this application you can contact the technical support by email:
<[email protected]>

3.4. Issues
• Not all XML schema aspects can be honoured by the proxy class. For instance there is a problem
with values which have a pattern defined (e.g. currency values with 2 decimal places). Depending on
the assignement the proxy class does not honour the defined pattern (0.00). A workaround for this
issue is to format the value explicitly as follows:

sd.Company.Staff[0].AHVAVSSalaries[0].AHVAVSIncome = Decimal.Parse(myNumber.ToString("0.00"));

Whenever you do a direct assignment you can use the shorter method:

sd.Company.Staff[0].AHVAVSSalaries[0].AHVAVSIncome = 125.00m

• If you regenerate the proxy class by using svcutil.exe you have to make sure that you annotate the
required classes again with XmlRootAttribute. For example:

...
[System.Xml.Serialization.XmlRootAttribute("SalaryDeclaration",
Namespace = -"http://www.swissdec.ch/schema/sd/20130514/SalaryDeclarationContainer", IsNullable = false)]
public partial class SalaryDeclarationType -: object, System.ComponentModel.INotifyPropertyChanged
...

This is only needed if you want to have the possibility to deserialize xml files into the object model
(as we do it in the sample). The normal use case for you will be to fill the objects directly from your
the database or input fields in the GUI.

README.pdf, Version 2020.05 - Ausgabe 2020-09-25 3

You might also like