7152-devToTest_2414 #2228

Merged
alexm merged 636 commits from 7152-devToTest_2414 into test 2024-03-28 08:26:34 +00:00
2 changed files with 356 additions and 362 deletions
Showing only changes of commit 1767ce426a - Show all commits

View File

@ -139,7 +139,7 @@
"Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*", "Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*",
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
"Distance must be lesser than 4000": "La distancia debe ser inferior a 4000", "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000",
"This ticket is deleted": "Este ticket está eliminado", "This ticket is deleted": "Este ticket está eliminado",
"Unable to clone this travel": "No ha sido posible clonar este travel", "Unable to clone this travel": "No ha sido posible clonar este travel",
"This thermograph id already exists": "La id del termógrafo ya existe", "This thermograph id already exists": "La id del termógrafo ya existe",
@ -336,6 +336,7 @@
"Incorrect pin": "Pin incorrecto", "Incorrect pin": "Pin incorrecto",
"You already have the mailAlias": "Ya tienes este alias de correo", "You already have the mailAlias": "Ya tienes este alias de correo",
"The alias cant be modified": "Este alias de correo no puede ser modificado", "The alias cant be modified": "Este alias de correo no puede ser modificado",
"No tickets to invoice": "No hay tickets para facturar",
"This ticket already has a cmr saved": "Este ticket ya tiene un cmr guardado", "This ticket already has a cmr saved": "Este ticket ya tiene un cmr guardado",
"Name should be uppercase": "El nombre debe ir en mayúscula", "Name should be uppercase": "El nombre debe ir en mayúscula",
"Bank entity must be specified": "La entidad bancaria es obligatoria", "Bank entity must be specified": "La entidad bancaria es obligatoria",
@ -343,18 +344,5 @@
"You cannot update these fields": "No puedes actualizar estos campos", "You cannot update these fields": "No puedes actualizar estos campos",
"CountryFK cannot be empty": "El país no puede estar vacío", "CountryFK cannot be empty": "El país no puede estar vacío",
"Cmr file does not exist": "El archivo del cmr no existe", "Cmr file does not exist": "El archivo del cmr no existe",
"You are not allowed to modify the alias": "No estás autorizado a modificar el alias", "We do not have availability for the selected item": "No tenemos disponible el artículo seleccionado"
"No tickets to invoice": "No hay tickets para facturar",
"This machine is already in use.": "Esta máquina ya está en uso.",
"the plate does not exist": "La máquina {{plate}} no existe",
"We do not have availability for the selected item": "No tenemos disponible el item seleccionado",
"You are already using a machine": "Ya estás usando una máquina.",
"this state does not exist": "Este estado no existe",
"The line could not be marked": "No se ha podido marcar la línea",
"The sale cannot be tracked": "La línea no puede ser rastreada",
"Shelving not valid": "Carro no válido",
"printerNotExists": "No existe la impresora",
"There are not picking tickets": "No hay tickets para sacar",
"ticketCommercial": "El ticket {{ticket}} del comercial {{salesMan}} está en preparación.(mensaje creado automáticamente)",
} }

View File

@ -1,3 +1,4 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('addSaleByCode', { Self.remoteMethodCtx('addSaleByCode', {
description: 'Add a collection', description: 'Add a collection',
@ -15,6 +16,10 @@ module.exports = Self => {
arg: 'ticketFk', arg: 'ticketFk',
type: 'number', type: 'number',
required: true required: true
}, {
arg: 'warehouseFk',
type: 'number',
required: true
}, },
], ],
@ -24,8 +29,7 @@ module.exports = Self => {
}, },
}); });
Self.addSaleByCode = async(ctx, code, quantity, ticketFk, options) => { Self.addSaleByCode = async(ctx, code, quantity, ticketFk, warehouseFk, options) => {
const models = Self.app.models;
const myOptions = {}; const myOptions = {};
let tx; let tx;
@ -38,8 +42,10 @@ module.exports = Self => {
} }
try { try {
const [{itemFk}] = await Self.rawSql('SELECT barcodeToItem(?) itemFk', [code], myOptions); const [[item]] = await Self.rawSql('CALL vn.item_getInfo(?,?)', [code, warehouseFk], myOptions);
await models.Ticket.addSale(ctx, ticketFk, itemFk, quantity, myOptions); if (!item?.available) throw new UserError('We do not have availability for the selected item');
await Self.rawSql('CALL vn.collection_addItem(?, ?, ?)', [item.id, quantity, ticketFk], myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();
} catch (e) { } catch (e) {