bug fixed list producction

This commit is contained in:
Daniel Herrero 2017-11-14 11:20:12 +01:00
parent 2bb87dc195
commit d19ebe0c8c
1 changed files with 10 additions and 9 deletions

View File

@ -68,7 +68,8 @@ module.exports = function(Self) {
}
function sum(tickets) {
var obj = {lines: 0, m3: 0};
let obj = {lines: 0, m3: 0};
if (tickets && tickets.length)
tickets.forEach(function(t, i) {
obj.lines += t.lines;
obj.m3 += t.m3;
@ -76,8 +77,8 @@ module.exports = function(Self) {
tickets[i].problem = tickets[i].problem.trim();
}, this);
obj.m3 = obj.m3.toFixed(2);
obj.total = tickets.length;
obj.tickets = tickets;
obj.total = tickets ? tickets.length : 0;
obj.tickets = tickets || [];
return obj;
}
};