#1023 claim.detail cantidad total parecer ser erronea

This commit is contained in:
Gerard 2019-01-22 10:31:12 +01:00
parent 457e68cd3c
commit b0a60fc94a
2 changed files with 49 additions and 34 deletions

View File

@ -82,38 +82,42 @@
</a>
</vn-vertical>
<!-- Add Lines Dialog -->
<vn-dialog vn-id="add-sales">
<vn-dialog vn-id="add-sales" class="modalForm">
<tpl-body>
<h3><span translate>Claimable sales from ticket</span> {{$ctrl.claim.ticketFk}}</h3>
<vn-table>
<vn-thead>
<vn-tr>
<vn-th number>Id</vn-th>
<vn-th number>Landed</vn-th>
<vn-th number>Quantity</vn-th>
<vn-th number>Description</vn-th>
<vn-th number>Price</vn-th>
<vn-th number>Disc.</vn-th>
<vn-th number>Total</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="sale in $ctrl.salesToClaim" class="clickable" ng-click="$ctrl.addClaimedSale($index)">
<vn-td number>{{sale.saleFk}} {{$index}}</vn-td>
<vn-td number>{{sale.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
<vn-td number>{{sale.quantity}}</vn-td>
<vn-td number>{{sale.concept}}</vn-td>
<vn-td number>{{sale.price | currency:'€':2}}</vn-td>
<vn-td number>{{sale.discount}} %</vn-td>
<vn-td number>
{{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency:'€':2}}
</vn-td>
</vn-tr>
</vn-tbody>
<vn-empty-rows ng-if="$ctrl.salesToClaim.length === 0" translate>
No results
</vn-empty-rows>
</vn-table>
<vn-horizontal pad-medium class="header">
<h5><span translate>Claimable sales from ticket</span> {{$ctrl.claim.ticketFk}}</h5>
</vn-horizontal>
<vn-horizontal pad-medium>
<vn-table>
<vn-thead>
<vn-tr>
<vn-th number>Id</vn-th>
<vn-th number>Landed</vn-th>
<vn-th number>Quantity</vn-th>
<vn-th number>Description</vn-th>
<vn-th number>Price</vn-th>
<vn-th number>Disc.</vn-th>
<vn-th number>Total</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="sale in $ctrl.salesToClaim" class="clickable" ng-click="$ctrl.addClaimedSale($index)">
<vn-td number>{{sale.saleFk}} {{$index}}</vn-td>
<vn-td number>{{sale.landed | dateTime: 'dd/MM/yyyy'}}</vn-td>
<vn-td number>{{sale.quantity}}</vn-td>
<vn-td number>{{sale.concept}}</vn-td>
<vn-td number>{{sale.price | currency:'€':2}}</vn-td>
<vn-td number>{{sale.discount}} %</vn-td>
<vn-td number>
{{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency:'€':2}}
</vn-td>
</vn-tr>
</vn-tbody>
<vn-empty-rows ng-if="$ctrl.salesToClaim.length === 0" translate>
No results
</vn-empty-rows>
</vn-table>
</vn-horizontal>
</tpl-body>
</vn-dialog>
<vn-item-descriptor-popover

View File

@ -24,6 +24,17 @@ class Controller {
};
}
set salesClaimed(value) {
this._salesClaimed = value;
if (value)
this.calculateTotals();
}
get salesClaimed() {
return this._salesClaimed;
}
openAddSalesDialog() {
this.getClaimableFromTicket();
this.$.addSales.show();
@ -71,9 +82,9 @@ class Controller {
calculateTotals() {
this.paidTotal = 0.0;
this.claimedTotal = 0.0;
if (!this.salesClaimed) return;
if (!this._salesClaimed) return;
this.salesClaimed.forEach(sale => {
this._salesClaimed.forEach(sale => {
let orgSale = sale.sale;
this.paidTotal += this.getSaleTotal(orgSale);
this.claimedTotal += sale.quantity * orgSale.price - ((orgSale.discount * (sale.quantity * orgSale.price)) / 100);
@ -81,7 +92,7 @@ class Controller {
}
getSaleTotal(sale) {
return sale.quantity * sale.price - ((100 - sale.discount) / 100);
return (sale.quantity * sale.price) - ((100 - sale.discount) / 100);
}
// Item Descriptor