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

View File

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

View File

@ -29,6 +29,9 @@ describe('claim', () => {
hide: () => {},
show: () => {}
};
controller.$.editPopover = {
hide: () => {}
};
}));
describe('openAddSalesDialog()', () => {
@ -110,16 +113,18 @@ describe('claim', () => {
spyOn(controller.vnApp, 'showSuccess');
spyOn(controller, 'calculateTotals');
spyOn(controller, 'clearDiscount');
spyOn(controller.$.model, 'refresh');
spyOn(controller.$.editPopover, 'hide');
$httpBackend.when('POST', 'Tickets/1/updateDiscount').respond({});
controller.updateDiscount();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
expect(controller.calculateTotals).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
Add sale item: Añadir artículo
Insuficient permisos: Permisos insuficientes
Total claimed price: Precio total reclamado

View File

@ -1,47 +1,27 @@
@import "variables";
vn-claim-detail {
.vn-textfield {
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;
.vn-popover .discount-popover {
width: 16em;
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;
.header {
background-color: $color-main;
color: $color-font-dark;
h5 {
color: inherit;
margin: 0 auto;
}
}
.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
New bank entity: Nueva entidad bancaria
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