1 32 33 package com.knowgate.hipergate; 34 35 import java.math.BigDecimal ; 36 37 import java.sql.Types ; 38 import java.sql.PreparedStatement ; 39 import java.sql.SQLException ; 40 41 import com.knowgate.jdc.JDCConnection; 42 import com.knowgate.dataobjs.DBPersist; 43 import com.knowgate.dataobjs.DB; 44 import com.knowgate.dataobjs.DBBind; 45 46 51 53 public class InvoiceLine extends DBPersist { 54 public InvoiceLine() { 55 super(DB.k_invoice_lines, "InvoiceLine"); 56 } 57 58 60 67 public boolean store (JDCConnection oConn) throws SQLException { 68 PreparedStatement oStmt = oConn.prepareStatement("UPDATE "+DB.k_invoices+" SET "+DB.dt_modified+"="+DBBind.Functions.GETDATE+" WHERE "+DB.gu_invoice+"=?"); 69 oStmt.setObject(1, get(DB.gu_invoice), Types.CHAR); 70 oStmt.executeUpdate(); 71 oStmt.close(); 72 return super.store(oConn); 73 } 74 75 77 82 public BigDecimal computeTotal () { 83 BigDecimal dTotal, dQuantity, dTax, dHundred = new BigDecimal (100), dOne = new BigDecimal (1); 84 boolean bTaxIncluded = false; 85 86 if (isNull(DB.pr_sale)) return null; 87 88 if (isNull(DB.nu_quantity)) 89 dQuantity = new BigDecimal (1); 90 else 91 dQuantity = new BigDecimal (getFloat(DB.nu_quantity)); 92 93 if (isNull(DB.pct_tax_rate)) 94 dTotal = getDecimal(DB.pr_sale).multiply(dQuantity); 95 else { 96 dTotal = getDecimal(DB.pr_sale).multiply(dQuantity); 97 if (!isNull(DB.is_tax_included)) 98 bTaxIncluded = (getShort(DB.is_tax_included)==(short)1); 99 if (!bTaxIncluded) { 100 if (getFloat(DB.pct_tax_rate)>1f) 101 dTax = new BigDecimal (getFloat(DB.pct_tax_rate)/100f); 102 else 103 dTax = new BigDecimal (getFloat(DB.pct_tax_rate)); 104 dTotal = dTotal.add(dTotal.multiply(dTax)); 105 } 106 } 107 replace(DB.pr_total, dTotal); 108 return dTotal; 109 } } 111 | Popular Tags |