Transaction

This section contains code samples related to transactions.
 
Example Code
 
 
Load transactions
Load all transactions.
 
    
    class Load
    {
        public static List<Transaction> transactions(Manager manager)
        {
            var currentClient = manager.getCurrentClient();
            var currentFiscalYear = manager.getCurrentFiscalYear();
            List<Transaction> transactions = null;

            string request = "clients/{0}/fiscalYears/{1}/transactions";
            var response = manager.httpClient.GetAsync(string.Format(request, currentClient.id, currentFiscalYear.id)).Result;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                transactions = JsonConvert.DeserializeObject<List<Transaction>>(response.Content.ReadAsStringAsync().Result);
            }

            return transactions;
        }
    }
    
  
Load Transactions
    
class Load:
  
    @staticmethod
    def transactions(manager):
        
        _currentClient = manager.getCurrentClient()
        _currentFiscalyear = manager.getCurrentFiscalyear()
        
        url = '{0}clients/{1}/fiscalYears/{2}/transactions'.format(manager.baseURL(), 
                                                                   _currentClient['id'], 
                                                                   _currentFiscalyear['id'])
                                                              
        response = requests.get(url, headers = manager.headers())

        if response.status_code == 200:
            return response.json()
        else:
            print(response.content())
            return None

    
  
Load Transactions
    
      UNDER CONSTRUCTION
    
  
JSON representation of a transaction
    
{
	"id": "10769dd5-9a3c-4721-9e56-6ad58f061b57",
	"fiscalYearFID": 55,
	"userFID": 21,
	"transactionTypeFID": 3,
	"docType": "",
	"docNum": 458,
	"docDate": "2019-06-06T00:00:00",
	"modifyDate": "2019-06-06T14:56:11.803",
	"isConfirmed": true,
	"numRangeFID": 265,
	"postings": [
		{
			"id": "eaa6596c-5858-4534-848f-5010fb89b04f",
			"transactionFID": "10769dd5-9a3c-4721-9e56-6ad58f061b57",
			"invoiceFID": "10769dd5-9a3c-4721-9e56-6ad58f061b57",
			"accountFID": 46,
			"contraAccountFID": 71,
			"vatFID": -1,
			"vatAccountFID": -1,
			"costCenterFID": -1,
			"postingTypeFID": 2,
			"amount": 4000.0,
			"fcAmount": 4000.0,
			"exchangeRate": 1.0,
			"vatAmount": 0.0,
			"vatFcAmount": 0.0,
			"vatPercent": 0.0,
			"vatQuote": 0.0,
			"text": "New Payables Invoice Posting #1",
			"freeCode": "Posting Free",
			"isDebit": false,
			"isInclusive": false,
			"isInvisible": false,
			"postingIndex": 1,
			"partyNum": 0,
			"freepartyNum": null,
			"partyName": null,
			"invoiceNum": 0,
			"freeInvoiceNum": null,
			"invoiceDate": "0001-01-01T00:00:00"
		},
		{
			"id": "40b21a88-b6a4-46e4-8e5f-d72839dbd657",
			"transactionFID": "10769dd5-9a3c-4721-9e56-6ad58f061b57",
			"invoiceFID": "10769dd5-9a3c-4721-9e56-6ad58f061b57",
			"accountFID": 71,
			"contraAccountFID": 46,
			"vatFID": -1,
			"vatAccountFID": -1,
			"costCenterFID": -1,
			"postingTypeFID": 2,
			"amount": 4000.0,
			"fcAmount": 4000.0,
			"exchangeRate": 1.0,
			"vatAmount": 0.0,
			"vatFcAmount": 0.0,
			"vatPercent": 0.0,
			"vatQuote": 0.0,
			"text": "New Payables Invoice Posting #2 (VAT posting)",
			"freeCode": "",
			"isDebit": true,
			"isInclusive": true,
			"isInvisible": false,
			"postingIndex": 2,
			"partyNum": 0,
			"freepartyNum": null,
			"partyName": null,
			"invoiceNum": 0,
			"freeInvoiceNum": null,
			"invoiceDate": "0001-01-01T00:00:00"
		}
	]
}
    
  
 
Load a transaction by id
 
    
    class Load
    {
        public static Transaction transaction_by_id(Guid id, Manager manager)
        {
            var currentClient = manager.getCurrentClient();
            var currentFiscalYear = manager.getCurrentFiscalYear();
            Transaction transactions = null;

            string request = "clients/{0}/fiscalYears/{1}/transactions/{2}";
            var response = manager.httpClient.GetAsync(string.Format(request, currentClient.id, currentFiscalYear.id, id)).Result;
            
            if (response.StatusCode == HttpStatusCode.OK)
            {
               transaction = JsonConvert.DeserializeObject<Transaction>(response.Content.ReadAsStringAsync().Result);
            }
            return transaction;
        }
    }
    
  
Load transaction by id
    

    
  
Load transaction by id
    
      UNDER CONSTRUCTION
    
  
JSON representation of a transaction