diff --git a/AstuteClient2/src/app/invoice-gen/invoice-gen.component.html b/AstuteClient2/src/app/invoice-gen/invoice-gen.component.html
index 31cb0d8..6285030 100644
--- a/AstuteClient2/src/app/invoice-gen/invoice-gen.component.html
+++ b/AstuteClient2/src/app/invoice-gen/invoice-gen.component.html
@@ -111,12 +111,12 @@
-
+
-
+
diff --git a/AstuteClient2/src/app/invoice-gen/invoice-gen.component.ts b/AstuteClient2/src/app/invoice-gen/invoice-gen.component.ts
index a1d6240..d187be5 100644
--- a/AstuteClient2/src/app/invoice-gen/invoice-gen.component.ts
+++ b/AstuteClient2/src/app/invoice-gen/invoice-gen.component.ts
@@ -4,6 +4,7 @@ import {AstuteClientService} from '../services/astute-client-service';
declare var html2pdf: any;
declare var html2canvas: any;
declare var jsPDF: any;
+declare var $: any
@Component({
selector: 'app-invoice-gen',
@@ -13,6 +14,9 @@ declare var jsPDF: any;
export class InvoiceGenComponent implements OnInit {
@ViewChild('doc') invoiceHTML: ElementRef;
+ gridX = []; // these are the layout grid STARTING
+ gridY = []; // from the 1 inch border (x: 25; y:23)
+
name;
email;
address;
@@ -40,14 +44,28 @@ export class InvoiceGenComponent implements OnInit {
cert;
constructor(protected astuteClientService: AstuteClientService) {
- // console.log("********** " + this.astuteClientService.getInvoiceGen("123").then());
- console.log("in invoice gen comp")
- this.astuteClientService.getInvoiceGen("NVCC-01_1712_21").then((data) => {
+ // console.log('********** ' + this.astuteClientService.getInvoiceGen('123').then());
+ }
+
+ ngOnInit() {
+ let x = 25;
+ let y = 23;
+ for (let i = 0; i < 17; i++) {
+ this.gridX[i] = x;
+ x += 10;
+ }
+ for (let j = 0; j < 26; j++) {
+ this.gridY[j] = y;
+ y += 10;
+ }
+ console.log('Layout Grid X: ' + this.gridX);
+ console.log('Layout Grid Y: ' + this.gridY);
+ this.astuteClientService.getInvoiceGen('3-01_DRAFT_258').then((data) => {
this.name = data.customer.customerName;
this.email = data.customer.email;
- this.address = data.customer.add1 + " " + data.customer.add2 + " " +
- data.customer.city + ", " + data.customer.state.toUpperCase() + ", " +
- data.customer.zip + "-" + data.customer.ziplast4;
+ this.address = data.customer.add1 + ' ' + data.customer.add2 + ' ' +
+ data.customer.city + ', ' + data.customer.state.toUpperCase() + ', ' +
+ data.customer.zip + '-' + data.customer.ziplast4;
this.poNum = data.po.ponum;
this.coNum = data.po.contractNum;
@@ -73,17 +91,13 @@ export class InvoiceGenComponent implements OnInit {
});
}
-
- ngOnInit() {
- }
-
downloadPDF() {
- // new html2pdf(document.getElementById("doc"));
+ // new html2pdf(document.getElementById('doc'));
- const A4_width = 425; // pixels
- const A4_height = 550; // pixels
- const ratio = 1;
- //
+ const A4_width = 210;//425; // pixels
+ const A4_height = 297;//550; // pixels
+ const ratio = 2;
+ // //
const oldCanvas = document.createElement('canvas');
oldCanvas.width = A4_width;
oldCanvas.height = A4_height;
@@ -92,10 +106,10 @@ export class InvoiceGenComponent implements OnInit {
oldImg.src = oldCanvas.toDataURL();
oldContext.drawImage(oldImg, 0, 0, A4_width, A4_height);
-
const newImg = new Image();
newImg.onload = () => {
html2canvas(this.invoiceHTML.nativeElement).then((newCanvas) => {
+ console.log(this.invoiceHTML.nativeElement);
// newCanvas.width = A4_width / 50;
// newCanvas.height = A4_height / 50;
const newContext = newCanvas.getContext('2d');
@@ -106,12 +120,12 @@ export class InvoiceGenComponent implements OnInit {
unit: 'mm'
});
pdfDoc.addImage(newImg, 'png', 0, 0, 210, 297); // imageData, format, x, y, w, h
- pdfDoc.addHTML(this.invoiceHTML.nativeElement);
+ //pdfDoc.addHTML(this.invoiceHTML.nativeElement);
pdfDoc.save(this.inNum + '.pdf'); // save file
newImg.onload = undefined; // kill the func
}
);
- }
+ };
newImg.src = oldImg.src;
@@ -121,16 +135,72 @@ export class InvoiceGenComponent implements OnInit {
// console.log(data);
// });
- setTimeout(window.close, 5000);
+ // setTimeout(window.close, 5000);
}
+ testjsPDF() {
+ const doc = jsPDF();
+ doc.text('INVOICE', this.gridX[13], this.gridY[0]);
+ doc.text('ASTUTE', this.gridX[0], this.gridY[0]);
+
+ // No. Column (header and rows)
+ doc.rect(this.gridX[0], this.gridY[5], 10, 10);
+ for (let i = 6; i < 15; i += 2) {
+ doc.rect(this.gridX[0], this.gridY[i], 10, 20);
+ }
+
+ // Description Column (header and rows)
+ doc.rect(this.gridX[1], this.gridY[5], 70, 10);
+ for (let i = 6; i < 15; i += 2) {
+ doc.rect(this.gridX[1], this.gridY[i], 70, 20);
+ }
+
+ // Hourly Rate Column (header and rows)
+ doc.rect(this.gridX[8], this.gridY[5], 30, 10);
+ for (let i = 6; i < 15; i += 2) {
+ doc.rect(this.gridX[8], this.gridY[i], 30, 20);
+ }
+
+ // Hours Column (header and rows)
+ doc.rect(this.gridX[11], this.gridY[5], 20, 10);
+ for (let i = 6; i < 15; i += 2) {
+ doc.rect(this.gridX[11], this.gridY[i], 20, 20);
+ }
+
+ // Amount Column (header and rows)
+ doc.rect(this.gridX[13], this.gridY[5], 30, 10);
+ for (let i = 6; i < 15; i += 2) {
+ doc.rect(this.gridX[13], this.gridY[i], 30, 20);
+ }
+ doc.addPage()
+ doc.addPage()
+ doc.text('I am on page 3', 10, 10)
+ doc.setPage(1)
+ doc.save('a4.pdf');
+ }
+
+ moreTestJsPDF() {
+ const doc = new jsPDF();
+ // const specialElementHandlers = {
+ // '#editor': function (element, renderer) {
+ // return true;
+ // }
+ // };
+ // doc.fromHTML(this.invoiceHTML.nativeElement, 15, 15, {
+ // 'width': 170,
+ // 'elementHandlers': specialElementHandlers
+ // });
+ console.log (this.invoiceHTML);
+ doc.addHTML(this.invoiceHTML.nativeElement);
+ doc.save('sample-file.pdf');
+ }
// html2pdf((
document.getElementById('doc')));
- // var data="hello";
- // $.get("http://localhost/ws/service.asmx/HelloWord", function(response) {
+ // var data='hello';
+ // $.get('http://localhost/ws/service.asmx/HelloWord', function(response) {
// data = response;
// }).error(function(){
- // alert("Sorry could not proceed");
+ // alert('Sorry could not proceed');
// });
diff --git a/AstuteClient2/src/app/invoice/invoice.component.html b/AstuteClient2/src/app/invoice/invoice.component.html
index 295a4f7..0579a60 100644
--- a/AstuteClient2/src/app/invoice/invoice.component.html
+++ b/AstuteClient2/src/app/invoice/invoice.component.html
@@ -1,6 +1,7 @@
Invoices
+
+
+
-
-
- Payment
- Received
+
+ Delete
-
+
Void
@@ -45,7 +47,9 @@
- Add
+
+ Add
+
@@ -167,8 +171,8 @@
# |
Description |
- Fee Type |
- Fee |
+ Rate Type |
+ Rate |
Quantity |
@@ -178,12 +182,15 @@
|
- |
+
+
+
+ |
|
+ (change)="onSelectedCellChange(i, 'fee', fee.value); updateSelectedBillAmt()" #fee disabled>
|
-
-
+
+
+
+ Original Contract Amount |
+
+ {{selectedPO.contractAmt}}
+ |
+ |
+ |
+
+
+ Net Changes by Change Orders |
+
+ 0
+ |
+ |
+ |
+
+
+ Total Contract Amount |
+ {{selectedPO.contractAmt}} |
+ |
+ |
+
+
+ Previously Billed |
+ {{selectedPO.previouslyBilledAmount}} |
+ |
+ |
+
+
+
+
+
+
+
+
+ Balance to be Billed |
+ {{selectedPO.contractAmt - selectedPO.previouslyBilledAmount - selectedBillAmt}} |
+
+
+
+
+
+
+
+
+
+
+
+
+ Total due this invoice |
+ {{selectedBillAmt}} |
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -392,10 +454,11 @@
+ |
# |
Description |
- Fee Type |
- Fee |
+ Rate Type |
+ Rate |
Quantity |
@@ -403,14 +466,22 @@
+
+
+ -
+
+ |
|
- |
+
+
+
+ |
|
+ (change)="onNewCellChange(i, 'fee', fee.value); updateNewBillAmt();" #fee disabled>
|
{{getPerc(qty.value, inDet.remainingQty)}}%
- |
+ |
diff --git a/AstuteClient2/src/app/invoice/invoice.component.ts b/AstuteClient2/src/app/invoice/invoice.component.ts
index fa4c411..5f82e1b 100644
--- a/AstuteClient2/src/app/invoice/invoice.component.ts
+++ b/AstuteClient2/src/app/invoice/invoice.component.ts
@@ -31,6 +31,7 @@ export class InvoiceComponent implements OnInit {
newInDetails = [];
newBillAmt = 0;
selectedInDetails = [];
+ selectedPO;
selectedBillAmt = 0;
poDetails = [];
selectedPODetails = [];
@@ -73,13 +74,13 @@ export class InvoiceComponent implements OnInit {
// apply amber 2004
'text-danger': function (params) {
- return params.data.invoiceStatus === 1
+ return params.data.invoiceStatus === 1;
},
'text-primary': function (params) {
- return params.data.invoiceStatus === 2
+ return params.data.invoiceStatus === 2;
},
'text-warning': function (params) {
- return params.data.invoiceStatus === 3
+ return params.data.invoiceStatus === 3;
},
// apply red to 2000
@@ -250,6 +251,11 @@ export class InvoiceComponent implements OnInit {
alert("get PO detail failed!")
}
});
+ this.pos.forEach((po) => {
+ if (po.ponum === this.chosenInv.poNum) {
+ this.selectedPO = po;
+ }
+ });
} else {
this.chosenInv = null;
this.selectedPODetails = [];
@@ -257,7 +263,7 @@ export class InvoiceComponent implements OnInit {
}
open(content, indexPO, indexINV) {
- content.open()
+ content.open();
// this.detailDescription = ViewChild('detailDescription');
// this.detailAmount = ViewChild('detailAmount');
// this.detailRate = ViewChild('detailRate');
@@ -307,6 +313,19 @@ export class InvoiceComponent implements OnInit {
return [year, month, day].join('-');
}
+ deleteInvoice (invoiceNum) {
+ if (confirm('Are you sure you want to delete invoice, ' + invoiceNum)) {
+ this.astuteClientService.deleteInvoice(invoiceNum).then((data) => {
+ if (data) {
+ console.log('Invoice, ' + invoiceNum + ' successfully deleted');
+ this.refreshData();
+ } else {
+ alert ('Error in deleting; Invoice, ' + invoiceNum + ' has not been deleted');
+ }
+ });
+ }
+ }
+
addInvoice(invoiceNumber, poNum, changeOrderNum, pmtStatus, billAmt, specialNotes, certification, status, ref) {
// String invoiceNumber;
// Date invoiceDate;
@@ -436,7 +455,7 @@ export class InvoiceComponent implements OnInit {
if (data) {
this.refreshData();
} else {
- alert('void invoice failed.')
+ alert('void invoice failed.');
}
});
}
diff --git a/AstuteClient2/src/app/modal-form/modal-form.component.html b/AstuteClient2/src/app/modal-form/modal-form.component.html
index c0e8aea..35961fe 100644
--- a/AstuteClient2/src/app/modal-form/modal-form.component.html
+++ b/AstuteClient2/src/app/modal-form/modal-form.component.html
@@ -2,7 +2,7 @@
diff --git a/AstuteClient2/src/app/sales-order/sales-order.component.html b/AstuteClient2/src/app/sales-order/sales-order.component.html
index c1aa020..5ee7809 100644
--- a/AstuteClient2/src/app/sales-order/sales-order.component.html
+++ b/AstuteClient2/src/app/sales-order/sales-order.component.html
@@ -59,7 +59,7 @@
Contract Number |
|
Contract Amount |
- |
+ |
|
@@ -84,10 +84,10 @@
| |
# |
Description |
- Fee Type |
+ Rate Type |
Service Type |
Qty |
- Fee |
+ Rate |
@@ -99,7 +99,10 @@
|
- |
+
+
+
+ |
|
- |
- |
+ |
+ |
@@ -202,7 +205,7 @@
Contract Number |
|
Contract Amount |
- |
+ |
@@ -277,10 +280,10 @@
# |
Description |
- Fee Type |
+ Rate Type |
Service Type |
Qty |
- Fee |
+ Rate |
@@ -294,7 +297,10 @@
|
- |
+
+
+
+ |
|
|
- |
- |
+ |
+ |
diff --git a/AstuteClient2/src/app/sales-order/sales-order.component.ts b/AstuteClient2/src/app/sales-order/sales-order.component.ts
index ce94d5b..3fda1fd 100644
--- a/AstuteClient2/src/app/sales-order/sales-order.component.ts
+++ b/AstuteClient2/src/app/sales-order/sales-order.component.ts
@@ -2,232 +2,260 @@ import {Component, OnInit, ViewChild} from '@angular/core';
import {AstuteClientService} from '../services/astute-client-service';
@Component({
- selector: 'app-sales-order',
- templateUrl: './sales-order.component.html',
- styleUrls: ['./sales-order.component.css']
+ selector: 'app-sales-order',
+ templateUrl: './sales-order.component.html',
+ styleUrls: ['./sales-order.component.css']
})
export class SalesOrderComponent implements OnInit {
- @ViewChild('agGrid') agGrid;
- selected = null;
- selectedPODetail = [];
- newPODetail = [];
- customers;
- pos;
- columnDefs = [
- {headerName: 'Project Number', field: 'astuteProjectNumber'},
- {headerName: 'SO Number', field: 'ponum'},
- // {headerName: 'Customer ID', field: 'customerId'},
- {headerName: 'Customer Name', field: 'customerName'},
- {headerName: 'Contract Number', field: 'contractNum'},
- {headerName: 'SO Title', field: 'title'},
- {headerName: 'Contract Amount', field: 'contractAmt'},
- {headerName: 'SO Date', field: 'podate'}
- ];
- rowData: any;
+ @ViewChild('agGrid') agGrid;
+ selected = null;
+ selectedPODetail = [];
+ newPODetail = [];
+ newContractAmount = 0;
+ editContractAmount = 0;
+ customers;
+ pos;
+ serviceTypes;
+ columnDefs = [
+ {headerName: 'Project Number', field: 'astuteProjectNumber'},
+ {headerName: 'SO Number', field: 'ponum'},
+ // {headerName: 'Customer ID', field: 'customerId'},
+ {headerName: 'Customer Name', field: 'customerName'},
+ {headerName: 'Contract Number', field: 'contractNum'},
+ {headerName: 'SO Title', field: 'title'},
+ {headerName: 'Contract Amount', field: 'contractAmt'},
+ {headerName: 'SO Date', field: 'podate'},
+ {headerName: '# of Invoice', field: 'invoiceSequence'}
+ ];
+ rowData: any;
- constructor(private astuteClientService: AstuteClientService) {
- }
-
- ngOnInit() {
- this.refreshData();
- }
-
- printValue(val) {
- console.log(val);
- }
-
- addPo(projNum, ponum, podate, customerid, contractnum, contractamt, title, ref ) {
- const poData = {
- "astuteProjectNumber": projNum,
- "poNum": ponum,
- "podate": podate,
- "customerId": customerid,
- "contractNum": contractnum,
- "contractAmt": contractamt,
- "title": title,
+ constructor(private astuteClientService: AstuteClientService) {
}
- console.log (poData);
- this.astuteClientService.createPO(poData).then((data) => {
- if (data) {
+
+ ngOnInit() {
this.refreshData();
- this.addPODetail(this.newPODetail);
- ref.close();
- } else {
- alert("PO Creation failed, check input fields");
- }
- }, (reason) => {
- alert("add po failed for " + reason);
- });
- }
+ this.astuteClientService.getServiceTypes().then((d) => {
+ if (d) {
+ this.serviceTypes = d;
+ } else {
+ alert ('get service types failed');
+ }
+ })
+ }
- addPODetail(details) {
- if (details.length) {
- console.log(details[0]);
- this.astuteClientService.createPODetail(details[0]).then((data) => {
- if (data) {
- details.splice(0, 1);
- this.addPODetail(details);
- } else {
- alert("add detail failed");
+ printValue(val) {
+ console.log(val);
+ }
+
+ addPo(projNum, ponum, podate, customerid, contractnum, contractamt, title, ref) {
+ const poData = {
+ "astuteProjectNumber": projNum,
+ "poNum": ponum,
+ "podate": podate,
+ "customerId": customerid,
+ "contractNum": contractnum,
+ "contractAmt": contractamt,
+ "title": title,
}
- });
- } else {
- this.newPODetail = [];
- }
- }
-
- editPo(projNum, ponum, podate, contractnum, contractamt, title, ref) {
- const poData = {
- "astuteProjectNumber": projNum,
- "poNum": ponum,
- "podate": podate,
- "contractNum": contractnum,
- "contractAmt": contractamt,
- "title": title,
- }
- console.log(poData);
- this.astuteClientService.updatePO(ponum, poData).then((data) => {
- if (data) {
- this.refreshData();
- this.editPODetail(this.selectedPODetail);
- ref.close();
- } else {
- alert("PO updating failed, check input fields");
- }
- }, (reason) => {
- alert("update po failed for " + reason);
- });
- }
-
- editPODetail (details) {
- if (details.length) {
- console.log(details[0]);
- this.astuteClientService.updatePODetail(details[0].ponum, details[0].lineItemNo, details[0]).then((data) => {
- if (data) {
- details.splice(0, 1);
- this.editPODetail(details);
- } else {
- alert("add detail failed")
- }
- });
- } else {
- this.newPODetail = [];
- }
- }
-
- pushOntoSelectedDetail(lineItemNo: number, ponum, serviceDesc, feeTypeId, serviceTypeId, qty, fee, remainingQty) {
- this.selectedPODetail.push({
- 'lineItemNo': lineItemNo,
- 'ponum': ponum,
- 'serviceDesc': serviceDesc,
- 'feeTypeId': feeTypeId,
- 'serviceTypeId': serviceTypeId,
- 'qty': qty,
- 'fee': fee,
- 'remainingQty': remainingQty
- });
- }
-
- pushOntoNewDetail(lineItemNo: number, ponum, serviceDesc, feeTypeId, serviceTypeId, qty, fee, remainingQty) {
- this.newPODetail.push({
- 'lineItemNo': lineItemNo,
- 'poNum': ponum,
- 'serviceDesc': serviceDesc,
- 'feeTypeId': feeTypeId,
- 'serviceTypeId': serviceTypeId,
- 'qty': qty,
- 'fee': fee,
- 'remainingQty': remainingQty
- });
- }
-
- open(ref) {
- this.getSelectedRows();
- ref.open();
- }
-
- close(ref) {
- this.newPODetail = [];
- this.selectedPODetail = [];
-
- ref.close();
- }
-
- onSelectedCellChange(row: number, col: string, value) {
- this.selectedPODetail[row][col] = value;
- console.log(this.selectedPODetail);
- }
-
- onNewCellChange(row: number, col: string, value) {
- this.newPODetail[row][col] = value;
- console.log(this.newPODetail);
- }
-
- getCurrDate() {
- const d = new Date();
- return this.formatDate(d);
- }
-
- formatDate(d: Date) {
- let month = '' + (d.getMonth() + 1),
- day = '' + d.getDate(),
- year = d.getFullYear();
-
- if (month.length < 2) {
- month = '0' + month;
- }
- if (day.length < 2) {
- day = '0' + day;
- }
- return [year, month, day].join('-');
- }
-
- getSelectedRows() {
- const selectedNodes = this.agGrid.api.getSelectedNodes();
- if (selectedNodes.length) {
- this.selected = selectedNodes.map(node => node.data)[0];
- this.astuteClientService.getPODetail(this.selected.ponum).then((data) => {
- if (data) {
- this.selectedPODetail = data;
- console.log(this.selectedPODetail);
- } else {
- alert("get PO detail failed!")
- }
- });
- } else {
- this.selected = null;
- this.selectedPODetail = [];
- }
- }
-
- refreshData() {
- this.astuteClientService.getCustomers().then((customers) => {
- if (customers) {
- this.customers = customers;
- this.astuteClientService.getPOs().then((data) => {
- if (data) {
- this.pos = data;
- this.rowData = data;
- this.rowData.forEach((row) => {
- row.customerName = this.getCustomerName(row.customerId);
- });
- }
+ console.log(poData);
+ this.astuteClientService.createPO(poData).then((data) => {
+ if (data) {
+ this.refreshData();
+ this.addPODetail(this.newPODetail);
+ ref.close();
+ } else {
+ alert("PO Creation failed, check input fields");
+ }
+ }, (reason) => {
+ alert("add po failed for " + reason);
});
- } else {
- alert("get Customers Failed!");
- }
- });
- // this.rowData = this.astuteClientService.getPOs();
+ }
- }
+ addPODetail(details) {
+ if (details.length) {
+ console.log(details[0]);
+ this.astuteClientService.createPODetail(details[0]).then((data) => {
+ if (data) {
+ details.splice(0, 1);
+ this.addPODetail(details);
+ } else {
+ alert("add detail failed");
+ }
+ });
+ } else {
+ this.newPODetail = [];
+ }
+ }
- getCustomerName(customerId) {
- let name = "";
- this.customers.forEach((customer) => {
- if (customer.customerId === customerId) {
- name = customer.customerName;
- }
- });
- return name;
- }
+ editPo(projNum, ponum, podate, contractnum, contractamt, title, ref) {
+ const poData = {
+ "astuteProjectNumber": projNum,
+ "poNum": ponum,
+ "podate": podate,
+ "contractNum": contractnum,
+ "contractAmt": contractamt,
+ "title": title,
+ }
+ console.log(poData);
+ this.astuteClientService.updatePO(ponum, poData).then((data) => {
+ if (data) {
+ this.refreshData();
+ this.editPODetail(this.selectedPODetail);
+ ref.close();
+ } else {
+ alert("PO updating failed, check input fields");
+ }
+ }, (reason) => {
+ alert("update po failed for " + reason);
+ });
+ }
+
+ editPODetail(details) {
+ if (details.length) {
+ console.log(details[0]);
+ this.astuteClientService.updatePODetail(details[0].ponum, details[0].lineItemNo, details[0]).then((data) => {
+ if (data) {
+ details.splice(0, 1);
+ this.editPODetail(details);
+ } else {
+ alert("add detail failed")
+ }
+ });
+ } else {
+ this.newPODetail = [];
+ }
+ }
+
+ pushOntoSelectedDetail(lineItemNo: number, ponum, serviceDesc, feeTypeId, serviceTypeId, qty, fee, remainingQty) {
+ this.selectedPODetail.push({
+ 'lineItemNo': lineItemNo,
+ 'ponum': ponum,
+ 'serviceDesc': serviceDesc,
+ 'feeTypeId': feeTypeId,
+ 'serviceTypeId': serviceTypeId,
+ 'qty': qty,
+ 'fee': fee,
+ 'remainingQty': remainingQty
+ });
+ }
+
+ pushOntoNewDetail(lineItemNo: number, ponum, serviceDesc, feeTypeId, serviceTypeId, qty, fee, remainingQty) {
+ this.newPODetail.push({
+ 'lineItemNo': lineItemNo,
+ 'poNum': ponum,
+ 'serviceDesc': serviceDesc,
+ 'feeTypeId': feeTypeId,
+ 'serviceTypeId': serviceTypeId,
+ 'qty': qty,
+ 'fee': fee,
+ 'remainingQty': remainingQty
+ });
+ }
+
+ updateNewContractAmt() {
+ let tot = 0;
+ this.newPODetail.forEach((d) => {
+ tot += +d.qty * +d.fee;
+ });
+ this.newContractAmount = tot;
+ }
+
+ updateEditContractAmt() {
+ let tot = 0;
+ this.selectedPODetail.forEach((d) => {
+ tot += +d.qty * +d.fee;
+ });
+ this.editContractAmount = tot;
+ }
+
+ open(ref) {
+ this.getSelectedRows();
+ ref.open();
+ }
+
+ close(ref) {
+ this.newPODetail = [];
+ this.selectedPODetail = [];
+
+ ref.close();
+ }
+
+ onSelectedCellChange(row: number, col: string, value) {
+ this.selectedPODetail[row][col] = value;
+ console.log(this.selectedPODetail);
+ }
+
+ onNewCellChange(row: number, col: string, value) {
+ this.newPODetail[row][col] = value;
+ console.log(this.newPODetail);
+ }
+
+ getCurrDate() {
+ const d = new Date();
+ return this.formatDate(d);
+ }
+
+ formatDate(d: Date) {
+ let month = '' + (d.getMonth() + 1),
+ day = '' + d.getDate(),
+ year = d.getFullYear();
+
+ if (month.length < 2) {
+ month = '0' + month;
+ }
+ if (day.length < 2) {
+ day = '0' + day;
+ }
+ return [year, month, day].join('-');
+ }
+
+ getSelectedRows() {
+ const selectedNodes = this.agGrid.api.getSelectedNodes();
+ if (selectedNodes.length) {
+ this.selected = selectedNodes.map(node => node.data)[0];
+ this.editContractAmount = +this.selected.contractAmt;
+ this.astuteClientService.getPODetail(this.selected.ponum).then((data) => {
+ if (data) {
+ this.selectedPODetail = data;
+ console.log(this.selectedPODetail);
+ } else {
+ alert("get PO detail failed!")
+ }
+ });
+ } else {
+ this.selected = null;
+ this.selectedPODetail = [];
+ }
+ }
+
+ refreshData() {
+ this.astuteClientService.getCustomers().then((customers) => {
+ if (customers) {
+ this.customers = customers;
+ this.astuteClientService.getPOs().then((data) => {
+ if (data) {
+ this.pos = data;
+ this.rowData = data;
+ this.rowData.forEach((row) => {
+ row.customerName = this.getCustomerName(row.customerId);
+ });
+ }
+ });
+ } else {
+ alert("get Customers Failed!");
+ }
+ });
+ // this.rowData = this.astuteClientService.getPOs();
+
+ }
+
+ getCustomerName(customerId) {
+ let name = "";
+ this.customers.forEach((customer) => {
+ if (customer.customerId === customerId) {
+ name = customer.customerName;
+ }
+ });
+ return name;
+ }
}
diff --git a/AstuteClient2/src/app/services/astute-client-service.ts b/AstuteClient2/src/app/services/astute-client-service.ts
index 8385fd3..aca3bdb 100644
--- a/AstuteClient2/src/app/services/astute-client-service.ts
+++ b/AstuteClient2/src/app/services/astute-client-service.ts
@@ -9,6 +9,7 @@ export class AstuteClientService {
private authUrl = 'http://localhost:8080/astutesystem/auth';
private customerUrl = 'http://localhost:8080/astutesystem/customer';
private POUrl = 'http://localhost:8080/astutesystem/po';
+ private POServiceTypesUrl = 'http://localhost:8080/astutesystem/po/serviceTypes';
private PODetailUrl = 'http://localhost:8080/astutesystem/po/detail';
private invoiceUrl = 'http://localhost:8080/astutesystem/invoice';
private invoiceDetailUrl = 'http://localhost:8080/astutesystem/invoice/detail';
@@ -88,6 +89,17 @@ export class AstuteClientService {
});
}
+ public getServiceTypes(): Promise {
+ console.log("*** In getPOServiceTypes()");
+ const url = `${this.POServiceTypesUrl}`;
+ return this.http.get(url)
+ .toPromise()
+ .then(response => {
+ console.log(response['entity']);
+ return response['entity'];
+ });
+ }
+
public getPODetail(ponum): Promise {
console.log("*** In getPODetails()");
const url = `${this.PODetailUrl}?PONum=${ponum}`;
@@ -163,6 +175,17 @@ export class AstuteClientService {
});
}
+ public deleteInvoice (invoiceNumber) {
+ console.log("*** In deleteInvoice(), invoiceNumber" + invoiceNumber);
+ const url = `${this.invoiceUrl}/${invoiceNumber}/delete`;
+ return this.http.put(url, {})
+ .toPromise()
+ .then(response => {
+ console.log (response['entity']);
+ return response['entity'];
+ });
+ }
+
public generateInvoiceNumber (ponum) {
console.log("*** In generateInvoiceNumber()");
const url = `${this.invoiceUrl}/generateInvoiceNumber/${ponum}`;