Merge pull request 'using hasAnyNegative: refs #6515' (!1905) from 6515-hasAnyNegativeBase into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1905 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
cdab389f22
|
@ -85,7 +85,7 @@ module.exports = Self => {
|
||||||
throw new UserError(`A ticket with an amount of zero can't be invoiced`);
|
throw new UserError(`A ticket with an amount of zero can't be invoiced`);
|
||||||
|
|
||||||
// Validates ticket nagative base
|
// Validates ticket nagative base
|
||||||
const hasNegativeBase = await getNegativeBase(ticketId, myOptions);
|
const hasNegativeBase = await getNegativeBase(maxShipped, clientId, companyId, myOptions);
|
||||||
if (hasNegativeBase && company.code == 'VNL')
|
if (hasNegativeBase && company.code == 'VNL')
|
||||||
throw new UserError(`A ticket with a negative base can't be invoiced`);
|
throw new UserError(`A ticket with a negative base can't be invoiced`);
|
||||||
} else {
|
} else {
|
||||||
|
@ -162,10 +162,13 @@ module.exports = Self => {
|
||||||
return result.invoiceable;
|
return result.invoiceable;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getNegativeBase(ticketId, options) {
|
async function getNegativeBase(maxShipped, clientId, companyId, options) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const query = 'SELECT vn.hasSomeNegativeBase(?) AS base';
|
await models.InvoiceOut.rawSql('CALL invoiceOut_exportationFromClient(?,?,?)',
|
||||||
const [result] = await models.InvoiceOut.rawSql(query, [ticketId], options);
|
[maxShipped, clientId, companyId], options
|
||||||
|
);
|
||||||
|
const query = 'SELECT vn.hasAnyNegativeBase() AS base';
|
||||||
|
const [result] = await models.InvoiceOut.rawSql(query, [], options);
|
||||||
|
|
||||||
return result.base;
|
return result.base;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue