6995-testToMaster_2410 #2139
|
@ -235,6 +235,7 @@ pipeline {
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
message = message.substring(0, index)
|
message = message.substring(0, index)
|
||||||
|
|
||||||
|
setEnv()
|
||||||
rocketSend(
|
rocketSend(
|
||||||
channel: 'vn-database',
|
channel: 'vn-database',
|
||||||
message: "*DB version uploaded:* ${message}"
|
message: "*DB version uploaded:* ${message}"
|
||||||
|
|
|
@ -88,7 +88,7 @@ module.exports = Self => {
|
||||||
warehouseFk: args.warehouseId,
|
warehouseFk: args.warehouseId,
|
||||||
reference: args.reference,
|
reference: args.reference,
|
||||||
description: args.description,
|
description: args.description,
|
||||||
contentType: args.contentType,
|
contentType: uploadedFile.type,
|
||||||
hasFile: args.hasFile
|
hasFile: args.hasFile
|
||||||
};
|
};
|
||||||
const extension = await models.DmsContainer.getFileExtension(uploadedFile.name);
|
const extension = await models.DmsContainer.getFileExtension(uploadedFile.name);
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn`.`doc`
|
|
||||||
AS SELECT `g`.`id` AS `id`,
|
|
||||||
`g`.`sref` AS `sref`,
|
|
||||||
`g`.`brief` AS `brief`,
|
|
||||||
`g`.`emp_id` AS `companyFk`,
|
|
||||||
`g`.`orden` AS `order`,
|
|
||||||
`g`.`file` AS `file`,
|
|
||||||
`g`.`original` AS `original`,
|
|
||||||
`g`.`trabajador_id` AS `workerFk`,
|
|
||||||
`g`.`odbc_date` AS `created`,
|
|
||||||
`g`.`warehouse_id` AS `warehouseFk`
|
|
||||||
FROM `vn2008`.`gestdoc` `g`
|
|
|
@ -1,9 +1,11 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
SQL SECURITY DEFINER
|
SQL SECURITY DEFINER
|
||||||
VIEW `vn2008`.`credit`
|
VIEW `vn2008`.`credit`
|
||||||
AS SELECT `c`.`id` AS `id`,
|
AS SELECT
|
||||||
|
`c`.`id` AS `id`,
|
||||||
`c`.`clientFk` AS `Id_Cliente`,
|
`c`.`clientFk` AS `Id_Cliente`,
|
||||||
`c`.`workerFk` AS `Id_Trabajador`,
|
`c`.`workerFk` AS `Id_Trabajador`,
|
||||||
`c`.`amount` AS `amount`,
|
`c`.`amount` AS `amount`,
|
||||||
`c`.`created` AS `odbc_date`
|
`c`.`created` AS `odbc_date`
|
||||||
FROM `vn`.`clientCredit` `c`
|
FROM
|
||||||
|
`vn`.`clientCredit` `c`
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn2008`.`versiones`
|
||||||
|
AS SELECT `m`.`app` AS `programa`,
|
||||||
|
`m`.`version` AS `version`,
|
||||||
|
0 AS `critical`
|
||||||
|
FROM `vn`.`mdbVersion` `m`
|
||||||
|
WHERE `m`.`branchFk` = 'master'
|
|
@ -97,10 +97,6 @@ ALTER TABLE IF EXISTS vn2008.Tickets_stack__ COMMENT='refs #6371 deprecated 2024
|
||||||
ALTER TABLE IF EXISTS vn2008.Tipos_f11 RENAME vn2008.Tipos_f11__;
|
ALTER TABLE IF EXISTS vn2008.Tipos_f11 RENAME vn2008.Tipos_f11__;
|
||||||
ALTER TABLE IF EXISTS vn2008.Tipos_f11__ COMMENT='refs #6371 deprecated 2024-01-11';
|
ALTER TABLE IF EXISTS vn2008.Tipos_f11__ COMMENT='refs #6371 deprecated 2024-01-11';
|
||||||
|
|
||||||
-- Para la tabla Tramos
|
|
||||||
ALTER TABLE IF EXISTS vn2008.Tramos RENAME vn2008.Tramos__;
|
|
||||||
ALTER TABLE IF EXISTS vn2008.Tramos__ COMMENT='refs #6371 deprecated 2024-01-11';
|
|
||||||
|
|
||||||
-- Para la tabla accion_dits
|
-- Para la tabla accion_dits
|
||||||
ALTER TABLE IF EXISTS vn2008.accion_dits RENAME vn2008.accion_dits__;
|
ALTER TABLE IF EXISTS vn2008.accion_dits RENAME vn2008.accion_dits__;
|
||||||
ALTER TABLE IF EXISTS vn2008.accion_dits__ COMMENT='refs #6371 deprecated 2024-01-11';
|
ALTER TABLE IF EXISTS vn2008.accion_dits__ COMMENT='refs #6371 deprecated 2024-01-11';
|
||||||
|
@ -161,10 +157,6 @@ ALTER TABLE IF EXISTS vn2008.cyc__ COMMENT='refs #6371 deprecated 2024-01-11';
|
||||||
ALTER TABLE IF EXISTS vn2008.cyc_declaration RENAME vn2008.cyc_declaration__;
|
ALTER TABLE IF EXISTS vn2008.cyc_declaration RENAME vn2008.cyc_declaration__;
|
||||||
ALTER TABLE IF EXISTS vn2008.cyc_declaration__ COMMENT='refs #6371 deprecated 2024-01-11';
|
ALTER TABLE IF EXISTS vn2008.cyc_declaration__ COMMENT='refs #6371 deprecated 2024-01-11';
|
||||||
|
|
||||||
-- Para la tabla dock
|
|
||||||
ALTER TABLE IF EXISTS vn2008.dock RENAME vn2008.dock__;
|
|
||||||
ALTER TABLE IF EXISTS vn2008.dock__ COMMENT='refs #6371 deprecated 2024-01-11';
|
|
||||||
|
|
||||||
-- Para la tabla edi_testigos
|
-- Para la tabla edi_testigos
|
||||||
ALTER TABLE IF EXISTS vn2008.edi_testigos RENAME vn2008.edi_testigos__;
|
ALTER TABLE IF EXISTS vn2008.edi_testigos RENAME vn2008.edi_testigos__;
|
||||||
ALTER TABLE IF EXISTS vn2008.edi_testigos__ COMMENT='refs #6371 deprecated 2024-01-11';
|
ALTER TABLE IF EXISTS vn2008.edi_testigos__ COMMENT='refs #6371 deprecated 2024-01-11';
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn2008`.`credit`AS
|
||||||
|
SELECT 1;
|
||||||
|
|
||||||
|
GRANT SELECT ON TABLE vn2008.credit TO financialBoss;
|
|
@ -1,24 +1,33 @@
|
||||||
ALTER TABLE IF EXISTS vn2008.gastos_resumen DROP FOREIGN KEY IF EXISTS gastos_resumen_expense_FK;
|
ALTER TABLE IF EXISTS vn2008.gastos_resumen DROP FOREIGN KEY IF EXISTS gastos_resumen_expense_FK;
|
||||||
ALTER TABLE IF EXISTS `vn2008`.`gastos_resumen` RENAME `vn`.`expenseManual`;
|
ALTER TABLE IF EXISTS `vn2008`.`gastos_resumen` RENAME `vn`.`expenseManual`;
|
||||||
|
|
||||||
ALTER TABLE IF EXISTS `vn`.`expenseManual`
|
ALTER TABLE `vn`.`expenseManual`
|
||||||
CHANGE COLUMN IF EXISTS `Id_Gasto` `expenseFk` varchar(10) NOT NULL,
|
CHANGE COLUMN IF EXISTS `Id_Gasto` `expenseFk` varchar(10) NOT NULL,
|
||||||
CHANGE COLUMN IF EXISTS `importe` `amount` decimal(10,2) DEFAULT NULL,
|
CHANGE COLUMN IF EXISTS `importe` `amount` decimal(10,2) DEFAULT NULL,
|
||||||
CHANGE COLUMN IF EXISTS `empresa_id` `companyFk` int(11) NOT NULL;
|
CHANGE COLUMN IF EXISTS `empresa_id` `companyFk` int(11) NOT NULL;
|
||||||
|
|
||||||
ALTER TABLE IF EXISTS vn.expenseManual COLLATE=utf8mb3_general_ci;
|
ALTER TABLE vn.expenseManual COLLATE=utf8mb3_general_ci;
|
||||||
|
|
||||||
ALTER TABLE IF EXISTS vn.expenseManual MODIFY COLUMN IF EXISTS expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;
|
ALTER TABLE vn.expenseManual MODIFY COLUMN IF EXISTS expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;
|
||||||
|
|
||||||
ALTER TABLE IF EXISTS vn.expenseManual ADD CONSTRAINT expenseManual_expense_FK FOREIGN KEY IF NOT EXISTS (expenseFk) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
ALTER TABLE vn.expenseManual DROP PRIMARY KEY;
|
||||||
|
|
||||||
ALTER TABLE IF EXISTS vn.expenseManual MODIFY COLUMN IF EXISTS companyFk int(10) unsigned NOT NULL;
|
|
||||||
|
|
||||||
ALTER TABLE vn.expenseManual MODIFY COLUMN companyFk int(10) unsigned NULL;
|
ALTER TABLE vn.expenseManual MODIFY COLUMN companyFk int(10) unsigned NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.expenseManual ADD CONSTRAINT expenseManual_expense_FK FOREIGN KEY IF NOT EXISTS (expenseFk) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE vn.expenseManual ADD CONSTRAINT expenseManual_company_FK FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE vn.expenseManual ADD IF NOT EXISTS id INT unsigned NOT NULL FIRST;
|
||||||
|
|
||||||
|
ALTER TABLE vn.expenseManual ADD CONSTRAINT expenseManual_pk PRIMARY KEY IF NOT EXISTS (id);
|
||||||
|
|
||||||
|
ALTER TABLE vn.expenseManual ADD CONSTRAINT expenseManual_unique UNIQUE KEY IF NOT EXISTS (expenseFk,`year`,`month`,companyFk);
|
||||||
|
|
||||||
|
ALTER TABLE vn.expenseManual MODIFY COLUMN IF EXISTS companyFk int(10) unsigned NOT NULL;
|
||||||
|
|
||||||
UPDATE vn.expenseManual
|
UPDATE vn.expenseManual
|
||||||
SET companyFK= NULL
|
SET companyFK= NULL
|
||||||
WHERE companyFk= 0;
|
WHERE companyFk= 0;
|
||||||
|
|
||||||
ALTER TABLE IF EXISTS vn.expenseManual ADD CONSTRAINT expenseManual_company_FK FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ module.exports = Self => {
|
||||||
Self.setRating = async function(ctx, id, rating, recommendedCredit, options) {
|
Self.setRating = async function(ctx, id, rating, recommendedCredit, options) {
|
||||||
let tx;
|
let tx;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
@ -42,6 +41,7 @@ module.exports = Self => {
|
||||||
const clientUpdated = await client.updateAttributes({
|
const clientUpdated = await client.updateAttributes({
|
||||||
rating: rating,
|
rating: rating,
|
||||||
recommendedCredit: recommendedCredit
|
recommendedCredit: recommendedCredit
|
||||||
|
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
|
@ -40,4 +40,26 @@ describe('Client setRating()', () => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should change rating and recommendedCredit to 0', async() => {
|
||||||
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const clientId = 1101;
|
||||||
|
const newRating = 0;
|
||||||
|
const newRecommendedCredit = 0;
|
||||||
|
|
||||||
|
const updatedClient = await models.Client.setRating(ctx, clientId, newRating, newRecommendedCredit, options);
|
||||||
|
|
||||||
|
expect(updatedClient.rating).toEqual(newRating);
|
||||||
|
expect(updatedClient.recommendedCredit).toEqual(newRecommendedCredit);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -319,7 +319,8 @@ module.exports = Self => {
|
||||||
await Self.changeCredit(ctx, finalState, changes);
|
await Self.changeCredit(ctx, finalState, changes);
|
||||||
|
|
||||||
// Credit management changes
|
// Credit management changes
|
||||||
if (changes?.rating || changes?.recommendedCredit)
|
|
||||||
|
if (changes?.rating >= 0 || changes?.recommendedCredit >= 0)
|
||||||
await Self.changeCreditManagement(ctx, finalState, changes);
|
await Self.changeCreditManagement(ctx, finalState, changes);
|
||||||
|
|
||||||
const oldInstance = {};
|
const oldInstance = {};
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('sale usesMana()', () => {
|
describe('sale usesMana()', () => {
|
||||||
const ctx = {
|
const ctx = {req: { accessToken: {userId: 18}}};
|
||||||
req: {
|
|
||||||
accessToken: {userId: 18}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should return that the worker uses mana', async() => {
|
it('should return that the worker uses mana', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
|
@ -45,4 +41,27 @@ describe('sale usesMana()', () => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return that the worker does not use mana because it is excluded', async() => {
|
||||||
|
const tx = await models.Sale.beginTransaction({});
|
||||||
|
const buyerId = 35;
|
||||||
|
const franceDepartmentId = 133;
|
||||||
|
const buyerCtx = {req: {accessToken: {userId: buyerId}}};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx}
|
||||||
|
|
||||||
|
await models.WorkerManaExcluded.create({workerFk: buyerId}, options);
|
||||||
|
await models.Business.updateAll({workerFk: buyerId}, {departmentFk: franceDepartmentId}, options);
|
||||||
|
|
||||||
|
const usesMana = await models.Sale.usesMana(buyerCtx, options);
|
||||||
|
|
||||||
|
expect(usesMana).toBe(false);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,9 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const isManaExcluded = await models.WorkerManaExcluded.findById(userId, null, myOptions);
|
||||||
|
if (isManaExcluded) return false;
|
||||||
|
|
||||||
const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions);
|
const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions);
|
||||||
const departments = await models.Department.getLeaves(ctx, salesDepartment.id, null, myOptions);
|
const departments = await models.Department.getLeaves(ctx, salesDepartment.id, null, myOptions);
|
||||||
const workerDepartment = await models.WorkerDepartment.findById(userId, null, myOptions);
|
const workerDepartment = await models.WorkerDepartment.findById(userId, null, myOptions);
|
||||||
|
|
|
@ -33,8 +33,8 @@ module.exports = Self => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||||
let tx;
|
let tx;
|
||||||
let ticket;
|
let dms;
|
||||||
let externalTickets = [];
|
let gestDocCreated = false;
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
@ -44,11 +44,6 @@ module.exports = Self => {
|
||||||
myOptions.transaction = tx;
|
myOptions.transaction = tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dmsTypeTicket = await models.DmsType.findOne({
|
|
||||||
where: {code: 'ticket'},
|
|
||||||
fields: ['id']
|
|
||||||
}, myOptions);
|
|
||||||
|
|
||||||
async function setLocation(ticketId) {
|
async function setLocation(ticketId) {
|
||||||
await models.Delivery.create({
|
await models.Delivery.create({
|
||||||
ticketFk: ticketId,
|
ticketFk: ticketId,
|
||||||
|
@ -58,106 +53,102 @@ module.exports = Self => {
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function hasSignDms(ticketId) {
|
async function gestDocExists(ticketId) {
|
||||||
const ticketDms = await models.TicketDms.findOne({
|
const ticketDms = await models.TicketDms.findOne({
|
||||||
where: {ticketFk: ticketId},
|
where: {ticketFk: ticketId},
|
||||||
|
fields: ['dmsFk']
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
|
if (!ticketDms) return false;
|
||||||
|
|
||||||
|
const ticket = await models.Ticket.findById(ticketId, {fields: ['isSigned']}, myOptions);
|
||||||
|
if (ticket.isSigned == true)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
await models.Dms.destroyAll({where: {reference: ticketId}}, myOptions);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createGestDoc(id) {
|
||||||
|
const ticket = await models.Ticket.findById(id,
|
||||||
|
{
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
relation: 'dms',
|
relation: 'warehouse',
|
||||||
fields: ['id'],
|
|
||||||
scope: {
|
scope: {
|
||||||
where: {dmsTypeFk: dmsTypeTicket.id}
|
fields: ['id']
|
||||||
}
|
}
|
||||||
}
|
}, {
|
||||||
]
|
relation: 'client',
|
||||||
}, myOptions);
|
|
||||||
if (ticketDms?.dms()?.id) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function createGestDoc() {
|
|
||||||
const ctxUploadFile = Object.assign({}, ctx);
|
|
||||||
ctxUploadFile.args = {
|
|
||||||
warehouseId: ticket.warehouseFk,
|
|
||||||
companyId: ticket.companyFk,
|
|
||||||
dmsTypeId: dmsTypeTicket.id,
|
|
||||||
reference: ticket.id,
|
|
||||||
description: `Firma del cliente - Ruta ${ticket.route().id}`,
|
|
||||||
contentType: 'image/png',
|
|
||||||
hasFile: true
|
|
||||||
};
|
|
||||||
const dms = await models.Dms.uploadFile(ctxUploadFile, myOptions);
|
|
||||||
await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (const ticketId of tickets) {
|
|
||||||
ticket = await models.Ticket.findById(ticketId, {
|
|
||||||
include: [{
|
|
||||||
relation: 'address',
|
|
||||||
scope: {
|
scope: {
|
||||||
include: {
|
fields: ['name']
|
||||||
relation: 'province',
|
|
||||||
scope: {
|
|
||||||
include: {
|
|
||||||
relation: 'country',
|
|
||||||
scope: {
|
|
||||||
fields: ['code']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
relation: 'route',
|
relation: 'route',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['id']
|
fields: ['id']
|
||||||
}
|
}
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
const dmsType = await models.DmsType.findOne({where: {code: 'Ticket'}, fields: ['id']}, myOptions);
|
||||||
|
const ctxUploadFile = Object.assign({}, ctx);
|
||||||
|
if (ticket.route() === null)
|
||||||
|
throw new UserError('Ticket without route');
|
||||||
|
ctxUploadFile.args = {
|
||||||
|
warehouseId: ticket.warehouseFk,
|
||||||
|
companyId: ticket.companyFk,
|
||||||
|
dmsTypeId: dmsType.id,
|
||||||
|
reference: '',
|
||||||
|
description: `Firma del cliente - Ruta ${ticket.route().id}`,
|
||||||
|
hasFile: false
|
||||||
|
};
|
||||||
|
dms = await models.Dms.uploadFile(ctxUploadFile, myOptions);
|
||||||
|
gestDocCreated = true;
|
||||||
|
}
|
||||||
|
|
||||||
const ticketState = await models.TicketState.findOne({
|
try {
|
||||||
where: {ticketFk: ticketId},
|
for (const ticketId of tickets) {
|
||||||
|
const ticketState = await models.TicketState.findOne(
|
||||||
|
{where: {ticketFk: ticketId},
|
||||||
fields: ['alertLevel']
|
fields: ['alertLevel']
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const packedAlertLevel = await models.AlertLevel.findOne({
|
const packedAlertLevel = await models.AlertLevel.findOne({where: {code: 'PACKED'},
|
||||||
where: {code: 'PACKED'},
|
|
||||||
fields: ['id']
|
fields: ['id']
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
if (!ticketState)
|
if (!ticketState)
|
||||||
throw new UserError('Ticket does not exist');
|
throw new UserError('Ticket does not exist');
|
||||||
if (!ticket.route())
|
|
||||||
throw new UserError('Ticket without route');
|
|
||||||
if (ticketState.alertLevel < packedAlertLevel.id)
|
if (ticketState.alertLevel < packedAlertLevel.id)
|
||||||
throw new UserError('This ticket cannot be signed because it has not been boxed');
|
throw new UserError('This ticket cannot be signed because it has not been boxed');
|
||||||
if (await ticket.isSigned)
|
if (await gestDocExists(ticketId))
|
||||||
throw new UserError('Ticket is already signed');
|
throw new UserError('Ticket is already signed');
|
||||||
|
|
||||||
if (location) await setLocation(ticketId);
|
if (location) await setLocation(ticketId);
|
||||||
if (!await hasSignDms(ticketId))
|
if (!gestDocCreated) await createGestDoc(ticketId);
|
||||||
await createGestDoc(ticketId);
|
await models.TicketDms.create({ticketFk: ticketId, dmsFk: dms[0].id}, myOptions);
|
||||||
|
const ticket = await models.Ticket.findById(ticketId, null, myOptions);
|
||||||
await ticket.updateAttribute('isSigned', true, myOptions);
|
await ticket.updateAttribute('isSigned', true, myOptions);
|
||||||
|
|
||||||
const deliveryState = await models.State.findOne({
|
const deliveryState = await models.State.findOne({
|
||||||
where: {code: 'DELIVERED'}
|
where: {
|
||||||
|
code: 'DELIVERED'
|
||||||
|
}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
await models.Ticket.state(ctx, {
|
await models.Ticket.state(ctx, {
|
||||||
ticketFk: ticketId,
|
ticketFk: ticketId,
|
||||||
stateFk: deliveryState.id
|
stateFk: deliveryState.id
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
}
|
||||||
|
|
||||||
if (ticket?.address()?.province()?.country()?.code != 'ES') {
|
|
||||||
await models.Ticket.saveCmr(ctx, [ticketId], myOptions);
|
|
||||||
externalTickets.push(ticketId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (tx) await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
await models.Route.cmrEmail(ctx, externalTickets);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -137,7 +137,8 @@ module.exports = Self => {
|
||||||
tb.type,
|
tb.type,
|
||||||
tb.businessFk,
|
tb.businessFk,
|
||||||
tb.permissionRate,
|
tb.permissionRate,
|
||||||
d.isTeleworking
|
d.isTeleworking,
|
||||||
|
d.hasToRefill
|
||||||
FROM tmp.timeBusinessCalculate tb
|
FROM tmp.timeBusinessCalculate tb
|
||||||
JOIN account.user u ON u.id = tb.userFk
|
JOIN account.user u ON u.id = tb.userFk
|
||||||
JOIN department d ON d.id = tb.departmentFk
|
JOIN department d ON d.id = tb.departmentFk
|
||||||
|
@ -174,7 +175,7 @@ module.exports = Self => {
|
||||||
myOptions.transaction = tx;
|
myOptions.transaction = tx;
|
||||||
try {
|
try {
|
||||||
workerFk = day.workerFk;
|
workerFk = day.workerFk;
|
||||||
if (day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null
|
if (day.hasToRefill && day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null
|
||||||
&& (day.permissionRate == null ? true : day.permissionRate)) {
|
&& (day.permissionRate == null ? true : day.permissionRate)) {
|
||||||
if (day.timeTable == null) {
|
if (day.timeTable == null) {
|
||||||
const timed = new Date(day.dated);
|
const timed = new Date(day.dated);
|
||||||
|
|
|
@ -86,6 +86,9 @@
|
||||||
"WorkerMana": {
|
"WorkerMana": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"WorkerManaExcluded": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"WorkerMistake": {
|
"WorkerMistake": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"name": "WorkerManaExcluded",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "workerManaExcluded"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"workerFk": {
|
||||||
|
"id": true,
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"worker": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Worker",
|
||||||
|
"foreignKey": "workerFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -56,7 +56,7 @@
|
||||||
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
|
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
|
||||||
"@babel/preset-env": "^7.11.0",
|
"@babel/preset-env": "^7.11.0",
|
||||||
"@babel/register": "^7.7.7",
|
"@babel/register": "^7.7.7",
|
||||||
"@verdnatura/myt": "^1.6.7",
|
"@verdnatura/myt": "^1.6.8",
|
||||||
"angular-mocks": "^1.7.9",
|
"angular-mocks": "^1.7.9",
|
||||||
"babel-jest": "^26.0.1",
|
"babel-jest": "^26.0.1",
|
||||||
"babel-loader": "^8.2.4",
|
"babel-loader": "^8.2.4",
|
||||||
|
|
|
@ -131,8 +131,8 @@ devDependencies:
|
||||||
specifier: ^7.7.7
|
specifier: ^7.7.7
|
||||||
version: 7.23.7(@babel/core@7.23.9)
|
version: 7.23.7(@babel/core@7.23.9)
|
||||||
'@verdnatura/myt':
|
'@verdnatura/myt':
|
||||||
specifier: ^1.6.7
|
specifier: ^1.6.8
|
||||||
version: 1.6.7
|
version: 1.6.8
|
||||||
angular-mocks:
|
angular-mocks:
|
||||||
specifier: ^1.7.9
|
specifier: ^1.7.9
|
||||||
version: 1.8.3
|
version: 1.8.3
|
||||||
|
@ -2633,8 +2633,8 @@ packages:
|
||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@verdnatura/myt@1.6.7:
|
/@verdnatura/myt@1.6.8:
|
||||||
resolution: {integrity: sha512-t/Q1T3QzHpZFdxwIyQL/CV5g+HJvWE6Q65VeA9k0svZdX/vezgnQ21nkI+wuvIurIl6BXqq2Arx7EWYkAhGNNA==}
|
resolution: {integrity: sha512-jpadr6yAR9TQXPv+has5yOYAolR/YEzsxbLgMR7BoDrpLyVFLHJEy4Dfe+Hy11r3AmxCB/8lWM+La1YGvXMWOA==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@sqltools/formatter': 1.2.5
|
'@sqltools/formatter': 1.2.5
|
||||||
|
|
|
@ -7,7 +7,8 @@ SELECT
|
||||||
s.discount,
|
s.discount,
|
||||||
s.itemFk,
|
s.itemFk,
|
||||||
s.concept,
|
s.concept,
|
||||||
tc.code vatType
|
tc.code vatType,
|
||||||
|
it.isPackaging
|
||||||
FROM vn.invoiceOut io
|
FROM vn.invoiceOut io
|
||||||
JOIN vn.ticket t ON t.refFk = io.ref
|
JOIN vn.ticket t ON t.refFk = io.ref
|
||||||
JOIN vn.supplier su ON su.id = io.companyFk
|
JOIN vn.supplier su ON su.id = io.companyFk
|
||||||
|
@ -34,9 +35,10 @@ SELECT
|
||||||
ts.quantity,
|
ts.quantity,
|
||||||
ts.price,
|
ts.price,
|
||||||
0 discount,
|
0 discount,
|
||||||
'',
|
NULL,
|
||||||
ts.description concept,
|
ts.description,
|
||||||
tc.code vatType
|
tc.code,
|
||||||
|
NULL
|
||||||
FROM vn.invoiceOut io
|
FROM vn.invoiceOut io
|
||||||
JOIN vn.ticket t ON t.refFk = io.ref
|
JOIN vn.ticket t ON t.refFk = io.ref
|
||||||
JOIN vn.ticketService ts ON ts.ticketFk = t.id
|
JOIN vn.ticketService ts ON ts.ticketFk = t.id
|
||||||
|
@ -46,3 +48,4 @@ SELECT
|
||||||
JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk
|
JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk
|
||||||
JOIN vn.taxClass tc ON tc.id = ts.taxClassFk
|
JOIN vn.taxClass tc ON tc.id = ts.taxClassFk
|
||||||
WHERE t.refFk = ?
|
WHERE t.refFk = ?
|
||||||
|
ORDER BY (isPackaging), concept, itemFk
|
||||||
|
|
Loading…
Reference in New Issue