Merge branch 'dev' into Hotfix-FixedPriceNameFilter
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2025-02-07 12:42:20 +00:00
commit 516f409ae5
32 changed files with 2914 additions and 2271 deletions

View File

@ -13,6 +13,7 @@ RUN apt-get update \
graphicsmagick \ graphicsmagick \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \ && apt-get install -y --no-install-recommends nodejs \
&& npm install -g corepack@0.31.0 \
&& corepack enable pnpm && corepack enable pnpm
# Puppeteer # Puppeteer

View File

@ -214,15 +214,15 @@ INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone
(1109, 'HLK', 'Bruce' , 'Banner', 19, 432978109), (1109, 'HLK', 'Bruce' , 'Banner', 19, 432978109),
(1110, 'JJJ', 'Jessica' , 'Jones' , 19, 432978110); (1110, 'JJJ', 'Jessica' , 'Jones' , 19, 432978110);
INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) INSERT INTO `vn`.`parking` (`id`, `sectorFk`, `code`, `pickingOrder`)
VALUES VALUES
('1', 700, '01', 1, '700-01', 70001), ('1', 1, '700-01', 70001),
('2', 700, '02', 2, '700-02', 70002), ('2', 2, '700-02', 70002),
('3', 100, '01', 1, '100-01', 1), ('3', 1, '100-01', 1),
(32397, 100, '02', 1, 'A-47-1', 1165), (32397, 1, 'A-47-1', 1165),
(34831, 200, '01', 1, 'K-26-2', 20220), (34831, 1, 'K-26-2', 20220),
(34965, 200, '02', 2, 'L-08-4', 21800), (34965, 2, 'L-08-4', 21800),
(39096, 200, '03', 2, 'LR-02-3', 99999); (39096, 2, 'LR-02-3', 99999);
INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `userFk`, `isRecyclable`) INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `userFk`, `isRecyclable`)
VALUES VALUES
@ -499,7 +499,7 @@ DROP TEMPORARY TABLE IF EXISTS tmp.address;
CREATE TEMPORARY TABLE tmp.address CREATE TEMPORARY TABLE tmp.address
SELECT * FROM `vn`.`address`; SELECT * FROM `vn`.`address`;
UPDATE `vn`.`client` `c` UPDATE `vn`.`client` `c`
JOIN `tmp`.`address` `a` ON `a`.`clientFk` = `c`.`id` JOIN `tmp`.`address` `a` ON `a`.`clientFk` = `c`.`id`
SET `c`.`defaultAddressFk` = `a`.`id` SET `c`.`defaultAddressFk` = `a`.`id`
WHERE `defaultAddressFk` IS NULL; WHERE `defaultAddressFk` IS NULL;
@ -854,14 +854,15 @@ INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`)
VALUES VALUES
(1, 'Gotham','1007 Mountain Drive, Gotham'); (1, 'Gotham','1007 Mountain Drive, Gotham');
INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`, `deliveryPointFk`) INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`, `deliveryPointFk`, `chassis`, `leasing`, `supplierFk`, `fuelTypeFk`, `bankPolicyFk`)
VALUES VALUES
(1, '3333-BAT', 'WAYNE INDUSTRIES', 'BATMOBILE', 442, 1, 'The ultimate war machine', 50, 1, 1), (1, '3333-BAT', 'WAYNE INDUSTRIES', 'BATMOBILE', 442, 1, 'The ultimate war machine', 50, 1, 1, 'XCSC133C60', 'Wayne leasing', 1, 1, 1),
(2, '1111-IMK', 'STARK INDUSTRIES', 'MARK-III', 442, 1, 'Iron-Man Heavy Armor MARK-III', 18, 1, 1), (2, '1111-IMK', 'STARK INDUSTRIES', 'MARK-III', 442, 1, 'Iron-Man Heavy Armor MARK-III', 18, 1, 1, '', '', 2, 2, 2),
(3, '2222-IMK', 'STARK INDUSTRIES', 'MARK-VI', 442, 1, 'Iron-Man Heavy Armor MARK-VI', 16, 1, 1), (3, '2222-IMK', 'STARK INDUSTRIES', 'MARK-VI', 442, 1, 'Iron-Man Heavy Armor MARK-VI', 16, 1, 1, '', '', 442, 2, null),
(4, '3333-IMK', 'STARK INDUSTRIES', 'MARK-VII', 442, 1, 'Iron-Man Heavy Armor MARK-VII', 14, 1, 1), (4, '3333-IMK', 'STARK INDUSTRIES', 'MARK-VII', 442, 1, 'Iron-Man Heavy Armor MARK-VII', 14, 1, 1, '', '', 442, 3, null),
(5, '4444-IMK', 'STARK INDUSTRIES', 'MARK-XLII', 442, 1, 'Iron-Man Heavy Armor MARK-XLII', 13, 1, 1), (5, '4444-IMK', 'STARK INDUSTRIES', 'MARK-XLII', 442, 1, 'Iron-Man Heavy Armor MARK-XLII', 13, 1, 1, '', '', 442, 4, null),
(6, '5555-IMK', 'STARK INDUSTRIES', 'MARK-XLV', 442, 1, 'Iron-Man Heavy Armor MARK-XLV', 12, 0, 1); (6, '5555-IMK', 'STARK INDUSTRIES', 'MARK-XLV', 442, 1, 'Iron-Man Heavy Armor MARK-XLV', 12, 0, 1, '', '', 442, 5, null),
(7, '5555-SHI', 'SHIELD', 'Quinjet', 442, 1, 'High-speed jet used by the Avengers', 30, 1, 1, 'QJ12345', 'SHIELD leasing', 1, 1, 1);
INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, `inventoried`) INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, `inventoried`)
VALUES VALUES
@ -1879,10 +1880,10 @@ INSERT INTO `vn`.`workerManaExcluded`(`workerFk`)
VALUES VALUES
(9); (9);
/* /*
el mana de los trabajadores lo podemos poner a mano en la tabla si lo calculamos antes, el mana de los trabajadores lo podemos poner a mano en la tabla si lo calculamos antes,
pero si hazemos alguna modificacion en alguna tabla que utiliza para calcularlo ya no seria correcto pero si hazemos alguna modificacion en alguna tabla que utiliza para calcularlo ya no seria correcto
La otra manera es poner el calculo con los 2 trabajadores que utilizamos ahora mismo para los tickets La otra manera es poner el calculo con los 2 trabajadores que utilizamos ahora mismo para los tickets
*/ */
call vn.manaSpellersRequery(19); call vn.manaSpellersRequery(19);
@ -4071,3 +4072,43 @@ UPDATE vn.worker
SET isFreelance=1 SET isFreelance=1
WHERE firstName='deliveryFreelancer'; WHERE firstName='deliveryFreelancer';
INSERT INTO vn.vehicleState (state, hasToNotify)
VALUES
('Operativo', NULL),
('Prestado', NULL),
('Robado', NULL),
('Taller', NULL),
('Targeta SOLRED', NULL),
('Via T SOLRED', NULL),
('ITV', NULL);
INSERT INTO vn.vehicleEvent (started, finished, vehicleStateFk, description, vehicleFk, userFk, notified)
VALUES
('2000-12-01', '2000-12-02', 4, 'cambio de aceite', 5, 103, NULL),
('2000-12-15', '2000-12-18', 2, 'viaje fin de curso', 5, 103, NULL),
('2000-12-20', '2001-01-01', 3, 'llaves puestas', 2, 103, NULL);
INSERT INTO vn.fuelType (id, name, code)
VALUES
(1, 'gasoil', 'gasoil'),
(2, 'gas', 'gas'),
(3, 'adblue', 'adblue'),
(4, 'gasolina', 'gasolina'),
(5, 'gasoil-frigo', 'gasoil-frigo'),
(6, 'electrico', 'electric');
INSERT INTO vn.bankPolicy (id, `ref`, amount, committedFee, nonCommittedFee, annualFee, started, ended, accountingFk, companyFk, supplierFk, description, hasGuarantee, dmsFk, notaryFk, currencyFk, amortizationTypeFk, periodicityTypeFk, insuranceExpired)
VALUES
(1, '11112222', 500000.0, 0.028, 0.0, 0.001, '2001-01-01', '2001-02-01', 1, 442, NULL, NULL, 0, NULL, NULL, 1, NULL, NULL, NULL),
(2, '33334444', 100000.0, 0.017, 0.0, 0.0, '2001-01-01', '2001-02-01', 1, 2, NULL, NULL, 0, NULL, NULL, 2, NULL, NULL, NULL);
INSERT INTO vn.ppe (id, amortization, firstAmortizated, lastAmortizated, finished, value, planFk, groupFk, account, endowment, elementAccount, nature, location, discharged, cause, isInvestmentAsset, workerFk, companyFk, description, isDone)
VALUES
(1, 0.00, '2001-01-01', NULL, NULL, 700.95, 16, 4, '3456000000', '4320000000', '12345', 'INMOVILIZADO', 'V02', NULL, NULL, 0, NULL, 442, 'UTILLAJE LASER ROTATIVO AUTONIVELANTE 500M', NULL),
(2, 0.00, '2001-01-01', NULL, NULL, 400.00, 16, 4, '5678000000', '1230000000', '67891', 'INMOVILIZADO', 'V02', NULL, NULL, 0, NULL, 442, 'UTILLAJE BALANZA Z100 150KILOS', NULL);
INSERT IGNORE INTO vn.vehicleType (id, name)
VALUES (1,'vehículo empresa'),
(2, 'furgoneta'),
(3, 'cabeza tractora'),
(4, 'remolque');

View File

@ -30,11 +30,16 @@ BEGIN
st.code stateCode, st.code stateCode,
sub2.code futureStateCode, sub2.code futureStateCode,
st.classColor, st.classColor,
sub2.classColor futureClassColor sub2.classColor futureClassColor,
am.id agencyFk,
am.name agency,
sub2.agencyModeFk futureAgencyFk,
sub2.agencyMode futureAgency
FROM vn.saleVolume sv FROM vn.saleVolume sv
JOIN vn.sale s ON s.id = sv.saleFk JOIN vn.sale s ON s.id = sv.saleFk
JOIN vn.item i ON i.id = s.itemFk JOIN vn.item i ON i.id = s.itemFk
JOIN vn.ticket t ON t.id = sv.ticketFk JOIN vn.ticket t ON t.id = sv.ticketFk
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
JOIN vn.address a ON a.id = t.addressFk JOIN vn.address a ON a.id = t.addressFk
JOIN vn.province p ON p.id = a.provinceFk JOIN vn.province p ON p.id = a.provinceFk
JOIN vn.country c ON c.id = p.countryFk JOIN vn.country c ON c.id = p.countryFk
@ -54,8 +59,11 @@ BEGIN
st.name state, st.name state,
st.code, st.code,
st.classColor, st.classColor,
am.id agencyModeFk,
am.name agencyMode,
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd
FROM vn.ticket t FROM vn.ticket t
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN vn.ticketState ts ON ts.ticketFk = t.id
JOIN vn.state st ON st.id = ts.stateFk JOIN vn.state st ON st.id = ts.stateFk
JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.sale s ON s.ticketFk = t.id

View File

@ -25,7 +25,7 @@ BEGIN
LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk
LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
WHERE dm.code IN ('AGENCY') WHERE dm.code IN ('AGENCY')
AND it.isFragile; AND (it.isFragile OR i.isFragile);
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket_warnings CREATE OR REPLACE TEMPORARY TABLE tmp.ticket_warnings
(PRIMARY KEY (ticketFk)) (PRIMARY KEY (ticketFk))

View File

@ -0,0 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`mandate_afterDelete`
AFTER DELETE ON `mandate`
FOR EACH ROW
BEGIN
INSERT INTO mandateLog
SET `action` = 'delete',
`changedModel` = 'mandate',
`changedModelId` = OLD.id,
`userFk` = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`mandate_beforeInsert`
BEFORE INSERT ON `mandate` BEFORE INSERT ON `mandate`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.editorFk = account.myUser_getId();
IF (NEW.code IS NULL) THEN IF (NEW.code IS NULL) THEN
SET NEW.code=CONCAT(NEW.clientFk,'-',(SELECT AUTO_INCREMENT SET NEW.code=CONCAT(NEW.clientFk,'-',(SELECT AUTO_INCREMENT
FROM information_schema.TABLES FROM information_schema.TABLES

View File

@ -0,0 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`mandate_beforeUpdate`
BEFORE INSERT ON `mandate`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -16,7 +16,6 @@ AS SELECT `t`.`id` AS `id`,
`t`.`kg` AS `kg`, `t`.`kg` AS `kg`,
`t`.`cargoSupplierFk` AS `cargoSupplierFk`, `t`.`cargoSupplierFk` AS `cargoSupplierFk`,
`t`.`totalEntries` AS `totalEntries`, `t`.`totalEntries` AS `totalEntries`,
`t`.`appointment` AS `appointment`,
`t`.`awbFk` AS `awbFk`, `t`.`awbFk` AS `awbFk`,
`t`.`isRaid` AS `isRaid`, `t`.`isRaid` AS `isRaid`,
`t`.`daysInForward` AS `daysInForward` `t`.`daysInForward` AS `daysInForward`

View File

@ -0,0 +1,23 @@
CREATE TABLE vn.parkingCoordinates (
parkingFk int(11) NOT NULL,
x varchar(5) NOT NULL,
y varchar(5) NOT NULL,
z varchar(5) NOT NULL,
CONSTRAINT parkingCoordinates_pk PRIMARY KEY (parkingFk),
CONSTRAINT parkingCoordinates_parking_FK FOREIGN KEY (parkingFk) REFERENCES vn.parking(id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8mb3
COLLATE=utf8mb3_unicode_ci;
INSERT INTO vn.parkingCoordinates (parkingFk, x, y, z)
SELECT id, `column`, `row`, `floor`
FROM vn.parking
WHERE `column` IS NOT NULL
OR `row` IS NOT NULL
OR `floor` IS NOT NULL;
ALTER TABLE vn.parking
DROP COLUMN `column`,
DROP COLUMN `row`,
DROP COLUMN `floor`;

View File

@ -0,0 +1,41 @@
USE vn;
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
VALUES ('Vehicle', 'filter', 'READ', 'ALLOW', 'ROLE', 'administrative'),
('Vehicle', 'filter', 'READ', 'ALLOW', 'ROLE', 'deliveryAssistant'),
('Vehicle', 'find', 'READ', 'ALLOW', 'ROLE', 'administrative'),
('Vehicle', 'find', 'READ', 'ALLOW', 'ROLE', 'deliveryAssistant'),
('Vehicle', 'findById', 'READ', 'ALLOW', 'ROLE', 'administrative'),
('Vehicle', 'findById', 'READ', 'ALLOW', 'ROLE', 'deliveryAssistant'),
('Vehicle', '__get__active', 'READ', 'ALLOW', 'ROLE', 'employee'),
('Vehicle', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
('Vehicle', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'deliveryAssistant'),
('Vehicle', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
('Vehicle', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'deliveryAssistant'),
('Vehicle', 'create', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
('Vehicle', 'create', 'WRITE', 'ALLOW', 'ROLE', 'deliveryAssistant'),
('BankPolicy', 'find', 'READ', 'ALLOW', 'ROLE', 'administrative'),
('BankPolicy', 'find', 'READ', 'ALLOW', 'ROLE', 'deliveryAssistant'),
('VehicleState', 'find', 'READ', 'ALLOW', 'ROLE', 'administrative'),
('VehicleState', 'find', 'READ', 'ALLOW', 'ROLE', 'deliveryAssistant'),
('Ppe', 'find', 'READ', 'ALLOW', 'ROLE', 'administrative' ),
('Ppe', 'find', 'READ', 'ALLOW', 'ROLE', 'deliveryAssistant' ),
('VehicleType', 'find', 'READ', 'ALLOW', 'ROLE', 'employee'),
('DeliveryPoint', 'find', 'READ', 'ALLOW', 'ROLE', 'deliveryAssistant'),
('DeliveryPoint', 'find', 'READ', 'ALLOW', 'ROLE', 'administrative');
CREATE TABLE IF NOT EXISTS vehicleType (
id INT(11) PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(45) NOT NULL
);
INSERT IGNORE INTO vehicleType (id, name)
VALUES (1,'vehículo empresa'),
(2, 'furgoneta'),
(3, 'cabeza tractora'),
(4, 'remolque');
ALTER TABLE vehicle ADD COLUMN importCooler decimal(10,2) DEFAULT NULL;
ALTER TABLE vehicle ADD COLUMN vehicleTypeFk INT(11) DEFAULT 1;
ALTER TABLE vehicle ADD CONSTRAINT fk_vehicle_vehicleType FOREIGN KEY (vehicleTypeFk) REFERENCES vehicleType(id);

View File

@ -0,0 +1,23 @@
CREATE OR REPLACE TABLE vn.mandateLog (
`id` int(11) NOT NULL AUTO_INCREMENT,
`originFk` int(11) DEFAULT NULL,
`userFk` int(10) unsigned DEFAULT NULL,
`action` set('insert','update','delete','select') NOT NULL,
`creationDate` timestamp NULL DEFAULT current_timestamp(),
`description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
`changedModel` enum('client') NOT NULL DEFAULT 'client',
`oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)),
`newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)),
`changedModelId` int(11) NOT NULL,
`changedModelValue` varchar(45) DEFAULT NULL,
`summaryId` varchar(30) DEFAULT NULL,
`reason` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `logMandate_userFk` (`userFk`),
KEY `mandateLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`),
KEY `mandateLog_originFk` (`originFk`,`creationDate`),
KEY `mandateLog_creationDate_IDX` (`creationDate` DESC) USING BTREE,
CONSTRAINT `mandateUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
ALTER TABLE vn.mandate ADD editorFk INT UNSIGNED DEFAULT NULL NULL;

View File

@ -0,0 +1 @@
ALTER TABLE vn.recovery DROP FOREIGN KEY cliente333;

View File

@ -58,10 +58,10 @@
"Swift / BIC can't be empty": "Swift / BIC can't be empty", "Swift / BIC can't be empty": "Swift / BIC can't be empty",
"Deleted sales from ticket": "I have deleted the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", "Deleted sales from ticket": "I have deleted the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}",
"Added sale to ticket": "I have added the following line to the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", "Added sale to ticket": "I have added the following line to the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}",
"Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}} {{ticketWeekly}}",
"Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
"Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})", "Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}}",
"Changed sale quantity": "I have changed {{changes}} of the ticket [{{ticketId}}]({{{ticketUrl}}})", "Changed sale quantity": "I have changed {{changes}} of the ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}}",
"Changes in sales": "the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}*", "Changes in sales": "the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}*",
"Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
"Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})", "Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})",
@ -253,5 +253,6 @@
"Sales already moved": "Sales already moved", "Sales already moved": "Sales already moved",
"Holidays to past days not available": "Holidays to past days not available", "Holidays to past days not available": "Holidays to past days not available",
"Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}", "Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}",
"Ticket has been delivered out of order": "The ticket {{ticket}} of route {{{fullUrl}}} has been delivered out of order." "Ticket has been delivered out of order": "The ticket {{ticket}} of route {{{fullUrl}}} has been delivered out of order.",
"clonedFromTicketWeekly": ", that is a cloned sale from ticket {{ ticketWeekly }}"
} }

View File

@ -121,10 +121,10 @@
"Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios", "Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios",
"Deleted sales from ticket": "He eliminado las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", "Deleted sales from ticket": "He eliminado las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}",
"Added sale to ticket": "He añadido la siguiente linea al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", "Added sale to ticket": "He añadido la siguiente linea al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}",
"Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}} {{ticketWeekly}}",
"Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
"Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}} ",
"Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}})", "Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}}",
"Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*", "Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*",
"State": "Estado", "State": "Estado",
"regular": "normal", "regular": "normal",
@ -396,6 +396,6 @@
"There are tickets to be invoiced": "La zona tiene tickets por facturar", "There are tickets to be invoiced": "La zona tiene tickets por facturar",
"Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}", "Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}",
"Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sido entregado en su orden.", "Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sido entregado en su orden.",
"Price cannot be blank": "El precio no puede estar en blanco" "Price cannot be blank": "El precio no puede estar en blanco",
"clonedFromTicketWeekly": ", que es una linea clonada del ticket {{ticketWeekly}}"
} }

View File

@ -1,4 +1,4 @@
name: muestra name: plantilla
columns: columns:
id: id id: id
created: creado created: creado

View File

@ -0,0 +1,10 @@
name: mandate
columns:
id: id
clientFk: client
companyFk: company
code: code
created: created
finished: finished
mandateTypeFk: mandate type
editorFk: editor

View File

@ -0,0 +1,10 @@
name: mandate
columns:
id: id
clientFk: cliente
companyFk: empresa
code: código
created: creado
finished: finalizado
mandateTypeFk: tipo de mandato
editorFk: editor

View File

@ -1,6 +1,9 @@
{ {
"name": "Mandate", "name": "Mandate",
"base": "VnModel", "base": "VnModel",
"mixins": {
"Loggable": true
},
"options": { "options": {
"mysql": { "mysql": {
"table": "mandate" "table": "mandate"

View File

@ -0,0 +1,128 @@
const {ParameterizedSQL} = require('loopback-connector');
const {buildFilter, mergeFilters} = require('vn-loopback/util/filter');
module.exports = Self => {
Self.remoteMethodCtx('filter', {
description: 'Find all instances of the model matched by filter from the data source.',
accessType: 'READ',
accepts: [{
arg: 'filter',
type: 'object',
description: 'Filter defining where, order, skip and limit - must be a JSON-encoded string',
http: {source: 'query'}
}, {
arg: 'search',
type: 'string',
description: 'Searchs the vehicle by id or numberPlate',
http: {source: 'query'}
}, {
arg: 'id',
type: 'number'
}, {
arg: 'description',
type: 'string'
}, {
arg: 'companyFk',
type: 'number'
}, {
arg: 'tradeMark',
type: 'string'
}, {
arg: 'numberPlate',
type: 'string'
}, {
arg: 'warehouseFk',
type: 'number'
}, {
arg: 'chassis',
type: 'string'
}, {
arg: 'leasing',
type: 'string'
}, {
arg: 'countryCodeFk',
type: 'string'
}, {
arg: 'vehicleTypeFk',
type: 'number'
}, {
arg: 'vehicleStateFk',
type: 'number'
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/filter`,
verb: `GET`
}
});
Self.filter = async(ctx, filter, options) => {
const conn = Self.dataSource.connector;
const myOptions = {};
if (typeof options == 'object') Object.assign(myOptions, options);
const where = buildFilter(ctx.args, (param, value) => {
switch (param) {
case 'search':
return {or: [{'v.id': value}, {numberPlate: {like: `%${value}%`}}]};
case 'id':
return {'v.id': value};
case 'description':
case 'tradeMark':
case 'numberPlate':
case 'chassis':
case 'leasing':
return {[param]: {like: `%${value}%`}};
case 'companyFk':
case 'warehouseFk':
case 'countryCodeFk':
case 'vehicleStateFk':
case 'vehicleTypeFk':
return {[param]: value};
}
});
filter = mergeFilters(filter, {where});
const stmt = new ParameterizedSQL(`
SELECT v.id,
v.numberPlate,
v.tradeMark,
v.model,
v.m3,
v.description,
v.isActive,
v.countryCodeFk,
v.chassis,
v.leasing,
vt.name type,
w.name warehouse,
c.code company,
sub.state
FROM vehicle v
JOIN vehicleType vt ON vt.id = v.vehicleTypeFk
LEFT JOIN warehouse w ON w.id = v.warehouseFk
LEFT JOIN company c ON c.id = v.companyFk
LEFT JOIN (
SELECT e.vehicleFk,
e.vehicleStateFk,
s.state,
ROW_NUMBER() OVER (PARTITION BY e.vehicleFk ORDER BY e.started DESC) rn
FROM vehicleEvent e
LEFT JOIN vehicleState s ON e.vehicleStateFk = s.id
) sub ON sub.vehicleFk = v.id AND sub.rn = 1
`);
const sqlWhere = conn.makeWhere(filter.where);
stmt.merge(sqlWhere);
stmt.merge(conn.makePagination(filter));
const sql = ParameterizedSQL.join([stmt], ';');
return conn.executeStmt(sql, myOptions);
};
};

