diff --git a/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.html b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.html new file mode 100644 index 000000000..c2c610de1 --- /dev/null +++ b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.html @@ -0,0 +1,42 @@ +
+ + + +
+ + + +
+ + + Annual Fees Transaction Date + + + + + Due Date is required + + + + + Amount + + + Amount is required + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.scss b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.scss new file mode 100644 index 000000000..d774f68da --- /dev/null +++ b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.spec.ts b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.spec.ts new file mode 100644 index 000000000..04425aa9b --- /dev/null +++ b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ApplyAnnualFeesSavingsAccountComponent } from './apply-annual-fees-savings-account.component'; + +describe('ApplyAnnualFeesSavingsAccountComponent', () => { + let component: ApplyAnnualFeesSavingsAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ApplyAnnualFeesSavingsAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ApplyAnnualFeesSavingsAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts new file mode 100644 index 000000000..710f9772b --- /dev/null +++ b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts @@ -0,0 +1,104 @@ +/** Angular Imports */ +import { Component, OnInit } from '@angular/core'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { DatePipe } from '@angular/common'; +import { ActivatedRoute, Router } from '@angular/router'; + +/** Custom Services */ +import { SavingsService } from 'app/savings/savings.service'; + +/** + * Apply Annual Fees Component + */ +@Component({ + selector: 'mifosx-apply-annual-fees-savings-account', + templateUrl: './apply-annual-fees-savings-account.component.html', + styleUrls: ['./apply-annual-fees-savings-account.component.scss'] +}) +export class ApplyAnnualFeesSavingsAccountComponent implements OnInit { + + /** Minimum date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum date allowed. */ + maxDate = new Date(); + /** Apply annual fees form. */ + applyAnnualFeesForm: FormGroup; + /** Savings Account Id */ + accountId: any; + /** Annual Fees charge Id */ + chargeId: any; + /** Savings Account Data */ + savingsAccountData: any; + + /** + * @param {FormBuilder} formBuilder Form Builder + * @param {SavingsService} savingsService Savings Service + * @param {DatePipe} datePipe Date Pipe + * @param {ActivatedRoute} route Activated Route + * @param {Router} router Router + */ + constructor(private formBuilder: FormBuilder, + private savingsService: SavingsService, + private datePipe: DatePipe, + private route: ActivatedRoute, + private router: Router) { + this.accountId = this.route.parent.snapshot.params['savingAccountId']; + this.route.parent.data.subscribe((data: { savingsAccountData: any }) => { + this.savingsAccountData = data.savingsAccountData; + }); + } + + /** + * Creates the apply annual fees form. + */ + ngOnInit() { + this.createApplyAnnualFeesForm(); + this.applyCharge(); + } + + /** + * Creates the apply annual fees form. + */ + createApplyAnnualFeesForm() { + this.applyAnnualFeesForm = this.formBuilder.group({ + 'dueDate': ['', Validators.required], + 'amount': [''] + }); + } + + /** + * Retireves apply annual fees charge for ID and amount. + */ + applyCharge() { + const charges: any[] = this.savingsAccountData.charges; + charges.forEach((charge: any) => { + if (charge.name === 'Annual fee - INR') { + this.chargeId = charge.id; + this.applyAnnualFeesForm.get('amount').patchValue(charge.amount); + } + }); + } + + /** + * Submits the form and applies the annual fees, + * if successful redirects to the saving account. + */ + submit() { + // TODO: Update once language and date settings are setup + const locale = 'en'; + const dateFormat = 'dd MMMM yyyy'; + const prevApprovedOnDate: Date = this.applyAnnualFeesForm.value.dueDate; + this.applyAnnualFeesForm.patchValue({ + dueDate: this.datePipe.transform(prevApprovedOnDate, dateFormat), + }); + const data = { + ...this.applyAnnualFeesForm.value, + dateFormat, + locale + }; + this.savingsService.executeSavingsAccountChargesCommand(this.accountId, 'paycharge', data, this.chargeId).subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/savings/saving-account-actions/saving-account-actions.component.html b/src/app/savings/saving-account-actions/saving-account-actions.component.html index 77729545c..7ccd85174 100644 --- a/src/app/savings/saving-account-actions/saving-account-actions.component.html +++ b/src/app/savings/saving-account-actions/saving-account-actions.component.html @@ -9,3 +9,4 @@ + diff --git a/src/app/savings/saving-account-actions/saving-account-actions.component.ts b/src/app/savings/saving-account-actions/saving-account-actions.component.ts index 7b481a50b..5ddfc4bc5 100644 --- a/src/app/savings/saving-account-actions/saving-account-actions.component.ts +++ b/src/app/savings/saving-account-actions/saving-account-actions.component.ts @@ -22,10 +22,11 @@ export class SavingAccountActionsComponent { 'Close': boolean 'Undo Approval': boolean 'Post Interest As On': boolean - 'Assign Staff': boolean // savings account and template + 'Assign Staff': boolean 'Add Charge': boolean 'Unassign Staff': boolean 'Withdraw By Client': boolean + 'Apply Annual Fees': boolean } = { 'Approve': false, 'Reject': false, @@ -38,7 +39,8 @@ export class SavingAccountActionsComponent { 'Assign Staff': false, 'Add Charge': false, 'Unassign Staff': false, - 'Withdraw By Client': false + 'Withdraw By Client': false, + 'Apply Annual Fees': false }; /** diff --git a/src/app/savings/savings-account-view/savings-account-view.component.ts b/src/app/savings/savings-account-view/savings-account-view.component.ts index 62f971b0e..670ebb351 100644 --- a/src/app/savings/savings-account-view/savings-account-view.component.ts +++ b/src/app/savings/savings-account-view/savings-account-view.component.ts @@ -128,6 +128,7 @@ export class SavingsAccountViewComponent implements OnInit { case 'Add Charge': case 'Unassign Staff': case 'Withdraw By Client': + case 'Apply Annual Fees': this.router.navigate([`actions/${name}`], { relativeTo: this.route }); break; case 'Withdraw': diff --git a/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.html b/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.html index ed3fd4b0f..c6b34d94b 100644 --- a/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.html +++ b/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.html @@ -63,6 +63,66 @@ {{ transactionData.amount }} +
+ Note +
+ +
+ {{ transactionData.note }} +
+ + + +
+ Payment Type +
+ +
+ {{ transactionData.paymentDetailData.paymentType.name }} +
+ +
+ Account No. +
+ +
+ {{ transactionData.paymentDetailData.accountNumber }} +
+ +
+ Cheque Number +
+ +
+ {{ transactionData.paymentDetailData.checkNumber }} +
+ +
+ Routing Code +
+ +
+ {{ transactionData.paymentDetailData.routingCode }} +
+ +
+ Receipt No. +
+ +
+ {{ transactionData.paymentDetailData.receiptNumber }} +
+ +
+ Bank No. +
+ +
+ {{ transactionData.paymentDetailData.bankNumber }} +
+ +
+ diff --git a/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.ts b/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.ts index 87456a070..a0aad5fd1 100644 --- a/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.ts +++ b/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.ts @@ -12,6 +12,7 @@ import { UndoTransactionDialogComponent } from '../../custom-dialogs/undo-transa /** * View Transaction Component. + * TODO: Add support for account transfers. */ @Component({ selector: 'mifosx-view-transaction', diff --git a/src/app/savings/savings.module.ts b/src/app/savings/savings.module.ts index 50de10104..50aa37669 100644 --- a/src/app/savings/savings.module.ts +++ b/src/app/savings/savings.module.ts @@ -45,6 +45,7 @@ import { ToggleWithholdTaxDialogComponent } from './savings-account-view/custom- import { ViewRecieptComponent } from './savings-account-view/transactions/view-reciept/view-reciept.component'; import { ExportTransactionsComponent } from './savings-account-view/transactions-tab/export-transactions/export-transactions.component'; import { EditTransactionComponent } from './savings-account-view/transactions/edit-transaction/edit-transaction.component'; +import { ApplyAnnualFeesSavingsAccountComponent } from './saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component'; /** @@ -95,7 +96,8 @@ import { EditTransactionComponent } from './savings-account-view/transactions/ed ToggleWithholdTaxDialogComponent, ViewRecieptComponent, ExportTransactionsComponent, - EditTransactionComponent + EditTransactionComponent, + ApplyAnnualFeesSavingsAccountComponent ], entryComponents: [ CalculateInterestDialogComponent,