Compare commits
106 Commits
6897-refac
...
dev
Author | SHA1 | Date |
---|---|---|
|
d7a25b06bf | |
|
8261b35559 | |
|
b56468d3aa | |
|
ec3210a5c0 | |
|
b1d2441d2e | |
|
95d2823666 | |
|
f04933a9c1 | |
|
516f409ae5 | |
|
d76db10e67 | |
|
f851a0b73b | |
|
23134deab5 | |
|
21d9369250 | |
|
1a274648a7 | |
|
6fd1c35819 | |
|
ef4d639499 | |
|
18fe468623 | |
|
47c3878a74 | |
|
a6de493271 | |
|
200f159c6b | |
|
ec01c6b0c2 | |
|
860d86d19e | |
|
fa098661b6 | |
|
6a83cec33f | |
|
35bf9abcf4 | |
|
aa44d0e727 | |
|
9f302fac24 | |
|
92ca3a2582 | |
|
2e8e2329ec | |
|
73a7a4cbd3 | |
|
ab0667f85c | |
|
f12a690bef | |
|
beed658f61 | |
|
110a5212c0 | |
|
e9e3a5f128 | |
|
fa5888f931 | |
|
9b2c0f1c48 | |
|
97be16b344 | |
|
9ba517b648 | |
|
b0dd1d4fff | |
|
8df36f296a | |
|
37b735b988 | |
|
abf73f5705 | |
|
0a25595ed5 | |
|
1ee5af96a5 | |
|
e89c12f753 | |
|
f216166806 | |
|
14a48bf4c6 | |
|
d79c19d92a | |
|
0646d2e817 | |
|
d98476b777 | |
|
1a8ce32833 | |
|
9d3a4257b7 | |
|
f484c3e653 | |
|
948bdbd2c6 | |
|
ce447b7de6 | |
|
1e18e48f8c | |
|
77623b489b | |
|
a0dc8f8104 | |
|
2f364ebc76 | |
|
a463a8f4d8 | |
|
2b443266b2 | |
|
051c6ffcbc | |
|
2eabfaaa8f | |
|
fb653c1eca | |
|
ec7bbd13b1 | |
|
2346205072 | |
|
3fba81b41e | |
|
f8e4561a59 | |
|
3a449896cd | |
|
e22a472e97 | |
|
3ea67675da | |
|
0440582e2b | |
|
d3b22ce6c9 | |
|
e05f740c3d | |
|
171296f2db | |
|
49e08fbf45 | |
|
2ae0097fa8 | |
|
7f5224ebca | |
|
b20dee8382 | |
|
55a0a5bc9a | |
|
e343e457ee | |
|
3d2a7cfb66 | |
|
946d08e543 | |
|
ecedc84164 | |
|
0e8d9137ed | |
|
a167e7fada | |
|
eca2ff84ef | |
|
bc495ed51e | |
|
68e42206c8 | |
|
e9b0b1b7a3 | |
|
8a6482ada5 | |
|
921edb238c | |
|
0de4ce9b3c | |
|
9731d13a9a | |
|
4d7387af18 | |
|
b01e4894c9 | |
|
f8c1e2aacf | |
|
fffd095ab3 | |
|
9aa790ecfd | |
|
39fc196464 | |
|
086b7aed4b | |
|
9b2fb7a430 | |
|
0652d11112 | |
|
a8cf01ca19 | |
|
6300795e52 | |
|
46c4f4786a |
|
@ -13,6 +13,7 @@ RUN apt-get update \
|
|||
graphicsmagick \
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||
&& apt-get install -y --no-install-recommends nodejs \
|
||||
&& npm install -g corepack@0.31.0 \
|
||||
&& corepack enable pnpm
|
||||
|
||||
# Puppeteer
|
||||
|
|
|
@ -168,7 +168,6 @@
|
|||
"emailVerified",
|
||||
"twoFactor"
|
||||
]
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,11 +30,16 @@ BEGIN
|
|||
st.code stateCode,
|
||||
sub2.code futureStateCode,
|
||||
st.classColor,
|
||||
sub2.classColor futureClassColor
|
||||
sub2.classColor futureClassColor,
|
||||
am.id agencyFk,
|
||||
am.name agency,
|
||||
sub2.agencyModeFk futureAgencyFk,
|
||||
sub2.agencyMode futureAgency
|
||||
FROM vn.saleVolume sv
|
||||
JOIN vn.sale s ON s.id = sv.saleFk
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.ticket t ON t.id = sv.ticketFk
|
||||
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.province p ON p.id = a.provinceFk
|
||||
JOIN vn.country c ON c.id = p.countryFk
|
||||
|
@ -54,16 +59,19 @@ BEGIN
|
|||
st.name state,
|
||||
st.code,
|
||||
st.classColor,
|
||||
am.id agencyModeFk,
|
||||
am.name agencyMode,
|
||||
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd
|
||||
FROM vn.ticket t
|
||||
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.state st ON st.id = ts.stateFk
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
WHERE t.shipped BETWEEN vFutureDated
|
||||
AND util.dayend(vFutureDated)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY t.id
|
||||
FROM vn.ticket t
|
||||
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.state st ON st.id = ts.stateFk
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
WHERE t.shipped BETWEEN vFutureDated
|
||||
AND util.dayend(vFutureDated)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY t.id
|
||||
) sub
|
||||
GROUP BY sub.addressFk
|
||||
) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id
|
||||
|
|
|
@ -25,7 +25,7 @@ BEGIN
|
|||
LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk
|
||||
LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||
WHERE dm.code IN ('AGENCY')
|
||||
AND it.isFragile;
|
||||
AND (it.isFragile OR i.isFragile);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket_warnings
|
||||
(PRIMARY KEY (ticketFk))
|
||||
|
|
|
@ -10,7 +10,6 @@ BEGIN
|
|||
|
||||
IF NEW.isBooked = OLD.isBooked AND (
|
||||
NOT (NEW.supplierFk <=> OLD.supplierFk) OR
|
||||
NOT (NEW.dated <=> OLD.dated) OR
|
||||
NOT (NEW.travelFk <=> OLD.travelFk) OR
|
||||
NOT (NEW.companyFk <=> OLD.companyFk) OR
|
||||
NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) OR
|
||||
|
|
|
@ -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 ;
|
|
@ -3,10 +3,12 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`mandate_beforeInsert`
|
|||
BEFORE INSERT ON `mandate`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
IF (NEW.code IS NULL) THEN
|
||||
SET NEW.code=CONCAT(NEW.clientFk,'-',(SELECT AUTO_INCREMENT
|
||||
FROM information_schema.TABLES
|
||||
WHERE TABLE_SCHEMA='vn' and TABLE_NAME='mandate'));
|
||||
END IF;
|
||||
SET NEW.code=CONCAT(NEW.clientFk,'-',(SELECT AUTO_INCREMENT
|
||||
FROM information_schema.TABLES
|
||||
WHERE TABLE_SCHEMA='vn' and TABLE_NAME='mandate'));
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -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 ;
|
|
@ -16,7 +16,6 @@ AS SELECT `t`.`id` AS `id`,
|
|||
`t`.`kg` AS `kg`,
|
||||
`t`.`cargoSupplierFk` AS `cargoSupplierFk`,
|
||||
`t`.`totalEntries` AS `totalEntries`,
|
||||
`t`.`appointment` AS `appointment`,
|
||||
`t`.`awbFk` AS `awbFk`,
|
||||
`t`.`isRaid` AS `isRaid`,
|
||||
`t`.`daysInForward` AS `daysInForward`
|
||||
|
|
|
@ -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`;
|
|
@ -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);
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
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,'"]}')
|
|
@ -0,0 +1,6 @@
|
|||
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')
|
||||
;
|
|
@ -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;
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE vn.recovery DROP FOREIGN KEY cliente333;
|
|
@ -58,10 +58,10 @@
|
|||
"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}}}",
|
||||
"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}}}",
|
||||
"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}}})",
|
||||
"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}}}) {{ticketWeekly}}",
|
||||
"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}}}",
|
||||
"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",
|
||||
"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 }}",
|
||||
"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",
|
||||
"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}}}",
|
||||
"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}}}",
|
||||
"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}}})",
|
||||
"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}}}) {{ticketWeekly}}",
|
||||
"Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*",
|
||||
"State": "Estado",
|
||||
"regular": "normal",
|
||||
|
@ -396,6 +396,6 @@
|
|||
"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 }}",
|
||||
"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: muestra
|
||||
name: plantilla
|
||||
columns:
|
||||
id: id
|
||||
created: creado
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
name: mandate
|
||||
columns:
|
||||
id: id
|
||||
clientFk: client
|
||||
companyFk: company
|
||||
code: code
|
||||
created: created
|
||||
finished: finished
|
||||
mandateTypeFk: mandate type
|
||||
editorFk: editor
|
|
@ -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
|
|
@ -248,9 +248,10 @@ module.exports = Self => {
|
|||
const models = Self.app.models;
|
||||
|
||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const accessToken = {req: loopBackContext.active.accessToken};
|
||||
|
||||
const editVerifiedDataWithoutTaxDataChecked = models.ACL.checkAccessAcl(
|
||||
const accessToken = {req: {accessToken: loopBackContext.active.accessToken}};
|
||||
|
||||
const editVerifiedDataWithoutTaxDataChecked = await models.ACL.checkAccessAcl(
|
||||
accessToken,
|
||||
'Client',
|
||||
'editVerifiedDataWithoutTaxDataCheck',
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
{
|
||||
"name": "Mandate",
|
||||
"base": "VnModel",
|
||||
"mixins": {
|
||||
"Loggable": true
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "mandate"
|
||||
|
@ -39,4 +42,4 @@
|
|||
"foreignKey": "mandateTypeFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,303 +0,0 @@
|
|||
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];
|
||||
};
|
||||
};
|
|
@ -1,46 +0,0 @@
|
|||
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
|
||||
);
|
||||
};
|
||||
};
|
|
@ -1,46 +0,0 @@
|
|||
|
||||
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;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -1,48 +0,0 @@
|
|||
|
||||
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,68 +129,7 @@ module.exports = Self => {
|
|||
arg: 'finalTemperature',
|
||||
type: 'number',
|
||||
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: {
|
||||
type: ['object'],
|
||||
|
@ -217,12 +156,19 @@ module.exports = Self => {
|
|||
{'s.name': {like: `%${value}%`}},
|
||||
{'s.nickname': {like: `%${value}%`}}
|
||||
]};
|
||||
case 'invoiceNumber':
|
||||
case 'reference':
|
||||
case 'ref':
|
||||
case 'evaNotes':
|
||||
param = `e.${param}`;
|
||||
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 'isBooked':
|
||||
case 'isConfirmed':
|
||||
|
@ -232,20 +178,8 @@ module.exports = Self => {
|
|||
case 'currencyFk':
|
||||
case 'supplierFk':
|
||||
case 'invoiceInFk':
|
||||
case 'isExcludedFromAvailable':
|
||||
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};
|
||||
param = `e.${param}`;
|
||||
return {[param]: value};
|
||||
case 'initialTemperature':
|
||||
return {'e.initialTemperature': {lte: value}};
|
||||
case 'finalTemperature':
|
||||
|
@ -263,14 +197,15 @@ module.exports = Self => {
|
|||
const stmts = [];
|
||||
let stmt;
|
||||
stmt = new ParameterizedSQL(
|
||||
`SELECT e.id,
|
||||
`SELECT
|
||||
e.id,
|
||||
e.supplierFk,
|
||||
e.dated,
|
||||
e.reference,
|
||||
e.invoiceNumber,
|
||||
e.isBooked,
|
||||
e.isExcludedFromAvailable,
|
||||
e.evaNotes,
|
||||
e.evaNotes observation,
|
||||
e.isConfirmed,
|
||||
e.isOrdered,
|
||||
t.isRaid,
|
||||
|
@ -292,27 +227,15 @@ module.exports = Self => {
|
|||
cu.code currencyCode,
|
||||
t.shipped,
|
||||
t.landed,
|
||||
t.ref travelRef,
|
||||
t.ref AS travelRef,
|
||||
t.warehouseInFk,
|
||||
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
|
||||
w.name warehouseInName
|
||||
FROM vn.entry e
|
||||
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||
LEFT JOIN vn.travel t ON t.id = e.travelFk
|
||||
LEFT JOIN vn.warehouse w ON w.id = t.warehouseInFk
|
||||
LEFT JOIN vn.warehouse w2 ON w2.id = t.warehouseOutFk
|
||||
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`
|
||||
JOIN vn.travel t ON t.id = e.travelFk
|
||||
JOIN vn.warehouse w ON w.id = t.warehouseInFk
|
||||
JOIN vn.company co ON co.id = e.companyFk
|
||||
JOIN vn.currency cu ON cu.id = e.currencyFk`
|
||||
);
|
||||
|
||||
stmt.merge(conn.makeWhere(filter.where));
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
|
||||
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,8 +31,5 @@
|
|||
},
|
||||
"InventoryConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"EntryConfig": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
{
|
||||
"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,13 +15,8 @@ module.exports = Self => {
|
|||
require('../methods/entry/transfer')(Self);
|
||||
require('../methods/entry/labelSupplier')(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(ctx, options) => {
|
||||
Self.observe('before save', async function(ctx, options) {
|
||||
if (ctx.isNewInstance) return;
|
||||
|
||||
const changes = ctx.data || ctx.instance;
|
||||
|
|
|
@ -56,7 +56,8 @@
|
|||
"required": true
|
||||
},
|
||||
"travelFk": {
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"companyFk": {
|
||||
"type": "number",
|
||||
|
@ -73,12 +74,6 @@
|
|||
},
|
||||
"finalTemperature": {
|
||||
"type": "number"
|
||||
},
|
||||
"lockerUserFk":{
|
||||
"type": "number"
|
||||
},
|
||||
"locked":{
|
||||
"type": "date"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -112,16 +107,6 @@
|
|||
"type": "belongsTo",
|
||||
"model": "EntryType",
|
||||
"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) {
|
||||
let newCreated = Date.vnNew();
|
||||
const companyFk = 69;
|
||||
await entry.updateAttributes({isBooked, typeFk}, options);
|
||||
await entry.updateAttributes({dated: newCreated}, options);
|
||||
await entry.updateAttributes({companyFk}, options);
|
||||
}
|
||||
|
||||
it('should throw an error when entry is booked and typeFk is null', async() => {
|
||||
|
|
|
@ -32,6 +32,12 @@ module.exports = Self => {
|
|||
description: 'The client id',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'companyFk',
|
||||
type: 'integer',
|
||||
description: 'The company id',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'fi',
|
||||
type: 'string',
|
||||
|
@ -148,6 +154,7 @@ module.exports = Self => {
|
|||
i.hasPdf,
|
||||
i.customsAgentFk,
|
||||
c.socialName AS clientSocialName,
|
||||
i.companyFk,
|
||||
co.code AS companyCode,
|
||||
ca.fiscalName AS customsAgentName
|
||||
FROM invoiceOut i
|
||||
|
|
|
@ -22,6 +22,11 @@ module.exports = Self => {
|
|||
type: 'integer',
|
||||
description: 'The item id',
|
||||
},
|
||||
{
|
||||
arg: 'name',
|
||||
type: 'string',
|
||||
description: 'The item name',
|
||||
},
|
||||
{
|
||||
arg: 'typeFk',
|
||||
type: 'integer',
|
||||
|
@ -112,6 +117,8 @@ module.exports = Self => {
|
|||
: {'it.code': {like: `%${value}%`}};
|
||||
case 'categoryFk':
|
||||
return {'it.categoryFk': value};
|
||||
case 'name':
|
||||
return {'i.name': {like: `%${value}%`}};
|
||||
case 'buyerFk':
|
||||
return {'it.workerFk': value};
|
||||
case 'warehouseFk':
|
||||
|
|
|
@ -89,7 +89,7 @@ describe('item filter()', () => {
|
|||
const ctx = {args: {filter: filter, workerFk: 16}, req: {accessToken: {userId: 1}}};
|
||||
const result = await models.Item.filter(ctx, filter, options);
|
||||
|
||||
expect(result.length).toEqual(3);
|
||||
expect(result.length).toEqual(2);
|
||||
expect(result[0].id).toEqual(16);
|
||||
expect(result[1].id).toEqual(71);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ describe('tag filterValue()', () => {
|
|||
const filter = {where: {value: 'Blue'}, limit: 5};
|
||||
const result = await models.Tag.filterValue(colorTagId, filter, options);
|
||||
|
||||
expect(result.length).toEqual(3);
|
||||
expect(result.length).toEqual(2);
|
||||
expect(result[0].value).toEqual('Blue');
|
||||
expect(result[1].value).toEqual('Blue/Silver');
|
||||
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
},
|
||||
"showOrder": {
|
||||
"type": "number"
|
||||
},
|
||||
"hexJson": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
};
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -5,12 +5,21 @@
|
|||
"AgencyTermConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"BankPolicy": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Cmr": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"DeliveryPoint": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"FuelType": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Ppe": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"RoadmapAddress": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -35,6 +44,12 @@
|
|||
"Vehicle": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"VehicleState": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"VehicleType": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"RoutesMonitor": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "BankPolicy",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "bankPolicy"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"ref": {
|
||||
"type": "string"
|
||||
},
|
||||
"dmsFk": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "Ppe",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "ppe"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "VehicleState",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "vehicleState"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"state": {
|
||||
"type": "string"
|
||||
},
|
||||
"hasToNotify": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "VehicleType",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "vehicleType"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/vehicle/sorted')(Self);
|
||||
require('../methods/vehicle/filter')(Self);
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "vehicle"
|
||||
"table": "vehicle"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
|
@ -29,6 +29,39 @@
|
|||
},
|
||||
"isActive": {
|
||||
"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": {
|
||||
|
@ -46,21 +79,57 @@
|
|||
"type": "belongsTo",
|
||||
"model": "DeliveryPoint",
|
||||
"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": {
|
||||
"where": {
|
||||
"isActive": {
|
||||
"scopes": {
|
||||
"active": {
|
||||
"fields": [
|
||||
"id",
|
||||
"numberPlate"
|
||||
],
|
||||
"where": {
|
||||
"isActive": {
|
||||
"neq": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,14 +12,6 @@
|
|||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"column": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"row": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
@ -7,6 +7,6 @@ describe('Supplier getItemsPackaging()', () => {
|
|||
expect(item.id).toEqual(1);
|
||||
expect(item.name).toEqual('Ranged weapon longbow 200cm');
|
||||
expect(item.quantity).toEqual(5000);
|
||||
expect(item.quantityTotal).toEqual(5200);
|
||||
expect(item.quantityTotal).toEqual(5100);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -113,6 +113,12 @@ module.exports = Self => {
|
|||
const salesPerson = sale.ticket().client().salesPersonUser();
|
||||
if (salesPerson) {
|
||||
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', {
|
||||
ticketId: sale.ticket().id,
|
||||
itemId: sale.itemFk,
|
||||
|
@ -121,7 +127,8 @@ module.exports = Self => {
|
|||
oldPrice: oldPrice,
|
||||
newPrice: newPrice,
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -72,6 +72,12 @@ module.exports = Self => {
|
|||
const salesPerson = sale.ticket().client().salesPersonUser();
|
||||
if (salesPerson) {
|
||||
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', {
|
||||
itemId: sale.itemFk,
|
||||
concept: sale.concept,
|
||||
|
@ -84,6 +90,7 @@ module.exports = Self => {
|
|||
ticketId: sale.ticket().id,
|
||||
changes: JSON.stringify(change),
|
||||
ticketUrl: `${url}ticket/${sale.ticket().id}/sale`,
|
||||
ticketWeekly: ticketWeekly ? $t('clonedFromTicketWeekly', {ticketWeekly}) : null
|
||||
});
|
||||
|
||||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
|
||||
|
|
|
@ -166,10 +166,18 @@ module.exports = Self => {
|
|||
const salesPerson = ticket.client().salesPersonUser();
|
||||
if (salesPerson) {
|
||||
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', {
|
||||
ticketId: id,
|
||||
ticketUrl: `${url}ticket/${id}/sale`,
|
||||
changes: changesMade
|
||||
changes: changesMade,
|
||||
ticketWeekly: ticketWeekly ? $t('clonedFromTicketWeekly', {ticketWeekly}) : null
|
||||
});
|
||||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const {mergeFilters, mergeWhere} = require('vn-loopback/util/filter');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('filter', {
|
||||
|
@ -33,7 +34,10 @@ module.exports = Self => {
|
|||
const conn = Self.dataSource.connector;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
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
|
||||
const account = await models.VnUser.findById(userId);
|
||||
|
||||
|
|
|
@ -155,6 +155,11 @@
|
|||
"type": "hasMany",
|
||||
"model": "WorkerRelative",
|
||||
"foreignKey": "workerFK"
|
||||
},
|
||||
"business": {
|
||||
"type": "hasMany",
|
||||
"model": "Business",
|
||||
"foreignKey": "workerFk"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
|
@ -272,7 +277,8 @@
|
|||
"relation": "department",
|
||||
"scope": {
|
||||
"fields": [
|
||||
"id"
|
||||
"id",
|
||||
"name"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -289,14 +295,23 @@
|
|||
"departmentFk",
|
||||
"workerBusinessProfessionalCategoryFk"
|
||||
],
|
||||
"include": [
|
||||
"include":[
|
||||
{
|
||||
"relation": "department",
|
||||
"scope": {
|
||||
"fields": ["id", "name"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"relation": "reasonEnd",
|
||||
"scope": {
|
||||
"fields": [
|
||||
"id",
|
||||
"reason"
|
||||
]
|
||||
"fields": ["id", "reason"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"relation": "workerBusinessProfessionalCategory",
|
||||
"scope": {
|
||||
"fields": ["id", "description"]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue