Thursday, 30 May 2013

AWT Invoices of a vendor gnerated by the system in month of may and june, and their payment

--AWT Invoices of a vendor gnerated by the system in month of may and june, and their payment(that is check_date) is made in july or aug or sep of next financial year,
--but thier WHT certificate is given in june of previous financial year.
select v.invoice_date Invoice_Date,c.check_date,v.invoice_amount from
ap_checks_all c,
ap_invoice_payments_all p,
ap_invoices_all     v
where
v.invoice_id=p.invoice_id
and c.check_id=p.check_id
and v.invoice_date  between '1-may-12' and '30-jun-12'
and c.check_date    between '1-jul-12' and '30-aug-12'
and v.invoice_id in (select d.awt_invoice_id   --This Query gives us the awt invoices of vendor, from standard invoices
from
ap_invoices_all v,                             -- distribution that is relation between invoices and distribution along with
                                               --  ap_awt_tax_rates                
ap_invoice_distributions_all d,
ap_awt_tax_rates_all         tr
where
v.invoice_id=d.invoice_id
and tr.tax_rate_id=d.awt_tax_rate_id
and d.line_type_lookup_code='AWT'
and v.invoice_date between &FDATE and &TODATE
and v.invoice_type_lookup_code='STANDARD'
and v.payment_status_flag='Y'
and tr.tax_name=&taxname
and v.vendor_id=&vendId)

No comments:

Post a Comment