×

Receivables Invoices

Topal Financial Accounting Interface provides the possibility to to transfer Invoices from a 3rd. Party Application to Topal.
The following examples give an idea how Invoices need to be prepared in order to be created in Topal.
 
Example Code
 
Create a receivable invoice
Create a receivable invoice.
 
External references to methods used in examples
#Code reference - GET.party_by_name
#Code reference - GET.party_by_id
#Code reference - GET.account_by_account_code
#Code reference - InternalTypes
#Code reference - POST.receivables_invoice
#Code reference - GET.receivables_invoice_by_freeinvoicenum
#Code reference - DELETE.receivables_invoice
    
        [TestMethod]
        public void REST_Receivables_invoice_create()
        {
            state = new ErrorState();
            decimal payment_amount = 1000.0m;

            Party party = GET.party_by_name("Bucherer AG", manager);
            party = GET.party_by_id(party.id, manager);

            List postings = new List();
            postings.Add(payment_amount);

            // Transfer object
            Invoice_DTO invoice_to = new Invoice_DTO
            {
                party = party,
                manager = manager,
                exchange_rate = 1,
                text = "Recivables Invoice",
                pay_method = "LSV-CHF",
                contra_account = "3200",
                cost_center_code = "",
                isDebit = true,
                free_inv_num = "RI_2999",
                payment_amount = payment_amount,
                posting_amounts = postings,
                date = DateTime.Today,
            };
            invoice_to.payment_fc_amount = invoice_to.payment_amount;

            Invoice invoice = Create.receivables_invoice(invoice_to);
            state.passed = POST.receivables_invoice(invoice, manager);
            Assert.AreEqual(true, state.passed, state.message);

            invoice = GET.receivables_invoice_by_freeinvoicenum(invoice_to.free_inv_num, manager);
            
            if (invoice != null) {
                state.passed = DELETE.receivables_invoice(invoice, manager);
                Assert.AreEqual(true, state.passed, state.message);
            }
        }

        class Create {
        public static Invoice receivables_invoice(Invoice_DTO invoice_to)
        {
            Invoice invoice = new Invoice();
            invoice.text = invoice_to.text;
            invoice.freeInvoiceNum = invoice_to.free_inv_num;
            DateTime date = new DateTime();

            date = invoice_to.date == null ? DateTime.Today : invoice_to.date;
            invoice.invoiceDate = new DateTime(date.Year, date.Month, date.Day);
            invoice.dueDate = date.AddDays(30);
            invoice.totalAmount = invoice_to.payment_amount;

            invoice.partyFID = invoice_to.party.id;
            invoice.personRoleFID = (int)InternalTypes.PersonRole.Debtor;
            IList pay_methods = invoice_to.party.debtor.payMethods;

            invoice.payMethodFID = pay_methods.SingleOrDefault(m => m.name.Equals(invoice_to.pay_method)).id;
            invoice.payTermFID = invoice_to.party.debtor.payTermFID;
            invoice.transaction.docDate = new DateTime(date.Year, date.Month, date.Day);

            // Create first posting
            // Invoice paymentod and paymethod_IBAN of first posting must always be the same 
            Posting posting1 = new Posting
            {
                accountFID = pay_methods.SingleOrDefault(m => m.name.Equals(invoice_to.pay_method)).accountFID,
                text = invoice_to.text.Equals("") ? "Posting text" : invoice_to.text,
                freeCode = "Posting Free 1"
            };

            if (invoice_to.payment_amount != invoice_to.payment_fc_amount)
            {
                decimal key_currency_amount = invoice_to.exchange_rate * invoice_to.payment_fc_amount;
                posting1.amount = key_currency_amount;             // mandatory
                posting1.fcAmount = invoice_to.payment_fc_amount;  // mandatory
                posting1.exchangeRate = invoice_to.exchange_rate;
            }
            else
            {
                posting1.amount = invoice_to.posting_amounts[0];    // mandatory
                posting1.fcAmount = invoice_to.posting_amounts[0];  // mandatory
                posting1.exchangeRate = invoice_to.exchange_rate;
            }

            posting1.isDebit = invoice_to.isDebit;
            posting1.postingTypeFID = (int)InternalTypes.PostingType.Invoice;
            posting1.isInclusive = invoice_to.invoiceType;
            posting1.costCenterFID = -1;
            invoice.transaction.postings.Add(posting1);

            /* create posting without VAT */
            foreach (decimal amount in invoice_to.posting_amounts)
            {
                Posting posting = new Posting();
                posting.accountFID = GET.account_by_account_code(invoice_to.contra_account, invoice_to.manager).id;
                posting.text = invoice_to.text.Equals("") ? "Posting text" : invoice_to.text;
                posting.isDebit = !invoice_to.isDebit;
                posting.amount = invoice_to.payment_amount;
                posting.fcAmount = invoice_to.payment_fc_amount;
                posting.exchangeRate = invoice_to.exchange_rate;
                posting.postingTypeFID = (int)InternalTypes.PostingType.Invoice;
                posting.isInclusive = invoice_to.invoiceType;
                posting.costCenterFID = !invoice_to.cost_center_code.Equals("") ? GET.costcenter_by_code(invoice_to.cost_center_code, invoice_to.manager).id : -1;
                invoice.transaction.postings.Add(posting);
            }
            invoice.transaction.transactionTypeFID = (int)InternalTypes.TransactionType.Invoice;

            return invoice;
        }
       }
    
  
Create Recivable Invoice
    
    UNDER CONSTRUCTION
    
  
JSON representation of a receivables invoice
    
    POST Request:
    {
	"id": "00000000-0000-0000-0000-000000000000",
	"authorizerFID": -1,
	"partyFID": 1,
	"payMethodFID": 1,
	"payTermFID": 9,
	"vatFID": -1,
	"personRoleFID": 2,
	"invoiceDate": "2022-05-12T00:00:00",
	"dueDate": "2022-06-11T00:00:00+02:00",
	"modifyDate": "0001-01-01T00:00:00",
	"invoiceNum": -1,
	"reminderLevel": 0,
	"freeInvoiceNum": "RI_2999",
	"text": "Recivables Invoice",
	"PayslipCode": null,
	"totalAmount": 1000.0,
	"totalAmountFC": 0.0,
	"exchangeRate": 0.0,
	"IsAuthorized": true,
	"noReminders": false,
	"Remarks": null,
	"partyNum": 0,
	"partyName": null,
	"partyShortName": null,
	"payTermCode": null,
	"accountCode": null,
	"currencyCode": null,
	"balance": 0.0,
	"balanceFC": 0.0,
	"barCode": null,
	"currentReminderLevel": 0,
	"hasDocument": 0,
	"currentReminderDate": "0001-01-01T00:00:00",
	"paymentPostings": [],
	"transaction": {
		"id": "00000000-0000-0000-0000-000000000000",
		"fiscalYearFID": -1,
		"userFID": -1,
		"transactionTypeFID": 3,
		"docType": null,
		"docNum": -1,
		"docDate": "2022-05-12T00:00:00",
		"modifyDate": "0001-01-01T00:00:00",
		"isConfirmed": true,
		"numRangeFID": -1,
		"hasDocument": false,
		"postings": [
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"transactionFID": "00000000-0000-0000-0000-000000000000",
				"invoiceFID": "00000000-0000-0000-0000-000000000000",
				"accountFID": 20,
				"contraAccountFID": -1,
				"vatFID": -1,
				"vatAccountFID": -1,
				"costCenterFID": -1,
				"postingTypeFID": 2,
				"amount": 1000.0,
				"fcAmount": 1000.0,
				"exchangeRate": 1.0,
				"vatAmount": 0.0,
				"vatFcAmount": 0.0,
				"vatPercent": 0.0,
				"vatQuote": 0.0,
				"text": "Recivables Invoice",
				"freeCode": "Posting Free 1",
				"isDebit": true,
				"isInclusive": false,
				"isInvisible": false,
				"postingIndex": 0,
				"partyNum": 0,
				"freepartyNum": null,
				"partyName": null,
				"invoiceNum": 0,
				"freeInvoiceNum": null,
				"invoiceDate": "0001-01-01T00:00:00"
			},
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"transactionFID": "00000000-0000-0000-0000-000000000000",
				"invoiceFID": "00000000-0000-0000-0000-000000000000",
				"accountFID": 71,
				"contraAccountFID": -1,
				"vatFID": -1,
				"vatAccountFID": -1,
				"costCenterFID": -1,
				"postingTypeFID": 2,
				"amount": 1000.0,
				"fcAmount": 1000.0,
				"exchangeRate": 1.0,
				"vatAmount": 0.0,
				"vatFcAmount": 0.0,
				"vatPercent": 0.0,
				"vatQuote": 0.0,
				"text": "Recivables Invoice",
				"freeCode": null,
				"isDebit": false,
				"isInclusive": false,
				"isInvisible": false,
				"postingIndex": 0,
				"partyNum": 0,
				"freepartyNum": null,
				"partyName": null,
				"invoiceNum": 0,
				"freeInvoiceNum": null,
				"invoiceDate": "0001-01-01T00:00:00"
			}
		]
	}
}

    
  
 
Create a receivable invoice VAT inclusive
Create a receivable invoice VAT inclusive.
 
External references to methods used in examples
#Code reference - GET.party_by_name
#Code reference - GET.party_by_id
#Code reference - GET.account_by_account_code
#Code reference - InternalTypes
#Code reference - POST.receivables_invoice
#Code reference - GET.receivables_invoice_by_freeinvoicenum
#Code reference - DELETE.receivables_invoice
    
        [TestMethod]
        public void REST_Receivables_invoice_inc_vat()
        {
            state = new ErrorState();
            decimal payment_amount = 10000.00m;

            Party party = GET.party_by_name("Bucherer AG", manager);
            party = GET.party_by_id(party.id, manager);

            List postings = new List();
            postings.Add(10000m);

            Invoice_DTO invoice_to = new Invoice_DTO
            {
                party = party,
                manager = manager,
                date = DateTime.Today,
                vat_code = "UStn",
                payment_amount = payment_amount,
                payment_fc_amount = payment_amount,
                posting_amounts = postings,
                text = "Recivables Invoice",
                free_inv_num = "RI_3811",
                payslip_code = "",
                contra_account = "3200",
                pay_method = "Method_1",
                invoiceType = Convert.ToBoolean(InvoiceType.INCLUSIVE),
                cost_center_code = ""
            };
            
            Invoice invoice = Create.receivables_invoice_vat(invoice_to);
            state.passed = POST.receivables_invoice(invoice, manager);
            Assert.AreEqual(true, state.passed, state.message);

            invoice = GET.receivables_invoice_by_freeinvoicenum(invoice_to.free_inv_num, manager);
            if (invoice != null) {
                state.passed = false;
                state.passed = DELETE.receivables_invoice(invoice, manager);
                Assert.AreEqual(true, state.passed, state.message);
            }
        }
        
        class Create 
        {
            public static Invoice receivables_invoice_vat(Invoice_DTO invoice_to)
            {
                IList pay_methods = invoice_to.party.debtor.payMethods;
                PayMethod pay_method = pay_methods.SingleOrDefault(m => m.name.Equals(invoice_to.pay_method));
            
                DateTime date = invoice_to.date;
                Invoice invoice = new Invoice
                {
                    dueDate = date.AddDays(30),
                    totalAmount = invoice_to.payment_amount,
                    totalAmountFC = invoice_to.payment_fc_amount,
                    PayslipCode = "",
                    Remarks = "",
                    exchangeRate = 1,
                    partyFID = invoice_to.party.id,
                    personRoleFID = (int)InternalTypes.PersonRole.Debtor,
                    payMethodFID = pay_methods.SingleOrDefault(m => m.name.Equals(invoice_to.pay_method)).id,
                    payTermFID = invoice_to.party.debtor.payTermFID,
                    freeInvoiceNum = invoice_to.free_inv_num.Equals("") ? $"Receivable_{Convert.ToString(invoice_to.payment_amount)}" : invoice_to.free_inv_num,
                    text = invoice_to.text,
                    invoiceDate = new DateTime(invoice_to.date.Year, invoice_to.date.Month, invoice_to.date.Day)
                };
                invoice.transaction.docDate = new DateTime(invoice_to.date.Year, invoice_to.date.Month, invoice_to.date.Day);

                // Create posting 1
                Posting posting1 = new Posting
                {
                    accountFID = pay_method.accountFID,  /* Invoice pay_method and paymethod_IBAN of first posting must always be the same */
                    text = invoice_to.text + " Posting #1",
                    freeCode = "Posting Free1",
                    isDebit = true,
                    postingTypeFID = (int)InternalTypes.PostingType.Invoice,
                    isInclusive = false,
                    costCenterFID = -1
                };

                if (invoice_to.payment_amount != invoice_to.payment_fc_amount)
                {
                    decimal key_currency_amount = invoice_to.exchange_rate * invoice_to.payment_fc_amount;
    
                    posting1.amount = key_currency_amount;              // mandatory
                    posting1.fcAmount = invoice_to.payment_fc_amount;   // mandatory
                    posting1.exchangeRate = invoice_to.exchange_rate;
                }
                else
                {
                    posting1.amount = invoice_to.payment_amount;    // mandatory
                    posting1.fcAmount = invoice_to.payment_fc_amount;  // mandatory
                    posting1.exchangeRate = invoice_to.exchange_rate;
                }
                invoice.transaction.postings.Add(posting1);

                foreach (decimal amount in invoice_to.posting_amounts)
                {
                    VATPosting_DTO vatposting_to = new VATPosting_DTO
                    {
                        is_inclusive = invoice_to.invoiceType,
                        vat_code = invoice_to.vat_code,
                        date = invoice_to.date,
                        manager = invoice_to.manager
                    };

                    if (invoice_to.payment_amount != invoice_to.payment_fc_amount)
                    {
                        decimal key_currency_amount = invoice_to.exchange_rate * amount;
                        vatposting_to.amount = key_currency_amount;
                        vatposting_to.fc_amount = amount;
                        vatposting_to.exchangeRate = invoice_to.exchange_rate;
                    }
                    else
                    {
    
                        vatposting_to.amount = amount;
                        vatposting_to.fc_amount = vatposting_to.amount;
                        vatposting_to.exchangeRate = 1;
                    }

                    Posting posting = GET.posting(vatposting_to);
                    posting.accountFID = GET.account_by_account_code("6510", invoice_to.manager).id;
                    posting.text = "Receivables Posting #";
                    posting.isDebit = false;
                    posting.postingTypeFID = (int)InternalTypes.PostingType.Invoice;
                    posting.isInclusive = vatposting_to.is_inclusive;

                    if (!invoice_to.cost_center_code.Equals(""))
                    {
                        int costcenter_id = GET.costcenter_by_code(invoice_to.cost_center_code, invoice_to.manager).id;
                        posting.costCenterFID = costcenter_id;
                    }
                    else { posting.costCenterFID = -1; }
                    invoice.transaction.postings.Add(posting);
                }
                invoice.transaction.transactionTypeFID = (int)InternalTypes.TransactionType.Invoice;

                return invoice;
            }
        }

    class GET {
        public static Posting posting(VATPosting_DTO vat_posting_to)
        {
            string param = $"&amount={vat_posting_to.amount}&fcAmount={vat_posting_to.fc_amount}&exchangeRate={vat_posting_to.exchangeRate}&vatCode={vat_posting_to.vat_code}&isInclusive={vat_posting_to.is_inclusive.ToString().ToLower()}";
            string request = string.Format("clients/{0}/fiscalYears/{1}/posting", vat_posting_to.manager.getCurrentClient().id, vat_posting_to.manager.getCurrentFiscalYear().id);
            request = request + "?" + param;

            var response = vat_posting_to.manager.httpClient.GetAsync(string.Format(request, vat_posting_to.manager.getCurrentClient().id, vat_posting_to.manager.getCurrentFiscalYear().id)).Result;
            var posting = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result);

            return posting;
        }
    }
    
  
