Merge branch 'dev' into 6281_buyFk
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Robert Ferrús 2024-05-23 06:29:16 +00:00
commit 974e327077
20 changed files with 103 additions and 49 deletions

View File

@ -1,3 +1,5 @@
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
Self.remoteMethodCtx('sendCheckingPresence', {
description: 'Creates a message in the chat model checking the user status',
@ -37,7 +39,7 @@ module.exports = Self => {
if (!recipient)
throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`);
if (process.env.NODE_ENV == 'test')
if (!isProduction())
message = `[Test:Environment to user ${userId}] ` + message;
const chat = await models.Chat.create({

View File

@ -1,4 +1,6 @@
const axios = require('axios');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
Self.remoteMethodCtx('sendQueued', {
description: 'Send a RocketChat message',
@ -94,7 +96,7 @@ module.exports = Self => {
* @return {Promise} - The request promise
*/
Self.sendMessage = async function sendMessage(senderFk, recipient, message) {
if (process.env.NODE_ENV !== 'production') {
if (!isProduction(false)) {
return new Promise(resolve => {
return resolve({
statusCode: 200,
@ -149,7 +151,7 @@ module.exports = Self => {
* @return {Promise} - The request promise
*/
Self.getUserStatus = async function getUserStatus(username) {
if (process.env.NODE_ENV !== 'production') {
if (!isProduction(false)) {
return new Promise(resolve => {
return resolve({
data: {

View File

@ -1,6 +1,7 @@
const UserError = require('vn-loopback/util/user-error');
const fs = require('fs-extra');
const path = require('path');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
Self.remoteMethod('deleteTrashFiles', {
@ -22,7 +23,7 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
if (process.env.NODE_ENV == 'test')
if (!isProduction())
throw new UserError(`Action not allowed on the test environment`);
const models = Self.app.models;

View File

@ -1,5 +1,6 @@
const UserError = require('vn-loopback/util/user-error');
const axios = require('axios');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
Self.remoteMethodCtx('upload', {
@ -119,7 +120,7 @@ module.exports = Self => {
]
};
if (process.env.NODE_ENV != 'production')
if (!isProduction(false))
throw new UserError('Action not allowed on the test environment');
// delete old

View File

@ -1,6 +1,7 @@
const fs = require('fs-extra');
const path = require('path');
const UserError = require('vn-loopback/util/user-error');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
Self.remoteMethod('scrub', {
@ -43,8 +44,7 @@ module.exports = Self => {
Self.scrub = async function(collection, remove, limit, dryRun, skipLock) {
const $ = Self.app.models;
const env = process.env.NODE_ENV;
dryRun = dryRun || (env && env !== 'production');
dryRun = dryRun || !isProduction(false);
const instance = await $.ImageCollection.findOne({
fields: ['id'],

View File

@ -1,6 +1,7 @@
const UserError = require('vn-loopback/util/user-error');
const fs = require('fs/promises');
const path = require('path');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
Self.remoteMethodCtx('upload', {
@ -41,7 +42,7 @@ module.exports = Self => {
if (!hasWriteRole)
throw new UserError(`You don't have enough privileges`);
if (process.env.NODE_ENV == 'test')
if (!isProduction())
throw new UserError(`Action not allowed on the test environment`);
// Upload file to temporary path

View File

@ -1,4 +1,5 @@
const {Email} = require('vn-print');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
Self.remoteMethod('send', {
@ -70,7 +71,7 @@ module.exports = Self => {
const newParams = Object.assign({}, queueParams, sendParams);
const email = new Email(queueName, newParams);
if (process.env.NODE_ENV != 'test')
if (isProduction())
await email.send();
await queue.updateAttribute('status', statusSent);

View File

@ -186,5 +186,8 @@
},
"AgencyWorkCenter": {
"dataSource": "vn"
},
"RouteConfig": {
"dataSource": "vn"
}
}

View File

@ -0,0 +1,18 @@
{
"name": "RouteConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "routeConfig"
}
},
"properties": {
"id": {
"type": "number",
"description": "Identifier"
},
"kmMax": {
"type": "number"
}
}
}

View File

@ -23,22 +23,19 @@ BEGIN
DECLARE vXtraLongAgj INT;
DECLARE vDefaultKlo INT;
SELECT
ec.usefulAuctionLeftSegmentLength,
ec.standardBarcodeLength,
ec.floridayBarcodeLength,
ec.floramondoBarcodeLength,
ec.defaultKlo
INTO
vUsefulAuctionLeftSegmentLength,
SELECT usefulAuctionLeftSegmentLength,
standardBarcodeLength,
floridayBarcodeLength,
floramondoBarcodeLength,
defaultKlo
INTO vUsefulAuctionLeftSegmentLength,
vStandardBarcodeLength,
vFloridayBarcodeLength,
vFloramondoBarcodeLength,
vDefaultKlo
FROM edi.ektConfig ec;
FROM ektConfig;
DROP TEMPORARY TABLE IF EXISTS tmp.ekt;
CREATE TEMPORARY TABLE tmp.ekt
CREATE OR REPLACE TEMPORARY TABLE tmp.ekt
ENGINE = MEMORY
SELECT id ektFk FROM ekt LIMIT 0;
@ -46,19 +43,19 @@ BEGIN
WHEN LENGTH(vBarcode) <= vFloridayBarcodeLength THEN
INSERT INTO tmp.ekt
SELECT id
FROM edi.ektRecent e
FROM ektRecent e
WHERE e.cps = vBarcode
OR e.batchNumber = vBarcode;
WHEN LENGTH(vBarcode) = vFloramondoBarcodeLength THEN
INSERT INTO tmp.ekt
SELECT e.id
FROM edi.ektRecent e
FROM ektRecent e
WHERE e.pro = MID(vBarcode,2,6)
AND CAST(e.ptd AS SIGNED) = MID(vBarcode,8,5);
AND CAST(e.ptd AS SIGNED) = MID(vBarcode, 8, 5);
ELSE
SET vBarcode = LPAD(vBarcode,vStandardBarcodeLength,'0');
SET vBarcode = LPAD(vBarcode, vStandardBarcodeLength, '0');
SET vAuction = MID(vBarcode, 1, 3);
SET vKlo = MID(vBarcode, 4, 2);
SET vFec = MAKEDATE(YEAR(util.VN_CURDATE()), MID(vBarcode, 6, 3));
@ -74,13 +71,15 @@ BEGIN
SELECT id
FROM ekt
WHERE fec >= vFec - INTERVAL 1 DAY
AND ((
vKlo = vDefaultKlo
AND (
(vKlo = vDefaultKlo
AND (klo = vKlo OR klo IS NULL OR klo = 0)
AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj))
OR (klo = vKlo
AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj)
) OR (
klo = vKlo
AND auction = vAuction
AND agj = vShortAgj)
AND agj = vShortAgj
)
)
ORDER BY agj DESC, fec DESC
LIMIT 1;
@ -91,9 +90,11 @@ BEGIN
IF NOT vIsFound THEN
INSERT INTO tmp.ekt
SELECT id
FROM edi.ektRecent e
WHERE e.batchNumber
= LEFT(vBarcode,vUsefulAuctionLeftSegmentLength)
FROM ektRecent e
WHERE e.batchNumber = LEFT(
vBarcode,
vUsefulAuctionLeftSegmentLength
)
AND e.batchNumber > 0;
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
@ -103,7 +104,7 @@ BEGIN
IF NOT vIsFound THEN
INSERT INTO tmp.ekt
SELECT id
FROM edi.ektRecent e
FROM ektRecent e
WHERE e.putOrderFk = vBarcode;
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
@ -113,13 +114,23 @@ BEGIN
IF NOT vIsFound THEN
INSERT INTO tmp.ekt
SELECT id
FROM edi.ektRecent e
WHERE e.deliveryNumber
= MID(vBarcode, 4, 13)
FROM ektRecent e
WHERE e.deliveryNumber = MID(vBarcode, 4, 13)
AND e.deliveryNumber > 0;
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
END IF;
-- Solo campo agj
IF NOT vIsFound THEN
INSERT INTO tmp.ekt
SELECT id
FROM ektRecent
WHERE agj = vShortAgj;
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
END IF;
END CASE;
IF vIsFound THEN

View File

@ -27,7 +27,10 @@ BEGIN
SELECT DISTINCT clientFk
FROM (
SELECT clientFk, SUM(quantity) totalQuantity
FROM tmp.packagingToInvoice
FROM tmp.packagingToInvoice tpi
JOIN client c ON c.id = tpi.clientFk
LEFT JOIN supplier s ON s.nif = c.fi
WHERE s.id IS NULL
GROUP BY itemFk, clientFk
HAVING totalQuantity > 0)sub;

View File

@ -0,0 +1,3 @@
-- Place your SQL code here
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
VALUES ('RouteConfig','*','READ','ALLOW','ROLE','employee');

View File

@ -1,4 +1,3 @@
module.exports = function(Self) {
require('../methods/application/status')(Self);
require('../methods/application/post')(Self);

View File

@ -0,0 +1,3 @@
module.exports = (localAsProduction = true) => {
return (!process.env.NODE_ENV && localAsProduction) || process.env.NODE_ENV == 'production';
};

View File

@ -3,9 +3,10 @@ const app = require('vn-loopback/server/server');
const ldap = require('../util/ldapjs-extra');
const crypto = require('crypto');
const nthash = require('smbhash').nthash;
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
const shouldSync = process.env.NODE_ENV !== 'test';
const shouldSync = isProduction();
Self.getLinker = async function() {
return await Self.findOne({

View File

@ -1,6 +1,7 @@
const ldap = require('../util/ldapjs-extra');
const execFile = require('child_process').execFile;
const isProduction = require('vn-loopback/server/boot/isProduction');
/**
* Summary of userAccountControl flags:
@ -12,7 +13,7 @@ const UserAccountControlFlags = {
};
module.exports = Self => {
const shouldSync = process.env.NODE_ENV !== 'test';
const shouldSync = isProduction();
Self.getLinker = async function() {
return await Self.findOne({

View File

@ -1,5 +1,6 @@
const got = require('got');
const UserError = require('vn-loopback/util/user-error');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
Self.remoteMethod('send', {
@ -47,7 +48,7 @@ module.exports = Self => {
let response;
try {
if (process.env.NODE_ENV !== 'production')
if (!isProduction(false))
response = {result: [{status: 'ok'}]};
else {
const jsonTest = {

View File

@ -1,5 +1,6 @@
const fs = require('fs-extra');
const path = require('path');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
Self.remoteMethodCtx('download', {
@ -66,7 +67,7 @@ module.exports = Self => {
console.error(err);
});
if (process.env.NODE_ENV == 'test') {
if (!isProduction()) {
try {
await fs.access(file.path);
} catch (error) {

View File

@ -1,6 +1,7 @@
const print = require('vn-print');
const path = require('path');
const UserError = require('vn-loopback/util/user-error');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
require('../methods/invoiceOut/filter')(Self);
@ -59,7 +60,7 @@ module.exports = Self => {
hasPdf: true
}, options);
if (process.env.NODE_ENV !== 'test') {
if (isProduction()) {
await print.storage.write(buffer, {
type: 'invoice',
path: pdfFile.path,

View File

@ -1,6 +1,7 @@
const fs = require('fs-extra');
const path = require('path');
const UserError = require('vn-loopback/util/user-error');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
Self.remoteMethodCtx('upload', {
@ -111,7 +112,7 @@ module.exports = Self => {
const destinationFile = path.join(
accessContainer.client.root, accessContainer.name, appName, `${toVersion}.7z`);
if (process.env.NODE_ENV == 'test')
if (!isProduction())
await fs.unlink(srcFile);
else {
await fs.move(srcFile, destinationFile, {