Tarea #330 Añadir a ticket.line el indicador de problemas

This commit is contained in:
gerard 2018-07-04 14:41:01 +02:00
parent 902909d8d1
commit 36a3d04216
7 changed files with 174 additions and 114 deletions

View File

@ -4,7 +4,7 @@
<section
class="inline-tag ellipsize" ng-class="{'empty': !fetchedTag.value}"
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}}
</section>
</vn-one>

View File

@ -1,4 +1,3 @@
<mg-ajax path="/ticket/api/sales/filter" options="vnIndexNonAuto" actions="$ctrl.getTaxes()"></mg-ajax>
<vn-vertical>
<vn-card pad-large>
<vn-vertical>
@ -45,7 +44,7 @@
<th></th>
<th number>
<vn-multi-check
data="index.model.instances"
data="$ctrl.sales"
disabled="!$ctrl.isEditable">
</vn-multi-check>
</th>
@ -58,13 +57,12 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="sale in index.model.instances track by sale.id">
<td><vn-icon ng-show="sale.reserved" icon="icon-reserved"></vn-icon></td>
<!-- <td>
<vn-icon ng-show="sale.disponible" icon="warning"></vn-icon>
<vn-icon ng-show="sale.disponible" icon="warning"></vn-icon>
<vn-icon ng-show="sale.disponible" icon="icon-reserved"></vn-icon>
</td> -->
<tr ng-repeat="sale in $ctrl.sales">
<td>
<vn-icon ng-show="sale.visible" icon="warning" vn-tooltip="Visible: {{::sale.visible}}"></vn-icon>
<vn-icon ng-show="sale.avaible" icon="warning" vn-tooltip="Avaible: {{::sale.avaible}}"></vn-icon>
<vn-icon ng-show="sale.reserved" icon="icon-reserved"></vn-icon>
</td>
<td number>
<vn-check
field="sale.checked"

View File

@ -1,15 +1,12 @@
import ngModule from '../module';
import FilterTicketList from '../filter-ticket-list';
import './style.scss';
class Controller extends FilterTicketList {
class Controller {
constructor($scope, $timeout, $stateParams, $http, vnApp, $translate) {
super($scope, $timeout, $stateParams);
this.$ = $scope;
this.vnApp = vnApp;
this.translate = $translate;
this.$timeout = $timeout;
this.onOrder('itemFk', 'ASC');
this.$state = $stateParams;
this.$http = $http;
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() {
let options = this.moreOptions.filter(o => o.always || this.isChecked);
this.$.moreButton.data = options;
@ -34,7 +41,7 @@ class Controller extends FilterTicketList {
}
getSubTotal() {
let sales = this.$.index.model.instances;
let sales = this.sales;
this.subTotal = 0.00;
sales.forEach(sale => {
@ -60,7 +67,7 @@ class Controller extends FilterTicketList {
}
get isChecked() {
let data = this.$.index.model.instances;
let data = this.sales;
if (data)
for (let instance of data)
if (instance.checked)
@ -71,7 +78,7 @@ class Controller extends FilterTicketList {
getCheckedLines() {
let lines = [];
let data = this.$.index.model.instances;
let data = this.sales;
if (data)
for (let i = 0; i < data.length; i++)
if (data[i].checked)
@ -144,7 +151,7 @@ class Controller extends FilterTicketList {
removeInstances(instances) {
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();
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) {
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.$.index.accept();
this.getSales();
});
}
this.$.editPricePopover.hide();
@ -253,19 +263,21 @@ class Controller extends FilterTicketList {
}
hideEditDialog() {
this.$.index.accept();
this.getSales();
this.$.editDialog.hide();
}
hideEditPopover() {
this.$.index.accept();
this.getSales();
this.$.editPopover.hide();
}
updateQuantity(id, quantity) {
this.$http.post(`/ticket/api/Sales/${id}/updateQuantity`, {quantity: parseInt(quantity)}).then(() => {
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();
}*/
/**
* 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
*/
@ -321,7 +321,7 @@ class Controller extends FilterTicketList {
let params = {sales: sales, ticketFk: this.ticket.id, reserved: reserved};
this.$http.post(`/ticket/api/Sales/reserve`, params).then(() => {
this.$.index.accept();
this.getSales();
});
}
}

View File

@ -10,4 +10,5 @@ Move to ticket: Mover a ticket
New ticket: Nuevo ticket
Edit price: Editar precio
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

View File

@ -1,87 +1,88 @@
@import "colors";
vn-popover.edit {
& div.popover{
width: 200px;
}
& vn-horizontal.header{
background-color: $main-01;
& h5{
color: white;
margin: 0 auto;
vn-ticket-sale {
vn-popover.edit {
& div.popover{
width: 200px;
}
& vn-horizontal.header{
background-color: $main-01;
& h5{
color: white;
margin: 0 auto;
}
}
& p.simulatorTitle{
margin-bottom: 0px;
font-size: 12px;
color: $main-01;
}
& vn-label-value{
padding-bottom: 20px;
}
div.simulator{
text-align: center;
}
}
& p.simulatorTitle{
margin-bottom: 0px;
font-size: 12px;
color: $main-01;
vn-dialog.edit {
@extend vn-popover.edit;
.buttons{
margin-top: 0!important;
}
p{
display: none;
}
vn-ticket-sale-edit-discount > div {
padding-bottom: 0!important;
}
}
& vn-label-value{
padding-bottom: 20px;
vn-ticket-sale{
& tr .mdl-textfield{
width: inherit;
max-width: 100%;
}
}
div.simulator{
text-align: center;
vn-popover.transfer{
& table {
min-width: 650px;
margin-bottom: 10px;
}
& i {
padding-top: 0.2em;
font-size: 1.8em;
}
}
}
vn-dialog.edit {
@extend vn-popover.edit;
.buttons{
margin-top: 0!important;
vn-dialog.ticket-create{
& vn-button[label=Cancel]{
display: none;
}
& vn-card.vn-ticket-create{
padding: 0!important;
}
}
p{
display: none;
table {
& vn-textfield {
max-width: 100px;
float: right;
}
}
vn-ticket-sale-edit-discount > div {
padding-bottom: 0!important;
}
}
vn-ticket-sale{
& tr .mdl-textfield{
width: inherit;
max-width: 100%;
}
}
vn-popover.transfer{
& table {
min-width: 650px;
margin-bottom: 10px;
}
& i {
padding-top: 0.2em;
font-size: 1.8em;
}
}
vn-dialog.ticket-create{
& vn-button[label=Cancel]{
display: none;
}
& vn-card.vn-ticket-create{
padding: 0!important;
}
}
table {
& vn-textfield {
max-width: 100px;
float: right;
}
}
vn-textfield {
& span.filter {
padding-top: 3px;
padding-right: 3px;
color: $main-font-color
vn-textfield {
& span.filter {
padding-top: 3px;
padding-right: 3px;
color: $main-font-color
}
}
}

View File

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

View File

@ -12,5 +12,6 @@ module.exports = Self => {
require('../methods/ticket/threeLastActive')(Self);
require('../methods/ticket/deleted')(Self);
require('../methods/ticket/getVAT')(Self);
require('../methods/ticket/getSales')(Self);
require('../methods/ticket/getSalesPersonMana')(Self);
};