Merge branch 'dev' into 5395-travel.extra-community
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
a32dea0acd
|
@ -30,16 +30,23 @@ module.exports = Self => {
|
|||
const recipient = to.replace('@', '');
|
||||
|
||||
if (sender.name != recipient) {
|
||||
await models.Chat.create({
|
||||
const chat = await models.Chat.create({
|
||||
senderFk: sender.id,
|
||||
recipient: to,
|
||||
dated: Date.vnNew(),
|
||||
checkUserStatus: 0,
|
||||
message: message,
|
||||
status: 0,
|
||||
status: 'sending',
|
||||
attempts: 0
|
||||
});
|
||||
|
||||
try {
|
||||
await Self.sendMessage(chat.senderFk, chat.recipient, chat.message);
|
||||
await Self.updateChat(chat, 'sent');
|
||||
} catch (error) {
|
||||
await Self.updateChat(chat, 'error', error);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,18 +24,13 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.sendCheckingPresence = async(ctx, recipientId, message, options) => {
|
||||
Self.sendCheckingPresence = async(ctx, recipientId, message) => {
|
||||
if (!recipientId) return false;
|
||||
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const sender = await models.Account.findById(userId);
|
||||
const recipient = await models.Account.findById(recipientId, null, myOptions);
|
||||
const sender = await models.Account.findById(userId, {fields: ['id']});
|
||||
const recipient = await models.Account.findById(recipientId, null);
|
||||
|
||||
// Prevent sending messages to yourself
|
||||
if (recipientId == userId) return false;
|
||||
|
@ -46,16 +41,23 @@ module.exports = Self => {
|
|||
if (process.env.NODE_ENV == 'test')
|
||||
message = `[Test:Environment to user ${userId}] ` + message;
|
||||
|
||||
await models.Chat.create({
|
||||
const chat = await models.Chat.create({
|
||||
senderFk: sender.id,
|
||||
recipient: `@${recipient.name}`,
|
||||
dated: Date.vnNew(),
|
||||
checkUserStatus: 1,
|
||||
message: message,
|
||||
status: 0,
|
||||
status: 'sending',
|
||||
attempts: 0
|
||||
});
|
||||
|
||||
try {
|
||||
await Self.sendCheckingUserStatus(chat);
|
||||
await Self.updateChat(chat, 'sent');
|
||||
} catch (error) {
|
||||
await Self.updateChat(chat, 'error', error);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,7 +3,6 @@ module.exports = Self => {
|
|||
Self.remoteMethodCtx('sendQueued', {
|
||||
description: 'Send a RocketChat message',
|
||||
accessType: 'WRITE',
|
||||
accepts: [],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
|
@ -16,14 +15,17 @@ module.exports = Self => {
|
|||
|
||||
Self.sendQueued = async() => {
|
||||
const models = Self.app.models;
|
||||
const maxAttempts = 3;
|
||||
const sentStatus = 1;
|
||||
const errorStatus = 2;
|
||||
|
||||
const chats = await models.Chat.find({
|
||||
where: {
|
||||
status: {neq: sentStatus},
|
||||
attempts: {lt: maxAttempts}
|
||||
status: {
|
||||
nin: [
|
||||
'sent',
|
||||
'sending'
|
||||
]
|
||||
|
||||
},
|
||||
attempts: {lt: 3}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -31,16 +33,16 @@ module.exports = Self => {
|
|||
if (chat.checkUserStatus) {
|
||||
try {
|
||||
await Self.sendCheckingUserStatus(chat);
|
||||
await updateChat(chat, sentStatus);
|
||||
await Self.updateChat(chat, 'sent');
|
||||
} catch (error) {
|
||||
await updateChat(chat, errorStatus, error);
|
||||
await Self.updateChat(chat, 'error', error);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await Self.sendMessage(chat.senderFk, chat.recipient, chat.message);
|
||||
await updateChat(chat, sentStatus);
|
||||
await Self.updateChat(chat, 'sent');
|
||||
} catch (error) {
|
||||
await updateChat(chat, errorStatus, error);
|
||||
await Self.updateChat(chat, 'error', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,15 +130,17 @@ module.exports = Self => {
|
|||
* @param {object} chat - The chat
|
||||
* @param {string} status - The new status
|
||||
* @param {string} error - The error
|
||||
* @param {object} options - Query options
|
||||
* @return {Promise} - The request promise
|
||||
*/
|
||||
async function updateChat(chat, status, error) {
|
||||
*/
|
||||
|
||||
Self.updateChat = async(chat, status, error) => {
|
||||
return chat.updateAttributes({
|
||||
status: status,
|
||||
attempts: ++chat.attempts,
|
||||
error: error
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the current user status on Rocketchat
|
||||
|
|
|
@ -10,7 +10,7 @@ describe('Chat sendCheckingPresence()', () => {
|
|||
|
||||
const chat = {
|
||||
checkUserStatus: 1,
|
||||
status: 0,
|
||||
status: 'pending',
|
||||
attempts: 0
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,7 @@ describe('Chat sendCheckingPresence()', () => {
|
|||
|
||||
const chat = {
|
||||
checkUserStatus: 0,
|
||||
status: 0,
|
||||
status: 'pending',
|
||||
attempts: 0
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
ALTER TABLE `vn`.`chat` ADD statusNew enum('pending','sent','error','sending') DEFAULT 'pending' NOT NULL;
|
||||
|
||||
UPDATE `vn`.`chat`
|
||||
SET statusNew = 'pending'
|
||||
WHERE status = 0;
|
||||
|
||||
UPDATE `vn`.`chat`
|
||||
SET statusNew = 'sent'
|
||||
WHERE status = 1;
|
||||
|
||||
UPDATE `vn`.`chat`
|
||||
SET statusNew = 'error'
|
||||
WHERE status = 2;
|
||||
|
||||
ALTER TABLE `vn`.`chat` CHANGE status status__ tinyint(1) DEFAULT NULL NULL;
|
||||
ALTER TABLE `vn`.`chat` CHANGE statusNew status enum('pending','sent','error','sending') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'pending' NOT NULL;
|
|
@ -501,7 +501,8 @@ INSERT INTO `vn`.`observationType`(`id`,`description`, `code`)
|
|||
(3, 'Delivery', 'delivery'),
|
||||
(4, 'SalesPerson', 'salesPerson'),
|
||||
(5, 'Administrative', 'administrative'),
|
||||
(6, 'Weight', 'weight');
|
||||
(6, 'Weight', 'weight'),
|
||||
(7, 'InvoiceOut', 'invoiceOut');
|
||||
|
||||
INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`)
|
||||
VALUES
|
||||
|
@ -738,7 +739,9 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des
|
|||
(9, 23, 5, 'care with the dog'),
|
||||
(10, 23, 4, 'Reclama ticket: 8'),
|
||||
(11, 24, 4, 'Reclama ticket: 7'),
|
||||
(12, 11, 3, 'Delivery after 10am');
|
||||
(12, 11, 3, 'Delivery after 10am'),
|
||||
(13, 1, 7, 'observation of ticket one'),
|
||||
(14, 2, 7, 'observation of ticket two');
|
||||
|
||||
-- FIX for state hours on local, inter_afterInsert
|
||||
-- UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND);
|
||||
|
@ -2631,8 +2634,8 @@ INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackage
|
|||
|
||||
INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `message`, `status`, `attempts`)
|
||||
VALUES
|
||||
(1101, '@PetterParker', util.VN_CURDATE(), 1, 'First test message', 0, 0),
|
||||
(1101, '@PetterParker', util.VN_CURDATE(), 0, 'Second test message', 0, 0);
|
||||
(1101, '@PetterParker', util.VN_CURDATE(), 1, 'First test message', 0, 'sent'),
|
||||
(1101, '@PetterParker', util.VN_CURDATE(), 0, 'Second test message', 0, 'pending');
|
||||
|
||||
|
||||
INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
||||
const {mergeFilters, mergeWhere} = require('vn-loopback/util/filter');
|
||||
const { mergeFilters, mergeWhere } = require('vn-loopback/util/filter');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('logs', {
|
||||
|
@ -12,27 +12,27 @@ module.exports = Self => {
|
|||
arg: 'id',
|
||||
type: 'Number',
|
||||
description: 'The claim id',
|
||||
http: {source: 'path'}
|
||||
http: { source: 'path' }
|
||||
},
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
http: {source: 'query'}
|
||||
http: { source: 'query' }
|
||||
},
|
||||
{
|
||||
arg: 'search',
|
||||
type: 'string',
|
||||
http: {source: 'query'}
|
||||
http: { source: 'query' }
|
||||
},
|
||||
{
|
||||
arg: 'userFk',
|
||||
type: 'number',
|
||||
http: {source: 'query'}
|
||||
http: { source: 'query' }
|
||||
},
|
||||
{
|
||||
arg: 'created',
|
||||
type: 'date',
|
||||
http: {source: 'query'}
|
||||
http: { source: 'query' }
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
|
@ -45,7 +45,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.logs = async(ctx, id, filter, options) => {
|
||||
Self.logs = async (ctx, id, filter, options) => {
|
||||
const conn = Self.dataSource.connector;
|
||||
const args = ctx.args;
|
||||
const myOptions = {};
|
||||
|
@ -56,25 +56,25 @@ module.exports = Self => {
|
|||
|
||||
let where = buildFilter(args, (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return {
|
||||
or: [
|
||||
{changedModel: {like: `%${value}%`}},
|
||||
{oldInstance: {like: `%${value}%`}}
|
||||
]
|
||||
};
|
||||
case 'userFk':
|
||||
return {'cl.userFk': value};
|
||||
case 'created':
|
||||
value.setHours(0, 0, 0, 0);
|
||||
to = new Date(value);
|
||||
to.setHours(23, 59, 59, 999);
|
||||
case 'search':
|
||||
return {
|
||||
or: [
|
||||
{ changedModel: { like: `%${value}%` } },
|
||||
{ oldInstance: { like: `%${value}%` } }
|
||||
]
|
||||
};
|
||||
case 'userFk':
|
||||
return { 'cl.userFk': value };
|
||||
case 'created':
|
||||
value.setHours(0, 0, 0, 0);
|
||||
to = new Date(value);
|
||||
to.setHours(23, 59, 59, 999);
|
||||
|
||||
return {creationDate: {between: [value, to]}};
|
||||
return { creationDate: { between: [value, to] } };
|
||||
}
|
||||
});
|
||||
where = mergeWhere(where, {['cl.originFk']: id});
|
||||
filter = mergeFilters(args.filter, {where});
|
||||
where = mergeWhere(where, { ['cl.originFk']: id });
|
||||
filter = mergeFilters(args.filter, { where });
|
||||
|
||||
const stmts = [];
|
||||
|
||||
|
@ -102,8 +102,8 @@ module.exports = Self => {
|
|||
const logs = [];
|
||||
for (const row of result) {
|
||||
const changes = [];
|
||||
const oldInstance = JSON.parse(row.oldInstance);
|
||||
const newInstance = JSON.parse(row.newInstance);
|
||||
const oldInstance = JSON.parse(row.oldInstance) || {};
|
||||
const newInstance = JSON.parse(row.newInstance) || {};
|
||||
const mergedProperties = [...Object.keys(oldInstance), ...Object.keys(newInstance)];
|
||||
const properties = new Set(mergedProperties);
|
||||
for (const property of properties) {
|
||||
|
|
|
@ -240,13 +240,18 @@
|
|||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<div class="columns vn-mt-xl" v-if="invoice.payMethodCode == 'wireTransfer'">
|
||||
<div class="columns vn-mt-xl" v-if="invoice.payMethodCode == 'wireTransfer' || ticketObservations">
|
||||
<div class="size50 pull-left no-page-break">
|
||||
<div class="panel">
|
||||
<div class="header">{{$t('observations')}}</div>
|
||||
<div class="body">
|
||||
<div>{{$t('wireTransfer')}}</div>
|
||||
<div>{{$t('accountNumber', [invoice.iban])}}</div>
|
||||
<div v-if="invoice.payMethodCode == 'wireTransfer'">
|
||||
<div>{{$t('wireTransfer')}}</div>
|
||||
<div>{{$t('accountNumber', [invoice.iban])}}</div>
|
||||
</div>
|
||||
<div v-if="ticketObservations">
|
||||
{{ticketObservations}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
ORDER BY t.shipped
|
||||
|
|
Loading…
Reference in New Issue