Design Notes for DB Modules

Accounting Application

Portal Framework


Created by James Pattie, 11/03/2000


Objects Needed: (Portal::Accounting::Objects::)

ReportTypeObject

  new ( id = -1, name, report_class, report_type, column_variable, column_variable_data, date_range, display_dates, max_columns, min_columns, text_font, text_size, data_font, data_size, total_column, fg_color, bg_color, underline_length )


ReportDataObject

  new ( id, index, cell_text, cell_type, item_name, fg_color, bg_color, display_level, initial_state, negative_format, other_attributes )


MemorizedReportDataObject

  new ( id, ledger_code, name, column_type, column_data, dates_entered, fg_color, bg_color, text_size, data_size, text_font, data_font, underline_length, account_format, data_precision, negative_format, total_column, sql_statement, headers, sorted_by, sorted_order, subtotal, subtotal_type )


ReportInfoObject

  new (name, id, editable)


MemorizedReportInfoObject

  new (name, id, ledger_code)


SubAccountTypeObject

  new (num, name)


SubAccountObject

  new (sub_acc_number, sub_acc_name)


AccountTypeObject

  new (name, num, type)


AccountObject

  new (number, name, debit_increases, acct_type)


KnownYearInfoObject

  new ( ledger_code, year, start_date, end_date, q1_start, q1_end, q2_start, q2_end, q3_start, q3_end, q4_start, q4_end )


SubEntityObject

  new (name, code)


ColorObject

  new (fg_color, bg_color)


AccountTypeSubAccountObject

  new ( num, sub_acct_type )


