diff --git a/modules/supplier/back/models/supplier-account.js b/modules/supplier/back/models/supplier-account.js
index 51da113ec..691e72580 100644
--- a/modules/supplier/back/models/supplier-account.js
+++ b/modules/supplier/back/models/supplier-account.js
@@ -7,18 +7,18 @@ module.exports = Self => {
});
async function ibanValidation(err, done) {
- const supplier = await Self.app.models.Supplier.findById(this.supplierFk);
+ if (!this.bankEntityFk)
+ return done();
+
+ const bankEntity = await Self.app.models.BankEntity.findById(this.bankEntityFk);
const filter = {
fields: ['code'],
- where: {id: supplier.countryFk}
+ where: {id: bankEntity.countryFk}
};
const country = await Self.app.models.Country.findOne(filter);
- const code = country ? country.code.toLowerCase() : null;
- if (code != 'es')
- return done();
- if (!validateIban(this.iban))
+ if (!validateIban(this.iban, country?.code))
err();
done();
}
diff --git a/modules/ticket/back/methods/ticket/docuwareDownload.js b/modules/ticket/back/methods/ticket/docuwareDownload.js
index e9b74b1a9..7084bbdd4 100644
--- a/modules/ticket/back/methods/ticket/docuwareDownload.js
+++ b/modules/ticket/back/methods/ticket/docuwareDownload.js
@@ -32,6 +32,14 @@ module.exports = Self => {
});
Self.docuwareDownload = async id => {
+ const models = Self.app.models;
+ const docuwareInfo = await models.Docuware.findOne({
+ where: {
+ code: 'deliveryNote',
+ action: 'find'
+ }
+ });
+
const filter = {
condition: [
{
@@ -50,6 +58,6 @@ module.exports = Self => {
}
]
};
- return Self.app.models.Docuware.download(id, 'deliveryNote', filter);
+ return models.Docuware.download(id, 'deliveryNote', filter);
};
};
diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js
index c37337253..14cb104be 100644
--- a/modules/ticket/back/models/ticket-methods.js
+++ b/modules/ticket/back/models/ticket-methods.js
@@ -42,4 +42,5 @@ module.exports = function(Self) {
require('../methods/ticket/expeditionPalletLabel')(Self);
require('../methods/ticket/saveSign')(Self);
require('../methods/ticket/invoiceTickets')(Self);
+ require('../methods/ticket/docuwareDownload')(Self);
};
diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js
index 360d93564..d1f39fd19 100644
--- a/modules/ticket/front/descriptor-menu/index.js
+++ b/modules/ticket/front/descriptor-menu/index.js
@@ -3,10 +3,11 @@ import Section from 'salix/components/section';
import './style.scss';
class Controller extends Section {
- constructor($element, $, vnReport, vnEmail) {
+ constructor($element, $, vnReport, vnEmail, vnFile) {
super($element, $);
this.vnReport = vnReport;
this.vnEmail = vnEmail;
+ this.vnFile = vnFile;
}
get ticketId() {
@@ -322,7 +323,7 @@ class Controller extends Section {
}
docuwareDownload() {
- this.vnFile.download(`api/Ticket/${this.ticket.id}/docuwareDownload`);
+ this.vnFile.download(`api/Tickets/${this.ticket.id}/docuwareDownload`);
}
setTicketWeight(weight) {
@@ -335,7 +336,7 @@ class Controller extends Section {
}
}
-Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];
+Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail', 'vnFile'];
ngModule.vnComponent('vnTicketDescriptorMenu', {
template: require('./index.html'),
diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js
index ab5e56a77..66fb7cc23 100644
--- a/modules/worker/back/methods/worker-time-control/sendMail.js
+++ b/modules/worker/back/methods/worker-time-control/sendMail.js
@@ -121,15 +121,18 @@ module.exports = Self => {
`, [started, ended]);
stmts.push(stmt);
- stmt = new ParameterizedSQL(`INSERT INTO mail (receiver, subject, body)
- SELECT CONCAT(u.name, '@verdnatura.es'),
- CONCAT('Error registro de horas semana ', ?, ' año ', ?) ,
- CONCAT('No se ha podido enviar el registro de horas al empleado/s: ', GROUP_CONCAT(DISTINCT CONCAT('
', w.id, ' ', w.firstName, ' ', w.lastName)))
- FROM tmp.timeControlError tce
- JOIN vn.workerTimeControl wtc ON wtc.id = tce.id
- JOIN worker w ON w.id = wtc.userFK
- JOIN account.user u ON u.id = w.bossFk
- GROUP BY w.bossFk`, [args.week, args.year]);
+ stmt = new ParameterizedSQL(`
+ INSERT INTO mail (receiver, subject, body)
+ SELECT CONCAT(u.name, '@verdnatura.es'),
+ CONCAT('Error registro de horas semana ', ?, ' año ', ?) ,
+ CONCAT('No se ha podido enviar el registro de horas al empleado/s: ',
+ GROUP_CONCAT(DISTINCT CONCAT('
', w.id, ' ', w.firstName, ' ', w.lastName)))
+ FROM tmp.timeControlError tce
+ JOIN vn.workerTimeControl wtc ON wtc.id = tce.id
+ JOIN worker w ON w.id = wtc.userFK
+ JOIN account.user u ON u.id = w.bossFk
+ GROUP BY w.bossFk
+ `, [args.week, args.year]);
stmts.push(stmt);
stmt = new ParameterizedSQL(`
@@ -177,10 +180,8 @@ module.exports = Self => {
const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions);
for (let day of days[index]) {
- if (!myOptions.transaction) {
- tx = await Self.beginTransaction({});
- myOptions.transaction = tx;
- }
+ tx = await Self.beginTransaction({});
+ myOptions.transaction = tx;
try {
workerFk = day.workerFk;
if (day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null
@@ -365,13 +366,31 @@ module.exports = Self => {
previousReceiver = day.receiver;
}
- if (tx) {
- await tx.commit();
- delete myOptions.transaction;
- }
+ if (tx) await tx.commit();
} catch (e) {
+ const stmts = [];
+ let stmt;
+ stmt = new ParameterizedSQL(`
+ INSERT INTO mail (receiver, subject, body)
+ SELECT CONCAT(u.name, '@verdnatura.es'),
+ CONCAT('Error registro de horas semana ', ?, ' año ', ?) ,
+ CONCAT('No se ha podido enviar el registro de horas al empleado: ',
+ w.id, ' ', w.firstName, ' ', w.lastName, ' por el motivo: ', ?)
+ FROM worker w
+ JOIN account.user u ON u.id = w.bossFk
+ WHERE w.id = ?
+ `, [args.week, args.year, e.message, day.workerFk]);
+ stmts.push(stmt);
+
+ const sql = ParameterizedSQL.join(stmts, ';');
+ await conn.executeStmt(sql);
+
+ previousWorkerFk = day.workerFk;
+ previousReceiver = day.receiver;
+
if (tx) await tx.rollback();
- throw e;
+
+ continue;
}
}
diff --git a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js
index f44080559..3203dea82 100644
--- a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js
+++ b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js
@@ -51,7 +51,7 @@ module.exports = Self => {
const salix = await models.Url.findOne({
where: {
appName: 'salix',
- environment: process.env.NODE_ENV || 'dev'
+ environment: process.env.NODE_ENV || 'development'
}
}, myOptions);
@@ -61,7 +61,7 @@ module.exports = Self => {
const url = `${salix.url}worker/${args.workerId}/time-control?timestamp=${timestamp}`;
ctx.args.url = url;
- Self.sendTemplate(ctx, 'weekly-hour-record');
+ await Self.sendTemplate(ctx, 'weekly-hour-record');
return models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, myOptions);
};
diff --git a/modules/worker/front/pbx/index.js b/modules/worker/front/pbx/index.js
index d37f6f7d8..3b6443d3c 100644
--- a/modules/worker/front/pbx/index.js
+++ b/modules/worker/front/pbx/index.js
@@ -5,7 +5,7 @@ class Controller extends Section {
onSubmit() {
const sip = this.worker.sip;
const params = {
- userFk: this.worker.userFk,
+ userFk: this.worker.id,
extension: sip.extension
};
this.$.watcher.check();
diff --git a/print/templates/reports/entry-order/sql/supplier.sql b/print/templates/reports/entry-order/sql/supplier.sql
index 11a2bc602..81ed7e883 100644
--- a/print/templates/reports/entry-order/sql/supplier.sql
+++ b/print/templates/reports/entry-order/sql/supplier.sql
@@ -8,4 +8,4 @@ SELECT
FROM supplier s
JOIN entry e ON e.supplierFk = s.id
LEFT JOIN province p ON p.id = s.provinceFk
-WHERE e.id = ?
\ No newline at end of file
+WHERE e.id = ?
diff --git a/print/templates/reports/invoiceIn/invoiceIn.html b/print/templates/reports/invoiceIn/invoiceIn.html
index 8f072947f..a86fd42b0 100644
--- a/print/templates/reports/invoiceIn/invoiceIn.html
+++ b/print/templates/reports/invoiceIn/invoiceIn.html
@@ -32,6 +32,7 @@
{{invoice.name}}
{{invoice.postalAddress}}
{{invoice.postcodeCity}}
+ {{invoice.postCode}}, {{invoice.city}}, ({{invoice.province}})
{{$t('fiscalId')}}: {{invoice.nif}}
{{$t('phone')}}: {{invoice.phone}}
diff --git a/print/templates/reports/invoiceIn/sql/invoice.sql b/print/templates/reports/invoiceIn/sql/invoice.sql
index dae979011..82eeebce0 100644
--- a/print/templates/reports/invoiceIn/sql/invoice.sql
+++ b/print/templates/reports/invoiceIn/sql/invoice.sql
@@ -4,6 +4,9 @@ SELECT
i.issued,
s.name,
s.street AS postalAddress,
+ s.city,
+ s.postCode,
+ pr.name province,
s.nif,
s.phone,
p.name payMethod
@@ -11,4 +14,5 @@ SELECT
JOIN supplier s ON s.id = i.supplierFk
JOIN company c ON c.id = i.companyFk
JOIN payMethod p ON p.id = s.payMethodFk
+ LEFT JOIN province pr ON pr.id = s.provinceFk
WHERE i.id = ?