# 工资数据报表

```` 
select e.lastname,sob.name as 账套名, record.salary_month as 薪资月, item.name as 薪资项 ,result.result_value as 值
from hrsa_salary_acct_record record 
left join hrsa_salary_sob sob  on record.salary_sob_id = sob.id and sob.delete_type = 0  and record.delete_type = 0 
left join hrsa_salary_acct_result result on record.id = result.salary_acct_record_id and result.delete_type = 0  and record.delete_type = 0 
left join hrsa_salary_item item on result.salary_item_id = item.id and item.delete_type = 0 
left join hrsa_tax_agent agent on agent.id=sob.tax_agent_id and agent.delete_type=0 
left join hrmresource e on e.id= result.employee_id


select e.lastname, record.salary_month as 薪资月, item.name as 薪资项 ,result.result_value as 值
from hrsa_salary_acct_record record 
left join hrsa_salary_acct_result result on record.id = result.salary_acct_record_id and result.delete_type = 0  and record.delete_type = 0 
left join hrsa_salary_item item on result.salary_item_id = item.id and item.delete_type = 0 
left join hrmresource e on e.id= result.employee_id
where item.name = '工资薪金合计'


# 获取档案信息

select i.item_value from hrsa_salary_archive_item i 
left join hrsa_salary_archive a on a.id = i.salary_archive_id 
left join hrsa_salary_item c on c.id=i.salary_item_id 
left join hrsa_tax_agent t on a.tax_agent_id=t.id  
where a.delete_type=0 and i.delete_type=0 and t.delete_type=0   and c.delete_type=0 
and a.employee_id=人员id and t.name=扣缴义务人名称
 and c.name='基本工资' order by effective_time desc


# 删除系统项目
UPDATE set hrsa_sys_salary_item  where delete_type =3 where delete_type =0;

update hrsa_salary_sob_default_item set delete_type =3 where delete_type =0;


update hrsa_salary_sob_item set delete_type= 3 where delete_type =0 and salary_item_id in (select id from hrsa_salary_item  where delete_type=0 and system_type=1 and use_in_employee_salary =0 and code not in('ressueTotal','issuedTotal')
);

UPDATE hrsa_salary_item set delete_type = 3 where delete_type=0 and system_type=1 and use_in_employee_salary =0 and code not in('ressueTotal','issuedTotal');


# 开启系统算税
update hrsa_salary_sys_conf set conf_value = '1' where conf_key = 'taxDeclarationFunction'

