expenses prevision turns works

This commit is contained in:
Baptiste Lemoine 2018-08-23 12:24:02 +02:00
parent e371483c59
commit 11b26bcf40
No known key found for this signature in database
GPG Key ID: 3A3B8ADA21ADF899
2 changed files with 13 additions and 9 deletions

View File

@ -17,7 +17,10 @@
</h2> </h2>
Euros disponibles au départ: Euros disponibles au départ:
<input type="number" ng-model="disponibility"> <input type="number" ng-model="disponibility">
Dépenses mensuelles: {{ sumMonthlyExpenses }} <strong>
Dépenses mensuelles: {{ sumMonthlyExpenses() }}
</strong>
</div> </div>
<div class="postes"> <div class="postes">
<h2>Postes de dépenses <h2>Postes de dépenses
@ -60,16 +63,16 @@
</td> </td>
<td> <td>
<input type="text" ng-model="e.delay"> <input type="number" ng-model="e.delay">
</td> </td>
<td> <td>
<input type="text" ng-model="e.repeat"> <input type="number" ng-model="e.repeat">
</td> </td>
<td class="text-right padded"> <td class="text-right padded">
{{ e.repeat * e.amount }} {{ e.repeat * e.amount }}
</td> </td>
<td> <td>
<input type="text" ng-model="e.amount"> <input type="number" ng-model="e.amount">
</td> </td>
<td class="text-right padded"> <td class="text-right padded">
{{ e.amount * 12 }} {{ e.amount * 12 }}
@ -128,18 +131,18 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="line in previsionTable"> <tr ng-repeat="line in previsionTable()">
<td> <td>
{{ $index }} {{ $index }}
</td> </td>
<td> <td>
- -
</td> </td>
<td> <td class="text-right ">
{{ line.expense }} {{ line.expense }}
</td> </td>
<td ng-class="{ 'bg-warning' : line.available < 0}"> <td class="text-right" ng-class="{ 'bg-warning' : line.available < 0}">
{{ line.available }} {{ line.available }}
</td> </td>

View File

@ -255,15 +255,16 @@ angular
}; };
$scope.previsionTable = () => { $scope.previsionTable = () => {
let turns = 60; let turns = 24;
let monthly = $scope.sumMonthlyExpenses(); let monthly = $scope.sumMonthlyExpenses();
let available = $scope.disponibility; let available = $scope.disponibility;
let previsionTable = []; let previsionTable = [];
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;
let newLine = { let newLine = {
expense: monthly, expense: monthly,
available: available - monthly, available: available,
}; };
previsionTable.push(newLine); previsionTable.push(newLine);
} }