Merge branch '1921-claim_detail_discount' of verdnatura/salix into dev
gitea/salix/dev This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-12-13 11:19:46 +00:00 committed by Gitea
commit da361a8ffb
7 changed files with 71 additions and 78 deletions

View File

@ -56,5 +56,6 @@
"Value has an invalid format": "Value has an invalid format", "Value has an invalid format": "Value has an invalid format",
"The postcode doesn't exists. Ensure you put the correct format": "The postcode doesn't exists. Ensure you put the correct format", "The postcode doesn't exists. Ensure you put the correct format": "The postcode doesn't exists. Ensure you put the correct format",
"Can't create stowaway for this ticket": "Can't create stowaway for this ticket", "Can't create stowaway for this ticket": "Can't create stowaway for this ticket",
"Has deleted the ticket id": "Has deleted the ticket id [#{{id}}]({{{url}}})" "Has deleted the ticket id": "Has deleted the ticket id [#{{id}}]({{{url}}})",
"Swift / BIC can't be empty": "Swift / BIC can't be empty"
} }

View File

@ -57,11 +57,11 @@
<span class="link" <span class="link"
vn-tooltip="Edit discount" vn-tooltip="Edit discount"
ng-click="$ctrl.showEditPopover($event, saleClaimed)"> ng-click="$ctrl.showEditPopover($event, saleClaimed)">
{{::saleClaimed.sale.discount}} % {{saleClaimed.sale.discount}} %
</span> </span>
</vn-td> </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>
<vn-td shrink> <vn-td shrink>
<vn-icon-button <vn-icon-button
@ -125,31 +125,33 @@
<vn-popover <vn-popover
class="edit" class="edit"
vn-id="edit-popover" vn-id="edit-popover"
on-open="$ctrl.getManaSalespersonMana()" on-open="$ctrl.getSalespersonMana()"
on-close="$ctrl.mana = null"> on-close="$ctrl.mana = null">
<vn-spinner <div class="discount-popover">
ng-if="$ctrl.mana == null" <vn-spinner
style="padding: 1em;" ng-if="$ctrl.mana == null"
enable="true"> style="padding: 1em;"
</vn-spinner> enable="true">
<div ng-if="$ctrl.mana != null"> </vn-spinner>
<vn-horizontal class="header vn-pa-md"> <div ng-if="$ctrl.mana != null">
<h5>MANÁ: {{$ctrl.mana | currency: 'EUR':0}}</h5> <vn-horizontal class="header vn-pa-md">
</vn-horizontal> <h5>MANÁ: {{$ctrl.mana | currency: 'EUR':0}}</h5>
<div class="vn-pa-md"> </vn-horizontal>
<vn-input-number <div class="vn-pa-md">
vn-focus <vn-input-number
label="Discount" vn-focus
ng-model="$ctrl.newDiscount" label="Discount"
type="text" ng-model="$ctrl.newDiscount"
step="0.01" type="text"
on-change="$ctrl.updateDiscount()" step="0.01"
suffix="€"> on-change="$ctrl.updateDiscount()"
</vn-input-number> suffix="€">
<div class="simulator"> </vn-input-number>
<p class="simulatorTitle" translate>New price</p> <div class="simulator">
<p>{{$ctrl.newPrice | currency: 'EUR':2}} <p class="simulatorTitle" translate>Total claimed price</p>
</p> <p>{{$ctrl.newPrice | currency: 'EUR':2}}
</p>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -128,25 +128,30 @@ class Controller {
this.$.editPopover.show(); this.$.editPopover.show();
} }
getManaSalespersonMana() { getSalespersonMana() {
this.$http.get(`Tickets/${this.claim.ticketFk}/getSalesPersonMana`).then(res => { this.$http.get(`Tickets/${this.claim.ticketFk}/getSalesPersonMana`).then(res => {
this.mana = res.data; this.mana = res.data;
}); });
} }
updateDiscount() { updateDiscount() {
if (this.newDiscount != this.saleClaimed.sale.discount) { const claimedSale = this.saleClaimed.sale;
const params = {salesIds: [this.saleClaimed.sale.id], newDiscount: this.newDiscount}; if (this.newDiscount != claimedSale.discount) {
const query = `Tickets/${this.saleClaimed.sale.ticketFk}/updateDiscount`; const params = {salesIds: [claimedSale.id], newDiscount: this.newDiscount};
const query = `Tickets/${claimedSale.ticketFk}/updateDiscount`;
this.$http.post(query, params).then(() => { this.$http.post(query, params).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!')); claimedSale.discount = this.newDiscount;
this.calculateTotals();
this.clearDiscount(); this.clearDiscount();
this.$.model.refresh();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
}).catch(err => { }).catch(err => {
this.vnApp.showError(err.message); this.vnApp.showError(err.message);
}); });
} }
this.$.editPopover.hide();
} }
updateNewPrice() { updateNewPrice() {

View File

@ -29,6 +29,9 @@ describe('claim', () => {
hide: () => {}, hide: () => {},
show: () => {} show: () => {}
}; };
controller.$.editPopover = {
hide: () => {}
};
})); }));
describe('openAddSalesDialog()', () => { describe('openAddSalesDialog()', () => {
@ -110,16 +113,18 @@ describe('claim', () => {
spyOn(controller.vnApp, 'showSuccess'); spyOn(controller.vnApp, 'showSuccess');
spyOn(controller, 'calculateTotals');
spyOn(controller, 'clearDiscount'); spyOn(controller, 'clearDiscount');
spyOn(controller.$.model, 'refresh'); spyOn(controller.$.editPopover, 'hide');
$httpBackend.when('POST', 'Tickets/1/updateDiscount').respond({}); $httpBackend.when('POST', 'Tickets/1/updateDiscount').respond({});
controller.updateDiscount(); controller.updateDiscount();
$httpBackend.flush(); $httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.calculateTotals).toHaveBeenCalledWith();
expect(controller.clearDiscount).toHaveBeenCalledWith(); expect(controller.clearDiscount).toHaveBeenCalledWith();
expect(controller.$.model.refresh).toHaveBeenCalledWith(); expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
expect(controller.$.editPopover.hide).toHaveBeenCalledWith();
}); });
}); });

