Example 1 - Historical accounts and forecast (Javascript inprocess)
In this example the calculation date is set to 2020-03. This will tell the calculation-engine that the ongoing account year is 2020-01-01 - 2020-12-31.
Default length of all fiscal years is 12 months and default start month is January. Default number of forcast years is 3 years.
The arrays ActualFigures.HistoricalIncomestatements and ActualFigures.HistoricalBalancesheets is always in cronological order and the last item is always the latest account year that is closed.
Input:
Field | 2017-01-01 | 2018-01-01 | 2019-01-01 | |
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 | 2018-01-01 | 2019-01-01 | 2020-01-01 | 2021-01-01 | 2022-01-01 |
---|---|---|---|---|---|---|
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.
Sourcecode:
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 ; var inputAsString = JSON.stringify(companyCalcInput1); var outputAsString = window.companycalc_engine_doCaseCalculation(inputAsString); var output = JSON.parse(outputAsString); //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); |