diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index 64d035e7c..413060d23 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -401,7 +401,7 @@ export default {
createButton: `button[type=submit]`
},
ticketDescriptor: {
- idLabelValue: 'vn-ticket-descriptor vn-label-value[label="Id"]',
+ id: 'vn-descriptor-content div.top > div',
stateLabelValue: 'vn-ticket-descriptor vn-label-value[label="State"]',
goBackToModuleIndexButton: 'vn-ticket-descriptor a[ui-sref="ticket.index"]',
moreMenu: 'vn-ticket-descriptor vn-icon-button[icon=more_vert]',
@@ -453,10 +453,11 @@ export default {
newItemFromCatalogButton: 'vn-ticket-sale vn-float-button[icon="add"]',
newItemButton: 'vn-ticket-sale vn-card vn-icon-button[icon="add_circle"]',
moreMenu: 'vn-ticket-sale vn-button[label="More"]',
- moreMenuCreateClaim: '.vn-drop-down.shown li[name="Add claim"]',
- moreMenuReserve: '.vn-drop-down.shown li[name="Mark as reserved"]',
- moreMenuUnmarkReseved: '.vn-drop-down.shown li[name="Unmark as reserved"]',
- moreMenuUpdateDiscount: '.vn-drop-down.shown li[name="Update discount"]',
+ moreMenuCreateClaim: 'vn-item[name="claim"]',
+ moreMenuReserve: 'vn-item[name="reserve"]',
+ moreMenuUnmarkReseved: 'vn-item[name="unreserve"]',
+ moreMenuUpdateDiscount: 'vn-item[name="discount"]',
+ moreMenuUpdateDiscountInput: 'vn-input-number[ng-model="$ctrl.edit.discount"] input',
transferQuantityInput: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable > span > text',
transferQuantityCell: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable',
firstSaleId: 'vn-ticket-sale vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(4) > span',
@@ -487,15 +488,16 @@ export default {
secondSaleIdInput: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-autocomplete',
secondSaleIdAutocomplete: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-autocomplete',
secondSaleQuantity: 'vn-ticket-sale vn-table vn-tr:nth-child(2) vn-input-number',
+ secondSaleQuantityCell: 'vn-ticket-sale > div > vn-card > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td-editable:nth-child(5)',
secondSaleConceptCell: 'vn-ticket-sale vn-tbody > :nth-child(2) > :nth-child(6)',
secondSaleConceptInput: 'vn-ticket-sale vn-tbody > :nth-child(2) > vn-td-editable.ng-isolate-scope.selected vn-textfield',
- totalImport: 'vn-ticket-sale > vn-vertical > vn-card > vn-vertical > vn-horizontal > vn-one > p:nth-child(3) > strong',
+ totalImport: 'vn-ticket-sale vn-one.taxes > p:nth-child(3) > strong',
selectAllSalesCheckbox: 'vn-ticket-sale vn-thead vn-check',
secondSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(2) vn-check[ng-model="sale.checked"]',
thirdSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(3) vn-check[ng-model="sale.checked"]',
deleteSaleButton: 'vn-ticket-sale vn-tool-bar > vn-button[icon="delete"]',
transferSaleButton: 'vn-ticket-sale vn-tool-bar > vn-button[icon="call_split"]',
- moveToTicketInput: '.vn-popover.shown vn-textfield[ng-model="$ctrl.transfer.ticketId"]',
+ moveToTicketInput: 'form vn-input-number[ng-model="$ctrl.transfer.ticketId"] input',
moveToTicketButton: '.vn-popover.shown vn-icon[icon="arrow_forward_ios"]',
moveToNewTicketButton: '.vn-popover.shown vn-button[label="New ticket"]',
acceptDeleteLineButton: '.vn-confirm.shown button[response=accept]',
diff --git a/modules/client/back/methods/client/canCreateTicket.js b/modules/client/back/methods/client/canCreateTicket.js
new file mode 100644
index 000000000..a47a5f6f3
--- /dev/null
+++ b/modules/client/back/methods/client/canCreateTicket.js
@@ -0,0 +1,31 @@
+module.exports = Self => {
+ Self.remoteMethod('canCreateTicket', {
+ description: 'Checks if the client is active',
+ accessType: 'READ',
+ accepts: [
+ {
+ arg: 'id',
+ type: 'string',
+ required: true,
+ description: 'The user id',
+ http: {source: 'path'}
+ }],
+ returns: {
+ type: 'boolean',
+ root: true
+ },
+ http: {
+ path: `/:id/canCreateTicket`,
+ verb: 'GET'
+ }
+ });
+
+ Self.canCreateTicket = async id => {
+ const client = await Self.app.models.Client.findById(id);
+ const canCreateTicket = client && client.isActive;
+ if (!canCreateTicket)
+ return false;
+
+ return true;
+ };
+};
diff --git a/modules/client/back/methods/client/isValidClient.js b/modules/client/back/methods/client/isValidClient.js
index 241121927..11f183563 100644
--- a/modules/client/back/methods/client/isValidClient.js
+++ b/modules/client/back/methods/client/isValidClient.js
@@ -44,7 +44,7 @@ module.exports = Self => {
return role.name === 'employee';
});
- if (!roleNames.length || isEmployee > -1 ) return false;
+ if (!roleNames.length || isEmployee > -1) return false;
return true;
};
diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js
index 056b49d01..66ab1fdc7 100644
--- a/modules/client/back/models/client.js
+++ b/modules/client/back/models/client.js
@@ -11,6 +11,7 @@ module.exports = Self => {
require('../methods/client/createWithUser')(Self);
require('../methods/client/listWorkers')(Self);
require('../methods/client/hasCustomerRole')(Self);
+ require('../methods/client/canCreateTicket')(Self);
require('../methods/client/isValidClient')(Self);
require('../methods/client/addressesPropagateRe')(Self);
require('../methods/client/getDebt')(Self);
diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js
index 43fbf62e7..2763f1bd0 100644
--- a/modules/ticket/back/methods/ticket/new.js
+++ b/modules/ticket/back/methods/ticket/new.js
@@ -82,7 +82,8 @@ module.exports = Self => {
agencyMode = await models.AgencyMode.findById(agencyModeId);
if (address.client().type().code === 'normal' && (!agencyMode || agencyMode.code != 'refund')) {
- if (!address.client().isActive)
+ const canCreateTicket = await models.Client.canCreateTicket(clientId);
+ if (!canCreateTicket)
throw new UserError(`You can't create a ticket for a inactive client`);
}
diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js
index c2257bf09..541f19615 100644
--- a/modules/ticket/back/methods/ticket/transferSales.js
+++ b/modules/ticket/back/methods/ticket/transferSales.js
@@ -55,8 +55,14 @@ module.exports = Self => {
where: {ticketFk: id}
}, options);
- if (!ticketId)
+ if (!ticketId) {
+ const ticket = await models.Ticket.findById(id);
+ const canCreateTicket = await models.Client.canCreateTicket(ticket.clientFk);
+ if (!canCreateTicket)
+ throw new UserError(`You can't create a ticket for a inactive client`);
+
ticketId = await cloneTicket(originalTicket, options);
+ }
const map = new Map();
for (const sale of originalSales)
diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html
index ae50d92f7..cc5a9ae98 100644
--- a/modules/ticket/front/sale/index.html
+++ b/modules/ticket/front/sale/index.html
@@ -417,13 +417,13 @@
Add claim
Mark as reserved
Unmark as reserved