From 7a3171c15f06ececdcd363d8b359f909554ba04f Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Thu, 23 Aug 2018 15:09:43 +0200 Subject: [PATCH] month preview no money and enable lines --- .../views/logged/previsionnel.html.twig | 21 +++++++++++++------ assets/js/parts/main.js | 10 ++++++++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/Resources/views/logged/previsionnel.html.twig b/app/Resources/views/logged/previsionnel.html.twig index 6ee05212..1e9dc713 100755 --- a/app/Resources/views/logged/previsionnel.html.twig +++ b/app/Resources/views/logged/previsionnel.html.twig @@ -25,6 +25,12 @@

+

+ Gérer délais + + Gérer répétitions + +

Dépenses mensuelles: {{ sumMonthlyExpenses() }} € @@ -55,13 +61,13 @@ Nom - + débute dans X mois - + mois répétitions - + prix répétitions @@ -83,14 +89,14 @@ - + - + - + {{ e.repeat * e.amount }} @@ -146,6 +152,9 @@

Simulation sur {{config.lines}} mois

+
+ Ce sera la dèche dans {{config.monthsBeforeNoMoney}} mois +
diff --git a/assets/js/parts/main.js b/assets/js/parts/main.js index 08d7e2f2..2b48b475 100755 --- a/assets/js/parts/main.js +++ b/assets/js/parts/main.js @@ -232,7 +232,10 @@ angular */ disponibility: 5000, averageMonthlyEarnings: 600, - warningThershold: 2000 + warningThershold: 2000, + showDelays: false, + showRepeats: false, + monthsBeforeNoMoney: null, }; let exampleExpenses = [ @@ -266,6 +269,7 @@ angular let monthly = $scope.sumMonthlyExpenses(); let available = $scope.config.disponibility; let previsionTable = []; + let changedNoMoneyConfig = false; for (let i = 0; i <= turns; i++) { // TODO take in account delays in expenses available = available - monthly + $scope.config.averageMonthlyEarnings; @@ -273,6 +277,10 @@ angular expense: monthly, available: available, }; + if (available <= 0 && !changedNoMoneyConfig) { + $scope.config.monthsBeforeNoMoney = i; + changedNoMoneyConfig = true; + } previsionTable.push(newLine); } return previsionTable;