diff --git a/AstuteClient2/src/app/invoice-payment/invoice-payment.component.html b/AstuteClient2/src/app/invoice-payment/invoice-payment.component.html new file mode 100644 index 0000000..4d48099 --- /dev/null +++ b/AstuteClient2/src/app/invoice-payment/invoice-payment.component.html @@ -0,0 +1,151 @@ + +

Invoice Payments

+
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+ + + + + + + + + + +
+ + + +
+
+ + +
+
diff --git a/AstuteClient2/src/app/invoice-payment/invoice-payment.component.spec.ts b/AstuteClient2/src/app/invoice-payment/invoice-payment.component.spec.ts new file mode 100644 index 0000000..b956b4d --- /dev/null +++ b/AstuteClient2/src/app/invoice-payment/invoice-payment.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { InvoicePaymentComponent } from './invoice-payment.component'; + +describe('InvoicePaymentComponent', () => { + let component: InvoicePaymentComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ InvoicePaymentComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(InvoicePaymentComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/AstuteClient2/src/app/invoice-payment/invoice-payment.component.ts b/AstuteClient2/src/app/invoice-payment/invoice-payment.component.ts new file mode 100644 index 0000000..9d5b8c1 --- /dev/null +++ b/AstuteClient2/src/app/invoice-payment/invoice-payment.component.ts @@ -0,0 +1,115 @@ +import {Component, OnInit, ViewChild} from '@angular/core'; +import {AstuteClientService} from '../services/astute-client-service'; + +@Component({ + selector: 'app-invoice-payment', + templateUrl: './invoice-payment.component.html', + styleUrls: ['./invoice-payment.component.css'] +}) +export class InvoicePaymentComponent implements OnInit { + @ViewChild('agGrid') agGrid; + selected = null; + chosenInv: any = 0; + chosenPaymentType: any = 0; + invoices; + rowData; + paymentTypes; + invoicePaymentData; + columnDefs = [ + {headerName: 'Invoice Payment Id', field: 'invoicePaymentId'}, + {headerName: 'Invoice Number', field: 'invoiceNum'}, + {headerName: 'payment Received', field: 'invoiceAmount'}, + {headerName: 'Date Received', field: 'paymentDate'}, + {headerName: 'Payment Type', field: 'paymentType'} + + ]; + constructor(protected astuteClientService: AstuteClientService) { + } + + ngOnInit() { + this.refreshData(); + } + + invoiceDropdownChange(index) { + this.chosenInv = this.invoices[index].invoiceNumber; + } + + paymentTypeDropdownChange(index) { + this.chosenPaymentType = this.paymentTypes[index].paymentTypeId; + } + + getSelectedRows() { + const selectedNodes = this.agGrid.api.getSelectedNodes(); + if (selectedNodes.length) { + this.selected = selectedNodes.map(node => node.data)[0]; + } else { + this.selected = null; + } + } + + addInvoicePayment(invoiceNum, invoicePaymentId, paymentTypeId, paymentType, paymentDate, paymentReceived, ref) { + let invoicePaymentData = { + "invoiceNum": invoiceNum, + "invoicePaymentId":invoicePaymentId, + "paymentTypeId":paymentTypeId, + "paymentType": paymentType, + "paymentDate": paymentDate, + "invoiceAmount": paymentReceived + }; + this.astuteClientService.addInvoicePayment(invoicePaymentData).then((data) => { + if (data) { + this.refreshData(); + ref.close(); + } else { + alert("Adding Invoice Payment Failed, Check Input Fields") + } + }, (reason) => { + alert("Adding Invoice Payment failed for " + reason); + }); + } + + updateInvoicePayment(invoiceNum, invoicePaymentId, paymentTypeId, paymentType, dateReceived, paymentReceived, ref) { + const invoicePaymentData = { + "invoiceNum": invoiceNum, + "invoicePaymentId": invoicePaymentId, + "paymentTypeId": paymentTypeId, + "paymentType": paymentType, + "paymentDate": dateReceived, + "invoiceAmount": paymentReceived + }; + + this.astuteClientService.updateInvoicePayment(invoiceNum, invoicePaymentId, invoicePaymentData).then((data) => { + if (data) { + this.refreshData(); + ref.close(); + } else { + alert("Updating Invoice Payment Failed, Check Input Fields") + } + }, (reason) => { + alert("Updating Invoice Payment failed for " + reason); + }); + } + + open(ref) { + this.getSelectedRows(); + ref.open(); + } + + close(ref) { + ref.close(); + } + + refreshData() { + this.astuteClientService.getSumittedInvoices().then((data) => { + this.invoices = data; + }); + this.astuteClientService.getInvoiceTypes().then((data) => { + this.paymentTypes = data; + }); + + this.rowData = this.astuteClientService.getInvoicePayments(); + this.astuteClientService.getInvoicePayments().then((data) => { + this.invoicePaymentData = data; + }); + } +}