Create Recivable Invoice
    
    UNDER CONSTRUCTION
    
  
JSON representation of a receivables invoice inc. vat
    
    POST Request:
    {
	"id": "00000000-0000-0000-0000-000000000000",
	"authorizerFID": -1,
	"partyFID": 1,
	"payMethodFID": 58,
	"payTermFID": 9,
	"vatFID": -1,
	"personRoleFID": 2,
	"invoiceDate": "2022-05-13T00:00:00",
	"dueDate": "2022-06-12T00:00:00+02:00",
	"modifyDate": "0001-01-01T00:00:00",
	"invoiceNum": -1,
	"reminderLevel": 0,
	"freeInvoiceNum": "RI_3811",
	"text": "Recivables Invoice",
	"PayslipCode": "",
	"totalAmount": 10000.0,
	"totalAmountFC": 10000.0,
	"exchangeRate": 1.0,
	"IsAuthorized": true,
	"noReminders": false,
	"Remarks": "",
	"partyNum": 0,
	"partyName": null,
	"partyShortName": null,
	"payTermCode": null,
	"accountCode": null,
	"currencyCode": null,
	"balance": 0.0,
	"balanceFC": 0.0,
	"barCode": null,
	"currentReminderLevel": 0,
	"hasDocument": 0,
	"currentReminderDate": "0001-01-01T00:00:00",
	"paymentPostings": [],
	"transaction": {
		"id": "00000000-0000-0000-0000-000000000000",
		"fiscalYearFID": -1,
		"userFID": -1,
		"transactionTypeFID": 3,
		"docType": null,
		"docNum": -1,
		"docDate": "2022-05-13T00:00:00",
		"modifyDate": "0001-01-01T00:00:00",
		"isConfirmed": true,
		"numRangeFID": -1,
		"hasDocument": false,
		"postings": [
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"transactionFID": "00000000-0000-0000-0000-000000000000",
				"invoiceFID": "00000000-0000-0000-0000-000000000000",
				"accountFID": 20,
				"contraAccountFID": -1,
				"vatFID": -1,
				"vatAccountFID": -1,
				"costCenterFID": -1,
				"postingTypeFID": 2,
				"amount": 10000.0,
				"fcAmount": 10000.0,
				"exchangeRate": 0.0,
				"vatAmount": 0.0,
				"vatFcAmount": 0.0,
				"vatPercent": 0.0,
				"vatQuote": 0.0,
				"text": "Recivables Invoice Posting #1",
				"freeCode": "Posting Free1",
				"isDebit": true,
				"isInclusive": false,
				"isInvisible": false,
				"postingIndex": 0,
				"partyNum": 0,
				"freepartyNum": null,
				"partyName": null,
				"invoiceNum": 0,
				"freeInvoiceNum": null,
				"invoiceDate": "0001-01-01T00:00:00"
			},
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"transactionFID": "00000000-0000-0000-0000-000000000000",
				"invoiceFID": "00000000-0000-0000-0000-000000000000",
				"accountFID": 155,
				"contraAccountFID": -1,
				"vatFID": 9,
				"vatAccountFID": 51,
				"costCenterFID": -1,
				"postingTypeFID": 2,
				"amount": 9285.05,
				"fcAmount": 9285.05,
				"exchangeRate": 1.0,
				"vatAmount": 714.95,
				"vatFcAmount": 714.95,
				"vatPercent": 7.7,
				"vatQuote": 100.0,
				"text": "Receivables Posting #",
				"freeCode": "",
				"isDebit": false,
				"isInclusive": true,
				"isInvisible": false,
				"postingIndex": 0,
				"partyNum": -1,
				"freepartyNum": "",
				"partyName": "",
				"invoiceNum": -1,
				"freeInvoiceNum": "",
				"invoiceDate": "2022-05-13T00:00:00"
			}
		]
	}
}
    
  
 
Create a receivable invoice VAT exclusive
Create a receivable invoice VAT exclusive.
 
External references to methods used in examples
#Code reference - GET.party_by_name
#Code reference - GET.party_by_id
#Code reference - GET.account_by_account_code
#Code reference - InternalTypes
#Code reference - POST.receivables_invoice
#Code reference - GET.receivables_invoice_by_freeinvoicenum
#Code reference - DELETE.receivables_invoice
    
        [TestMethod]
        public void REST_Receivables_invoice_exc_vat()
        {
            state = new ErrorState();
            decimal payment_amount = 10770.00m;

            Party party = GET.party_by_name("Bucherer AG", manager);
            party = GET.party_by_id(party.id, manager);

            List postings = new List();
            postings.Add(10000m);

            Invoice_DTO invoice_to = new Invoice_DTO
            {
                party = party,
                manager = manager,
                vat_code = "UStn",
                payment_amount = payment_amount,
                payment_fc_amount = payment_amount,
                posting_amounts = postings, 
                text = "Recivables Invoice",
                free_inv_num = "RI_3811",
                payslip_code = "",
                contra_account = "3200",
                pay_method = "Method_1",
                invoiceType = Convert.ToBoolean(InvoiceType.EXCLUSIVE),
                date = DateTime.Today,
                cost_center_code = ""
            };

            Invoice invoice = Create.receivables_invoice_vat(invoice_to);
            state.passed = POST.receivables_invoice(invoice, manager);
            Assert.AreEqual(true, state.passed, state.message);

            invoice = GET.receivables_invoice_by_freeinvoicenum(invoice_to.free_inv_num, manager);
            if (invoice != null)
            {
                state.passed = false;
                state.passed = DELETE.receivables_invoice(invoice, manager);
                Assert.AreEqual(true, state.passed, state.message);
            }
        }
        
        class Create 
        {
            public static Invoice receivables_invoice_vat(Invoice_DTO invoice_to)
            {
                IList pay_methods = invoice_to.party.debtor.payMethods;
                PayMethod pay_method = pay_methods.SingleOrDefault(m => m.name.Equals(invoice_to.pay_method));
            
                DateTime date = invoice_to.date;
                Invoice invoice = new Invoice
                {
                    dueDate = date.AddDays(30),
                    totalAmount = invoice_to.payment_amount,
                    totalAmountFC = invoice_to.payment_fc_amount,
                    PayslipCode = "",
                    Remarks = "",
                    exchangeRate = 1,
                    partyFID = invoice_to.party.id,
                    personRoleFID = (int)InternalTypes.PersonRole.Debtor,
                    payMethodFID = pay_methods.SingleOrDefault(m => m.name.Equals(invoice_to.pay_method)).id,
                    payTermFID = invoice_to.party.debtor.payTermFID,
                    freeInvoiceNum = invoice_to.free_inv_num.Equals("") ? $"Receivable_{Convert.ToString(invoice_to.payment_amount)}" : invoice_to.free_inv_num,
                    text = invoice_to.text,
                    invoiceDate = new DateTime(invoice_to.date.Year, invoice_to.date.Month, invoice_to.date.Day)
                };
                invoice.transaction.docDate = new DateTime(invoice_to.date.Year, invoice_to.date.Month, invoice_to.date.Day);

                // Create posting 1
                Posting posting1 = new Posting
                {
                    accountFID = pay_method.accountFID,  /* Invoice pay_method and paymethod_IBAN of first posting must always be the same */
                    text = invoice_to.text + " Posting #1",
                    freeCode = "Posting Free1",
                    isDebit = true,
                    postingTypeFID = (int)InternalTypes.PostingType.Invoice,
                    isInclusive = false,
                    costCenterFID = -1
                };

                if (invoice_to.payment_amount != invoice_to.payment_fc_amount)
                {
                    decimal key_currency_amount = invoice_to.exchange_rate * invoice_to.payment_fc_amount;
    
                    posting1.amount = key_currency_amount;              // mandatory
                    posting1.fcAmount = invoice_to.payment_fc_amount;   // mandatory
                    posting1.exchangeRate = invoice_to.exchange_rate;
                }
                else
                {
                    posting1.amount = invoice_to.payment_amount;    // mandatory
                    posting1.fcAmount = invoice_to.payment_fc_amount;  // mandatory
                    posting1.exchangeRate = invoice_to.exchange_rate;
                }
                invoice.transaction.postings.Add(posting1);

                foreach (decimal amount in invoice_to.posting_amounts)
                {
                    VATPosting_DTO vatposting_to = new VATPosting_DTO
                    {
                        is_inclusive = invoice_to.invoiceType,
                        vat_code = invoice_to.vat_code,
                        date = invoice_to.date,
                        manager = invoice_to.manager
                    };

                    if (invoice_to.payment_amount != invoice_to.payment_fc_amount)
                    {
                        decimal key_currency_amount = invoice_to.exchange_rate * amount;
                        vatposting_to.amount = key_currency_amount;
                        vatposting_to.fc_amount = amount;
                        vatposting_to.exchangeRate = invoice_to.exchange_rate;
                    }
                    else
                    {
    
                        vatposting_to.amount = amount;
                        vatposting_to.fc_amount = vatposting_to.amount;
                        vatposting_to.exchangeRate = 1;
                    }

                    Posting posting = GET.posting(vatposting_to);
                    posting.accountFID = GET.account_by_account_code("6510", invoice_to.manager).id;
                    posting.text = "Receivables Posting #";
                    posting.isDebit = false;
                    posting.postingTypeFID = (int)InternalTypes.PostingType.Invoice;
                    posting.isInclusive = vatposting_to.is_inclusive;

                    if (!invoice_to.cost_center_code.Equals(""))
                    {
                        int costcenter_id = GET.costcenter_by_code(invoice_to.cost_center_code, invoice_to.manager).id;
                        posting.costCenterFID = costcenter_id;
                    }
                    else { posting.costCenterFID = -1; }
                    invoice.transaction.postings.Add(posting);
                }
                invoice.transaction.transactionTypeFID = (int)InternalTypes.TransactionType.Invoice;

                return invoice;
            }
        }


    class GET {
        public static Posting posting(VATPosting_DTO vat_posting_to)
        {
            string param = $"&amount={vat_posting_to.amount}&fcAmount={vat_posting_to.fc_amount}&exchangeRate={vat_posting_to.exchangeRate}&vatCode={vat_posting_to.vat_code}&isInclusive={vat_posting_to.is_inclusive.ToString().ToLower()}";
            string request = string.Format("clients/{0}/fiscalYears/{1}/posting", vat_posting_to.manager.getCurrentClient().id, vat_posting_to.manager.getCurrentFiscalYear().id);
            request = request + "?" + param;

            var response = vat_posting_to.manager.httpClient.GetAsync(string.Format(request, vat_posting_to.manager.getCurrentClient().id, vat_posting_to.manager.getCurrentFiscalYear().id)).Result;
            var posting = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result);

            return posting;
        }
    }
    
  
Create Recivable Invoice
    
    UNDER CONSTRUCTION
    
  
