@@ -169,12 +170,20 @@
class="link">
{{ticket.refFk}}
-
{{ticket.state}}
+
+
+
+ |
-
Filter by selection
-
Exclude selection
-
Remove filter
-
Remove all filters
-
Copy value
diff --git a/modules/route/back/methods/route/specs/clone.spec.js b/modules/route/back/methods/route/specs/clone.spec.js
index 9192854f8..496ae1c89 100644
--- a/modules/route/back/methods/route/specs/clone.spec.js
+++ b/modules/route/back/methods/route/specs/clone.spec.js
@@ -1,6 +1,22 @@
const app = require('vn-loopback/server/server');
+const LoopBackContext = require('loopback-context');
describe('route clone()', () => {
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
const createdDate = Date.vnNew();
it('should throw an error if the amount of ids pased to the clone function do no match the database', async() => {
const ids = [996, 997, 998, 999];
diff --git a/modules/route/back/methods/route/specs/updateWorkCenter.spec.js b/modules/route/back/methods/route/specs/updateWorkCenter.spec.js
index 5328dc240..baa63f226 100644
--- a/modules/route/back/methods/route/specs/updateWorkCenter.spec.js
+++ b/modules/route/back/methods/route/specs/updateWorkCenter.spec.js
@@ -1,6 +1,20 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('route updateWorkCenter()', () => {
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
const routeId = 1;
it('should set the commission work center if the worker has workCenter', async() => {
diff --git a/modules/route/back/models/route.json b/modules/route/back/models/route.json
index 12b9785db..3b12f4ee6 100644
--- a/modules/route/back/models/route.json
+++ b/modules/route/back/models/route.json
@@ -2,7 +2,8 @@
"name": "Route",
"base": "Loggable",
"log": {
- "model":"RouteLog"
+ "model":"RouteLog",
+ "grabUser": true
},
"options": {
"mysql": {
diff --git a/modules/ticket/back/methods/sale/specs/canEdit.spec.js b/modules/ticket/back/methods/sale/specs/canEdit.spec.js
index a6c299321..62f98421a 100644
--- a/modules/ticket/back/methods/sale/specs/canEdit.spec.js
+++ b/modules/ticket/back/methods/sale/specs/canEdit.spec.js
@@ -1,7 +1,21 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('sale canEdit()', () => {
const employeeId = 1;
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
describe('sale editTracked', () => {
it('should return true if the role is production regardless of the saleTrackings', async() => {
diff --git a/modules/ticket/back/methods/sale/specs/deleteSales.spec.js b/modules/ticket/back/methods/sale/specs/deleteSales.spec.js
index 82cf916b3..3d3e06e22 100644
--- a/modules/ticket/back/methods/sale/specs/deleteSales.spec.js
+++ b/modules/ticket/back/methods/sale/specs/deleteSales.spec.js
@@ -1,6 +1,21 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('sale deleteSales()', () => {
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
it('should throw an error if the ticket of the given sales is not editable', async() => {
const tx = await models.Sale.beginTransaction({});
diff --git a/modules/ticket/back/methods/sale/specs/reserve.spec.js b/modules/ticket/back/methods/sale/specs/reserve.spec.js
index 7ab79f9c0..259cb8cd5 100644
--- a/modules/ticket/back/methods/sale/specs/reserve.spec.js
+++ b/modules/ticket/back/methods/sale/specs/reserve.spec.js
@@ -1,4 +1,5 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('sale reserve()', () => {
const ctx = {
@@ -9,6 +10,20 @@ describe('sale reserve()', () => {
}
};
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
it('should throw an error if the ticket can not be modified', async() => {
const tx = await models.Sale.beginTransaction({});
diff --git a/modules/ticket/back/methods/sale/specs/updateConcept.spec.js b/modules/ticket/back/methods/sale/specs/updateConcept.spec.js
index 0e7e9bf0f..1b42e7140 100644
--- a/modules/ticket/back/methods/sale/specs/updateConcept.spec.js
+++ b/modules/ticket/back/methods/sale/specs/updateConcept.spec.js
@@ -1,6 +1,21 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('sale updateConcept()', () => {
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
const ctx = {req: {accessToken: {userId: 9}}};
const saleId = 25;
diff --git a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js
index 51cd2403f..133be8de3 100644
--- a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js
+++ b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js
@@ -1,6 +1,21 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('sale updatePrice()', () => {
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 18},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
const ctx = {
req: {
accessToken: {userId: 18},
diff --git a/modules/ticket/back/methods/sale/specs/updateQuantity.spec.js b/modules/ticket/back/methods/sale/specs/updateQuantity.spec.js
index 53a05cd7e..4778f6b6d 100644
--- a/modules/ticket/back/methods/sale/specs/updateQuantity.spec.js
+++ b/modules/ticket/back/methods/sale/specs/updateQuantity.spec.js
@@ -1,6 +1,21 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('sale updateQuantity()', () => {
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
const ctx = {
req: {
accessToken: {userId: 9},
diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js
index 597ece3e5..a5d04bc4c 100644
--- a/modules/ticket/back/methods/ticket/new.js
+++ b/modules/ticket/back/methods/ticket/new.js
@@ -127,19 +127,6 @@ module.exports = Self => {
], myOptions);
const ticket = await models.Ticket.findById(result[1][0].newTicketId, null, myOptions);
- const cleanInstance = JSON.parse(JSON.stringify(ticket));
-
- const logRecord = {
- originFk: cleanInstance.id,
- userFk: myUserId,
- action: 'insert',
- changedModel: 'Ticket',
- changedModelId: cleanInstance.id,
- oldInstance: {},
- newInstance: cleanInstance
- };
-
- await models.TicketLog.create(logRecord, myOptions);
if (tx) await tx.commit();
diff --git a/modules/ticket/back/methods/ticket/specs/addSale.spec.js b/modules/ticket/back/methods/ticket/specs/addSale.spec.js
index cfd149511..2e568716a 100644
--- a/modules/ticket/back/methods/ticket/specs/addSale.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/addSale.spec.js
@@ -1,7 +1,21 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('ticket addSale()', () => {
const ticketId = 13;
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
it('should create a new sale for the ticket with id 13', async() => {
const tx = await models.Ticket.beginTransaction({});
diff --git a/modules/ticket/back/methods/ticket/specs/merge.spec.js b/modules/ticket/back/methods/ticket/specs/merge.spec.js
index 78eb0c8f3..3254e58a8 100644
--- a/modules/ticket/back/methods/ticket/specs/merge.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/merge.spec.js
@@ -10,11 +10,15 @@ describe('ticket merge()', () => {
workerFk: 1
};
- const activeCtx = {
- accessToken: {userId: 9},
- };
-
- beforeEach(() => {
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
@@ -35,16 +39,16 @@ describe('ticket merge()', () => {
try {
const options = {transaction: tx};
- const chatNotificationBeforeMerge = await models.Chat.find();
+ const chatNotificationBeforeMerge = await models.Chat.find(null, options);
await models.Ticket.merge(ctx, [tickets], options);
- const createdTicketLog = await models.TicketLog.find({where: {originFk: tickets.originId}}, options);
+ const createdTicketLog = await models.TicketLog.find({where: {originFk: tickets.destinationId}}, options);
const deletedTicket = await models.Ticket.findOne({where: {id: tickets.originId}}, options);
const salesTicketFuture = await models.Sale.find({where: {ticketFk: tickets.destinationId}}, options);
- const chatNotificationAfterMerge = await models.Chat.find();
+ const chatNotificationAfterMerge = await models.Chat.find(null, options);
- expect(createdTicketLog.length).toEqual(2);
+ expect(createdTicketLog.length).toEqual(1);
expect(deletedTicket.isDeleted).toEqual(true);
expect(salesTicketFuture.length).toEqual(2);
expect(chatNotificationBeforeMerge.length).toEqual(chatNotificationAfterMerge.length - 2);
diff --git a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js
index 1f6712087..41de1fd6e 100644
--- a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js
@@ -1,6 +1,20 @@
const models = require('vn-loopback/server/server').models;
+const LoopBackContext = require('loopback-context');
describe('sale updateDiscount()', () => {
+ beforeAll(async() => {
+ const activeCtx = {
+ accessToken: {userId: 9},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
const originalSaleId = 8;
it('should throw an error if no sales were selected', async() => {
diff --git a/modules/ticket/back/models/sale.json b/modules/ticket/back/models/sale.json
index 669b05be6..7b8cf501b 100644
--- a/modules/ticket/back/models/sale.json
+++ b/modules/ticket/back/models/sale.json
@@ -4,7 +4,8 @@
"log": {
"model": "TicketLog",
"relation": "ticket",
- "showField": "concept"
+ "showField": "concept",
+ "grabUser": true
},
"options": {
"mysql": {
diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json
index 1cf2642a5..dabda838a 100644
--- a/modules/ticket/back/models/ticket.json
+++ b/modules/ticket/back/models/ticket.json
@@ -3,7 +3,8 @@
"base": "Loggable",
"log": {
"model":"TicketLog",
- "showField": "id"
+ "showField": "id",
+ "grabUser": true
},
"options": {
"mysql": {
diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json
index c20b7b0bf..7dd9f5bba 100644
--- a/modules/travel/back/models/travel.json
+++ b/modules/travel/back/models/travel.json
@@ -3,7 +3,8 @@
"base": "Loggable",
"log": {
"model":"TravelLog",
- "showField": "ref"
+ "showField": "ref",
+ "grabUser": true
},
"options": {
"mysql": {
diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html
index eb133c0cd..0be5a30f0 100644
--- a/print/templates/reports/delivery-note/delivery-note.html
+++ b/print/templates/reports/delivery-note/delivery-note.html
@@ -33,7 +33,7 @@
-
+
{{address.nickname}}
{{address.street}}
{{address.postalCode}}, {{address.city}} ({{address.province}})
@@ -245,13 +245,8 @@
-
-
+
\ No newline at end of file
diff --git a/print/templates/reports/invoice/invoice.html b/print/templates/reports/invoice/invoice.html
index 2d180878a..7a1ed3319 100644
--- a/print/templates/reports/invoice/invoice.html
+++ b/print/templates/reports/invoice/invoice.html
@@ -240,13 +240,18 @@
-
+
- {{$t('wireTransfer')}}
- {{$t('accountNumber', [invoice.iban])}}
+
+ {{$t('wireTransfer')}}
+ {{$t('accountNumber', [invoice.iban])}}
+
+
+ {{ticketObservations}}
+
diff --git a/print/templates/reports/invoice/invoice.js b/print/templates/reports/invoice/invoice.js
index b135e152b..42988113f 100755
--- a/print/templates/reports/invoice/invoice.js
+++ b/print/templates/reports/invoice/invoice.js
@@ -21,11 +21,15 @@ module.exports = {
const map = new Map();
+ this.ticketObservations = '';
for (let ticket of tickets) {
ticket.sales = [];
map.set(ticket.id, ticket);
+
+ if (ticket.description) this.ticketObservations += ticket.description + ' ';
}
+ this.ticketObservations = this.ticketObservations.trim();
for (let sale of sales) {
const ticket = map.get(sale.ticketFk);
diff --git a/print/templates/reports/invoice/sql/tickets.sql b/print/templates/reports/invoice/sql/tickets.sql
index 162f043e2..a8385599c 100644
--- a/print/templates/reports/invoice/sql/tickets.sql
+++ b/print/templates/reports/invoice/sql/tickets.sql
@@ -1,8 +1,12 @@
SELECT
t.id,
t.shipped,
- t.nickname
-FROM invoiceOut io
- JOIN ticket t ON t.refFk = io.ref
+ t.nickname,
+ tto.description
+FROM invoiceOut io
+ JOIN ticket t ON t.refFk = io.REF
+ LEFT JOIN observationType ot ON ot.code = 'invoiceOut'
+ LEFT JOIN ticketObservation tto ON tto.ticketFk = t.id
+ AND tto.observationTypeFk = ot.id
WHERE t.refFk = ?
-ORDER BY t.shipped
\ No newline at end of file
+ORDER BY t.shipped
|