|
@@ -33,7 +33,8 @@
|
|
|
IFNULL( sum( inspectionRedPackFee ), 0 ) AS inspectionRedPackFee,
|
|
|
IFNULL( sum( commissionFee ), 0 ) AS commissionFee,
|
|
|
IFNULL( sum( otherFee ), 0 ) AS otherFee,
|
|
|
- IFNULL( sum( contractAmount ), 0 ) AS contractAmount
|
|
|
+ IFNULL( sum( contractAmount ), 0 ) AS contractAmount,
|
|
|
+ IFNULL( sum( requestFundsAmount ), 0 ) AS requestFundsAmount
|
|
|
FROM
|
|
|
(
|
|
|
<include refid="getProfitClearing"/>
|
|
@@ -46,7 +47,7 @@
|
|
|
sc.`code` AS salesContractCode,
|
|
|
sc.customer_id,
|
|
|
cu.`name` AS customerName,
|
|
|
- ( SELECT IFNULL( sum( cc.contract_money ), 0 ) FROM bytesailing_sale.claim_contract cc WHERE cc.contract_id = sc.id ) AS contractClaimAmount,
|
|
|
+ ( SELECT IFNULL( sum( cc.contract_money ), 0 ) FROM bytesailing_sale.claim_contract cc WHERE cc.del_flag=0 and cc.contract_id = sc.id ) AS contractClaimAmount,
|
|
|
sc.contract_amount AS contractAmount,
|
|
|
(
|
|
|
SELECT
|
|
@@ -57,7 +58,8 @@
|
|
|
JOIN bytesailing_mes.work_order wo ON sj.work_order_id = wo.id
|
|
|
JOIN sales_contract_details scd ON wo.contract_details_id = scd.id
|
|
|
WHERE
|
|
|
- scd.sales_contract_id = sc.id
|
|
|
+ sjd.del_flag=0
|
|
|
+ and scd.sales_contract_id = sc.id
|
|
|
) AS materialFee,
|
|
|
(
|
|
|
SELECT
|
|
@@ -76,7 +78,8 @@
|
|
|
sc.inspection_red_pack_fee AS inspectionRedPackFee,
|
|
|
sc.commission_fee AS commissionFee,
|
|
|
sc.other_fee AS otherFee,
|
|
|
- sc.is_settled
|
|
|
+ sc.is_settled,
|
|
|
+ (SELECT IFNULL( sum( arfd.amount ), 0 ) FROM bytesailing_account.account_request_funds_detail arfd WHERE arfd.contract_id = sc.id) as requestFundsAmount
|
|
|
FROM
|
|
|
sales_contract sc
|
|
|
LEFT JOIN bytesailing_customer.customer cu ON sc.customer_id = cu.id
|