JSON representation of a receivables invoice inc. vat
    
    POST Request:
    {
	"id": "00000000-0000-0000-0000-000000000000",
	"authorizerFID": -1,
	"partyFID": 1,
	"payMethodFID": 58,
	"payTermFID": 9,
	"vatFID": -1,
	"personRoleFID": 2,
	"invoiceDate": "2022-05-13T00:00:00",
	"dueDate": "2022-06-12T00:00:00+02:00",
	"modifyDate": "0001-01-01T00:00:00",
	"invoiceNum": -1,
	"reminderLevel": 0,
	"freeInvoiceNum": "RI_3811",
	"text": "Recivables Invoice",
	"PayslipCode": "",
	"totalAmount": 10770.0,
	"totalAmountFC": 10770.0,
	"exchangeRate": 1.0,
	"IsAuthorized": true,
	"noReminders": false,
	"Remarks": "",
	"partyNum": 0,
	"partyName": null,
	"partyShortName": null,
	"payTermCode": null,
	"accountCode": null,
	"currencyCode": null,
	"balance": 0.0,
	"balanceFC": 0.0,
	"barCode": null,
	"currentReminderLevel": 0,
	"hasDocument": 0,
	"currentReminderDate": "0001-01-01T00:00:00",
	"paymentPostings": [],
	"transaction": {
		"id": "00000000-0000-0000-0000-000000000000",
		"fiscalYearFID": -1,
		"userFID": -1,
		"transactionTypeFID": 3,
		"docType": null,
		"docNum": -1,
		"docDate": "2022-05-13T00:00:00",
		"modifyDate": "0001-01-01T00:00:00",
		"isConfirmed": true,
		"numRangeFID": -1,
		"hasDocument": false,
		"postings": [
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"transactionFID": "00000000-0000-0000-0000-000000000000",
				"invoiceFID": "00000000-0000-0000-0000-000000000000",
				"accountFID": 20,
				"contraAccountFID": -1,
				"vatFID": -1,
				"vatAccountFID": -1,
				"costCenterFID": -1,
				"postingTypeFID": 2,
				"amount": 10770.0,
				"fcAmount": 10770.0,
				"exchangeRate": 0.0,
				"vatAmount": 0.0,
				"vatFcAmount": 0.0,
				"vatPercent": 0.0,
				"vatQuote": 0.0,
				"text": "Recivables Invoice Posting #1",
				"freeCode": "Posting Free1",
				"isDebit": true,
				"isInclusive": false,
				"isInvisible": false,
				"postingIndex": 0,
				"partyNum": 0,
				"freepartyNum": null,
				"partyName": null,
				"invoiceNum": 0,
				"freeInvoiceNum": null,
				"invoiceDate": "0001-01-01T00:00:00"
			},
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"transactionFID": "00000000-0000-0000-0000-000000000000",
				"invoiceFID": "00000000-0000-0000-0000-000000000000",
				"accountFID": 155,
				"contraAccountFID": -1,
				"vatFID": 9,
				"vatAccountFID": 51,
				"costCenterFID": -1,
				"postingTypeFID": 2,
				"amount": 10000.0,
				"fcAmount": 10000.0,
				"exchangeRate": 1.0,
				"vatAmount": 770.0,
				"vatFcAmount": 770.0,
				"vatPercent": 7.7,
				"vatQuote": 100.0,
				"text": "Receivables Posting #",
				"freeCode": "",
				"isDebit": false,
				"isInclusive": false,
				"isInvisible": false,
				"postingIndex": 0,
				"partyNum": -1,
				"freepartyNum": "",
				"partyName": "",
				"invoiceNum": -1,
				"freeInvoiceNum": "",
				"invoiceDate": "2022-05-13T00:00:00"
			}
		]
	}
}
    
  
 
Create a receivable invoice multi posting VAT inclusive
Create a receivable invoice multi posting VAT inclusive.
 
External references to methods used in examples
#Code reference - GET.party_by_name
#Code reference - GET.party_by_id
#Code reference - GET.account_by_account_code
#Code reference - InternalTypes
#Code reference - POST.receivables_invoice
#Code reference - GET.receivables_invoice_by_freeinvoicenum
#Code reference - DELETE.receivables_invoice
    
        [TestMethod]
        public void REST_Receivables_invoice_multi_posting_inc_vat()
        {
            state = new ErrorState { passed = false};
            decimal payment_amount = 16200m;

            Party party = GET.party_by_name("Bucherer AG", manager);
            party = GET.party_by_id(party.id, manager);

            List postings = new List();
            postings.Add(5000m);
            postings.Add(3400m);
            postings.Add(7800m);

            Invoice_DTO invoice_to = new Invoice_DTO
            {
                party = party,
                manager = manager,
                date = DateTime.Today,
                vat_code = "UStn",
                payment_amount = payment_amount,
                payment_fc_amount = payment_amount,
                posting_amounts = postings,
                text = "Recivables Invoice",
                free_inv_num = "RI_3802",
                payslip_code = "",
                contra_account = "3200",
                pay_method = "Method_1",
                invoiceType = Convert.ToBoolean(InvoiceType.INCLUSIVE),
                cost_center_code = ""
            };
            invoice_to.payment_fc_amount = invoice_to.payment_amount;
            invoice_to.date = DateTime.Now;

            Invoice invoice = Create.receivables_invoice_vat(invoice_to);
            state.passed = POST.receivables_invoice(invoice, manager);
            Assert.AreEqual(true, state.passed, state.message);

            invoice = GET.receivables_invoice_by_freeinvoicenum(invoice_to.free_inv_num, manager);
            if (invoice != null)
            {
                state.passed = false;
                state.passed = DELETE.receivables_invoice(invoice, manager);
                Assert.AreEqual(true, state.passed, state.message);
            }
        }
        
        class Create 
        {
            public static Invoice receivables_invoice_vat(Invoice_DTO invoice_to)
            {
                IList pay_methods = invoice_to.party.debtor.payMethods;
                PayMethod pay_method = pay_methods.SingleOrDefault(m => m.name.Equals(invoice_to.pay_method));
            
                DateTime date = invoice_to.date;
                Invoice invoice = new Invoice
                {
                    dueDate = date.AddDays(30),
                    totalAmount = invoice_to.payment_amount,
                    totalAmountFC = invoice_to.payment_fc_amount,
                    PayslipCode = "",
                    Remarks = "",
                    exchangeRate = 1,
                    partyFID = invoice_to.party.id,
                    personRoleFID = (int)InternalTypes.PersonRole.Debtor,
                    payMethodFID = pay_methods.SingleOrDefault(m => m.name.Equals(invoice_to.pay_method)).id,
                    payTermFID = invoice_to.party.debtor.payTermFID,
                    freeInvoiceNum = invoice_to.free_inv_num.Equals("") ? $"Receivable_{Convert.ToString(invoice_to.payment_amount)}" : invoice_to.free_inv_num,
                    text = invoice_to.text,
                    invoiceDate = new DateTime(invoice_to.date.Year, invoice_to.date.Month, invoice_to.date.Day)
                };
                invoice.transaction.docDate = new DateTime(invoice_to.date.Year, invoice_to.date.Month, invoice_to.date.Day);

                // Create posting 1
                Posting posting1 = new Posting
                {
                    accountFID = pay_method.accountFID,  /* Invoice pay_method and paymethod_IBAN of first posting must always be the same */
                    text = invoice_to.text + " Posting #1",
                    freeCode = "Posting Free1",
                    isDebit = true,
                    postingTypeFID = (int)InternalTypes.PostingType.Invoice,
                    isInclusive = false,
                    costCenterFID = -1
                };

                if (invoice_to.payment_amount != invoice_to.payment_fc_amount)
                {
                    decimal key_currency_amount = invoice_to.exchange_rate * invoice_to.payment_fc_amount;
    
                    posting1.amount = key_currency_amount;              // mandatory
                    posting1.fcAmount = invoice_to.payment_fc_amount;   // mandatory
                    posting1.exchangeRate = invoice_to.exchange_rate;
                }
                else
                {
                    posting1.amount = invoice_to.payment_amount;    // mandatory
                    posting1.fcAmount = invoice_to.payment_fc_amount;  // mandatory
                    posting1.exchangeRate = invoice_to.exchange_rate;
                }
                invoice.transaction.postings.Add(posting1);

                foreach (decimal amount in invoice_to.posting_amounts)
                {
                    VATPosting_DTO vatposting_to = new VATPosting_DTO
                    {
                        is_inclusive = invoice_to.invoiceType,
                        vat_code = invoice_to.vat_code,
                        date = invoice_to.date,
                        manager = invoice_to.manager
                    };

                    if (invoice_to.payment_amount != invoice_to.payment_fc_amount)
                    {
                        decimal key_currency_amount = invoice_to.exchange_rate * amount;
                        vatposting_to.amount = key_currency_amount;
                        vatposting_to.fc_amount = amount;
                        vatposting_to.exchangeRate = invoice_to.exchange_rate;
                    }
                    else
                    {
    
                        vatposting_to.amount = amount;
                        vatposting_to.fc_amount = vatposting_to.amount;
                        vatposting_to.exchangeRate = 1;
                    }

                    Posting posting = GET.posting(vatposting_to);
                    posting.accountFID = GET.account_by_account_code("6510", invoice_to.manager).id;
                    posting.text = "Receivables Posting #";
                    posting.isDebit = false;
                    posting.postingTypeFID = (int)InternalTypes.PostingType.Invoice;
                    posting.isInclusive = vatposting_to.is_inclusive;

                    if (!invoice_to.cost_center_code.Equals(""))
                    {
                        int costcenter_id = GET.costcenter_by_code(invoice_to.cost_center_code, invoice_to.manager).id;
                        posting.costCenterFID = costcenter_id;
                    }
                    else { posting.costCenterFID = -1; }
                    invoice.transaction.postings.Add(posting);
                }
                invoice.transaction.transactionTypeFID = (int)InternalTypes.TransactionType.Invoice;

                return invoice;
            }
        }


    class GET {
        public static Posting posting(VATPosting_DTO vat_posting_to)
        {
            string param = $"&amount={vat_posting_to.amount}&fcAmount={vat_posting_to.fc_amount}&exchangeRate={vat_posting_to.exchangeRate}&vatCode={vat_posting_to.vat_code}&isInclusive={vat_posting_to.is_inclusive.ToString().ToLower()}";
            string request = string.Format("clients/{0}/fiscalYears/{1}/posting", vat_posting_to.manager.getCurrentClient().id, vat_posting_to.manager.getCurrentFiscalYear().id);
            request = request + "?" + param;

            var response = vat_posting_to.manager.httpClient.GetAsync(string.Format(request, vat_posting_to.manager.getCurrentClient().id, vat_posting_to.manager.getCurrentFiscalYear().id)).Result;
            var posting = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result);

            return posting;
        }
    }
    
  
Create Recivable Invoice
    
    UNDER CONSTRUCTION
    
  
JSON representation of a receivables invoice inc. vat
    
    POST Request:
    {
	"id": "00000000-0000-0000-0000-000000000000",
	"authorizerFID": -1,
	"partyFID": 1,
	"payMethodFID": 58,
	"payTermFID": 9,
	"vatFID": -1,
	"personRoleFID": 2,
	"invoiceDate": "2022-05-13T00:00:00",
	"dueDate": "2022-06-12T11:02:45.9691004+02:00",
	"modifyDate": "0001-01-01T00:00:00",
	"invoiceNum": -1,
	"reminderLevel": 0,
	"freeInvoiceNum": "RI_3802",
	"text": "Recivables Invoice",
	"PayslipCode": "",
	"totalAmount": 16200.0,
	"totalAmountFC": 16200.0,
	"exchangeRate": 1.0,
	"IsAuthorized": true,
	"noReminders": false,
	"Remarks": "",
	"partyNum": 0,
	"partyName": null,
	"partyShortName": null,
	"payTermCode": null,
	"accountCode": null,
	"currencyCode": null,
	"balance": 0.0,
	"balanceFC": 0.0,
	"barCode": null,
	"currentReminderLevel": 0,
	"hasDocument": 0,
	"currentReminderDate": "0001-01-01T00:00:00",
	"paymentPostings": [],
	"transaction": {
		"id": "00000000-0000-0000-0000-000000000000",
		"fiscalYearFID": -1,
		"userFID": -1,
		"transactionTypeFID": 3,
		"docType": null,
		"docNum": -1,
		"docDate": "2022-05-13T00:00:00",
		"modifyDate": "0001-01-01T00:00:00",
		"isConfirmed": true,
		"numRangeFID": -1,
		"hasDocument": false,
		"postings": [
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"transactionFID": "00000000-0000-0000-0000-000000000000",
				"invoiceFID": "00000000-0000-0000-0000-000000000000",
				"accountFID": 20,
				"contraAccountFID": -1,
				"vatFID": -1,
				"vatAccountFID": -1,
				"costCenterFID": -1,
				"postingTypeFID": 2,
				"amount": 16200.0,
				"fcAmount": 16200.0,
				"exchangeRate": 0.0,
				"vatAmount": 0.0,
				"vatFcAmount": 0.0,
				"vatPercent": 0.0,
				"vatQuote": 0.0,
				"text": "Recivables Invoice Posting #1",
				"freeCode": "Posting Free1",
				"isDebit": true,
				"isInclusive": false,
				"isInvisible": false,
				"postingIndex": 0,
				"partyNum": 0,
				"freepartyNum": null,
				"partyName": null,
				"invoiceNum": 0,
				"freeInvoiceNum": null,
				"invoiceDate": "0001-01-01T00:00:00"
			},
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"transactionFID": "00000000-0000-0000-0000-000000000000",
				"invoiceFID": "00000000-0000-0000-0000-000000000000",
				"accountFID": 155,
				"contraAccountFID": -1,
				"vatFID": 9,
				"vatAccountFID": 51,
				"costCenterFID": -1,
				"postingTypeFID": 2,
				"amount": 4642.53,
				"fcAmount": 4642.53,
				"exchangeRate": 1.0,
				"vatAmount": 357.47,
				"vatFcAmount": 357.47,
				"vatPercent": 7.7,
				"vatQuote": 100.0,
				"text": "Receivables Posting #",
				"freeCode": "",
				"isDebit": false,
				"isInclusive": true,
				"isInvisible": false,
				"postingIndex": 0,
				"partyNum": -1,
				"freepartyNum": "",
				"partyName": "",
				"invoiceNum": -1,
				"freeInvoiceNum": "",
				"invoiceDate": "2022-05-13T00:00:00"
			},
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"transactionFID": "00000000-0000-0000-0000-000000000000",
				"invoiceFID": "00000000-0000-0000-0000-000000000000",
				"accountFID": 155,
				"contraAccountFID": -1,
				"vatFID": 9,
				"vatAccountFID": 51,
				"costCenterFID": -1,
				"postingTypeFID": 2,
				"amount": 3156.92,
				"fcAmount": 3156.92,
				"exchangeRate": 1.0,
				"vatAmount": 243.08,
				"vatFcAmount": 243.08,
				"vatPercent": 7.7,
				"vatQuote": 100.0,
				"text": "Receivables Posting #",
				"freeCode": "",
				"isDebit": false,
				"isInclusive": true,
				"isInvisible": false,
				"postingIndex": 0,
				"partyNum": -1,
				"freepartyNum": "",
				"partyName": "",
				"invoiceNum": -1,
				"freeInvoiceNum": "",
				"invoiceDate": "2022-05-13T00:00:00"
			},
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"transactionFID": "00000000-0000-0000-0000-000000000000",
				"invoiceFID": "00000000-0000-0000-0000-000000000000",
				"accountFID": 155,
				"contraAccountFID": -1,
				"vatFID": 9,
				"vatAccountFID": 51,
				"costCenterFID": -1,
				"postingTypeFID": 2,
				"amount": 7242.34,
				"fcAmount": 7242.34,
				"exchangeRate": 1.0,
				"vatAmount": 557.66,
				"vatFcAmount": 557.66,
				"vatPercent": 7.7,
				"vatQuote": 100.0,
				"text": "Receivables Posting #",
				"freeCode": "",
				"isDebit": false,
				"isInclusive": true,
				"isInvisible": false,
				"postingIndex": 0,
				"partyNum": -1,
				"freepartyNum": "",
				"partyName": "",
				"invoiceNum": -1,
				"freeInvoiceNum": "",
				"invoiceDate": "2022-05-13T00:00:00"
			}
		]
	}
}    
  
 
Create a receivable invoice VAT multi posting exclusive
Create a receivable invoice multi posting VAT exclusive.
 
