udpate 统计视图sql 项目增加确认收入状态,税额,未税金额
This commit is contained in:
+146
-24
@@ -20,30 +20,36 @@ select pp.id as projectId,
|
||||
type,
|
||||
if(billMoney is null, 0, billMoney) as billMoney,
|
||||
confirmAmount,
|
||||
invoiceNoTaxAmount,
|
||||
paidNoTaxAmount,
|
||||
confirmNoTaxAmount,
|
||||
contactsName,
|
||||
pp.pack
|
||||
from (SELECT pwgs.id,
|
||||
pwg.id as superId,
|
||||
pwg.working_group_project AS projectName,
|
||||
pwg.principal_name_a as principalName,
|
||||
pwgs.charge_company_id AS chargeCompanyId,
|
||||
pwgs.charge_company_temporary_id as chargeCompanyTemporaryId,
|
||||
pwgs.charge_company_temporary_name AS chargeCompanyTemporaryName,
|
||||
pwgs.receivable_amount as allMoney,
|
||||
pwgs.paid_amount as comeAllMoney,
|
||||
pwgs.charge_use as chargeUse,
|
||||
sd.depart_name as depart,
|
||||
pwgs.pack as pack,
|
||||
pwg.year as year,
|
||||
pwgs.in_account as payStatue,
|
||||
su.org_code as departCode,
|
||||
sd.id as departId,
|
||||
pwg.principal_id_a as principalNameId,
|
||||
2 as type,
|
||||
pwgs.invoice_amount AS billMoney,
|
||||
confirm_amount as confirmAmount,
|
||||
pwg.id as superId,
|
||||
pwg.working_group_project AS projectName,
|
||||
pwg.principal_name_a as principalName,
|
||||
pwgs.charge_company_id AS chargeCompanyId,
|
||||
pwgs.charge_company_temporary_id as chargeCompanyTemporaryId,
|
||||
pwgs.charge_company_temporary_name AS chargeCompanyTemporaryName,
|
||||
pwgs.receivable_amount as allMoney,
|
||||
pwgs.paid_amount as comeAllMoney,
|
||||
pwgs.charge_use as chargeUse,
|
||||
sd.depart_name as depart,
|
||||
pwgs.pack as pack,
|
||||
pwg.year as year,
|
||||
pwgs.in_account as payStatue,
|
||||
su.org_code as departCode,
|
||||
sd.id as departId,
|
||||
pwg.principal_id_a as principalNameId,
|
||||
2 as type,
|
||||
pwgs.invoice_amount AS billMoney,
|
||||
confirm_amount as confirmAmount,
|
||||
invoice_no_tax_amount as invoiceNoTaxAmount,
|
||||
paid_no_tax_amount as paidNoTaxAmount,
|
||||
confirm_no_tax_amount as confirmNoTaxAmount,
|
||||
GROUP_CONCAT(pwgsc.contacts_temporary_name order by pwgsc.contacts_temporary_name) as contactsName,
|
||||
pwgs.create_time as createTime
|
||||
pwgs.create_time as createTime
|
||||
FROM pay_working_group pwg
|
||||
right join pay_working_group_subitem pwgs on (pwg.id = pwgs.working_group_id)
|
||||
left JOIN sys_user su on (pwg.principal_id_a = su.id)
|
||||
@@ -71,6 +77,9 @@ from (SELECT pwgs.id,
|
||||
1 as type,
|
||||
pcp.invoice_amount AS billMoney,
|
||||
confirm_amount as confirmAmount,
|
||||
invoice_no_tax_amount as invoiceNoTaxAmount,
|
||||
paid_no_tax_amount as paidNoTaxAmount,
|
||||
confirm_no_tax_amount as confirmNoTaxAmount,
|
||||
contacts_temporary_name as contactsName,
|
||||
pcp.create_time as createTime
|
||||
FROM pay_common_project pcp
|
||||
@@ -97,6 +106,9 @@ from (SELECT pwgs.id,
|
||||
4 as type,
|
||||
pmps.invoice_amount AS billMoney,
|
||||
confirm_amount as confirmAmount,
|
||||
invoice_no_tax_amount as invoiceNoTaxAmount,
|
||||
paid_no_tax_amount as paidNoTaxAmount,
|
||||
confirm_no_tax_amount as confirmNoTaxAmount,
|
||||
company_contact_name as contactsName,
|
||||
pmps.create_time as createTime
|
||||
FROM pay_member_project pmp
|
||||
@@ -124,6 +136,9 @@ from (SELECT pwgs.id,
|
||||
3 as type,
|
||||
pms.invoice_amount AS billMoney,
|
||||
confirm_amount as confirmAmount,
|
||||
invoice_no_tax_amount as invoiceNoTaxAmount,
|
||||
paid_no_tax_amount as paidNoTaxAmount,
|
||||
confirm_no_tax_amount as confirmNoTaxAmount,
|
||||
company_contact_name as contactsName,
|
||||
pms.create_time as createTime
|
||||
FROM pay_meeting pm
|
||||
@@ -151,6 +166,9 @@ from (SELECT pwgs.id,
|
||||
5 as type,
|
||||
tmps.invoice_amount AS billMoney,
|
||||
confirm_amount as confirmAmount,
|
||||
invoice_no_tax_amount as invoiceNoTaxAmount,
|
||||
paid_no_tax_amount as paidNoTaxAmount,
|
||||
confirm_no_tax_amount as confirmNoTaxAmount,
|
||||
liaison_man as contactsName,
|
||||
tmps.create_time as createTime
|
||||
FROM tb_member_project tmp
|
||||
@@ -178,6 +196,9 @@ from (SELECT pwgs.id,
|
||||
6 as type,
|
||||
tcp.invoice_amount AS billMoney,
|
||||
confirm_amount as confirmAmount,
|
||||
invoice_no_tax_amount as invoiceNoTaxAmount,
|
||||
paid_no_tax_amount as paidNoTaxAmount,
|
||||
confirm_no_tax_amount as confirmNoTaxAmount,
|
||||
liaison_man as contactsName,
|
||||
tcp.create_time as createTime
|
||||
FROM tb_member_project tmp
|
||||
@@ -217,14 +238,63 @@ alter table tb_certificate_payment
|
||||
add column confirm_amount decimal(12, 2) default 0 null comment '确认金额';
|
||||
-- 新增税额和未税金额
|
||||
alter table pay_payment_record
|
||||
add column tax decimal(12, 2) default 0 comment '税额',
|
||||
add column tax decimal(12, 2) default 0 comment '税额',
|
||||
add column no_tax_amount decimal(12, 2) default 0 comment '未税金额';
|
||||
alter table pay_mail_bill
|
||||
add column tax decimal(12, 2) default 0 comment '税额',
|
||||
add column tax decimal(12, 2) default 0 comment '税额',
|
||||
add column no_tax_amount decimal(12, 2) default 0 comment '未税金额';
|
||||
alter table pay_confirm_payment_record
|
||||
add column tax decimal(12, 2) default 0 comment '税额',
|
||||
add column tax decimal(12, 2) default 0 comment '税额',
|
||||
add column no_tax_amount decimal(12, 2) default 0 comment '未税金额';
|
||||
-- 项目增加确认收入状态,税额,未税金额
|
||||
alter table pay_common_project
|
||||
add column affirm_income tinyint(1) null comment '确认收入',
|
||||
add column confirm_no_tax_amount decimal(12, 2) default 0 comment '确认金额未税',
|
||||
add column paid_no_tax_amount decimal(12, 2) default 0 comment '到账金额未税',
|
||||
add column invoice_no_tax_amount decimal(12, 2) default 0 comment '开票金额未税',
|
||||
add column confirm_tax decimal(12, 2) default 0 comment '确认金额税额',
|
||||
add column paid_tax decimal(12, 2) default 0 comment '到账金额税额',
|
||||
add column invoice_tax decimal(12, 2) default 0 comment '开票金额税额';
|
||||
alter table pay_working_group_subitem
|
||||
add column affirm_income tinyint(1) null comment '确认收入',
|
||||
add column confirm_no_tax_amount decimal(12, 2) default 0 comment '确认金额未税',
|
||||
add column paid_no_tax_amount decimal(12, 2) default 0 comment '到账金额未税',
|
||||
add column invoice_no_tax_amount decimal(12, 2) default 0 comment '开票金额未税',
|
||||
add column confirm_tax decimal(12, 2) default 0 comment '确认金额税额',
|
||||
add column paid_tax decimal(12, 2) default 0 comment '到账金额税额',
|
||||
add column invoice_tax decimal(12, 2) default 0 comment '开票金额税额';
|
||||
alter table pay_member_project_subitem
|
||||
add column affirm_income tinyint(1) null comment '确认收入',
|
||||
add column confirm_no_tax_amount decimal(12, 2) default 0 comment '确认金额未税',
|
||||
add column paid_no_tax_amount decimal(12, 2) default 0 comment '到账金额未税',
|
||||
add column invoice_no_tax_amount decimal(12, 2) default 0 comment '开票金额未税',
|
||||
add column confirm_tax decimal(12, 2) default 0 comment '确认金额税额',
|
||||
add column paid_tax decimal(12, 2) default 0 comment '到账金额税额',
|
||||
add column invoice_tax decimal(12, 2) default 0 comment '开票金额税额';
|
||||
alter table pay_meeting_situation
|
||||
add column affirm_income tinyint(1) null comment '确认收入',
|
||||
add column confirm_no_tax_amount decimal(12, 2) default 0 comment '确认金额未税',
|
||||
add column paid_no_tax_amount decimal(12, 2) default 0 comment '到账金额未税',
|
||||
add column invoice_no_tax_amount decimal(12, 2) default 0 comment '开票金额未税',
|
||||
add column confirm_tax decimal(12, 2) default 0 comment '确认金额税额',
|
||||
add column paid_tax decimal(12, 2) default 0 comment '到账金额税额',
|
||||
add column invoice_tax decimal(12, 2) default 0 comment '开票金额税额';
|
||||
alter table tb_member_project_subitem
|
||||
add column affirm_income tinyint(1) null comment '确认收入',
|
||||
add column confirm_no_tax_amount decimal(12, 2) default 0 comment '确认金额未税',
|
||||
add column paid_no_tax_amount decimal(12, 2) default 0 comment '到账金额未税',
|
||||
add column invoice_no_tax_amount decimal(12, 2) default 0 comment '开票金额未税',
|
||||
add column confirm_tax decimal(12, 2) default 0 comment '确认金额税额',
|
||||
add column paid_tax decimal(12, 2) default 0 comment '到账金额税额',
|
||||
add column invoice_tax decimal(12, 2) default 0 comment '开票金额税额';
|
||||
alter table tb_certificate_payment
|
||||
add column affirm_income tinyint(1) null comment '确认收入',
|
||||
add column confirm_no_tax_amount decimal(12, 2) default 0 comment '确认金额未税',
|
||||
add column paid_no_tax_amount decimal(12, 2) default 0 comment '到账金额未税',
|
||||
add column invoice_no_tax_amount decimal(12, 2) default 0 comment '开票金额未税',
|
||||
add column confirm_tax decimal(12, 2) default 0 comment '确认金额税额',
|
||||
add column paid_tax decimal(12, 2) default 0 comment '到账金额税额',
|
||||
add column invoice_tax decimal(12, 2) default 0 comment '开票金额税额';
|
||||
-- 处理历史数据
|
||||
update pay_payment_record
|
||||
set no_tax_amount = amount_received / 1.06,
|
||||
@@ -239,4 +309,56 @@ where invoice_amount is not null;
|
||||
update pay_confirm_payment_record
|
||||
set no_tax_amount = amount_received / 1.06,
|
||||
tax = amount_received - no_tax_amount
|
||||
where amount_received is not null;
|
||||
where amount_received is not null;
|
||||
-- 六个项目处理历史数据
|
||||
update pay_common_project
|
||||
set confirm_no_tax_amount = confirm_amount / 1.06,
|
||||
paid_no_tax_amount = paid_amount / 1.06,
|
||||
invoice_no_tax_amount = invoice_amount / 1.06,
|
||||
confirm_tax = confirm_amount - confirm_no_tax_amount,
|
||||
paid_tax = paid_amount - paid_no_tax_amount,
|
||||
invoice_tax = invoice_amount - invoice_no_tax_amount
|
||||
where 1 = 1;
|
||||
update pay_working_group_subitem
|
||||
set confirm_no_tax_amount = confirm_amount / 1.06,
|
||||
paid_no_tax_amount = paid_amount / 1.06,
|
||||
invoice_no_tax_amount = invoice_amount / 1.06,
|
||||
confirm_tax = confirm_amount - confirm_no_tax_amount,
|
||||
paid_tax = paid_amount - paid_no_tax_amount,
|
||||
invoice_tax = invoice_amount - invoice_no_tax_amount
|
||||
where 1 = 1;
|
||||
update pay_member_project_subitem
|
||||
set confirm_no_tax_amount = confirm_amount / 1.06,
|
||||
paid_no_tax_amount = paid_amount / 1.06,
|
||||
invoice_no_tax_amount = invoice_amount / 1.06,
|
||||
confirm_tax = confirm_amount - confirm_no_tax_amount,
|
||||
paid_tax = paid_amount - paid_no_tax_amount,
|
||||
invoice_tax = invoice_amount - invoice_no_tax_amount
|
||||
where 1 = 1;
|
||||
update pay_meeting_situation
|
||||
set confirm_no_tax_amount = confirm_amount / 1.06,
|
||||
paid_no_tax_amount = paid_amount / 1.06,
|
||||
invoice_no_tax_amount = invoice_amount / 1.06,
|
||||
confirm_tax = confirm_amount - confirm_no_tax_amount,
|
||||
paid_tax = paid_amount - paid_no_tax_amount,
|
||||
invoice_tax = invoice_amount - invoice_no_tax_amount
|
||||
where 1 = 1;
|
||||
update tb_member_project_subitem
|
||||
set confirm_no_tax_amount = confirm_amount / 1.06,
|
||||
paid_no_tax_amount = paid_amount / 1.06,
|
||||
invoice_no_tax_amount = invoice_amount / 1.06,
|
||||
confirm_tax = confirm_amount - confirm_no_tax_amount,
|
||||
paid_tax = paid_amount - paid_no_tax_amount,
|
||||
invoice_tax = invoice_amount - invoice_no_tax_amount
|
||||
where 1 = 1;
|
||||
update tb_certificate_payment
|
||||
set confirm_no_tax_amount = confirm_amount / 1.06,
|
||||
paid_no_tax_amount = paid_amount / 1.06,
|
||||
invoice_no_tax_amount = invoice_amount / 1.06,
|
||||
confirm_tax = confirm_amount - confirm_no_tax_amount,
|
||||
paid_tax = paid_amount - paid_no_tax_amount,
|
||||
invoice_tax = invoice_amount - invoice_no_tax_amount
|
||||
where 1 = 1;
|
||||
|
||||
select *
|
||||
from v_statistical;
|
||||
Reference in New Issue
Block a user