Merge branch 'dev' into 5447-TravelExtraCommunity
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
a1f4c58adf
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
|
@ -54,6 +54,12 @@ For end-to-end tests run from project's root.
|
||||||
$ npm run test:e2e
|
$ npm run test:e2e
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Generate changeLog test → master
|
||||||
|
```
|
||||||
|
$ bash changelog.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Visual Studio Code extensions
|
## Visual Studio Code extensions
|
||||||
|
|
||||||
Open Visual Studio Code, press Ctrl+P and paste the following commands.
|
Open Visual Studio Code, press Ctrl+P and paste the following commands.
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('sendCheckingPresence', {
|
Self.remoteMethodCtx('sendCheckingPresence', {
|
||||||
description: 'Creates a message in the chat model checking the user status',
|
description: 'Creates a message in the chat model checking the user status',
|
||||||
|
@ -37,7 +39,7 @@ module.exports = Self => {
|
||||||
if (!recipient)
|
if (!recipient)
|
||||||
throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`);
|
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;
|
message = `[Test:Environment to user ${userId}] ` + message;
|
||||||
|
|
||||||
const chat = await models.Chat.create({
|
const chat = await models.Chat.create({
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('sendQueued', {
|
Self.remoteMethodCtx('sendQueued', {
|
||||||
description: 'Send a RocketChat message',
|
description: 'Send a RocketChat message',
|
||||||
|
@ -94,7 +96,7 @@ module.exports = Self => {
|
||||||
* @return {Promise} - The request promise
|
* @return {Promise} - The request promise
|
||||||
*/
|
*/
|
||||||
Self.sendMessage = async function sendMessage(senderFk, recipient, message) {
|
Self.sendMessage = async function sendMessage(senderFk, recipient, message) {
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (!isProduction(false)) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
return resolve({
|
return resolve({
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
|
@ -149,7 +151,7 @@ module.exports = Self => {
|
||||||
* @return {Promise} - The request promise
|
* @return {Promise} - The request promise
|
||||||
*/
|
*/
|
||||||
Self.getUserStatus = async function getUserStatus(username) {
|
Self.getUserStatus = async function getUserStatus(username) {
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (!isProduction(false)) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
return resolve({
|
return resolve({
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('deleteTrashFiles', {
|
Self.remoteMethod('deleteTrashFiles', {
|
||||||
|
@ -22,7 +23,7 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
if (process.env.NODE_ENV == 'test')
|
if (!isProduction())
|
||||||
throw new UserError(`Action not allowed on the test environment`);
|
throw new UserError(`Action not allowed on the test environment`);
|
||||||
|
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('upload', {
|
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');
|
throw new UserError('Action not allowed on the test environment');
|
||||||
|
|
||||||
// delete old
|
// delete old
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('scrub', {
|
Self.remoteMethod('scrub', {
|
||||||
|
@ -43,8 +44,7 @@ module.exports = Self => {
|
||||||
Self.scrub = async function(collection, remove, limit, dryRun, skipLock) {
|
Self.scrub = async function(collection, remove, limit, dryRun, skipLock) {
|
||||||
const $ = Self.app.models;
|
const $ = Self.app.models;
|
||||||
|
|
||||||
const env = process.env.NODE_ENV;
|
dryRun = dryRun || !isProduction(false);
|
||||||
dryRun = dryRun || (env && env !== 'production');
|
|
||||||
|
|
||||||
const instance = await $.ImageCollection.findOne({
|
const instance = await $.ImageCollection.findOne({
|
||||||
fields: ['id'],
|
fields: ['id'],
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
const fs = require('fs/promises');
|
const fs = require('fs/promises');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('upload', {
|
Self.remoteMethodCtx('upload', {
|
||||||
|
@ -41,7 +42,7 @@ module.exports = Self => {
|
||||||
if (!hasWriteRole)
|
if (!hasWriteRole)
|
||||||
throw new UserError(`You don't have enough privileges`);
|
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`);
|
throw new UserError(`Action not allowed on the test environment`);
|
||||||
|
|
||||||
// Upload file to temporary path
|
// Upload file to temporary path
|
||||||
|
|
|
@ -39,8 +39,6 @@ module.exports = Self => {
|
||||||
const xmlString = response.data;
|
const xmlString = response.data;
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||||
const [resultElement] = xmlDoc.getElementsByTagName('Mensaje');
|
return xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
|
||||||
|
|
||||||
return resultElement.textContent;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,7 +42,8 @@ module.exports = Self => {
|
||||||
throw new UserError(`Some mrwConfig parameters are not set`);
|
throw new UserError(`Some mrwConfig parameters are not set`);
|
||||||
|
|
||||||
const query =
|
const query =
|
||||||
`SELECT CASE co.code
|
`SELECT
|
||||||
|
CASE co.code
|
||||||
WHEN 'ES' THEN a.postalCode
|
WHEN 'ES' THEN a.postalCode
|
||||||
WHEN 'PT' THEN LEFT(a.postalCode, 4)
|
WHEN 'PT' THEN LEFT(a.postalCode, 4)
|
||||||
WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00')
|
WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00')
|
||||||
|
@ -89,14 +90,9 @@ module.exports = Self => {
|
||||||
const getLabelResponse = await sendXmlDoc('getLabel', {mrw, shipmentId}, 'text/xml');
|
const getLabelResponse = await sendXmlDoc('getLabel', {mrw, shipmentId}, 'text/xml');
|
||||||
const file = getTextByTag(getLabelResponse, 'EtiquetaFile');
|
const file = getTextByTag(getLabelResponse, 'EtiquetaFile');
|
||||||
|
|
||||||
try {
|
if (tx) await tx.commit();
|
||||||
await models.Expedition.updateAll({id: expeditionFk}, {externalId: shipmentId}, myOptions);
|
|
||||||
if (tx) await tx.commit();
|
return {shipmentId, file};
|
||||||
} catch (error) {
|
|
||||||
if (tx) await tx.rollback();
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
return file;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function getTextByTag(xmlDoc, tag) {
|
function getTextByTag(xmlDoc, tag) {
|
||||||
|
|
|
@ -81,9 +81,9 @@ describe('MRWConfig createShipment()', () => {
|
||||||
|
|
||||||
spyOn(axios, 'post').and.callFake(() => Promise.resolve(mockPostResponses.pop()));
|
spyOn(axios, 'post').and.callFake(() => Promise.resolve(mockPostResponses.pop()));
|
||||||
|
|
||||||
const base64Binary = await models.MrwConfig.createShipment(expedition1.id, options);
|
const {file} = await models.MrwConfig.createShipment(expedition1.id, options);
|
||||||
|
|
||||||
expect(base64Binary).toEqual(mockBase64Binary);
|
expect(file).toEqual(mockBase64Binary);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail if mrwConfig has no data', async() => {
|
it('should fail if mrwConfig has no data', async() => {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const {Email} = require('vn-print');
|
const {Email} = require('vn-print');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('send', {
|
Self.remoteMethod('send', {
|
||||||
|
@ -70,7 +71,7 @@ module.exports = Self => {
|
||||||
const newParams = Object.assign({}, queueParams, sendParams);
|
const newParams = Object.assign({}, queueParams, sendParams);
|
||||||
const email = new Email(queueName, newParams);
|
const email = new Email(queueName, newParams);
|
||||||
|
|
||||||
if (process.env.NODE_ENV != 'test')
|
if (isProduction())
|
||||||
await email.send();
|
await email.send();
|
||||||
|
|
||||||
await queue.updateAttribute('status', statusSent);
|
await queue.updateAttribute('status', statusSent);
|
||||||
|
|
|
@ -186,5 +186,8 @@
|
||||||
},
|
},
|
||||||
"AgencyWorkCenter": {
|
"AgencyWorkCenter": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"RouteConfig": {
|
||||||
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "RouteConfig",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "routeConfig"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"kmMax": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
features_types=(chore feat style)
|
||||||
|
changes_types=(refactor perf)
|
||||||
|
fix_types=(fix revert)
|
||||||
|
file="CHANGELOG.md"
|
||||||
|
file_tmp="temp_log.txt"
|
||||||
|
file_current_tmp="temp_current_log.txt"
|
||||||
|
|
||||||
|
setType(){
|
||||||
|
echo "### $1" >> $file_tmp
|
||||||
|
arr=("$@")
|
||||||
|
echo "" > $file_current_tmp
|
||||||
|
for i in "${arr[@]}"
|
||||||
|
do
|
||||||
|
git log --grep="$i" --oneline --no-merges --format="- %s %d by:%an" master..test >> $file_current_tmp
|
||||||
|
done
|
||||||
|
# remove duplicates
|
||||||
|
sort -o $file_current_tmp -u $file_current_tmp
|
||||||
|
cat $file_current_tmp >> $file_tmp
|
||||||
|
echo "" >> $file_tmp
|
||||||
|
# remove tmp current file
|
||||||
|
[ -e $file_current_tmp ] && rm $file_current_tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "# Version XX.XX - XXXX-XX-XX" >> $file_tmp
|
||||||
|
echo "" >> $file_tmp
|
||||||
|
|
||||||
|
setType "Added 🆕" "${features_types[@]}"
|
||||||
|
setType "Changed 📦" "${changes_types[@]}"
|
||||||
|
setType "Fixed 🛠️" "${fix_types[@]}"
|
||||||
|
|
||||||
|
cat $file >> $file_tmp
|
||||||
|
mv $file_tmp $file
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
"vn": {
|
"vn": {
|
||||||
"view": {
|
"view": {
|
||||||
"expeditionPallet_Print": "288cbd6e8289df083ed5eb1a2c808f7a82ba4c90c8ad9781104808a7a54471fb"
|
"expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,42 +23,39 @@ BEGIN
|
||||||
DECLARE vXtraLongAgj INT;
|
DECLARE vXtraLongAgj INT;
|
||||||
DECLARE vDefaultKlo INT;
|
DECLARE vDefaultKlo INT;
|
||||||
|
|
||||||
SELECT
|
SELECT usefulAuctionLeftSegmentLength,
|
||||||
ec.usefulAuctionLeftSegmentLength,
|
standardBarcodeLength,
|
||||||
ec.standardBarcodeLength,
|
floridayBarcodeLength,
|
||||||
ec.floridayBarcodeLength,
|
floramondoBarcodeLength,
|
||||||
ec.floramondoBarcodeLength,
|
defaultKlo
|
||||||
ec.defaultKlo
|
INTO vUsefulAuctionLeftSegmentLength,
|
||||||
INTO
|
|
||||||
vUsefulAuctionLeftSegmentLength,
|
|
||||||
vStandardBarcodeLength,
|
vStandardBarcodeLength,
|
||||||
vFloridayBarcodeLength,
|
vFloridayBarcodeLength,
|
||||||
vFloramondoBarcodeLength,
|
vFloramondoBarcodeLength,
|
||||||
vDefaultKlo
|
vDefaultKlo
|
||||||
FROM edi.ektConfig ec;
|
FROM ektConfig;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ekt;
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ekt
|
||||||
CREATE TEMPORARY TABLE tmp.ekt
|
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT id ektFk FROM ekt LIMIT 0;
|
SELECT id ektFk FROM ekt LIMIT 0;
|
||||||
|
|
||||||
CASE
|
CASE
|
||||||
WHEN LENGTH(vBarcode) <= vFloridayBarcodeLength THEN
|
WHEN LENGTH(vBarcode) <= vFloridayBarcodeLength THEN
|
||||||
INSERT INTO tmp.ekt
|
INSERT INTO tmp.ekt
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM edi.ektRecent e
|
FROM ektRecent e
|
||||||
WHERE e.cps = vBarcode
|
WHERE e.cps = vBarcode
|
||||||
OR e.batchNumber = vBarcode;
|
OR e.batchNumber = vBarcode;
|
||||||
|
|
||||||
WHEN LENGTH(vBarcode) = vFloramondoBarcodeLength THEN
|
WHEN LENGTH(vBarcode) = vFloramondoBarcodeLength THEN
|
||||||
INSERT INTO tmp.ekt
|
INSERT INTO tmp.ekt
|
||||||
SELECT e.id
|
SELECT e.id
|
||||||
FROM edi.ektRecent e
|
FROM ektRecent e
|
||||||
WHERE e.pro = MID(vBarcode,2,6)
|
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
|
ELSE
|
||||||
SET vBarcode = LPAD(vBarcode,vStandardBarcodeLength,'0');
|
SET vBarcode = LPAD(vBarcode, vStandardBarcodeLength, '0');
|
||||||
SET vAuction = MID(vBarcode, 1, 3);
|
SET vAuction = MID(vBarcode, 1, 3);
|
||||||
SET vKlo = MID(vBarcode, 4, 2);
|
SET vKlo = MID(vBarcode, 4, 2);
|
||||||
SET vFec = MAKEDATE(YEAR(util.VN_CURDATE()), MID(vBarcode, 6, 3));
|
SET vFec = MAKEDATE(YEAR(util.VN_CURDATE()), MID(vBarcode, 6, 3));
|
||||||
|
@ -69,21 +66,23 @@ BEGIN
|
||||||
-- Clásico de subasta
|
-- Clásico de subasta
|
||||||
-- Trade standard
|
-- Trade standard
|
||||||
-- Trade que construye como la subasta
|
-- Trade que construye como la subasta
|
||||||
-- Trade como el anterior pero sin trade code
|
-- Trade como el anterior pero sin trade code
|
||||||
INSERT INTO tmp.ekt
|
INSERT INTO tmp.ekt
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM ekt
|
FROM ekt
|
||||||
WHERE fec >= vFec - INTERVAL 1 DAY
|
WHERE fec >= vFec - INTERVAL 1 DAY
|
||||||
AND ((
|
AND (
|
||||||
vKlo = vDefaultKlo
|
(vKlo = vDefaultKlo
|
||||||
AND (klo = vKlo OR klo IS NULL OR klo = 0)
|
AND (klo = vKlo OR klo IS NULL OR klo = 0)
|
||||||
AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj))
|
AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj)
|
||||||
OR (klo = vKlo
|
) OR (
|
||||||
|
klo = vKlo
|
||||||
AND auction = vAuction
|
AND auction = vAuction
|
||||||
AND agj = vShortAgj)
|
AND agj = vShortAgj
|
||||||
|
)
|
||||||
)
|
)
|
||||||
ORDER BY agj DESC, fec DESC
|
ORDER BY agj DESC, fec DESC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||||
|
|
||||||
|
@ -91,9 +90,11 @@ BEGIN
|
||||||
IF NOT vIsFound THEN
|
IF NOT vIsFound THEN
|
||||||
INSERT INTO tmp.ekt
|
INSERT INTO tmp.ekt
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM edi.ektRecent e
|
FROM ektRecent e
|
||||||
WHERE e.batchNumber
|
WHERE e.batchNumber = LEFT(
|
||||||
= LEFT(vBarcode,vUsefulAuctionLeftSegmentLength)
|
vBarcode,
|
||||||
|
vUsefulAuctionLeftSegmentLength
|
||||||
|
)
|
||||||
AND e.batchNumber > 0;
|
AND e.batchNumber > 0;
|
||||||
|
|
||||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||||
|
@ -103,7 +104,7 @@ BEGIN
|
||||||
IF NOT vIsFound THEN
|
IF NOT vIsFound THEN
|
||||||
INSERT INTO tmp.ekt
|
INSERT INTO tmp.ekt
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM edi.ektRecent e
|
FROM ektRecent e
|
||||||
WHERE e.putOrderFk = vBarcode;
|
WHERE e.putOrderFk = vBarcode;
|
||||||
|
|
||||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||||
|
@ -113,18 +114,28 @@ BEGIN
|
||||||
IF NOT vIsFound THEN
|
IF NOT vIsFound THEN
|
||||||
INSERT INTO tmp.ekt
|
INSERT INTO tmp.ekt
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM edi.ektRecent e
|
FROM ektRecent e
|
||||||
WHERE e.deliveryNumber
|
WHERE e.deliveryNumber = MID(vBarcode, 4, 13)
|
||||||
= MID(vBarcode, 4, 13)
|
|
||||||
AND e.deliveryNumber > 0;
|
AND e.deliveryNumber > 0;
|
||||||
|
|
||||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||||
END IF;
|
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;
|
END CASE;
|
||||||
|
|
||||||
IF vIsFound THEN
|
IF vIsFound THEN
|
||||||
UPDATE ekt e
|
UPDATE ekt e
|
||||||
JOIN tmp.ekt t ON t.ektFk = e.id
|
JOIN tmp.ekt t ON t.ektFk = e.id
|
||||||
SET e.scanned = TRUE;
|
SET e.scanned = TRUE;
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`client_userDisable`
|
||||||
|
ON SCHEDULE EVERY 1 MONTH
|
||||||
|
STARTS '2023-06-01 00:00:00.000'
|
||||||
|
ON COMPLETION PRESERVE
|
||||||
|
ENABLE
|
||||||
|
DO CALL client_userDisable()$$
|
||||||
|
DELIMITER ;
|
|
@ -1,25 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`clientsDisable`
|
|
||||||
ON SCHEDULE EVERY 1 MONTH
|
|
||||||
STARTS '2023-06-01 00:00:00.000'
|
|
||||||
ON COMPLETION PRESERVE
|
|
||||||
ENABLE
|
|
||||||
DO BEGIN
|
|
||||||
UPDATE account.user u
|
|
||||||
JOIN client c ON c.id = u.id
|
|
||||||
LEFT JOIN account.account a ON a.id = u.id
|
|
||||||
SET u.active = FALSE
|
|
||||||
WHERE c.typeFk = 'normal'
|
|
||||||
AND a.id IS NULL
|
|
||||||
AND u.active
|
|
||||||
AND c.created < util.VN_CURDATE() - INTERVAL 12 MONTH
|
|
||||||
AND u.id NOT IN (
|
|
||||||
SELECT DISTINCT c.id
|
|
||||||
FROM client c
|
|
||||||
LEFT JOIN ticket t ON t.clientFk = c.id
|
|
||||||
WHERE c.salesPersonFk IS NOT NULL
|
|
||||||
OR t.created > util.VN_CURDATE() - INTERVAL 12 MONTH
|
|
||||||
OR shipped > util.VN_CURDATE() - INTERVAL 12 MONTH
|
|
||||||
);
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -1,5 +1,6 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(vAsiento INT,
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(
|
||||||
|
vBookNumber INT,
|
||||||
vDated DATE,
|
vDated DATE,
|
||||||
vSubaccount VARCHAR(12),
|
vSubaccount VARCHAR(12),
|
||||||
vAccount VARCHAR(12),
|
vAccount VARCHAR(12),
|
||||||
|
@ -12,33 +13,33 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(vAsient
|
||||||
vVat DOUBLE,
|
vVat DOUBLE,
|
||||||
vRe DOUBLE,
|
vRe DOUBLE,
|
||||||
vAux TINYINT,
|
vAux TINYINT,
|
||||||
vCompany INT
|
vCompanyFk INT
|
||||||
)
|
)
|
||||||
RETURNS int(11)
|
RETURNS int(11)
|
||||||
NOT DETERMINISTIC
|
NOT DETERMINISTIC
|
||||||
NO SQL
|
NO SQL
|
||||||
BEGIN
|
BEGIN
|
||||||
IF vAsiento IS NULL THEN
|
IF vBookNumber IS NULL THEN
|
||||||
CALL vn.ledger_next(vAsiento);
|
CALL ledger_next(YEAR(vDated), vBookNumber);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
INSERT INTO XDiario
|
INSERT INTO XDiario
|
||||||
SET ASIEN = vAsiento,
|
SET ASIEN = vBookNumber,
|
||||||
FECHA = vDated,
|
FECHA = vDated,
|
||||||
SUBCTA = vSubaccount,
|
SUBCTA = vSubaccount,
|
||||||
CONTRA = vAccount,
|
CONTRA = vAccount,
|
||||||
CONCEPTO = vConcept,
|
CONCEPTO = vConcept,
|
||||||
EURODEBE = vDebit,
|
EURODEBE = vDebit,
|
||||||
EUROHABER = vCredit,
|
EUROHABER = vCredit,
|
||||||
BASEEURO = vEuro,
|
BASEEURO = vEuro,
|
||||||
SERIE = vSerie,
|
SERIE = vSerie,
|
||||||
FACTURA = vInvoice,
|
FACTURA = vInvoice,
|
||||||
IVA = vVat,
|
IVA = vVat,
|
||||||
RECEQUIV = vRe,
|
RECEQUIV = vRe,
|
||||||
AUXILIAR = IF(vAux = FALSE, NULL, '*'),
|
AUXILIAR = IF(vAux = FALSE, NULL, '*'),
|
||||||
MONEDAUSO = 2,
|
MONEDAUSO = 2,
|
||||||
empresa_id = vCompany;
|
empresa_id = vCompanyFk;
|
||||||
|
|
||||||
RETURN vAsiento;
|
RETURN vBookNumber;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -0,0 +1,57 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_clone`(vEntryFk INT)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Clone buys to an entry
|
||||||
|
*
|
||||||
|
* @param vEntryFk The entry id
|
||||||
|
* @table tmp.buy(id)
|
||||||
|
*/
|
||||||
|
INSERT INTO buy(
|
||||||
|
entryFk,
|
||||||
|
itemFk,
|
||||||
|
quantity,
|
||||||
|
buyingValue,
|
||||||
|
freightValue,
|
||||||
|
isIgnored,
|
||||||
|
stickers,
|
||||||
|
packagingFk,
|
||||||
|
packing,
|
||||||
|
`grouping`,
|
||||||
|
groupingMode,
|
||||||
|
comissionValue,
|
||||||
|
packageValue,
|
||||||
|
price1,
|
||||||
|
price2,
|
||||||
|
price3,
|
||||||
|
minPrice,
|
||||||
|
isChecked,
|
||||||
|
location,
|
||||||
|
weight,
|
||||||
|
itemOriginalFk)
|
||||||
|
SELECT vEntryFk,
|
||||||
|
b.itemFk,
|
||||||
|
b.quantity,
|
||||||
|
b.buyingValue,
|
||||||
|
b.freightValue,
|
||||||
|
b.isIgnored,
|
||||||
|
b.stickers,
|
||||||
|
b.packagingFk,
|
||||||
|
b.packing,
|
||||||
|
b.`grouping`,
|
||||||
|
b.groupingMode,
|
||||||
|
b.comissionValue,
|
||||||
|
b.packageValue,
|
||||||
|
b.price1,
|
||||||
|
b.price2,
|
||||||
|
b.price3,
|
||||||
|
b.minPrice,
|
||||||
|
b.isChecked,
|
||||||
|
b.location,
|
||||||
|
b.weight,
|
||||||
|
b.itemOriginalFk
|
||||||
|
FROM tmp.buy tb
|
||||||
|
JOIN vn.buy b ON b.id = tb.id;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -10,7 +10,7 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
|
DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
|
||||||
|
|
||||||
CREATE TEMPORARY TABLE tmp.buyRecalc
|
CREATE TEMPORARY TABLE tmp.buyRecalc
|
||||||
SELECT vBuyFk id;
|
SELECT vBuyFk id;
|
||||||
|
|
||||||
CALL buy_recalcPrices();
|
CALL buy_recalcPrices();
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_userDisable`()
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Desactiva los clientes inactivos en los últimos X meses.
|
||||||
|
*/
|
||||||
|
DECLARE vMonths INT;
|
||||||
|
|
||||||
|
SELECT monthsToDisableUser INTO vMonths
|
||||||
|
FROM clientConfig;
|
||||||
|
|
||||||
|
IF vMonths IS NULL THEN
|
||||||
|
CALL util.throw('Config parameter not set');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
UPDATE account.user u
|
||||||
|
JOIN client c ON c.id = u.id
|
||||||
|
LEFT JOIN account.account a ON a.id = u.id
|
||||||
|
SET u.active = FALSE
|
||||||
|
WHERE c.typeFk = 'normal'
|
||||||
|
AND a.id IS NULL
|
||||||
|
AND u.active
|
||||||
|
AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH
|
||||||
|
AND u.id NOT IN (
|
||||||
|
SELECT DISTINCT c.id
|
||||||
|
FROM client c
|
||||||
|
LEFT JOIN ticket t ON t.clientFk = c.id
|
||||||
|
WHERE c.salesPersonFk IS NOT NULL
|
||||||
|
OR t.created > util.VN_CURDATE() - INTERVAL vMonths MONTH
|
||||||
|
OR shipped > util.VN_CURDATE() - INTERVAL vMonths MONTH
|
||||||
|
);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -2,127 +2,121 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaTaxBooking`(vDuaFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaTaxBooking`(vDuaFk INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vBookNumber INT;
|
DECLARE vBookNumber INT;
|
||||||
DECLARE vBookDated DATE;
|
DECLARE vBookDated DATE;
|
||||||
DECLARE vDiff DECIMAL(10,2);
|
DECLARE vDiff DECIMAL(10,2);
|
||||||
DECLARE vApunte BIGINT;
|
DECLARE vApunte BIGINT;
|
||||||
|
|
||||||
SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE()) INTO vBookNumber, vBookDated
|
SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE())
|
||||||
FROM dua
|
INTO vBookNumber, vBookDated
|
||||||
|
FROM dua
|
||||||
WHERE id = vDuaFk;
|
WHERE id = vDuaFk;
|
||||||
|
|
||||||
IF vBookNumber IS NULL OR NOT vBookNumber THEN
|
IF vBookNumber IS NULL OR NOT vBookNumber THEN
|
||||||
CALL ledger_next(vBookNumber);
|
CALL ledger_next(YEAR(vBookDated), vBookNumber);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Apunte de la aduana
|
-- Apunte de la aduana
|
||||||
|
|
||||||
INSERT INTO XDiario(
|
INSERT INTO XDiario(
|
||||||
ASIEN,
|
ASIEN,
|
||||||
FECHA,
|
FECHA,
|
||||||
SUBCTA,
|
SUBCTA,
|
||||||
CONCEPTO,
|
CONCEPTO,
|
||||||
EUROHABER,
|
EUROHABER,
|
||||||
SERIE,
|
SERIE,
|
||||||
empresa_id,
|
empresa_id,
|
||||||
CLAVE,
|
CLAVE,
|
||||||
FACTURA)
|
FACTURA)
|
||||||
|
SELECT vBookNumber,
|
||||||
|
d.bookEntried,
|
||||||
|
'4700000999',
|
||||||
|
CONCAT('DUA ',d.`code`),
|
||||||
|
sum(dt.base * dt.rate / 100) EUROHABER,
|
||||||
|
'R',
|
||||||
|
d.companyFk,
|
||||||
|
vDuaFk,
|
||||||
|
vDuaFk
|
||||||
|
FROM duaTax dt
|
||||||
|
JOIN dua d ON d.id = dt.duaFk
|
||||||
|
WHERE dt.duaFk = vDuaFk;
|
||||||
|
|
||||||
SELECT
|
-- Apuntes por tipo de IVA y proveedor
|
||||||
vBookNumber,
|
INSERT INTO XDiario(
|
||||||
d.bookEntried,
|
ASIEN,
|
||||||
'4700000999',
|
FECHA,
|
||||||
CONCAT('DUA ',d.`code`),
|
SUBCTA,
|
||||||
sum(dt.base * dt.rate / 100) EUROHABER,
|
CONTRA,
|
||||||
'R',
|
EURODEBE,
|
||||||
d.companyFk,
|
BASEEURO,
|
||||||
vDuaFk,
|
CONCEPTO,
|
||||||
vDuaFk
|
FACTURA,
|
||||||
FROM duaTax dt
|
IVA,
|
||||||
JOIN dua d ON d.id = dt.duaFk
|
AUXILIAR,
|
||||||
WHERE dt.duaFk = vDuaFk;
|
SERIE,
|
||||||
|
FECHA_EX,
|
||||||
-- Apuntes por tipo de IVA y proveedor
|
FECHA_OP,
|
||||||
|
FACTURAEX,
|
||||||
INSERT INTO XDiario(
|
NFACTICK,
|
||||||
ASIEN,
|
L340,
|
||||||
FECHA,
|
LDIFADUAN,
|
||||||
SUBCTA,
|
TIPOCLAVE,
|
||||||
CONTRA,
|
TIPOEXENCI,
|
||||||
EURODEBE,
|
TIPONOSUJE,
|
||||||
BASEEURO,
|
TIPOFACT,
|
||||||
CONCEPTO,
|
TIPORECTIF,
|
||||||
FACTURA,
|
TERIDNIF,
|
||||||
IVA,
|
TERNIF,
|
||||||
AUXILIAR,
|
TERNOM,
|
||||||
SERIE,
|
empresa_id,
|
||||||
FECHA_EX,
|
FECREGCON)
|
||||||
FECHA_OP,
|
SELECT vBookNumber ASIEN,
|
||||||
FACTURAEX,
|
vBookDated FECHA,
|
||||||
NFACTICK,
|
tr.account SUBCTA,
|
||||||
L340,
|
'4330002067' CONTRA,
|
||||||
LDIFADUAN,
|
SUM(dt.tax) EURODEBE,
|
||||||
TIPOCLAVE,
|
SUM(dt.base) BASEEURO,
|
||||||
TIPOEXENCI,
|
CONCAT('DUA nº',d.code) CONCEPTO,
|
||||||
TIPONOSUJE,
|
d.id FACTURA,
|
||||||
TIPOFACT,
|
dt.rate IVA,
|
||||||
TIPORECTIF,
|
'*' AUXILIAR,
|
||||||
TERIDNIF,
|
'D' SERIE,
|
||||||
TERNIF,
|
d.issued FECHA_EX,
|
||||||
TERNOM,
|
d.operated FECHA_OP,
|
||||||
empresa_id,
|
d.code FACTURAEX,
|
||||||
FECREGCON
|
1 NFACTICK,
|
||||||
)
|
1 L340,
|
||||||
|
TRUE LDIFADUAN,
|
||||||
SELECT
|
1 TIPOCLAVE,
|
||||||
vBookNumber ASIEN,
|
1 TIPOEXENCI,
|
||||||
vBookDated FECHA,
|
1 TIPONOSUJE,
|
||||||
tr.account SUBCTA,
|
5 TIPOFACT,
|
||||||
'4330002067' CONTRA,
|
1 TIPORECTIF,
|
||||||
sum(dt.tax) EURODEBE,
|
IF(c.code = 'ES', 1, 4) TERIDNIF,
|
||||||
sum(dt.base) BASEEURO,
|
s.nif TERNIF,
|
||||||
CONCAT('DUA nº',d.code) CONCEPTO,
|
s.name TERNOM,
|
||||||
d.id FACTURA,
|
d.companyFk,
|
||||||
dt.rate IVA,
|
d.booked FECREGCON
|
||||||
'*' AUXILIAR,
|
FROM duaTax dt
|
||||||
'D' SERIE,
|
JOIN dua d ON dt.duaFk = d.id
|
||||||
d.issued FECHA_EX,
|
JOIN (SELECT account, rate
|
||||||
d.operated FECHA_OP,
|
FROM
|
||||||
d.code FACTURAEX,
|
(SELECT rate, account
|
||||||
1 NFACTICK,
|
FROM invoiceInTaxBookingAccount ta
|
||||||
1 L340,
|
WHERE ta.effectived <= vBookDated
|
||||||
TRUE LDIFADUAN,
|
AND taxAreaFk = 'WORLD'
|
||||||
1 TIPOCLAVE,
|
ORDER BY ta.effectived DESC
|
||||||
1 TIPOEXENCI,
|
LIMIT 10000000000000000000
|
||||||
1 TIPONOSUJE,
|
) tba
|
||||||
5 TIPOFACT,
|
GROUP BY rate
|
||||||
1 TIPORECTIF,
|
|
||||||
IF(c.code = 'ES', 1, 4) TERIDNIF,
|
|
||||||
s.nif TERNIF,
|
|
||||||
s.name TERNOM,
|
|
||||||
d.companyFk,
|
|
||||||
d.booked FECREGCON
|
|
||||||
FROM duaTax dt
|
|
||||||
JOIN dua d ON dt.duaFk = d.id
|
|
||||||
JOIN (SELECT account, rate
|
|
||||||
FROM
|
|
||||||
(SELECT rate, account
|
|
||||||
FROM invoiceInTaxBookingAccount ta
|
|
||||||
WHERE ta.effectived <= vBookDated
|
|
||||||
AND taxAreaFk = 'WORLD'
|
|
||||||
ORDER BY ta.effectived DESC
|
|
||||||
LIMIT 10000000000000000000
|
|
||||||
) tba
|
|
||||||
GROUP BY rate
|
|
||||||
) tr ON tr.rate = dt.rate
|
) tr ON tr.rate = dt.rate
|
||||||
JOIN supplier s ON s.id = d.companyFk
|
JOIN supplier s ON s.id = d.companyFk
|
||||||
JOIN country c ON c.id = s.countryFk
|
JOIN country c ON c.id = s.countryFk
|
||||||
WHERE d.id = vDuaFk
|
WHERE d.id = vDuaFk
|
||||||
GROUP BY dt.rate;
|
GROUP BY dt.rate;
|
||||||
|
|
||||||
SELECT SUM(EURODEBE) -SUM(EUROHABER), MAX(id) INTO vDiff, vApunte
|
SELECT SUM(EURODEBE) -SUM(EUROHABER), MAX(id) INTO vDiff, vApunte
|
||||||
FROM XDiario
|
FROM XDiario
|
||||||
WHERE ASIEN = vBookNumber;
|
WHERE ASIEN = vBookNumber;
|
||||||
|
|
||||||
UPDATE XDiario
|
UPDATE XDiario
|
||||||
SET BASEEURO = 100 * (EURODEBE - vDiff) / IVA,
|
SET BASEEURO = 100 * (EURODEBE - vDiff) / IVA,
|
||||||
EURODEBE = EURODEBE - vDiff
|
EURODEBE = EURODEBE - vDiff
|
||||||
|
@ -131,6 +125,5 @@ BEGIN
|
||||||
UPDATE dua
|
UPDATE dua
|
||||||
SET ASIEN = vBookNumber
|
SET ASIEN = vBookNumber
|
||||||
WHERE id = vDuaFk;
|
WHERE id = vDuaFk;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -9,8 +9,8 @@ BEGIN
|
||||||
* Clones an entry header.
|
* Clones an entry header.
|
||||||
*
|
*
|
||||||
* @param vSelf The entry id
|
* @param vSelf The entry id
|
||||||
|
* @param OUT vNewEntryFk The new entry id
|
||||||
* @param vTravelFk Travel for the new entry or %NULL to use the source entry travel
|
* @param vTravelFk Travel for the new entry or %NULL to use the source entry travel
|
||||||
* @param vNewEntryFk The new entry id
|
|
||||||
*/
|
*/
|
||||||
INSERT INTO entry(
|
INSERT INTO entry(
|
||||||
travelFk,
|
travelFk,
|
||||||
|
|
|
@ -1,59 +1,18 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_copyBuys`(vSelf INT, vCopyTo INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_copyBuys`(vSelf INT, vDestinationEntryFk INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Copies an entry buys to another buy.
|
* Copies all buys from an entry to an entry.
|
||||||
*
|
*
|
||||||
* @param vSelf The entry id
|
* @param vSelf The entry id
|
||||||
* @param vCopyTo The destination entry id
|
* @param vDestinationEntryFk The destination entry id
|
||||||
*/
|
*/
|
||||||
INSERT INTO buy(
|
CREATE OR REPLACE TEMPORARY TABLE tmp.buy
|
||||||
entryFk,
|
SELECT id
|
||||||
itemFk,
|
|
||||||
quantity,
|
|
||||||
buyingValue,
|
|
||||||
freightValue,
|
|
||||||
isIgnored,
|
|
||||||
stickers,
|
|
||||||
packing,
|
|
||||||
`grouping`,
|
|
||||||
groupingMode,
|
|
||||||
containerFk,
|
|
||||||
comissionValue,
|
|
||||||
packageValue,
|
|
||||||
packagingFk,
|
|
||||||
price1,
|
|
||||||
price2,
|
|
||||||
price3,
|
|
||||||
minPrice,
|
|
||||||
isChecked,
|
|
||||||
location,
|
|
||||||
weight,
|
|
||||||
itemOriginalFk
|
|
||||||
)
|
|
||||||
SELECT vCopyTo,
|
|
||||||
itemFk,
|
|
||||||
quantity,
|
|
||||||
buyingValue,
|
|
||||||
freightValue,
|
|
||||||
isIgnored,
|
|
||||||
stickers,
|
|
||||||
packing,
|
|
||||||
`grouping`,
|
|
||||||
groupingMode,
|
|
||||||
containerFk,
|
|
||||||
comissionValue,
|
|
||||||
packageValue,
|
|
||||||
packagingFk,
|
|
||||||
price1,
|
|
||||||
price2,
|
|
||||||
price3,
|
|
||||||
minPrice,
|
|
||||||
isChecked,
|
|
||||||
location,
|
|
||||||
weight,
|
|
||||||
itemOriginalFk
|
|
||||||
FROM buy
|
FROM buy
|
||||||
WHERE entryFk = vSelf;
|
WHERE entryFk = vSelf;
|
||||||
|
|
||||||
|
CALL buy_clone(vDestinationEntryFk);
|
||||||
|
DROP TEMPORARY TABLE tmp.buy;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -26,7 +26,6 @@ BEGIN
|
||||||
packing,
|
packing,
|
||||||
`grouping`,
|
`grouping`,
|
||||||
groupingMode,
|
groupingMode,
|
||||||
containerFk,
|
|
||||||
comissionValue,
|
comissionValue,
|
||||||
packageValue,
|
packageValue,
|
||||||
location,
|
location,
|
||||||
|
@ -46,7 +45,6 @@ BEGIN
|
||||||
packing,
|
packing,
|
||||||
`grouping`,
|
`grouping`,
|
||||||
groupingMode,
|
groupingMode,
|
||||||
containerFk,
|
|
||||||
comissionValue,
|
comissionValue,
|
||||||
packageValue,
|
packageValue,
|
||||||
location,
|
location,
|
||||||
|
|
|
@ -56,7 +56,6 @@ BEGIN
|
||||||
packing,
|
packing,
|
||||||
`grouping`,
|
`grouping`,
|
||||||
groupingMode,
|
groupingMode,
|
||||||
containerFk,
|
|
||||||
comissionValue,
|
comissionValue,
|
||||||
packageValue,
|
packageValue,
|
||||||
packagingFk,
|
packagingFk,
|
||||||
|
@ -77,7 +76,6 @@ BEGIN
|
||||||
packing,
|
packing,
|
||||||
`grouping`,
|
`grouping`,
|
||||||
groupingMode,
|
groupingMode,
|
||||||
containerFk,
|
|
||||||
comissionValue,
|
comissionValue,
|
||||||
packageValue,
|
packageValue,
|
||||||
packagingFk,
|
packagingFk,
|
||||||
|
@ -114,7 +112,6 @@ BEGIN
|
||||||
packing,
|
packing,
|
||||||
`grouping`,
|
`grouping`,
|
||||||
groupingMode,
|
groupingMode,
|
||||||
containerFk,
|
|
||||||
comissionValue,
|
comissionValue,
|
||||||
packageValue,
|
packageValue,
|
||||||
location,
|
location,
|
||||||
|
@ -133,7 +130,6 @@ BEGIN
|
||||||
packing,
|
packing,
|
||||||
`grouping`,
|
`grouping`,
|
||||||
groupingMode,
|
groupingMode,
|
||||||
containerFk,
|
|
||||||
comissionValue,
|
comissionValue,
|
||||||
packageValue,
|
packageValue,
|
||||||
location,
|
location,
|
||||||
|
|
|
@ -76,7 +76,6 @@ BEGIN
|
||||||
packing,
|
packing,
|
||||||
`grouping`,
|
`grouping`,
|
||||||
groupingMode,
|
groupingMode,
|
||||||
containerFk,
|
|
||||||
comissionValue,
|
comissionValue,
|
||||||
packageValue,
|
packageValue,
|
||||||
location,
|
location,
|
||||||
|
@ -103,7 +102,6 @@ BEGIN
|
||||||
packing,
|
packing,
|
||||||
`grouping`,
|
`grouping`,
|
||||||
groupingMode,
|
groupingMode,
|
||||||
containerFk,
|
|
||||||
comissionValue,
|
comissionValue,
|
||||||
packageValue,
|
packageValue,
|
||||||
location,
|
location,
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromEntries`(IN vInvoiceInFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromEntries`(
|
||||||
|
IN vInvoiceInFk INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vRate DOUBLE DEFAULT 1;
|
DECLARE vRate DOUBLE DEFAULT 1;
|
||||||
DECLARE vDated DATE;
|
|
||||||
DECLARE vExpenseFk VARCHAR(10);
|
DECLARE vExpenseFk VARCHAR(10);
|
||||||
|
|
||||||
SELECT MAX(rr.dated) INTO vDated
|
WITH rate AS(
|
||||||
FROM referenceRate rr
|
SELECT MAX(rr.dated) dated, ii.currencyFk
|
||||||
JOIN invoiceIn ii ON ii.id = vInvoiceInFk
|
FROM vn.invoiceIn ii
|
||||||
WHERE rr.dated <= ii.issued
|
JOIN vn.referenceRate rr ON rr.currencyFk = ii.currencyFk
|
||||||
AND rr.currencyFk = ii.currencyFk ;
|
WHERE ii.id = vInvoiceInFk
|
||||||
|
AND rr.dated <= ii.issued
|
||||||
IF vDated THEN
|
) SELECT `value` INTO vRate
|
||||||
SELECT `value` INTO vRate
|
FROM vn.referenceRate rr
|
||||||
FROM referenceRate
|
JOIN rate r ON r.dated = rr.dated
|
||||||
WHERE dated = vDated;
|
AND r.currencyFk = rr.currencyFk;
|
||||||
END IF;
|
|
||||||
|
|
||||||
SELECT id INTO vExpenseFk
|
SELECT id INTO vExpenseFk
|
||||||
FROM vn.expense
|
FROM expense
|
||||||
WHERE `name` = 'Adquisición mercancia Extracomunitaria'
|
WHERE `name` = 'Adquisición mercancia Extracomunitaria'
|
||||||
GROUP BY id
|
GROUP BY id
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
@ -26,19 +26,25 @@ BEGIN
|
||||||
DELETE FROM invoiceInTax
|
DELETE FROM invoiceInTax
|
||||||
WHERE invoiceInFk = vInvoiceInFk;
|
WHERE invoiceInFk = vInvoiceInFk;
|
||||||
|
|
||||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, foreignValue, taxTypeSageFk, transactionTypeSageFk)
|
INSERT INTO invoiceInTax(
|
||||||
SELECT ii.id,
|
invoiceInFk,
|
||||||
SUM(b.buyingValue * b.quantity) / IFNULL(vRate,1) taxableBase,
|
taxableBase,
|
||||||
vExpenseFk,
|
expenseFk,
|
||||||
IF(ii.currencyFk = 1,NULL,SUM(b.buyingValue * b.quantity )) divisa,
|
foreignValue,
|
||||||
taxTypeSageFk,
|
taxTypeSageFk,
|
||||||
transactionTypeSageFk
|
transactionTypeSageFk
|
||||||
|
)SELECT ii.id,
|
||||||
|
SUM(b.buyingValue * b.quantity) / vRate taxableBase,
|
||||||
|
vExpenseFk,
|
||||||
|
IF(ii.currencyFk = 1,
|
||||||
|
NULL,
|
||||||
|
SUM(b.buyingValue * b.quantity )),
|
||||||
|
taxTypeSageFk,
|
||||||
|
transactionTypeSageFk
|
||||||
FROM invoiceIn ii
|
FROM invoiceIn ii
|
||||||
JOIN entry e ON e.invoiceInFk = ii.id
|
JOIN entry e ON e.invoiceInFk = ii.id
|
||||||
JOIN supplier s ON s.id = e.supplierFk
|
JOIN supplier s ON s.id = e.supplierFk
|
||||||
JOIN buy b ON b.entryFk = e.id
|
JOIN buy b ON b.entryFk = e.id
|
||||||
LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk
|
|
||||||
AND rr.dated = ii.issued
|
|
||||||
WHERE ii.id = vInvoiceInFk
|
WHERE ii.id = vInvoiceInFk
|
||||||
HAVING taxableBase IS NOT NULL;
|
HAVING taxableBase IS NOT NULL;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -2,6 +2,7 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`(vSelf INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`(vSelf INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vBookNumber INT;
|
DECLARE vBookNumber INT;
|
||||||
|
DECLARE vFiscalYear INT;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn
|
CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
|
@ -56,7 +57,8 @@ BEGIN
|
||||||
LEFT JOIN sage.taxType tt ON tt.id = ti.CodigoIva
|
LEFT JOIN sage.taxType tt ON tt.id = ti.CodigoIva
|
||||||
WHERE ii.id = vSelf;
|
WHERE ii.id = vSelf;
|
||||||
|
|
||||||
CALL vn.ledger_next(vBookNumber);
|
SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1;
|
||||||
|
CALL ledger_next(vFiscalYear, vBookNumber);
|
||||||
|
|
||||||
-- Apunte del proveedor
|
-- Apunte del proveedor
|
||||||
INSERT INTO XDiario(
|
INSERT INTO XDiario(
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOutBooking`(IN vInvoice INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOutBooking`(IN vInvoice INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
/* Asienta la factura emitida
|
/**
|
||||||
*
|
* Asienta una factura emitida
|
||||||
* param vInvoice factura_id
|
*
|
||||||
*/
|
* @param vInvoice Id invoiceOut
|
||||||
|
*/
|
||||||
DECLARE vBookNumber INT;
|
DECLARE vBookNumber INT;
|
||||||
DECLARE vExpenseConcept VARCHAR(50);
|
DECLARE vExpenseConcept VARCHAR(50);
|
||||||
DECLARE vSpainCountryFk INT;
|
DECLARE vSpainCountryFk INT;
|
||||||
DECLARE vOldBookNumber INT;
|
DECLARE vOldBookNumber INT;
|
||||||
|
DECLARE vFiscalYear INT;
|
||||||
|
|
||||||
SELECT id INTO vSpainCountryFk FROM country WHERE code = 'ES';
|
SELECT id INTO vSpainCountryFk FROM country WHERE `code` = 'ES';
|
||||||
|
|
||||||
SELECT ASIEN
|
SELECT ASIEN
|
||||||
INTO vOldBookNumber
|
INTO vOldBookNumber
|
||||||
FROM XDiario x
|
FROM XDiario x
|
||||||
JOIN invoiceOut io ON io.id = vInvoice
|
JOIN invoiceOut io ON io.id = vInvoice
|
||||||
WHERE x.SERIE = io.serial
|
WHERE x.SERIE = io.serial
|
||||||
AND x.FACTURA = RIGHT(io.ref, LENGTH(io.ref) - 1)
|
AND x.FACTURA = RIGHT(io.ref, LENGTH(io.ref) - 1)
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
|
@ -26,140 +28,133 @@ BEGIN
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS rs;
|
DROP TEMPORARY TABLE IF EXISTS rs;
|
||||||
CREATE TEMPORARY TABLE rs
|
CREATE TEMPORARY TABLE rs
|
||||||
SELECT
|
SELECT c.accountingAccount clientBookingAccount,
|
||||||
c.accountingAccount AS clientBookingAccount,
|
io.amount totalAmount,
|
||||||
io.amount as totalAmount,
|
CONCAT('n/fra ', io.ref) simpleConcept,
|
||||||
CONCAT('n/fra ', io.ref) as simpleConcept,
|
CONCAT('n/fra ', io.ref, ' ', c.name) Concept,
|
||||||
CONCAT('n/fra ', io.ref, ' ', c.name) as Concept,
|
io.serial SERIE,
|
||||||
io.serial AS SERIE,
|
io.issued FECHA_EX,
|
||||||
io.issued AS FECHA_EX,
|
io.issued FECHA_OP,
|
||||||
io.issued AS FECHA_OP,
|
io.issued FECHA,
|
||||||
io.issued AS FECHA,
|
1 NFACTICK,
|
||||||
1 AS NFACTICK,
|
IF(ic.correctingFk,'D','') TIPOOPE,
|
||||||
IF(ic.correctingFk,'D','') AS TIPOOPE,
|
io.siiTrascendencyInvoiceOutFk TIPOCLAVE,
|
||||||
io.siiTrascendencyInvoiceOutFk AS TIPOCLAVE,
|
io.cplusTaxBreakFk TIPOEXENCI,
|
||||||
io.cplusTaxBreakFk AS TIPOEXENCI,
|
io.cplusSubjectOpFk TIPONOSUJE,
|
||||||
io.cplusSubjectOpFk AS TIPONOSUJE,
|
io.siiTypeInvoiceOutFk TIPOFACT,
|
||||||
io.siiTypeInvoiceOutFk AS TIPOFACT,
|
ic.cplusRectificationTypeFk TIPORECTIF,
|
||||||
ic.cplusRectificationTypeFk AS TIPORECTIF,
|
|
||||||
io.companyFk,
|
io.companyFk,
|
||||||
RIGHT(io.ref, LENGTH(io.ref) - 1) AS invoiceNum,
|
RIGHT(io.ref, LENGTH(io.ref) - 1) invoiceNum,
|
||||||
IF(c.countryFk = vSpainCountryFk, vSpainCountryFk, IF(ct.isUeeMember,2,4)) AS TERIDNIF,
|
IF(c.countryFk = vSpainCountryFk, vSpainCountryFk, IF(ct.isUeeMember,2,4)) TERIDNIF,
|
||||||
CONCAT(IF(ct.isUeeMember AND c.countryFk <> vSpainCountryFk,ct.code,''),c.fi) AS TERNIF,
|
CONCAT(IF(ct.isUeeMember AND c.countryFk <> vSpainCountryFk,ct.code,''),c.fi) TERNIF,
|
||||||
c.socialName AS TERNOM,
|
c.socialName TERNOM,
|
||||||
ior.serial AS SERIE_RT,
|
ior.serial SERIE_RT,
|
||||||
RIGHT(ior.ref, LENGTH(ior.ref) - 1) AS FACTU_RT,
|
RIGHT(ior.ref, LENGTH(ior.ref) - 1) FACTU_RT,
|
||||||
ior.issued AS FECHA_RT,
|
ior.issued FECHA_RT,
|
||||||
IF(ior.id,TRUE,FALSE) AS RECTIFICA
|
IF(ior.id,TRUE,FALSE) RECTIFICA
|
||||||
FROM invoiceOut io
|
FROM invoiceOut io
|
||||||
JOIN invoiceOutSerial ios ON ios.code = io.serial
|
JOIN invoiceOutSerial ios ON ios.code = io.serial
|
||||||
JOIN client c ON c.id = io.clientFk
|
JOIN client c ON c.id = io.clientFk
|
||||||
JOIN country ct ON ct.id = c.countryFk
|
JOIN country ct ON ct.id = c.countryFk
|
||||||
LEFT JOIN invoiceCorrection ic ON ic.correctingFk = io.id
|
LEFT JOIN invoiceCorrection ic ON ic.correctingFk = io.id
|
||||||
LEFT JOIN invoiceOut ior ON ior.id = ic.correctedFk
|
LEFT JOIN invoiceOut ior ON ior.id = ic.correctedFk
|
||||||
WHERE io.id = vInvoice;
|
WHERE io.id = vInvoice;
|
||||||
|
|
||||||
CALL vn.ledger_next(vBookNumber);
|
SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1;
|
||||||
|
CALL ledger_next(vFiscalYear, vBookNumber);
|
||||||
-- Linea del cliente
|
-- Linea del cliente
|
||||||
INSERT INTO XDiario(
|
INSERT INTO XDiario(
|
||||||
ASIEN,
|
ASIEN,
|
||||||
FECHA,
|
FECHA,
|
||||||
SUBCTA,
|
SUBCTA,
|
||||||
EURODEBE,
|
EURODEBE,
|
||||||
CONCEPTO,
|
CONCEPTO,
|
||||||
FECHA_EX,
|
FECHA_EX,
|
||||||
FECHA_OP,
|
FECHA_OP,
|
||||||
empresa_id
|
empresa_id)
|
||||||
)
|
SELECT vBookNumber,
|
||||||
SELECT
|
|
||||||
vBookNumber AS ASIEN,
|
|
||||||
rs.FECHA,
|
rs.FECHA,
|
||||||
rs.clientBookingAccount AS SUBCTA,
|
rs.clientBookingAccount,
|
||||||
rs.totalAmount AS EURODEBE,
|
rs.totalAmount,
|
||||||
rs.simpleConcept AS CONCEPTO,
|
rs.simpleConcept,
|
||||||
rs.FECHA_EX,
|
rs.FECHA_EX,
|
||||||
rs.FECHA_OP,
|
rs.FECHA_OP,
|
||||||
rs.companyFk AS empresa_id
|
rs.companyFk
|
||||||
FROM rs;
|
FROM rs;
|
||||||
|
|
||||||
-- Lineas de gasto
|
-- Lineas de gasto
|
||||||
INSERT INTO XDiario(
|
INSERT INTO XDiario(
|
||||||
ASIEN,
|
ASIEN,
|
||||||
FECHA,
|
FECHA,
|
||||||
SUBCTA,
|
SUBCTA,
|
||||||
CONTRA,
|
CONTRA,
|
||||||
EUROHABER,
|
EUROHABER,
|
||||||
CONCEPTO,
|
CONCEPTO,
|
||||||
FECHA_EX,
|
FECHA_EX,
|
||||||
FECHA_OP,
|
FECHA_OP,
|
||||||
empresa_id
|
empresa_id)
|
||||||
)
|
SELECT vBookNumber,
|
||||||
SELECT
|
rs.FECHA,
|
||||||
vBookNumber AS ASIEN,
|
ioe.expenseFk,
|
||||||
rs.FECHA,
|
rs.clientBookingAccount,
|
||||||
ioe.expenseFk AS SUBCTA,
|
ioe.amount,
|
||||||
rs.clientBookingAccount AS CONTRA,
|
rs.Concept,
|
||||||
ioe.amount AS EUROHABER,
|
rs.FECHA_EX,
|
||||||
rs.Concept AS CONCEPTO,
|
rs.FECHA_OP,
|
||||||
rs.FECHA_EX,
|
rs.companyFk
|
||||||
rs.FECHA_OP,
|
FROM rs
|
||||||
rs.companyFk AS empresa_id
|
JOIN invoiceOutExpense ioe
|
||||||
FROM rs
|
WHERE ioe.invoiceOutFk = vInvoice;
|
||||||
JOIN invoiceOutExpense ioe
|
|
||||||
WHERE ioe.invoiceOutFk = vInvoice;
|
|
||||||
|
|
||||||
SELECT GROUP_CONCAT(`name` SEPARATOR ',')
|
SELECT GROUP_CONCAT(`name` SEPARATOR ',')
|
||||||
INTO vExpenseConcept
|
INTO vExpenseConcept
|
||||||
FROM expense e
|
FROM expense e
|
||||||
JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id
|
JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id
|
||||||
WHERE ioe.invoiceOutFk = vInvoice;
|
WHERE ioe.invoiceOutFk = vInvoice;
|
||||||
|
|
||||||
-- Lineas de IVA
|
-- Lineas de IVA
|
||||||
INSERT INTO XDiario(
|
INSERT INTO XDiario(
|
||||||
ASIEN,
|
ASIEN,
|
||||||
FECHA,
|
FECHA,
|
||||||
SUBCTA,
|
SUBCTA,
|
||||||
CONTRA,
|
CONTRA,
|
||||||
EUROHABER,
|
EUROHABER,
|
||||||
BASEEURO,
|
BASEEURO,
|
||||||
CONCEPTO,
|
CONCEPTO,
|
||||||
FACTURA,
|
FACTURA,
|
||||||
IVA,
|
IVA,
|
||||||
RECEQUIV,
|
RECEQUIV,
|
||||||
AUXILIAR,
|
AUXILIAR,
|
||||||
SERIE,
|
SERIE,
|
||||||
SERIE_RT,
|
SERIE_RT,
|
||||||
FACTU_RT,
|
FACTU_RT,
|
||||||
RECTIFICA,
|
RECTIFICA,
|
||||||
FECHA_RT,
|
FECHA_RT,
|
||||||
FECHA_OP,
|
FECHA_OP,
|
||||||
FECHA_EX,
|
FECHA_EX,
|
||||||
TIPOOPE,
|
TIPOOPE,
|
||||||
NFACTICK,
|
NFACTICK,
|
||||||
TERIDNIF,
|
TERIDNIF,
|
||||||
TERNIF,
|
TERNIF,
|
||||||
TERNOM,
|
TERNOM,
|
||||||
L340,
|
L340,
|
||||||
TIPOCLAVE,
|
TIPOCLAVE,
|
||||||
TIPOEXENCI,
|
TIPOEXENCI,
|
||||||
TIPONOSUJE,
|
TIPONOSUJE,
|
||||||
TIPOFACT,
|
TIPOFACT,
|
||||||
TIPORECTIF,
|
TIPORECTIF,
|
||||||
empresa_id
|
empresa_id)
|
||||||
)
|
SELECT vBookNumber ASIEN,
|
||||||
SELECT
|
|
||||||
vBookNumber AS ASIEN,
|
|
||||||
rs.FECHA,
|
rs.FECHA,
|
||||||
iot.pgcFk AS SUBCTA,
|
iot.pgcFk SUBCTA,
|
||||||
rs.clientBookingAccount AS CONTRA,
|
rs.clientBookingAccount CONTRA,
|
||||||
iot.vat AS EUROHABER,
|
iot.vat EUROHABER,
|
||||||
iot.taxableBase AS BASEEURO,
|
iot.taxableBase BASEEURO,
|
||||||
CONCAT(vExpenseConcept,' : ',rs.Concept) AS CONCEPTO,
|
CONCAT(vExpenseConcept,' : ',rs.Concept) CONCEPTO,
|
||||||
rs.invoiceNum AS FACTURA,
|
rs.invoiceNum FACTURA,
|
||||||
IF(pe2.equFk,0,pgc.rate) AS IVA,
|
IF(pe2.equFk,0,pgc.rate) IVA,
|
||||||
IF(pe2.equFk,0,pgce.rate) AS RECEQUIV,
|
IF(pe2.equFk,0,pgce.rate) RECEQUIV,
|
||||||
IF(pgc.mod347,'','*') AS AUXILIAR,
|
IF(pgc.mod347,'','*') AUXILIAR,
|
||||||
rs.SERIE,
|
rs.SERIE,
|
||||||
rs.SERIE_RT,
|
rs.SERIE_RT,
|
||||||
rs.FACTU_RT,
|
rs.FACTU_RT,
|
||||||
|
@ -168,27 +163,27 @@ BEGIN
|
||||||
rs.FECHA_OP,
|
rs.FECHA_OP,
|
||||||
rs.FECHA_EX,
|
rs.FECHA_EX,
|
||||||
rs.TIPOOPE,
|
rs.TIPOOPE,
|
||||||
rs.NFACTICK,
|
rs.NFACTICK,
|
||||||
rs.TERIDNIF,
|
rs.TERIDNIF,
|
||||||
rs.TERNIF,
|
rs.TERNIF,
|
||||||
rs.TERNOM,
|
rs.TERNOM,
|
||||||
pgc.mod340 AS L340,
|
pgc.mod340 L340,
|
||||||
pgc.siiTrascendencyInvoiceOutFk AS TIPOCLAVE,
|
pgc.siiTrascendencyInvoiceOutFk TIPOCLAVE,
|
||||||
pgc.cplusTaxBreakFk as TIPOEXENCI,
|
pgc.cplusTaxBreakFk TIPOEXENCI,
|
||||||
rs.TIPONOSUJE,
|
rs.TIPONOSUJE,
|
||||||
rs.TIPOFACT,
|
rs.TIPOFACT,
|
||||||
rs.TIPORECTIF,
|
rs.TIPORECTIF,
|
||||||
rs.companyFk AS empresa_id
|
rs.companyFk
|
||||||
FROM rs
|
FROM rs
|
||||||
JOIN invoiceOutTax iot
|
JOIN invoiceOutTax iot
|
||||||
JOIN pgc ON pgc.code = iot.pgcFk
|
JOIN pgc ON pgc.code = iot.pgcFk
|
||||||
LEFT JOIN pgcEqu pe ON pe.vatFk = iot.pgcFk -- --------------- Comprueba si la linea es de iva con rec.equiv. asociado
|
LEFT JOIN pgcEqu pe ON pe.vatFk = iot.pgcFk -- --------------- Comprueba si la linea es de iva con rec.equiv. asociado
|
||||||
LEFT JOIN pgc pgce ON pgce.code = pe.equFk
|
LEFT JOIN pgc pgce ON pgce.code = pe.equFk
|
||||||
LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv.
|
LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv.
|
||||||
WHERE iot.invoiceOutFk = vInvoice;
|
WHERE iot.invoiceOutFk = vInvoice;
|
||||||
|
|
||||||
UPDATE invoiceOut
|
UPDATE invoiceOut
|
||||||
SET booked = util.VN_CURDATE()
|
SET booked = util.VN_CURDATE()
|
||||||
WHERE id = vInvoice;
|
WHERE id = vInvoice;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -18,11 +18,12 @@ BEGIN
|
||||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||||
JOIN vn.sector sc ON sc.id = p.sectorFk
|
JOIN vn.sector sc ON sc.id = p.sectorFk
|
||||||
JOIN vn.warehouse w ON w.id = sc.warehouseFk
|
JOIN vn.warehouse w ON w.id = sc.warehouseFk
|
||||||
WHERE sc.id = vSectorFk
|
WHERE ish.visible > 0
|
||||||
AND ish.visible > 0
|
|
||||||
AND ish.itemFk = vItemFk
|
AND ish.itemFk = vItemFk
|
||||||
GROUP BY ish.id
|
GROUP BY ish.id
|
||||||
ORDER BY sh.priority DESC,
|
ORDER BY
|
||||||
|
(sc.id = vSectorFk) DESC,
|
||||||
|
sh.priority DESC,
|
||||||
ish.created,
|
ish.created,
|
||||||
p.pickingOrder;
|
p.pickingOrder;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`(
|
||||||
|
vBarcodeItem INT,
|
||||||
|
vShelvingFK VARCHAR(10)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Obtiene el precio y visible de un item
|
||||||
|
*
|
||||||
|
* @param vBarcodeItem barcode de artículo
|
||||||
|
* @param vShelvingFK Ubicación actual del artículo
|
||||||
|
*/
|
||||||
|
DECLARE vIsItem BOOL;
|
||||||
|
DECLARE vBuyFk INT;
|
||||||
|
DECLARE vWarehouseFk INT;
|
||||||
|
|
||||||
|
SELECT COUNT(*) > 0 INTO vIsItem
|
||||||
|
FROM item
|
||||||
|
WHERE id = vBarcodeItem;
|
||||||
|
|
||||||
|
IF vIsItem THEN
|
||||||
|
SELECT warehouseFk INTO vWarehouseFk
|
||||||
|
FROM operator
|
||||||
|
WHERE workerFk = account.myUser_getId();
|
||||||
|
|
||||||
|
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
|
||||||
|
|
||||||
|
SELECT buyFk INTO vBuyFk
|
||||||
|
FROM tmp.buyUltimate
|
||||||
|
WHERE itemFk = vBarcodeItem
|
||||||
|
AND warehouseFk = vWarehouseFk;
|
||||||
|
|
||||||
|
DELETE FROM tmp.buyUltimate;
|
||||||
|
ELSE
|
||||||
|
SELECT vBarcodeItem INTO vBuyFk;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
WITH visible AS(
|
||||||
|
SELECT itemFk,
|
||||||
|
IFNULL(buyingValue, 0) +
|
||||||
|
IFNULL(freightValue, 0) +
|
||||||
|
IFNULL(comissionValue, 0) +
|
||||||
|
IFNULL(packageValue, 0) itemCost
|
||||||
|
FROM vn.buy b
|
||||||
|
WHERE b.id = vBuyFk
|
||||||
|
) SELECT v.itemFk,
|
||||||
|
vShelvingFK,
|
||||||
|
v.itemCost,
|
||||||
|
SUM(ish.visible) visible
|
||||||
|
FROM vn.itemShelving ish
|
||||||
|
JOIN visible v
|
||||||
|
WHERE ish.shelvingFK = vShelvingFK COLLATE utf8mb3_general_ci
|
||||||
|
AND ish.itemFk = v.itemFk;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,408 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_devalueA2`(
|
||||||
|
vSelf INT,
|
||||||
|
vShelvingFK VARCHAR(10),
|
||||||
|
vBuyingValue DECIMAL(10,4),
|
||||||
|
vQuantity INT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Devalua un item modificando su calidad de A1 a A2.
|
||||||
|
* Si no existe el item A2 lo crea y genera los movimientos de las entradas
|
||||||
|
* de almacén y shelvings correspondientes
|
||||||
|
*
|
||||||
|
* @param vSelf Id de artículo a devaluar
|
||||||
|
* @param vShelvingFK Ubicación actual del artículo
|
||||||
|
* @param vBuyingValue Nuevo precio de coste
|
||||||
|
* @param vQuantity Cantidad del ítem a pasar a A2
|
||||||
|
*/
|
||||||
|
DECLARE vItemA2Fk INT;
|
||||||
|
DECLARE vLastBuyFk BIGINT;
|
||||||
|
DECLARE vA1BuyFk INT;
|
||||||
|
DECLARE vA2BuyFk INT;
|
||||||
|
DECLARE vTargetEntryFk INT;
|
||||||
|
DECLARE vTargetEntryDate DATE;
|
||||||
|
DECLARE vTargetItemShelvingFk BIGINT;
|
||||||
|
DECLARE vWarehouseFk INT;
|
||||||
|
DECLARE vCacheFk INT;
|
||||||
|
DECLARE vLastEntryFk INT;
|
||||||
|
DECLARE vCurrentVisible INT;
|
||||||
|
DECLARE vDevalueTravelFk INT;
|
||||||
|
DECLARE vCurdate DATE;
|
||||||
|
DECLARE vBuyingValueOriginal DECIMAL(10,4);
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
|
||||||
|
BEGIN
|
||||||
|
ROLLBACK;
|
||||||
|
RESIGNAL;
|
||||||
|
END;
|
||||||
|
|
||||||
|
IF (SELECT TRUE FROM item WHERE id = vSelf AND (category <> 'A1' OR category IS NULL)) THEN
|
||||||
|
CALL util.throw('Item has not category A1');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT warehouseFk INTO vWarehouseFk
|
||||||
|
FROM userConfig
|
||||||
|
WHERE userFk = account.myUser_getId();
|
||||||
|
|
||||||
|
IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN
|
||||||
|
CALL util.throw ('Operator has not a valid warehouse');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF vQuantity <= 0 OR vQuantity IS NULL THEN
|
||||||
|
CALL util.throw ('The quantity is incorrect');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT util.VN_CURDATE() INTO vCurdate;
|
||||||
|
|
||||||
|
SELECT t.id INTO vDevalueTravelFk
|
||||||
|
FROM travel t
|
||||||
|
JOIN travelConfig tc
|
||||||
|
WHERE t.shipped = vCurdate
|
||||||
|
AND t.landed = vCurdate
|
||||||
|
AND t.warehouseInFk = vWarehouseFk
|
||||||
|
AND t.warehouseOutFk = tc.devalueWarehouseOutFk
|
||||||
|
AND t.agencyModeFk = tc.devalueAgencyModeFk
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
IF NOT vDevalueTravelFk OR vDevalueTravelFk IS NULL THEN
|
||||||
|
INSERT INTO travel (
|
||||||
|
shipped,
|
||||||
|
landed,
|
||||||
|
warehouseInFk,
|
||||||
|
warehouseOutFk,
|
||||||
|
`ref`,
|
||||||
|
isReceived,
|
||||||
|
agencyModeFk)
|
||||||
|
SELECT vCurdate,
|
||||||
|
vCurdate,
|
||||||
|
vWarehouseFk,
|
||||||
|
tc.devalueWarehouseOutFk,
|
||||||
|
tc.devalueRef,
|
||||||
|
TRUE,
|
||||||
|
tc.devalueAgencyModeFk
|
||||||
|
FROM travelConfig tc;
|
||||||
|
SET vDevalueTravelFk = LAST_INSERT_ID();
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT id, DATE(dated) INTO vTargetEntryFk, vTargetEntryDate
|
||||||
|
FROM `entry` e
|
||||||
|
WHERE DATE(dated) = vCurdate
|
||||||
|
AND typeFk = 'devaluation'
|
||||||
|
AND travelFk = vDevalueTravelFk
|
||||||
|
ORDER BY created DESC
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
CALL buyUltimate(vWarehouseFk, vCurdate);
|
||||||
|
|
||||||
|
SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal
|
||||||
|
FROM tmp.buyUltimate bu
|
||||||
|
JOIN vn.buy b ON b.id = bu.buyFk
|
||||||
|
WHERE bu.itemFk = vSelf
|
||||||
|
AND bu.warehouseFk = vWarehouseFk;
|
||||||
|
|
||||||
|
IF vBuyingValue > vBuyingValueOriginal THEN
|
||||||
|
CALL util.throw ('Price not valid');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF vLastEntryFk IS NULL OR vLastBuyFk IS NULL THEN
|
||||||
|
CALL util.throw ('The item has not a buy');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT id,visible INTO vTargetItemShelvingFk, vCurrentVisible
|
||||||
|
FROM itemShelving
|
||||||
|
WHERE shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
|
||||||
|
AND itemFk = vSelf
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
IF vCurrentVisible IS NULL THEN
|
||||||
|
CALL util.throw ('The shelving has not a visible for this item');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF vQuantity > vCurrentVisible THEN
|
||||||
|
CALL util.throw('Quantity is greater than visible');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
IF NOT vTargetEntryFk OR vTargetEntryFk IS NULL
|
||||||
|
OR NOT vTargetEntryDate <=> vCurdate THEN
|
||||||
|
INSERT INTO entry(
|
||||||
|
travelFk,
|
||||||
|
supplierFk,
|
||||||
|
dated,
|
||||||
|
commission,
|
||||||
|
currencyFk,
|
||||||
|
companyFk,
|
||||||
|
clonedFrom,
|
||||||
|
typeFk
|
||||||
|
)
|
||||||
|
SELECT vDevalueTravelFk,
|
||||||
|
supplierFk,
|
||||||
|
vCurdate,
|
||||||
|
commission,
|
||||||
|
currencyFk,
|
||||||
|
companyFk,
|
||||||
|
vLastEntryFk,
|
||||||
|
'devaluation'
|
||||||
|
FROM entry
|
||||||
|
WHERE id = vLastEntryFk;
|
||||||
|
|
||||||
|
SET vTargetEntryFk = LAST_INSERT_ID();
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT i.id INTO vItemA2Fk
|
||||||
|
FROM item i
|
||||||
|
JOIN (
|
||||||
|
SELECT i.id,
|
||||||
|
i.name,
|
||||||
|
i.subname,
|
||||||
|
i.value5,
|
||||||
|
i.value6,
|
||||||
|
i.value7,
|
||||||
|
i.value8,
|
||||||
|
i.value9,
|
||||||
|
i.value10,
|
||||||
|
i.NumberOfItemsPerCask,
|
||||||
|
i.EmbalageCode,
|
||||||
|
i.quality
|
||||||
|
FROM item i
|
||||||
|
WHERE i.id = vSelf
|
||||||
|
)i2 ON i2.name <=> i.name
|
||||||
|
AND i2.subname <=> i.subname
|
||||||
|
AND i2.value5 <=> i.value5
|
||||||
|
AND i2.value6 <=> i.value6
|
||||||
|
AND i2.value8 <=> i.value8
|
||||||
|
AND i2.value9 <=> i.value9
|
||||||
|
AND i2.value10 <=> i.value10
|
||||||
|
AND i2.NumberOfItemsPerCask <=> i.NumberOfItemsPerCask
|
||||||
|
AND i2.EmbalageCode <=> i.EmbalageCode
|
||||||
|
AND i2.quality <=> i.quality
|
||||||
|
WHERE i.id <> i2.id
|
||||||
|
AND i.category = 'A2'
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
IF vItemA2Fk IS NULL THEN
|
||||||
|
INSERT INTO item (
|
||||||
|
equivalent,
|
||||||
|
name,
|
||||||
|
`size`,
|
||||||
|
stems,
|
||||||
|
minPrice,
|
||||||
|
isToPrint,
|
||||||
|
family,
|
||||||
|
box,
|
||||||
|
category,
|
||||||
|
originFk,
|
||||||
|
doPhoto,
|
||||||
|
image,
|
||||||
|
inkFk,
|
||||||
|
intrastatFk,
|
||||||
|
hasMinPrice,
|
||||||
|
created,
|
||||||
|
comment,
|
||||||
|
typeFk,
|
||||||
|
generic,
|
||||||
|
producerFk,
|
||||||
|
description,
|
||||||
|
density,
|
||||||
|
relevancy,
|
||||||
|
expenseFk,
|
||||||
|
isActive,
|
||||||
|
longName,
|
||||||
|
subName,
|
||||||
|
minimum,
|
||||||
|
upToDown,
|
||||||
|
supplyResponseFk,
|
||||||
|
hasKgPrice,
|
||||||
|
isFloramondo,
|
||||||
|
isFragile,
|
||||||
|
numberOfItemsPerCask,
|
||||||
|
embalageCode,
|
||||||
|
quality,
|
||||||
|
stemMultiplier,
|
||||||
|
itemPackingTypeFk,
|
||||||
|
packingOut,
|
||||||
|
genericFk,
|
||||||
|
isLaid,
|
||||||
|
lastUsed,
|
||||||
|
weightByPiece,
|
||||||
|
editorFk,
|
||||||
|
recycledPlastic,
|
||||||
|
nonRecycledPlastic)
|
||||||
|
SELECT equivalent,
|
||||||
|
name,
|
||||||
|
`size`,
|
||||||
|
stems,
|
||||||
|
minPrice,
|
||||||
|
isToPrint,
|
||||||
|
family,
|
||||||
|
box,
|
||||||
|
'A2',
|
||||||
|
originFk,
|
||||||
|
doPhoto,
|
||||||
|
image,
|
||||||
|
inkFk,
|
||||||
|
intrastatFk,
|
||||||
|
hasMinPrice,
|
||||||
|
created,
|
||||||
|
comment,
|
||||||
|
typeFk,
|
||||||
|
generic,
|
||||||
|
producerFk,
|
||||||
|
description,
|
||||||
|
density,
|
||||||
|
relevancy,
|
||||||
|
expenseFk,
|
||||||
|
isActive,
|
||||||
|
longName,
|
||||||
|
subName,
|
||||||
|
minimum,
|
||||||
|
upToDown,
|
||||||
|
supplyResponseFk,
|
||||||
|
hasKgPrice,
|
||||||
|
isFloramondo,
|
||||||
|
isFragile,
|
||||||
|
numberOfItemsPerCask,
|
||||||
|
embalageCode,
|
||||||
|
quality,
|
||||||
|
stemMultiplier,
|
||||||
|
itemPackingTypeFk,
|
||||||
|
packingOut,
|
||||||
|
genericFk,
|
||||||
|
isLaid,
|
||||||
|
lastUsed,
|
||||||
|
weightByPiece,
|
||||||
|
editorFk,
|
||||||
|
recycledPlastic,
|
||||||
|
nonRecycledPlastic
|
||||||
|
FROM item
|
||||||
|
WHERE id = vSelf;
|
||||||
|
|
||||||
|
SET vItemA2Fk = LAST_INSERT_ID();
|
||||||
|
|
||||||
|
INSERT INTO itemTag (itemFk, tagFk, `value`, intValue, priority, editorFk)
|
||||||
|
SELECT vItemA2Fk, tagFk, `value`, intValue, priority, editorFk
|
||||||
|
FROM itemTag
|
||||||
|
WHERE id = vSelf;
|
||||||
|
|
||||||
|
UPDATE itemTaxCountry itc
|
||||||
|
JOIN itemTaxCountry itc2 ON itc2.itemFk = vSelf
|
||||||
|
AND itc2.countryFk = itc.countryFk
|
||||||
|
SET itc2.taxClassFk = itc.taxClassFk
|
||||||
|
WHERE itc.id = vItemA2Fk;
|
||||||
|
|
||||||
|
INSERT INTO itemBotanical (itemFk, genusFk, specieFk)
|
||||||
|
SELECT vItemA2Fk, genusFk, specieFk
|
||||||
|
FROM itemBotanical
|
||||||
|
WHERE itemFk = vSelf;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF vQuantity = vCurrentVisible THEN
|
||||||
|
DELETE FROM itemShelving
|
||||||
|
WHERE id = vTargetItemShelvingFk;
|
||||||
|
ELSE
|
||||||
|
UPDATE itemShelving
|
||||||
|
SET visible = vCurrentVisible - vQuantity
|
||||||
|
WHERE id = vTargetItemShelvingFk;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
INSERT INTO buy(
|
||||||
|
entryFk,
|
||||||
|
itemFk,
|
||||||
|
quantity,
|
||||||
|
buyingValue,
|
||||||
|
freightValue,
|
||||||
|
isIgnored,
|
||||||
|
stickers,
|
||||||
|
packagingFk,
|
||||||
|
packing,
|
||||||
|
`grouping`,
|
||||||
|
groupingMode,
|
||||||
|
comissionValue,
|
||||||
|
packageValue,
|
||||||
|
price1,
|
||||||
|
price2,
|
||||||
|
price3,
|
||||||
|
minPrice,
|
||||||
|
isChecked,
|
||||||
|
location,
|
||||||
|
weight,
|
||||||
|
itemOriginalFk)
|
||||||
|
SELECT vTargetEntryFk,
|
||||||
|
itemFk,
|
||||||
|
- LEAST(vQuantity, vCurrentVisible),
|
||||||
|
buyingValue,
|
||||||
|
freightValue,
|
||||||
|
TRUE,
|
||||||
|
stickers,
|
||||||
|
packagingFk,
|
||||||
|
packing,
|
||||||
|
`grouping`,
|
||||||
|
groupingMode,
|
||||||
|
comissionValue,
|
||||||
|
packageValue,
|
||||||
|
price1,
|
||||||
|
price2,
|
||||||
|
price3,
|
||||||
|
minPrice,
|
||||||
|
isChecked,
|
||||||
|
location,
|
||||||
|
weight,
|
||||||
|
itemOriginalFk
|
||||||
|
FROM vn.buy
|
||||||
|
WHERE id = vLastBuyFk
|
||||||
|
UNION
|
||||||
|
SELECT vTargetEntryFk,
|
||||||
|
vItemA2Fk,
|
||||||
|
vQuantity,
|
||||||
|
vBuyingValue,
|
||||||
|
freightValue,
|
||||||
|
TRUE,
|
||||||
|
stickers,
|
||||||
|
packagingFk,
|
||||||
|
packing,
|
||||||
|
`grouping`,
|
||||||
|
groupingMode,
|
||||||
|
comissionValue,
|
||||||
|
packageValue,
|
||||||
|
price1,
|
||||||
|
price2,
|
||||||
|
price3,
|
||||||
|
minPrice,
|
||||||
|
isChecked,
|
||||||
|
location,
|
||||||
|
weight,
|
||||||
|
itemOriginalFk
|
||||||
|
FROM vn.buy
|
||||||
|
WHERE id = vLastBuyFk;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO itemShelving (
|
||||||
|
itemFk,
|
||||||
|
shelvingFk,
|
||||||
|
visible,
|
||||||
|
`grouping`,
|
||||||
|
packing,
|
||||||
|
packagingFk,
|
||||||
|
userFk,
|
||||||
|
isChecked)
|
||||||
|
SELECT vItemA2Fk,
|
||||||
|
shelvingFk,
|
||||||
|
vQuantity ,
|
||||||
|
`grouping`,
|
||||||
|
packing,
|
||||||
|
packagingFk,
|
||||||
|
account.myUser_getId(),
|
||||||
|
isChecked
|
||||||
|
FROM itemShelving
|
||||||
|
WHERE itemFK = vSelf
|
||||||
|
AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
visible = vQuantity + VALUES(visible);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
CALL cache.visible_refresh(vCacheFk, TRUE, vWarehouseFk);
|
||||||
|
CALL cache.available_refresh(vCacheFk, TRUE, vWarehouseFk, vCurdate);
|
||||||
|
CALL buy_recalcPricesByBuy(vA2BuyFk);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,5 +1,13 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_doCompensation`(vDated DATE, vCompensationAccount VARCHAR(10) , vBankFk VARCHAR(10), vConcept VARCHAR(255), vAmount DECIMAL(10,2), vCompanyFk INT, vOriginalAccount VARCHAR(10))
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_doCompensation`(
|
||||||
|
vDated DATE,
|
||||||
|
vCompensationAccount VARCHAR(10),
|
||||||
|
vBankFk VARCHAR(10),
|
||||||
|
vConcept VARCHAR(255),
|
||||||
|
vAmount DECIMAL(10,2),
|
||||||
|
vCompanyFk INT,
|
||||||
|
vOriginalAccount VARCHAR(10)
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Compensa un pago o un recibo insertando en contabilidad
|
* Compensa un pago o un recibo insertando en contabilidad
|
||||||
|
@ -9,29 +17,31 @@ BEGIN
|
||||||
* @param vBankFk banco de la compensacion
|
* @param vBankFk banco de la compensacion
|
||||||
* @param vConcept descripcion
|
* @param vConcept descripcion
|
||||||
* @param vAmount cantidad que se compensa
|
* @param vAmount cantidad que se compensa
|
||||||
* @param vCompany empresa
|
* @param vCompanyFk empresa
|
||||||
* @param vOriginalAccount cuenta contable desde la cual se compensa
|
* @param vOriginalAccount cuenta contable desde la cual se compensa
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
DECLARE vNewBookEntry INT;
|
DECLARE vNewBookEntry INT;
|
||||||
DECLARE vIsClientCompensation INT;
|
DECLARE vIsClientCompensation INT;
|
||||||
DECLARE vClientFk INT;
|
DECLARE vClientFk INT;
|
||||||
DECLARE vSupplierFk INT;
|
DECLARE vSupplierFk INT;
|
||||||
DECLARE vIsOriginalAClient BOOL;
|
DECLARE vIsOriginalAClient BOOL;
|
||||||
DECLARE vPayMethodCompensation INT;
|
DECLARE vPayMethodCompensation INT;
|
||||||
|
|
||||||
CALL ledger_next(vNewBookEntry);
|
|
||||||
|
|
||||||
SELECT COUNT(id) INTO vIsOriginalAClient FROM client WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci;
|
CALL ledger_next(YEAR(vDated), vNewBookEntry);
|
||||||
|
|
||||||
|
SELECT COUNT(id) INTO vIsOriginalAClient
|
||||||
|
FROM client
|
||||||
|
WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci;
|
||||||
|
|
||||||
SELECT id, COUNT(id) INTO vClientFk, vIsClientCompensation
|
SELECT id, COUNT(id) INTO vClientFk, vIsClientCompensation
|
||||||
FROM client
|
FROM client
|
||||||
WHERE accountingAccount LIKE vCompensationAccount COLLATE utf8_general_ci;
|
WHERE accountingAccount LIKE vCompensationAccount COLLATE utf8_general_ci;
|
||||||
|
|
||||||
SET @vAmount1:= 0.0;
|
SET @vAmount1:= 0.0;
|
||||||
SET @vAmount2:= 0.0;
|
SET @vAmount2:= 0.0;
|
||||||
|
|
||||||
INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id)
|
INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id)
|
||||||
VALUES ( vNewBookEntry,
|
VALUES ( vNewBookEntry,
|
||||||
vDated,
|
vDated,
|
||||||
vOriginalAccount,
|
vOriginalAccount,
|
||||||
|
@ -49,30 +59,51 @@ BEGIN
|
||||||
),
|
),
|
||||||
vCompanyFk
|
vCompanyFk
|
||||||
),
|
),
|
||||||
( vNewBookEntry,
|
( vNewBookEntry,
|
||||||
vDated,
|
vDated,
|
||||||
vCompensationAccount,
|
vCompensationAccount,
|
||||||
vOriginalAccount,
|
vOriginalAccount,
|
||||||
vConcept,
|
vConcept,
|
||||||
@vAmount2,
|
@vAmount2,
|
||||||
@vAmount1,
|
@vAmount1,
|
||||||
vCompanyFk);
|
vCompanyFk);
|
||||||
|
|
||||||
IF vIsClientCompensation THEN
|
IF vIsClientCompensation THEN
|
||||||
IF vIsOriginalAClient THEN
|
IF vIsOriginalAClient THEN
|
||||||
SET vAmount = -vAmount;
|
SET vAmount = -vAmount;
|
||||||
END IF;
|
END IF;
|
||||||
INSERT INTO receipt(invoiceFk, amountPaid, payed, bankFk, companyFk, clientFk, isConciliate)
|
|
||||||
VALUES (vConcept, vAmount, vDated, vBankFk, vCompanyFk, vClientFk, TRUE);
|
INSERT INTO receipt
|
||||||
ELSE
|
SET invoiceFk = vConcept,
|
||||||
IF NOT vIsOriginalAClient THEN
|
amountPaid = vAmount,
|
||||||
SET vAmount = -vAmount;
|
payed = vDated,
|
||||||
END IF;
|
bankFk = vBankFk,
|
||||||
SELECT id INTO vSupplierFk FROM supplier WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci;
|
companyFk = vCompanyFk,
|
||||||
SELECT id INTO vPayMethodCompensation FROM payMethod WHERE `code` = 'compensation';
|
clientFk = vClientFk,
|
||||||
|
isConciliate = TRUE;
|
||||||
INSERT INTO payment (received, dueDated, supplierFk, amount, bankFk, payMethodFk, concept, companyFk, isConciliated)
|
ELSE
|
||||||
VALUES(vDated, vDated, vSupplierFk, vAmount, vBankFk, vPayMethodCompensation, vConcept, vCompanyFk, TRUE);
|
IF NOT vIsOriginalAClient THEN
|
||||||
END IF;
|
SET vAmount = -vAmount;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT id INTO vSupplierFk
|
||||||
|
FROM supplier
|
||||||
|
WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
SELECT id INTO vPayMethodCompensation
|
||||||
|
FROM payMethod
|
||||||
|
WHERE `code` = 'compensation';
|
||||||
|
|
||||||
|
INSERT INTO payment
|
||||||
|
SET received = vDated,
|
||||||
|
dueDated = vDated,
|
||||||
|
supplierFk = vSupplierFk,
|
||||||
|
amount = vAmount,
|
||||||
|
bankFk = vBankFk,
|
||||||
|
payMethodFk = vPayMethodCompensation,
|
||||||
|
concept = vConcept,
|
||||||
|
companyFk = vCompanyFk,
|
||||||
|
isConciliated = TRUE;
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(OUT vNewBookEntry INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(
|
||||||
|
IN vFiscalYear INT,
|
||||||
|
OUT vNewBookEntry INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
UPDATE ledgerCompany
|
||||||
UPDATE vn.ledgerConfig SET lastBookEntry = LAST_INSERT_ID(lastBookEntry + 1);
|
SET bookEntry = LAST_INSERT_ID(bookEntry + 1)
|
||||||
SET vNewBookEntry = LAST_INSERT_ID();
|
WHERE fiscalYear = vFiscalYear;
|
||||||
|
|
||||||
|
SET vNewBookEntry = LAST_INSERT_ID();
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -35,7 +35,7 @@ BEGIN
|
||||||
itemFk,
|
itemFk,
|
||||||
longName,
|
longName,
|
||||||
supplier,
|
supplier,
|
||||||
entryFk,
|
CONCAT('E',entryFk) entryFk,
|
||||||
landed,
|
landed,
|
||||||
`in`,
|
`in`,
|
||||||
`out`,
|
`out`,
|
||||||
|
@ -49,16 +49,98 @@ BEGIN
|
||||||
itemFk,
|
itemFk,
|
||||||
longName,
|
longName,
|
||||||
supplier,
|
supplier,
|
||||||
'previous',
|
'E previous',
|
||||||
vFromDated,
|
vFromDated,
|
||||||
SUM(`in`),
|
SUM(`in`),
|
||||||
SUM(`out`),
|
SUM(`out`),
|
||||||
NULL,
|
NULL,
|
||||||
buyingValue
|
AVG(buyingValue)
|
||||||
FROM supplierPackaging
|
FROM supplierPackaging
|
||||||
WHERE supplierFk = vSupplierFk
|
WHERE supplierFk = vSupplierFk
|
||||||
AND landed < vFromDated
|
AND landed < vFromDated
|
||||||
GROUP BY itemFk
|
GROUP BY itemFk
|
||||||
|
UNION ALL
|
||||||
|
SELECT vSupplierFk,
|
||||||
|
s.itemFk,
|
||||||
|
i.longName,
|
||||||
|
c.name,
|
||||||
|
CONCAT('T',s.ticketFk),
|
||||||
|
DATE(t.shipped),
|
||||||
|
-LEAST(s.quantity,0) `in`,
|
||||||
|
GREATEST(s.quantity,0) `out`,
|
||||||
|
t.warehouseFk,
|
||||||
|
s.price * (100 - s.discount) / 100
|
||||||
|
FROM sale s
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
JOIN packaging p ON p.itemFk = i.id
|
||||||
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
|
JOIN client c ON c.id = t.clientFk
|
||||||
|
JOIN supplier su ON su.nif = c.fi
|
||||||
|
WHERE su.id = vSupplierFk
|
||||||
|
AND t.shipped >= vFromDated
|
||||||
|
AND p.isPackageReturnable
|
||||||
|
UNION ALL
|
||||||
|
SELECT vSupplierFk,
|
||||||
|
s.itemFk,
|
||||||
|
i.longName,
|
||||||
|
c.name,
|
||||||
|
'T previous',
|
||||||
|
vFromDated,
|
||||||
|
SUM(-LEAST(s.quantity,0)) `in`,
|
||||||
|
SUM(GREATEST(s.quantity,0)) `out`,
|
||||||
|
NULL,
|
||||||
|
AVG(s.price * (100 - s.discount) / 100)
|
||||||
|
FROM sale s
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
JOIN packaging p ON p.itemFk = i.id
|
||||||
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
|
JOIN client c ON c.id = t.clientFk
|
||||||
|
JOIN supplier su ON su.nif = c.fi
|
||||||
|
WHERE su.id = vSupplierFk
|
||||||
|
AND t.shipped < vFromDated
|
||||||
|
AND p.isPackageReturnable
|
||||||
|
GROUP BY s.itemFk
|
||||||
|
UNION ALL
|
||||||
|
SELECT vSupplierFk,
|
||||||
|
p.itemFk,
|
||||||
|
i.longName,
|
||||||
|
c.name,
|
||||||
|
CONCAT('TP',tp.ticketFk),
|
||||||
|
DATE(t.shipped),
|
||||||
|
-LEAST(tp.quantity,0) `in`,
|
||||||
|
GREATEST(tp.quantity,0) `out`,
|
||||||
|
t.warehouseFk,
|
||||||
|
0
|
||||||
|
FROM ticketPackaging tp
|
||||||
|
JOIN packaging p ON p.id = tp.packagingFk
|
||||||
|
JOIN item i ON i.id = p.itemFk
|
||||||
|
JOIN ticket t ON t.id = tp.ticketFk
|
||||||
|
JOIN client c ON c.id = t.clientFk
|
||||||
|
JOIN supplier su ON su.nif = c.fi
|
||||||
|
WHERE su.id = vSupplierFk
|
||||||
|
AND t.shipped >= vFromDated
|
||||||
|
AND p.isPackageReturnable
|
||||||
|
UNION ALL
|
||||||
|
SELECT vSupplierFk,
|
||||||
|
p.itemFk,
|
||||||
|
i.longName,
|
||||||
|
c.name,
|
||||||
|
'TP previous',
|
||||||
|
vFromDated,
|
||||||
|
SUM(-LEAST(tp.quantity,0)) `in`,
|
||||||
|
SUM(GREATEST(tp.quantity,0)) `out`,
|
||||||
|
NULL,
|
||||||
|
0
|
||||||
|
FROM ticketPackaging tp
|
||||||
|
JOIN packaging p ON p.id = tp.packagingFk
|
||||||
|
JOIN item i ON i.id = p.itemFk
|
||||||
|
JOIN ticket t ON t.id = tp.ticketFk
|
||||||
|
JOIN client c ON c.id = t.clientFk
|
||||||
|
JOIN supplier su ON su.nif = c.fi
|
||||||
|
WHERE su.id = vSupplierFk
|
||||||
|
AND t.shipped >= vFromDated
|
||||||
|
AND p.isPackageReturnable
|
||||||
|
GROUP BY p.itemFk
|
||||||
ORDER BY itemFk, landed, entryFk
|
ORDER BY itemFk, landed, entryFk
|
||||||
) sub
|
) sub
|
||||||
WHERE `out` OR `in`;
|
WHERE `out` OR `in`;
|
||||||
|
@ -69,8 +151,8 @@ BEGIN
|
||||||
supplier,
|
supplier,
|
||||||
entryFk,
|
entryFk,
|
||||||
landed,
|
landed,
|
||||||
`in`,
|
CAST(`in` AS DECIMAL(10,0)) `in`,
|
||||||
`out`,
|
CAST(`out` AS DECIMAL(10,0)) `out`,
|
||||||
warehouse,
|
warehouse,
|
||||||
buyingValue,
|
buyingValue,
|
||||||
balance
|
balance
|
||||||
|
|
|
@ -27,7 +27,10 @@ BEGIN
|
||||||
SELECT DISTINCT clientFk
|
SELECT DISTINCT clientFk
|
||||||
FROM (
|
FROM (
|
||||||
SELECT clientFk, SUM(quantity) totalQuantity
|
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
|
GROUP BY itemFk, clientFk
|
||||||
HAVING totalQuantity > 0)sub;
|
HAVING totalQuantity > 0)sub;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_checkMultipleDevice`(
|
||||||
|
vSelf INT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Verify if a worker has multiple assigned devices,
|
||||||
|
* except for freelancers.
|
||||||
|
*
|
||||||
|
* @param vUserFk worker id.
|
||||||
|
*/
|
||||||
|
DECLARE vHasPda BOOLEAN;
|
||||||
|
DECLARE vIsFreelance BOOLEAN;
|
||||||
|
DECLARE vMaxDevicesPerUser INT;
|
||||||
|
|
||||||
|
SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = vSelf;
|
||||||
|
SELECT IFNULL(isFreelance, FALSE) INTO vIsFreelance FROM worker WHERE id = vSelf;
|
||||||
|
SELECT IFNULL(maxDevicesPerUser, FALSE) INTO vMaxDevicesPerUser FROM deviceProductionConfig LIMIT 1;
|
||||||
|
|
||||||
|
IF NOT vIsFreelance AND vHasPda > vMaxDevicesPerUser THEN
|
||||||
|
CALL util.throw('You can only have one PDA');
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_afterInsert`
|
||||||
|
AFTER INSERT ON `deviceProductionUser`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
CALL worker_checkMultipleDevice(NEW.userFk);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_
|
||||||
BEFORE UPDATE ON `deviceProductionUser`
|
BEFORE UPDATE ON `deviceProductionUser`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
|
CALL worker_checkMultipleDevice(NEW.userFk);
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -3,92 +3,93 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`payment_beforeInsert`
|
||||||
BEFORE INSERT ON `payment`
|
BEFORE INSERT ON `payment`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE cuenta_banco,cuenta_proveedor DOUBLE;
|
DECLARE vBankAccount DOUBLE;
|
||||||
DECLARE vNewBookEntry INT;
|
DECLARE vSupplierAccount DOUBLE;
|
||||||
DECLARE bolCASH BOOLEAN;
|
DECLARE vNewBookEntry INT;
|
||||||
DECLARE isSupplierActive BOOLEAN;
|
DECLARE vIsCash BOOLEAN;
|
||||||
|
DECLARE vIsSupplierActive BOOLEAN;
|
||||||
|
|
||||||
-- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH
|
-- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH
|
||||||
SELECT (at2.code = 'cash') INTO bolCASH
|
SELECT (at2.code = 'cash') INTO vIsCash
|
||||||
FROM accounting a
|
FROM accounting a
|
||||||
JOIN accountingType at2 ON at2.id = a.accountingTypeFk
|
JOIN accountingType at2 ON at2.id = a.accountingTypeFk
|
||||||
WHERE a.id = NEW.bankFk;
|
WHERE a.id = NEW.bankFk;
|
||||||
|
|
||||||
IF bolCASH THEN
|
IF vIsCash THEN
|
||||||
|
SELECT account INTO vBankAccount
|
||||||
SELECT account INTO cuenta_banco
|
FROM accounting
|
||||||
FROM accounting
|
WHERE id = NEW.bankFk;
|
||||||
WHERE id = NEW.bankFk;
|
|
||||||
|
|
||||||
SELECT account INTO cuenta_proveedor
|
|
||||||
FROM supplier
|
|
||||||
WHERE id = NEW.supplierFk;
|
|
||||||
|
|
||||||
CALL ledger_next(vNewBookEntry);
|
SELECT account INTO vSupplierAccount
|
||||||
|
|
||||||
INSERT INTO XDiario ( ASIEN,
|
|
||||||
FECHA,
|
|
||||||
SUBCTA,
|
|
||||||
CONTRA,
|
|
||||||
CONCEPTO,
|
|
||||||
EURODEBE,
|
|
||||||
EUROHABER,
|
|
||||||
empresa_id)
|
|
||||||
SELECT vNewBookEntry,
|
|
||||||
NEW.received,
|
|
||||||
SUBCTA,
|
|
||||||
CONTRA,
|
|
||||||
NEW.concept,
|
|
||||||
EURODEBE,
|
|
||||||
EUROHABER,
|
|
||||||
NEW.companyFk
|
|
||||||
FROM ( SELECT cuenta_banco SUBCTA,
|
|
||||||
cuenta_proveedor CONTRA,
|
|
||||||
0 EURODEBE,
|
|
||||||
NEW.amount + NEW.bankingFees EUROHABER
|
|
||||||
UNION ALL
|
|
||||||
SELECT cuenta_proveedor SUBCTA,
|
|
||||||
cuenta_banco CONTRA,
|
|
||||||
NEW.amount EURODEBE,
|
|
||||||
0 EUROHABER) gf;
|
|
||||||
|
|
||||||
IF NEW.bankingFees <> 0 THEN
|
|
||||||
INSERT INTO XDiario ( ASIEN,
|
|
||||||
FECHA,
|
|
||||||
SUBCTA,
|
|
||||||
CONTRA,
|
|
||||||
CONCEPTO,
|
|
||||||
EURODEBE,
|
|
||||||
EUROHABER,
|
|
||||||
empresa_id)
|
|
||||||
SELECT vNewBookEntry,
|
|
||||||
NEW.received,
|
|
||||||
IF(c.id = 1,6260000002,
|
|
||||||
IF(CEE = 1,6260000003,6260000004)),
|
|
||||||
cuenta_banco,
|
|
||||||
NEW.concept,
|
|
||||||
NEW.bankingFees,
|
|
||||||
0,
|
|
||||||
NEW.companyFk
|
|
||||||
FROM supplier s
|
|
||||||
JOIN country c ON s.countryFk = c.id
|
|
||||||
WHERE s.id = NEW.supplierFk;
|
|
||||||
END IF;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received);
|
|
||||||
|
|
||||||
SELECT isActive INTO isSupplierActive
|
|
||||||
FROM supplier
|
FROM supplier
|
||||||
WHERE id = NEW.supplierFk;
|
WHERE id = NEW.supplierFk;
|
||||||
|
|
||||||
IF isSupplierActive = FALSE THEN
|
CALL ledger_next(YEAR(NEW.received), NEW.companyFk, vNewBookEntry);
|
||||||
CALL util.throw('SUPPLIER_INACTIVE');
|
|
||||||
END IF;
|
INSERT INTO XDiario (
|
||||||
|
ASIEN,
|
||||||
IF ISNULL(NEW.workerFk) THEN
|
FECHA,
|
||||||
SET NEW.workerFk = account.myUser_getId();
|
SUBCTA,
|
||||||
END IF;
|
CONTRA,
|
||||||
|
CONCEPTO,
|
||||||
END$$
|
EURODEBE,
|
||||||
|
EUROHABER,
|
||||||
|
empresa_id)
|
||||||
|
SELECT vNewBookEntry,
|
||||||
|
NEW.received,
|
||||||
|
SUBCTA,
|
||||||
|
CONTRA,
|
||||||
|
NEW.concept,
|
||||||
|
EURODEBE,
|
||||||
|
EUROHABER,
|
||||||
|
NEW.companyFk
|
||||||
|
FROM (SELECT vBankAccount SUBCTA,
|
||||||
|
vSupplierAccount CONTRA,
|
||||||
|
0 EURODEBE,
|
||||||
|
NEW.amount + NEW.bankingFees EUROHABER
|
||||||
|
UNION ALL
|
||||||
|
SELECT vSupplierAccount SUBCTA,
|
||||||
|
vBankAccount CONTRA,
|
||||||
|
NEW.amount EURODEBE,
|
||||||
|
0 EUROHABER) gf;
|
||||||
|
|
||||||
|
IF NEW.bankingFees <> 0 THEN
|
||||||
|
INSERT INTO XDiario (
|
||||||
|
ASIEN,
|
||||||
|
FECHA,
|
||||||
|
SUBCTA,
|
||||||
|
CONTRA,
|
||||||
|
CONCEPTO,
|
||||||
|
EURODEBE,
|
||||||
|
EUROHABER,
|
||||||
|
empresa_id)
|
||||||
|
SELECT vNewBookEntry,
|
||||||
|
NEW.received,
|
||||||
|
IF(c.id = 1,6260000002,
|
||||||
|
IF(CEE = 1,6260000003,6260000004)),
|
||||||
|
vBankAccount,
|
||||||
|
NEW.concept,
|
||||||
|
NEW.bankingFees,
|
||||||
|
0,
|
||||||
|
NEW.companyFk
|
||||||
|
FROM supplier s
|
||||||
|
JOIN country c ON s.countryFk = c.id
|
||||||
|
WHERE s.id = NEW.supplierFk;
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received);
|
||||||
|
|
||||||
|
SELECT isActive INTO vIsSupplierActive
|
||||||
|
FROM supplier
|
||||||
|
WHERE id = NEW.supplierFk;
|
||||||
|
|
||||||
|
IF vIsSupplierActive = FALSE THEN
|
||||||
|
CALL util.throw('SUPPLIER_INACTIVE');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF ISNULL(NEW.workerFk) THEN
|
||||||
|
SET NEW.workerFk = account.myUser_getId();
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -18,11 +18,6 @@ BEGIN
|
||||||
`changedModel` = 'TicketTracking',
|
`changedModel` = 'TicketTracking',
|
||||||
`changedModelId` = OLD.id,
|
`changedModelId` = OLD.id,
|
||||||
`userFk` = account.myUser_getId();
|
`userFk` = account.myUser_getId();
|
||||||
|
|
||||||
CALL util.debugAdd('deletedState',
|
|
||||||
CONCAT('interFk: ', OLD.id,
|
|
||||||
' ticketFk: ', OLD.ticketFk,
|
|
||||||
' stateFk: ', OLD.stateFk));
|
|
||||||
|
|
||||||
SELECT i.ticketFk, i.id, s.`name`
|
SELECT i.ticketFk, i.id, s.`name`
|
||||||
INTO vTicketFk, vTicketTrackingFk, vStateName
|
INTO vTicketFk, vTicketTrackingFk, vStateName
|
||||||
|
|
|
@ -37,7 +37,7 @@ FROM (
|
||||||
)
|
)
|
||||||
JOIN `vn`.`volumeConfig` `vc`
|
JOIN `vn`.`volumeConfig` `vc`
|
||||||
)
|
)
|
||||||
JOIN `vn`.`itemCost` `ic` ON(
|
JOIN `vn`.`itemCost` `ic` FORCE INDEX (`PRIMARY`) ON(
|
||||||
`ic`.`itemFk` = `s`.`itemFk`
|
`ic`.`itemFk` = `s`.`itemFk`
|
||||||
AND `ic`.`warehouseFk` = `t`.`warehouseFk`
|
AND `ic`.`warehouseFk` = `t`.`warehouseFk`
|
||||||
)
|
)
|
||||||
|
|
|
@ -28,6 +28,5 @@ AS SELECT `c`.`id` AS `Id_Compra`,
|
||||||
`c`.`workerFk` AS `Id_Trabajador`,
|
`c`.`workerFk` AS `Id_Trabajador`,
|
||||||
`c`.`weight` AS `weight`,
|
`c`.`weight` AS `weight`,
|
||||||
`c`.`dispatched` AS `dispatched`,
|
`c`.`dispatched` AS `dispatched`,
|
||||||
`c`.`containerFk` AS `container_id`,
|
|
||||||
`c`.`itemOriginalFk` AS `itemOriginalFk`
|
`c`.`itemOriginalFk` AS `itemOriginalFk`
|
||||||
FROM `vn`.`buy` `c`
|
FROM `vn`.`buy` `c`
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
INSERT IGNORE INTO vn.entryType (code, description)
|
||||||
|
VALUES ('devaluation', 'Devaluación');
|
||||||
|
|
||||||
|
ALTER TABLE vn.travelConfig ADD IF NOT EXISTS devalueWarehouseOutFk SMALLINT(6) UNSIGNED NULL
|
||||||
|
COMMENT 'Datos del travel para las entradas generadas al devaluar artículos de A1 a A2';
|
||||||
|
|
||||||
|
ALTER TABLE vn.travelConfig ADD IF NOT EXISTS devalueAgencyModeFk INT(11) NULL;
|
||||||
|
ALTER TABLE vn.travelConfig ADD IF NOT EXISTS devalueRef varchar(20) NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.travelConfig DROP FOREIGN KEY IF EXISTS travelConfig_agencyMode_FK;
|
||||||
|
|
||||||
|
ALTER TABLE vn.travelConfig ADD CONSTRAINT travelConfig_agencyMode_FK
|
||||||
|
FOREIGN KEY (devalueAgencyModeFk) REFERENCES vn.agencyMode(id) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE vn.travelConfig DROP FOREIGN KEY IF EXISTS travelConfig_warehouse_FK;
|
||||||
|
ALTER TABLE vn.travelConfig ADD CONSTRAINT travelConfig_warehouse_FK
|
||||||
|
FOREIGN KEY (devalueWarehouseOutFk) REFERENCES vn.warehouse(id) ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@ -0,0 +1,21 @@
|
||||||
|
ALTER TABLE vn.deviceProductionUser DROP INDEX IF EXISTS deviceProductionUser_UN;
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionUser DROP FOREIGN KEY IF EXISTS deviceProductionUser_FK;
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionUser DROP PRIMARY KEY;
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionUser ADD IF NOT EXISTS id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY FIRST;
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_deviceProduction_FK FOREIGN KEY IF NOT EXISTS (deviceProductionFk) REFERENCES vn.deviceProduction(id);
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_unique UNIQUE KEY IF NOT EXISTS (deviceProductionFk);
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionUser ADD IF NOT EXISTS simSerialNumber TEXT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.deviceProductionConfig ADD IF NOT EXISTS maxDevicesPerUser INT UNSIGNED NULL;
|
||||||
|
|
||||||
|
UPDATE vn.deviceProductionConfig SET maxDevicesPerUser=1 WHERE id=1;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('Worker','getAvailablePda','READ','ALLOW','ROLE','hr');
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
UPDATE vn.route
|
||||||
|
SET vehicleFk = NULL
|
||||||
|
WHERE vehicleFk NOT IN (SELECT id FROM vn.vehicle);
|
||||||
|
|
||||||
|
ALTER TABLE vn.route
|
||||||
|
ADD CONSTRAINT route_vehicleFk FOREIGN KEY (vehicleFk) REFERENCES vn.vehicle(id);
|
||||||
|
|
||||||
|
ALTER TABLE vn.route
|
||||||
|
MODIFY COLUMN firstEditorFk int(10) unsigned NULL;
|
||||||
|
|
||||||
|
UPDATE vn.route
|
||||||
|
SET firstEditorFk = NULL
|
||||||
|
WHERE firstEditorFk NOT IN (SELECT id FROM account.user);
|
||||||
|
|
||||||
|
ALTER TABLE vn.route
|
||||||
|
ADD CONSTRAINT route_firstEditorFk FOREIGN KEY (firstEditorFk) REFERENCES account.user(id);
|
|
@ -1,3 +1,3 @@
|
||||||
ALTER TABLE pbx.sipConfig
|
ALTER TABLE pbx.sipConfig
|
||||||
CHANGE incomingLimit `call-limit` varchar(10)
|
CHANGE incomingLimit `call-limit` varchar(10)
|
||||||
CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;
|
CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
CREATE OR REPLACE TABLE vn.ledgerCompany (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`fiscalYear` int(10) unsigned NOT NULL COMMENT 'Año del ejercicio contable',
|
||||||
|
`bookEntry` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Contador asiento contable',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `ledgerCompany_unique` (`fiscalYear`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci
|
||||||
|
COMMENT='Contador para asientos contables';
|
||||||
|
|
||||||
|
INSERT IGNORE INTO vn.ledgerCompany (fiscalYear, bookEntry)
|
||||||
|
SELECT YEAR(util.VN_CURDATE()), lastBookEntry
|
||||||
|
FROM vn.ledgerConfig;
|
||||||
|
|
||||||
|
ALTER TABLE vn.ledgerConfig CHANGE IF EXISTS lastBookEntry lastBookEntry__ int(11) NOT NULL
|
||||||
|
COMMENT '@deprecated 2024-05-28 refs #7400 Modificar contador asientos contables';
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
ALTER TABLE vn.clientConfig
|
||||||
|
ADD monthsToDisableUser int(10) unsigned DEFAULT NULL NULL;
|
||||||
|
|
||||||
|
UPDATE IGNORE vn.clientConfig
|
||||||
|
SET monthsToDisableUser = 12;
|
|
@ -0,0 +1,26 @@
|
||||||
|
DROP TABLE IF EXISTS vn2008.scanTree__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.payroll_embargos__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.unary_source__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.unary_scan_line_buy__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.unary_scan_line__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.unary_scan__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.scan_line__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Familias__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.language__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Clientes_dits__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.unary_scan_line_expedition__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.warehouse_group__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Espionajes__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.jerarquia__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.wks__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Proveedores_comunicados__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.integra2_escala__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.cp__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.unary__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Estados__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.agency_hour__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Reservas__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.cyc_declaration__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.route__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Proveedores_escritos__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.config__;
|
|
@ -0,0 +1,41 @@
|
||||||
|
DROP TABLE IF EXISTS vn2008.form_query__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.filtros__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Objetivos__;
|
||||||
|
UPDATE IGNORE vn.province
|
||||||
|
SET zoneFk = NULL
|
||||||
|
WHERE zoneFk IN (
|
||||||
|
SELECT zoneFk
|
||||||
|
FROM vn.province
|
||||||
|
WHERE zoneFk IS NOT NULL AND zoneFk NOT IN (SELECT id FROM vn.`zone`)
|
||||||
|
);
|
||||||
|
ALTER TABLE vn.province DROP FOREIGN KEY province_zone_fk;
|
||||||
|
ALTER TABLE vn.province MODIFY COLUMN zoneFk int(11) DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE vn.province ADD CONSTRAINT
|
||||||
|
province_zone_FK FOREIGN KEY (zoneFk) REFERENCES vn.`zone`(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
DROP TABLE IF EXISTS vn2008.zones__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.rec_translator__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.warehouse_joined__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.warehouse_filtro__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.viaxpress__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.cl_que__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Recibos_recorded__;
|
||||||
|
RENAME TABLE vn.coolerPathDetail TO vn.coolerPathDetail__;
|
||||||
|
ALTER TABLE vn.coolerPathDetail__ DROP FOREIGN KEY coolerPathDetail_FK;
|
||||||
|
DROP TABLE IF EXISTS vn2008.cooler_path__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.payrroll_apEmpresarial__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Compres_ok__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Movimientos_avisar__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Clases__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.payroll_basess__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.payroll_tipobasess__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.guillen__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.guillen_carry__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Series__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Permisos__;
|
||||||
|
ALTER TABLE vn.buy DROP FOREIGN KEY buy_FK_1;
|
||||||
|
DROP TABLE IF EXISTS vn2008.container__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.travel_reserve__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.tmpNEWTARIFAS__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Clientes_potenciales__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.duaDismissed__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.cl_pet__;
|
|
@ -0,0 +1,27 @@
|
||||||
|
DROP TABLE IF EXISTS vn2008.expeditions_deleted__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Tipos_f11__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.commission__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Movimientos_revisar__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.recibida_agricola__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.tipsa__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.rounding__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Informes__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Monitoring__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Forms__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Clientes_event__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.wh_selection__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.template_bionic_component__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Agencias_province__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.travel_pattern__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.sort_merge_results_ernesto__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Conteo__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Consignatarios_devices__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.link__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.agency_warehouse__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.warehouse_lc__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.emp_day_pay__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Entradas_kop__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.dock__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.unaryScanFilter__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Grupos__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.nichos__;
|
|
@ -0,0 +1,26 @@
|
||||||
|
DROP TABLE IF EXISTS vn2008.preparation_exception__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Clientes_empresa__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.call_information__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.template_bionic_price__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.invoice_observation__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.edi_testigos__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.cl_dep__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.agencia_descuadre__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.payroll_datos__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.tblIVA__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.cyc__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Tickets_stack__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.config_host_forms__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.template_bionic_lot__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.payroll_bonificaciones__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.widget__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.accion_dits__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.credit_card__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Brasa__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Jefes__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.call_option__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.expeditions_pictures__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.scan__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.trolley__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.transport__;
|
||||||
|
DROP TABLE IF EXISTS vn2008.Baldas__;
|
|
@ -0,0 +1,2 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE floranet.`order` ADD IF NOT EXISTS observations TEXT NULL;
|
|
@ -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');
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE vn.buy CHANGE containerFk containerFk__ smallint(5) unsigned DEFAULT NULL NULL;
|
|
@ -1,41 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Worker pda path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('hr', 'worker');
|
|
||||||
await page.accessToSearchResult('employeeNick');
|
|
||||||
await page.accessToSection('worker.card.pda');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check if worker has already a PDA allocated', async() => {
|
|
||||||
expect(await page.waitToGetProperty(selectors.workerPda.currentPDA, 'value')).toContain('serialNumber1');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should deallocate the PDA', async() => {
|
|
||||||
await page.waitToClick(selectors.workerPda.delete);
|
|
||||||
let message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('PDA deallocated');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should allocate a new PDA', async() => {
|
|
||||||
await page.autocompleteSearch(selectors.workerPda.newPDA, 'serialNumber2');
|
|
||||||
await page.waitToClick(selectors.workerPda.submit);
|
|
||||||
let message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('PDA allocated');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check if a new PDA has been allocated', async() => {
|
|
||||||
expect(await page.waitToGetProperty(selectors.workerPda.currentPDA, 'value')).toContain('serialNumber2');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
require('../methods/application/status')(Self);
|
require('../methods/application/status')(Self);
|
||||||
require('../methods/application/post')(Self);
|
require('../methods/application/post')(Self);
|
||||||
|
|
|
@ -355,6 +355,8 @@
|
||||||
"No results found": "No se han encontrado resultados",
|
"No results found": "No se han encontrado resultados",
|
||||||
"InvoiceIn is already booked": "La factura recibida está contabilizada",
|
"InvoiceIn is already booked": "La factura recibida está contabilizada",
|
||||||
"This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia",
|
"This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia",
|
||||||
"Select ticket or client": "Elija un ticket o un client",
|
"Select ticket or client": "Elija un ticket o un client",
|
||||||
"It was not able to create the invoice": "No se pudo crear la factura"
|
"It was not able to create the invoice": "No se pudo crear la factura",
|
||||||
}
|
"This PDA is already assigned to another user": "This PDA is already assigned to another user",
|
||||||
|
"ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)"
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = (localAsProduction = true) => {
|
||||||
|
return (!process.env.NODE_ENV && localAsProduction) || process.env.NODE_ENV == 'production';
|
||||||
|
};
|
|
@ -3,9 +3,10 @@ const app = require('vn-loopback/server/server');
|
||||||
const ldap = require('../util/ldapjs-extra');
|
const ldap = require('../util/ldapjs-extra');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const nthash = require('smbhash').nthash;
|
const nthash = require('smbhash').nthash;
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
const shouldSync = process.env.NODE_ENV !== 'test';
|
const shouldSync = isProduction();
|
||||||
|
|
||||||
Self.getLinker = async function() {
|
Self.getLinker = async function() {
|
||||||
return await Self.findOne({
|
return await Self.findOne({
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
const ldap = require('../util/ldapjs-extra');
|
const ldap = require('../util/ldapjs-extra');
|
||||||
const execFile = require('child_process').execFile;
|
const execFile = require('child_process').execFile;
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Summary of userAccountControl flags:
|
* Summary of userAccountControl flags:
|
||||||
|
@ -12,7 +13,7 @@ const UserAccountControlFlags = {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
const shouldSync = process.env.NODE_ENV !== 'test';
|
const shouldSync = isProduction();
|
||||||
|
|
||||||
Self.getLinker = async function() {
|
Self.getLinker = async function() {
|
||||||
return await Self.findOne({
|
return await Self.findOne({
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const got = require('got');
|
const got = require('got');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('send', {
|
Self.remoteMethod('send', {
|
||||||
|
@ -47,7 +48,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
let response;
|
let response;
|
||||||
try {
|
try {
|
||||||
if (process.env.NODE_ENV !== 'production')
|
if (!isProduction(false))
|
||||||
response = {result: [{status: 'ok'}]};
|
response = {result: [{status: 'ok'}]};
|
||||||
else {
|
else {
|
||||||
const jsonTest = {
|
const jsonTest = {
|
||||||
|
|
|
@ -76,7 +76,6 @@ module.exports = Self => {
|
||||||
packing: buyUltimate.packing,
|
packing: buyUltimate.packing,
|
||||||
grouping: buyUltimate.grouping,
|
grouping: buyUltimate.grouping,
|
||||||
groupingMode: buyUltimate.groupingMode,
|
groupingMode: buyUltimate.groupingMode,
|
||||||
containerFk: buyUltimate.containerFk,
|
|
||||||
comissionValue: buyUltimate.comissionValue,
|
comissionValue: buyUltimate.comissionValue,
|
||||||
packageValue: buyUltimate.packageValue,
|
packageValue: buyUltimate.packageValue,
|
||||||
location: buyUltimate.location,
|
location: buyUltimate.location,
|
||||||
|
|
|
@ -63,9 +63,6 @@
|
||||||
"isIgnored": {
|
"isIgnored": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"containerFk": {
|
|
||||||
"type": "number"
|
|
||||||
},
|
|
||||||
"location": {
|
"location": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('download', {
|
Self.remoteMethodCtx('download', {
|
||||||
|
@ -66,7 +67,7 @@ module.exports = Self => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (process.env.NODE_ENV == 'test') {
|
if (!isProduction()) {
|
||||||
try {
|
try {
|
||||||
await fs.access(file.path);
|
await fs.access(file.path);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const print = require('vn-print');
|
const print = require('vn-print');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/invoiceOut/filter')(Self);
|
require('../methods/invoiceOut/filter')(Self);
|
||||||
|
@ -59,7 +60,7 @@ module.exports = Self => {
|
||||||
hasPdf: true
|
hasPdf: true
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'test') {
|
if (isProduction()) {
|
||||||
await print.storage.write(buffer, {
|
await print.storage.write(buffer, {
|
||||||
type: 'invoice',
|
type: 'invoice',
|
||||||
path: pdfFile.path,
|
path: pdfFile.path,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('upload', {
|
Self.remoteMethodCtx('upload', {
|
||||||
|
@ -111,7 +112,7 @@ module.exports = Self => {
|
||||||
const destinationFile = path.join(
|
const destinationFile = path.join(
|
||||||
accessContainer.client.root, accessContainer.name, appName, `${toVersion}.7z`);
|
accessContainer.client.root, accessContainer.name, appName, `${toVersion}.7z`);
|
||||||
|
|
||||||
if (process.env.NODE_ENV == 'test')
|
if (!isProduction())
|
||||||
await fs.unlink(srcFile);
|
await fs.unlink(srcFile);
|
||||||
else {
|
else {
|
||||||
await fs.move(srcFile, destinationFile, {
|
await fs.move(srcFile, destinationFile, {
|
||||||
|
|
|
@ -62,12 +62,12 @@ module.exports = Self => {
|
||||||
|
|
||||||
const clone = await models.Roadmap.create(roadmap, options);
|
const clone = await models.Roadmap.create(roadmap, options);
|
||||||
|
|
||||||
const expeditionTrucks = roadmap.expeditionTruck();
|
const roadmapStops = roadmap.roadmapStop();
|
||||||
expeditionTrucks.map(expeditionTruck => {
|
roadmapStops.map(roadmapStop => {
|
||||||
expeditionTruck.roadmapFk = clone.id;
|
roadmapStop.roadmapFk = clone.id;
|
||||||
return expeditionTruck;
|
return roadmapStop;
|
||||||
});
|
});
|
||||||
await models.ExpeditionTruck.create(expeditionTrucks, options);
|
await models.RoadmapStop.create(roadmapStops, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
await tx.commit();
|
await tx.commit();
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"DeliveryPoint": {
|
"DeliveryPoint": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"ExpeditionTruck": {
|
"RoadmapStop": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Roadmap": {
|
"Roadmap": {
|
||||||
|
|
|
@ -54,9 +54,9 @@
|
||||||
"model": "Supplier",
|
"model": "Supplier",
|
||||||
"foreignKey": "supplierFk"
|
"foreignKey": "supplierFk"
|
||||||
},
|
},
|
||||||
"expeditionTruck": {
|
"roadmapStop": {
|
||||||
"type": "hasMany",
|
"type": "hasMany",
|
||||||
"model": "ExpeditionTruck",
|
"model": "RoadmapStop",
|
||||||
"foreignKey": "roadmapFk"
|
"foreignKey": "roadmapFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ExpeditionTruck",
|
"name": "RoadmapStop",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "expeditionTruck"
|
"table": "roadmapStop"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
|
@ -1,22 +1,22 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="ExpeditionTrucks"
|
url="RoadmapStops"
|
||||||
where="{roadmapFk: $ctrl.$params.id}"
|
where="{roadmapFk: $ctrl.$params.id}"
|
||||||
order="eta ASC"
|
order="eta ASC"
|
||||||
data="$ctrl.expeditionTrucks"
|
data="$ctrl.roadmapStops"
|
||||||
auto-load="true">
|
auto-load="true">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-watcher
|
<vn-watcher
|
||||||
vn-id="watcher"
|
vn-id="watcher"
|
||||||
data="$ctrl.expeditionTrucks"
|
data="$ctrl.roadmapStops"
|
||||||
form="form">
|
form="form">
|
||||||
</vn-watcher>
|
</vn-watcher>
|
||||||
<form class="vn-w-md" name="form" ng-submit="$ctrl.onSubmit()">
|
<form class="vn-w-md" name="form" ng-submit="$ctrl.onSubmit()">
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-horizontal ng-repeat="expeditionTruck in $ctrl.expeditionTrucks">
|
<vn-horizontal ng-repeat="roadmapStop in $ctrl.roadmapStops">
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
label="Warehouse"
|
label="Warehouse"
|
||||||
ng-model="expeditionTruck.warehouseFk"
|
ng-model="roadmapStop.warehouseFk"
|
||||||
url="Warehouses"
|
url="Warehouses"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
|
@ -25,18 +25,18 @@
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-date-picker vn-one
|
<vn-date-picker vn-one
|
||||||
label="ETA date"
|
label="ETA date"
|
||||||
ng-model="expeditionTruck.eta"
|
ng-model="roadmapStop.eta"
|
||||||
rule>
|
rule>
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
<vn-input-time
|
<vn-input-time
|
||||||
vn-one
|
vn-one
|
||||||
label="ETA hour"
|
label="ETA hour"
|
||||||
ng-model="expeditionTruck.eta">
|
ng-model="roadmapStop.eta">
|
||||||
</vn-input-time>
|
</vn-input-time>
|
||||||
<vn-textArea
|
<vn-textArea
|
||||||
vn-one
|
vn-one
|
||||||
label="Description"
|
label="Description"
|
||||||
ng-model="expeditionTruck.description"
|
ng-model="roadmapStop.description"
|
||||||
rule>
|
rule>
|
||||||
</vn-textArea>
|
</vn-textArea>
|
||||||
<vn-none>
|
<vn-none>
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
vn-bind="+"
|
vn-bind="+"
|
||||||
vn-tooltip="Add stop"
|
vn-tooltip="Add stop"
|
||||||
icon="add_circle"
|
icon="add_circle"
|
||||||
vn-click-stop="addExpeditionTruck.show()">
|
vn-click-stop="addRoadmapStop.show()">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
@ -61,9 +61,9 @@
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="expeditionTruck in summary.expeditionTruck">
|
<vn-tr ng-repeat="roadmapStop in summary.roadmapStop">
|
||||||
<vn-td>{{expeditionTruck.warehouse.name}}</vn-td>
|
<vn-td>{{roadmapStop.warehouse.name}}</vn-td>
|
||||||
<vn-td expand>{{expeditionTruck.eta | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
<vn-td expand>{{roadmapStop.eta | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-tbody>
|
</vn-tbody>
|
||||||
</vn-table>
|
</vn-table>
|
||||||
|
@ -75,14 +75,14 @@
|
||||||
</vn-supplier-descriptor-popover>
|
</vn-supplier-descriptor-popover>
|
||||||
|
|
||||||
<vn-dialog
|
<vn-dialog
|
||||||
vn-id="addExpeditionTruck"
|
vn-id="addRoadmapStop"
|
||||||
on-open="$ctrl.getETD()"
|
on-open="$ctrl.getETD()"
|
||||||
on-accept="$ctrl.onAddAccept()">
|
on-accept="$ctrl.onAddAccept()">
|
||||||
<tpl-body>
|
<tpl-body>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Warehouse"
|
label="Warehouse"
|
||||||
ng-model="$ctrl.expeditionTruck.warehouseFk"
|
ng-model="$ctrl.roadmapStop.warehouseFk"
|
||||||
url="Warehouses"
|
url="Warehouses"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
|
@ -93,18 +93,18 @@
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
label="ETA date"
|
label="ETA date"
|
||||||
ng-model="$ctrl.expeditionTruck.eta"
|
ng-model="$ctrl.roadmapStop.eta"
|
||||||
rule>
|
rule>
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
<vn-input-time
|
<vn-input-time
|
||||||
label="ETA hour"
|
label="ETA hour"
|
||||||
ng-model="$ctrl.expeditionTruck.eta">
|
ng-model="$ctrl.roadmapStop.eta">
|
||||||
</vn-input-time>
|
</vn-input-time>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textArea
|
<vn-textArea
|
||||||
label="Description"
|
label="Description"
|
||||||
ng-model="$ctrl.expeditionTruck.description"
|
ng-model="$ctrl.roadmapStop.description"
|
||||||
rule>
|
rule>
|
||||||
</vn-textArea>
|
</vn-textArea>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Controller extends Component {
|
||||||
include: [
|
include: [
|
||||||
{relation: 'supplier'},
|
{relation: 'supplier'},
|
||||||
{relation: 'worker'},
|
{relation: 'worker'},
|
||||||
{relation: 'expeditionTruck',
|
{relation: 'roadmapStop',
|
||||||
scope: {
|
scope: {
|
||||||
include: [
|
include: [
|
||||||
{relation: 'warehouse'}
|
{relation: 'warehouse'}
|
||||||
|
@ -36,19 +36,19 @@ class Controller extends Component {
|
||||||
const eta = new Date(this.roadmap.etd);
|
const eta = new Date(this.roadmap.etd);
|
||||||
eta.setDate(eta.getDate() + 1);
|
eta.setDate(eta.getDate() + 1);
|
||||||
|
|
||||||
this.expeditionTruck = {eta: eta};
|
this.roadmapStop = {eta: eta};
|
||||||
}
|
}
|
||||||
|
|
||||||
onAddAccept() {
|
onAddAccept() {
|
||||||
try {
|
try {
|
||||||
const data = {
|
const data = {
|
||||||
roadmapFk: this.roadmap.id,
|
roadmapFk: this.roadmap.id,
|
||||||
warehouseFk: this.expeditionTruck.warehouseFk,
|
warehouseFk: this.roadmapStop.warehouseFk,
|
||||||
eta: this.expeditionTruck.eta,
|
eta: this.roadmapStop.eta,
|
||||||
description: this.expeditionTruck.description
|
description: this.roadmapStop.description
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$http.post(`ExpeditionTrucks`, data)
|
this.$http.post(`RoadmapStops`, data)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.loadData();
|
this.loadData();
|
||||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
|
|
|
@ -138,12 +138,13 @@ module.exports = Self => {
|
||||||
JOIN alertLevel al ON al.id = ts.alertLevel
|
JOIN alertLevel al ON al.id = ts.alertLevel
|
||||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||||
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||||
JOIN zone z ON z.id = t.zoneFk
|
LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id
|
||||||
SET t.routeFk = NULL
|
SET t.routeFk = NULL
|
||||||
WHERE DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?)
|
WHERE DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?)
|
||||||
AND al.code NOT IN('DELIVERED','PACKED')
|
AND al.code NOT IN ('DELIVERED', 'PACKED')
|
||||||
AND t.routeFk
|
AND NOT t.packages
|
||||||
AND z.name LIKE '%MADRID%'`, [toDate, toDate], {userId: ctx.req.accessToken.userId});
|
AND tob.id IS NULL
|
||||||
|
AND t.routeFk`, [toDate, toDate], {userId: ctx.req.accessToken.userId});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
message: 'Success'
|
message: 'Success'
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"expeditionTruck": {
|
"roadmapStop": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "ExpeditionTruck",
|
"model": "RoadmapStop",
|
||||||
"foreignKey": "truckFk"
|
"foreignKey": "truckFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "string"
|
"type": "number",
|
||||||
|
"id": true
|
||||||
},
|
},
|
||||||
"originFk": {
|
"originFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
|
|
@ -37,18 +37,19 @@ class Controller extends Section {
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
fields: ['originFk', 'creationDate', 'newInstance'],
|
fields: ['id', 'originFk', 'creationDate', 'newInstance'],
|
||||||
where: {
|
where: {
|
||||||
originFk: value,
|
originFk: value,
|
||||||
newInstance: {like: '%"isDeleted":true%'}
|
newInstance: {like: '%"isDeleted":true%'}
|
||||||
},
|
},
|
||||||
order: 'creationDate DESC'
|
order: 'creationDate DESC',
|
||||||
|
limit: 1
|
||||||
};
|
};
|
||||||
this.$http.get(`TicketLogs/findOne`, {filter})
|
this.$http.get(`TicketLogs`, {filter})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res && res.data) {
|
if (res && res.data && res.data.length) {
|
||||||
const now = Date.vnNew();
|
const now = Date.vnNew();
|
||||||
const maxDate = new Date(res.data.creationDate);
|
const maxDate = new Date(res.data[0].creationDate);
|
||||||
maxDate.setHours(maxDate.getHours() + 1);
|
maxDate.setHours(maxDate.getHours() + 1);
|
||||||
if (now <= maxDate)
|
if (now <= maxDate)
|
||||||
return this.canRestoreTicket = true;
|
return this.canRestoreTicket = true;
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('getAvailablePda', {
|
||||||
|
description: 'returns devices without user',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [],
|
||||||
|
returns: {
|
||||||
|
type: 'array',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/getAvailablePda`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Self.getAvailablePda = async() => {
|
||||||
|
return Self.app.models.DeviceProduction.rawSql(
|
||||||
|
`SELECT d.*
|
||||||
|
FROM deviceProduction d
|
||||||
|
LEFT JOIN deviceProductionUser du ON du.deviceProductionFk = d.id
|
||||||
|
WHERE du.deviceProductionFk IS NULL`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,13 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
|
describe('worker getAvailablePda()', () => {
|
||||||
|
it('should return a Pda that has no user assigned', async() => {
|
||||||
|
const [{id}] = await models.Worker.getAvailablePda();
|
||||||
|
|
||||||
|
const deviceProductionUser = await models.DeviceProductionUser.findOne({
|
||||||
|
where: {deviceProductionFk: id}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(!deviceProductionUser).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,8 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.rewriteDbError(function(err) {
|
||||||
|
if (err.code === 'ER_DUP_ENTRY')
|
||||||
|
return new UserError(`This PDA is already assigned to another user`);
|
||||||
|
return err;
|
||||||
|
});
|
||||||
|
};
|
|
@ -14,6 +14,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true
|
||||||
|
},
|
||||||
"deviceProductionFk": {
|
"deviceProductionFk": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"id": true
|
"id": true
|
||||||
|
@ -21,6 +25,9 @@
|
||||||
"userFk": {
|
"userFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"simSerialNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"created": {
|
"created": {
|
||||||
"type": "date"
|
"type": "date"
|
||||||
}
|
}
|
||||||
|
@ -28,7 +35,7 @@
|
||||||
"relations": {
|
"relations": {
|
||||||
"deviceProduction": {
|
"deviceProduction": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "DeviceProduction",
|
"model": "DeviceProduction",
|
||||||
"foreignKey": "deviceProductionFk"
|
"foreignKey": "deviceProductionFk"
|
||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
|
@ -36,5 +43,10 @@
|
||||||
"model": "User",
|
"model": "User",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"scope": {
|
||||||
|
"include":{
|
||||||
|
"relation": "deviceProduction"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ module.exports = Self => {
|
||||||
require('../methods/worker/search')(Self);
|
require('../methods/worker/search')(Self);
|
||||||
require('../methods/worker/isAuthorized')(Self);
|
require('../methods/worker/isAuthorized')(Self);
|
||||||
require('../methods/worker/setPassword')(Self);
|
require('../methods/worker/setPassword')(Self);
|
||||||
|
require('../methods/worker/getAvailablePda')(Self);
|
||||||
|
|
||||||
Self.validateAsync('fi', tinIsValid, {
|
Self.validateAsync('fi', tinIsValid, {
|
||||||
message: 'Invalid TIN'
|
message: 'Invalid TIN'
|
||||||
|
|
|
@ -62,7 +62,23 @@
|
||||||
},
|
},
|
||||||
"isFreelance": {
|
"isFreelance": {
|
||||||
"type" : "boolean"
|
"type" : "boolean"
|
||||||
|
},
|
||||||
|
"fiDueDate": {
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
"hasMachineryAuthorized": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"seniority": {
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
"isDisable": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"isSsDiscounted": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"user": {
|
"user": {
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
<div class="vn-w-md" ng-show="$ctrl.currentPDA">
|
|
||||||
<vn-card class="vn-pa-lg">
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-textfield
|
|
||||||
label="Current PDA"
|
|
||||||
ng-model="$ctrl.currentPDA.description"
|
|
||||||
disabled="true">
|
|
||||||
<append>
|
|
||||||
<vn-icon-button
|
|
||||||
icon="delete"
|
|
||||||
vn-tooltip="Deallocate PDA"
|
|
||||||
ng-click="$ctrl.deallocatePDA()"
|
|
||||||
vn-acl="hr, productionAssi">
|
|
||||||
</vn-icon-button>
|
|
||||||
</append>
|
|
||||||
</vn-textfield>
|
|
||||||
</vn-horizontal>
|
|
||||||
</vn-card>
|
|
||||||
</div>
|
|
||||||
<form name="form" ng-show="!$ctrl.currentPDA" ng-submit="$ctrl.allocatePDA()" class="vn-w-md">
|
|
||||||
<vn-card class="vn-pa-lg">
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-autocomplete
|
|
||||||
vn-acl="hr, productionAssi"
|
|
||||||
ng-model="$ctrl.newPDA"
|
|
||||||
url="DeviceProductions"
|
|
||||||
fields="['id', 'modelFk', 'serialNumber']"
|
|
||||||
where="{'stateFk': 'idle'}"
|
|
||||||
label="New PDA"
|
|
||||||
order="id"
|
|
||||||
value-field="id"
|
|
||||||
show-field="serialNumber">
|
|
||||||
<tpl-item>
|
|
||||||
<div>
|
|
||||||
ID: {{id}}
|
|
||||||
</div>
|
|
||||||
<div class="text-caption text-grey">
|
|
||||||
{{modelFk}}, {{serialNumber}}
|
|
||||||
</div>
|
|
||||||
</tpl-item>
|
|
||||||
</vn-autocomplete>
|
|
||||||
</vn-horizontal>
|
|
||||||
</vn-card>
|
|
||||||
<vn-button-bar>
|
|
||||||
<vn-submit
|
|
||||||
disabled="!$ctrl.newPDA"
|
|
||||||
label="Assign">
|
|
||||||
</vn-submit>
|
|
||||||
</vn-button-bar>
|
|
||||||
</form>
|
|
|
@ -1,53 +1,18 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
import './style.scss';
|
|
||||||
|
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
const filter = {
|
|
||||||
where: {userFk: this.$params.id},
|
|
||||||
include: {relation: 'deviceProduction'}
|
|
||||||
};
|
|
||||||
this.$http.get('DeviceProductionUsers', {filter}).
|
|
||||||
then(res => {
|
|
||||||
if (res.data && res.data.length > 0)
|
|
||||||
this.setCurrentPDA(res.data[0]);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deallocatePDA() {
|
async $onInit() {
|
||||||
this.$http.post(`Workers/${this.$params.id}/deallocatePDA`, {pda: this.currentPDA.deviceProductionFk})
|
const url = await this.vnApp.getUrl(`worker/${this.$params.id}/pda`);
|
||||||
.then(() => {
|
this.$state.go('worker.card.summary', {id: this.$params.id});
|
||||||
this.vnApp.showSuccess(this.$t('PDA deallocated'));
|
window.location.href = url;
|
||||||
delete this.currentPDA;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
allocatePDA() {
|
|
||||||
this.$http.post(`Workers/${this.$params.id}/allocatePDA`, {pda: this.newPDA})
|
|
||||||
.then(res => {
|
|
||||||
if (res.data)
|
|
||||||
this.setCurrentPDA(res.data);
|
|
||||||
|
|
||||||
this.vnApp.showSuccess(this.$t('PDA allocated'));
|
|
||||||
delete this.newPDA;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setCurrentPDA(data) {
|
|
||||||
this.currentPDA = data;
|
|
||||||
this.currentPDA.description = [];
|
|
||||||
this.currentPDA.description.push(`ID: ${this.currentPDA.deviceProductionFk}`);
|
|
||||||
this.currentPDA.description.push(`${this.$t('Model')}: ${this.currentPDA.deviceProduction.modelFk}`);
|
|
||||||
this.currentPDA.description.push(`${this.$t('Serial Number')}: ${this.currentPDA.deviceProduction.serialNumber}`);
|
|
||||||
this.currentPDA.description = this.currentPDA.description.join(' ');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$element', '$scope'];
|
|
||||||
|
|
||||||
ngModule.vnComponent('vnWorkerPda', {
|
ngModule.vnComponent('vnWorkerPda', {
|
||||||
template: require('./index.html'),
|
controller: Controller
|
||||||
controller: Controller,
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
import './index';
|
|
||||||
|
|
||||||
describe('Worker', () => {
|
|
||||||
describe('Component vnWorkerPda', () => {
|
|
||||||
let $httpBackend;
|
|
||||||
let $scope;
|
|
||||||
let $element;
|
|
||||||
let controller;
|
|
||||||
|
|
||||||
beforeEach(ngModule('worker'));
|
|
||||||
|
|
||||||
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
|
||||||
$httpBackend = _$httpBackend_;
|
|
||||||
$scope = $rootScope.$new();
|
|
||||||
$element = angular.element('<vn-worker-pda></vn-worker-pda>');
|
|
||||||
controller = $componentController('vnWorkerPda', {$element, $scope});
|
|
||||||
$httpBackend.expectGET(`DeviceProductionUsers`).respond();
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('deallocatePDA()', () => {
|
|
||||||
it('should make an HTTP Post query to deallocatePDA', () => {
|
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
||||||
controller.currentPDA = {deviceProductionFk: 1};
|
|
||||||
controller.$params.id = 1;
|
|
||||||
|
|
||||||
$httpBackend
|
|
||||||
.expectPOST(`Workers/${controller.$params.id}/deallocatePDA`,
|
|
||||||
{pda: controller.currentPDA.deviceProductionFk})
|
|
||||||
.respond();
|
|
||||||
controller.deallocatePDA();
|
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
|
||||||
expect(controller.currentPDA).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('allocatePDA()', () => {
|
|
||||||
it('should make an HTTP Post query to allocatePDA', () => {
|
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
||||||
controller.newPDA = 4;
|
|
||||||
controller.$params.id = 1;
|
|
||||||
|
|
||||||
$httpBackend
|
|
||||||
.expectPOST(`Workers/${controller.$params.id}/allocatePDA`,
|
|
||||||
{pda: controller.newPDA})
|
|
||||||
.respond();
|
|
||||||
controller.allocatePDA();
|
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
|
||||||
expect(controller.newPDA).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('setCurrentPDA()', () => {
|
|
||||||
it('should set CurrentPDA', () => {
|
|
||||||
const data = {
|
|
||||||
deviceProductionFk: 1,
|
|
||||||
deviceProduction: {
|
|
||||||
modelFk: 1,
|
|
||||||
serialNumber: 1
|
|
||||||
}
|
|
||||||
};
|
|
||||||
controller.setCurrentPDA(data);
|
|
||||||
|
|
||||||
expect(controller.currentPDA).toBeDefined();
|
|
||||||
expect(controller.currentPDA.description).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,6 +0,0 @@
|
||||||
@import "./variables";
|
|
||||||
|
|
||||||
.text-grey {
|
|
||||||
color: $color-font-light;
|
|
||||||
}
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ localFixtures:
|
||||||
- expeditionScan
|
- expeditionScan
|
||||||
- expeditionState
|
- expeditionState
|
||||||
- expeditionStateType
|
- expeditionStateType
|
||||||
- expeditionTruck
|
- roadmapStop
|
||||||
- expense
|
- expense
|
||||||
- genus
|
- genus
|
||||||
- greuge
|
- greuge
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "salix-back",
|
"name": "salix-back",
|
||||||
"version": "24.22.0",
|
"version": "24.24.0",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "Salix backend",
|
"description": "Salix backend",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
Loading…
Reference in New Issue