mirror of
https://github.com/dyiop/astute.git
synced 2025-04-05 13:00:16 -04:00
Bug fixes
This commit is contained in:
parent
f9120250be
commit
dbb904d7c2
|
@ -99,6 +99,13 @@ export class CustomerComponent implements OnInit {
|
|||
|
||||
// inName.value, inBillToDept.value, inAdd1.value, inAdd2.value, inCity.value, inState.value, inZIP.value, inZIP4.value, inEmail.value, inPhone.value, inFax.value
|
||||
addCustomer(customerId, name, billTo, add1, add2, city, state, zip, zip4, email, phone, phExt, fax, ref) {
|
||||
if (fax.length > 0 && fax.length < 14) {
|
||||
alert('Invalid fax.');
|
||||
} else if (phone.length > 0 && phone.length < 14) {
|
||||
alert('Invalid phone.');
|
||||
} else if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email) == false) {
|
||||
alert("You have entered an invalid email address!")
|
||||
} else {
|
||||
let customerData = {
|
||||
"customerId": customerId,
|
||||
"customerName": name,
|
||||
|
@ -124,25 +131,33 @@ export class CustomerComponent implements OnInit {
|
|||
}, (reason) => {
|
||||
alert("add customer failed for " + reason);
|
||||
});
|
||||
}
|
||||
}}
|
||||
|
||||
|
||||
editCustomer(id, name, billTo, add1, add2, city, state, zip, zip4, email, phone, phExt, fax, ref) {
|
||||
const customerData = {
|
||||
"customerId": id,
|
||||
"customerName": name,
|
||||
"billToDept": billTo,
|
||||
"add1": add1,
|
||||
"add2": add2,
|
||||
"city": city,
|
||||
"state": state,
|
||||
"zip": zip,
|
||||
"ziplast4": zip4,
|
||||
"email": email,
|
||||
"phone": phone,
|
||||
"phExt": phExt,
|
||||
"fax": fax
|
||||
};
|
||||
if (fax.length > 0 && fax.length < 14) {
|
||||
alert('Invalid fax.');
|
||||
} else if (phone.length > 0 && phone.length < 14) {
|
||||
alert('Invalid phone.');
|
||||
} else if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email) == false) {
|
||||
alert("You have entered an invalid email address!")
|
||||
} else {
|
||||
const customerData = {
|
||||
"customerId": id,
|
||||
"customerName": name,
|
||||
"billToDept": billTo,
|
||||
"add1": add1,
|
||||
"add2": add2,
|
||||
"city": city,
|
||||
"state": state,
|
||||
"zip": zip,
|
||||
"ziplast4": zip4,
|
||||
"email": email,
|
||||
"phone": phone,
|
||||
"phExt": phExt,
|
||||
"fax": fax
|
||||
};
|
||||
|
||||
this.astuteClientService.updateCustomer(id, customerData).then((data) => {
|
||||
if (data) {
|
||||
this.refreshData();
|
||||
|
@ -153,7 +168,7 @@ export class CustomerComponent implements OnInit {
|
|||
}, (reason) => {
|
||||
alert("update customer failed for " + reason);
|
||||
});
|
||||
}
|
||||
}}
|
||||
|
||||
deleteCustomer (customerId) {
|
||||
if (confirm('Are you sure you want to delete customer, ' + customerId)) {
|
||||
|
|
|
@ -59,7 +59,7 @@ export class InvoiceGenComponent implements OnInit {
|
|||
this.gridY[j] = y;
|
||||
y += 10;
|
||||
}
|
||||
this.astuteClientService.getInvoiceGen('MDO-01_DRAFT_720').then((data) => {
|
||||
this.astuteClientService.getInvoiceGen('VDO-02_0108_3').then((data) => {
|
||||
this.name = data.customer.customerName;
|
||||
this.email = data.customer.email;
|
||||
this.address = data.customer.add1 + ' ' + data.customer.add2 + ' ' +
|
||||
|
|
|
@ -1,34 +1,35 @@
|
|||
<nav class="navbar navbar-expand-lg navbar-dark navbar-lightblue">
|
||||
<a class="navbar-brand" routerLink="/">Astute Internal System</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
|
||||
<div class="navbar-nav">
|
||||
<a class="nav-link" [ngClass]="customerActive ? 'active' : ''" routerLink="/customer" routerLinkActive="active">Customer</a>
|
||||
<a class="nav-link" [ngClass]="salesOrderActive ? 'active' : ''"routerLink="/sales-order" routerLinkActive="active">Sales Order</a>
|
||||
<a class="nav-link" [ngClass]="invoiceActive ? 'active' : ''"routerLink="/invoice" routerLinkActive="active">Invoice</a>
|
||||
<a class="nav-link" [ngClass]="invoicePaymentActive ? 'active' : ''"routerLink="/invoice-payment" routerLinkActive="active">Invoice Payment</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!--<div class="card text-center">-->
|
||||
<!--<div class="card-header">-->
|
||||
<!--<a class="navbar-brand" href="#">Astute Internal System</a>-->
|
||||
<!--<ul class="nav nav-pills card-header-pills">-->
|
||||
<!--<li class="nav-item">-->
|
||||
<!--<a class="nav-link" [ngClass]="customerActive ? 'active' : ''" routerLink="/customer" routerLinkActive="active">Customer</a>-->
|
||||
<!--</li>-->
|
||||
<!--<li class="nav-item">-->
|
||||
<!--<a class="nav-link" [ngClass]="salesOrderActive ? 'active' : ''"routerLink="/sales-order" routerLinkActive="active">Sales Order</a>-->
|
||||
<!--</li>-->
|
||||
<!--<li class="nav-item">-->
|
||||
<!--<a class="nav-link" [ngClass]="invoiceActive ? 'active' : ''"routerLink="/invoice" routerLinkActive="active">Invoice</a>-->
|
||||
<!--</li>-->
|
||||
<!--</ul>-->
|
||||
<!--</div>-->
|
||||
<!--<div class="card-body">-->
|
||||
<!--<app-homepage></app-homepage>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<nav class="navbar navbar-expand-lg navbar-dark navbar-lightblue">
|
||||
<a class="navbar-brand" routerLink="/homepage">Astute Internal System</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
|
||||
<div class="navbar-nav">
|
||||
<a class="nav-link" [ngClass]="customerActive ? 'active' : ''" routerLink="/customer" routerLinkActive="active">Customer</a>
|
||||
<a class="nav-link" [ngClass]="salesOrderActive ? 'active' : ''"routerLink="/sales-order" routerLinkActive="active">Sales Order</a>
|
||||
<a class="nav-link" [ngClass]="invoiceActive ? 'active' : ''"routerLink="/invoice" routerLinkActive="active">Invoice</a>
|
||||
<a class="nav-link" [ngClass]="invoicePaymentActive ? 'active' : ''"routerLink="/invoice-payment" routerLinkActive="active">Invoice Payment</a>
|
||||
<a class="nav-link" [ngClass]="logoffActive ? 'active' : ''"routerLink="/login" routerLinkActive="active">Log off</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!--<div class="card text-center">-->
|
||||
<!--<div class="card-header">-->
|
||||
<!--<a class="navbar-brand" href="#">Astute Internal System</a>-->
|
||||
<!--<ul class="nav nav-pills card-header-pills">-->
|
||||
<!--<li class="nav-item">-->
|
||||
<!--<a class="nav-link" [ngClass]="customerActive ? 'active' : ''" routerLink="/customer" routerLinkActive="active">Customer</a>-->
|
||||
<!--</li>-->
|
||||
<!--<li class="nav-item">-->
|
||||
<!--<a class="nav-link" [ngClass]="salesOrderActive ? 'active' : ''"routerLink="/sales-order" routerLinkActive="active">Sales Order</a>-->
|
||||
<!--</li>-->
|
||||
<!--<li class="nav-item">-->
|
||||
<!--<a class="nav-link" [ngClass]="invoiceActive ? 'active' : ''"routerLink="/invoice" routerLinkActive="active">Invoice</a>-->
|
||||
<!--</li>-->
|
||||
<!--</ul>-->
|
||||
<!--</div>-->
|
||||
<!--<div class="card-body">-->
|
||||
<!--<app-homepage></app-homepage>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
import {Component, Input, OnInit} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-nav-bar',
|
||||
templateUrl: './nav-bar.component.html',
|
||||
styleUrls: ['./nav-bar.component.css']
|
||||
})
|
||||
export class NavBarComponent implements OnInit {
|
||||
@Input() customerActive: boolean;
|
||||
@Input() salesOrderActive: boolean;
|
||||
@Input() invoiceActive: boolean;
|
||||
@Input() invoicePaymentActive: boolean;
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-nav-bar',
|
||||
templateUrl: './nav-bar.component.html',
|
||||
styleUrls: ['./nav-bar.component.css']
|
||||
})
|
||||
export class NavBarComponent implements OnInit {
|
||||
@Input() customerActive: boolean;
|
||||
@Input() salesOrderActive: boolean;
|
||||
@Input() invoiceActive: boolean;
|
||||
@Input() invoicePaymentActive: boolean;
|
||||
@Input() logoffActive: boolean;
|
||||
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
<button class="btn btn-info" style="width: 100%" (click)="open(edit)">Edit</button>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<button class="btn btn-primary" style="width: 100%" (click)="open(edit)">Finalize</button>
|
||||
<button class="btn btn-primary" style="width: 100%" (click)="finalizePO(selected.ponum)" [disabled]="selected.final === 1">Finalize</button>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<button class="btn btn-danger" style="width: 100%" (click)="open(edit)">Delete</button>
|
||||
<button class="btn btn-danger" style="width: 100%" (click)="deletePO(selected.ponum)" [disabled]="selected.final === 0">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -45,11 +45,16 @@ export class SalesOrderComponent implements OnInit {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
printValue(val) {
|
||||
console.log(val);
|
||||
}
|
||||
|
||||
gridOptions = {
|
||||
onRowClicked: (event) => {
|
||||
this.getSelectedRows();
|
||||
}
|
||||
}
|
||||
|
||||
addPo(projNum, ponum, podate, customerid, contractnum, contractamt, title, notes, ref) {
|
||||
const poData = {
|
||||
"astuteProjectNumber": projNum,
|
||||
|
@ -131,6 +136,28 @@ export class SalesOrderComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
finalizePO(ponum) {
|
||||
this.astuteClientService.finalizePO(ponum).then((data) => {
|
||||
if (data) {
|
||||
this.refreshData();
|
||||
alert("PO is now final and ready to be used, you can't delete it anymore!");
|
||||
} else {
|
||||
alert("Finalizing PO failed, check input fields");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
deletePO(ponum) {
|
||||
this.astuteClientService.deletePO(ponum).then((data) => {
|
||||
if (data) {
|
||||
this.refreshData();
|
||||
} else {
|
||||
alert("deleting PO failed, check input fields");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pushOntoSelectedDetail(lineItemNo: number, ponum, serviceDesc, feeTypeId, serviceTypeId, qty, fee, remainingQty) {
|
||||
this.selectedPODetail.push({
|
||||
'lineItemNo': lineItemNo,
|
||||
|
|
|
@ -181,7 +181,24 @@ export class AstuteClientService {
|
|||
.then(response => response['entity']);
|
||||
}
|
||||
|
||||
// **************************************** Invoice Service methods
|
||||
public finalizePO(ponum: string){
|
||||
console.log("*** In finalizePO()");
|
||||
const url = `${this.POUrl}/${ponum}/finalize`; //TODO send sessionId
|
||||
return this.http.put(url, {})
|
||||
.toPromise()
|
||||
.then(response => response['entity']);
|
||||
}
|
||||
|
||||
|
||||
public deletePO(ponum: string) {
|
||||
console.log("*** In deletePO()");
|
||||
const url = `${this.POUrl}/${ponum}/delete`; //TODO send sessionId
|
||||
return this.http.put(url, {})
|
||||
.toPromise()
|
||||
.then(response => response['entity']);
|
||||
}
|
||||
|
||||
// **************************************** Invoice Service methods
|
||||
|
||||
// /{InvoiceNumber}/void
|
||||
public submitInvoice (invoiceNumber) {
|
||||
|
|
586
AstuteSystem/sql/astute_old.sql
Normal file
586
AstuteSystem/sql/astute_old.sql
Normal file
|
@ -0,0 +1,586 @@
|
|||
-- --------------------------------------------------------
|
||||
-- Host: 127.0.0.1
|
||||
-- Server version: 5.7.12-log - MySQL Community Server (GPL)
|
||||
-- Server OS: Win64
|
||||
-- HeidiSQL Version: 9.4.0.5125
|
||||
-- --------------------------------------------------------
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
/*!50503 SET NAMES utf8mb4 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
|
||||
|
||||
-- Dumping database structure for astute
|
||||
DROP DATABASE IF EXISTS `astute`;
|
||||
CREATE DATABASE IF NOT EXISTS `astute` /*!40100 DEFAULT CHARACTER SET utf8 */;
|
||||
USE `astute`;
|
||||
|
||||
-- Dumping structure for table astute.change_order
|
||||
CREATE TABLE IF NOT EXISTS `change_order` (
|
||||
`PO_num` varchar(20) NOT NULL,
|
||||
`change_order_num` int(20) NOT NULL,
|
||||
`change_order_date` date DEFAULT NULL,
|
||||
`change_order_amt` double NOT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
PRIMARY KEY (`PO_num`,`change_order_num`),
|
||||
CONSTRAINT `fk_PO_CO_POnum` FOREIGN KEY (`PO_num`) REFERENCES `po` (`PO_num`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.change_order: ~0 rows (approximately)
|
||||
/*!40000 ALTER TABLE `change_order` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `change_order` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for function astute.create_customer_fun
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` FUNCTION `create_customer_fun`(customerid varchar(20), customerName varchar(100), billToDept varchar(100), add1In varchar(100), add2In varchar(100), cityIn varchar(50), stateIn varchar(20), zipIn int(5), zipLast4In int(4), emailIn varchar(50), phoneIn varchar(20), faxIn varchar(20)) RETURNS varchar(20) CHARSET utf8
|
||||
BEGIN
|
||||
DECLARE last_inserted_id varchar(20);
|
||||
INSERT INTO customer (customer_id, customer_name, bill_to_dept, add1, add2, city, state ,zip, zip_last_4, email, phone, fax)
|
||||
VALUES (customerid, customerName, billToDept, add1In, add2In, cityIn, stateIn, zipIn, ziplast4In, emailIn, phoneIn, faxIn);
|
||||
SELECT LAST_INSERT_ID() into last_inserted_id;
|
||||
return last_inserted_id;
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for procedure astute.create_invoice
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `create_invoice`(invNo varchar(20),invDate date,PONo varchar(20),paymentStatus int,billAmt double,specialNotes varchar(500), certClause Varchar(500), invoiceStatus int)
|
||||
BEGIN
|
||||
INSERT INTO invoice (inv_no,inv_date,PO_num,pmt_status,bill_amt,special_notes,certification,inv_status)
|
||||
VALUES (invNo, invDate, PONo, paymentStatus, billAmt, specialNotes, certClause, invoiceStatus);
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for procedure astute.create_invoice_detail
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `create_invoice_detail`(invoiceNum varchar(20), lineItemNum int, POLineItemNum varchar(20), serviceTypeId int, description varchar(500), qty_in double, fee_in double, fee_type_id_in int)
|
||||
BEGIN
|
||||
INSERT INTO INVOICE_DETAIL (inv_num, line_item_num, PO_line_item_num, service_type_id, description, qty, fee, fee_type_id)
|
||||
VALUES (invoiceNum, lineItemNum, POLineItemNum, serviceTypeId, description, qty_in, fee_in, fee_type_id_in);
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for procedure astute.create_po
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `create_po`(PONum varchar(40), contractNum varchar(20), PODate date, contractAmt double(10,2), customerid varchar(20), astute_project_num_in varchar(20), title_in varchar(200))
|
||||
BEGIN
|
||||
DECLARE next_po_id int(11);
|
||||
SELECT count(*) + 1 INTO next_po_id FROM PO WHERE customer_id = customerid;
|
||||
INSERT INTO PO (po_id, PO_num, contract_num, PO_date, contract_amt, customer_id,astute_project_num, title )
|
||||
VALUES (next_po_id, PONum, contractNum, PODate, contractAmt, customerId,astute_project_num_in, title_in);
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for procedure astute.create_po_detail
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `create_po_detail`(PONum varchar(40), lineItemNo int, servicedesc varchar(500), feetypeid int(11), quantity double, fee_in double, servicetypeid int(1), remaining_qty double)
|
||||
BEGIN
|
||||
INSERT INTO PO_DETAIL (PO_num,line_item_no,service_desc,fee_type_id,qty,fee,service_type_id, remaining_qty)
|
||||
VALUES (POnum,lineitemno,servicedesc,feetypeid,quantity,fee_in, servicetypeid, remaining_qty);
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for table astute.customer
|
||||
CREATE TABLE IF NOT EXISTS `customer` (
|
||||
`customer_id` varchar(10) NOT NULL,
|
||||
`customer_name` varchar(100) DEFAULT NULL,
|
||||
`bill_to_dept` varchar(50) DEFAULT NULL,
|
||||
`add1` varchar(50) DEFAULT NULL,
|
||||
`add2` varchar(50) DEFAULT NULL,
|
||||
`city` varchar(50) DEFAULT NULL,
|
||||
`state` varchar(2) DEFAULT NULL,
|
||||
`zip` int(5) DEFAULT NULL,
|
||||
`zip_last_4` int(4) DEFAULT NULL,
|
||||
`email` varchar(50) DEFAULT NULL,
|
||||
`phone` varchar(20) DEFAULT NULL,
|
||||
`fax` varchar(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`customer_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.customer: ~0 rows (approximately)
|
||||
/*!40000 ALTER TABLE `customer` DISABLE KEYS */;
|
||||
INSERT INTO `customer` (`customer_id`, `customer_name`, `bill_to_dept`, `add1`, `add2`, `city`, `state`, `zip`, `zip_last_4`, `email`, `phone`, `fax`) VALUES
|
||||
('VDOT', 'Virginia Depart of Transportation', 'Billing Department', '13134 Saturn Drive', 'Unit 100', 'McLean', 'VA', 22043, 0, 'Billing@vdot.gov', '(703) 122-1234', '(703) 122-1212');
|
||||
/*!40000 ALTER TABLE `customer` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for function astute.delete_invoice
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` FUNCTION `delete_invoice`(inv_no_in varchar(20)) RETURNS varchar(40) CHARSET utf8
|
||||
BEGIN
|
||||
|
||||
DECLARE inv_status_in int;
|
||||
|
||||
SELECT inv_status
|
||||
INTO inv_status_in
|
||||
FROM invoice
|
||||
WHERE inv_no = inv_no_in;
|
||||
|
||||
IF inv_status_in <> 1 THEN
|
||||
RETURN 'ERROR - ONLY DRAFT INVOICE CAN BE DELETED';
|
||||
END IF;
|
||||
|
||||
UPDATE INVOICE_DETAIL SET QTY = 0 WHERE inv_num = inv_no_in;
|
||||
CALL update_all_remaining_quantities(inv_no_in);
|
||||
DELETE FROM INVOICE WHERE inv_no = inv_no_in;
|
||||
|
||||
RETURN 'SUCCESS';
|
||||
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for function astute.duplicate_invoice
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` FUNCTION `duplicate_invoice`(inv_no_in varchar(20)) RETURNS varchar(20) CHARSET utf8
|
||||
BEGIN
|
||||
DECLARE generated_inv_number varchar(20);
|
||||
DECLARE po_num_in varchar(20);
|
||||
|
||||
SELECT po_num
|
||||
INTO po_num_in
|
||||
FROM invoice
|
||||
WHERE inv_no = inv_no_in;
|
||||
|
||||
SELECT generate_inv_number(po_num_in)
|
||||
INTO generated_inv_number;
|
||||
|
||||
INSERT INTO invoice
|
||||
(inv_no,inv_date,PO_num,change_order_num,bill_amt,special_notes,certification,inv_status,pmt_status)
|
||||
(SELECT generated_inv_number, CURDATE(), PO_num, change_order_num, bill_amt, special_notes, certification, inv_status, pmt_status
|
||||
FROM invoice
|
||||
WHERE inv_no = inv_no_in);
|
||||
|
||||
INSERT INTO invoice_detail
|
||||
(inv_num,line_item_num,PO_line_item_num,service_type_id,description,qty,fee,fee_type_id)
|
||||
(SELECT generated_inv_number, line_item_num, PO_line_item_num, service_type_id, description, 0, fee, fee_type_id
|
||||
FROM invoice_detail
|
||||
WHERE inv_num = inv_no_in);
|
||||
|
||||
return generated_inv_number;
|
||||
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for table astute.fee_type
|
||||
CREATE TABLE IF NOT EXISTS `fee_type` (
|
||||
`fee_type_id` int(11) NOT NULL,
|
||||
`fee_type_desc` varchar(40) NOT NULL,
|
||||
PRIMARY KEY (`fee_type_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.fee_type: ~2 rows (approximately)
|
||||
/*!40000 ALTER TABLE `fee_type` DISABLE KEYS */;
|
||||
INSERT INTO `fee_type` (`fee_type_id`, `fee_type_desc`) VALUES
|
||||
(1, 'Fixed fee'),
|
||||
(2, 'Hourly');
|
||||
/*!40000 ALTER TABLE `fee_type` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for function astute.generate_final_inv_number
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` FUNCTION `generate_final_inv_number`(po_num_in varchar(20)) RETURNS varchar(40) CHARSET utf8
|
||||
BEGIN
|
||||
DECLARE customer_id_in int;
|
||||
DECLARE customer_code varchar(4);
|
||||
DECLARE po_count int;
|
||||
DECLARE inv_count int;
|
||||
DECLARE inv_number varchar(40);
|
||||
|
||||
SELECT customer_id
|
||||
INTO customer_id_in
|
||||
FROM po
|
||||
WHERE po.po_num = po_num_in;
|
||||
|
||||
SELECT substr(customer.customer_id, 1, 3)
|
||||
INTO customer_code
|
||||
FROM customer
|
||||
WHERE customer_id = customer_id_in;
|
||||
|
||||
SELECT po_id
|
||||
INTO po_count
|
||||
FROM po
|
||||
WHERE PO_num = po_num_in;
|
||||
|
||||
SELECT inv_seq+1
|
||||
INTO inv_count
|
||||
FROM po
|
||||
WHERE po.PO_num = po_num_in;
|
||||
|
||||
SELECT concat(customer_code, '-',LPAD(po_count, 2, '0'), '_', date_format(now(),'%m%d'),'_',inv_count) INTO inv_number;
|
||||
RETURN inv_number;
|
||||
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for function astute.generate_inv_number
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` FUNCTION `generate_inv_number`(po_num_in varchar(20)) RETURNS varchar(40) CHARSET utf8
|
||||
BEGIN
|
||||
DECLARE customer_id_in varchar(20);
|
||||
DECLARE customer_code varchar(4);
|
||||
DECLARE po_count int;
|
||||
DECLARE inv_count int;
|
||||
DECLARE inv_number varchar(40);
|
||||
|
||||
SELECT customer_id
|
||||
INTO customer_id_in
|
||||
FROM po
|
||||
WHERE po.po_num = po_num_in;
|
||||
|
||||
SELECT substr(customer.customer_id, 1, 3)
|
||||
INTO customer_code
|
||||
FROM customer
|
||||
WHERE customer_id = customer_id_in;
|
||||
|
||||
SELECT po_id
|
||||
INTO po_count
|
||||
FROM po
|
||||
WHERE PO_num = po_num_in;
|
||||
|
||||
SELECT inv_seq + 1
|
||||
INTO inv_count
|
||||
FROM PO
|
||||
WHERE PO.PO_num = po_num_in;
|
||||
|
||||
SELECT concat(customer_code, '-',LPAD(po_count, 2, '0'), '_DRAFT_',FLOOR(RAND()*(999))) INTO inv_number;
|
||||
RETURN inv_number;
|
||||
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for function astute.get_payment_type
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` FUNCTION `get_payment_type`(pmt_type int) RETURNS varchar(20) CHARSET utf8
|
||||
BEGIN
|
||||
declare payment_type VARCHAR(20);
|
||||
SELECT payment_type_name INTO payment_type FROM payment_type WHERE payment_type_id = pmt_type;
|
||||
return payment_type;
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for function astute.get_previously_billed_amt
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` FUNCTION `get_previously_billed_amt`(po_no varchar(20)) RETURNS double(10,2)
|
||||
BEGIN
|
||||
declare billed_amt double(10,2);
|
||||
SELECT sum(bill_amt) INTO billed_amt FROM invoice WHERE invoice.PO_num = po_no;
|
||||
return billed_amt;
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for table astute.invoice
|
||||
CREATE TABLE IF NOT EXISTS `invoice` (
|
||||
`inv_no` varchar(20) NOT NULL,
|
||||
`inv_date` date NOT NULL,
|
||||
`PO_num` varchar(40) NOT NULL,
|
||||
`bill_amt` double NOT NULL,
|
||||
`special_notes` varchar(500) DEFAULT NULL,
|
||||
`certification` varchar(500) DEFAULT 'Certified that the above items and rates are in accordance with the contractual agreement as verified by the undersigned.',
|
||||
`inv_status` int(2) DEFAULT '1',
|
||||
`pmt_status` int(11) NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (`inv_no`),
|
||||
KEY `fk_InvMaster_POnum` (`PO_num`),
|
||||
CONSTRAINT `fk_InvMaster_POnum` FOREIGN KEY (`PO_num`) REFERENCES `po` (`PO_num`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.invoice: ~2 rows (approximately)
|
||||
/*!40000 ALTER TABLE `invoice` DISABLE KEYS */;
|
||||
INSERT INTO `invoice` (`inv_no`, `inv_date`, `PO_num`, `bill_amt`, `special_notes`, `certification`, `inv_status`, `pmt_status`) VALUES
|
||||
('VDO-01_0927_1', '2018-09-23', 'VDOT-54321', 5000, 'First invoice', 'Certified that the above items and rates are in accordance with the contractual agreement as verified by the undersigned', 2, 0),
|
||||
('VDO-02_DRAFT_392', '2018-09-23', 'ABC-123', 500, 'First Invoice', 'Certified that the above items and rates are in accordance with the contractual agreement as verified by the undersigned', 1, 0);
|
||||
/*!40000 ALTER TABLE `invoice` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for table astute.invoice_detail
|
||||
CREATE TABLE IF NOT EXISTS `invoice_detail` (
|
||||
`inv_num` varchar(20) NOT NULL,
|
||||
`line_item_num` int(11) NOT NULL,
|
||||
`PO_line_item_num` int(11) DEFAULT NULL,
|
||||
`service_type_id` int(11) DEFAULT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
`qty` double DEFAULT NULL,
|
||||
`fee` double DEFAULT NULL,
|
||||
`fee_type_id` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`inv_num`,`line_item_num`),
|
||||
KEY `fk_InvDetail_FeeType` (`fee_type_id`),
|
||||
CONSTRAINT `fk_InvDetail_FeeType` FOREIGN KEY (`fee_type_id`) REFERENCES `fee_type` (`fee_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_InvDetail_InvNum` FOREIGN KEY (`inv_num`) REFERENCES `invoice` (`inv_no`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.invoice_detail: ~4 rows (approximately)
|
||||
/*!40000 ALTER TABLE `invoice_detail` DISABLE KEYS */;
|
||||
INSERT INTO `invoice_detail` (`inv_num`, `line_item_num`, `PO_line_item_num`, `service_type_id`, `description`, `qty`, `fee`, `fee_type_id`) VALUES
|
||||
('VDO-01_0927_1', 1, 1, 1, 'Study existing designs', 0, 1000, 1),
|
||||
('VDO-01_0927_1', 2, 4, 3, 'Peer Review', 50, 100, 2),
|
||||
('VDO-02_DRAFT_392', 1, 1, 2, 'Design', 0, 5000, 1),
|
||||
('VDO-02_DRAFT_392', 2, -1, 1, 'Out of Pocket Expenses', 50, 10, 1);
|
||||
/*!40000 ALTER TABLE `invoice_detail` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for table astute.invoice_notes
|
||||
CREATE TABLE IF NOT EXISTS `invoice_notes` (
|
||||
`inv_no` varchar(20) NOT NULL,
|
||||
`inv_note` varchar(500) NOT NULL,
|
||||
PRIMARY KEY (`inv_no`),
|
||||
CONSTRAINT `fk_inv_notes_inv_no` FOREIGN KEY (`inv_no`) REFERENCES `invoice` (`inv_no`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.invoice_notes: ~0 rows (approximately)
|
||||
/*!40000 ALTER TABLE `invoice_notes` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `invoice_notes` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for table astute.invoice_payment
|
||||
CREATE TABLE IF NOT EXISTS `invoice_payment` (
|
||||
`inv_no` varchar(20) NOT NULL,
|
||||
`invoice_payment_type` int(11) NOT NULL,
|
||||
`invoice_amount` double NOT NULL,
|
||||
`payment_date` date NOT NULL,
|
||||
`invoice_payment_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`description` varchar(50) DEFAULT NULL,
|
||||
PRIMARY KEY (`invoice_payment_id`),
|
||||
KEY `fk_inv_pmt_inv_no` (`inv_no`),
|
||||
KEY `fk_pinv_pmt_type` (`invoice_payment_type`),
|
||||
CONSTRAINT `fk_inv_pmt_inv_no` FOREIGN KEY (`inv_no`) REFERENCES `invoice` (`inv_no`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_pinv_pmt_type` FOREIGN KEY (`invoice_payment_type`) REFERENCES `payment_type` (`payment_type_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.invoice_payment: ~6 rows (approximately)
|
||||
/*!40000 ALTER TABLE `invoice_payment` DISABLE KEYS */;
|
||||
INSERT INTO `invoice_payment` (`inv_no`, `invoice_payment_type`, `invoice_amount`, `payment_date`, `invoice_payment_id`, `description`) VALUES
|
||||
('VDO-01_0927_1', 2, 900, '2018-09-29', 1, 'VDO-01_0927_1 FIrst Payment'),
|
||||
('VDO-01_0927_1', 2, 980, '2018-09-27', 2, NULL),
|
||||
('VDO-01_0927_1', 2, 1000, '2018-09-27', 3, NULL),
|
||||
('VDO-01_0927_1', 2, 1000, '2018-09-27', 4, NULL),
|
||||
('VDO-01_0927_1', 2, 1000, '2018-09-27', 5, NULL),
|
||||
('VDO-01_0927_1', 2, 200, '2018-09-28', 12, NULL);
|
||||
/*!40000 ALTER TABLE `invoice_payment` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for table astute.invoice_status
|
||||
CREATE TABLE IF NOT EXISTS `invoice_status` (
|
||||
`inv_status_id` int(11) NOT NULL,
|
||||
`inv_status_desc` varchar(20) NOT NULL,
|
||||
PRIMARY KEY (`inv_status_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.invoice_status: ~3 rows (approximately)
|
||||
/*!40000 ALTER TABLE `invoice_status` DISABLE KEYS */;
|
||||
INSERT INTO `invoice_status` (`inv_status_id`, `inv_status_desc`) VALUES
|
||||
(1, 'Draft'),
|
||||
(2, 'Submitted'),
|
||||
(3, 'Void');
|
||||
/*!40000 ALTER TABLE `invoice_status` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for table astute.payment_status
|
||||
CREATE TABLE IF NOT EXISTS `payment_status` (
|
||||
`payment_status_id` int(11) NOT NULL,
|
||||
`payment_status_desc` varchar(20) NOT NULL,
|
||||
PRIMARY KEY (`payment_status_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.payment_status: ~3 rows (approximately)
|
||||
/*!40000 ALTER TABLE `payment_status` DISABLE KEYS */;
|
||||
INSERT INTO `payment_status` (`payment_status_id`, `payment_status_desc`) VALUES
|
||||
(1, 'Outstanding'),
|
||||
(2, 'Partially paid'),
|
||||
(3, 'Paid');
|
||||
/*!40000 ALTER TABLE `payment_status` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for table astute.payment_type
|
||||
CREATE TABLE IF NOT EXISTS `payment_type` (
|
||||
`payment_type_id` int(11) NOT NULL,
|
||||
`payment_type_name` varchar(20) NOT NULL,
|
||||
PRIMARY KEY (`payment_type_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.payment_type: ~3 rows (approximately)
|
||||
/*!40000 ALTER TABLE `payment_type` DISABLE KEYS */;
|
||||
INSERT INTO `payment_type` (`payment_type_id`, `payment_type_name`) VALUES
|
||||
(1, 'Credit Card'),
|
||||
(2, 'Check'),
|
||||
(3, 'ACH');
|
||||
/*!40000 ALTER TABLE `payment_type` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for table astute.po
|
||||
CREATE TABLE IF NOT EXISTS `po` (
|
||||
`PO_num` varchar(40) NOT NULL COMMENT 'Alpha numeric, auto generated in frontend',
|
||||
`contract_num` varchar(20) DEFAULT NULL,
|
||||
`PO_date` date DEFAULT NULL,
|
||||
`contract_amt` double(10,2) DEFAULT NULL,
|
||||
`customer_id` varchar(11) NOT NULL,
|
||||
`astute_project_num` varchar(20) NOT NULL,
|
||||
`po_id` int(11) NOT NULL,
|
||||
`title` varchar(200) DEFAULT NULL,
|
||||
`inv_seq` int(3) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`PO_num`),
|
||||
KEY `ind_pomaster_contractno` (`contract_num`),
|
||||
KEY `ind_pomaster_podate` (`PO_date`),
|
||||
KEY `po_customer_id` (`customer_id`),
|
||||
CONSTRAINT `po_customer_id_fk` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.po: ~2 rows (approximately)
|
||||
/*!40000 ALTER TABLE `po` DISABLE KEYS */;
|
||||
INSERT INTO `po` (`PO_num`, `contract_num`, `PO_date`, `contract_amt`, `customer_id`, `astute_project_num`, `po_id`, `title`, `inv_seq`) VALUES
|
||||
('ABC-123', 'ABC-123', '2018-09-23', 5000.00, 'VDOT', 'ABC-123', 2, 'ABC-123', 0),
|
||||
('VDOT-54321', 'VDOT-54321', '2018-09-22', 10000.00, 'VDOT', 'VDOTProj', 1, 'Supervisor', 1);
|
||||
/*!40000 ALTER TABLE `po` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for table astute.po_detail
|
||||
CREATE TABLE IF NOT EXISTS `po_detail` (
|
||||
`PO_num` varchar(40) NOT NULL,
|
||||
`line_item_no` int(11) NOT NULL,
|
||||
`service_desc` varchar(500) DEFAULT NULL,
|
||||
`fee_type_id` int(11) DEFAULT '1' COMMENT '1-fixed fee, 2-hourly',
|
||||
`qty` double DEFAULT NULL,
|
||||
`service_type_id` int(1) DEFAULT '1' COMMENT '1-studies, 2-supplemental service, 3-out of pocket, 4-reimbursement, 5-',
|
||||
`fee` double DEFAULT NULL,
|
||||
`remaining_qty` double DEFAULT NULL,
|
||||
PRIMARY KEY (`PO_num`,`line_item_no`),
|
||||
KEY `fk_PODetail_ServType` (`service_type_id`),
|
||||
CONSTRAINT `fk_PODetail_POnum` FOREIGN KEY (`PO_num`) REFERENCES `po` (`PO_num`),
|
||||
CONSTRAINT `fk_PODetail_ServType` FOREIGN KEY (`service_type_id`) REFERENCES `service_type` (`service_type_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.po_detail: ~5 rows (approximately)
|
||||
/*!40000 ALTER TABLE `po_detail` DISABLE KEYS */;
|
||||
INSERT INTO `po_detail` (`PO_num`, `line_item_no`, `service_desc`, `fee_type_id`, `qty`, `service_type_id`, `fee`, `remaining_qty`) VALUES
|
||||
('ABC-123', 1, 'Design', 1, 1, 2, 5000, 1),
|
||||
('VDOT-54321', 1, 'Study existing designs', 1, 1, 1, 1000, 1),
|
||||
('VDOT-54321', 2, 'Modify design', 1, 1, 2, 2000, 1),
|
||||
('VDOT-54321', 3, 'Cost estimation', 1, 1, 4, 1000, 1),
|
||||
('VDOT-54321', 4, 'Peer Review', 2, 100, 3, 100, 50);
|
||||
/*!40000 ALTER TABLE `po_detail` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for table astute.service_type
|
||||
CREATE TABLE IF NOT EXISTS `service_type` (
|
||||
`service_type_id` int(11) NOT NULL,
|
||||
`desc` varchar(40) NOT NULL,
|
||||
PRIMARY KEY (`service_type_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.service_type: ~5 rows (approximately)
|
||||
/*!40000 ALTER TABLE `service_type` DISABLE KEYS */;
|
||||
INSERT INTO `service_type` (`service_type_id`, `desc`) VALUES
|
||||
(1, 'Study'),
|
||||
(2, 'Design'),
|
||||
(3, 'Peer Review'),
|
||||
(4, 'Cost Estimation'),
|
||||
(5, 'Forensic Investigation'),
|
||||
(6, 'Out-of-pocket Expense');
|
||||
/*!40000 ALTER TABLE `service_type` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for table astute.session
|
||||
CREATE TABLE IF NOT EXISTS `session` (
|
||||
`session_id` varchar(200) NOT NULL,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`session_start_date` date DEFAULT NULL,
|
||||
`session_end_date` date DEFAULT NULL,
|
||||
PRIMARY KEY (`session_id`),
|
||||
KEY `fk_session_user_id` (`user_id`),
|
||||
CONSTRAINT `fk_session_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.session: ~10 rows (approximately)
|
||||
/*!40000 ALTER TABLE `session` DISABLE KEYS */;
|
||||
INSERT INTO `session` (`session_id`, `user_id`, `session_start_date`, `session_end_date`) VALUES
|
||||
('058cdb87447645da9ec265e566af834c', 1, NULL, NULL),
|
||||
('4f48b60481ab4729a26b809c077fc7c0', 1, NULL, NULL),
|
||||
('66ed2bccbaf34b1e96b2b81393996cf9', 1, NULL, NULL),
|
||||
('8f8991185a174b87adb7d0b1b40c1475', 1, NULL, NULL),
|
||||
('92cd1d01085c4ead892a1c7c137631dd', 1, NULL, NULL),
|
||||
('abeefc05fe8e48e5bac7ffab65c85ca6', 1, NULL, NULL),
|
||||
('b356aab1dbe84d4f9eea9c1cd965c9a4', 1, NULL, NULL),
|
||||
('d6387d93d84341fc91a0c4a5cbf266db', 1, NULL, NULL),
|
||||
('dcb4b261f925464bb69ff685c1c6134d', 1, NULL, NULL),
|
||||
('fea623a6ff3148899214750707f4f52e', 1, NULL, NULL);
|
||||
/*!40000 ALTER TABLE `session` ENABLE KEYS */;
|
||||
|
||||
-- Dumping structure for procedure astute.submit_invoice
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `submit_invoice`(invNo varchar(20))
|
||||
BEGIN
|
||||
DECLARE po_no varchar(20);
|
||||
UPDATE INVOICE SET INV_STATUS = 2 WHERE INV_NO = invNo;
|
||||
SELECT PO_NUM INTO po_no FROM INVOICE WHERE INV_NO = invNo;
|
||||
UPDATE INVOICE SET INV_NO = generate_final_inv_number(po_no), INV_STATUS = 2 WHERE INV_NO = invNo;
|
||||
UPDATE PO SET INV_SEQ = INV_SEQ + 1 WHERE PO_NUM = po_no;
|
||||
Commit;
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for procedure astute.update_all_remaining_quantities
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `update_all_remaining_quantities`(invNo varchar(20))
|
||||
BEGIN
|
||||
|
||||
DECLARE po_line_item_no int;
|
||||
DECLARE remaining_qty double;
|
||||
DECLARE finished INTEGER DEFAULT 0;
|
||||
DECLARE p_finished INTEGER DEFAULT 0;
|
||||
DECLARE done boolean DEFAULT FALSE;
|
||||
|
||||
DECLARE po_line_items CURSOR FOR select distinct po_line_item_num from invoice_detail where inv_num = invNo;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET p_finished = 1;
|
||||
OPEN po_line_items;
|
||||
po_loop: LOOP
|
||||
FETCH po_line_items INTO po_line_item_no;
|
||||
IF p_finished = 1 THEN
|
||||
LEAVE po_loop;
|
||||
END IF;
|
||||
BEGIN
|
||||
SET remaining_qty = update_remaining_qty_fun('',invNo,po_line_item_no);
|
||||
END;
|
||||
END LOOP po_loop;
|
||||
CLOSE po_line_items;
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for function astute.update_remaining_qty_fun
|
||||
DELIMITER //
|
||||
CREATE DEFINER=`root`@`localhost` FUNCTION `update_remaining_qty_fun`(po_no_in varchar(40), inv_num_in varchar(40), item_no_in int) RETURNS double
|
||||
BEGIN
|
||||
DECLARE rem_qty double;
|
||||
DECLARE po_no varchar(40);
|
||||
if inv_num_in <> null or inv_num_in <> '' THEN
|
||||
SELECT po_num INTO po_no FROM invoice where inv_no = inv_num_in;
|
||||
else
|
||||
set po_no = po_no_in;
|
||||
end if;
|
||||
|
||||
select po_detail.qty - ifnull(sum(invoice_detail.qty),0) into rem_qty from invoice_detail, invoice, po_detail
|
||||
where invoice_detail.inv_num in (select inv_no from invoice where invoice.PO_num = po_no)
|
||||
and invoice_detail.po_line_item_num = item_no_in
|
||||
and po_detail.PO_num = po_no
|
||||
and invoice.PO_num = po_detail.PO_num
|
||||
and invoice.inv_no = invoice_detail.inv_num
|
||||
and invoice.inv_status <> 3
|
||||
and invoice_detail.po_line_item_num = po_detail.line_item_no;
|
||||
|
||||
update po_detail set remaining_qty = rem_qty where PO_num = po_no and line_item_no = item_no_in;
|
||||
return rem_qty;
|
||||
END//
|
||||
DELIMITER ;
|
||||
|
||||
-- Dumping structure for table astute.user
|
||||
CREATE TABLE IF NOT EXISTS `user` (
|
||||
`user_id` int(5) NOT NULL,
|
||||
`username` varchar(20) DEFAULT NULL,
|
||||
`password` varchar(20) DEFAULT NULL,
|
||||
`first_name` varchar(20) DEFAULT NULL,
|
||||
`middle_name` varchar(20) DEFAULT NULL,
|
||||
`last_name` varchar(20) DEFAULT NULL,
|
||||
`role` varchar(20) DEFAULT NULL,
|
||||
`email` varchar(40) DEFAULT NULL,
|
||||
`office_phone_ext` int(3) DEFAULT NULL,
|
||||
`cell_phone` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Dumping data for table astute.user: ~2 rows (approximately)
|
||||
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
|
||||
INSERT INTO `user` (`user_id`, `username`, `password`, `first_name`, `middle_name`, `last_name`, `role`, `email`, `office_phone_ext`, `cell_phone`) VALUES
|
||||
(1, 'sparikh', 'sparikh', 'Saurin', NULL, 'Parikh', 'Owner', 'sparikh@Astuteng.com', 2024002004, 3014616485),
|
||||
(2, 'humarethiya', 'humarethiya', 'Haresh', NULL, 'Umaretiya', 'Owner', 'Humaretiya@astuteng.com', 2024002004, 0);
|
||||
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
|
||||
|
||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
|
@ -60,7 +60,7 @@ public abstract class DAO {
|
|||
host = "localhost";
|
||||
port = 3306;
|
||||
schema = "astute";
|
||||
username = "root";
|
||||
username = "astute_user";
|
||||
password = "password";
|
||||
System.out.println("=============================================");
|
||||
System.out.println("host is " + host);
|
||||
|
@ -101,6 +101,10 @@ public abstract class DAO {
|
|||
|
||||
public abstract void createPODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId, Double remainingQuantity) throws AstuteException;
|
||||
|
||||
public abstract void finalizePO(String PONum) throws AstuteException;
|
||||
|
||||
public abstract void deletePO(String PONum) throws AstuteException;
|
||||
|
||||
public abstract List<ServiceType> getServiceTypes() throws AstuteException;
|
||||
|
||||
public abstract void createServiceType(String desc) throws AstuteException;
|
||||
|
|
|
@ -248,6 +248,30 @@ 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 + "''";
|
||||
System.out.println(sql);
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.executeUpdate(sql);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
throw new AstuteException(DB_ERROR,e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void deletePO(String PONum) throws AstuteException {
|
||||
try {
|
||||
String sql = "DELETE FROM PO_MASTER SET final = 1 WHERE PO_Num = '" + PONum + "'' AND final = 0";
|
||||
System.out.println(sql);
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.executeUpdate(sql);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
throw new AstuteException(DB_ERROR,e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public List<ServiceType> getServiceTypes() throws AstuteException {
|
||||
try {
|
||||
List<ServiceType> serviceTypes = new ArrayList<ServiceType>();
|
||||
|
|
|
@ -74,6 +74,22 @@ public class POResource {
|
|||
return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse();
|
||||
}
|
||||
|
||||
// Finalize
|
||||
@Path("/{PONum}/finalize")
|
||||
@POST
|
||||
public Response finalizePO(@PathParam("PONum") String PONum) throws AstuteException {
|
||||
POService.finalizePO(PONum);
|
||||
return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse();
|
||||
}
|
||||
|
||||
// delete
|
||||
@Path("/{PONum}/delete")
|
||||
@POST
|
||||
public Response deletePO(@PathParam("PONum") String PONum) throws AstuteException {
|
||||
POService.deletePO(PONum);
|
||||
return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse();
|
||||
}
|
||||
|
||||
// Misc
|
||||
@Path("/serviceTypes")
|
||||
@GET
|
||||
|
|
|
@ -50,6 +50,14 @@ public class POService extends Service{
|
|||
getDao().createPODetail(POnum, lineItemNo, serviceDesc, feeTypeId, qty, fee, serviceTypeId, remainingQuantity);
|
||||
}
|
||||
|
||||
public void finalizePO(String PONum) throws AstuteException {
|
||||
getDao().finalizePO(PONum);
|
||||
}
|
||||
|
||||
public void deletePO(String PONum) throws AstuteException {
|
||||
getDao().finalizePO(PONum);
|
||||
}
|
||||
|
||||
public List<ServiceType> getServiceTypes() throws AstuteException {
|
||||
return getDao().getServiceTypes();
|
||||
}
|
||||
|
|
6
AstuteSystem/src/main/resources/db.config
Normal file
6
AstuteSystem/src/main/resources/db.config
Normal file
|
@ -0,0 +1,6 @@
|
|||
database=sql
|
||||
host=localhost
|
||||
port=3306
|
||||
username=root
|
||||
password=password
|
||||
schema=astute
|
Loading…
Reference in New Issue
Block a user