text: # table definition
  table = {
      'table_name'    : 'ar_uea_bf',
      'module_id'     : 'ar',
      'short_descr'   : 'Ar cust unearned b/f',
      'long_descr'    : 'Ar customer unearned balance b/f',
      'sub_types'     : None,
      'sub_trans'     : None,
      'sequence'      : None,
      'tree_params'   : None,
      'roll_params'   : None,
      'indexes'       : None,
      'ledger_col'    : 'cust_row_id>ledger_row_id',
      'defn_company'  : None,
      'data_company'  : None,
      'read_only'     : False,
      }
  
  # column definitions
  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'   : 'cust_row_id',
      'data_type'  : 'INT',
      'short_descr': 'Customer row id',
      'long_descr' : 'Customer row id',
      'col_head'   : 'Customer',
      'key_field'  : 'A',
      'data_source': 'input',
      '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'       : [
          'ar_customers', 'row_id', 'ledger_id, cust_id, location_id, function_id',
          'ledger_id, cust_id, location_id, function_id', False, None
          ],
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'tran_number',
      'data_type'  : 'TEXT',
      'short_descr': 'Transaction number',
      'long_descr' : 'Transaction number',
      'col_head'   : 'Tran no',
      'key_field'  : 'A',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': False,
      'max_len'    : 15,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : None,
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'tran_date',
      'data_type'  : 'DTE',
      'short_descr': 'Balance date',
      'long_descr' : 'Balance date',
      'col_head'   : 'Date',
      'key_field'  : 'N',
      'data_source': 'input',
      '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' : [
          ['per_date', 'Must be prior to start', [
              ['check', '', '$value', 'pyfunc', 'custom.date_funcs.check_bf_date', ''],
              ]],
          ],
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'text',
      'data_type'  : 'TEXT',
      'short_descr': 'Text',
      'long_descr' : 'Line of text to appear on reports',
      'col_head'   : 'Text',
      'key_field'  : 'N',
      'data_source': 'input',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': False,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : 'B/fwd',
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'tran_exch_rate',
      'data_type'  : 'DEC',
      'short_descr': 'Transaction exchange rate',
      'long_descr' : 'Exchange rate from transaction currency to local',
      'col_head'   : 'Rate tran',
      'key_field'  : 'N',
      'data_source': 'calc',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': False,
      'max_len'    : 0,
      'db_scale'   : 8,
      'scale_ptr'  : None,
      'dflt_val'   : None,
      'dflt_rule'  : (
          '<case>'
              '<compare test="[[`if`, ``, `cust_row_id>currency_id`, `=`, `_param.local_curr_id`, ``]]">'
                  '<literal value="1"/>'
              '</compare>'
              '<default>'
                  '<exch_rate>'
                      '<fld_val name="cust_row_id>currency_id"/>'
                      '<fld_val name="tran_date"/>'
                  '</exch_rate>'
              '</default>'
          '</case>'
          ),
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  cols.append ({
      'col_name'   : 'posted',
      'data_type'  : 'BOOL',
      'short_descr': 'Posted?',
      'long_descr' : 'Has transaction been posted?',
      'col_head'   : 'Posted?',
      'key_field'  : 'N',
      'data_source': 'prog',
      'condition'  : None,
      'allow_null' : False,
      'allow_amend': False,
      'max_len'    : 0,
      'db_scale'   : 0,
      'scale_ptr'  : None,
      'dflt_val'   : 'false',
      'dflt_rule'  : None,
      'col_checks' : None,
      'fkey'       : None,
      'choices'    : None,
      })
  
  # virtual column definitions
  virt = []
  virt.append ({
      'col_name'   : 'module_id',
      'data_type'  : 'TEXT',
      'short_descr': 'Module id',
      'long_descr' : 'Module id',
      'col_head'   : 'Module',
      'sql'        : "'ar'",
      })
  virt.append ({
      'col_name'   : 'tran_type',
      'data_type'  : 'TEXT',
      'short_descr': 'Transaction type',
      'long_descr' : 'Transaction type',
      'col_head'   : 'Tran type',
      'sql'        : "'ar_uea_bf'",
      })
  virt.append ({
      'col_name'   : 'trantype_row_id',
      'data_type'  : 'INT',
      'short_descr': 'Tran type row id',
      'long_descr' : 'Tran type row id',
      'col_head'   : 'Tran type row id',
      'sql'        : "SELECT row_id FROM {company}.adm_tran_types WHERE tran_type = 'ar_uea_bf'",
      })
  virt.append ({
      'col_name'   : 'ledger_row_id',
      'data_type'  : 'INT',
      'short_descr': 'Ledger row id',
      'long_descr' : 'Ledger row id',
      'col_head'   : 'Ledger',
      'sql'        : 'a.cust_row_id>ledger_row_id',
      })
  virt.append ({
      'col_name'   : 'location_row_id',
      'data_type'  : 'INT',
      'short_descr': 'Location row id',
      'long_descr' : 'Location row id',
      'col_head'   : 'Location',
      'sql'        : 'a.cust_row_id>location_row_id',
      })
  virt.append ({
      'col_name'   : 'function_row_id',
      'data_type'  : 'INT',
      'short_descr': 'Function row id',
      'long_descr' : 'Function row id',
      'col_head'   : 'Function',
      'sql'        : 'a.cust_row_id>function_row_id',
      })
  virt.append ({
      'col_name'   : 'rev_sign_sls',
      'data_type'  : 'BOOL',
      'short_descr': 'Reverse sign?',
      'long_descr' : 'Reverse sign - sales transactions?',
      'col_head'   : 'Reverse sign?',
      'sql'        : '$False',
      })
  virt.append ({
      'col_name'   : 'currency_id',
      'data_type'  : 'INT',
      'short_descr': 'Transaction currency',
      'long_descr' : 'Currency used to enter transaction',
      'col_head'   : 'Currency',
      'sql'        : 'a.cust_row_id>currency_id',
      })
  
  # cursor definitions
  cursors = []
  
  # actions
  actions = []
  