Merge branch 'dev' into Fix-ItemRequest
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
9e9773578a
|
@ -32,8 +32,7 @@ RUN apt-get update \
|
|||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
samba-common-bin samba-dsdb-modules\
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& npm -g install pm2
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Salix
|
||||
|
||||
|
@ -55,4 +54,4 @@ COPY \
|
|||
README.md \
|
||||
./
|
||||
|
||||
CMD ["pm2-runtime", "./back/process.yml"]
|
||||
CMD ["node", "--tls-min-v1.0", "--openssl-legacy-provider", "./loopback/server/server.js"]
|
|
@ -1,7 +0,0 @@
|
|||
apps:
|
||||
- script: ./loopback/server/server.js
|
||||
name: salix-back
|
||||
instances: 1
|
||||
max_restarts: 0
|
||||
autorestart: false
|
||||
node_args: --tls-min-v1.0 --openssl-legacy-provider
|
|
@ -1,5 +1,7 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getTax`(IN vTaxArea VARCHAR(25))
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getTax`(
|
||||
vTaxArea VARCHAR(25)
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula la base imponible, el IVA y el recargo de equivalencia para
|
||||
|
@ -33,30 +35,39 @@ BEGIN
|
|||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketTax
|
||||
(PRIMARY KEY (ticketFk, code, rate))
|
||||
ENGINE = MEMORY
|
||||
SELECT * FROM (
|
||||
SELECT tmpTicket.ticketFk,
|
||||
WITH sales AS (
|
||||
SELECT s.ticketFk,
|
||||
s.itemFk,
|
||||
s.quantity * s.price * (100 - s.discount) / 100 total,
|
||||
t.companyFk,
|
||||
t.addressFk,
|
||||
su.countryFk,
|
||||
ata.areaFk,
|
||||
itc.taxClassFk
|
||||
FROM vn.sale s
|
||||
JOIN tmp.ticket tmp ON tmp.ticketFk = s.ticketFk
|
||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
JOIN vn.supplier su ON su.id = t.companyFk
|
||||
JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk
|
||||
AND ata.companyFk = t.companyFk
|
||||
JOIN vn.itemTaxCountry itc ON itc.itemFk = s.itemFk
|
||||
AND itc.countryFk = su.countryFk
|
||||
HAVING total
|
||||
)
|
||||
SELECT s.ticketFk,
|
||||
bp.pgcFk,
|
||||
SUM(s.quantity * s.price * (100 - s.discount) / 100 ) taxableBase,
|
||||
SUM(s.total) taxableBase,
|
||||
pgc.rate,
|
||||
tc.code,
|
||||
bp.priority
|
||||
FROM tmp.ticket tmpTicket
|
||||
JOIN sale s ON s.ticketFk = tmpTicket.ticketFk
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN ticket t ON t.id = tmpTicket.ticketFk
|
||||
JOIN supplier su ON su.id = t.companyFk
|
||||
JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk
|
||||
AND ata.companyFk = t.companyFk
|
||||
JOIN itemTaxCountry itc ON itc.itemFk = i.id
|
||||
AND itc.countryFk = su.countryFk
|
||||
JOIN bookingPlanner bp ON bp.countryFk = su.countryFk
|
||||
AND bp.taxAreaFk = ata.areaFk
|
||||
AND bp.taxClassFk = itc.taxClassFk
|
||||
JOIN pgc ON pgc.code = bp.pgcFk
|
||||
JOIN taxClass tc ON tc.id = bp.taxClassFk
|
||||
GROUP BY tmpTicket.ticketFk, pgc.code, pgc.rate
|
||||
FROM sales s
|
||||
JOIN vn.bookingPlanner bp ON bp.countryFk = s.countryFk
|
||||
AND bp.taxAreaFk = s.areaFk
|
||||
AND bp.taxClassFk = s.taxClassFk
|
||||
JOIN vn.pgc ON pgc.code = bp.pgcFk
|
||||
JOIN vn.taxClass tc ON tc.id = bp.taxClassFk
|
||||
GROUP BY s.ticketFk, pgc.code, pgc.rate
|
||||
HAVING taxableBase
|
||||
) t3
|
||||
ORDER BY priority;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
ALTER TABLE `vn`.`operator`
|
||||
ADD COLUMN `machineFk` int(11) DEFAULT NULL,
|
||||
ADD CONSTRAINT `operator_machine_FK` FOREIGN KEY (`machineFk`) REFERENCES `vn`.`machine` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Machine','*','*','ALLOW','ROLE','productionBoss');
|
|
@ -240,5 +240,6 @@
|
|||
"There is already a tray with the same height": "There is already a tray with the same height",
|
||||
"The height must be greater than 50cm": "The height must be greater than 50cm",
|
||||
"The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm",
|
||||
"The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line"
|
||||
"The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line",
|
||||
"There are tickets for this area, delete them first": "There are tickets for this area, delete them first"
|
||||
}
|
||||
|
|
|
@ -382,5 +382,6 @@
|
|||
"This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha",
|
||||
"No valid travel thermograph found": "No se encontró un termógrafo válido",
|
||||
"The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea",
|
||||
"type cannot be blank": "Se debe rellenar el tipo"
|
||||
"type cannot be blank": "Se debe rellenar el tipo",
|
||||
"There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero"
|
||||
}
|
|
@ -48,13 +48,13 @@ module.exports = Self => {
|
|||
let stmt;
|
||||
stmts.push(new ParameterizedSQL(
|
||||
`CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||
(KEY (ticketFk))
|
||||
(INDEX (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT id ticketFk
|
||||
FROM ticket t
|
||||
FROM ticket
|
||||
WHERE shipped BETWEEN ? AND util.dayEnd(?)
|
||||
AND refFk IS NULL`, [args.from, args.to]));
|
||||
stmts.push(`CALL vn.ticket_getTax(NULL)`);
|
||||
stmts.push(`CALL ticket_getTax(NULL)`);
|
||||
stmts.push(new ParameterizedSQL(
|
||||
`CREATE OR REPLACE TEMPORARY TABLE tmp.filter
|
||||
ENGINE = MEMORY
|
||||
|
@ -71,12 +71,12 @@ module.exports = Self => {
|
|||
c.isTaxDataChecked,
|
||||
w.id comercialId,
|
||||
u.name workerName
|
||||
FROM vn.ticket t
|
||||
JOIN vn.company co ON co.id = t.companyFk
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.client c ON c.id = t.clientFk
|
||||
JOIN vn.country cou ON cou.id = c.countryFk
|
||||
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
||||
FROM ticket t
|
||||
JOIN company co ON co.id = t.companyFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN country cou ON cou.id = c.countryFk
|
||||
LEFT JOIN worker w ON w.id = c.salesPersonFk
|
||||
JOIN account.user u ON u.id = w.id
|
||||
LEFT JOIN (
|
||||
SELECT ticketFk, taxableBase
|
||||
|
|
|
@ -228,7 +228,7 @@ module.exports = Self => {
|
|||
stmt = new ParameterizedSQL(`
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
ENGINE = MEMORY
|
||||
ENGINE = InnoDB
|
||||
SELECT t.id,
|
||||
t.shipped,
|
||||
CAST(DATE(t.shipped) AS CHAR) shippedDate,
|
||||
|
@ -260,7 +260,12 @@ module.exports = Self => {
|
|||
z.name zoneName,
|
||||
z.id zoneFk,
|
||||
CAST(z.hour AS CHAR) hour,
|
||||
a.nickname addressNickname
|
||||
a.nickname addressNickname,
|
||||
(SELECT GROUP_CONCAT(DISTINCT i2.itemPackingTypeFk ORDER BY i2.itemPackingTypeFk SEPARATOR ',')
|
||||
FROM sale s2
|
||||
JOIN item i2 ON i2.id = s2.itemFk
|
||||
WHERE s2.ticketFk = t.id
|
||||
) AS packing
|
||||
FROM ticket t
|
||||
LEFT JOIN invoiceOut io ON t.refFk = io.ref
|
||||
LEFT JOIN zone z ON z.id = t.zoneFk
|
||||
|
@ -292,6 +297,7 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
stmt.merge(conn.makeWhere(filter.where));
|
||||
|
||||
stmts.push(stmt);
|
||||
|
||||
stmt = new ParameterizedSQL(`
|
||||
|
|
|
@ -24,12 +24,27 @@
|
|||
"warehouseFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"sectorFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"labelerFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"isOnReservationMode": {
|
||||
"type": "boolean",
|
||||
"required": true
|
||||
},
|
||||
"machineFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"linesLimit": {
|
||||
"type": "number"
|
||||
},
|
||||
"volumeLimit": {
|
||||
"type": "number"
|
||||
},
|
||||
"sizeLimit": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -53,6 +68,11 @@
|
|||
"model": "ItemPackingType",
|
||||
"foreignKey": "itemPackingTypeFk",
|
||||
"primaryKey": "code"
|
||||
},
|
||||
"machine": {
|
||||
"type": "belongsTo",
|
||||
"model": "Machine",
|
||||
"foreignKey": "machineFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('deleteZone', {
|
||||
description: 'Delete a zone',
|
||||
|
@ -49,26 +50,12 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
};
|
||||
const promises = [];
|
||||
|
||||
const ticketList = await models.Ticket.find(filter, myOptions);
|
||||
const fixingState = await models.State.findOne({where: {code: 'FIXING'}}, myOptions);
|
||||
const worker = await models.Worker.findOne({
|
||||
where: {id: userId}
|
||||
}, myOptions);
|
||||
|
||||
await models.Ticket.rawSql('UPDATE ticket SET zoneFk = NULL WHERE zoneFk = ?', [id], myOptions);
|
||||
if (ticketList.length > 0)
|
||||
throw new UserError('There are tickets for this area, delete them first');
|
||||
|
||||
for (ticket of ticketList) {
|
||||
if (ticket.ticketState().alertLevel == 0) {
|
||||
promises.push(models.Ticket.state(ctx, {
|
||||
ticketFk: ticket.id,
|
||||
stateFk: fixingState.id,
|
||||
userFk: worker.id
|
||||
}, myOptions));
|
||||
}
|
||||
}
|
||||
await Promise.all(promises);
|
||||
await models.Zone.destroyById(id, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
|
|
@ -8,9 +8,9 @@ describe('zone deletezone()', () => {
|
|||
__: value => value
|
||||
};
|
||||
const ctx = {req: activeCtx};
|
||||
const zoneId = 9;
|
||||
const zoneId = 4;
|
||||
const zoneId2 = 3;
|
||||
let ticketIDs;
|
||||
let originalTicketStates;
|
||||
|
||||
beforeAll(async() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
|
@ -35,18 +35,8 @@ describe('zone deletezone()', () => {
|
|||
await models.Zone.deleteZone(ctx, zoneId, options);
|
||||
|
||||
const updatedZone = await models.Zone.findById(zoneId, null, options);
|
||||
const anUpdatedTicket = await models.Ticket.findById(ticketIDs[0], null, options);
|
||||
|
||||
const updatedTicketStates = await models.TicketState.find({
|
||||
where: {
|
||||
ticketFk: {inq: ticketIDs},
|
||||
code: 'FIXING'
|
||||
}
|
||||
}, options);
|
||||
|
||||
expect(updatedZone).toBeNull();
|
||||
expect(anUpdatedTicket.zoneFk).toBeNull();
|
||||
expect(updatedTicketStates.length).toBeGreaterThan(originalTicketStates.length);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -54,4 +44,20 @@ describe('zone deletezone()', () => {
|
|||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should not delete the zone if it has tickets', async() => {
|
||||
const tx = await models.Zone.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
await models.Zone.deleteZone(ctx, zoneId2, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error).toEqual('There are tickets for this area, delete them first');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue