Merge pull request 'closes #4789 hasInvoice on ticket searchbar' (!1153) from 4789-search-ticket-without-invoice into dev
gitea/salix/pipeline/head There was a failure building this commit Details

Reviewed-on: #1153
Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
Pau 2022-11-24 09:27:18 +00:00
commit c17435f6c4
4 changed files with 54 additions and 1 deletions

View File

@ -88,6 +88,11 @@ module.exports = Self => {
type: 'boolean', type: 'boolean',
description: `Whether to show only tickets with route` description: `Whether to show only tickets with route`
}, },
{
arg: 'hasInvoice',
type: 'boolean',
description: `Whether to show only tickets with invoice`
},
{ {
arg: 'pending', arg: 'pending',
type: 'boolean', type: 'boolean',
@ -199,6 +204,10 @@ module.exports = Self => {
if (value == true) if (value == true)
return {'t.routeFk': {neq: null}}; return {'t.routeFk': {neq: null}};
return {'t.routeFk': null}; return {'t.routeFk': null};
case 'hasInvoice':
if (value == true)
return {'t.refFk': {neq: null}};
return {'t.refFk': null};
case 'pending': case 'pending':
return {'st.isNotValidated': value}; return {'st.isNotValidated': value};
case 'id': case 'id':

View File

@ -39,7 +39,7 @@ describe('ticket filter()', () => {
const filter = {}; const filter = {};
const result = await models.Ticket.filter(ctx, filter, options); const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(6); expect(result.length).toBeGreaterThan(3);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -278,4 +278,42 @@ describe('ticket filter()', () => {
throw e; throw e;
} }
}); });
it('should return the tickets with the invoice on false', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: 9}}, args: {hasInvoice: true}};
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(6);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the tickets with the invoice on null', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: 9}}, args: {hasInvoice: null}};
const filter = {};
const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toBeGreaterThanOrEqual(27);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
}); });

View File

@ -141,6 +141,11 @@
ng-model="filter.hasRoute" ng-model="filter.hasRoute"
triple-state="true"> triple-state="true">
</vn-check> </vn-check>
<vn-check
vn-one
label="Has invoice"
ng-model="filter.hasInvoice"
triple-state="true">
</vn-horizontal> </vn-horizontal>
<vn-horizontal class="vn-px-lg vn-pb-lg vn-mt-lg"> <vn-horizontal class="vn-px-lg vn-pb-lg vn-mt-lg">
<vn-submit label="Search"></vn-submit> <vn-submit label="Search"></vn-submit>

View File

@ -13,6 +13,7 @@ Grouped States: Estado agrupado
Days onward: Días adelante Days onward: Días adelante
With problems: Con problemas With problems: Con problemas
Has route: Con ruta Has route: Con ruta
Has invoice: Con factura
Pending: Pendiente Pending: Pendiente
FREE: Libre FREE: Libre
DELIVERED: Servido DELIVERED: Servido