Update queries.py
Browse files- queries.py +85 -7
queries.py
CHANGED
|
@@ -1,5 +1,82 @@
|
|
| 1 |
|
| 2 |
queries = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
# Query 1
|
| 4 |
'1. fynd-db.finance_recon_tool_asia.01_finance_avis_data_final': '''
|
| 5 |
select
|
|
@@ -240,16 +317,17 @@ queries = {
|
|
| 240 |
# Query 14
|
| 241 |
'14. Net collection collection & refund validation': '''
|
| 242 |
select
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
from `fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily`
|
| 249 |
where
|
| 250 |
-
|
| 251 |
''',
|
| 252 |
|
|
|
|
| 253 |
|
| 254 |
# Query 15
|
| 255 |
'15. 09_Net collection collection & refund validation': '''
|
|
@@ -367,7 +445,7 @@ queries = {
|
|
| 367 |
sett_date > "2024-04-01" )
|
| 368 |
group by
|
| 369 |
1,2,3
|
| 370 |
-
having Diff
|
| 371 |
''',
|
| 372 |
|
| 373 |
# Query 21
|
|
|
|
| 1 |
|
| 2 |
queries = {
|
| 3 |
+
|
| 4 |
+
# Query 0.0
|
| 5 |
+
'0.0. Check how many bags pushed into 09_net_collection having the collection_partner as seller': '''
|
| 6 |
+
select
|
| 7 |
+
distinct
|
| 8 |
+
A.bag_id as bag_id_avis_01,
|
| 9 |
+
C.bag_id as bag_id_05,
|
| 10 |
+
B.bag_id as bag_id_09,
|
| 11 |
+
A.collection_partner,
|
| 12 |
+
A.Settlement_type
|
| 13 |
+
from
|
| 14 |
+
`fynd-db.finance_recon_tool_asia.01_finance_avis_data_final` as A
|
| 15 |
+
left join `fynd-db.finance_recon_tool_asia.05_partner_collection` as C
|
| 16 |
+
on
|
| 17 |
+
A.bag_id = C.bag_id
|
| 18 |
+
left join `fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` as B
|
| 19 |
+
on
|
| 20 |
+
A.bag_id = B.bag_id
|
| 21 |
+
where C.receipt_date >= '2024-04-01'
|
| 22 |
+
and A.recon_status in ('delivery_done')
|
| 23 |
+
and
|
| 24 |
+
A.collection_partner <> 'fynd'
|
| 25 |
+
and A.Settlement_type <> 'NA'
|
| 26 |
+
''',
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
# Query 0.1
|
| 30 |
+
'0.1. Check how many bags are not pushed in 09_net_collection from 01_avis': '''
|
| 31 |
+
select
|
| 32 |
+
distinct
|
| 33 |
+
A.bag_id as bag_id_avis_01,
|
| 34 |
+
C.bag_id as bag_id_05,
|
| 35 |
+
B.bag_id as bag_id_09,
|
| 36 |
+
A.collection_partner,
|
| 37 |
+
A.Settlement_type
|
| 38 |
+
from
|
| 39 |
+
`fynd-db.finance_recon_tool_asia.01_finance_avis_data_final` as A
|
| 40 |
+
left join `fynd-db.finance_recon_tool_asia.05_partner_collection` as C
|
| 41 |
+
on
|
| 42 |
+
A.bag_id = C.bag_id
|
| 43 |
+
left join `fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` as B
|
| 44 |
+
on
|
| 45 |
+
A.bag_id = B.bag_id
|
| 46 |
+
where C.receipt_date >= '2024-04-01'
|
| 47 |
+
and A.recon_status in ('delivery_done')
|
| 48 |
+
and B.bag_id is null
|
| 49 |
+
and
|
| 50 |
+
A.collection_partner <> 'fynd'
|
| 51 |
+
and A.Settlement_type <> 'NA'
|
| 52 |
+
''',
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
# Query 0.2
|
| 57 |
+
'0.2. Check how many bags are not pushed in 05_partner_refunds from 01_avis': '''
|
| 58 |
+
select
|
| 59 |
+
distinct
|
| 60 |
+
A.bag_id as bag_id_avis_01,
|
| 61 |
+
C.bag_id as bag_id_05,
|
| 62 |
+
B.bag_id as bag_id_09,
|
| 63 |
+
A.refund_partner
|
| 64 |
+
from
|
| 65 |
+
`fynd-db.finance_recon_tool_asia.01_finance_avis_data_final` as A
|
| 66 |
+
left join `fynd-db.finance_recon_tool_asia.05_partner_refunds` as C
|
| 67 |
+
on
|
| 68 |
+
A.bag_id = C.bag_id
|
| 69 |
+
left join `fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` as B
|
| 70 |
+
on
|
| 71 |
+
A.bag_id = B.bag_id
|
| 72 |
+
where C.refund_date >= '2024-04-01'
|
| 73 |
+
and A.recon_status in ('return_bag_picked','return_bag_delivered')
|
| 74 |
+
and B.bag_id is null
|
| 75 |
+
''',
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
|
| 80 |
# Query 1
|
| 81 |
'1. fynd-db.finance_recon_tool_asia.01_finance_avis_data_final': '''
|
| 82 |
select
|
|
|
|
| 317 |
# Query 14
|
| 318 |
'14. Net collection collection & refund validation': '''
|
| 319 |
select
|
| 320 |
+
bag_id,
|
| 321 |
+
settlement_type,
|
| 322 |
+
collection_partner,
|
| 323 |
+
refund_partner,
|
| 324 |
+
case when settlement_type in ('collection','Claim',"dispute","rectify","rectify_R", "Sale_NR") and collection_partner = 'fynd' then 'Yes' when settlement_type = 'refund' and refund_partner = 'fynd' then 'Yes' else 'No' end as Comment
|
| 325 |
from `fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily`
|
| 326 |
where
|
| 327 |
+
(case when settlement_type in ('collection','Claim',"dispute","rectify","rectify_R", "Sale_NR") and collection_partner = 'fynd' then 'Yes' when settlement_type = 'refund' and refund_partner = 'fynd' then 'Yes' else 'No' end) = 'No'
|
| 328 |
''',
|
| 329 |
|
| 330 |
+
|
| 331 |
|
| 332 |
# Query 15
|
| 333 |
'15. 09_Net collection collection & refund validation': '''
|
|
|
|
| 445 |
sett_date > "2024-04-01" )
|
| 446 |
group by
|
| 447 |
1,2,3
|
| 448 |
+
having Diff > 0
|
| 449 |
''',
|
| 450 |
|
| 451 |
# Query 21
|