refs #4764 validator create
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
06d1334e1f
commit
58bcad7b2d
|
@ -5,6 +5,10 @@ export const validators = {
|
||||||
if (validator.isEmpty(value ? String(value) : ''))
|
if (validator.isEmpty(value ? String(value) : ''))
|
||||||
throw new Error(_($translate, `Value can't be empty`));
|
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) => {
|
absence: ($translate, value) => {
|
||||||
if (!validator.isEmpty(value))
|
if (!validator.isEmpty(value))
|
||||||
throw new Error(_($translate, `Value should be empty`));
|
throw new Error(_($translate, `Value should be empty`));
|
||||||
|
@ -104,9 +108,8 @@ export function checkNull($translate, value, conf) {
|
||||||
export function _($translate, text, params = []) {
|
export function _($translate, text, params = []) {
|
||||||
text = $translate.instant(text);
|
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]);
|
text = text.replace('%s', params[i]);
|
||||||
}
|
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 empty: El valor debe estar vacío
|
||||||
Value should be integer: El valor debe ser entero
|
Value should be integer: El valor debe ser entero
|
||||||
Value should be a number: El valor debe ser numérico
|
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
|
Invalid value: Valor incorrecto
|
||||||
Value can't be blank: El valor no puede estar en blanco
|
Value can't be blank: El valor no puede estar en blanco
|
||||||
Value can't be null: El valor no puede ser nulo
|
Value can't be null: El valor no puede ser nulo
|
||||||
|
|
|
@ -10,11 +10,6 @@ module.exports = Self => {
|
||||||
{
|
{
|
||||||
arg: 'servicesIds',
|
arg: 'servicesIds',
|
||||||
type: ['number']
|
type: ['number']
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'withWarehouse',
|
|
||||||
type: 'boolean',
|
|
||||||
required: true
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: {
|
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 models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
let tx;
|
let tx;
|
||||||
|
@ -72,7 +67,7 @@ module.exports = Self => {
|
||||||
const [firstTicketId] = ticketsIds;
|
const [firstTicketId] = ticketsIds;
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
// 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) {
|
for (const sale of sales) {
|
||||||
const createdSale = await models.Sale.create({
|
const createdSale = await models.Sale.create({
|
||||||
|
@ -103,7 +98,7 @@ module.exports = Self => {
|
||||||
const [firstTicketId] = ticketsIds;
|
const [firstTicketId] = ticketsIds;
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
// 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) {
|
if (servicesIds && servicesIds.length > 0) {
|
||||||
|
@ -114,8 +109,8 @@ module.exports = Self => {
|
||||||
for (const service of services) {
|
for (const service of services) {
|
||||||
await models.TicketService.create({
|
await models.TicketService.create({
|
||||||
description: service.description,
|
description: service.description,
|
||||||
quantity: - service.quantity,
|
quantity: service.quantity,
|
||||||
price: service.price,
|
price: - service.price,
|
||||||
taxClassFk: service.taxClassFk,
|
taxClassFk: service.taxClassFk,
|
||||||
ticketFk: refundTicket.id,
|
ticketFk: refundTicket.id,
|
||||||
ticketServiceTypeFk: service.ticketServiceTypeFk,
|
ticketServiceTypeFk: service.ticketServiceTypeFk,
|
||||||
|
@ -147,7 +142,6 @@ module.exports = Self => {
|
||||||
addressFk: ticket.address().id,
|
addressFk: ticket.address().id,
|
||||||
agencyModeFk: refundAgencyMode.id,
|
agencyModeFk: refundAgencyMode.id,
|
||||||
nickname: ticket.address().nickname,
|
nickname: ticket.address().nickname,
|
||||||
warehouseFk: withWarehouse ? ticket.warehouseFk : null,
|
|
||||||
companyFk: ticket.companyFk,
|
companyFk: ticket.companyFk,
|
||||||
landed: now,
|
landed: now,
|
||||||
zoneFk: refoundZoneId
|
zoneFk: refoundZoneId
|
||||||
|
|
Loading…
Reference in New Issue