Compare commits
66 Commits
7119-creat
...
dev
Author | SHA1 | Date |
---|---|---|
Ivan Mas | 074fe5b0ac | |
Ivan Mas | 2e4c5fe401 | |
Ivan Mas | 83228d481d | |
Ivan Mas | 3fa74a18de | |
Ivan Mas | 45ccf8da28 | |
Ivan Mas | fa9b9cc5a3 | |
Ivan Mas | 66a08f7641 | |
Jon Elias | 923fef444c | |
Ivan Mas | a2258a005a | |
Carlos Satorres | 3fede6d586 | |
Ivan Mas | da5e395450 | |
Carlos Satorres | e1125dc46d | |
Jon Elias | 53ee0c1617 | |
Ivan Mas | 4d210b34c7 | |
Ivan Mas | f68f62543d | |
Ivan Mas | 148072b39d | |
Ivan Mas | 9e95afa190 | |
Ivan Mas | e0e72272a7 | |
Ivan Mas | ecc92792da | |
Ivan Mas | 85c3dc54fa | |
Jon Elias | ef8e206520 | |
Jon Elias | 0a89a6a6fd | |
Ivan Mas | 2a7795d432 | |
Ivan Mas | 70d286df80 | |
Ivan Mas | dfcc155ef9 | |
Ivan Mas | 821e2cbe4d | |
Carlos Satorres | b14beb83f4 | |
Carlos Satorres | 10a6626a65 | |
Carlos Satorres | 024ab8602d | |
Carlos Satorres | 6ef0d2625d | |
Carlos Satorres | 60f0b169d4 | |
Carlos Satorres | a4f9d62504 | |
Carlos Satorres | 358f93c454 | |
Carlos Satorres | 978914aa71 | |
Carlos Satorres | c8d57a1efa | |
Carlos Satorres | 209bd21548 | |
Carlos Satorres | bd1cee6d8b | |
Carlos Satorres | a139c9849c | |
Carlos Satorres | ddecfee24b | |
Carlos Satorres | 6f16974320 | |
Carlos Satorres | e2a4c5339a | |
Carlos Satorres | c1b9032534 | |
Carlos Satorres | 4bc475d132 | |
Carlos Satorres | d1aa164aea | |
Carlos Satorres | 601909e853 | |
Carlos Satorres | 4b9a39e6ba | |
Carlos Satorres | 2aa0e2af2a | |
Carlos Satorres | c3c60b1fa7 | |
Carlos Satorres | ff328c9f0d | |
Carlos Satorres | a27e3ed60f | |
Carlos Satorres | 5e5a8078ca | |
Carlos Satorres | cf651dc2e1 | |
Alex Moreno | 36b4c7fb74 | |
Alex Moreno | 3362d7562f | |
Carlos Satorres | cc8af9d14a | |
Carlos Satorres | be0de3511b | |
Carlos Satorres | 0486c40454 | |
Alex Moreno | 4f7b625a4f | |
Alex Moreno | a9ad3df592 | |
Alex Moreno | e8d0ebe91d | |
Carlos Satorres | 41fabecc9b | |
Carlos Satorres | 06fe0f5cef | |
Carlos Satorres | 5d73af5392 | |
Carlos Satorres | 11d1cd8eb3 | |
Carlos Satorres | a5ffdddb53 | |
Carlos Satorres | 3e1b296b29 |
|
@ -856,15 +856,14 @@ INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'Gotham','1007 Mountain Drive, Gotham');
|
(1, 'Gotham','1007 Mountain Drive, Gotham');
|
||||||
|
|
||||||
INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`, `deliveryPointFk`, `chassis`, `leasing`, `supplierFk`, `fuelTypeFk`, `bankPolicyFk`)
|
INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`, `deliveryPointFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, '3333-BAT', 'WAYNE INDUSTRIES', 'BATMOBILE', 442, 1, 'The ultimate war machine', 50, 1, 1, 'XCSC133C60', 'Wayne leasing', 1, 1, 1),
|
(1, '3333-BAT', 'WAYNE INDUSTRIES', 'BATMOBILE', 442, 1, 'The ultimate war machine', 50, 1, 1),
|
||||||
(2, '1111-IMK', 'STARK INDUSTRIES', 'MARK-III', 442, 1, 'Iron-Man Heavy Armor MARK-III', 18, 1, 1, '', '', 2, 2, 2),
|
(2, '1111-IMK', 'STARK INDUSTRIES', 'MARK-III', 442, 1, 'Iron-Man Heavy Armor MARK-III', 18, 1, 1),
|
||||||
(3, '2222-IMK', 'STARK INDUSTRIES', 'MARK-VI', 442, 1, 'Iron-Man Heavy Armor MARK-VI', 16, 1, 1, '', '', 442, 2, null),
|
(3, '2222-IMK', 'STARK INDUSTRIES', 'MARK-VI', 442, 1, 'Iron-Man Heavy Armor MARK-VI', 16, 1, 1),
|
||||||
(4, '3333-IMK', 'STARK INDUSTRIES', 'MARK-VII', 442, 1, 'Iron-Man Heavy Armor MARK-VII', 14, 1, 1, '', '', 442, 3, null),
|
(4, '3333-IMK', 'STARK INDUSTRIES', 'MARK-VII', 442, 1, 'Iron-Man Heavy Armor MARK-VII', 14, 1, 1),
|
||||||
(5, '4444-IMK', 'STARK INDUSTRIES', 'MARK-XLII', 442, 1, 'Iron-Man Heavy Armor MARK-XLII', 13, 1, 1, '', '', 442, 4, null),
|
(5, '4444-IMK', 'STARK INDUSTRIES', 'MARK-XLII', 442, 1, 'Iron-Man Heavy Armor MARK-XLII', 13, 1, 1),
|
||||||
(6, '5555-IMK', 'STARK INDUSTRIES', 'MARK-XLV', 442, 1, 'Iron-Man Heavy Armor MARK-XLV', 12, 0, 1, '', '', 442, 5, null),
|
(6, '5555-IMK', 'STARK INDUSTRIES', 'MARK-XLV', 442, 1, 'Iron-Man Heavy Armor MARK-XLV', 12, 0, 1);
|
||||||
(7, '5555-SHI', 'SHIELD', 'Quinjet', 442, 1, 'High-speed jet used by the Avengers', 30, 1, 1, 'QJ12345', 'SHIELD leasing', 1, 1, 1);
|
|
||||||
|
|
||||||
INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, `inventoried`)
|
INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, `inventoried`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -3208,7 +3207,7 @@ UPDATE vn.department
|
||||||
SET workerFk = null;
|
SET workerFk = null;
|
||||||
|
|
||||||
INSERT INTO vn.packaging
|
INSERT INTO vn.packaging
|
||||||
VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0,0,1);
|
VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0,0,1,0);
|
||||||
|
|
||||||
|
|
||||||
INSERT IGNORE INTO vn.intrastat
|
INSERT IGNORE INTO vn.intrastat
|
||||||
|
@ -4072,43 +4071,3 @@ UPDATE vn.worker
|
||||||
SET isFreelance=1
|
SET isFreelance=1
|
||||||
WHERE firstName='deliveryFreelancer';
|
WHERE firstName='deliveryFreelancer';
|
||||||
|
|
||||||
INSERT INTO vn.vehicleState (state, hasToNotify)
|
|
||||||
VALUES
|
|
||||||
('Operativo', NULL),
|
|
||||||
('Prestado', NULL),
|
|
||||||
('Robado', NULL),
|
|
||||||
('Taller', NULL),
|
|
||||||
('Targeta SOLRED', NULL),
|
|
||||||
('Via T SOLRED', NULL),
|
|
||||||
('ITV', NULL);
|
|
||||||
|
|
||||||
INSERT INTO vn.vehicleEvent (started, finished, vehicleStateFk, description, vehicleFk, userFk, notified)
|
|
||||||
VALUES
|
|
||||||
('2000-12-01', '2000-12-02', 4, 'cambio de aceite', 5, 103, NULL),
|
|
||||||
('2000-12-15', '2000-12-18', 2, 'viaje fin de curso', 5, 103, NULL),
|
|
||||||
('2000-12-20', '2001-01-01', 3, 'llaves puestas', 2, 103, NULL);
|
|
||||||
|
|
||||||
INSERT INTO vn.fuelType (id, name, code)
|
|
||||||
VALUES
|
|
||||||
(1, 'gasoil', 'gasoil'),
|
|
||||||
(2, 'gas', 'gas'),
|
|
||||||
(3, 'adblue', 'adblue'),
|
|
||||||
(4, 'gasolina', 'gasolina'),
|
|
||||||
(5, 'gasoil-frigo', 'gasoil-frigo'),
|
|
||||||
(6, 'electrico', 'electric');
|
|
||||||
|
|
||||||
INSERT INTO vn.bankPolicy (id, `ref`, amount, committedFee, nonCommittedFee, annualFee, started, ended, accountingFk, companyFk, supplierFk, description, hasGuarantee, dmsFk, notaryFk, currencyFk, amortizationTypeFk, periodicityTypeFk, insuranceExpired)
|
|
||||||
VALUES
|
|
||||||
(1, '11112222', 500000.0, 0.028, 0.0, 0.001, '2001-01-01', '2001-02-01', 1, 442, NULL, NULL, 0, NULL, NULL, 1, NULL, NULL, NULL),
|
|
||||||
(2, '33334444', 100000.0, 0.017, 0.0, 0.0, '2001-01-01', '2001-02-01', 1, 2, NULL, NULL, 0, NULL, NULL, 2, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
INSERT INTO vn.ppe (id, amortization, firstAmortizated, lastAmortizated, finished, value, planFk, groupFk, account, endowment, elementAccount, nature, location, discharged, cause, isInvestmentAsset, workerFk, companyFk, description, isDone)
|
|
||||||
VALUES
|
|
||||||
(1, 0.00, '2001-01-01', NULL, NULL, 700.95, 16, 4, '3456000000', '4320000000', '12345', 'INMOVILIZADO', 'V02', NULL, NULL, 0, NULL, 442, 'UTILLAJE LASER ROTATIVO AUTONIVELANTE 500M', NULL),
|
|
||||||
(2, 0.00, '2001-01-01', NULL, NULL, 400.00, 16, 4, '5678000000', '1230000000', '67891', 'INMOVILIZADO', 'V02', NULL, NULL, 0, NULL, 442, 'UTILLAJE BALANZA Z100 150KILOS', NULL);
|
|
||||||
|
|
||||||
INSERT IGNORE INTO vn.vehicleType (id, name)
|
|
||||||
VALUES (1,'vehículo empresa'),
|
|
||||||
(2, 'furgoneta'),
|
|
||||||
(3, 'cabeza tractora'),
|
|
||||||
(4, 'remolque');
|
|
|
@ -18,5 +18,6 @@ AS SELECT `p`.`id` AS `Id_Cubo`,
|
||||||
`p`.`base` AS `Base`,
|
`p`.`base` AS `Base`,
|
||||||
`p`.`isBox` AS `box`,
|
`p`.`isBox` AS `box`,
|
||||||
`p`.`returnCost` AS `costeRetorno`,
|
`p`.`returnCost` AS `costeRetorno`,
|
||||||
`p`.`isActive` AS `isActive`
|
`p`.`isActive` AS `isActive`,
|
||||||
|
`p`.`flippingCost` AS `flippingCost`
|
||||||
FROM `vn`.`packaging` `p`
|
FROM `vn`.`packaging` `p`
|
||||||
|
|
|
@ -29,5 +29,6 @@ AS SELECT `a`.`id` AS `id`,
|
||||||
`a`.`invoiceInPaletizedFk` AS `invoiceInPaletizedFk`,
|
`a`.`invoiceInPaletizedFk` AS `invoiceInPaletizedFk`,
|
||||||
`a`.`observation` AS `observation`,
|
`a`.`observation` AS `observation`,
|
||||||
`a`.`hasFreightPrepaid` AS `hasFreightPrepaid`,
|
`a`.`hasFreightPrepaid` AS `hasFreightPrepaid`,
|
||||||
`a`.`propertyNumber` AS `propertyNumber`
|
`a`.`propertyNumber` AS `propertyNumber`,
|
||||||
|
`a`.`costPerKg` AS `costPerKg`
|
||||||
FROM `vn`.`awb` `a`
|
FROM `vn`.`awb` `a`
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
ALTER TABLE vn.business
|
||||||
|
ADD CONSTRAINT `business_companyCodeFk` FOREIGN KEY (`companyCodeFk`) REFERENCES `company` (`code`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- Auto-generated SQL script. Actual values for binary/complex data types may differ - what you see is the default string representation of values.
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('BusinessReasonEnd','find','*','ALLOW','ROLE','hr');
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('CalendarType','find','*','ALLOW','ROLE','hr');
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('OccupationCode','find','*','ALLOW','ROLE','hr');
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('BusinessReasonEnd','find','*','ALLOW','ROLE','hr');
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('WorkerBusinessProfessionalCategory','find','*','ALLOW','ROLE','hr');
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('WorkerBusinessAgreement','find','*','ALLOW','ROLE','hr');
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('WorkerBusinessType','find','*','ALLOW','ROLE','hr');
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('PayrollCategory','find','*','ALLOW','ROLE','hr');
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('Worker','__get__business','*','ALLOW','ROLE','hr');
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('Worker','__create__business','*','ALLOW','ROLE','hr');
|
||||||
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
|
VALUES ('Business','crud','*','ALLOW','ROLE','hr');
|
||||||
|
|
|
@ -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,2 @@
|
||||||
|
ALTER TABLE vn.packaging
|
||||||
|
ADD COLUMN flippingCost decimal(10, 2) NOT NULL DEFAULT 0.00
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE vn.travel CHANGE appointment appointment__ datetime DEFAULT NULL COMMENT '@deprecated 2025-01-28';
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE `vn`.`awb`
|
||||||
|
ADD COLUMN `costPerKg` DECIMAL(10, 2) UNSIGNED DEFAULT NULL COMMENT 'Tarifa que indica a cuanto cuesta el kilo en ese vuelo';
|
|
@ -158,10 +158,12 @@ module.exports = Self => {
|
||||||
a.provinceFk AS provinceAddressFk,
|
a.provinceFk AS provinceAddressFk,
|
||||||
p.name AS province,
|
p.name AS province,
|
||||||
u.id AS salesPersonFk,
|
u.id AS salesPersonFk,
|
||||||
u.name AS salesPerson
|
u.name AS salesPerson,
|
||||||
|
co.name AS country
|
||||||
FROM client c
|
FROM client c
|
||||||
LEFT JOIN account.user u ON u.id = c.salesPersonFk
|
LEFT JOIN account.user u ON u.id = c.salesPersonFk
|
||||||
LEFT JOIN province p ON p.id = c.provinceFk
|
LEFT JOIN province p ON p.id = c.provinceFk
|
||||||
|
LEFT JOIN country co ON co.id = c.countryFk
|
||||||
JOIN address a ON a.clientFk = c.id
|
JOIN address a ON a.clientFk = c.id
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
|
|
@ -139,5 +139,23 @@
|
||||||
},
|
},
|
||||||
"Xdiario": {
|
"Xdiario": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"BusinessReasonEnd": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"OccupationCode": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"WorkerBusinessProfessionalCategory": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"CalendarType": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"WorkerBusinessType": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"PayrollCategory": {
|
||||||
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "BusinessReasonEnd",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "businessReasonEnd"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"reason": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,63 @@
|
||||||
},
|
},
|
||||||
"workcenterFk" : {
|
"workcenterFk" : {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"companyCodeFk" : {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"started" : {
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
"ended" : {
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
"workerBusiness" : {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"reasonEndFk" : {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"payedHolidays" : {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"occupationCodeFk" : {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"workerFk" : {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"notes" : {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"departmentFk": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"workerBusinessProfessionalCategoryFk": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"calendarTypeFk": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"isHourlyLabor": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"rate": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"workerBusinessCategoryFk": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"workerBusinessTypeFk": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"amount": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"workerBusinessAgreementFk": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"basicSalary": {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
@ -25,6 +82,59 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Department",
|
"model": "Department",
|
||||||
"foreignKey": "departmentFk"
|
"foreignKey": "departmentFk"
|
||||||
}
|
},
|
||||||
|
"workCenter": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "WorkCenter",
|
||||||
|
"foreignKey": "workcenterFk"
|
||||||
|
},
|
||||||
|
"companyCode": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Company",
|
||||||
|
"foreignKey": "companyCodeFk",
|
||||||
|
"primaryKey": "code"
|
||||||
|
},
|
||||||
|
"reasonEnd": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "BusinessReasonEnd",
|
||||||
|
"foreignKey": "reasonEndFk"
|
||||||
|
},
|
||||||
|
"occupationCode": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "OccupationCode",
|
||||||
|
"foreignKey":"occupationCodeFk",
|
||||||
|
"primaryKey": "code"
|
||||||
|
},
|
||||||
|
"payrollCategory": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "PayrollCategory",
|
||||||
|
"foreignKey":"workerBusinessCategoryFk"
|
||||||
|
},
|
||||||
|
"workerBusinessProfessionalCategory": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "WorkerBusinessProfessionalCategory",
|
||||||
|
"foreignKey": "workerBusinessProfessionalCategoryFk"
|
||||||
|
},
|
||||||
|
"calendarType": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "CalendarType",
|
||||||
|
"foreignKey": "calendarTypeFk"
|
||||||
|
},
|
||||||
|
"workerBusinessCategory": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "WorkerBusinessCategory",
|
||||||
|
"foreignKey": "workerBusinessCategoryFk"
|
||||||
|
},
|
||||||
|
"workerBusinessType": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "WorkerBusinessType",
|
||||||
|
"foreignKey": "workerBusinessTypeFk"
|
||||||
|
},
|
||||||
|
"workerBusinessAgreement": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "WorkerBusinessAgreement",
|
||||||
|
"foreignKey": "workerBusinessAgreementFk"
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"name": "CalendarType",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "calendarType"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"hoursWeek": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"isPartial": "number"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "OccupationCode",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "occupationCode"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"code": {
|
||||||
|
"type": "string",
|
||||||
|
"id": true
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,20 +1,19 @@
|
||||||
{
|
{
|
||||||
"name": "BankPolicy",
|
"name": "PayrollCategory",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "bankPolicy"
|
"table": "payrollCategories"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "number",
|
"type": "number"
|
||||||
"id": true
|
|
||||||
},
|
},
|
||||||
"ref": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"dmsFk": {
|
"rate": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,21 +1,20 @@
|
||||||
{
|
{
|
||||||
"name": "VehicleState",
|
"name": "WorkerBusinessProfessionalCategory",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "vehicleState"
|
"table": "professionalCategory"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "number",
|
"type": "number"
|
||||||
"id": true
|
|
||||||
},
|
},
|
||||||
"state": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"hasToNotify": {
|
"code": {
|
||||||
"type": "number"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"name": "WorkerBusinessAgreement",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "workerBusinessAgreement"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"monthHolidays": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"yearsHours": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"started": {
|
||||||
|
"type": "date"
|
||||||
|
},
|
||||||
|
"ended": {
|
||||||
|
"type": "date"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "WorkerBusinessType",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "workerBusinessType"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "number",
|
||||||
|
"id": true
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"isFullTime": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"isPermanent": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"hasHolidayEntitlement": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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,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,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);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -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": {
|
|
||||||
"fields": [
|
|
||||||
"id",
|
|
||||||
"numberPlate"
|
|
||||||
],
|
|
||||||
"where": {
|
"where": {
|
||||||
"isActive": {
|
"isActive": {
|
||||||
"neq": false
|
"neq": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"acls": [
|
||||||
|
{
|
||||||
|
"accessType": "READ",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
const validateTin = require('vn-loopback/util/validateTin');
|
|
||||||
require('../methods/worker/filter')(Self);
|
require('../methods/worker/filter')(Self);
|
||||||
require('../methods/worker/mySubordinates')(Self);
|
require('../methods/worker/mySubordinates')(Self);
|
||||||
require('../methods/worker/isSubordinate')(Self);
|
require('../methods/worker/isSubordinate')(Self);
|
||||||
|
@ -23,26 +22,10 @@ module.exports = Self => {
|
||||||
require('../methods/worker/getAvailablePda')(Self);
|
require('../methods/worker/getAvailablePda')(Self);
|
||||||
require('../methods/worker/myTeam')(Self);
|
require('../methods/worker/myTeam')(Self);
|
||||||
|
|
||||||
Self.validateAsync('fi', tinIsValid, {
|
|
||||||
message: 'Invalid TIN'
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.canModifyAbsenceInPast = async(ctx, time) => {
|
Self.canModifyAbsenceInPast = async(ctx, time) => {
|
||||||
const hasPrivs = await Self.app.models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE');
|
const hasPrivs = await Self.app.models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE');
|
||||||
const today = Date.vnNew();
|
const today = Date.vnNew();
|
||||||
today.setHours(0, 0, 0, 0);
|
today.setHours(0, 0, 0, 0);
|
||||||
return hasPrivs || today.getTime() < time;
|
return hasPrivs || today.getTime() < time;
|
||||||
};
|
};
|
||||||
|
|
||||||
async function tinIsValid(err, done) {
|
|
||||||
const country = await Self.app.models.Country.findOne({
|
|
||||||
fields: ['code'],
|
|
||||||
where: {id: this.originCountryFk}
|
|
||||||
});
|
|
||||||
const code = country ? country.code.toLowerCase() : null;
|
|
||||||
|
|
||||||
if (!this.fi || !validateTin(this.fi, code))
|
|
||||||
err();
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -75,6 +75,9 @@
|
||||||
},
|
},
|
||||||
"isSsDiscounted": {
|
"isSsDiscounted": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"businessFk": {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
@ -103,6 +106,11 @@
|
||||||
"model": "WorkerDepartment",
|
"model": "WorkerDepartment",
|
||||||
"foreignKey": "id"
|
"foreignKey": "id"
|
||||||
},
|
},
|
||||||
|
"currentBusiness": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Business",
|
||||||
|
"foreignKey": "businessFk"
|
||||||
|
},
|
||||||
"collegues": {
|
"collegues": {
|
||||||
"type": "hasMany",
|
"type": "hasMany",
|
||||||
"model": "WorkerTeamCollegues",
|
"model": "WorkerTeamCollegues",
|
||||||
|
@ -113,6 +121,11 @@
|
||||||
"model": "Locker",
|
"model": "Locker",
|
||||||
"foreignKey": "workerFk"
|
"foreignKey": "workerFk"
|
||||||
},
|
},
|
||||||
|
"business": {
|
||||||
|
"type": "hasMany",
|
||||||
|
"model": "Business",
|
||||||
|
"foreignKey": "workerFk"
|
||||||
|
},
|
||||||
"medicalReview": {
|
"medicalReview": {
|
||||||
"type": "hasMany",
|
"type": "hasMany",
|
||||||
"model": "MedicalReview",
|
"model": "MedicalReview",
|
||||||
|
@ -259,12 +272,36 @@
|
||||||
"relation": "department",
|
"relation": "department",
|
||||||
"scope": {
|
"scope": {
|
||||||
"fields": [
|
"fields": [
|
||||||
"name"
|
"id"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"relation": "business",
|
||||||
|
"scope": {
|
||||||
|
"fields": [
|
||||||
|
"id",
|
||||||
|
"started",
|
||||||
|
"ended",
|
||||||
|
"reasonEndFk",
|
||||||
|
"departmentFk",
|
||||||
|
"workerBusinessProfessionalCategoryFk"
|
||||||
|
],
|
||||||
|
"include": [
|
||||||
|
{
|
||||||
|
"relation": "reasonEnd",
|
||||||
|
"scope": {
|
||||||
|
"fields": [
|
||||||
|
"id",
|
||||||
|
"reason"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"relation": "boss",
|
"relation": "boss",
|
||||||
"scope": {
|
"scope": {
|
||||||
|
@ -312,7 +349,8 @@
|
||||||
"educationLevelFk",
|
"educationLevelFk",
|
||||||
"originCountryFk",
|
"originCountryFk",
|
||||||
"maritalStatus",
|
"maritalStatus",
|
||||||
"SSN"
|
"SSN",
|
||||||
|
"businessFk"
|
||||||
],
|
],
|
||||||
"include": [
|
"include": [
|
||||||
{
|
{
|
||||||
|
@ -323,6 +361,48 @@
|
||||||
"phone"
|
"phone"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"relation": "currentBusiness",
|
||||||
|
"scope": {
|
||||||
|
"fields": [
|
||||||
|
"id",
|
||||||
|
"started",
|
||||||
|
"ended",
|
||||||
|
"reasonEndFk",
|
||||||
|
"departmentFk",
|
||||||
|
"workerBusinessProfessionalCategoryFk"
|
||||||
|
],
|
||||||
|
"include": [
|
||||||
|
{
|
||||||
|
"relation": "reasonEnd",
|
||||||
|
"scope": {
|
||||||
|
"fields": [
|
||||||
|
"id",
|
||||||
|
"reason"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"relation": "department",
|
||||||
|
"scope": {
|
||||||
|
"fields": [
|
||||||
|
"id",
|
||||||
|
"name"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"relation": "workerBusinessProfessionalCategory",
|
||||||
|
"scope": {
|
||||||
|
"fields": [
|
||||||
|
"id",
|
||||||
|
"description"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue