BrightSide Workbench Full Report + Source Code
org.turro.financials.report.AccountReportItem Class Reference

Public Member Functions

 AccountReportItem (String label)
 
AccountReportItem addItem (String label)
 
AccountReportItem addItem (AccountReportItem item)
 
void addPattern (String pattern)
 
List< AccountReportItemgetChildren ()
 
String getLabel ()
 
void setLabel (String label)
 
ItemMode getMode ()
 
void setMode (ItemMode mode)
 
AccountReportItem getParent ()
 
void setParent (AccountReportItem parent)
 
PeriodSet getPeriods ()
 
AccountReport getReport ()
 
void setReport (AccountReport report)
 
boolean isShowTotal ()
 
void setShowTotal (boolean showTotal)
 
boolean isTitleItem ()
 
boolean isTotalItem ()
 
void setTotalItem (boolean totalItem)
 
AccountReportItem getItem (String label)
 
PeriodSet loadData (PeriodSet existingPeriods)
 
AccountReportPeriod getPeriodFor (AccountReportPeriod accountReportPeriod)
 
void regularizeMode (PeriodSet existingPeriods)
 
AccountReportItem getTotalItem ()
 
double getAccumulatedFor (AccountReportPeriod period)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 30 of file AccountReportItem.java.

Constructor & Destructor Documentation

◆ AccountReportItem()

org.turro.financials.report.AccountReportItem.AccountReportItem ( String  label)

Definition at line 42 of file AccountReportItem.java.

42  {
43  this.label = label;
44  }
Here is the caller graph for this function:

Member Function Documentation

◆ addItem() [1/2]

AccountReportItem org.turro.financials.report.AccountReportItem.addItem ( AccountReportItem  item)

Definition at line 50 of file AccountReportItem.java.

50  {
51  item.setReport(report);
52  item.setParent(this);
53  children.add(item);
54  return item;
55  }
Here is the call graph for this function:

◆ addItem() [2/2]

AccountReportItem org.turro.financials.report.AccountReportItem.addItem ( String  label)

Definition at line 46 of file AccountReportItem.java.

46  {
47  return addItem(new AccountReportItem(label));
48  }
Here is the call graph for this function:

◆ addPattern()

void org.turro.financials.report.AccountReportItem.addPattern ( String  pattern)

Definition at line 57 of file AccountReportItem.java.

57  {
58  patterns.add(pattern);
59  }

◆ getAccumulatedFor()

double org.turro.financials.report.AccountReportItem.getAccumulatedFor ( AccountReportPeriod  period)

Definition at line 217 of file AccountReportItem.java.

217  {
218  AccountReportPeriod p = period == null ? null : getPeriodFor(period);
219  double accumulated = p == null ? 0.0 : p.getValue();
220  for(AccountReportItem item : children) {
221  accumulated += item.getAccumulatedFor(period);
222  }
223  return accumulated;
224  }
AccountReportPeriod getPeriodFor(AccountReportPeriod accountReportPeriod)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getChildren()

List<AccountReportItem> org.turro.financials.report.AccountReportItem.getChildren ( )

Definition at line 61 of file AccountReportItem.java.

61  {
62  return children;
63  }

◆ getItem()

AccountReportItem org.turro.financials.report.AccountReportItem.getItem ( String  label)

Definition at line 124 of file AccountReportItem.java.

124  {
125  if(!Strings.isBlank(label)) {
126  for(AccountReportItem ari : children) {
127  if(label.equals(ari.getLabel())) {
128  return ari;
129  }
130  AccountReportItem ari2 = ari.getItem(label);
131  if(ari2 != null) {
132  return ari2;
133  }
134  }
135  }
136  return null;
137  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLabel()

String org.turro.financials.report.AccountReportItem.getLabel ( )

Definition at line 65 of file AccountReportItem.java.

65  {
66  return label;
67  }

◆ getMode()

ItemMode org.turro.financials.report.AccountReportItem.getMode ( )

Definition at line 73 of file AccountReportItem.java.

73  {
74  return mode;
75  }

◆ getParent()

AccountReportItem org.turro.financials.report.AccountReportItem.getParent ( )

Definition at line 81 of file AccountReportItem.java.

81  {
82  return parent;
83  }

◆ getPeriodFor()

AccountReportPeriod org.turro.financials.report.AccountReportItem.getPeriodFor ( AccountReportPeriod  accountReportPeriod)

Definition at line 162 of file AccountReportItem.java.

162  {
163  for(AccountReportPeriod period : getPeriods()) {
164  if(period.getYear() == accountReportPeriod.getYear() && period.getMonth() == accountReportPeriod.getMonth()) {
165  return period;
166  }
167  }
168  return null;
169  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPeriods()

PeriodSet org.turro.financials.report.AccountReportItem.getPeriods ( )

Definition at line 89 of file AccountReportItem.java.

89  {
90  return periods;
91  }
Here is the caller graph for this function:

◆ getReport()

AccountReport org.turro.financials.report.AccountReportItem.getReport ( )

Definition at line 93 of file AccountReportItem.java.

93  {
94  return report;
95  }
Here is the caller graph for this function:

◆ getTotalItem()

AccountReportItem org.turro.financials.report.AccountReportItem.getTotalItem ( )

Definition at line 202 of file AccountReportItem.java.

202  {
203  AccountReportItem total = new AccountReportItem(label);
204  total.setMode(mode);
205  total.setParent(parent);
206  total.setReport(report);
207  total.setTotalItem(true);
208  for(AccountReportPeriod period : periods) {
209  AccountReportPeriod arp = new AccountReportPeriod(period.getYear(), period.getMonth());
210  arp.setItem(total);
211  arp.setValue(getAccumulatedFor(period));
212  total.getPeriods().add(arp);
213  }
214  return total;
215  }
double getAccumulatedFor(AccountReportPeriod period)
Here is the call graph for this function:

◆ isShowTotal()

boolean org.turro.financials.report.AccountReportItem.isShowTotal ( )

Definition at line 101 of file AccountReportItem.java.

101  {
102  return showTotal;
103  }

◆ isTitleItem()

boolean org.turro.financials.report.AccountReportItem.isTitleItem ( )

Definition at line 109 of file AccountReportItem.java.

109  {
110  return patterns == null || patterns.isEmpty();
111  }

◆ isTotalItem()

boolean org.turro.financials.report.AccountReportItem.isTotalItem ( )

Definition at line 113 of file AccountReportItem.java.

113  {
114  return totalItem;
115  }

◆ loadData()

PeriodSet org.turro.financials.report.AccountReportItem.loadData ( PeriodSet  existingPeriods)

Definition at line 139 of file AccountReportItem.java.

139  {
140  if(periods == null) {
141  periods = new PeriodSet();
142  if(!patterns.isEmpty()) {
143  String sqlQuery = getSQLQuery();
144  if(!sqlQuery.contains("in ()")) {
145  List l = getReport().getDao().getResultList(sqlQuery);
146  for(Object[] o : (List<Object[]>) l) {
147  AccountReportPeriod arp = new AccountReportPeriod((Integer) o[0], (Integer) o[1]);
148  arp.setValue((Double) o[2]);
149  arp.setItem(this);
150  periods.add(arp);
151  existingPeriods.add(arp);
152  }
153  }
154  }
155  for(AccountReportItem ari : children) {
156  ari.loadData(existingPeriods);
157  }
158  }
159  return periods;
160  }
Here is the call graph for this function:

◆ regularizeMode()

void org.turro.financials.report.AccountReportItem.regularizeMode ( PeriodSet  existingPeriods)

Definition at line 171 of file AccountReportItem.java.

171  {
172  for(AccountReportPeriod period : existingPeriods) {
173  AccountReportPeriod arp = new AccountReportPeriod(period.getYear(), period.getMonth());
174  arp.setItem(this);
175  periods.add(arp);
176  }
177  if(mode == ItemMode.BY_YEAR) {
178  double acumulated = 0;
179  int year = 0;
180  for(AccountReportPeriod period : getPeriods()) {
181  if(period.getYear() == year) {
182  acumulated += period.getValue();
183  } else {
184  acumulated = period.getValue();
185  year = period.getYear();
186  }
187  period.setValue(acumulated);
188  }
189  } else if(mode == ItemMode.BY_TAM) {
190  TamBuffer tam = new TamBuffer();
191  for(AccountReportPeriod period : getPeriods()) {
192  tam.add(period.getValue());
193  period.setValue(tam.getTotal());
194  }
195 
196  }
197  for(AccountReportItem ari : children) {
198  ari.regularizeMode(existingPeriods);
199  }
200  }
Here is the call graph for this function:

◆ setLabel()

void org.turro.financials.report.AccountReportItem.setLabel ( String  label)

Definition at line 69 of file AccountReportItem.java.

69  {
70  this.label = label;
71  }

◆ setMode()

void org.turro.financials.report.AccountReportItem.setMode ( ItemMode  mode)

Definition at line 77 of file AccountReportItem.java.

77  {
78  this.mode = mode;
79  }
Here is the caller graph for this function:

◆ setParent()

void org.turro.financials.report.AccountReportItem.setParent ( AccountReportItem  parent)

Definition at line 85 of file AccountReportItem.java.

85  {
86  this.parent = parent;
87  }
Here is the caller graph for this function:

◆ setReport()

void org.turro.financials.report.AccountReportItem.setReport ( AccountReport  report)

Definition at line 97 of file AccountReportItem.java.

97  {
98  this.report = report;
99  }
Here is the caller graph for this function:

◆ setShowTotal()

void org.turro.financials.report.AccountReportItem.setShowTotal ( boolean  showTotal)

Definition at line 105 of file AccountReportItem.java.

105  {
106  this.showTotal = showTotal;
107  }

◆ setTotalItem()

void org.turro.financials.report.AccountReportItem.setTotalItem ( boolean  totalItem)

Definition at line 117 of file AccountReportItem.java.

117  {
118  this.totalItem = totalItem;
119  if(totalItem) {
120  periods = new PeriodSet();
121  }
122  }
Here is the caller graph for this function:

The documentation for this class was generated from the following file: