parent
9527b839df
commit
54ee27dcef
|
@ -73,27 +73,36 @@
|
|||
{{::sale.itemFk}}
|
||||
</td>
|
||||
<td><vn-fetched-tags sale="sale"/></td>
|
||||
<td number>{{sale.quantity}}</td>
|
||||
<!--<td ng-if="$ctrl.ticket.tracking.state.alertLevel == 0">
|
||||
<td ng-if="!$ctrl.isEditable" number>{{sale.quantity}}</td>
|
||||
<td ng-if="$ctrl.isEditable" number>
|
||||
<vn-textfield
|
||||
model="sale.quantity"
|
||||
type="number"
|
||||
ng-blur="updateLine()">
|
||||
on-change="$ctrl.updateQuantity(sale.id,sale.quantity)"
|
||||
unclearable="true">
|
||||
</vn-textfield>
|
||||
</td>-->
|
||||
<td number>{{sale.price | currency:'€':2}}</td>
|
||||
<td number>{{sale.discount}} %</td>
|
||||
<td number>{{sale.quantity * sale.price | currency:'€':2}}</td>
|
||||
<!--<td number>
|
||||
<vn-icon-button
|
||||
ng-if="$ctrl.ticket.tracking.state.alertLevel == 0"
|
||||
pointer
|
||||
vn-tooltip="Add note"
|
||||
tooltip-position="left"
|
||||
icon="mode_edit"
|
||||
ng-click="$ctrl.showEditPopover($event, sale)">
|
||||
</vn-icon-button>
|
||||
</td>-->
|
||||
</td>
|
||||
<td number
|
||||
ng-if="$ctrl.isEditable"
|
||||
ng-click="$ctrl.showEditPricePopover($event, sale)"
|
||||
pointer
|
||||
vn-tooltip="Edit Price">
|
||||
{{sale.price | currency:'€':2}}
|
||||
</td>
|
||||
<td number ng-if="!$ctrl.isEditable">
|
||||
{{sale.price | currency:'€':2}}
|
||||
</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 ng-if="index.model.count === 0" class="list list-element">
|
||||
<td colspan="8" style="text-align: center" translate>No results</td>
|
||||
|
@ -166,35 +175,66 @@
|
|||
</tpl-body>
|
||||
</vn-dialog>
|
||||
|
||||
<!-- Edit Popover -->
|
||||
<vn-popover class="edit" vn-id="edit">
|
||||
<!-- Edit Price Popover -->
|
||||
<vn-popover
|
||||
class="edit dialog-summary"
|
||||
vn-id="editPricePopover"
|
||||
on-open="$ctrl.getManaSalespersonMana()">
|
||||
<vn-horizontal pad-medium class="header">
|
||||
<h5>MANÁ: {{$ctrl.workerMana}}</h5>
|
||||
<h5>MANÁ: {{$ctrl.mana | currency:' €':0}}</h5>
|
||||
</vn-horizontal>
|
||||
<div pad-medium>
|
||||
<h5>{{$ctrl.client.name}}</h5>
|
||||
<vn-textfield
|
||||
label="Quantity"
|
||||
model="$ctrl.edit.quantity"
|
||||
type="number">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-focus
|
||||
label="Price"
|
||||
model="$ctrl.edit.price"
|
||||
type="number">
|
||||
model="$ctrl.editedPrice"
|
||||
type="number"
|
||||
on-change="$ctrl.updatePrice()">
|
||||
<t-right-icons>
|
||||
<span class="filter">€</span>
|
||||
</t-right-icons>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
label="Discount"
|
||||
model="$ctrl.edit.discount"
|
||||
type="number">
|
||||
</vn-textfield>
|
||||
<vn-button
|
||||
label="Save"
|
||||
ng-click="$ctrl.updateLine()">
|
||||
</vn-button>
|
||||
<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
|
||||
label="Save"
|
||||
ng-click="$ctrl.updatePrice()">
|
||||
</vn-button>
|
||||
</div>
|
||||
</div>
|
||||
</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 -->
|
||||
<vn-popover class="transfer" vn-id="transfer">
|
||||
<div pad-medium>
|
||||
|
@ -232,11 +272,11 @@
|
|||
ng-click="$ctrl.moveLines($ctrl.moveToTicketFk)">
|
||||
</vn-icon-button>
|
||||
</vn-horizontal>
|
||||
<!-- <vn-button
|
||||
<vn-button
|
||||
pointer
|
||||
label="New ticket"
|
||||
ng-click="$ctrl.showticketCreate()">
|
||||
</vn-button> -->
|
||||
ng-click="$ctrl.linesToNewTicket()">
|
||||
</vn-button>
|
||||
</div>
|
||||
</vn-popover>
|
||||
</vn-vertical>
|
||||
|
|
|
@ -3,15 +3,17 @@ import FilterTicketList from '../filter-ticket-list';
|
|||
import './style.scss';
|
||||
|
||||
class Controller extends FilterTicketList {
|
||||
constructor($scope, $timeout, $stateParams, $http, $state, vnApp) {
|
||||
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;
|
||||
this.edit = {};
|
||||
this.moreOptions = [
|
||||
{callback: this.showAddTurnDialog, name: "Add turn"},
|
||||
{callback: this.showDeleteTicketDialog, name: "Delete ticket"}
|
||||
|
@ -28,7 +30,7 @@ class Controller extends FilterTicketList {
|
|||
|
||||
this.subTotal = 0.00;
|
||||
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};
|
||||
this.$http.post(`/ticket/api/TicketTrackings/changeState`, params).then(() => {
|
||||
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() {
|
||||
let params = [this.ticket.clientFk, this.ticket.warehouseFk, this.ticket.companyFk, this.ticket.addressFk, this.ticket.agencyModeFk, null];
|
||||
this.$http.post(`/ticket/api/Tickets/create`, params).then(res => {
|
||||
console.log(res);
|
||||
// In Progress
|
||||
linesToNewTicket() {
|
||||
let ticket = {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
// Slesperson Mana
|
||||
getManaSalespersonMana() {
|
||||
this.$http.get(`/api/Tickets/${this.$state.params.id}/getSalesPersonMana`).then(res => {
|
||||
this.mana = res.data;
|
||||
});
|
||||
}
|
||||
// Item Descriptor
|
||||
showDescriptor(event, itemFk) {
|
||||
this.$.descriptor.itemFk = itemFk;
|
||||
|
@ -177,39 +195,65 @@ class Controller extends FilterTicketList {
|
|||
this.$.popover.relocate();
|
||||
}
|
||||
|
||||
// Ticket Create
|
||||
showticketCreate() {
|
||||
console.log(this);
|
||||
this.$.newTicket.show();
|
||||
// Edit Line
|
||||
showEditPricePopover(event, sale) {
|
||||
this.sale = sale;
|
||||
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) {
|
||||
if (response === 'ACCEPT') {
|
||||
let newTicketID = this.$.newTicket.dialog.createTicket();
|
||||
console.log(newTicketID);
|
||||
updatePrice() {
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
// Edit Line
|
||||
_getworkerMana() {
|
||||
this.$http.get(`/api/WorkerManas/getCurrentWorkerMana`).then(res => {
|
||||
this.workerMana = res.data[0].mana;
|
||||
});
|
||||
this.$.editPricePopover.hide();
|
||||
}
|
||||
|
||||
showEditPopover(event, sale) {
|
||||
this.sale = sale;
|
||||
this.edit = {
|
||||
this.edit = [{
|
||||
ticketFk: this.ticket.id,
|
||||
id: sale.id,
|
||||
quantity: sale.quantity,
|
||||
price: sale.price,
|
||||
discount: sale.discount
|
||||
};
|
||||
this.$.edit.parent = event.target;
|
||||
this._getworkerMana();
|
||||
this.$.edit.show();
|
||||
}];
|
||||
this.$.editPopover.parent = event.target;
|
||||
this.$.editPopover.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) {
|
||||
this.$http.post(`/ticket/api/Sales/updateQuantity`, {id: this.edit.id, quantity: this.edit.quantity}).then(() => {
|
||||
this.sale.quantity = this.edit.quantity;
|
||||
|
@ -228,12 +272,12 @@ class Controller extends FilterTicketList {
|
|||
});
|
||||
}
|
||||
this.$.edit.hide();
|
||||
}
|
||||
}*/
|
||||
|
||||
onMoreClick() {
|
||||
this.removeOptionByName('Mark as reserved');
|
||||
this.removeOptionByName('Unmark as reserved');
|
||||
|
||||
this.removeOptionByName('Update discount');
|
||||
if (!this.isChecked) return;
|
||||
|
||||
this.moreOptions.push({
|
||||
|
@ -245,6 +289,11 @@ class Controller extends FilterTicketList {
|
|||
callback: this.unmarkAsReserved,
|
||||
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', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -4,3 +4,8 @@ Delete ticket: Borrar ticket
|
|||
Mark as reserved: Marcar como reservado
|
||||
Unmark as reserved: Desmarcar como reservado
|
||||
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";
|
||||
|
||||
vn-popover.edit {
|
||||
|
||||
& div.popover{
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
& vn-horizontal.header{
|
||||
background-color: $main-01;
|
||||
text-align: center;
|
||||
|
||||
& 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;
|
||||
}
|
||||
}
|
||||
|
||||
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{
|
||||
|
@ -28,7 +56,7 @@ vn-popover.transfer{
|
|||
min-width: 650px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
& i {
|
||||
& i {
|
||||
padding-top: 0.2em;
|
||||
font-size: 1.8em;
|
||||
}
|
||||
|
@ -41,4 +69,19 @@ vn-dialog.ticket-create{
|
|||
& 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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue