feat: refs #6321 fix methods
This commit is contained in:
parent
9791f3b935
commit
7fdd3d1eb8
|
@ -26,10 +26,7 @@ module.exports = Self => {
|
|||
Object.assign(myOptions, options);
|
||||
|
||||
const {where} = filter;
|
||||
const today =
|
||||
new Date().toLocaleDateString('en-US', {year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit'});
|
||||
|
||||
const query = [
|
||||
filter.itemFk,
|
||||
where.warehouseFk,
|
||||
|
@ -38,78 +35,7 @@ module.exports = Self => {
|
|||
where.scopeDays ?? 2
|
||||
];
|
||||
const [results] = await Self.rawSql('CALL vn.item_getSimilar(?, ?, ?, ?, ?)', query, myOptions);
|
||||
// return results
|
||||
return [
|
||||
{
|
||||
'id': 1,
|
||||
'longName': 'Ranged weapon longbow 50cm',
|
||||
'subName': 'Stark Industries',
|
||||
'tag5': 'Color',
|
||||
'value5': 'Brown',
|
||||
'match5': 0,
|
||||
'match6': 0,
|
||||
'match7': 0,
|
||||
'match8': 1,
|
||||
'tag6': 'Categoria',
|
||||
'value6': '+1 precission',
|
||||
'tag7': 'Tallos',
|
||||
'value7': '1',
|
||||
'tag8': null,
|
||||
'value8': null,
|
||||
'available': 20,
|
||||
'calc_id': 6,
|
||||
'counter': 0,
|
||||
'minQuantity': 1,
|
||||
'visible': null,
|
||||
'price2': 1
|
||||
},
|
||||
{
|
||||
'id': 2,
|
||||
'longName': 'Ranged weapon longbow 100cm',
|
||||
'subName': 'Stark Industries',
|
||||
'tag5': 'Color',
|
||||
'value5': 'Brown',
|
||||
'match5': 0,
|
||||
'match6': 1,
|
||||
'match7': 0,
|
||||
'match8': 1,
|
||||
'tag6': 'Categoria',
|
||||
'value6': '+1 precission',
|
||||
'tag7': 'Tallos',
|
||||
'value7': '1',
|
||||
'tag8': null,
|
||||
'value8': null,
|
||||
'available': 50,
|
||||
'calc_id': 6,
|
||||
'counter': 1,
|
||||
'minQuantity': 5,
|
||||
'visible': null,
|
||||
'price2': 10
|
||||
},
|
||||
{
|
||||
'id': 3,
|
||||
'longName': 'Ranged weapon longbow 200cm',
|
||||
'subName': 'Stark Industries',
|
||||
'tag5': 'Color',
|
||||
'value5': 'Brown',
|
||||
'match5': 1,
|
||||
'match6': 1,
|
||||
'match7': 1,
|
||||
'match8': 1,
|
||||
'tag6': 'Categoria',
|
||||
'value6': '+1 precission',
|
||||
'tag7': 'Tallos',
|
||||
'value7': '1',
|
||||
'tag8': null,
|
||||
'value8': null,
|
||||
'available': 185,
|
||||
'calc_id': 6,
|
||||
'counter': 10,
|
||||
'minQuantity': 10,
|
||||
'visible': null,
|
||||
'price2': 100
|
||||
}
|
||||
|
||||
];
|
||||
return results;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,21 +3,22 @@ module.exports = Self => {
|
|||
Self.remoteMethodCtx('replaceItem', {
|
||||
description: 'Replace item from sale',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'saleFk',
|
||||
type: 'number',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'substitutionFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'quantity',
|
||||
type: 'number',
|
||||
required: true
|
||||
}
|
||||
accepts: [
|
||||
{
|
||||
arg: 'saleFk',
|
||||
type: 'number',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'substitutionFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'quantity',
|
||||
type: 'number',
|
||||
required: true
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: 'object',
|
||||
|
@ -36,8 +37,6 @@ module.exports = Self => {
|
|||
|
||||
const models = Self.app.models;
|
||||
|
||||
// const {_saleFk, _substitutionFk, _quantity} = ctx.args;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
|
@ -47,25 +46,46 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
try {
|
||||
const _replaceItem = {
|
||||
const replaceItemQuery = {
|
||||
sql: 'CALL sale_replaceItem(?,?,?)',
|
||||
query: [saleFk, substitutionFk, quantity]
|
||||
};
|
||||
const resultReplaceItem = await Self.rawSql(_replaceItem.sql, _replaceItem.query, myOptions);
|
||||
const resultReplaceItem = await Self.rawSql(replaceItemQuery.sql, replaceItemQuery.query, myOptions);
|
||||
const sale = await models.Sale.findById(saleFk, {
|
||||
fields: ['id', 'ticketFk', 'itemFk', 'quantity', 'price'],
|
||||
include: [
|
||||
{
|
||||
relation: 'ticket',
|
||||
scope: {
|
||||
fields: ['id']
|
||||
},
|
||||
}, {
|
||||
relation: 'item',
|
||||
scope: {
|
||||
fields: ['id', 'name', 'longName']
|
||||
}
|
||||
}
|
||||
]
|
||||
}, myOptions);
|
||||
|
||||
const _salesPerson = {
|
||||
const salesPersonQuery = {
|
||||
sql: 'SELECT vn.client_getSalesPersonByTicket(?)',
|
||||
query: [saleFk.ticket.id]
|
||||
query: [sale.ticketFk]
|
||||
};
|
||||
const salesPerson = await Self.rawSql(_salesPerson.query, _salesPerson.sql, myOptions);
|
||||
|
||||
const salesPerson = await Self.rawSql(salesPersonQuery.sql, salesPersonQuery.query, myOptions);
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const substitution = await models.Item.findById(substitutionFk, {
|
||||
fields: ['id', 'name', 'longName']
|
||||
}, myOptions);
|
||||
const message = $t('negativeReplaced', {
|
||||
oldItemId: itemFk,
|
||||
oldItemUrl: `${url}item/${itemFk}/summary`,
|
||||
newItemId: substitutionFk,
|
||||
newItemUrl: `${url}item/${substitutionFk}/summary`,
|
||||
ticketId: ticketFk,
|
||||
ticketUrl: `${url}ticket/${ticketFk}/sale`,
|
||||
oldItemId: sale.itemFk,
|
||||
oldItem: sale.item().longName,
|
||||
oldItemUrl: `${url}item/${sale.itemFk}/summary`,
|
||||
newItemId: substitution.id,
|
||||
newItem: substitution.longName,
|
||||
newItemUrl: `${url}item/${substitution.id}/summary`,
|
||||
ticketId: sale.ticketFk,
|
||||
ticketUrl: `${url}ticket/${sale.ticketFk}/sale`
|
||||
});
|
||||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ const {ParameterizedSQL} = require('loopback-connector');
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('itemLackDetail', {
|
||||
description: 'Retrieve detail from ticket',
|
||||
description: 'Retrieve detail from ticket as negative',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
|
|
|
@ -90,7 +90,7 @@ describe('Item Lack', () => {
|
|||
try {
|
||||
const result = await models.Ticket.itemLack(ctx, filter, options);
|
||||
|
||||
expect(result.length).toEqual(0);
|
||||
expect(result.length).toEqual(1);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('split', {
|
||||
description: 'Split ticket',
|
||||
description: 'Split ticket with custom date',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
{
|
||||
|
@ -8,6 +8,11 @@ module.exports = Self => {
|
|||
type: 'Object',
|
||||
required: true,
|
||||
http: {source: 'body'}
|
||||
},
|
||||
{
|
||||
arg: 'date',
|
||||
type: 'date',
|
||||
required: true,
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
|
|
@ -33,8 +33,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.transferSales = async(ctx, id, ticketId, sales,
|
||||
options) => {
|
||||
Self.transferSales = async(ctx, id, ticketId, sales, options) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const models = Self.app.models;
|
||||
const myOptions = {userId};
|
||||
|
|
Loading…
Reference in New Issue