{{::address.nickname}} - #{{::address.id}}
{{::address.street}}
- {{::address.postalCode}} -
- {{::address.city}},
- {{::address.province.name}}
+ {{::address.postalCode}} -
+ {{::address.city}},
+ {{::address.province.name}},
+ {{::address.province.country.country}}
{{::address.phone}},
@@ -72,7 +73,7 @@
class="vn-hide-narrow vn-px-md border-solid-left"
style="height: 6em; overflow: auto;">
- {{::observation.observationType.description}}:
+ {{::observation.observationType.description}}:
{{::observation.description}}
diff --git a/modules/client/front/address/index/index.js b/modules/client/front/address/index/index.js
index 608bbbc202..4bad9d4c84 100644
--- a/modules/client/front/address/index/index.js
+++ b/modules/client/front/address/index/index.js
@@ -33,7 +33,13 @@ class Controller extends Section {
}, {
relation: 'province',
scope: {
- fields: ['id', 'name']
+ fields: ['id', 'name', 'countryFk'],
+ include: {
+ relation: 'country',
+ scope: {
+ fields: ['id', 'country']
+ }
+ }
}
}
]
diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js
index 661b656dfe..f8eb4d1439 100644
--- a/modules/ticket/back/methods/sale/clone.js
+++ b/modules/ticket/back/methods/sale/clone.js
@@ -14,17 +14,30 @@ module.exports = Self => {
}
try {
- const salesFilter = {
- where: {id: {inq: salesIds}},
- include: {
- relation: 'components',
- scope: {
- fields: ['saleFk', 'componentFk', 'value']
+ let sales;
+ let services;
+
+ if (salesIds && salesIds.length) {
+ sales = await models.Sale.find({
+ where: {id: {inq: salesIds}},
+ include: {
+ relation: 'components',
+ scope: {
+ fields: ['saleFk', 'componentFk', 'value']
+ }
}
- }
- };
- const sales = await models.Sale.find(salesFilter, myOptions);
- let ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))];
+ }, myOptions);
+ }
+
+ if (servicesIds && servicesIds.length) {
+ services = await models.TicketService.find({
+ where: {id: {inq: servicesIds}}
+ }, myOptions);
+ }
+
+ let ticketsIds = sales ?
+ [...new Set(sales.map(sale => sale.ticketFk))] :
+ [...new Set(services.map(service => service.ticketFk))];
const mappedTickets = new Map();
@@ -39,32 +52,28 @@ module.exports = Self => {
newTickets.push(newTicket);
mappedTickets.set(ticketId, newTicket.id);
}
+ if (sales) {
+ for (const sale of sales) {
+ const newTicketId = mappedTickets.get(sale.ticketFk);
- for (const sale of sales) {
- const newTicketId = mappedTickets.get(sale.ticketFk);
+ const createdSale = await models.Sale.create({
+ ticketFk: newTicketId,
+ itemFk: sale.itemFk,
+ quantity: negative ? - sale.quantity : sale.quantity,
+ concept: sale.concept,
+ price: sale.price,
+ discount: sale.discount,
+ }, myOptions);
- const createdSale = await models.Sale.create({
- ticketFk: newTicketId,
- itemFk: sale.itemFk,
- quantity: negative ? - sale.quantity : sale.quantity,
- concept: sale.concept,
- price: sale.price,
- discount: sale.discount,
- }, myOptions);
+ const components = sale.components();
+ for (const component of components)
+ component.saleFk = createdSale.id;
- const components = sale.components();
- for (const component of components)
- component.saleFk = createdSale.id;
-
- await models.SaleComponent.create(components, myOptions);
+ await models.SaleComponent.create(components, myOptions);
+ }
}
- if (servicesIds && servicesIds.length) {
- const servicesFilter = {
- where: {id: {inq: servicesIds}}
- };
- const services = await models.TicketService.find(servicesFilter, myOptions);
-
+ if (services) {
for (const service of services) {
const newTicketId = mappedTickets.get(service.ticketFk);
diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js
index a19bb3df81..19a8dfbb0b 100644
--- a/modules/ticket/back/methods/sale/refund.js
+++ b/modules/ticket/back/methods/sale/refund.js
@@ -6,7 +6,6 @@ module.exports = Self => {
{
arg: 'salesIds',
type: ['number'],
- required: true
},
{
arg: 'servicesIds',
diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js
index 60f77e90c5..ab5e1e281b 100644
--- a/modules/ticket/back/methods/sale/specs/refund.spec.js
+++ b/modules/ticket/back/methods/sale/specs/refund.spec.js
@@ -44,24 +44,7 @@ describe('Sale refund()', () => {
const tickets = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, options);
- const refundedTicket = await models.Ticket.findOne({
- where: {
- id: tickets[0].id
- },
- include: [
- {
- relation: 'ticketSales',
- scope: {
- include: {
- relation: 'components'
- }
- }
- },
- {
- relation: 'ticketServices',
- }
- ]
- }, options);
+ const refundedTicket = await getTicketRefund(tickets[0].id, options);
const ticketsAfter = await models.Ticket.find({}, options);
const salesLength = refundedTicket.ticketSales().length;
const componentsLength = refundedTicket.ticketSales()[0].components().length;
@@ -77,4 +60,42 @@ describe('Sale refund()', () => {
throw e;
}
});
+
+ it('should create a ticket without sales', async() => {
+ const servicesIds = [4];
+ const tx = await models.Sale.beginTransaction({});
+ const options = {transaction: tx};
+ try {
+ const tickets = await models.Sale.refund(ctx, null, servicesIds, withWarehouse, options);
+ const refundedTicket = await getTicketRefund(tickets[0].id, options);
+
+ expect(refundedTicket).toBeDefined();
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
});
+
+async function getTicketRefund(id, options) {
+ return models.Ticket.findOne({
+ where: {
+ id
+ },
+ include: [
+ {
+ relation: 'ticketSales',
+ scope: {
+ include: {
+ relation: 'components'
+ }
+ }
+ },
+ {
+ relation: 'ticketServices',
+ }
+ ]
+ }, options);
+}
diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js
index 3acd68cfb1..0786b72c87 100644
--- a/modules/ticket/back/methods/ticket/componentUpdate.js
+++ b/modules/ticket/back/methods/ticket/componentUpdate.js
@@ -74,8 +74,8 @@ module.exports = Self => {
},
{
arg: 'option',
- type: 'number',
- description: 'Action id'
+ type: 'string',
+ description: 'Action code'
},
{
arg: 'isWithoutNegatives',
diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js
index 40be4161c1..c9a13b4ccb 100644
--- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js
@@ -60,7 +60,7 @@ describe('ticket componentUpdate()', () => {
shipped: today,
landed: tomorrow,
isDeleted: false,
- option: 1,
+ option: 'renewPrices',
isWithoutNegatives: false
};
@@ -110,7 +110,7 @@ describe('ticket componentUpdate()', () => {
shipped: today,
landed: tomorrow,
isDeleted: false,
- option: 1,
+ option: 'renewPrices',
isWithoutNegatives: false
};
@@ -176,7 +176,7 @@ describe('ticket componentUpdate()', () => {
shipped: newDate,
landed: tomorrow,
isDeleted: false,
- option: 1,
+ option: 'renewPrices',
isWithoutNegatives: true
};
@@ -235,7 +235,7 @@ describe('ticket componentUpdate()', () => {
shipped: newDate,
landed: tomorrow,
isDeleted: false,
- option: 1,
+ option: 'renewPrices',
isWithoutNegatives: false,
keepPrice: true
};
@@ -288,7 +288,7 @@ describe('ticket componentUpdate()', () => {
shipped: newDate,
landed: tomorrow,
isDeleted: false,
- option: 1,
+ option: 'renewPrices',
isWithoutNegatives: false,
keepPrice: false
};
diff --git a/modules/ticket/front/basic-data/step-two/index.html b/modules/ticket/front/basic-data/step-two/index.html
index fc57a354a2..5289711545 100644
--- a/modules/ticket/front/basic-data/step-two/index.html
+++ b/modules/ticket/front/basic-data/step-two/index.html
@@ -76,7 +76,7 @@
+ val={{::action.code}}>
diff --git a/modules/ticket/front/basic-data/step-two/index.js b/modules/ticket/front/basic-data/step-two/index.js
index 8c8a3a079e..9717d1ea42 100644
--- a/modules/ticket/front/basic-data/step-two/index.js
+++ b/modules/ticket/front/basic-data/step-two/index.js
@@ -25,12 +25,7 @@ class Controller extends Component {
loadDefaultTicketAction() {
const isSalesAssistant = this.aclService.hasAny(['salesAssistant']);
- const defaultOption = isSalesAssistant ? 'turnInMana' : 'changePrice';
- const filter = {where: {code: defaultOption}};
-
- this.$http.get(`TicketUpdateActions`, {filter}).then(response => {
- return this.ticket.option = response.data[0].id;
- });
+ this.ticket.option = isSalesAssistant ? 'mana' : 'buyerDiscount';
}
onStepChange() {
@@ -112,7 +107,7 @@ class Controller extends Component {
shipped: this.ticket.shipped,
landed: this.ticket.landed,
isDeleted: this.ticket.isDeleted,
- option: parseInt(this.ticket.option),
+ option: this.ticket.option,
isWithoutNegatives: this.ticket.withoutNegatives,
withWarningAccept: this.ticket.withWarningAccept,
keepPrice: false
diff --git a/modules/worker/back/methods/worker-time-control/updateTimeEntry.js b/modules/worker/back/methods/worker-time-control/updateTimeEntry.js
index 8231be7bbf..e9d35f8803 100644
--- a/modules/worker/back/methods/worker-time-control/updateTimeEntry.js
+++ b/modules/worker/back/methods/worker-time-control/updateTimeEntry.js
@@ -3,7 +3,7 @@ const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('updateTimeEntry', {
description: 'Updates a time entry for a worker if the user role is above the worker',
- accessType: 'READ',
+ accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
diff --git a/package-lock.json b/package-lock.json
index 36e11dc8fe..4a8aa4fb88 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "salix-back",
- "version": "24.04.01",
+ "version": "24.06.01",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "salix-back",
- "version": "24.04.01",
+ "version": "24.06.01",
"license": "GPL-3.0",
"dependencies": {
"axios": "^1.2.2",
diff --git a/package.json b/package.json
index f13c441628..ba8006e8a2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "salix-back",
- "version": "24.04.01",
+ "version": "24.06.01",
"author": "Verdnatura Levante SL",
"description": "Salix backend",
"license": "GPL-3.0",