Fix: Product Ledger was taking into account unposted entries and also the footer was not displaying the totals

This commit is contained in:
tanshu 2018-06-28 16:38:27 +05:30
parent b8c2e9eeb1
commit c6272762da
2 changed files with 9 additions and 24 deletions

View File

@ -66,46 +66,46 @@
<ng-container matColumnDef="debitQuantity">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Debit Quantity</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{row.debitQuantity | number:'1.2-2'}}</mat-cell>
<mat-footer-cell *matFooterCellDef>{{info.debitQuantity | number:'1.2-2'}}</mat-footer-cell>
<mat-footer-cell *matFooterCellDef class="right">{{debitQuantity | number:'1.2-2'}}</mat-footer-cell>
</ng-container>
<!-- Debit Column -->
<ng-container matColumnDef="debitAmount">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Amount</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{row.debitAmount | currency:'INR'}}</mat-cell>
<mat-footer-cell *matFooterCellDef>{{info.debitAmount | currency:'INR'}}</mat-footer-cell>
<mat-footer-cell *matFooterCellDef class="right">{{debitAmount | currency:'INR'}}</mat-footer-cell>
</ng-container>
<!-- Credit Column -->
<ng-container matColumnDef="creditQuantity">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Credit</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{row.creditQuantity | number:'1.2-2'}}</mat-cell>
<mat-footer-cell *matFooterCellDef>{{info.creditQuantity | number:'1.2-2'}}</mat-footer-cell>
<mat-footer-cell *matFooterCellDef class="right">{{creditQuantity | number:'1.2-2'}}</mat-footer-cell>
</ng-container>
<!-- Credit Column -->
<ng-container matColumnDef="creditAmount">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Credit</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{row.creditAmount | currency:'INR'}}</mat-cell>
<mat-footer-cell *matFooterCellDef>{{info.creditAmount | currency:'INR'}}</mat-footer-cell>
<mat-footer-cell *matFooterCellDef class="right">{{creditAmount | currency:'INR'}}</mat-footer-cell>
</ng-container>
<!-- Running Column -->
<ng-container matColumnDef="runningQuantity">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Running</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{row.runningQuantity | number:'1.2-2'}}</mat-cell>
<mat-footer-cell *matFooterCellDef>{{info.runningQuantity | number:'1.2-2'}}</mat-footer-cell>
<mat-footer-cell *matFooterCellDef class="right">{{runningQuantity | number:'1.2-2'}}</mat-footer-cell>
</ng-container>
<!-- Running Column -->
<ng-container matColumnDef="runningAmount">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Running</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{row.runningAmount | currency:'INR'}}</mat-cell>
<mat-footer-cell *matFooterCellDef>{{info.runningAmount | currency:'INR'}}</mat-footer-cell>
<mat-footer-cell *matFooterCellDef class="right">{{runningAmount | currency:'INR'}}</mat-footer-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;" [ngClass]="getRowClass(row.id, row.posted)"
<mat-row *matRowDef="let row; columns: displayedColumns;" [class.selected]="selectedRowId === row.id"
(click)="selectRow(row.id)"></mat-row>
<mat-footer-row *matFooterRowDef="displayedColumns"></mat-footer-row>
</mat-table>

View File

@ -88,14 +88,9 @@ export class ProductLedgerComponent implements OnInit {
this.debitAmount += item.debitAmount;
this.creditQuantity += item.creditQuantity;
this.creditAmount += item.creditAmount;
if (item.posted) {
this.runningQuantity += item.debitQuantity - item.creditQuantity;
this.runningAmount += item.debitAmount - item.creditAmount;
}
} else {
this.runningQuantity += item.debitQuantity - item.creditQuantity;
this.runningAmount += item.debitAmount - item.creditAmount;
}
this.runningQuantity += item.debitQuantity - item.creditQuantity;
this.runningAmount += item.debitAmount - item.creditAmount;
item.runningQuantity = this.runningQuantity;
item.runningAmount = this.runningAmount;
});
@ -109,16 +104,6 @@ export class ProductLedgerComponent implements OnInit {
this.selectedRowId = id;
}
getRowClass(id: string, posted: boolean): string {
if (this.selectedRowId === id) {
return 'selected';
} else if (!posted) {
return 'unposted';
} else {
return '';
}
}
show() {
const l = this.prepareSubmit();
this.router.navigate(['ProductLedger', l.product.id], {