#6321 - Negative tickets #1945
|
@ -3,11 +3,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`(
|
|||
vForce BOOLEAN,
|
||||
vDays INT,
|
||||
vId INT,
|
||||
jsegarra marked this conversation as resolved
|
||||
vLongname INT,
|
||||
vLongname VARCHAR(255),
|
||||
vSupplierFk VARCHAR(255),
|
||||
jgallego marked this conversation as resolved
Outdated
jgallego
commented
si es varchar no es un Fk, mirando el codigo deduzco que producerName si es varchar no es un Fk, mirando el codigo deduzco que producerName
jsegarra
commented
cambiado cambiado
|
||||
vColor VARCHAR(255),
|
||||
vSize INT,
|
||||
vOrigen VARCHAR(255),
|
||||
vOrigen INT,
|
||||
vLack INT,
|
||||
vWarehouseFk INT
|
||||
)
|
||||
|
@ -59,11 +59,11 @@ BEGIN
|
|||
AND ic.display
|
||||
AND it.code != 'GEN'
|
||||
AND (vId IS NULL OR i.id = vId)
|
||||
AND (vLongname IS NULL OR i.longName = vLongname)
|
||||
AND (vLongname IS NULL OR i.name = vLongname)
|
||||
AND (vSupplierFk IS NULL OR p.`name` LIKE CONCAT('%', vSupplierFk, '%'))
|
||||
jgallego
commented
estas seguro que quieren esto? si hay un productor que se llama flor, saldran tambien todos los floral, floristeria... yo creo que conviene dejar el = estas seguro que quieren esto? si hay un productor que se llama flor, saldran tambien todos los floral, floristeria... yo creo que conviene dejar el =
|
||||
AND (vColor IS NULL OR vColor = i.inkFk)
|
||||
AND (vSize IS NULL OR vSize = i.`size`)
|
||||
AND (vOrigen IS NULL OR vOrigen = w.name)
|
||||
AND (vOrigen IS NULL OR vOrigen = w.id)
|
||||
AND (vLack IS NULL OR vLack = sub.amount)
|
||||
AND (vWarehouseFk IS NULL OR vWarehouseFk = w.id)
|
||||
GROUP BY i.id, w.id
|
||||
|
|
|
@ -8,6 +8,12 @@ module.exports = Self => {
|
|||
type: 'object',
|
||||
http: {source: 'context'}
|
||||
},
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
|
@ -62,18 +68,25 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.itemLack = async(ctx, options) => {
|
||||
Self.itemLack = async(ctx, filter, options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const filterKeyOrder = ['id', 'longname', 'supplier', 'colour', 'size', 'origen', 'lack', 'warehouse'];
|
||||
|
||||
delete ctx.args.ctx;
|
||||
delete ctx.args.filter;
|
||||
delete ctx?.args?.ctx;
|
||||
|
||||
delete ctx?.args?.filter;
|
||||
if (filter)
|
||||
ctx.args = Object.assign(ctx.args ?? {}, filter);
|
||||
|
||||
let procedureParams = [true, 2];
|
||||
procedureParams.push(...filterKeyOrder.map(clave => ctx.args[clave] ?? null));
|
||||
|
||||
const procedureArgs = Array(procedureParams.length).fill('?').join(', ');
|
||||
|
||||
let query = `CALL vn.item_getLack(${procedureArgs})`;
|
||||
|
||||
const result = await Self.rawSql(query, procedureParams, myOptions);
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = Self => {
|
|||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
arg: 'itemFk',
|
||||
jsegarra marked this conversation as resolved
Outdated
jgallego
commented
si estamos en la seccion ticket, yo el argumento lo llamaria itemFk, porque a mitad codigo, id puede dar confusion a que es el id de la entidad, en este caso ticket si estamos en la seccion ticket, yo el argumento lo llamaria itemFk, porque a mitad codigo, id puede dar confusion a que es el id de la entidad, en este caso ticket
|
||||
type: 'number',
|
||||
description: 'The item id',
|
||||
},
|
||||
|
@ -19,7 +19,7 @@ module.exports = Self => {
|
|||
},
|
||||
],
|
||||
http: {
|
||||
path: `/itemLack/:id/detail`,
|
||||
path: `/itemLack/:itemFk/detail`,
|
||||
verb: 'GET',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Item Lack', () => {
|
||||
beforeAll(async() => {
|
||||
fdescribe('Item Lack', () => {
|
||||
jsegarra marked this conversation as resolved
jgallego
commented
modules/ticket/back/methods/ticket/specs/closure.spec.js dile a chatgpt que coja este arhcivo como plantilla y cambie el tuyo para dejar los beginTransaction y los rollback en un beforeEach y afterEach modules/ticket/back/methods/ticket/specs/closure.spec.js dile a chatgpt que coja este arhcivo como plantilla y cambie el tuyo para dejar los beginTransaction y los rollback en un beforeEach y afterEach
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {},
|
||||
|
@ -85,7 +85,7 @@ describe('Item Lack', () => {
|
|||
|
||||
const options = {transaction: tx};
|
||||
const filter = {
|
||||
color: 'BRW'
|
||||
colour: 'BRW'
|
||||
};
|
||||
try {
|
||||
const result = await models.Ticket.itemLack(ctx, filter, options);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Item Lack Detail', () => {
|
||||
fdescribe('Item Lack Detail', () => {
|
||||
it('should return false if id is null', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
si esto es el id del artículo, lo ponemos en primer lugar y se llama vSelf