BrightSide Workbench Full Report + Source Code
org.turro.financials.account.DiaryReport Class Reference
Inheritance diagram for org.turro.financials.account.DiaryReport:
Collaboration diagram for org.turro.financials.account.DiaryReport:

Public Member Functions

 DiaryReport ()
 
Collection< Long > getRegisters ()
 
WhereClause getSQLRegisters ()
 
- Public Member Functions inherited from org.turro.zkoss.print.ReportMenuitem
 ReportMenuitem ()
 
void afterCompose ()
 

Static Public Member Functions

static void exportDiary ()
 
static void exportAccountBalance (int year, int month, boolean carry, boolean breakdown)
 
static Integer getLastInitialSince (int year)
 

Protected Member Functions

void print (final String type)
 

Detailed Description

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

Definition at line 63 of file DiaryReport.java.

Constructor & Destructor Documentation

◆ DiaryReport()

org.turro.financials.account.DiaryReport.DiaryReport ( )

Definition at line 69 of file DiaryReport.java.

69  {
70  }

Member Function Documentation

◆ exportAccountBalance()

static void org.turro.financials.account.DiaryReport.exportAccountBalance ( int  year,
int  month,
boolean  carry,
boolean  breakdown 
)
static

Definition at line 231 of file DiaryReport.java.

231  {
232  WhereClause wc = new WhereClause();
233  wc.addClause("select r.view.name,");
234  if(breakdown) {
235  wc.addClause("year(r.registerDate),");
236  wc.addClause("month(r.registerDate),");
237  }
238  wc.addClause("substring(re.account.id, 1, 1), (select ma1.description from MajorAccount ma1 where ma1.account = substring(re.account.id, 1, 1)),");
239  wc.addClause("substring(re.account.id, 1, 2), (select ma2.description from MajorAccount ma2 where ma2.account = substring(re.account.id, 1, 2)),");
240  wc.addClause("substring(re.account.id, 1, 3), (select ma3.description from MajorAccount ma3 where ma3.account = substring(re.account.id, 1, 3)),");
241  wc.addClause("ma.account, ma.description, re.account.id,");
242  wc.addClause("re.account.description, sum(re.debit), sum(re.credit)");
243  wc.addClause("from RegisterEntry re join re.register r, MajorAccount ma");
244  wc.addClause("where ma.account = (select max(m.account) from MajorAccount as m");
245  wc.addClause("where re.account.id like concat(m.account, '%'))");
246  wc.addClause("and r.registerDate < :date");
247  wc.addNamedValue("date", new CheckDate(year, month, 1, 0, 0, 0).addMonths(1).getDate());
248  if(carry) {
249  wc.addClause("and year(r.registerDate) >= :carry");
250  wc.addNamedValue("carry", getLastInitialSince(year));
251  wc.addClause("and not (r.exclude = TRUE and year(r.registerDate) = :year)");
252  wc.addNamedValue("year", year);
253  } else {
254  wc.addClause("and year(r.registerDate) = :carry");
255  wc.addNamedValue("carry", year);
256  wc.addClause("and not (r.exclude = TRUE or r.closing = TRUE)");
257  }
258  if(breakdown) {
259  wc.addClause("group by r.view.name, year(r.registerDate), month(r.registerDate), re.account.id, ma.account, ma.description");
260  } else {
261  wc.addClause("group by r.view.name, re.account.id, ma.account, ma.description");
262  }
263  wc.addClause("order by re.account.id");
264 
265  List<String> l;
266  if(breakdown) {
267  l = Arrays.asList(new String[] {
268  I_.get("View"),
269  I_.get("Year"),
270  I_.get("Month"),
271  "M1", "M1Desc", "M2", "M2Desc", "M3", "M3Desc",
272  I_.get("Major account"),
273  I_.get("Name"),
274  I_.get("Account"),
275  I_.get("Description"),
276  I_.get("Debit"),
277  I_.get("Credit")
278  });
279  } else {
280  l = Arrays.asList(new String[] {
281  I_.get("View"),
282  "M1", "M1Desc", "M2", "M2Desc", "M3", "M3Desc",
283  I_.get("Major account"),
284  I_.get("Name"),
285  I_.get("Account"),
286  I_.get("Description"),
287  I_.get("Debit"),
288  I_.get("Credit")
289  });
290  }
291  Dao dao = new FinancialsPU();
292  String name = ElephantContext.getSiteName() + "_AccountBalance.xls";
293  ExportQuery eq = new ExportQuery(l, dao.getResultList(wc));
294  Filedownload.save(eq.getExcel(name), new MimetypesFileTypeMap().getContentType(name), name);
295  }
static Integer getLastInitialSince(int year)
Here is the call graph for this function:

◆ exportDiary()

static void org.turro.financials.account.DiaryReport.exportDiary ( )
static

Definition at line 183 of file DiaryReport.java.

183  {
184  IContact contact = Authentication.getIContact();
185  MailSenders.getHeavy()
186  .addContact(contact)
187  .onStart(s -> MessageQueue.pushMessage(contact, I_.get("Report will be sent by email")))
188  .onCancel(s -> MessageQueue.pushMessage(contact, I_.get("Task already running")))
189  .onBuild(s -> diaryToExcel((IMailSender) s))
190  .send(I_.get("Export diary"), I_.get("Export diary"));
191  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLastInitialSince()

static Integer org.turro.financials.account.DiaryReport.getLastInitialSince ( int  year)
static

Definition at line 297 of file DiaryReport.java.

297  {
298  return SqlClause.select("year(max(registerDate))").from("Register")
299  .where().equal("closing", true)
300  .and().equal("exclude", false)
301  .and().smallerOrEqual("year(registerDate)", year)
302  .and().equal("view.id", 1L)
303  .dao(new FinancialsPU())
304  .singleResult(Integer.class);
305  }

◆ getRegisters()

Collection<Long> org.turro.financials.account.DiaryReport.getRegisters ( )

Definition at line 156 of file DiaryReport.java.

156  {
157  WhereClause wc = new WhereClause();
158  wc.addClause("select reg.id");
159  wc.addClause("from Register reg");
160  wc.addClause("where reg.view = :view");
161  wc.addNamedValue("view", view);
162  wc.addClause("and year(reg.registerDate) = :year");
163  wc.addNamedValue("year", year);
164  wc.addClause("order by reg.idRegister");
165 
166  Dao dao = new FinancialsPU();
167  return dao.getResultList(wc);
168  }
Here is the call graph for this function:

◆ getSQLRegisters()

WhereClause org.turro.financials.account.DiaryReport.getSQLRegisters ( )

Definition at line 170 of file DiaryReport.java.

170  {
171  WhereClause wc = new WhereClause();
172  wc.addClause("select reg");
173  wc.addClause("from Register reg");
174  wc.addClause("where reg.view = :view");
175  wc.addNamedValue("view", view);
176  wc.addClause("and year(reg.registerDate) = :year");
177  wc.addNamedValue("year", year);
178  wc.addClause("order by reg.idRegister");
179 
180  return wc;
181  }
Here is the call graph for this function:

◆ print()

void org.turro.financials.account.DiaryReport.print ( final String  type)
protected

Reimplemented from org.turro.zkoss.print.ReportMenuitem.

Definition at line 73 of file DiaryReport.java.

73  {
74  if(view == null) {
75  view = ViewWrapper.getFormalView();
76  }
77  year = new CheckDate().getYear();
78  startPage = 1;
79 
80  InputDialog.getInput(
81  Framework.getCurrent().getPage(),
82  I_.get("Diary book"),
83  new InputField[] {
84  new InputField("Year", year, null, 0),
85  new InputField("Start page", startPage, null, 0),
86  new InputField("View", null, null, 0) {
87  @Override
88  protected HtmlBasedComponent createEditor() {
89  ViewListbox vl = new ViewListbox();
90  vl.setMold("select");
91  return vl;
92  }
93  }
94  }, new Command() {
95  @Override
96  public Object execute(Context context) {
97  InputField[] fields = (InputField[]) context.get("fields");
98  if(fields.length > 0) {
99  for(InputField f : fields) {
100  if("Year".equals(f.getLabel())) {
101  year = (Integer) f.getValue();
102  } else if("Start page".equals(f.getLabel())) {
103  startPage = (Integer) f.getValue() - 1;
104  } else if("View".equals(f.getLabel())) {
105  view = (RegisterView) f.getValue();
106  }
107  }
108  if(year != null) {
109  IContact contact = Authentication.getIContact();
110  MailSenders.getHeavy()
111  .addContact(contact)
112  .onStart(s -> MessageQueue.pushMessage(contact, I_.get("Report will be sent by email")))
113  .onCancel(s -> MessageQueue.pushMessage(contact, I_.get("Task already running")))
114  .onBuild(s -> print2execute((IMailSender) s))
115  .send(I_.get("Diary book"), I_.get("Diary book"));
116  }
117  }
118  return null;
119  }
120  });
121  }
Here is the call graph for this function:

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