@Wahson
2019-11-10T11:01:39.000000Z
字数 1447
阅读 505
wanbo
use payment_db;
create table invoice
(
id bigint auto_increment primary key,
invoice_no varchar(12) not null comment '发票号码',
type smallint(2) not null comment '发票类型invoiceType, 1:专用发票(special)',
type_code varchar(12) not null comment '类别代码',
class smallint(2) not null comment '发票种类,1:进项发票(input_invoice);2:销项发票(output_invoice)',
company_id bigint not null comment '公司id',
company_name varchar(100) not null comment '公司名称',
amount decimal(13, 2) not null comment '开票金额',
amount_with_tax decimal(13, 2) not null comment '含税金额',
attachment_id bigint not null comment '发票附件id',
invoice_by int(5) null comment '开票人,进项发票时为null',
invoice_at datetime null comment '开票时间,进项发票时为null',
created_at timestamp default current_timestamp() not null,
created_by int default 0 not null,
updated_at timestamp default current_timestamp() not null on update current_timestamp(),
updated_by int default 0 not null,
remark varchar(128) null
) comment '发票' charset = utf8mb4 engine = innoDb;
create table invoice_detail
(
id bigint auto_increment primary key,
invoice_id bigint not null comment 'invoice.id',
related_item_id bigint not null comment '关联子单id',
weight decimal(8, 3) not null comment '开票数量',
tax_rate decimal(5, 4) not null comment '税率',
amount decimal(13, 2) not null comment '开票金额',
created_at timestamp default current_timestamp() not null,
created_by int default 0 not null,
updated_at timestamp default current_timestamp() not null on update current_timestamp(),
updated_by int default 0 not null,
remark varchar(128) null,
key ind_invoice(invoice_id),
key idx_related_item(related_item_id)
) comment '发票详情' charset = utf8mb4 engine = innoDb;