From 483966501a2b6e46ade7e13d79c334df1fa9d565 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 5 Dec 2024 08:31:09 +0100 Subject: [PATCH] fix: refs #7031 fix vnPrice --- db/versions/11376-pinkBamboo/00-firstScript.sql | 2 +- loopback/locale/en.json | 7 ++++--- loopback/locale/es.json | 10 +++++----- modules/zone/back/models/zone.js | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/db/versions/11376-pinkBamboo/00-firstScript.sql b/db/versions/11376-pinkBamboo/00-firstScript.sql index 607a22b4d..0c1e71a2f 100644 --- a/db/versions/11376-pinkBamboo/00-firstScript.sql +++ b/db/versions/11376-pinkBamboo/00-firstScript.sql @@ -1,2 +1,2 @@ -ALTER TABLE `zone` MODIFY COLUMN `price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 CHECK (`price` > 0); +ALTER TABLE vn.`zone` MODIFY COLUMN `price` DECIMAL(10,2); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ff0281d4a..af07b29fa 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -246,6 +246,7 @@ "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}", "The raid information is not correct": "The raid information is not correct", "Payment method is required": "Payment method is required", - "Sales already moved": "Sales already moved", - "There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first" -} + "Sales already moved": "Sales already moved", + "There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first", + "Price cannot be blank": "Price cannot be blank" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 1eb953d89..37572de03 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,8 +388,8 @@ "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada", "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", "The web user's email already exists": "El correo del usuario web ya existe", - "Sales already moved": "Ya han sido transferidas", - "The raid information is not correct": "La información de la redada no es correcta", - "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero" -} - + "Sales already moved": "Ya han sido transferidas", + "The raid information is not correct": "La información de la redada no es correcta", + "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", + "Price cannot be blank": "Price cannot be blank" +} \ No newline at end of file diff --git a/modules/zone/back/models/zone.js b/modules/zone/back/models/zone.js index 6d5a6cdca..7b5cb4301 100644 --- a/modules/zone/back/models/zone.js +++ b/modules/zone/back/models/zone.js @@ -14,4 +14,18 @@ module.exports = Self => { Self.validatesPresenceOf('agencyModeFk', { message: `Agency cannot be blank` }); + + Self.validatesPresenceOf('price', { + message: 'Price cannot be blank' + }); + Self.validateAsync('price', priceIsValid, { + message: 'Price must be greater than 0' + }); + + async function priceIsValid(err, done) { + if (this.price <= 0) + err(); + + done(); + } };