weaver-hrm-salary/resource/sqlupgrade/Mysql/sql202308160103.sql

22 lines
961 B
SQL

create table hrsa_acct_tax_agent
(
id bigint primary key comment 'ID' ,
create_time datetime comment '创建时间' ,
update_time datetime comment '修改时间' ,
creator bigint comment '创建人id' ,
delete_type int default 0 comment '是否删除' ,
tenant_key varchar(10) comment '租户KEY' ,
salary_acct_record_id bigint comment '薪资核算记录的id' ,
tax_agent_id bigint comment '个税扣缴义务人的id' ,
salary_month datetime comment '薪资所属月' ,
tax_cycle datetime comment '税款所属期' ,
income_category varchar(100)
)
;
insert into hrsa_acct_tax_agent(id, create_time, update_time, creator, tenant_key, salary_acct_record_id, tax_agent_id, salary_month, tax_cycle)
select id, create_time, update_time, creator, tenant_key, salary_acct_record_id, tax_agent_id, salary_month, tax_cycle
from hrsa_salary_acct_emp
where delete_type = 0
and id in (select max(id) from hrsa_salary_acct_emp group by salary_acct_record_id, tax_agent_id, tax_cycle)
;