SELECT cm.Centre, pr.proname `Sales_Manager`,pm.Payment_Mode, if(pm.Panel_Code='',pm.InvoiceTo,pm.Panel_Code) Client_Code,pm.company_name Client_Name, ROUND(SUM(IFNULL(t1_Credit.PreviousBookingWithoutInv,0))+ SUM(IFNULL(t1_Cash.PreviousBookingWithoutInv,0))+ SUM(IFNULL(t2.PreviousBookingWithInv,0))- SUM(IFNULL(t3_Credit.PreviousReceivedAmount,0))- SUM(IFNULL(t3_Cash.PreviousReceivedAmount,0)))OpeningAmount, ROUND(SUM(IFNULL(t4_Credit.CurrentBookingWithoutInv,0))+SUM(IFNULL(t4_Cash.CurrentBookingWithoutInv,0))+ SUM(IFNULL(t5.CurrentBookingWithInv,0))) CurrentBooking, ROUND(SUM(IFNULL(t6_Credit.CurrentReceivedAmount,0))+SUM(IFNULL(t6_Cash.CurrentReceivedAmount,0))) ReceivedAmount, ROUND(SUM(IFNULL(t1_Credit.PreviousBookingWithoutInv,0)) + SUM(IFNULL(t1_Cash.PreviousBookingWithoutInv,0)) + SUM(IFNULL(t2.PreviousBookingWithInv,0))+ SUM(IFNULL(t4_Credit.CurrentBookingWithoutInv,0)) + SUM(IFNULL(t4_Cash.CurrentBookingWithoutInv,0)) + SUM(IFNULL(t5.CurrentBookingWithInv,0))- SUM(IFNULL(t3_Credit.PreviousReceivedAmount,0)) - SUM(IFNULL(t3_Cash.PreviousReceivedAmount,0)) - SUM(IFNULL(t6_Credit.CurrentReceivedAmount,0))- SUM(IFNULL(t6_Cash.CurrentReceivedAmount,0)) ) ClosingAmount FROM f_panel_master pm INNER JOIN centre_master cm ON cm.CentreID=pm.TagBusinessLabID INNER JOIN pro_master pr ON pr.PROID=pm.PROID LEFT JOIN ( SELECT pm1.InvoiceTo panel_id, ifnull(SUM(IF(plos.`IsSampleCollected`='R',0,plos.`PCCInvoiceAmt`)),0) PreviousBookingWithoutInv FROM f_ledgertransaction lt INNER JOIN patient_labinvestigation_opd_share plos on plos.`LedgerTransactionID`=lt.`LedgerTransactionID` and lt.IsCredit>0 INNER JOIN f_panel_master pm1 ON pm1.panel_id=lt.panel_id WHERE plos.DATE<'2024-09-01 00:00:00' and ifnull(plos.InvoiceNo,'')='' AND pm1.InvoiceTo IN ('651','794','1194','508','842','668','851','1294','194','1023','256','375','1293','897','514','877','1265','682','1344','236','961','599','742','191','149','1251','1081','281','351','1008','1324','1151','413','1020','404','441','541','419','439','145','989','336','431','203','1244','380','1064','1281','1165','361','143','1137','1234','1181','568','1176','1261','397','517','686','545','241','1182','273','688','1021','181','1018','965','292','834','590','275','547','1177','403','1035','1116','652','390','494','168','156','704','973','459','201','501','942','153','489','1326','308','1218','1263','490','276','353','463','596','979','1140','705','523','770','1260','1135','1252','739','386','1314','841','1315','268','140','299','1275','939','376','147','857','387','158','389','424','1086','782','1043','1132','996','1172','587','398','660','694','406','571','669','626','364','655','636','667','634','643','663','618','683','644','637','645','638','617','616','728','664','374','734','598','1312','1012','760','679','1216','954','304','311','569','1321','573','493','267','232','1198','1209','1200','1169','293','346','167','1167','1336','230','435','775','774','687','385','963','737','787','535','544','1239','449','970','1100','297','1051','821','1071','888','929','882','1077','807','853','812','949','894','1049','934','865','801','904','1091','967','922','1123','1048','850','826','845','1073','1095','818','820','876','856','854','1074','875','916','813','838','814','1162','915','917','1164','893','1059','458','1047','1088','905','1107','804','859','868','1041','935','985','805','827','1078','986','943','928','884','1157','1096','1003','887','953','982','946','808','825','847','809','861','822','858','994','849','870','864','803','1083','1075','902','869','950','830','860','828','891','1143','1128','983','823','1094','913','1178','919','908','817','839','890','862','892','1092','816','1076','848','912','907','918','911','815','960','1084','819','1098','846','951','931','889','1121','937','1122','885','852','998','802','871','1067','800','855','1063','938','920','829','1093','959','1066','1129','872','1097','579','867','496','477','507','427','585','620','526','196','657','995','1053','322','1238','430','213','154','1032','661','670','677','947','741','795','455','1243','1044','1237','614','836','779','584','425','186','566','681','246','347','423','327','198','382','570','320','285','486','152','487','811','632','589','873','906','866','1161','1126','956','216','214','539','495','1105','1103','1104','1348','1349','574','577','305','1282','396','948','1189','1034','930','797','927','1062','903','662','722','685','729','754','767','831','696','750','675','747','1046','697','1163','631','752','999','806','684','749','755','753','698','968','629','633','743','914','745','783','763','727','768','955','719','778','786','940','952','725','665','723','713','1124','710','788','630','957','720','730','910','773','762','765','921','761','909','792','738','658','716','756','824','708','945','674','881','785','896','941','766','740','764','844','958','758','863','777','656','744','789','784','796','790','732','746','748','726','936','840','776','607','699','735','695','721','707','190','609','1351','329','328','1262','179','146','199','378','772','562','1019','703','613','1039','220','1150','1154','1343','1188','511','279','1217','1153','1190','316','1229','1085','274','898','611','1257','1242','1254','1278','164','266','290','348','1342','513','1246','1027','659','175','226','1042','234','1297','516','591','300','580','1001','1009','1130','317','280','180','1340','605','1302','1352','899','895','437','646','436','997','1319','549','250','543','264','484','263','1141','1270','1056','1110','1354','170','1306','610','1156','182','1158','360','358','1108','402','1241','1230','1332','711','1057','1111','428','1148','966','174','139','339','343','1249','313','835','291','1033','1299','1160','498','416','518','1333','992','253','462','1227','1226','1228','1330','1346','1347','1323','461','488','530','1202','1203','1286','257','414','576','363','137','244','608','475','252','519','470','1004','78','1166','258','499','460','138','482','231','648','649','647','650','400','251','160','1052','1255','603','1212','269','1026','833','991','372','1087','497','1274','1311','1060','883','192','210','586','718','714','1283','235','769','557','408','429','150','1296','1024','1144','976','271','709','1317','1258','1205','228','1058','1112','1173','515','1288','1068','1266','227','1308','561','1290','286','736','759','326','445','393','555','1113','1045','1276','223','1000','1183','368','1335','492','162','1082','440','987','712','880','202','1025','901','900','964','357','715','242','1353','594','421','1146','512','622','1210','205','1303','1192','306','1213','1145','700','165','981','502','757','1201','289','401','1072','365','409','340','771','283','1136','702','1247','255','1273','1159','359','1298','1171','1080','1322','211','595','1117','932','1245','248','247','249','438','189','1345','245','1109','538','692','969','504','392','284','465','1187','208','448','352','623','342','468','1291','184','510','799','1099','301','225','1040','1267','1253','1313','159','287','341','525','1065','1292','1028','349','1221','1174','467','218','843','307','444','975','379','990','558','333','418','318','615','1236','524','176','399','680','331','355','298','886','332','926','478','288','1284','391','556','1250','521','528','1309','1147','166','323','706','676','1017','1005','1320','254','923','1010','310','627','1220','1232','751','1280','1127','335','188','1233','602','474','1279','1175','217','456','624','1002','1118','588','207','1139','520','453','993','215','1029','540','434','529','1014','1186','452','1268','672','533','239','924','309','879','560','1036','473','469','565','505','277','222','407','1287','334','1102','1193','1304','270','837','442','1327','527','1152','324','1179','206','325','1197','204','1207','142','296','1155','1191','980','1054','1114','1289','1264','503','1301','415','481','731','148','302','1338','554','1211','1307','1090','1214','1256','1199','1038','1119','1070','1120','1310','604','984','978','564','793','1316','1037','420','183','1259','532','1195','315','1235','197','433','260','295','193','1050','1225','1277','583','259','373','362','384','567','1305','1271','224','1007','185','550','542','337','509','1318','1223','689','798','1215','597','443','878','693','1069','1180','1030','221','592','563','1295','151','593','321','1219','582','974','522','410','1101','1133','238','988','282','601','451','369','1224','371','141','1184','471','472','426','411','1285','581','962','243','1272','1089','944','1329','294','314','874','422','155','1350','1339','925','1055','1115','356','612','383','546','1300','345','1079','412','1134','575','1185','1240','338','395','319','1222','781','1149','531','1248','388','1356','1131','1325','450','370','464','491','733','717','240','454','479','1061','832','559','1331','1334','480','780','1269','1022','972','1208','229','1231','157','1168','791','366','1006','1011','1106','381','1016','1206','536','144','161','600','1170','169','394','1013','1337','1015','606','178','354','1204','261','621','671','534','1355','200','673','303','209','1138','506','1031','1328','553','551','537','237','163','1341','195','212','619','312','977','233','552','173','485','466','476','1125','278','701','350','1142','691') GROUP BY pm1.InvoiceTo ) t1_Credit ON pm.panel_id= t1_Credit.panel_id LEFT JOIN ( SELECT lt.panel_id, ifnull(SUM(plos.`Amount`),0) PreviousBookingWithoutInv FROM f_ledgertransaction lt INNER JOIN patient_labinvestigation_opd plos on plos.`LedgerTransactionID`=lt.`LedgerTransactionID` and lt.IsCredit=0 WHERE plos.DATE<'2024-09-01 00:00:00' AND lt.Panel_Id IN ('651','794','1194','508','842','668','851','1294','194','1023','256','375','1293','897','514','877','1265','682','1344','236','961','599','742','191','149','1251','1081','281','351','1008','1324','1151','413','1020','404','441','541','419','439','145','989','336','431','203','1244','380','1064','1281','1165','361','143','1137','1234','1181','568','1176','1261','397','517','686','545','241','1182','273','688','1021','181','1018','965','292','834','590','275','547','1177','403','1035','1116','652','390','494','168','156','704','973','459','201','501','942','153','489','1326','308','1218','1263','490','276','353','463','596','979','1140','705','523','770','1260','1135','1252','739','386','1314','841','1315','268','140','299','1275','939','376','147','857','387','158','389','424','1086','782','1043','1132','996','1172','587','398','660','694','406','571','669','626','364','655','636','667','634','643','663','618','683','644','637','645','638','617','616','728','664','374','734','598','1312','1012','760','679','1216','954','304','311','569','1321','573','493','267','232','1198','1209','1200','1169','293','346','167','1167','1336','230','435','775','774','687','385','963','737','787','535','544','1239','449','970','1100','297','1051','821','1071','888','929','882','1077','807','853','812','949','894','1049','934','865','801','904','1091','967','922','1123','1048','850','826','845','1073','1095','818','820','876','856','854','1074','875','916','813','838','814','1162','915','917','1164','893','1059','458','1047','1088','905','1107','804','859','868','1041','935','985','805','827','1078','986','943','928','884','1157','1096','1003','887','953','982','946','808','825','847','809','861','822','858','994','849','870','864','803','1083','1075','902','869','950','830','860','828','891','1143','1128','983','823','1094','913','1178','919','908','817','839','890','862','892','1092','816','1076','848','912','907','918','911','815','960','1084','819','1098','846','951','931','889','1121','937','1122','885','852','998','802','871','1067','800','855','1063','938','920','829','1093','959','1066','1129','872','1097','579','867','496','477','507','427','585','620','526','196','657','995','1053','322','1238','430','213','154','1032','661','670','677','947','741','795','455','1243','1044','1237','614','836','779','584','425','186','566','681','246','347','423','327','198','382','570','320','285','486','152','487','811','632','589','873','906','866','1161','1126','956','216','214','539','495','1105','1103','1104','1348','1349','574','577','305','1282','396','948','1189','1034','930','797','927','1062','903','662','722','685','729','754','767','831','696','750','675','747','1046','697','1163','631','752','999','806','684','749','755','753','698','968','629','633','743','914','745','783','763','727','768','955','719','778','786','940','952','725','665','723','713','1124','710','788','630','957','720','730','910','773','762','765','921','761','909','792','738','658','716','756','824','708','945','674','881','785','896','941','766','740','764','844','958','758','863','777','656','744','789','784','796','790','732','746','748','726','936','840','776','607','699','735','695','721','707','190','609','1351','329','328','1262','179','146','199','378','772','562','1019','703','613','1039','220','1150','1154','1343','1188','511','279','1217','1153','1190','316','1229','1085','274','898','611','1257','1242','1254','1278','164','266','290','348','1342','513','1246','1027','659','175','226','1042','234','1297','516','591','300','580','1001','1009','1130','317','280','180','1340','605','1302','1352','899','895','437','646','436','997','1319','549','250','543','264','484','263','1141','1270','1056','1110','1354','170','1306','610','1156','182','1158','360','358','1108','402','1241','1230','1332','711','1057','1111','428','1148','966','174','139','339','343','1249','313','835','291','1033','1299','1160','498','416','518','1333','992','253','462','1227','1226','1228','1330','1346','1347','1323','461','488','530','1202','1203','1286','257','414','576','363','137','244','608','475','252','519','470','1004','78','1166','258','499','460','138','482','231','648','649','647','650','400','251','160','1052','1255','603','1212','269','1026','833','991','372','1087','497','1274','1311','1060','883','192','210','586','718','714','1283','235','769','557','408','429','150','1296','1024','1144','976','271','709','1317','1258','1205','228','1058','1112','1173','515','1288','1068','1266','227','1308','561','1290','286','736','759','326','445','393','555','1113','1045','1276','223','1000','1183','368','1335','492','162','1082','440','987','712','880','202','1025','901','900','964','357','715','242','1353','594','421','1146','512','622','1210','205','1303','1192','306','1213','1145','700','165','981','502','757','1201','289','401','1072','365','409','340','771','283','1136','702','1247','255','1273','1159','359','1298','1171','1080','1322','211','595','1117','932','1245','248','247','249','438','189','1345','245','1109','538','692','969','504','392','284','465','1187','208','448','352','623','342','468','1291','184','510','799','1099','301','225','1040','1267','1253','1313','159','287','341','525','1065','1292','1028','349','1221','1174','467','218','843','307','444','975','379','990','558','333','418','318','615','1236','524','176','399','680','331','355','298','886','332','926','478','288','1284','391','556','1250','521','528','1309','1147','166','323','706','676','1017','1005','1320','254','923','1010','310','627','1220','1232','751','1280','1127','335','188','1233','602','474','1279','1175','217','456','624','1002','1118','588','207','1139','520','453','993','215','1029','540','434','529','1014','1186','452','1268','672','533','239','924','309','879','560','1036','473','469','565','505','277','222','407','1287','334','1102','1193','1304','270','837','442','1327','527','1152','324','1179','206','325','1197','204','1207','142','296','1155','1191','980','1054','1114','1289','1264','503','1301','415','481','731','148','302','1338','554','1211','1307','1090','1214','1256','1199','1038','1119','1070','1120','1310','604','984','978','564','793','1316','1037','420','183','1259','532','1195','315','1235','197','433','260','295','193','1050','1225','1277','583','259','373','362','384','567','1305','1271','224','1007','185','550','542','337','509','1318','1223','689','798','1215','597','443','878','693','1069','1180','1030','221','592','563','1295','151','593','321','1219','582','974','522','410','1101','1133','238','988','282','601','451','369','1224','371','141','1184','471','472','426','411','1285','581','962','243','1272','1089','944','1329','294','314','874','422','155','1350','1339','925','1055','1115','356','612','383','546','1300','345','1079','412','1134','575','1185','1240','338','395','319','1222','781','1149','531','1248','388','1356','1131','1325','450','370','464','491','733','717','240','454','479','1061','832','559','1331','1334','480','780','1269','1022','972','1208','229','1231','157','1168','791','366','1006','1011','1106','381','1016','1206','536','144','161','600','1170','169','394','1013','1337','1015','606','178','354','1204','261','621','671','534','1355','200','673','303','209','1138','506','1031','1328','553','551','537','237','163','1341','195','212','619','312','977','233','552','173','485','466','476','1125','278','701','350','1142','691') GROUP BY lt.Panel_Id ) t1_Cash ON pm.panel_id= t1_Cash.Panel_id LEFT JOIN ( SELECT pm1.InvoiceTo panel_id, ifnull(SUM(im.ShareAmt),0) PreviousBookingWithInv FROM invoicemaster im INNER JOIN f_panel_master pm1 ON pm1.panel_id=im.PanelID and im.IsCancel=0 WHERE im.InvoiceDate<'2024-09-01' AND pm1.InvoiceTo IN ('651','794','1194','508','842','668','851','1294','194','1023','256','375','1293','897','514','877','1265','682','1344','236','961','599','742','191','149','1251','1081','281','351','1008','1324','1151','413','1020','404','441','541','419','439','145','989','336','431','203','1244','380','1064','1281','1165','361','143','1137','1234','1181','568','1176','1261','397','517','686','545','241','1182','273','688','1021','181','1018','965','292','834','590','275','547','1177','403','1035','1116','652','390','494','168','156','704','973','459','201','501','942','153','489','1326','308','1218','1263','490','276','353','463','596','979','1140','705','523','770','1260','1135','1252','739','386','1314','841','1315','268','140','299','1275','939','376','147','857','387','158','389','424','1086','782','1043','1132','996','1172','587','398','660','694','406','571','669','626','364','655','636','667','634','643','663','618','683','644','637','645','638','617','616','728','664','374','734','598','1312','1012','760','679','1216','954','304','311','569','1321','573','493','267','232','1198','1209','1200','1169','293','346','167','1167','1336','230','435','775','774','687','385','963','737','787','535','544','1239','449','970','1100','297','1051','821','1071','888','929','882','1077','807','853','812','949','894','1049','934','865','801','904','1091','967','922','1123','1048','850','826','845','1073','1095','818','820','876','856','854','1074','875','916','813','838','814','1162','915','917','1164','893','1059','458','1047','1088','905','1107','804','859','868','1041','935','985','805','827','1078','986','943','928','884','1157','1096','1003','887','953','982','946','808','825','847','809','861','822','858','994','849','870','864','803','1083','1075','902','869','950','830','860','828','891','1143','1128','983','823','1094','913','1178','919','908','817','839','890','862','892','1092','816','1076','848','912','907','918','911','815','960','1084','819','1098','846','951','931','889','1121','937','1122','885','852','998','802','871','1067','800','855','1063','938','920','829','1093','959','1066','1129','872','1097','579','867','496','477','507','427','585','620','526','196','657','995','1053','322','1238','430','213','154','1032','661','670','677','947','741','795','455','1243','1044','1237','614','836','779','584','425','186','566','681','246','347','423','327','198','382','570','320','285','486','152','487','811','632','589','873','906','866','1161','1126','956','216','214','539','495','1105','1103','1104','1348','1349','574','577','305','1282','396','948','1189','1034','930','797','927','1062','903','662','722','685','729','754','767','831','696','750','675','747','1046','697','1163','631','752','999','806','684','749','755','753','698','968','629','633','743','914','745','783','763','727','768','955','719','778','786','940','952','725','665','723','713','1124','710','788','630','957','720','730','910','773','762','765','921','761','909','792','738','658','716','756','824','708','945','674','881','785','896','941','766','740','764','844','958','758','863','777','656','744','789','784','796','790','732','746','748','726','936','840','776','607','699','735','695','721','707','190','609','1351','329','328','1262','179','146','199','378','772','562','1019','703','613','1039','220','1150','1154','1343','1188','511','279','1217','1153','1190','316','1229','1085','274','898','611','1257','1242','1254','1278','164','266','290','348','1342','513','1246','1027','659','175','226','1042','234','1297','516','591','300','580','1001','1009','1130','317','280','180','1340','605','1302','1352','899','895','437','646','436','997','1319','549','250','543','264','484','263','1141','1270','1056','1110','1354','170','1306','610','1156','182','1158','360','358','1108','402','1241','1230','1332','711','1057','1111','428','1148','966','174','139','339','343','1249','313','835','291','1033','1299','1160','498','416','518','1333','992','253','462','1227','1226','1228','1330','1346','1347','1323','461','488','530','1202','1203','1286','257','414','576','363','137','244','608','475','252','519','470','1004','78','1166','258','499','460','138','482','231','648','649','647','650','400','251','160','1052','1255','603','1212','269','1026','833','991','372','1087','497','1274','1311','1060','883','192','210','586','718','714','1283','235','769','557','408','429','150','1296','1024','1144','976','271','709','1317','1258','1205','228','1058','1112','1173','515','1288','1068','1266','227','1308','561','1290','286','736','759','326','445','393','555','1113','1045','1276','223','1000','1183','368','1335','492','162','1082','440','987','712','880','202','1025','901','900','964','357','715','242','1353','594','421','1146','512','622','1210','205','1303','1192','306','1213','1145','700','165','981','502','757','1201','289','401','1072','365','409','340','771','283','1136','702','1247','255','1273','1159','359','1298','1171','1080','1322','211','595','1117','932','1245','248','247','249','438','189','1345','245','1109','538','692','969','504','392','284','465','1187','208','448','352','623','342','468','1291','184','510','799','1099','301','225','1040','1267','1253','1313','159','287','341','525','1065','1292','1028','349','1221','1174','467','218','843','307','444','975','379','990','558','333','418','318','615','1236','524','176','399','680','331','355','298','886','332','926','478','288','1284','391','556','1250','521','528','1309','1147','166','323','706','676','1017','1005','1320','254','923','1010','310','627','1220','1232','751','1280','1127','335','188','1233','602','474','1279','1175','217','456','624','1002','1118','588','207','1139','520','453','993','215','1029','540','434','529','1014','1186','452','1268','672','533','239','924','309','879','560','1036','473','469','565','505','277','222','407','1287','334','1102','1193','1304','270','837','442','1327','527','1152','324','1179','206','325','1197','204','1207','142','296','1155','1191','980','1054','1114','1289','1264','503','1301','415','481','731','148','302','1338','554','1211','1307','1090','1214','1256','1199','1038','1119','1070','1120','1310','604','984','978','564','793','1316','1037','420','183','1259','532','1195','315','1235','197','433','260','295','193','1050','1225','1277','583','259','373','362','384','567','1305','1271','224','1007','185','550','542','337','509','1318','1223','689','798','1215','597','443','878','693','1069','1180','1030','221','592','563','1295','151','593','321','1219','582','974','522','410','1101','1133','238','988','282','601','451','369','1224','371','141','1184','471','472','426','411','1285','581','962','243','1272','1089','944','1329','294','314','874','422','155','1350','1339','925','1055','1115','356','612','383','546','1300','345','1079','412','1134','575','1185','1240','338','395','319','1222','781','1149','531','1248','388','1356','1131','1325','450','370','464','491','733','717','240','454','479','1061','832','559','1331','1334','480','780','1269','1022','972','1208','229','1231','157','1168','791','366','1006','1011','1106','381','1016','1206','536','144','161','600','1170','169','394','1013','1337','1015','606','178','354','1204','261','621','671','534','1355','200','673','303','209','1138','506','1031','1328','553','551','537','237','163','1341','195','212','619','312','977','233','552','173','485','466','476','1125','278','701','350','1142','691') GROUP BY pm1.InvoiceTo ) t2 ON pm.panel_id= t2.panel_id LEFT JOIN ( SELECT panel_id , IFNULL(SUM(receivedamt),0) PreviousReceivedAmount FROM invoicemaster_onaccount WHERE ReceivedDate < '2024-09-01' AND panel_id IN ('651','794','1194','508','842','668','851','1294','194','1023','256','375','1293','897','514','877','1265','682','1344','236','961','599','742','191','149','1251','1081','281','351','1008','1324','1151','413','1020','404','441','541','419','439','145','989','336','431','203','1244','380','1064','1281','1165','361','143','1137','1234','1181','568','1176','1261','397','517','686','545','241','1182','273','688','1021','181','1018','965','292','834','590','275','547','1177','403','1035','1116','652','390','494','168','156','704','973','459','201','501','942','153','489','1326','308','1218','1263','490','276','353','463','596','979','1140','705','523','770','1260','1135','1252','739','386','1314','841','1315','268','140','299','1275','939','376','147','857','387','158','389','424','1086','782','1043','1132','996','1172','587','398','660','694','406','571','669','626','364','655','636','667','634','643','663','618','683','644','637','645','638','617','616','728','664','374','734','598','1312','1012','760','679','1216','954','304','311','569','1321','573','493','267','232','1198','1209','1200','1169','293','346','167','1167','1336','230','435','775','774','687','385','963','737','787','535','544','1239','449','970','1100','297','1051','821','1071','888','929','882','1077','807','853','812','949','894','1049','934','865','801','904','1091','967','922','1123','1048','850','826','845','1073','1095','818','820','876','856','854','1074','875','916','813','838','814','1162','915','917','1164','893','1059','458','1047','1088','905','1107','804','859','868','1041','935','985','805','827','1078','986','943','928','884','1157','1096','1003','887','953','982','946','808','825','847','809','861','822','858','994','849','870','864','803','1083','1075','902','869','950','830','860','828','891','1143','1128','983','823','1094','913','1178','919','908','817','839','890','862','892','1092','816','1076','848','912','907','918','911','815','960','1084','819','1098','846','951','931','889','1121','937','1122','885','852','998','802','871','1067','800','855','1063','938','920','829','1093','959','1066','1129','872','1097','579','867','496','477','507','427','585','620','526','196','657','995','1053','322','1238','430','213','154','1032','661','670','677','947','741','795','455','1243','1044','1237','614','836','779','584','425','186','566','681','246','347','423','327','198','382','570','320','285','486','152','487','811','632','589','873','906','866','1161','1126','956','216','214','539','495','1105','1103','1104','1348','1349','574','577','305','1282','396','948','1189','1034','930','797','927','1062','903','662','722','685','729','754','767','831','696','750','675','747','1046','697','1163','631','752','999','806','684','749','755','753','698','968','629','633','743','914','745','783','763','727','768','955','719','778','786','940','952','725','665','723','713','1124','710','788','630','957','720','730','910','773','762','765','921','761','909','792','738','658','716','756','824','708','945','674','881','785','896','941','766','740','764','844','958','758','863','777','656','744','789','784','796','790','732','746','748','726','936','840','776','607','699','735','695','721','707','190','609','1351','329','328','1262','179','146','199','378','772','562','1019','703','613','1039','220','1150','1154','1343','1188','511','279','1217','1153','1190','316','1229','1085','274','898','611','1257','1242','1254','1278','164','266','290','348','1342','513','1246','1027','659','175','226','1042','234','1297','516','591','300','580','1001','1009','1130','317','280','180','1340','605','1302','1352','899','895','437','646','436','997','1319','549','250','543','264','484','263','1141','1270','1056','1110','1354','170','1306','610','1156','182','1158','360','358','1108','402','1241','1230','1332','711','1057','1111','428','1148','966','174','139','339','343','1249','313','835','291','1033','1299','1160','498','416','518','1333','992','253','462','1227','1226','1228','1330','1346','1347','1323','461','488','530','1202','1203','1286','257','414','576','363','137','244','608','475','252','519','470','1004','78','1166','258','499','460','138','482','231','648','649','647','650','400','251','160','1052','1255','603','1212','269','1026','833','991','372','1087','497','1274','1311','1060','883','192','210','586','718','714','1283','235','769','557','408','429','150','1296','1024','1144','976','271','709','1317','1258','1205','228','1058','1112','1173','515','1288','1068','1266','227','1308','561','1290','286','736','759','326','445','393','555','1113','1045','1276','223','1000','1183','368','1335','492','162','1082','440','987','712','880','202','1025','901','900','964','357','715','242','1353','594','421','1146','512','622','1210','205','1303','1192','306','1213','1145','700','165','981','502','757','1201','289','401','1072','365','409','340','771','283','1136','702','1247','255','1273','1159','359','1298','1171','1080','1322','211','595','1117','932','1245','248','247','249','438','189','1345','245','1109','538','692','969','504','392','284','465','1187','208','448','352','623','342','468','1291','184','510','799','1099','301','225','1040','1267','1253','1313','159','287','341','525','1065','1292','1028','349','1221','1174','467','218','843','307','444','975','379','990','558','333','418','318','615','1236','524','176','399','680','331','355','298','886','332','926','478','288','1284','391','556','1250','521','528','1309','1147','166','323','706','676','1017','1005','1320','254','923','1010','310','627','1220','1232','751','1280','1127','335','188','1233','602','474','1279','1175','217','456','624','1002','1118','588','207','1139','520','453','993','215','1029','540','434','529','1014','1186','452','1268','672','533','239','924','309','879','560','1036','473','469','565','505','277','222','407','1287','334','1102','1193','1304','270','837','442','1327','527','1152','324','1179','206','325','1197','204','1207','142','296','1155','1191','980','1054','1114','1289','1264','503','1301','415','481','731','148','302','1338','554','1211','1307','1090','1214','1256','1199','1038','1119','1070','1120','1310','604','984','978','564','793','1316','1037','420','183','1259','532','1195','315','1235','197','433','260','295','193','1050','1225','1277','583','259','373','362','384','567','1305','1271','224','1007','185','550','542','337','509','1318','1223','689','798','1215','597','443','878','693','1069','1180','1030','221','592','563','1295','151','593','321','1219','582','974','522','410','1101','1133','238','988','282','601','451','369','1224','371','141','1184','471','472','426','411','1285','581','962','243','1272','1089','944','1329','294','314','874','422','155','1350','1339','925','1055','1115','356','612','383','546','1300','345','1079','412','1134','575','1185','1240','338','395','319','1222','781','1149','531','1248','388','1356','1131','1325','450','370','464','491','733','717','240','454','479','1061','832','559','1331','1334','480','780','1269','1022','972','1208','229','1231','157','1168','791','366','1006','1011','1106','381','1016','1206','536','144','161','600','1170','169','394','1013','1337','1015','606','178','354','1204','261','621','671','534','1355','200','673','303','209','1138','506','1031','1328','553','551','537','237','163','1341','195','212','619','312','977','233','552','173','485','466','476','1125','278','701','350','1142','691') AND iscancel=0 AND TYPE='ON ACCOUNT' GROUP BY Panel_id ) t3_Credit ON pm.panel_id=t3_Credit.panel_id LEFT JOIN ( SELECT lt.panel_id , IFNULL(SUM(r.Amount),0) PreviousReceivedAmount FROM f_receipt r INNER JOIN f_ledgertransaction lt ON lt.`LedgerTransactionID`=r.`LedgerTransactionID` AND lt.`IsCredit`=0 WHERE r.CreatedDate < '2024-09-01 00:00:00' AND lt.panel_id IN ('651','794','1194','508','842','668','851','1294','194','1023','256','375','1293','897','514','877','1265','682','1344','236','961','599','742','191','149','1251','1081','281','351','1008','1324','1151','413','1020','404','441','541','419','439','145','989','336','431','203','1244','380','1064','1281','1165','361','143','1137','1234','1181','568','1176','1261','397','517','686','545','241','1182','273','688','1021','181','1018','965','292','834','590','275','547','1177','403','1035','1116','652','390','494','168','156','704','973','459','201','501','942','153','489','1326','308','1218','1263','490','276','353','463','596','979','1140','705','523','770','1260','1135','1252','739','386','1314','841','1315','268','140','299','1275','939','376','147','857','387','158','389','424','1086','782','1043','1132','996','1172','587','398','660','694','406','571','669','626','364','655','636','667','634','643','663','618','683','644','637','645','638','617','616','728','664','374','734','598','1312','1012','760','679','1216','954','304','311','569','1321','573','493','267','232','1198','1209','1200','1169','293','346','167','1167','1336','230','435','775','774','687','385','963','737','787','535','544','1239','449','970','1100','297','1051','821','1071','888','929','882','1077','807','853','812','949','894','1049','934','865','801','904','1091','967','922','1123','1048','850','826','845','1073','1095','818','820','876','856','854','1074','875','916','813','838','814','1162','915','917','1164','893','1059','458','1047','1088','905','1107','804','859','868','1041','935','985','805','827','1078','986','943','928','884','1157','1096','1003','887','953','982','946','808','825','847','809','861','822','858','994','849','870','864','803','1083','1075','902','869','950','830','860','828','891','1143','1128','983','823','1094','913','1178','919','908','817','839','890','862','892','1092','816','1076','848','912','907','918','911','815','960','1084','819','1098','846','951','931','889','1121','937','1122','885','852','998','802','871','1067','800','855','1063','938','920','829','1093','959','1066','1129','872','1097','579','867','496','477','507','427','585','620','526','196','657','995','1053','322','1238','430','213','154','1032','661','670','677','947','741','795','455','1243','1044','1237','614','836','779','584','425','186','566','681','246','347','423','327','198','382','570','320','285','486','152','487','811','632','589','873','906','866','1161','1126','956','216','214','539','495','1105','1103','1104','1348','1349','574','577','305','1282','396','948','1189','1034','930','797','927','1062','903','662','722','685','729','754','767','831','696','750','675','747','1046','697','1163','631','752','999','806','684','749','755','753','698','968','629','633','743','914','745','783','763','727','768','955','719','778','786','940','952','725','665','723','713','1124','710','788','630','957','720','730','910','773','762','765','921','761','909','792','738','658','716','756','824','708','945','674','881','785','896','941','766','740','764','844','958','758','863','777','656','744','789','784','796','790','732','746','748','726','936','840','776','607','699','735','695','721','707','190','609','1351','329','328','1262','179','146','199','378','772','562','1019','703','613','1039','220','1150','1154','1343','1188','511','279','1217','1153','1190','316','1229','1085','274','898','611','1257','1242','1254','1278','164','266','290','348','1342','513','1246','1027','659','175','226','1042','234','1297','516','591','300','580','1001','1009','1130','317','280','180','1340','605','1302','1352','899','895','437','646','436','997','1319','549','250','543','264','484','263','1141','1270','1056','1110','1354','170','1306','610','1156','182','1158','360','358','1108','402','1241','1230','1332','711','1057','1111','428','1148','966','174','139','339','343','1249','313','835','291','1033','1299','1160','498','416','518','1333','992','253','462','1227','1226','1228','1330','1346','1347','1323','461','488','530','1202','1203','1286','257','414','576','363','137','244','608','475','252','519','470','1004','78','1166','258','499','460','138','482','231','648','649','647','650','400','251','160','1052','1255','603','1212','269','1026','833','991','372','1087','497','1274','1311','1060','883','192','210','586','718','714','1283','235','769','557','408','429','150','1296','1024','1144','976','271','709','1317','1258','1205','228','1058','1112','1173','515','1288','1068','1266','227','1308','561','1290','286','736','759','326','445','393','555','1113','1045','1276','223','1000','1183','368','1335','492','162','1082','440','987','712','880','202','1025','901','900','964','357','715','242','1353','594','421','1146','512','622','1210','205','1303','1192','306','1213','1145','700','165','981','502','757','1201','289','401','1072','365','409','340','771','283','1136','702','1247','255','1273','1159','359','1298','1171','1080','1322','211','595','1117','932','1245','248','247','249','438','189','1345','245','1109','538','692','969','504','392','284','465','1187','208','448','352','623','342','468','1291','184','510','799','1099','301','225','1040','1267','1253','1313','159','287','341','525','1065','1292','1028','349','1221','1174','467','218','843','307','444','975','379','990','558','333','418','318','615','1236','524','176','399','680','331','355','298','886','332','926','478','288','1284','391','556','1250','521','528','1309','1147','166','323','706','676','1017','1005','1320','254','923','1010','310','627','1220','1232','751','1280','1127','335','188','1233','602','474','1279','1175','217','456','624','1002','1118','588','207','1139','520','453','993','215','1029','540','434','529','1014','1186','452','1268','672','533','239','924','309','879','560','1036','473','469','565','505','277','222','407','1287','334','1102','1193','1304','270','837','442','1327','527','1152','324','1179','206','325','1197','204','1207','142','296','1155','1191','980','1054','1114','1289','1264','503','1301','415','481','731','148','302','1338','554','1211','1307','1090','1214','1256','1199','1038','1119','1070','1120','1310','604','984','978','564','793','1316','1037','420','183','1259','532','1195','315','1235','197','433','260','295','193','1050','1225','1277','583','259','373','362','384','567','1305','1271','224','1007','185','550','542','337','509','1318','1223','689','798','1215','597','443','878','693','1069','1180','1030','221','592','563','1295','151','593','321','1219','582','974','522','410','1101','1133','238','988','282','601','451','369','1224','371','141','1184','471','472','426','411','1285','581','962','243','1272','1089','944','1329','294','314','874','422','155','1350','1339','925','1055','1115','356','612','383','546','1300','345','1079','412','1134','575','1185','1240','338','395','319','1222','781','1149','531','1248','388','1356','1131','1325','450','370','464','491','733','717','240','454','479','1061','832','559','1331','1334','480','780','1269','1022','972','1208','229','1231','157','1168','791','366','1006','1011','1106','381','1016','1206','536','144','161','600','1170','169','394','1013','1337','1015','606','178','354','1204','261','621','671','534','1355','200','673','303','209','1138','506','1031','1328','553','551','537','237','163','1341','195','212','619','312','977','233','552','173','485','466','476','1125','278','701','350','1142','691') AND r.iscancel=0 GROUP BY lt.Panel_id ) t3_Cash ON pm.panel_id=t3_Cash.panel_id LEFT JOIN ( SELECT pm1.InvoiceTo panel_id,ifnull(SUM(IF(plos.`IsSampleCollected`='R',0,plos.`PCCInvoiceAmt`)),0) CurrentBookingWithoutInv FROM f_ledgertransaction lt INNER JOIN patient_labinvestigation_opd_share plos on plos.`LedgerTransactionID`=lt.`LedgerTransactionID` and lt.IsCredit>0 INNER JOIN f_panel_master pm1 ON pm1.panel_id=lt.panel_id and ifnull(plos.InvoiceNo,'')='' WHERE plos.DATE>='2024-09-01 00:00:00' and plos.DATE<='2024-09-30 23:59:59' AND pm1.InvoiceTo IN ('651','794','1194','508','842','668','851','1294','194','1023','256','375','1293','897','514','877','1265','682','1344','236','961','599','742','191','149','1251','1081','281','351','1008','1324','1151','413','1020','404','441','541','419','439','145','989','336','431','203','1244','380','1064','1281','1165','361','143','1137','1234','1181','568','1176','1261','397','517','686','545','241','1182','273','688','1021','181','1018','965','292','834','590','275','547','1177','403','1035','1116','652','390','494','168','156','704','973','459','201','501','942','153','489','1326','308','1218','1263','490','276','353','463','596','979','1140','705','523','770','1260','1135','1252','739','386','1314','841','1315','268','140','299','1275','939','376','147','857','387','158','389','424','1086','782','1043','1132','996','1172','587','398','660','694','406','571','669','626','364','655','636','667','634','643','663','618','683','644','637','645','638','617','616','728','664','374','734','598','1312','1012','760','679','1216','954','304','311','569','1321','573','493','267','232','1198','1209','1200','1169','293','346','167','1167','1336','230','435','775','774','687','385','963','737','787','535','544','1239','449','970','1100','297','1051','821','1071','888','929','882','1077','807','853','812','949','894','1049','934','865','801','904','1091','967','922','1123','1048','850','826','845','1073','1095','818','820','876','856','854','1074','875','916','813','838','814','1162','915','917','1164','893','1059','458','1047','1088','905','1107','804','859','868','1041','935','985','805','827','1078','986','943','928','884','1157','1096','1003','887','953','982','946','808','825','847','809','861','822','858','994','849','870','864','803','1083','1075','902','869','950','830','860','828','891','1143','1128','983','823','1094','913','1178','919','908','817','839','890','862','892','1092','816','1076','848','912','907','918','911','815','960','1084','819','1098','846','951','931','889','1121','937','1122','885','852','998','802','871','1067','800','855','1063','938','920','829','1093','959','1066','1129','872','1097','579','867','496','477','507','427','585','620','526','196','657','995','1053','322','1238','430','213','154','1032','661','670','677','947','741','795','455','1243','1044','1237','614','836','779','584','425','186','566','681','246','347','423','327','198','382','570','320','285','486','152','487','811','632','589','873','906','866','1161','1126','956','216','214','539','495','1105','1103','1104','1348','1349','574','577','305','1282','396','948','1189','1034','930','797','927','1062','903','662','722','685','729','754','767','831','696','750','675','747','1046','697','1163','631','752','999','806','684','749','755','753','698','968','629','633','743','914','745','783','763','727','768','955','719','778','786','940','952','725','665','723','713','1124','710','788','630','957','720','730','910','773','762','765','921','761','909','792','738','658','716','756','824','708','945','674','881','785','896','941','766','740','764','844','958','758','863','777','656','744','789','784','796','790','732','746','748','726','936','840','776','607','699','735','695','721','707','190','609','1351','329','328','1262','179','146','199','378','772','562','1019','703','613','1039','220','1150','1154','1343','1188','511','279','1217','1153','1190','316','1229','1085','274','898','611','1257','1242','1254','1278','164','266','290','348','1342','513','1246','1027','659','175','226','1042','234','1297','516','591','300','580','1001','1009','1130','317','280','180','1340','605','1302','1352','899','895','437','646','436','997','1319','549','250','543','264','484','263','1141','1270','1056','1110','1354','170','1306','610','1156','182','1158','360','358','1108','402','1241','1230','1332','711','1057','1111','428','1148','966','174','139','339','343','1249','313','835','291','1033','1299','1160','498','416','518','1333','992','253','462','1227','1226','1228','1330','1346','1347','1323','461','488','530','1202','1203','1286','257','414','576','363','137','244','608','475','252','519','470','1004','78','1166','258','499','460','138','482','231','648','649','647','650','400','251','160','1052','1255','603','1212','269','1026','833','991','372','1087','497','1274','1311','1060','883','192','210','586','718','714','1283','235','769','557','408','429','150','1296','1024','1144','976','271','709','1317','1258','1205','228','1058','1112','1173','515','1288','1068','1266','227','1308','561','1290','286','736','759','326','445','393','555','1113','1045','1276','223','1000','1183','368','1335','492','162','1082','440','987','712','880','202','1025','901','900','964','357','715','242','1353','594','421','1146','512','622','1210','205','1303','1192','306','1213','1145','700','165','981','502','757','1201','289','401','1072','365','409','340','771','283','1136','702','1247','255','1273','1159','359','1298','1171','1080','1322','211','595','1117','932','1245','248','247','249','438','189','1345','245','1109','538','692','969','504','392','284','465','1187','208','448','352','623','342','468','1291','184','510','799','1099','301','225','1040','1267','1253','1313','159','287','341','525','1065','1292','1028','349','1221','1174','467','218','843','307','444','975','379','990','558','333','418','318','615','1236','524','176','399','680','331','355','298','886','332','926','478','288','1284','391','556','1250','521','528','1309','1147','166','323','706','676','1017','1005','1320','254','923','1010','310','627','1220','1232','751','1280','1127','335','188','1233','602','474','1279','1175','217','456','624','1002','1118','588','207','1139','520','453','993','215','1029','540','434','529','1014','1186','452','1268','672','533','239','924','309','879','560','1036','473','469','565','505','277','222','407','1287','334','1102','1193','1304','270','837','442','1327','527','1152','324','1179','206','325','1197','204','1207','142','296','1155','1191','980','1054','1114','1289','1264','503','1301','415','481','731','148','302','1338','554','1211','1307','1090','1214','1256','1199','1038','1119','1070','1120','1310','604','984','978','564','793','1316','1037','420','183','1259','532','1195','315','1235','197','433','260','295','193','1050','1225','1277','583','259','373','362','384','567','1305','1271','224','1007','185','550','542','337','509','1318','1223','689','798','1215','597','443','878','693','1069','1180','1030','221','592','563','1295','151','593','321','1219','582','974','522','410','1101','1133','238','988','282','601','451','369','1224','371','141','1184','471','472','426','411','1285','581','962','243','1272','1089','944','1329','294','314','874','422','155','1350','1339','925','1055','1115','356','612','383','546','1300','345','1079','412','1134','575','1185','1240','338','395','319','1222','781','1149','531','1248','388','1356','1131','1325','450','370','464','491','733','717','240','454','479','1061','832','559','1331','1334','480','780','1269','1022','972','1208','229','1231','157','1168','791','366','1006','1011','1106','381','1016','1206','536','144','161','600','1170','169','394','1013','1337','1015','606','178','354','1204','261','621','671','534','1355','200','673','303','209','1138','506','1031','1328','553','551','537','237','163','1341','195','212','619','312','977','233','552','173','485','466','476','1125','278','701','350','1142','691') GROUP BY pm1.InvoiceTo ) t4_Credit ON pm.panel_id= t4_Credit.panel_id LEFT JOIN ( SELECT lt.Panel_ID, ifnull(SUM(plos.`Amount`),0) CurrentBookingWithoutInv FROM f_ledgertransaction lt INNER JOIN patient_labinvestigation_opd plos on plos.`LedgerTransactionID`=lt.`LedgerTransactionID` and lt.IsCredit=0 WHERE plos.DATE>='2024-09-01 00:00:00' and plos.DATE<='2024-09-30 23:59:59' AND lt.Panel_ID IN ('651','794','1194','508','842','668','851','1294','194','1023','256','375','1293','897','514','877','1265','682','1344','236','961','599','742','191','149','1251','1081','281','351','1008','1324','1151','413','1020','404','441','541','419','439','145','989','336','431','203','1244','380','1064','1281','1165','361','143','1137','1234','1181','568','1176','1261','397','517','686','545','241','1182','273','688','1021','181','1018','965','292','834','590','275','547','1177','403','1035','1116','652','390','494','168','156','704','973','459','201','501','942','153','489','1326','308','1218','1263','490','276','353','463','596','979','1140','705','523','770','1260','1135','1252','739','386','1314','841','1315','268','140','299','1275','939','376','147','857','387','158','389','424','1086','782','1043','1132','996','1172','587','398','660','694','406','571','669','626','364','655','636','667','634','643','663','618','683','644','637','645','638','617','616','728','664','374','734','598','1312','1012','760','679','1216','954','304','311','569','1321','573','493','267','232','1198','1209','1200','1169','293','346','167','1167','1336','230','435','775','774','687','385','963','737','787','535','544','1239','449','970','1100','297','1051','821','1071','888','929','882','1077','807','853','812','949','894','1049','934','865','801','904','1091','967','922','1123','1048','850','826','845','1073','1095','818','820','876','856','854','1074','875','916','813','838','814','1162','915','917','1164','893','1059','458','1047','1088','905','1107','804','859','868','1041','935','985','805','827','1078','986','943','928','884','1157','1096','1003','887','953','982','946','808','825','847','809','861','822','858','994','849','870','864','803','1083','1075','902','869','950','830','860','828','891','1143','1128','983','823','1094','913','1178','919','908','817','839','890','862','892','1092','816','1076','848','912','907','918','911','815','960','1084','819','1098','846','951','931','889','1121','937','1122','885','852','998','802','871','1067','800','855','1063','938','920','829','1093','959','1066','1129','872','1097','579','867','496','477','507','427','585','620','526','196','657','995','1053','322','1238','430','213','154','1032','661','670','677','947','741','795','455','1243','1044','1237','614','836','779','584','425','186','566','681','246','347','423','327','198','382','570','320','285','486','152','487','811','632','589','873','906','866','1161','1126','956','216','214','539','495','1105','1103','1104','1348','1349','574','577','305','1282','396','948','1189','1034','930','797','927','1062','903','662','722','685','729','754','767','831','696','750','675','747','1046','697','1163','631','752','999','806','684','749','755','753','698','968','629','633','743','914','745','783','763','727','768','955','719','778','786','940','952','725','665','723','713','1124','710','788','630','957','720','730','910','773','762','765','921','761','909','792','738','658','716','756','824','708','945','674','881','785','896','941','766','740','764','844','958','758','863','777','656','744','789','784','796','790','732','746','748','726','936','840','776','607','699','735','695','721','707','190','609','1351','329','328','1262','179','146','199','378','772','562','1019','703','613','1039','220','1150','1154','1343','1188','511','279','1217','1153','1190','316','1229','1085','274','898','611','1257','1242','1254','1278','164','266','290','348','1342','513','1246','1027','659','175','226','1042','234','1297','516','591','300','580','1001','1009','1130','317','280','180','1340','605','1302','1352','899','895','437','646','436','997','1319','549','250','543','264','484','263','1141','1270','1056','1110','1354','170','1306','610','1156','182','1158','360','358','1108','402','1241','1230','1332','711','1057','1111','428','1148','966','174','139','339','343','1249','313','835','291','1033','1299','1160','498','416','518','1333','992','253','462','1227','1226','1228','1330','1346','1347','1323','461','488','530','1202','1203','1286','257','414','576','363','137','244','608','475','252','519','470','1004','78','1166','258','499','460','138','482','231','648','649','647','650','400','251','160','1052','1255','603','1212','269','1026','833','991','372','1087','497','1274','1311','1060','883','192','210','586','718','714','1283','235','769','557','408','429','150','1296','1024','1144','976','271','709','1317','1258','1205','228','1058','1112','1173','515','1288','1068','1266','227','1308','561','1290','286','736','759','326','445','393','555','1113','1045','1276','223','1000','1183','368','1335','492','162','1082','440','987','712','880','202','1025','901','900','964','357','715','242','1353','594','421','1146','512','622','1210','205','1303','1192','306','1213','1145','700','165','981','502','757','1201','289','401','1072','365','409','340','771','283','1136','702','1247','255','1273','1159','359','1298','1171','1080','1322','211','595','1117','932','1245','248','247','249','438','189','1345','245','1109','538','692','969','504','392','284','465','1187','208','448','352','623','342','468','1291','184','510','799','1099','301','225','1040','1267','1253','1313','159','287','341','525','1065','1292','1028','349','1221','1174','467','218','843','307','444','975','379','990','558','333','418','318','615','1236','524','176','399','680','331','355','298','886','332','926','478','288','1284','391','556','1250','521','528','1309','1147','166','323','706','676','1017','1005','1320','254','923','1010','310','627','1220','1232','751','1280','1127','335','188','1233','602','474','1279','1175','217','456','624','1002','1118','588','207','1139','520','453','993','215','1029','540','434','529','1014','1186','452','1268','672','533','239','924','309','879','560','1036','473','469','565','505','277','222','407','1287','334','1102','1193','1304','270','837','442','1327','527','1152','324','1179','206','325','1197','204','1207','142','296','1155','1191','980','1054','1114','1289','1264','503','1301','415','481','731','148','302','1338','554','1211','1307','1090','1214','1256','1199','1038','1119','1070','1120','1310','604','984','978','564','793','1316','1037','420','183','1259','532','1195','315','1235','197','433','260','295','193','1050','1225','1277','583','259','373','362','384','567','1305','1271','224','1007','185','550','542','337','509','1318','1223','689','798','1215','597','443','878','693','1069','1180','1030','221','592','563','1295','151','593','321','1219','582','974','522','410','1101','1133','238','988','282','601','451','369','1224','371','141','1184','471','472','426','411','1285','581','962','243','1272','1089','944','1329','294','314','874','422','155','1350','1339','925','1055','1115','356','612','383','546','1300','345','1079','412','1134','575','1185','1240','338','395','319','1222','781','1149','531','1248','388','1356','1131','1325','450','370','464','491','733','717','240','454','479','1061','832','559','1331','1334','480','780','1269','1022','972','1208','229','1231','157','1168','791','366','1006','1011','1106','381','1016','1206','536','144','161','600','1170','169','394','1013','1337','1015','606','178','354','1204','261','621','671','534','1355','200','673','303','209','1138','506','1031','1328','553','551','537','237','163','1341','195','212','619','312','977','233','552','173','485','466','476','1125','278','701','350','1142','691') GROUP BY lt.Panel_ID ) t4_Cash ON pm.panel_id= t4_Cash.panel_id LEFT JOIN ( SELECT pm1.InvoiceTo panel_id, ifnull(SUM(im.ShareAmt),0) CurrentBookingWithInv FROM invoicemaster im INNER JOIN f_panel_master pm1 ON pm1.panel_id=im.PanelID and im.IsCancel=0 WHERE im.InvoiceDate>='2024-09-01' and im.InvoiceDate<='2024-09-30' AND pm1.InvoiceTo IN ('651','794','1194','508','842','668','851','1294','194','1023','256','375','1293','897','514','877','1265','682','1344','236','961','599','742','191','149','1251','1081','281','351','1008','1324','1151','413','1020','404','441','541','419','439','145','989','336','431','203','1244','380','1064','1281','1165','361','143','1137','1234','1181','568','1176','1261','397','517','686','545','241','1182','273','688','1021','181','1018','965','292','834','590','275','547','1177','403','1035','1116','652','390','494','168','156','704','973','459','201','501','942','153','489','1326','308','1218','1263','490','276','353','463','596','979','1140','705','523','770','1260','1135','1252','739','386','1314','841','1315','268','140','299','1275','939','376','147','857','387','158','389','424','1086','782','1043','1132','996','1172','587','398','660','694','406','571','669','626','364','655','636','667','634','643','663','618','683','644','637','645','638','617','616','728','664','374','734','598','1312','1012','760','679','1216','954','304','311','569','1321','573','493','267','232','1198','1209','1200','1169','293','346','167','1167','1336','230','435','775','774','687','385','963','737','787','535','544','1239','449','970','1100','297','1051','821','1071','888','929','882','1077','807','853','812','949','894','1049','934','865','801','904','1091','967','922','1123','1048','850','826','845','1073','1095','818','820','876','856','854','1074','875','916','813','838','814','1162','915','917','1164','893','1059','458','1047','1088','905','1107','804','859','868','1041','935','985','805','827','1078','986','943','928','884','1157','1096','1003','887','953','982','946','808','825','847','809','861','822','858','994','849','870','864','803','1083','1075','902','869','950','830','860','828','891','1143','1128','983','823','1094','913','1178','919','908','817','839','890','862','892','1092','816','1076','848','912','907','918','911','815','960','1084','819','1098','846','951','931','889','1121','937','1122','885','852','998','802','871','1067','800','855','1063','938','920','829','1093','959','1066','1129','872','1097','579','867','496','477','507','427','585','620','526','196','657','995','1053','322','1238','430','213','154','1032','661','670','677','947','741','795','455','1243','1044','1237','614','836','779','584','425','186','566','681','246','347','423','327','198','382','570','320','285','486','152','487','811','632','589','873','906','866','1161','1126','956','216','214','539','495','1105','1103','1104','1348','1349','574','577','305','1282','396','948','1189','1034','930','797','927','1062','903','662','722','685','729','754','767','831','696','750','675','747','1046','697','1163','631','752','999','806','684','749','755','753','698','968','629','633','743','914','745','783','763','727','768','955','719','778','786','940','952','725','665','723','713','1124','710','788','630','957','720','730','910','773','762','765','921','761','909','792','738','658','716','756','824','708','945','674','881','785','896','941','766','740','764','844','958','758','863','777','656','744','789','784','796','790','732','746','748','726','936','840','776','607','699','735','695','721','707','190','609','1351','329','328','1262','179','146','199','378','772','562','1019','703','613','1039','220','1150','1154','1343','1188','511','279','1217','1153','1190','316','1229','1085','274','898','611','1257','1242','1254','1278','164','266','290','348','1342','513','1246','1027','659','175','226','1042','234','1297','516','591','300','580','1001','1009','1130','317','280','180','1340','605','1302','1352','899','895','437','646','436','997','1319','549','250','543','264','484','263','1141','1270','1056','1110','1354','170','1306','610','1156','182','1158','360','358','1108','402','1241','1230','1332','711','1057','1111','428','1148','966','174','139','339','343','1249','313','835','291','1033','1299','1160','498','416','518','1333','992','253','462','1227','1226','1228','1330','1346','1347','1323','461','488','530','1202','1203','1286','257','414','576','363','137','244','608','475','252','519','470','1004','78','1166','258','499','460','138','482','231','648','649','647','650','400','251','160','1052','1255','603','1212','269','1026','833','991','372','1087','497','1274','1311','1060','883','192','210','586','718','714','1283','235','769','557','408','429','150','1296','1024','1144','976','271','709','1317','1258','1205','228','1058','1112','1173','515','1288','1068','1266','227','1308','561','1290','286','736','759','326','445','393','555','1113','1045','1276','223','1000','1183','368','1335','492','162','1082','440','987','712','880','202','1025','901','900','964','357','715','242','1353','594','421','1146','512','622','1210','205','1303','1192','306','1213','1145','700','165','981','502','757','1201','289','401','1072','365','409','340','771','283','1136','702','1247','255','1273','1159','359','1298','1171','1080','1322','211','595','1117','932','1245','248','247','249','438','189','1345','245','1109','538','692','969','504','392','284','465','1187','208','448','352','623','342','468','1291','184','510','799','1099','301','225','1040','1267','1253','1313','159','287','341','525','1065','1292','1028','349','1221','1174','467','218','843','307','444','975','379','990','558','333','418','318','615','1236','524','176','399','680','331','355','298','886','332','926','478','288','1284','391','556','1250','521','528','1309','1147','166','323','706','676','1017','1005','1320','254','923','1010','310','627','1220','1232','751','1280','1127','335','188','1233','602','474','1279','1175','217','456','624','1002','1118','588','207','1139','520','453','993','215','1029','540','434','529','1014','1186','452','1268','672','533','239','924','309','879','560','1036','473','469','565','505','277','222','407','1287','334','1102','1193','1304','270','837','442','1327','527','1152','324','1179','206','325','1197','204','1207','142','296','1155','1191','980','1054','1114','1289','1264','503','1301','415','481','731','148','302','1338','554','1211','1307','1090','1214','1256','1199','1038','1119','1070','1120','1310','604','984','978','564','793','1316','1037','420','183','1259','532','1195','315','1235','197','433','260','295','193','1050','1225','1277','583','259','373','362','384','567','1305','1271','224','1007','185','550','542','337','509','1318','1223','689','798','1215','597','443','878','693','1069','1180','1030','221','592','563','1295','151','593','321','1219','582','974','522','410','1101','1133','238','988','282','601','451','369','1224','371','141','1184','471','472','426','411','1285','581','962','243','1272','1089','944','1329','294','314','874','422','155','1350','1339','925','1055','1115','356','612','383','546','1300','345','1079','412','1134','575','1185','1240','338','395','319','1222','781','1149','531','1248','388','1356','1131','1325','450','370','464','491','733','717','240','454','479','1061','832','559','1331','1334','480','780','1269','1022','972','1208','229','1231','157','1168','791','366','1006','1011','1106','381','1016','1206','536','144','161','600','1170','169','394','1013','1337','1015','606','178','354','1204','261','621','671','534','1355','200','673','303','209','1138','506','1031','1328','553','551','537','237','163','1341','195','212','619','312','977','233','552','173','485','466','476','1125','278','701','350','1142','691') GROUP BY pm1.InvoiceTo ) t5 ON pm.panel_id= t5.panel_id LEFT JOIN ( SELECT panel_id , IFNULL(SUM(receivedamt),0) CurrentReceivedAmount FROM invoicemaster_onaccount WHERE ReceivedDate >= '2024-09-01' and ReceivedDate<= '2024-09-30' AND panel_id IN ('651','794','1194','508','842','668','851','1294','194','1023','256','375','1293','897','514','877','1265','682','1344','236','961','599','742','191','149','1251','1081','281','351','1008','1324','1151','413','1020','404','441','541','419','439','145','989','336','431','203','1244','380','1064','1281','1165','361','143','1137','1234','1181','568','1176','1261','397','517','686','545','241','1182','273','688','1021','181','1018','965','292','834','590','275','547','1177','403','1035','1116','652','390','494','168','156','704','973','459','201','501','942','153','489','1326','308','1218','1263','490','276','353','463','596','979','1140','705','523','770','1260','1135','1252','739','386','1314','841','1315','268','140','299','1275','939','376','147','857','387','158','389','424','1086','782','1043','1132','996','1172','587','398','660','694','406','571','669','626','364','655','636','667','634','643','663','618','683','644','637','645','638','617','616','728','664','374','734','598','1312','1012','760','679','1216','954','304','311','569','1321','573','493','267','232','1198','1209','1200','1169','293','346','167','1167','1336','230','435','775','774','687','385','963','737','787','535','544','1239','449','970','1100','297','1051','821','1071','888','929','882','1077','807','853','812','949','894','1049','934','865','801','904','1091','967','922','1123','1048','850','826','845','1073','1095','818','820','876','856','854','1074','875','916','813','838','814','1162','915','917','1164','893','1059','458','1047','1088','905','1107','804','859','868','1041','935','985','805','827','1078','986','943','928','884','1157','1096','1003','887','953','982','946','808','825','847','809','861','822','858','994','849','870','864','803','1083','1075','902','869','950','830','860','828','891','1143','1128','983','823','1094','913','1178','919','908','817','839','890','862','892','1092','816','1076','848','912','907','918','911','815','960','1084','819','1098','846','951','931','889','1121','937','1122','885','852','998','802','871','1067','800','855','1063','938','920','829','1093','959','1066','1129','872','1097','579','867','496','477','507','427','585','620','526','196','657','995','1053','322','1238','430','213','154','1032','661','670','677','947','741','795','455','1243','1044','1237','614','836','779','584','425','186','566','681','246','347','423','327','198','382','570','320','285','486','152','487','811','632','589','873','906','866','1161','1126','956','216','214','539','495','1105','1103','1104','1348','1349','574','577','305','1282','396','948','1189','1034','930','797','927','1062','903','662','722','685','729','754','767','831','696','750','675','747','1046','697','1163','631','752','999','806','684','749','755','753','698','968','629','633','743','914','745','783','763','727','768','955','719','778','786','940','952','725','665','723','713','1124','710','788','630','957','720','730','910','773','762','765','921','761','909','792','738','658','716','756','824','708','945','674','881','785','896','941','766','740','764','844','958','758','863','777','656','744','789','784','796','790','732','746','748','726','936','840','776','607','699','735','695','721','707','190','609','1351','329','328','1262','179','146','199','378','772','562','1019','703','613','1039','220','1150','1154','1343','1188','511','279','1217','1153','1190','316','1229','1085','274','898','611','1257','1242','1254','1278','164','266','290','348','1342','513','1246','1027','659','175','226','1042','234','1297','516','591','300','580','1001','1009','1130','317','280','180','1340','605','1302','1352','899','895','437','646','436','997','1319','549','250','543','264','484','263','1141','1270','1056','1110','1354','170','1306','610','1156','182','1158','360','358','1108','402','1241','1230','1332','711','1057','1111','428','1148','966','174','139','339','343','1249','313','835','291','1033','1299','1160','498','416','518','1333','992','253','462','1227','1226','1228','1330','1346','1347','1323','461','488','530','1202','1203','1286','257','414','576','363','137','244','608','475','252','519','470','1004','78','1166','258','499','460','138','482','231','648','649','647','650','400','251','160','1052','1255','603','1212','269','1026','833','991','372','1087','497','1274','1311','1060','883','192','210','586','718','714','1283','235','769','557','408','429','150','1296','1024','1144','976','271','709','1317','1258','1205','228','1058','1112','1173','515','1288','1068','1266','227','1308','561','1290','286','736','759','326','445','393','555','1113','1045','1276','223','1000','1183','368','1335','492','162','1082','440','987','712','880','202','1025','901','900','964','357','715','242','1353','594','421','1146','512','622','1210','205','1303','1192','306','1213','1145','700','165','981','502','757','1201','289','401','1072','365','409','340','771','283','1136','702','1247','255','1273','1159','359','1298','1171','1080','1322','211','595','1117','932','1245','248','247','249','438','189','1345','245','1109','538','692','969','504','392','284','465','1187','208','448','352','623','342','468','1291','184','510','799','1099','301','225','1040','1267','1253','1313','159','287','341','525','1065','1292','1028','349','1221','1174','467','218','843','307','444','975','379','990','558','333','418','318','615','1236','524','176','399','680','331','355','298','886','332','926','478','288','1284','391','556','1250','521','528','1309','1147','166','323','706','676','1017','1005','1320','254','923','1010','310','627','1220','1232','751','1280','1127','335','188','1233','602','474','1279','1175','217','456','624','1002','1118','588','207','1139','520','453','993','215','1029','540','434','529','1014','1186','452','1268','672','533','239','924','309','879','560','1036','473','469','565','505','277','222','407','1287','334','1102','1193','1304','270','837','442','1327','527','1152','324','1179','206','325','1197','204','1207','142','296','1155','1191','980','1054','1114','1289','1264','503','1301','415','481','731','148','302','1338','554','1211','1307','1090','1214','1256','1199','1038','1119','1070','1120','1310','604','984','978','564','793','1316','1037','420','183','1259','532','1195','315','1235','197','433','260','295','193','1050','1225','1277','583','259','373','362','384','567','1305','1271','224','1007','185','550','542','337','509','1318','1223','689','798','1215','597','443','878','693','1069','1180','1030','221','592','563','1295','151','593','321','1219','582','974','522','410','1101','1133','238','988','282','601','451','369','1224','371','141','1184','471','472','426','411','1285','581','962','243','1272','1089','944','1329','294','314','874','422','155','1350','1339','925','1055','1115','356','612','383','546','1300','345','1079','412','1134','575','1185','1240','338','395','319','1222','781','1149','531','1248','388','1356','1131','1325','450','370','464','491','733','717','240','454','479','1061','832','559','1331','1334','480','780','1269','1022','972','1208','229','1231','157','1168','791','366','1006','1011','1106','381','1016','1206','536','144','161','600','1170','169','394','1013','1337','1015','606','178','354','1204','261','621','671','534','1355','200','673','303','209','1138','506','1031','1328','553','551','537','237','163','1341','195','212','619','312','977','233','552','173','485','466','476','1125','278','701','350','1142','691') AND iscancel=0 AND TYPE='ON ACCOUNT' GROUP BY Panel_id ) t6_Credit ON pm.panel_id=t6_Credit.panel_id LEFT JOIN ( SELECT lt.panel_id , IFNULL(SUM(r.Amount),0) CurrentReceivedAmount FROM f_receipt r INNER JOIN f_ledgertransaction lt ON lt.`LedgerTransactionID`=r.`LedgerTransactionID` AND lt.`IsCredit`=0 WHERE r.CreatedDate >= '2024-09-01 00:00:00' and r.CreatedDate<= '2024-09-30 23:59:59' AND lt.Panel_id IN ('651','794','1194','508','842','668','851','1294','194','1023','256','375','1293','897','514','877','1265','682','1344','236','961','599','742','191','149','1251','1081','281','351','1008','1324','1151','413','1020','404','441','541','419','439','145','989','336','431','203','1244','380','1064','1281','1165','361','143','1137','1234','1181','568','1176','1261','397','517','686','545','241','1182','273','688','1021','181','1018','965','292','834','590','275','547','1177','403','1035','1116','652','390','494','168','156','704','973','459','201','501','942','153','489','1326','308','1218','1263','490','276','353','463','596','979','1140','705','523','770','1260','1135','1252','739','386','1314','841','1315','268','140','299','1275','939','376','147','857','387','158','389','424','1086','782','1043','1132','996','1172','587','398','660','694','406','571','669','626','364','655','636','667','634','643','663','618','683','644','637','645','638','617','616','728','664','374','734','598','1312','1012','760','679','1216','954','304','311','569','1321','573','493','267','232','1198','1209','1200','1169','293','346','167','1167','1336','230','435','775','774','687','385','963','737','787','535','544','1239','449','970','1100','297','1051','821','1071','888','929','882','1077','807','853','812','949','894','1049','934','865','801','904','1091','967','922','1123','1048','850','826','845','1073','1095','818','820','876','856','854','1074','875','916','813','838','814','1162','915','917','1164','893','1059','458','1047','1088','905','1107','804','859','868','1041','935','985','805','827','1078','986','943','928','884','1157','1096','1003','887','953','982','946','808','825','847','809','861','822','858','994','849','870','864','803','1083','1075','902','869','950','830','860','828','891','1143','1128','983','823','1094','913','1178','919','908','817','839','890','862','892','1092','816','1076','848','912','907','918','911','815','960','1084','819','1098','846','951','931','889','1121','937','1122','885','852','998','802','871','1067','800','855','1063','938','920','829','1093','959','1066','1129','872','1097','579','867','496','477','507','427','585','620','526','196','657','995','1053','322','1238','430','213','154','1032','661','670','677','947','741','795','455','1243','1044','1237','614','836','779','584','425','186','566','681','246','347','423','327','198','382','570','320','285','486','152','487','811','632','589','873','906','866','1161','1126','956','216','214','539','495','1105','1103','1104','1348','1349','574','577','305','1282','396','948','1189','1034','930','797','927','1062','903','662','722','685','729','754','767','831','696','750','675','747','1046','697','1163','631','752','999','806','684','749','755','753','698','968','629','633','743','914','745','783','763','727','768','955','719','778','786','940','952','725','665','723','713','1124','710','788','630','957','720','730','910','773','762','765','921','761','909','792','738','658','716','756','824','708','945','674','881','785','896','941','766','740','764','844','958','758','863','777','656','744','789','784','796','790','732','746','748','726','936','840','776','607','699','735','695','721','707','190','609','1351','329','328','1262','179','146','199','378','772','562','1019','703','613','1039','220','1150','1154','1343','1188','511','279','1217','1153','1190','316','1229','1085','274','898','611','1257','1242','1254','1278','164','266','290','348','1342','513','1246','1027','659','175','226','1042','234','1297','516','591','300','580','1001','1009','1130','317','280','180','1340','605','1302','1352','899','895','437','646','436','997','1319','549','250','543','264','484','263','1141','1270','1056','1110','1354','170','1306','610','1156','182','1158','360','358','1108','402','1241','1230','1332','711','1057','1111','428','1148','966','174','139','339','343','1249','313','835','291','1033','1299','1160','498','416','518','1333','992','253','462','1227','1226','1228','1330','1346','1347','1323','461','488','530','1202','1203','1286','257','414','576','363','137','244','608','475','252','519','470','1004','78','1166','258','499','460','138','482','231','648','649','647','650','400','251','160','1052','1255','603','1212','269','1026','833','991','372','1087','497','1274','1311','1060','883','192','210','586','718','714','1283','235','769','557','408','429','150','1296','1024','1144','976','271','709','1317','1258','1205','228','1058','1112','1173','515','1288','1068','1266','227','1308','561','1290','286','736','759','326','445','393','555','1113','1045','1276','223','1000','1183','368','1335','492','162','1082','440','987','712','880','202','1025','901','900','964','357','715','242','1353','594','421','1146','512','622','1210','205','1303','1192','306','1213','1145','700','165','981','502','757','1201','289','401','1072','365','409','340','771','283','1136','702','1247','255','1273','1159','359','1298','1171','1080','1322','211','595','1117','932','1245','248','247','249','438','189','1345','245','1109','538','692','969','504','392','284','465','1187','208','448','352','623','342','468','1291','184','510','799','1099','301','225','1040','1267','1253','1313','159','287','341','525','1065','1292','1028','349','1221','1174','467','218','843','307','444','975','379','990','558','333','418','318','615','1236','524','176','399','680','331','355','298','886','332','926','478','288','1284','391','556','1250','521','528','1309','1147','166','323','706','676','1017','1005','1320','254','923','1010','310','627','1220','1232','751','1280','1127','335','188','1233','602','474','1279','1175','217','456','624','1002','1118','588','207','1139','520','453','993','215','1029','540','434','529','1014','1186','452','1268','672','533','239','924','309','879','560','1036','473','469','565','505','277','222','407','1287','334','1102','1193','1304','270','837','442','1327','527','1152','324','1179','206','325','1197','204','1207','142','296','1155','1191','980','1054','1114','1289','1264','503','1301','415','481','731','148','302','1338','554','1211','1307','1090','1214','1256','1199','1038','1119','1070','1120','1310','604','984','978','564','793','1316','1037','420','183','1259','532','1195','315','1235','197','433','260','295','193','1050','1225','1277','583','259','373','362','384','567','1305','1271','224','1007','185','550','542','337','509','1318','1223','689','798','1215','597','443','878','693','1069','1180','1030','221','592','563','1295','151','593','321','1219','582','974','522','410','1101','1133','238','988','282','601','451','369','1224','371','141','1184','471','472','426','411','1285','581','962','243','1272','1089','944','1329','294','314','874','422','155','1350','1339','925','1055','1115','356','612','383','546','1300','345','1079','412','1134','575','1185','1240','338','395','319','1222','781','1149','531','1248','388','1356','1131','1325','450','370','464','491','733','717','240','454','479','1061','832','559','1331','1334','480','780','1269','1022','972','1208','229','1231','157','1168','791','366','1006','1011','1106','381','1016','1206','536','144','161','600','1170','169','394','1013','1337','1015','606','178','354','1204','261','621','671','534','1355','200','673','303','209','1138','506','1031','1328','553','551','537','237','163','1341','195','212','619','312','977','233','552','173','485','466','476','1125','278','701','350','1142','691') AND r.iscancel=0 GROUP BY lt.Panel_id ) t6_Cash ON pm.panel_id=t6_Cash.panel_id WHERE pm.InvoiceTo IN ('651','794','1194','508','842','668','851','1294','194','1023','256','375','1293','897','514','877','1265','682','1344','236','961','599','742','191','149','1251','1081','281','351','1008','1324','1151','413','1020','404','441','541','419','439','145','989','336','431','203','1244','380','1064','1281','1165','361','143','1137','1234','1181','568','1176','1261','397','517','686','545','241','1182','273','688','1021','181','1018','965','292','834','590','275','547','1177','403','1035','1116','652','390','494','168','156','704','973','459','201','501','942','153','489','1326','308','1218','1263','490','276','353','463','596','979','1140','705','523','770','1260','1135','1252','739','386','1314','841','1315','268','140','299','1275','939','376','147','857','387','158','389','424','1086','782','1043','1132','996','1172','587','398','660','694','406','571','669','626','364','655','636','667','634','643','663','618','683','644','637','645','638','617','616','728','664','374','734','598','1312','1012','760','679','1216','954','304','311','569','1321','573','493','267','232','1198','1209','1200','1169','293','346','167','1167','1336','230','435','775','774','687','385','963','737','787','535','544','1239','449','970','1100','297','1051','821','1071','888','929','882','1077','807','853','812','949','894','1049','934','865','801','904','1091','967','922','1123','1048','850','826','845','1073','1095','818','820','876','856','854','1074','875','916','813','838','814','1162','915','917','1164','893','1059','458','1047','1088','905','1107','804','859','868','1041','935','985','805','827','1078','986','943','928','884','1157','1096','1003','887','953','982','946','808','825','847','809','861','822','858','994','849','870','864','803','1083','1075','902','869','950','830','860','828','891','1143','1128','983','823','1094','913','1178','919','908','817','839','890','862','892','1092','816','1076','848','912','907','918','911','815','960','1084','819','1098','846','951','931','889','1121','937','1122','885','852','998','802','871','1067','800','855','1063','938','920','829','1093','959','1066','1129','872','1097','579','867','496','477','507','427','585','620','526','196','657','995','1053','322','1238','430','213','154','1032','661','670','677','947','741','795','455','1243','1044','1237','614','836','779','584','425','186','566','681','246','347','423','327','198','382','570','320','285','486','152','487','811','632','589','873','906','866','1161','1126','956','216','214','539','495','1105','1103','1104','1348','1349','574','577','305','1282','396','948','1189','1034','930','797','927','1062','903','662','722','685','729','754','767','831','696','750','675','747','1046','697','1163','631','752','999','806','684','749','755','753','698','968','629','633','743','914','745','783','763','727','768','955','719','778','786','940','952','725','665','723','713','1124','710','788','630','957','720','730','910','773','762','765','921','761','909','792','738','658','716','756','824','708','945','674','881','785','896','941','766','740','764','844','958','758','863','777','656','744','789','784','796','790','732','746','748','726','936','840','776','607','699','735','695','721','707','190','609','1351','329','328','1262','179','146','199','378','772','562','1019','703','613','1039','220','1150','1154','1343','1188','511','279','1217','1153','1190','316','1229','1085','274','898','611','1257','1242','1254','1278','164','266','290','348','1342','513','1246','1027','659','175','226','1042','234','1297','516','591','300','580','1001','1009','1130','317','280','180','1340','605','1302','1352','899','895','437','646','436','997','1319','549','250','543','264','484','263','1141','1270','1056','1110','1354','170','1306','610','1156','182','1158','360','358','1108','402','1241','1230','1332','711','1057','1111','428','1148','966','174','139','339','343','1249','313','835','291','1033','1299','1160','498','416','518','1333','992','253','462','1227','1226','1228','1330','1346','1347','1323','461','488','530','1202','1203','1286','257','414','576','363','137','244','608','475','252','519','470','1004','78','1166','258','499','460','138','482','231','648','649','647','650','400','251','160','1052','1255','603','1212','269','1026','833','991','372','1087','497','1274','1311','1060','883','192','210','586','718','714','1283','235','769','557','408','429','150','1296','1024','1144','976','271','709','1317','1258','1205','228','1058','1112','1173','515','1288','1068','1266','227','1308','561','1290','286','736','759','326','445','393','555','1113','1045','1276','223','1000','1183','368','1335','492','162','1082','440','987','712','880','202','1025','901','900','964','357','715','242','1353','594','421','1146','512','622','1210','205','1303','1192','306','1213','1145','700','165','981','502','757','1201','289','401','1072','365','409','340','771','283','1136','702','1247','255','1273','1159','359','1298','1171','1080','1322','211','595','1117','932','1245','248','247','249','438','189','1345','245','1109','538','692','969','504','392','284','465','1187','208','448','352','623','342','468','1291','184','510','799','1099','301','225','1040','1267','1253','1313','159','287','341','525','1065','1292','1028','349','1221','1174','467','218','843','307','444','975','379','990','558','333','418','318','615','1236','524','176','399','680','331','355','298','886','332','926','478','288','1284','391','556','1250','521','528','1309','1147','166','323','706','676','1017','1005','1320','254','923','1010','310','627','1220','1232','751','1280','1127','335','188','1233','602','474','1279','1175','217','456','624','1002','1118','588','207','1139','520','453','993','215','1029','540','434','529','1014','1186','452','1268','672','533','239','924','309','879','560','1036','473','469','565','505','277','222','407','1287','334','1102','1193','1304','270','837','442','1327','527','1152','324','1179','206','325','1197','204','1207','142','296','1155','1191','980','1054','1114','1289','1264','503','1301','415','481','731','148','302','1338','554','1211','1307','1090','1214','1256','1199','1038','1119','1070','1120','1310','604','984','978','564','793','1316','1037','420','183','1259','532','1195','315','1235','197','433','260','295','193','1050','1225','1277','583','259','373','362','384','567','1305','1271','224','1007','185','550','542','337','509','1318','1223','689','798','1215','597','443','878','693','1069','1180','1030','221','592','563','1295','151','593','321','1219','582','974','522','410','1101','1133','238','988','282','601','451','369','1224','371','141','1184','471','472','426','411','1285','581','962','243','1272','1089','944','1329','294','314','874','422','155','1350','1339','925','1055','1115','356','612','383','546','1300','345','1079','412','1134','575','1185','1240','338','395','319','1222','781','1149','531','1248','388','1356','1131','1325','450','370','464','491','733','717','240','454','479','1061','832','559','1331','1334','480','780','1269','1022','972','1208','229','1231','157','1168','791','366','1006','1011','1106','381','1016','1206','536','144','161','600','1170','169','394','1013','1337','1015','606','178','354','1204','261','621','671','534','1355','200','673','303','209','1138','506','1031','1328','553','551','537','237','163','1341','195','212','619','312','977','233','552','173','485','466','476','1125','278','701','350','1142','691') and pm.TagBusinessLabID in ('5','2','6','1','3','4') and pr.ProID in ('101','22','64','74','20','120','1','15','49','21','108','47','84','122','28','4','27','24','23','2','33','36','67','68','12','3','48','112','38','61','42','17','62','115','124','114','111','53','41','102','45','70','89','119','30','18','59','96','116','76','55','85','105','65','106','104','109','29','113','60','6','34','43','75','125','54','25','97','39','95','71','100','110','117','58','5','35','86','98','83','87','91','90','8','63','16','66','88','123','50','9','94','93','118','7','80','37','73','13','44','92','10','103','78','19','40','57','11','32','79','81','77','121','26','82','14','69','51','52','107','56','72','99','46','31') group by pm.invoiceto order by pm.company_name;