Tarea #330 Añadir a ticket.line el indicador de problemas
This commit is contained in:
parent
902909d8d1
commit
36a3d04216
|
@ -4,7 +4,7 @@
|
||||||
<section
|
<section
|
||||||
class="inline-tag ellipsize" ng-class="{'empty': !fetchedTag.value}"
|
class="inline-tag ellipsize" ng-class="{'empty': !fetchedTag.value}"
|
||||||
ng-repeat="fetchedTag in $ctrl.sale.item.tags track by $index"
|
ng-repeat="fetchedTag in $ctrl.sale.item.tags track by $index"
|
||||||
title="{{::fetchedTag.tag.name}}: {{::fetchedTag.value}}">
|
vn-tooltip="{{::fetchedTag.tag.name}}: {{::fetchedTag.value}}">
|
||||||
{{::fetchedTag.value}}
|
{{::fetchedTag.value}}
|
||||||
</section>
|
</section>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
<mg-ajax path="/ticket/api/sales/filter" options="vnIndexNonAuto" actions="$ctrl.getTaxes()"></mg-ajax>
|
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-card pad-large>
|
<vn-card pad-large>
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
|
@ -45,7 +44,7 @@
|
||||||
<th></th>
|
<th></th>
|
||||||
<th number>
|
<th number>
|
||||||
<vn-multi-check
|
<vn-multi-check
|
||||||
data="index.model.instances"
|
data="$ctrl.sales"
|
||||||
disabled="!$ctrl.isEditable">
|
disabled="!$ctrl.isEditable">
|
||||||
</vn-multi-check>
|
</vn-multi-check>
|
||||||
</th>
|
</th>
|
||||||
|
@ -58,13 +57,12 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="sale in index.model.instances track by sale.id">
|
<tr ng-repeat="sale in $ctrl.sales">
|
||||||
<td><vn-icon ng-show="sale.reserved" icon="icon-reserved"></vn-icon></td>
|
<td>
|
||||||
<!-- <td>
|
<vn-icon ng-show="sale.visible" icon="warning" vn-tooltip="Visible: {{::sale.visible}}"></vn-icon>
|
||||||
<vn-icon ng-show="sale.disponible" icon="warning"></vn-icon>
|
<vn-icon ng-show="sale.avaible" icon="warning" vn-tooltip="Avaible: {{::sale.avaible}}"></vn-icon>
|
||||||
<vn-icon ng-show="sale.disponible" icon="warning"></vn-icon>
|
<vn-icon ng-show="sale.reserved" icon="icon-reserved"></vn-icon>
|
||||||
<vn-icon ng-show="sale.disponible" icon="icon-reserved"></vn-icon>
|
</td>
|
||||||
</td> -->
|
|
||||||
<td number>
|
<td number>
|
||||||
<vn-check
|
<vn-check
|
||||||
field="sale.checked"
|
field="sale.checked"
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
import FilterTicketList from '../filter-ticket-list';
|
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class Controller extends FilterTicketList {
|
class Controller {
|
||||||
constructor($scope, $timeout, $stateParams, $http, vnApp, $translate) {
|
constructor($scope, $timeout, $stateParams, $http, vnApp, $translate) {
|
||||||
super($scope, $timeout, $stateParams);
|
|
||||||
this.$ = $scope;
|
this.$ = $scope;
|
||||||
this.vnApp = vnApp;
|
this.vnApp = vnApp;
|
||||||
this.translate = $translate;
|
this.translate = $translate;
|
||||||
this.$timeout = $timeout;
|
this.$timeout = $timeout;
|
||||||
this.onOrder('itemFk', 'ASC');
|
|
||||||
this.$state = $stateParams;
|
this.$state = $stateParams;
|
||||||
this.$http = $http;
|
this.$http = $http;
|
||||||
this.deletable = false;
|
this.deletable = false;
|
||||||
|
@ -23,6 +20,16 @@ class Controller extends FilterTicketList {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSales() {
|
||||||
|
this.$http.get(`/api/Tickets/${this.ticket.id}/getSales`).then(res => {
|
||||||
|
this.sales = res.data;
|
||||||
|
this.getTaxes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$onChanges() {
|
||||||
|
if (this.ticket)
|
||||||
|
this.getSales(this.ticket.clientFk);
|
||||||
|
}
|
||||||
onMoreOpen() {
|
onMoreOpen() {
|
||||||
let options = this.moreOptions.filter(o => o.always || this.isChecked);
|
let options = this.moreOptions.filter(o => o.always || this.isChecked);
|
||||||
this.$.moreButton.data = options;
|
this.$.moreButton.data = options;
|
||||||
|
@ -34,7 +41,7 @@ class Controller extends FilterTicketList {
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubTotal() {
|
getSubTotal() {
|
||||||
let sales = this.$.index.model.instances;
|
let sales = this.sales;
|
||||||
|
|
||||||
this.subTotal = 0.00;
|
this.subTotal = 0.00;
|
||||||
sales.forEach(sale => {
|
sales.forEach(sale => {
|
||||||
|
@ -60,7 +67,7 @@ class Controller extends FilterTicketList {
|
||||||
}
|
}
|
||||||
|
|
||||||
get isChecked() {
|
get isChecked() {
|
||||||
let data = this.$.index.model.instances;
|
let data = this.sales;
|
||||||
if (data)
|
if (data)
|
||||||
for (let instance of data)
|
for (let instance of data)
|
||||||
if (instance.checked)
|
if (instance.checked)
|
||||||
|
@ -71,7 +78,7 @@ class Controller extends FilterTicketList {
|
||||||
|
|
||||||
getCheckedLines() {
|
getCheckedLines() {
|
||||||
let lines = [];
|
let lines = [];
|
||||||
let data = this.$.index.model.instances;
|
let data = this.sales;
|
||||||
if (data)
|
if (data)
|
||||||
for (let i = 0; i < data.length; i++)
|
for (let i = 0; i < data.length; i++)
|
||||||
if (data[i].checked)
|
if (data[i].checked)
|
||||||
|
@ -144,7 +151,7 @@ class Controller extends FilterTicketList {
|
||||||
|
|
||||||
removeInstances(instances) {
|
removeInstances(instances) {
|
||||||
for (let i = instances.length - 1; i >= 0; i--) {
|
for (let i = instances.length - 1; i >= 0; i--) {
|
||||||
this.$.index.model.instances.splice(instances[i].instance, 1);
|
this.sales.splice(instances[i].instance, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +193,10 @@ class Controller extends FilterTicketList {
|
||||||
let sales = this.getCheckedLines();
|
let sales = this.getCheckedLines();
|
||||||
|
|
||||||
this.$http.post(`/api/Sales/MoveToNewTicket`, {ticket: ticket, sales: sales}).then(res => {
|
this.$http.post(`/api/Sales/MoveToNewTicket`, {ticket: ticket, sales: sales}).then(res => {
|
||||||
this.goToTicket(res.data.id);
|
let url = this.$state.href("ticket.card.sale", {id: res.data.id}, {absolute: true});
|
||||||
|
window.open(url, '_blank');
|
||||||
|
this.$.transfer.hide();
|
||||||
|
this.getSales();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +238,7 @@ class Controller extends FilterTicketList {
|
||||||
if (this.editedPrice != this.sale.price) {
|
if (this.editedPrice != this.sale.price) {
|
||||||
this.$http.post(`/ticket/api/Sales/updatePrice`, {id: this.edit.id, price: this.editedPrice, ticketFk: this.ticket.id}).then(() => {
|
this.$http.post(`/ticket/api/Sales/updatePrice`, {id: this.edit.id, price: this.editedPrice, ticketFk: this.ticket.id}).then(() => {
|
||||||
this.sale.price = this.edit.price;
|
this.sale.price = this.edit.price;
|
||||||
this.$.index.accept();
|
this.getSales();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.$.editPricePopover.hide();
|
this.$.editPricePopover.hide();
|
||||||
|
@ -253,19 +263,21 @@ class Controller extends FilterTicketList {
|
||||||
}
|
}
|
||||||
|
|
||||||
hideEditDialog() {
|
hideEditDialog() {
|
||||||
this.$.index.accept();
|
this.getSales();
|
||||||
this.$.editDialog.hide();
|
this.$.editDialog.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
hideEditPopover() {
|
hideEditPopover() {
|
||||||
this.$.index.accept();
|
this.getSales();
|
||||||
this.$.editPopover.hide();
|
this.$.editPopover.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateQuantity(id, quantity) {
|
updateQuantity(id, quantity) {
|
||||||
this.$http.post(`/ticket/api/Sales/${id}/updateQuantity`, {quantity: parseInt(quantity)}).then(() => {
|
this.$http.post(`/ticket/api/Sales/${id}/updateQuantity`, {quantity: parseInt(quantity)}).then(() => {
|
||||||
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
||||||
this.$.index.accept();
|
}).catch(e => {
|
||||||
|
this.vnApp.showError(this.translate.instant(e.data.error.message));
|
||||||
|
this.getSales();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,18 +302,6 @@ class Controller extends FilterTicketList {
|
||||||
this.$.edit.hide();
|
this.$.edit.hide();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove options from 'More' menu
|
|
||||||
* @param {String} name - Option name
|
|
||||||
*/
|
|
||||||
removeOptionByName(name) {
|
|
||||||
let options = this.moreOptions;
|
|
||||||
for (let i = 0; i < this.moreOptions.length; i++) {
|
|
||||||
if (options[i].name === name)
|
|
||||||
this.moreOptions.splice(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unmark sale as reserved
|
* Unmark sale as reserved
|
||||||
*/
|
*/
|
||||||
|
@ -321,7 +321,7 @@ class Controller extends FilterTicketList {
|
||||||
let params = {sales: sales, ticketFk: this.ticket.id, reserved: reserved};
|
let params = {sales: sales, ticketFk: this.ticket.id, reserved: reserved};
|
||||||
|
|
||||||
this.$http.post(`/ticket/api/Sales/reserve`, params).then(() => {
|
this.$http.post(`/ticket/api/Sales/reserve`, params).then(() => {
|
||||||
this.$.index.accept();
|
this.getSales();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,3 +11,4 @@ New ticket: Nuevo ticket
|
||||||
Edit price: Editar precio
|
Edit price: Editar precio
|
||||||
You are going to delete lines of the ticket: Vas a borrar lineas del ticket
|
You are going to delete lines of the ticket: Vas a borrar lineas del ticket
|
||||||
Continue anyway?: ¿Estás seguro?
|
Continue anyway?: ¿Estás seguro?
|
||||||
|
The new quantity should be smaller than the old one: La nueva cantidad debe de ser menor que la anterior
|
|
@ -1,6 +1,6 @@
|
||||||
@import "colors";
|
@import "colors";
|
||||||
|
vn-ticket-sale {
|
||||||
vn-popover.edit {
|
vn-popover.edit {
|
||||||
& div.popover{
|
& div.popover{
|
||||||
width: 200px;
|
width: 200px;
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,9 @@ vn-popover.edit {
|
||||||
div.simulator{
|
div.simulator{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vn-dialog.edit {
|
vn-dialog.edit {
|
||||||
@extend vn-popover.edit;
|
@extend vn-popover.edit;
|
||||||
|
|
||||||
.buttons{
|
.buttons{
|
||||||
|
@ -42,16 +42,16 @@ vn-dialog.edit {
|
||||||
vn-ticket-sale-edit-discount > div {
|
vn-ticket-sale-edit-discount > div {
|
||||||
padding-bottom: 0!important;
|
padding-bottom: 0!important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vn-ticket-sale{
|
vn-ticket-sale{
|
||||||
& tr .mdl-textfield{
|
& tr .mdl-textfield{
|
||||||
width: inherit;
|
width: inherit;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vn-popover.transfer{
|
vn-popover.transfer{
|
||||||
& table {
|
& table {
|
||||||
min-width: 650px;
|
min-width: 650px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
@ -60,28 +60,29 @@ vn-popover.transfer{
|
||||||
padding-top: 0.2em;
|
padding-top: 0.2em;
|
||||||
font-size: 1.8em;
|
font-size: 1.8em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vn-dialog.ticket-create{
|
vn-dialog.ticket-create{
|
||||||
& vn-button[label=Cancel]{
|
& vn-button[label=Cancel]{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
& vn-card.vn-ticket-create{
|
& vn-card.vn-ticket-create{
|
||||||
padding: 0!important;
|
padding: 0!important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
& vn-textfield {
|
& vn-textfield {
|
||||||
max-width: 100px;
|
max-width: 100px;
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vn-textfield {
|
vn-textfield {
|
||||||
& span.filter {
|
& span.filter {
|
||||||
padding-top: 3px;
|
padding-top: 3px;
|
||||||
padding-right: 3px;
|
padding-right: 3px;
|
||||||
color: $main-font-color
|
color: $main-font-color
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('getSales', {
|
||||||
|
description: 'New filter',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'ticketFk',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'ticket id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: ['Object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:ticketFk/getSales`,
|
||||||
|
verb: 'get'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.getSales = async ticketFk => {
|
||||||
|
let query = `CALL vn.ticketGetVisibleAvailable(?)`;
|
||||||
|
let [lines] = await Self.rawSql(query, [ticketFk]);
|
||||||
|
let ids = [];
|
||||||
|
|
||||||
|
for (line of lines)
|
||||||
|
ids.push(line.itemFk);
|
||||||
|
|
||||||
|
let filter = {
|
||||||
|
fields: ['id'],
|
||||||
|
where: {id: {inq: ids}},
|
||||||
|
include: {
|
||||||
|
relation: 'tags',
|
||||||
|
scope: {
|
||||||
|
fields: ['tagFk', 'value', 'priority'],
|
||||||
|
where: {priority: {lte: 6}},
|
||||||
|
order: 'priority',
|
||||||
|
include: {
|
||||||
|
relation: 'tag',
|
||||||
|
scope: {
|
||||||
|
fields: ['name']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let items = await Self.app.models.Item.find(filter);
|
||||||
|
|
||||||
|
let map = {};
|
||||||
|
for (item of items)
|
||||||
|
map[item.id] = item;
|
||||||
|
|
||||||
|
for (line of lines)
|
||||||
|
line.item = {tags: map[line.itemFk].tags()};
|
||||||
|
|
||||||
|
return lines;
|
||||||
|
};
|
||||||
|
};
|
|
@ -12,5 +12,6 @@ module.exports = Self => {
|
||||||
require('../methods/ticket/threeLastActive')(Self);
|
require('../methods/ticket/threeLastActive')(Self);
|
||||||
require('../methods/ticket/deleted')(Self);
|
require('../methods/ticket/deleted')(Self);
|
||||||
require('../methods/ticket/getVAT')(Self);
|
require('../methods/ticket/getVAT')(Self);
|
||||||
|
require('../methods/ticket/getSales')(Self);
|
||||||
require('../methods/ticket/getSalesPersonMana')(Self);
|
require('../methods/ticket/getSalesPersonMana')(Self);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue