Merge pull request '6745-2404_testToMaster' (!1950) from 6745-2404_testToMaster into master
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1950 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
bfbe8302b6
|
@ -16,6 +16,7 @@
|
||||||
},
|
},
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"salix",
|
"salix",
|
||||||
"fdescribe"
|
"fdescribe",
|
||||||
|
"Loggable"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [2404.01] - 2024-01-25
|
||||||
|
|
||||||
|
### Added
|
||||||
|
### Changed
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
|
||||||
## [2402.01] - 2024-01-11
|
## [2402.01] - 2024-01-11
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -35,10 +35,17 @@ module.exports = Self => {
|
||||||
let html = `<strong>Motivo</strong>:<br/>${reason}<br/>`;
|
let html = `<strong>Motivo</strong>:<br/>${reason}<br/>`;
|
||||||
html += `<strong>Usuario</strong>:<br/>${ctx.req.accessToken.userId} ${emailUser.email}<br/>`;
|
html += `<strong>Usuario</strong>:<br/>${ctx.req.accessToken.userId} ${emailUser.email}<br/>`;
|
||||||
|
|
||||||
|
delete additionalData.backError.config.headers.Authorization;
|
||||||
|
const httpRequest = JSON.parse(additionalData?.httpRequest);
|
||||||
|
|
||||||
|
if (httpRequest)
|
||||||
|
delete httpRequest.config.headers.Authorization;
|
||||||
|
additionalData.httpRequest = httpRequest;
|
||||||
|
|
||||||
for (const data in additionalData)
|
for (const data in additionalData)
|
||||||
html += `<strong>${data}</strong>:<br/>${tryParse(additionalData[data])}<br/>`;
|
html += `<strong>${data}</strong>:<br/>${tryParse(additionalData[data])}<br/>`;
|
||||||
|
|
||||||
const subjectReason = JSON.parse(additionalData?.httpRequest)?.data?.error;
|
const subjectReason = httpRequest?.data?.error;
|
||||||
smtp.send({
|
smtp.send({
|
||||||
to: `${config.app.reportEmail}, ${emailUser.email}`,
|
to: `${config.app.reportEmail}, ${emailUser.email}`,
|
||||||
subject:
|
subject:
|
||||||
|
|
|
@ -68,7 +68,7 @@ module.exports = Self => {
|
||||||
userToUpdate.hasGrant = hasGrant;
|
userToUpdate.hasGrant = hasGrant;
|
||||||
|
|
||||||
if (roleFk) {
|
if (roleFk) {
|
||||||
const role = await models.Role.findById(roleFk, {fields: ['name']}, myOptions);
|
const role = await models.VnRole.findById(roleFk, {fields: ['name']}, myOptions);
|
||||||
const hasRole = await Self.hasRole(userId, role.name, myOptions);
|
const hasRole = await Self.hasRole(userId, role.name, myOptions);
|
||||||
|
|
||||||
if (!hasRole)
|
if (!hasRole)
|
||||||
|
|
|
@ -70,7 +70,7 @@ describe('VnUser privileges()', () => {
|
||||||
const tx = await models.VnUser.beginTransaction({});
|
const tx = await models.VnUser.beginTransaction({});
|
||||||
|
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const agency = await models.Role.findOne({
|
const agency = await models.VnRole.findOne({
|
||||||
where: {
|
where: {
|
||||||
name: 'agency'
|
name: 'agency'
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,9 +139,6 @@
|
||||||
"Warehouse": {
|
"Warehouse": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"VnUser": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"OsTicket": {
|
"OsTicket": {
|
||||||
"dataSource": "osticket"
|
"dataSource": "osticket"
|
||||||
},
|
},
|
||||||
|
@ -156,6 +153,12 @@
|
||||||
},
|
},
|
||||||
"ViaexpressConfig": {
|
"ViaexpressConfig": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"VnUser": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"VnRole": {
|
||||||
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,6 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"path": {
|
|
||||||
"type": "string",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"code": {
|
"code": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"required": true
|
"required": true
|
||||||
|
@ -29,12 +25,12 @@
|
||||||
"relations": {
|
"relations": {
|
||||||
"readRole": {
|
"readRole": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Role",
|
"model": "VnRole",
|
||||||
"foreignKey": "readRoleFk"
|
"foreignKey": "readRoleFk"
|
||||||
},
|
},
|
||||||
"writeRole": {
|
"writeRole": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Role",
|
"model": "VnRole",
|
||||||
"foreignKey": "writeRoleFk"
|
"foreignKey": "writeRoleFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -46,12 +46,12 @@
|
||||||
},
|
},
|
||||||
"readRole": {
|
"readRole": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Role",
|
"model": "VnRole",
|
||||||
"foreignKey": "readRoleFk"
|
"foreignKey": "readRoleFk"
|
||||||
},
|
},
|
||||||
"writeRole": {
|
"writeRole": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Role",
|
"model": "VnRole",
|
||||||
"foreignKey": "writeRoleFk"
|
"foreignKey": "writeRoleFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -64,4 +64,3 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
},
|
},
|
||||||
"role": {
|
"role": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Role",
|
"model": "VnRole",
|
||||||
"foreignKey": "roleFk"
|
"foreignKey": "roleFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"name": "VnRole",
|
||||||
|
"base": "Role",
|
||||||
|
"validateUpsert": true,
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "account.role"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,9 @@
|
||||||
"table": "account.user"
|
"table": "account.user"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"resetPasswordTokenTTL": "604800",
|
"resetPasswordTokenTTL": "604800",
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
|
@ -63,7 +66,7 @@
|
||||||
"relations": {
|
"relations": {
|
||||||
"role": {
|
"role": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Role",
|
"model": "VnRole",
|
||||||
"foreignKey": "roleFk"
|
"foreignKey": "roleFk"
|
||||||
},
|
},
|
||||||
"roles": {
|
"roles": {
|
||||||
|
|
|
@ -59,8 +59,8 @@ async function test() {
|
||||||
const JunitReporter = require('jasmine-reporters');
|
const JunitReporter = require('jasmine-reporters');
|
||||||
jasmine.addReporter(new JunitReporter.JUnitXmlReporter());
|
jasmine.addReporter(new JunitReporter.JUnitXmlReporter());
|
||||||
|
|
||||||
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
|
|
||||||
jasmine.exitOnCompletion = true;
|
jasmine.exitOnCompletion = true;
|
||||||
|
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 900000;
|
||||||
}
|
}
|
||||||
|
|
||||||
const backSpecs = [
|
const backSpecs = [
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM mariadb:10.7.7
|
FROM mariadb:10.11.6
|
||||||
|
|
||||||
ENV MYSQL_ROOT_PASSWORD root
|
ENV MYSQL_ROOT_PASSWORD root
|
||||||
ENV TZ Europe/Madrid
|
ENV TZ Europe/Madrid
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE `vn`.`item` DROP COLUMN stars;
|
|
@ -0,0 +1,4 @@
|
||||||
|
REVOKE UPDATE ON TABLE `vn`.`item` FROM `employee`;
|
||||||
|
|
||||||
|
|
||||||
|
GRANT UPDATE(id, equivalent, stems, minPrice, isToPrint, family, box, category, doPhoto, image, inkFk, intrastatFk, hasMinPrice, created, comment, typeFk, generic, producerFk, description, density, relevancy, expenseFk, isActive, subName, tag5, value5, tag6, value6, tag7, value7, tag8, value8, tag9, value9, tag10, value10, minimum, upToDown, supplyResponseFk, hasKgPrice, isFloramondo, isFragile, numberOfItemsPerCask, embalageCode, quality, stemMultiplier, itemPackingTypeFk, packingOut, genericFk, packingShelve, isLaid, lastUsed, weightByPiece, weightByPiece, editorFk, recycledPlastic, nonRecycledPlastic, minQuantity) ON TABLE `vn`.`item` TO `employee`;
|
|
@ -0,0 +1,12 @@
|
||||||
|
ALTER TABLE `vn`.`company` MODIFY COLUMN `supplierAccountFk` mediumint(8) unsigned DEFAULT NULL NULL COMMENT 'Cuenta por defecto para ingresos desde este pais';
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE `vn`.`supplierAccount`
|
||||||
|
ADD COLUMN `countryFk` mediumint(8) unsigned DEFAULT NULL,
|
||||||
|
ADD CONSTRAINT `fk_supplierAccount_country`
|
||||||
|
FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE `vn`.`supplierAccount`
|
||||||
|
ADD UNIQUE KEY `uk_supplier_country` (`supplierFk`, `countryFk`);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
ALTER TABLE `vn`.`clientSms` ADD `ticketFk` int(11) NULL;
|
||||||
|
ALTER TABLE `vn`.`clientSms` ADD CONSTRAINT `clientSms_FK_2` FOREIGN KEY (`ticketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
INSERT INTO`vn`.`clientSms` (`clientFk`, `smsFk`, `ticketFk`)
|
||||||
|
SELECT `t`.`clientFk`, `s`.`smsFk`, `s`.`ticketFk`
|
||||||
|
FROM `vn`.`clientSms` `s`
|
||||||
|
JOIN `vn`.`ticket` `t` ON `t`.`id` = `s`.`ticketFk`;
|
||||||
|
|
||||||
|
RENAME TABLE `vn`.`ticketSms` TO `vn`.`ticketSms__`;
|
|
@ -0,0 +1,74 @@
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro
|
||||||
|
*
|
||||||
|
* @param vOriginDated Fecha en cuestión
|
||||||
|
* @param vFutureDated Fecha en el futuro a sondear
|
||||||
|
* @param vWarehouseFk Identificador de vn.warehouse
|
||||||
|
*/
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.filter
|
||||||
|
(INDEX (id))
|
||||||
|
SELECT sv.ticketFk id,
|
||||||
|
sub2.id futureId,
|
||||||
|
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt,
|
||||||
|
CAST(sum(litros) AS DECIMAL(10,0)) liters,
|
||||||
|
CAST(count(*) AS DECIMAL(10,0)) `lines`,
|
||||||
|
st.name state,
|
||||||
|
sub2.iptd futureIpt,
|
||||||
|
sub2.state futureState,
|
||||||
|
t.clientFk,
|
||||||
|
t.warehouseFk,
|
||||||
|
ts.alertLevel,
|
||||||
|
t.shipped,
|
||||||
|
t.totalWithVat,
|
||||||
|
sub2.shipped futureShipped,
|
||||||
|
t.workerFk,
|
||||||
|
st.code stateCode,
|
||||||
|
sub2.code futureStateCode,
|
||||||
|
st.classColor,
|
||||||
|
sub2.classColor futureClassColor
|
||||||
|
FROM vn.saleVolume sv
|
||||||
|
JOIN vn.sale s ON s.id = sv.saleFk
|
||||||
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
|
JOIN vn.ticket t ON t.id = sv.ticketFk
|
||||||
|
JOIN vn.address a ON a.id = t.addressFk
|
||||||
|
JOIN vn.province p ON p.id = a.provinceFk
|
||||||
|
JOIN vn.country c ON c.id = p.countryFk
|
||||||
|
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||||
|
JOIN vn.state st ON st.id = ts.stateFk
|
||||||
|
JOIN vn.alertLevel al ON al.id = ts.alertLevel
|
||||||
|
LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT *
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
t.addressFk,
|
||||||
|
t.id,
|
||||||
|
t.shipped,
|
||||||
|
st.name state,
|
||||||
|
st.code,
|
||||||
|
st.classColor,
|
||||||
|
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd
|
||||||
|
FROM vn.ticket t
|
||||||
|
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||||
|
JOIN vn.state st ON st.id = ts.stateFk
|
||||||
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
|
WHERE t.shipped BETWEEN vFutureDated
|
||||||
|
AND util.dayend(vFutureDated)
|
||||||
|
AND t.warehouseFk = vWarehouseFk
|
||||||
|
GROUP BY t.id
|
||||||
|
) sub
|
||||||
|
GROUP BY sub.addressFk
|
||||||
|
) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
|
||||||
|
WHERE t.shipped BETWEEN vOriginDated AND util.dayend(vOriginDated)
|
||||||
|
AND t.warehouseFk = vWarehouseFk
|
||||||
|
AND al.code = 'FREE'
|
||||||
|
AND tp.ticketFk IS NULL
|
||||||
|
GROUP BY sv.ticketFk
|
||||||
|
HAVING futureId;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,6 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) VALUES
|
||||||
|
('VnRole','*','READ','ALLOW','ROLE','employee'),
|
||||||
|
('VnRole','*','WRITE','ALLOW','ROLE','it');
|
||||||
|
|
||||||
|
DELETE FROM`salix`.`ACL` WHERE model='Role';
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE `vn`.`productionConfig` ADD itemPreviousDefaultSize int NULL COMMENT 'Altura por defecto para los artículos de previa';
|
||||||
|
UPDATE IGNORE `vn`.`productionConfig` SET itemPreviousDefaultSize = 40 WHERE id = 1;
|
|
@ -0,0 +1,9 @@
|
||||||
|
UPDATE `vn`.`supplierAccount` sa
|
||||||
|
JOIN `vn`.`country` c ON sa.countryFk = c.id AND c.code = 'FR'
|
||||||
|
SET countryFk = c.id
|
||||||
|
WHERE iban = 'FR7630003012690002801121597';
|
||||||
|
|
||||||
|
UPDATE `vn`.`supplierAccount` sa
|
||||||
|
JOIN `vn`.`country` c ON sa.countryFk = c.id AND c.code = 'PT'
|
||||||
|
SET countryFk = c.id
|
||||||
|
WHERE iban = 'PT50001000005813059150168';
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE `vn`.`invoiceOutConfig`
|
||||||
|
ADD IF NOT EXISTS refLen TINYINT UNSIGNED DEFAULT 5 NOT NULL COMMENT 'Invoice reference identifier length';
|
|
@ -0,0 +1,59 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceOut_beforeInsert`
|
||||||
|
BEFORE INSERT ON `invoiceOut`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Generates the next reference for the invoice serial. There cannot be gaps
|
||||||
|
* between identifiers of the same serial!
|
||||||
|
*
|
||||||
|
* Reference format:
|
||||||
|
* {0} Invoice serial
|
||||||
|
* {1} The company code
|
||||||
|
* {2-3} Last two digits of issue year
|
||||||
|
* {4-$} Autoincrement identifier
|
||||||
|
*/
|
||||||
|
DECLARE vRef INT DEFAULT 0;
|
||||||
|
DECLARE vRefLen INT;
|
||||||
|
DECLARE vRefPrefix VARCHAR(255);
|
||||||
|
DECLARE vLastRef VARCHAR(255);
|
||||||
|
DECLARE vCompanyCode INT;
|
||||||
|
DECLARE vYearLen INT DEFAULT 2;
|
||||||
|
DECLARE vPrefixLen INT;
|
||||||
|
|
||||||
|
SELECT companyCode INTO vCompanyCode
|
||||||
|
FROM company
|
||||||
|
WHERE id = NEW.companyFk;
|
||||||
|
|
||||||
|
IF vCompanyCode IS NULL THEN
|
||||||
|
CALL util.throw('companyCodeNotDefined');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT MAX(i.ref) INTO vLastRef
|
||||||
|
FROM invoiceOut i
|
||||||
|
WHERE i.serial = NEW.serial
|
||||||
|
AND i.issued BETWEEN util.firstDayOfYear(NEW.issued) AND util.lastDayOfYear(NEW.issued)
|
||||||
|
AND i.companyFk = NEW.companyFk;
|
||||||
|
|
||||||
|
IF vLastRef IS NOT NULL THEN
|
||||||
|
SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vCompanyCode) + vYearLen;
|
||||||
|
SET vRefLen = LENGTH(vLastRef) - vPrefixLen;
|
||||||
|
SET vRefPrefix = LEFT(vLastRef, vPrefixLen);
|
||||||
|
SET vRef = RIGHT(vLastRef, vRefLen);
|
||||||
|
ELSE
|
||||||
|
SELECT refLen INTO vRefLen FROM invoiceOutConfig;
|
||||||
|
SET vRefPrefix = CONCAT(
|
||||||
|
NEW.serial,
|
||||||
|
vCompanyCode,
|
||||||
|
RIGHT(YEAR(NEW.issued), vYearLen)
|
||||||
|
);
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SET vRef = vRef + 1;
|
||||||
|
IF LENGTH(vRef) > vRefLen THEN
|
||||||
|
CALL util.throw('refIdLenExceeded');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SET NEW.ref = CONCAT(vRefPrefix, LPAD(vRef, vRefLen, '0'));
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,589 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_calculateComponent`(vSelf INT, vOption VARCHAR(25))
|
||||||
|
proc: BEGIN
|
||||||
|
/**
|
||||||
|
* Crea tabla temporal para vn.sale_recalcComponent() para recalcular los componentes
|
||||||
|
*
|
||||||
|
* @param vSelf Id de la venta
|
||||||
|
* @param vOption indica en que componente pone el descuadre, NULL en casos habituales
|
||||||
|
*/
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
|
||||||
|
SELECT s.id
|
||||||
|
FROM sale s
|
||||||
|
WHERE s.id = vSelf;
|
||||||
|
|
||||||
|
CALL sale_recalcComponent(vOption);
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tmp.recalculateSales;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_checkNoComponents`(vCreatedFrom DATETIME, vCreatedTo DATETIME)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Comprueba que las ventas creadas entre un rango de fechas tienen componentes
|
||||||
|
*
|
||||||
|
* @param vCreatedFrom inicio del rango
|
||||||
|
* @param vCreatedTo fin del rango
|
||||||
|
*/
|
||||||
|
DECLARE v_done BOOL DEFAULT FALSE;
|
||||||
|
DECLARE vSaleFk INTEGER;
|
||||||
|
DECLARE vTicketFk INTEGER;
|
||||||
|
DECLARE vConcept VARCHAR(50);
|
||||||
|
DECLARE vCur CURSOR FOR
|
||||||
|
SELECT s.id
|
||||||
|
FROM sale s
|
||||||
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
JOIN itemType tp ON tp.id = i.typeFk
|
||||||
|
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||||
|
LEFT JOIN tmp.coste c ON c.id = s.id
|
||||||
|
WHERE s.created >= vCreatedFrom AND s.created <= vCreatedTo
|
||||||
|
AND c.id IS NULL
|
||||||
|
AND t.agencyModeFk IS NOT NULL
|
||||||
|
AND t.isDeleted IS FALSE
|
||||||
|
AND t.warehouseFk = 60
|
||||||
|
AND ic.merchandise != FALSE
|
||||||
|
GROUP BY s.id;
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
||||||
|
SET v_done = TRUE;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.coste;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.coste;
|
||||||
|
CREATE TEMPORARY TABLE tmp.coste
|
||||||
|
(PRIMARY KEY (id)) ENGINE = MEMORY
|
||||||
|
SELECT s.id
|
||||||
|
FROM sale s
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
JOIN itemType tp ON tp.id = i.typeFk
|
||||||
|
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||||
|
JOIN saleComponent sc ON sc.saleFk = s.id
|
||||||
|
JOIN component c ON c.id = sc.componentFk
|
||||||
|
JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 6
|
||||||
|
WHERE s.created >= vCreatedFrom
|
||||||
|
AND ic.merchandise != FALSE;
|
||||||
|
|
||||||
|
OPEN vCur;
|
||||||
|
|
||||||
|
l: LOOP
|
||||||
|
SET v_done = FALSE;
|
||||||
|
FETCH vCur INTO vSaleFk;
|
||||||
|
|
||||||
|
IF v_done THEN
|
||||||
|
LEAVE l;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT ticketFk, concept
|
||||||
|
INTO vTicketFk, vConcept
|
||||||
|
FROM sale
|
||||||
|
WHERE id = vSaleFk;
|
||||||
|
|
||||||
|
CALL sale_calculateComponent(vSaleFk, 'renewPrices');
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
CLOSE vCur;
|
||||||
|
DROP TEMPORARY TABLE tmp.coste;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_recalcComponent`(vOption VARCHAR(25))
|
||||||
|
proc: BEGIN
|
||||||
|
/**
|
||||||
|
* Este procedimiento recalcula los componentes de un conjunto de sales,
|
||||||
|
* eliminando los componentes existentes e insertandolos de nuevo
|
||||||
|
*
|
||||||
|
* @param vOption si no se quiere forzar llamar con NULL
|
||||||
|
* @table tmp.recalculateSales (id)
|
||||||
|
*/
|
||||||
|
DECLARE vShipped DATE;
|
||||||
|
DECLARE vWarehouseFk SMALLINT;
|
||||||
|
DECLARE vAgencyModeFk INT;
|
||||||
|
DECLARE vAddressFk INT;
|
||||||
|
DECLARE vTicketFk INT;
|
||||||
|
DECLARE vLanded DATE;
|
||||||
|
DECLARE vIsEditable BOOLEAN;
|
||||||
|
DECLARE vZoneFk INTEGER;
|
||||||
|
DECLARE vDone BOOL DEFAULT FALSE;
|
||||||
|
|
||||||
|
DECLARE vCur CURSOR FOR
|
||||||
|
SELECT DISTINCT s.ticketFk
|
||||||
|
FROM tmp.recalculateSales rs
|
||||||
|
JOIN vn.sale s ON s.id = rs.id;
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
OPEN vCur;
|
||||||
|
|
||||||
|
l: LOOP
|
||||||
|
SET vDone = FALSE;
|
||||||
|
FETCH vCur INTO vTicketFk;
|
||||||
|
|
||||||
|
IF vDone THEN
|
||||||
|
LEAVE l;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT (hasToRecalcPrice OR ts.alertLevel IS NULL) AND t.refFk IS NULL,
|
||||||
|
t.zoneFk,
|
||||||
|
t.warehouseFk,
|
||||||
|
t.shipped,
|
||||||
|
t.addressFk,
|
||||||
|
t.agencyModeFk,
|
||||||
|
t.landed
|
||||||
|
INTO vIsEditable,
|
||||||
|
vZoneFk,
|
||||||
|
vWarehouseFk,
|
||||||
|
vShipped,
|
||||||
|
vAddressFk,
|
||||||
|
vAgencyModeFk,
|
||||||
|
vLanded
|
||||||
|
FROM ticket t
|
||||||
|
LEFT JOIN ticketState ts ON t.id = ts.ticketFk
|
||||||
|
LEFT JOIN alertLevel al ON al.id = ts.alertLevel
|
||||||
|
WHERE t.id = vTicketFk;
|
||||||
|
|
||||||
|
CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE);
|
||||||
|
|
||||||
|
IF NOT EXISTS (SELECT TRUE FROM tmp.zoneGetLanded LIMIT 1) THEN
|
||||||
|
CALL util.throw(CONCAT('There is no zone for these parameters ', vTicketFk));
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF vLanded IS NULL OR vZoneFk IS NULL THEN
|
||||||
|
|
||||||
|
UPDATE ticket t
|
||||||
|
SET t.landed = (SELECT landed FROM tmp.zoneGetLanded LIMIT 1)
|
||||||
|
WHERE t.id = vTicketFk AND t.landed IS NULL;
|
||||||
|
|
||||||
|
IF vZoneFk IS NULL THEN
|
||||||
|
SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetLanded LIMIT 1;
|
||||||
|
UPDATE ticket t
|
||||||
|
SET t.zoneFk = vZoneFk
|
||||||
|
WHERE t.id = vTicketFk AND t.zoneFk IS NULL;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tmp.zoneGetLanded;
|
||||||
|
|
||||||
|
-- rellena la tabla buyUltimate con la ultima compra
|
||||||
|
CALL buyUltimate (vWarehouseFk, vShipped);
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||||
|
(PRIMARY KEY (saleFk)) ENGINE = MEMORY
|
||||||
|
SELECT s.id saleFk, vWarehouseFk warehouseFk
|
||||||
|
FROM sale s
|
||||||
|
JOIN tmp.recalculateSales rs ON s.id = rs.id
|
||||||
|
WHERE s.ticketFk = vTicketFk;
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketLot
|
||||||
|
SELECT vWarehouseFk warehouseFk, NULL available, s.itemFk, bu.buyFk, vZoneFk zoneFk
|
||||||
|
FROM sale s
|
||||||
|
JOIN tmp.recalculateSales rs ON s.id = rs.id
|
||||||
|
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
||||||
|
WHERE s.ticketFk = vTicketFk
|
||||||
|
GROUP BY s.itemFk;
|
||||||
|
|
||||||
|
CALL catalog_componentPrepare();
|
||||||
|
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
|
||||||
|
|
||||||
|
IF vOption IS NULL THEN
|
||||||
|
SET vOption = IF(vIsEditable, 'renewPrices', 'imbalance');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
CALL ticketComponentUpdateSale(vOption);
|
||||||
|
CALL catalog_componentPurge();
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||||
|
DROP TEMPORARY TABLE tmp.sale;
|
||||||
|
|
||||||
|
END LOOP;
|
||||||
|
CLOSE vCur;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT)
|
||||||
|
BEGIN
|
||||||
|
/*
|
||||||
|
* Recalcula los componentes un ticket clonado,
|
||||||
|
* las lineas a precio cero fuerza para que tengan precio, el resto lo respeta
|
||||||
|
* @param vTicketNew nuevo ticket clonado
|
||||||
|
* @param vTicketOld icket original, a partir del qual se clonara el nuevo
|
||||||
|
*/
|
||||||
|
|
||||||
|
REPLACE INTO orderTicket(orderFk,ticketFk)
|
||||||
|
SELECT orderFk, vTicketNew
|
||||||
|
FROM orderTicket
|
||||||
|
WHERE ticketFk = vTicketOld;
|
||||||
|
|
||||||
|
-- Bionizamos lineas con Preu = 0
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
|
||||||
|
(PRIMARY KEY (id)) ENGINE = MEMORY
|
||||||
|
SELECT id
|
||||||
|
FROM sale
|
||||||
|
WHERE ticketFk = vTicketNew AND price = 0;
|
||||||
|
|
||||||
|
CALL sale_recalcComponent('renewPrices');
|
||||||
|
|
||||||
|
-- Bionizamos lineas con Preu > 0
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
|
||||||
|
(PRIMARY KEY (id)) ENGINE = MEMORY
|
||||||
|
SELECT id
|
||||||
|
FROM sale
|
||||||
|
WHERE ticketFk = vTicketNew AND price > 0;
|
||||||
|
|
||||||
|
CALL sale_recalcComponent('imbalance');
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketComponentUpdate`(
|
||||||
|
vTicketFk INT,
|
||||||
|
vClientFk INT,
|
||||||
|
vAgencyModeFk INT,
|
||||||
|
vAddressFk INT,
|
||||||
|
vWarehouseFk TINYINT,
|
||||||
|
vCompanyFk SMALLINT,
|
||||||
|
vShipped DATETIME,
|
||||||
|
vLanded DATE,
|
||||||
|
vIsDeleted BOOLEAN,
|
||||||
|
vHasToBeUnrouted BOOLEAN,
|
||||||
|
vOption VARCHAR(25))
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
|
BEGIN
|
||||||
|
ROLLBACK;
|
||||||
|
RESIGNAL;
|
||||||
|
END;
|
||||||
|
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
|
||||||
|
|
||||||
|
UPDATE ticket t
|
||||||
|
JOIN address a ON a.id = vAddressFk
|
||||||
|
SET t.nickname = a.nickname
|
||||||
|
WHERE t.id = vTicketFk;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
UPDATE ticket t
|
||||||
|
SET
|
||||||
|
t.clientFk = vClientFk,
|
||||||
|
t.agencyModeFk = vAgencyModeFk,
|
||||||
|
t.addressFk = vAddressFk,
|
||||||
|
t.warehouseFk = vWarehouseFk,
|
||||||
|
t.companyFk = vCompanyFk,
|
||||||
|
t.landed = vLanded,
|
||||||
|
t.shipped = vShipped,
|
||||||
|
t.isDeleted = vIsDeleted
|
||||||
|
WHERE
|
||||||
|
t.id = vTicketFk;
|
||||||
|
|
||||||
|
IF vHasToBeUnrouted THEN
|
||||||
|
UPDATE ticket t SET t.routeFk = NULL
|
||||||
|
WHERE t.id = vTicketFk;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
|
||||||
|
CREATE TEMPORARY TABLE tmp.sale
|
||||||
|
(PRIMARY KEY (saleFk))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT id AS saleFk, vWarehouseFk warehouseFk
|
||||||
|
FROM sale s WHERE s.ticketFk = vTicketFk;
|
||||||
|
|
||||||
|
CALL ticketComponentUpdateSale (vOption);
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tmp.sale;
|
||||||
|
COMMIT;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketComponentUpdateSale`(vCode VARCHAR(25))
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* A partir de la tabla tmp.sale, crea los Movimientos_componentes
|
||||||
|
* y modifica el campo Preu de la tabla Movimientos
|
||||||
|
*
|
||||||
|
* @param i_option integer tipo de actualizacion
|
||||||
|
* @param table tmp.sale tabla memory con el campo saleFk, warehouseFk
|
||||||
|
**/
|
||||||
|
DECLARE vComponentFk INT;
|
||||||
|
|
||||||
|
IF vCode <> 'renewPrices' THEN
|
||||||
|
SELECT id INTO vComponentFk FROM component WHERE `code` = vCode;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
DELETE sc.*
|
||||||
|
FROM tmp.sale tmps
|
||||||
|
JOIN saleComponent sc ON sc.saleFk = tmps.saleFk
|
||||||
|
JOIN `component` c ON c.id = sc.componentFk
|
||||||
|
WHERE c.isRenewable;
|
||||||
|
|
||||||
|
REPLACE INTO saleComponent(saleFk, componentFk, value)
|
||||||
|
SELECT s.id, tc.componentFk, tc.cost
|
||||||
|
FROM sale s
|
||||||
|
JOIN tmp.sale tmps ON tmps.saleFk = s.id
|
||||||
|
JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk
|
||||||
|
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||||
|
AND sc.componentFk = tc.componentFk
|
||||||
|
LEFT JOIN `component` c ON c.id = tc.componentFk
|
||||||
|
WHERE IF(sc.componentFk IS NULL AND NOT c.isRenewable, FALSE, TRUE);
|
||||||
|
|
||||||
|
-- Añadir componente venta por paquete
|
||||||
|
REPLACE INTO saleComponent(saleFk, componentFk, value)
|
||||||
|
SELECT t.id, t.componentFk, t.cost
|
||||||
|
FROM (
|
||||||
|
SELECT s.id, tc.componentFk, tc.cost, MOD(s.quantity, b.packing) as resto
|
||||||
|
FROM vn.sale s
|
||||||
|
JOIN tmp.sale tmps ON tmps.saleFk = s.id
|
||||||
|
JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND tmps.warehouseFk = lb.warehouse_id
|
||||||
|
JOIN vn.buy b ON b.id = buy_id
|
||||||
|
JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk
|
||||||
|
JOIN `component` c ON c.id = tc.componentFk AND c.code = 'salePerPackage'
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT s.id
|
||||||
|
FROM vn.sale s
|
||||||
|
JOIN tmp.sale tmps ON tmps.saleFk = s.id
|
||||||
|
JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk
|
||||||
|
JOIN saleComponent sc ON sc.saleFk = s.id AND sc.componentFk = tc.componentFk
|
||||||
|
JOIN `component` c ON c.id = sc.componentFk AND c.code = 'lastUnitsDiscount'
|
||||||
|
) tp ON tp.id = s.id
|
||||||
|
WHERE tp.id IS NULL
|
||||||
|
HAVING resto <> 0) t;
|
||||||
|
|
||||||
|
IF vCode <> 'renewPrices' THEN
|
||||||
|
REPLACE INTO saleComponent(saleFk, componentFk, value)
|
||||||
|
SELECT s.id, vComponentFk, ROUND((s.price * (100 - s.discount) / 100) - SUM(sc.value), 3) dif
|
||||||
|
FROM sale s
|
||||||
|
JOIN tmp.sale tmps ON tmps.saleFk = s.id
|
||||||
|
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||||
|
WHERE sc.saleFk <> vComponentFk
|
||||||
|
GROUP BY s.id
|
||||||
|
HAVING dif <> 0;
|
||||||
|
ELSE
|
||||||
|
UPDATE sale s
|
||||||
|
JOIN item i on i.id = s.itemFk
|
||||||
|
JOIN itemType it on it.id = i.typeFk
|
||||||
|
JOIN (SELECT SUM(sc.value) sumValue, sc.saleFk
|
||||||
|
FROM saleComponent sc
|
||||||
|
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
|
||||||
|
GROUP BY sc.saleFk) sc ON sc.saleFk = s.id
|
||||||
|
SET s.price = sumValue / ((100 - s.discount) / 100)
|
||||||
|
WHERE it.code != 'PRT' ;
|
||||||
|
|
||||||
|
REPLACE INTO saleComponent(saleFk, componentFk, value)
|
||||||
|
SELECT s.id, 21, ROUND((s.price * (100 - s.discount) / 100) - SUM(value), 3) saleValue
|
||||||
|
FROM sale s
|
||||||
|
JOIN tmp.sale tmps ON tmps.saleFk = s.id
|
||||||
|
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||||
|
WHERE sc.componentFk != 21
|
||||||
|
GROUP BY s.id
|
||||||
|
HAVING ROUND(saleValue, 4) <> 0;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
UPDATE sale s
|
||||||
|
JOIN (
|
||||||
|
SELECT SUM(sc.value) sumValue, sc.saleFk
|
||||||
|
FROM saleComponent sc
|
||||||
|
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
|
||||||
|
JOIN `component` c ON c.id = sc.componentFk
|
||||||
|
JOIN componentType ct on ct.id = c.typeFk AND ct.isBase
|
||||||
|
GROUP BY sc.saleFk) sc ON sc.saleFk = s.id
|
||||||
|
SET s.priceFixed = sumValue, s.isPriceFixed = 1;
|
||||||
|
|
||||||
|
DELETE sc.*
|
||||||
|
FROM saleComponent sc
|
||||||
|
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
|
||||||
|
JOIN sale s on s.id = sc.saleFk
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
JOIN itemType it ON it.id = i.typeFk
|
||||||
|
WHERE it.code = 'PRT';
|
||||||
|
|
||||||
|
INSERT INTO saleComponent(saleFk, componentFk, value)
|
||||||
|
SELECT s.id, 15, s.price
|
||||||
|
FROM sale s
|
||||||
|
JOIN tmp.sale tmps ON tmps.saleFk = s.id
|
||||||
|
JOIN item i ON i.id = s.itemFK
|
||||||
|
JOIN itemType it ON it.id = i.typeFk
|
||||||
|
WHERE it.code = 'PRT' AND s.price > 0;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_checkNoComponents`(vShippedFrom DATETIME, vShippedTo DATETIME)
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comprueba que los tickets entre un rango de fechas tienen componentes
|
||||||
|
* y recalcula sus componentes
|
||||||
|
*
|
||||||
|
* @param vShippedFrom rango inicial de fecha
|
||||||
|
* @param vShippedTo rango final de fecha
|
||||||
|
*/
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.coste
|
||||||
|
(primary key (id)) ENGINE = MEMORY
|
||||||
|
SELECT s.id
|
||||||
|
FROM ticket t
|
||||||
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
JOIN itemType tp ON tp.id = i.typeFk
|
||||||
|
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||||
|
JOIN saleComponent sc ON sc.saleFk = s.id
|
||||||
|
JOIN component c ON c.id = sc.componentFk
|
||||||
|
JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 1
|
||||||
|
WHERE t.shipped BETWEEN vShippedFrom AND vShippedTo
|
||||||
|
AND ic.merchandise;
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
|
||||||
|
(primary key (id)) ENGINE = MEMORY
|
||||||
|
SELECT DISTINCT s.id
|
||||||
|
FROM ticket t
|
||||||
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
JOIN itemType tp ON tp.id = i.typeFk
|
||||||
|
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||||
|
LEFT JOIN tmp.coste c ON c.id = s.id
|
||||||
|
WHERE t.shipped >= vShippedFrom AND t.shipped <= vShippedTo
|
||||||
|
AND c.id IS NULL
|
||||||
|
AND ic.merchandise;
|
||||||
|
|
||||||
|
CALL sale_recalcComponent('renewPrices');
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tmp.recalculateSales;
|
||||||
|
DROP TEMPORARY TABLE tmp.coste;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_componentMakeUpdate`(
|
||||||
|
vTicketFk INT,
|
||||||
|
vClientFk INT,
|
||||||
|
vNickname VARCHAR(50),
|
||||||
|
vAgencyModeFk INT,
|
||||||
|
vAddressFk INT,
|
||||||
|
vZoneFk INT,
|
||||||
|
vWarehouseFk INT,
|
||||||
|
vCompanyFk INT,
|
||||||
|
vShipped DATETIME,
|
||||||
|
vLanded DATE,
|
||||||
|
vIsDeleted BOOLEAN,
|
||||||
|
vHasToBeUnrouted BOOLEAN,
|
||||||
|
vOption VARCHAR(25))
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modifica en el ticket los campos que se le pasan por parámetro
|
||||||
|
* y cambia sus componentes
|
||||||
|
*
|
||||||
|
* @param vTicketFk Id del ticket a modificar
|
||||||
|
* @param vClientFk nuevo cliente
|
||||||
|
* @param vNickname nuevo alias
|
||||||
|
* @param vAgencyModeFk nueva agencia
|
||||||
|
* @param vAddressFk nuevo consignatario
|
||||||
|
* @param vZoneFk nueva zona
|
||||||
|
* @param vWarehouseFk nuevo almacen
|
||||||
|
* @param vCompanyFk nueva empresa
|
||||||
|
* @param vShipped nueva fecha del envio de mercancia
|
||||||
|
* @param vLanded nueva fecha de recepcion de mercancia
|
||||||
|
* @param vIsDeleted si se borra el ticket
|
||||||
|
* @param vHasToBeUnrouted si se le elimina la ruta al ticket
|
||||||
|
* @param vOption opcion para el case del proc ticketComponentUpdateSale
|
||||||
|
*/
|
||||||
|
|
||||||
|
DECLARE vPrice DECIMAL(10,2);
|
||||||
|
DECLARE vBonus DECIMAL(10,2);
|
||||||
|
|
||||||
|
CALL ticket_componentPreview (vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk);
|
||||||
|
|
||||||
|
IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
|
||||||
|
|
||||||
|
UPDATE ticket t
|
||||||
|
JOIN address a ON a.id = vAddressFk
|
||||||
|
SET t.nickname = a.nickname
|
||||||
|
WHERE t.id = vTicketFk;
|
||||||
|
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
CALL zone_getShipped(vLanded, vAddressFk, vAgencyModeFk, TRUE);
|
||||||
|
|
||||||
|
SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus
|
||||||
|
FROM tmp.zoneGetShipped
|
||||||
|
WHERE shipped BETWEEN DATE(vShipped) AND util.dayEnd(vShipped) AND warehouseFk = vWarehouseFk LIMIT 1;
|
||||||
|
|
||||||
|
UPDATE ticket t
|
||||||
|
SET
|
||||||
|
t.clientFk = vClientFk,
|
||||||
|
t.nickname = vNickname,
|
||||||
|
t.agencyModeFk = vAgencyModeFk,
|
||||||
|
t.addressFk = vAddressFk,
|
||||||
|
t.zoneFk = vZoneFk,
|
||||||
|
t.zonePrice = vPrice,
|
||||||
|
t.zoneBonus = vBonus,
|
||||||
|
t.warehouseFk = vWarehouseFk,
|
||||||
|
t.companyFk = vCompanyFk,
|
||||||
|
t.landed = vLanded,
|
||||||
|
t.shipped = vShipped,
|
||||||
|
t.isDeleted = vIsDeleted
|
||||||
|
WHERE
|
||||||
|
t.id = vTicketFk;
|
||||||
|
|
||||||
|
IF vHasToBeUnrouted THEN
|
||||||
|
UPDATE ticket t SET t.routeFk = NULL
|
||||||
|
WHERE t.id = vTicketFk;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
|
||||||
|
CREATE TEMPORARY TABLE tmp.sale
|
||||||
|
(PRIMARY KEY (saleFk))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT id AS saleFk, vWarehouseFk warehouseFk
|
||||||
|
FROM sale s WHERE s.ticketFk = vTicketFk;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent;
|
||||||
|
CREATE TEMPORARY TABLE tmp.ticketComponent
|
||||||
|
SELECT * FROM tmp.ticketComponentPreview;
|
||||||
|
|
||||||
|
CALL ticketComponentUpdateSale (vOption);
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tmp.sale;
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tmp.zoneGetShipped, tmp.ticketComponentPreview;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcComponents`(vSelf INT, vOption VARCHAR(25))
|
||||||
|
proc: BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crea tabla temporal para sale_recalcComponent() para recalcular los componentes
|
||||||
|
*
|
||||||
|
* @param vSelf Id del ticket
|
||||||
|
* @param vOption si no se quiere forzar llamar con NULL
|
||||||
|
*/
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.recalculateSales
|
||||||
|
SELECT s.id
|
||||||
|
FROM sale s
|
||||||
|
WHERE s.ticketFk = vSelf;
|
||||||
|
|
||||||
|
CALL sale_recalcComponent(vOption);
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tmp.recalculateSales;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
TRUNCATE TABLE `vn`.`ticketUpdateAction`;
|
||||||
|
INSERT INTO `vn`.`ticketUpdateAction` (id, description, code) VALUES(1, 'Cambiar los precios en el ticket', 'renewPrices');
|
||||||
|
INSERT INTO `vn`.`ticketUpdateAction` (id, description, code) VALUES(2, 'Convertir en maná', 'mana');
|
|
@ -600,6 +600,9 @@ INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`
|
||||||
('NATIONAL', 0, 1),
|
('NATIONAL', 0, 1),
|
||||||
('WORLD', 2, 15);
|
('WORLD', 2, 15);
|
||||||
|
|
||||||
|
INSERT INTO vn.invoiceOutConfig
|
||||||
|
SET parallelism = 8;
|
||||||
|
|
||||||
INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`)
|
INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`)
|
||||||
VALUES
|
VALUES
|
||||||
('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'),
|
('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'),
|
||||||
|
@ -623,9 +626,6 @@ UPDATE `vn`.`invoiceOut` SET ref = 'T3333333' WHERE id = 3;
|
||||||
UPDATE `vn`.`invoiceOut` SET ref = 'T4444444' WHERE id = 4;
|
UPDATE `vn`.`invoiceOut` SET ref = 'T4444444' WHERE id = 4;
|
||||||
UPDATE `vn`.`invoiceOut` SET ref = 'A1111111' WHERE id = 5;
|
UPDATE `vn`.`invoiceOut` SET ref = 'A1111111' WHERE id = 5;
|
||||||
|
|
||||||
INSERT INTO vn.invoiceOutConfig
|
|
||||||
SET parallelism = 8;
|
|
||||||
|
|
||||||
INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`)
|
INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 895.76, 89.58, 4722000010),
|
(1, 895.76, 89.58, 4722000010),
|
||||||
|
@ -929,25 +929,25 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`)
|
||||||
('VT', 'Sales');
|
('VT', 'Sales');
|
||||||
|
|
||||||
INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`,
|
INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`,
|
||||||
`comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`, `weightByPiece`)
|
`comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`, `weightByPiece`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'EMB', 0, NULL, 'V', 0, 15,3),
|
(1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 15,3),
|
||||||
(2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0, 10,2),
|
(2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 10,2),
|
||||||
(3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, 5,5),
|
(3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5,5),
|
||||||
(4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
(4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||||
(5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
(5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||||
(6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
(6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||||
(7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
(7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||||
(8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
(8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||||
(9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL,NULL),
|
(9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL,NULL),
|
||||||
(10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
(10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||||
(11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
(11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||||
(12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
(12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL),
|
||||||
(13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1, NULL,NULL),
|
(13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL,NULL),
|
||||||
(14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL,NULL),
|
(14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL,NULL),
|
||||||
(15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
|
(15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
|
||||||
(16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
|
(16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL,NULL),
|
||||||
(71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL);
|
(71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL,NULL);
|
||||||
|
|
||||||
-- Update the taxClass after insert of the items
|
-- Update the taxClass after insert of the items
|
||||||
UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2
|
UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2
|
||||||
|
@ -1426,16 +1426,29 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`)
|
||||||
(5, 6),
|
(5, 6),
|
||||||
(15, 6);
|
(15, 6);
|
||||||
|
|
||||||
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`)
|
INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk)
|
||||||
VALUES
|
VALUES
|
||||||
(1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1),
|
(1, '07546501420', 67, 671, util.VN_CURDATE(), 1761, 1, 1),
|
||||||
(2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2),
|
(2, '07546491421', 252, 2769, util.VN_CURDATE(), 5231, 1, 1),
|
||||||
(3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1),
|
(3, '07546500823', 102, 1495, util.VN_CURDATE(), 3221, 1, 1),
|
||||||
(4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2),
|
(4, '99610288821', 252, 2777, util.VN_CURDATE(), 3641, 1, 1),
|
||||||
(5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1),
|
(5, '07546500834', 229, 3292, util.VN_CURDATE(), 6601, 2, 1),
|
||||||
(6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2),
|
(6, '22101929561', 37, 458, util.VN_CURDATE(), 441, 2, 1),
|
||||||
(7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1),
|
(7, '07546491432', 258, 3034, util.VN_CURDATE(), 6441, 2, 1),
|
||||||
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2);
|
(8, '99610288644', 476, 4461, util.VN_CURDATE(), 5751, 442, 1),
|
||||||
|
(9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
|
||||||
|
(10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`)
|
||||||
|
VALUES
|
||||||
|
(1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1),
|
||||||
|
(2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2, 2),
|
||||||
|
(3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3),
|
||||||
|
(4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4),
|
||||||
|
(5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5),
|
||||||
|
(6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6),
|
||||||
|
(7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7),
|
||||||
|
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10);
|
||||||
|
|
||||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`)
|
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2499,20 +2512,7 @@ INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate
|
||||||
(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25),
|
(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25),
|
||||||
(util.VN_CURDATE(), 1, 12, 17, 22, 27);
|
(util.VN_CURDATE(), 1, 12, 17, 22, 27);
|
||||||
|
|
||||||
INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk)
|
INSERT INTO `vn`.`dua` (id, code, awbFk__, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk)
|
||||||
VALUES
|
|
||||||
(1, '07546501420', 67, 671, util.VN_CURDATE(), 1761, 1, 1),
|
|
||||||
(2, '07546491421', 252, 2769, util.VN_CURDATE(), 5231, 1, 1),
|
|
||||||
(3, '07546500823', 102, 1495, util.VN_CURDATE(), 3221, 1, 1),
|
|
||||||
(4, '99610288821', 252, 2777, util.VN_CURDATE(), 3641, 1, 1),
|
|
||||||
(5, '07546500834', 229, 3292, util.VN_CURDATE(), 6601, 2, 1),
|
|
||||||
(6, '22101929561', 37, 458, util.VN_CURDATE(), 441, 2, 1),
|
|
||||||
(7, '07546491432', 258, 3034, util.VN_CURDATE(), 6441, 2, 1),
|
|
||||||
(8, '99610288644', 476, 4461, util.VN_CURDATE(), 5751, 442, 1),
|
|
||||||
(9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1),
|
|
||||||
(10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1);
|
|
||||||
|
|
||||||
INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk)
|
|
||||||
VALUES
|
VALUES
|
||||||
(1, '19ES0028013A481523', 1, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442),
|
(1, '19ES0028013A481523', 1, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442),
|
||||||
(2, '21ES00280136115760', 2, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442),
|
(2, '21ES00280136115760', 2, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442),
|
||||||
|
@ -2525,6 +2525,17 @@ INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried,
|
||||||
(9, '19ES00280132025491', 9, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 7126.23, 442),
|
(9, '19ES00280132025491', 9, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 7126.23, 442),
|
||||||
(10, '19ES00280132025492', 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 4631.45, 442);
|
(10, '19ES00280132025492', 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 4631.45, 442);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroValue`)
|
||||||
|
VALUES
|
||||||
|
(1, 1, 1.00, 1.00, 1.00),
|
||||||
|
(2, 2, 1.00, 1.00, 1.00),
|
||||||
|
(3, 3, 1.00, 1.00, 1.00),
|
||||||
|
(4, 4, 1.00, 1.00, 1.00),
|
||||||
|
(5, 5, 1.00, 1.00, 1.00),
|
||||||
|
(6, 6, 1.00, 1.00, 1.00),
|
||||||
|
(7, 7, 1.00, 1.00, 1.00),
|
||||||
|
(8, 8, 1.00, 1.00, 1.00);
|
||||||
|
|
||||||
REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`)
|
REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1),
|
(1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1),
|
||||||
|
@ -2911,8 +2922,7 @@ INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `payMethodFk
|
||||||
|
|
||||||
INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`)
|
INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 12),
|
(24, 7);
|
||||||
(8, 10);
|
|
||||||
|
|
||||||
INSERT INTO `vn`.`deviceProductionModels` (`code`)
|
INSERT INTO `vn`.`deviceProductionModels` (`code`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -3011,6 +3021,15 @@ INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`)
|
||||||
(2, 'Error in sales details'),
|
(2, 'Error in sales details'),
|
||||||
(3, 'Error in customer data');
|
(3, 'Error in customer data');
|
||||||
|
|
||||||
|
UPDATE `vn`.`client`
|
||||||
|
SET fi='65004204V'
|
||||||
|
WHERE id=1;
|
||||||
|
|
||||||
|
UPDATE `vn`.`worker`
|
||||||
|
SET fi='59328808D'
|
||||||
|
WHERE id=1106;
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO `account`.`mailAliasAcl` (`mailAliasFk`, `roleFk`)
|
INSERT INTO `account`.`mailAliasAcl` (`mailAliasFk`, `roleFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1),
|
(1, 1),
|
||||||
|
@ -3021,3 +3040,17 @@ INSERT INTO `vn`.`docuwareTablet` (`tablet`,`description`)
|
||||||
VALUES
|
VALUES
|
||||||
('Tablet1','Jarvis tablet'),
|
('Tablet1','Jarvis tablet'),
|
||||||
('Tablet2','Avengers tablet');
|
('Tablet2','Avengers tablet');
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`sms` (`id`, `senderFk`, `sender`, `destination`, `message`, `statusCode`, `status`, `created`)
|
||||||
|
VALUES (1, 66, '111111111', '0001111111111', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE()),
|
||||||
|
(2, 66, '222222222', '0002222222222', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'PENDING', util.VN_CURDATE()),
|
||||||
|
(3, 66, '333333333', '0003333333333', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'ERROR', util.VN_CURDATE()),
|
||||||
|
(4, 66, '444444444', '0004444444444', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE());
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`)
|
||||||
|
VALUES(1, 1103, 1, NULL),
|
||||||
|
(2, 1103, 2, NULL),
|
||||||
|
(3, 1103, 3, 32),
|
||||||
|
(4, 1103, 4, 32),
|
||||||
|
(13, 1101, 1, NULL),
|
||||||
|
(14, 1101, 4, 27);
|
||||||
|
|
|
@ -27523,7 +27523,7 @@ DROP TABLE IF EXISTS `dua`;
|
||||||
CREATE TABLE `dua` (
|
CREATE TABLE `dua` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`code` varchar(45) DEFAULT NULL,
|
`code` varchar(45) DEFAULT NULL,
|
||||||
`awbFk` smallint(11) unsigned NOT NULL,
|
`awbFk__` smallint(11) unsigned NOT NULL,
|
||||||
`issued` date DEFAULT NULL,
|
`issued` date DEFAULT NULL,
|
||||||
`operated` date DEFAULT NULL,
|
`operated` date DEFAULT NULL,
|
||||||
`booked` date DEFAULT NULL,
|
`booked` date DEFAULT NULL,
|
||||||
|
@ -27534,12 +27534,10 @@ CREATE TABLE `dua` (
|
||||||
`ASIEN` double DEFAULT NULL,
|
`ASIEN` double DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `code_UNIQUE` (`code`),
|
UNIQUE KEY `code_UNIQUE` (`code`),
|
||||||
KEY `fk_awb_dua_awb_idx` (`awbFk`),
|
|
||||||
KEY `fk_dua_gestdoc1_idx` (`gestdocFk`),
|
KEY `fk_dua_gestdoc1_idx` (`gestdocFk`),
|
||||||
KEY `dua_fk4_idx` (`companyFk`),
|
KEY `dua_fk4_idx` (`companyFk`),
|
||||||
CONSTRAINT `duaCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE,
|
CONSTRAINT `duaCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE,
|
||||||
CONSTRAINT `dua_fk1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
CONSTRAINT `dua_fk1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
CONSTRAINT `dua_fk2` FOREIGN KEY (`awbFk`) REFERENCES `awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
@ -41404,6 +41402,7 @@ CREATE TABLE `travel` (
|
||||||
`agencyModeFk` int(11) DEFAULT NULL,
|
`agencyModeFk` int(11) DEFAULT NULL,
|
||||||
`clonedFrom` int(11) DEFAULT NULL,
|
`clonedFrom` int(11) DEFAULT NULL,
|
||||||
`editorFk` int(10) unsigned DEFAULT NULL,
|
`editorFk` int(10) unsigned DEFAULT NULL,
|
||||||
|
`awbFk` SMALLINT(11) UNSIGNED,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `shipment_1` (`shipped`,`landed`,`warehouseInFk`,`warehouseOutFk`,`agencyFk`,`agencyModeFk`,`ref`),
|
UNIQUE KEY `shipment_1` (`shipped`,`landed`,`warehouseInFk`,`warehouseOutFk`,`agencyFk`,`agencyModeFk`,`ref`),
|
||||||
KEY `agency_id` (`agencyFk`),
|
KEY `agency_id` (`agencyFk`),
|
||||||
|
@ -41418,7 +41417,8 @@ CREATE TABLE `travel` (
|
||||||
CONSTRAINT `travel_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`),
|
CONSTRAINT `travel_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`),
|
||||||
CONSTRAINT `travel_ibfk_1` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
|
CONSTRAINT `travel_ibfk_1` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
|
||||||
CONSTRAINT `travel_ibfk_2` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
|
CONSTRAINT `travel_ibfk_2` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
|
||||||
CONSTRAINT `travel_ibfk_3` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE
|
CONSTRAINT `travel_ibfk_3` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `travel_FK_1` FOREIGN KEY (`awbFk`) REFERENCES `awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci ROW_FORMAT=DYNAMIC;
|
) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci ROW_FORMAT=DYNAMIC;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
|
||||||
|
@ -81330,7 +81330,34 @@ USE `vn`;
|
||||||
/*!50001 SET collation_connection = utf8mb3_general_ci */;
|
/*!50001 SET collation_connection = utf8mb3_general_ci */;
|
||||||
/*!50001 CREATE ALGORITHM=UNDEFINED */
|
/*!50001 CREATE ALGORITHM=UNDEFINED */
|
||||||
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
|
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
|
||||||
/*!50001 VIEW `awbVolume` AS select `d`.`awbFk` AS `awbFk`,`b`.`stickers` * `i`.`density` * if(`p`.`volume` > 0,`p`.`volume`,`p`.`width` * `p`.`depth` * if(`p`.`height` = 0,`i`.`size` + 10,`p`.`height`)) / (`vc`.`aerealVolumetricDensity` * 1000) AS `volume`,`b`.`id` AS `buyFk` from ((((((((`buy` `b` join `item` `i` on(`b`.`itemFk` = `i`.`id`)) join `itemType` `it` on(`i`.`typeFk` = `it`.`id`)) join `packaging` `p` on(`p`.`id` = `b`.`packagingFk`)) join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`t`.`id` = `e`.`travelFk`)) join `duaEntry` `de` on(`de`.`entryFk` = `e`.`id`)) join `dua` `d` on(`d`.`id` = `de`.`duaFk`)) join `volumeConfig` `vc`) where `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1,1) */;
|
/*!50001 VIEW `awbVolume` AS SELECT `t`.`awbFk` AS `awbFk`,
|
||||||
|
`b`.`stickers` * `i`.`density` * IF(
|
||||||
|
`p`.`volume` > 0,
|
||||||
|
`p`.`volume`,
|
||||||
|
`p`.`width` * `p`.`depth` * IF(`p`.`height` = 0, `i`.`size` + 10, `p`.`height`)
|
||||||
|
) / (`vc`.`aerealVolumetricDensity` * 1000) AS `volume`,
|
||||||
|
`b`.`id` AS `buyFk`
|
||||||
|
FROM (
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(
|
||||||
|
`vn`.`buy` `b`
|
||||||
|
JOIN `vn`.`item` `i` ON(`b`.`itemFk` = `i`.`id`)
|
||||||
|
)
|
||||||
|
JOIN `vn`.`itemType` `it` ON(`i`.`typeFk` = `it`.`id`)
|
||||||
|
)
|
||||||
|
JOIN `vn`.`packaging` `p` ON(`p`.`id` = `b`.`packagingFk`)
|
||||||
|
)
|
||||||
|
JOIN `vn`.`entry` `e` ON(`b`.`entryFk` = `e`.`id`)
|
||||||
|
)
|
||||||
|
JOIN `vn`.`travel` `t` ON(`t`.`id` = `e`.`travelFk`)
|
||||||
|
)
|
||||||
|
JOIN `vn`.`volumeConfig` `vc`
|
||||||
|
)
|
||||||
|
WHERE `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1, 1)
|
||||||
|
AND t.awbFk*/;
|
||||||
/*!50001 SET character_set_client = @saved_cs_client */;
|
/*!50001 SET character_set_client = @saved_cs_client */;
|
||||||
/*!50001 SET character_set_results = @saved_cs_results */;
|
/*!50001 SET character_set_results = @saved_cs_results */;
|
||||||
/*!50001 SET collation_connection = @saved_col_connection */;
|
/*!50001 SET collation_connection = @saved_col_connection */;
|
||||||
|
|
|
@ -1,123 +0,0 @@
|
||||||
const app = require('vn-loopback/server/server');
|
|
||||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
|
||||||
|
|
||||||
// 2277 solucionar problema al testear procedimiento con start transaction / rollback
|
|
||||||
xdescribe('ticket_componentMakeUpdate()', () => {
|
|
||||||
it('should recalculate the ticket components without make modifications', async() => {
|
|
||||||
let stmts = [];
|
|
||||||
let stmt;
|
|
||||||
|
|
||||||
let params = {
|
|
||||||
ticketId: 11,
|
|
||||||
clientId: 1102,
|
|
||||||
agencyModeId: 2,
|
|
||||||
addressId: 122,
|
|
||||||
zoneId: 3,
|
|
||||||
warehouseId: 1,
|
|
||||||
companyId: 442,
|
|
||||||
isDeleted: 0,
|
|
||||||
hasToBeUnrouted: 0,
|
|
||||||
componentOption: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
stmts.push('START TRANSACTION');
|
|
||||||
|
|
||||||
stmt = new ParameterizedSQL('SELECT * FROM vn.ticket WHERE id = ?', [
|
|
||||||
params.ticketId
|
|
||||||
]);
|
|
||||||
stmts.push(stmt);
|
|
||||||
|
|
||||||
let originalTicketIndex = stmts.push(stmt) - 1;
|
|
||||||
|
|
||||||
stmt = new ParameterizedSQL('CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, DATE_ADD(CURDATE(), INTERVAL +1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY), ?, ?, ?)', [
|
|
||||||
params.ticketId,
|
|
||||||
params.clientId,
|
|
||||||
params.agencyModeId,
|
|
||||||
params.addressId,
|
|
||||||
params.zoneId,
|
|
||||||
params.warehouseId,
|
|
||||||
params.companyId,
|
|
||||||
params.isDeleted,
|
|
||||||
params.hasToBeUnrouted,
|
|
||||||
params.componentOption
|
|
||||||
]);
|
|
||||||
stmts.push(stmt);
|
|
||||||
|
|
||||||
stmt = new ParameterizedSQL('SELECT * FROM vn.ticket WHERE id = ?', [
|
|
||||||
params.ticketId
|
|
||||||
]);
|
|
||||||
stmts.push(stmt);
|
|
||||||
|
|
||||||
let updatedTicketIndex = stmts.push(stmt) - 1;
|
|
||||||
|
|
||||||
stmts.push('ROLLBACK');
|
|
||||||
|
|
||||||
let sql = ParameterizedSQL.join(stmts, ';');
|
|
||||||
let result = await app.models.Ticket.rawStmt(sql);
|
|
||||||
|
|
||||||
let originalTicketData = result[originalTicketIndex];
|
|
||||||
let updatedTicketData = result[updatedTicketIndex];
|
|
||||||
|
|
||||||
expect(originalTicketData[0].isDeleted).toEqual(updatedTicketData[0].isDeleted);
|
|
||||||
expect(originalTicketData[0].routeFk).toEqual(updatedTicketData[0].routeFk);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should delete and unroute a ticket and recalculate the components', async() => {
|
|
||||||
let stmts = [];
|
|
||||||
let stmt;
|
|
||||||
|
|
||||||
let params = {
|
|
||||||
ticketId: 11,
|
|
||||||
clientId: 1102,
|
|
||||||
agencyModeId: 2,
|
|
||||||
addressId: 122,
|
|
||||||
zoneId: 3,
|
|
||||||
warehouseId: 1,
|
|
||||||
companyId: 442,
|
|
||||||
isDeleted: 1,
|
|
||||||
hasToBeUnrouted: 1,
|
|
||||||
componentOption: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
stmts.push('START TRANSACTION');
|
|
||||||
|
|
||||||
stmt = new ParameterizedSQL('SELECT * FROM vn.ticket WHERE id = ?', [
|
|
||||||
params.ticketId
|
|
||||||
]);
|
|
||||||
stmts.push(stmt);
|
|
||||||
|
|
||||||
let originalTicketIndex = stmts.push(stmt) - 1;
|
|
||||||
|
|
||||||
stmt = new ParameterizedSQL('CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, DATE_ADD(CURDATE(), INTERVAL +1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY), ?, ?, ?)', [
|
|
||||||
params.ticketId,
|
|
||||||
params.clientId,
|
|
||||||
params.agencyModeId,
|
|
||||||
params.addressId,
|
|
||||||
params.zoneId,
|
|
||||||
params.warehouseId,
|
|
||||||
params.companyId,
|
|
||||||
params.isDeleted,
|
|
||||||
params.hasToBeUnrouted,
|
|
||||||
params.componentOption
|
|
||||||
]);
|
|
||||||
stmts.push(stmt);
|
|
||||||
|
|
||||||
stmt = new ParameterizedSQL('SELECT * FROM vn.ticket WHERE id = ?', [
|
|
||||||
params.ticketId
|
|
||||||
]);
|
|
||||||
stmts.push(stmt);
|
|
||||||
|
|
||||||
let updatedTicketIndex = stmts.push(stmt) - 1;
|
|
||||||
|
|
||||||
stmts.push('ROLLBACK');
|
|
||||||
|
|
||||||
let sql = ParameterizedSQL.join(stmts, ';');
|
|
||||||
let result = await app.models.Ticket.rawStmt(sql);
|
|
||||||
|
|
||||||
let originalTicketData = result[originalTicketIndex];
|
|
||||||
let updatedTicketData = result[updatedTicketIndex];
|
|
||||||
|
|
||||||
expect(originalTicketData[0].isDeleted).not.toEqual(updatedTicketData[0].isDeleted);
|
|
||||||
expect(originalTicketData[0].routeFk).not.toEqual(updatedTicketData[0].routeFk);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -56,63 +56,6 @@ describe('Worker time control path', () => {
|
||||||
expect(result).toContain(month);
|
expect(result).toContain(month);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should return error when insert 'out' of first entry`, async() => {
|
|
||||||
pending('https://redmine.verdnatura.es/issues/4707');
|
|
||||||
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
|
|
||||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm);
|
|
||||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
|
||||||
await page.respondToDialog('accept');
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should insert 'in' monday`, async() => {
|
|
||||||
pending('https://redmine.verdnatura.es/issues/4707');
|
|
||||||
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
|
|
||||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm);
|
|
||||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
|
|
||||||
await page.respondToDialog('accept');
|
|
||||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
|
|
||||||
|
|
||||||
expect(result).toEqual(eightAm);
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should insert 'out' monday`, async() => {
|
|
||||||
pending('https://redmine.verdnatura.es/issues/4707');
|
|
||||||
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
|
|
||||||
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, fourPm);
|
|
||||||
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
|
|
||||||
await page.respondToDialog('accept');
|
|
||||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText');
|
|
||||||
|
|
||||||
expect(result).toEqual(fourPm);
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should check Hank Pym worked 8:20 hours`, async() => {
|
|
||||||
pending('https://redmine.verdnatura.es/issues/4707');
|
|
||||||
await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '08:20 h.');
|
|
||||||
await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '08:20 h.');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should remove first entry of monday', async() => {
|
|
||||||
pending('https://redmine.verdnatura.es/issues/4707');
|
|
||||||
await page.waitForTextInElement(selectors.workerTimeControl.firstEntryOfMonday, eightAm);
|
|
||||||
await page.waitForTextInElement(selectors.workerTimeControl.secondEntryOfMonday, fourPm);
|
|
||||||
await page.waitToClick(selectors.workerTimeControl.firstEntryOfMondayDelete);
|
|
||||||
await page.respondToDialog('accept');
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Entry removed');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should be the 'out' the first entry of monday`, async() => {
|
|
||||||
pending('https://redmine.verdnatura.es/issues/4707');
|
|
||||||
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
|
|
||||||
|
|
||||||
expect(result).toEqual(fourPm);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should change week of month', async() => {
|
it('should change week of month', async() => {
|
||||||
await page.click(selectors.workerTimeControl.thrirdWeekDay);
|
await page.click(selectors.workerTimeControl.thrirdWeekDay);
|
||||||
const result = await page.getProperty(selectors.workerTimeControl.mondayWorkedHours, 'innerText');
|
const result = await page.getProperty(selectors.workerTimeControl.mondayWorkedHours, 'innerText');
|
||||||
|
|
|
@ -27,11 +27,8 @@ describe('Item Edit basic data path', () => {
|
||||||
|
|
||||||
it(`should edit the item basic data and confirm the item data was edited`, async() => {
|
it(`should edit the item basic data and confirm the item data was edited`, async() => {
|
||||||
const values = {
|
const values = {
|
||||||
name: 'Rose of Purity',
|
|
||||||
longName: 'RS Rose of Purity',
|
|
||||||
type: 'Anthurium',
|
type: 'Anthurium',
|
||||||
intrastat: 'Coral y materiales similares',
|
intrastat: 'Coral y materiales similares',
|
||||||
origin: 'Spain',
|
|
||||||
relevancy: 1,
|
relevancy: 1,
|
||||||
generic: 'Pallet',
|
generic: 'Pallet',
|
||||||
isActive: false,
|
isActive: false,
|
||||||
|
|
|
@ -188,17 +188,6 @@ describe('Ticket Edit sale path', () => {
|
||||||
expect(result).toContain('22.50');
|
expect(result).toContain('22.50');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check in the history that logs has been added', async() => {
|
|
||||||
pending('https://redmine.verdnatura.es/issues/5455');
|
|
||||||
await page.reload({waitUntil: ['networkidle0', 'domcontentloaded']});
|
|
||||||
await page.waitToClick(selectors.ticketSales.firstSaleHistoryButton);
|
|
||||||
await page.waitForSelector(selectors.ticketSales.firstSaleHistory);
|
|
||||||
const result = await page.countElement(selectors.ticketSales.firstSaleHistory);
|
|
||||||
|
|
||||||
expect(result).toBeGreaterThan(0);
|
|
||||||
await page.waitToClick(selectors.ticketSales.closeHistory);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should recalculate price of sales', async() => {
|
it('should recalculate price of sales', async() => {
|
||||||
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
||||||
await page.waitToClick(selectors.ticketSales.secondSaleCheckbox);
|
await page.waitToClick(selectors.ticketSales.secondSaleCheckbox);
|
||||||
|
@ -236,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.accessToSearchResult('16');
|
await page.accessToSearchResult('7');
|
||||||
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
|
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
|
||||||
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket);
|
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket);
|
||||||
await page.waitToClick(selectors.globalItems.acceptButton);
|
await page.waitToClick(selectors.globalItems.acceptButton);
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
// #2221 Local MySQL8 crashes when rest method Items/getBalance is called
|
|
||||||
xdescribe('Ticket diary path', () => {
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
page = (await getBrowser()).page;
|
|
||||||
await page.loginAndModule('employee', 'ticket');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await page.browser().close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should navigate to item diary from ticket sale and check the lines`, async() => {
|
|
||||||
await page.accessToSearchResult('1');
|
|
||||||
await page.waitToClick(selectors.ticketSummary.firstSaleItemId);
|
|
||||||
await page.waitToClick(selectors.ticketSummary.popoverDiaryButton);
|
|
||||||
await page.waitForState('item.card.diary');
|
|
||||||
|
|
||||||
const secondIdClass = await page.getClassName(selectors.itemDiary.secondTicketId);
|
|
||||||
const fourthBalanceClass = await page.getClassName(selectors.itemDiary.fourthBalance);
|
|
||||||
const firstBalanceClass = await page.getClassName(selectors.itemDiary.firstBalance);
|
|
||||||
|
|
||||||
expect(secondIdClass).toContain('message');
|
|
||||||
expect(fourthBalanceClass).toContain('message');
|
|
||||||
expect(firstBalanceClass).toContain('balance');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,114 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer.js';
|
|
||||||
|
|
||||||
// #1528 e2e claim/detail
|
|
||||||
xdescribe('Claim detail', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('salesPerson', 'claim');
|
|
||||||
await page.accessToSearchResult('1');
|
|
||||||
await page.accessToSection('claim.card.detail');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should add the first claimable item from ticket to the claim', async() => {
|
|
||||||
await page.waitToClick(selectors.claimDetail.addItemButton);
|
|
||||||
await page.waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket);
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the claim contains now two items', async() => {
|
|
||||||
const result = await page.countElement(selectors.claimDetail.claimDetailLine);
|
|
||||||
|
|
||||||
expect(result).toEqual(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should edit de first item claimed quantity', async() => {
|
|
||||||
await page.clearInput(selectors.claimDetail.firstItemQuantityInput); // selector deleted, find new upon fixes
|
|
||||||
await page.write(selectors.claimDetail.firstItemQuantityInput, '4'); // selector deleted, find new upon fixes
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the first item quantity, and the claimed total were correctly edited', async() => {
|
|
||||||
const claimedQuantity = page
|
|
||||||
.waitToGetProperty(selectors.claimDetail.firstItemQuantityInput, 'value'); // selector deleted, find new upon fixes
|
|
||||||
|
|
||||||
const totalClaimed = page
|
|
||||||
.waitToGetProperty(selectors.claimDetail.totalClaimed, 'innerText');
|
|
||||||
|
|
||||||
expect(claimedQuantity).toEqual('4');
|
|
||||||
expect(totalClaimed).toContain('€47.62');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should login as salesAssistant and navigate to the claim.detail section', async() => {
|
|
||||||
await page.loginAndModule('salesAssistant', 'claim');
|
|
||||||
await page.accessToSearchResult('1');
|
|
||||||
await page.accessToSection('claim.card.detail');
|
|
||||||
let url = await page.expectURL('/detail'); // replace with waitForState
|
|
||||||
|
|
||||||
expect(url).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should edit de second item claimed discount', async() => {
|
|
||||||
await page.waitToClick(selectors.claimDetail.secondItemDiscount);
|
|
||||||
await page.write(selectors.claimDetail.discount, '100');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check the mana is the expected one', async() => {
|
|
||||||
await page.waitToClick(selectors.claimDetail.secondItemDiscount);
|
|
||||||
const result = await page.waitToGetProperty(selectors.claimDetail.discoutPopoverMana, 'innerText');
|
|
||||||
|
|
||||||
expect(result).toContain('MANÁ: €106');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should delete the second item from the claim', async() => {
|
|
||||||
await page.waitToClick(selectors.claimDetail.secondItemDeleteButton);
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the claim contains now one item', async() => {
|
|
||||||
const result = await page.countElement(selectors.claimDetail.claimDetailLine);
|
|
||||||
|
|
||||||
expect(result).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should add the deleted ticket from to the claim', async() => {
|
|
||||||
await page.waitToClick(selectors.claimDetail.addItemButton);
|
|
||||||
await page.waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket);
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should have been redirected to the next section in claims`, async() => {
|
|
||||||
let url = await page.expectURL('development'); // replace with waitForState
|
|
||||||
|
|
||||||
expect(url).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should navigate back to claim.detail to confirm the claim contains now two items', async() => {
|
|
||||||
await page.accessToSection('claim.card.detail');
|
|
||||||
await page.waitForSelector(selectors.claimDetail.claimDetailLine);
|
|
||||||
const result = await page.countElement(selectors.claimDetail.claimDetailLine);
|
|
||||||
|
|
||||||
expect(result).toEqual(2);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -105,17 +105,4 @@ describe('Travel basic data path', () => {
|
||||||
it(`should check the received checkbox was saved even tho it doesn't make sense`, async() => {
|
it(`should check the received checkbox was saved even tho it doesn't make sense`, async() => {
|
||||||
await page.waitForClassPresent(selectors.travelBasicData.received, 'checked');
|
await page.waitForClassPresent(selectors.travelBasicData.received, 'checked');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate to the travel logs', async() => {
|
|
||||||
pending('https://redmine.verdnatura.es/issues/5455');
|
|
||||||
await page.accessToSection('travel.card.log');
|
|
||||||
await page.waitForState('travel.card.log');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check the 1st log contains details from the changes made', async() => {
|
|
||||||
pending('https://redmine.verdnatura.es/issues/5455');
|
|
||||||
const result = await page.waitToGetProperty(selectors.travelLog.firstLogFirstTD, 'innerText');
|
|
||||||
|
|
||||||
expect(result).toContain('new reference!');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,18 +33,6 @@ describe('Component vnTreeview', () => {
|
||||||
$element.remove();
|
$element.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
// See how to test DOM element in Jest
|
|
||||||
xdescribe('undrop()', () => {
|
|
||||||
it(`should reset all drop events and properties`, () => {
|
|
||||||
controller.dropping = angular.element(`<vn-treeview-child class="dropping"></vn-treeview-child>`);
|
|
||||||
jest.spyOn(controller.dropping.classList, 'remove');
|
|
||||||
|
|
||||||
controller.undrop();
|
|
||||||
|
|
||||||
expect(controller.dropping).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('dragOver()', () => {
|
describe('dragOver()', () => {
|
||||||
it(`should set the dragClientY property`, () => {
|
it(`should set the dragClientY property`, () => {
|
||||||
const event = new Event('dragover');
|
const event = new Event('dragover');
|
||||||
|
|
|
@ -23,7 +23,6 @@ export function directive($translate, $window) {
|
||||||
let rule = $attrs.rule.split('.');
|
let rule = $attrs.rule.split('.');
|
||||||
let modelName = rule.shift();
|
let modelName = rule.shift();
|
||||||
let fieldName = rule.shift();
|
let fieldName = rule.shift();
|
||||||
|
|
||||||
let split = $attrs.ngModel.split('.');
|
let split = $attrs.ngModel.split('.');
|
||||||
if (!fieldName) fieldName = split.pop() || null;
|
if (!fieldName) fieldName = split.pop() || null;
|
||||||
if (!modelName) modelName = firstUpper(split.pop() || '');
|
if (!modelName) modelName = firstUpper(split.pop() || '');
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
async function handleObserve(ctx) {
|
||||||
|
ctx.options.httpCtx = LoopBackContext.getCurrentContext();
|
||||||
|
}
|
||||||
|
module.exports = function(Self) {
|
||||||
|
let Mixin = {
|
||||||
|
'before save': handleObserve,
|
||||||
|
'before delete': handleObserve,
|
||||||
|
};
|
||||||
|
for (const [listener, handler] of Object.entries(Mixin))
|
||||||
|
Self.observe(listener, handler);
|
||||||
|
};
|
|
@ -1,15 +0,0 @@
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
module.exports = function(Self) {
|
|
||||||
Self.setup = function() {
|
|
||||||
Self.super_.setup.call(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
Self.observe('before save', async function(ctx) {
|
|
||||||
ctx.options.httpCtx = LoopBackContext.getCurrentContext();
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.observe('before delete', async function(ctx) {
|
|
||||||
ctx.options.httpCtx = LoopBackContext.getCurrentContext();
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Loggable",
|
|
||||||
"base": "VnModel",
|
|
||||||
"validateUpsert": true
|
|
||||||
}
|
|
|
@ -69,8 +69,7 @@
|
||||||
"Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})",
|
"Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
"Change quantity": "{{concept}} change of {{oldQuantity}} to {{newQuantity}}",
|
"Change quantity": "{{concept}} change of {{oldQuantity}} to {{newQuantity}}",
|
||||||
"Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked",
|
"Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked",
|
||||||
"Claim state has changed to incomplete": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *incomplete*",
|
"Claim state has changed to": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *{{newState}}*",
|
||||||
"Claim state has changed to canceled": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *canceled*",
|
|
||||||
"Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member",
|
"Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member",
|
||||||
"Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member",
|
"Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member",
|
||||||
"Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}",
|
"Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}",
|
||||||
|
|
|
@ -136,8 +136,7 @@
|
||||||
"Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})",
|
"Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
"Change quantity": "{{concept}} cambia de {{oldQuantity}} a {{newQuantity}}",
|
"Change quantity": "{{concept}} cambia de {{oldQuantity}} a {{newQuantity}}",
|
||||||
"Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*",
|
"Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*",
|
||||||
"Claim state has changed to incomplete": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *incompleta*",
|
"Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*",
|
||||||
"Claim state has changed to canceled": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *anulado*",
|
|
||||||
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
|
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
|
||||||
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
|
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
|
||||||
"Distance must be lesser than 1000": "La distancia debe ser inferior a 1000",
|
"Distance must be lesser than 1000": "La distancia debe ser inferior a 1000",
|
||||||
|
@ -332,6 +331,7 @@
|
||||||
"quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima",
|
"quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima",
|
||||||
"Cannot past travels with entries": "No se pueden pasar envíos con entradas",
|
"Cannot past travels with entries": "No se pueden pasar envíos con entradas",
|
||||||
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
|
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
|
||||||
|
"This claim has been updated": "La reclamación con Id: {{claimId}}, ha sido actualizada",
|
||||||
"This user does not have an assigned tablet": "Este usuario no tiene tablet asignada",
|
"This user does not have an assigned tablet": "Este usuario no tiene tablet asignada",
|
||||||
"Incorrect pin": "Pin incorrecto.",
|
"Incorrect pin": "Pin incorrecto.",
|
||||||
"You already have the mailAlias": "Ya tienes este alias de correo",
|
"You already have the mailAlias": "Ya tienes este alias de correo",
|
||||||
|
|
|
@ -270,8 +270,8 @@ class VnMySQL extends MySQL {
|
||||||
|
|
||||||
isLoggable(model) {
|
isLoggable(model) {
|
||||||
const Model = this.getModelDefinition(model).model;
|
const Model = this.getModelDefinition(model).model;
|
||||||
const settings = Model.definition.settings;
|
const {settings} = Model.definition;
|
||||||
return settings.base && settings.base === 'Loggable';
|
return settings.mixins?.Loggable;
|
||||||
}
|
}
|
||||||
|
|
||||||
invokeMethod(method, args, model, ctx, opts, cb) {
|
invokeMethod(method, args, model, ctx, opts, cb) {
|
||||||
|
@ -291,7 +291,7 @@ class VnMySQL extends MySQL {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const userId = opts.httpCtx && opts.httpCtx.active.accessToken.userId;
|
const userId = opts.httpCtx && opts.httpCtx.active?.accessToken?.userId;
|
||||||
if (userId) {
|
if (userId) {
|
||||||
const user = await Model.app.models.VnUser.findById(userId, {fields: ['name']}, opts);
|
const user = await Model.app.models.VnUser.findById(userId, {fields: ['name']}, opts);
|
||||||
await this.executeP(`CALL account.myUser_loginWithName(?)`, [user.name], opts);
|
await this.executeP(`CALL account.myUser_loginWithName(?)`, [user.name], opts);
|
||||||
|
|
|
@ -25,20 +25,19 @@
|
||||||
"FieldAcl": {
|
"FieldAcl": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"Role": {
|
|
||||||
"dataSource": "vn",
|
|
||||||
"options": {
|
|
||||||
"mysql": {
|
|
||||||
"table": "salix.Role"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"RoleMapping": {
|
"RoleMapping": {
|
||||||
"dataSource": "vn",
|
"dataSource": "vn",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "salix.RoleMapping"
|
"table": "salix.RoleMapping"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"role": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "VnRole",
|
||||||
|
"foreignKey": "roleId"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Schema": {
|
"Schema": {
|
||||||
|
|
|
@ -1,49 +1,49 @@
|
||||||
{
|
{
|
||||||
"name": "Account",
|
"name": "Account",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "account.account"
|
"table": "account.account"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"id": true
|
"id": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"user": {
|
"user": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "id"
|
"foreignKey": "id"
|
||||||
},
|
|
||||||
"aliases": {
|
|
||||||
"type": "hasMany",
|
|
||||||
"model": "MailAliasAccount",
|
|
||||||
"foreignKey": "account"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"acls": [
|
|
||||||
{
|
|
||||||
"property": "login",
|
|
||||||
"accessType": "EXECUTE",
|
|
||||||
"principalType": "ROLE",
|
|
||||||
"principalId": "$everyone",
|
|
||||||
"permission": "ALLOW"
|
|
||||||
},
|
},
|
||||||
{
|
"aliases": {
|
||||||
|
"type": "hasMany",
|
||||||
|
"model": "MailAliasAccount",
|
||||||
|
"foreignKey": "account"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"acls": [
|
||||||
|
{
|
||||||
|
"property": "login",
|
||||||
|
"accessType": "EXECUTE",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
},
|
||||||
|
{
|
||||||
"property": "logout",
|
"property": "logout",
|
||||||
"accessType": "EXECUTE",
|
"accessType": "EXECUTE",
|
||||||
"principalType": "ROLE",
|
"principalType": "ROLE",
|
||||||
"principalId": "$authenticated",
|
"principalId": "$authenticated",
|
||||||
"permission": "ALLOW"
|
"permission": "ALLOW"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"property": "changePassword",
|
"property": "changePassword",
|
||||||
"accessType": "EXECUTE",
|
"accessType": "EXECUTE",
|
||||||
"principalType": "ROLE",
|
"principalType": "ROLE",
|
||||||
"principalId": "$everyone",
|
"principalId": "$everyone",
|
||||||
"permission": "ALLOW"
|
"permission": "ALLOW"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
// Prepare data
|
// Prepare data
|
||||||
|
|
||||||
let roles = await $.Role.find({
|
let roles = await $.VnRole.find({
|
||||||
fields: ['id', 'name', 'description']
|
fields: ['id', 'name', 'description']
|
||||||
});
|
});
|
||||||
let roleRoles = await $.RoleRole.find({
|
let roleRoles = await $.RoleRole.find({
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
"relations": {
|
"relations": {
|
||||||
"owner": {
|
"owner": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Role",
|
"model": "VnRole",
|
||||||
"foreignKey": "role"
|
"foreignKey": "role"
|
||||||
},
|
},
|
||||||
"inherits": {
|
"inherits": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Role",
|
"model": "VnRole",
|
||||||
"foreignKey": "inheritsFrom"
|
"foreignKey": "inheritsFrom"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
"relations": {
|
"relations": {
|
||||||
"owner": {
|
"owner": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Role",
|
"model": "VnRole",
|
||||||
"foreignKey": "role"
|
"foreignKey": "role"
|
||||||
},
|
},
|
||||||
"inherits": {
|
"inherits": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Role",
|
"model": "VnRole",
|
||||||
"foreignKey": "inheritsFrom"
|
"foreignKey": "inheritsFrom"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Role"
|
label="Role"
|
||||||
ng-model="$ctrl.acl.principalId"
|
ng-model="$ctrl.acl.principalId"
|
||||||
url="Roles"
|
url="VnRoles"
|
||||||
id-field="name"
|
id-field="name"
|
||||||
value-field="name"
|
value-field="name"
|
||||||
vn-focus>
|
vn-focus>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Role"
|
label="Role"
|
||||||
ng-model="filter.principalId"
|
ng-model="filter.principalId"
|
||||||
url="Roles"
|
url="VnRoles"
|
||||||
value-field="name">
|
value-field="name">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Role"
|
label="Role"
|
||||||
ng-model="$ctrl.user.roleFk"
|
ng-model="$ctrl.user.roleFk"
|
||||||
url="Roles"
|
url="VnRoles"
|
||||||
rule="VnUser">
|
rule="VnUser">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Role"
|
label="Role"
|
||||||
ng-model="$ctrl.user.roleFk"
|
ng-model="$ctrl.user.roleFk"
|
||||||
url="Roles">
|
url="VnRoles">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
|
|
@ -1,25 +1,27 @@
|
||||||
<vn-watcher
|
<vn-watcher
|
||||||
vn-id="watcher"
|
vn-id="watcher"
|
||||||
url="Roles"
|
url="VnRoles"
|
||||||
data="$ctrl.role"
|
data="$ctrl.role"
|
||||||
form="form">
|
form="form">
|
||||||
</vn-watcher>
|
</vn-watcher>
|
||||||
<form
|
<form
|
||||||
name="form"
|
name="form"
|
||||||
ng-submit="watcher.submit()"
|
ng-submit="watcher.submit()"
|
||||||
|
|
||||||
class="vn-w-md">
|
class="vn-w-md">
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Name"
|
label="Name"
|
||||||
ng-model="$ctrl.role.name"
|
ng-model="$ctrl.role.name"
|
||||||
rule
|
rule="VnRole.name"
|
||||||
vn-focus>
|
vn-focus>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Description"
|
label="Description"
|
||||||
ng-model="$ctrl.role.description"
|
ng-model="$ctrl.role.description"
|
||||||
rule>
|
rule="VnRole.description"
|
||||||
|
>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import ModuleCard from 'salix/components/module-card';
|
||||||
|
|
||||||
class Controller extends ModuleCard {
|
class Controller extends ModuleCard {
|
||||||
reload() {
|
reload() {
|
||||||
this.$http.get(`Roles/${this.$params.id}`)
|
this.$http.get(`VnRoles/${this.$params.id}`)
|
||||||
.then(res => this.role = res.data);
|
.then(res => this.role = res.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import './index';
|
import './index';
|
||||||
|
|
||||||
describe('component vnRoleCard', () => {
|
fdescribe('component vnRoleCard', () => {
|
||||||
let controller;
|
let controller;
|
||||||
let $httpBackend;
|
let $httpBackend;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ describe('component vnRoleCard', () => {
|
||||||
it('should reload the controller data', () => {
|
it('should reload the controller data', () => {
|
||||||
controller.$params.id = 1;
|
controller.$params.id = 1;
|
||||||
|
|
||||||
$httpBackend.expectGET('Roles/1').respond('foo');
|
$httpBackend.expectGET('VnRoles/1').respond('foo');
|
||||||
controller.reload();
|
controller.reload();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<vn-watcher
|
<vn-watcher
|
||||||
vn-id="watcher"
|
vn-id="watcher"
|
||||||
url="Roles"
|
url="VnRoles"
|
||||||
data="$ctrl.role"
|
data="$ctrl.role"
|
||||||
insert-mode="true"
|
insert-mode="true"
|
||||||
form="form">
|
form="form">
|
||||||
|
@ -14,13 +14,13 @@
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Name"
|
label="Name"
|
||||||
ng-model="$ctrl.role.name"
|
ng-model="$ctrl.role.name"
|
||||||
rule
|
rule="VnRole.name"
|
||||||
vn-focus>
|
vn-focus>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
label="Description"
|
label="Description"
|
||||||
ng-model="$ctrl.role.description"
|
ng-model="$ctrl.role.description"
|
||||||
rule>
|
rule="VnRole.description">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Controller extends Descriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
onDelete() {
|
onDelete() {
|
||||||
return this.$http.delete(`Roles/${this.id}`)
|
return this.$http.delete(`VnRoles/${this.id}`)
|
||||||
.then(() => this.$state.go('account.role'))
|
.then(() => this.$state.go('account.role'))
|
||||||
.then(() => this.vnApp.showSuccess(this.$t('Role removed')));
|
.then(() => this.vnApp.showSuccess(this.$t('Role removed')));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import './index';
|
import './index';
|
||||||
|
|
||||||
describe('component vnRoleDescriptor', () => {
|
fdescribe('component vnRoleDescriptor', () => {
|
||||||
let controller;
|
let controller;
|
||||||
let $httpBackend;
|
let $httpBackend;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ describe('component vnRoleDescriptor', () => {
|
||||||
controller.$state.go = jest.fn();
|
controller.$state.go = jest.fn();
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
$httpBackend.expectDELETE('Roles/1').respond();
|
$httpBackend.expectDELETE('VnRoles/1').respond();
|
||||||
controller.onDelete();
|
controller.onDelete();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="Roles"
|
url="VnRoles"
|
||||||
filter="::$ctrl.filter"
|
filter="::$ctrl.filter"
|
||||||
limit="20">
|
limit="20">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="Role"
|
label="Role"
|
||||||
ng-model="$ctrl.addData.inheritsFrom"
|
ng-model="$ctrl.addData.inheritsFrom"
|
||||||
url="Roles"
|
url="VnRoles"
|
||||||
vn-focus>
|
vn-focus>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</tpl-body>
|
</tpl-body>
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Controller extends Component {
|
||||||
this._role = value;
|
this._role = value;
|
||||||
this.$.summary = null;
|
this.$.summary = null;
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
this.$http.get(`Roles/${value.id}`)
|
this.$http.get(`VnRoles/${value.id}`)
|
||||||
.then(res => this.$.summary = res.data);
|
.then(res => this.$.summary = res.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
vn-one
|
vn-one
|
||||||
label="Role"
|
label="Role"
|
||||||
ng-model="filter.roleFk"
|
ng-model="filter.roleFk"
|
||||||
url="Roles"
|
url="VnRoles"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
show-field="name">
|
show-field="name">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
|
|
@ -120,7 +120,7 @@ module.exports = Self => {
|
||||||
observationTypeFk: obsevationType.id
|
observationTypeFk: obsevationType.id
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
await models.TicketTracking.create({
|
await models.Ticket.state(ctx, {
|
||||||
ticketFk: newRefundTicket.id,
|
ticketFk: newRefundTicket.id,
|
||||||
stateFk: state.id,
|
stateFk: state.id,
|
||||||
userFk: worker.id
|
userFk: worker.id
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
const i18n = require('i18n');
|
||||||
describe('Update Claim', () => {
|
describe('Update Claim', () => {
|
||||||
let url;
|
let url;
|
||||||
|
let claimStatesMap = {};
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
url = await app.models.Url.getUrl();
|
url = await app.models.Url.getUrl();
|
||||||
const activeCtx = {
|
const activeCtx = {
|
||||||
|
@ -16,6 +17,8 @@ describe('Update Claim', () => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
active: activeCtx
|
active: activeCtx
|
||||||
});
|
});
|
||||||
|
const claimStates = await app.models.ClaimState.find();
|
||||||
|
claimStatesMap = claimStates.reduce((acc, state) => ({...acc, [state.code]: state.id}), {});
|
||||||
});
|
});
|
||||||
const newDate = Date.vnNew();
|
const newDate = Date.vnNew();
|
||||||
const originalData = {
|
const originalData = {
|
||||||
|
@ -62,6 +65,123 @@ describe('Update Claim', () => {
|
||||||
expect(error.message).toEqual(`You don't have enough privileges to change that field`);
|
expect(error.message).toEqual(`You don't have enough privileges to change that field`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it(`should success to update the claimState to 'pending' and send a rocket message`, async() => {
|
||||||
|
const tx = await app.models.Claim.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const newClaim = await app.models.Claim.create(originalData, options);
|
||||||
|
|
||||||
|
const chatModel = app.models.Chat;
|
||||||
|
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
|
||||||
|
|
||||||
|
const pendingState = claimStatesMap.pending;
|
||||||
|
const claimManagerId = 72;
|
||||||
|
const ctx = {
|
||||||
|
req: {
|
||||||
|
accessToken: {userId: claimManagerId},
|
||||||
|
headers: {origin: url}
|
||||||
|
},
|
||||||
|
args: {
|
||||||
|
observation: 'valid observation',
|
||||||
|
claimStateFk: pendingState,
|
||||||
|
hasToPickUp: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ctx.req.__ = i18n.__;
|
||||||
|
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
|
||||||
|
|
||||||
|
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
|
||||||
|
|
||||||
|
expect(updatedClaim.observation).toEqual(ctx.args.observation);
|
||||||
|
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should success to update the claimState to 'managed' and send a rocket message`, async() => {
|
||||||
|
const tx = await app.models.Claim.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const newClaim = await app.models.Claim.create(originalData, options);
|
||||||
|
|
||||||
|
const chatModel = app.models.Chat;
|
||||||
|
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
|
||||||
|
|
||||||
|
const managedState = claimStatesMap.managed;
|
||||||
|
const claimManagerId = 72;
|
||||||
|
const ctx = {
|
||||||
|
req: {
|
||||||
|
accessToken: {userId: claimManagerId},
|
||||||
|
headers: {origin: url}
|
||||||
|
},
|
||||||
|
args: {
|
||||||
|
observation: 'valid observation',
|
||||||
|
claimStateFk: managedState,
|
||||||
|
hasToPickUp: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ctx.req.__ = i18n.__;
|
||||||
|
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
|
||||||
|
|
||||||
|
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
|
||||||
|
|
||||||
|
expect(updatedClaim.observation).toEqual(ctx.args.observation);
|
||||||
|
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should success to update the claimState to 'resolved' and send a rocket message`, async() => {
|
||||||
|
const tx = await app.models.Claim.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const newClaim = await app.models.Claim.create(originalData, options);
|
||||||
|
|
||||||
|
const chatModel = app.models.Chat;
|
||||||
|
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
|
||||||
|
|
||||||
|
const resolvedState = claimStatesMap.resolved;
|
||||||
|
const claimManagerId = 72;
|
||||||
|
const ctx = {
|
||||||
|
req: {
|
||||||
|
accessToken: {userId: claimManagerId},
|
||||||
|
headers: {origin: url}
|
||||||
|
},
|
||||||
|
args: {
|
||||||
|
observation: 'valid observation',
|
||||||
|
claimStateFk: resolvedState,
|
||||||
|
hasToPickUp: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ctx.req.__ = i18n.__;
|
||||||
|
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
|
||||||
|
|
||||||
|
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
|
||||||
|
|
||||||
|
expect(updatedClaim.observation).toEqual(ctx.args.observation);
|
||||||
|
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it(`should success to update the claimState to 'canceled' and send a rocket message`, async() => {
|
it(`should success to update the claimState to 'canceled' and send a rocket message`, async() => {
|
||||||
const tx = await app.models.Claim.beginTransaction({});
|
const tx = await app.models.Claim.beginTransaction({});
|
||||||
|
|
||||||
|
@ -73,7 +193,7 @@ describe('Update Claim', () => {
|
||||||
const chatModel = app.models.Chat;
|
const chatModel = app.models.Chat;
|
||||||
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
|
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
|
||||||
|
|
||||||
const canceledState = 4;
|
const canceledState = claimStatesMap.canceled;
|
||||||
const claimManagerId = 72;
|
const claimManagerId = 72;
|
||||||
const ctx = {
|
const ctx = {
|
||||||
req: {
|
req: {
|
||||||
|
@ -86,9 +206,7 @@ describe('Update Claim', () => {
|
||||||
hasToPickUp: false
|
hasToPickUp: false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ctx.req.__ = (value, params) => {
|
ctx.req.__ = i18n.__;
|
||||||
return params.nickname;
|
|
||||||
};
|
|
||||||
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
|
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
|
||||||
|
|
||||||
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
|
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
|
||||||
|
@ -127,9 +245,7 @@ describe('Update Claim', () => {
|
||||||
hasToPickUp: false
|
hasToPickUp: false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ctx.req.__ = (value, params) => {
|
ctx.req.__ = i18n.__;
|
||||||
return params.nickname;
|
|
||||||
};
|
|
||||||
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
|
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
|
||||||
|
|
||||||
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
|
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
|
||||||
|
@ -168,9 +284,7 @@ describe('Update Claim', () => {
|
||||||
hasToPickUp: true
|
hasToPickUp: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ctx.req.__ = (value, params) => {
|
ctx.req.__ = i18n.__;
|
||||||
return params.nickname;
|
|
||||||
};
|
|
||||||
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
|
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
|
||||||
|
|
||||||
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
|
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
|
||||||
|
|
|
@ -96,12 +96,9 @@ module.exports = Self => {
|
||||||
// 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);
|
||||||
if (newState.hasToNotify) {
|
await notifyStateChange(ctx, salesPerson.id, claim, newState.code);
|
||||||
if (newState.code == 'incomplete')
|
if (newState.code == 'canceled')
|
||||||
await notifyStateChange(ctx, salesPerson.id, claim, newState.code);
|
await notifyStateChange(ctx, claim.workerFk, claim, newState.code);
|
||||||
if (newState.code == 'canceled')
|
|
||||||
await notifyStateChange(ctx, claim.workerFk, claim, newState.code);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
@ -113,15 +110,16 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function notifyStateChange(ctx, workerId, claim, state) {
|
async function notifyStateChange(ctx, workerId, claim, newState) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const url = await models.Url.getUrl();
|
const url = await models.Url.getUrl();
|
||||||
const $t = ctx.req.__; // $translate
|
const $t = ctx.req.__; // $translate
|
||||||
|
|
||||||
const message = $t(`Claim state has changed to ${state}`, {
|
const message = $t(`Claim state has changed to`, {
|
||||||
claimId: claim.id,
|
claimId: claim.id,
|
||||||
clientName: claim.client().name,
|
clientName: claim.client().name,
|
||||||
claimUrl: `${url}claim/${claim.id}/summary`
|
claimUrl: `${url}claim/${claim.id}/summary`,
|
||||||
|
newState
|
||||||
});
|
});
|
||||||
await models.Chat.sendCheckingPresence(ctx, workerId, message);
|
await models.Chat.sendCheckingPresence(ctx, workerId, message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ClaimBeginning",
|
"name": "ClaimBeginning",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "claimBeginning"
|
"table": "claimBeginning"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ClaimDevelopment",
|
"name": "ClaimDevelopment",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "claimDevelopment"
|
"table": "claimDevelopment"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ClaimDms",
|
"name": "ClaimDms",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "claimDms"
|
"table": "claimDms"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ClaimEnd",
|
"name": "ClaimEnd",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "claimEnd"
|
"table": "claimEnd"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ClaimObservation",
|
"name": "ClaimObservation",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "claimObservation"
|
"table": "claimObservation"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ClaimState",
|
"name": "ClaimState",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "claimState"
|
"table": "claimState"
|
||||||
|
@ -32,7 +35,7 @@
|
||||||
"relations": {
|
"relations": {
|
||||||
"writeRole": {
|
"writeRole": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Role",
|
"model": "VnRole",
|
||||||
"foreignKey": "roleFk"
|
"foreignKey": "roleFk"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "Claim",
|
"name": "Claim",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "claim"
|
"table": "claim"
|
||||||
|
|
|
@ -113,9 +113,6 @@
|
||||||
"SageTransactionType": {
|
"SageTransactionType": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"TicketSms": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"TpvError": {
|
"TpvError": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "Address",
|
"name": "Address",
|
||||||
"description": "Client addresses",
|
"description": "Client addresses",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "address"
|
"table": "address"
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "ClientContact",
|
"name": "ClientContact",
|
||||||
"description": "Client phone contacts",
|
"description": "Client phone contacts",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "clientContact"
|
"table": "clientContact"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ClientDms",
|
"name": "ClientDms",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "clientDms"
|
"table": "clientDms"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ClientInforma",
|
"name": "ClientInforma",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"log": {
|
"log": {
|
||||||
"model":"ClientLog",
|
"model":"ClientLog",
|
||||||
"relation": "client",
|
"relation": "client",
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "ClientObservation",
|
"name": "ClientObservation",
|
||||||
"description": "Client notes",
|
"description": "Client notes",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "clientObservation"
|
"table": "clientObservation"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ClientSample",
|
"name": "ClientSample",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "clientSample"
|
"table": "clientSample"
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Sms",
|
"model": "Sms",
|
||||||
"foreignKey": "smsFk"
|
"foreignKey": "smsFk"
|
||||||
|
},
|
||||||
|
"ticket": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Ticket",
|
||||||
|
"foreignKey": "ticketFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "Client",
|
"name": "Client",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "client"
|
"table": "client"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "Greuge",
|
"name": "Greuge",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "greuge"
|
"table": "greuge"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "Recovery",
|
"name": "Recovery",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "recovery"
|
"table": "recovery"
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
"relations": {
|
"relations": {
|
||||||
"role": {
|
"role": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Role",
|
"model": "VnRole",
|
||||||
"foreignKey": "roleFk"
|
"foreignKey": "roleFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
{
|
|
||||||
"name": "TicketSms",
|
|
||||||
"base": "VnModel",
|
|
||||||
"options": {
|
|
||||||
"mysql": {
|
|
||||||
"table": "ticketSms"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"properties": {
|
|
||||||
"smsFk": {
|
|
||||||
"type": "number",
|
|
||||||
"id": true,
|
|
||||||
"description": "Identifier"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"relations": {
|
|
||||||
"ticket": {
|
|
||||||
"type": "belongsTo",
|
|
||||||
"model": "Ticket",
|
|
||||||
"foreignKey": "ticketFk"
|
|
||||||
},
|
|
||||||
"sms": {
|
|
||||||
"type": "belongsTo",
|
|
||||||
"model": "Sms",
|
|
||||||
"foreignKey": "smsFk"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +1,2 @@
|
||||||
<vn-crud-model
|
<vn-card>
|
||||||
vn-id="model"
|
</vn-card>
|
||||||
url="ClientSms"
|
|
||||||
link="{clientFk: $ctrl.$params.id}"
|
|
||||||
filter="::$ctrl.filter"
|
|
||||||
data="clientSmsList"
|
|
||||||
limit="20"
|
|
||||||
auto-load="true">
|
|
||||||
</vn-crud-model>
|
|
||||||
<vn-data-viewer model="model">
|
|
||||||
<vn-card class="vn-w-lg">
|
|
||||||
<vn-table model="model" auto-load="false">
|
|
||||||
<vn-thead>
|
|
||||||
<vn-tr>
|
|
||||||
<vn-th field="senderFk">Sender</vn-th>
|
|
||||||
<vn-th field="destination" number>Destination</vn-th>
|
|
||||||
<vn-th field="message">Message</vn-th>
|
|
||||||
<vn-th field="status">Status</vn-th>
|
|
||||||
<vn-th field="created" expand>Created</vn-th>
|
|
||||||
</vn-tr>
|
|
||||||
</vn-thead>
|
|
||||||
<vn-tbody>
|
|
||||||
<vn-tr ng-repeat="clientSms in clientSmsList">
|
|
||||||
<vn-td>
|
|
||||||
<span class="link" ng-click="workerDescriptor.show($event, clientSms.sms.senderFk)">
|
|
||||||
{{::clientSms.sms.sender.name}}
|
|
||||||
</span>
|
|
||||||
</vn-td>
|
|
||||||
<vn-td number expand>{{::clientSms.sms.destination}}</vn-td>
|
|
||||||
<vn-td expand vn-tooltip="{{::clientSms.sms.message}}">{{::clientSms.sms.message}}</vn-td>
|
|
||||||
<vn-td>{{::clientSms.sms.status}}</vn-td>
|
|
||||||
<vn-td shrink-datetime>{{::clientSms.sms.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
|
|
||||||
</vn-tr>
|
|
||||||
</vn-tbody>
|
|
||||||
</vn-table>
|
|
||||||
</vn-card>
|
|
||||||
</vn-data-viewer>
|
|
||||||
<vn-worker-descriptor-popover
|
|
||||||
vn-id="worker-descriptor">
|
|
||||||
</vn-worker-descriptor-popover>
|
|
||||||
|
|
|
@ -1,32 +1,14 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
export default class Controller extends Section {
|
class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
|
}
|
||||||
|
|
||||||
this.filter = {
|
async $onInit() {
|
||||||
fields: ['id', 'smsFk'],
|
this.$state.go('client.card.summary', {id: this.$params.id});
|
||||||
include: {
|
window.location.href = await this.vnApp.getUrl(`Customer/${this.$params.id}/sms`);
|
||||||
relation: 'sms',
|
|
||||||
scope: {
|
|
||||||
fields: [
|
|
||||||
'senderFk',
|
|
||||||
'sender',
|
|
||||||
'destination',
|
|
||||||
'message',
|
|
||||||
'statusCode',
|
|
||||||
'status',
|
|
||||||
'created'],
|
|
||||||
include: {
|
|
||||||
relation: 'sender',
|
|
||||||
scope: {
|
|
||||||
fields: ['name']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "Buy",
|
"name": "Buy",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "buy"
|
"table": "buy"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "EntryObservation",
|
"name": "EntryObservation",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "entryObservation"
|
"table": "entryObservation"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "Entry",
|
"name": "Entry",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "entry"
|
"table": "entry"
|
||||||
|
|
|
@ -127,7 +127,7 @@ module.exports = Self => {
|
||||||
case 'isBooked':
|
case 'isBooked':
|
||||||
return {[`ii.${param}`]: value};
|
return {[`ii.${param}`]: value};
|
||||||
case 'awbCode':
|
case 'awbCode':
|
||||||
return {'awb.code': value};
|
return {'sub.code': value};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -143,20 +143,27 @@ module.exports = Self => {
|
||||||
ii.issued,
|
ii.issued,
|
||||||
ii.isBooked,
|
ii.isBooked,
|
||||||
ii.supplierRef,
|
ii.supplierRef,
|
||||||
ii.docFk AS dmsFk,
|
ii.docFk dmsFk,
|
||||||
dm.file,
|
dm.file,
|
||||||
ii.supplierFk,
|
ii.supplierFk,
|
||||||
ii.expenseFkDeductible deductibleExpenseFk,
|
ii.expenseFkDeductible deductibleExpenseFk,
|
||||||
s.name AS supplierName,
|
s.name supplierName,
|
||||||
s.account,
|
s.account,
|
||||||
SUM(iid.amount) AS amount,
|
SUM(iid.amount) amount,
|
||||||
awb.code AS awbCode
|
sub.code awbCode
|
||||||
FROM invoiceIn ii
|
FROM invoiceIn ii
|
||||||
JOIN supplier s ON s.id = ii.supplierFk
|
JOIN supplier s ON s.id = ii.supplierFk
|
||||||
LEFT JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id
|
LEFT JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id
|
||||||
LEFT JOIN duaInvoiceIn dii ON dii.invoiceInFk = ii.id
|
LEFT JOIN duaInvoiceIn dii ON dii.invoiceInFk = ii.id
|
||||||
LEFT JOIN dua d ON d.id = dii.duaFk
|
LEFT JOIN dua d ON d.id = dii.duaFk
|
||||||
LEFT JOIN awb ON awb.id = d.awbFk
|
LEFT JOIN (
|
||||||
|
SELECT awb.code, de.duaFk
|
||||||
|
FROM duaEntry de
|
||||||
|
JOIN entry e ON e.id = de.entryFk
|
||||||
|
JOIN travel t ON t.id = e.travelFk
|
||||||
|
JOIN awb ON awb.id = t.awbFk
|
||||||
|
GROUP BY de.duaFk
|
||||||
|
) sub ON sub.duaFk = d.id
|
||||||
LEFT JOIN company co ON co.id = ii.companyFk
|
LEFT JOIN company co ON co.id = ii.companyFk
|
||||||
LEFT JOIN dms dm ON dm.id = ii.docFk`
|
LEFT JOIN dms dm ON dm.id = ii.docFk`
|
||||||
);
|
);
|
||||||
|
|
|
@ -98,9 +98,10 @@ describe('InvoiceIn filter()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const awbExpected = '07546501420';
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
awbCode: '07546500856',
|
awbCode: awbExpected,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,8 +109,8 @@ describe('InvoiceIn filter()', () => {
|
||||||
const firstRow = result[0];
|
const firstRow = result[0];
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
expect(firstRow.id).toEqual(10);
|
expect(firstRow.id).toEqual(1);
|
||||||
expect(firstRow.awbCode).toEqual('07546500856');
|
expect(firstRow.awbCode).toEqual(awbExpected);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "InvoiceInTax",
|
"name": "InvoiceInTax",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "invoiceInTax"
|
"table": "invoiceInTax"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "InvoiceIn",
|
"name": "InvoiceIn",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "invoiceIn"
|
"table": "invoiceIn"
|
||||||
|
|
|
@ -85,7 +85,7 @@ module.exports = Self => {
|
||||||
throw new UserError(`A ticket with an amount of zero can't be invoiced`);
|
throw new UserError(`A ticket with an amount of zero can't be invoiced`);
|
||||||
|
|
||||||
// Validates ticket nagative base
|
// Validates ticket nagative base
|
||||||
const hasNegativeBase = await getNegativeBase(ticketId, myOptions);
|
const hasNegativeBase = await getNegativeBase(maxShipped, clientId, companyId, myOptions);
|
||||||
if (hasNegativeBase && company.code == 'VNL')
|
if (hasNegativeBase && company.code == 'VNL')
|
||||||
throw new UserError(`A ticket with a negative base can't be invoiced`);
|
throw new UserError(`A ticket with a negative base can't be invoiced`);
|
||||||
} else {
|
} else {
|
||||||
|
@ -162,10 +162,13 @@ module.exports = Self => {
|
||||||
return result.invoiceable;
|
return result.invoiceable;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getNegativeBase(ticketId, options) {
|
async function getNegativeBase(maxShipped, clientId, companyId, options) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const query = 'SELECT vn.hasSomeNegativeBase(?) AS base';
|
await models.InvoiceOut.rawSql('CALL invoiceOut_exportationFromClient(?,?,?)',
|
||||||
const [result] = await models.InvoiceOut.rawSql(query, [ticketId], options);
|
[maxShipped, clientId, companyId], options
|
||||||
|
);
|
||||||
|
const query = 'SELECT vn.hasAnyNegativeBase() AS base';
|
||||||
|
const [result] = await models.InvoiceOut.rawSql(query, [], options);
|
||||||
|
|
||||||
return result.base;
|
return result.base;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ module.exports = Self => {
|
||||||
const sales = await models.Sale.find(filterTicket, myOptions);
|
const sales = await models.Sale.find(filterTicket, myOptions);
|
||||||
const salesIds = sales.map(sale => sale.id);
|
const salesIds = sales.map(sale => sale.id);
|
||||||
|
|
||||||
const clonedTickets = await models.Sale.clone(ctx, salesIds, servicesIds, null, false, false, myOptions);
|
const clonedTickets = await models.Sale.clone(ctx, salesIds, servicesIds, null, false, myOptions);
|
||||||
const clonedTicketIds = [];
|
const clonedTicketIds = [];
|
||||||
|
|
||||||
for (const clonedTicket of clonedTickets) {
|
for (const clonedTicket of clonedTickets) {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ItemBarcode",
|
"name": "ItemBarcode",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "itemBarcode"
|
"table": "itemBarcode"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ItemBotanical",
|
"name": "ItemBotanical",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "itemBotanical"
|
"table": "itemBotanical"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ItemShelving",
|
"name": "ItemShelving",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "itemShelving"
|
"table": "itemShelving"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ItemTag",
|
"name": "ItemTag",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "itemTag"
|
"table": "itemTag"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "ItemTaxCountry",
|
"name": "ItemTaxCountry",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "itemTaxCountry"
|
"table": "itemTaxCountry"
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue