Added draft Remaining Qty

This commit is contained in:
Gopi Katwala 2019-07-16 22:46:04 -04:00
parent 3d38651747
commit 12748b8035
3 changed files with 34 additions and 3 deletions

View File

@ -755,6 +755,20 @@ DECLARE CONTINUE HANDLER FOR NOT FOUND SET p_finished = 1;
END//
DELIMITER ;
CREATE FUNCTION astute.`get_draft_remaining_qty_fun`(inv_num_in varchar(40), item_no_in int) RETURNS double
BEGIN
DECLARE draft_qty double;
DECLARE ponum varchar(20);
DECLARE submitted_qty double;
DECLARE po_item_no_in int;
SELECT po_line_item_num into po_item_no_in from invoice_detail where inv_num = inv_num_in and line_item_num = item_no_in;
SELECT po_num into ponum from invoice where inv_no = inv_num_in;
SELECT sum(qty) into draft_qty from invoice_detail where inv_num = inv_num_in and po_line_item_num = po_item_no_in;
SELECT remaining_qty into submitted_qty from po_detail where PO_num = ponum and line_item_no = po_item_no_in;
return submitted_qty-draft_qty;
END;
-- 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

View File

@ -485,7 +485,13 @@ public class SqlDAO extends DAO {
PO po = getPOMaster(PONo, null, null, null).get(0);
String customerId = po.getCustomerId();
Customer customer = getCustomers(customerId).get(0);
Double previouslyBilledAmt = getPreviouslyBilledAmount(PONo);
if (invoice.getInvoiceStatus()==2) {
// TODO substract current invoice's bill amount from previouslyBilledAmt
// if it is a submitted invoice
}
Double toBeBilledAmt = po.getContractAmt() - previouslyBilledAmt - invoice.getBillAmt();
generatedInvoice = new GeneratedInvoice(invoice, invoiceDetail, po, customer, previouslyBilledAmt, toBeBilledAmt );
return generatedInvoice;
@ -541,7 +547,7 @@ public class SqlDAO extends DAO {
try {
List<InvoiceDetail> services = new ArrayList<>();
Statement stmt = conn.createStatement();
String sql = "SELECT inv_num, line_item_num, PO_line_item_num, service_type_id, description, fee_type_id, fee, qty FROM INVOICE_DETAIL ";
String sql = "SELECT inv_num, line_item_num, PO_line_item_num, service_type_id, description, fee_type_id, fee, qty, get_draft_remaining_qty_fun('"+invoiceNum+"',"+ lineItemNo + ") as draftRemainingQty FROM INVOICE_DETAIL ";
String whereClause = " WHERE ";
boolean whereClauseIndicator = false;
@ -567,7 +573,8 @@ public class SqlDAO extends DAO {
int feeTypeId = rs.getInt(6);
Double fee = rs.getDouble(7);
Double qty = rs.getDouble(8);
InvoiceDetail service = new InvoiceDetail(invNo, lineItemNum, POLineItemNum, serviceTypeId, desc, qty, fee, feeTypeId);
Double draftRemainingQty = rs.getDouble(9);
InvoiceDetail service = new InvoiceDetail(invNo, lineItemNum, POLineItemNum, serviceTypeId, desc, qty, fee, feeTypeId,draftRemainingQty);
services.add(service);
}
return services;

View File

@ -9,8 +9,9 @@ public class InvoiceDetail {
double qty;
double fee;
int feeTypeId;
double draftRemainingQty;
public InvoiceDetail(String invoiceNum, int lineItemNum, int poLineItemNum, int serviceTypeId, String desc, double qty, double fee, int feeTypeId) {
public InvoiceDetail(String invoiceNum, int lineItemNum, int poLineItemNum, int serviceTypeId, String desc, double qty, double fee, int feeTypeId, double draftRemainingQty) {
this.invoiceNum = invoiceNum;
this.lineItemNum = lineItemNum;
this.poLineItemNum = poLineItemNum;
@ -19,6 +20,7 @@ public class InvoiceDetail {
this.qty = qty;
this.fee = fee;
this.feeTypeId = feeTypeId;
this.draftRemainingQty = draftRemainingQty;
}
public String getInvoiceNum() {
@ -84,4 +86,12 @@ public class InvoiceDetail {
public void setFeeTypeId(int feeTypeId) {
this.feeTypeId = feeTypeId;
}
public double getDraftRemainingQty() {
return draftRemainingQty;
}
public void setDraftRemainingQty(double draftRemainingQty) {
this.draftRemainingQty = draftRemainingQty;
}
}