diff --git a/modules/client/back/methods/client/specs/updateAddress.spec.js b/modules/client/back/methods/client/specs/updateAddress.spec.js
index 5597c6e5a..2ad564cc5 100644
--- a/modules/client/back/methods/client/specs/updateAddress.spec.js
+++ b/modules/client/back/methods/client/specs/updateAddress.spec.js
@@ -33,7 +33,6 @@ describe('Address updateAddress', () => {
error = e;
}
- expect(error).toBeDefined();
expect(error.message).toEqual('Incoterms is required for a non UEE member');
});
@@ -57,7 +56,6 @@ describe('Address updateAddress', () => {
error = e;
}
- expect(error).toBeDefined();
expect(error.message).toEqual('Customs agent is required for a non UEE member');
});
@@ -91,6 +89,8 @@ describe('Address updateAddress', () => {
it('should return an error for a user without enough privileges', async() => {
const tx = await models.Client.beginTransaction({});
+ let error;
+
try {
const options = {transaction: tx};
ctx.args = {
@@ -124,8 +124,10 @@ describe('Address updateAddress', () => {
expect(address.isLogifloraAllowed).toEqual(true);
await tx.rollback();
+ ctx.req.accessToken.userId = employeeId;
} catch (e) {
await tx.rollback();
+ ctx.req.accessToken.userId = employeeId;
throw e;
}
});
diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js
index d7e20b876..cae797f6b 100644
--- a/modules/client/back/methods/client/updateAddress.js
+++ b/modules/client/back/methods/client/updateAddress.js
@@ -89,11 +89,12 @@ module.exports = function(Self) {
const args = ctx.args;
const userId = ctx.req.accessToken.userId;
const myOptions = {};
- const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', myOptions);
if (typeof options == 'object')
Object.assign(myOptions, options);
+ const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', myOptions);
+
if (args.isLogifloraAllowed && !isSalesAssistant)
throw new UserError(`You don't have enough privileges`);
diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js
index 6c692848b..25e661aee 100644
--- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js
+++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js
@@ -1,12 +1,11 @@
-const models = require('vn-loopback/server/server').models;
-
+const {models} = require('vn-loopback/server/server');
describe('item lastEntriesFilter()', () => {
- const minDate = new Date(value);
- minHour.setHours(0, 0, 0, 0);
- const maxDate = new Date(value);
- maxHour.setHours(23, 59, 59, 59);
+ it('should return one entry for the given item', async() => {
+ const minDate = new Date();
+ minDate.setHours(0, 0, 0, 0);
+ const maxDate = new Date();
+ maxDate.setHours(23, 59, 59, 59);
- it('should return one entry for a given item', async() => {
const tx = await models.Item.beginTransaction({});
const options = {transaction: tx};
@@ -23,13 +22,18 @@ describe('item lastEntriesFilter()', () => {
}
});
- it('should return five entries for a given item', async() => {
+ it('should return five entries for the given item', async() => {
+ const minDate = new Date();
+ minDate.setHours(0, 0, 0, 0);
+ minDate.setMonth(minDate.getMonth() - 2, 1);
+
+ const maxDate = new Date();
+ maxDate.setHours(23, 59, 59, 59);
+
const tx = await models.Item.beginTransaction({});
const options = {transaction: tx};
try {
- minDate.setMonth(minDate.getMonth() - 2, 1);
-
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
const result = await models.Item.lastEntriesFilter(filter, options);
diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js
index d67c5c3fc..4521b2351 100644
--- a/modules/monitor/back/methods/sales-monitor/salesFilter.js
+++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js
@@ -304,7 +304,7 @@ module.exports = Self => {
{'tp.hasTicketRequest': true},
{'tp.hasComponentLack': true},
{'tp.isTaxDataChecked': false},
- {'tp.isAvailable': false}
+ {'tp.itemShortage': {neq: null}}
]};
} else if (hasProblems === false) {
whereProblems = {and: [
@@ -313,7 +313,7 @@ module.exports = Self => {
{'tp.hasTicketRequest': false},
{'tp.hasComponentLack': false},
{'tp.isTaxDataChecked': true},
- {'tp.isAvailable': true}
+ {'tp.itemShortage': null}
]};
}
diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html
index 76b9219ee..968215e67 100644
--- a/modules/monitor/front/index/tickets/index.html
+++ b/modules/monitor/front/index/tickets/index.html
@@ -98,8 +98,8 @@
icon="icon-buyrequest">
diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js
index 58c440e95..902831d99 100644
--- a/modules/ticket/back/methods/ticket/filter.js
+++ b/modules/ticket/back/methods/ticket/filter.js
@@ -324,7 +324,7 @@ module.exports = Self => {
case true:
condition = `or`;
hasProblem = true;
- range = 0;
+ range = {neq: null};
hasWhere = true;
break;
@@ -340,7 +340,7 @@ module.exports = Self => {
{'tp.isFreezed': hasProblem},
{'tp.risk': hasProblem},
{'tp.hasTicketRequest': hasProblem},
- {'tp.isAvailable': range}
+ {'tp.itemShortage': range}
]};
if (hasWhere)
diff --git a/modules/ticket/back/methods/ticket/getSales.js b/modules/ticket/back/methods/ticket/getSales.js
index 6dfee5dfa..3e45b3fb5 100644
--- a/modules/ticket/back/methods/ticket/getSales.js
+++ b/modules/ticket/back/methods/ticket/getSales.js
@@ -94,7 +94,7 @@ module.exports = Self => {
sale.visible = itemStock.visible;
sale.claim = claimedSales.get(sale.id);
if (problems) {
- sale.isAvailable = problems.isAvailable;
+ sale.itemShortage = problems.itemShortage;
sale.hasTicketRequest = problems.hasTicketRequest;
sale.hasComponentLack = problems.hasComponentLack;
}
diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js
index b251d5335..4b583fc87 100644
--- a/modules/ticket/back/methods/ticket/specs/filter.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js
@@ -39,7 +39,7 @@ describe('ticket filter()', () => {
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
- expect(result.length).toEqual(4);
+ expect(result.length).toEqual(6);
await tx.rollback();
} catch (e) {
diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html
index 36af86001..1e18ce284 100644
--- a/modules/ticket/front/index/index.html
+++ b/modules/ticket/front/index/index.html
@@ -52,8 +52,8 @@
icon="icon-buyrequest">
diff --git a/modules/ticket/front/index/locale/es.yml b/modules/ticket/front/index/locale/es.yml
index eac0084f6..74b17b0f3 100644
--- a/modules/ticket/front/index/locale/es.yml
+++ b/modules/ticket/front/index/locale/es.yml
@@ -1,6 +1,7 @@
Weekly tickets: Tickets programados
Go to lines: Ir a lineas
Not available: No disponible
+Not visible: No visible
Payment on account...: Pago a cuenta...
Set as delivered and open delivery note(s): Marcar como servido/s y abrir albarán/es
Closure: Cierre
diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html
index 836fadb9b..f4e5840f3 100644
--- a/modules/ticket/front/sale/index.html
+++ b/modules/ticket/front/sale/index.html
@@ -95,8 +95,8 @@
translate-attr="{title: 'Reserved'}">
diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html
index 99fb949b6..fe49a301f 100644
--- a/modules/ticket/front/summary/index.html
+++ b/modules/ticket/front/summary/index.html
@@ -157,8 +157,8 @@
translate-attr="{title: 'Reserved'}">