4. Send Classifications

This guide will help you implement the myDATA dll and send your first Invoice Classification.

You must be able to access and manage invoices to the fullest extent before you can send a classification.

Continue reading to learn how to retrieve invoices if you don't already know how. 
 
The SendClassifications class, which is the most widely used, will be covered in this topic.

  1. Call the constructor of SendClassifications: SendClassifications Constructor 
    SendClassifications cls = new SendClassifications("AADEUserID", _
                               "OcpApimSubscriptionKey", "ExecuteEntityVatNumber", _
                               "Arbitrans User", "Arbitrans Key", false);					
    This language is not supported or no code example is available.
    Dim cls As SendClassifications = New SendClassifications("AADEUserID", _
                                      "OcpApimSubscriptionKey", "ExecuteEntityVatNumber", _
                                      "Arbitrans User", "Arbitrans Key", False)					
    This language is not supported or no code example is available.
  2. Create a classification list
    var clsList = new List();					
    This language is not supported or no code example is available.
    Dim clsList As New List(Of classifications)					
    This language is not supported or no code example is available.

    The classification list will include the classification for each row of the invoice to be classified.

  3. In order to know which row you are classifying, use the getInvoice(int32) Method from RequestInvoices
    Create an invoice, type of RequestInvoices.invoice, and retrieve the invoice you want to classify. In the following example, we will work with the very first invoice we retrieved, with index 0. 
    RequestInvoices.invoice inv;
     inv = rqd.getInvoice(0);					
    This language is not supported or no code example is available.
    Dim inv As RequestInvoices.invoice
     inv = rqd.getInvoice(0)					
    This language is not supported or no code example is available.
  4. For each row of the invoice, create a Classifications object for each line, fill in the fields, and add it to the classification list
    var clsList = new List(); // initialize a new list of classifications
     for (int i = 1, loopTo = inv.lines.count - 1; i <= loopTo; i++)
     {
         classifications clsLine = cls.newClassification; // create a new classification
         clsLine.lineNumber = inv.lines(i).lineNumber;
         clsLine.classificationType = "E3_561_001";
         clsLine.classificationCategory = "category1_3";
         clsLine.amount = 100;
         clsLine.VatCategory = "VAT_361"; // VatCategory should have value only if the line concerns expenses. 
         clsList.Add(clsLine); // add the classification into the list
     }					
    This language is not supported or no code example is available.
    Dim clsList as new List(of classifications) 'initialize a new list of classifications
     For i = 1 To inv.lines.count - 1
         Dim clsLine As classifications = cls.newClassification 'create a new classification
         clsLine.lineNumber = inv.lines(i).lineNumber
         clsLine.classificationType = "E3_561_001"
         clsLine.classificationCategory = "category1_3"
         clsLine.amount = 100
         clsLine.VatCategory = "VAT_361" ' VatCategory should have value only if the line concerns expenses.
         clsList.Add(clsLine) 'add the classification into the list
     Next					
    This language is not supported or no code example is available.
  5. Send the Classification, using the mark of the invoice you're goin to classify, and the classification list we created above.
    Dim result As String = cls.Send("400000000000001", clsList)					
    This language is not supported or no code example is available.
    Dim result As String = cls.Send("400000000000001", clsList)					
    This language is not supported or no code example is available.
  6. The result will include either the classification mark (evidence that the invoice has been classified) or errors, so you can handle them properly.

The final code will resemble this after the above steps have been followed:

using System.Collections.Generic;
 using ArbitransMyData;
 using ArbitransMyData.MyDataApi;
 
 public partial class myClass
 {
     public void RequestInvoices()
     {
         // The Request Invoices Code
     }
 
 
     public void SendClassifications()
     {
         var cls = new SendClassifications("AADEUserID", _
                   "OcpApimSubscriptionKey", "ExecuteEntityVatNumber", _
                   "Arbitrans User", "Arbitrans Key", false);
 
         var clsList = new List(); // initialize a new list of classifications
         for (int i = 1, loopTo = inv.lines.count - 1; i <= loopTo; i++)
         {
             classifications clsLine = cls.newClassification; // create a new classification
             clsLine.lineNumber = inv.lines(i).lineNumber;
             clsLine.classificationType = "E3_561_001";
             clsLine.classificationCategory = "category1_3";
             clsLine.amount = 100;
             clsLine.VatCategory = "VAT_361"; // VatCategory should have value only if the line concerns expenses.
             clsList.Add(clsLine); // add the classification into the list
         }
 
 
         string result = cls.Send("400000000000001", clsList);
     }
 }					
This language is not supported or no code example is available.
Imports ArbitransMyData
 Imports ArbitransMyData.MyDataApi
 
 Public Class myClass
  Public Sub RequestInvoices
   ' The Request Invoices Code
  End Sub
 
 Public Sub SendClassification
   Dim cls As SendClassifications = New SendClassifications("AADEUserID", _
                                    "OcpApimSubscriptionKey", "ExecuteEntityVatNumber", _
                                    "Arbitrans User", "Arbitrans Key", False)
 
   Dim clsList As New List(Of classifications)
   For i = 1 To inv.lines.count - 1
      Dim clsLine As classifications = cls.newClassification 'create a new classification
      clsLine.lineNumber = inv.lines(i).lineNumber
      clsLine.classificationType = "E3_561_001"
      clsLine.classificationCategory = "category1_3"
      clsLine.amount = 100
      clsLine.VatCategory = "VAT_361" ' VatCategory should have value only if the line concerns expenses.
      clsList.Add(clsLine) 'add the classification into the list
   Next
 
   Dim result As String = cls.Send("400000000000001", clsList)
 End Sub
 End Class					
This language is not supported or no code example is available.
Remarks
 
Important: When the classificationCategory is category2 5, you must use the Gross Value as an amount and leave the classifications.VatCategory blank.

In this article

Definition