|
|
|
queries = { |
|
|
|
'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 |
|
bag_id, |
|
concat(bag_id,transaction_type) as Merged, |
|
count(concat(bag_id,transaction_type)) |
|
from `fynd-db.finance_recon_tool_asia.11_seller_fees_daily` |
|
group by 1,2 |
|
having |
|
count(concat(bag_id,transaction_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 |
|
* |
|
from `fynd-db.finance_recon_tool_asia.11_seller_fees_daily` |
|
where |
|
transaction_type in ('Sale','SLA','Claim') |
|
and net_charges > 0 |
|
''', |
|
|
|
|
|
|
|
'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") 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") 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') 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 |
|
''', |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'18. PPD validation': ''' |
|
select |
|
* |
|
from |
|
(SELECT |
|
* |
|
FROM |
|
`fynd-db.Outstanding.09_Payable_File` |
|
where |
|
expected_payout_date <= current_date() |
|
and order_type = "PPD" |
|
and lower(collection_partner) = "seller") as A |
|
left join |
|
(select |
|
bag_id, |
|
txn_id, |
|
collected_amount |
|
from |
|
`fynd-db.finance_recon_tool_asia.05_partner_collection`) as B |
|
on |
|
A.bag_id = B.bag_id |
|
where |
|
B.bag_id is not null |
|
''', |
|
|
|
|
|
} |