diff --git a/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml b/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml
index 95556e2e5..f3a7f8cfd 100644
--- a/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml
+++ b/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml
@@ -314,7 +314,8 @@
end
)
)
- and b.trade_date
+ then case
+ when b.trade_date
(
case
when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
@@ -323,25 +324,79 @@
else a.payment_due_date
end
)
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ when a.settle_type = '2'
+ and a.credit_period in (30,60,90)
+ and a.settle_day = '1'
+ then case
+ when b.trade_date
+ (
+ case
+ when a.credit_period = 30 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when a.credit_period = 60 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ end
+ )
then ifnull(d.pay_money,0)
- when b.trade_date a.payment_due_date then ifnull(d.pay_money,0)
else 0
+ end
+ else case
+ when b.trade_date a.payment_due_date then ifnull(d.pay_money,0)
+ else 0
+ end
end
) AS recdMoneyIn,
- sum( if(
- a.settle_type='2'
- and a.credit_period = ]]> 30
- and b.trade_date ]]> a.payment_due_date
- and b.trade_date ]]> a.payment_due_date
- and b.trade_date DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY )
- and NOT EXISTS (
- SELECT 1
- FROM emis_settle_invoice_record f
- WHERE f.del_flag='0'
- AND f.settle_bill_no = a.settle_bill_no
- AND f.bl_delay = '1'
- )
- ,ifnull(d.pay_money,0) ,0) ) AS recdPayMoney60D,
+ sum(
+ case
+ when a.settle_type = '2'
+ and a.credit_period = 30
+ and a.settle_day = '1'
+ and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ and b.trade_date DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ and NOT EXISTS (
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = a.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when a.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ then ifnull(d.pay_money,0)
+ when a.settle_type='2'
+ and a.credit_period = ]]> 30
+ and b.trade_date ]]> a.payment_due_date
+ and b.trade_date ]]> a.payment_due_date
+ and b.trade_date DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY )
+ and NOT EXISTS (
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = a.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when a.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ ) AS recdPayMoney60D,
sum(
case
when a.settle_type = '2'
@@ -362,7 +417,8 @@
end
)
)
- and b.trade_date = ]]>
+ then case
+ when b.trade_date = ]]>
(
case
when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
@@ -371,9 +427,34 @@
else a.payment_due_date
end
)
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ when a.settle_type = '2'
+ and a.credit_period in (30,60,90)
+ and a.settle_day = '1'
+ then case
+ when (
+ (a.credit_period = 30 and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH))
+ or (a.credit_period = 60 and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH))
+ or (a.credit_period = 90 and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH))
+ )
then ifnull(d.pay_money,0)
- when (a.settle_type='2' and a.credit_period = ]]> 30 and b.trade_date ]]> a.payment_due_date and b.trade_date = ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ) ) or ( ( (a.settle_type='2' and a.credit_period 30) or a.settle_type='1' ) and b.trade_date ]]> a.payment_due_date )
- then ifnull(d.pay_money,0)
+ else 0
+ end
+ when a.settle_type='2'
+ and a.credit_period = ]]> 30
+ then case
+ when b.trade_date ]]> a.payment_due_date
+ and b.trade_date = ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY )
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ when ( (a.settle_type='2' and a.credit_period 30) or a.settle_type='1' )
+ then case
+ when b.trade_date ]]> a.payment_due_date then ifnull(d.pay_money,0)
+ else 0
+ end
else 0
end
) AS recdPayMoneyGreat60D
@@ -933,7 +1014,8 @@
end
)
)
- and b.trade_date
+ then case
+ when b.trade_date
(
case
when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
@@ -942,25 +1024,79 @@
else a.payment_due_date
end
)
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ when a.settle_type = '2'
+ and a.credit_period in (30,60,90)
+ and a.settle_day = '1'
+ then case
+ when b.trade_date
+ (
+ case
+ when a.credit_period = 30 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when a.credit_period = 60 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ end
+ )
then ifnull(d.pay_money,0)
- when b.trade_date a.payment_due_date then ifnull(d.pay_money,0)
else 0
+ end
+ else case
+ when b.trade_date a.payment_due_date then ifnull(d.pay_money,0)
+ else 0
+ end
end
) AS recdMoneyIn,
- sum( if(
- a.settle_type='2'
- and a.credit_period = ]]> 30
- and b.trade_date ]]> a.payment_due_date
- and b.trade_date ]]> a.payment_due_date
- and b.trade_date DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY )
- and NOT EXISTS (
- SELECT 1
- FROM emis_settle_invoice_record f
- WHERE f.del_flag='0'
- AND f.settle_bill_no = a.settle_bill_no
- AND f.bl_delay = '1'
- )
- ,ifnull(d.pay_money,0) ,0) ) AS recdPayMoney60D,
+ sum(
+ case
+ when a.settle_type = '2'
+ and a.credit_period = 30
+ and a.settle_day = '1'
+ and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ and b.trade_date DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ and NOT EXISTS (
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = a.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when a.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ then ifnull(d.pay_money,0)
+ when a.settle_type='2'
+ and a.credit_period = ]]> 30
+ and b.trade_date ]]> a.payment_due_date
+ and b.trade_date ]]> a.payment_due_date
+ and b.trade_date DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY )
+ and NOT EXISTS (
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = a.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when a.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ ) AS recdPayMoney60D,
sum(
case
when a.settle_type = '2'
@@ -981,7 +1117,8 @@
end
)
)
- and b.trade_date = ]]>
+ then case
+ when b.trade_date = ]]>
(
case
when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
@@ -990,9 +1127,34 @@
else a.payment_due_date
end
)
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ when a.settle_type = '2'
+ and a.credit_period in (30,60,90)
+ and a.settle_day = '1'
+ then case
+ when (
+ (a.credit_period = 30 and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH))
+ or (a.credit_period = 60 and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH))
+ or (a.credit_period = 90 and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH))
+ )
then ifnull(d.pay_money,0)
- when (a.settle_type='2' and a.credit_period = ]]> 30 and b.trade_date ]]> a.payment_due_date and b.trade_date = ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ) ) or ( ( (a.settle_type='2' and a.credit_period 30) or a.settle_type='1' ) and b.trade_date ]]> a.payment_due_date )
- then ifnull(d.pay_money,0)
+ else 0
+ end
+ when a.settle_type='2'
+ and a.credit_period = ]]> 30
+ then case
+ when b.trade_date ]]> a.payment_due_date
+ and b.trade_date = ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY )
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ when ( (a.settle_type='2' and a.credit_period 30) or a.settle_type='1' )
+ then case
+ when b.trade_date ]]> a.payment_due_date then ifnull(d.pay_money,0)
+ else 0
+ end
else 0
end
) AS recdPayMoneyGreat60D
diff --git a/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml b/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml
index 7edd839ad..daccddf6e 100644
--- a/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml
+++ b/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml
@@ -333,76 +333,248 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and espbr.settle_bill_no=esb.settle_bill_no
and (
- ( esb.settle_type = '2'
- and esb.credit_period in (30,35,45,60,75,90)
- and EXISTS(
- SELECT 1
- FROM emis_settle_invoice_record f
- WHERE f.del_flag = '0'
- AND f.settle_bill_no = esb.settle_bill_no
- AND f.bl_delay = '1'
- AND f.apply_date
- (
- case
- when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
- when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
- when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
- else NULL
- end
- )
- )
- and b.trade_date
- (
- case
- when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
- when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
- when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH)
- else esb.payment_due_date
- end
+
+ (
+ esb.settle_type = '2'
+ and esb.credit_period in (30,35,45,60,75,90)
+ and EXISTS(
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = esb.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
)
- ) or b.trade_date esb.payment_due_date
+ and b.trade_date
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH)
+ else esb.payment_due_date
+ end
+ )
+ )
+
+ OR
+ (
+ NOT (
+ EXISTS(
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = esb.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ )
+ and esb.settle_type = '2'
+ and esb.credit_period in (30,60,90)
+ and esb.settle_day = '1'
+ and b.trade_date
+ (
+ case
+ when esb.credit_period = 30 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when esb.credit_period = 60 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ end
+ )
+ )
+
+ OR
+ (
+ NOT (
+ EXISTS(
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = esb.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ )
+ and NOT (
+ esb.settle_type = '2'
+ and esb.credit_period in (30,60,90)
+ and esb.settle_day = '1'
+ )
+ and b.trade_date esb.payment_due_date
+ )
)
- and ( esb.settle_type='2' and esb.credit_period = ]]> 30 and b.trade_date ]]> esb.payment_due_date and b.trade_date ]]> esb.payment_due_date and b.trade_date DATE_SUB( esb.payment_due_date, INTERVAL (esb.credit_period-60) DAY )
- and NOT EXISTS (
- SELECT 1
- FROM emis_settle_invoice_record f
- WHERE f.del_flag='0'
- AND f.settle_bill_no = esb.settle_bill_no
- AND f.bl_delay = '1'
- ) )
+ and (
+ (
+ esb.settle_type = '2'
+ and esb.credit_period = 30
+ and esb.settle_day = '1'
+ and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ and b.trade_date DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ and NOT EXISTS (
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = a.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ )
+ OR
+ (
+ NOT (
+ esb.settle_type = '2'
+ and esb.credit_period = 30
+ and esb.settle_day = '1'
+ )
+ and esb.settle_type='2'
+ and esb.credit_period = ]]> 30
+ and b.trade_date ]]> esb.payment_due_date
+ and b.trade_date DATE_SUB( esb.payment_due_date, INTERVAL (esb.credit_period-60) DAY )
+ and NOT EXISTS (
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = a.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ )
+ )
and (
- ( esb.settle_type = '2'
- and esb.credit_period in (30,35,45,60,75,90)
- and EXISTS(
- SELECT 1
- FROM emis_settle_invoice_record f
- WHERE f.del_flag = '0'
- AND f.settle_bill_no = esb.settle_bill_no
- AND f.bl_delay = '1'
- AND f.apply_date
- (
- case
- when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
- when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
- when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
- else NULL
- end
- )
- )
- and b.trade_date = ]]>
- (
- case
- when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
- when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
- when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH)
- else esb.payment_due_date
- end
+ (
+ esb.settle_type = '2'
+ and esb.credit_period in (30,35,45,60,75,90)
+ and EXISTS(
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = esb.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
)
- ) or ( ( esb.settle_type='2' and esb.credit_period = ]]> 30 and b.trade_date ]]> esb.payment_due_date and b.trade_date = ]]> DATE_SUB( esb.payment_due_date, INTERVAL (esb.credit_period-60) DAY ) ) or ( ( (esb.settle_type='2' and esb.credit_period 30) or esb.settle_type='1' ) and b.trade_date ]]> esb.payment_due_date ) )
+ and b.trade_date = ]]>
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH)
+ else esb.payment_due_date
+ end
+ )
+ )
+ OR
+ (
+ NOT (
+ EXISTS(
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = esb.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ )
+ and esb.settle_type = '2'
+ and esb.credit_period in (30,60,90)
+ and esb.settle_day = '1'
+ and b.trade_date = ]]>
+ (
+ case
+ when esb.credit_period = 30 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 60 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH)
+ end
+ )
+ )
+ OR
+ (
+ NOT (
+ EXISTS(
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = esb.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ )
+ and NOT (
+ esb.settle_type = '2'
+ and esb.credit_period in (30,60,90)
+ and esb.settle_day = '1'
+
+ )
+ and esb.settle_type='2'
+ and esb.credit_period = ]]> 30
+ and b.trade_date ]]> esb.payment_due_date
+ and b.trade_date = ]]> DATE_SUB( esb.payment_due_date, INTERVAL (esb.credit_period-60) DAY )
+ )
)