renamed expence to expense and added field
gitea/salix/1919-ticket_service_type There was a failure building this commit Details

This commit is contained in:
Joan Sanchez 2019-12-13 11:59:25 +01:00
parent 2325127390
commit 780f1e4773
14 changed files with 82 additions and 39 deletions

View File

@ -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"]',

View File

@ -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() => {

View File

@ -46,7 +46,7 @@ module.exports = Self => {
},
{relation: 'intrastat'},
{relation: 'itemBarcode'},
{relation: 'expence'},
{relation: 'expense'},
{relation: 'origin'},
{relation: 'taxes',
scope: {

View File

@ -1,5 +1,5 @@
{
"Expence": {
"Expense": {
"dataSource": "vn"
},
"Genus": {

View File

@ -1,5 +1,5 @@
{
"name": "Expence",
"name": "Expense",
"base": "VnModel",
"options": {
"mysql": {

View File

@ -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",

View File

@ -1,7 +1,7 @@
<mg-ajax
path="Items/{{patch.params.id}}"
options="vnPatch"
override="{filter: {include: [{relation: 'itemType'}, {relation: 'origin'}, {relation: 'ink'}, {relation: 'producer'}, {relation: 'expence'}]}}">
override="{filter: {include: [{relation: 'itemType'}, {relation: 'origin'}, {relation: 'ink'}, {relation: 'producer'}, {relation: 'expense'}]}}">
</mg-ajax>
<vn-watcher
vn-id="watcher"
@ -49,10 +49,10 @@
</tpl-item>
</vn-autocomplete>
<vn-autocomplete vn-one
url="Expences"
label="Expence"
ng-model="$ctrl.item.expenceFk"
initial-data="$ctrl.item.expence">
url="Expenses"
label="Expense"
ng-model="$ctrl.item.expenseFk"
initial-data="$ctrl.item.expense">
</vn-autocomplete>
<vn-autocomplete vn-one
url="Origins"

View File

@ -4,5 +4,5 @@ Full name calculates based on tags 1-3. Is not recommended to change it manually
basado en los tags 1-3.
No se recomienda cambiarlo manualmente
Is active: Activo
Expence: Gasto
Expense: Gasto
Price in kg: Precio en kg

View File

@ -60,8 +60,8 @@
<vn-label-value label="Compression"
value="{{$ctrl.summary.item.compression}}">
</vn-label-value>
<vn-label-value label="Expence"
value="{{$ctrl.summary.item.expence.name}}">
<vn-label-value label="Expense"
value="{{$ctrl.summary.item.expense.name}}">
</vn-label-value>
</vn-one>
<vn-one name="tags">

View File

@ -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"
}
}
}

View File

@ -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;
}
}
});

View File

@ -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"
}
}
}

View File

@ -12,14 +12,12 @@
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
<vn-card class="vn-pa-lg">
<vn-horizontal ng-repeat="service in $ctrl.services track by $index">
<vn-autocomplete
vn-one
vn-focus
<vn-autocomplete vn-two vn-focus
url="TicketServiceTypes"
label="Description"
show-field="name"
value-field="name"
ng-model="service.description">
value-field="id"
ng-model="service.ticketServiceTypeFk">
<append>
<vn-icon-button
icon="add_circle"
@ -87,6 +85,15 @@
vn-focus>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one vn-focus
url="Expenses"
label="Expense"
show-field="name"
value-field="id"
ng-model="$ctrl.newServiceType.expenseFk">
</vn-autocomplete>
</vn-horizontal>
</tpl-body>
<tpl-buttons>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>

View File

@ -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;
});
}
}