refactor: savings module (#1226)

See: #1196
This commit is contained in:
Karan Takalkar
2020-08-25 17:46:54 +05:30
committed by GitHub
parent f215e1aa96
commit efdd779aa9
30 changed files with 129 additions and 103 deletions
@@ -248,9 +248,9 @@ export class ChargesTabComponent implements OnInit {
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
*/
private reload() {
const clientId = this.savingsAccountData.clientId;
const url: string = this.router.url;
this.router.navigateByUrl(`/clients/${clientId}/savingsaccounts`, {skipLocationChange: true})
const refreshUrl: string = this.router.url.slice(0, this.router.url.indexOf('savings-accounts') + 'savings-accounts'.length);
this.router.navigateByUrl(refreshUrl, {skipLocationChange: true})
.then(() => this.router.navigate([url]));
}
@@ -21,7 +21,7 @@
</mat-card-title>
<mat-card-subtitle>
<p>
Account #: {{savingsAccountData.accountNo}} | Client Name: {{savingsAccountData.clientName}}<br/>
Account #: {{savingsAccountData.accountNo}} | {{entityType}} Name: {{savingsAccountData.clientName || savingsAccountData.groupName}}<br/>
<span *ngIf="!savingsAccountData.status.rejected && !savingsAccountData.status.submittedAndPendingApproval">
Current Balance: {{savingsAccountData.currency.displaySymbol}}&nbsp;{{savingsAccountData.summary.accountBalance}}<br/>
Available Balance: {{savingsAccountData.currency.displaySymbol}}&nbsp;{{savingsAccountData.summary.availableBalance}}<br/>
@@ -29,6 +29,8 @@ export class SavingsAccountViewComponent implements OnInit {
savingsDatatables: any;
/** Button Configurations */
buttonConfig: SavingsButtonsConfiguration;
/** Entity Type */
entityType: string;
/**
* Fetches savings account data from `resolve`
@@ -44,6 +46,13 @@ export class SavingsAccountViewComponent implements OnInit {
this.savingsAccountData = data.savingsAccountData;
this.savingsDatatables = data.savingsDatatables;
});
if (this.router.url.includes('clients')) {
this.entityType = 'Client';
} else if (this.router.url.includes('groups')) {
this.entityType = 'Group';
} else if (this.router.url.includes('centers')) {
this.entityType = 'Center';
}
}
ngOnInit() {
@@ -101,13 +110,13 @@ export class SavingsAccountViewComponent implements OnInit {
/**
* Refetches data fot the component
* Refetches data foe the component
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
*/
reload() {
const clientId = this.savingsAccountData.clientId;
private reload() {
const url: string = this.router.url;
this.router.navigateByUrl(`/clients/${clientId}/savingsaccounts`, {skipLocationChange: true})
const refreshUrl: string = this.router.url.slice(0, this.router.url.indexOf('savings-accounts') + 'savings-accounts'.length);
this.router.navigateByUrl(refreshUrl, {skipLocationChange: true})
.then(() => this.router.navigate([url]));
}
@@ -135,7 +144,7 @@ export class SavingsAccountViewComponent implements OnInit {
this.router.navigate([`actions/Withdrawal`], { relativeTo: this.route });
break;
case 'Modify Application':
this.router.navigate(['edit-savings-account'], { relativeTo: this.route });
this.router.navigate(['edit'], { relativeTo: this.route });
break;
case 'Delete':
this.deleteSavingsAccount();
@@ -5,7 +5,7 @@
<h3>All Transactions</h3>
</div>
<div class="action-button m-b-20" fxLayout="row" fxLayoutGap="20px" *ngIf="checkStatus()">
<button mat-raised-button color="primary">View Journal Entries</button>
<button mat-raised-button color="primary" [routerLink]="['/accounting', 'journal-entries']">View Journal Entries</button>
<button mat-raised-button color="primary" [routerLink]="['export']">Export</button>
</div>
</div>
@@ -29,7 +29,7 @@ export class TransactionsTabComponent implements OnInit {
constructor(private route: ActivatedRoute,
private router: Router) {
this.route.parent.parent.data.subscribe((data: { savingsAccountData: any }) => {
this.transactionsData = data.savingsAccountData.transactions.filter((transaction: any) => !transaction.reversed);
this.transactionsData = data.savingsAccountData.transactions?.filter((transaction: any) => !transaction.reversed);
this.status = data.savingsAccountData.status.value;
});
}
@@ -49,7 +49,7 @@ export class ViewChargeComponent {
this.route.data.subscribe((data: { savingsAccountCharge: any }) => {
this.chargeData = data.savingsAccountCharge;
});
this.route.parent.parent.data.subscribe((data: { savingsAccountData: any }) => {
this.route.data.subscribe((data: { savingsAccountData: any }) => {
this.savingsAccountData = data.savingsAccountData;
});
}
@@ -194,9 +194,9 @@ export class ViewChargeComponent {
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
*/
private reload() {
const clientId = this.savingsAccountData.clientId;
const url: string = this.router.url.replace(`/${this.chargeData.id}`, '');
this.router.navigateByUrl(`/clients/${clientId}/savingsaccounts`, {skipLocationChange: true})
const refreshUrl: string = this.router.url.slice(0, this.router.url.indexOf('savings-accounts') + 'savings-accounts'.length);
this.router.navigateByUrl(refreshUrl, {skipLocationChange: true})
.then(() => this.router.navigate([url]));
}