diff --git a/modules/agency/front/events/index.js b/modules/agency/front/events/index.js
index b6352802a..90f06c8d1 100644
--- a/modules/agency/front/events/index.js
+++ b/modules/agency/front/events/index.js
@@ -36,22 +36,14 @@ class Controller extends Section {
: this.$t('Everyday');
}
- onSelection(days, type, weekday, data) {
+ onSelection(days, type, weekday, events, exclusions) {
+ console.log(events, exclusions);
if (this.editMode == 'include') {
- let dayData = data[0] || {};
- let event = dayData.events && dayData.events[0];
-
- if (event)
- this.edit(event);
+ if (events.length)
+ this.edit(events[0]);
else
this.create(days, type, weekday);
} else {
- let exclusions = [];
- for (let dayData of data) {
- if (dayData.exclusion)
- exclusions.push(dayData.exclusion.id);
- }
-
if (exclusions.length)
this.exclusionDelete(exclusions);
else
@@ -155,16 +147,16 @@ class Controller extends Section {
.then(() => this.refresh());
}
- exclusionDelete(ids) {
- let promises = [];
+ exclusionDelete(exclusions) {
+ let reqs = [];
- for (let id of ids) {
- promises.push(
- this.$http.delete(`${this.exclusionsPath}/${id}`)
- );
+ for (let exclusion of exclusions) {
+ if (!exclusion.id) continue;
+ let path = `${this.exclusionsPath}/${exclusion.id}`;
+ reqs.push(this.$http.delete(path));
}
- this.$q.all(promises)
+ this.$q.all(reqs)
.then(() => this.refresh());
}
}
diff --git a/modules/worker/back/methods/worker/getWorkerInfo.js b/modules/worker/back/methods/worker/getWorkerInfo.js
deleted file mode 100644
index c91f84078..000000000
--- a/modules/worker/back/methods/worker/getWorkerInfo.js
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-Author : Enrique Blasco BLanquer
-Date: 28 de mayo de 2019
-*/
-module.exports = Self => {
- Self.remoteMethodCtx('getWorkerInfo', {
- description: 'Get worker info (name, isWorking, total worked hours ...)',
- accessType: 'WRITE',
- returns: [{
- type: 'Object',
- root: true
- }],
- http: {
- path: `/getWorkerInfo`,
- verb: 'GET'
- }
- });
-
- Self.getWorkerInfo = async(ctx, data) => {
- let prevHour = new Date(); // default value to start work
- let diff = 0; // difference of value between two dates
- let isOdd = true; // determine if timed is odd or not in db
- const myUserId = ctx.req.accessToken.userId; // get user id
-
-
- // 1 get name and photo for the user
- let [user] = await Self.rawSql(`SELECT u.name, t.Foto FROM vn.user u INNER JOIN vn2008.Trabajadores t ON u.id = t.user_id WHERE id = ?;`, [myUserId]);
- // 2 get all jornaly work time registered
- let workedHours = await Self.rawSql(`SELECT * FROM vn.workerTimeControl WHERE userFk = ? AND DATE(timed) = CURDATE() ORDER BY timed ASC;`, [myUserId]);
- let today = new Date();
- // 3 get the number of hours to work in one day
- let date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
- let [hoursForDay] = await Self.rawSql(`SELECT cl.hours_week AS hoursWeek,
- GROUP_CONCAT(DISTINCT LEFT(j.start,2) ORDER BY j.start ASC SEPARATOR '-') start ,
- GROUP_CONCAT(DISTINCT LEFT(j.end,2) ORDER BY j.end ASC SEPARATOR '-') end,
- CAST(IFNULL((SUM(TIME_TO_SEC(j.end))-SUM(TIME_TO_SEC(j.start)))/3600,if(cl.hours_week=40
- AND DAYOFWEEK(t.dated) IN(2,3,4,5,6),8,0)) AS DECIMAL(10,2)) workingHours
- FROM vn.time t
- LEFT JOIN postgresql.business b ON t.dated BETWEEN b.date_start AND ifnull(b.date_end,? )
- LEFT JOIN postgresql.profile AS pr ON b.client_id = pr.profile_id
- LEFT JOIN postgresql.person AS p ON pr.person_id = p.person_id
- LEFT JOIN vn.worker AS w ON p.id_trabajador = w.id
- LEFT JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id
- LEFT JOIN postgresql.calendar_labour_type AS cl ON bl.calendar_labour_type_id = cl.calendar_labour_type_id
- LEFT JOIN postgresql.journey AS j ON j.business_id = b.business_id and j.day_id=WEEKDAY(t.dated)+1
- WHERE t.dated BETWEEN ? AND ? AND userFk = ?
- GROUP BY w.userFk,dated`, [date, date, date, myUserId]);
-
- // 4 Add all the hours and see the total worked
- for (hour of workedHours) {
- if (!isOdd)
- diff += Math.abs((new Date(hour.timed)).getTime() - prevHour.getTime());
- else
- prevHour = new Date(hour.timed);
-
- isOdd = !isOdd;
- }
-
- // 5 calculate hours and minutes from a number value
- let decimalTime = diff / 1000 / 3600;
- decimalTime = decimalTime * 60 * 60;
- let hours = Math.floor((decimalTime / (60 * 60)));
- decimalTime = decimalTime - (hours * 60 * 60);
- let minutes = Math.floor((decimalTime / 60));
-
- // 6 default total hours
- let totalHours = '7:40';
- let hoursWeek = 40;
-
- // 7 Get the hours you have to work today and the hours to work in a week
- if (hoursForDay != null) {
- // If it exceeds 5 hours we take 20 minutes of breakfast.
- if (hoursForDay.workingHours > 5)
- hoursForDay.workingHours -= 20 * 0.016666;
- let decimalTime = parseFloat(hoursForDay.workingHours);
- decimalTime = decimalTime * 60 * 60;
- let hoursDay = Math.floor((decimalTime / (60 * 60)));
- decimalTime = decimalTime - (hoursDay * 60 * 60);
- let minutesDay = Math.floor((decimalTime / 60));
- totalHours = hoursDay + ':' + minutesDay;
- }
-
-
- // 8 return value
- if (hoursForDay != null)
- hoursWeek = hoursForDay.hoursWeek;
- return {
- 'name': user.name,
- 'hours': hours,
- 'minutes': minutes,
- 'today': today,
- 'isWorking': !isOdd,
- 'lastDate': prevHour,
- 'totalHours': totalHours,
- 'hoursWeek': hoursWeek
- };
- };
-};
diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js
index 9abdeb737..5abf65513 100644
--- a/modules/worker/back/models/worker.js
+++ b/modules/worker/back/models/worker.js
@@ -3,5 +3,4 @@ module.exports = Self => {
require('../methods/worker/mySubordinates')(Self);
require('../methods/worker/isSubordinate')(Self);
require('../methods/worker/getWorkedHours')(Self);
- require('../methods/worker/getWorkerInfo')(Self);
};
diff --git a/print/methods/closure.js b/print/methods/closure.js
index c12dd07b0..4b25c5abc 100644
--- a/print/methods/closure.js
+++ b/print/methods/closure.js
@@ -16,8 +16,7 @@ module.exports = app => {
JOIN client c ON c.id = t.clientFk
JOIN warehouse w ON w.id = t.warehouseFk AND hasComission
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
- WHERE
- ts.alertLevel = 2
+ WHERE ts.code = 'PACKED'
AND DATE(t.shipped) BETWEEN DATE_ADD(CURDATE(), INTERVAL -2 DAY) AND CURDATE()
AND t.refFk IS NULL
GROUP BY e.ticketFk`);
@@ -37,22 +36,30 @@ module.exports = app => {
await email.send();
} catch (error) {
// Save tickets on a list of failed ids
- failedtickets.push(ticket.id);
+ failedtickets.push({
+ id: ticket.id,
+ stacktrace: error
+ });
}
}
// Send email with failed tickets
if (failedtickets.length > 0) {
- const ticketList = failedtickets.join(', ');
+ let body = 'This following tickets has failed:
';
+
+ for (ticket of failedtickets) {
+ body += `Ticket: ${ticket.id}
+
${ticket.stacktrace}
`;
+ }
+
smtp.send({
to: config.app.reportEmail,
- subject: 'Nightly ticket closure has failed',
- text: `This following tickets has failed: ${ticketList}`
+ subject: '[API] Nightly ticket closure has failed',
+ html: body
});
}
res.status(200).json({
- statusCode: 200,
message: 'Closure executed successfully'
});
});
diff --git a/print/templates/email/payment-update/payment-update.html b/print/templates/email/payment-update/payment-update.html
index 4313b3d25..49bdc4e1b 100644
--- a/print/templates/email/payment-update/payment-update.html
+++ b/print/templates/email/payment-update/payment-update.html
@@ -33,16 +33,18 @@
{{ $t('sections.pay.method') }}:
- {{client.payMethodName}}
+ {{payMethod.name}}
-
+
{{ $t('sections.pay.day') }}:
- {{ $t('sections.pay.dueDay', [client.dueDay]) }}
+ {{ $t('sections.pay.dueDay', [payMethod.dueDay]) }}
-
-
+
+
+
{{ $t('sections.pay.cardImplicates') }}
diff --git a/print/templates/email/payment-update/payment-update.js b/print/templates/email/payment-update/payment-update.js
index 8510e088e..4479deb81 100755
--- a/print/templates/email/payment-update/payment-update.js
+++ b/print/templates/email/payment-update/payment-update.js
@@ -6,29 +6,27 @@ const emailFooter = new Component('email-footer');
module.exports = {
name: 'payment-update',
async serverPrefetch() {
- this.client = await this.fetchClient(this.clientId);
+ this.payMethod = await this.fetchPayMethod(this.clientId);
- if (!this.client)
+ if (!this.payMethod)
throw new Error('Something went wrong');
},
computed: {
accountAddress: function() {
- return this.iban.slice(-4);
+ return this.payMethod.iban.slice(-4);
},
},
methods: {
- // Redmine #1854 Replace payMethodId by code
- fetchClient(id) {
+ fetchPayMethod(clientId) {
return db.findOne(
`SELECT
c.dueDay,
c.iban,
- pm.id payMethodId,
- pm.name payMethodName
+ pm.name,
+ pm.code
FROM client c
JOIN payMethod pm ON pm.id = c.payMethodFk
- JOIN account.user u ON u.id = c.id
- WHERE c.id = :clientId`, {clientId: id});
+ WHERE c.id = :clientId`, {clientId: clientId});
}
},
components: {
diff --git a/print/templates/reports/delivery-note/locale/fr.yml b/print/templates/reports/delivery-note/locale/fr.yml
new file mode 100644
index 000000000..98b1264b1
--- /dev/null
+++ b/print/templates/reports/delivery-note/locale/fr.yml
@@ -0,0 +1,26 @@
+title: Bon de livraison
+ticketId: Bon de livraison
+clientId: Client
+deliveryAddress: Addresse de livraison
+fiscalData: Datos fiscales
+saleLines: Líneas de pedido
+date: Date
+reference: Ref.
+quantity: Cant.
+concept: Concepto
+price: PVP/u
+discount: Dto.
+vat: IVA
+amount: Importe
+type: Tipo
+taxBase: Base imp.
+tax: Tasa
+fee: Cuota
+total: Total
+subtotal: Subtotal
+taxBreakdown: Répartition de la taxe
+packagings: Seaux et emballages
+services: Servicios
+vatType: Tipo de IVA
+digitalSignature: Firma digital
+ticket: Albarán {0}
\ No newline at end of file