1 14 package org.compiere.report; 15 16 import java.util.*; 17 import java.sql.*; 18 import java.math.*; 19 import java.io.Serializable ; 20 21 import org.compiere.model.*; 22 import org.compiere.util.*; 23 24 30 public class MReportColumn extends X_PA_ReportColumn 31 { 32 37 public MReportColumn (Properties ctx, int PA_ReportColumn_ID) 38 { 39 super (ctx, PA_ReportColumn_ID); 40 if (PA_ReportColumn_ID == 0) 41 { 42 setIsPrinted (true); 43 setSeqNo (0); 44 } 45 } 47 52 public MReportColumn (Properties ctx, ResultSet rs) 53 { 54 super (ctx, rs); 55 } 57 58 59 64 public String getSelectClause (boolean withSum) 65 { 66 String at = getAmountType().substring(0,1); StringBuffer sb = new StringBuffer (); 68 if (withSum) 69 sb.append("SUM("); 70 if (AmountType_Balance.equals(at)) 71 sb.append("AmtAcctDr-AmtAcctCr"); 72 else if (AmountType_CR.equals(at)) 73 sb.append("AmtAcctCr"); 74 else if (AmountType_DR.equals(at)) 75 sb.append("AmtAcctDr"); 76 else if (AmountType_Qty.equals(at)) 77 sb.append("Qty"); 78 else 79 { 80 Log.error ("MReportColumn.getSelectClause - AmountType=" + getAmountType () + ", at=" + at); 81 return "NULL"; 82 } 83 if (withSum) 84 sb.append(")"); 85 return sb.toString(); 86 } 88 92 public boolean isPeriodBalance() 93 { 94 String at = getAmountType(); 95 if (at == null) 96 return false; 97 return AMOUNTTYPE_PeriodBalance.equals(at); 98 } 100 104 public boolean isYearBalance() 105 { 106 String at = getAmountType(); 107 if (at == null) 108 return false; 109 return AMOUNTTYPE_YearBalance.equals(at); 110 } 112 116 public boolean isTotalBalance() 117 { 118 String at = getAmountType(); 119 if (at == null) 120 return false; 121 return AMOUNTTYPE_TotalBalance.equals(at); 122 } 124 125 129 public String toString () 130 { 131 StringBuffer sb = new StringBuffer ("MReportColumn[") 132 .append(getID()).append(" - ").append(getName()).append(" - ").append(getDescription()) 133 .append(", SeqNo=").append(getSeqNo()).append(", AmountType=").append(getAmountType()) 134 .append(", CurrencyType=").append(getCurrencyType()).append("/").append(getC_Currency_ID()) 135 .append(" - ColumnType=").append(getColumnType()); 136 if (isColumnTypeCalculation()) 137 sb.append(" - Calculation=").append(getCalculationType()) 138 .append(" - ").append(getOper_1_ID()).append(" - ").append(getOper_2_ID()); 139 else if (isColumnTypeRelativePeriod()) 140 sb.append(" - Period=").append(getRelativePeriod()); 141 else 142 sb.append(" - SegmentValue ElementType=").append(getElementType()); 143 sb.append ("]"); 144 return sb.toString (); 145 } 147 public static final String AmountType_Balance = "B"; 148 public static final String AmountType_CR = "C"; 149 public static final String AmountType_DR = "D"; 150 public static final String AmountType_Qty = "Q"; 151 public static final String AmountType_Period = "P"; 153 public static final String AmountType_Year = "Y"; 154 public static final String AmountType_Total = "T"; 155 156 157 public boolean isCalculationTypeRange() 158 { 159 return CALCULATIONTYPE_AddRangeOp1ToOp2.equals(getCalculationType()); 160 } 161 public boolean isCalculationTypeAdd() 162 { 163 return CALCULATIONTYPE_AddOp1PlusOp2.equals(getCalculationType()); 164 } 165 public boolean isCalculationTypeSubtract() 166 { 167 return CALCULATIONTYPE_SubtractOp1MinusOp2.equals(getCalculationType()); 168 } 169 public boolean isCalculationTypePercent() 170 { 171 return CALCULATIONTYPE_PercentageOp2OfOp1.equals(getCalculationType()); 172 } 173 174 175 public boolean isColumnTypeCalculation() 176 { 177 return COLUMNTYPE_Calculation.equals(getColumnType()); 178 } 179 public boolean isColumnTypeRelativePeriod() 180 { 181 return COLUMNTYPE_RelativePeriod.equals(getColumnType()); 182 } 183 public boolean isColumnTypeSegmentValue() 184 { 185 return COLUMNTYPE_SegmentValue.equals(getColumnType()); 186 } 187 188 public int getRelativePeriodAsInt () 189 { 190 BigDecimal bd = getRelativePeriod(); 191 if (bd == null) 192 return 0; 193 return bd.intValue(); 194 } 196 200 private void setPA_ReportColumnSet_ID (int PA_ReportColumnSet_ID) 201 { 202 setValueNoCheck ("PA_ReportColumnSet_ID", new Integer (PA_ReportColumnSet_ID)); 203 } 205 206 207 208 217 public static MReportColumn copy (Properties ctx, int AD_Client_ID, int AD_Org_ID, int PA_ReportColumnSet_ID, MReportColumn source) 218 { 219 MReportColumn retValue = new MReportColumn (ctx, 0); 220 MReportColumn.copyValues(source, retValue, AD_Client_ID, AD_Org_ID); 221 retValue.setPA_ReportColumnSet_ID(PA_ReportColumnSet_ID); return retValue; 223 } 225 } | Popular Tags |