refs #4764 validator create
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Satorres 2023-06-12 12:42:30 +02:00
parent 06d1334e1f
commit 58bcad7b2d
3 changed files with 11 additions and 13 deletions

View File

@ -5,6 +5,10 @@ export const validators = {
if (validator.isEmpty(value ? String(value) : ''))
throw new Error(_($translate, `Value can't be empty`));
},
negative: $translate => {
if (validator < 0)
throw new Error(_($translate, `Negative numbers are not allowed. Please enter a valid number.`));
},
absence: ($translate, value) => {
if (!validator.isEmpty(value))
throw new Error(_($translate, `Value should be empty`));
@ -104,9 +108,8 @@ export function checkNull($translate, value, conf) {
export function _($translate, text, params = []) {
text = $translate.instant(text);
for (let i = 0; i < params.length; i++) {
for (let i = 0; i < params.length; i++)
text = text.replace('%s', params[i]);
}
return text;
}

View File

@ -16,6 +16,7 @@ Value can't be empty: El valor no puede estar vacío
Value should be empty: El valor debe estar vacío
Value should be integer: El valor debe ser entero
Value should be a number: El valor debe ser numérico
Negative numbers are not allowed. Please enter a valid number: No se permiten números negativos. Por favor, ingrese un número válido
Invalid value: Valor incorrecto
Value can't be blank: El valor no puede estar en blanco
Value can't be null: El valor no puede ser nulo

View File

@ -10,11 +10,6 @@ module.exports = Self => {
{
arg: 'servicesIds',
type: ['number']
},
{
arg: 'withWarehouse',
type: 'boolean',
required: true
}
],
returns: {
@ -27,7 +22,7 @@ module.exports = Self => {
}
});
Self.refund = async(salesIds, servicesIds, withWarehouse, options) => {
Self.refund = async(salesIds, servicesIds, options) => {
const models = Self.app.models;
const myOptions = {};
let tx;
@ -72,7 +67,7 @@ module.exports = Self => {
const [firstTicketId] = ticketsIds;
// eslint-disable-next-line max-len
refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, withWarehouse, refoundZoneId, myOptions);
refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, myOptions);
for (const sale of sales) {
const createdSale = await models.Sale.create({
@ -103,7 +98,7 @@ module.exports = Self => {
const [firstTicketId] = ticketsIds;
// eslint-disable-next-line max-len
refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, withWarehouse, refoundZoneId, myOptions);
refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, myOptions);
}
if (servicesIds && servicesIds.length > 0) {
@ -114,8 +109,8 @@ module.exports = Self => {
for (const service of services) {
await models.TicketService.create({
description: service.description,
quantity: - service.quantity,
price: service.price,
quantity: service.quantity,
price: - service.price,
taxClassFk: service.taxClassFk,
ticketFk: refundTicket.id,
ticketServiceTypeFk: service.ticketServiceTypeFk,
@ -147,7 +142,6 @@ module.exports = Self => {
addressFk: ticket.address().id,
agencyModeFk: refundAgencyMode.id,
nickname: ticket.address().nickname,
warehouseFk: withWarehouse ? ticket.warehouseFk : null,
companyFk: ticket.companyFk,
landed: now,
zoneFk: refoundZoneId