External references to methods used in examples
#Code reference - GET.party_by_name
#Code reference - GET.party_by_id
#Code reference - GET.account_by_account_code
#Code reference - InternalTypes
#Code reference - POST.receivables_invoice
#Code reference - GET.receivables_invoice_by_freeinvoicenum
#Code reference - DELETE.receivables_invoice
    
        [TestMethod]
        public void REST_Receivables_invoice_multi_posting_exc_vat()
        {
            state = new ErrorState { passed = false};
            decimal payment_amount = 17447.40m;
            
            Party party = GET.party_by_name("Bucherer AG", manager);
            party = GET.party_by_id(party.id, manager);

            List postings = new List();
            postings.Add(5000m);
            postings.Add(3400m);
            postings.Add(7800m);

            Invoice_DTO invoice_dto = new Invoice_DTO
            {
                party = party,
                manager = manager,
                date = DateTime.Today,
                vat_code = "UStn",
                payment_amount = payment_amount,
                payment_fc_amount = payment_amount,
                posting_amounts = postings,
                text = "Recivables Invoice",
                free_inv_num = "RI_3802",
                payslip_code = "",
                contra_account = "3200",
                pay_method = "Method_1",
                invoiceType = Convert.ToBoolean(InvoiceType.EXCLUSIVE),
                cost_center_code = ""
            };
            invoice_dto.payment_fc_amount = invoice_dto.payment_amount;
            invoice_dto.date = DateTime.Now;

            Invoice invoice = Create.receivables_invoice_vat(invoice_dto);
            state.passed = POST.receivables_invoice(invoice, manager);
            Assert.AreEqual(true, state.passed, state.message);

            invoice = GET.receivables_invoice_by_freeinvoicenum(invoice_dto.free_inv_num, manager);
            if (invoice != null)
            {
                state.passed = false;
                state.passed = DELETE.receivables_invoice(invoice, manager);
                Assert.AreEqual(true, state.passed, state.message);
            }
        }
        
        class Create 
        {
            public static Invoice receivables_invoice_vat(Invoice_DTO invoice_to)
            {
                IList pay_methods = invoice_to.party.debtor.payMethods;
                PayMethod pay_method = pay_methods.SingleOrDefault(m => m.name.Equals(invoice_to.pay_method));
            
                DateTime date = invoice_to.date;
                Invoice invoice = new Invoice
                {
                    dueDate = date.AddDays(30),
                    totalAmount = invoice_to.payment_amount,
                    totalAmountFC = invoice_to.payment_fc_amount,
                    PayslipCode = "",
                    Remarks = "",
                    exchangeRate = 1,
                    partyFID = invoice_to.party.id,
                    personRoleFID = (int)InternalTypes.PersonRole.Debtor,
                    payMethodFID = pay_methods.SingleOrDefault(m => m.name.Equals(invoice_to.pay_method)).id,
                    payTermFID = invoice_to.party.debtor.payTermFID,
                    freeInvoiceNum = invoice_to.free_inv_num.Equals("") ? $"Receivable_{Convert.ToString(invoice_to.payment_amount)}" : invoice_to.free_inv_num,
                    text = invoice_to.text,
                    invoiceDate = new DateTime(invoice_to.date.Year, invoice_to.date.Month, invoice_to.date.Day)
                };
                invoice.transaction.docDate = new DateTime(invoice_to.date.Year, invoice_to.date.Month, invoice_to.date.Day);

                // Create posting 1
                Posting posting1 = new Posting
                {
                    accountFID = pay_method.accountFID,  /* Invoice pay_method and paymethod_IBAN of first posting must always be the same */
                    text = invoice_to.text + " Posting #1",
                    freeCode = "Posting Free1",
                    isDebit = true,
                    postingTypeFID = (int)InternalTypes.PostingType.Invoice,
                    isInclusive = false,
                    costCenterFID = -1
                };

                if (invoice_to.payment_amount != invoice_to.payment_fc_amount)
                {
                    decimal key_currency_amount = invoice_to.exchange_rate * invoice_to.payment_fc_amount;
    
                    posting1.amount = key_currency_amount;              // mandatory
                    posting1.fcAmount = invoice_to.payment_fc_amount;   // mandatory
                    posting1.exchangeRate = invoice_to.exchange_rate;
                }
                else
                {
                    posting1.amount = invoice_to.payment_amount;    // mandatory
                    posting1.fcAmount = invoice_to.payment_fc_amount;  // mandatory
                    posting1.exchangeRate = invoice_to.exchange_rate;
                }
                invoice.transaction.postings.Add(posting1);

                foreach (decimal amount in invoice_to.posting_amounts)
                {
                    VATPosting_DTO vatposting_to = new VATPosting_DTO
                    {
                        is_inclusive = invoice_to.invoiceType,
                        vat_code = invoice_to.vat_code,
                        date = invoice_to.date,
                        manager = invoice_to.manager
                    };

                    if (invoice_to.payment_amount != invoice_to.payment_fc_amount)
                    {
                        decimal key_currency_amount = invoice_to.exchange_rate * amount;
                        vatposting_to.amount = key_currency_amount;
                        vatposting_to.fc_amount = amount;
                        vatposting_to.exchangeRate = invoice_to.exchange_rate;
                    }
                    else
                    {
    
                        vatposting_to.amount = amount;
                        vatposting_to.fc_amount = vatposting_to.amount;
                        vatposting_to.exchangeRate = 1;
                    }

                    Posting posting = GET.posting(vatposting_to);
                    posting.accountFID = GET.account_by_account_code("6510", invoice_to.manager).id;
                    posting.text = "Receivables Posting #";
                    posting.isDebit = false;
                    posting.postingTypeFID = (int)InternalTypes.PostingType.Invoice;
                    posting.isInclusive = vatposting_to.is_inclusive;

                    if (!invoice_to.cost_center_code.Equals(""))
                    {
                        int costcenter_id = GET.costcenter_by_code(invoice_to.cost_center_code, invoice_to.manager).id;
                        posting.costCenterFID = costcenter_id;
                    }
                    else { posting.costCenterFID = -1; }
                    invoice.transaction.postings.Add(posting);
                }
                invoice.transaction.transactionTypeFID = (int)InternalTypes.TransactionType.Invoice;

                return invoice;
            }
        }

    class GET {
        public static Posting posting(VATPosting_DTO vat_posting_to)
        {
            string param = $"&amount={vat_posting_to.amount}&fcAmount={vat_posting_to.fc_amount}&exchangeRate={vat_posting_to.exchangeRate}&vatCode={vat_posting_to.vat_code}&isInclusive={vat_posting_to.is_inclusive.ToString().ToLower()}";
            string request = string.Format("clients/{0}/fiscalYears/{1}/posting", vat_posting_to.manager.getCurrentClient().id, vat_posting_to.manager.getCurrentFiscalYear().id);
            request = request + "?" + param;

            var response = vat_posting_to.manager.httpClient.GetAsync(string.Format(request, vat_posting_to.manager.getCurrentClient().id, vat_posting_to.manager.getCurrentFiscalYear().id)).Result;
            var posting = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result);

            return posting;
        }
    }
    
  
