feat: refs #6321 changes
This commit is contained in:
parent
bd54eacda1
commit
1a0992da78
|
@ -254,5 +254,7 @@
|
||||||
"Sales already moved": "Sales already moved",
|
"Sales already moved": "Sales already moved",
|
||||||
"Holidays to past days not available": "Holidays to past days not available",
|
"Holidays to past days not available": "Holidays to past days not available",
|
||||||
"Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}",
|
"Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}",
|
||||||
"Ticket has been delivered out of order": "The ticket {{ticket}} {{{fullUrl}}} has been delivered out of order."
|
"Ticket has been delivered out of order": "The ticket {{ticket}} {{{fullUrl}}} has been delivered out of order.",
|
||||||
}
|
"negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -396,5 +396,6 @@
|
||||||
"There are tickets to be invoiced": "La zona tiene tickets por facturar",
|
"There are tickets to be invoiced": "La zona tiene tickets por facturar",
|
||||||
"Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}",
|
"Incorrect delivery order alert on route": "Alerta de orden de entrega incorrecta en ruta: {{ route }} zona: {{ zone }}",
|
||||||
"Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sigo entregado en su orden.",
|
"Ticket has been delivered out of order": "El ticket {{ticket}} {{{fullUrl}}} no ha sigo entregado en su orden.",
|
||||||
"Price cannot be blank": "El precio no puede estar en blanco"
|
"Price cannot be blank": "El precio no puede estar en blanco",
|
||||||
}
|
"negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})"
|
||||||
|
}
|
||||||
|
|
|
@ -368,5 +368,7 @@
|
||||||
"ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}",
|
"ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}",
|
||||||
"The web user's email already exists": "L'email de l'internaute existe déjà",
|
"The web user's email already exists": "L'email de l'internaute existe déjà",
|
||||||
"Incorrect delivery order alert on route": "Alerte de bon de livraison incorrect sur l'itinéraire: {{ route }} zone : {{ zone }}",
|
"Incorrect delivery order alert on route": "Alerte de bon de livraison incorrect sur l'itinéraire: {{ route }} zone : {{ zone }}",
|
||||||
"Ticket has been delivered out of order": "Le ticket {{ticket}} {{{fullUrl}}} a été livré hors ordre."
|
"Ticket has been delivered out of order": "Le ticket {{ticket}} {{{fullUrl}}} a été livré hors ordre.",
|
||||||
}
|
"negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -367,5 +367,7 @@
|
||||||
"ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}",
|
"ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}",
|
||||||
"The web user's email already exists": "O e-mail do utilizador da web já existe.",
|
"The web user's email already exists": "O e-mail do utilizador da web já existe.",
|
||||||
"Incorrect delivery order alert on route": "Alerta de ordem de entrega incorreta na rota: {{ route }} zona: {{ zone }}",
|
"Incorrect delivery order alert on route": "Alerta de ordem de entrega incorreta na rota: {{ route }} zona: {{ zone }}",
|
||||||
"Ticket has been delivered out of order": "O ticket {{ticket}} {{{fullUrl}}} foi entregue fora de ordem."
|
"Ticket has been delivered out of order": "O ticket {{ticket}} {{{fullUrl}}} foi entregue fora de ordem.",
|
||||||
}
|
"negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -47,21 +47,29 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const _replaceItem = {sql: 'CALL sale_replaceItem(?,?,?)', query: [saleFk, substitutionFk, quantity]};
|
const _replaceItem = {
|
||||||
const result = await Self.rawSql(_replaceItem.sql, _replaceItem.query, myOptions);
|
sql: 'CALL sale_replaceItem(?,?,?)',
|
||||||
const _salesPerson = {sql: 'SELECT vn.client_getSalesPersonByTicket(?)', query: [saleFk.ticket.id]};
|
query: [saleFk, substitutionFk, quantity]
|
||||||
|
};
|
||||||
|
const resultReplaceItem = await Self.rawSql(_replaceItem.sql, _replaceItem.query, myOptions);
|
||||||
|
|
||||||
|
const _salesPerson = {
|
||||||
|
sql: 'SELECT vn.client_getSalesPersonByTicket(?)',
|
||||||
|
query: [saleFk.ticket.id]
|
||||||
|
};
|
||||||
const salesPerson = await Self.rawSql(_salesPerson.query, _salesPerson.sql, myOptions);
|
const salesPerson = await Self.rawSql(_salesPerson.query, _salesPerson.sql, myOptions);
|
||||||
|
|
||||||
const message = $t('negativeReplaced', {
|
const message = $t('negativeReplaced', {
|
||||||
old: itemFk,
|
oldItemId: itemFk,
|
||||||
oldUrl: `${url}item/${itemFk}/summary`,
|
oldItemUrl: `${url}item/${itemFk}/summary`,
|
||||||
new: itemFk,
|
newItemId: substitutionFk,
|
||||||
newUrl: `${url}item/${itemFk}/summary`,
|
newItemUrl: `${url}item/${substitutionFk}/summary`,
|
||||||
ticket: ticketFk,
|
ticketId: ticketFk,
|
||||||
ticketUrl: `${url}ticket/${ticketFk}/sale`,
|
ticketUrl: `${url}ticket/${ticketFk}/sale`,
|
||||||
});
|
});
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
|
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
|
||||||
|
|
||||||
return result;
|
return resultReplaceItem;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (tx) await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -79,7 +79,7 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const filterKeyOrder = ['days', 'itemFk', 'longname', 'supplier', 'colour', 'size', 'origen', 'lack', 'warehouseFk'];
|
const filterKeyOrder = ['days', 'itemFk', 'longname', 'supplier', 'colour', 'size', 'originFk', 'lack', 'warehouseFk'];
|
||||||
|
|
||||||
delete ctx?.args?.ctx;
|
delete ctx?.args?.ctx;
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,6 @@ module.exports = Self => {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'The item id',
|
description: 'The item id',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
arg: 'warehouseFk',
|
|
||||||
type: 'number',
|
|
||||||
description: 'The warehouse id',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
arg: 'filter',
|
arg: 'filter',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
@ -35,7 +30,7 @@ module.exports = Self => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.itemLackDetail = async(itemFk, warehouseFk, filter, options) => {
|
Self.itemLackDetail = async(itemFk, filter, options) => {
|
||||||
const conn = Self.dataSource.connector;
|
const conn = Self.dataSource.connector;
|
||||||
|
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
@ -91,8 +86,8 @@ module.exports = Self => {
|
||||||
WHERE warehouseFk = ?
|
WHERE warehouseFk = ?
|
||||||
AND s.itemFk = ?
|
AND s.itemFk = ?
|
||||||
AND s.quantity <> 0
|
AND s.quantity <> 0
|
||||||
AND t.shipped >= CURDATE()
|
AND t.shipped >= util.VN_CURDATE()
|
||||||
AND t.shipped < DATE_ADD(CURDATE(), INTERVAL ? DAY)
|
AND t.shipped < DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY)
|
||||||
AND sgd.saleFk IS NULL
|
AND sgd.saleFk IS NULL
|
||||||
AND (al.code IN ('FREE', 'ON_PREVIOUS') OR al.code IS NULL)
|
AND (al.code IN ('FREE', 'ON_PREVIOUS') OR al.code IS NULL)
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
@ -131,15 +126,15 @@ module.exports = Self => {
|
||||||
WHERE ot.code = 'substitution'
|
WHERE ot.code = 'substitution'
|
||||||
GROUP BY co.clientFk
|
GROUP BY co.clientFk
|
||||||
) AS substitution ON substitution.clientFk = c.id
|
) AS substitution ON substitution.clientFk = c.id
|
||||||
WHERE r.shipment >= CURDATE()
|
WHERE r.shipment >= util.VN_CURDATE()
|
||||||
AND r.shipment < DATE_ADD(CURDATE(), INTERVAL ? DAY)
|
|
||||||
AND r.warehouseFk = ?
|
AND r.warehouseFk = ?
|
||||||
AND r.created >= STR_TO_DATE(CURDATE(), '%Y-%m-%d %H:%i:%s')
|
AND r.shipment < DATE_ADD(util.VN_CURDATE(), INTERVAL ? DAY)
|
||||||
|
AND r.created >= STR_TO_DATE(util.VN_CURDATE(), '%Y-%m-%d %H:%i:%s')
|
||||||
AND NOT o.confirmed
|
AND NOT o.confirmed
|
||||||
AND r.itemFk = ?
|
AND r.itemFk = ?
|
||||||
AND r.amount <> 0
|
AND r.amount <> 0
|
||||||
ORDER BY hasToIgnore, isBasket;`,
|
ORDER BY hasToIgnore, isBasket;`,
|
||||||
[itemFk, warehouseFk, 2, 2, warehouseFk, itemFk]);
|
[filter.where.warehouseFk, itemFk, 2, filter.where.warehouseFk, 2, itemFk]);
|
||||||
|
|
||||||
if (filter.where.stateFk) {
|
if (filter.where.stateFk) {
|
||||||
stmt.merge({
|
stmt.merge({
|
||||||
|
|
|
@ -31,12 +31,12 @@ describe('Item Lack', () => {
|
||||||
|
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const filter = {
|
const filter = {
|
||||||
id: 88
|
itemFk: 88
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const result = await models.Ticket.itemLack(ctx, filter, options);
|
const result = await models.Ticket.itemLack(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(2);
|
expect(result.length).toEqual(1);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -49,7 +49,7 @@ describe('Item Lack', () => {
|
||||||
|
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const filter = {
|
const filter = {
|
||||||
longname: 'Lack negative'
|
longname: 'Ranged weapon pistol 9mm'
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const result = await models.Ticket.itemLack(ctx, filter, options);
|
const result = await models.Ticket.itemLack(ctx, filter, options);
|
||||||
|
@ -62,23 +62,23 @@ describe('Item Lack', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
xit('should return data with filter.name', async() => {
|
// it('should return data with filter.name', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
// const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
const options = {transaction: tx};
|
// const options = {transaction: tx};
|
||||||
const filter = {
|
// const filter = {
|
||||||
name: 1
|
// name: 1
|
||||||
};
|
// };
|
||||||
try {
|
// try {
|
||||||
const result = await models.Ticket.itemLack(ctx, filter, options);
|
// const result = await models.Ticket.itemLack(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
// expect(result.length).toEqual(1);
|
||||||
await tx.rollback();
|
// await tx.rollback();
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
await tx.rollback();
|
// await tx.rollback();
|
||||||
throw e;
|
// throw e;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
it('should return data with filter.color', async() => {
|
it('should return data with filter.color', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
@ -90,7 +90,7 @@ describe('Item Lack', () => {
|
||||||
try {
|
try {
|
||||||
const result = await models.Ticket.itemLack(ctx, filter, options);
|
const result = await models.Ticket.itemLack(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(0);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -103,7 +103,7 @@ describe('Item Lack', () => {
|
||||||
|
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const filter = {
|
const filter = {
|
||||||
origen: 1
|
originFk: 1
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const result = await models.Ticket.itemLack(ctx, filter, options);
|
const result = await models.Ticket.itemLack(ctx, filter, options);
|
||||||
|
@ -121,7 +121,7 @@ describe('Item Lack', () => {
|
||||||
|
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const filter = {
|
const filter = {
|
||||||
size: '200'
|
size: '15'
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const result = await models.Ticket.itemLack(ctx, filter, options);
|
const result = await models.Ticket.itemLack(ctx, filter, options);
|
||||||
|
@ -139,7 +139,7 @@ describe('Item Lack', () => {
|
||||||
|
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const filter = {
|
const filter = {
|
||||||
lack: '-155'
|
lack: '-15'
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const result = await models.Ticket.itemLack(ctx, filter, options);
|
const result = await models.Ticket.itemLack(ctx, filter, options);
|
||||||
|
|
|
@ -8,7 +8,9 @@ describe('Item Lack Detail', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const id = null;
|
const id = null;
|
||||||
|
|
||||||
const result = await models.Ticket.itemLackDetail(id, options);
|
const filter = {where: {id: 0}};
|
||||||
|
const warehouseFk = 60;
|
||||||
|
const result = await models.Ticket.itemLackDetail(id, warehouseFk, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(0);
|
expect(result.length).toEqual(0);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -24,7 +26,9 @@ describe('Item Lack Detail', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const id = 1167;
|
const id = 1167;
|
||||||
const result = await models.Ticket.itemLackDetail(id, options);
|
const filter = {where: {id: 0}};
|
||||||
|
const warehouseFk = 60;
|
||||||
|
const result = await models.Ticket.itemLackDetail(id, warehouseFk, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(0);
|
expect(result.length).toEqual(0);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
@ -40,7 +44,9 @@ describe('Item Lack Detail', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const id = 0;
|
const id = 0;
|
||||||
const result = await models.Ticket.itemLackDetail(id, options);
|
const filter = {where: {id: 0}};
|
||||||
|
const warehouseFk = 60;
|
||||||
|
const result = await models.Ticket.itemLackDetail(id, warehouseFk, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(0);
|
expect(result.length).toEqual(0);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('Split', () => {
|
fdescribe('Split', () => {
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
ctx = {
|
ctx = {
|
||||||
req: {
|
req: {
|
||||||
|
@ -44,7 +44,7 @@ describe('Split', () => {
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
expect(result[0].ticket).toEqual(8);
|
expect(result[0].ticket).toEqual(8);
|
||||||
expect(result[0].status).toEqual('error');
|
expect(result[0].status).toEqual('error');
|
||||||
expect(result[0].message).toEqual('This ticket is not editable.');
|
expect(result[0].message).toEqual('Can\'t transfer claimed sales');
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -43,8 +43,8 @@ module.exports = Self => {
|
||||||
const {code} = await models.State.findById(params.stateFk, {fields: ['code']}, myOptions);
|
const {code} = await models.State.findById(params.stateFk, {fields: ['code']}, myOptions);
|
||||||
params.code = code;
|
params.code = code;
|
||||||
} else {
|
} else {
|
||||||
const {id} = await models.State.findOne({where: {code: params.code}}, myOptions);
|
const state = await models.State.findOne({where: {id: params.code}}, myOptions);
|
||||||
params.stateFk = id;
|
params.stateFk = state.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!params.userFk) {
|
if (!params.userFk) {
|
||||||
|
|
Loading…
Reference in New Issue