@@ -653,10 +660,57 @@
+
+
+
+
+
+
+
+
+
+
Total Cost: {{selectedBillAmt | currency}}
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AstuteClient2/src/app/invoice/invoice.component.ts b/AstuteClient2/src/app/invoice/invoice.component.ts
index 61df7ab..414a0b2 100644
--- a/AstuteClient2/src/app/invoice/invoice.component.ts
+++ b/AstuteClient2/src/app/invoice/invoice.component.ts
@@ -11,71 +11,23 @@ declare var $: any;
styleUrls: ['./invoice.component.css']
})
export class InvoiceComponent implements OnInit {
- @ViewChild('agGrid') agGrid;
- chosenCustomerID: any = 0;
- chosenInv: any = 0;
- source;
- customers;
- pos = [];
- chosenPo;
- correspondingPos = [];
- correspondingCustomer = [];
- generatedInvoiceNumber = '';
- feeTypes = ['Fixed Fee', 'Hourly'];
- serviceTypes = ['Study', 'Design', 'Peer Review', 'Cost Investigation', 'Forensic Investigation'];
+ gridApi;
+ gridColumnApi;
+ detailGridApi;
+ detailColumnApi;
+
columnDefs = [
+ {headerName: 'Customer', field: 'customerId'},
{headerName: 'Invoice Number', field: 'invoiceNumber'},
{headerName: 'Date', field: 'invoiceDate'},
{headerName: 'Sales Order Number', field: 'poNum'},
{headerName: 'Change Order Number', field: 'changeOrderNum'},
- {headerName: 'Outstanding Balance', field: 'outstandingBalance'},
- {headerName: 'Bll Amount', field: 'billAmt'}
+ {headerName: 'Outstanding Balance', field: 'outstandingBalanceString'},
+ {headerName: 'Bill Amount', field: 'billAmtString'},
+ {headerName: 'Notes', field: 'specialNotes', editable: true, cellEditor: 'agLargeTextCellEditor'}
];
- newInDetails = [];
- newBillAmt = 0;
- selectedInDetails = [];
- selectedPO;
- selectedBillAmt = 0;
- poDetails = [];
- selectedPODetails = [];
-
gridOptions = {
-
- // PROPERTIES - object properties, myRowData and myColDefs are created somewhere in your application
- rowData: this.source,
- columnDefs: this.columnDefs,
-
- // PROPERTIES - simple boolean / string / number properties
- enableColResize: true,
- rowSelection: 'single',
-
- // EVENTS - add event callback handlers
- onRowClicked: (event) => {
- this.getSelectedRows();
- },
- onColumnResized: function (event) {
- console.log('a column was resized');
- },
- onGridReady: (event) => {
- },
- // this.agGrid.sizeColumnsToFit();
- // 1: draft
- // 2: submitted
- // 3: void
-
- // getRowStyle: function(params) {
- // if (params.data.invoiceStatus === 1) {
- // return { 'color': 'red' }
- // } else if (params.data.invoiceStatus === 3) {
- // return { 'text-decoration': 'line-through'}
- // }
- // }
-
rowClassRules: {
- // apply green to 2008
- // 'bg-red': true,
-
- // apply amber 2004
'text-danger': function (params) {
return params.data.invoiceStatus === 1;
},
@@ -84,19 +36,58 @@ export class InvoiceComponent implements OnInit {
},
'text-warning': function (params) {
return params.data.invoiceStatus === 3;
- },
-
- // apply red to 2000
- // 'rag-red-outer': function(params) { return params.data.year === 2000}
+ }
}
- }
+ };
+ detailColumnDefs = [
+ {headerName: '#', field: 'lineItemNum'},
+ {headerName: 'PO Detail', field: 'poDetailName'},
+ {headerName: 'Description', field: 'desc', editable: true, cellEditor: 'agLargeTextCellEditor'},
+ {headerName: 'Fee Type', field: 'feeTypeName'},
+ {headerName: 'Service Type', field: 'serviceTypeName'},
+ {headerName: 'Qty or Hours', field: 'qty', editable: true},
+ {headerName: '(/Remaining)', field: 'remainingQty'},
+ {headerName: 'Fee', field: 'fee', editable: true}
+ ];
- constructor(protected astuteClientService: AstuteClientService, protected printService: PrintInvoiceService) {
+ chosenCustomerID: any = 0;
+ chosenInv: any = 0;
+ source;
+
+ chosenPo;
+ correspondingPos = [];
+ generatedInvoiceNumber = '';
+
+ serviceTypes = [];
+ serviceNames = [];
+ rateTypes = [];
+ rateNames = [];
+ customers;
+ pos = [];
+ allPODetails = [];
+
+ newInDetails = [];
+ newBillAmt = 0;
+
+ selectedInDetails;
+ selectedPO;
+ selectedBillAmt = 0;
+ selectedPODetails = [];
+
+ // poDetails = [];
+
+
+
+ constructor(protected astuteClientService: AstuteClientService,
+ protected printService: PrintInvoiceService) {
}
customerDropdownChange(index) {
this.chosenCustomerID = this.customers[index].customerId;
- this.setCorrespondingPos();
+ this.correspondingPos = this.pos.filter((po) => {
+ console.log(po);
+ return po.customerId === this.chosenCustomerID && !po.oneInvInDraft && po.isFinal;
+ });
}
poDropdownChange(ponum) {
@@ -105,31 +96,22 @@ export class InvoiceComponent implements OnInit {
this.chosenPo = po;
}
})
- this.astuteClientService.getPODetail(ponum).then((data) => {
- if (data) {
- // fee
- // feeTypeId
- // lineItemNo
- // ponum
- // qty
- // remainingQty
- // serviceDesc
- // serviceTypeId
-
- // lineItemNo, feeTypeId, serviceTypeId, serviceDesc, fee, remainingQty
- this.poDetails = data;
- this.poDetails[-1] = {
- 'lineItemNo': -1,
- 'feeTypeId': 1,
- 'serviceTypeId': 1,
- 'serviceDesc': 'Out of Pocket Expenses',
- 'fee': 0,
- 'remainingQty': 0
- };
- } else {
- alert("get PO detail failed!");
- }
- });
+ // this.astuteClientService.getPODetail(ponum).then((data) => {
+ // if (data) {
+ // // lineItemNo, feeTypeId, serviceTypeId, serviceDesc, fee, remainingQty
+ // this.poDetails = data;
+ // this.poDetails[-1] = {
+ // 'lineItemNo': -1,
+ // 'feeTypeId': 1,
+ // 'serviceTypeId': 1,
+ // 'serviceDesc': 'Out of Pocket Expenses',
+ // 'fee': 0,
+ // 'remainingQty': 0
+ // };
+ // } else {
+ // alert('get PO detail failed!');
+ // }
+ // });
this.astuteClientService.generateInvoiceNumber(ponum).then((data) => {
if (data) {
this.generatedInvoiceNumber = data;
@@ -140,42 +122,152 @@ export class InvoiceComponent implements OnInit {
}
ngOnInit() {
+ this.astuteClientService.getServiceTypes().then((d) => {
+ if (d) {
+ this.serviceTypes = d;
+ this.serviceTypes.forEach((type) => {
+ this.serviceNames.push(type.serviceTypeDesc);
+ });
+ } else {
+ alert ('Get service types failed');
+ }
+ }, reason => {
+ alert('Get service type failed: ' + reason);
+ });
+ this.astuteClientService.getRateTypes().then((d) => {
+ if (d) {
+ this.rateTypes = d;
+ this.rateTypes.forEach((type) => {
+ this.rateNames.push(type.feeTypeDesc);
+ });
+ } else {
+ alert ('Get rate types failed');
+ }
+ }, reason => {
+ alert('Get rate type failed: ' + reason);
+ });
+ this.astuteClientService.getCustomers().then((customers) => {
+ if (customers) {
+ this.customers = customers;
+ } else {
+ alert('Get Customers Failed!');
+ }
+ }, (reason) => {
+ alert('Get Customers Failed: ' + reason);
+ });
+ this.astuteClientService.getPOs().then((data) => {
+ this.pos = data;
+ this.pos.forEach((po) => {
+ this.astuteClientService.getPODetail(po.ponum).then((details) => {
+ if (details) {
+ details.forEach((detail) => {
+ this.allPODetails.push(detail);
+ });
+ // console.log(this.allPODetails);
+ } else {
+ alert('Get PO Detail for ' + po.ponum + ' failed!');
+ }
+ }, (reason) => {
+ alert('Get PO Detail for ' + po.ponum + ' failed: ' + reason);
+
+ });
+ });
+ }, (reason) => {
+ alert('Get SOs Failed: ' + reason);
+ });
this.refreshData();
}
refreshData() {
this.astuteClientService.getInvoices().then((data) => {
- this.source = data;
- console.log(data);
- this.source.forEach((row) => {
- row.billAmt = formatCurrency(row.billAmt, 'en-US', '$', 'USD');
- });
- this.source.forEach((row) => {
- row.outstandingBalance = formatCurrency(row.outstandingBalance, 'en-US', '$', 'USD');
- });
- });
-
- this.astuteClientService.getCustomers().then((data) => {
- this.customers = data;
- });
-
- this.astuteClientService.getPOs().then((data) => {
- this.pos = data;
+ if (data) {
+ this.source = data;
+ // console.log(data);
+ this.source.forEach((row) => {
+ row.billAmtString = formatCurrency(row.billAmt, 'en-US', '$', 'USD');
+ row.outstandingBalanceString = formatCurrency(row.outstandingBalance, 'en-US', '$', 'USD');
+ });
+ } else {
+ alert('Get Invoices failed!');
+ }
});
}
+ refreshDetailsOfSelected() {
+ this.setSelectedRow(null);
+ }
getPODetails(poIndex) {
- let ponum = this.pos[poIndex].ponum;
- this.astuteClientService.getPODetail(ponum).then((data) => {
- this.selectedInDetails = data;
- console.log("inDetails:");
- console.log(this.selectedInDetails);
+ const ponum = this.pos[poIndex].ponum;
+ this.selectedInDetails = this.astuteClientService.getPODetail(ponum);
+ }
+
+ updateRow(event) {
+ const eventData = event.data;
+ console.log(eventData);
+ this.astuteClientService.updateInvoice(eventData.invoiceNumber, eventData).then((data) => {
+ if (!data) {
+ this.refreshData();
+ alert('Invoice Updating Failed, Check Input Fields');
+ }
+ }, (reason) => {
+ alert('Update invoice failed: ' + reason);
+ });
+ // this.refreshData();
+ }
+ updateDetailRow(event) {
+ const eventData = event.data;
+ console.log(eventData);
+ this.astuteClientService.updateInvoiceDetail(eventData.invoiceNumber, eventData.lineItemNum, eventData).then((data) => {
+ if (!data) {
+ this.refreshDetailsOfSelected();
+ alert('Detail Updating Failed, Check Input Fields');
+ }
+ }, (reason) => {
+ alert('Update Detail failed: ' + reason);
+ });
+ }
+
+ setSelectedRow(event) {
+ if (event) {
+ this.chosenInv = event.data;
+ }
+ this.selectedBillAmt = this.chosenInv.billAmt;
+ this.selectedPODetails = this.allPODetails.filter((detail) => {
+ return (detail.ponum === this.chosenInv.poNum);
+ });
+ this.selectedInDetails = this.astuteClientService.getInvoiceDetail(this.chosenInv.invoiceNumber).then((data) => {
+ if (data) {
+ data.forEach((invDetail) => {
+ const tempPo = this.selectedPODetails.filter((po) => {
+ return po.lineItemNo === invDetail.poLineItemNum;
+ })[0];
+ if (tempPo) {
+ invDetail.remainingQty = tempPo.remainingQty;
+ }
+
+ invDetail.serviceTypeName = this.serviceNames[invDetail.serviceTypeId - 1];
+ invDetail.rateTypeName = this.rateNames[invDetail.feeTypeId - 1];
+ if (invDetail.poLineItemNum === -1) {
+ invDetail.poDetailName = 'Out of Pocket Expenses';
+ } else {
+ invDetail.poDetailName = this.selectedPODetails[invDetail.poLineItemNum - 1].serviceDesc;
+ }
+ });
+ return data;
+ } else {
+ alert('get Inv detail failed!');
+ }
+ });
+ this.pos.forEach((po) => {
+ if (po.ponum === this.chosenInv.poNum) {
+ this.selectedPO = po;
+ }
});
}
onSelectedCellChange(row: number, col: string, value) {
- this.selectedInDetails[row][col] = value;
- console.log(this.selectedInDetails);
+ // this.selectedInDetails[row][col] = value;
+ // console.log(this.selectedInDetails);
}
onNewCellChange(row: number, col: string, value) {
@@ -184,15 +276,15 @@ export class InvoiceComponent implements OnInit {
}
pushOntoSelectedDetail(invoiceNum, lineItemNum, poLineItemNum, serviceTypeId, desc, qty, fee) {
- this.selectedInDetails.push({
- 'invoiceNum': invoiceNum,
- 'lineItemNum': lineItemNum,
- 'poLineItemNum': poLineItemNum,
- 'serviceTypeId': serviceTypeId,
- 'desc': desc,
- 'qty': +qty,
- 'fee': +fee
- });
+ // this.selectedInDetails.push({
+ // 'invoiceNum': invoiceNum,
+ // 'lineItemNum': lineItemNum,
+ // 'poLineItemNum': poLineItemNum,
+ // 'serviceTypeId': serviceTypeId,
+ // 'desc': desc,
+ // 'qty': +qty,
+ // 'fee': +fee
+ // });
}
pushOntoNewDetail(invoiceNum, lineItemNum, poLineItemNum, feeTypeId, serviceTypeId, desc, qty, fee, remainingQty, poNum) {
@@ -218,65 +310,68 @@ export class InvoiceComponent implements OnInit {
});
this.newBillAmt = tot;
}
-
updateSelectedBillAmt() {
- let tot = 0;
- this.selectedInDetails.forEach((d) => {
- tot += +d.qty * +d.fee;
- });
- this.selectedBillAmt = tot;
+ // let tot = 0;
+ // this.selectedInDetails.forEach((d) => {
+ // tot += +d.qty * +d.fee;
+ // });
+ // this.selectedBillAmt = tot;
}
- assignActity(): void {
- window.open('/invoice-gen');
- }
printInvoice() {
this.printService.printPDF (this.chosenInv.invoiceNumber);
}
- getSelectedRows() {
- const selectedNodes = this.agGrid.api.getSelectedNodes();
- if (selectedNodes.length) {
- this.chosenInv = selectedNodes.map(node => node.data)[0];
- // console.log (this.chosenInv);
- this.selectedBillAmt = +(this.chosenInv.billAmt.replace(',', '').replace('$', ''));
- this.astuteClientService.getPODetail(this.chosenInv.poNum).then((poDetails) => {
- if (poDetails) {
- this.selectedPODetails = poDetails;
- this.astuteClientService.getInvoiceDetail(this.chosenInv.invoiceNumber).then((invoiceDetails) => {
- if (invoiceDetails) {
- this.selectedInDetails = invoiceDetails;
- this.selectedInDetails.forEach((invDetail) => {
- const tempPo = this.selectedPODetails.filter((po) => {
- // console.log (po.lineItemNo + " and " + invDetail.poLineItemNum);
- return po.lineItemNo === invDetail.poLineItemNum;
- })[0];
- if (tempPo) {
- invDetail.remainingQty = tempPo.remainingQty;
- }
- });
- } else {
- alert("get Inv detail failed!");
- }
- });
- } else {
- alert("get PO detail failed!")
- }
- });
- this.pos.forEach((po) => {
- if (po.ponum === this.chosenInv.poNum) {
- this.selectedPO = po;
- }
- });
- } else {
- this.chosenInv = null;
- this.selectedPODetails = [];
- }
- }
+ // getSelectedRows() {
+ // const selectedNodes = this.gridApi.getSelectedNodes();
+ // if (selectedNodes.length) {
+ // this.chosenInv = selectedNodes.map(node => node.data)[0];
+ // // console.log (this.chosenInv);
+ // this.selectedBillAmt = +(this.chosenInv.billAmt.replace(',', '').replace('$', ''));
+ // this.astuteClientService.getPODetail(this.chosenInv.poNum).then((poDetails) => {
+ // if (poDetails) {
+ // this.selectedPODetails = poDetails;
+ // this.astuteClientService.getInvoiceDetail(this.chosenInv.invoiceNumber).then((invoiceDetails) => {
+ // if (invoiceDetails) {
+ // this.selectedInDetails = invoiceDetails;
+ // this.selectedInDetails.forEach((invDetail) => {
+ // const tempPo = this.selectedPODetails.filter((po) => {
+ // // console.log (po.lineItemNo + " and " + invDetail.poLineItemNum);
+ // return po.lineItemNo === invDetail.poLineItemNum;
+ // })[0];
+ // if (tempPo) {
+ // invDetail.remainingQty = tempPo.remainingQty;
+ // }
+ // });
+ // } else {
+ // alert("get Inv detail failed!");
+ // }
+ // });
+ // } else {
+ // alert("get PO detail failed!")
+ // }
+ // });
+ // this.pos.forEach((po) => {
+ // if (po.ponum === this.chosenInv.poNum) {
+ // this.selectedPO = po;
+ // }
+ // });
+ // } else {
+ // this.chosenInv = null;
+ // this.selectedPODetails = [];
+ // }
+ // }
- open(content, indexPO, indexINV) {
- this.setCorrespondingCustomer();
+ // open(content, indexPO, indexINV) {
+ open(content) {
+ // this.setCorrespondingCustomer();
+ if (this.gridColumnApi) {
+ this.gridColumnApi.autoSizeAllColumns();
+ }
+ if (this.detailColumnApi) {
+ this.detailColumnApi.autoSizeAllColumns();
+ }
content.open();
// this.detailDescription = ViewChild('detailDescription');
// this.detailAmount = ViewChild('detailAmount');
@@ -295,7 +390,6 @@ export class InvoiceComponent implements OnInit {
// this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
// });
}
-
close(content) {
content.close();
// this.newInDetails = [];
@@ -340,7 +434,6 @@ export class InvoiceComponent implements OnInit {
});
}
}
-
addInvoice(invoiceNumber, poNum, changeOrderNum, pmtStatus, billAmt, specialNotes, certification, status, ref) {
// String invoiceNumber;
// Date invoiceDate;
@@ -372,61 +465,13 @@ export class InvoiceComponent implements OnInit {
.then((data) => {
if (data) {
this.refreshData();
- this.addInvoiceDetail(this.newInDetails);
+ // this.addInvoiceDetail(this.newInDetails);
ref.close();
} else {
alert('Invoice Creation Failed, Check Input Fields');
}
});
}
-
- addInvoiceDetail(details) {
- if (details.length) {
- // console.log(details[0]);
- // if (details[0].poLineItemNum !== -1) {
- this.astuteClientService.createInvoiceDetail(details[0]).then((data) => {
- if (data) {
- details.splice(0, 1);
- this.addInvoiceDetail(details);
- } else {
- alert('add inv detail failed');
- }
- });
- // } else {
- // desc
- // fee
- // feeTypeId
- // invoiceNum
- // lineItemNum
- // poLineItemNum
- // qty
- // remainingQty
- // serviceTypeId
- // poNum
-
- // const data = {
- // // 'lineItemNo': details[0].,
- // 'poNum': details[0].poNum,
- // 'serviceDesc': details[0].desc,
- // 'feeTypeId': details[0].feeTypeId,
- // 'serviceTypeId': details[0].serviceTypeId,
- // 'qty': +details[0].qty,
- // 'fee': +details[0].fee,
- // 'remainingQty': +details[0].fee * +details[0].qty
- // };
- // this.astuteClientService.createPODetail(data).then((d) => {
- // if (d) {
- // console.log (d);
- // } else {
- // alert('create custom PO failed.');
- // }
- // });
- // }
- } else {
- this.newInDetails = [];
- }
- }
-
editInvoice(invoiceNumber, poNum, changeOrderNum, pmtStatus, billAmt, specialNotes, certification) {
// String invoiceNumber;
// Date invoiceDate;
@@ -464,7 +509,6 @@ export class InvoiceComponent implements OnInit {
}
});
}
-
voidInvoice(invoiceNumber) {
if (confirm('Are you sure you want to void invoice, ' + invoiceNumber)) {
this.astuteClientService.voidInvoice(invoiceNumber).then((data) => {
@@ -476,7 +520,6 @@ export class InvoiceComponent implements OnInit {
});
}
}
-
submitInvoice(invoiceNumber) {
this.astuteClientService.submitInvoice(invoiceNumber).then((data) => {
if (data) {
@@ -487,23 +530,141 @@ export class InvoiceComponent implements OnInit {
});
}
+ // creates empty line item detail
+ addEmptyDetail(poLineItemNum) {
+ const emptyData = {
+ desc: '',
+ fee: 0,
+ feeTypeId: 1,
+ invoiceNum: this.chosenInv.invoiceNumber,
+ // lineItemNum: 1,
+ poLineItemNum: poLineItemNum,
+ qty: 1,
+ remainingQty: 1,
+ serviceTypeId: 1
+ };
+
+ // desc: "Design Somethign"
+ // fee: 2500
+ // feeTypeId: 1
+ // invoiceNum: "MDO-01_DRAFT_157"
+ // lineItemNum: 1
+ // poLineItemNum: 1
+ // qty: 1
+ // remainingQty: 0
+ // serviceTypeId: 2
+
+ this.astuteClientService.createInvoiceDetail(emptyData).then((data) => {
+ if (!data) {
+ this.refreshDetailsOfSelected();
+ alert('Creating SO detailed failed!');
+ }
+ }, (reason) => {
+ alert('Creating SO detailed failed: ' + reason);
+ });
+ }
+
+ // addInvoiceDetail(details) {
+ // if (details.length) {
+ // // console.log(details[0]);
+ // // if (details[0].poLineItemNum !== -1) {
+ // this.astuteClientService.createInvoiceDetail(details[0]).then((data) => {
+ // if (data) {
+ // details.splice(0, 1);
+ // this.addInvoiceDetail(details);
+ // } else {
+ // alert('add inv detail failed');
+ // }
+ // });
+ // // } else {
+ // // desc
+ // // fee
+ // // feeTypeId
+ // // invoiceNum
+ // // lineItemNum
+ // // poLineItemNum
+ // // qty
+ // // remainingQty
+ // // serviceTypeId
+ // // poNum
+ //
+ // // const data = {
+ // // // 'lineItemNo': details[0].,
+ // // 'poNum': details[0].poNum,
+ // // 'serviceDesc': details[0].desc,
+ // // 'feeTypeId': details[0].feeTypeId,
+ // // 'serviceTypeId': details[0].serviceTypeId,
+ // // 'qty': +details[0].qty,
+ // // 'fee': +details[0].fee,
+ // // 'remainingQty': +details[0].fee * +details[0].qty
+ // // };
+ // // this.astuteClientService.createPODetail(data).then((d) => {
+ // // if (d) {
+ // // console.log (d);
+ // // } else {
+ // // alert('create custom PO failed.');
+ // // }
+ // // });
+ // // }
+ // } else {
+ // this.newInDetails = [];
+ // }
+ // }
+
+
getPerc(amt, total): number {
return Math.floor(((amt) / total) * 100);
}
-
getRangeMax(total, num) {
return Math.floor(total / num);
}
- setCorrespondingPos() {
- this.correspondingPos = this.pos.filter((po, index, array) => {
- return po.customerId === this.chosenCustomerID && !po.oneInvInDraft && po.final;
+
+ // setCorrespondingCustomer() {
+ // this.correspondingCustomer = this.customers.filter((customer, index, array) => {
+ // return customer.customerId === this.chosenInv.customerId;
+ // });
+ // }
+
+ getCustomerNameFromId(customerId) {
+ let name = '';
+ this.customers.forEach((customer) => {
+ if (customer.customerId === customerId) {
+ name = customer.customerName;
+ }
});
+ return name;
+ }
+ getServiceIdFromName(name) {
+ let id = -1;
+ this.serviceTypes.forEach((type) => {
+ console.log(type.serviceTypeDesc + ' ' + name);
+ if (type.serviceTypeDesc === name) {
+ id = type.serviceTypeId;
+ }
+ });
+ return id;
+ }
+ getFeeIdFromName(name: any) {
+ let id = -1;
+ this.rateTypes.forEach((type) => {
+ if (type.feeTypeDesc === name) {
+ id = type.feeTypeId;
+ }
+ });
+ return id;
}
- setCorrespondingCustomer() {
- this.correspondingCustomer = this.customers.filter((customer, index, array) => {
- return customer.customerId === this.chosenInv.customerId;
- });
+ // ag grid callbacks
+ onGridReady(evt) {
+ this.gridApi = evt.api;
+ this.gridColumnApi = evt.columnApi;
+ }
+ onDetailGridReady(evt) {
+ this.detailGridApi = evt.api;
+ this.detailColumnApi = evt.columnApi;
+ }
+ resizeColumns(evt) {
+ evt.columnApi.autoSizeAllColumns();
}
}
diff --git a/AstuteClient2/src/app/sales-order/sales-order.component.ts b/AstuteClient2/src/app/sales-order/sales-order.component.ts
index c97da4e..03ce765 100644
--- a/AstuteClient2/src/app/sales-order/sales-order.component.ts
+++ b/AstuteClient2/src/app/sales-order/sales-order.component.ts
@@ -37,6 +37,16 @@ export class SalesOrderComponent implements OnInit {
{headerName: 'notes', field: 'notes', editable: true, cellEditor: 'agLargeTextCellEditor'}
// {headerName: 'oneInvInDraft', field: 'oneInvInDraft'}
];
+ gridOptions = {
+ rowClassRules: {
+ 'text-danger': function (params) {
+ return !params.data.isFinal;
+ },
+ 'text-primary': function (params) {
+ return params.data.isFinal;
+ },
+ }
+ };
selected = null; // the selected SO row
// data for SO detail grid
@@ -85,13 +95,13 @@ export class SalesOrderComponent implements OnInit {
this.astuteClientService.getCustomers().then((customers) => {
if (customers) {
this.customers = customers;
- this.refreshData();
} else {
alert('Get Customers Failed!');
}
}, (reason) => {
alert('Get Customers Failed: ' + reason);
});
+ this.refreshData();
}
// callback for grid selection
@@ -109,12 +119,12 @@ export class SalesOrderComponent implements OnInit {
});
// console.log(this.selectedPODetail);
this.updateContractAmt();
- if (this.gridColumnApi) {
- this.gridColumnApi.autoSizeAllColumns();
- }
- if (this.detailColumnApi) {
- this.detailColumnApi.autoSizeAllColumns();
- }
+ // if (this.gridColumnApi) {
+ // this.gridColumnApi.autoSizeAllColumns();
+ // }
+ // if (this.detailColumnApi) {
+ // this.detailColumnApi.autoSizeAllColumns();
+ // }
return data;
} else {
alert('Get SO detail failed!');
@@ -132,8 +142,8 @@ export class SalesOrderComponent implements OnInit {
this.astuteClientService.updatePO(eventData.poNum, eventData).then((data) => {
if (!data) {
alert('SO updating failed, check input fields');
+ this.refreshData();
}
- this.refreshData();
}, (reason) => {
alert('Update SO failed: ' + reason);
});
@@ -152,8 +162,8 @@ export class SalesOrderComponent implements OnInit {
this.astuteClientService.updatePODetail(eventData.poNum, eventData.lineItemNo, eventData).then((data) => {
if (!data) {
alert('SO Detail updating failed, check input fields');
+ this.refreshDetailsOfSelected();
}
- this.refreshDetailsOfSelected();
}, (reason) => {
alert('Update SO Detail failed: ' + reason);
});
@@ -270,8 +280,12 @@ export class SalesOrderComponent implements OnInit {
// open and closing modal-form components
open(ref) {
// this.getSelectedRows();
- this.gridColumnApi.autoSizeAllColumns();
- this.detailColumnApi.autoSizeAllColumns();
+ if (this.gridColumnApi) {
+ this.gridColumnApi.autoSizeAllColumns();
+ }
+ if (this.detailColumnApi) {
+ this.detailColumnApi.autoSizeAllColumns();
+ }
ref.open();
}
close(ref) {
diff --git a/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java b/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java
index fca2b15..5e7616a 100644
--- a/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java
+++ b/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java
@@ -140,7 +140,7 @@ public class SqlDAO extends DAO {
updateClause = updateClause + " PO_Date = STR_TO_DATE('" + PODate + "', '%Y-%m-%d')" + ",";
updateClause = updateClause + " contract_amt = " + contractAmt+ ",";
updateClause = updateClause + " astute_project_num = '" + astuteProjectNumber +"',";
- updateClause = updateClause + " title = '" + title +"'";
+ updateClause = updateClause + " title = '" + title +"',";
updateClause = updateClause + " notes = '" + notes +"'";
sql = sql+ updateClause + whereClause;
System.out.println(sql);
@@ -266,7 +266,7 @@ public class SqlDAO extends DAO {
public void finalizePO(String PONum) throws AstuteException {
try {
- String sql = "UPDATE PO_MASTER SET final = 1 WHERE PO_Num = '" + PONum + "''";
+ String sql = "UPDATE PO SET final = 1 WHERE PO_Num = '" + PONum + "'";
System.out.println(sql);
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
@@ -278,7 +278,7 @@ public class SqlDAO extends DAO {
public void deletePO(String PONum) throws AstuteException {
try {
- String sql = "DELETE FROM PO_MASTER SET final = 1 WHERE PO_Num = '" + PONum + "'' AND final = 0";
+ String sql = "DELETE FROM PO SET final = 1 WHERE PO_Num = '" + PONum + "' AND final = 0";
System.out.println(sql);
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
@@ -329,7 +329,7 @@ public class SqlDAO extends DAO {
public void createServiceType(String desc) throws AstuteException {
try {
Statement stmt = conn.createStatement();
- String sql = "INSERT INTO service_type (service_type_id, `desc`) VALUES ((SELECT MAX(service_type_id)+1 FROM SERVICE_TYPE B), desc)";
+ String sql = "INSERT INTO service_type (service_type_id, `desc`) VALUES ((SELECT MAX(service_type_id)+1 FROM SERVICE_TYPE B), '" + desc + "')";
stmt.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
@@ -449,7 +449,6 @@ public class SqlDAO extends DAO {
whereClause = whereClause + " pmt_status = "+ pmtStatus;
}
if (!whereClause.equals(" WHERE ")) {
-
sql += whereClause;
}
System.out.println(sql);
@@ -986,7 +985,7 @@ public class SqlDAO extends DAO {
stmt.executeUpdate();
result = stmt.getString(1);
System.out.println(result);
- if (!result.equals("SUCCESS")) {
+ if (!result.equals("Success")) {
throw new AstuteException(DB_ERROR, result);
}
} catch (SQLException e) {
@@ -1049,25 +1048,24 @@ public class SqlDAO extends DAO {
String sql = "select user_id, username, password, CONCAT(first_name, ' ', last_name) as name from user where username='" + username + "'";
try {
- Statement stmt = conn.createStatement();
- ResultSet resultSet = stmt.executeQuery(sql);
+ Statement stmt = conn.createStatement();
+ ResultSet resultSet = stmt.executeQuery(sql);
- User user = null;
- if(resultSet.next()) {
- user = new User(resultSet.getInt(1),
- resultSet.getString(2),
- resultSet.getString(3),
- resultSet.getString(4),null
- );
- }
-// conn.close();
-
- return user;
+ User user = null;
+ if(resultSet.next()) {
+ user = new User(resultSet.getInt(1),
+ resultSet.getString(2),
+ resultSet.getString(3),
+ resultSet.getString(4), null
+ );
+ }
+// conn.close();
+ return user;
} catch (SQLException e) {
e.printStackTrace();
throw new AstuteException(DB_ERROR,e.getMessage());
}
- }
+ }
public void createSession(int userId, String sessionId) throws AstuteException {
try {
@@ -1273,7 +1271,7 @@ public class SqlDAO extends DAO {
public User login(String username, String password) throws AstuteException{
User user = getUser(username);
boolean check = false;
- if (password.equals(user.getPassword())) {
+ if (user != null && password.equals(user.getPassword())) {
check = true;
}
// try {
@@ -1283,14 +1281,14 @@ public class SqlDAO extends DAO {
// } catch (InvalidKeySpecException e) {
//
// }
- if(check) {
+ if (check) {
//create session
String sessionId = UUID.randomUUID().toString().replaceAll("-", "");
createSession(user.getUserId(), sessionId);
user.setSessionId(sessionId);
return user;
- }else{
+ } else {
return null; //"Username or password was not correct";
}
}
diff --git a/AstuteSystem/src/main/java/com/astute/requests/ServiceTypeRequest.java b/AstuteSystem/src/main/java/com/astute/requests/ServiceTypeRequest.java
index 153b612..4b901df 100644
--- a/AstuteSystem/src/main/java/com/astute/requests/ServiceTypeRequest.java
+++ b/AstuteSystem/src/main/java/com/astute/requests/ServiceTypeRequest.java
@@ -20,6 +20,8 @@ public class ServiceTypeRequest {
this.serviceTypeDesc = serviceTypeDesc;
}
+ public ServiceTypeRequest() {}
+
public ServiceTypeRequest(int serviceTypeId, String desc) {
this.serviceTypeId = serviceTypeId;
this.serviceTypeDesc = serviceTypeDesc;
diff --git a/AstuteSystem/src/main/java/com/astute/resources/AuthResource.java b/AstuteSystem/src/main/java/com/astute/resources/AuthResource.java
index 61880db..47072bb 100644
--- a/AstuteSystem/src/main/java/com/astute/resources/AuthResource.java
+++ b/AstuteSystem/src/main/java/com/astute/resources/AuthResource.java
@@ -14,7 +14,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-@Path("auth")
+@Path("/auth")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class AuthResource {
diff --git a/AstuteSystem/src/main/main.iml b/AstuteSystem/src/main/main.iml
deleted file mode 100644
index 80f2369..0000000
--- a/AstuteSystem/src/main/main.iml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file