Tarea #445 claim.detail
This commit is contained in:
parent
dacdc39a28
commit
0333ba96b0
|
@ -2,12 +2,22 @@
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="claim/api/ClaimBeginnings"
|
url="claim/api/ClaimBeginnings"
|
||||||
filter="$ctrl.filter"
|
filter="$ctrl.filter"
|
||||||
data="$ctrl.salesClaimed" on-data-change="$ctrl.onDataChange()">
|
data="$ctrl.salesClaimed">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-card pad-large>
|
<vn-card pad-large>
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
<vn-title>Detail</vn-title>
|
<vn-horizontal>
|
||||||
|
<vn-title vn-two>Detail</vn-title>
|
||||||
|
<div class="totalBox">
|
||||||
|
<vn-label-value label="Total"
|
||||||
|
value="{{$ctrl.paidTotal | currency:'€':2}}">
|
||||||
|
</vn-label-value>
|
||||||
|
<vn-label-value label="Total claimed"
|
||||||
|
value="{{$ctrl.claimedTotal | currency:'€':2}}">
|
||||||
|
</vn-label-value>
|
||||||
|
</div>
|
||||||
|
</vn-horizontal>
|
||||||
<vn-table model="model">
|
<vn-table model="model">
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
|
@ -22,12 +32,13 @@
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr ng-repeat="saleClaimed in $ctrl.salesClaimed" vn-repeat-last on-last="$ctrl.focusLastInput()">
|
<vn-tr ng-repeat="saleClaimed in $ctrl.salesClaimed" vn-repeat-last on-last="$ctrl.calculateTotals()">
|
||||||
<vn-td number>{{saleClaimed.sale.id}}</vn-td>
|
<vn-td number>{{saleClaimed.sale.id}}</vn-td>
|
||||||
<vn-td number>{{saleClaimed.sale.ticket.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
|
<vn-td number>{{saleClaimed.sale.ticket.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
|
||||||
<vn-td number>{{saleClaimed.sale.quantity}}</vn-td>
|
<vn-td number>{{saleClaimed.sale.quantity}}</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
|
vn-focus
|
||||||
id="claimedQuantity"
|
id="claimedQuantity"
|
||||||
model="saleClaimed.quantity"
|
model="saleClaimed.quantity"
|
||||||
on-change="$ctrl.setClaimedQuantity(saleClaimed.id, saleClaimed.quantity)"
|
on-change="$ctrl.setClaimedQuantity(saleClaimed.id, saleClaimed.quantity)"
|
||||||
|
@ -59,16 +70,11 @@
|
||||||
No results
|
No results
|
||||||
</vn-empty-rows>
|
</vn-empty-rows>
|
||||||
</vn-table>
|
</vn-table>
|
||||||
<vn-one pad-medium-top>
|
|
||||||
<vn-icon-button
|
|
||||||
vn-bind="+"
|
|
||||||
vn-tooltip="Add tag"
|
|
||||||
icon="add_circle"
|
|
||||||
ng-click="$ctrl.openAddSalesDialog()">
|
|
||||||
</vn-icon-button>
|
|
||||||
</vn-one>
|
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
<a ng-click="$ctrl.openAddSalesDialog()" vn-tooltip="New item" vn-bind="+" fixed-bottom-right>
|
||||||
|
<vn-float-button icon="add"></vn-float-button>
|
||||||
|
</a>
|
||||||
|
|
||||||
<!-- Add Lines Dialog -->
|
<!-- Add Lines Dialog -->
|
||||||
<vn-dialog
|
<vn-dialog
|
||||||
|
|
|
@ -58,11 +58,6 @@ class Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
focusLastInput() {
|
|
||||||
let inputs = document.querySelectorAll("#claimedQuantity");
|
|
||||||
inputs[inputs.length - 1].querySelector("input").select();
|
|
||||||
}
|
|
||||||
|
|
||||||
setClaimedQuantity(id, claimedQuantity) {
|
setClaimedQuantity(id, claimedQuantity) {
|
||||||
let params = {id: id, quantity: claimedQuantity};
|
let params = {id: id, quantity: claimedQuantity};
|
||||||
let query = `claim/api/ClaimBeginnings/`;
|
let query = `claim/api/ClaimBeginnings/`;
|
||||||
|
@ -71,6 +66,17 @@ class Controller {
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calculateTotals() {
|
||||||
|
this.paidTotal = 0;
|
||||||
|
this.salesClaimed.forEach(sale => {
|
||||||
|
this.paidTotal += (sale.sale.quantity * sale.sale.price) - ((sale.sale.discount * (sale.sale.quantity * sale.sale.price)) / 100);
|
||||||
|
});
|
||||||
|
this.claimedTotal = 0;
|
||||||
|
this.salesClaimed.forEach(sale => {
|
||||||
|
this.claimedTotal += (sale.quantity * sale.sale.price) - ((sale.sale.discount * (sale.quantity * sale.sale.price)) / 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp'];
|
Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp'];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import './index.js';
|
import './index.js';
|
||||||
|
|
||||||
describe('claim', () => {
|
fdescribe('claim', () => {
|
||||||
describe('Component vnClaimDetail', () => {
|
describe('Component vnClaimDetail', () => {
|
||||||
let $componentController;
|
let $componentController;
|
||||||
let controller;
|
let controller;
|
||||||
|
@ -90,5 +90,15 @@ describe('claim', () => {
|
||||||
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('calculateTotals()', () => {
|
||||||
|
it('should set paidTotal and claimedTotal to 0 if salesClaimed has no data', () => {
|
||||||
|
controller.salesClaimed = [];
|
||||||
|
controller.calculateTotals();
|
||||||
|
|
||||||
|
expect(controller.paidTotal).toEqual(0);
|
||||||
|
expect(controller.claimedTotal).toEqual(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue