Compare commits
2 Commits
dev
...
4560-gasto
Author | SHA1 | Date |
---|---|---|
Alexandre Riera | 530c300ea5 | |
Alexandre Riera | 8a3231b615 |
|
@ -0,0 +1,26 @@
|
||||||
|
CREATE TABLE `vn`.`routeDeliveryMan` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`supplierFk` int(11) DEFAULT NULL,
|
||||||
|
`minCost` decimal(10,0) DEFAULT NULL,
|
||||||
|
`minM3` int(10) unsigned DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `routeDeliveryMan_FK` (`supplierFk`),
|
||||||
|
CONSTRAINT `routeDeliveryMan_FK` FOREIGN KEY (`supplierFk`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE `vn`.`routeDeliveryManAgency` (
|
||||||
|
`deliveryManFk` int(10) unsigned NOT NULL,
|
||||||
|
`agencyModeFk` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`deliveryManFk`),
|
||||||
|
KEY `routeDeliveryManAgency_FK` (`agencyModeFk`),
|
||||||
|
CONSTRAINT `routeDeliveryManAgency_FK` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `routeDeliveryManAgency_FK_1` FOREIGN KEY (`deliveryManFk`) REFERENCES `routeDeliveryMan` (`id`) ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
ALTER TABLE `vn`.`route` ADD `invoiceOutFk` varchar(10) NULL;
|
||||||
|
ALTER TABLE `vn`.`route` ADD CONSTRAINT `route_FK` FOREIGN KEY (`invoiceOutFk`) REFERENCES `vn`.`invoiceOut`(`ref`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('DeliveryMan', '*', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||||
|
('DeliveryManAgency', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1 +0,0 @@
|
||||||
Delete this file
|
|
|
@ -1798,7 +1798,7 @@ INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRa
|
||||||
(1103, 2000, 0.00, 0.00, 0.02, 1.00),
|
(1103, 2000, 0.00, 0.00, 0.02, 1.00),
|
||||||
(1104, 2500, 150.00, 0.02, 0.10, 1.00);
|
(1104, 2500, 150.00, 0.02, 0.10, 1.00);
|
||||||
|
|
||||||
INSERT INTO vn.claimRma (`id`, `code`, `created`, `workerFk`)
|
INSERT INTO `vn`.`claimRma` (`id`, `code`, `created`, `workerFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, '02676A049183', DEFAULT, 1106),
|
(1, '02676A049183', DEFAULT, 1106),
|
||||||
(2, '02676A049183', DEFAULT, 1106),
|
(2, '02676A049183', DEFAULT, 1106),
|
||||||
|
@ -1806,7 +1806,13 @@ INSERT INTO vn.claimRma (`id`, `code`, `created`, `workerFk`)
|
||||||
(4, '02676A049183', DEFAULT, 1107),
|
(4, '02676A049183', DEFAULT, 1107),
|
||||||
(5, '01837B023653', DEFAULT, 1106);
|
(5, '01837B023653', DEFAULT, 1106);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`routeDeliveryMan` (`id`, `supplierFk`, `minCost`, `minM3`)
|
||||||
|
VALUES
|
||||||
|
(1, 442, 10.0, 10);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`routeDeliveryManAgency` (`deliveryManFk`, `agencyModeFk`)
|
||||||
|
VALUES
|
||||||
|
(1, 1);
|
||||||
|
|
||||||
INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, `secretKey`)
|
INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, `secretKey`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2735,4 +2741,4 @@ INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`
|
||||||
|
|
||||||
INSERT INTO `vn`.`ticketLog` (`id`, `originFk`, `userFk`, `action`, `changedModel`, `oldInstance`, `newInstance`, `changedModelId`)
|
INSERT INTO `vn`.`ticketLog` (`id`, `originFk`, `userFk`, `action`, `changedModel`, `oldInstance`, `newInstance`, `changedModelId`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 9, 'insert', 'Ticket', '{}', '{"clientFk":1, "nickname": "Bat cave"}', 1);
|
(1, 1, 9, 'insert', 'Ticket', '{}', '{"clientFk":1, "nickname": "Bat cave"}', 1);
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('updateDeliveryMan', {
|
||||||
|
description: 'Updates delivery man data',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'ctx',
|
||||||
|
type: 'object',
|
||||||
|
http: {source: 'context'}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: false,
|
||||||
|
description: 'The delivery man id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'minCost',
|
||||||
|
type: 'number'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'minM3',
|
||||||
|
type: 'number'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'agencyFk',
|
||||||
|
type: 'number'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'supplierFk',
|
||||||
|
type: 'number'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
accessType: 'WRITE',
|
||||||
|
returns: {
|
||||||
|
type: 'Object',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/updateDeliveryMan/:id`,
|
||||||
|
verb: 'PATCH'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.updateDeliveryMan = async(ctx, id, options) => {
|
||||||
|
const models = Self.app.models;
|
||||||
|
const args = ctx.args;
|
||||||
|
let tx;
|
||||||
|
const myOptions = {};
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const deliveryMan = await models.DeliveryMan.findById(id, null, myOptions);
|
||||||
|
await deliveryMan.updateAttributes({
|
||||||
|
minCost: args.minCost,
|
||||||
|
minM3: args.minM3,
|
||||||
|
supplierFk: args.supplierFk
|
||||||
|
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
return deliveryMan;
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -16,6 +16,12 @@
|
||||||
},
|
},
|
||||||
"DeliveryPoint": {
|
"DeliveryPoint": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"DeliveryMan": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"DeliveryManAgency": {
|
||||||
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"name": "DeliveryMan",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "routeDeliveryMan"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"id": true,
|
||||||
|
"type": "number",
|
||||||
|
"forceId": false
|
||||||
|
},
|
||||||
|
"supplierFk": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"minCost": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"minM3": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"supplier": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Supplier",
|
||||||
|
"foreignKey": "supplierFk"
|
||||||
|
},
|
||||||
|
"deliveryManAgency": {
|
||||||
|
"type": "hasOne",
|
||||||
|
"model": "DeliveryManAgency",
|
||||||
|
"foreignKey": "deliveryManFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"name": "DeliveryManAgency",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "routeDeliveryManAgency"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"deliveryManFk": {
|
||||||
|
"id": true
|
||||||
|
},
|
||||||
|
"agencyModeFk": {
|
||||||
|
"id": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"deliveryMan": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "DeliveryMan",
|
||||||
|
"foreignKey": "deliveryManFk"
|
||||||
|
},
|
||||||
|
"agencyMode": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "AgencyMode",
|
||||||
|
"foreignKey": "agencyModeFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ module.exports = Self => {
|
||||||
require('../methods/route/driverRoutePdf')(Self);
|
require('../methods/route/driverRoutePdf')(Self);
|
||||||
require('../methods/route/driverRouteEmail')(Self);
|
require('../methods/route/driverRouteEmail')(Self);
|
||||||
require('../methods/route/sendSms')(Self);
|
require('../methods/route/sendSms')(Self);
|
||||||
|
require('../methods/route/updateDeliveryMan')(Self);
|
||||||
|
|
||||||
Self.validate('kmStart', validateDistance, {
|
Self.validate('kmStart', validateDistance, {
|
||||||
message: 'Distance must be lesser than 1000'
|
message: 'Distance must be lesser than 1000'
|
||||||
|
|
Loading…
Reference in New Issue