Simple transaction with VAT inclusive and exclusive

The following section describes how a simple transactions either with inclusive or exclusive VAT have to be established.
 
Example code
 
Create a simple transaction with VAT inclusive
 
Simple transaction key currency VAT inclusive
    
            decimal totalAmount = 7000.0M;

            errorcode = manager.LoadTransactions();
            
            // Add here some logic to handle the error code

            ITransaction transaction = new Transaction();
            transaction.NumRangeFID = manager.Defaults.DefSimpleNumRangeFID;
            transaction.TransactionTypeFID = (int)TransactionType.Simple;
            transaction.DocNum = manager.Defaults.DefSimpleCurrNum;

            transaction.DocType = "RR";
            DateTime date = DateTime.Today;
            transaction.DocDate = new DateTime(date.Year, date.Month, date.Day);

            manager.LoadAccounts();

            // create a VAT instance 
            IVAT vat = new VAT();
            vat = manager.FindVAT("UStn");
            vat.IsInclusive = true;

            // Create your first posting
            IPosting posting1 = new Posting();
            posting1.AccountFID = manager.FindAccountID("1020");
            posting1.Text = "TestCase Single Transaction Posting #1";
            posting1.FreeCode = "Free 1";
            posting1.Amount = totalAmount;
            posting1.FcAmount = totalAmount;
            posting1.ExchangeRate = 1;
            posting1.IsDebit = true;

            // Create your second posting
            IPosting posting2 = new Posting();
            posting2.AccountFID = manager.FindAccountID("3200");
            posting2.Text = "TestCase Single Transaction Posting #2 with VAT";
            posting2.FreeCode = "Free 2";
            posting2.Amount = totalAmount;
            posting2.FcAmount = totalAmount;
            posting2.ExchangeRate = 1;
            posting2.IsDebit = false;

            // assign VAT to posting
            manager.FillVATPosting(posting2, vat);

            posting2.IsInclusive = true;
            posting2.CalcAmounts(totalAmount, false);

            transaction.Postings.Add(posting1);
            transaction.Postings.Add(posting2);

            // Save the created transaction
            errorcode = manager.SaveTransaction(transaction);

            // Add here some logic to handle the error code
    
  
Simple transaction key currency VAT inclusive
    
UNDER CONSTRUCTION
    
  

 
Create a simple transaction with VAT exclusive
There is one aspect which needs to be considered in case of a transaction where the VAT amount is exclusive.
The total amount (e.g amount: CHF 7000.- VAT: 8% -> CHF 560.- -> CHF 7560.-) as well as the posting amount (e.g. CHF 7000.-)
needs to be supplied.
 
Simple transaction key currency VAT exclusive
    
            decimal totalAmount = 7560.0M;
            decimal postingAmount = 7000.0M;

            // Load transactions via LoadTransactions()
            errorcode = manager.LoadTransactions();

           // Add here some logic to handle the error code

            IClient client = manager.Client;
            bool kc_swiss_rounded = client.IsKCSwissRounded;
            bool vat_swiss_rounded = client.IsVATSwissRounded;

            // Create a transaction instance
            ITransaction transaction = new Transaction();
            transaction.NumRangeFID = manager.Defaults.DefSimpleNumRangeFID;
            transaction.TransactionTypeFID = (int)TransactionType.Simple;
            transaction.DocNum = manager.Defaults.DefSimpleCurrNum;

            transaction.DocType = "RR";
            DateTime date = DateTime.Today;
            transaction.DocDate = new DateTime(date.Year, date.Month, date.Day);

            // create a VAT instance 
            IVAT vat = new VAT();
            vat = manager.FindVAT("UStn");

            manager.LoadAccounts();
            
            // Create your first posting
            IPosting posting1 = new Posting();
            posting1.AccountFID = manager.FindAccountID("1020");
            posting1.Text = "TestCase Single Transaction Posting #1";
            posting1.FreeCode = "Free 1";
            posting1.Amount = totalAmount;
            posting1.FcAmount = totalAmount;
            posting1.ExchangeRate = 1;
            posting1.IsDebit = true;

            // Create your second posting
            IPosting posting2 = new Posting();
            posting2.AccountFID = manager.FindAccountID("3200");
            posting2.Text = "TestCase Single Transaction Posting #2 with VAT";
            posting2.FreeCode = "Free 2";
            posting2.Amount = postingAmount;
            posting2.FcAmount = postingAmount;
            posting2.ExchangeRate = 1;
            posting2.IsDebit = false;

            manager.FillVATPosting(posting2, vat);

            posting2.IsInclusive = false;
            posting2.CalcAmounts(postingAmount, false);

            transaction.Postings.Add(posting1);
            transaction.Postings.Add(posting2);

            // Save the created transaction
            errorcode = manager.SaveTransaction(transaction);

           // Add here some logic to handle the error code
    
  
Simple transaction key currency VAT exclusive
    
UNDER CONSTRUCTION