View File

@ -0,0 +1,127 @@
const {models} = require('vn-loopback/server/server');
describe('Vehicle filter()', () => {
const deliveryAssiId = 123;
const ctx = beforeAll.getCtx(deliveryAssiId);
let options;
let tx;
beforeEach(async() => {
ctx.args = {};
options = {};
tx = await models.Sale.beginTransaction({});
options.transaction = tx;
});
afterEach(async() => {
await tx.rollback();
});
it('should return the vehicles matching "search"', async() => {
const {id} = await models.Vehicle.findById(1, null, options);
const {numberPlate} = await models.Vehicle.findById(2, null, options);
ctx.args = {search: id};
const [searchResult] = await models.Vehicle.filter(ctx);
ctx.args = {search: numberPlate};
const [searchResult2] = await models.Vehicle.filter(ctx);
expect(searchResult.id).toEqual(id);
expect(searchResult2.numberPlate).toEqual(numberPlate);
});
it('should return the vehicles matching "companyFk"', async() => {
const company = await models.Company.findOne({where: {code: 'VNL'}}, options);
ctx.args = {companyFk: company.id};
const searchResult = await models.Vehicle.filter(ctx, null, options);
searchResult.forEach(record => {
expect(record.company).toEqual(company.code);
});
});
it('should return the vehicles matching "tradeMark"', async() => {
const tradeMark = 'WAYNE INDUSTRIES';
ctx.args = {tradeMark};
const searchResult = await models.Vehicle.filter(ctx);
searchResult.forEach(record => {
expect(record.tradeMark).toEqual(tradeMark);
});
});
it('should return the vehicles matching "numberPlate"', async() => {
const {numberPlate} = await models.Vehicle.findById(1, null, options);
ctx.args = {numberPlate};
const searchResult = await models.Vehicle.filter(ctx);
searchResult.forEach(record => {
expect(record.numberPlate).toEqual(numberPlate);
});
});
it('should return the vehicles matching "warehouseFk"', async() => {
const warehouse = await models.Warehouse.findById(1, null, options);
ctx.args = {warehouseFk: warehouse.id};
const searchResult = await models.Vehicle.filter(ctx);
searchResult.forEach(record => {
expect(record.warehouse).toEqual(warehouse.name);
});
});
it('should return the vehicles matching "chassis"', async() => {
const {chassis} = await models.Vehicle.findById(1, null, options);
ctx.args = {chassis};
const [searchResult] = await models.Vehicle.filter(ctx);
expect(searchResult.chassis).toEqual(chassis);
});
it('should return the vehicles matching "leasing"', async() => {
const leasing = 'Wayne leasing';
ctx.args = {leasing};
const searchResult = await models.Vehicle.filter(ctx);
searchResult.forEach(record => {
expect(record.leasing).toEqual(leasing);
});
});
it('should return the vehicles matching "countryCodeFk"', async() => {
const countryCodeFk = 'ES';
ctx.args = {countryCodeFk};
const searchResult = await models.Vehicle.filter(ctx);
searchResult.forEach(record => {
expect(record.countryCodeFk).toEqual(countryCodeFk);
});
});
it('should return the vehicles matching "vehicleTypeFk"', async() => {
const {name, id} = await models.VehicleType.findById(1, null, options);
ctx.args = {vehicleTypeFk: id};
const searchResult = await models.Vehicle.filter(ctx);
searchResult.forEach(record => {
expect(record.type).toEqual(name);
});
});
it('should return the vehicles matching "vehicleStateFk"', async() => {
const {state, id} = await models.VehicleState.findById(3);
ctx.args = {vehicleStateFk: id};
const searchResult = await models.Vehicle.filter(ctx);
searchResult.forEach(record => {
expect(record.state).toEqual(state);
});
});
it('should return the vehicles matching "description"', async() => {
const {description} = await models.Vehicle.findById(2);
ctx.args = {description};
const searchResult = await models.Vehicle.filter(ctx);
searchResult.forEach(record => {
expect(record.description).toEqual(description);
});
});
});

View File

@ -5,12 +5,21 @@
"AgencyTermConfig": { "AgencyTermConfig": {
"dataSource": "vn" "dataSource": "vn"
}, },
"BankPolicy": {
"dataSource": "vn"
},
"Cmr": { "Cmr": {
"dataSource": "vn" "dataSource": "vn"
}, },
"DeliveryPoint": { "DeliveryPoint": {
"dataSource": "vn" "dataSource": "vn"
}, },
"FuelType": {
"dataSource": "vn"
},
"Ppe": {
"dataSource": "vn"
},
"RoadmapAddress": { "RoadmapAddress": {
"dataSource": "vn" "dataSource": "vn"
}, },
@ -35,6 +44,12 @@
"Vehicle": { "Vehicle": {
"dataSource": "vn" "dataSource": "vn"
}, },
"VehicleState": {
"dataSource": "vn"
},
"VehicleType": {
"dataSource": "vn"
},
"RoutesMonitor": { "RoutesMonitor": {
"dataSource": "vn" "dataSource": "vn"
} }

View File

@ -0,0 +1,21 @@
{
"name": "BankPolicy",
"base": "VnModel",
"options": {
"mysql": {
"table": "bankPolicy"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"ref": {
"type": "string"
},
"dmsFk": {
"type": "number"
}
}
}

View File

@ -0,0 +1,30 @@
{
"name": "FuelType",
"base": "VnModel",
"options": {
"mysql": {
"table": "fuelType"
}
},
"properties": {
"id": {
"type": "number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string"
},
"code": {
"type": "string"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -0,0 +1,15 @@
{
"name": "Ppe",
"base": "VnModel",
"options": {
"mysql": {
"table": "ppe"
}
},
"properties": {
"id": {
"type": "number",
"id": true
}
}
}

View File

@ -0,0 +1,21 @@
{
"name": "VehicleState",
"base": "VnModel",
"options": {
"mysql": {
"table": "vehicleState"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"state": {
"type": "string"
},
"hasToNotify": {
"type": "number"
}
}
}

View File

@ -0,0 +1,19 @@
{
"name": "VehicleType",
"base": "VnModel",
"options": {
"mysql": {
"table": "vehicleType"
}
},
"properties": {
"id": {
"type": "number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string"
}
}
}

View File

@ -1,3 +1,4 @@
module.exports = Self => { module.exports = Self => {
require('../methods/vehicle/sorted')(Self); require('../methods/vehicle/sorted')(Self);
require('../methods/vehicle/filter')(Self);
}; };

View File

@ -29,6 +29,39 @@
}, },
"isActive": { "isActive": {
"type": "number" "type": "number"
},
"countryCodeFk": {
"type": "string"
},
"chassis": {
"type": "string"
},
"leasing": {
"type": "string"
},
"isKmTruckRate": {
"type": "number"
},
"fuelTypeFk": {
"type": "number"
},
"import": {
"type": "number"
},
"importCooler": {
"type": "number"
},
"vin": {
"type": "string"
},
"ppeFk": {
"type": "number"
},
"vehicleTypeFk": {
"type": "number"
},
"deliveryPointFk": {
"type": "number"
} }
}, },
"relations": { "relations": {
@ -46,21 +79,57 @@
"type": "belongsTo", "type": "belongsTo",
"model": "DeliveryPoint", "model": "DeliveryPoint",
"foreignKey": "deliveryPointFk" "foreignKey": "deliveryPointFk"
},
"event": {
"type": "hasMany",
"model": "VehicleEvent",
"foreignKey": "vehicleFk",
"property": "id"
},
"supplier": {
"type": "belongsTo",
"model": "Supplier",
"foreignKey": "supplierFk"
},
"supplierCooler": {
"type": "belongsTo",
"model": "Supplier",
"foreignKey": "supplierCoolerFk"
},
"bankPolicy": {
"type": "belongsTo",
"model": "BankPolicy",
"foreignKey": "bankPolicyFk"
},
"fuelType": {
"type": "belongsTo",
"model": "FuelType",
"foreignKey": "fuelTypeFk"
},
"ppe": {
"type": "hasOne",
"model": "Ppe",
"foreignKey": "id",
"property": "ppeFk"
},
"type": {
"type": "hasOne",
"model": "VehicleType",
"foreignKey": "id",
"property": "vehicleTypeFk"
} }
}, },
"scope": { "scopes": {
"active": {
"fields": [
"id",
"numberPlate"
],
"where": { "where": {
"isActive": { "isActive": {
"neq": false "neq": false
} }
} }
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
} }
] }
} }

View File

@ -12,14 +12,6 @@
"id": true, "id": true,
"description": "Identifier" "description": "Identifier"
}, },
"column": {
"type": "string",
"required": true
},
"row": {
"type": "string",
"required": true
},
"code": { "code": {
"type": "string" "type": "string"
}, },

View File

@ -113,6 +113,12 @@ module.exports = Self => {
const salesPerson = sale.ticket().client().salesPersonUser(); const salesPerson = sale.ticket().client().salesPersonUser();
if (salesPerson) { if (salesPerson) {
const url = await Self.app.models.Url.getUrl(); const url = await Self.app.models.Url.getUrl();
const saleCloned = await Self.app.models.SaleCloned.findById(sale.id, {
include: 'saleOriginal',
});
const ticketWeekly = saleCloned?.saleOriginal()?.ticketFk || null;
const message = $t('Changed sale price', { const message = $t('Changed sale price', {
ticketId: sale.ticket().id, ticketId: sale.ticket().id,
itemId: sale.itemFk, itemId: sale.itemFk,
@ -121,7 +127,8 @@ module.exports = Self => {
oldPrice: oldPrice, oldPrice: oldPrice,
newPrice: newPrice, newPrice: newPrice,
ticketUrl: `${url}ticket/${sale.ticket().id}/sale`, ticketUrl: `${url}ticket/${sale.ticket().id}/sale`,
itemUrl: `${url}item/${sale.itemFk}/summary` itemUrl: `${url}item/${sale.itemFk}/summary`,
ticketWeekly: ticketWeekly ? $t('clonedFromTicketWeekly', {ticketWeekly}) : null
}); });
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions); await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
} }

View File

@ -72,6 +72,12 @@ module.exports = Self => {
const salesPerson = sale.ticket().client().salesPersonUser(); const salesPerson = sale.ticket().client().salesPersonUser();
if (salesPerson) { if (salesPerson) {
const url = await Self.app.models.Url.getUrl(); const url = await Self.app.models.Url.getUrl();
const saleCloned = await Self.app.models.SaleCloned.findById(sale.id, {
include: 'saleOriginal',
});
const ticketWeekly = saleCloned?.saleOriginal()?.ticketFk || null;
const change = $t('Changes in sales', { const change = $t('Changes in sales', {
itemId: sale.itemFk, itemId: sale.itemFk,
concept: sale.concept, concept: sale.concept,
@ -84,6 +90,7 @@ module.exports = Self => {
ticketId: sale.ticket().id, ticketId: sale.ticket().id,
changes: JSON.stringify(change), changes: JSON.stringify(change),
ticketUrl: `${url}ticket/${sale.ticket().id}/sale`, ticketUrl: `${url}ticket/${sale.ticket().id}/sale`,
ticketWeekly: ticketWeekly ? $t('clonedFromTicketWeekly', {ticketWeekly}) : null
}); });
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions); await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);

View File

@ -166,10 +166,18 @@ module.exports = Self => {
const salesPerson = ticket.client().salesPersonUser(); const salesPerson = ticket.client().salesPersonUser();
if (salesPerson) { if (salesPerson) {
const url = await Self.app.models.Url.getUrl(); const url = await Self.app.models.Url.getUrl();
const saleId = sales[0].id;
const saleCloned = await Self.app.models.SaleCloned.findById(saleId, {
include: 'saleOriginal',
});
const ticketWeekly = saleCloned?.saleOriginal()?.ticketFk || null;
const message = $t('Changed sale discount', { const message = $t('Changed sale discount', {
ticketId: id, ticketId: id,
ticketUrl: `${url}ticket/${id}/sale`, ticketUrl: `${url}ticket/${id}/sale`,
changes: changesMade changes: changesMade,
ticketWeekly: ticketWeekly ? $t('clonedFromTicketWeekly', {ticketWeekly}) : null
}); });
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions); await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
} }