Merge pull request '3261-ticket_request' (#774) from 3261-ticket_request into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #774
Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
Joan Sanchez 2021-11-15 09:18:08 +00:00
commit 5eec8480c0
6 changed files with 37 additions and 13 deletions

View File

@ -117,5 +117,6 @@
"INACTIVE_PROVIDER": "Inactive provider",
"reference duplicated": "reference duplicated",
"The PDF document does not exists": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option",
"This item is not available": "This item is not available"
"This item is not available": "This item is not available",
"Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}"
}

View File

@ -133,6 +133,7 @@
"reserved": "reservado",
"Changed sale reserved state": "He cambiado el estado reservado de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
"Bought units from buy request": "Se ha comprado {{quantity}} unidades de [{{itemId}} {{concept}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})",
"Deny buy request":"Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}",
"MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*",
"Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})",
"Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})",

View File

@ -24,6 +24,8 @@ module.exports = Self => {
});
Self.deny = async(ctx, options) => {
const models = Self.app.models;
const $t = ctx.req.__; // $translate
const myOptions = {};
let tx;
@ -48,6 +50,17 @@ module.exports = Self => {
const request = await Self.app.models.TicketRequest.findById(ctx.args.id, null, myOptions);
await request.updateAttributes(params, myOptions);
const origin = ctx.req.headers.origin;
const requesterId = request.requesterFk;
const message = $t('Deny buy request', {
ticketId: request.ticketFk,
url: `${origin}/#!/ticket/${request.ticketFk}/request/index`,
observation: params.response
});
await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions);
if (tx) await tx.commit();
return request;

View File

@ -1,13 +1,23 @@
const models = require('vn-loopback/server/server').models;
describe('ticket-request deny()', () => {
it('should return the dinied ticket request', async() => {
it('should return the denied ticket request', async() => {
const tx = await models.TicketRequest.beginTransaction({});
try {
const options = {transaction: tx};
const ctx = {req: {accessToken: {userId: 9}}, args: {id: 4, observation: 'my observation'}};
const ctx = {
req: {
accessToken: {userId: 9},
headers: {origin: 'http://localhost'}
},
args: {id: 4, observation: 'my observation'},
};
ctx.req.__ = value => {
return value;
};
const result = await models.TicketRequest.deny(ctx, options);

View File

@ -25,7 +25,7 @@
<vn-th number>Quantity</vn-th>
<vn-th number>Price</vn-th>
<vn-th number>Item id</vn-th>
<vn-th number>Ok</vn-th>
<vn-th number>State</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
@ -78,13 +78,9 @@
{{::request.saleFk | zeroFill:6}}
</span>
</vn-td>
<vn-td number>
<vn-check vn-one
ng-model="::request.isOk"
triple-state="true"
title="{{$ctrl.getRequestState(request.isOk)}}"
disabled="true">
</vn-check>
<vn-td number
translate>
{{$ctrl.getRequestState(request.isOk)}}
</vn-td>
<vn-td number>
<vn-icon-button

View File

@ -5,3 +5,6 @@ New request: Crear petición
Sale id: Id linea
Requester: Solicitante
New purchase request: Nueva petición de compra
Denied: Denegada
Acepted: Aceptada
New: Nueva