Reporting Module

  rc makeReportTypeEntry(ReportTypeObject)

    sql = "INSERT INTO report_type_tb (name, report_class, report_type, column_variable, column_variable_data, date_range, display_dates, max_columns, min_columns, text_font, text_size, data_font, data_size, total_column, fg_color, bg_color, underline_length, editable) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'true')"


  scalar getReportId(name)

    sql = "SELECT id FROM report_type_tb WHERE name = ?"


  rc updateReportTypeEntry(ReportTypeObject)

    sql = "UPDATE report_type_tb SET name = ?, report_class = ?, report_type = ?, column_variable = ?, column_variable_data = ?, date_range = ?, display_dates = ?, max_columns = ?, min_columns = ?, text_font = ?, text_size = ?, data_font = ?, data_size = ?, total_column = ?, fg_color = ?, bg_color = ?, underline_length = ? WHERE id = ?"


  scalar getReportName(id)

    sql = "SELECT name FROM report_type_tb WHERE id = ?"


  ReportTypeObject getReportTypeInfo(id)

    sql = "SELECT name, report_class, report_type, column_variable, column_variable_data, date_range, display_dates, max_columns, min_columns, text_font, text_size, data_font, data_size, total_column, fg_color, bg_color, underline_length, editable FROM report_type_tb WHERE id = ?"


  ReportInfoObject[] getAllReports(void)

    sql = "SELECT name, id, editable FROM report_type_tb ORDER BY name, id"


  bool deleteReport(id)

    sql = "DELETE FROM report_data_tb WHERE id = ?"

    sql = "DELETE FROM report_type_tb WHERE id = ?"

    sql = "DELETE FROM memorized_report_tb WHERE id = ?" (may not be necessary)


  MemorizedReportInfoObject[] getAllLedgerSpecificMemorizedReports(ledger_code)

    sql = "SELECT name, id FROM memorized_report_tb WHERE ledger_code = ? ORDER BY name, id"


  scalar getRowCountForReport(id)

    sql = "SELECT count(index) FROM report_data_tb WHERE id = ?"


  scalar getCountOfMemorizedReports(id)

    sql = "SELECT count(name) FROM memorized_report_tb WHERE id = ?"


  ReportInfoObject[] getValidReports(id, report_type)

    sql = "SELECT DISTINCT(id), name, editable FROM report_type_tb WHERE report_type = '?' AND id = report_data_tb.id ORDER BY name, id"

      report_type = (r,d)


  ReportDataObject[] getReportData(id)

    sql = "SELECT index, cell_text, cell_type, item_name, fg_color, bg_color, display_level, initial_state, negative_format, other_attributes FROM report_data_tb WHERE id = ? ORDER BY index"


  bool CreateReportDataEntries(ReportDataObject[])

    sql = "INSERT INTO report_data_tb (id, index, cell_text, cell_type, item_name, fg_color, bg_color, display_level, initial_state, negative_format, other_attributes) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"


  MemorizedReportDataObject getMemorizedReportData(id, ledger_code, name)

    sql = "SELECT column_type, column_data, dates_entered, fg_color, bg_color, text_size, data_size, text_font, data_font, underline_length, account_format, data_precision, negative_format, total_column, sql_statement, headers, sorted_by, sorted_order, subtotal, subtotal_type FROM memorized_report_tb WHERE ledger_code = ? AND id = ? AND name = ?"


  bool makeTempFileEntry(fname)

    sql = "INSERT INTO temp_file_tb (timeof, fname) VALUES (now(), ?)"


  bool deleteMemorizedReport(id, ledger_code, name)

    sql = "DELETE FROM memorized_report_tb WHERE id = ? AND ledger_code = ? AND name = ?"


  bool memorizeReport(MemorizedReportDataObject)

    sql = "INSERT INTO memorized_report_tb (id, name, column_type, column_data, dates_entered, fg_color, bg_color, text_size, text_font, data_size, data_font, underline_length, ledger_code, account_format, data_precision, negative_format, total_column, sql_statement, headers, sorted_by, sorted_order, subtotal, subtotal_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"


  scalar getMemorizedReportId(ledger_code, name)

    sql = "SELECT id FROM memorized_report_tb WHERE name = ? AND ledger_code = ?"


  MemorizedReportInfoObject[] getAllMemorizedReports(void)

    sql = "SELECT name, id, ledger_code FROM memorized_report_tb ORDER BY ledger_code, name, id"


  bool doesMemorizedReportExist(id, name, ledger_code)

    sql = "SELECT name FROM memorized_report_tb WHERE id = ? AND name = ? AND ledger_code = ?"


  bool isReportEditable(id)

    sql = "SELECT editable FROM report_type_tb WHERE id = ?"


  ColorObject getDefaultReportColors(id)

    sql = "SELECT fg_color, bg_color FROM report_type_tb WHERE id = ?"


  scalar getTypeOfReport(id)

    sql = "SELECT report_type FROM report_type_tb WHERE id = ?"


  


Configuration Module

sql phrase 1054, 1068, 1069, 1070, 1073-1123 not processed yet.


  SubAccountTypeObject[] getSubAccountTypes(void)

    sql = "SELECT num, name FROM sub_acct_type_tb ORDER BY num"


  SubAccountObject[] getSubAccountsOfType(type)

    sql = "SELECT sub_acc_number, sub_acc_name FROM sub_acc_tb WHERE type = ? ORDER BY sub_acc_number"


  scalar getEntityName(database_name)

    sql = "SELECT name FROM entity_tb WHERE database_name = ?"


  scalar getLedgerCode(name)

    sql = "SELECT code FROM ledger_tb WHERE name = ?"


  scalar getLedgerColor(code)

    sql = "SELECT color FROM ledger_tb WHERE code = ?"


  AccountTypeObject[] getAccountTypes()

    sql = "SELECT name, num FROM acct_type_tb ORDER BY name, num"


  KnownYearInfoObject[] getKnownYears(ledger_code)

    sql = "SELECT year, start_date, end_date, q1_start, q1_end, q2_start, q2_end, q3_start, q3_end, q4_start, q4_end FROM known_years_tb WHERE ledger_code = ? ORDER BY year"


  SubEntityObject[] getSubEntities(ledger_code)

    sql = "SELECT name, code FROM sub_entity_tb WHERE ledger_code = ?"


  scalar getSubAccountName(sub_acc_number)

    sql = "SELECT sub_acc_name FROM sub_acc_tb WHERE sub_acc_number = ?"


  scalar getSubAccountTypeName(num)

    sql = "SELECT name FROM sub_acct_type_tb WHERE num = ?"


  scalar getAccountTypeName(num)

    sql = "SELECT debit_increases FROM acct_type_tb WHERE num = ?"


  bool getDebitIncreasesFlag(num)

    sql = "SELECT debit_increases FROM acct_type_tb WHERE num = ?"


  array of numbers getAccountsOfType(type)

    sql = "SELECT number FROM account_tb WHERE type = ? ORDER BY number"


  AccountObject getLocalAccounts(AccountTypeObject[], taxable (0,1,2), ledger_code)

    sql = "SELECT acct_num FROM local_accounts_tb WHERE ledger_code = ? AND taxable = true AND sub_entity_code IS NULL AND acct_num IN (##?##) ORDER BY acct_num" (##?## is replaced by the list of Account Type numbers passed in)

    sql = "SELECT acct_num FROM local_accounts_tb WHERE ledger_code = ? AND taxable = false AND sub_entity_code IS NULL AND acct_num IN (##?##) ORDER BY acct_num" (##?## is replaced by the list of Account Type numbers passed in)

    sql = "SELECT acct_num FROM local_accounts_tb WHERE ledger_code = ? AND sub_entity_code IS NULL AND acct_num IN (##?##) ORDER BY acct_num" (##?## is replaced by the list of Account Type numbers passed in)


  scalar getAccountName(number)

    sql = "SELECT name FROM account_tb WHERE number = ?"


  AccountTypeObject[] getAccountTypes(first_digit)

    sql = "SELECT num FROM acct_type_tb ##?## ORDER BY num" (if first_digit not given, then ##?## is removed, else substituted for)


  array of numbers getReportDisplayLevels(id)

    sql = "SELECT DISTINCT(display_level) FROM report_data_tb WHERE id = ? ORDER BY display_level"


  scalar getSubAccountType(num)

    sql = "SELECT sub_acct_type FROM acct_type_tb WHERE num = ?"


  AccountObject getAccountType(number)

    sql = "SELECT account_tb.type, acct_type_tb.debit_increases FROM account_tb, acct_type_tb WHERE account_tb.number = ? AND acct_type_tb.num = account_tb.type" (do we lookup the name or just set it to an empty value?)


  scalar getTypeOfSubAccount(sub_acc_number)

    sql = "SELECT type FROM sub_acc_tb WHERE sub_acc_number = ?"


  AccountTypeSubAccountObject getAccountTypeSubAccountPairs(void)

    sql = "SELECT num, sub_acct_type FROM acct_type_tb"


  void setDateStyle(style)

    sql = "SET datestyle TO ?" (style defaults to 'POSTGRES,US')


  scalar getSubEntityName(code, ledger_code)

    sql = "SELECT name FROM sub_entity_tb WHERE ledger_code = ? AND code = ?"


  scalar getLedgerName(code, ledger_code)

    sql = "SELECT name FROM journal_tb WHERE ledger_code = ? AND code = ?"


  scalar getWorkingYear(ledger_code)

    sql = "SELECT working_year FROM variables_tb WHERE ledger_code = ?"


  


Transaction Module


sql phrase 1050, 1052, 1053, 1061, 1062, 1063 not processed yet.


  scalar getLastBalanceDate(bal_date, ledger_code)

    sql = "SELECT max(bal_date) FROM acct_bal_tb WHERE ledger_code = ? and bal_date <= ?"


  



Copyright (c) 2001 HLR
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1; A copy of the license is available at http://www.gnu.org/licenses/licenses.html#FDL.

Updated: $Id: Modules.html,v 1.1.1.1 2001/08/09 19:03:00 moreejt Exp $