|
|
|
queries = { |
|
|
|
|
|
'0.0. Check how many bags pushed into 09_net_collection having the collection_partner as seller': ''' |
|
select |
|
distinct |
|
A.bag_id as bag_id_avis_01, |
|
C.bag_id as bag_id_05, |
|
B.bag_id as bag_id_09, |
|
A.collection_partner, |
|
A.Settlement_type |
|
from |
|
`fynd-db.finance_recon_tool_asia.01_finance_avis_data_final` as A |
|
left join `fynd-db.finance_recon_tool_asia.05_partner_collection` as C |
|
on |
|
A.bag_id = C.bag_id |
|
left join `fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` as B |
|
on |
|
A.bag_id = B.bag_id |
|
where C.receipt_date >= '2024-04-01' |
|
and A.recon_status in ('delivery_done') |
|
and |
|
A.collection_partner <> 'fynd' |
|
and A.Settlement_type <> 'NA' |
|
''', |
|
|
|
|
|
|
|
'0.1. Check how many bags are not pushed in 09_net_collection from 01_avis': ''' |
|
select |
|
distinct |
|
A.bag_id as bag_id_avis_01, |
|
C.bag_id as bag_id_05, |
|
B.bag_id as bag_id_09, |
|
A.collection_partner, |
|
A.Settlement_type |
|
from |
|
`fynd-db.finance_recon_tool_asia.01_finance_avis_data_final` as A |
|
left join `fynd-db.finance_recon_tool_asia.05_partner_collection` as C |
|
on |
|
A.bag_id = C.bag_id |
|
left join `fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` as B |
|
on |
|
A.bag_id = B.bag_id |
|
where C.receipt_date >= '2024-04-01' |
|
and A.recon_status in ('delivery_done') |
|
and B.bag_id is null |
|
and |
|
A.collection_partner <> 'fynd' |
|
and A.Settlement_type <> 'NA' |
|
''', |
|
|
|
|
|
|
|
|
|
'0.2. Check how many bags are not pushed in 05_partner_refunds from 01_avis': ''' |
|
select |
|
distinct |
|
A.bag_id as bag_id_avis_01, |
|
C.bag_id as bag_id_05, |
|
B.bag_id as bag_id_09, |
|
A.refund_partner |
|
from |
|
`fynd-db.finance_recon_tool_asia.01_finance_avis_data_final` as A |
|
left join `fynd-db.finance_recon_tool_asia.05_partner_refunds` as C |
|
on |
|
A.bag_id = C.bag_id |
|
left join `fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` as B |
|
on |
|
A.bag_id = B.bag_id |
|
where C.refund_date >= '2024-04-01' |
|
and A.recon_status in ('return_bag_picked','return_bag_delivered') |
|
and B.bag_id is null |
|
''', |
|
|
|
|
|
|
|
|
|
|
|
'1. fynd-db.finance_recon_tool_asia.01_finance_avis_data_final': ''' |
|
select |
|
bag_id, |
|
concat(bag_id,Recon_Status,Settlement_type,Transaction_Type) as Merged, |
|
count(concat(bag_id,Recon_Status,Settlement_type,Transaction_Type)) |
|
from `fynd-db.finance_recon_tool_asia.01_finance_avis_data_final` |
|
group by |
|
1,2 |
|
having count(concat(bag_id,Recon_Status,Settlement_type,Transaction_Type)) not in (1) |
|
''', |
|
|
|
|
|
'2. Seller fees date validation': ''' |
|
select |
|
* |
|
from `fynd-db.finance_recon_tool_asia.11_seller_fees_daily` |
|
where |
|
invoice_generation_date is null |
|
''', |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'3. Transaction components validation': ''' |
|
select |
|
bag_id, |
|
transaction_type, |
|
inserted_date, |
|
round(transaction_fee+packaging_fee+logistics_charges+refund_support_fees+sla_charges-net_charges,0) as diff |
|
from `fynd-db.finance_recon_tool_asia.11_seller_fees_daily` |
|
where |
|
round(transaction_fee+packaging_fee+logistics_charges+refund_support_fees+sla_charges-net_charges,0) not in (0,-1,-1) |
|
and inserted_date > '2023-09-30' |
|
group by 1,2,3, transaction_fee,packaging_fee,refund_support_fees,sla_charges,net_charges,logistics_charges |
|
''', |
|
|
|
|
|
'4. Transactions in net collection validation': ''' |
|
select |
|
concat(bag_id,Settlement_type) as Merged, |
|
count(concat(bag_id,Settlement_type)) |
|
from `fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` |
|
group by 1 |
|
having |
|
count(concat(bag_id,Settlement_type)) not in (1) |
|
''', |
|
|
|
|
|
'5. Transactions in seller fees validation': ''' |
|
select |
|
concat(bag_id,Settlement_type) as Merged, |
|
count(concat(bag_id,Settlement_type)) |
|
from `fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` |
|
group by |
|
1 |
|
having |
|
count(concat(bag_id,Settlement_type)) not in (1) |
|
''', |
|
|
|
|
|
|
|
'6. Transactions in seller claims validation': ''' |
|
select |
|
current_shipment_id, |
|
concat(current_shipment_id,transaction_type) as Merged, |
|
count(concat(current_shipment_id,transaction_type)) |
|
from `fynd-db.finance_recon_tool_asia.12_seller_claims_daily` |
|
group by 1,2 |
|
having |
|
count(concat(current_shipment_id,transaction_type)) not in (1) |
|
''', |
|
|
|
|
|
|
|
'7. Aggregate liability validation': ''' |
|
select |
|
* |
|
from `fynd-db.finance_recon_tool_asia.12_seller_claims_daily` |
|
where |
|
aggregate_liability is null |
|
''', |
|
|
|
|
|
|
|
'8. Lost claim validation': ''' |
|
select |
|
* |
|
from `fynd-db.finance_recon_tool_asia.01_finance_avis_data_final` as A |
|
left join |
|
`fynd-db.finance_recon_tool_asia.12_seller_claims_daily` as B |
|
on |
|
A.current_shipment_id = B.current_shipment_id |
|
where |
|
A.claim_settle_date is not null |
|
and A.transaction_type = 'Claim' |
|
and A.dp_partner = 'fynd' |
|
and B.current_shipment_id is null |
|
''', |
|
|
|
|
|
|
|
|
|
'9. Gstin validation': ''' |
|
select |
|
company_id, |
|
company_name, |
|
ordering_channel |
|
from `fynd-db.finance_recon_tool_asia.11_seller_fees_daily` |
|
where |
|
company_gstn is null |
|
group by |
|
1,2,3 |
|
''', |
|
|
|
|
|
|
|
|
|
'10. Positive transaction components validation': ''' |
|
SELECT |
|
CONCAT(bag_id,transaction_type,total_charges) AS Merged, |
|
FROM |
|
`fynd-db.finance_recon_tool_asia.11_seller_fees_daily` |
|
GROUP BY |
|
1 |
|
HAVING |
|
COUNT(CONCAT(bag_id,transaction_type)) NOT IN (1) |
|
''', |
|
|
|
|
|
|
|
'11. Negative transaction components validation': ''' |
|
select |
|
* |
|
from `fynd-db.finance_recon_tool_asia.11_seller_fees_daily` |
|
where |
|
transaction_type = 'Return' |
|
and net_charges < 0 |
|
''', |
|
|
|
|
|
|
|
'12. GST Tag validation': ''' |
|
select |
|
company_id, |
|
company_name, |
|
ordering_channel, |
|
company_gstn, |
|
gst_tag, |
|
case WHEN LENGTH(company_gstn) = 10 then "SGST" |
|
when SUBSTRING(company_gstn,1,2) = '27' then "SGST" else "IGST" end as Tag, |
|
case when gst_tag = (case WHEN LENGTH(company_gstn) = 10 then "SGST" |
|
when SUBSTRING(company_gstn,1,2) = '27' then "SGST" else "IGST" end) then "Match" else "Not_Match" end as CC |
|
from `fynd-db.finance_recon_tool_asia.11_seller_fees_daily` |
|
where |
|
(case when gst_tag = (case WHEN LENGTH(company_gstn) = 10 then "SGST" |
|
when SUBSTRING(company_gstn,1,2) = '27' then "SGST" else "IGST" end) then "Match" else "Not_Match" end) = "Not_Match" |
|
group by 1,2,3,4,5,6 |
|
''', |
|
|
|
|
|
'13. 09_Net collection all data validation': ''' |
|
select |
|
A.company_id, |
|
A.company_name, |
|
A.ordering_channel, |
|
A.bag_id, |
|
A.Settlement_type, |
|
A.recon_status, |
|
A.recon_date, |
|
A.inserted_date, |
|
B.bag_id, |
|
B.Settlement_type |
|
from `fynd-db.finance_recon_tool_asia.01_finance_avis_data_final` as A |
|
left join |
|
`fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` as B |
|
on |
|
A.bag_id = B.bag_id |
|
and A.Settlement_type = B.Settlement_type |
|
where |
|
A.Settlement_type not in ('NA','SLA') |
|
and A.recon_status in ('delivery_done','return_bag_delivered','return_bag_picked') |
|
and B.bag_id is null |
|
and (case when A.Settlement_type = 'collection' and A.collection_partner = 'fynd' then 'yes' |
|
when A.Settlement_type = 'refund' and A.refund_partner = 'fynd' then 'yes' else 'no' end) = 'yes' |
|
group by |
|
1,2,3,4,5,6,7,8,9,10 |
|
''', |
|
|
|
|
|
|
|
'14. Net collection collection & refund validation': ''' |
|
select |
|
bag_id, |
|
settlement_type, |
|
collection_partner, |
|
refund_partner, |
|
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 |
|
from `fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` |
|
where |
|
(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' |
|
''', |
|
|
|
|
|
|
|
|
|
'15. 09_Net collection collection & refund validation': ''' |
|
select |
|
A.bag_id, |
|
B.bag_id, |
|
A.settlement_type, |
|
B.settlement_type, |
|
A.transaction_type, |
|
A.collection_partner, |
|
A.refund_partner, |
|
case when A.settlement_type = 'collection' and A.collection_partner = 'fynd' then 'Yes' when A.settlement_type = 'refund' and A.refund_partner = 'fynd' then 'Yes' else 'No' end as Comment |
|
from `fynd-db.finance_recon_tool_asia.01_finance_avis_data_final` as A |
|
left join |
|
`fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` as B |
|
on |
|
A.bag_id = B.bag_id |
|
and A.settlement_type = B.settlement_type |
|
where |
|
A.settlement_type <> 'NA' |
|
and A.recon_status not in ("bag_lost","return_bag_lost") |
|
and (case when A.settlement_type = 'collection' and A.collection_partner = 'fynd' then 'yes' when A.settlement_type = 'refund' and A.refund_partner = 'fynd' then 'yes' else 'No' end) = 'yes' |
|
and (case when A.transaction_type = 'Sale' and A.collection_partner = 'fynd' then 'Yes' when A.transaction_type = 'Return' and A.refund_partner = 'fynd' then 'Yes' when A.transaction_type = 'Claim' and A.collection_partner = 'fynd' then 'Yes' else 'No' end) = 'Yes' |
|
and B.bag_id is null |
|
''', |
|
|
|
|
|
|
|
'16. NA settlement validation': ''' |
|
select |
|
* |
|
from `fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` |
|
where |
|
-- settlement_type = 'NA' |
|
|
|
(case when settlement_type in ('collection','Claim','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' |
|
''', |
|
|
|
|
|
|
|
'17. Fynd collection placed bags validation': ''' |
|
select |
|
A.bag_id, |
|
B.bag_id, |
|
A.order_type, |
|
A.transaction_type, |
|
case when B.settlement_type = 'collection' then 'Sale' else 'Return' end as transaction_type, |
|
from `fynd-db.finance_recon_tool_asia.11_seller_fees_daily` as A |
|
left join |
|
`fynd-db.finance_recon_tool_asia.09_seller_net_collection_daily` as B |
|
on |
|
A.bag_id = B.bag_id |
|
and A.transaction_type = (case when B.settlement_type = 'collection' then 'Sale' when B.settlement_type = 'refund' then 'Return' else 'NA' end ) |
|
where |
|
transaction_type <> 'SLA' |
|
and (case when A.transaction_type = 'Sale' and A.collection_partner = 'fynd' then 'yes' when A.transaction_type = 'Return' and A.refund_partner = 'fynd' then 'yes' else 'no'end) = 'yes' |
|
and B.bag_id is null |
|
''', |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'19. Checking sett_id count in payout process table': ''' |
|
select |
|
sett_id, |
|
count(sett_id) |
|
from `fynd-db.finance_recon_tool_asia.payout_process_table` |
|
group by |
|
1 |
|
having |
|
count(sett_id) <> 1 |
|
''', |
|
|
|
|
|
'20. Checking bagwise payout report': ''' |
|
select |
|
UTR, |
|
paid_amt, |
|
dispute, |
|
round(sum(Net_Payout),2) as payable, |
|
round(sum(Net_Payout)+dispute-paid_amt) as Diff |
|
from `fynd-db.finance_recon_tool_asia.Bag_Wise_Payout_Report` |
|
where |
|
UTR in (select |
|
utr_no |
|
from |
|
`fynd-db.finance_recon_tool_asia.14_seller_payouts_New` |
|
where |
|
sett_date > "2024-04-01" ) |
|
group by |
|
1,2,3 |
|
having Diff > 0 |
|
''', |
|
|
|
|
|
'21. Checking claimwise payout report': ''' |
|
select |
|
SF_UTR, |
|
total_utr_paid, |
|
round(sum(claimable_amt),2), |
|
round(sum(claimable_amt)-total_utr_paid) as Diff |
|
from `fynd-db.finance_recon_tool_asia.Shipment_wise_Claim_UTR` |
|
where |
|
SF_UTR in ("_2414920231016000202198812", |
|
"_2414920231016000202197711", |
|
"_AXISCN0279665404", |
|
"_AXISCN0312196630", |
|
"_2414920231016000202198811") |
|
group by 1,2 |
|
having Diff <> 0 |
|
''', |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'22. Checking any old data inserted into new table': ''' |
|
select |
|
A.bag_id, |
|
collection_partner, |
|
Settlement_type, |
|
inserted_date, |
|
B.bag_id, |
|
B.Transaction_type |
|
from `fynd-db.finance_recon_tool_asia.01_finance_avis_data_final` as A |
|
left join |
|
`fynd-db.finance_dwh.Brand_Settlement_pulse` as B |
|
on A.bag_id = B.bag_id |
|
and (case when Settlement_type = 'collection' then 'Sale'when Settlement_type = 'refund' then 'Return' else 'Claim' end) = B.Transaction_type |
|
where |
|
Settlement_type <> 'NA' |
|
and B.bag_id is not null |
|
group by |
|
1,2,3,4,5,6 |
|
''', |
|
|
|
|
|
'23. Checking old lost claim check inserted into new table': ''' |
|
select |
|
* |
|
from `fynd-db.finance_recon_tool_asia.01_finance_avis_data_final` |
|
where |
|
Bag_ID in (select |
|
Bag_ID |
|
from `fynd-db.finance_dwh.Brand_Lost_settlement` |
|
group by |
|
1) |
|
and transaction_type = 'Claim' |
|
''', |
|
|
|
|
|
|
|
'24. Checking duplicate count in bag_wise payout report ': ''' |
|
with bag_count as |
|
(select |
|
bag_id, |
|
transaction_type, |
|
concat(bag_id,transaction_type,UTR) as merged, |
|
count(concat(bag_id,transaction_type)) as bag_count |
|
from `fynd-db.finance_recon_tool_asia.Bag_Wise_Payout_Report` |
|
group by |
|
1,2,3) |
|
|
|
select |
|
* |
|
from |
|
(select |
|
A.bag_id, |
|
company_id, |
|
company_name, |
|
Payment_Date, |
|
A.transaction_type, |
|
UTR, |
|
concat(A.bag_id,A.transaction_type,UTR) as merged, |
|
bag_count, |
|
seller_net_collection, |
|
total_charges, |
|
Net_Payout |
|
from `fynd-db.finance_recon_tool_asia.Bag_Wise_Payout_Report` as A |
|
left join |
|
bag_count as B |
|
on |
|
concat(A.bag_id,A.transaction_type,UTR) = B.merged |
|
where |
|
bag_count <> 1 |
|
) |
|
where bag_id = 32841543 |
|
group by |
|
all |
|
|
|
''', |
|
|
|
|
|
|
|
'25. Bags in 11_seller_fees_daily without collection partner as fynd ': ''' |
|
select |
|
* |
|
from |
|
`fynd-db.finance_recon_tool_asia.11_seller_fees_daily` |
|
where |
|
bag_id in ( |
|
select |
|
bag_id |
|
from |
|
`fynd-db.finance_recon_tool_asia.05_partner_collection` |
|
) |
|
and |
|
collection_partner <> 'fynd' |
|
''' |
|
|
|
|
|
} |