0% found this document useful (0 votes)
5 views1 page

Qrysettlmnt

Uploaded by

Rethuna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Qrysettlmnt

Uploaded by

Rethuna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

"SELECT (select count(*) from invoiceheader where routekey=5494 and

COALESCE(voidflag,0) = 0)as totalsales ,


(select count(*) from salesorderheader where routekey=5494 and COALESCE(voidflag,0)
= 0)as totalorder ,
(select count(*) from arheader where advancepaymentflag=0 and routekey=5494 and
COALESCE(voidflag,0) = 0)as totalcollection,
(select count(*) from arheader where advancepaymentflag=1 and routekey=5494 and
COALESCE(voidflag,0) = 0)as totaladvancepayment,
CAST((select CAST(sum(ifnull(amount,0)) AS VARCHAR) - COALESCE((SELECT
CAST(SUM(amount) AS VARCHAR) from enddaydetail where detailtypecode= 2
and routekey=cashcheckdetail.routekey),0) from cashcheckdetail where istemp =
'false' and typecode=0 AND updateindicator=0 AND routekey=5494) AS VARCHAR)
as totalcash ,CAST((select sum(ifnull(amount,0)) from cashcheckdetail where
istemp = 'false' and typecode=1 AND routekey=5494) AS VARCHAR) as totalcheque,
CAST((select sum(ifnull(totalinvoiceamount,0)) from salesorderheader where
routekey=5494 and COALESCE(voidflag,0) = 0) AS VARCHAR) as totalorderamount,
CAST((select sum(ifnull(totalinvoiceamount,0)) from invoiceheader where
routekey=5494 and COALESCE(voidflag,0) = 0) AS VARCHAR) as totalsalesamount,
CAST((select sum(ifnull(totalinvoiceamount,0)) from invoiceheader where
gcpaymenttype=2 and routekey=5494 and COALESCE(voidflag,0) = 0) AS VARCHAR)as
totalcreditamount,
CAST((select sum(ifnull(immediatepaid,0)) from invoiceheader where immediatepaid!
=0 and routekey=5494 and COALESCE(voidflag,0) = 0) AS VARCHAR) as totalcashamount,
CAST((select sum(ifnull(amountpaid,0)) from arheader where routekey=5494 and
COALESCE(voidflag,0) = 0) AS VARCHAR) as totalcollectionadvanceamount,(select
ifnull(totalexpenses,0)
from startendday where routekey=5494)as totalexpenses,CAST((select sum((((CASE
WHEN im.unitspercase=1 THEN 0 ELSE itd.quantity END )%unitspercase)*itd.itemprice)
+(CAST(((CASE WHEN im.unitspercase=1 THEN itd.quantity ELSE itd.quantity END
)/unitspercase) AS INT)*itd.itemcaseprice) )from inventorytransactiondetail itd
inner join itemmaster im on im.actualitemcode=itd.itemcode And
itd.transactiontypecode in (9,10)) AS VARCHAR) as totalinventory,CAST((select
sum((((CASE WHEN im.unitspercase=1
THEN 0 ELSE itd.quantity END )%unitspercase)*itd.itemprice) +(CAST(((CASE WHEN
im.unitspercase=1 THEN itd.quantity ELSE itd.quantity END )/unitspercase) AS
INT)*itd.itemcaseprice)
+COALESCE((CASE WHEN im.unitspercase>1 and tm.taxbase = 1 THEN
( ( cast(( (COALESCE(itd.quantity,0))/ im.unitspercase) as
int)*im.exciseouterprice)
+ (((COALESCE(itd.quantity,0))%
im.unitspercase)*im.excisepackprice))*(tm.taxpercentage/100) WHEN
im.unitspercase<=1 and tm.taxbase = 1
THEN (((COALESCE(itd.quantity,0)))*im.excisepackprice)*tm.taxpercentage/100
END),0))from inventorytransactiondetail itd inner join itemmaster im on
im.actualitemcode=itd.itemcode
And itd.transactiontypecode in (10) left join taxmaster tm on
tm.taxcode=im.itemtaxkey1 ) AS VARCHAR) as totaldamageinventory,ifnull((select
sum(totalinvoiceamount) from invoiceheader
ih inner join customeroperationscontrol coc on ih.visitkey=coc.visitkey where
coc.reasoncode=1000 and ih.istemp='false'),0) as varianceinvoice ,
(select ifnull(cashvariance,0) from startendday where routekey=5494)as
cashvariance"

You might also like