Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 3940-export_database

This commit is contained in:
Vicent Llopis 2022-05-06 08:08:06 +02:00
commit ddcbaa72c6
12 changed files with 35 additions and 27 deletions

View File

@ -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;
}
});

View File

@ -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`);

View File

@ -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);

View File

@ -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}
]};
}

View File

@ -98,8 +98,8 @@
icon="icon-buyrequest">
</vn-icon>
<vn-icon
ng-show="::ticket.isAvailable === 0"
translate-attr="{title: 'Not available'}"
ng-show="::ticket.itemShortage"
translate-attr="{title: 'Not visible'}"
class="bright"
icon="icon-unavailable">
</vn-icon>

View File

@ -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)

View File

@ -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;
}

View File

@ -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) {

View File

@ -52,8 +52,8 @@
icon="icon-buyrequest">
</vn-icon>
<vn-icon
ng-show="::ticket.isAvailable === 0"
translate-attr="{title: 'Not available'}"
ng-show="::ticket.itemShortage"
translate-attr="{title: 'Not visible'}"
class="bright"
icon="icon-unavailable">
</vn-icon>

View File

@ -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

View File

@ -95,8 +95,8 @@
translate-attr="{title: 'Reserved'}">
</vn-icon>
<vn-icon
ng-show="::sale.isAvailable === 0"
translate-attr="{title: 'Not available'}"
ng-show="::sale.itemShortage"
translate-attr="{title: 'Not visible'}"
class="bright"
icon="icon-unavailable">
</vn-icon>

View File

@ -157,8 +157,8 @@
translate-attr="{title: 'Reserved'}">
</vn-icon>
<vn-icon
ng-show="::sale.isAvailable === 0"
translate-attr="{title: 'Not available'}"
ng-show="::sale.itemShortage"
translate-attr="{title: 'Not visible'}"
class="bright"
icon="icon-unavailable">
</vn-icon>