Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6296-countryAddress
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
commit
55b5e4cfcd
|
@ -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,2 @@
|
||||||
|
ALTER TABLE vn.invoiceOutConfig
|
||||||
|
ADD IF NOT EXISTS refLen TINYINT UNSIGNED DEFAULT 5 NOT NULL COMMENT 'Invoice reference identifier length';
|
|
@ -4,17 +4,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceOut_beforeInse
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
|
* Generates the next reference for the invoice serial. There cannot be gaps
|
||||||
|
* between identifiers of the same serial!
|
||||||
|
*
|
||||||
* Reference format:
|
* Reference format:
|
||||||
* - 0: Serial [A-Z]
|
* {0} Invoice serial
|
||||||
* - 1: Sage company id
|
* {1} The company code
|
||||||
* - 2-3: Last two digits of issued year
|
* {2-3} Last two digits of issue year
|
||||||
* - 4-8: Autoincrement identifier
|
* {4-$} Autoincrement identifier
|
||||||
**/
|
*/
|
||||||
DECLARE vNewRef INT DEFAULT 0;
|
DECLARE vRef INT DEFAULT 0;
|
||||||
DECLARE vCompanyCode INT;
|
DECLARE vRefLen INT;
|
||||||
|
DECLARE vRefPrefix VARCHAR(255);
|
||||||
DECLARE vLastRef VARCHAR(255);
|
DECLARE vLastRef VARCHAR(255);
|
||||||
DECLARE vRefStr VARCHAR(255);
|
DECLARE vCompanyCode INT;
|
||||||
DECLARE vRefLen INT DEFAULT 5;
|
|
||||||
DECLARE vYearLen INT DEFAULT 2;
|
DECLARE vYearLen INT DEFAULT 2;
|
||||||
DECLARE vPrefixLen INT;
|
DECLARE vPrefixLen INT;
|
||||||
|
|
||||||
|
@ -23,36 +26,34 @@ BEGIN
|
||||||
WHERE id = NEW.companyFk;
|
WHERE id = NEW.companyFk;
|
||||||
|
|
||||||
IF vCompanyCode IS NULL THEN
|
IF vCompanyCode IS NULL THEN
|
||||||
CALL util.throw('sageCompanyNotDefined');
|
CALL util.throw('companyCodeNotDefined');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT MAX(i.ref) INTO vLastRef
|
SELECT MAX(i.ref) INTO vLastRef
|
||||||
FROM invoiceOut i
|
FROM invoiceOut i
|
||||||
WHERE i.serial = NEW.serial
|
WHERE i.serial = NEW.serial
|
||||||
AND i.issued BETWEEN util.firstDayOfYear(NEW.issued) AND util.dayEnd(util.lastDayOfYear(NEW.issued))
|
AND i.issued BETWEEN util.firstDayOfYear(NEW.issued) AND util.lastDayOfYear(NEW.issued)
|
||||||
AND i.companyFk = NEW.companyFk;
|
AND i.companyFk = NEW.companyFk;
|
||||||
|
|
||||||
IF vLastRef IS NOT NULL THEN
|
IF vLastRef IS NOT NULL THEN
|
||||||
SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vCompanyCode) + vYearLen;
|
SET vPrefixLen = LENGTH(NEW.serial) + LENGTH(vCompanyCode) + vYearLen;
|
||||||
SET vRefLen = LENGTH(vLastRef) - vPrefixLen;
|
SET vRefLen = LENGTH(vLastRef) - vPrefixLen;
|
||||||
SET vRefStr = SUBSTRING(vLastRef, vPrefixLen + 1);
|
SET vRefPrefix = LEFT(vLastRef, vPrefixLen);
|
||||||
SET vNewRef = vRefStr + 1;
|
SET vRef = RIGHT(vLastRef, vRefLen);
|
||||||
|
|
||||||
IF LENGTH(vNewRef) > vRefLen THEN
|
|
||||||
CALL util.throw('refLenExceeded');
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
SET NEW.ref = CONCAT(
|
|
||||||
SUBSTRING(vLastRef, 1, vPrefixLen),
|
|
||||||
LPAD(vNewRef, LENGTH(vRefStr), '0')
|
|
||||||
);
|
|
||||||
ELSE
|
ELSE
|
||||||
SET NEW.ref = CONCAT(
|
SELECT refLen INTO vRefLen FROM invoiceOutConfig;
|
||||||
|
SET vRefPrefix = CONCAT(
|
||||||
NEW.serial,
|
NEW.serial,
|
||||||
vCompanyCode,
|
vCompanyCode,
|
||||||
RIGHT(YEAR(NEW.issued), vYearLen),
|
RIGHT(YEAR(NEW.issued), vYearLen)
|
||||||
LPAD(1, vRefLen, '0')
|
|
||||||
);
|
);
|
||||||
END IF;
|
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$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -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),
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "RoutesMonitor",
|
"name": "RoutesMonitor",
|
||||||
"base": "Loggable",
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "routesMonitor"
|
"table": "routesMonitor"
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<td id="outline" class="ellipsize">{{labelData.workerCode || '---'}}</td>
|
<td id="outline" class="ellipsize">{{labelData.workerCode || '---'}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td id="outline" class="ellipsize">{{labelCount || labelData.labelCount || 0}}</td>
|
<td id="outline" class="ellipsize">{{labelData.labelCount || 0}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td id="outline" class="ellipsize">{{labelData.code == 'V' ? (labelData.size || 0) + 'cm' : (labelData.volume || 0) + 'm³'}}</td>
|
<td id="outline" class="ellipsize">{{labelData.code == 'V' ? (labelData.size || 0) + 'cm' : (labelData.volume || 0) + 'm³'}}</td>
|
||||||
|
|
|
@ -18,9 +18,9 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
|
await this.rawSql('SET @hasPrevia := 0');
|
||||||
let ticketIds;
|
let ticketIds;
|
||||||
const res = await this.rawSqlFromDef('tickets', [this.id]);
|
const res = await this.rawSqlFromDef('tickets', [this.id]);
|
||||||
|
|
||||||
if (res.length) {
|
if (res.length) {
|
||||||
ticketIds = [];
|
ticketIds = [];
|
||||||
for (const row of res)
|
for (const row of res)
|
||||||
|
|
|
@ -7,14 +7,16 @@ SELECT c.itemPackingTypeFk code,
|
||||||
cc.code color,
|
cc.code color,
|
||||||
t.clientFk,
|
t.clientFk,
|
||||||
CAST(SUM(sv.volume) AS DECIMAL(5, 2)) volume,
|
CAST(SUM(sv.volume) AS DECIMAL(5, 2)) volume,
|
||||||
MAX(i.`size`) `size`,
|
MAX(
|
||||||
|
IF(sgd.id, IFNULL(pc.itemPreviousDefaultSize, i.`size`), i.`size`)
|
||||||
|
) `size`,
|
||||||
w.code workerCode,
|
w.code workerCode,
|
||||||
TIME_FORMAT(t.shipped, '%H:%i') shippedHour,
|
TIME_FORMAT(t.shipped, '%H:%i') shippedHour,
|
||||||
TIME_FORMAT(zo.`hour`, '%H:%i') zoneHour,
|
TIME_FORMAT(zo.`hour`, '%H:%i') zoneHour,
|
||||||
DATE_FORMAT(t.shipped, '%d/%m/%y') shipped,
|
DATE_FORMAT(t.shipped, '%d/%m/%y') shipped,
|
||||||
tt.labelCount,
|
tt.labelCount,
|
||||||
t.nickName,
|
t.nickName,
|
||||||
COUNT(*) lineCount,
|
SUM(IF(sgd.id, IF(@hasPrevia, 0, @hasPrevia := 1), 1)) lineCount,
|
||||||
rm.routeFk
|
rm.routeFk
|
||||||
FROM vn.ticket t
|
FROM vn.ticket t
|
||||||
JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
|
JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
|
||||||
|
@ -23,7 +25,7 @@ SELECT c.itemPackingTypeFk code,
|
||||||
AND cc.wagon = tc.wagon
|
AND cc.wagon = tc.wagon
|
||||||
AND cc.trainFk = c.trainFk
|
AND cc.trainFk = c.trainFk
|
||||||
JOIN vn.sale s ON s.ticketFk = t.id
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id
|
LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id
|
||||||
JOIN vn.item i ON i.id = s.itemFk
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
JOIN vn.itemType it ON it.id = i.typeFk
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
|
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
|
||||||
|
@ -32,7 +34,9 @@ SELECT c.itemPackingTypeFk code,
|
||||||
LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id
|
LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id
|
||||||
LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id
|
LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id
|
||||||
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
|
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
|
||||||
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
|
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
|
||||||
|
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
|
||||||
|
JOIN vn.productionConfig pc
|
||||||
WHERE t.id IN (?)
|
WHERE t.id IN (?)
|
||||||
GROUP BY t.id
|
GROUP BY t.id
|
||||||
ORDER BY cc.`code`;
|
ORDER BY cc.`code`
|
Loading…
Reference in New Issue