fix 首页应收账款统计不准确

This commit is contained in:
lijiarao
2023-07-25 13:56:52 +08:00
parent f28a2ffbc8
commit 427164f471
2 changed files with 237 additions and 9 deletions
+228
View File
@@ -720,3 +720,231 @@ INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `descri
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1587319992635285506', '1587319627974107138', '13%', '0.13', '', 7.00, 1, 'LKGLZ', '2022-11-01 13:45:52', 'LKGLZ', '2022-11-01 13:54:02');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1587320050650898434', '1587319627974107138', '19%欧洲', '0.19', '', 8.00, 1, 'LKGLZ', '2022-11-01 13:46:06', 'LKGLZ', '2022-11-01 13:53:55');
create view v_statistical_all as
select pp.id as projectId,
pp.superId,
pp.projectName,
principalName,
chargeCompanyId,
chargeCompanyTemporaryId,
chargeCompanyTemporaryName,
allMoney,
comeAllMoney,
chargeUse,
depart,
createTime,
if(pp.pack = 0, '', '') as packText,
year,
payStatue,
departId,
departCode,
principalNameId,
type,
billMoney as invoiceAmount,
if(billMoney is null, 0, billMoney) as billMoney,
confirmAmount,
invoiceNoTaxAmount,
paidNoTaxAmount,
confirmNoTaxAmount,
contactsName,
confirmDate,
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.no_tax_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,
sd.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(DISTINCT pwgsc.contacts_temporary_name order by pwgsc.contacts_temporary_name) as contactsName,
GROUP_CONCAT(DISTINCT DATE_FORMAT(pcpr.payment_date,'%Y-%m')) as confirmDate,
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)
left join sys_depart sd on (su.depart_ids = sd.id)
left JOIN pay_working_group_subitem_contacts pwgsc on pwgsc.working_group_sub_id = pwgs.id
left join pay_confirm_payment_record pcpr on pwgs.id = pcpr.project_id
group by pwgs.id
union all
SELECT pcp.id,
pcp.id as superId,
pcp.charge_project AS projectName,
pcp.principal_name as principalName,
pcp.charge_company_id AS chargeCompanyId,
pcp.charge_company_temporary_id as chargeCompanyTemporaryId,
pcp.charge_company_temporary_name AS chargeCompanyTemporaryName,
pcp.no_tax_amount as allMoney,
pcp.paid_amount as comeAllMoney,
pcp.charge_use as chargeUse,
sd.depart_name as depart,
pcp.pack as pack,
pcp.year as year,
pcp.in_account as payStatue,
sd.org_code as departCode,
sd.id as departId,
pcp.principal_id as principalNameId,
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,
GROUP_CONCAT(DATE_FORMAT(pcpr.payment_date,'%Y-%m')) as confirmDate,
pcp.create_time as createTime
FROM pay_common_project pcp
left JOIN sys_user su on (pcp.principal_id = su.id)
left join sys_depart sd on (su.depart_ids = sd.id)
left join pay_confirm_payment_record pcpr on pcp.id = pcpr.project_id
group by pcp.id
union all
SELECT pmps.id,
pmp.id as superId,
pmp.project_name AS projectName,
su.realname as principalName,
pmps.company_id AS chargeCompanyId,
pmps.company_id as chargeCompanyTemporaryId,
pmps.company_name AS chargeCompanyTemporaryName,
pmps.no_tax_amount as allMoney,
pmps.paid_amount as comeAllMoney,
pmps.charge_use as chargeUse,
sd.depart_name as depart,
pmps.pack as pack,
pmp.particular_year as year,
pmps.in_account as payStatue,
sd.org_code as departCode,
sd.id as departId,
pmp.director_id as principalNameId,
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,
GROUP_CONCAT(DATE_FORMAT(pcpr.payment_date,'%Y-%m')) as confirmDate,
pmps.create_time as createTime
FROM pay_member_project pmp
right join pay_member_project_subitem pmps on (pmp.id = pmps.project_id)
left JOIN sys_user su on (pmp.director_id = su.id)
left join sys_depart sd on (su.depart_ids = sd.id)
left join pay_confirm_payment_record pcpr on pmps.id = pcpr.project_id
group by pmps.id
union all
SELECT pms.id,
pm.id as superId,
pm.meeting_name AS projectName,
su.realname as principalName,
pms.company_id AS chargeCompanyId,
pms.company_id as chargeCompanyTemporaryId,
pms.company_name AS chargeCompanyTemporaryName,
pms.no_tax_amount as allMoney,
pms.paid_amount as comeAllMoney,
pms.charge_use as chargeUse,
sd.depart_name as depart,
pms.pack as pack,
pm.particular_year as year,
pms.in_account as payStatue,
sd.org_code as departCode,
sd.id as departId,
pm.director_id as principalNameId,
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,
GROUP_CONCAT(DATE_FORMAT(pcpr.payment_date,'%Y-%m')) as confirmDate,
pms.create_time as createTime
FROM pay_meeting pm
right join pay_meeting_situation pms on (pm.id = pms.meeting_id)
left JOIN sys_user su on (pm.director_id = su.id)
left join sys_depart sd on (su.depart_ids = sd.id)
left join pay_confirm_payment_record pcpr on pms.id = pcpr.project_id
group by pms.id
union all
SELECT tmps.id,
tmp.id as superId,
tmp.project_name AS projectName,
su.realname as principalName,
tmps.company_id AS chargeCompanyId,
tmps.company_id as chargeCompanyTemporaryId,
tmps.company_name AS chargeCompanyTemporaryName,
tmps.no_tax_amount as allMoney,
tmps.paid_amount as comeAllMoney,
tmps.charge_use as chargeUse,
sd.depart_name as depart,
tmps.pack as pack,
tmp.year as year,
tmps.in_account as payStatue,
sd.org_code as departCode,
sd.id as departId,
tmp.director_id as principalNameId,
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,
GROUP_CONCAT(DATE_FORMAT(pcpr.payment_date,'%Y-%m')) as confirmDate,
tmps.create_time as createTime
FROM tb_member_project tmp
left join tb_member_project_subitem tmps on (tmp.id = tmps.project_id)
left JOIN sys_user su on (tmp.director_id = su.id)
left join sys_depart sd on (su.depart_ids = sd.id)
left join pay_confirm_payment_record pcpr on tmps.id = pcpr.project_id
group by tmps.id
union all
SELECT tcp.id,
tmp.id as superId,
tmp.project_name AS projectName,
su.realname as principalName,
tcp.company_id AS chargeCompanyId,
tcp.company_id as chargeCompanyTemporaryId,
tcp.company_name AS chargeCompanyTemporaryName,
tcp.no_tax_amount as allMoney,
tcp.paid_amount as comeAllMoney,
tcp.charge_use as chargeUse,
sd.depart_name as depart,
tcp.pack as pack,
tmp.year as year,
tcp.in_account as payStatue,
sd.org_code as departCode,
sd.id as departId,
tmp.director_id as principalNameId,
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,
GROUP_CONCAT(DATE_FORMAT(pcpr.payment_date,'%Y-%m')) as confirmDate,
tcp.create_time as createTime
FROM tb_member_project tmp
left join tb_certificate_payment tcp on (tmp.id = tcp.project_id)
left JOIN sys_user su on (tmp.director_id = su.id)
left join sys_depart sd on (su.depart_ids = sd.id)
left join pay_confirm_payment_record pcpr on tcp.id = pcpr.project_id
group by tcp.id
) pp
order by pp.createTime;
@@ -2368,7 +2368,7 @@
IFNULL(sum(money),0) from
(
SELECT distinct v.projectId, invoiceNoTaxAmount - ifnull( paidNoTaxAmount, 0) money
FROM v_statistical v
FROM v_statistical_all v
left join pay_mail_bill_project pmbp on v.projectId = pmbp.project_id
left join pay_mail_bill pmb on pmb.id = pmbp.bill_id
<where>
@@ -2385,8 +2385,8 @@
and departCode = #{departCode}
</if>
<!-- 开票未来款 -->
AND (paidNoTaxAmount <![CDATA[<]]> invoiceNoTaxAmount or
(paidNoTaxAmount is null and invoiceNoTaxAmount is not null and invoiceNoTaxAmount != 0))
AND (comeAllMoney <![CDATA[<]]> v.invoiceAmount or
(comeAllMoney is null and v.invoiceAmount is not null and v.invoiceAmount != 0))
</where>
) a
</select>
@@ -2438,7 +2438,7 @@
invoiceNoTaxAmount AS billMoney,
confirmNoTaxAmount AS confirmAmount,
year
FROM v_statistical v
FROM v_statistical_all v
left join pay_mail_bill_project pmbp on v.projectId = pmbp.project_id
left join pay_mail_bill pmb on pmb.id = pmbp.bill_id
<where>
@@ -2455,8 +2455,8 @@
and departCode = #{departCode}
</if>
<!-- 开票未来款 -->
AND (paidNoTaxAmount <![CDATA[<]]> invoiceNoTaxAmount or
(paidNoTaxAmount is null and invoiceNoTaxAmount is not null and invoiceNoTaxAmount != 0))
AND (comeAllMoney <![CDATA[<]]> v.invoiceAmount or
(comeAllMoney is null and v.invoiceAmount is not null and v.invoiceAmount != 0))
</where>) p
<if test="column != null and column != ''">
<if test="column == 'allMoney' and order == 'desc'">
@@ -2498,7 +2498,7 @@
paidNoTaxAmount,
invoiceNoTaxAmount,
confirmNoTaxAmount
FROM v_statistical v
FROM v_statistical_all v
left join pay_mail_bill_project pmbp on v.projectId = pmbp.project_id
left join pay_mail_bill pmb on pmb.id = pmbp.bill_id
<where>
@@ -2515,8 +2515,8 @@
and departCode = #{departCode}
</if>
<!-- 开票未来款 -->
AND (paidNoTaxAmount <![CDATA[<]]> invoiceNoTaxAmount or
(paidNoTaxAmount is null and invoiceNoTaxAmount is not null and invoiceNoTaxAmount != 0))
AND (comeAllMoney <![CDATA[<]]> v.invoiceAmount or
(comeAllMoney is null and v.invoiceAmount is not null and v.invoiceAmount != 0))
</where>
) a
</select>