In this example you need that Capitex Företagslån is installed on the same host as the html-page that makes the servercall. We also have a possibility for cross domain calls using JSONP but that involves handling of a security token and is a bit more complicated, but contact us if you are interested in that kind of calls instead.

In this example you need that Capitex Företagslån is installed on the same host as the html-page that makes the servercall. We also have a possibility for cross domain calls using JSONP but that involves handling of a security token and is a bit more complicated, but contact us if you are interested in that kind of calls instead.

Input: 

Field

2017-01-01
2017-12-31

2018-01-01
2018-12-31

2019-01-01
2019-12-31

CalculationYear

2020

CalculationMonth

3

Revenue

100 000

200 000

300 000

Cash

200 000

300 000

400 000

Unrestricted equity

200 000

300 000

400 000

Output read in this example:

The default forecast method for the field Revenue is an automatic choice between linear regression and weighted running average. In this case the calculation engine choosed the linear regression because it was the best fit.

The first three years is redunant information copied from the input. The last three years is the calculated forecast.

Field

2017-01-01
2017-12-31

2018-01-01
2018-12-31

2019-01-01
2019-12-31

2020-01-01
2020-12-31

2021-01-01
2021-12-31

2022-01-01
2022-12-31

Revenue

100 000

200 000

300 000

400 000

500 000

600 000

The sourcecode in this example doesn't use JSON-notation but of course it's possible to use JSON-notation as well. If you want to run the sourcecode just start Capitex Företagslån and open the javascript console in your browser and paste in the code below in the consol and you will se the revenue output in the console.

var companyCalcInput1 = {"datatype":"capitex.companycalc.dto.CompanyCalcInput"};
companyCalcInput1.Companies = [];
var company1 = {"datatype":"capitex.companycalc.dto.Company"};
companyCalcInput1.Companies[0] = company1;
  
var actualFigures1 = {"datatype":"capitex.companycalc.dto.ActualFigures"};
company1.ActualFigures = actualFigures1;
  
actualFigures1.HistoricalIncomestatements = [];
var incomestatement1 = {"datatype":"capitex.companycalc.dto.Incomestatement"};
actualFigures1.HistoricalIncomestatements[0] = incomestatement1;
incomestatement1.Revenue = 100000.0;
var incomestatement2 = {"datatype":"capitex.companycalc.dto.Incomestatement"};
actualFigures1.HistoricalIncomestatements[1] = incomestatement2;
incomestatement2.Revenue = 200000.0;
var incomestatement3 = {"datatype":"capitex.companycalc.dto.Incomestatement"};
actualFigures1.HistoricalIncomestatements[2] = incomestatement3;
incomestatement3.Revenue = 300000.0;
  
actualFigures1.HistoricalBalanceSheet = [];
var balanceSheet1 = {"datatype":"capitex.companycalc.dto.BalanceSheet"};
actualFigures1.HistoricalBalanceSheet[0] = balanceSheet1;
balanceSheet1.Cash = 200000.0;
balanceSheet1.UnrestrictedEquity = 200000.0;
var balanceSheet2 = {"datatype":"capitex.companycalc.dto.BalanceSheet"};
actualFigures1.HistoricalBalanceSheet[1] = balanceSheet2;
balanceSheet2.Cash = 300000.0;
balanceSheet2.UnrestrictedEquity = 300000.0;
var balanceSheet3 = {"datatype":"capitex.companycalc.dto.BalanceSheet"};
actualFigures1.HistoricalBalanceSheet[2] = balanceSheet3;
balanceSheet3.Cash = 400000.0;
balanceSheet3.UnrestrictedEquity = 400000.0;
  
company1.ID = "30DF1502-08F0-4AEF-A9C2-2C66CC10D056";
companyCalcInput1.CalculationYear = 2020;
companyCalcInput1.CalculationMonth = 10;
 
 
 
$.post( "https://host/context/services/companycalc/Applicationsservice?json=1&method=doCaseCalculation", { data: companyCalcInput1 })
  .done(function(outputAsJsonString) {
    var output = JSON.parse(outputAsJsonString);
        //100 000
        console.log(output.DetailedResultsPerCompany[0].ResultsBeforeLoanAdjusted[0].IncomeBalanceAndKPI.Incomestatement.Revenue);
        //200 000
        console.log(output.DetailedResultsPerCompany[0].ResultsBeforeLoanAdjusted[1].IncomeBalanceAndKPI.Incomestatement.Revenue);
        //300 000
        console.log(output.DetailedResultsPerCompany[0].ResultsBeforeLoanAdjusted[2].IncomeBalanceAndKPI.Incomestatement.Revenue);
        //400 000
        console.log(output.DetailedResultsPerCompany[0].ResultsBeforeLoanAdjusted[3].IncomeBalanceAndKPI.Incomestatement.Revenue);
        //500 000
        console.log(output.DetailedResultsPerCompany[0].ResultsBeforeLoanAdjusted[4].IncomeBalanceAndKPI.Incomestatement.Revenue);
        //600 000
        console.log(output.DetailedResultsPerCompany[0].ResultsBeforeLoanAdjusted[5].IncomeBalanceAndKPI.Incomestatement.Revenue);
  });