Spaces:
Sleeping
Sleeping
File size: 3,002 Bytes
245e020 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
queries_merged_01 = {
# Query 1
'''
merge
`fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` as A
using
`fynd-db.CN_Working.settlement_id_update` as B
on
A.bag_id = B.bag_id
and A.settlement_type = B.settlement_type
and A.sett_id = B.sett_id
when matched then
update set
A.sett_id = B.New_sett_id
'''
}
queries_merged_02 = {
# Query 1
'''
merge
`fynd-db.finance_recon_tool_asia.11_seller_fees_daily` as A
using
`fynd-db.CN_Working.settlement_id_update` as B
on
A.bag_id = B.bag_id
and A.transaction_type = B.transaction_type
and A.sett_id = B.sett_id
when matched then
update set
A.sett_id = B.New_sett_id
'''
}
queries_merged_03 = {
# Query 1
'''
merge
`fynd-db.finance_recon_tool_asia.12_seller_claims_daily` as A
using
`fynd-db.CN_Working.settlement_id_update` as B
on
concat(A.current_shipment_id,A.recon_status) = B.merged
--and A.recon_status = B.recon_status
and A.sett_id = B.sett_id
when matched then
update set
A.sett_id = B.New_sett_id
'''
}
conso_query = '''
SELECT
sett_id,
SUM(seller_net_collection),
"NC" AS Type
FROM
`fynd-db.Outstanding.09_Payable_File_table`
WHERE
expected_payout_date <= @selected_date
GROUP BY 1
UNION ALL
SELECT
sett_id,
SUM(total_charges),
"FS" AS Type
FROM
`fynd-db.Outstanding.11_fees_payable`
WHERE
expected_payout_date <= @selected_date
GROUP BY 1
UNION ALL
SELECT
sett_id,
SUM(claimable_amt),
"CS" AS Type
FROM
`fynd-db.Outstanding.12_claim_payable`
WHERE
claim_settle_date <= @selected_date
GROUP BY 1
UNION ALL
SELECT
sett_id,
SUM(dispute_amount),
"MD" AS Type
FROM
`fynd-db.Outstanding.Manual_Dispute`
GROUP BY 1
'''
disburse_query = '''
select
*,
CASE
WHEN company_Id in (269,
334,
43,
1103,
1115,
2704,
7151,
1202,
4204,
5275,
1951,
644,
46,
1708,
442,
5842,
480,
2250,
5234,
2196,
4770) THEN 'RBL' ELSE 'Non RBL'
END as company_type,
from
`finance_recon_tool_asia.disbursement_summary`
where sett_id in (
SELECT
sett_id
FROM
`fynd-db.Outstanding.09_Payable_File_table`
WHERE
expected_payout_date <= @selected_date
GROUP BY 1
UNION ALL
SELECT
sett_id
FROM
`fynd-db.Outstanding.11_fees_payable`
WHERE
expected_payout_date <= @selected_date
GROUP BY 1
UNION ALL
SELECT
sett_id,
FROM
`fynd-db.Outstanding.12_claim_payable`
WHERE
claim_settle_date <= @selected_date
GROUP BY 1
UNION ALL
SELECT
sett_id,
FROM
`fynd-db.Outstanding.Manual_Dispute`
GROUP BY 1
)
'''
|