Tarea #1419 claim.detail permitir modificar descuento
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
parent
4729a7e9a9
commit
a6951bc0a1
|
@ -52,7 +52,13 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td expand>{{::saleClaimed.sale.concept}}</vn-td>
|
<vn-td expand>{{::saleClaimed.sale.concept}}</vn-td>
|
||||||
<vn-td number>{{::saleClaimed.sale.price | currency: 'EUR':2}}</vn-td>
|
<vn-td number>{{::saleClaimed.sale.price | currency: 'EUR':2}}</vn-td>
|
||||||
<vn-td number>{{::saleClaimed.sale.discount}} %</vn-td>
|
<vn-td number>
|
||||||
|
<span class="link"
|
||||||
|
vn-tooltip="Edit discount"
|
||||||
|
ng-click="$ctrl.showEditPopover($event, saleClaimed)">
|
||||||
|
{{::saleClaimed.sale.discount}} %
|
||||||
|
</span>
|
||||||
|
</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
{{::$ctrl.getSaleTotal(saleClaimed.sale) | currency: 'EUR':2}}
|
{{::$ctrl.getSaleTotal(saleClaimed.sale) | currency: 'EUR':2}}
|
||||||
</vn-td>
|
</vn-td>
|
||||||
|
@ -112,3 +118,40 @@
|
||||||
<vn-item-descriptor-popover
|
<vn-item-descriptor-popover
|
||||||
vn-id="descriptor">
|
vn-id="descriptor">
|
||||||
</vn-item-descriptor-popover>
|
</vn-item-descriptor-popover>
|
||||||
|
<vn-popover
|
||||||
|
class="edit dialog-summary"
|
||||||
|
vn-id="edit-popover"
|
||||||
|
on-open="$ctrl.getManaSalespersonMana()"
|
||||||
|
on-close="$ctrl.mana = null">
|
||||||
|
<vn-spinner
|
||||||
|
ng-if="$ctrl.mana == null"
|
||||||
|
style="padding: 1em;"
|
||||||
|
enable="true">
|
||||||
|
</vn-spinner>
|
||||||
|
<div ng-if="$ctrl.mana != null">
|
||||||
|
<vn-horizontal pad-medium class="header">
|
||||||
|
<h5>MANÁ: {{$ctrl.mana | currency: 'EUR':0}}</h5>
|
||||||
|
</vn-horizontal>
|
||||||
|
<div pad-medium>
|
||||||
|
<vn-input-number
|
||||||
|
vn-focus
|
||||||
|
label="Discount"
|
||||||
|
model="$ctrl.newDiscount"
|
||||||
|
type="text"
|
||||||
|
step="0.01"
|
||||||
|
on-change="$ctrl.updateDiscount()">
|
||||||
|
<t-right-icons>
|
||||||
|
<span class="filter">€</span>
|
||||||
|
</t-right-icons>
|
||||||
|
</vn-input-number>
|
||||||
|
<div class="simulator">
|
||||||
|
<p class="simulatorTitle" translate>New price</p>
|
||||||
|
<p>{{($ctrl.saleClaimed.quantity * $ctrl.saleClaimed.sale.price) -
|
||||||
|
(($ctrl.newDiscount * ($ctrl.saleClaimed.quantity * $ctrl.saleClaimed.sale.price))/100)
|
||||||
|
| currency: 'EUR':2}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</vn-popover>
|
||||||
|
<p>
|
|
@ -2,13 +2,14 @@ import ngModule from '../module';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
class Controller {
|
class Controller {
|
||||||
constructor($state, $scope, $http, $translate, vnApp, aclService) {
|
constructor($state, $, $http, $translate, vnApp, aclService) {
|
||||||
this.$state = $state;
|
this.$state = $state;
|
||||||
this.$scope = $scope;
|
this.$ = $;
|
||||||
this.$http = $http;
|
this.$http = $http;
|
||||||
this.$translate = $translate;
|
this.$translate = $translate;
|
||||||
this.vnApp = vnApp;
|
this.vnApp = vnApp;
|
||||||
this.aclService = aclService;
|
this.aclService = aclService;
|
||||||
|
this.edit = {};
|
||||||
this.filter = {
|
this.filter = {
|
||||||
where: {claimFk: $state.params.id},
|
where: {claimFk: $state.params.id},
|
||||||
include: [
|
include: [
|
||||||
|
@ -38,7 +39,7 @@ class Controller {
|
||||||
|
|
||||||
openAddSalesDialog() {
|
openAddSalesDialog() {
|
||||||
this.getClaimableFromTicket();
|
this.getClaimableFromTicket();
|
||||||
this.$scope.addSales.show();
|
this.$.addSales.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
getClaimableFromTicket() {
|
getClaimableFromTicket() {
|
||||||
|
@ -55,8 +56,8 @@ class Controller {
|
||||||
let saleToAdd = {saleFk: sale.saleFk, claimFk: this.claim.id, quantity: sale.quantity};
|
let saleToAdd = {saleFk: sale.saleFk, claimFk: this.claim.id, quantity: sale.quantity};
|
||||||
let query = `claim/api/ClaimBeginnings/`;
|
let query = `claim/api/ClaimBeginnings/`;
|
||||||
this.$http.post(query, saleToAdd).then(() => {
|
this.$http.post(query, saleToAdd).then(() => {
|
||||||
this.$scope.addSales.hide();
|
this.$.addSales.hide();
|
||||||
this.$scope.model.refresh();
|
this.$.model.refresh();
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
|
|
||||||
if (this.aclService.hasAny(['salesAssistant']))
|
if (this.aclService.hasAny(['salesAssistant']))
|
||||||
|
@ -69,7 +70,7 @@ class Controller {
|
||||||
let query = `claim/api/ClaimBeginnings/${sale.id}`;
|
let query = `claim/api/ClaimBeginnings/${sale.id}`;
|
||||||
this.$http.delete(query).then(() => {
|
this.$http.delete(query).then(() => {
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
this.$scope.model.remove(index);
|
this.$.model.remove(index);
|
||||||
this.calculateTotals();
|
this.calculateTotals();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -103,9 +104,44 @@ class Controller {
|
||||||
|
|
||||||
// Item Descriptor
|
// Item Descriptor
|
||||||
showDescriptor(event, itemFk) {
|
showDescriptor(event, itemFk) {
|
||||||
this.$scope.descriptor.itemFk = itemFk;
|
this.$.descriptor.itemFk = itemFk;
|
||||||
this.$scope.descriptor.parent = event.target;
|
this.$.descriptor.parent = event.target;
|
||||||
this.$scope.descriptor.show();
|
this.$.descriptor.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
showEditPopover(event, saleClaimed) {
|
||||||
|
this.saleClaimed = saleClaimed;
|
||||||
|
|
||||||
|
if (!this.aclService.hasAny(['salesAssistant']))
|
||||||
|
return this.vnApp.showError(this.$translate.instant('Insuficient permisos'));
|
||||||
|
|
||||||
|
this.$.editPopover.parent = event.target;
|
||||||
|
this.$.editPopover.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
getManaSalespersonMana() {
|
||||||
|
this.$http.get(`/api/Tickets/${this.claim.ticketFk}/getSalesPersonMana`).then(res => {
|
||||||
|
this.mana = res.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDiscount() {
|
||||||
|
if (this.newDiscount != this.saleClaimed.sale.discount) {
|
||||||
|
const params = {salesIds: [this.saleClaimed.sale.id], newDiscount: this.newDiscount};
|
||||||
|
const query = `/api/Tickets/${this.saleClaimed.sale.ticketFk}/updateDiscount`;
|
||||||
|
|
||||||
|
this.$http.post(query, params).then(() => {
|
||||||
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
|
this.clearDiscount();
|
||||||
|
this.$.model.refresh();
|
||||||
|
}).catch(err => {
|
||||||
|
this.vnApp.showError(err.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clearDiscount() {
|
||||||
|
this.newDiscount = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ describe('claim', () => {
|
||||||
controller.salesToClaim = [{saleFk: 1}, {saleFk: 2}];
|
controller.salesToClaim = [{saleFk: 1}, {saleFk: 2}];
|
||||||
controller.salesClaimed = [{id: 1, sale: {}}];
|
controller.salesClaimed = [{id: 1, sale: {}}];
|
||||||
controller.claim = {ticketFk: 1};
|
controller.claim = {ticketFk: 1};
|
||||||
controller.$scope.model = crudModel;
|
controller.$.model = crudModel;
|
||||||
controller.$scope.addSales = {
|
controller.$.addSales = {
|
||||||
hide: () => {},
|
hide: () => {},
|
||||||
show: () => {}
|
show: () => {}
|
||||||
};
|
};
|
||||||
|
@ -30,11 +30,11 @@ describe('claim', () => {
|
||||||
it('should call getClaimableFromTicket and $.addSales.show', () => {
|
it('should call getClaimableFromTicket and $.addSales.show', () => {
|
||||||
controller.$ = {addSales: {show: () => {}}};
|
controller.$ = {addSales: {show: () => {}}};
|
||||||
spyOn(controller, 'getClaimableFromTicket');
|
spyOn(controller, 'getClaimableFromTicket');
|
||||||
spyOn(controller.$scope.addSales, 'show');
|
spyOn(controller.$.addSales, 'show');
|
||||||
controller.openAddSalesDialog();
|
controller.openAddSalesDialog();
|
||||||
|
|
||||||
expect(controller.getClaimableFromTicket).toHaveBeenCalledWith();
|
expect(controller.getClaimableFromTicket).toHaveBeenCalledWith();
|
||||||
expect(controller.$scope.addSales.show).toHaveBeenCalledWith();
|
expect(controller.$.addSales.show).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -50,25 +50,25 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('addClaimedSale(index)', () => {
|
describe('addClaimedSale(index)', () => {
|
||||||
it('should make a post and call refresh, hide and showSuccess', () => {
|
it('should make a post and call refresh, hide and showSuccess', () => {
|
||||||
spyOn(controller.$scope.addSales, 'hide');
|
spyOn(controller.$.addSales, 'hide');
|
||||||
spyOn(controller.$state, 'go');
|
spyOn(controller.$state, 'go');
|
||||||
$httpBackend.expectPOST(`claim/api/ClaimBeginnings/`).respond({});
|
$httpBackend.expectPOST(`claim/api/ClaimBeginnings/`).respond({});
|
||||||
controller.addClaimedSale(1);
|
controller.addClaimedSale(1);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.$scope.addSales.hide).toHaveBeenCalledWith();
|
expect(controller.$.addSales.hide).toHaveBeenCalledWith();
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.development');
|
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.development');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('deleteClaimedSale(index)', () => {
|
describe('deleteClaimedSale(index)', () => {
|
||||||
it('should make a delete and call refresh and showSuccess', () => {
|
it('should make a delete and call refresh and showSuccess', () => {
|
||||||
spyOn(controller.$scope.model, 'remove');
|
spyOn(controller.$.model, 'remove');
|
||||||
$httpBackend.expectDELETE(`claim/api/ClaimBeginnings/1`).respond({});
|
$httpBackend.expectDELETE(`claim/api/ClaimBeginnings/1`).respond({});
|
||||||
controller.deleteClaimedSale(0);
|
controller.deleteClaimedSale(0);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.$scope.model.remove).toHaveBeenCalledWith(0);
|
expect(controller.$.model.remove).toHaveBeenCalledWith(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -92,5 +92,26 @@ describe('claim', () => {
|
||||||
expect(controller.claimedTotal).toEqual(0);
|
expect(controller.claimedTotal).toEqual(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('updateDiscount()', () => {
|
||||||
|
it('should perform a query if the new discount differs from the claim discount', () => {
|
||||||
|
controller.newDiscount = 10;
|
||||||
|
controller.saleClaimed = {sale: {discount: 5}};
|
||||||
|
controller.saleClaimed = {sale: {id: 7}};
|
||||||
|
controller.saleClaimed = {sale: {ticketFk: 1}};
|
||||||
|
|
||||||
|
spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
spyOn(controller, 'clearDiscount');
|
||||||
|
spyOn(controller.$.model, 'refresh');
|
||||||
|
|
||||||
|
$httpBackend.when('POST', '/api/Tickets/1/updateDiscount').respond({});
|
||||||
|
controller.updateDiscount();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
||||||
|
expect(controller.clearDiscount).toHaveBeenCalledWith();
|
||||||
|
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,3 +6,4 @@ Price: Precio
|
||||||
Claimable sales from ticket: Lineas reclamables del ticket
|
Claimable sales from ticket: Lineas reclamables del ticket
|
||||||
Detail: Detalles
|
Detail: Detalles
|
||||||
Add sale item: Añadir artículo
|
Add sale item: Añadir artículo
|
||||||
|
Insuficient permisos: Permisos insuficientes
|
|
@ -1,3 +1,5 @@
|
||||||
|
@import "variables";
|
||||||
|
|
||||||
vn-claim-detail {
|
vn-claim-detail {
|
||||||
vn-textfield {
|
vn-textfield {
|
||||||
margin: 0!important;
|
margin: 0!important;
|
||||||
|
@ -16,5 +18,30 @@ vn-claim-detail {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
vn-popover.edit {
|
||||||
|
div.popover {
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
vn-horizontal.header {
|
||||||
|
background-color: $color-main;
|
||||||
|
color: $color-font-dark;
|
||||||
|
|
||||||
|
h5 {
|
||||||
|
color: inherit;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.simulatorTitle {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: $color-main;
|
||||||
|
}
|
||||||
|
vn-label-value {
|
||||||
|
padding-bottom: 20px;
|
||||||
|
}
|
||||||
|
div.simulator{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue