text: # table definition
  table = {
      'table_name'    : 'sys_finrpt_defns',
      'module_id'     : 'sys',
      'short_descr'   : 'Financial report definitions',
      'long_descr'    : 'Financial report definitions - filter by module',
      'sub_types'     : None,
      'sub_trans'     : None,
      'sequence'      : None,
      'tree_params'   : None,
      'roll_params'   : None,
      'indexes'       : None,
      'ledger_col'    : None,
      'defn_company'  : None,
      'data_company'  : None,
      'read_only'     : False,
      }
  
  # column definition
  cols = []
  cols.append ({
      'col_name'   : 'row_id',
      'data_type'  : 'AUTO',
      'short_descr': 'Row id',
      'long_descr' : 'Row id',
      'col_head'   : 'Row',
      'key_field'  : 'Y',
      'data_source': 'gen',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': False,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : None,
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'created_id',
      'data_type'  : 'INT',
      'short_descr': 'Created id',
      'long_descr' : 'Created row id',
      'col_head'   : 'Created',
      'key_field'  : 'N',
      'data_source': 'gen',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': False,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : '0',
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'deleted_id',
      'data_type'  : 'INT',
      'short_descr': 'Deleted id',
      'long_descr' : 'Deleted row id',
      'col_head'   : 'Deleted',
      'key_field'  : 'N',
      'data_source': 'gen',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': False,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : '0',
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'module_row_id',
      'data_type'  : 'INT',
      'short_descr': 'Module row id',
      'long_descr' : 'Module row id',
      'col_head'   : 'Module',
      'key_field'  : 'A',
      'data_source': 'ctx',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': False,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : '{_ctx.module_row_id}',
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : ['db_modules', 'row_id', 'module_id', 'module_id', False, None],
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'report_name',
      'data_type'  : 'TEXT',
      'short_descr': 'Report name',
      'long_descr' : 'Report name',
      'col_head'   : 'Report',
      'key_field'  : 'A',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': False,
      'max_len'    : 20,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : None,
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'descr',
      'data_type'  : 'TEXT',
      'short_descr': 'Description',
      'long_descr' : 'Description',
      'col_head'   : 'Description',
      'key_field'  : 'N',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': True,
      'max_len'    : 36,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : None,
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'table_name',
      'data_type'  : 'TEXT',
      'short_descr': 'Table name',
      'long_descr' : 'Table name',
      'col_head'   : 'Table',
      'key_field'  : 'N',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : True,
      'allow_amend': True,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : None,
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'report_type',
      'data_type'  : 'TEXT',
      'short_descr': 'Report type',
      'long_descr' : 'Report type - as_at, from_to, bf_cf',
      'col_head'   : 'Type',
      'key_field'  : 'N',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': True,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : None,
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : [
              ['as_at', 'Balance at date'],
              ['from_to', 'From_date to_date'],
              ['bf_cf', 'B/f, mvmt, c/f'],
          ],
      })
  cols.append ({
      'col_name'   : 'group_params',
      'data_type'  : 'JSON',
      'short_descr': 'Group parameters',
      'long_descr' : 'Group parameters - outer=code/loc/fun/src/date, inner=[group name, filter] or [date params]',
      'col_head'   : 'Groups',
      'key_field'  : 'N',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : True,
      'allow_amend': True,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : None,
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'columns',
      'data_type'  : 'JSON',
      'short_descr': 'Column definitions',
      'long_descr' : 'Column definitions - col_name, sql, col_head, data_type, lng, pvt',
      'col_head'   : 'Columns',
      'key_field'  : 'N',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : True,
      'allow_amend': True,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : None,
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'calc_cols',
      'data_type'  : 'JSON',
      'short_descr': 'Calculated columns',
      'long_descr' : 'Calculated column definitions - col_name, sql, col_head, data_type, lng',
      'col_head'   : 'Calc cols',
      'key_field'  : 'N',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : True,
      'allow_amend': True,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : None,
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'include_zeros',
      'data_type'  : 'BOOL',
      'short_descr': 'Include zeros?',
      'long_descr' : 'Include zeros? Applies to gl_codes, locations, functions',
      'col_head'   : 'Incl zero?',
      'key_field'  : 'N',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': True,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : 'false',
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'expand_subledg',
      'data_type'  : 'BOOL',
      'short_descr': 'Expand subledgers?',
      'long_descr' : 'If ctrl a/c for nsls/npch, expand to subledger?',
      'col_head'   : 'Expand?',
      'key_field'  : 'N',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': True,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : 'false',
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'allow_select_loc_fun',
      'data_type'  : 'BOOL',
      'short_descr': 'Allow selection of loc/fun?',
      'long_descr' : 'Allow runtime selection of single location or function?',
      'col_head'   : 'Single?',
      'key_field'  : 'N',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': True,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : 'false',
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'pivot_on',
      'data_type'  : 'JSON',
      'short_descr': 'Pivot on',
      'long_descr' : 'Pivot on. 2-part tuple. 1: dim to pivot on. 2: group name if select all, else None.',
      'col_head'   : 'Pivot',
      'key_field'  : 'N',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : True,
      'allow_amend': True,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : None,
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'cashflow_params',
      'data_type'  : 'TEXT',
      'short_descr': 'Cash flow params',
      'long_descr' : 'Cash flow params - None, $all, or cashbook_id',
      'col_head'   : 'Cash flow',
      'key_field'  : 'N',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : True,
      'allow_amend': True,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : None,
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  
  # virtual column definitions
  virt = []
  
  # cursor definitions
  cursors = []
  
  cursors.append({
      'cursor_name': 'finrpt_setup',
      'title': 'Maintain fin rpt defns',
      'columns': [
          ['report_name', 160, False, False],
          ['descr', 300, True, False],
          ],
      'filter': [
          ['WHERE', '', 'module_row_id', '=', '_ctx.module_row_id', ''],
          ],
      'sequence': [['report_name', False]],
      'formview_name': 'finrpt_setup',
      })
  
  cursors.append({
      'cursor_name': 'finrpt_list',
      'title': 'Display fin rpt defns',
      'columns': [
          ['report_name', 160, False, False],
          ['descr', 300, True, False],
          ],
      'filter': [
          ['WHERE', '', 'module_row_id', '=', '_ctx.module_row_id', ''],
          ],
      'sequence': [['report_name', False]],
      'formview_name': 'finrpt_run',
      })
  
  # actions
  actions = []
  