Skip to content

Parsing and creating files for requesting RUT & ROT tax deductions from Skatteverket (Swedish Tax Agency)

Notifications You must be signed in to change notification settings

marinasundstrom/RotRutParsing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROT & RUT

Code for parsing and creating files for requesting RUT & ROT tax deductions from Skatteverket (Swedish Tax Agency)

Written in C#/.NET.

What is this?

The project defines models representing the file structures of the XML and JSON files.

These are the scenarios:

  • Parsing and creating RUT & ROT Request files in XML that will be sent to Skatteverket.
  • Parsing the JSON files containing the Decisions you have got from Skatteverket.

Why?

I could not find any library or sample code for handling the files, so I decided to write this as a reference project.

The files are usually being produced by accounting software, like Fortnox. But there are scenarios when you want to parse and generate them yourself.

How to use it

This demonstrates how to use the library.

Deserialize Request

using var stream = File.OpenRead("Begaran.xaml");
var begaran = RotRutBegaran.Deserialize(stream);

Serialize Request

var begaran = new BegaranFil();

using var stream = File.OpenWrite("Begaran.xaml");
RotRutBegaran.Serialize(stream, begaran);

Validate

To perform a nested validation of the models:

var begaran = new BegaranFil();

var validationResults = new List<ValidationResult>();

var valid = RotRutBegaran.Validate(begaran, validationResults);

XML Format

The structure is defined in the schema that can be found in the <repository>/Files/Schemas/v6 folder.

Basically, both ROT and RUT requests share the same root structure (BegaranFil),

ROT or RUT may only contain a maximum of 100 request posts per file (Ärende, "errand" or "matter"). Any number above needs to be put in a separate file.

Terminology

These are some concepts that are being used in the code:

  • Begäran - Request (for Skatteverket)
  • Beslut - Decision (by Skatteverket)

To do

  • Polish the model
  • Add validation to models

Disclaimer

This code is being published with no warranty whatsoever.

The project should be considered a reference for your own implementation.

All personal numbers (SSN) have been generated for demo purposes.

Resources

About

Parsing and creating files for requesting RUT & ROT tax deductions from Skatteverket (Swedish Tax Agency)

Topics

Resources

Stars

Watchers

Forks

Languages