month preview no money and enable lines

This commit is contained in:
Baptiste Lemoine 2018-08-23 15:09:43 +02:00
parent 70ad259885
commit 7a3171c15f
No known key found for this signature in database
GPG Key ID: 3A3B8ADA21ADF899
2 changed files with 24 additions and 7 deletions

View File

@ -25,6 +25,12 @@
<input type="number" ng-model="config.averageMonthlyEarnings"> <input type="number" ng-model="config.averageMonthlyEarnings">
</p> </p>
<p> <p>
<p>
Gérer délais
<input type="checkbox" ng-model="config.showDelays">
Gérer répétitions
<input type="checkbox" ng-model="config.showRepeats">
</p>
<strong> <strong>
Dépenses mensuelles: {{ sumMonthlyExpenses() }} Dépenses mensuelles: {{ sumMonthlyExpenses() }}
@ -55,13 +61,13 @@
<td class="padded" > <td class="padded" >
Nom Nom
</td> </td>
<td class="padded" > <td class="padded" ng-if="config.showDelays">
débute dans X mois débute dans X mois
</td> </td>
<td class="padded" > <td class="padded" ng-if="config.showRepeats">
mois répétitions mois répétitions
</td> </td>
<td class="padded" > <td class="padded" ng-if="config.showRepeats">
prix répétitions prix répétitions
</td> </td>
<td class="padded" > <td class="padded" >
@ -83,14 +89,14 @@
<td> <td>
<input type="text" ng-model="e.name"> <input type="text" ng-model="e.name">
</td> </td>
<td> <td ng-if="config.showDelays">
<input type="number" ng-model="e.delay"> <input type="number" ng-model="e.delay">
</td> </td>
<td> <td ng-if="config.showRepeats">
<input type="number" ng-model="e.repeat"> <input type="number" ng-model="e.repeat">
</td> </td>
<td class="text-right padded"> <td ng-if="config.showRepeats" class="text-right padded">
{{ e.repeat * e.amount }} {{ e.repeat * e.amount }}
</td> </td>
<td> <td>
@ -146,6 +152,9 @@
<div class="col-5 col-xs-12 col-sm-5"> <div class="col-5 col-xs-12 col-sm-5">
<h2>Simulation sur {{config.lines}} mois</h2> <h2>Simulation sur {{config.lines}} mois</h2>
<div class="well" ng-if="config.monthsBeforeNoMoney < config.lines">
Ce sera la dèche dans {{config.monthsBeforeNoMoney}} mois
</div>
<table> <table>
<thead> <thead>
<tr > <tr >

View File

@ -232,7 +232,10 @@ angular
*/ */
disponibility: 5000, disponibility: 5000,
averageMonthlyEarnings: 600, averageMonthlyEarnings: 600,
warningThershold: 2000 warningThershold: 2000,
showDelays: false,
showRepeats: false,
monthsBeforeNoMoney: null,
}; };
let exampleExpenses = [ let exampleExpenses = [
@ -266,6 +269,7 @@ angular
let monthly = $scope.sumMonthlyExpenses(); let monthly = $scope.sumMonthlyExpenses();
let available = $scope.config.disponibility; let available = $scope.config.disponibility;
let previsionTable = []; let previsionTable = [];
let changedNoMoneyConfig = false;
for (let i = 0; i <= turns; i++) { for (let i = 0; i <= turns; i++) {
// TODO take in account delays in expenses // TODO take in account delays in expenses
available = available - monthly + $scope.config.averageMonthlyEarnings; available = available - monthly + $scope.config.averageMonthlyEarnings;
@ -273,6 +277,10 @@ angular
expense: monthly, expense: monthly,
available: available, available: available,
}; };
if (available <= 0 && !changedNoMoneyConfig) {
$scope.config.monthsBeforeNoMoney = i;
changedNoMoneyConfig = true;
}
previsionTable.push(newLine); previsionTable.push(newLine);
} }
return previsionTable; return previsionTable;