From bc42292d2caccf6c739313ef2f4c8d1095994ccc Mon Sep 17 00:00:00 2001
From: gopi17701 <41270090+gopi17701@users.noreply.github.com>
Date: Fri, 28 Sep 2018 12:40:49 -0400
Subject: [PATCH] Add files via upload
---
.../invoice-payment.component.html | 151 ++++++++++++++++++
.../invoice-payment.component.spec.ts | 25 +++
.../invoice-payment.component.ts | 115 +++++++++++++
3 files changed, 291 insertions(+)
create mode 100644 AstuteClient2/src/app/invoice-payment/invoice-payment.component.html
create mode 100644 AstuteClient2/src/app/invoice-payment/invoice-payment.component.spec.ts
create mode 100644 AstuteClient2/src/app/invoice-payment/invoice-payment.component.ts
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Choose an Invoice First!
+
+
+
+
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;
+ });
+ }
+}