diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 311e9deff..5c9b4011f 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -501,16 +501,17 @@ export default { }, ticketService: { addServiceButton: 'vn-ticket-service vn-icon-button[vn-tooltip="Add service"] > button', - firstAddDescriptionButton: 'vn-ticket-service vn-icon-button[vn-tooltip="New service type"]', - firstDescriptionAutocomplete: 'vn-ticket-service vn-autocomplete[ng-model="service.description"]', + firstAddServiceTypeButton: 'vn-ticket-service vn-icon-button[vn-tooltip="New service type"]', + firstServiceTypeAutocomplete: 'vn-ticket-service vn-autocomplete[ng-model="service.ticketServiceTypeFk"]', firstQuantityInput: 'vn-ticket-service vn-input-number[label="Quantity"] input', firstPriceInput: 'vn-ticket-service vn-input-number[label="Price"] input', firstVatTypeAutocomplete: 'vn-ticket-service vn-autocomplete[label="Tax class"]', fistDeleteServiceButton: 'vn-ticket-service form vn-horizontal:nth-child(1) vn-icon-button[icon="delete"]', - newDescriptionInput: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newServiceType.name"] input', + newServiceTypeNameInput: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newServiceType.name"] input', + newServiceTypeExpenseAutocomplete: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.newServiceType.expenseFk"]', serviceLine: 'vn-ticket-service > form > vn-card > vn-one:nth-child(2) > vn-horizontal', saveServiceButton: `button[type=submit]`, - saveDescriptionButton: '.vn-dialog.shown tpl-buttons > button' + saveServiceTypeButton: '.vn-dialog.shown tpl-buttons > button' }, createStateView: { stateAutocomplete: 'vn-autocomplete[ng-model="$ctrl.stateFk"]', diff --git a/e2e/paths/05-ticket-module/13_services.spec.js b/e2e/paths/05-ticket-module/13_services.spec.js index 01da91f1b..3ad674950 100644 --- a/e2e/paths/05-ticket-module/13_services.spec.js +++ b/e2e/paths/05-ticket-module/13_services.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Ticket services path', () => { +fdescribe('Ticket services path', () => { const nightmare = createNightmare(); const invoicedTicketId = 1; @@ -15,10 +15,10 @@ describe('Ticket services path', () => { it('should find the add descripton button disabled for this user role', async() => { const result = await nightmare - .waitForClassPresent(selectors.ticketService.firstAddDescriptionButton, 'disabled') + .waitForClassPresent(selectors.ticketService.firstAddServiceTypeButton, 'disabled') .waitToClick(selectors.ticketService.addServiceButton) - .wait(selectors.ticketService.firstAddDescriptionButton) - .isDisabled(selectors.ticketService.firstAddDescriptionButton); + .wait(selectors.ticketService.firstAddServiceTypeButton) + .isDisabled(selectors.ticketService.firstAddServiceTypeButton); expect(result).toBeTruthy(); }, 100000); @@ -50,7 +50,7 @@ describe('Ticket services path', () => { it('should click on the add button to prepare the form to create a new service', async() => { const result = await nightmare .waitToClick(selectors.ticketService.addServiceButton) - .isVisible(selectors.ticketService.firstDescriptionAutocomplete); + .isVisible(selectors.ticketService.firstServiceTypeAutocomplete); expect(result).toBeTruthy(); }); @@ -63,27 +63,28 @@ describe('Ticket services path', () => { expect(result).toEqual(`can't be blank`); }); - it('should click on the add new description to open the dialog', async() => { + it('should click on the add new service type to open the dialog', async() => { const result = await nightmare - .waitToClick(selectors.ticketService.firstAddDescriptionButton) + .waitToClick(selectors.ticketService.firstAddServiceTypeButton) .wait('.vn-dialog.shown') - .isVisible(selectors.ticketService.newDescriptionInput); + .isVisible(selectors.ticketService.newServiceTypeNameInput); expect(result).toBeTruthy(); }); - it('should receive an error if description is empty on submit', async() => { + it('should receive an error if service type is empty on submit', async() => { const result = await nightmare - .waitToClick(selectors.ticketService.saveDescriptionButton) + .waitToClick(selectors.ticketService.saveServiceTypeButton) .waitForLastSnackbar(); expect(result).toEqual(`Name can't be empty`); }); - it('should create a new description then add price then create the service', async() => { + it('should create a new service type then add price then create the service', async() => { const result = await nightmare - .write(selectors.ticketService.newDescriptionInput, 'accurate description') - .waitToClick(selectors.ticketService.saveDescriptionButton) + .write(selectors.ticketService.newServiceTypeNameInput, 'Documentos') + .autocompleteSearch(selectors.ticketService.newServiceTypeExpenseAutocomplete, 'Retencion') + .waitToClick(selectors.ticketService.saveServiceTypeButton) .write(selectors.ticketService.firstPriceInput, 999) .waitToClick(selectors.ticketService.saveServiceButton) .waitForLastSnackbar(); @@ -94,9 +95,9 @@ describe('Ticket services path', () => { it('should confirm the service description was created correctly', async() => { const result = await nightmare .reloadSection('ticket.card.service') - .waitToGetProperty(`${selectors.ticketService.firstDescriptionAutocomplete} input`, 'value'); + .waitToGetProperty(`${selectors.ticketService.firstServiceTypeAutocomplete} input`, 'value'); - expect(result).toEqual('accurate description'); + expect(result).toEqual('Documentos'); }); it('should confirm the service quantity was created correctly', async() => { diff --git a/modules/item/back/methods/item/getSummary.js b/modules/item/back/methods/item/getSummary.js index 749e1212f..4fb9d9ed1 100644 --- a/modules/item/back/methods/item/getSummary.js +++ b/modules/item/back/methods/item/getSummary.js @@ -46,7 +46,7 @@ module.exports = Self => { }, {relation: 'intrastat'}, {relation: 'itemBarcode'}, - {relation: 'expence'}, + {relation: 'expense'}, {relation: 'origin'}, {relation: 'taxes', scope: { diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index 41f5448b4..db8eed9d5 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -1,5 +1,5 @@ { - "Expence": { + "Expense": { "dataSource": "vn" }, "Genus": { diff --git a/modules/item/back/models/expence.json b/modules/item/back/models/expense.json similarity index 96% rename from modules/item/back/models/expence.json rename to modules/item/back/models/expense.json index 79af34988..c0ef2c487 100644 --- a/modules/item/back/models/expence.json +++ b/modules/item/back/models/expense.json @@ -1,5 +1,5 @@ { - "name": "Expence", + "name": "Expense", "base": "VnModel", "options": { "mysql": { diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index 7e2a93e11..d8d1cb64d 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -116,6 +116,12 @@ "hasKgPrice": { "type": "Boolean", "description": "Price per Kg" + }, + "expenseFk": { + "type": "Number", + "mysql": { + "columnName": "expenceFk" + } } }, "relations": { @@ -144,10 +150,10 @@ "model": "Intrastat", "foreignKey": "intrastatFk" }, - "expence": { + "expense": { "type": "belongsTo", - "model": "Expence", - "foreignKey": "expenceFk" + "model": "Expense", + "foreignKey": "expenseFk" }, "tags": { "type": "hasMany", diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html index c4c273ad3..4fe9bfe21 100644 --- a/modules/item/front/basic-data/index.html +++ b/modules/item/front/basic-data/index.html @@ -1,7 +1,7 @@ + override="{filter: {include: [{relation: 'itemType'}, {relation: 'origin'}, {relation: 'ink'}, {relation: 'producer'}, {relation: 'expense'}]}}"> + url="Expenses" + label="Expense" + ng-model="$ctrl.item.expenseFk" + initial-data="$ctrl.item.expense"> - + diff --git a/modules/ticket/back/models/ticket-service-type.json b/modules/ticket/back/models/ticket-service-type.json index a17431644..9912c7952 100644 --- a/modules/ticket/back/models/ticket-service-type.json +++ b/modules/ticket/back/models/ticket-service-type.json @@ -14,6 +14,20 @@ "name": { "type": "String", "required": true + }, + "expenseFk": { + "type": "Number", + "required": true, + "mysql": { + "columnName": "expenceFk" + } + } + }, + "relations": { + "expenditure": { + "type": "belongsTo", + "model": "Expense", + "foreignKey": "expenseFk" } } } \ No newline at end of file diff --git a/modules/ticket/back/models/ticket-service.js b/modules/ticket/back/models/ticket-service.js index ce675f360..cdb57650a 100644 --- a/modules/ticket/back/models/ticket-service.js +++ b/modules/ticket/back/models/ticket-service.js @@ -12,6 +12,11 @@ module.exports = Self => { let isEditable = await models.Ticket.isEditable(httpCtx, ticketId); if (!isEditable) throw new UserError(`The current ticket can't be modified`); + + if (changes.ticketServiceTypeFk) { + const ticketServiceType = await models.TicketServiceType.findById(changes.ticketServiceTypeFk); + changes.description = ticketServiceType.name; + } } }); diff --git a/modules/ticket/back/models/ticket-service.json b/modules/ticket/back/models/ticket-service.json index b3878e89e..8b0c490a8 100644 --- a/modules/ticket/back/models/ticket-service.json +++ b/modules/ticket/back/models/ticket-service.json @@ -36,6 +36,10 @@ "taxClassFk": { "type": "Number", "required": true + }, + "ticketServiceTypeFk": { + "type": "Number", + "required": true } }, "relations": { @@ -48,6 +52,11 @@ "type": "belongsTo", "model": "Ticket", "foreignKey": "ticketFk" + }, + "ticketService": { + "type": "belongsTo", + "model": "TicketServiceType", + "foreignKey": "ticketServiceTypeFk" } } } \ No newline at end of file diff --git a/modules/ticket/front/services/index.html b/modules/ticket/front/services/index.html index f7db96a5c..0cbcbe5df 100644 --- a/modules/ticket/front/services/index.html +++ b/modules/ticket/front/services/index.html @@ -12,14 +12,12 @@
- + value-field="id" + ng-model="service.ticketServiceTypeFk"> + + + + diff --git a/modules/ticket/front/services/index.js b/modules/ticket/front/services/index.js index e45381940..fca4cd070 100644 --- a/modules/ticket/front/services/index.js +++ b/modules/ticket/front/services/index.js @@ -50,7 +50,7 @@ class Controller { throw new UserError(`Name can't be empty`); this.$http.post(`TicketServiceTypes`, this.newServiceType).then(response => { - this.services[this.currentServiceIndex].description = response.data.name; + this.services[this.currentServiceIndex].ticketServiceTypeFk = response.data.id; }); } }