#795 ticket.services

This commit is contained in:
Gerard 2018-11-30 07:57:41 +01:00
parent 706588d7dd
commit fdf0c5f1c0
13 changed files with 170 additions and 18 deletions

View File

@ -198,6 +198,12 @@
"abstract": true,
"component": "ui-view"
},
{
"url": "/service",
"state": "ticket.card.service",
"component": "vn-ticket-service",
"description": "Service"
},
{
"url" : "/index",
"state": "ticket.card.request.index",
@ -226,6 +232,7 @@
{"state": "ticket.card.volume", "icon": "icon-volume"},
{"state": "ticket.card.expedition", "icon": "icon-volum"},
{"state": "ticket.card.package.index", "icon": "icon-bucket"},
{"state": "ticket.card.service"},
{"state": "ticket.card.tracking.index", "icon": "remove_red_eye"},
{"state": "ticket.card.saleChecked", "icon": "assignment"},
{"state": "ticket.card.components", "icon": "icon-components"},

View File

@ -0,0 +1,67 @@
<vn-crud-model
vn-id="model"
url="/ticket/api/TicketServices"
link="{ticketFk: $ctrl.$stateParams.id}"
data="services" on-data-change="$ctrl.onDataChange()">
</vn-crud-model>
<vn-watcher
vn-id="watcher"
data="services"
form="form">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()">
<vn-card pad-large>
<vn-title>Service</vn-title>
<vn-one>
<vn-horizontal ng-repeat="service in services track by $index">
<vn-textfield
vn-one
vn-focus
label="Description"
model="service.description"
rule="TicketService.description">
</vn-textfield>
<vn-textfield
vn-one
label="Quantity"
model="service.quantity"
rule="TicketService.quantity">
</vn-textfield>
<vn-textfield
vn-one
label="Price"
model="service.price"
rule="TicketService.price">
</vn-textfield>
<vn-autocomplete vn-one
url="/api/TaxClasses"
label="Tax class"
show-field="description"
value-field="id"
field="service.taxClassFk">
</vn-autocomplete>
<vn-auto pad-medium-top>
<vn-icon
pointer
medium-grey
vn-tooltip="Remove service"
icon="delete"
ng-click="model.remove($index)">
</vn-icon>
</vn-one>
</vn-horizontal>
</vn-one>
<vn-one>
<vn-icon-button
pointer
vn-tooltip="Add service"
vn-bind="+"
icon="add_circle"
ng-click="$ctrl.add()">
</vn-icon-button>
</vn-one>
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
</vn-button-bar>
</form>

View File

@ -0,0 +1,31 @@
import ngModule from '../module';
class Controller {
constructor($scope, $stateParams) {
this.$scope = $scope;
this.$stateParams = $stateParams;
}
add() {
this.$scope.model.insert({
taxClassFk: 2,
quantity: 1,
ticketFk: this.$stateParams.id
});
}
onSubmit() {
this.$scope.watcher.check();
this.$scope.model.save().then(() => {
this.$scope.watcher.notifySaved();
this.$scope.model.refresh();
});
}
}
Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnTicketService', {
template: require('./index.html'),
controller: Controller
});

View File

@ -0,0 +1,4 @@
Service: Servicios
Tax class: Tipo IVA
Add service: Añadir servicio
Remove service: Quitar servicio

View File

@ -19,6 +19,7 @@ import './sale/editDiscount';
import './tracking/index';
import './tracking/edit';
import './sale-checked';
import './services';
import './component';
import './sale-tracking';
import './picture';

View File

@ -1,13 +1,4 @@
{
"TaxClass": {
"dataSource": "vn"
},
"TaxCode": {
"dataSource": "vn"
},
"TaxType": {
"dataSource": "vn"
},
"ItemNiche": {
"dataSource": "vn"
},
@ -23,9 +14,6 @@
"ItemPlacement": {
"dataSource": "vn"
},
"ItemTaxCountry": {
"dataSource": "vn"
},
"Warehouse": {
"dataSource": "vn"
},

View File

@ -28,7 +28,7 @@ module.exports = Self => {
]
});
let clientFk = address.clientFk;
console.log(address);
if (address.client().isFreezed)
throw new UserError(`You can't create an order for a frozen client`);

View File

@ -0,0 +1,39 @@
{
"name": "TicketService",
"base": "VnModel",
"options": {
"mysql": {
"table": "ticketService"
}
},
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"description": {
"type": "String",
"required": true
},
"quantity": {
"type": "Number",
"required": true
},
"price": {
"type": "Number",
"required": true
},
"taxClassFk": {
"type": "Number",
"required": true
}
},
"relations": {
"taxClass": {
"type": "belongsTo",
"model": "TaxClass",
"foreignKey": "taxClassFk"
}
}
}

View File

@ -99,6 +99,21 @@
"TicketState":{
"dataSource": "vn"
},
"TaxClass": {
"dataSource": "vn"
},
"TaxCode": {
"dataSource": "vn"
},
"TaxType": {
"dataSource": "vn"
},
"ItemTaxCountry": {
"dataSource": "vn"
},
"TicketService":{
"dataSource": "vn"
},
"Item": {
"dataSource": "vn"
},