View File

@ -7,3 +7,4 @@ 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 Insuficient permisos: Permisos insuficientes
Total claimed price: Precio total reclamado

View File

@ -1,47 +1,27 @@
@import "variables"; @import "variables";
vn-claim-detail { .vn-popover .discount-popover {
.vn-textfield { width: 16em;
margin: 0!important;
max-width: 100px;
}
vn-dialog[vn-id=addSales] {
tpl-body {
width: 950px;
div {
div.buttons {
display: none;
}
vn-table{
min-width: 950px;
}
}
}
}
vn-popover.edit {
div.popover {
width: 200px;
}
vn-horizontal.header {
background-color: $color-main;
color: $color-font-dark;
h5 { .header {
color: inherit; background-color: $color-main;
margin: 0 auto; color: $color-font-dark;
}
} h5 {
p.simulatorTitle { color: inherit;
margin-bottom: 0px; margin: 0 auto;
font-size: 12px;
color: $color-main;
}
vn-label-value {
padding-bottom: 20px;
}
div.simulator{
text-align: center;
} }
} }
.simulatorTitle {
margin-bottom: 0px;
font-size: 12px;
color: $color-main;
}
vn-label-value {
padding-bottom: 20px;
}
.simulator{
text-align: center;
}
} }

View File

@ -15,5 +15,4 @@ Received B2B VNL: Recibido B2B VNL
Save: Guardar Save: Guardar
New bank entity: Nueva entidad bancaria New bank entity: Nueva entidad bancaria
Name can't be empty: El nombre no puede quedar vacío Name can't be empty: El nombre no puede quedar vacío
Swift / BIC can't be empty: El Swift / BIC no puede quedar vacío
Entity Code: Código Entity Code: Código