package realcix20.classes;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.Vector;
import realcix20.classes.basic.BaseClass;
import realcix20.classes.basic.Cell;
import realcix20.classes.basic.ClassManager;
import realcix20.classes.basic.Row;
import realcix20.classes.plugins.RAndRi;
import realcix20.guis.utils.TimeManager;
import realcix20.guis.utils.TxtManager;
import realcix20.utils.DAO;
import realcix20.utils.GlobalValueManager;
import realcix20.utils.ObjectUtil;
import realcix20.utils.Resources;
public class TaxClass extends BaseClass {
public TaxClass(int clsId) {
super(clsId);
}
public static void deleteRelativeRegs(Row taxRow) {
TaxClass tax = (TaxClass)ClassManager.createClass(530);
tax.loadChilds(taxRow);
Iterator cItemRowsIter = taxRow.getRowSet().getRows().iterator();
while (cItemRowsIter.hasNext()) {
Row cItemRow = (Row)cItemRowsIter.next();
boolean needDelete = true;
if ( (ObjectUtil.findNewCell(cItemRow, "TAXI", "R").getColumnValue() == null) ||
(ObjectUtil.findNewCell(cItemRow, "TAXI", "RI").getColumnValue() == null) ) {
needDelete = false;
}
// if (needDelete) {
// int r = Integer.parseInt(ObjectUtil.findNewCell(cItemRow, "TAXI", "R").getColumnValue().toString());
// int ri = Integer.parseInt(ObjectUtil.findNewCell(cItemRow, "TAXI", "RI").getColumnValue().toString());
// RegClass.deleteRelativeThings(r, ri);
// DAO dao = DAO.getInstance();
// dao.update(Resources.DELETE_RI_BY_R_RI_SQL);
// dao.setInt(1, r);
// dao.setInt(2, ri);
// dao.executeUpdate();
// }
if (needDelete) {
int r = Integer.parseInt(ObjectUtil.findNewCell(cItemRow, "TAXI", "R").getColumnValue().toString());
// int ri = Integer.parseInt(ObjectUtil.findNewCell(cItemRow, "TAXI", "RI").getColumnValue().toString());
// RegClass.deleteRelativeThings(r, ri);
// DAO dao = DAO.getInstance();
// dao.update(Resources.DELETE_RI_BY_R_RI_SQL);
// dao.setInt(1, r);
// dao.setInt(2, ri);
// dao.executeUpdate();
RegClass.delete(r);
}
}
}
public static boolean isRegUsedInTax(Row regItemRow) {
boolean result = false;
if ( (ObjectUtil.findNewCell(regItemRow, "RI", "R").getColumnValue() == null) ||
(ObjectUtil.findNewCell(regItemRow, "RI", "RI").getColumnValue() == null) ) {
return false;
}
int r = Integer.parseInt(ObjectUtil.findNewCell(regItemRow, "RI", "R").getColumnValue().toString());
int ri = Integer.parseInt(ObjectUtil.findNewCell(regItemRow, "RI", "RI").getColumnValue().toString());
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_FROM_TAXI_BY_R_RI_SQL);
dao.setInt(1, r);
dao.setInt(2, ri);
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
result = true;
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static boolean isTaxtUsedInTax(Row taxTypeRow) {
boolean result = false;
String taxt = ObjectUtil.findNewCell(taxTypeRow, "TAXT", "TAXT").getColumnValue().toString();
TaxClass tax = (TaxClass)ClassManager.createClass(530);
DAO dao = DAO.getInstance();
dao.query(tax.getBasicSQL());
ResultSet rs = dao.executeQuery();
try {
ResultSetMetaData rsmd = rs.getMetaData();
int i;
for (i = 1; i <= rsmd.getColumnCount(); i++) {
if ( (rsmd.getTableName(i).equals("TAX")) && (rsmd.getColumnName(i).equals("TAXT")) )
break;
}
while (rs.next()) {
if (rs.getObject(i).equals(taxt)) {
result = true;
break;
}
}
rs.close();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
return result;
}
public static boolean isPReferenceInTax(Row pRow) {
boolean result = false;
String ns = ObjectUtil.findNewCell(pRow, "P", "NS").getColumnValue().toString();
String p = ObjectUtil.findNewCell(pRow, "P", "P").getColumnValue().toString();
TaxClass tax = (TaxClass)ClassManager.createClass(530);
Iterator taxRowsIter = tax.getRows().iterator();
while (taxRowsIter.hasNext()) {
Row taxRow = (Row)taxRowsIter.next();
String taxNS = ObjectUtil.findNewCell(taxRow, "TAX", "NS").getColumnValue().toString();
String taxP = ObjectUtil.findNewCell(taxRow, "TAX", "P").getColumnValue().toString();
if ( (ns.equals(taxNS)) && (p.equals(taxP)) ) {
result = true;
break;
}
}
return result;
}
public void clearRITAXI(String taxt, int tax) {
DAO dao = DAO.getInstance();
dao.update(Resources.CLEAR_RITAXI_BY_TAXT_TAX_SQL);
dao.setString(1, taxt);
dao.setInt(2, tax);
dao.executeUpdate();
}
public void addAllTaxedRegs(Vector taxs) {
boolean cleared = false;
Iterator taxsIter = taxs.iterator();
while (taxsIter.hasNext()) {
Vector taxData = (Vector)taxsIter.next();
Row taxRow = (Row)taxData.get(0);
if (!cleared) {
int tax = -1;
String taxt = ObjectUtil.findNewCell(taxRow, "TAX", "TAXT").getColumnValue().toString();
if ( (ObjectUtil.findNewCell(taxRow, "TAX", "TAX").getColumnValue() != null) && (ObjectUtil.findNewCell(taxRow, "TAX", "TAX").getColumnValue().toString().trim().length() > 0) ) {
tax = Integer.parseInt(ObjectUtil.findNewCell(taxRow, "TAX", "TAX").getColumnValue().toString());
}
clearRITAXI(taxt, tax);
cleared = true;
}
Vector positiveRowData = (Vector)taxData.get(3);
Vector nagativeRowData = (Vector)taxData.get(4);
Iterator positiveRowDataIter = positiveRowData.iterator();
while (positiveRowDataIter.hasNext()) {
Vector rowData = (Vector)positiveRowDataIter.next();
Row regRow = (Row)rowData.get(rowData.size() - 1);
updateRITAXI(taxRow, regRow, 1);
}
Iterator nagativeRowDataIter = nagativeRowData.iterator();
while (nagativeRowDataIter.hasNext()) {
Vector rowData = (Vector)nagativeRowDataIter.next();
Row regRow = (Row)rowData.get(rowData.size() - 1);
updateRITAXI(taxRow, regRow, -1);
}
}
}
public boolean calculatorTax(Row row) {
boolean result = true;
String formula = null;
double para1 = 0.0;
double para2 = 0.0;
double para3 = 0.0;
double para4 = 0.0;
double para5 = 0.0;
double para6 = 0.0;
double para7 = 0.0;
double para8 = 0.0;
double para9 = 0.0;
double para10 = 0.0;
double para11 = 0.0;
double para12 = 0.0;
double para13 = 0.0;
double para14 = 0.0;
double para15 = 0.0;
double para16 = 0.0;
double para17 = 0.0;
double para18 = 0.0;
double para19 = 0.0;
double para20 = 0.0;
double para21 = 0.0;
double para22 = 0.0;
double para23 = 0.0;
double para24 = 0.0;
double para25 = 0.0;
double para26 = 0.0;
double para27 = 0.0;
double para28 = 0.0;
double para29 = 0.0;
double para30 = 0.0;
double b1 = 0.0;
Cell cell = ObjectUtil.findNewCell(row, "TAXI", "TAXBASEAMT1");
b1 = getDouble(cell.getColumnValue());
double b2 = 0.0;
cell = ObjectUtil.findNewCell(row, "TAXI", "TAXBASEAMT2");
b2 = getDouble(cell.getColumnValue());
String taxt = null;
cell = ObjectUtil.findNewCell(row, "TAX", "TAXT");
taxt = (String)cell.getColumnValue();
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_FROM_TAXT_SQL);
dao.setObject(1, taxt);
try {
ResultSet rs = dao.executeQuery();
if (rs.next()) {
formula = rs.getString("FORMULA");
para1 = rs.getDouble("PARA1");
para2 = rs.getDouble("PARA2");
para3 = rs.getDouble("PARA3");
para4 = rs.getDouble("PARA4");
para5 = rs.getDouble("PARA5");
para6 = rs.getDouble("PARA6");
para7 = rs.getDouble("PARA7");
para8 = rs.getDouble("PARA8");
para9 = rs.getDouble("PARA9");
para10 = rs.getDouble("PARA10");
para11 = rs.getDouble("PARA11");
para12 = rs.getDouble("PARA12");
para13 = rs.getDouble("PARA13");
para14 = rs.getDouble("PARA14");
para15 = rs.getDouble("PARA15");
para16 = rs.getDouble("PARA16");
para17 = rs.getDouble("PARA17");
para18 = rs.getDouble("PARA18");
para19 = rs.getDouble("PARA19");
para20 = rs.getDouble("PARA20");
para21 = rs.getDouble("PARA21");
para22 = rs.getDouble("PARA22");
para23 = rs.getDouble("PARA23");
para24 = rs.getDouble("PARA24");
para25 = rs.getDouble("PARA25");
para26 = rs.getDouble("PARA26");
para27 = rs.getDouble("PARA27");
para28 = rs.getDouble("PARA28");
para29 = rs.getDouble("PARA29");
para30 = rs.getDouble("PARA30");
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
StringTokenizer st = new StringTokenizer(formula,"[]");
int n = 0;
if (formula.indexOf("[") == 0)
n = 1;
Vector paras = new Vector();
while (st.hasMoreElements()) {
String element = (String)st.nextElement();
if (n%2 == 1) {
paras.add(element);
}
n++;
}
StringBuffer sb = new StringBuffer(formula);
Iterator parasIter = paras.iterator();
while (parasIter.hasNext()) {
String para = (String)parasIter.next();
int fromIndex = sb.indexOf("[" + para + "]");
if (para.equals("B1"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(b1));
else if (para.equals("B2"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(b2));
else if (para.equals("P1"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para1));
else if (para.equals("P2"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para2));
else if (para.equals("P3"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para3));
else if (para.equals("P4"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para4));
else if (para.equals("P5"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para5));
else if (para.equals("P6"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para6));
else if (para.equals("P7"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para7));
else if (para.equals("P8"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para8));
else if (para.equals("P9"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para9));
else if (para.equals("P10"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para10));
else if (para.equals("P11"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para11));
else if (para.equals("P12"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para12));
else if (para.equals("P13"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para13));
else if (para.equals("P14"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para14));
else if (para.equals("P15"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para15));
else if (para.equals("P16"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para16));
else if (para.equals("P17"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para17));
else if (para.equals("P18"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para18));
else if (para.equals("P19"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para19));
else if (para.equals("P20"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para20));
else if (para.equals("P21"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para21));
else if (para.equals("P22"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para22));
else if (para.equals("P23"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para23));
else if (para.equals("P24"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para24));
else if (para.equals("P25"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para25));
else if (para.equals("P26"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para26));
else if (para.equals("P27"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para27));
else if (para.equals("P28"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para28));
else if (para.equals("P29"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para29));
else if (para.equals("P30"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para30));
}
formula = sb.toString();
String sql = "CALL " + formula;
dao.query(sql);
try {
ResultSet rs = dao.executeQuery();
if (rs.next()) {
cell = ObjectUtil.findNewCell(row, "TAXI", "TAMT");
cell.setColumnValue(rs.getObject(1));
}
rs.close();
result = true;
} catch (Exception e) {
result =false;
}
return result;
}
public double calculatorTax(Row row, double baseAMT1, double baseAMT2) {
double result = 0.0;
String formula = null;
double para1 = 0.0;
double para2 = 0.0;
double para3 = 0.0;
double para4 = 0.0;
double para5 = 0.0;
double para6 = 0.0;
double para7 = 0.0;
double para8 = 0.0;
double para9 = 0.0;
double para10 = 0.0;
double para11 = 0.0;
double para12 = 0.0;
double para13 = 0.0;
double para14 = 0.0;
double para15 = 0.0;
double para16 = 0.0;
double para17 = 0.0;
double para18 = 0.0;
double para19 = 0.0;
double para20 = 0.0;
double para21 = 0.0;
double para22 = 0.0;
double para23 = 0.0;
double para24 = 0.0;
double para25 = 0.0;
double para26 = 0.0;
double para27 = 0.0;
double para28 = 0.0;
double para29 = 0.0;
double para30 = 0.0;
double b1 = baseAMT1;
double b2 = baseAMT2;
String taxt = null;
Cell cell = ObjectUtil.findNewCell(row, "TAX", "TAXT");
taxt = (String)cell.getColumnValue();
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_FROM_TAXT_SQL);
dao.setObject(1, taxt);
try {
ResultSet rs = dao.executeQuery();
if (rs.next()) {
formula = rs.getString("FORMULA");
para1 = rs.getDouble("PARA1");
para2 = rs.getDouble("PARA2");
para3 = rs.getDouble("PARA3");
para4 = rs.getDouble("PARA4");
para5 = rs.getDouble("PARA5");
para6 = rs.getDouble("PARA6");
para7 = rs.getDouble("PARA7");
para8 = rs.getDouble("PARA8");
para9 = rs.getDouble("PARA9");
para10 = rs.getDouble("PARA10");
para11 = rs.getDouble("PARA11");
para12 = rs.getDouble("PARA12");
para13 = rs.getDouble("PARA13");
para14 = rs.getDouble("PARA14");
para15 = rs.getDouble("PARA15");
para16 = rs.getDouble("PARA16");
para17 = rs.getDouble("PARA17");
para18 = rs.getDouble("PARA18");
para19 = rs.getDouble("PARA19");
para20 = rs.getDouble("PARA20");
para21 = rs.getDouble("PARA21");
para22 = rs.getDouble("PARA22");
para23 = rs.getDouble("PARA23");
para24 = rs.getDouble("PARA24");
para25 = rs.getDouble("PARA25");
para26 = rs.getDouble("PARA26");
para27 = rs.getDouble("PARA27");
para28 = rs.getDouble("PARA28");
para29 = rs.getDouble("PARA29");
para30 = rs.getDouble("PARA30");
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
StringTokenizer st = new StringTokenizer(formula,"[]");
int n = 0;
if (formula.indexOf("[") == 0)
n = 1;
Vector paras = new Vector();
while (st.hasMoreElements()) {
String element = (String)st.nextElement();
if (n%2 == 1) {
paras.add(element);
}
n++;
}
StringBuffer sb = new StringBuffer(formula);
Iterator parasIter = paras.iterator();
while (parasIter.hasNext()) {
String para = (String)parasIter.next();
int fromIndex = sb.indexOf("[" + para + "]");
if (para.equals("B1"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(b1));
else if (para.equals("B2"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(b2));
else if (para.equals("P1"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para1));
else if (para.equals("P2"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para2));
else if (para.equals("P3"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para3));
else if (para.equals("P4"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para4));
else if (para.equals("P5"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para5));
else if (para.equals("P6"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para6));
else if (para.equals("P7"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para7));
else if (para.equals("P8"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para8));
else if (para.equals("P9"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para9));
else if (para.equals("P10"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para10));
else if (para.equals("P11"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para11));
else if (para.equals("P12"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para12));
else if (para.equals("P13"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para13));
else if (para.equals("P14"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para14));
else if (para.equals("P15"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para15));
else if (para.equals("P16"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para16));
else if (para.equals("P17"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para17));
else if (para.equals("P18"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para18));
else if (para.equals("P19"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para19));
else if (para.equals("P20"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para20));
else if (para.equals("P21"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para21));
else if (para.equals("P22"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para22));
else if (para.equals("P23"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para23));
else if (para.equals("P24"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para24));
else if (para.equals("P25"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para25));
else if (para.equals("P26"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para26));
else if (para.equals("P27"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para27));
else if (para.equals("P28"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para28));
else if (para.equals("P29"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para29));
else if (para.equals("P30"))
sb.replace(fromIndex, fromIndex + ("[" + para + "]").length(), Double.toString(para30));
}
formula = sb.toString();
String sql = "CALL " + formula;
dao.query(sql);
try {
ResultSet rs = dao.executeQuery();
if (rs.next()) {
result = rs.getDouble(1);
}
rs.close();
} catch (Exception e) {
}
return result;
}
public static boolean regsAllTaxes(Vector rows) {
boolean result = true;
Iterator rowsIter = rows.iterator();
Vector rAndRis = new Vector();
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
Cell cell1 = ObjectUtil.findNewCell(row, "TAXI", "R");
Cell cell2 = ObjectUtil.findNewCell(row, "TAXI", "RI");
if ( (cell1.getColumnValue() != null) && (cell2.getColumnValue() != null) ) {
boolean flag = true;//used by some bug
int r = 0;
if (cell1.getColumnValue() instanceof Number)
r = ((Number)cell1.getColumnValue()).intValue();
else if (cell1.getColumnValue() instanceof String) {
if (((String)cell1.getColumnValue()).trim().equals("")) {
flag = false;
} else {
r = Integer.parseInt((String)cell1.getColumnValue());
}
}
int ri = 0;
if (cell2.getColumnValue() instanceof Number)
ri = ((Number)cell2.getColumnValue()).intValue();
else if (cell2.getColumnValue() instanceof String) {
if (((String)cell2.getColumnValue()).trim().equals("")) {
flag = false;
} else {
ri = Integer.parseInt((String)cell2.getColumnValue());
}
}
if (flag) {
Vector data = new Vector();
data.add(r);
data.add(ri);
Iterator rAndRisIter = rAndRis.iterator();
while (rAndRisIter.hasNext()) {
Vector oldData = (Vector)rAndRisIter.next();
Integer oldR = (Integer)oldData.get(0);
Integer oldRi = (Integer)oldData.get(1);
if ( (r == oldR.intValue()) && (ri == oldRi.intValue()) ) {
result = false;
break;
}
}
if (result)
rAndRis.add(data);
}
}
}
if (result) {
int newR = 0;
int newRi = 1;
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_MAX_R_FROM_R_SQL);
ResultSet rs = dao.executeQuery();
try {
if (rs.next())
newR = rs.getInt(1) + 1;
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
boolean hasNewRow = false;
boolean firstNewRow = true;
rowsIter = rows.iterator();
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
Cell cell1 = ObjectUtil.findNewCell(row, "TAXI", "R");
Cell cell2 = ObjectUtil.findNewCell(row, "TAXI", "RI");
boolean isAdd = false;
if ( (cell1.getColumnValue() != null) && (cell2.getColumnValue() != null) ) {
try {
if ( (cell1.getColumnValue() instanceof Number) && (cell2.getColumnValue() instanceof Number) ) {
isAdd = false;
} else if ( (cell1.getColumnValue() instanceof String) && (cell2.getColumnValue() instanceof String) ) {
Integer.parseInt((String)cell1.getColumnValue());
Integer.parseInt((String)cell2.getColumnValue());
isAdd = false;
}
} catch (Exception e) {
isAdd = true;
e.printStackTrace();
}
} else {
isAdd = true;
}
// System.err.println("isAdd = " + isAdd);
//LD
String ld = "";
String user = GlobalValueManager.getValue("SESSION.LOGINUSER");
Cell taxtCell = ObjectUtil.findNewCell(row, "TAXI", "TAXT");
dao.query(Resources.SELECT_LD_BY_TAXTYPE_SQL);
dao.setObject(1, taxtCell.getColumnValue());
dao.setObject(2, user);
rs = dao.executeQuery();
try {
if (rs.next()) {
ld = rs.getString(1);
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
//TC
String tc = "";
Cell tcCell = ObjectUtil.findNewCell(row, "TAXI", "TC");
tc = (String)tcCell.getColumnValue();
//TAMT
double tamt = 0.0;
Cell tamtCell = ObjectUtil.findNewCell(row, "TAXI", "TAMT");
tamt = getDouble(tamtCell.getColumnValue());
//R
int r = 0;
if (isAdd) {
r = newR;
} else {
if (cell1.getColumnValue() instanceof Number)
r = ((Number)cell1.getColumnValue()).intValue();
else
r = Integer.parseInt((String)cell1.getColumnValue());
}
//RI
int ri = 0;
if (isAdd) {
ri =newRi;
newRi++;
} else {
if (cell2.getColumnValue() instanceof Number)
ri = ((Number)cell2.getColumnValue()).intValue();
else
ri = Integer.parseInt((String)cell2.getColumnValue());
}
// System.err.println("R = " + r);
// System.err.println("RI = " + ri);
//LC
String lc = "";
dao.query(Resources.SELECT_LC_FROM_FAMILY_SQL);
rs = dao.executeQuery();
try {
if (rs.next()) {
lc = rs.getString("LC");
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
//TDATE
Cell tdateCell = ObjectUtil.findNewCell(row, "TAX", "TDATE");
//some bugs
String tdate;
tdate = tdateCell.getColumnValue().toString();
//XR
double xr = 1.0;
dao.query(Resources.SELECT_XR_SQL);
dao.setObject(1, lc);
dao.setObject(2, tc);
dao.setObject(3, lc);
dao.setObject(4, tc);
dao.setObject(5, tdate);
rs = dao.executeQuery();
try {
if (rs.next())
xr = rs.getDouble(1);
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
//LAMT
double lamt = tamt * xr;
// System.err.println("r=" + r + " ri=" + ri + " ld=" + ld + " tc=" + tc + " tamt=" + tamt + " lc=" + lc + " lamt=" + lamt + " tdate=" + tdate + " xr=" + xr);
//set new taxes
if (isAdd) {
if (!row.isDelete()) {
hasNewRow = true;
//insert r table
if (firstNewRow) {
firstNewRow = false;
dao.update(Resources.INSERT_R_SQL);
dao.setObject(1, r);
dao.setObject(2, "REAL");
dao.setObject(3, tdate);
String now = TimeManager.getTime(System.currentTimeMillis());
dao.setObject(4, now);
dao.setObject(5, user);
dao.setObject(6, now);
dao.setObject(7, user);
dao.setObject(8, "TAX");
dao.executeUpdate();
}
//insert ri tables
Vector values = getNSAndPAndPA(row);
dao.update(Resources.INSERT_RI_SQL);
dao.setObject(1, r);
dao.setObject(2, ri);
dao.setObject(3, "TAX");
dao.setObject(4, ld);
dao.setObject(5, tc);
dao.setObject(6, tamt);
dao.setObject(7, lc);
dao.setObject(8, xr);
dao.setObject(9, lamt);
dao.setObject(10, values.get(0));
dao.setObject(11, values.get(1));
dao.setObject(12, values.get(2));
for (int i = 13; i <= 22; i++)
dao.setObject(i, null);
dao.executeUpdate();
//update taxRows
Cell rCell = ObjectUtil.findNewCell(row, "TAXI", "R");
rCell.setColumnValue(r);
rCell = ObjectUtil.findOldCell(row, "TAXI", "R");
rCell.setColumnValue(r);
Cell riCell = ObjectUtil.findNewCell(row, "TAXI", "RI");
riCell.setColumnValue(ri);
riCell = ObjectUtil.findOldCell(row, "TAXI", "RI");
riCell.setColumnValue(ri);
}
}
}
if (hasNewRow) {
dao = DAO.getInstance();
dao.query(Resources.SELECT_SUM_LAMT_SQL);
dao.setObject(1, newR);
double sumLamt = 0.0;
rs = dao.executeQuery();
try {
if (rs.next())
sumLamt = rs.getDouble(1);
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
if (sumLamt != 0.0) {
//LD
String ld="";
dao.query(Resources.SELECT_DEFLD_FROM_LT_SQL);
dao.setObject(1, "X");
rs = dao.executeQuery();
try {
if (rs.next())
ld = rs.getString("DEFLD");
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
//LC
String lc = "";
dao.query(Resources.SELECT_LC_FROM_FAMILY_SQL);
rs = dao.executeQuery();
try {
if (rs.next()) {
lc = rs.getString("LC");
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
//XR
double xr = 1.0;
//TC
String tc = lc;
//LAMT
double lamt = -sumLamt;
//TAMT
double tamt = lamt / xr;
dao.update(Resources.INSERT_RI_SQL);
dao.setObject(1, newR);
dao.setObject(2, newRi);
dao.setObject(3, "TAX X");
dao.setObject(4, ld);
dao.setObject(5, tc);
dao.setObject(6 , tamt);
dao.setObject(7, lc);
dao.setObject(8, xr);
dao.setObject(9, lamt);
for (int i = 10; i <= 22; i++)
dao.setObject(i, null);
dao.executeUpdate();
}
}
}
return result;
}
private void updateRITAXI(Row taxRow, Row regRow, double sign) {
Cell cell = ObjectUtil.findNewCell(regRow, "RI", "R");
Integer r = 0;
if (cell.getColumnValue() instanceof Number)
r = ((Number)cell.getColumnValue()).intValue();
else
r = Integer.parseInt((String)cell.getColumnValue());
cell = ObjectUtil.findNewCell(regRow, "RI", "RI");
Integer ri = 0;
if (cell.getColumnValue() instanceof Number)
ri = ((Number)cell.getColumnValue()).intValue();
else
ri = Integer.parseInt((String)cell.getColumnValue());
cell = ObjectUtil.findOldCell(regRow, "RI", "R");
Integer oldr = 0;
if (cell.getColumnValue() instanceof Number)
oldr = ((Number)cell.getColumnValue()).intValue();
else
oldr = Integer.parseInt((String)cell.getColumnValue());
cell = ObjectUtil.findOldCell(regRow, "RI", "RI");
Integer oldri = 0;
if (cell.getColumnValue() instanceof Number)
oldri = ((Number)cell.getColumnValue()).intValue();
else
oldri = Integer.parseInt((String)cell.getColumnValue());
cell = ObjectUtil.findNewCell(taxRow, "TAXI", "TAXT");
String taxt = (String)cell.getColumnValue();
cell = ObjectUtil.findNewCell(taxRow, "TAXI", "TAX");
String tax = (String)cell.getColumnValue();
cell = ObjectUtil.findNewCell(taxRow, "TAXI", "TAXI");
String taxi = (String)cell.getColumnValue();
DAO dao = DAO.getInstance();
// System.err.println("taxRow.isAdd() = " + taxRow.isAdd());
// System.err.println("taxRow.isModify() = " + taxRow.isModify());
// System.err.println("taxRow.isDelete() = " + taxRow.isDelete());
if ( (taxRow.isDelete()) && (!taxRow.isAdd()) ) {
dao.update(Resources.DELETE_RITAXI_SQL);
dao.setObject(1, oldr);
dao.setObject(2, oldri);
dao.setObject(3, taxt);
dao.setObject(4, tax);
dao.setObject(5, taxi);
dao.executeUpdate();
} else if ( (!taxRow.isAdd()) && (!taxRow.isDelete()) ) {
dao.update(Resources.DELETE_RITAXI_SQL);
dao.setObject(1, oldr);
dao.setObject(2, oldri);
dao.setObject(3, taxt);
dao.setObject(4, tax);
dao.setObject(5, taxi);
dao.executeUpdate();
dao.update(Resources.INSERT_RITAXI_SQL);
dao.setObject(1, r);
dao.setObject(2, ri);
dao.setObject(3, taxt);
dao.setObject(4, tax);
dao.setObject(5, taxi);
dao.setObject(6, sign);
dao.executeUpdate();
} else if ( (taxRow.isAdd()) && (!taxRow.isDelete()) ) {
dao.update(Resources.INSERT_RITAXI_SQL);
dao.setObject(1, r);
dao.setObject(2, ri);
dao.setObject(3, taxt);
dao.setObject(4, tax);
dao.setObject(5, taxi);
dao.setObject(6, sign);
dao.executeUpdate();
}
}
private static Vector getNSAndPAndPA(Row taxRow) {
Vector values = new Vector();
Cell cell = ObjectUtil.findNewCell(taxRow, "TAX", "TAXT");
// System.err.println(cell.getColumnValue());
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_CO_TAXDEP_FROM_TAXT_SQL);
dao.setObject(1, cell.getColumnValue());
ResultSet rs = dao.executeQuery();
String co = "";
String taxdep = "";
try {
if (rs.next()) {
co = rs.getString("CO");
taxdep = rs.getString("TAXDEP");
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
String p = co + "." + taxdep;
dao.query(Resources.SELECT_NS_FROM_P_SQL);
dao.setObject(1, p);
rs = dao.executeQuery();
String ns = "";
String defpa = "";
try {
if (rs.next()) {
ns = rs.getString("NS");
defpa = "defpa";
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
values.add(ns);
values.add(p);
values.add(defpa);
return values;
}
private static double getDouble(Object value) {
double d = 0.0;
if (value != null) {
if (value instanceof Number)
d = ((Number)value).doubleValue();
else if (((String)value).trim().equals(""))
d = 0.0;
else
d = Double.parseDouble((String)value);
}
return d;
}
public static boolean isTaxPartnerBlocked(Row taxRow) {
boolean result = true;
String ns = (String)ObjectUtil.findNewCell(taxRow, "TAX", "NS").getColumnValue();
String p = (String)ObjectUtil.findNewCell(taxRow, "TAX", "P").getColumnValue();
String pa = (String)ObjectUtil.findNewCell(taxRow, "TAX", "PA").getColumnValue();
DAO dao = DAO.getInstance();
dao.query(Resources.GET_PA_SQL);
dao.setString(1, ns);
dao.setString(2, p);
dao.setString(3, pa);
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
result = rs.getBoolean("BLOCK");
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static boolean taxRegsInformation(Row taxRow) {
boolean result = true;
Vector rAndRis = new Vector();
Iterator rowsIter = taxRow.getRowSet().getRows().iterator();
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
int newR = -1;
int newRI = -1;
if ( (ObjectUtil.findNewCell(row, "TAXI", "R").getColumnValue() != null) && (ObjectUtil.findNewCell(row, "TAXI", "R").getColumnValue().toString().trim().length() > 0) ) {
newR = Integer.parseInt(ObjectUtil.findNewCell(row, "TAXI", "R").getColumnValue().toString());
}
if ( (ObjectUtil.findNewCell(row, "TAXI", "RI").getColumnValue() != null) && (ObjectUtil.findNewCell(row, "TAXI", "RI").getColumnValue().toString().trim().length() > 0) ) {
newRI = Integer.parseInt(ObjectUtil.findNewCell(row, "TAXI", "RI").getColumnValue().toString());
}
if (rAndRis.size() == 0) {
String str = newR + "-" + newRI;
rAndRis.add(str);
} else {
String str = newR + "-" + newRI;
Iterator rAndRisIter = rAndRis.iterator();
while (rAndRisIter.hasNext()) {
String tempStr = (String)rAndRisIter.next();
if ( (newR != -1) && (newRI != -1) ) {
if (tempStr.equals(str)) {
result = false;
break;
}
}
}
}
}
return result;
}
public static boolean needDeleteRegs(Row taxRow) {
boolean result = false;
Iterator rowsIter = taxRow.getRowSet().getRows().iterator();
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
int newR = -1;
if ( (ObjectUtil.findNewCell(row, "TAXI", "R").getColumnValue() != null) && (ObjectUtil.findNewCell(row, "TAXI", "R").getColumnValue().toString().trim().length() > 0) ) {
newR = Integer.parseInt(ObjectUtil.findNewCell(row, "TAXI", "R").getColumnValue().toString());
}
if (newR != -1) {
result = true;
break;
}
}
return result;
}
public static int taxRegs(Row taxRow) {
//Test if can regs
boolean allTamtEqualsZero = true;
Iterator rowsIter = taxRow.getRowSet().getRows().iterator();
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
if (taxRow.isAdd()) {
if (row != taxRow) {
Double tempTAmt = Double.parseDouble(ObjectUtil.findNewCell(row, "TAXI", "TAMT").getColumnValue().toString());
if (tempTAmt != 0.0) {
allTamtEqualsZero = false;
break;
}
}
} else {
Double tempTAmt = Double.parseDouble(ObjectUtil.findNewCell(row, "TAXI", "TAMT").getColumnValue().toString());
if (tempTAmt != 0.0) {
allTamtEqualsZero = false;
break;
}
}
}
if (allTamtEqualsZero) {
return -1;
}
//delete oldR
Vector newRAndOldRs = new Vector();//data struct: new_R-newR
rowsIter = taxRow.getRowSet().getRows().iterator();
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
int oldR = -1;
int newR = -1;
if ( (ObjectUtil.findOldCell(row, "TAXI", "R").getColumnValue() != null) && (ObjectUtil.findOldCell(row, "TAXI", "R").getColumnValue().toString().trim().length() > 0) ) {
oldR = Integer.parseInt(ObjectUtil.findOldCell(row, "TAXI", "R").getColumnValue().toString());
}
if ( (ObjectUtil.findNewCell(row, "TAXI", "R").getColumnValue() != null) && (ObjectUtil.findNewCell(row, "TAXI", "R").getColumnValue().toString().trim().length() > 0) ) {
newR = Integer.parseInt(ObjectUtil.findNewCell(row, "TAXI", "R").getColumnValue().toString());
}
if (!row.isDelete()) {
if (oldR != -1) {
TaxClass.deleteR(oldR);
TaxClass.deleteRI(oldR);
}
if (newR != -1) {
TaxClass.deleteR(newR);
TaxClass.deleteRI(newR);
}
} else {
if (!row.isAdd()) {
if (oldR != -1) {
TaxClass.deleteR(oldR);
TaxClass.deleteRI(oldR);
}
}
}
}
rowsIter = taxRow.getRowSet().getRows().iterator();
int new_R = getMAXR() + 1;
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
int newR = -1;
if ( (ObjectUtil.findNewCell(row, "TAXI", "R").getColumnValue() != null) && (ObjectUtil.findNewCell(row, "TAXI", "R").getColumnValue().toString().trim().length() > 0) ) {
newR = Integer.parseInt(ObjectUtil.findNewCell(row, "TAXI", "R").getColumnValue().toString());
}
String str = new_R + "-" + newR;
newRAndOldRs.add(str);
}
//add new R
rowsIter = taxRow.getRowSet().getRows().iterator();
Iterator newRAndOldRsIter = newRAndOldRs.iterator();
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
String str = (String)newRAndOldRsIter.next();
StringTokenizer st = new StringTokenizer(str, "-");
String tDate = (String)ObjectUtil.findNewCell(taxRow, "TAX", "TDATE").getColumnValue();
String txt512 = "";
if (ObjectUtil.findNewCell(taxRow, "TAX", "TXT512").getColumnValue() != null)
txt512 = (String)ObjectUtil.findNewCell(taxRow, "TAX", "TXT512").getColumnValue();
new_R = Integer.parseInt(st.nextElement().toString());
TaxClass.insertr(new_R, tDate, txt512);
}
//add newri
taxRow.setModify(true);
taxRow.print();
rowsIter = taxRow.getRowSet().getRows().iterator();
newRAndOldRsIter = newRAndOldRs.iterator();
int currentRI = 1;
while (rowsIter.hasNext()) {
Row row = (Row)rowsIter.next();
String str = (String)newRAndOldRsIter.next();
StringTokenizer st = new StringTokenizer(str, "-");
String tDate = (String)ObjectUtil.findNewCell(taxRow, "TAX", "TDATE").getColumnValue();
String txt512 = "";
String ld = TaxClass.getLD(taxRow);
if (ObjectUtil.findNewCell(row, "TAXI", "TXT256").getColumnValue() != null)
txt512 = (String)ObjectUtil.findNewCell(row, "TAXI", "TXT256").getColumnValue();
String tc = "";
double tamt = 0.0;
if (taxRow.isAdd()) {
if (row != taxRow) {
tc = ObjectUtil.findNewCell(row, "TAXI", "TC").getColumnValue().toString();
tamt = Double.parseDouble(ObjectUtil.findNewCell(row, "TAXI", "TAMT").getColumnValue().toString());
}
} else if (taxRow.isModify()) {
tc = ObjectUtil.findNewCell(row, "TAXI", "TC").getColumnValue().toString();
tamt = Double.parseDouble(ObjectUtil.findNewCell(row, "TAXI", "TAMT").getColumnValue().toString());
}
String taxt = (String)ObjectUtil.findNewCell(taxRow, "TAX", "TAXT").getColumnValue();
String tax = (String)ObjectUtil.findNewCell(taxRow, "TAX", "TAX").getColumnValue();
String taxi = (String)ObjectUtil.findNewCell(row, "TAXI", "TAXI").getColumnValue();
txt512 = taxt + " - " + tax + " - " + taxi;
new_R = Integer.parseInt(st.nextElement().toString());
if (taxRow.isAdd()) {
if (row != taxRow) {
//taxRow.print();
insertri(taxRow, new_R, currentRI, ld, txt512, tc, 0 - tamt, tDate);
ObjectUtil.findNewCell(row, "TAXI", "RI").setColumnValue(currentRI);
currentRI++;
ObjectUtil.findNewCell(row, "TAXI", "R").setColumnValue(new_R);
}
} else {
insertri(taxRow, new_R, currentRI, ld, txt512, tc, 0 - tamt, tDate);
ObjectUtil.findNewCell(row, "TAXI", "RI").setColumnValue(currentRI);
currentRI++;
ObjectUtil.findNewCell(row, "TAXI", "R").setColumnValue(new_R);
}
}
//BALANCE
newRAndOldRsIter = newRAndOldRs.iterator();
String balanceLd = TaxClass.getBalanceLD();
String txt256 = TxtManager.getTxt("VIEW.OBJECTEDIT.TAX.TAXOFFSET");
String tc = FamilyClass.getLocalCurrency();
String lc = tc;
String tDate = ObjectUtil.findNewCell(taxRow, "TAX", "TDATE").getColumnValue().toString();
int currentR = -1;
while (newRAndOldRsIter.hasNext()) {
String str = (String)newRAndOldRsIter.next();
StringTokenizer st = new StringTokenizer(str, "-");
new_R = Integer.parseInt(st.nextElement().toString());
if (currentR != new_R) {
currentR = new_R;
int ri = getMAXRIByR(currentR) + 1;
double tamt = 0 - getSUMLamt(currentR);
insertri_balance(taxRow, currentR, ri, balanceLd, txt256, tc, tamt, tDate);
}
}
return new_R;
}
public static double getSUMLamt(int r) {
double sumLamt = -1;
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_SUM_LAMT_SQL);
dao.setInt(1, r);
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
sumLamt = rs.getDouble(1);
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return sumLamt;
}
public static int getMAXRIByR(int r) {
int maxRI = -1;
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_MAXRI_BY_R_SQL);
dao.setInt(1, r);
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
maxRI = rs.getInt(1);
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return maxRI;
}
public static int getMAXR() {
int maxR = -1;
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_MAX_R_FROM_R_SQL);
ResultSet rs = dao.executeQuery();
try {
if (rs.next())
maxR = rs.getInt(1);
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return maxR;
}
public static void insertr(int r, String rDate, String txt256) {
// System.err.println("r = " + r + " rDate = " + rDate + " txt256 = " + txt256);
String ruser = GlobalValueManager.getValue("SESSION.LOGINUSER");
String at = GlobalValueManager.getValue("APPLICATION.AT");
DAO dao = DAO.getInstance();
dao.update(Resources.INSERT_R_SQL);
dao.setObject(1, r);
dao.setObject(2, at);
dao.setObject(3, rDate);
String now = TimeManager.getTime(System.currentTimeMillis());
dao.setObject(4, now);
dao.setObject(5, ruser);
dao.setObject(6, now);
dao.setObject(7, ruser);
dao.setObject(8, txt256);
// System.err.println("dao.getStatmt = " + dao.getPstmt());
dao.executeUpdate();
}
public static void insertri_balance(Row taxRow, int r, int ri, String ld, String txt256, String tc, double tamt, String rDate) {
DAO dao = DAO.getInstance();
String lc = FamilyClass.getLocalCurrency();
double xr = TaxClass.getXR(lc, tc, rDate);
double lamt = tamt * xr;
dao.query(Resources.INSERT_RI_VALUE_SQL);
dao.setObject(1, r);
dao.setObject(2, ri);
dao.setObject(3, txt256);
dao.setObject(4, ld);
dao.setObject(5, tc);
dao.setObject(6, tamt);
dao.setObject(7, lc);
dao.setObject(8, xr);
dao.setObject(9, lamt);
dao.setObject(10, null);
dao.setObject(11, null);
dao.setObject(12, null);
dao.executeUpdate();
}
public static void insertri(Row taxRow, int r, int ri, String ld, String txt256, String tc, double tamt, String rDate) {
DAO dao = DAO.getInstance();
String lc = FamilyClass.getLocalCurrency();
double xr = TaxClass.getXR(lc, tc, rDate);
double lamt = tamt * xr;
dao.query(Resources.INSERT_RI_VALUE_SQL);
dao.setObject(1, r);
dao.setObject(2, ri);
dao.setObject(3, txt256);
dao.setObject(4, ld);
dao.setObject(5, tc);
dao.setObject(6, tamt);
dao.setObject(7, lc);
dao.setObject(8, xr);
dao.setObject(9, lamt);
dao.setObject(10, ObjectUtil.findNewCell(taxRow, "TAX", "NS").getColumnValue().toString());
dao.setObject(11, ObjectUtil.findNewCell(taxRow, "TAX", "P").getColumnValue().toString());
dao.setObject(12, ObjectUtil.findNewCell(taxRow, "TAX", "PA").getColumnValue().toString());
dao.executeUpdate();
}
public static double getXR(String lc, String tc, String rDate) {
double xr = 1.0;
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_XR_SQL);
dao.setObject(1, lc);
dao.setObject(2, tc);
dao.setObject(3, lc);
dao.setObject(4, tc);
dao.setObject(5, rDate);
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
xr = rs.getDouble(1);
}
rs.close();
} catch (Exception e) {
}
return xr;
}
public static String getBalanceLD() {
String balanceLD = null;
String lt = "X";
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_DEFLD_SQL);
dao.setObject(1, lt);
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
balanceLD = rs.getString("DEFLD");
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return balanceLD;
}
public static String getLD(Row taxRow) {
String ld = null;
DAO dao = DAO.getInstance();
dao.query(Resources.SELECT_LD_FROM_PA_SQL);
dao.setObject(1, ObjectUtil.findNewCell(taxRow, "TAX", "NS").getColumnValue().toString());
dao.setObject(2, ObjectUtil.findNewCell(taxRow, "TAX", "P").getColumnValue().toString());
dao.setObject(3, ObjectUtil.findNewCell(taxRow, "TAX", "PA").getColumnValue().toString());
ResultSet rs = dao.executeQuery();
try {
if (rs.next()) {
ld = rs.getString("LD");
}
rs.close();
} catch (Exception e) {
}
return ld;
}
public static boolean isRInVector(RAndRi rAndRi, Vector rAndRis) {
boolean result = false;
Iterator rAndRisIter = rAndRis.iterator();
while (rAndRisIter.hasNext()) {
RAndRi tempRAndRi = (RAndRi)rAndRisIter.next();
if (tempRAndRi.r == rAndRi.r) {
result = true;
break;
}
}
return result;
}
public static boolean isRAndRiInVector(RAndRi rAndRi, Vector rAndRis) {
boolean result = false;
Iterator rAndRisIter = rAndRis.iterator();
while (rAndRisIter.hasNext()) {
RAndRi tempRAndRi = (RAndRi)rAndRisIter.next();
if ( (tempRAndRi.r == rAndRi.r) && (tempRAndRi.ri == rAndRi.ri) ) {
result = true;
break;
}
}
return result;
}
public static void deleteRI(int r) {
DAO dao = DAO.getInstance();
dao.update(Resources.DELETE_RI_SQL);
dao.setInt(1, r);
dao.executeUpdate();
}
public static void deleteR(int r) {
DAO dao = DAO.getInstance();
dao.update(Resources.DELETE_R_SQL);
dao.setInt(1, r);
dao.executeUpdate();
}
}