Create Recivable Invoice
    
    UNDER CONSTRUCTION
    
  
JSON representation of a receivables invoice inc. vat
    
    POST Request:
    {
	"id": "00000000-0000-0000-0000-000000000000",
	"authorizerFID": -1,
	"partyFID": 1,
	"payMethodFID": 58,
	"payTermFID": 9,
	"vatFID": -1,
	"personRoleFID": 2,
	"invoiceDate": "2022-05-13T00:00:00",
	"dueDate": "2022-06-12T00:00:00+02:00",
	"modifyDate": "0001-01-01T00:00:00",
	"invoiceNum": -1,
	"reminderLevel": 0,
	"freeInvoiceNum": "RI_3811",
	"text": "Recivables Invoice",
	"PayslipCode": "",
	"totalAmount": 10770.0,
	"totalAmountFC": 10770.0,
	"exchangeRate": 1.0,
	"IsAuthorized": true,
	"noReminders": false,
	"Remarks": "",
	"partyNum": 0,
	"partyName": null,
	"partyShortName": null,
	"payTermCode": null,
	"accountCode": null,
	"currencyCode": null,
	"balance": 0.0,
	"balanceFC": 0.0,
	"barCode": null,
	"currentReminderLevel": 0,
	"hasDocument": 0,
	"currentReminderDate": "0001-01-01T00:00:00",
	"paymentPostings": [],
	"transaction": {
		"id": "00000000-0000-0000-0000-000000000000",
		"fiscalYearFID": -1,
		"userFID": -1,
		"transactionTypeFID": 3,
		"docType": null,
		"docNum": -1,
		"docDate": "2022-05-13T00:00:00",
		"modifyDate": "0001-01-01T00:00:00",
		"isConfirmed": true,
		"numRangeFID": -1,
		"hasDocument": false,
		"postings": [
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"transactionFID": "00000000-0000-0000-0000-000000000000",
				"invoiceFID": "00000000-0000-0000-0000-000000000000",
				"accountFID": 20,
				"contraAccountFID": -1,
				"vatFID": -1,
				"vatAccountFID": -1,
				"costCenterFID": -1,
				"postingTypeFID": 2,
				"amount": 10770.0,
				"fcAmount": 10770.0,
				"exchangeRate": 0.0,
				"vatAmount": 0.0,
				"vatFcAmount": 0.0,
				"vatPercent": 0.0,
				"vatQuote": 0.0,
				"text": "Recivables Invoice Posting #1",
				"freeCode": "Posting Free1",
				"isDebit": true,
				"isInclusive": false,
				"isInvisible": false,
				"postingIndex": 0,
				"partyNum": 0,
				"freepartyNum": null,
				"partyName": null,
				"invoiceNum": 0,
				"freeInvoiceNum": null,
				"invoiceDate": "0001-01-01T00:00:00"
			},
			{
				"id": "00000000-0000-0000-0000-000000000000",
				"transactionFID": "00000000-0000-0000-0000-000000000000",
				"invoiceFID": "00000000-0000-0000-0000-000000000000",
				"accountFID": 155,
				"contraAccountFID": -1,
				"vatFID": 9,
				"vatAccountFID": 51,
				"costCenterFID": -1,
				"postingTypeFID": 2,
				"amount": 10000.0,
				"fcAmount": 10000.0,
				"exchangeRate": 1.0,
				"vatAmount": 770.0,
				"vatFcAmount": 770.0,
				"vatPercent": 7.7,
				"vatQuote": 100.0,
				"text": "Receivables Posting #",
				"freeCode": "",
				"isDebit": false,
				"isInclusive": false,
				"isInvisible": false,
				"postingIndex": 0,
				"partyNum": -1,
				"freepartyNum": "",
				"partyName": "",
				"invoiceNum": -1,
				"freeInvoiceNum": "",
				"invoiceDate": "2022-05-13T00:00:00"
			}
		]
	}
}