finance.sql 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. create table `voucher_ep`
  2. (
  3. id int unsigned primary key not null auto_increment,
  4. company_id int unsigned not null,
  5. content text not null comment '摘要内容',
  6. creator_id int unsigned,
  7. creator_name varchar(100),
  8. create_time datetime,
  9. updater_id int unsigned,
  10. updater_name varchar(100),
  11. update_time datetime
  12. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='凭证摘要';
  13. create table `voucher_tpl_type`
  14. (
  15. id int unsigned primary key not null auto_increment,
  16. company_id int unsigned not null,
  17. name varchar(255) not null comment '类别名称',
  18. creator_id int unsigned,
  19. creator_name varchar(100),
  20. create_time datetime,
  21. updater_id int unsigned,
  22. updater_name varchar(100),
  23. update_time datetime
  24. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='凭证模板类别';
  25. create table `voucher_tpl`
  26. (
  27. id int unsigned primary key not null auto_increment,
  28. company_id int unsigned not null,
  29. type_id int unsigned not null comment '类别',
  30. name varchar(255) not null comment '模板名称',
  31. enabled boolean default true comment '是否启用',
  32. creator_id int unsigned,
  33. creator_name varchar(100),
  34. create_time datetime,
  35. updater_id int unsigned,
  36. updater_name varchar(100),
  37. update_time datetime
  38. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='凭证模板';
  39. create table `voucher_tpl_item`
  40. (
  41. id int unsigned primary key not null auto_increment,
  42. company_id int unsigned not null,
  43. tpl_id int unsigned not null comment '模板ID',
  44. vd_detno int comment '序号',
  45. vd_explanation varchar(255) comment '摘要',
  46. vd_catecode varchar(30) comment '科目号',
  47. vd_currency varchar(30) comment '币别',
  48. vd_debit double comment '借方金额',
  49. vd_credit double comment '贷方金额',
  50. vd_flowcode varchar(30) comment '现金流量项目',
  51. creator_id int unsigned,
  52. creator_name varchar(100),
  53. create_time datetime,
  54. updater_id int unsigned,
  55. updater_name varchar(100),
  56. update_time datetime
  57. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='凭证模板分录';
  58. create table `voucher_tpl_ass`
  59. (
  60. id int unsigned primary key not null auto_increment,
  61. company_id int unsigned not null,
  62. tpl_id int unsigned not null comment '模板ID',
  63. item_id int unsigned not null comment '分录ID',
  64. vds_asstype varchar(30),
  65. vds_assid int,
  66. vds_asscode varchar(50),
  67. vds_assname varchar(255)
  68. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='凭证模板辅助核算';
  69. create table `voucher_mark`
  70. (
  71. id int unsigned primary key not null auto_increment,
  72. company_id int unsigned not null,
  73. order_num int unsigned not null comment '顺序',
  74. name varchar(50) not null comment '凭证字',
  75. print_title varchar(255) comment '打印标题',
  76. default_use boolean comment '是否默认',
  77. creator_id int unsigned,
  78. creator_name varchar(100),
  79. create_time datetime,
  80. updater_id int unsigned,
  81. updater_name varchar(100),
  82. update_time datetime
  83. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='凭证字';
  84. create table `fin_report_item`
  85. (
  86. report_type varchar(30) not null comment '报表类型balance, income, cashflow',
  87. item_code varchar(30) not null comment '报表项目编号',
  88. item_name varchar(255) comment '报表项目名称',
  89. item_type int default 0 comment '项目计算类型, 0 - 不计算, 1 - 取rule表数据, 2 - 按formula计算',
  90. order_num int comment '显示顺序',
  91. rownum int comment '行次',
  92. formula varchar(255) comment '计算公式'
  93. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='财务报表';
  94. create table `fin_report_rule`
  95. (
  96. id int unsigned primary key not null auto_increment,
  97. company_id int unsigned not null,
  98. report_type varchar(30),
  99. item_code varchar(30),
  100. ca_id int unsigned not null,
  101. symbol char(1) comment '运算符号+/-',
  102. rule int comment '取数规则, 1 - 余额, 2 - 借方余额, 3 - 贷方余额, 4 - 科目借方余额, 5 - 科目贷方余额'
  103. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='财务报表取数规则';
  104. create table `fin_cashflow_item`
  105. (
  106. cl_itemcode varchar(30) comment '现金流量项目编号',
  107. cl_itemname varchar(255) comment '现金流量项目名称',
  108. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='现金流量项目';
  109. create table `fin_cashflow_ledger`
  110. (
  111. id int unsigned primary key not null auto_increment,
  112. company_id int unsigned not null,
  113. cl_yearmonth int comment '期间',
  114. cl_itemcode varchar(30) comment '现金流量项目编号',
  115. cl_itemname varchar(255) comment '现金流量项目名称',
  116. cl_begin double comment '期初余额',
  117. cl_this double comment '本期发生',
  118. cl_end double comment '期末余额',
  119. cl_accum double comment '本年累计'
  120. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='现金流量余额';
  121. create table `fin_profit_ledger`
  122. (
  123. id int unsigned primary key not null auto_increment,
  124. company_id int unsigned not null,
  125. pl_yearmonth int comment '期间',
  126. pl_cacode varchar(30) comment '科目编号',
  127. pl_caname varchar(255) comment '科目名称',
  128. pl_caid int comment '科目ID',
  129. pl_begin double comment '上期发生',
  130. pl_this double comment '本期发生',
  131. pl_balancetype varchar(10) comment '方向',
  132. pl_accum double comment '本年累计'
  133. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='损益发生';
  134. create table `fin_report_data`
  135. (
  136. company_id int unsigned not null,
  137. report_type varchar(30) not null comment '报表类型balance, income, cashflow',
  138. period int comment '期间',
  139. order_num int comment '顺序',
  140. itemcode_0 varchar(30) not null comment '报表项目编号',
  141. itemname_0 varchar(255) comment '报表项目名称',
  142. itemtype_0 int default 0 comment '项目计算类型, 0 - 不计算, 1 - 取rule表数据, 2 - 按formula计算',
  143. rownum_0 int comment '行次',
  144. formula_0 varchar(255) comment '计算公式',
  145. balance_0 double comment '金额',
  146. prebalance_0 double comment '金额',
  147. itemcode_1 varchar(30) comment '报表项目编号',
  148. itemname_1 varchar(255) comment '报表项目名称',
  149. itemtype_1 int default 0 comment '项目计算类型, 0 - 不计算, 1 - 取rule表数据, 2 - 按formula计算',
  150. rownum_1 int comment '行次',
  151. formula_1 varchar(255) comment '计算公式',
  152. balance_1 double comment '金额',
  153. prebalance_1 double comment '金额'
  154. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='财务报表历史数据';