diff --git a/proto/server/public/javascript/balance_sheet.js b/proto/server/public/javascript/balance_sheet.js
index 35541d1..349f8c7 100644
--- a/proto/server/public/javascript/balance_sheet.js
+++ b/proto/server/public/javascript/balance_sheet.js
@@ -71,6 +71,30 @@ var updateData = function($scope, $http){
var balanceSheetCallback = function($scope, $http, balanceSheet) {
console.log(balanceSheet);
+
+ var currAssets = balanceSheet.assets.curr;
+ var nonCurrAssets = balanceSheet.assets.nonCurr;
+ $scope.cashAndBankDeposits = currAssets.cashAndBankDeposits;
+ $scope.inventory = currAssets.inventory;
+ $scope.clients = currAssets.clients;
+ $scope.stateAndOtherPubEntAssets = currAssets.stateAndOtherPubEntAssets;
+ $scope.otherCurrAssets = currAssets.otherCurrAssets;
+ $scope.totalCurrAssets = currAssets.totalCurrAssets;
+ $scope.shareholders_partners = nonCurrAssets.shareholders_partners;
+ $scope.tangibleFixedAssets = nonCurrAssets.tangibleFixedAssets;
+ $scope.otherNonCurrAssets = nonCurrAssets.otherNonCurrAssets;
+ $scope.totalNonCurrAssets = nonCurrAssets.totalNonCurrAssets;
+
+ var liabilities = balanceSheet.liabilities;
+ $scope.suppliers = liabilities.suppliers;
+ $scope.customerDownPayment = liabilities.customerDownPayment;
+ $scope.stateAndOtherPubEntAssetsLiabilities = liabilities.stateAndOtherPubEntAssetsLiabilities;
+ $scope.otherLiabilities = liabilities.otherLiabilities;
+ $scope.totalLiabilities = liabilities.value;
+
+ $scope.assets = balanceSheet.assets.value;
+ $scope.liabilities = balanceSheet.liabilities.value;
+ $scope.equity = balanceSheet.equity.value;
}
var getMonthName = function(index) {
diff --git a/proto/server/public/javascript/income_statement.js b/proto/server/public/javascript/income_statement.js
index 6fed684..7997b0c 100644
--- a/proto/server/public/javascript/income_statement.js
+++ b/proto/server/public/javascript/income_statement.js
@@ -13,7 +13,7 @@ app.controller('income_statement_controller', function($scope, $http) {
//init vars
var today = new Date();
- var url_string = window.location.href
+ var url_string = window.location.href;
var url = new URL(url_string);
$scope.chosenYear = url.searchParams.get("year");
diff --git a/proto/server/templates/balance_sheet.html b/proto/server/templates/balance_sheet.html
index 3e0897d..755ab37 100644
--- a/proto/server/templates/balance_sheet.html
+++ b/proto/server/templates/balance_sheet.html
@@ -88,12 +88,12 @@
[[equity | euro]]
- Property |
- [[property | euro]] |
+ Tangible fixed assets |
+ [[tangibleFixedAssets | euro]] |
- Other Debtors and Creditors |
- [[otherDebtorsAndCreditors | euro]] |
+ Shareholders / partners |
+ [[shareholders_partners | euro]] |
Other non current assets |
@@ -109,7 +109,7 @@ [[equity | euro]]
- Current Liabilities |
+ Liabilities |
[[dateTable]] |
@@ -119,47 +119,20 @@ [[equity | euro]]
[[suppliers | euro]] |
- Customer Advance |
- [[customerAdvance | euro]] |
+ Customer Down Payment |
+ [[customerDownPayment | euro]] |
State and other public entities |
[[stateAndOtherPubEntAssetsLiabilities | euro]] |
- Other bills to pay |
- [[otherBillsToPay | euro]] |
+ Other liabilities |
+ [[otherLiabilities | euro]] |
- Total current liablities |
- [[totalCurrLiabilities | euro]] |
-
-
-
-
-
-
-
- Non Current Liabilities |
- [[dateTable]] |
-
-
-
-
- Provisions |
- [[provisions | euro]] |
-
-
- Long-term debt |
- [[customerAdvance | euro]] |
-
-
- Other non current liabilities |
- [[otherNonCurrentLiabilities | euro]] |
-
-
- Total non current liablities |
- [[totalNonCurrLiabilities | euro]] |
+ Total liablities |
+ [[totalLiabilities | euro]] |
diff --git a/proto/server/templates/finances.html b/proto/server/templates/finances.html
index 11281bb..eb6d6d4 100644
--- a/proto/server/templates/finances.html
+++ b/proto/server/templates/finances.html
@@ -83,6 +83,8 @@ [[equity | euro]]
+
+
diff --git a/proto/server/utils.js b/proto/server/utils.js
index a20332d..b7b5c75 100644
--- a/proto/server/utils.js
+++ b/proto/server/utils.js
@@ -212,15 +212,32 @@ function calcCumulativeBalancetes(transactions, accounts, year, month) {
return balancetes;
}
+// based on http://www.dfk.pt/snc/balanco.htm
function calcBalanco(balancete) {
var balanco = {
- 'assets':{
+ 'assets': {
'accounts': [],
'value': 0,
+ 'curr': {
+ 'cashAndBankDeposits': 0,
+ 'inventory': 0,
+ 'clients': 0,
+ 'stateAndOtherPubEntAssets': 0,
+ 'otherCurrAssets': 0
+ },
+ 'nonCurr': {
+ 'shareholders_partners': 0,
+ 'tangibleFixedAssets': 0,
+ 'otherNonCurrAssets': 0,
+ }
},
'liabilities': {
'accounts': [],
'value': 0,
+ 'suppliers': 0,
+ 'stateAndOtherPubEntAssetsLiabilities': 0,
+ 'otherLiabilities': 0,
+ 'customerDownPayment': 0,
},
'equity': {
'accounts': [],
@@ -235,8 +252,13 @@ function calcBalanco(balancete) {
balancete[i].AccountID[0] === '6' ||
balancete[i].AccountID[0] === '7' ||
balancete[i].AccountID[0] === '8' ||
- balancete[i].AccountID[0] === '9')
+ balancete[i].AccountID[0] === '9') {
+ if (balancete[i].AccountID === "219") {
+ balanco.assets.accounts.push(balancete[i]);
+ balanco.liabilities.accounts.push(balancete[i]);
+ }
continue;
+ }
balancete[i].ClosingDebitBalance = balancete[i].OpeningDebitBalance + balancete[i].DebtMovements;
balancete[i].ClosingCreditBalance = balancete[i].OpeningCreditBalance + balancete[i].CreditMovements;
@@ -245,17 +267,82 @@ function calcBalanco(balancete) {
balancete[i].ClosingDebitBalance = balancete[i].ClosingDebitBalance - balancete[i].ClosingCreditBalance;
balancete[i].ClosingCreditBalance = 0;
balanco.assets.accounts.push(balancete[i])
- balanco.assets.value += balancete[i].ClosingDebitBalance;
}
else {
balancete[i].ClosingCreditBalance = balancete[i].ClosingCreditBalance - balancete[i].ClosingDebitBalance;
balancete[i].ClosingDebitBalance = 0;
balanco.liabilities.accounts.push(balancete[i]);
- balanco.liabilities.value += balancete[i].ClosingCreditBalance;
}
}
- balanco.equity.value = balanco.assets.value - balanco.liabilities.value;
+
+ for (var i = 0; i < balanco.assets.accounts.length; i++) {
+ var account = balanco.assets.accounts[i];
+ var id = account.AccountID;
+
+ // Current Assets
+ if (id === "11" || id === "12" || id == "13") {
+ balanco.assets.curr.cashAndBankDeposits += account.ClosingDebitBalance - account.ClosingCreditBalance;
+ }
+ else if (id === "32" || id === "33" || id === "34" || id === "35" || id === "36" || id == "39") { // 32/3/4/5/6/9
+ balanco.assets.curr.inventory += account.ClosingDebitBalance;
+ }
+ else if (id === "21") {
+ balanco.assets.curr.clients += account.ClosingDebitBalance;
+ }
+ else if (id === "219") {
+ balanco.assets.curr.clients -= - account.ClosingCreditBalance;
+ }
+ else if (id === "24") {
+ if (account.ClosingDebitBalance > account.ClosingCreditBalance)
+ balanco.assets.curr.stateAndOtherPubEntAssets += account.ClosingDebitBalance;
+ }
+ else {
+ balanco.assets.curr.otherCurrAssets += 0;
+ }
+ // Non current assets
+ if (id === "26") {
+ balanco.assets.nonCurr.shareholders_partners += account.ClosingDebitBalance;
+ }
+ else if (id === "43") {
+ balanco.assets.nonCurr.tangibleFixedAssets += account.ClosingDebitBalance;
+ }
+ else {
+ balanco.assets.nonCurr.otherNonCurrAssets += 0;
+ }
+ }
+ balanco.assets.curr.totalCurrAssets = balanco.assets.curr.cashAndBankDeposits
+ + balanco.assets.curr.inventory
+ + balanco.assets.curr.clients
+ + balanco.assets.curr.stateAndOtherPubEntAssets
+ + balanco.assets.curr.otherCurrAssets;
+ balanco.assets.nonCurr.totalNonCurrAssets = balanco.assets.nonCurr.shareholders_partners
+ + balanco.assets.nonCurr.tangibleFixedAssets
+ + balanco.assets.nonCurr.otherNonCurrAssets;
+ balanco.assets.value = balanco.assets.curr.totalCurrAssets + balanco.assets.nonCurr.totalNonCurrAssets;
+
+ for (var i = 0; i < balanco.liabilities.accounts.length; i++) {
+ var account = balanco.liabilities.accounts[i];
+ var id = account.AccountID;
+
+ // liabilities
+ if (id === "22") {
+ balanco.liabilities.suppliers += account.ClosingCreditBalance;
+ }
+ else if (id === "219") {
+ balanco.liabilities.customerDownPayment += account.ClosingCreditBalance;
+ }
+ else if (id == "24") {
+ balanco.liabilities.stateAndOtherPubEntAssetsLiabilities += account.ClosingCreditBalance;
+ }
+ else {
+ balanco.liabilities.otherLiabilities += 0;
+ }
+ }
+ balanco.liabilities.value = balanco.liabilities.suppliers + balanco.liabilities.customerDownPayment +
+ balanco.liabilities.stateAndOtherPubEntAssetsLiabilities + balanco.liabilities.otherLiabilities;
+ balanco.equity.value = balanco.assets.value - balanco.liabilities.value;
+ console.log(balanco);
return balanco;
}