fix: refs #6900 fine tunning #2905
|
@ -1,18 +1,23 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceSerial`(vClientFk INT, vCompanyFk INT, vType CHAR(15))
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceSerial`(
|
||||||
|
vClientFk INT,
|
||||||
|
vCompanyFk INT,
|
||||||
|
vType CHAR(15)
|
||||||
|
)
|
||||||
RETURNS char(2) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
|
RETURNS char(2) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
|
||||||
DETERMINISTIC
|
DETERMINISTIC
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Obtiene la serie de una factura
|
* Obtiene la serie de una factura
|
||||||
* dependiendo del area del cliente.
|
* dependiendo del area del cliente.
|
||||||
*
|
*
|
||||||
* @param vClientFk Id del cliente
|
* @param vClientFk Id del cliente
|
||||||
* @param vCompanyFk Id de la empresa
|
* @param vCompanyFk Id de la empresa
|
||||||
* @param vType Tipo de factura ['global','multiple','quick']
|
* @param vType Tipo de factura (vn.invoiceOutSerial.type[ENUM])
|
||||||
* @return vSerie de la factura
|
* @return vSerie de la factura
|
||||||
*/
|
*/
|
||||||
DECLARE vTaxArea VARCHAR(25) COLLATE utf8mb3_general_ci;
|
DECLARE vTaxArea VARCHAR(25) COLLATE utf8mb3_general_ci;
|
||||||
|
DECLARE vTransactionCode INT(2);
|
||||||
DECLARE vSerie CHAR(2);
|
DECLARE vSerie CHAR(2);
|
||||||
|
|
||||||
IF (SELECT hasInvoiceSimplified FROM client WHERE id = vClientFk) THEN
|
IF (SELECT hasInvoiceSimplified FROM client WHERE id = vClientFk) THEN
|
||||||
|
@ -23,9 +28,15 @@ BEGIN
|
||||||
FROM client
|
FROM client
|
||||||
WHERE id = vClientFk;
|
WHERE id = vClientFk;
|
||||||
|
|
||||||
SELECT code INTO vSerie
|
SELECT CodigoTransaccion INTO vTransactionCode
|
||||||
FROM invoiceOutSerial
|
FROM taxArea
|
||||||
WHERE `type` = vType AND taxAreaFk = vTaxArea;
|
WHERE code = vTaxArea;
|
||||||
|
|
||||||
|
SELECT ios.code INTO vSerie
|
||||||
|
FROM invoiceOutSerial ios
|
||||||
|
JOIN taxArea ta ON ta.code = ios.taxAreaFk
|
||||||
|
WHERE ios.`type` = vType
|
||||||
|
AND ta.CodigoTransaccion = vTransactionCode;
|
||||||
|
|
||||||
RETURN vSerie;
|
RETURN vSerie;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -23,43 +23,36 @@ BEGIN
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
DELETE tt.*
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale_problems (
|
||||||
FROM tmp.sale_getProblems tt
|
ticketFk INT(11),
|
||||||
JOIN ticketObservation tto ON tto.ticketFk = tt.ticketFk
|
saleFk INT(11),
|
||||||
JOIN observationType ot ON ot.id = tto.observationTypeFk
|
isFreezed INTEGER(1) DEFAULT 0,
|
||||||
WHERE ot.code = 'administrative'
|
risk DECIMAL(10,1) DEFAULT 0,
|
||||||
AND tto.description = 'Miriam';
|
hasRisk TINYINT(1) DEFAULT 0,
|
||||||
|
hasHighRisk TINYINT(1) DEFAULT 0,
|
||||||
|
hasTicketRequest INTEGER(1) DEFAULT 0,
|
||||||
|
itemShortage VARCHAR(255),
|
||||||
|
isTaxDataChecked INTEGER(1) DEFAULT 1,
|
||||||
|
itemDelay VARCHAR(255),
|
||||||
|
itemLost VARCHAR(255),
|
||||||
|
hasComponentLack INTEGER(1),
|
||||||
|
hasRounding VARCHAR(255),
|
||||||
|
isTooLittle BOOL DEFAULT FALSE,
|
||||||
|
isVip BOOL DEFAULT FALSE,
|
||||||
|
PRIMARY KEY (ticketFk, saleFk)
|
||||||
|
) ENGINE = MEMORY;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale_problems (
|
INSERT INTO tmp.sale_problems(ticketFk,
|
||||||
ticketFk INT(11),
|
saleFk,
|
||||||
saleFk INT(11),
|
isFreezed,
|
||||||
isFreezed INTEGER(1) DEFAULT 0,
|
risk,
|
||||||
risk DECIMAL(10,1) DEFAULT 0,
|
hasRisk,
|
||||||
hasRisk TINYINT(1) DEFAULT 0,
|
hasHighRisk,
|
||||||
hasHighRisk TINYINT(1) DEFAULT 0,
|
hasTicketRequest,
|
||||||
hasTicketRequest INTEGER(1) DEFAULT 0,
|
isTaxDataChecked,
|
||||||
itemShortage VARCHAR(255),
|
hasComponentLack,
|
||||||
isTaxDataChecked INTEGER(1) DEFAULT 1,
|
hasRounding,
|
||||||
itemDelay VARCHAR(255),
|
isTooLittle)
|
||||||
itemLost VARCHAR(255),
|
|
||||||
hasComponentLack INTEGER(1),
|
|
||||||
hasRounding VARCHAR(255),
|
|
||||||
isTooLittle BOOL DEFAULT FALSE,
|
|
||||||
isVip BOOL DEFAULT FALSE,
|
|
||||||
PRIMARY KEY (ticketFk, saleFk)
|
|
||||||
) ENGINE = MEMORY;
|
|
||||||
|
|
||||||
INSERT INTO tmp.sale_problems(ticketFk,
|
|
||||||
saleFk,
|
|
||||||
isFreezed,
|
|
||||||
risk,
|
|
||||||
hasRisk,
|
|
||||||
hasHighRisk,
|
|
||||||
hasTicketRequest,
|
|
||||||
isTaxDataChecked,
|
|
||||||
hasComponentLack,
|
|
||||||
hasRounding,
|
|
||||||
isTooLittle)
|
|
||||||
SELECT sgp.ticketFk,
|
SELECT sgp.ticketFk,
|
||||||
s.id,
|
s.id,
|
||||||
IF(FIND_IN_SET('isFreezed', t.problem), TRUE, FALSE) isFreezed,
|
IF(FIND_IN_SET('isFreezed', t.problem), TRUE, FALSE) isFreezed,
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE dipole.expedition_PrintOut MODIFY COLUMN isPrinted int(11) DEFAULT 0 NOT NULL COMMENT '0.- Not Printed ; 1.- Printed; 2.- Selected ; 3.- Error ; 4.- Waiting to be printed';
|
|
@ -27,25 +27,25 @@ module.exports = function(Self) {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// this.beforeRemote('**', async ctx => {
|
this.beforeRemote('**', async ctx => {
|
||||||
// if (!this.hasFilter(ctx)) return;
|
if (!this.hasFilter(ctx)) return;
|
||||||
|
|
||||||
// const defaultLimit = this.app.orm.selectLimit;
|
const defaultLimit = this.app.orm.selectLimit;
|
||||||
// const filter = ctx.args.filter || {limit: defaultLimit};
|
const filter = ctx.args.filter || {limit: defaultLimit};
|
||||||
|
|
||||||
// if (filter.limit > defaultLimit) {
|
if (filter.limit > defaultLimit) {
|
||||||
// filter.limit = defaultLimit;
|
filter.limit = defaultLimit;
|
||||||
// ctx.args.filter = filter;
|
ctx.args.filter = filter;
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
// this.afterRemote('**', async ctx => {
|
this.afterRemote('**', async ctx => {
|
||||||
// if (!this.hasFilter(ctx)) return;
|
if (!this.hasFilter(ctx)) return;
|
||||||
|
|
||||||
// const {result} = ctx;
|
const {result} = ctx;
|
||||||
// const length = Array.isArray(result) ? result.length : result ? 1 : 0;
|
const length = Array.isArray(result) ? result.length : result ? 1 : 0;
|
||||||
// if (length >= this.app.orm.selectLimit) throw new UserError('Too many records');
|
if (length >= this.app.orm.selectLimit) throw new UserError('Too many records');
|
||||||
// });
|
});
|
||||||
|
|
||||||
// Register field ACL validation
|
// Register field ACL validation
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// module.exports = async function(app) {
|
module.exports = async function(app) {
|
||||||
// if (!app.orm) {
|
if (!app.orm) {
|
||||||
// const ormConfig = await app.models.OrmConfig.findOne();
|
const ormConfig = await app.models.OrmConfig.findOne();
|
||||||
// app.orm = ormConfig;
|
app.orm = ormConfig;
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
|
|
|
@ -13,23 +13,20 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
|
||||||
const failedtickets = [];
|
const failedtickets = [];
|
||||||
for (const ticket of tickets) {
|
for (const ticket of tickets) {
|
||||||
try {
|
try {
|
||||||
await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'M');
|
await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'multiple');
|
||||||
await Self.rawSql(
|
await Self.rawSql(
|
||||||
`CALL vn.ticket_closeByTicket(?)`,
|
`CALL vn.ticket_closeByTicket(?)`,
|
||||||
[ticket.id],
|
[ticket.id],
|
||||||
{userId}
|
{userId}
|
||||||
);
|
);
|
||||||
|
|
||||||
const [invoiceOut] = await Self.rawSql(
|
const [invoiceOut] = await Self.rawSql(`
|
||||||
`
|
|
||||||
SELECT io.id, io.ref, io.serial, cny.code companyCode, io.issued
|
SELECT io.id, io.ref, io.serial, cny.code companyCode, io.issued
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
JOIN invoiceOut io ON io.ref = t.refFk
|
JOIN invoiceOut io ON io.ref = t.refFk
|
||||||
JOIN company cny ON cny.id = io.companyFk
|
JOIN company cny ON cny.id = io.companyFk
|
||||||
WHERE t.id = ?
|
WHERE t.id = ?
|
||||||
`,
|
`, [ticket.id]);
|
||||||
[ticket.id],
|
|
||||||
);
|
|
||||||
|
|
||||||
const mailOptions = {
|
const mailOptions = {
|
||||||
overrideAttachments: true,
|
overrideAttachments: true,
|
||||||
|
@ -104,17 +101,14 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Incoterms authorization
|
// Incoterms authorization
|
||||||
const [{firstOrder}] = await Self.rawSql(
|
const [{firstOrder}] = await Self.rawSql(`
|
||||||
`
|
SELECT COUNT(*) as firstOrder
|
||||||
SELECT COUNT(*) as firstOrder
|
FROM ticket t
|
||||||
FROM ticket t
|
JOIN client c ON c.id = t.clientFk
|
||||||
JOIN client c ON c.id = t.clientFk
|
WHERE t.clientFk = ?
|
||||||
WHERE t.clientFk = ?
|
AND NOT t.isDeleted
|
||||||
AND NOT t.isDeleted
|
AND c.isVies
|
||||||
AND c.isVies
|
`, [ticket.clientFk]);
|
||||||
`,
|
|
||||||
[ticket.clientFk],
|
|
||||||
);
|
|
||||||
|
|
||||||
if (firstOrder == 1) {
|
if (firstOrder == 1) {
|
||||||
const args = {
|
const args = {
|
||||||
|
@ -129,26 +123,17 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
|
||||||
const email = new Email('incoterms-authorization', args);
|
const email = new Email('incoterms-authorization', args);
|
||||||
await email.send();
|
await email.send();
|
||||||
|
|
||||||
const [sample] = await Self.rawSql(
|
const [sample] = await Self.rawSql(`
|
||||||
`SELECT id
|
SELECT id
|
||||||
FROM sample
|
FROM sample
|
||||||
WHERE code = 'incoterms-authorization'
|
WHERE code = 'incoterms-authorization'
|
||||||
`,
|
`);
|
||||||
);
|
|
||||||
|
|
||||||
await Self.rawSql(
|
await Self.rawSql(`
|
||||||
`
|
|
||||||
INSERT INTO clientSample (clientFk, typeFk, companyFk) VALUES(?, ?, ?)
|
INSERT INTO clientSample (clientFk, typeFk, companyFk) VALUES(?, ?, ?)
|
||||||
`,
|
`, [ticket.clientFk, sample.id, ticket.companyFk], {userId});
|
||||||
[ticket.clientFk, sample.id, ticket.companyFk],
|
|
||||||
{userId},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await Self.rawSql(`
|
|
||||||
INSERT INTO util.debug (variable, value)
|
|
||||||
VALUES ('invoicingTicketError', ?)
|
|
||||||
`, [ticket.id + ' - ' + error]);
|
|
||||||
// Domain not found
|
// Domain not found
|
||||||
if (error.responseCode == 450) {
|
if (error.responseCode == 450) {
|
||||||
await invalidEmail(ticket);
|
await invalidEmail(ticket);
|
||||||
|
|
|
@ -6,16 +6,6 @@
|
||||||
order="concept ASC, quantity DESC"
|
order="concept ASC, quantity DESC"
|
||||||
auto-load="true">
|
auto-load="true">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-crud-model
|
|
||||||
url="Shelvings"
|
|
||||||
data="shelvings"
|
|
||||||
auto-load="true">
|
|
||||||
</vn-crud-model>
|
|
||||||
<vn-crud-model
|
|
||||||
url="Parkings"
|
|
||||||
data="parkings"
|
|
||||||
auto-load="true">
|
|
||||||
</vn-crud-model>
|
|
||||||
<vn-data-viewer model="model">
|
<vn-data-viewer model="model">
|
||||||
<vn-card class="vn-w-lg">
|
<vn-card class="vn-w-lg">
|
||||||
<vn-table model="model">
|
<vn-table model="model">
|
||||||
|
@ -208,7 +198,7 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td expand>
|
<vn-td expand>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
data="shelvings"
|
url="Shelvings"
|
||||||
show-field="code"
|
show-field="code"
|
||||||
value-field="code"
|
value-field="code"
|
||||||
ng-model="itemShelvingSale.shelvingFk"
|
ng-model="itemShelvingSale.shelvingFk"
|
||||||
|
@ -217,7 +207,7 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td expand>
|
<vn-td expand>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
data="parkings"
|
url="Parkings"
|
||||||
show-field="code"
|
show-field="code"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
ng-model="itemShelvingSale.parkingFk"
|
ng-model="itemShelvingSale.parkingFk"
|
||||||
|
|
|
@ -7,8 +7,8 @@ SELECT m.code mandateCode,
|
||||||
sp.name province,
|
sp.name province,
|
||||||
ad.value accountDetailValue
|
ad.value accountDetailValue
|
||||||
FROM client c
|
FROM client c
|
||||||
JOIN mandate m ON m.clientFk = c.id
|
JOIN mandate m ON m.clientFk = c.id
|
||||||
JOIN mandateType mt ON mt.id = m.mandateTypeFk
|
JOIN mandateType mt ON mt.id = m.mandateTypeFk
|
||||||
JOIN supplier s ON s.id = m.companyFk
|
JOIN supplier s ON s.id = m.companyFk
|
||||||
LEFT JOIN country sc ON sc.id = s.countryFk
|
LEFT JOIN country sc ON sc.id = s.countryFk
|
||||||
LEFT JOIN province sp ON sp.id = s.provinceFk
|
LEFT JOIN province sp ON sp.id = s.provinceFk
|
||||||
|
@ -18,7 +18,7 @@ SELECT m.code mandateCode,
|
||||||
WHERE m.companyFk = ?
|
WHERE m.companyFk = ?
|
||||||
AND m.finished IS NULL
|
AND m.finished IS NULL
|
||||||
AND c.id = ?
|
AND c.id = ?
|
||||||
AND mt.name = 'CORE'
|
AND mt.code = 'CORE'
|
||||||
AND adt.description = 'Referencia Remesas'
|
AND adt.description = 'Referencia Remesas'
|
||||||
GROUP BY m.id, ad.value
|
GROUP BY m.id, ad.value
|
||||||
ORDER BY m.created DESC
|
ORDER BY m.created DESC
|
||||||
|
|
Loading…
Reference in New Issue