Merge branch 'dev' into 7296-expeditionTruckToRoadmapStop
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
3720f7acfe
|
@ -121,7 +121,7 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def packageJson = readJSON file: 'package.json'
|
def packageJson = readJSON file: 'package.json'
|
||||||
env.VERSION = packageJson.version
|
env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
|
||||||
}
|
}
|
||||||
sh 'docker-compose build back'
|
sh 'docker-compose build back'
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def packageJson = readJSON file: 'package.json'
|
def packageJson = readJSON file: 'package.json'
|
||||||
env.VERSION = packageJson.version
|
env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
|
||||||
}
|
}
|
||||||
sh 'gulp build'
|
sh 'gulp build'
|
||||||
sh 'docker-compose build front'
|
sh 'docker-compose build front'
|
||||||
|
@ -179,7 +179,7 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def packageJson = readJSON file: 'package.json'
|
def packageJson = readJSON file: 'package.json'
|
||||||
env.VERSION = packageJson.version
|
env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
|
||||||
}
|
}
|
||||||
sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY'
|
sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY'
|
||||||
sh 'docker-compose push'
|
sh 'docker-compose push'
|
||||||
|
@ -210,7 +210,7 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def packageJson = readJSON file: 'package.json'
|
def packageJson = readJSON file: 'package.json'
|
||||||
env.VERSION = packageJson.version
|
env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
|
||||||
}
|
}
|
||||||
withKubeConfig([
|
withKubeConfig([
|
||||||
serverUrl: "$KUBERNETES_API",
|
serverUrl: "$KUBERNETES_API",
|
||||||
|
|
|
@ -26,10 +26,11 @@
|
||||||
<mrw:Nif><%= expeditionData.fi %></mrw:Nif>
|
<mrw:Nif><%= expeditionData.fi %></mrw:Nif>
|
||||||
<mrw:Nombre><%= expeditionData.clientName %></mrw:Nombre>
|
<mrw:Nombre><%= expeditionData.clientName %></mrw:Nombre>
|
||||||
<mrw:Telefono><%= expeditionData.phone %></mrw:Telefono>
|
<mrw:Telefono><%= expeditionData.phone %></mrw:Telefono>
|
||||||
|
<mrw:Observaciones><%= expeditionData.deliveryObservation %></mrw:Observaciones>
|
||||||
</mrw:DatosEntrega>
|
</mrw:DatosEntrega>
|
||||||
<mrw:DatosServicio>
|
<mrw:DatosServicio>
|
||||||
<mrw:Fecha><%= expeditionData.created %></mrw:Fecha>
|
<mrw:Fecha><%= expeditionData.created %></mrw:Fecha>
|
||||||
<mrw:Referencia><%= expeditionData.expeditionDataId %></mrw:Referencia>
|
<mrw:Referencia><%= expeditionData.reference %></mrw:Referencia>
|
||||||
<mrw:CodigoServicio><%= expeditionData.serviceType %></mrw:CodigoServicio>
|
<mrw:CodigoServicio><%= expeditionData.serviceType %></mrw:CodigoServicio>
|
||||||
<mrw:NumeroBultos>1</mrw:NumeroBultos>
|
<mrw:NumeroBultos>1</mrw:NumeroBultos>
|
||||||
<mrw:EntregaSabado><%= expeditionData.weekDays %></mrw:EntregaSabado>
|
<mrw:EntregaSabado><%= expeditionData.weekDays %></mrw:EntregaSabado>
|
||||||
|
|
|
@ -45,7 +45,7 @@ module.exports = Self => {
|
||||||
`SELECT
|
`SELECT
|
||||||
CASE co.code
|
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, mc.portugalPostCodeTrim)
|
||||||
WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00')
|
WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00')
|
||||||
END postalCode,
|
END postalCode,
|
||||||
a.city,
|
a.city,
|
||||||
|
@ -56,9 +56,10 @@ module.exports = Self => {
|
||||||
c.phone,
|
c.phone,
|
||||||
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
|
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
|
||||||
t.shipped,
|
t.shipped,
|
||||||
e.id expeditionId,
|
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
|
||||||
LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), 4 ,'0') serviceType,
|
LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth,'0') serviceType,
|
||||||
IF(mw.weekdays, 'S', 'N') weekDays
|
IF(mw.weekdays, 'S', 'N') weekDays,
|
||||||
|
oa.description deliveryObservation
|
||||||
FROM expedition e
|
FROM expedition e
|
||||||
JOIN ticket t ON e.ticketFk = t.id
|
JOIN ticket t ON e.ticketFk = t.id
|
||||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||||
|
@ -66,8 +67,12 @@ module.exports = Self => {
|
||||||
LEFT JOIN mrwServiceWeekday mw ON mw.weekdays = DATE_FORMAT(t.shipped, '%a')
|
LEFT JOIN mrwServiceWeekday mw ON mw.weekdays = DATE_FORMAT(t.shipped, '%a')
|
||||||
JOIN client c ON t.clientFk = c.id
|
JOIN client c ON t.clientFk = c.id
|
||||||
JOIN address a ON t.addressFk = a.id
|
JOIN address a ON t.addressFk = a.id
|
||||||
|
LEFT JOIN addressObservation oa ON oa.addressFk = a.id
|
||||||
|
LEFT JOIN observationType ot ON ot.id = oa.observationTypeFk
|
||||||
|
AND ot.code = 'delivery'
|
||||||
JOIN province p ON a.provinceFk = p.id
|
JOIN province p ON a.provinceFk = p.id
|
||||||
JOIN country co ON co.id = p.countryFk
|
JOIN country co ON co.id = p.countryFk
|
||||||
|
JOIN mrwConfig mc
|
||||||
WHERE e.id = ?
|
WHERE e.id = ?
|
||||||
LIMIT 1`;
|
LIMIT 1`;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
{
|
{
|
||||||
"name": "Collection",
|
"name": "Collection",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"id": true,
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"workerFk": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "collection"
|
"table": "collection"
|
||||||
|
|
|
@ -762,7 +762,12 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF
|
||||||
(30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
(30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||||
(31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
(31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||||
(32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
(32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||||
(33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL);
|
(33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||||
|
(34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL),
|
||||||
|
(35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL),
|
||||||
|
(36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL),
|
||||||
|
(37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL);
|
||||||
|
|
||||||
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
|
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 11, 1, 'ready'),
|
(1, 11, 1, 'ready'),
|
||||||
|
@ -808,7 +813,10 @@ INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`)
|
||||||
(21, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
|
(21, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
|
||||||
(22, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
|
(22, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
|
||||||
(23, 16, 21, util.VN_NOW()),
|
(23, 16, 21, util.VN_NOW()),
|
||||||
(24, 16, 21, util.VN_NOW());
|
(24, 16, 21, util.VN_NOW()),
|
||||||
|
(34, 14, 49, util.VN_NOW()),
|
||||||
|
(35, 14, 18, util.VN_NOW()),
|
||||||
|
(36, 14, 18, util.VN_NOW());
|
||||||
|
|
||||||
INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`)
|
INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -1068,7 +1076,10 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
|
||||||
(37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
(37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||||
(36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
(36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||||
(38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
|
(38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
|
||||||
(39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE());
|
(39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()),
|
||||||
|
(40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE()),
|
||||||
|
(41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE()),
|
||||||
|
(42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE());
|
||||||
|
|
||||||
INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
|
INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -1247,14 +1258,20 @@ INSERT INTO `vn`.`operator` (`workerFk`, `numberOfWagons`, `trainFk`, `itemPacki
|
||||||
INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`)
|
INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1106, 5, DATE_ADD(util.VN_CURDATE(),INTERVAL +1 DAY), 1),
|
(1, 1106, 5, DATE_ADD(util.VN_CURDATE(),INTERVAL +1 DAY), 1),
|
||||||
(2, 1106, 14, util.VN_CURDATE(), 1);
|
(2, 1106, 14, util.VN_CURDATE(), 1),
|
||||||
|
(4, 49, 5, util.VN_CURDATE(), 1),
|
||||||
|
(5, 18, 5, util.VN_CURDATE(), 1),
|
||||||
|
(6, 18, 5, util.VN_CURDATE(), 1);
|
||||||
|
|
||||||
INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`)
|
INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 1),
|
(1, 1, 1),
|
||||||
(2, 1, NULL),
|
(2, 1, NULL),
|
||||||
(3, 2, NULL),
|
(3, 2, NULL),
|
||||||
(23, 1, NULL);
|
(23, 1, NULL),
|
||||||
|
(34, 4, 1),
|
||||||
|
(35, 5, 1),
|
||||||
|
(8, 6, 1);
|
||||||
|
|
||||||
INSERT INTO `vn`.`genus`(`id`, `name`)
|
INSERT INTO `vn`.`genus`(`id`, `name`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -3705,7 +3722,8 @@ INSERT IGNORE INTO vn.saleGroup
|
||||||
SET id = 4,
|
SET id = 4,
|
||||||
userFk = 1,
|
userFk = 1,
|
||||||
parkingFk = 9,
|
parkingFk = 9,
|
||||||
sectorFk = 9992;
|
sectorFk = 9992,
|
||||||
|
ticketFk = 36;
|
||||||
|
|
||||||
INSERT IGNORE INTO vn.sectorCollectionSaleGroup
|
INSERT IGNORE INTO vn.sectorCollectionSaleGroup
|
||||||
SET id = 9999,
|
SET id = 9999,
|
||||||
|
@ -3807,3 +3825,27 @@ INSERT INTO `vn`.`ledgerCompany` SET
|
||||||
|
|
||||||
INSERT INTO `vn`.`ledgerConfig` SET
|
INSERT INTO `vn`.`ledgerConfig` SET
|
||||||
maxTolerance = 0.01;
|
maxTolerance = 0.01;
|
||||||
|
|
||||||
|
INSERT INTO vn.sectorCollection
|
||||||
|
SET id = 2,
|
||||||
|
userFk = 18,
|
||||||
|
sectorFk = 1;
|
||||||
|
|
||||||
|
INSERT INTO vn.sectorCollectionSaleGroup
|
||||||
|
SET id = 8,
|
||||||
|
sectorCollectionFk = 2,
|
||||||
|
saleGroupFk = 4;
|
||||||
|
|
||||||
|
INSERT INTO vn.saleGroup (userFk, parkingFk, sectorFk, ticketFk)
|
||||||
|
VALUES
|
||||||
|
(1, 1, 1, 37);
|
||||||
|
|
||||||
|
INSERT INTO vn.sectorCollection
|
||||||
|
SET id = 3,
|
||||||
|
userFk = 18,
|
||||||
|
sectorFk = 1;
|
||||||
|
|
||||||
|
INSERT INTO vn.sectorCollectionSaleGroup
|
||||||
|
SET id = 9,
|
||||||
|
sectorCollectionFk = 3,
|
||||||
|
saleGroupFk = 6;
|
|
@ -11,10 +11,7 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vClient INT DEFAULT NULL;
|
DECLARE vClient INT DEFAULT NULL;
|
||||||
|
|
||||||
-- SET vPhone = vPhone COLLATE 'utf8_unicode_ci';
|
CREATE OR REPLACE TEMPORARY TABLE tClient
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tClient;
|
|
||||||
CREATE TEMPORARY TABLE tClient
|
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT id clientFk
|
SELECT id clientFk
|
||||||
FROM `client`
|
FROM `client`
|
||||||
|
@ -27,13 +24,14 @@ BEGIN
|
||||||
OR mobile = vPhone
|
OR mobile = vPhone
|
||||||
UNION
|
UNION
|
||||||
SELECT clientFk
|
SELECT clientFk
|
||||||
FROM vn.clientContact
|
FROM clientContact
|
||||||
WHERE phone = vPhone;
|
WHERE phone = vPhone;
|
||||||
|
|
||||||
SELECT t.clientFk INTO vClient
|
SELECT t.clientFk INTO vClient
|
||||||
FROM tClient t
|
FROM tClient t
|
||||||
JOIN `client` c ON c.id = t.clientFk
|
JOIN `client` c ON c.id = t.clientFk
|
||||||
WHERE c.isActive
|
WHERE c.isActive
|
||||||
|
AND c.salesPersonFk
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tClient;
|
DROP TEMPORARY TABLE tClient;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE vn.item ADD COLUMN photoMotivation VARCHAR(255);
|
|
@ -0,0 +1,46 @@
|
||||||
|
use account;
|
||||||
|
|
||||||
|
INSERT INTO role
|
||||||
|
SET name = 'reviewer',
|
||||||
|
description = 'Revisor de producción',
|
||||||
|
hasLogin = TRUE,
|
||||||
|
created = util.VN_CURDATE(),
|
||||||
|
modified = util.VN_CURDATE(),
|
||||||
|
editorFk = NULL;
|
||||||
|
|
||||||
|
INSERT INTO roleInherit(
|
||||||
|
role,
|
||||||
|
inheritsFrom
|
||||||
|
)
|
||||||
|
SELECT r1.id,
|
||||||
|
r2.id
|
||||||
|
FROM role r1
|
||||||
|
JOIN role r2
|
||||||
|
WHERE r1.name = 'reviewer'
|
||||||
|
AND r2.name = 'production'
|
||||||
|
UNION
|
||||||
|
SELECT ri.role,
|
||||||
|
r2.id
|
||||||
|
FROM roleInherit ri
|
||||||
|
JOIN role r1 ON r1.id = ri.role
|
||||||
|
JOIN role r2 ON r2.name = 'reviewer'
|
||||||
|
WHERE r1.name IN ('claimManager', 'productionBoss')
|
||||||
|
GROUP BY ri.role;
|
||||||
|
|
||||||
|
DELETE ri
|
||||||
|
FROM roleInherit ri
|
||||||
|
JOIN role r1 ON ri.role = r1.id
|
||||||
|
JOIN role r2 ON ri.inheritsFrom = r2.id
|
||||||
|
WHERE r1.name = 'replenisher'
|
||||||
|
AND r2.name = 'buyer';
|
||||||
|
|
||||||
|
UPDATE salix.ACL
|
||||||
|
SET principalId = 'reviewer'
|
||||||
|
WHERE property = 'isInPreparing';
|
||||||
|
|
||||||
|
UPDATE user u
|
||||||
|
JOIN vn.workerDepartment wd ON wd.workerFk = u.id
|
||||||
|
JOIN vn.department d ON wd.departmentFk = d.id
|
||||||
|
JOIN role r ON r.name = 'reviewer'
|
||||||
|
SET u.role = r.id
|
||||||
|
WHERE d.name IN ('REVISION', 'PREVIA');
|
|
@ -0,0 +1,3 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS expeditionDeadLine TIME NULL
|
||||||
|
COMMENT 'This field stores the latest time by which expeditions can be generated to be sent today';
|
|
@ -0,0 +1,9 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS counterWidth INT UNSIGNED NULL
|
||||||
|
COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.';
|
||||||
|
|
||||||
|
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS serviceTypeWidth INT UNSIGNED NULL
|
||||||
|
COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.';
|
||||||
|
|
||||||
|
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS portugalPostCodeTrim INT UNSIGNED NULL
|
||||||
|
COMMENT 'It will trim the last characters of the postal code';
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('Ticket','refund','WRITE','ALLOW','ROLE','logistic');
|
|
@ -225,7 +225,7 @@ describe('Ticket Edit sale path', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show error trying to delete a ticket with a refund', async() => {
|
it('should show error trying to delete a ticket with a refund', async() => {
|
||||||
await page.loginAndModule('production', 'ticket');
|
await page.loginAndModule('salesPerson', 'ticket');
|
||||||
await page.accessToSearchResult('8');
|
await page.accessToSearchResult('8');
|
||||||
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
|
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
|
||||||
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket);
|
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket);
|
||||||
|
|
|
@ -164,6 +164,7 @@ export default class UploadPhoto extends Component {
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
type: 'blob',
|
type: 'blob',
|
||||||
|
size: 'original'
|
||||||
};
|
};
|
||||||
return this.editor.result(options)
|
return this.editor.result(options)
|
||||||
.then(blob => this.newPhoto.blob = blob)
|
.then(blob => this.newPhoto.blob = blob)
|
||||||
|
|
|
@ -61,7 +61,8 @@
|
||||||
"Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
"Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
"Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})",
|
"Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
"Changed sale quantity": "I have changed the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}* of the ticket [{{ticketId}}]({{{ticketUrl}}})",
|
"Changed sale quantity": "I have changed {{changes}} of the ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
|
"Changes in sales": "the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}*",
|
||||||
"Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
"Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})",
|
"Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})",
|
||||||
"MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*",
|
"MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*",
|
||||||
|
|
|
@ -124,7 +124,8 @@
|
||||||
"Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
"Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
"Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})",
|
"Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
"Changed sale quantity": "He cambiado la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* del ticket [{{ticketId}}]({{{ticketUrl}}})",
|
"Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
|
"Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*",
|
||||||
"State": "Estado",
|
"State": "Estado",
|
||||||
"regular": "normal",
|
"regular": "normal",
|
||||||
"reserved": "reservado",
|
"reserved": "reservado",
|
||||||
|
@ -358,8 +359,8 @@
|
||||||
"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",
|
||||||
"ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)",
|
"ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)",
|
||||||
"This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario",
|
"This PDA is already assigned to another user": "Esta PDA ya está asignado a otro usuario",
|
||||||
"You can only have one PDA": "Solo puedes tener un PDA",
|
"You can only have one PDA": "Solo puedes tener una PDA",
|
||||||
"Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE",
|
"Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE",
|
||||||
"You can not use the same password": "No puedes usar la misma contraseña"
|
"You can not use the same password": "No puedes usar la misma contraseña"
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,8 +123,9 @@
|
||||||
"Added sale to ticket": "J'ai ajouté la ligne suivante au ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}",
|
"Added sale to ticket": "J'ai ajouté la ligne suivante au ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}",
|
||||||
"Changed sale discount": "J'ai changé le rabais des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
"Changed sale discount": "J'ai changé le rabais des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Created claim": "J'ai créé la réclamation [{{claimId}}]({{{claimUrl}}}) des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
"Created claim": "J'ai créé la réclamation [{{claimId}}]({{{claimUrl}}}) des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Changed sale price": "J'ai changé le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})",
|
"Changed sale price": " le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})",,
|
||||||
"Changed sale quantity": "J'ai changé la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}} du ticket [{{ticketId}}]({{{ticketUrl}}})",
|
"Changed sale quantity": "J'ai changé {{changes}} du ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
|
"Changes in sales": "la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}}",
|
||||||
"State": "État",
|
"State": "État",
|
||||||
"regular": "normal",
|
"regular": "normal",
|
||||||
"reserved": "réservé",
|
"reserved": "réservé",
|
||||||
|
@ -357,4 +358,4 @@
|
||||||
"This workCenter is already assigned to this agency": "Ce centre de travail est déjà assigné à cette agence",
|
"This workCenter is already assigned to this agency": "Ce centre de travail est déjà assigné à cette agence",
|
||||||
"Select ticket or client": "Choisissez un ticket ou un client",
|
"Select ticket or client": "Choisissez un ticket ou un client",
|
||||||
"It was not able to create the invoice": "Il n'a pas été possible de créer la facture"
|
"It was not able to create the invoice": "Il n'a pas été possible de créer la facture"
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,8 @@
|
||||||
"Changed sale discount": "Desconto da venda alterado no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
"Changed sale discount": "Desconto da venda alterado no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Created claim": "Reclamação criada [{{claimId}}]({{{claimUrl}}}) no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
"Created claim": "Reclamação criada [{{claimId}}]({{{claimUrl}}}) no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Changed sale price": "Preço da venda alterado para [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* no ticket [{{ticketId}}]({{{ticketUrl}}})",
|
"Changed sale price": "Preço da venda alterado para [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* no ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
"Changed sale quantity": "Quantidade da venda alterada para [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* no ticket [{{ticketId}}]({{{ticketUrl}}})",
|
"Changed sale quantity": "Quantidade da venda alterada para {{changes}} no ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
|
"Changes in sales": " [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* ",
|
||||||
"State": "Estado",
|
"State": "Estado",
|
||||||
"regular": "normal",
|
"regular": "normal",
|
||||||
"reserved": "reservado",
|
"reserved": "reservado",
|
||||||
|
@ -357,4 +358,4 @@
|
||||||
"This workCenter is already assigned to this agency": "Este centro de trabalho já está atribuído a esta agência",
|
"This workCenter is already assigned to this agency": "Este centro de trabalho já está atribuído a esta agência",
|
||||||
"Select ticket or client": "Selecione um ticket ou cliente",
|
"Select ticket or client": "Selecione um ticket ou cliente",
|
||||||
"It was not able to create the invoice": "Não foi possível criar a fatura"
|
"It was not able to create the invoice": "Não foi possível criar a fatura"
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,8 +85,12 @@ exports.translateValues = async(instance, changes, options = {}) => {
|
||||||
exports.getChanges = (original, changes) => {
|
exports.getChanges = (original, changes) => {
|
||||||
const oldChanges = {};
|
const oldChanges = {};
|
||||||
const newChanges = {};
|
const newChanges = {};
|
||||||
|
const dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
||||||
|
|
||||||
for (let property in changes) {
|
for (let property in changes) {
|
||||||
|
if (dateRegex.test(original[property]))
|
||||||
|
original[property] = new Date(Date.parse(original[property]));
|
||||||
|
|
||||||
const firstChar = property.substring(0, 1);
|
const firstChar = property.substring(0, 1);
|
||||||
const isPrivate = firstChar == '$';
|
const isPrivate = firstChar == '$';
|
||||||
if (isPrivate) return;
|
if (isPrivate) return;
|
||||||
|
|
|
@ -6,6 +6,7 @@ describe('claimBeginning', () => {
|
||||||
const claimManagerId = 72;
|
const claimManagerId = 72;
|
||||||
const activeCtx = {
|
const activeCtx = {
|
||||||
accessToken: {userId: claimManagerId},
|
accessToken: {userId: claimManagerId},
|
||||||
|
__: value => value
|
||||||
};
|
};
|
||||||
const ctx = {req: activeCtx};
|
const ctx = {req: activeCtx};
|
||||||
|
|
||||||
|
|
|
@ -88,15 +88,17 @@ module.exports = Self => {
|
||||||
const updatedClaim = await claim.updateAttributes(args, myOptions);
|
const updatedClaim = await claim.updateAttributes(args, myOptions);
|
||||||
|
|
||||||
// When pickup has been changed
|
// When pickup has been changed
|
||||||
if (salesPerson && changedPickup && updatedClaim.pickup)
|
if (salesPerson) {
|
||||||
await notifyPickUp(ctx, salesPerson.id, claim);
|
if (changedPickup && updatedClaim.pickup)
|
||||||
|
await notifyPickUp(ctx, salesPerson.id, claim);
|
||||||
|
|
||||||
// When claimState has been changed
|
// When claimState has been changed
|
||||||
if (args.claimStateFk) {
|
if (args.claimStateFk) {
|
||||||
const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions);
|
const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions);
|
||||||
await notifyStateChange(ctx, salesPerson.id, claim, newState.description);
|
await notifyStateChange(ctx, salesPerson.id, claim, newState.description);
|
||||||
if (newState.code == 'canceled')
|
if (newState.code == 'canceled')
|
||||||
await notifyStateChange(ctx, claim.workerFk, claim, newState.description);
|
await notifyStateChange(ctx, claim.workerFk, claim, newState.description);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
|
@ -22,5 +22,8 @@
|
||||||
},
|
},
|
||||||
"EntryObservation": {
|
"EntryObservation": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"EntryType": {
|
||||||
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
"name": "EntryType",
|
||||||
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "entryType"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"code": {
|
||||||
|
"type": "string",
|
||||||
|
"id": true,
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"isInformal": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,9 +35,9 @@
|
||||||
},
|
},
|
||||||
"isVirtual": {
|
"isVirtual": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"columnName": "isRaid"
|
"columnName": "isRaid"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"isRaid": {
|
"isRaid": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
@ -53,9 +53,9 @@
|
||||||
},
|
},
|
||||||
"observation": {
|
"observation": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"columnName": "evaNotes"
|
"columnName": "evaNotes"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"loadPriority": {
|
"loadPriority": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
@ -101,6 +101,11 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Account",
|
"model": "Account",
|
||||||
"foreignKey": "observationEditorFk"
|
"foreignKey": "observationEditorFk"
|
||||||
|
},
|
||||||
|
"entryType": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "EntryType",
|
||||||
|
"foreignKey": "typeFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -54,6 +54,20 @@ module.exports = Self => {
|
||||||
value: rate
|
value: rate
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const monday = 1;
|
||||||
|
if (xmlDateWithoutTime.getDay() === monday) {
|
||||||
|
const saturday = new Date(xmlDateWithoutTime);
|
||||||
|
saturday.setDate(xmlDateWithoutTime.getDate() - 2);
|
||||||
|
const sunday = new Date(xmlDateWithoutTime);
|
||||||
|
sunday.setDate(xmlDateWithoutTime.getDate() - 1);
|
||||||
|
|
||||||
|
for (const date of [saturday, sunday]) {
|
||||||
|
await models.ReferenceRate.upsertWithWhere(
|
||||||
|
{currencyFk: currency.id, dated: date},
|
||||||
|
{currencyFk: currency.id, dated: date, value: rate}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ module.exports = Self => {
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
arg: 'barcode',
|
arg: 'barcode',
|
||||||
type: 'number',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'barcode'
|
description: 'barcode'
|
||||||
}],
|
}],
|
||||||
|
@ -18,7 +18,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.toItem = async(barcode, options) => {
|
Self.toItem = async (barcode, options) => {
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
|
|
|
@ -64,7 +64,7 @@ describe('item getBalance()', () => {
|
||||||
const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options);
|
const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options);
|
||||||
|
|
||||||
expect(firstItemBalance[9].claimFk).toEqual(null);
|
expect(firstItemBalance[9].claimFk).toEqual(null);
|
||||||
expect(secondItemBalance[4].claimFk).toEqual(2);
|
expect(secondItemBalance[7].claimFk).toEqual(2);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -155,6 +155,9 @@
|
||||||
"minQuantity": {
|
"minQuantity": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"description": "Min quantity"
|
"description": "Min quantity"
|
||||||
|
},
|
||||||
|
"photoMotivation": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -151,7 +151,7 @@ describe('SalesMonitor salesFilter()', () => {
|
||||||
const result = await models.SalesMonitor.salesFilter(ctx, filter, options);
|
const result = await models.SalesMonitor.salesFilter(ctx, filter, options);
|
||||||
const firstRow = result[0];
|
const firstRow = result[0];
|
||||||
|
|
||||||
expect(result.length).toEqual(12);
|
expect(result.length).toEqual(15);
|
||||||
expect(firstRow.alertLevel).not.toEqual(0);
|
expect(firstRow.alertLevel).not.toEqual(0);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
"Sector": {
|
"Sector": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"SectorCollection": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"SectorCollectionSaleGroup": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"Train": {
|
"Train": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"name": "SectorCollection",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "sectorCollection"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true
|
||||||
|
},
|
||||||
|
"created": {
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
"userFk": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"sectorFk": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "SectorCollectionSaleGroup",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "sectorCollectionSaleGroup"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true
|
||||||
|
},
|
||||||
|
"created": {
|
||||||
|
"type": "date"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"sectorCollection": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "SectorCollection",
|
||||||
|
"foreignKey": "sectorCollectionFk"
|
||||||
|
},
|
||||||
|
"saleGroup": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "SaleGroup",
|
||||||
|
"foreignKey": "saleGroupFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,7 +33,7 @@ module.exports = Self => {
|
||||||
JOIN vn.item i ON i.id = b.itemFk
|
JOIN vn.item i ON i.id = b.itemFk
|
||||||
WHERE e.id = ? AND e.supplierFk = ?
|
WHERE e.id = ? AND e.supplierFk = ?
|
||||||
GROUP BY i.id
|
GROUP BY i.id
|
||||||
) SELECT i.id, i.name, et.quantity, SUM(b.quantity) quantityTotal, et.printedStickers
|
) SELECT i.id, i.name, et.quantity, SUM(b.quantity) quantityTotal, et.printedStickers, ic.url
|
||||||
FROM vn.buy b
|
FROM vn.buy b
|
||||||
JOIN vn.item i ON i.id = b.itemFk
|
JOIN vn.item i ON i.id = b.itemFk
|
||||||
JOIN vn.entry e ON e.id = b.entryFk
|
JOIN vn.entry e ON e.id = b.entryFk
|
||||||
|
@ -41,6 +41,7 @@ module.exports = Self => {
|
||||||
JOIN vn.buyConfig bc ON bc.monthsAgo
|
JOIN vn.buyConfig bc ON bc.monthsAgo
|
||||||
JOIN vn.travel t ON t.id = e.travelFk
|
JOIN vn.travel t ON t.id = e.travelFk
|
||||||
LEFT JOIN entryTmp et ON et.id = i.id
|
LEFT JOIN entryTmp et ON et.id = i.id
|
||||||
|
JOIN hedera.imageConfig ic
|
||||||
WHERE e.supplierFk = ?
|
WHERE e.supplierFk = ?
|
||||||
AND i.family IN ('EMB', 'CONT')
|
AND i.family IN ('EMB', 'CONT')
|
||||||
AND b.created > (util.VN_CURDATE() - INTERVAL bc.monthsAgo MONTH)
|
AND b.created > (util.VN_CURDATE() - INTERVAL bc.monthsAgo MONTH)
|
||||||
|
|
|
@ -2,10 +2,12 @@ const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('ticket setDelivered()', () => {
|
describe('ticket setDelivered()', () => {
|
||||||
const userId = 50;
|
const userId = 49;
|
||||||
const activeCtx = {
|
const activeCtx = {
|
||||||
accessToken: {userId: userId},
|
accessToken: {userId: userId},
|
||||||
|
__: value => value
|
||||||
};
|
};
|
||||||
|
const ctx = {req: activeCtx};
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
@ -19,8 +21,6 @@ describe('ticket setDelivered()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 49}}};
|
|
||||||
|
|
||||||
const originalTicketOne = await models.Ticket.findById(8, null, options);
|
const originalTicketOne = await models.Ticket.findById(8, null, options);
|
||||||
const originalTicketTwo = await models.Ticket.findById(10, null, options);
|
const originalTicketTwo = await models.Ticket.findById(10, null, options);
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ module.exports = Self => {
|
||||||
http: {source: 'path'}
|
http: {source: 'path'}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'itemId',
|
arg: 'barcode',
|
||||||
type: 'number',
|
type: 'any',
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.addSale = async(ctx, id, itemId, quantity, options) => {
|
Self.addSale = async(ctx, id, barcode, quantity, options) => {
|
||||||
const $t = ctx.req.__; // $translate
|
const $t = ctx.req.__; // $translate
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||||
|
@ -46,7 +46,9 @@ module.exports = Self => {
|
||||||
try {
|
try {
|
||||||
await models.Ticket.isEditableOrThrow(ctx, id, myOptions);
|
await models.Ticket.isEditableOrThrow(ctx, id, myOptions);
|
||||||
|
|
||||||
|
const itemId = await models.ItemBarcode.toItem(barcode, myOptions);
|
||||||
const item = await models.Item.findById(itemId, null, myOptions);
|
const item = await models.Item.findById(itemId, null, myOptions);
|
||||||
|
|
||||||
const ticket = await models.Ticket.findById(id, {
|
const ticket = await models.Ticket.findById(id, {
|
||||||
include: {
|
include: {
|
||||||
relation: 'client',
|
relation: 'client',
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
|
||||||
module.exports = Self => {
|
|
||||||
Self.remoteMethodCtx('addSaleByCode', {
|
|
||||||
description: 'Add a collection',
|
|
||||||
accessType: 'WRITE',
|
|
||||||
accepts: [
|
|
||||||
{
|
|
||||||
arg: 'barcode',
|
|
||||||
type: 'string',
|
|
||||||
required: true
|
|
||||||
}, {
|
|
||||||
arg: 'quantity',
|
|
||||||
type: 'number',
|
|
||||||
required: true
|
|
||||||
}, {
|
|
||||||
arg: 'ticketFk',
|
|
||||||
type: 'number',
|
|
||||||
required: true
|
|
||||||
}, {
|
|
||||||
arg: 'warehouseFk',
|
|
||||||
type: 'number',
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
|
|
||||||
],
|
|
||||||
http: {
|
|
||||||
path: `/addSaleByCode`,
|
|
||||||
verb: 'POST'
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.addSaleByCode = async(ctx, barcode, quantity, ticketFk, warehouseFk, options) => {
|
|
||||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
|
||||||
let tx;
|
|
||||||
|
|
||||||
if (typeof options == 'object')
|
|
||||||
Object.assign(myOptions, options);
|
|
||||||
|
|
||||||
if (!myOptions.transaction) {
|
|
||||||
tx = await Self.beginTransaction({});
|
|
||||||
myOptions.transaction = tx;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const [[item]] = await Self.rawSql('CALL vn.item_getInfo(?,?)', [barcode, warehouseFk], myOptions);
|
|
||||||
if (!item?.available) throw new UserError('We do not have availability for the selected item');
|
|
||||||
|
|
||||||
await Self.rawSql('CALL vn.collection_addItem(?, ?, ?)', [item.id, quantity, ticketFk], myOptions);
|
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
|
||||||
} catch (e) {
|
|
||||||
if (tx) await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -8,18 +8,13 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const state = await models.TicketState.findOne({
|
const state = await models.TicketState.findOne({where: {ticketFk: id}}, myOptions);
|
||||||
where: {ticketFk: id}
|
|
||||||
}, myOptions);
|
|
||||||
|
|
||||||
const isRoleAdvanced = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*');
|
const isRoleAdvanced = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*');
|
||||||
|
const isProductionReviewer = await models.ACL.checkAccessAcl(ctx, 'Sale', 'isInPreparing', '*');
|
||||||
const canEditWeeklyTicket = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'canEditWeekly', 'WRITE');
|
const canEditWeeklyTicket = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'canEditWeekly', 'WRITE');
|
||||||
const alertLevel = state ? state.alertLevel : null;
|
const alertLevel = state ? state.alertLevel : null;
|
||||||
const ticket = await models.Ticket.findById(id, {
|
const ticket = await models.Ticket.findById(id, {
|
||||||
fields: ['clientFk'],
|
fields: ['clientFk'], include: {relation: 'client'}
|
||||||
include: {
|
|
||||||
relation: 'client'
|
|
||||||
}
|
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const isLocked = await models.Ticket.isLocked(id, myOptions);
|
const isLocked = await models.Ticket.isLocked(id, myOptions);
|
||||||
|
@ -29,10 +24,24 @@ module.exports = Self => {
|
||||||
const isNormalClient = ticket && ticket.client().typeFk == 'normal';
|
const isNormalClient = ticket && ticket.client().typeFk == 'normal';
|
||||||
const isEditable = !(alertLevelGreaterThanZero && isNormalClient);
|
const isEditable = !(alertLevelGreaterThanZero && isNormalClient);
|
||||||
|
|
||||||
|
const ticketCollection = await models.TicketCollection.findOne({
|
||||||
|
include: {relation: 'collection'}, where: {ticketFk: id}
|
||||||
|
}, myOptions);
|
||||||
|
let isOwner = ticketCollection?.collection()?.workerFk === ctx.req.accessToken.userId;
|
||||||
|
|
||||||
|
if (!isOwner) {
|
||||||
|
const saleGroup = await models.SaleGroup.findOne({fields: ['id'], where: {ticketFk: id}}, myOptions);
|
||||||
|
const sectorCollectionSaleGroup = saleGroup && await models.SectorCollectionSaleGroup.findOne({
|
||||||
|
include: {relation: 'sectorCollection'}, where: {saleGroupFk: saleGroup.id}
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
|
isOwner = sectorCollectionSaleGroup?.sectorCollection()?.userFk === ctx.req.accessToken.userId;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ticket)
|
if (!ticket)
|
||||||
throw new ForbiddenError(`The ticket doesn't exist.`);
|
throw new ForbiddenError(`The ticket doesn't exist.`);
|
||||||
|
|
||||||
if (!isEditable && !isRoleAdvanced)
|
if (!isEditable && !isRoleAdvanced && !isProductionReviewer && !isOwner)
|
||||||
throw new ForbiddenError(`This ticket is not editable.`);
|
throw new ForbiddenError(`This ticket is not editable.`);
|
||||||
|
|
||||||
if (isLocked && !isWeekly)
|
if (isLocked && !isWeekly)
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Ticket addSaleByCode()', () => {
|
|
||||||
const quantity = 3;
|
|
||||||
const ticketFk = 13;
|
|
||||||
const warehouseFk = 1;
|
|
||||||
beforeAll(async() => {
|
|
||||||
activeCtx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'},
|
|
||||||
__: value => value
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should add a new sale', async() => {
|
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = {transaction: tx};
|
|
||||||
const code = '1111111111';
|
|
||||||
|
|
||||||
const salesBefore = await models.Sale.find(null, options);
|
|
||||||
await models.Ticket.addSaleByCode(activeCtx, code, quantity, ticketFk, warehouseFk, options);
|
|
||||||
const salesAfter = await models.Sale.find(null, options);
|
|
||||||
|
|
||||||
expect(salesAfter.length).toEqual(salesBefore.length + 1);
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -68,7 +68,7 @@ describe('ticket filter()', () => {
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const result = await models.Ticket.filter(ctx, filter, options);
|
const result = await models.Ticket.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(7);
|
expect(result.length).toEqual(10);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ describe('sale priceDifference()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 1106}}};
|
const ctx = {req: {accessToken: {userId: 1105}}};
|
||||||
ctx.args = {
|
ctx.args = {
|
||||||
id: 1,
|
id: 1,
|
||||||
landed: Date.vnNew(),
|
landed: Date.vnNew(),
|
||||||
|
@ -84,7 +84,7 @@ describe('sale priceDifference()', () => {
|
||||||
|
|
||||||
const {items} = await models.Ticket.priceDifference(ctx, options);
|
const {items} = await models.Ticket.priceDifference(ctx, options);
|
||||||
|
|
||||||
expect(items[0].movable).toEqual(410);
|
expect(items[0].movable).toEqual(386);
|
||||||
expect(items[1].movable).toEqual(1810);
|
expect(items[1].movable).toEqual(1810);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
|
@ -7,6 +7,7 @@ describe('ticket state()', () => {
|
||||||
const productionId = 49;
|
const productionId = 49;
|
||||||
const activeCtx = {
|
const activeCtx = {
|
||||||
accessToken: {userId: 9},
|
accessToken: {userId: 9},
|
||||||
|
__: value => value
|
||||||
};
|
};
|
||||||
const ctx = {req: activeCtx};
|
const ctx = {req: activeCtx};
|
||||||
const now = Date.vnNew();
|
const now = Date.vnNew();
|
||||||
|
@ -88,7 +89,8 @@ describe('ticket state()', () => {
|
||||||
const ticket = await models.Ticket.create(sampleTicket, options);
|
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||||
|
|
||||||
activeCtx.accessToken.userId = productionId;
|
activeCtx.accessToken.userId = productionId;
|
||||||
const params = {ticketFk: ticket.id, stateFk: 3};
|
const stateOk = await models.State.findOne({where: {code: 'OK'}}, options);
|
||||||
|
const params = {ticketFk: ticket.id, stateFk: stateOk.id};
|
||||||
|
|
||||||
const ticketTracking = await models.Ticket.state(ctx, params, options);
|
const ticketTracking = await models.Ticket.state(ctx, params, options);
|
||||||
|
|
||||||
|
@ -112,16 +114,68 @@ describe('ticket state()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ticket = await models.Ticket.create(sampleTicket, options);
|
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||||
const ctx = {req: {accessToken: {userId: 18}}};
|
activeCtx.accessToken.userId = salesPersonId;
|
||||||
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
||||||
const params = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1};
|
const paramsAssigned = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1};
|
||||||
const res = await models.Ticket.state(ctx, params, options);
|
const resAssigned = await models.Ticket.state(ctx, paramsAssigned, options);
|
||||||
|
|
||||||
expect(res.ticketFk).toBe(params.ticketFk);
|
expect(resAssigned.ticketFk).toBe(paramsAssigned.ticketFk);
|
||||||
expect(res.stateFk).toBe(params.stateFk);
|
expect(resAssigned.stateFk).toBe(paramsAssigned.stateFk);
|
||||||
expect(res.userFk).toBe(params.userFk);
|
expect(resAssigned.userFk).toBe(paramsAssigned.userFk);
|
||||||
expect(res.userFk).toBe(1);
|
expect(resAssigned.userFk).toBe(1);
|
||||||
expect(res.id).toBeDefined();
|
expect(resAssigned.id).toBeDefined();
|
||||||
|
|
||||||
|
activeCtx.accessToken.userId = productionId;
|
||||||
|
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
||||||
|
const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId};
|
||||||
|
const resPacked = await models.Ticket.state(ctx, paramsPacked, options);
|
||||||
|
|
||||||
|
expect(resPacked.stateFk).toBe(paramsPacked.stateFk);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should equalize the quantities of quantity and originalQuantity' +
|
||||||
|
' if they are different', async() => {
|
||||||
|
const tx = await models.TicketTracking.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||||
|
activeCtx.accessToken.userId = salesPersonId;
|
||||||
|
|
||||||
|
const sampleSale = {
|
||||||
|
ticketFk: ticket.id,
|
||||||
|
itemFk: 1,
|
||||||
|
concept: 'Test',
|
||||||
|
quantity: 10,
|
||||||
|
originalQuantity: 6
|
||||||
|
};
|
||||||
|
await models.Sale.create(sampleSale, options);
|
||||||
|
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
||||||
|
const paramsAssigned = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1};
|
||||||
|
const resAssigned = await models.Ticket.state(ctx, paramsAssigned, options);
|
||||||
|
|
||||||
|
expect(resAssigned.ticketFk).toBe(paramsAssigned.ticketFk);
|
||||||
|
expect(resAssigned.stateFk).toBe(paramsAssigned.stateFk);
|
||||||
|
expect(resAssigned.userFk).toBe(paramsAssigned.userFk);
|
||||||
|
expect(resAssigned.userFk).toBe(1);
|
||||||
|
expect(resAssigned.id).toBeDefined();
|
||||||
|
|
||||||
|
activeCtx.accessToken.userId = productionId;
|
||||||
|
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
||||||
|
const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId};
|
||||||
|
const resPacked = await models.Ticket.state(ctx, paramsPacked, options);
|
||||||
|
|
||||||
|
const sale = await models.Sale.findOne({where: {ticketFk: ticket.id}}, options);
|
||||||
|
|
||||||
|
expect(resPacked.stateFk).toBe(paramsPacked.stateFk);
|
||||||
|
expect(sale.quantity).toBe(sale.originalQuantity);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -64,7 +64,63 @@ module.exports = Self => {
|
||||||
if ((ticketState && !oldStateAllowed) || !newStateAllowed)
|
if ((ticketState && !oldStateAllowed) || !newStateAllowed)
|
||||||
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
|
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
|
||||||
|
|
||||||
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [params.ticketFk, params.code], myOptions);
|
const ticket = await models.Ticket.findById(params.ticketFk, {
|
||||||
|
include: [{
|
||||||
|
relation: 'client',
|
||||||
|
scope: {
|
||||||
|
fields: ['salesPersonFk']
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
fields: ['id', 'clientFk']
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
|
const salesPersonFk = ticket.client().salesPersonFk;
|
||||||
|
if (salesPersonFk) {
|
||||||
|
const sales = await Self.rawSql(`
|
||||||
|
SELECT DISTINCT s.id,
|
||||||
|
s.itemFk,
|
||||||
|
s.concept,
|
||||||
|
s.originalQuantity AS oldQuantity,
|
||||||
|
s.quantity AS newQuantity
|
||||||
|
FROM vn.sale s
|
||||||
|
JOIN vn.saleTracking st ON st.saleFk = s.id
|
||||||
|
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||||
|
JOIN vn.client c ON c.id = t.clientFk
|
||||||
|
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||||
|
JOIN vn.state s2 ON s2.id = ts.stateFk
|
||||||
|
WHERE s.ticketFk = ?
|
||||||
|
AND st.isChecked
|
||||||
|
AND s.originalQuantity IS NOT NULL
|
||||||
|
AND s.originalQuantity <> s.quantity
|
||||||
|
AND s2.\`order\` < (SELECT \`order\` FROM vn.state WHERE code = 'CHECKED')
|
||||||
|
ORDER BY st.created DESC
|
||||||
|
`, [params.ticketFk], myOptions);
|
||||||
|
|
||||||
|
let changes = '';
|
||||||
|
const url = await models.Url.getUrl();
|
||||||
|
const $t = ctx.req.__;
|
||||||
|
for (let sale of sales) {
|
||||||
|
changes += `\r\n-` + $t('Changes in sales', {
|
||||||
|
itemId: sale.itemFk,
|
||||||
|
concept: sale.concept,
|
||||||
|
oldQuantity: sale.oldQuantity,
|
||||||
|
newQuantity: sale.newQuantity,
|
||||||
|
itemUrl: `${url}item/${sale.itemFk}/summary`
|
||||||
|
});
|
||||||
|
const currentSale = await models.Sale.findById(sale.id, null, myOptions);
|
||||||
|
await currentSale.updateAttributes({
|
||||||
|
originalQuantity: currentSale.quantity
|
||||||
|
}, myOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
const message = $t('Changed sale quantity', {
|
||||||
|
ticketId: ticket.id,
|
||||||
|
changes: changes,
|
||||||
|
ticketUrl: `${url}ticket/${ticket.id}/sale`
|
||||||
|
});
|
||||||
|
await models.Chat.sendCheckingPresence(ctx, salesPersonFk, message, myOptions);
|
||||||
|
}
|
||||||
|
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticket.id, params.code], myOptions);
|
||||||
|
|
||||||
const ticketTracking = await models.TicketTracking.findOne({
|
const ticketTracking = await models.TicketTracking.findOne({
|
||||||
where: {ticketFk: params.ticketFk},
|
where: {ticketFk: params.ticketFk},
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
},
|
},
|
||||||
"parkingFk": {
|
"parkingFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"ticketFk": {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -1,361 +1,318 @@
|
||||||
/* eslint max-len: ["error", { "code": 150 }]*/
|
/* eslint max-len: ["error", { "code": 150 }]*/
|
||||||
|
const {models} = require('vn-loopback/server/server');
|
||||||
const models = require('vn-loopback/server/server').models;
|
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('sale model ', () => {
|
describe('sale model ', () => {
|
||||||
const ctx = {
|
const developerId = 9;
|
||||||
req: {
|
const buyerId = 35;
|
||||||
accessToken: {userId: 9},
|
const employeeId = 1;
|
||||||
headers: {origin: 'localhost:5000'},
|
const productionId = 49;
|
||||||
__: () => {}
|
const salesPersonId = 18;
|
||||||
}
|
const reviewerId = 130;
|
||||||
};
|
|
||||||
function getActiveCtx(userId) {
|
const barcode = '4444444444';
|
||||||
return {
|
const ticketCollectionProd = 34;
|
||||||
active: {
|
const ticketCollectionSalesPerson = 35;
|
||||||
accessToken: {userId},
|
const previaTicketSalesPerson = 36;
|
||||||
http: {
|
const previaTicketProd = 37;
|
||||||
req: {
|
const notEditableError = 'This ticket is not editable.';
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
const ctx = getCtx(developerId);
|
||||||
}
|
let tx;
|
||||||
}
|
let opts;
|
||||||
};
|
|
||||||
|
function getCtx(userId, active = false) {
|
||||||
|
const accessToken = {userId};
|
||||||
|
const headers = {origin: 'localhost:5000'};
|
||||||
|
if (!active) return {req: {accessToken, headers, __: () => {}}};
|
||||||
|
return {active: {accessToken, http: {req: {headers}}}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beforeEach(async() => {
|
||||||
|
tx = await models.Sale.beginTransaction({});
|
||||||
|
opts = {transaction: tx};
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async() => await tx.rollback());
|
||||||
|
|
||||||
describe('quantity field ', () => {
|
describe('quantity field ', () => {
|
||||||
it('should add quantity if the quantity is greater than it should be and is role advanced', async() => {
|
it('should add quantity if the quantity is greater than it should be and is role advanced', async() => {
|
||||||
const saleId = 17;
|
const saleId = 17;
|
||||||
const buyerId = 35;
|
const ctx = getCtx(buyerId);
|
||||||
const ctx = {
|
|
||||||
req: {
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(buyerId, true));
|
||||||
accessToken: {userId: buyerId},
|
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => {
|
||||||
headers: {origin: 'localhost:5000'},
|
|
||||||
__: () => {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(buyerId));
|
|
||||||
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, options) => {
|
|
||||||
if (sqlStatement.includes('catalog_calcFromItem')) {
|
if (sqlStatement.includes('catalog_calcFromItem')) {
|
||||||
sqlStatement = `CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY
|
sqlStatement = `CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY
|
||||||
SELECT 100 as available;`;
|
SELECT 100 as available;`;
|
||||||
params = null;
|
params = null;
|
||||||
}
|
}
|
||||||
return models.Ticket.rawSql(sqlStatement, params, options);
|
return models.Ticket.rawSql(sqlStatement, params, opts);
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
const isRoleAdvanced = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*');
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
const isRoleAdvanced = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*');
|
expect(isRoleAdvanced).toEqual(true);
|
||||||
|
|
||||||
expect(isRoleAdvanced).toEqual(true);
|
const originalLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, opts);
|
||||||
|
|
||||||
const originalLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, options);
|
expect(originalLine.quantity).toEqual(30);
|
||||||
|
|
||||||
expect(originalLine.quantity).toEqual(30);
|
const newQuantity = originalLine.quantity + 1;
|
||||||
|
await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts);
|
||||||
|
|
||||||
const newQuantity = originalLine.quantity + 1;
|
const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, opts);
|
||||||
await models.Sale.updateQuantity(ctx, saleId, newQuantity, options);
|
|
||||||
|
|
||||||
const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, options);
|
expect(modifiedLine.quantity).toEqual(newQuantity);
|
||||||
|
|
||||||
expect(modifiedLine.quantity).toEqual(newQuantity);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the quantity of a given sale current line', async() => {
|
it('should update the quantity of a given sale current line', async() => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(9));
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(developerId, true));
|
||||||
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
const saleId = 25;
|
const saleId = 25;
|
||||||
const newQuantity = 4;
|
const newQuantity = 4;
|
||||||
|
|
||||||
try {
|
const originalLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, opts);
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
const originalLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, options);
|
expect(originalLine.quantity).toEqual(20);
|
||||||
|
|
||||||
expect(originalLine.quantity).toEqual(20);
|
await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts);
|
||||||
|
|
||||||
await models.Sale.updateQuantity(ctx, saleId, newQuantity, options);
|
const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, opts);
|
||||||
|
|
||||||
const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, options);
|
expect(modifiedLine.quantity).toEqual(newQuantity);
|
||||||
|
|
||||||
expect(modifiedLine.quantity).toEqual(newQuantity);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the quantity is negative and it is not a refund ticket', async() => {
|
it('should throw an error if the quantity is negative and it is not a refund ticket', async() => {
|
||||||
const ctx = {
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true));
|
||||||
req: {
|
|
||||||
accessToken: {userId: 1},
|
|
||||||
headers: {origin: 'localhost:5000'},
|
|
||||||
__: () => {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(1));
|
|
||||||
|
|
||||||
const saleId = 17;
|
const saleId = 17;
|
||||||
const newQuantity = -10;
|
const newQuantity = -10;
|
||||||
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
|
|
||||||
let error;
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts);
|
||||||
|
|
||||||
await models.Sale.updateQuantity(ctx, saleId, newQuantity, options);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
expect(e).toEqual(new Error('You can only add negative amounts in refund tickets'));
|
||||||
error = e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error).toEqual(new Error('You can only add negative amounts in refund tickets'));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update a negative quantity when is a ticket refund', async() => {
|
it('should update a negative quantity when is a ticket refund', async() => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(9));
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(developerId, true));
|
||||||
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
const saleId = 32;
|
const saleId = 32;
|
||||||
const newQuantity = -10;
|
const newQuantity = -10;
|
||||||
|
|
||||||
try {
|
await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts);
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
await models.Sale.updateQuantity(ctx, saleId, newQuantity, options);
|
const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, opts);
|
||||||
|
|
||||||
const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, options);
|
expect(modifiedLine.quantity).toEqual(newQuantity);
|
||||||
|
|
||||||
expect(modifiedLine.quantity).toEqual(newQuantity);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the quantity is less than the minimum quantity of the item', async() => {
|
it('should throw an error if the quantity is less than the minimum quantity of the item', async() => {
|
||||||
const ctx = {
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true));
|
||||||
req: {
|
|
||||||
accessToken: {userId: 1},
|
|
||||||
headers: {origin: 'localhost:5000'},
|
|
||||||
__: () => {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(1));
|
|
||||||
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
const itemId = 2;
|
const itemId = 2;
|
||||||
const saleId = 17;
|
const saleId = 17;
|
||||||
const minQuantity = 30;
|
const minQuantity = 30;
|
||||||
const newQuantity = minQuantity - 1;
|
const newQuantity = minQuantity - 1;
|
||||||
|
|
||||||
let error;
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const item = await models.Item.findById(itemId, null, opts);
|
||||||
|
await item.updateAttribute('minQuantity', minQuantity, opts);
|
||||||
const item = await models.Item.findById(itemId, null, options);
|
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => {
|
||||||
await item.updateAttribute('minQuantity', minQuantity, options);
|
|
||||||
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, options) => {
|
|
||||||
if (sqlStatement.includes('catalog_calcFromItem')) {
|
if (sqlStatement.includes('catalog_calcFromItem')) {
|
||||||
sqlStatement = `CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY
|
sqlStatement = `CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY
|
||||||
SELECT 100 as available;`;
|
SELECT 100 as available;`;
|
||||||
params = null;
|
params = null;
|
||||||
}
|
}
|
||||||
return models.Ticket.rawSql(sqlStatement, params, options);
|
return models.Ticket.rawSql(sqlStatement, params, opts);
|
||||||
});
|
});
|
||||||
|
|
||||||
await models.Sale.updateQuantity(ctx, saleId, newQuantity, options);
|
await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts);
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
expect(e).toEqual(new Error('The amount cannot be less than the minimum'));
|
||||||
error = e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error).toEqual(new Error('The amount cannot be less than the minimum'));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change quantity if has minimum quantity and new quantity is equal than item available', async() => {
|
it('should change quantity if has minimum quantity and new quantity is equal than item available', async() => {
|
||||||
const ctx = {
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true));
|
||||||
req: {
|
|
||||||
accessToken: {userId: 1},
|
|
||||||
headers: {origin: 'localhost:5000'},
|
|
||||||
__: () => {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(1));
|
|
||||||
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
const itemId = 2;
|
const itemId = 2;
|
||||||
const saleId = 17;
|
const saleId = 17;
|
||||||
const minQuantity = 30;
|
const minQuantity = 30;
|
||||||
const newQuantity = minQuantity - 1;
|
const newQuantity = minQuantity - 1;
|
||||||
|
|
||||||
try {
|
const item = await models.Item.findById(itemId, null, opts);
|
||||||
const options = {transaction: tx};
|
await item.updateAttribute('minQuantity', minQuantity, opts);
|
||||||
|
|
||||||
const item = await models.Item.findById(itemId, null, options);
|
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => {
|
||||||
await item.updateAttribute('minQuantity', minQuantity, options);
|
if (sqlStatement.includes('catalog_calcFromItem')) {
|
||||||
|
sqlStatement = `CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY
|
||||||
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, options) => {
|
|
||||||
if (sqlStatement.includes('catalog_calcFromItem')) {
|
|
||||||
sqlStatement = `CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY
|
|
||||||
SELECT ${newQuantity} as available;`;
|
SELECT ${newQuantity} as available;`;
|
||||||
params = null;
|
params = null;
|
||||||
}
|
}
|
||||||
return models.Ticket.rawSql(sqlStatement, params, options);
|
return models.Ticket.rawSql(sqlStatement, params, opts);
|
||||||
});
|
});
|
||||||
|
|
||||||
await models.Sale.updateQuantity(ctx, saleId, newQuantity, options);
|
await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts);
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('newPrice', () => {
|
describe('newPrice', () => {
|
||||||
it('should increase quantity if you have enough available and the new price is the same as the previous one', async() => {
|
it('should increase quantity if you have enough available and the new price is the same as the previous one', async() => {
|
||||||
const ctx = {
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true));
|
||||||
req: {
|
|
||||||
accessToken: {userId: 1},
|
|
||||||
headers: {origin: 'localhost:5000'},
|
|
||||||
__: () => {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(1));
|
|
||||||
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
const itemId = 2;
|
const itemId = 2;
|
||||||
const saleId = 17;
|
const saleId = 17;
|
||||||
const minQuantity = 30;
|
const minQuantity = 30;
|
||||||
const newQuantity = 31;
|
const newQuantity = 31;
|
||||||
|
|
||||||
try {
|
const item = await models.Item.findById(itemId, null, opts);
|
||||||
const options = {transaction: tx};
|
await item.updateAttribute('minQuantity', minQuantity, opts);
|
||||||
|
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => {
|
||||||
const item = await models.Item.findById(itemId, null, options);
|
if (sqlStatement.includes('catalog_calcFromItem')) {
|
||||||
await item.updateAttribute('minQuantity', minQuantity, options);
|
sqlStatement = `
|
||||||
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, options) => {
|
|
||||||
if (sqlStatement.includes('catalog_calcFromItem')) {
|
|
||||||
sqlStatement = `
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available;
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available;
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY SELECT 1 as grouping, 7.07 as price;`;
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY SELECT 1 as grouping, 7.07 as price;`;
|
||||||
params = null;
|
params = null;
|
||||||
}
|
}
|
||||||
return models.Ticket.rawSql(sqlStatement, params, options);
|
return models.Ticket.rawSql(sqlStatement, params, opts);
|
||||||
});
|
});
|
||||||
|
|
||||||
await models.Sale.updateQuantity(ctx, saleId, newQuantity, options);
|
await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts);
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should increase quantity when the new price is lower than the previous one', async() => {
|
it('should increase quantity when the new price is lower than the previous one', async() => {
|
||||||
const ctx = {
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true));
|
||||||
req: {
|
|
||||||
accessToken: {userId: 1},
|
|
||||||
headers: {origin: 'localhost:5000'},
|
|
||||||
__: () => {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(1));
|
|
||||||
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
const itemId = 2;
|
const itemId = 2;
|
||||||
const saleId = 17;
|
const saleId = 17;
|
||||||
const minQuantity = 30;
|
const minQuantity = 30;
|
||||||
const newQuantity = 31;
|
const newQuantity = 31;
|
||||||
|
|
||||||
try {
|
const item = await models.Item.findById(itemId, null, opts);
|
||||||
const options = {transaction: tx};
|
await item.updateAttribute('minQuantity', minQuantity, opts);
|
||||||
|
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => {
|
||||||
const item = await models.Item.findById(itemId, null, options);
|
if (sqlStatement.includes('catalog_calcFromItem')) {
|
||||||
await item.updateAttribute('minQuantity', minQuantity, options);
|
sqlStatement = `
|
||||||
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, options) => {
|
|
||||||
if (sqlStatement.includes('catalog_calcFromItem')) {
|
|
||||||
sqlStatement = `
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available;
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available;
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY SELECT 1 as grouping, 1 as price;`;
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY SELECT 1 as grouping, 1 as price;`;
|
||||||
params = null;
|
params = null;
|
||||||
}
|
}
|
||||||
return models.Ticket.rawSql(sqlStatement, params, options);
|
return models.Ticket.rawSql(sqlStatement, params, opts);
|
||||||
});
|
});
|
||||||
|
|
||||||
await models.Sale.updateQuantity(ctx, saleId, newQuantity, options);
|
await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts);
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error when increase quantity and the new price is higher than the previous one', async() => {
|
it('should throw error when increase quantity and the new price is higher than the previous one', async() => {
|
||||||
const ctx = {
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true));
|
||||||
req: {
|
|
||||||
accessToken: {userId: 1},
|
|
||||||
headers: {origin: 'localhost:5000'},
|
|
||||||
__: () => {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(1));
|
|
||||||
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
const itemId = 2;
|
const itemId = 2;
|
||||||
const saleId = 17;
|
const saleId = 17;
|
||||||
const minQuantity = 30;
|
const minQuantity = 30;
|
||||||
const newQuantity = 31;
|
const newQuantity = 31;
|
||||||
|
|
||||||
let error;
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const item = await models.Item.findById(itemId, null, opts);
|
||||||
|
await item.updateAttribute('minQuantity', minQuantity, opts);
|
||||||
const item = await models.Item.findById(itemId, null, options);
|
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => {
|
||||||
await item.updateAttribute('minQuantity', minQuantity, options);
|
|
||||||
spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, options) => {
|
|
||||||
if (sqlStatement.includes('catalog_calcFromItem')) {
|
if (sqlStatement.includes('catalog_calcFromItem')) {
|
||||||
sqlStatement = `
|
sqlStatement = `
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available;
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available;
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY SELECT 1 as grouping, 100000 as price;`;
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY SELECT 1 as grouping, 100000 as price;`;
|
||||||
params = null;
|
params = null;
|
||||||
}
|
}
|
||||||
return models.Ticket.rawSql(sqlStatement, params, options);
|
return models.Ticket.rawSql(sqlStatement, params, opts);
|
||||||
});
|
});
|
||||||
|
|
||||||
await models.Sale.updateQuantity(ctx, saleId, newQuantity, options);
|
await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts);
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
expect(e).toEqual(new Error('The price of the item changed'));
|
||||||
error = e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error).toEqual(new Error('The price of the item changed'));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('add a sale from a collection or previa ticket', () => {
|
||||||
|
it('if is allocated to them and alert level higher than 0 as Production role', async() => {
|
||||||
|
const ctx = getCtx(productionId);
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(productionId, true));
|
||||||
|
|
||||||
|
const beforeSalesCollection = await models.Sale.count({ticketFk: ticketCollectionProd}, opts);
|
||||||
|
await models.Ticket.addSale(ctx, ticketCollectionProd, barcode, 20, opts);
|
||||||
|
const afterSalesCollection = await models.Sale.count({ticketFk: ticketCollectionProd}, opts);
|
||||||
|
|
||||||
|
expect(afterSalesCollection).toEqual(beforeSalesCollection + 1);
|
||||||
|
|
||||||
|
const beforeSalesPrevia = await models.Sale.count({ticketFk: previaTicketProd}, opts);
|
||||||
|
await models.Ticket.addSale(ctx, previaTicketProd, barcode, 20, opts);
|
||||||
|
const afterSalesPrevia = await models.Sale.count({ticketFk: previaTicketProd}, opts);
|
||||||
|
|
||||||
|
expect(afterSalesPrevia).toEqual(beforeSalesPrevia + 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error if is not allocated to them and alert level higher than 0 as Production role', async() => {
|
||||||
|
const ctx = getCtx(productionId);
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(productionId, true));
|
||||||
|
|
||||||
|
try {
|
||||||
|
await models.Ticket.addSale(ctx, ticketCollectionSalesPerson, barcode, 20, opts);
|
||||||
|
} catch ({message}) {
|
||||||
|
expect(message).toEqual(notEditableError);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await models.Ticket.addSale(ctx, previaTicketSalesPerson, barcode, 20, opts);
|
||||||
|
} catch ({message}) {
|
||||||
|
expect(message).toEqual(notEditableError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('if is allocated to them and alert level higher than 0 as salesPerson role', async() => {
|
||||||
|
const ctx = getCtx(salesPersonId);
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(salesPersonId, true));
|
||||||
|
|
||||||
|
const beforeSalesCollection = await models.Sale.count({ticketFk: ticketCollectionSalesPerson}, opts);
|
||||||
|
await models.Ticket.addSale(ctx, ticketCollectionSalesPerson, barcode, 20, opts);
|
||||||
|
const afterSalesCollection = await models.Sale.count({ticketFk: ticketCollectionSalesPerson}, opts);
|
||||||
|
|
||||||
|
expect(afterSalesCollection).toEqual(beforeSalesCollection + 1);
|
||||||
|
|
||||||
|
const beforeSalesPrevia = await models.Sale.count({ticketFk: previaTicketSalesPerson}, opts);
|
||||||
|
await models.Ticket.addSale(ctx, previaTicketSalesPerson, barcode, 20, opts);
|
||||||
|
const afterSalesPrevia = await models.Sale.count({ticketFk: previaTicketSalesPerson}, opts);
|
||||||
|
|
||||||
|
expect(afterSalesPrevia).toEqual(beforeSalesPrevia + 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error if is not allocated to them and alert level higher than 0 as salesPerson role', async() => {
|
||||||
|
const ctx = getCtx(salesPersonId);
|
||||||
|
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(salesPersonId, true));
|
||||||
|
|
||||||
|
try {
|
||||||
|
await models.Ticket.addSale(ctx, ticketCollectionProd, barcode, 20, opts);
|
||||||
|
} catch ({message}) {
|
||||||
|
expect(message).toEqual(notEditableError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('if is a reviewer', async() => {
|
||||||
|
const ctx = getCtx(reviewerId);
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(reviewerId, true));
|
||||||
|
|
||||||
|
const beforeSalesCollection = await models.Sale.count({ticketFk: ticketCollectionSalesPerson}, opts);
|
||||||
|
await models.Ticket.addSale(ctx, ticketCollectionSalesPerson, barcode, 20, opts);
|
||||||
|
const afterSalesCollection = await models.Sale.count({ticketFk: ticketCollectionSalesPerson}, opts);
|
||||||
|
|
||||||
|
expect(afterSalesCollection).toEqual(beforeSalesCollection + 1);
|
||||||
|
|
||||||
|
const beforeSalesPrevia = await models.Sale.count({ticketFk: previaTicketSalesPerson}, opts);
|
||||||
|
await models.Ticket.addSale(ctx, previaTicketSalesPerson, barcode, 20, opts);
|
||||||
|
const afterSalesPrevia = await models.Sale.count({ticketFk: previaTicketSalesPerson}, opts);
|
||||||
|
|
||||||
|
expect(afterSalesPrevia).toEqual(beforeSalesPrevia + 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,6 +46,5 @@ module.exports = function(Self) {
|
||||||
require('../methods/ticket/invoiceTicketsAndPdf')(Self);
|
require('../methods/ticket/invoiceTicketsAndPdf')(Self);
|
||||||
require('../methods/ticket/docuwareDownload')(Self);
|
require('../methods/ticket/docuwareDownload')(Self);
|
||||||
require('../methods/ticket/myLastModified')(Self);
|
require('../methods/ticket/myLastModified')(Self);
|
||||||
require('../methods/ticket/addSaleByCode')(Self);
|
|
||||||
require('../methods/ticket/clone')(Self);
|
require('../methods/ticket/clone')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -152,7 +152,7 @@
|
||||||
</vn-item>
|
</vn-item>
|
||||||
<vn-item class="dropdown"
|
<vn-item class="dropdown"
|
||||||
vn-click-stop="refundMenu.show($event, 'left')"
|
vn-click-stop="refundMenu.show($event, 'left')"
|
||||||
vn-acl="invoicing, claimManager, salesAssistant"
|
vn-acl="invoicing, claimManager, salesAssistant, logistic"
|
||||||
vn-acl-action="remove"
|
vn-acl-action="remove"
|
||||||
vn-tooltip="Create a single ticket with all the content of the current ticket"
|
vn-tooltip="Create a single ticket with all the content of the current ticket"
|
||||||
translate>
|
translate>
|
||||||
|
|
|
@ -476,7 +476,7 @@ class Controller extends Section {
|
||||||
*/
|
*/
|
||||||
addSale(sale) {
|
addSale(sale) {
|
||||||
const data = {
|
const data = {
|
||||||
itemId: sale.itemFk,
|
barcode: sale.itemFk,
|
||||||
quantity: sale.quantity
|
quantity: sale.quantity
|
||||||
};
|
};
|
||||||
const query = `tickets/${this.ticket.id}/addSale`;
|
const query = `tickets/${this.ticket.id}/addSale`;
|
||||||
|
|
|
@ -659,7 +659,7 @@ describe('Ticket', () => {
|
||||||
jest.spyOn(controller, 'resetChanges').mockReturnThis();
|
jest.spyOn(controller, 'resetChanges').mockReturnThis();
|
||||||
|
|
||||||
const newSale = {itemFk: 4, quantity: 10};
|
const newSale = {itemFk: 4, quantity: 10};
|
||||||
const expectedParams = {itemId: 4, quantity: 10};
|
const expectedParams = {barcode: 4, quantity: 10};
|
||||||
const expectedResult = {
|
const expectedResult = {
|
||||||
id: 30,
|
id: 30,
|
||||||
quantity: 10,
|
quantity: 10,
|
||||||
|
|
|
@ -20,7 +20,7 @@ module.exports = Self => {
|
||||||
const notifications = await models.NotificationQueue.find(
|
const notifications = await models.NotificationQueue.find(
|
||||||
{where: {created: {gte: new Date(Date.vnNow() - (backupPrinterNotificationDelay * 1000))},
|
{where: {created: {gte: new Date(Date.vnNow() - (backupPrinterNotificationDelay * 1000))},
|
||||||
notificationFk: notificationName,
|
notificationFk: notificationName,
|
||||||
status: 'sent'
|
status: {neq: 'error'}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,8 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
ng-model="$ctrl.worker.originCountryFk"
|
ng-model="$ctrl.worker.originCountryFk"
|
||||||
url="Countries"
|
url="Countries"
|
||||||
fields="['id', 'country', 'code']"
|
fields="['id', 'name', 'code']"
|
||||||
show-field="country"
|
show-field="name"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
label="Origin country">
|
label="Origin country">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
|
|
@ -5,6 +5,7 @@ describe('zone deletezone()', () => {
|
||||||
const userId = 9;
|
const userId = 9;
|
||||||
const activeCtx = {
|
const activeCtx = {
|
||||||
accessToken: {userId: userId},
|
accessToken: {userId: userId},
|
||||||
|
__: value => value
|
||||||
};
|
};
|
||||||
const ctx = {req: activeCtx};
|
const ctx = {req: activeCtx};
|
||||||
const zoneId = 9;
|
const zoneId = 9;
|
||||||
|
@ -15,19 +16,15 @@ describe('zone deletezone()', () => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
active: activeCtx
|
active: activeCtx
|
||||||
});
|
});
|
||||||
try {
|
const originalTickets = await models.Ticket.find({
|
||||||
const originalTickets = await models.Ticket.find({
|
where: {
|
||||||
where: {
|
zoneFk: zoneId
|
||||||
zoneFk: zoneId
|
}
|
||||||
}
|
});
|
||||||
});
|
ticketIDs = originalTickets.map(ticket => ticket.id);
|
||||||
ticketIDs = originalTickets.map(ticket => ticket.id);
|
originalTicketStates = await models.TicketState.find({where: {
|
||||||
originalTicketStates = await models.TicketState.find({where: {
|
ticketFk: {inq: ticketIDs},
|
||||||
ticketFk: {inq: ticketIDs},
|
code: 'FIXING'}});
|
||||||
code: 'FIXING'}});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete a zone and update their tickets', async() => {
|
it('should delete a zone and update their tickets', async() => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "salix-back",
|
"name": "salix-back",
|
||||||
"version": "24.24.1",
|
"version": "24.24.3",
|
||||||
"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