parent
9527b839df
commit
54ee27dcef
|
@ -73,27 +73,36 @@
|
||||||
{{::sale.itemFk}}
|
{{::sale.itemFk}}
|
||||||
</td>
|
</td>
|
||||||
<td><vn-fetched-tags sale="sale"/></td>
|
<td><vn-fetched-tags sale="sale"/></td>
|
||||||
<td number>{{sale.quantity}}</td>
|
<td ng-if="!$ctrl.isEditable" number>{{sale.quantity}}</td>
|
||||||
<!--<td ng-if="$ctrl.ticket.tracking.state.alertLevel == 0">
|
<td ng-if="$ctrl.isEditable" number>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
model="sale.quantity"
|
model="sale.quantity"
|
||||||
type="number"
|
on-change="$ctrl.updateQuantity(sale.id,sale.quantity)"
|
||||||
ng-blur="updateLine()">
|
unclearable="true">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</td>-->
|
</td>
|
||||||
<td number>{{sale.price | currency:'€':2}}</td>
|
<td number
|
||||||
<td number>{{sale.discount}} %</td>
|
ng-if="$ctrl.isEditable"
|
||||||
<td number>{{sale.quantity * sale.price | currency:'€':2}}</td>
|
ng-click="$ctrl.showEditPricePopover($event, sale)"
|
||||||
<!--<td number>
|
|
||||||
<vn-icon-button
|
|
||||||
ng-if="$ctrl.ticket.tracking.state.alertLevel == 0"
|
|
||||||
pointer
|
pointer
|
||||||
vn-tooltip="Add note"
|
vn-tooltip="Edit Price">
|
||||||
tooltip-position="left"
|
{{sale.price | currency:'€':2}}
|
||||||
icon="mode_edit"
|
</td>
|
||||||
ng-click="$ctrl.showEditPopover($event, sale)">
|
<td number ng-if="!$ctrl.isEditable">
|
||||||
</vn-icon-button>
|
{{sale.price | currency:'€':2}}
|
||||||
</td>-->
|
</td>
|
||||||
|
<td number
|
||||||
|
ng-if="$ctrl.isEditable"
|
||||||
|
ng-click="$ctrl.showEditPopover($event, sale)"
|
||||||
|
pointer
|
||||||
|
vn-tooltip="Edit discount">
|
||||||
|
{{sale.discount}} %
|
||||||
|
</td>
|
||||||
|
<td number
|
||||||
|
ng-if="!$ctrl.isEditable">
|
||||||
|
{{sale.discount}} %
|
||||||
|
</td>
|
||||||
|
<td number>{{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency:' €':2}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr ng-if="index.model.count === 0" class="list list-element">
|
<tr ng-if="index.model.count === 0" class="list list-element">
|
||||||
<td colspan="8" style="text-align: center" translate>No results</td>
|
<td colspan="8" style="text-align: center" translate>No results</td>
|
||||||
|
@ -166,35 +175,66 @@
|
||||||
</tpl-body>
|
</tpl-body>
|
||||||
</vn-dialog>
|
</vn-dialog>
|
||||||
|
|
||||||
<!-- Edit Popover -->
|
<!-- Edit Price Popover -->
|
||||||
<vn-popover class="edit" vn-id="edit">
|
<vn-popover
|
||||||
|
class="edit dialog-summary"
|
||||||
|
vn-id="editPricePopover"
|
||||||
|
on-open="$ctrl.getManaSalespersonMana()">
|
||||||
<vn-horizontal pad-medium class="header">
|
<vn-horizontal pad-medium class="header">
|
||||||
<h5>MANÁ: {{$ctrl.workerMana}}</h5>
|
<h5>MANÁ: {{$ctrl.mana | currency:' €':0}}</h5>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<div pad-medium>
|
<div pad-medium>
|
||||||
<h5>{{$ctrl.client.name}}</h5>
|
|
||||||
<vn-textfield
|
|
||||||
label="Quantity"
|
|
||||||
model="$ctrl.edit.quantity"
|
|
||||||
type="number">
|
|
||||||
</vn-textfield>
|
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
|
vn-focus
|
||||||
label="Price"
|
label="Price"
|
||||||
model="$ctrl.edit.price"
|
model="$ctrl.editedPrice"
|
||||||
type="number">
|
type="number"
|
||||||
</vn-textfield>
|
on-change="$ctrl.updatePrice()">
|
||||||
<vn-textfield
|
<t-right-icons>
|
||||||
label="Discount"
|
<span class="filter">€</span>
|
||||||
model="$ctrl.edit.discount"
|
</t-right-icons>
|
||||||
type="number">
|
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
|
<div class="simulator">
|
||||||
|
<p class="simulatorTitle" translate>New price</p>
|
||||||
|
<p>{{($ctrl.sale.quantity * $ctrl.sale.price)
|
||||||
|
- (($ctrl.sale.discount * ($ctrl.sale.quantity * $ctrl.editedPrice))/100)
|
||||||
|
| currency:' €':2}}</p>
|
||||||
<vn-button
|
<vn-button
|
||||||
label="Save"
|
label="Save"
|
||||||
ng-click="$ctrl.updateLine()">
|
ng-click="$ctrl.updatePrice()">
|
||||||
</vn-button>
|
</vn-button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</vn-popover>
|
</vn-popover>
|
||||||
|
|
||||||
|
<!-- Edit Popover -->
|
||||||
|
<vn-popover
|
||||||
|
class="edit dialog-summary"
|
||||||
|
vn-id="editPopover"
|
||||||
|
on-open="$ctrl.getManaSalespersonMana()">
|
||||||
|
<vn-ticket-sale-edit-discount
|
||||||
|
mana="$ctrl.mana"
|
||||||
|
bulk="false"
|
||||||
|
edit="$ctrl.edit"
|
||||||
|
hide="$ctrl.hideEditPopover()">
|
||||||
|
</vn-ticket-sale-edit-discount>
|
||||||
|
</vn-popover>
|
||||||
|
|
||||||
|
<!-- Edit Dialog -->
|
||||||
|
<vn-dialog
|
||||||
|
vn-id="editDialog"
|
||||||
|
class="edit"
|
||||||
|
on-open="$ctrl.getManaSalespersonMana()">
|
||||||
|
<tpl-body>
|
||||||
|
<vn-ticket-sale-edit-discount
|
||||||
|
mana="$ctrl.mana"
|
||||||
|
bulk="true"
|
||||||
|
edit="$ctrl.edit"
|
||||||
|
hide="$ctrl.hideEditDialog()">
|
||||||
|
</vn-ticket-sale-edit-discount>
|
||||||
|
</tpl-body>
|
||||||
|
</vn-dialog>
|
||||||
|
|
||||||
<!-- Transfer Popover -->
|
<!-- Transfer Popover -->
|
||||||
<vn-popover class="transfer" vn-id="transfer">
|
<vn-popover class="transfer" vn-id="transfer">
|
||||||
<div pad-medium>
|
<div pad-medium>
|
||||||
|
@ -232,11 +272,11 @@
|
||||||
ng-click="$ctrl.moveLines($ctrl.moveToTicketFk)">
|
ng-click="$ctrl.moveLines($ctrl.moveToTicketFk)">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<!-- <vn-button
|
<vn-button
|
||||||
pointer
|
pointer
|
||||||
label="New ticket"
|
label="New ticket"
|
||||||
ng-click="$ctrl.showticketCreate()">
|
ng-click="$ctrl.linesToNewTicket()">
|
||||||
</vn-button> -->
|
</vn-button>
|
||||||
</div>
|
</div>
|
||||||
</vn-popover>
|
</vn-popover>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
|
|
|
@ -3,15 +3,17 @@ import FilterTicketList from '../filter-ticket-list';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class Controller extends FilterTicketList {
|
class Controller extends FilterTicketList {
|
||||||
constructor($scope, $timeout, $stateParams, $http, $state, vnApp) {
|
constructor($scope, $timeout, $stateParams, $http, vnApp, $translate) {
|
||||||
super($scope, $timeout, $stateParams);
|
super($scope, $timeout, $stateParams);
|
||||||
this.$ = $scope;
|
this.$ = $scope;
|
||||||
this.vnApp = vnApp;
|
this.vnApp = vnApp;
|
||||||
|
this.translate = $translate;
|
||||||
this.$timeout = $timeout;
|
this.$timeout = $timeout;
|
||||||
this.onOrder('itemFk', 'ASC');
|
this.onOrder('itemFk', 'ASC');
|
||||||
this.$state = $stateParams;
|
this.$state = $stateParams;
|
||||||
this.$http = $http;
|
this.$http = $http;
|
||||||
this.deletable = false;
|
this.deletable = false;
|
||||||
|
this.edit = {};
|
||||||
this.moreOptions = [
|
this.moreOptions = [
|
||||||
{callback: this.showAddTurnDialog, name: "Add turn"},
|
{callback: this.showAddTurnDialog, name: "Add turn"},
|
||||||
{callback: this.showDeleteTicketDialog, name: "Delete ticket"}
|
{callback: this.showDeleteTicketDialog, name: "Delete ticket"}
|
||||||
|
@ -28,7 +30,7 @@ class Controller extends FilterTicketList {
|
||||||
|
|
||||||
this.subTotal = 0.00;
|
this.subTotal = 0.00;
|
||||||
sales.forEach(sale => {
|
sales.forEach(sale => {
|
||||||
this.subTotal += sale.quantity * sale.price;
|
this.subTotal += (sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price)) / 100);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +89,7 @@ class Controller extends FilterTicketList {
|
||||||
let params = {ticketFk: this.$state.params.id, stateFk: value};
|
let params = {ticketFk: this.$state.params.id, stateFk: value};
|
||||||
this.$http.post(`/ticket/api/TicketTrackings/changeState`, params).then(() => {
|
this.$http.post(`/ticket/api/TicketTrackings/changeState`, params).then(() => {
|
||||||
this.card.reload();
|
this.card.reload();
|
||||||
this.vnApp.showMessage(this.translate.instant('Data saved'));
|
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,12 +152,22 @@ class Controller extends FilterTicketList {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* newTicket() {
|
// In Progress
|
||||||
let params = [this.ticket.clientFk, this.ticket.warehouseFk, this.ticket.companyFk, this.ticket.addressFk, this.ticket.agencyModeFk, null];
|
linesToNewTicket() {
|
||||||
this.$http.post(`/ticket/api/Tickets/create`, params).then(res => {
|
let ticket = {
|
||||||
console.log(res);
|
oldTicketFk: this.ticket.id,
|
||||||
|
clientFk: this.ticket.clientFk,
|
||||||
|
addressFk: this.ticket.addressFk,
|
||||||
|
agencyModeFk: this.ticket.agencyModeFk,
|
||||||
|
warehouseFk: this.ticket.warehouseFk
|
||||||
|
};
|
||||||
|
|
||||||
|
let sales = this.getCheckedLines();
|
||||||
|
|
||||||
|
this.$http.post(`/api/Sales/MoveToNewTicket`, {ticket: ticket, sales: sales}).then(res => {
|
||||||
|
this.goToTicket(res.data.id);
|
||||||
});
|
});
|
||||||
}*/
|
}
|
||||||
|
|
||||||
goToTicket(ticketID) {
|
goToTicket(ticketID) {
|
||||||
this.$state.go("ticket.card.sale", {id: ticketID});
|
this.$state.go("ticket.card.sale", {id: ticketID});
|
||||||
|
@ -166,6 +178,12 @@ class Controller extends FilterTicketList {
|
||||||
this.$.index.model.instances.splice(instances[i].instance, 1);
|
this.$.index.model.instances.splice(instances[i].instance, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Slesperson Mana
|
||||||
|
getManaSalespersonMana() {
|
||||||
|
this.$http.get(`/api/Tickets/${this.$state.params.id}/getSalesPersonMana`).then(res => {
|
||||||
|
this.mana = res.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
// Item Descriptor
|
// Item Descriptor
|
||||||
showDescriptor(event, itemFk) {
|
showDescriptor(event, itemFk) {
|
||||||
this.$.descriptor.itemFk = itemFk;
|
this.$.descriptor.itemFk = itemFk;
|
||||||
|
@ -177,39 +195,65 @@ class Controller extends FilterTicketList {
|
||||||
this.$.popover.relocate();
|
this.$.popover.relocate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ticket Create
|
// Edit Line
|
||||||
showticketCreate() {
|
showEditPricePopover(event, sale) {
|
||||||
console.log(this);
|
this.sale = sale;
|
||||||
this.$.newTicket.show();
|
this.editedPrice = this.sale.price;
|
||||||
|
this.edit = {
|
||||||
|
ticketFk: this.ticket.id,
|
||||||
|
id: sale.id,
|
||||||
|
quantity: sale.quantity
|
||||||
|
};
|
||||||
|
this.$.editPricePopover.parent = event.target;
|
||||||
|
this.$.editPricePopover.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
onResponse(response) {
|
updatePrice() {
|
||||||
if (response === 'ACCEPT') {
|
if (this.editedPrice != this.sale.price) {
|
||||||
let newTicketID = this.$.newTicket.dialog.createTicket();
|
this.$http.post(`/ticket/api/Sales/updatePrice`, {id: this.edit.id, price: this.editedPrice, ticketFk: this.ticket.id}).then(() => {
|
||||||
console.log(newTicketID);
|
this.sale.price = this.edit.price;
|
||||||
}
|
this.$.index.accept();
|
||||||
}
|
|
||||||
// Edit Line
|
|
||||||
_getworkerMana() {
|
|
||||||
this.$http.get(`/api/WorkerManas/getCurrentWorkerMana`).then(res => {
|
|
||||||
this.workerMana = res.data[0].mana;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.$.editPricePopover.hide();
|
||||||
|
}
|
||||||
|
|
||||||
showEditPopover(event, sale) {
|
showEditPopover(event, sale) {
|
||||||
this.sale = sale;
|
this.sale = sale;
|
||||||
this.edit = {
|
this.edit = [{
|
||||||
|
ticketFk: this.ticket.id,
|
||||||
id: sale.id,
|
id: sale.id,
|
||||||
quantity: sale.quantity,
|
quantity: sale.quantity,
|
||||||
price: sale.price,
|
price: sale.price,
|
||||||
discount: sale.discount
|
discount: sale.discount
|
||||||
};
|
}];
|
||||||
this.$.edit.parent = event.target;
|
this.$.editPopover.parent = event.target;
|
||||||
this._getworkerMana();
|
this.$.editPopover.show();
|
||||||
this.$.edit.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLine() {
|
async showEditDialog() {
|
||||||
|
this.edit = this.getCheckedLines();
|
||||||
|
this.$.editDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
hideEditDialog() {
|
||||||
|
this.$.index.accept();
|
||||||
|
this.$.editDialog.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
hideEditPopover() {
|
||||||
|
this.$.index.accept();
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* updateLine() {
|
||||||
if (this.edit.quantity != this.sale.quantity) {
|
if (this.edit.quantity != this.sale.quantity) {
|
||||||
this.$http.post(`/ticket/api/Sales/updateQuantity`, {id: this.edit.id, quantity: this.edit.quantity}).then(() => {
|
this.$http.post(`/ticket/api/Sales/updateQuantity`, {id: this.edit.id, quantity: this.edit.quantity}).then(() => {
|
||||||
this.sale.quantity = this.edit.quantity;
|
this.sale.quantity = this.edit.quantity;
|
||||||
|
@ -228,12 +272,12 @@ class Controller extends FilterTicketList {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.$.edit.hide();
|
this.$.edit.hide();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
onMoreClick() {
|
onMoreClick() {
|
||||||
this.removeOptionByName('Mark as reserved');
|
this.removeOptionByName('Mark as reserved');
|
||||||
this.removeOptionByName('Unmark as reserved');
|
this.removeOptionByName('Unmark as reserved');
|
||||||
|
this.removeOptionByName('Update discount');
|
||||||
if (!this.isChecked) return;
|
if (!this.isChecked) return;
|
||||||
|
|
||||||
this.moreOptions.push({
|
this.moreOptions.push({
|
||||||
|
@ -245,6 +289,11 @@ class Controller extends FilterTicketList {
|
||||||
callback: this.unmarkAsReserved,
|
callback: this.unmarkAsReserved,
|
||||||
name: 'Unmark as reserved'}
|
name: 'Unmark as reserved'}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.moreOptions.push({
|
||||||
|
callback: this.showEditDialog,
|
||||||
|
name: 'Update discount'}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -294,7 +343,7 @@ class Controller extends FilterTicketList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$scope', '$timeout', '$state', '$http', 'vnApp'];
|
Controller.$inject = ['$scope', '$timeout', '$state', '$http', 'vnApp', '$translate'];
|
||||||
|
|
||||||
ngModule.component('vnTicketSale', {
|
ngModule.component('vnTicketSale', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
|
|
|
@ -4,3 +4,8 @@ Delete ticket: Borrar ticket
|
||||||
Mark as reserved: Marcar como reservado
|
Mark as reserved: Marcar como reservado
|
||||||
Unmark as reserved: Desmarcar como reservado
|
Unmark as reserved: Desmarcar como reservado
|
||||||
Update discount: Actualizar descuento
|
Update discount: Actualizar descuento
|
||||||
|
There is no changes to save: No hay cambios que guardar
|
||||||
|
Edit discount: Editar descuento
|
||||||
|
Move to ticket: Mover a ticket
|
||||||
|
New ticket: Nuevo ticket
|
||||||
|
Edit price: Editar precio
|
|
@ -1,19 +1,47 @@
|
||||||
@import "colors";
|
@import "colors";
|
||||||
|
|
||||||
vn-popover.edit {
|
vn-popover.edit {
|
||||||
|
|
||||||
& div.popover{
|
& div.popover{
|
||||||
width: 200px;
|
width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
& vn-horizontal.header{
|
& vn-horizontal.header{
|
||||||
background-color: $main-01;
|
background-color: $main-01;
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
& h5{
|
& h5{
|
||||||
color: white;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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-ticket-sale{
|
vn-ticket-sale{
|
||||||
|
@ -42,3 +70,18 @@ vn-dialog.ticket-create{
|
||||||
padding: 0!important;
|
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
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue