Compare commits
7 Commits
dev
...
6897-refac
Author | SHA1 | Date |
---|---|---|
|
26faaad5b4 | |
|
e4cd30bc27 | |
|
13d9cac340 | |
|
8f3bf46165 | |
|
e7dd1f6a58 | |
|
ef5c2ab3a2 | |
|
f8a156b7ab |
|
@ -13,7 +13,6 @@ 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
|
||||||
|
|
|
@ -168,6 +168,7 @@
|
||||||
"emailVerified",
|
"emailVerified",
|
||||||
"twoFactor"
|
"twoFactor"
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,16 +30,11 @@ 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
|
||||||
|
@ -59,19 +54,16 @@ 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
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
JOIN vn.item i ON i.id = s.itemFk
|
WHERE t.shipped BETWEEN vFutureDated
|
||||||
WHERE t.shipped BETWEEN vFutureDated
|
AND util.dayend(vFutureDated)
|
||||||
AND util.dayend(vFutureDated)
|
AND t.warehouseFk = vWarehouseFk
|
||||||
AND t.warehouseFk = vWarehouseFk
|
GROUP BY t.id
|
||||||
GROUP BY t.id
|
|
||||||
) sub
|
) sub
|
||||||
GROUP BY sub.addressFk
|
GROUP BY sub.addressFk
|
||||||
) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
|
) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
|
||||||
|
|
|
@ -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 OR i.isFragile);
|
AND it.isFragile;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket_warnings
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket_warnings
|
||||||
(PRIMARY KEY (ticketFk))
|
(PRIMARY KEY (ticketFk))
|
||||||
|
|
|
@ -10,6 +10,7 @@ BEGIN
|
||||||
|
|
||||||
IF NEW.isBooked = OLD.isBooked AND (
|
IF NEW.isBooked = OLD.isBooked AND (
|
||||||
NOT (NEW.supplierFk <=> OLD.supplierFk) OR
|
NOT (NEW.supplierFk <=> OLD.supplierFk) OR
|
||||||
|
NOT (NEW.dated <=> OLD.dated) OR
|
||||||
NOT (NEW.travelFk <=> OLD.travelFk) OR
|
NOT (NEW.travelFk <=> OLD.travelFk) OR
|
||||||
NOT (NEW.companyFk <=> OLD.companyFk) OR
|
NOT (NEW.companyFk <=> OLD.companyFk) OR
|
||||||
NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) OR
|
NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) OR
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
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 ;
|
|
|
@ -3,12 +3,10 @@ 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
|
||||||
WHERE TABLE_SCHEMA='vn' and TABLE_NAME='mandate'));
|
WHERE TABLE_SCHEMA='vn' and TABLE_NAME='mandate'));
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
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 ;
|
|
|
@ -16,6 +16,7 @@ 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`
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
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`;
|
|
|
@ -1,41 +0,0 @@
|
||||||
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);
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('Entry','getBuyList','READ','ALLOW','ROLE','buyer'),
|
||||||
|
('Entry','getBuyUltimate','READ','ALLOW','ROLE','buyer'),
|
||||||
|
('Entry','create','WRITE','ALLOW','ROLE','buyer'),
|
||||||
|
('Entry','cloneEntry','WRITE','ALLOW','ROLE','buyer'),
|
||||||
|
('Entry','deleteEntry','WRITE','ALLOW','ROLE','buyer'),
|
||||||
|
('Entry','recalcEntryPrices','WRITE','ALLOW','ROLE','buyer'),
|
||||||
|
('EntryType','find','READ','ALLOW','ROLE','buyer'),
|
||||||
|
('EntryConfig','findOne','READ','ALLOW','ROLE','buyer');
|
||||||
|
|
||||||
|
ALTER TABLE vn.ink ADD IF NOT EXISTS hexJson TEXT NOT NULL;
|
||||||
|
|
||||||
|
UPDATE vn.ink
|
||||||
|
SET hexJson = CONCAT('{"value": ["',hex,'"]}')
|
|
@ -1,6 +0,0 @@
|
||||||
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
|
|
||||||
VALUES
|
|
||||||
('WorkerDms', 'hasHighPrivs', 'READ', 'ALLOW', 'ROLE', 'hr'),
|
|
||||||
('Business', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'hr'),
|
|
||||||
('Worker', '__get__business', 'READ', 'ALLOW', 'ROLE', 'hr')
|
|
||||||
;
|
|
|
@ -1,23 +0,0 @@
|
||||||
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;
|
|
|
@ -1 +0,0 @@
|
||||||
ALTER TABLE vn.recovery DROP FOREIGN KEY cliente333;
|
|
|
@ -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}}} {{ticketWeekly}}",
|
"Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
"Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}}",
|
"Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
"Changed sale quantity": "I have changed {{changes}} of the ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}}",
|
"Changed sale quantity": "I have changed {{changes}} of the ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
"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,6 +253,5 @@
|
||||||
"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 }}"
|
|
||||||
}
|
}
|
|
@ -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}}} {{ticketWeekly}}",
|
"Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
"Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||||
"Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}} ",
|
"Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
"Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}}) {{ticketWeekly}}",
|
"Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
"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}}"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name: plantilla
|
name: muestra
|
||||||
columns:
|
columns:
|
||||||
id: id
|
id: id
|
||||||
created: creado
|
created: creado
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
name: mandate
|
|
||||||
columns:
|
|
||||||
id: id
|
|
||||||
clientFk: client
|
|
||||||
companyFk: company
|
|
||||||
code: code
|
|
||||||
created: created
|
|
||||||
finished: finished
|
|
||||||
mandateTypeFk: mandate type
|
|
||||||
editorFk: editor
|
|
|
@ -1,10 +0,0 @@
|
||||||
name: mandate
|
|
||||||
columns:
|
|
||||||
id: id
|
|
||||||
clientFk: cliente
|
|
||||||
companyFk: empresa
|
|
||||||
code: código
|
|
||||||
created: creado
|
|
||||||
finished: finalizado
|
|
||||||
mandateTypeFk: tipo de mandato
|
|
||||||
editorFk: editor
|
|
|
@ -248,10 +248,9 @@ module.exports = Self => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
|
||||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||||
|
const accessToken = {req: loopBackContext.active.accessToken};
|
||||||
|
|
||||||
const accessToken = {req: {accessToken: loopBackContext.active.accessToken}};
|
const editVerifiedDataWithoutTaxDataChecked = models.ACL.checkAccessAcl(
|
||||||
|
|
||||||
const editVerifiedDataWithoutTaxDataChecked = await models.ACL.checkAccessAcl(
|
|
||||||
accessToken,
|
accessToken,
|
||||||
'Client',
|
'Client',
|
||||||
'editVerifiedDataWithoutTaxDataCheck',
|
'editVerifiedDataWithoutTaxDataCheck',
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Mandate",
|
"name": "Mandate",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"mixins": {
|
|
||||||
"Loggable": true
|
|
||||||
},
|
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "mandate"
|
"table": "mandate"
|
||||||
|
|
|
@ -0,0 +1,303 @@
|
||||||
|
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||||
|
const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
||||||
|
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('getBuyList', {
|
||||||
|
description: 'Returns buys for editing of one entry',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'entryFk',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'The entry id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'filter',
|
||||||
|
type: 'object',
|
||||||
|
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'isIgnored',
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'check if the buy is ignored',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'itemFk',
|
||||||
|
type: 'number',
|
||||||
|
description: 'item id',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'name',
|
||||||
|
type: 'string',
|
||||||
|
description: 'item name',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'size',
|
||||||
|
type: 'number',
|
||||||
|
description: 'item size',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'stickers',
|
||||||
|
type: 'number',
|
||||||
|
description: 'sticker quantity',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'packagingFk',
|
||||||
|
type: 'number',
|
||||||
|
description: 'packaging id',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'weight',
|
||||||
|
type: 'number',
|
||||||
|
description: 'weight',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'packing',
|
||||||
|
type: 'number',
|
||||||
|
description: 'packing quantity',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'grouping',
|
||||||
|
type: 'number',
|
||||||
|
description: 'grouping quantity',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'quantity',
|
||||||
|
type: 'number',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'buyingValue',
|
||||||
|
type: 'number',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'amount',
|
||||||
|
type: 'number',
|
||||||
|
description: 'buying value * quantity',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'price2',
|
||||||
|
type: 'number',
|
||||||
|
description: 'price for the package',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'price3',
|
||||||
|
type: 'number',
|
||||||
|
description: 'price for the box',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'minPrice',
|
||||||
|
type: 'number',
|
||||||
|
description: 'item minimum price',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'packingOut',
|
||||||
|
type: 'number',
|
||||||
|
description: 'quantity of package on a vn box',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'comment',
|
||||||
|
type: 'string',
|
||||||
|
description: 'item comment',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'subName',
|
||||||
|
type: 'string',
|
||||||
|
description: 'supplier name',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'subName',
|
||||||
|
type: 'string',
|
||||||
|
description: 'supplier name',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'company_name',
|
||||||
|
type: 'string',
|
||||||
|
description: 'company name',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'workerFk',
|
||||||
|
type: 'number',
|
||||||
|
description: 'buyer id',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'itemTypeFk',
|
||||||
|
type: 'number',
|
||||||
|
description: 'item family id',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'groupingMode',
|
||||||
|
type: 'string',
|
||||||
|
description: 'grouping mode',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'hasMinPrice',
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'grouping mode',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'groupBy',
|
||||||
|
type: 'string',
|
||||||
|
description: 'group by',
|
||||||
|
http: {source: 'query'}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: ['object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:entryFk/getBuyList`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.getBuyList = async(ctx, entryFk, filter, options) => {
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
let conn = Self.dataSource.connector;
|
||||||
|
let where = buildFilter(ctx.args, (param, value) => {
|
||||||
|
switch (param) {
|
||||||
|
case 'name':
|
||||||
|
case 'subName':
|
||||||
|
case 'company_name':
|
||||||
|
case 'comment':
|
||||||
|
return {[param]: {like: `%${value}%`}};
|
||||||
|
case 'size':
|
||||||
|
case 'isIgnored':
|
||||||
|
case 'itemFk':
|
||||||
|
case 'stickers':
|
||||||
|
case 'packagingFk':
|
||||||
|
case 'weight':
|
||||||
|
case 'packing':
|
||||||
|
case 'grouping':
|
||||||
|
case 'quantity':
|
||||||
|
case 'buyingValue':
|
||||||
|
case 'amount':
|
||||||
|
case 'price2':
|
||||||
|
case 'price3':
|
||||||
|
case 'packingOut':
|
||||||
|
case 'minPrice':
|
||||||
|
case 'workerFk':
|
||||||
|
case 'itemTypeFk':
|
||||||
|
case 'groupingMode':
|
||||||
|
case 'hasMinPrice':
|
||||||
|
return {[param]: value};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
filter = mergeFilters(filter, {where});
|
||||||
|
|
||||||
|
let stmts = [];
|
||||||
|
let stmt;
|
||||||
|
|
||||||
|
const selectFields = `b.id,
|
||||||
|
b.isIgnored,
|
||||||
|
b.itemFk,
|
||||||
|
b.printedStickers,
|
||||||
|
b.stickers,
|
||||||
|
b.packagingFk,
|
||||||
|
b.weight,
|
||||||
|
b.packing,
|
||||||
|
b.groupingMode,
|
||||||
|
b.grouping,
|
||||||
|
b.quantity,
|
||||||
|
b.buyingValue,
|
||||||
|
ROUND(b.buyingValue * b.quantity, 2) amount,
|
||||||
|
b.isChecked,
|
||||||
|
b.price2,
|
||||||
|
b.price3,
|
||||||
|
i.name,
|
||||||
|
i.size,
|
||||||
|
i.minPrice,
|
||||||
|
i.hasMinPrice,
|
||||||
|
i.packingOut,
|
||||||
|
i.comment,
|
||||||
|
i.subName,
|
||||||
|
i.tag5,
|
||||||
|
i.value5,
|
||||||
|
i.tag6,
|
||||||
|
i.value6,
|
||||||
|
i.tag7,
|
||||||
|
i.value7,
|
||||||
|
i.tag8,
|
||||||
|
i.value8,
|
||||||
|
i.tag9,
|
||||||
|
i.value9,
|
||||||
|
i.tag10,
|
||||||
|
i.value10,
|
||||||
|
s.company_name,
|
||||||
|
ik.hexJson,
|
||||||
|
it.workerFk,
|
||||||
|
it.id itemTypeFk
|
||||||
|
`;
|
||||||
|
|
||||||
|
const groupByFields = `SUM(b.printedStickers) printedStickers,
|
||||||
|
SUM(b.packing) packing,
|
||||||
|
SUM(b.stickers) stickers,
|
||||||
|
SUM(b.weight) weight,
|
||||||
|
SUM(b.quantity) quantity,
|
||||||
|
SUM(ROUND(b.buyingValue * b.quantity, 2)) amount
|
||||||
|
`;
|
||||||
|
|
||||||
|
const groupBy = ctx.args.groupBy;
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL(
|
||||||
|
`SELECT *
|
||||||
|
FROM(
|
||||||
|
SELECT
|
||||||
|
${ groupBy ? groupByFields : selectFields}
|
||||||
|
FROM item i
|
||||||
|
LEFT JOIN ink ik ON ik.id = i.inkFk
|
||||||
|
LEFT JOIN buy b ON b.itemFk = i.id
|
||||||
|
LEFT JOIN edi.ekt e ON e.id = b.ektFk
|
||||||
|
LEFT JOIN edi.supplier s ON e.pro = s.supplier_id
|
||||||
|
LEFT JOIN itemType it ON it.id = i.typeFk
|
||||||
|
WHERE b.entryFk = ?
|
||||||
|
${groupBy ?? ''}
|
||||||
|
) sub`,
|
||||||
|
[entryFk]
|
||||||
|
);
|
||||||
|
|
||||||
|
stmt.merge(conn.makeSuffix(filter));
|
||||||
|
let itemsIndex = stmts.push(stmt) - 1;
|
||||||
|
|
||||||
|
let sql = ParameterizedSQL.join(stmts, ';');
|
||||||
|
let result = await conn.executeStmt(sql, myOptions);
|
||||||
|
|
||||||
|
if (groupBy && result.length) {
|
||||||
|
const buys = await Self.app.models.Buy.find({where: {entryFk}}, myOptions);
|
||||||
|
const buysChecked = buys.filter(buy => buy?.isChecked);
|
||||||
|
result[0].isChecked = buysChecked.length === buys.length;
|
||||||
|
}
|
||||||
|
return itemsIndex === 0 ? result : result[itemsIndex];
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,46 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('getBuyUltimate', {
|
||||||
|
description: 'Returns the last buy of the item',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'itemFk',
|
||||||
|
type: 'number',
|
||||||
|
required: true
|
||||||
|
}, {
|
||||||
|
arg: 'warehouseFk',
|
||||||
|
type: 'number',
|
||||||
|
required: true
|
||||||
|
}, {
|
||||||
|
arg: 'date',
|
||||||
|
type: 'date',
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/getBuyUltimate`,
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Self.getBuyUltimate = async(ctx, itemFk, warehouseFk, date, options) => {
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
await Self.rawSql('CALL vn.buy_getUltimate(?, ?, ?)', [itemFk, warehouseFk, date], myOptions);
|
||||||
|
return Self.rawSql(
|
||||||
|
`SELECT b.*
|
||||||
|
FROM cache.last_buy lb
|
||||||
|
JOIN buy b ON b.id = lb.buy_id
|
||||||
|
WHERE lb.item_id = ?
|
||||||
|
ORDER BY (lb.warehouse_id = ?) desc
|
||||||
|
LIMIT 1`,
|
||||||
|
[itemFk, warehouseFk], myOptions
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,46 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('cloneEntry', {
|
||||||
|
description: 'Clones an entry',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'The entry id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/cloneEntry`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.cloneEntry = async(ctx, id, options) => {
|
||||||
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
const myOptions = {userId};
|
||||||
|
let tx;
|
||||||
|
let result;
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = await Self.rawSql('CALL entry_clone(?)', [id], myOptions);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
return result[0];
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,48 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('deleteEntry', {
|
||||||
|
description: 'Clones an entry',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'The entry id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
}],
|
||||||
|
http: {
|
||||||
|
path: `/:id/deleteEntry`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.deleteEntry = async(ctx, id, options) => {
|
||||||
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
const myOptions = {userId};
|
||||||
|
let tx;
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const entry = await Self.findById(id, null, myOptions);
|
||||||
|
await entry.updateAttribute('travelFk', null, myOptions);
|
||||||
|
await Self.rawSql('DELETE FROM vn.duaEntry WHERE entryFk = ?;', [id], myOptions);
|
||||||
|
await Self.rawSql(`
|
||||||
|
DELETE i.*
|
||||||
|
FROM vn.invoiceIn i
|
||||||
|
JOIN vn.entry e ON e.invoiceInFk = i.id
|
||||||
|
WHERE e.id = ?`, [id], myOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -129,7 +129,68 @@ module.exports = Self => {
|
||||||
arg: 'finalTemperature',
|
arg: 'finalTemperature',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'Final temperature value'
|
description: 'Final temperature value'
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
arg: 'isExcludedFromAvailable',
|
||||||
|
type: 'boolean',
|
||||||
|
description: `landing date`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'isReceived',
|
||||||
|
type: 'boolean',
|
||||||
|
description: `travel received`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'isRaid',
|
||||||
|
type: 'boolean',
|
||||||
|
description: `travel isRaid`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'landed',
|
||||||
|
type: 'date',
|
||||||
|
description: `landing date`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'invoiceNumber',
|
||||||
|
type: 'string',
|
||||||
|
description: `entry invoice`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'reference',
|
||||||
|
type: 'string',
|
||||||
|
description: `entry reference`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'awbCode',
|
||||||
|
type: 'string',
|
||||||
|
description: `awb code`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'agencyModeId',
|
||||||
|
type: 'number',
|
||||||
|
description: `agency mode id`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'evaNotes',
|
||||||
|
type: 'string',
|
||||||
|
description: `observation`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'warehouseInFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `warehouse in id`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'warehouseOutFk',
|
||||||
|
type: 'number',
|
||||||
|
description: `warehouse out id`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'entryTypeCode',
|
||||||
|
type: 'string',
|
||||||
|
description: 'entry type code'
|
||||||
|
},
|
||||||
|
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
type: ['object'],
|
type: ['object'],
|
||||||
|
@ -156,19 +217,12 @@ module.exports = Self => {
|
||||||
{'s.name': {like: `%${value}%`}},
|
{'s.name': {like: `%${value}%`}},
|
||||||
{'s.nickname': {like: `%${value}%`}}
|
{'s.nickname': {like: `%${value}%`}}
|
||||||
]};
|
]};
|
||||||
|
case 'invoiceNumber':
|
||||||
|
case 'reference':
|
||||||
case 'ref':
|
case 'ref':
|
||||||
|
case 'evaNotes':
|
||||||
param = `e.${param}`;
|
param = `e.${param}`;
|
||||||
return {[param]: {like: `%${value}%`}};
|
return {[param]: {like: `%${value}%`}};
|
||||||
case 'created':
|
|
||||||
return {'e.created': {gte: value}};
|
|
||||||
case 'from':
|
|
||||||
return {'t.landed': {gte: value}};
|
|
||||||
case 'fromShipped':
|
|
||||||
return {'t.shipped': {gte: value}};
|
|
||||||
case 'to':
|
|
||||||
return {'t.landed': {lte: value}};
|
|
||||||
case 'toShipped':
|
|
||||||
return {'t.shipped': {lte: value}};
|
|
||||||
case 'id':
|
case 'id':
|
||||||
case 'isBooked':
|
case 'isBooked':
|
||||||
case 'isConfirmed':
|
case 'isConfirmed':
|
||||||
|
@ -178,8 +232,20 @@ module.exports = Self => {
|
||||||
case 'currencyFk':
|
case 'currencyFk':
|
||||||
case 'supplierFk':
|
case 'supplierFk':
|
||||||
case 'invoiceInFk':
|
case 'invoiceInFk':
|
||||||
param = `e.${param}`;
|
case 'isExcludedFromAvailable':
|
||||||
return {[param]: value};
|
return {[`e.${param}`]: value};
|
||||||
|
case 'isReceived':
|
||||||
|
case 'landed':
|
||||||
|
case 'isRaid':
|
||||||
|
case 'warehouseInFk':
|
||||||
|
case 'warehouseOutFk':
|
||||||
|
return {[`t.${param}`]: value};
|
||||||
|
case 'awbCode':
|
||||||
|
return {'a.code': {like: `%${value}%`}};
|
||||||
|
case 'agencyModeId':
|
||||||
|
return {[`am.id`]: value};
|
||||||
|
case 'entryTypeCode':
|
||||||
|
return {[`et.code`]: value};
|
||||||
case 'initialTemperature':
|
case 'initialTemperature':
|
||||||
return {'e.initialTemperature': {lte: value}};
|
return {'e.initialTemperature': {lte: value}};
|
||||||
case 'finalTemperature':
|
case 'finalTemperature':
|
||||||
|
@ -197,15 +263,14 @@ module.exports = Self => {
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
stmt = new ParameterizedSQL(
|
stmt = new ParameterizedSQL(
|
||||||
`SELECT
|
`SELECT e.id,
|
||||||
e.id,
|
|
||||||
e.supplierFk,
|
e.supplierFk,
|
||||||
e.dated,
|
e.dated,
|
||||||
e.reference,
|
e.reference,
|
||||||
e.invoiceNumber,
|
e.invoiceNumber,
|
||||||
e.isBooked,
|
e.isBooked,
|
||||||
e.isExcludedFromAvailable,
|
e.isExcludedFromAvailable,
|
||||||
e.evaNotes observation,
|
e.evaNotes,
|
||||||
e.isConfirmed,
|
e.isConfirmed,
|
||||||
e.isOrdered,
|
e.isOrdered,
|
||||||
t.isRaid,
|
t.isRaid,
|
||||||
|
@ -227,15 +292,27 @@ module.exports = Self => {
|
||||||
cu.code currencyCode,
|
cu.code currencyCode,
|
||||||
t.shipped,
|
t.shipped,
|
||||||
t.landed,
|
t.landed,
|
||||||
t.ref AS travelRef,
|
t.ref travelRef,
|
||||||
t.warehouseInFk,
|
t.warehouseInFk,
|
||||||
w.name warehouseInName
|
w.name warehouseInName,
|
||||||
|
t.warehouseOutFk,
|
||||||
|
w2.name warehouseOutName,
|
||||||
|
a.code awbCode,
|
||||||
|
am.id agencyModeId,
|
||||||
|
am.name agencyModeName,
|
||||||
|
et.code entryTypeCode,
|
||||||
|
et.description entryTypeDescription,
|
||||||
|
t.isReceived
|
||||||
FROM vn.entry e
|
FROM vn.entry e
|
||||||
JOIN vn.supplier s ON s.id = e.supplierFk
|
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||||
JOIN vn.travel t ON t.id = e.travelFk
|
LEFT JOIN vn.travel t ON t.id = e.travelFk
|
||||||
JOIN vn.warehouse w ON w.id = t.warehouseInFk
|
LEFT JOIN vn.warehouse w ON w.id = t.warehouseInFk
|
||||||
JOIN vn.company co ON co.id = e.companyFk
|
LEFT JOIN vn.warehouse w2 ON w2.id = t.warehouseOutFk
|
||||||
JOIN vn.currency cu ON cu.id = e.currencyFk`
|
LEFT JOIN vn.company co ON co.id = e.companyFk
|
||||||
|
LEFT JOIN vn.currency cu ON cu.id = e.currencyFk
|
||||||
|
LEFT JOIN vn.awb a ON a.id = t.awbFk
|
||||||
|
LEFT JOIN vn.agencyMode am ON am.id = t.agencyModeFk
|
||||||
|
LEFT JOIN vn.entryType et ON et.code = e.typeFk`
|
||||||
);
|
);
|
||||||
|
|
||||||
stmt.merge(conn.makeWhere(filter.where));
|
stmt.merge(conn.makeWhere(filter.where));
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('recalcEntryPrices', {
|
||||||
|
description: 'Clones an entry',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'entryFk',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'The entry id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: 'object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:entryFk/recalcEntryPrices`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.recalcEntryPrices = async(ctx, entryFk, options) => {
|
||||||
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
const myOptions = {userId};
|
||||||
|
let tx;
|
||||||
|
let result;
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
const entry = await Self.findById(entryFk, myOptions);
|
||||||
|
const entryConfig = await Self.app.models.EntryConfig.findOne(myOptions);
|
||||||
|
|
||||||
|
if (entry.supplierFk === entryConfig.inventorySupplierFk) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = await Self.rawSql('CALL vn.buy_recalcPricesByEntry(?)', [entryFk], myOptions);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
return result[0];
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -31,5 +31,8 @@
|
||||||
},
|
},
|
||||||
"InventoryConfig": {
|
"InventoryConfig": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"EntryConfig": {
|
||||||
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "EntryConfig",
|
||||||
|
"base": "VnModel",
|
||||||
|
"mixins": {
|
||||||
|
"Loggable": true
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "entryConfig"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"defaultEntry": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true
|
||||||
|
},
|
||||||
|
"mailToNotify": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"inventorySupplierFk": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"maxLockTime": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"defaultSupplierFk": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,8 +15,13 @@ module.exports = Self => {
|
||||||
require('../methods/entry/transfer')(Self);
|
require('../methods/entry/transfer')(Self);
|
||||||
require('../methods/entry/labelSupplier')(Self);
|
require('../methods/entry/labelSupplier')(Self);
|
||||||
require('../methods/entry/buyLabelSupplier')(Self);
|
require('../methods/entry/buyLabelSupplier')(Self);
|
||||||
|
require('../methods/entry-buys/getBuyList')(Self);
|
||||||
|
require('../methods/entry-buys/getBuyUltimate')(Self);
|
||||||
|
require('../methods/entry/cloneEntry')(Self);
|
||||||
|
require('../methods/entry/deleteEntry')(Self);
|
||||||
|
require('../methods/entry/recalcEntryPrices')(Self);
|
||||||
|
|
||||||
Self.observe('before save', async function(ctx, options) {
|
Self.observe('before save', async(ctx, options) => {
|
||||||
if (ctx.isNewInstance) return;
|
if (ctx.isNewInstance) return;
|
||||||
|
|
||||||
const changes = ctx.data || ctx.instance;
|
const changes = ctx.data || ctx.instance;
|
||||||
|
|
|
@ -56,8 +56,7 @@
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"travelFk": {
|
"travelFk": {
|
||||||
"type": "number",
|
"type": "number"
|
||||||
"required": true
|
|
||||||
},
|
},
|
||||||
"companyFk": {
|
"companyFk": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
|
@ -74,6 +73,12 @@
|
||||||
},
|
},
|
||||||
"finalTemperature": {
|
"finalTemperature": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"lockerUserFk":{
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"locked":{
|
||||||
|
"type": "date"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
@ -107,6 +112,16 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "EntryType",
|
"model": "EntryType",
|
||||||
"foreignKey": "typeFk"
|
"foreignKey": "typeFk"
|
||||||
}
|
},
|
||||||
|
"invoiceIn": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "InvoiceIn",
|
||||||
|
"foreignKey": "invoiceInFk"
|
||||||
|
},
|
||||||
|
"user": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "VnUser",
|
||||||
|
"foreignKey": "lockerUserFk"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,9 @@ describe('entry_isEditable trigger', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
async function prepareEntry(isBooked, typeFk) {
|
async function prepareEntry(isBooked, typeFk) {
|
||||||
const companyFk = 69;
|
let newCreated = Date.vnNew();
|
||||||
await entry.updateAttributes({isBooked, typeFk}, options);
|
await entry.updateAttributes({isBooked, typeFk}, options);
|
||||||
await entry.updateAttributes({companyFk}, options);
|
await entry.updateAttributes({dated: newCreated}, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should throw an error when entry is booked and typeFk is null', async() => {
|
it('should throw an error when entry is booked and typeFk is null', async() => {
|
||||||
|
|
|
@ -32,12 +32,6 @@ module.exports = Self => {
|
||||||
description: 'The client id',
|
description: 'The client id',
|
||||||
http: {source: 'query'}
|
http: {source: 'query'}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
arg: 'companyFk',
|
|
||||||
type: 'integer',
|
|
||||||
description: 'The company id',
|
|
||||||
http: {source: 'query'}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
arg: 'fi',
|
arg: 'fi',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
@ -154,7 +148,6 @@ module.exports = Self => {
|
||||||
i.hasPdf,
|
i.hasPdf,
|
||||||
i.customsAgentFk,
|
i.customsAgentFk,
|
||||||
c.socialName AS clientSocialName,
|
c.socialName AS clientSocialName,
|
||||||
i.companyFk,
|
|
||||||
co.code AS companyCode,
|
co.code AS companyCode,
|
||||||
ca.fiscalName AS customsAgentName
|
ca.fiscalName AS customsAgentName
|
||||||
FROM invoiceOut i
|
FROM invoiceOut i
|
||||||
|
|
|
@ -22,11 +22,6 @@ module.exports = Self => {
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
description: 'The item id',
|
description: 'The item id',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
arg: 'name',
|
|
||||||
type: 'string',
|
|
||||||
description: 'The item name',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
arg: 'typeFk',
|
arg: 'typeFk',
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
|
@ -117,8 +112,6 @@ module.exports = Self => {
|
||||||
: {'it.code': {like: `%${value}%`}};
|
: {'it.code': {like: `%${value}%`}};
|
||||||
case 'categoryFk':
|
case 'categoryFk':
|
||||||
return {'it.categoryFk': value};
|
return {'it.categoryFk': value};
|
||||||
case 'name':
|
|
||||||
return {'i.name': {like: `%${value}%`}};
|
|
||||||
case 'buyerFk':
|
case 'buyerFk':
|
||||||
return {'it.workerFk': value};
|
return {'it.workerFk': value};
|
||||||
case 'warehouseFk':
|
case 'warehouseFk':
|
||||||
|
|
|
@ -89,7 +89,7 @@ describe('item filter()', () => {
|
||||||
const ctx = {args: {filter: filter, workerFk: 16}, req: {accessToken: {userId: 1}}};
|
const ctx = {args: {filter: filter, workerFk: 16}, req: {accessToken: {userId: 1}}};
|
||||||
const result = await models.Item.filter(ctx, filter, options);
|
const result = await models.Item.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(2);
|
expect(result.length).toEqual(3);
|
||||||
expect(result[0].id).toEqual(16);
|
expect(result[0].id).toEqual(16);
|
||||||
expect(result[1].id).toEqual(71);
|
expect(result[1].id).toEqual(71);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe('tag filterValue()', () => {
|
||||||
const filter = {where: {value: 'Blue'}, limit: 5};
|
const filter = {where: {value: 'Blue'}, limit: 5};
|
||||||
const result = await models.Tag.filterValue(colorTagId, filter, options);
|
const result = await models.Tag.filterValue(colorTagId, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(2);
|
expect(result.length).toEqual(3);
|
||||||
expect(result[0].value).toEqual('Blue');
|
expect(result[0].value).toEqual('Blue');
|
||||||
expect(result[1].value).toEqual('Blue/Silver');
|
expect(result[1].value).toEqual('Blue/Silver');
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
},
|
},
|
||||||
"showOrder": {
|
"showOrder": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"hexJson": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"acls": [
|
"acls": [
|
||||||
|
|
|
@ -1,128 +0,0 @@
|
||||||
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);
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -1,127 +0,0 @@
|
||||||
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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -5,21 +5,12 @@
|
||||||
"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"
|
||||||
},
|
},
|
||||||
|
@ -44,12 +35,6 @@
|
||||||
"Vehicle": {
|
"Vehicle": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"VehicleState": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"VehicleType": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"RoutesMonitor": {
|
"RoutesMonitor": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
"name": "BankPolicy",
|
|
||||||
"base": "VnModel",
|
|
||||||
"options": {
|
|
||||||
"mysql": {
|
|
||||||
"table": "bankPolicy"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "number",
|
|
||||||
"id": true
|
|
||||||
},
|
|
||||||
"ref": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"dmsFk": {
|
|
||||||
"type": "number"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Ppe",
|
|
||||||
"base": "VnModel",
|
|
||||||
"options": {
|
|
||||||
"mysql": {
|
|
||||||
"table": "ppe"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "number",
|
|
||||||
"id": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
"name": "VehicleState",
|
|
||||||
"base": "VnModel",
|
|
||||||
"options": {
|
|
||||||
"mysql": {
|
|
||||||
"table": "vehicleState"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "number",
|
|
||||||
"id": true
|
|
||||||
},
|
|
||||||
"state": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"hasToNotify": {
|
|
||||||
"type": "number"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
{
|
|
||||||
"name": "VehicleType",
|
|
||||||
"base": "VnModel",
|
|
||||||
"options": {
|
|
||||||
"mysql": {
|
|
||||||
"table": "vehicleType"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "number",
|
|
||||||
"id": true,
|
|
||||||
"description": "Identifier"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,3 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/vehicle/sorted')(Self);
|
require('../methods/vehicle/sorted')(Self);
|
||||||
require('../methods/vehicle/filter')(Self);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "vehicle"
|
"table": "vehicle"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -29,39 +29,6 @@
|
||||||
},
|
},
|
||||||
"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": {
|
||||||
|
@ -79,57 +46,21 @@
|
||||||
"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"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scopes": {
|
"scope": {
|
||||||
"active": {
|
"where": {
|
||||||
"fields": [
|
"isActive": {
|
||||||
"id",
|
|
||||||
"numberPlate"
|
|
||||||
],
|
|
||||||
"where": {
|
|
||||||
"isActive": {
|
|
||||||
"neq": false
|
"neq": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"acls": [
|
||||||
|
{
|
||||||
|
"accessType": "READ",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
|
@ -12,6 +12,14 @@
|
||||||
"id": true,
|
"id": true,
|
||||||
"description": "Identifier"
|
"description": "Identifier"
|
||||||
},
|
},
|
||||||
|
"column": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"row": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
"code": {
|
"code": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,6 +7,6 @@ describe('Supplier getItemsPackaging()', () => {
|
||||||
expect(item.id).toEqual(1);
|
expect(item.id).toEqual(1);
|
||||||
expect(item.name).toEqual('Ranged weapon longbow 200cm');
|
expect(item.name).toEqual('Ranged weapon longbow 200cm');
|
||||||
expect(item.quantity).toEqual(5000);
|
expect(item.quantity).toEqual(5000);
|
||||||
expect(item.quantityTotal).toEqual(5100);
|
expect(item.quantityTotal).toEqual(5200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -113,12 +113,6 @@ 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,
|
||||||
|
@ -127,8 +121,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,12 +72,6 @@ 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,
|
||||||
|
@ -90,7 +84,6 @@ 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);
|
||||||
|
|
|
@ -166,18 +166,10 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||||
const {mergeFilters, mergeWhere} = require('vn-loopback/util/filter');
|
const {mergeFilters, mergeWhere} = require('vn-loopback/util/filter');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('filter', {
|
Self.remoteMethodCtx('filter', {
|
||||||
|
@ -34,10 +33,7 @@ module.exports = Self => {
|
||||||
const conn = Self.dataSource.connector;
|
const conn = Self.dataSource.connector;
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const hasPrivs = await models.ACL.checkAccessAcl(ctx, 'WorkerDms', 'hasHighPrivs', '*');
|
|
||||||
|
|
||||||
if (!hasPrivs && userId !== id)
|
|
||||||
throw new UserError('You don\'t have enough privileges');
|
|
||||||
// Get ids alloweds
|
// Get ids alloweds
|
||||||
const account = await models.VnUser.findById(userId);
|
const account = await models.VnUser.findById(userId);
|
||||||
|
|
||||||
|
|
|
@ -155,11 +155,6 @@
|
||||||
"type": "hasMany",
|
"type": "hasMany",
|
||||||
"model": "WorkerRelative",
|
"model": "WorkerRelative",
|
||||||
"foreignKey": "workerFK"
|
"foreignKey": "workerFK"
|
||||||
},
|
|
||||||
"business": {
|
|
||||||
"type": "hasMany",
|
|
||||||
"model": "Business",
|
|
||||||
"foreignKey": "workerFk"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"acls": [
|
"acls": [
|
||||||
|
@ -277,8 +272,7 @@
|
||||||
"relation": "department",
|
"relation": "department",
|
||||||
"scope": {
|
"scope": {
|
||||||
"fields": [
|
"fields": [
|
||||||
"id",
|
"id"
|
||||||
"name"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,23 +289,14 @@
|
||||||
"departmentFk",
|
"departmentFk",
|
||||||
"workerBusinessProfessionalCategoryFk"
|
"workerBusinessProfessionalCategoryFk"
|
||||||
],
|
],
|
||||||
"include":[
|
"include": [
|
||||||
{
|
|
||||||
"relation": "department",
|
|
||||||
"scope": {
|
|
||||||
"fields": ["id", "name"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"relation": "reasonEnd",
|
"relation": "reasonEnd",
|
||||||
"scope": {
|
"scope": {
|
||||||
"fields": ["id", "reason"]
|
"fields": [
|
||||||
}
|
"id",
|
||||||
},
|
"reason"
|
||||||
{
|
]
|
||||||
"relation": "workerBusinessProfessionalCategory",
|
|
||||||
"scope": {
|
|
||||||
"fields": ["id", "description"]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue