postgresql-2023-08-20_000000.log:2023-08-20 08:00:13 +04,11042 LOG: duration: 7256.751 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-20_000000.log:2023-08-20 09:00:13 +04,12448 LOG: duration: 7255.263 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-20_000000.log:2023-08-20 10:00:13 +04,13891 LOG: duration: 7458.275 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-20_000000.log:2023-08-20 11:00:13 +04,15314 LOG: duration: 7275.303 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-20_000000.log:2023-08-20 12:00:12 +04,16679 LOG: duration: 7270.926 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-20_000000.log:2023-08-20 13:00:12 +04,18057 LOG: duration: 7270.791 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-20_000000.log:2023-08-20 14:00:13 +04,19422 LOG: duration: 7263.623 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-20_000000.log:2023-08-20 15:00:12 +04,20789 LOG: duration: 7287.723 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-20_000000.log:2023-08-20 16:00:13 +04,22199 LOG: duration: 7265.416 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-20_000000.log:2023-08-20 17:00:13 +04,23586 LOG: duration: 7854.466 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-20_000000.log:2023-08-20 18:00:13 +04,25043 LOG: duration: 7893.967 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-21_000000.log:2023-08-21 08:00:13 +04,11479 LOG: duration: 7802.041 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-21_000000.log:2023-08-21 08:26:55 +04,12077 LOG: duration: 16746.422 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-21_000000.log:2023-08-21 08:27:09 +04,12076 LOG: duration: 31825.028 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_000000.log:2023-08-21 08:49:46 +04,12079 LOG: duration: 16587.285 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-21_000000.log:2023-08-21 08:50:01 +04,12640 LOG: duration: 31772.188 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_000000.log:2023-08-21 09:00:14 +04,13047 LOG: duration: 7830.143 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-21_000000.log:2023-08-21 09:21:07 +04,13243 LOG: duration: 13249.645 ms execute : select pr.name as name, sum(coalesce(st.qtyonhand, 0) )as qty, pr.UPC as barcode, pr.m_product_id, sum(st.qtyreserved) as reserved, pr.unitsperpack, pc.name as proCategoryName, (coalesce(pr.group1,' ')||' '||coalesce(pr.group2,' ')) as group, coalesce(sum(st.qtyOrdered), 0) as qty_ordered, sum(coalesce(minl.pickedqty, 0) + coalesce(mmov.movementqty, 0) + coalesce(st.qtyintransit, 0)) as qtyintransit, coalesce(uomc.dividerate,1) as dividerate, uom.c_uom_id, uom.uomsymbol, uom.stdprecision,pr.sku as SKU, productAttribute(pr.m_attributesetinstance_id) AS nonInstanceAttribute ,null as firstAttributeValue , pbp.name as vendorname, pr.group1, pr.group2, pr.commodity_code,pr.classification as pclassification, case when pr.cw_uom_id > 0 then sum(coalesce(st.cwqtyonhand, 0)) else 0 end as cwqty, pr.hscode as hscode, pr.c_taxcategory_id as c_taxcategory_id, sum(coalesce(minl.pickedqty, 0)) venShippedQty FROM M_PRODUCT pr JOIN M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on pr.m_product_id = uomc.m_product_id LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN M_product_PO ppo on pr.m_product_id = ppo.m_product_id and ppo.iscurrentvendor='Y' LEFT JOIN C_Bpartner pbp on ppo.c_bpartner_id = pbp.c_bpartner_id JOIN c_taxcategory tc on tc.c_taxcategory_id = pr.c_taxcategory_id LEFT JOIN (SELECT SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.qtyonhand END), 0)) qtyonhand, SUM(COALESCE(s.qtyreserved, 0)) qtyreserved, SUM(COALESCE(s.qtyOrdered, 0)) qtyOrdered, SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN s.qtyonhand ELSE 0 END), 0)) qtyintransit, s.m_product_id , SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.cwqtyonhand END), 0)) cwqtyonhand FROM M_Storage s JOIN M_Locator loc ON loc.m_locator_id = s.m_locator_id JOIN M_Warehouse wr ON wr.m_warehouse_id = loc.m_warehouse_id WHERE s.m_locator_id in (select m_locator_id from m_locator where m_warehouse_id = 1000000) GROUP BY s.m_product_id) st ON (st.M_PRODUCT_ID=pr.M_PRODUCT_ID AND ((st.qtyonhand+st.qtyreserved+st.qtyordered+st.qtyintransit+st.cwqtyonhand) <> 0 OR st.qtyonhand <> 0 OR st.qtyreserved <> 0 OR st.qtyordered <> 0 OR st.qtyintransit<>0 OR st.cwqtyonhand <>0 )) left join (select sum(inl.pickedqty) as pickedqty, inl.m_product_id, inl.m_attributesetinstance_id from m_inoutline inl join m_inout min on inl.m_inout_id = min.m_inout_id where min.docstatus in ('IP') AND min.m_warehouse_id = 1000000 group by m_product_id, inl.m_attributesetinstance_id) minl on pr.m_product_id = minl.m_product_id left join (select sum(m.movementqty) as movementqty, m.m_product_id, m.m_attributesetinstance_id from m_movementline m join m_movement mov on m.m_movement_id = mov.m_movement_id and mov.docstatus in ('IP') AND m.m_locatorto_id in (select m_locator_id from m_locator where m_warehouse_id = 1000000) group by m_product_id, m.m_attributesetinstance_id) mmov on pr.m_product_id = mmov.m_product_id where pr.isbaseproduct = 'N' AND pr.AD_CLIENT_ID = 1000000 and pr.isactive = 'Y' AND pc.m_product_category_id in (1000008,1005208,1005219,1015314,1005287,1015326) and lower(coalesce(pr.group1,'')) like lower($1) AND pr.ad_org_id IN (0,1000000) group by pr.m_product_id, pc.name, uomc.dividerate,uom.c_uom_id, firstAttributeValue,pbp.name having sum(st.qtyonhand)> 0 order by name postgresql-2023-08-21_000000.log:2023-08-21 09:21:26 +04,13610 LOG: duration: 13370.688 ms execute : select pr.name as name, sum(coalesce(st.qtyonhand, 0) )as qty, pr.UPC as barcode, pr.m_product_id, sum(st.qtyreserved) as reserved, pr.unitsperpack, pc.name as proCategoryName, (coalesce(pr.group1,' ')||' '||coalesce(pr.group2,' ')) as group, coalesce(sum(st.qtyOrdered), 0) as qty_ordered, sum(coalesce(minl.pickedqty, 0) + coalesce(mmov.movementqty, 0) + coalesce(st.qtyintransit, 0)) as qtyintransit, coalesce(uomc.dividerate,1) as dividerate, uom.c_uom_id, uom.uomsymbol, uom.stdprecision,pr.sku as SKU, productAttribute(pr.m_attributesetinstance_id) AS nonInstanceAttribute ,null as firstAttributeValue , pbp.name as vendorname, pr.group1, pr.group2, pr.commodity_code,pr.classification as pclassification, case when pr.cw_uom_id > 0 then sum(coalesce(st.cwqtyonhand, 0)) else 0 end as cwqty, pr.hscode as hscode, pr.c_taxcategory_id as c_taxcategory_id, sum(coalesce(minl.pickedqty, 0)) venShippedQty FROM M_PRODUCT pr JOIN M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on pr.m_product_id = uomc.m_product_id LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN M_product_PO ppo on pr.m_product_id = ppo.m_product_id and ppo.iscurrentvendor='Y' LEFT JOIN C_Bpartner pbp on ppo.c_bpartner_id = pbp.c_bpartner_id JOIN c_taxcategory tc on tc.c_taxcategory_id = pr.c_taxcategory_id LEFT JOIN (SELECT SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.qtyonhand END), 0)) qtyonhand, SUM(COALESCE(s.qtyreserved, 0)) qtyreserved, SUM(COALESCE(s.qtyOrdered, 0)) qtyOrdered, SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN s.qtyonhand ELSE 0 END), 0)) qtyintransit, s.m_product_id , SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.cwqtyonhand END), 0)) cwqtyonhand FROM M_Storage s JOIN M_Locator loc ON loc.m_locator_id = s.m_locator_id JOIN M_Warehouse wr ON wr.m_warehouse_id = loc.m_warehouse_id WHERE s.m_locator_id in (select m_locator_id from m_locator where m_warehouse_id = 1000000) GROUP BY s.m_product_id) st ON (st.M_PRODUCT_ID=pr.M_PRODUCT_ID AND ((st.qtyonhand+st.qtyreserved+st.qtyordered+st.qtyintransit+st.cwqtyonhand) <> 0 OR st.qtyonhand <> 0 OR st.qtyreserved <> 0 OR st.qtyordered <> 0 OR st.qtyintransit<>0 OR st.cwqtyonhand <>0 )) left join (select sum(inl.pickedqty) as pickedqty, inl.m_product_id, inl.m_attributesetinstance_id from m_inoutline inl join m_inout min on inl.m_inout_id = min.m_inout_id where min.docstatus in ('IP') AND min.m_warehouse_id = 1000000 group by m_product_id, inl.m_attributesetinstance_id) minl on pr.m_product_id = minl.m_product_id left join (select sum(m.movementqty) as movementqty, m.m_product_id, m.m_attributesetinstance_id from m_movementline m join m_movement mov on m.m_movement_id = mov.m_movement_id and mov.docstatus in ('IP') AND m.m_locatorto_id in (select m_locator_id from m_locator where m_warehouse_id = 1000000) group by m_product_id, m.m_attributesetinstance_id) mmov on pr.m_product_id = mmov.m_product_id where pr.isbaseproduct = 'N' AND pr.AD_CLIENT_ID = 1000000 and pr.isactive = 'Y' AND pc.m_product_category_id in (1000008,1005208,1005219,1015314,1005287,1015326) and lower(coalesce(pr.group1,'')) like lower($1) AND pr.ad_org_id IN (0,1000000) group by pr.m_product_id, pc.name, uomc.dividerate,uom.c_uom_id, firstAttributeValue,pbp.name having sum(st.qtyonhand)> 25 order by name postgresql-2023-08-21_000000.log:2023-08-21 09:24:19 +04,13243 LOG: duration: 15854.528 ms execute : select pr.name as name, sum(coalesce(st.qtyonhand, 0) )as qty, pr.UPC as barcode, pr.m_product_id, sum(st.qtyreserved) as reserved, pr.unitsperpack, pc.name as proCategoryName, (coalesce(pr.group1,' ')||' '||coalesce(pr.group2,' ')) as group, coalesce(sum(st.qtyOrdered), 0) as qty_ordered, sum(coalesce(minl.pickedqty, 0) + coalesce(mmov.movementqty, 0) + coalesce(st.qtyintransit, 0)) as qtyintransit, coalesce(uomc.dividerate,1) as dividerate, uom.c_uom_id, uom.uomsymbol, uom.stdprecision,pr.sku as SKU, productAttribute(pr.m_attributesetinstance_id) AS nonInstanceAttribute ,null as firstAttributeValue , pbp.name as vendorname, pr.group1, pr.group2, pr.commodity_code,pr.classification as pclassification, case when pr.cw_uom_id > 0 then sum(coalesce(st.cwqtyonhand, 0)) else 0 end as cwqty, pr.hscode as hscode, pr.c_taxcategory_id as c_taxcategory_id, sum(coalesce(minl.pickedqty, 0)) venShippedQty FROM M_PRODUCT pr JOIN M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on pr.m_product_id = uomc.m_product_id LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN M_product_PO ppo on pr.m_product_id = ppo.m_product_id and ppo.iscurrentvendor='Y' LEFT JOIN C_Bpartner pbp on ppo.c_bpartner_id = pbp.c_bpartner_id JOIN c_taxcategory tc on tc.c_taxcategory_id = pr.c_taxcategory_id LEFT JOIN (SELECT SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.qtyonhand END), 0)) qtyonhand, SUM(COALESCE(s.qtyreserved, 0)) qtyreserved, SUM(COALESCE(s.qtyOrdered, 0)) qtyOrdered, SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN s.qtyonhand ELSE 0 END), 0)) qtyintransit, s.m_product_id , SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.cwqtyonhand END), 0)) cwqtyonhand FROM M_Storage s JOIN M_Locator loc ON loc.m_locator_id = s.m_locator_id JOIN M_Warehouse wr ON wr.m_warehouse_id = loc.m_warehouse_id WHERE s.m_locator_id in (select m_locator_id from m_locator where m_warehouse_id = 1000000) GROUP BY s.m_product_id) st ON (st.M_PRODUCT_ID=pr.M_PRODUCT_ID AND ((st.qtyonhand+st.qtyreserved+st.qtyordered+st.qtyintransit+st.cwqtyonhand) <> 0 OR st.qtyonhand <> 0 OR st.qtyreserved <> 0 OR st.qtyordered <> 0 OR st.qtyintransit<>0 OR st.cwqtyonhand <>0 )) left join (select sum(inl.pickedqty) as pickedqty, inl.m_product_id, inl.m_attributesetinstance_id from m_inoutline inl join m_inout min on inl.m_inout_id = min.m_inout_id where min.docstatus in ('IP') AND min.m_warehouse_id = 1000000 group by m_product_id, inl.m_attributesetinstance_id) minl on pr.m_product_id = minl.m_product_id left join (select sum(m.movementqty) as movementqty, m.m_product_id, m.m_attributesetinstance_id from m_movementline m join m_movement mov on m.m_movement_id = mov.m_movement_id and mov.docstatus in ('IP') AND m.m_locatorto_id in (select m_locator_id from m_locator where m_warehouse_id = 1000000) group by m_product_id, m.m_attributesetinstance_id) mmov on pr.m_product_id = mmov.m_product_id where pr.isbaseproduct = 'N' AND pr.AD_CLIENT_ID = 1000000 and pr.isactive = 'Y' AND pc.m_product_category_id in (1000114,1000008,1000047,1000069,1000070,1005210,1001277,1001276,1005274,1005293,1015327,1000086,1000013,1000018,1000051,1000087,1000119,1000017,1005208,1005219,1005295,1015314,1005287,1015326) and lower(coalesce(pr.group1,'')) like lower($1) AND pr.ad_org_id IN (0,1000000) group by pr.m_product_id, pc.name, uomc.dividerate,uom.c_uom_id, firstAttributeValue,pbp.name having sum(st.qtyonhand)> 25 order by name postgresql-2023-08-21_000000.log:2023-08-21 10:00:13 +04,14662 LOG: duration: 7851.310 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-21_103320.log:2023-08-21 11:00:13 +04,16171 LOG: duration: 7341.199 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-21_103320.log:2023-08-21 11:02:45 +04,16202 LOG: duration: 5855.935 ms execute : select pr.name as name, sum(coalesce(st.qtyonhand, 0) )as qty, pr.UPC as barcode, pr.m_product_id, sum(st.qtyreserved) as reserved, pr.unitsperpack, pc.name as proCategoryName, (coalesce(pr.group1,' ')||' '||coalesce(pr.group2,' ')) as group, coalesce(sum(st.qtyOrdered), 0) as qty_ordered, sum(coalesce(minl.pickedqty, 0) + coalesce(mmov.movementqty, 0) + coalesce(st.qtyintransit, 0)) as qtyintransit, coalesce(uomc.dividerate,1) as dividerate, uom.c_uom_id, uom.uomsymbol, uom.stdprecision,pr.sku as SKU, productAttribute(pr.m_attributesetinstance_id) AS nonInstanceAttribute ,null as firstAttributeValue , pbp.name as vendorname, pr.group1, pr.group2, pr.commodity_code,pr.classification as pclassification, case when pr.cw_uom_id > 0 then sum(coalesce(st.cwqtyonhand, 0)) else 0 end as cwqty, pr.hscode as hscode, pr.c_taxcategory_id as c_taxcategory_id, sum(coalesce(minl.pickedqty, 0)) venShippedQty FROM M_PRODUCT pr JOIN M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on pr.m_product_id = uomc.m_product_id LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN M_product_PO ppo on pr.m_product_id = ppo.m_product_id and ppo.iscurrentvendor='Y' LEFT JOIN C_Bpartner pbp on ppo.c_bpartner_id = pbp.c_bpartner_id JOIN c_taxcategory tc on tc.c_taxcategory_id = pr.c_taxcategory_id LEFT JOIN (SELECT SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.qtyonhand END), 0)) qtyonhand, SUM(COALESCE(s.qtyreserved, 0)) qtyreserved, SUM(COALESCE(s.qtyOrdered, 0)) qtyOrdered, SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN s.qtyonhand ELSE 0 END), 0)) qtyintransit, s.m_product_id , SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.cwqtyonhand END), 0)) cwqtyonhand FROM M_Storage s JOIN M_Locator loc ON loc.m_locator_id = s.m_locator_id JOIN M_Warehouse wr ON wr.m_warehouse_id = loc.m_warehouse_id WHERE s.m_locator_id in (select m_locator_id from m_locator where m_warehouse_id = 1000000) GROUP BY s.m_product_id) st ON (st.M_PRODUCT_ID=pr.M_PRODUCT_ID AND ((st.qtyonhand+st.qtyreserved+st.qtyordered+st.qtyintransit+st.cwqtyonhand) <> 0 OR st.qtyonhand <> 0 OR st.qtyreserved <> 0 OR st.qtyordered <> 0 OR st.qtyintransit<>0 OR st.cwqtyonhand <>0 )) left join (select sum(inl.pickedqty) as pickedqty, inl.m_product_id, inl.m_attributesetinstance_id from m_inoutline inl join m_inout min on inl.m_inout_id = min.m_inout_id where min.docstatus in ('IP') AND min.m_warehouse_id = 1000000 group by m_product_id, inl.m_attributesetinstance_id) minl on pr.m_product_id = minl.m_product_id left join (select sum(m.movementqty) as movementqty, m.m_product_id, m.m_attributesetinstance_id from m_movementline m join m_movement mov on m.m_movement_id = mov.m_movement_id and mov.docstatus in ('IP') AND m.m_locatorto_id in (select m_locator_id from m_locator where m_warehouse_id = 1000000) group by m_product_id, m.m_attributesetinstance_id) mmov on pr.m_product_id = mmov.m_product_id where pr.isbaseproduct = 'N' AND pr.AD_CLIENT_ID = 1000000 and pr.isactive = 'Y' and lower(coalesce(pr.group1,'')) like lower($1) and lower(coalesce(pr.group2,'')) like lower($2) AND pr.ad_org_id IN (0,1000000) group by pr.m_product_id, pc.name, uomc.dividerate,uom.c_uom_id, firstAttributeValue,pbp.name having sum(st.qtyonhand)> 0 order by name postgresql-2023-08-21_103320.log:2023-08-21 11:20:04 +04,15085 LOG: duration: 31589.476 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_103320.log:2023-08-21 11:58:21 +04,17736 LOG: duration: 17311.281 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-21_103320.log:2023-08-21 11:58:35 +04,17725 LOG: duration: 32050.576 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_115839.log:2023-08-21 12:00:14 +04,17851 LOG: duration: 7951.338 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-21_115839.log:2023-08-21 12:17:13 +04,17864 LOG: duration: 31669.934 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_123807.log:2023-08-21 12:40:05 +04,17864 LOG: duration: 31550.305 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_123807.log:2023-08-21 12:40:27 +04,18955 LOG: duration: 31871.737 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_123807.log:2023-08-21 12:41:56 +04,17864 LOG: duration: 31845.026 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_123807.log:2023-08-21 12:42:13 +04,18955 LOG: duration: 31460.269 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_123807.log:2023-08-21 12:54:42 +04,19350 LOG: duration: 16529.557 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-21_123807.log:2023-08-21 12:54:57 +04,19314 LOG: duration: 31786.471 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_123807.log:2023-08-21 13:00:13 +04,19569 LOG: duration: 7816.052 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-21_123807.log:2023-08-21 13:38:17 +04,19665 LOG: duration: 32331.790 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_123807.log:2023-08-21 13:38:21 +04,20552 LOG: duration: 32276.201 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_123807.log:2023-08-21 13:38:26 +04,20555 LOG: duration: 32324.231 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_123807.log:2023-08-21 13:38:43 +04,19619 LOG: duration: 32082.819 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_123807.log:2023-08-21 14:00:13 +04,21144 LOG: duration: 7398.209 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-21_145650.log:2023-08-21 15:00:13 +04,22626 LOG: duration: 7802.994 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-21_152016.log:2023-08-21 15:31:37 +04,23469 LOG: duration: 16773.807 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-21_152016.log:2023-08-21 15:31:52 +04,23256 LOG: duration: 32409.910 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_152016.log:2023-08-21 16:00:13 +04,24269 LOG: duration: 7861.154 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-21_161501.log:2023-08-21 16:20:53 +04,24596 LOG: duration: 5094.659 ms execute : select distinct pr.m_product_id, pr.name, pr.upc, pr.sku, pr.description, pr.group1, pr.group2, pr.commodity_code, coalesce(dividerate,1) dividerate,uomc.c_uom_to_id,uom.uomsymbol,uom.stdprecision,pr.c_uom_id, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId from m_product pr join M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id join M_TRANSACTION v on v.m_product_id = pr.m_product_id JOIN m_locator l on v.m_locator_id = l.m_locator_id LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on invl.m_inventory_id = inv.m_inventory_id WHERE v.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on io.m_inout_id = iol.m_inout_id WHERE v.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on mml.m_movement_id = mm.m_movement_id WHERE v.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on pp.m_production_id = ppl.m_production_id WHERE v.m_productionline_id = ppl.m_productionline_id ) pl on true LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pr.m_product_id) LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = v.m_attributesetinstance_id and ass.m_attributeset_id = pr.m_attributeset_id where pr.ad_client_id = 1000000 and l.ad_org_id in (0,0,1000000,1000002,1000001) and l.M_warehouse_ID=1010008 and v.movementdate between TO_TIMESTAMP('2023-08-14 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-21 23:59:59','YYYY-MM-DD HH24:MI:SS') and v.movementqty != 0 And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') and v.AD_CLIENT_ID=1000000 order by name postgresql-2023-08-21_161501.log:2023-08-21 16:21:08 +04,24596 LOG: duration: 11334.836 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000 AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND l.M_warehouse_ID=1010008 AND MovementDate < TO_TIMESTAMP('2023-08-14 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000 AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND l.M_Warehouse_ID=1010008 AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2023-08-14 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-21 23:59:59','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-21_161501.log:2023-08-21 16:27:47 +04,25101 LOG: duration: 31719.978 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_161501.log:2023-08-21 16:28:03 +04,25137 LOG: duration: 31796.451 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_161501.log:2023-08-21 16:46:06 +04,25669 LOG: duration: 10880.418 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000 AND l.AD_Org_ID in (0,1000002) AND l.M_warehouse_ID=1010036 AND MovementDate < TO_TIMESTAMP('2023-08-14 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000 AND l.AD_Org_ID in (0,1000002) AND l.M_Warehouse_ID=1010036 AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2023-08-14 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-21 23:59:59','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-21_161501.log:2023-08-21 16:51:46 +04,25670 LOG: duration: 11248.314 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000 AND l.AD_Org_ID in (0,1000002) AND l.M_warehouse_ID=1010036 AND MovementDate < TO_TIMESTAMP('2023-08-14 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000 AND l.AD_Org_ID in (0,1000002) AND l.M_Warehouse_ID=1010036 AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2023-08-14 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-21 23:59:59','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-21_161501.log:2023-08-21 17:00:14 +04,26068 LOG: duration: 8148.006 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-21_171217.log:2023-08-21 17:31:20 +04,26549 LOG: duration: 31565.896 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_171217.log:2023-08-21 17:51:09 +04,26549 LOG: duration: 31926.798 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_171217.log:2023-08-21 17:51:26 +04,27428 LOG: duration: 31595.549 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_171217.log:2023-08-21 17:54:50 +04,27485 LOG: duration: 16294.196 ms execute : select pr.name as name, sum(coalesce(st.qtyonhand, 0) )as qty, pr.UPC as barcode, pr.m_product_id, sum(st.qtyreserved) as reserved, pr.unitsperpack, pc.name as proCategoryName, (coalesce(pr.group1,' ')||' '||coalesce(pr.group2,' ')) as group, coalesce(sum(st.qtyOrdered), 0) as qty_ordered, sum(coalesce(minl.pickedqty, 0) + coalesce(mmov.movementqty, 0) + coalesce(st.qtyintransit, 0)) as qtyintransit, coalesce(uomc.dividerate,1) as dividerate, uom.c_uom_id, uom.uomsymbol, uom.stdprecision,pr.sku as SKU, productAttribute(pr.m_attributesetinstance_id) AS nonInstanceAttribute ,null as firstAttributeValue , pbp.name as vendorname, pr.group1, pr.group2, pr.commodity_code,pr.classification as pclassification, case when pr.cw_uom_id > 0 then sum(coalesce(st.cwqtyonhand, 0)) else 0 end as cwqty, pr.hscode as hscode, pr.c_taxcategory_id as c_taxcategory_id, sum(coalesce(minl.pickedqty, 0)) venShippedQty FROM M_PRODUCT pr JOIN M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on pr.m_product_id = uomc.m_product_id LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN M_product_PO ppo on pr.m_product_id = ppo.m_product_id and ppo.iscurrentvendor='Y' LEFT JOIN C_Bpartner pbp on ppo.c_bpartner_id = pbp.c_bpartner_id JOIN c_taxcategory tc on tc.c_taxcategory_id = pr.c_taxcategory_id LEFT JOIN (SELECT SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.qtyonhand END), 0)) qtyonhand, SUM(COALESCE(s.qtyreserved, 0)) qtyreserved, SUM(COALESCE(s.qtyOrdered, 0)) qtyOrdered, SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN s.qtyonhand ELSE 0 END), 0)) qtyintransit, s.m_product_id , SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.cwqtyonhand END), 0)) cwqtyonhand FROM M_Storage s JOIN M_Locator loc ON loc.m_locator_id = s.m_locator_id JOIN M_Warehouse wr ON wr.m_warehouse_id = loc.m_warehouse_id WHERE s.m_locator_id in (select m_locator_id from m_locator where m_warehouse_id = 1000000) GROUP BY s.m_product_id) st ON (st.M_PRODUCT_ID=pr.M_PRODUCT_ID AND ((st.qtyonhand+st.qtyreserved+st.qtyordered+st.qtyintransit+st.cwqtyonhand) <> 0 OR st.qtyonhand <> 0 OR st.qtyreserved <> 0 OR st.qtyordered <> 0 OR st.qtyintransit<>0 OR st.cwqtyonhand <>0 )) left join (select sum(inl.pickedqty) as pickedqty, inl.m_product_id, inl.m_attributesetinstance_id from m_inoutline inl join m_inout min on inl.m_inout_id = min.m_inout_id where min.docstatus in ('IP') AND min.m_warehouse_id = 1000000 group by m_product_id, inl.m_attributesetinstance_id) minl on pr.m_product_id = minl.m_product_id left join (select sum(m.movementqty) as movementqty, m.m_product_id, m.m_attributesetinstance_id from m_movementline m join m_movement mov on m.m_movement_id = mov.m_movement_id and mov.docstatus in ('IP') AND m.m_locatorto_id in (select m_locator_id from m_locator where m_warehouse_id = 1000000) group by m_product_id, m.m_attributesetinstance_id) mmov on pr.m_product_id = mmov.m_product_id where pr.isbaseproduct = 'N' AND pr.AD_CLIENT_ID = 1000000 and pr.isactive = 'Y' AND pc.m_product_category_id in (1000114,1000008,1000047,1000069,1000070,1005210,1001277,1001276,1005274,1005293,1015327,1000086,1000013,1000018,1000051,1000087,1000119,1000017,1005208,1005219,1005295,1015314,1005287,1015326) and lower(coalesce(pr.group1,'')) like lower($1) AND pr.ad_org_id IN (0,1000000) group by pr.m_product_id, pc.name, uomc.dividerate,uom.c_uom_id, firstAttributeValue,pbp.name having sum(st.qtyonhand)> 0 order by name postgresql-2023-08-21_171217.log:2023-08-21 18:00:13 +04,27685 LOG: duration: 7817.230 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-21_171217.log:2023-08-21 18:02:33 +04,27428 LOG: duration: 31975.210 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-21_181859.log:2023-08-21 18:19:07 +04,28197 LOG: duration: 20899.017 ms execute : select distinct pro.m_product_id,pro.description,pro.name, sum(coalesce(st.qtyOrdered, 0)) as qty_ordered, puom.c_uom_id,puom.uomsymbol,puom.stdprecision,max(ss.mdate), sum(coalesce(st.qtyonhand, 0)) as qty_onhand, coalesce(pro.UPC,pro.SKU)as barcode, (coalesce(pro.group1,' ')||' '||coalesce(pro.group2,' ')) as group,pc.name as proCategoryName ,coalesce(uomc.dividerate,1),uomc.c_uom_to_id,uom.uomsymbol,max(coalesce(intransit.qty, 0)) as intransitQty, pro.group1, pro.group2, pro.commodity_code, pro.classification as pclassification, productAttribute(pro.m_attributesetinstance_id) AS nonInstanceAttribute, pro.unitsperpack from m_product pro left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pro.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pro.m_product_id) left join c_uom as uom on uomc.c_uom_to_id = uom.c_uom_id left join m_storage st on st.m_product_id=pro.m_product_id left join m_locator l on st.m_locator_id = l.m_locator_id left join c_uom as puom on puom.c_uom_id = pro.c_uom_id left join lateral (select max(mn.movementdate) mdate from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where m_product_id = pro.m_product_id and m_locator_id = l.m_locator_id group by mnl.m_product_id) as ss on true LEFT JOIN M_PRODUCT_CATEGORY pc on pro.m_product_category_id = pc.m_product_category_id left join lateral (select sum(mil.pickedqty) qty from m_inoutline mil join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and m_product_id= pro.m_product_id and m_locator_id = l.m_locator_id group By mil.m_product_id) intransit on true LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = st.m_attributesetinstance_id and ass.m_attributeset_id = pro.m_attributeset_id WHERE pro.AD_CLIENT_ID = 1000000 and pro.isactive = 'Y'AND pro.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_org_ID in (0,1000000,1000002,1000001) group by pro.m_product_id,pro.description,pro.name,puom.c_uom_id,puom.uomsymbol,puom.stdprecision,uomc.dividerate,uomc.c_uom_to_id,uom.uomsymbol, pro.UPC, pro.SKU, pro.group1, pro.group2, pc.name order by qty_ordered postgresql-2023-08-21_181859.log:2023-08-21 18:19:41 +04,27962 LOG: duration: 20483.826 ms execute : select distinct pro.m_product_id,pro.description,pro.name, sum(coalesce(st.qtyOrdered, 0)) as qty_ordered, puom.c_uom_id,puom.uomsymbol,puom.stdprecision,max(ss.mdate), sum(coalesce(st.qtyonhand, 0)) as qty_onhand, coalesce(pro.UPC,pro.SKU)as barcode, (coalesce(pro.group1,' ')||' '||coalesce(pro.group2,' ')) as group,pc.name as proCategoryName ,coalesce(uomc.dividerate,1),uomc.c_uom_to_id,uom.uomsymbol,max(coalesce(intransit.qty, 0)) as intransitQty, pro.group1, pro.group2, pro.commodity_code, pro.classification as pclassification, productAttribute(pro.m_attributesetinstance_id) AS nonInstanceAttribute, pro.unitsperpack from m_product pro left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pro.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pro.m_product_id) left join c_uom as uom on uomc.c_uom_to_id = uom.c_uom_id left join m_storage st on st.m_product_id=pro.m_product_id left join m_locator l on st.m_locator_id = l.m_locator_id left join c_uom as puom on puom.c_uom_id = pro.c_uom_id left join lateral (select max(mn.movementdate) mdate from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where m_product_id = pro.m_product_id and m_locator_id = l.m_locator_id group by mnl.m_product_id) as ss on true LEFT JOIN M_PRODUCT_CATEGORY pc on pro.m_product_category_id = pc.m_product_category_id left join lateral (select sum(mil.pickedqty) qty from m_inoutline mil join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and m_product_id= pro.m_product_id and m_locator_id = l.m_locator_id group By mil.m_product_id) intransit on true LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = st.m_attributesetinstance_id and ass.m_attributeset_id = pro.m_attributeset_id WHERE pro.AD_CLIENT_ID = 1000000 and pro.isactive = 'Y'AND pro.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_org_ID in (0,1000000,1000002,1000001) group by pro.m_product_id,pro.description,pro.name,puom.c_uom_id,puom.uomsymbol,puom.stdprecision,uomc.dividerate,uomc.c_uom_to_id,uom.uomsymbol, pro.UPC, pro.SKU, pro.group1, pro.group2, pc.name order by qty_ordered postgresql-2023-08-21_181859.log:2023-08-21 18:32:00 +04,28490 LOG: duration: 16944.264 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-21_181859.log:2023-08-21 18:32:15 +04,28489 LOG: duration: 32350.651 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_000000.log:2023-08-22 08:00:13 +04,17429 LOG: duration: 8055.597 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-22_000000.log:2023-08-22 08:05:24 +04,17564 LOG: duration: 17998.979 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-22_000000.log:2023-08-22 08:05:38 +04,17563 LOG: duration: 31755.856 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_000000.log:2023-08-22 08:09:49 +04,17563 LOG: duration: 31945.908 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_000000.log:2023-08-22 08:22:05 +04,17563 LOG: duration: 5238.295 ms execute : select to_char(round(coalesce(sum(invoiceopen(c_invoice_id,0)),0),0),'999,99,99,999') postgresql-2023-08-22_000000.log:2023-08-22 08:22:13 +04,17994 LOG: duration: 17973.730 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-22_000000.log:2023-08-22 08:22:18 +04,17996 LOG: duration: 17963.957 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-22_000000.log:2023-08-22 08:22:29 +04,17992 LOG: duration: 33592.265 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_000000.log:2023-08-22 08:22:33 +04,17654 LOG: duration: 33035.719 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_000000.log:2023-08-22 08:23:02 +04,18030 LOG: duration: 16756.949 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-22_000000.log:2023-08-22 08:23:17 +04,17654 LOG: duration: 31997.512 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_000000.log:2023-08-22 08:34:08 +04,18031 LOG: duration: 31466.859 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_000000.log:2023-08-22 08:46:43 +04,18752 LOG: duration: 31706.408 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_000000.log:2023-08-22 08:51:40 +04,18858 LOG: duration: 16784.527 ms execute : SELECT CASE WHEN UPPER(Name) LIKE UPPER($1) THEN 1 ELSE 2 END AS Sort, p.Name, p.M_Product_ID, p.UPC, p.Description ,SUM(COALESCE(s.QtyOnHand, 0)) AS QtyOnHand ,coalesce(bompricestd(p.M_Product_ID,1000001,0,null),0) as stdPrice FROM M_Product p LEFT JOIN M_Storage s ON (s.M_Product_ID = p.M_Product_ID AND s.M_Locator_ID IN (SELECT M_Locator_ID FROM M_Locator WHERE M_Warehouse_ID = $2))WHERE p.AD_Client_ID=$3 AND p.IsActive='Y' AND UPPER(Name) LIKE UPPER($4) GROUP BY Sort, p.Name, p.M_Product_ID, p.UPC, p.Description ORDER BY Sort, p.Name, p.M_Product_ID, p.UPC, p.Description postgresql-2023-08-22_000000.log:2023-08-22 08:52:22 +04,18863 LOG: duration: 14044.879 ms execute : select distinct pr.m_product_id, pr.name, pr.upc, pr.sku, pr.description, pr.group1, pr.group2, pr.commodity_code, coalesce(dividerate,1) dividerate,uomc.c_uom_to_id,uom.uomsymbol,uom.stdprecision,pr.c_uom_id, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId from m_product pr join M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id join M_TRANSACTION v on v.m_product_id = pr.m_product_id JOIN m_locator l on v.m_locator_id = l.m_locator_id LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on invl.m_inventory_id = inv.m_inventory_id WHERE v.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on io.m_inout_id = iol.m_inout_id WHERE v.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on mml.m_movement_id = mm.m_movement_id WHERE v.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on pp.m_production_id = ppl.m_production_id WHERE v.m_productionline_id = ppl.m_productionline_id ) pl on true LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pr.m_product_id) LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = v.m_attributesetinstance_id and ass.m_attributeset_id = pr.m_attributeset_id where pr.ad_client_id = 1000000 and l.ad_org_id = 1000002 and v.movementdate between TO_TIMESTAMP('2023-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-31 23:59:59','YYYY-MM-DD HH24:MI:SS') and v.movementqty != 0 And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') and v.AD_CLIENT_ID=1000000 order by name postgresql-2023-08-22_000000.log:2023-08-22 08:53:18 +04,18863 LOG: duration: 19048.176 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000 AND l.AD_Org_ID = 1000002 AND MovementDate < TO_TIMESTAMP('2023-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000 AND l.AD_Org_ID = 1000002 AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2023-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-31 23:59:59','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-22_000000.log:2023-08-22 08:56:03 +04,18934 LOG: duration: 13085.175 ms execute : select distinct pr.m_product_id, pr.name, pr.upc, pr.sku, pr.description, pr.group1, pr.group2, pr.commodity_code, coalesce(dividerate,1) dividerate,uomc.c_uom_to_id,uom.uomsymbol,uom.stdprecision,pr.c_uom_id, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId from m_product pr join M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id join M_TRANSACTION v on v.m_product_id = pr.m_product_id JOIN m_locator l on v.m_locator_id = l.m_locator_id LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on invl.m_inventory_id = inv.m_inventory_id WHERE v.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on io.m_inout_id = iol.m_inout_id WHERE v.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on mml.m_movement_id = mm.m_movement_id WHERE v.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on pp.m_production_id = ppl.m_production_id WHERE v.m_productionline_id = ppl.m_productionline_id ) pl on true LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pr.m_product_id) LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = v.m_attributesetinstance_id and ass.m_attributeset_id = pr.m_attributeset_id where pr.ad_client_id = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) and l.ad_org_id in (0,0,1000000,1000002,1000001) and v.movementdate between TO_TIMESTAMP('2020-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-06 23:59:59','YYYY-MM-DD HH24:MI:SS') and v.movementqty != 0 And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') and v.AD_CLIENT_ID=1000000 order by name postgresql-2023-08-22_000000.log:2023-08-22 08:56:09 +04,18934 LOG: duration: 6360.732 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND MovementDate < TO_TIMESTAMP('2020-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $2) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2020-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-06 23:59:59','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-22_000000.log:2023-08-22 08:57:37 +04,18992 LOG: duration: 8227.517 ms execute : SELECT iv.documentno,coalesce(jn.amt,ivl.linetotalamt),iv.dateAcct as TIMESTAMP,ch.name,bp.name,ur.name,dc.name, jn.revenue,jn.name expense,iv.c_invoice_id,bp.c_bpartner_id,iv.c_order_id, iv.docstatus, iv.description,ivl.created as dateCreated,'N' as isBaStatement,dep.name,dep.hr_department_id,iv.user1_id , dc.docbasetype as docBase from c_Invoice iv join c_invoiceline ivl on ivl.c_invoice_id = iv.c_invoice_id join c_Charge ch on ivl.c_charge_id = ch.c_charge_id AND ivl.c_charge_id= 1000365 join c_Doctype dc on dc.c_doctype_id = iv.c_doctype_id join c_Bpartner bp on bp.c_bpartner_id = iv.c_bpartner_id join ad_user ur on ur.ad_user_id = iv.createdby left join ((SELECT rev.name as revenue,case when acc.amtacctcr <> 0 then acc.amtacctcr else acc.amtacctdr end as amt ,acc.record_id,acc.line_id line from fact_acct acc join c_elementvalue rev on rev.c_elementvalue_id = acc.account_id AND acc.ad_table_id = 318 and acc.line_id > 0) acc join Fact_Acct acct on acct.record_id = acc.record_id join C_Elementvalue exp on exp.c_elementvalue_id = acct.account_id and acct.line_id is null and acct.ad_table_id = 318 and (c_tax_id =0 or c_tax_id is null)) jn on jn.line = ivl.c_invoiceline_id left join hr_department dep on (iv.hr_department_id=dep.hr_department_id) left join c_elementvalue elv on (iv.user1_id=elv.c_elementvalue_id and elv.isActive='Y') WHERE iv.ad_client_id = $1 AND (iv.DESCRIPTION NOT LIKE 'DESC JE%' OR iv.DESCRIPTION IS NULL) and iv.docstatus in ('CO','CL','IP') AND iv.c_invoice_id not in (SELECT cin.c_invoice_id from c_invoice cin join c_invoiceline cline on cin.c_invoice_id = cline.c_invoice_id join c_landedcost land on land.c_invoiceline_id = cline.c_invoiceline_id ) AND ivl.ad_org_id in (0,1000000,1000002,1000001) AND iv.Dateinvoiced BETWEEN TO_TIMESTAMP('2023-07-01 00:00:00','YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') UNION ALL SELECT distinct iv.documentno,coalesce(case when dc.docbasetype in ('ARI','APC') then jn.cramt else jn.amt end,iv.grandtotal),iv.dateAcct as TIMESTAMP,'Charge Tax ' || tx.name || '-'|| tx.rate,bp.name,ur.name,dc.name, jn.revenue,jn.expense,iv.c_invoice_id,bp.c_bpartner_id,iv.c_order_id, iv.docstatus, iv.description,ivt.created as dateCreated,'N' as isBaStatement,dep.name,dep.hr_department_id,iv.user1_id , dc.docbasetype as docBase from c_Invoice iv join c_invoicetax ivt on ivt.c_invoice_id=iv.c_invoice_id join c_Charge ch on iv.c_charge_id = ch.c_charge_id AND iv.c_charge_id= 1000365 join c_Doctype dc on dc.c_doctype_id = iv.c_doctype_id join c_Bpartner bp on bp.c_bpartner_id = iv.c_bpartner_id join ad_user ur on ur.ad_user_id = iv.createdby left join (SELECT rev.name as revenue,acct.amtacctdr amt, acc.amtacctcr cramt,exp.name as expense,coalesce(acc.record_id,acct.record_id) record_id,coalesce(acc.c_tax_id,acct.c_tax_id) tax from fact_acct acc left join c_elementvalue rev on rev.c_elementvalue_id = acc.account_id join Fact_Acct acct on acct.record_id = acc.record_id left join C_Elementvalue exp on exp.c_elementvalue_id = acct.account_id where acc.amtacctcr != 0 AND acct.amtacctdr != 0 AND acc.ad_table_id = 318 and acct.ad_table_id = 318 and acct.line_id is null and acc.line_id is null) jn on jn.record_id = iv.c_invoice_id left join c_tax tx on tx.c_tax_id=jn.tax left join hr_department dep on (iv.hr_department_id=dep.hr_department_id) left join c_elementvalue elv on (iv.user1_id=elv.c_elementvalue_id and elv.isActive='Y') WHERE iv.ad_client_id = $2 AND ivt.taxamt<> 0 AND (iv.DESCRIPTION NOT LIKE 'DESC JE%' OR iv.DESCRIPTION IS NULL) and iv.docstatus in ('CO','CL','IP') AND iv.c_invoice_id not in (SELECT cin.c_invoice_id from c_invoice cin join c_invoiceline cline on cin.c_invoice_id = cline.c_invoice_id join c_landedcost land on land.c_invoiceline_id = cline.c_invoiceline_id ) AND iv.ad_org_id in (0,1000000,1000002,1000001) AND iv.Dateinvoiced BETWEEN TO_TIMESTAMP('2023-07-01 00:00:00','YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') UNION ALL SELECT pc.documentno,pc.payamt,pc.datetrx as TIMESTAMP,ch.name,bp.name,ur.name,dc.name, jn.revenue,jn.expense,pc.c_payment_id,bp.c_bpartner_id,pc.c_order_id, pc.docstatus, pc.description,pc.created as dateCreated,'N' as isBaStatement,dep.name,dep.hr_department_id,pc.user1_id, dc.docbasetype as docBase from c_Payment pc join c_Charge ch on ch.c_charge_id = pc.c_charge_id join c_Doctype dc on dc.c_doctype_id = pc.c_doctype_id join c_Bpartner bp on bp.c_bpartner_id = pc.c_bpartner_id join ad_user ur on ur.ad_user_id = pc.createdby left join (select rev.name as revenue,acct.amtacctdr amt,exp.name as expense,acc.record_id from fact_acct acc join c_elementvalue rev on rev.c_elementvalue_id = acc.account_id join Fact_Acct acct on acct.record_id = acc.record_id join C_Elementvalue exp on exp.c_elementvalue_id = acct.account_id where acc.amtacctcr != 0 AND acct.amtacctdr != 0 AND acc.ad_table_id = 335 and acct.ad_table_id = 335) jn on jn.record_id = pc.c_payment_id left join hr_department dep on (pc.hr_department_id=dep.hr_department_id) left join c_elementvalue elv on (dep.user1_id=elv.c_elementvalue_id and elv.isActive='Y') WHERE pc.ad_client_id = $3 AND pc.c_charge_id= 1000365 AND pc.ad_org_id in (0,1000000,1000002,1000001) AND pc.datetrx BETWEEN TO_TIMESTAMP('2023-07-01 00:00:00','YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') AND pc.docstatus in ('CO','CL','IP') Union ALL SELECT distinct ba.accountno,coalesce(bsl.chargeamt,0),bs.statementdate as TIMESTAMP,ch.name,'Bank Statement',ur.name,'', jn.revenue,jn.expense,0,0,0, bs.docstatus, '',bs.created as dateCreated,'Y' as isBaStatement,'',0,0, NULL as docBase FROM c_bankstatementline bsl join c_bankstatement bs on bsl.c_bankstatement_id = bs.c_bankstatement_id JOIN adempiere.C_BankAccount ba ON bs.c_bankaccount_id= ba.c_bankaccount_id join c_bank b on ba.c_bank_id = b.c_bank_id JOIN adempiere.ad_org o ON o.ad_org_id=b.ad_org_id join c_charge ch on bsl.c_charge_id = ch.c_charge_id join ad_user ur on ur.ad_user_id = bs.createdby left join (select rev.name as revenue,acct.amtacctdr amt,exp.name as expense,acc.record_id,acc.line_id from fact_acct acc join c_elementvalue rev on rev.c_elementvalue_id = acc.account_id join Fact_Acct acct on acct.record_id = acc.record_id join C_Elementvalue exp on exp.c_elementvalue_id = acct.account_id where acc.amtacctcr != 0 AND acct.amtacctdr != 0 AND acc.ad_table_id = 392 and acct.ad_table_id = 392) jn on (jn.record_id = bs.c_bankstatement_id and jn.line_id = bsl.c_bankstatementline_id) WHERE b.AD_Client_ID=$4 AND b.IsActive='Y' AND b.routingno!='999999999' AND ba.IsActive='Y' AND o.IsActive='Y' AND ba.bankAccountType != 'B' and b.name != 'BANK ACCOUNT FOR TRANSFERS' AND ba.accountno not like '%Cash' AND NOT EXISTS (SELECT * FROM AD_OrgInfo oi WHERE oi.TransferBank_ID=b.C_Bank_ID) AND bsl.c_charge_id= 1000365 AND bsl.ad_org_id in (0,1000000,1000002,1000001) AND bsl.created BETWEEN TO_TIMESTAMP('2023-07-01 00:00:00','YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') AND bs.docstatus in ('CO','CL','IP') order by TIMESTAMP DESC, dateCreated DESC, 1 DESC postgresql-2023-08-22_000000.log:2023-08-22 09:00:13 +04,19137 LOG: duration: 7671.488 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-22_000000.log:2023-08-22 09:07:05 +04,18667 LOG: duration: 31901.456 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_000000.log:2023-08-22 09:56:18 +04,20642 LOG: duration: 8090.798 ms execute : select distinct pr.m_product_id, pr.name, pr.upc, pr.sku, pr.description, pr.group1, pr.group2, pr.commodity_code, coalesce(dividerate,1) dividerate,uomc.c_uom_to_id,uom.uomsymbol,uom.stdprecision,pr.c_uom_id, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId from m_product pr join M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id join M_TRANSACTION v on v.m_product_id = pr.m_product_id JOIN m_locator l on v.m_locator_id = l.m_locator_id LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on invl.m_inventory_id = inv.m_inventory_id WHERE v.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on io.m_inout_id = iol.m_inout_id WHERE v.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on mml.m_movement_id = mm.m_movement_id WHERE v.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on pp.m_production_id = ppl.m_production_id WHERE v.m_productionline_id = ppl.m_productionline_id ) pl on true LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pr.m_product_id) LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = v.m_attributesetinstance_id and ass.m_attributeset_id = pr.m_attributeset_id where pr.ad_client_id = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) and l.ad_org_id in (0,0,1000000,1000002,1000001) and l.M_warehouse_ID=1000000 and v.movementdate between TO_TIMESTAMP('2022-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') and v.movementqty != 0 And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') and v.AD_CLIENT_ID=1000000 order by name postgresql-2023-08-22_000000.log:2023-08-22 09:56:31 +04,20642 LOG: duration: 12220.167 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND l.M_warehouse_ID=1000000 AND MovementDate < TO_TIMESTAMP('2022-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $2) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND l.M_Warehouse_ID=1000000 AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2022-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-22_095748.log:2023-08-22 10:00:14 +04,20879 LOG: duration: 7638.046 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-22_095748.log:2023-08-22 10:03:29 +04,20946 LOG: duration: 10199.756 ms execute : select distinct pr.m_product_id, pr.name, pr.upc, pr.sku, pr.description, pr.group1, pr.group2, pr.commodity_code, coalesce(dividerate,1) dividerate,uomc.c_uom_to_id,uom.uomsymbol,uom.stdprecision,pr.c_uom_id, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId from m_product pr join M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id join M_TRANSACTION v on v.m_product_id = pr.m_product_id JOIN m_locator l on v.m_locator_id = l.m_locator_id LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on invl.m_inventory_id = inv.m_inventory_id WHERE v.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on io.m_inout_id = iol.m_inout_id WHERE v.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on mml.m_movement_id = mm.m_movement_id WHERE v.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on pp.m_production_id = ppl.m_production_id WHERE v.m_productionline_id = ppl.m_productionline_id ) pl on true LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pr.m_product_id) LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = v.m_attributesetinstance_id and ass.m_attributeset_id = pr.m_attributeset_id where pr.ad_client_id = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) and l.ad_org_id in (0,0,1000000,1000002,1000001) and v.movementdate between TO_TIMESTAMP('2022-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') and v.movementqty != 0 And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') and v.AD_CLIENT_ID=1000000 order by name postgresql-2023-08-22_095748.log:2023-08-22 10:03:41 +04,21011 LOG: duration: 12393.992 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND MovementDate < TO_TIMESTAMP('2022-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $2) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2022-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-22_095748.log:2023-08-22 10:05:46 +04,20946 LOG: duration: 10225.601 ms execute : select distinct pr.m_product_id, pr.name, pr.upc, pr.sku, pr.description, pr.group1, pr.group2, pr.commodity_code, coalesce(dividerate,1) dividerate,uomc.c_uom_to_id,uom.uomsymbol,uom.stdprecision,pr.c_uom_id, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId from m_product pr join M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id join M_TRANSACTION v on v.m_product_id = pr.m_product_id JOIN m_locator l on v.m_locator_id = l.m_locator_id LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on invl.m_inventory_id = inv.m_inventory_id WHERE v.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on io.m_inout_id = iol.m_inout_id WHERE v.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on mml.m_movement_id = mm.m_movement_id WHERE v.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on pp.m_production_id = ppl.m_production_id WHERE v.m_productionline_id = ppl.m_productionline_id ) pl on true LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pr.m_product_id) LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = v.m_attributesetinstance_id and ass.m_attributeset_id = pr.m_attributeset_id where pr.ad_client_id = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) and l.ad_org_id in (0,0,1000000,1000002,1000001) and v.movementdate between TO_TIMESTAMP('2022-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') and v.movementqty != 0 And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') and v.AD_CLIENT_ID=1000000 order by name postgresql-2023-08-22_095748.log:2023-08-22 10:05:58 +04,20946 LOG: duration: 11972.949 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND MovementDate < TO_TIMESTAMP('2022-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $2) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2022-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-22_095748.log:2023-08-22 10:09:48 +04,20968 LOG: duration: 10430.295 ms execute : select distinct pr.m_product_id, pr.name, pr.upc, pr.sku, pr.description, pr.group1, pr.group2, pr.commodity_code, coalesce(dividerate,1) dividerate,uomc.c_uom_to_id,uom.uomsymbol,uom.stdprecision,pr.c_uom_id, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId from m_product pr join M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id join M_TRANSACTION v on v.m_product_id = pr.m_product_id JOIN m_locator l on v.m_locator_id = l.m_locator_id LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on invl.m_inventory_id = inv.m_inventory_id WHERE v.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on io.m_inout_id = iol.m_inout_id WHERE v.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on mml.m_movement_id = mm.m_movement_id WHERE v.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on pp.m_production_id = ppl.m_production_id WHERE v.m_productionline_id = ppl.m_productionline_id ) pl on true LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pr.m_product_id) LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = v.m_attributesetinstance_id and ass.m_attributeset_id = pr.m_attributeset_id where pr.ad_client_id = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) and l.ad_org_id in (0,0,1000000,1000002,1000001) and v.movementdate between TO_TIMESTAMP('2022-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') and v.movementqty != 0 And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') and v.AD_CLIENT_ID=1000000 order by name postgresql-2023-08-22_095748.log:2023-08-22 10:10:01 +04,20968 LOG: duration: 12280.092 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND MovementDate < TO_TIMESTAMP('2022-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $2) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2022-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-22_104140.log:2023-08-22 11:00:13 +04,22436 LOG: duration: 7787.331 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-22_104140.log:2023-08-22 11:19:11 +04,22949 LOG: duration: 31682.044 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_113619.log:2023-08-22 11:44:34 +04,23593 LOG: duration: 17046.421 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-22_113619.log:2023-08-22 11:44:49 +04,22946 LOG: duration: 32219.851 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_113619.log:2023-08-22 12:00:13 +04,24138 LOG: duration: 7681.581 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-22_113619.log:2023-08-22 12:29:51 +04,24924 LOG: duration: 6021.510 ms execute : SELECT m.M_MOVEMENT_ID, m.DOCUMENTNO, m.movementdate,m.isactive,m.c_doctype_id,m.description, CASE WHEN m.docstatus='CO' and towar.isintransit='Y' and towar.parentwarehouseid <> 0 and confmov.m_movement_id is null then 'IT' ELSE m.docstatus END AS docstatus, m.isapproved,m.created, CASE WHEN towar.isintransit='Y' and towar.parentwarehouseid <> 0 then confmov.movementdate ELSE mc.confirmdate END as confirmdate, org.name as orgfromname, toorg.name as orgtoname, war.name as fromwarename, coalesce(to_par.name,towar.name) towarename, sum(coalesce(bompricestd(ml.m_product_id,1010047, ml.m_attributesetinstance_id, m.movementdate ) * ml.movementqty, 0)) AS totalCost, sum(ml.movementqty) as movementqty, CASE WHEN towar.isintransit='Y' and towar.parentwarehouseid <> 0 then confmovc.documentno ELSE mc.documentno END as confirmno, SUM(round((ml.movementqty) * ((case when pl.istaxincluded ='Y' then coalesce(bompricestd(ml.m_product_id, 1000001, 0, 0, null), 0) else coalesce(bompricestd(ml.m_product_id, 1000001, 0, 0, null) * (1+(tax.rate/100)) ,0) END)),3)) AS inclprice, SUM(round((ml.movementqty) * ((case when pl.istaxincluded ='N' then coalesce(bompricestd(ml.m_product_id, 1000001, 0, 0, null), 0) else coalesce(bompricestd(ml.m_product_id, 1000001, 0, 0, null)/(1+(tax.rate/100)) ,0) END)),3)) AS exclprice FROM M_MOVEMENT m JOIN M_MOVEMENTLINE ml ON ml.m_movement_id = m.m_movement_id LEFT JOIN m_movementconfirm mc ON mc.m_movement_id = m.m_movement_id JOIN m_locator loc on loc.m_locator_id = ml.m_locator_id join m_locator toloc on toloc.m_locator_id = ml.m_locatorto_id JOIN m_warehouse war ON loc.m_warehouse_id = war.m_warehouse_id and NOT (war.isintransit='Y' and war.parentwarehouseid <> 0) JOIN m_warehouse towar ON towar.m_warehouse_id = toloc.m_warehouse_id LEFT JOIN M_warehouse to_par ON towar.isintransit='Y' and towar.parentwarehouseid = to_par.m_warehouse_id JOIN ad_org org ON org.ad_org_id = war.ad_org_id JOIN ad_org toorg ON toorg.ad_org_id=towar.ad_org_id LEFT JOIN m_costdetail cd on cd.m_movementline_id=ml.m_movementline_id and cd.amt > 0 LEFT JOIN M_Movement confmov on m.m_movement_id = confmov.ref_movement_id and confmov.docstatus in ('CO','CL') LEFT JOIN M_MovementConfirm confmovc on confmov.m_movement_id=confmovc.m_movement_id LEFT JOIN M_Product p on ml.m_product_id = p.m_product_id LEFT JOIN C_TAX tax on p.c_taxcategory_id = tax.c_taxcategory_id and tax.isdefault='Y' , m_pricelist pl WHERE loc.m_warehouse_id <> toloc.m_warehouse_id and m.AD_CLIENT_ID = 1000000 AND war.AD_ORG_ID = 1000000 and m.docstatus='CO' AND (towar.isintransit='N' OR coalesce(towar.parentwarehouseid,0) = 0 OR coalesce(confmov.m_movement_id,0) != 0) and m.MOVEMENTDATE between TO_TIMESTAMP('2023-08-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-22 12:29:45','YYYY-MM-DD HH24:MI:SS') AND pl.m_pricelist_id = 1000001 group by m.m_movement_id,confmov.m_movement_id,mc.m_movementconfirm_id,org.ad_org_id,org.name,toorg.ad_org_id,toorg.name,war.m_warehouse_id,war.name,towar.m_warehouse_id,towar.isintransit,towar.parentwarehouseid,to_par.m_warehouse_id,to_par.name,towar.m_warehouse_id,towar.name,confmovc.documentno ORDER BY movementdate desc, DOCUMENTNO DESC postgresql-2023-08-22_113619.log:2023-08-22 12:31:09 +04,24882 LOG: duration: 8291.518 ms execute : SELECT t.m_product_id,t.m_locator_id, sum(movementqty),t.m_attributesetinstance_id, sum(cwmovementqty) cwqty from M_Transaction t join m_locator l on t.m_locator_id = l.m_locator_id where l.m_warehouse_id = 1000000 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id postgresql-2023-08-22_113619.log:2023-08-22 12:31:14 +04,24882 LOG: duration: 5466.709 ms execute : select m_product_id, sum(reserved), sum(ordered),m_attributesetinstance_id from (select ol.m_product_id,ol.m_attributesetinstance_id, CASE ISSOTRX WHEN 'Y' then qtyreserved ELSE 0 END as reserved, CASE ISSOTRX WHEN 'N' then qtyreserved ELSE 0 END as ordered from c_orderline ol join c_order o on o.c_order_id=ol.c_order_id where ol.m_warehouse_id=1000000 and ol.ad_client_id = 1000000 and o.isactive='Y' and o.docstatus in ('CO','CL','IP')) ss group by m_product_id,m_attributesetinstance_id postgresql-2023-08-22_113619.log:2023-08-22 13:00:13 +04,25782 LOG: duration: 7787.020 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-22_113619.log:2023-08-22 13:34:48 +04,24983 LOG: duration: 17203.574 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-22_113619.log:2023-08-22 13:35:03 +04,26563 LOG: duration: 31649.991 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_113619.log:2023-08-22 13:53:54 +04,26564 LOG: duration: 31548.010 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_113619.log:2023-08-22 14:00:13 +04,27213 LOG: duration: 7533.205 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-22_113619.log:2023-08-22 15:00:13 +04,28745 LOG: duration: 7338.168 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-22_113619.log:2023-08-22 15:54:46 +04,29734 LOG: duration: 10293.835 ms execute : select distinct pro.m_product_id,pro.description,pro.name, sum(coalesce(st.qtyOrdered, 0)) as qty_ordered, puom.c_uom_id,puom.uomsymbol,puom.stdprecision,max(ss.mdate), sum(coalesce(st.qtyonhand, 0)) as qty_onhand, coalesce(pro.UPC,pro.SKU)as barcode, (coalesce(pro.group1,' ')||' '||coalesce(pro.group2,' ')) as group,pc.name as proCategoryName ,coalesce(uomc.dividerate,1),uomc.c_uom_to_id,uom.uomsymbol,max(coalesce(intransit.qty, 0)) as intransitQty, pro.group1, pro.group2, pro.commodity_code, pro.classification as pclassification, productAttribute(pro.m_attributesetinstance_id) AS nonInstanceAttribute, pro.unitsperpack from m_product pro left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pro.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pro.m_product_id) left join c_uom as uom on uomc.c_uom_to_id = uom.c_uom_id left join m_storage st on st.m_product_id=pro.m_product_id left join m_locator l on st.m_locator_id = l.m_locator_id left join c_uom as puom on puom.c_uom_id = pro.c_uom_id left join lateral (select max(mn.movementdate) mdate from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where m_product_id = pro.m_product_id and m_locator_id = l.m_locator_id group by mnl.m_product_id) as ss on true LEFT JOIN M_PRODUCT_CATEGORY pc on pro.m_product_category_id = pc.m_product_category_id left join lateral (select sum(mil.pickedqty) qty from m_inoutline mil join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and m_product_id= pro.m_product_id and m_locator_id = l.m_locator_id group By mil.m_product_id) intransit on true LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = st.m_attributesetinstance_id and ass.m_attributeset_id = pro.m_attributeset_id WHERE pro.AD_CLIENT_ID = 1000000 and pro.isactive = 'Y' AND l.AD_org_ID = 1000000 and lower(coalesce(pro.group2,'')) like lower($1) group by pro.m_product_id,pro.description,pro.name,puom.c_uom_id,puom.uomsymbol,puom.stdprecision,uomc.dividerate,uomc.c_uom_to_id,uom.uomsymbol, pro.UPC, pro.SKU, pro.group1, pro.group2, pc.name order by qty_ordered postgresql-2023-08-22_113619.log:2023-08-22 15:54:56 +04,29860 LOG: duration: 10183.536 ms execute : select distinct pro.m_product_id,pro.description,pro.name, sum(coalesce(st.qtyOrdered, 0)) as qty_ordered, puom.c_uom_id,puom.uomsymbol,puom.stdprecision,max(ss.mdate), sum(coalesce(st.qtyonhand, 0)) as qty_onhand, coalesce(pro.UPC,pro.SKU)as barcode, (coalesce(pro.group1,' ')||' '||coalesce(pro.group2,' ')) as group,pc.name as proCategoryName ,coalesce(uomc.dividerate,1),uomc.c_uom_to_id,uom.uomsymbol,max(coalesce(intransit.qty, 0)) as intransitQty, pro.group1, pro.group2, pro.commodity_code, pro.classification as pclassification, productAttribute(pro.m_attributesetinstance_id) AS nonInstanceAttribute, pro.unitsperpack from m_product pro left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pro.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pro.m_product_id) left join c_uom as uom on uomc.c_uom_to_id = uom.c_uom_id left join m_storage st on st.m_product_id=pro.m_product_id left join m_locator l on st.m_locator_id = l.m_locator_id left join c_uom as puom on puom.c_uom_id = pro.c_uom_id left join lateral (select max(mn.movementdate) mdate from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where m_product_id = pro.m_product_id and m_locator_id = l.m_locator_id group by mnl.m_product_id) as ss on true LEFT JOIN M_PRODUCT_CATEGORY pc on pro.m_product_category_id = pc.m_product_category_id left join lateral (select sum(mil.pickedqty) qty from m_inoutline mil join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and m_product_id= pro.m_product_id and m_locator_id = l.m_locator_id group By mil.m_product_id) intransit on true LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = st.m_attributesetinstance_id and ass.m_attributeset_id = pro.m_attributeset_id WHERE pro.AD_CLIENT_ID = 1000000 and pro.isactive = 'Y' AND l.AD_org_ID = 1000000 and lower(coalesce(pro.group2,'')) like lower($1) group by pro.m_product_id,pro.description,pro.name,puom.c_uom_id,puom.uomsymbol,puom.stdprecision,uomc.dividerate,uomc.c_uom_to_id,uom.uomsymbol, pro.UPC, pro.SKU, pro.group1, pro.group2, pc.name order by qty_ordered postgresql-2023-08-22_113619.log:2023-08-22 16:00:14 +04,30284 LOG: duration: 7840.320 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-22_163653.log:2023-08-22 16:53:47 +04,31523 LOG: duration: 10137.835 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,1000000) AND MovementDate < TO_TIMESTAMP('2023-06-01 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $2) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,1000000) AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2023-06-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-22 16:53:33','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-22_163653.log:2023-08-22 16:56:06 +04,31632 LOG: duration: 17549.449 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-22_163653.log:2023-08-22 16:56:20 +04,31630 LOG: duration: 31976.871 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_163653.log:2023-08-22 16:56:30 +04,31523 LOG: duration: 10045.499 ms execute : select distinct pro.m_product_id,pro.description,pro.name, sum(coalesce(st.qtyOrdered, 0)) as qty_ordered, puom.c_uom_id,puom.uomsymbol,puom.stdprecision,max(ss.mdate), sum(coalesce(st.qtyonhand, 0)) as qty_onhand, coalesce(pro.UPC,pro.SKU)as barcode, (coalesce(pro.group1,' ')||' '||coalesce(pro.group2,' ')) as group,pc.name as proCategoryName ,coalesce(uomc.dividerate,1),uomc.c_uom_to_id,uom.uomsymbol,max(coalesce(intransit.qty, 0)) as intransitQty, pro.group1, pro.group2, pro.commodity_code, pro.classification as pclassification, productAttribute(pro.m_attributesetinstance_id) AS nonInstanceAttribute, pro.unitsperpack from m_product pro left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pro.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pro.m_product_id) left join c_uom as uom on uomc.c_uom_to_id = uom.c_uom_id left join m_storage st on st.m_product_id=pro.m_product_id left join m_locator l on st.m_locator_id = l.m_locator_id left join c_uom as puom on puom.c_uom_id = pro.c_uom_id left join lateral (select max(mn.movementdate) mdate from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where m_product_id = pro.m_product_id and m_locator_id = l.m_locator_id group by mnl.m_product_id) as ss on true LEFT JOIN M_PRODUCT_CATEGORY pc on pro.m_product_category_id = pc.m_product_category_id left join lateral (select sum(mil.pickedqty) qty from m_inoutline mil join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and m_product_id= pro.m_product_id and m_locator_id = l.m_locator_id group By mil.m_product_id) intransit on true LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = st.m_attributesetinstance_id and ass.m_attributeset_id = pro.m_attributeset_id WHERE pro.AD_CLIENT_ID = 1000000 and pro.isactive = 'Y' AND l.AD_org_ID in (0,1000000,1000002,1000001) and lower(coalesce(pro.group1,'')||' '||coalesce(pro.group2,'')) like lower($1) group by pro.m_product_id,pro.description,pro.name,puom.c_uom_id,puom.uomsymbol,puom.stdprecision,uomc.dividerate,uomc.c_uom_to_id,uom.uomsymbol, pro.UPC, pro.SKU, pro.group1, pro.group2, pc.name order by qty_ordered postgresql-2023-08-22_163653.log:2023-08-22 16:57:15 +04,31640 LOG: duration: 12061.741 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND l.M_warehouse_ID=1010008 AND MovementDate < TO_TIMESTAMP('2023-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $2) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND l.M_Warehouse_ID=1010008 AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2023-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-22 23:59:59','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-22_163653.log:2023-08-22 17:00:14 +04,31782 LOG: duration: 7807.866 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-22_163653.log:2023-08-22 17:06:36 +04,31882 LOG: duration: 19481.601 ms execute : select distinct pro.m_product_id,pro.description,pro.name, sum(coalesce(st.qtyOrdered, 0)) as qty_ordered, puom.c_uom_id,puom.uomsymbol,puom.stdprecision,max(ss.mdate), sum(coalesce(st.qtyonhand, 0)) as qty_onhand, coalesce(pro.UPC,pro.SKU)as barcode, (coalesce(pro.group1,' ')||' '||coalesce(pro.group2,' ')) as group,pc.name as proCategoryName ,coalesce(uomc.dividerate,1),uomc.c_uom_to_id,uom.uomsymbol,max(coalesce(intransit.qty, 0)) as intransitQty, pro.group1, pro.group2, pro.commodity_code, pro.classification as pclassification, productAttribute(pro.m_attributesetinstance_id) AS nonInstanceAttribute, pro.unitsperpack from m_product pro left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pro.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pro.m_product_id) left join c_uom as uom on uomc.c_uom_to_id = uom.c_uom_id left join m_storage st on st.m_product_id=pro.m_product_id left join m_locator l on st.m_locator_id = l.m_locator_id left join c_uom as puom on puom.c_uom_id = pro.c_uom_id left join lateral (select max(mn.movementdate) mdate from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where m_product_id = pro.m_product_id and m_locator_id = l.m_locator_id group by mnl.m_product_id) as ss on true LEFT JOIN M_PRODUCT_CATEGORY pc on pro.m_product_category_id = pc.m_product_category_id left join lateral (select sum(mil.pickedqty) qty from m_inoutline mil join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and m_product_id= pro.m_product_id and m_locator_id = l.m_locator_id group By mil.m_product_id) intransit on true LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = st.m_attributesetinstance_id and ass.m_attributeset_id = pro.m_attributeset_id WHERE pro.AD_CLIENT_ID = 1000000 and pro.isactive = 'Y'AND pro.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_org_ID in (0,1000000,1000002,1000001) group by pro.m_product_id,pro.description,pro.name,puom.c_uom_id,puom.uomsymbol,puom.stdprecision,uomc.dividerate,uomc.c_uom_to_id,uom.uomsymbol, pro.UPC, pro.SKU, pro.group1, pro.group2, pc.name order by qty_ordered postgresql-2023-08-22_163653.log:2023-08-22 17:09:03 +04,31924 LOG: duration: 19275.103 ms execute : select distinct pro.m_product_id,pro.description,pro.name, sum(coalesce(st.qtyOrdered, 0)) as qty_ordered, puom.c_uom_id,puom.uomsymbol,puom.stdprecision,max(ss.mdate), sum(coalesce(st.qtyonhand, 0)) as qty_onhand, coalesce(pro.UPC,pro.SKU)as barcode, (coalesce(pro.group1,' ')||' '||coalesce(pro.group2,' ')) as group,pc.name as proCategoryName ,coalesce(uomc.dividerate,1),uomc.c_uom_to_id,uom.uomsymbol,max(coalesce(intransit.qty, 0)) as intransitQty, pro.group1, pro.group2, pro.commodity_code, pro.classification as pclassification, productAttribute(pro.m_attributesetinstance_id) AS nonInstanceAttribute, pro.unitsperpack from m_product pro left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pro.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pro.m_product_id) left join c_uom as uom on uomc.c_uom_to_id = uom.c_uom_id left join m_storage st on st.m_product_id=pro.m_product_id left join m_locator l on st.m_locator_id = l.m_locator_id left join c_uom as puom on puom.c_uom_id = pro.c_uom_id left join lateral (select max(mn.movementdate) mdate from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where m_product_id = pro.m_product_id and m_locator_id = l.m_locator_id group by mnl.m_product_id) as ss on true LEFT JOIN M_PRODUCT_CATEGORY pc on pro.m_product_category_id = pc.m_product_category_id left join lateral (select sum(mil.pickedqty) qty from m_inoutline mil join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and m_product_id= pro.m_product_id and m_locator_id = l.m_locator_id group By mil.m_product_id) intransit on true LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = st.m_attributesetinstance_id and ass.m_attributeset_id = pro.m_attributeset_id WHERE pro.AD_CLIENT_ID = 1000000 and pro.isactive = 'Y'AND pro.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_org_ID in (0,1000000,1000002,1000001) group by pro.m_product_id,pro.description,pro.name,puom.c_uom_id,puom.uomsymbol,puom.stdprecision,uomc.dividerate,uomc.c_uom_to_id,uom.uomsymbol, pro.UPC, pro.SKU, pro.group1, pro.group2, pc.name order by qty_ordered postgresql-2023-08-22_174606.log:2023-08-22 17:57:21 +04,564 LOG: duration: 19487.294 ms execute : select distinct pro.m_product_id,pro.description,pro.name, sum(coalesce(st.qtyOrdered, 0)) as qty_ordered, puom.c_uom_id,puom.uomsymbol,puom.stdprecision,max(ss.mdate), sum(coalesce(st.qtyonhand, 0)) as qty_onhand, coalesce(pro.UPC,pro.SKU)as barcode, (coalesce(pro.group1,' ')||' '||coalesce(pro.group2,' ')) as group,pc.name as proCategoryName ,coalesce(uomc.dividerate,1),uomc.c_uom_to_id,uom.uomsymbol,max(coalesce(intransit.qty, 0)) as intransitQty, pro.group1, pro.group2, pro.commodity_code, pro.classification as pclassification, productAttribute(pro.m_attributesetinstance_id) AS nonInstanceAttribute, pro.unitsperpack from m_product pro left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pro.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pro.m_product_id) left join c_uom as uom on uomc.c_uom_to_id = uom.c_uom_id left join m_storage st on st.m_product_id=pro.m_product_id left join m_locator l on st.m_locator_id = l.m_locator_id left join c_uom as puom on puom.c_uom_id = pro.c_uom_id left join lateral (select max(mn.movementdate) mdate from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where m_product_id = pro.m_product_id and m_locator_id = l.m_locator_id group by mnl.m_product_id) as ss on true LEFT JOIN M_PRODUCT_CATEGORY pc on pro.m_product_category_id = pc.m_product_category_id left join lateral (select sum(mil.pickedqty) qty from m_inoutline mil join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and m_product_id= pro.m_product_id and m_locator_id = l.m_locator_id group By mil.m_product_id) intransit on true LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = st.m_attributesetinstance_id and ass.m_attributeset_id = pro.m_attributeset_id WHERE pro.AD_CLIENT_ID = 1000000 and pro.isactive = 'Y'AND pro.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_org_ID in (0,1000000,1000002,1000001) group by pro.m_product_id,pro.description,pro.name,puom.c_uom_id,puom.uomsymbol,puom.stdprecision,uomc.dividerate,uomc.c_uom_to_id,uom.uomsymbol, pro.UPC, pro.SKU, pro.group1, pro.group2, pc.name order by qty_ordered postgresql-2023-08-22_174606.log:2023-08-22 17:59:02 +04,564 LOG: duration: 19057.975 ms execute : select distinct pro.m_product_id,pro.description,pro.name, sum(coalesce(st.qtyOrdered, 0)) as qty_ordered, puom.c_uom_id,puom.uomsymbol,puom.stdprecision,max(ss.mdate), sum(coalesce(st.qtyonhand, 0)) as qty_onhand, coalesce(pro.UPC,pro.SKU)as barcode, (coalesce(pro.group1,' ')||' '||coalesce(pro.group2,' ')) as group,pc.name as proCategoryName ,coalesce(uomc.dividerate,1),uomc.c_uom_to_id,uom.uomsymbol,max(coalesce(intransit.qty, 0)) as intransitQty, pro.group1, pro.group2, pro.commodity_code, pro.classification as pclassification, productAttribute(pro.m_attributesetinstance_id) AS nonInstanceAttribute, pro.unitsperpack from m_product pro left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pro.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pro.m_product_id) left join c_uom as uom on uomc.c_uom_to_id = uom.c_uom_id left join m_storage st on st.m_product_id=pro.m_product_id left join m_locator l on st.m_locator_id = l.m_locator_id left join c_uom as puom on puom.c_uom_id = pro.c_uom_id left join lateral (select max(mn.movementdate) mdate from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where m_product_id = pro.m_product_id and m_locator_id = l.m_locator_id group by mnl.m_product_id) as ss on true LEFT JOIN M_PRODUCT_CATEGORY pc on pro.m_product_category_id = pc.m_product_category_id left join lateral (select sum(mil.pickedqty) qty from m_inoutline mil join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and m_product_id= pro.m_product_id and m_locator_id = l.m_locator_id group By mil.m_product_id) intransit on true LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = st.m_attributesetinstance_id and ass.m_attributeset_id = pro.m_attributeset_id WHERE pro.AD_CLIENT_ID = 1000000 and pro.isactive = 'Y'AND pro.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_org_ID in (0,1000000,1000002,1000001) group by pro.m_product_id,pro.description,pro.name,puom.c_uom_id,puom.uomsymbol,puom.stdprecision,uomc.dividerate,uomc.c_uom_to_id,uom.uomsymbol, pro.UPC, pro.SKU, pro.group1, pro.group2, pc.name order by qty_ordered postgresql-2023-08-22_174606.log:2023-08-22 18:00:13 +04,963 LOG: duration: 7473.255 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-22_174606.log:2023-08-22 18:00:14 +04,855 LOG: duration: 7919.709 ms execute : SELECT t.m_product_id,t.m_locator_id, sum(movementqty),t.m_attributesetinstance_id, sum(cwmovementqty) cwqty from M_Transaction t join m_locator l on t.m_locator_id = l.m_locator_id where l.m_warehouse_id = 1000000 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id postgresql-2023-08-22_174606.log:2023-08-22 18:00:19 +04,855 LOG: duration: 5443.750 ms execute : select m_product_id, sum(reserved), sum(ordered),m_attributesetinstance_id from (select ol.m_product_id,ol.m_attributesetinstance_id, CASE ISSOTRX WHEN 'Y' then qtyreserved ELSE 0 END as reserved, CASE ISSOTRX WHEN 'N' then qtyreserved ELSE 0 END as ordered from c_orderline ol join c_order o on o.c_order_id=ol.c_order_id where ol.m_warehouse_id=1000000 and ol.ad_client_id = 1000000 and o.isactive='Y' and o.docstatus in ('CO','CL','IP')) ss group by m_product_id,m_attributesetinstance_id postgresql-2023-08-22_174606.log:2023-08-22 18:04:42 +04,727 LOG: duration: 17514.905 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-22_174606.log:2023-08-22 18:04:57 +04,758 LOG: duration: 32219.873 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-22_174606.log:2023-08-22 18:15:35 +04,1042 LOG: duration: 31834.553 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_000000.log:2023-08-23 07:34:29 +04,21310 LOG: duration: 32093.461 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_000000.log:2023-08-23 08:00:14 +04,21972 LOG: duration: 7915.996 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-23_000000.log:2023-08-23 08:06:04 +04,22120 LOG: duration: 17122.092 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-23_000000.log:2023-08-23 08:06:19 +04,22122 LOG: duration: 31900.324 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_000000.log:2023-08-23 08:10:50 +04,22120 LOG: duration: 31748.768 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_000000.log:2023-08-23 08:20:29 +04,22492 LOG: duration: 17398.449 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-23_000000.log:2023-08-23 08:20:44 +04,22226 LOG: duration: 31966.780 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_000000.log:2023-08-23 08:25:25 +04,22226 LOG: duration: 31812.970 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_000000.log:2023-08-23 08:56:28 +04,23422 LOG: duration: 17071.016 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-23_000000.log:2023-08-23 08:56:43 +04,23417 LOG: duration: 32125.673 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_000000.log:2023-08-23 09:00:14 +04,23564 LOG: duration: 7810.064 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-23_091154.log:2023-08-23 09:15:10 +04,23934 LOG: duration: 31634.133 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_091154.log:2023-08-23 09:35:43 +04,24470 LOG: duration: 26775.051 ms execute : select m_transaction_id from m_transaction where m_inoutline_ID in (2524667,2524666,2524665,2524664,2524663,2524662,2524661,2524660,2524659,2524651,2524650,2524649,2524648,2524647,2524646,2524645,2524644,2524643,2524642,2524641,2524640,2524639,2524638,2524637,2524636,2524635,2524634,2524633,2524632,2524631,2524630,2524629,2524628,2524627,2524626,2524625,2524624,2524623,2524622,2524621,2524620,2524619,2524618,2524617,2524616,2524615,2524614,2524613,2524612,2524611,2524610,2524609,2524608,2524607,2524606,2524605,2524604,2524603,2524602,2524601,2524600,2524599,2524598,2524597,2524596,2524595,2524594,2524593,2524592,2524591,2524590,2524589,2524588,2524587,2524586,2524585,2524584,2524583,2524582,2524581,2524580,2524579,2524578,2524577,2524576,2524575,2524574,2524573,2524572,2524571,2524570,2524569,2524568,2524567,2524566,2524565,2524564,2524563,2524562,2524561,2524560,2524559,2524558,2524557,2524556,2524555,2524554,2524553,2524552,2524551,2524550,2524549,2524548,2524547,2524546,2524545,2524544,2524543,2524542,2524541,2524540,2524723,2524722,2524721,2524720,2524719,2524718,2524717,2524716,2524715,2524714,2524713,2524712,2524711,2524710,2524709,2524708,2524707,2524706,2524705,2524704,2524703,2524702,2524701,2524700,2524699,2524698,2524697,2524696,2524695,2524694,2524693,2524692,2524691,2524690,2524689,2524688,2524687,2524686,2524685,2524684,2524683,2524682,2524681,2524680,2524679,2524678,2524677,2524676,2524675,2524674,2524673,2524672,2524671,2524670,2524669,2524668,2524658,2524657,2524656,2524655,2524654,2524653,2524652,2524735,2524734,2524733,2524732,2524731,2524730,2524729,2524728,2524727,2524726,2524725,2524724,2524775,2524774,2524773,2524772,2524771,2524770,2524769,2524768,2524767,2524766,2524765,2524764,2524763,2524762,2524761,2524760,2524759,2524758,2524757,2524756,2524755,2524754,2524753,2524752,2524751,2524750,2524749,2524748,2524747,2524746,2524745,2524744,2524743,2524742,2524741,2524740,2524739,2524738,2524737,2524736,2524778,2524777,2524776,2524804,2524803,2524802,2524801,2524800,2524799,2524798,2524797,2524796,2524795,2524794,2524793,2524792,2524791,2524790,2524789,2524788,2524787,2524786,2524785,2524784,2524783,2524782,2524781,2524780,2524779) postgresql-2023-08-23_091154.log:2023-08-23 09:36:23 +04,24470 LOG: duration: 5150.240 ms execute : select Fact_Acct_id from Fact_Acct where updated > current_date -5 and ad_client_id=1000000 postgresql-2023-08-23_094058.log:2023-08-23 10:00:13 +04,25404 LOG: duration: 7844.799 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-23_102742.log:2023-08-23 11:00:13 +04,27629 LOG: duration: 7864.975 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-23_111505.log:2023-08-23 11:30:47 +04,28399 LOG: duration: 26737.355 ms execute : SELECT bp.C_BP_Group_ID, bp.C_BPartner_ID,oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID, oi.C_Currency_ID, oi.IsSOTrx, oi.DateInvoiced, oi.NetDays, oi.DueDate, oi.DaysDue,currencyConvert(oi.C_Conversion_Rate_ID,oi.GrandTotal,oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID), coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoicePaidToDate(oi.C_Invoice_ID, oi.C_Currency_ID, 1,TO_TIMESTAMP('2023-08-23','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) PaidAmt, coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,TO_TIMESTAMP('2023-08-23','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) OpenAmt,oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID,oi.AD_Org_ID FROM RV_OpenItemToDate oi INNER JOIN C_BPartner bp ON coalesce(oi.pay_bpartner_id,oi.C_BPartner_ID)=bp.C_BPartner_ID WHERE oi.AD_Client_ID IN(0,1000000) AND oi.AD_ORG_ID in (0,1000000,1000002,1000001) AND invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,'2023-08-23 23:59:59.0') <> 0 AND oi.isSoTrx = 'Y' ORDER BY oi.C_BPartner_ID, oi.C_Currency_ID, oi.C_Invoice_ID postgresql-2023-08-23_111505.log:2023-08-23 11:31:20 +04,28399 LOG: duration: 31407.545 ms execute : select op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-23','YYYY-MM-DD') THEN 0 ELSE op.DISCOUNTAMT END AS discountamt,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID, CASE WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = 0 THEN 'Paid' WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = inv.GRANDTOTAL THEN 'UnPaid' ELSE 'Partially Paid' END AS status, CASE WHEN sign(op.OPENAMT) = -1 THEN 'overPaid' ELSE 'NULL' END AS sign, ord.poreference as ord_reference, inv.poreference as inv_reference,inv.c_charge_id, CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-23','YYYY-MM-DD') THEN 0 ELSE pt.discount END AS Trade_DiscountPercent, op.dateacct, bp.c_currency_id bpcurrency, bp.po_pricelist_id venPLId from RV_OPENITEM op JOIN C_Invoice inv on op.C_INVOICE_ID=inv.C_INVOICE_ID JOIN C_BPartner bp on op.C_BPARTNER_ID=bp.C_BPARTNER_ID JOIN C_PAYMENTTERM pt on op.C_PAYMENTTERM_ID=pt.C_PAYMENTTERM_ID left join c_cashline cl on op.C_INVOICE_ID=cl.C_INVOICE_ID JOIN C_CURRENCY cr on op.C_CURRENCY_ID=cr.C_CURRENCY_ID LEFT JOIN C_ORDER ord ON op.C_ORDER_ID=ord.C_ORDER_ID where op.AD_CLIENT_ID=1000000 and coalesce(ord.ordertype,'') <> 'Lay Buy Order' and op.issotrx='Y' and op.DATEINVOICED <= TO_TIMESTAMP('2023-08-23 23:59:59','YYYY-MM-DD HH24:MI:SS') and op.ad_org_id in (0,1000000,1000002,1000001) group by op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,op.DISCOUNTAMT ,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID,ord.poreference, inv.poreference,inv.c_charge_id, pt.discount, op.dateacct, bpcurrency, venPLId order by op.DATEINVOICED asc postgresql-2023-08-23_111505.log:2023-08-23 11:40:41 +04,28156 LOG: duration: 17021.482 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-23_111505.log:2023-08-23 11:40:56 +04,28207 LOG: duration: 31610.560 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_111505.log:2023-08-23 12:00:13 +04,29266 LOG: duration: 7825.137 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-23_111505.log:2023-08-23 12:18:21 +04,29841 LOG: duration: 16945.269 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-23_111505.log:2023-08-23 12:18:36 +04,29843 LOG: duration: 32171.079 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_111505.log:2023-08-23 13:00:13 +04,30903 LOG: duration: 7504.077 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-23_111505.log:2023-08-23 14:00:13 +04,32312 LOG: duration: 7824.864 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-23_111505.log:2023-08-23 14:07:47 +04,32480 LOG: duration: 31525.359 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_111505.log:2023-08-23 15:00:13 +04,1357 LOG: duration: 7593.112 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-23_152349.log:2023-08-23 16:00:13 +04,3387 LOG: duration: 7743.924 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-23_152349.log:2023-08-23 16:20:16 +04,3886 LOG: duration: 7172.293 ms execute : select distinct pr.m_product_id, pr.name, pr.upc, pr.sku, pr.description, pr.group1, pr.group2, pr.commodity_code, coalesce(dividerate,1) dividerate,uomc.c_uom_to_id,uom.uomsymbol,uom.stdprecision,pr.c_uom_id, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId from m_product pr join M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id join M_TRANSACTION v on v.m_product_id = pr.m_product_id JOIN m_locator l on v.m_locator_id = l.m_locator_id LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on invl.m_inventory_id = inv.m_inventory_id WHERE v.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on io.m_inout_id = iol.m_inout_id WHERE v.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on mml.m_movement_id = mm.m_movement_id WHERE v.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on pp.m_production_id = ppl.m_production_id WHERE v.m_productionline_id = ppl.m_productionline_id ) pl on true LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pr.m_product_id) LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = v.m_attributesetinstance_id and ass.m_attributeset_id = pr.m_attributeset_id where pr.ad_client_id = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) and l.ad_org_id in (0,0,1000000,1000002,1000001) and l.M_warehouse_ID=1000000 and v.movementdate between TO_TIMESTAMP('2022-12-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-23 23:59:59','YYYY-MM-DD HH24:MI:SS') and v.movementqty != 0 And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') and v.AD_CLIENT_ID=1000000 order by name postgresql-2023-08-23_152349.log:2023-08-23 16:20:28 +04,3886 LOG: duration: 11554.560 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND l.M_warehouse_ID=1000000 AND MovementDate < TO_TIMESTAMP('2022-12-01 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $2) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND l.M_Warehouse_ID=1000000 AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2022-12-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-23 23:59:59','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-23_152349.log:2023-08-23 16:39:31 +04,4294 LOG: duration: 8025.450 ms execute : SELECT t.m_product_id,t.m_locator_id, sum(movementqty),t.m_attributesetinstance_id, sum(cwmovementqty) cwqty from M_Transaction t join m_locator l on t.m_locator_id = l.m_locator_id where l.m_warehouse_id = 1000000 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id postgresql-2023-08-23_152349.log:2023-08-23 16:39:37 +04,4294 LOG: duration: 5485.907 ms execute : select m_product_id, sum(reserved), sum(ordered),m_attributesetinstance_id from (select ol.m_product_id,ol.m_attributesetinstance_id, CASE ISSOTRX WHEN 'Y' then qtyreserved ELSE 0 END as reserved, CASE ISSOTRX WHEN 'N' then qtyreserved ELSE 0 END as ordered from c_orderline ol join c_order o on o.c_order_id=ol.c_order_id where ol.m_warehouse_id=1000000 and ol.ad_client_id = 1000000 and o.isactive='Y' and o.docstatus in ('CO','CL','IP')) ss group by m_product_id,m_attributesetinstance_id postgresql-2023-08-23_152349.log:2023-08-23 16:50:44 +04,4740 LOG: duration: 26496.840 ms execute : SELECT bp.C_BP_Group_ID, bp.C_BPartner_ID,oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID, oi.C_Currency_ID, oi.IsSOTrx, oi.DateInvoiced, oi.NetDays, oi.DueDate, oi.DaysDue,currencyConvert(oi.C_Conversion_Rate_ID,oi.GrandTotal,oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID), coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoicePaidToDate(oi.C_Invoice_ID, oi.C_Currency_ID, 1,TO_TIMESTAMP('2023-08-23','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) PaidAmt, coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,TO_TIMESTAMP('2023-08-23','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) OpenAmt,oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID,oi.AD_Org_ID FROM RV_OpenItemToDate oi INNER JOIN C_BPartner bp ON coalesce(oi.pay_bpartner_id,oi.C_BPartner_ID)=bp.C_BPartner_ID WHERE oi.AD_Client_ID IN(0,1000000) AND oi.AD_ORG_ID in (0,1000000,1000002,1000001) AND invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,'2023-08-23 23:59:59.0') <> 0 AND oi.isSoTrx = 'Y' ORDER BY oi.C_BPartner_ID, oi.C_Currency_ID, oi.C_Invoice_ID postgresql-2023-08-23_152349.log:2023-08-23 16:51:17 +04,4740 LOG: duration: 31266.431 ms execute : select op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-23','YYYY-MM-DD') THEN 0 ELSE op.DISCOUNTAMT END AS discountamt,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID, CASE WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = 0 THEN 'Paid' WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = inv.GRANDTOTAL THEN 'UnPaid' ELSE 'Partially Paid' END AS status, CASE WHEN sign(op.OPENAMT) = -1 THEN 'overPaid' ELSE 'NULL' END AS sign, ord.poreference as ord_reference, inv.poreference as inv_reference,inv.c_charge_id, CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-23','YYYY-MM-DD') THEN 0 ELSE pt.discount END AS Trade_DiscountPercent, op.dateacct, bp.c_currency_id bpcurrency, bp.po_pricelist_id venPLId from RV_OPENITEM op JOIN C_Invoice inv on op.C_INVOICE_ID=inv.C_INVOICE_ID JOIN C_BPartner bp on op.C_BPARTNER_ID=bp.C_BPARTNER_ID JOIN C_PAYMENTTERM pt on op.C_PAYMENTTERM_ID=pt.C_PAYMENTTERM_ID left join c_cashline cl on op.C_INVOICE_ID=cl.C_INVOICE_ID JOIN C_CURRENCY cr on op.C_CURRENCY_ID=cr.C_CURRENCY_ID LEFT JOIN C_ORDER ord ON op.C_ORDER_ID=ord.C_ORDER_ID where op.AD_CLIENT_ID=1000000 and coalesce(ord.ordertype,'') <> 'Lay Buy Order' and op.issotrx='Y' and op.DATEINVOICED <= TO_TIMESTAMP('2023-08-23 23:59:59','YYYY-MM-DD HH24:MI:SS') and op.ad_org_id in (0,1000000,1000002,1000001) group by op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,op.DISCOUNTAMT ,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID,ord.poreference, inv.poreference,inv.c_charge_id, pt.discount, op.dateacct, bpcurrency, venPLId order by op.DATEINVOICED asc postgresql-2023-08-23_152349.log:2023-08-23 17:00:13 +04,5040 LOG: duration: 7589.137 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-23_152349.log:2023-08-23 17:01:17 +04,3903 LOG: duration: 32192.951 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_152349.log:2023-08-23 17:20:46 +04,5560 LOG: duration: 17914.397 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-23_152349.log:2023-08-23 17:21:00 +04,5557 LOG: duration: 31828.624 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-23_152349.log:2023-08-23 18:00:13 +04,6573 LOG: duration: 7815.707 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-23_152349.log:2023-08-23 18:11:32 +04,6829 LOG: duration: 26277.391 ms execute : SELECT bp.C_BP_Group_ID, bp.C_BPartner_ID,oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID, oi.C_Currency_ID, oi.IsSOTrx, oi.DateInvoiced, oi.NetDays, oi.DueDate, oi.DaysDue,currencyConvert(oi.C_Conversion_Rate_ID,oi.GrandTotal,oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID), coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoicePaidToDate(oi.C_Invoice_ID, oi.C_Currency_ID, 1,TO_TIMESTAMP('2023-08-23','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) PaidAmt, coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,TO_TIMESTAMP('2023-08-23','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) OpenAmt,oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID,oi.AD_Org_ID FROM RV_OpenItemToDate oi INNER JOIN C_BPartner bp ON coalesce(oi.pay_bpartner_id,oi.C_BPartner_ID)=bp.C_BPartner_ID WHERE oi.AD_Client_ID IN(0,1000000) AND oi.AD_ORG_ID in (0,1000000,1000002,1000001) AND invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,'2023-08-23 23:59:59.0') <> 0 AND oi.isSoTrx = 'Y' ORDER BY oi.C_BPartner_ID, oi.C_Currency_ID, oi.C_Invoice_ID postgresql-2023-08-23_152349.log:2023-08-23 18:12:05 +04,6829 LOG: duration: 31100.486 ms execute : select op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-23','YYYY-MM-DD') THEN 0 ELSE op.DISCOUNTAMT END AS discountamt,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID, CASE WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = 0 THEN 'Paid' WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = inv.GRANDTOTAL THEN 'UnPaid' ELSE 'Partially Paid' END AS status, CASE WHEN sign(op.OPENAMT) = -1 THEN 'overPaid' ELSE 'NULL' END AS sign, ord.poreference as ord_reference, inv.poreference as inv_reference,inv.c_charge_id, CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-23','YYYY-MM-DD') THEN 0 ELSE pt.discount END AS Trade_DiscountPercent, op.dateacct, bp.c_currency_id bpcurrency, bp.po_pricelist_id venPLId from RV_OPENITEM op JOIN C_Invoice inv on op.C_INVOICE_ID=inv.C_INVOICE_ID JOIN C_BPartner bp on op.C_BPARTNER_ID=bp.C_BPARTNER_ID JOIN C_PAYMENTTERM pt on op.C_PAYMENTTERM_ID=pt.C_PAYMENTTERM_ID left join c_cashline cl on op.C_INVOICE_ID=cl.C_INVOICE_ID JOIN C_CURRENCY cr on op.C_CURRENCY_ID=cr.C_CURRENCY_ID LEFT JOIN C_ORDER ord ON op.C_ORDER_ID=ord.C_ORDER_ID where op.AD_CLIENT_ID=1000000 and coalesce(ord.ordertype,'') <> 'Lay Buy Order' and op.issotrx='Y' and op.DATEINVOICED <= TO_TIMESTAMP('2023-08-23 23:59:59','YYYY-MM-DD HH24:MI:SS') and op.ad_org_id in (0,1000000,1000002,1000001) group by op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,op.DISCOUNTAMT ,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID,ord.poreference, inv.poreference,inv.c_charge_id, pt.discount, op.dateacct, bpcurrency, venPLId order by op.DATEINVOICED asc postgresql-2023-08-23_183020.log:2023-08-23 19:04:27 +04,8386 LOG: duration: 17437.620 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-23_183020.log:2023-08-23 19:04:41 +04,8382 LOG: duration: 31741.745 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_000000.log:2023-08-24 08:00:13 +04,27860 LOG: duration: 7486.429 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-24_000000.log:2023-08-24 08:26:44 +04,28188 LOG: duration: 31744.900 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_000000.log:2023-08-24 08:42:14 +04,28868 LOG: duration: 16988.724 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-24_000000.log:2023-08-24 08:42:29 +04,28873 LOG: duration: 31768.109 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_000000.log:2023-08-24 08:43:59 +04,28914 LOG: duration: 7521.900 ms execute : SELECT m.M_MOVEMENT_ID, m.DOCUMENTNO, m.movementdate,m.isactive,m.c_doctype_id,m.description, CASE WHEN m.docstatus='CO' and towar.isintransit='Y' and towar.parentwarehouseid <> 0 and confmov.m_movement_id is null then 'IT' ELSE m.docstatus END AS docstatus, m.isapproved,m.created, CASE WHEN towar.isintransit='Y' and towar.parentwarehouseid <> 0 then confmov.movementdate ELSE mc.confirmdate END as confirmdate, org.name as orgfromname, toorg.name as orgtoname, war.name as fromwarename, coalesce(to_par.name,towar.name) towarename, sum(coalesce(bompricestd(ml.m_product_id,1010047, ml.m_attributesetinstance_id, m.movementdate ) * ml.movementqty, 0)) AS totalCost, sum(ml.movementqty) as movementqty, CASE WHEN towar.isintransit='Y' and towar.parentwarehouseid <> 0 then confmovc.documentno ELSE mc.documentno END as confirmno, SUM(round((ml.movementqty) * ((case when pl.istaxincluded ='Y' then coalesce(bompricestd(ml.m_product_id, 1000001, 0, 0, null), 0) else coalesce(bompricestd(ml.m_product_id, 1000001, 0, 0, null) * (1+(tax.rate/100)) ,0) END)),3)) AS inclprice, SUM(round((ml.movementqty) * ((case when pl.istaxincluded ='N' then coalesce(bompricestd(ml.m_product_id, 1000001, 0, 0, null), 0) else coalesce(bompricestd(ml.m_product_id, 1000001, 0, 0, null)/(1+(tax.rate/100)) ,0) END)),3)) AS exclprice FROM M_MOVEMENT m JOIN M_MOVEMENTLINE ml ON ml.m_movement_id = m.m_movement_id LEFT JOIN m_movementconfirm mc ON mc.m_movement_id = m.m_movement_id JOIN m_locator loc on loc.m_locator_id = ml.m_locator_id join m_locator toloc on toloc.m_locator_id = ml.m_locatorto_id JOIN m_warehouse war ON loc.m_warehouse_id = war.m_warehouse_id and NOT (war.isintransit='Y' and war.parentwarehouseid <> 0) JOIN m_warehouse towar ON towar.m_warehouse_id = toloc.m_warehouse_id LEFT JOIN M_warehouse to_par ON towar.isintransit='Y' and towar.parentwarehouseid = to_par.m_warehouse_id JOIN ad_org org ON org.ad_org_id = war.ad_org_id JOIN ad_org toorg ON toorg.ad_org_id=towar.ad_org_id LEFT JOIN m_costdetail cd on cd.m_movementline_id=ml.m_movementline_id and cd.amt > 0 LEFT JOIN M_Movement confmov on m.m_movement_id = confmov.ref_movement_id and confmov.docstatus in ('CO','CL') LEFT JOIN M_MovementConfirm confmovc on confmov.m_movement_id=confmovc.m_movement_id LEFT JOIN M_Product p on ml.m_product_id = p.m_product_id LEFT JOIN C_TAX tax on p.c_taxcategory_id = tax.c_taxcategory_id and tax.isdefault='Y' , m_pricelist pl WHERE loc.m_warehouse_id <> toloc.m_warehouse_id and m.AD_CLIENT_ID = 1000000 AND war.AD_ORG_ID = 1000000 and m.MOVEMENTDATE between TO_TIMESTAMP('2023-08-12 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-24 08:43:52','YYYY-MM-DD HH24:MI:SS') AND pl.m_pricelist_id = 1000001 group by m.m_movement_id,confmov.m_movement_id,mc.m_movementconfirm_id,org.ad_org_id,org.name,toorg.ad_org_id,toorg.name,war.m_warehouse_id,war.name,towar.m_warehouse_id,towar.isintransit,towar.parentwarehouseid,to_par.m_warehouse_id,to_par.name,towar.m_warehouse_id,towar.name,confmovc.documentno ORDER BY movementdate desc, DOCUMENTNO DESC postgresql-2023-08-24_000000.log:2023-08-24 08:44:39 +04,28914 LOG: duration: 18489.352 ms execute : select distinct pro.m_product_id,pro.description,pro.name, sum(coalesce(st.qtyOrdered, 0)) as qty_ordered, puom.c_uom_id,puom.uomsymbol,puom.stdprecision,max(ss.mdate), sum(coalesce(st.qtyonhand, 0)) as qty_onhand, coalesce(pro.UPC,pro.SKU)as barcode, (coalesce(pro.group1,' ')||' '||coalesce(pro.group2,' ')) as group,pc.name as proCategoryName ,coalesce(uomc.dividerate,1),uomc.c_uom_to_id,uom.uomsymbol,max(coalesce(intransit.qty, 0)) as intransitQty, pro.group1, pro.group2, pro.commodity_code, pro.classification as pclassification, productAttribute(pro.m_attributesetinstance_id) AS nonInstanceAttribute, pro.unitsperpack from m_product pro left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pro.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pro.m_product_id) left join c_uom as uom on uomc.c_uom_to_id = uom.c_uom_id left join m_storage st on st.m_product_id=pro.m_product_id left join m_locator l on st.m_locator_id = l.m_locator_id left join c_uom as puom on puom.c_uom_id = pro.c_uom_id left join lateral (select max(mn.movementdate) mdate from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where m_product_id = pro.m_product_id and m_locator_id = l.m_locator_id group by mnl.m_product_id) as ss on true LEFT JOIN M_PRODUCT_CATEGORY pc on pro.m_product_category_id = pc.m_product_category_id left join lateral (select sum(mil.pickedqty) qty from m_inoutline mil join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and m_product_id= pro.m_product_id and m_locator_id = l.m_locator_id group By mil.m_product_id) intransit on true LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = st.m_attributesetinstance_id and ass.m_attributeset_id = pro.m_attributeset_id WHERE pro.AD_CLIENT_ID = 1000000 and pro.isactive = 'Y'AND pro.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_org_ID = 1000000 group by pro.m_product_id,pro.description,pro.name,puom.c_uom_id,puom.uomsymbol,puom.stdprecision,uomc.dividerate,uomc.c_uom_to_id,uom.uomsymbol, pro.UPC, pro.SKU, pro.group1, pro.group2, pc.name order by qty_ordered postgresql-2023-08-24_000000.log:2023-08-24 08:45:14 +04,28367 LOG: duration: 19954.849 ms execute : select distinct pro.m_product_id,pro.description,pro.name, sum(coalesce(st.qtyOrdered, 0)) as qty_ordered, puom.c_uom_id,puom.uomsymbol,puom.stdprecision,max(ss.mdate), sum(coalesce(st.qtyonhand, 0)) as qty_onhand, coalesce(pro.UPC,pro.SKU)as barcode, (coalesce(pro.group1,' ')||' '||coalesce(pro.group2,' ')) as group,pc.name as proCategoryName ,coalesce(uomc.dividerate,1),uomc.c_uom_to_id,uom.uomsymbol,max(coalesce(intransit.qty, 0)) as intransitQty, pro.group1, pro.group2, pro.commodity_code, pro.classification as pclassification, productAttribute(pro.m_attributesetinstance_id) AS nonInstanceAttribute, pro.unitsperpack from m_product pro left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pro.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pro.m_product_id) left join c_uom as uom on uomc.c_uom_to_id = uom.c_uom_id left join m_storage st on st.m_product_id=pro.m_product_id left join m_locator l on st.m_locator_id = l.m_locator_id left join c_uom as puom on puom.c_uom_id = pro.c_uom_id left join lateral (select max(mn.movementdate) mdate from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where m_product_id = pro.m_product_id and m_locator_id = l.m_locator_id group by mnl.m_product_id) as ss on true LEFT JOIN M_PRODUCT_CATEGORY pc on pro.m_product_category_id = pc.m_product_category_id left join lateral (select sum(mil.pickedqty) qty from m_inoutline mil join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and m_product_id= pro.m_product_id and m_locator_id = l.m_locator_id group By mil.m_product_id) intransit on true LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = st.m_attributesetinstance_id and ass.m_attributeset_id = pro.m_attributeset_id WHERE pro.AD_CLIENT_ID = 1000000 and pro.isactive = 'Y'AND pro.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_org_ID in (0,1000000,1000002,1000001) group by pro.m_product_id,pro.description,pro.name,puom.c_uom_id,puom.uomsymbol,puom.stdprecision,uomc.dividerate,uomc.c_uom_to_id,uom.uomsymbol, pro.UPC, pro.SKU, pro.group1, pro.group2, pc.name order by qty_ordered postgresql-2023-08-24_000000.log:2023-08-24 08:45:32 +04,28939 LOG: duration: 45199.355 ms execute : SELECT 1, mp.name AS productname, mp.description,coalesce(mp.upc,mp.sku) as barcode,(coalesce(mp.group1,' ')||' '||coalesce(mp.group2,' ')) as group,pc.name as category , mp.m_product_id, mp.commodity_code, mp.group1, mp.group2, mp.upc as ItemRef, mp.sku as UPC,cur.c_currency_id,cur.cursymbol, mpl.istaxincluded, co.ordertype, SUM(round(case when mp.cw_uom_id > 0 then coalesce (col.qtypriced - cwinl.cwmovementqty, 0) else 0 end, cw.stdprecision)) as cwqty, round(SUM(col.linenetamt*(col.qtyordered - col.qtydelivered - coalesce(minl.pickedqty, 0))/COALESCE(NULLIF(col.qtyordered,0),1)),cur.stdprecision) AS Price, SUM(round((col.qtyordered - col.qtydelivered - coalesce(minl.pickedqty, 0)),uom.stdprecision)) AS QTY, SUM(round(col.qtydelivered,uom.stdprecision)) AS qtydelivered,round(SUM(col.linenetamt/COALESCE(NULLIF(col.qtyordered,0),1)),cur.stdprecision) AS unitprice, round(sum(currencyconvert(co.C_Conversion_Rate_ID,col.linenetamt*(col.qtyordered - col.qtydelivered)/COALESCE(NULLIF(col.qtyordered,0),1),co.c_currency_id,238,co.dateacct,null,co.ad_client_id,co.ad_org_id)),3) as amtInBase ,SUM(round(case when mp.cw_uom_id > 0 then col.linenetamt/COALESCE(NULLIF(col.qtypriced,0),1) else 0 end,cur.stdprecision)) as cwUnitprice , co.documentno ,co.dateordered as documentDate , co.c_order_id,co.poreference , SUM( (round((bompricestd(mp.m_product_id,1000001,0,case when mp.cw_uom_id > 0 then mp.cw_uom_id else uom.c_uom_id end,null) * (case when mp.cw_uom_id > 0 then (col.qtypriced - coalesce(cwinl.cwmovementqty, 0)) else (col.qtyordered - col.qtydelivered - coalesce(minl.pickedqty, 0)) end) ),cur.stdprecision))) as salesvalue,null as subgroupvalue ,uom.uomsymbol as uom FROM C_Orderline col left join C_Order co ON (co.C_Order_id = col.C_Order_id and co.issotrx='N' AND co.ad_client_id = 1000000 and co.ordertype in ('POS Goods Receive Note','Purchase Order')) JOIN C_currency cur ON co.C_currency_id = cur.C_currency_id JOIN M_Product mp on mp.M_Product_id = col.M_Product_id JOIN C_UOM uom on uom.c_uom_id = mp.c_uom_id JOIN M_pricelist mpl on mpl.m_pricelist_id = co.m_pricelist_id JOIN c_taxcategory tc on mp.c_taxcategory_id=tc.c_taxcategory_id JOIN C_tax ctax on tc.c_taxcategory_id = ctax.c_taxcategory_id and ctax.isdefault='Y' JOIN M_PRODUCT_CATEGORY pc on mp.m_product_category_id = pc.m_product_category_id JOIN C_Bpartner b on co.c_bpartner_id = b.c_bpartner_id LEFT JOIN M_Product basep on basep.m_product_id = mp.m_baseproduct_id LEFT JOIN c_uom cw ON cw.c_uom_id = col.price_uom_id left join lateral (select coalesce(sum(inl.pickedqty), 0) as pickedqty from m_inoutline inl join m_inout min on inl.m_inout_id = min.m_inout_id where min.docstatus in ('IP') AND inl.m_product_id = mp.m_product_id AND inl.c_orderline_id = col.c_orderline_id) minl on true left join lateral (select coalesce(sum(inl.cwmovementqty), 0) as cwmovementqty from m_inoutline inl join m_inout min on inl.m_inout_id = min.m_inout_id where min.docstatus in ('IP', 'CO', 'CL') AND inl.m_product_id = mp.m_product_id AND inl.c_orderline_id = col.c_orderline_id) cwinl on true WHERE co.dateordered BETWEEN TO_TIMESTAMP('2021-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP('2023-08-24 23:59:59','YYYY-MM-DD HH24:MI:SS') AND col.qtyordered > col.qtydelivered and co.docstatus in ('CO','CL') AND co.ad_org_id in (0,1000000,1000002,1000001) GROUP BY cur.c_currency_id,cur.stdprecision,cur.cursymbol,mpl.m_pricelist_id, mpl.istaxincluded, co.ordertype,mp.m_product_id, mp.name, mp.description, mp.upc, mp.sku ,mp.group1,mp.group2,pc.name,mp.commodity_code , co.c_order_id ,subgroupvalue,uom.uomsymbol HAVING SUM(round(col.qtyordered - col.qtydelivered)) > 0 ORDER BY 2 ,co.dateordered ,co.documentno postgresql-2023-08-24_000000.log:2023-08-24 09:00:13 +04,29371 LOG: duration: 7554.088 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-24_091932.log:2023-08-24 09:31:27 +04,30322 LOG: duration: 17259.531 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-24_091932.log:2023-08-24 09:31:42 +04,30319 LOG: duration: 32187.583 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_094456.log:2023-08-24 09:52:36 +04,30319 LOG: duration: 17368.478 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-24_094456.log:2023-08-24 09:52:51 +04,30987 LOG: duration: 32055.162 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_094456.log:2023-08-24 10:00:13 +04,31263 LOG: duration: 7872.487 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-24_094456.log:2023-08-24 10:14:12 +04,31514 LOG: duration: 178232.650 ms execute : select sum(coalesce(openingstockofdate(p.m_product_id,null,'{0,1000000,1000002,1000001}',null,null,'2023-06-01 00:00:00.0'),0)) as openingbal,sum(coalesce(coalesce (bompricestd(p.m_product_id,1010047,0,'2023-06-01 00:00:00.0'),bompricestd(p.m_product_id,1010047,0,null)),0) ) as openingRate,coalesce(sum(salesData.qtySold),0) as qtySold,coalesce(sum(salesData.qtySoldAmt-salesData.qtyCustomReturnAmt),0) as qtySoldAmt,coalesce(sum(vendorreturnqty),0) as vendorreturnqty,coalesce(sum(stockinqty+stockin.purchaseqty),0) as stockinqty,coalesce(sum((stockinqty*bompricestd(p.m_product_id,1010047,0,null))+stockin.purchasetotal),0) as stockinqtyAmt, sum(coalesce( closingstockofdate(p.m_product_id,null,'{0,1000000,1000002,1000001}',null,null,'2023-08-24 10:11:13.932'),0)) as closingbal,sum(coalesce(coalesce(bompricestd(p.m_product_id,1010047,0,'2023-08-24 10:11:13.932'),bompricestd (p.m_product_id,1010047,0,null)),0) ) as closingRate, coalesce(p.upc, p.sku) as barcode,p.m_product_id as pId,p.name,p.description as descrip,bp.name as vendorName,p.c_uom_id as uomId from m_product p LEFT JOIN (select il.m_product_id, sum(qtydelivered) as qtySold,sum(case when i.istaxincluded='Y' and o.ordertype='POS Order' then (il.linenetamt-taxamt) when i.istaxincluded='N' and o.ordertype='POS Order' then il.linenetamt else 0 end) as qtySoldAmt, sum(case when i.istaxincluded='Y' and o.ordertype='Customer Returned Order' then (il.linenetamt-taxamt) when i.istaxincluded='N' and o.ordertype='Customer Returned Order' then il.linenetamt else 0 end) as qtyCustomReturnAmt from c_invoiceline il join c_invoice i on i.c_invoice_id = il.c_invoice_id left join c_orderline ol on ol.c_orderline_id = il.c_orderline_id join c_order o on o.c_order_id = ol.c_order_id left join m_product p on p.m_product_id = il.m_product_id where i.issotrx='Y' and i.isactive='Y' and i.ad_client_id =1000000 and i.ad_org_id in (0,1000000,1000002,1000001) and o.docstatus in ('CO','CL') and o.dateordered >=TO_TIMESTAMP('2023-06-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and o.dateordered <=TO_TIMESTAMP('2023-08-24 10:11:13','YYYY-MM-DD HH24:MI:SS') group by il.m_product_id) as salesData on p.m_product_id = salesData.m_product_id LEFT JOIN (select il.m_product_id,sum(movementqty) as vendorreturnqty from m_inout i join m_inoutline il on i.m_inout_id = il.m_inout_id left join m_product p on p.m_product_id = il.m_product_id where movementtype='V-' and i.isactive='Y' and i.docstatus in ('CO','CL') and i.ad_client_id =1000000 and i.ad_org_id in (0,1000000,1000002,1000001) and i.movementdate >=TO_TIMESTAMP('2023-06-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and i.movementdate <=TO_TIMESTAMP('2023-08-24 10:11:13','YYYY-MM-DD HH24:MI:SS') group by il.m_product_id ) as VendorReturn on p.m_product_id = vendorReturn.m_product_id LEFT JOIN (select t.m_product_id, sum( case when movementtype ='V+' then iol.movementqty else 0 end ) as purchaseqty, sum( case when movementtype !='V+' then t.movementqty else 0 end) as stockinqty, sum(case when (movementtype = 'V+' and co.istaxincluded ='N') THEN ol.priceactual*qtydelivered when (movementtype = 'V+' and co.istaxincluded ='Y') THEN ((ol.priceactual*qtydelivered*100)/(ct.rate+100)) else 0 end ) as purchasetotal from m_transaction t join m_locator ml on t.m_locator_id=ml.m_locator_id left join m_inoutline iol on iol.m_inoutline_id = t.m_inoutline_id left join c_orderline ol on ol.c_orderline_id = iol.c_orderline_id left join c_order co on co.c_order_id = ol.c_order_id left join c_tax ct on ct.c_tax_id =ol.c_tax_id left join m_product p on p.m_product_id = t.m_product_id where t.ad_client_id =1000000 and movementtype in ('I+','I-','V+','M+','M-') and ml.ad_org_id in (0,1000000,1000002,1000001) and t.movementdate >=TO_TIMESTAMP('2023-06-01 00:00:00','YYYY-MM-DD HH24:MI:SS') and t.movementdate <=TO_TIMESTAMP('2023-08-24 10:11:13','YYYY-MM-DD HH24:MI:SS') group by t.m_product_id) as stockin ON stockin.m_product_id = p.m_product_id left join m_product_po po on po.m_product_id = p.m_product_id and iscurrentVendor ='Y' left join c_bpartner bp on po.c_bpartner_id = bp.c_bpartner_id where p.ad_client_id =1000000 and p.isactive like 'Y' group by p.m_product_id,p.name,descrip, vendorName,uomId having coalesce(sum(stockinqty),0) > 0 and coalesce(sum(salesData.qtySold),0) = 0 order by p.name asc postgresql-2023-08-24_094456.log:2023-08-24 10:19:09 +04,30319 LOG: duration: 31388.654 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_094456.log:2023-08-24 10:23:01 +04,31840 LOG: duration: 31773.215 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_094456.log:2023-08-24 10:47:18 +04,32370 LOG: duration: 26569.050 ms execute : SELECT bp.C_BP_Group_ID, bp.C_BPartner_ID,oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID, oi.C_Currency_ID, oi.IsSOTrx, oi.DateInvoiced, oi.NetDays, oi.DueDate, oi.DaysDue,currencyConvert(oi.C_Conversion_Rate_ID,oi.GrandTotal,oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID), coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoicePaidToDate(oi.C_Invoice_ID, oi.C_Currency_ID, 1,TO_TIMESTAMP('2023-08-24','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) PaidAmt, coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,TO_TIMESTAMP('2023-08-24','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) OpenAmt,oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID,oi.AD_Org_ID FROM RV_OpenItemToDate oi INNER JOIN C_BPartner bp ON coalesce(oi.pay_bpartner_id,oi.C_BPartner_ID)=bp.C_BPartner_ID WHERE oi.AD_Client_ID IN(0,1000000) AND oi.AD_ORG_ID in (0,1000000,1000002,1000001) AND invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,'2023-08-24 23:59:59.0') <> 0 AND oi.isSoTrx = 'Y' ORDER BY oi.C_BPartner_ID, oi.C_Currency_ID, oi.C_Invoice_ID postgresql-2023-08-24_104718.log:2023-08-24 10:47:51 +04,32370 LOG: duration: 31228.435 ms execute : select op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-24','YYYY-MM-DD') THEN 0 ELSE op.DISCOUNTAMT END AS discountamt,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID, CASE WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = 0 THEN 'Paid' WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = inv.GRANDTOTAL THEN 'UnPaid' ELSE 'Partially Paid' END AS status, CASE WHEN sign(op.OPENAMT) = -1 THEN 'overPaid' ELSE 'NULL' END AS sign, ord.poreference as ord_reference, inv.poreference as inv_reference,inv.c_charge_id, CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-24','YYYY-MM-DD') THEN 0 ELSE pt.discount END AS Trade_DiscountPercent, op.dateacct, bp.c_currency_id bpcurrency, bp.po_pricelist_id venPLId from RV_OPENITEM op JOIN C_Invoice inv on op.C_INVOICE_ID=inv.C_INVOICE_ID JOIN C_BPartner bp on op.C_BPARTNER_ID=bp.C_BPARTNER_ID JOIN C_PAYMENTTERM pt on op.C_PAYMENTTERM_ID=pt.C_PAYMENTTERM_ID left join c_cashline cl on op.C_INVOICE_ID=cl.C_INVOICE_ID JOIN C_CURRENCY cr on op.C_CURRENCY_ID=cr.C_CURRENCY_ID LEFT JOIN C_ORDER ord ON op.C_ORDER_ID=ord.C_ORDER_ID where op.AD_CLIENT_ID=1000000 and coalesce(ord.ordertype,'') <> 'Lay Buy Order' and op.issotrx='Y' and op.DATEINVOICED <= TO_TIMESTAMP('2023-08-24 23:59:59','YYYY-MM-DD HH24:MI:SS') and op.ad_org_id in (0,1000000,1000002,1000001) group by op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,op.DISCOUNTAMT ,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID,ord.poreference, inv.poreference,inv.c_charge_id, pt.discount, op.dateacct, bpcurrency, venPLId order by op.DATEINVOICED asc postgresql-2023-08-24_104718.log:2023-08-24 11:00:13 +04,408 LOG: duration: 7819.217 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-24_104718.log:2023-08-24 12:00:14 +04,2087 LOG: duration: 7806.587 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-24_123559.log:2023-08-24 13:00:14 +04,4060 LOG: duration: 7801.515 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-24_123559.log:2023-08-24 14:00:14 +04,5453 LOG: duration: 7814.697 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-24_123559.log:2023-08-24 14:10:08 +04,5729 LOG: duration: 31828.606 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_123559.log:2023-08-24 14:53:04 +04,6541 LOG: duration: 31406.355 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_145517.log:2023-08-24 15:00:13 +04,7299 LOG: duration: 7274.245 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-24_154350.log:2023-08-24 15:52:02 +04,8612 LOG: duration: 17178.593 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-24_154350.log:2023-08-24 15:52:17 +04,8613 LOG: duration: 31674.818 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_154350.log:2023-08-24 16:00:13 +04,8878 LOG: duration: 7262.771 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-24_154350.log:2023-08-24 16:03:44 +04,8732 LOG: duration: 36363.688 ms execute : select distinct pr.m_product_id, pr.name, pr.upc, pr.sku, pr.description, pr.group1, pr.group2, pr.commodity_code, coalesce(dividerate,1) dividerate,uomc.c_uom_to_id,uom.uomsymbol,uom.stdprecision,pr.c_uom_id, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId from m_product pr join M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id join M_TRANSACTION v on v.m_product_id = pr.m_product_id JOIN m_locator l on v.m_locator_id = l.m_locator_id LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on invl.m_inventory_id = inv.m_inventory_id WHERE v.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on io.m_inout_id = iol.m_inout_id WHERE v.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on mml.m_movement_id = mm.m_movement_id WHERE v.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on pp.m_production_id = ppl.m_production_id WHERE v.m_productionline_id = ppl.m_productionline_id ) pl on true LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pr.m_product_id) LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN (m_attributeset ass join m_attributesetinstance asi on ass.m_attributeset_id = asi.m_attributeset_id) on asi.m_attributesetinstance_id = v.m_attributesetinstance_id and ass.m_attributeset_id = pr.m_attributeset_id where pr.ad_client_id = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ($1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) and l.ad_org_id in (0,0,1000000,1000002,1000001) and l.M_warehouse_ID=1000000 and v.movementdate between TO_TIMESTAMP('2023-08-12 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-24 16:03:08','YYYY-MM-DD HH24:MI:SS') and v.movementqty != 0 And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') and v.AD_CLIENT_ID=1000000 order by name postgresql-2023-08-24_154350.log:2023-08-24 16:04:01 +04,8732 LOG: duration: 16710.620 ms execute : SELECT aa.*, coalesce(DivideRate,1) as dividerate, uomc.C_UoM_To_ID, uom.UoMSymbol, uom.StdPrecision FROM (select DISTINCT pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.group1, pr.group2, pr.commodity_code, pr.C_UoM_ID, sum(MovementQty) MovementQty, pr.m_product_category_id, pc.name as category_name, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id ) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $1) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND l.M_warehouse_ID=1000000 AND MovementDate < TO_TIMESTAMP('2023-08-12 00:00:00','YYYY-MM-DD HH24:MI:SS') GROUP BY pr.M_Product_ID, pr.Name, pr.UPC, pr.SKU, pr.Description, pr.C_UoM_ID, pr.group1, pr.group2, pr.commodity_code, firstAttributeValue, pr.m_product_category_id, pc.name) as aa LEFT JOIN (select DISTINCT pr.M_Product_ID, MovementQty MovementQty, pr.m_baseproduct_id as baseProductId,null as firstAttributeValue FROM M_Product pr JOIN M_Transaction tr ON tr.M_Product_ID = pr.M_Product_ID LEFT JOIN LATERAL (select inv.docstatus from m_inventoryline invl inner join m_inventory inv on (invl.m_inventory_id = inv.m_inventory_id ) WHERE tr.m_inventoryline_id = invl.m_inventoryline_id ) il on true LEFT JOIN LATERAL (select io.docstatus from m_inoutline iol inner join m_inout io on (io.m_inout_id = iol.m_inout_id) WHERE tr.m_inoutline_id = iol.m_inoutline_id ) ml on true LEFT JOIN LATERAL (select mm.docstatus from m_movementline mml inner join m_movement mm on (mml.m_movement_id = mm.m_movement_id) WHERE tr.m_movementline_id = mml.m_movementline_id ) ol on true LEFT JOIN LATERAL (select pp.docstatus from m_productionline ppl inner join m_production pp on (pp.m_production_id = ppl.m_production_id) WHERE tr.m_productionline_id = ppl.m_productionline_id ) pl on true JOIN M_Product_Category pc ON pr.M_Product_Category_ID = pc.M_Product_Category_ID JOIN M_Locator l ON tr.M_Locator_ID = l.M_Locator_ID WHERE pr.AD_Client_ID = 1000000AND pr.M_Product_ID in (select M_product_id from p_barcodemap where lowercode in ( $2) and codetype in ('PS','PU','PC','SN','El','Ey','EM','ED','Ed','EV')) AND l.AD_Org_ID in (0,0,1000000,1000002,1000001) AND l.M_Warehouse_ID=1000000 AND MovementQty <> 0 and tr.movementdate between TO_TIMESTAMP('2023-08-12 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP('2023-08-24 16:03:08','YYYY-MM-DD HH24:MI:SS') And coalesce(il.docstatus,ml.docstatus,ol.docstatus,pl.docstatus) in ('CO','CL') GROUP BY pr.M_Product_ID, MovementQty, firstAttributeValue ) bb on aa.M_Product_ID = bb.M_Product_ID LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =aa.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = aa.m_product_id) LEFT JOIN C_UoM uom ON uom.C_UoM_ID = coalesce(uomc.C_UoM_To_ID, aa.C_UoM_ID) WHERE aa.MovementQty <> 0 and (bb.MovementQty is NULL or bb.MovementQty = 0 ) order by 1 postgresql-2023-08-24_162453.log:2023-08-24 16:35:06 +04,9788 LOG: duration: 17330.531 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-24_162453.log:2023-08-24 16:35:20 +04,9760 LOG: duration: 31359.913 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_164731.log:2023-08-24 17:00:12 +04,10513 LOG: duration: 7256.920 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-24_164731.log:2023-08-24 17:33:12 +04,10897 LOG: duration: 31758.518 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_164731.log:2023-08-24 17:33:29 +04,10051 LOG: duration: 32000.357 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-24_164731.log:2023-08-24 17:41:28 +04,11294 LOG: duration: 751259.530 ms statement: copy (WITH date_series AS ( postgresql-2023-08-24_164731.log:2023-08-24 18:00:13 +04,12200 LOG: duration: 7300.544 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-25_000000.log:2023-08-25 08:00:13 +04,32629 LOG: duration: 7391.033 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-25_000000.log:2023-08-25 08:07:07 +04,330 LOG: duration: 17356.535 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-25_000000.log:2023-08-25 08:07:21 +04,328 LOG: duration: 31492.220 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-25_000000.log:2023-08-25 08:15:57 +04,333 LOG: duration: 31360.318 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-25_000000.log:2023-08-25 08:44:05 +04,871 LOG: duration: 17857.098 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-25_000000.log:2023-08-25 08:44:11 +04,927 LOG: duration: 32247.458 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-25_000000.log:2023-08-25 08:44:20 +04,1365 LOG: duration: 32399.258 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-25_000000.log:2023-08-25 08:55:55 +04,1830 LOG: duration: 17413.816 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-25_000000.log:2023-08-25 08:56:09 +04,1829 LOG: duration: 31414.073 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-25_000000.log:2023-08-25 08:59:58 +04,1936 LOG: duration: 31304.110 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-25_000000.log:2023-08-25 09:00:13 +04,2032 LOG: duration: 7414.774 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-25_000000.log:2023-08-25 09:06:23 +04,2241 LOG: duration: 29337.826 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-25_000000.log:2023-08-25 09:32:58 +04,3224 LOG: duration: 5258.177 ms execute : select pr.name as name, sum(coalesce(st.qtyonhand, 0) )as qty, pr.UPC as barcode, pr.m_product_id, sum(st.qtyreserved) as reserved, pr.unitsperpack, pc.name as proCategoryName, (coalesce(pr.group1,' ')||' '||coalesce(pr.group2,' ')) as group, coalesce(sum(st.qtyOrdered), 0) as qty_ordered, sum(coalesce(minl.pickedqty, 0) + coalesce(mmov.movementqty, 0) + coalesce(st.qtyintransit, 0)) as qtyintransit, coalesce(uomc.dividerate,1) as dividerate, uom.c_uom_id, uom.uomsymbol, uom.stdprecision,pr.sku as SKU, productAttribute(pr.m_attributesetinstance_id) AS nonInstanceAttribute ,null as firstAttributeValue , pbp.name as vendorname, pr.group1, pr.group2, pr.commodity_code,pr.classification as pclassification, case when pr.cw_uom_id > 0 then sum(coalesce(st.cwqtyonhand, 0)) else 0 end as cwqty, pr.hscode as hscode, pr.c_taxcategory_id as c_taxcategory_id, sum(coalesce(minl.pickedqty, 0)) venShippedQty FROM M_PRODUCT pr JOIN M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on pr.m_product_id = uomc.m_product_id LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN M_product_PO ppo on pr.m_product_id = ppo.m_product_id and ppo.iscurrentvendor='Y' LEFT JOIN C_Bpartner pbp on ppo.c_bpartner_id = pbp.c_bpartner_id JOIN c_taxcategory tc on tc.c_taxcategory_id = pr.c_taxcategory_id LEFT JOIN (SELECT SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.qtyonhand END), 0)) qtyonhand, SUM(COALESCE(s.qtyreserved, 0)) qtyreserved, SUM(COALESCE(s.qtyOrdered, 0)) qtyOrdered, SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN s.qtyonhand ELSE 0 END), 0)) qtyintransit, s.m_product_id , SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.cwqtyonhand END), 0)) cwqtyonhand FROM M_Storage s JOIN M_Locator loc ON loc.m_locator_id = s.m_locator_id JOIN M_Warehouse wr ON wr.m_warehouse_id = loc.m_warehouse_id WHERE s.m_locator_id in (select m_locator_id from m_locator where ad_org_id IN (0,0,1000000,1000002,1000001)) GROUP BY s.m_product_id) st ON (st.M_PRODUCT_ID=pr.M_PRODUCT_ID AND ((st.qtyonhand+st.qtyreserved+st.qtyordered+st.qtyintransit+st.cwqtyonhand) <> 0 OR st.qtyonhand <> 0 OR st.qtyreserved <> 0 OR st.qtyordered <> 0 OR st.qtyintransit<>0 OR st.cwqtyonhand <>0 )) left join (select sum(inl.pickedqty) as pickedqty, inl.m_product_id, inl.m_attributesetinstance_id from m_inoutline inl join m_inout min on inl.m_inout_id = min.m_inout_id where min.docstatus in ('IP') AND min.ad_org_id IN (0,0,1000000,1000002,1000001) group by m_product_id, inl.m_attributesetinstance_id) minl on pr.m_product_id = minl.m_product_id left join (select sum(m.movementqty) as movementqty, m.m_product_id, m.m_attributesetinstance_id from m_movementline m join m_movement mov on m.m_movement_id = mov.m_movement_id and mov.docstatus in ('IP')AND m.m_locatorto_id in (select m_locator_id from m_locator where ad_org_id IN (0,0,1000000,1000002,1000001)) group by m_product_id, m.m_attributesetinstance_id) mmov on pr.m_product_id = mmov.m_product_id where pr.isbaseproduct = 'N' AND pr.AD_CLIENT_ID = 1000000 and pr.isactive = 'Y' and lower(coalesce(pr.group1,'')) like lower($1) and pr.classification ='Ageing Stock' AND pr.ad_org_id IN (0,0,1000000,1000002,1000001) group by pr.m_product_id, pc.name, uomc.dividerate,uom.c_uom_id, firstAttributeValue,pbp.name having sum(st.qtyonhand)/coalesce(uomc.dividerate,1) > 0 order by name postgresql-2023-08-25_000000.log:2023-08-25 09:42:05 +04,3676 LOG: duration: 5326.272 ms execute : select pr.name as name, sum(coalesce(st.qtyonhand, 0) )as qty, pr.UPC as barcode, pr.m_product_id, sum(st.qtyreserved) as reserved, pr.unitsperpack, pc.name as proCategoryName, (coalesce(pr.group1,' ')||' '||coalesce(pr.group2,' ')) as group, coalesce(sum(st.qtyOrdered), 0) as qty_ordered, sum(coalesce(minl.pickedqty, 0) + coalesce(mmov.movementqty, 0) + coalesce(st.qtyintransit, 0)) as qtyintransit, coalesce(uomc.dividerate,1) as dividerate, uom.c_uom_id, uom.uomsymbol, uom.stdprecision,pr.sku as SKU, productAttribute(pr.m_attributesetinstance_id) AS nonInstanceAttribute ,null as firstAttributeValue , pbp.name as vendorname, pr.group1, pr.group2, pr.commodity_code,pr.classification as pclassification, case when pr.cw_uom_id > 0 then sum(coalesce(st.cwqtyonhand, 0)) else 0 end as cwqty, pr.hscode as hscode, pr.c_taxcategory_id as c_taxcategory_id, sum(coalesce(minl.pickedqty, 0)) venShippedQty FROM M_PRODUCT pr JOIN M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on pr.m_product_id = uomc.m_product_id LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN M_product_PO ppo on pr.m_product_id = ppo.m_product_id and ppo.iscurrentvendor='Y' LEFT JOIN C_Bpartner pbp on ppo.c_bpartner_id = pbp.c_bpartner_id JOIN c_taxcategory tc on tc.c_taxcategory_id = pr.c_taxcategory_id LEFT JOIN (SELECT SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.qtyonhand END), 0)) qtyonhand, SUM(COALESCE(s.qtyreserved, 0)) qtyreserved, SUM(COALESCE(s.qtyOrdered, 0)) qtyOrdered, SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN s.qtyonhand ELSE 0 END), 0)) qtyintransit, s.m_product_id , SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.cwqtyonhand END), 0)) cwqtyonhand FROM M_Storage s JOIN M_Locator loc ON loc.m_locator_id = s.m_locator_id JOIN M_Warehouse wr ON wr.m_warehouse_id = loc.m_warehouse_id WHERE s.m_locator_id in (select m_locator_id from m_locator where ad_org_id IN (0,0,1000000,1000002,1000001)) GROUP BY s.m_product_id) st ON (st.M_PRODUCT_ID=pr.M_PRODUCT_ID AND ((st.qtyonhand+st.qtyreserved+st.qtyordered+st.qtyintransit+st.cwqtyonhand) <> 0 OR st.qtyonhand <> 0 OR st.qtyreserved <> 0 OR st.qtyordered <> 0 OR st.qtyintransit<>0 OR st.cwqtyonhand <>0 )) left join (select sum(inl.pickedqty) as pickedqty, inl.m_product_id, inl.m_attributesetinstance_id from m_inoutline inl join m_inout min on inl.m_inout_id = min.m_inout_id where min.docstatus in ('IP') AND min.ad_org_id IN (0,0,1000000,1000002,1000001) group by m_product_id, inl.m_attributesetinstance_id) minl on pr.m_product_id = minl.m_product_id left join (select sum(m.movementqty) as movementqty, m.m_product_id, m.m_attributesetinstance_id from m_movementline m join m_movement mov on m.m_movement_id = mov.m_movement_id and mov.docstatus in ('IP')AND m.m_locatorto_id in (select m_locator_id from m_locator where ad_org_id IN (0,0,1000000,1000002,1000001)) group by m_product_id, m.m_attributesetinstance_id) mmov on pr.m_product_id = mmov.m_product_id where pr.isbaseproduct = 'N' AND pr.AD_CLIENT_ID = 1000000 and pr.isactive = 'Y' and lower(coalesce(pr.group1,'')) like lower($1) and pr.classification ='Ageing Stock' AND pr.ad_org_id IN (0,0,1000000,1000002,1000001) group by pr.m_product_id, pc.name, uomc.dividerate,uom.c_uom_id, firstAttributeValue,pbp.name having sum(st.qtyonhand)/coalesce(uomc.dividerate,1) > 0 order by name postgresql-2023-08-25_000000.log:2023-08-25 09:44:45 +04,3794 LOG: duration: 26358.033 ms execute : SELECT bp.C_BP_Group_ID, bp.C_BPartner_ID,oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID, oi.C_Currency_ID, oi.IsSOTrx, oi.DateInvoiced, oi.NetDays, oi.DueDate, oi.DaysDue,currencyConvert(oi.C_Conversion_Rate_ID,oi.GrandTotal,oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID), coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoicePaidToDate(oi.C_Invoice_ID, oi.C_Currency_ID, 1,TO_TIMESTAMP('2023-08-25','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) PaidAmt, coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,TO_TIMESTAMP('2023-08-25','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) OpenAmt,oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID,oi.AD_Org_ID FROM RV_OpenItemToDate oi INNER JOIN C_BPartner bp ON coalesce(oi.pay_bpartner_id,oi.C_BPartner_ID)=bp.C_BPartner_ID WHERE oi.AD_Client_ID IN(0,1000000) AND oi.AD_ORG_ID in (0,1000000,1000002,1000001) AND invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,'2023-08-25 23:59:59.0') <> 0 AND oi.isSoTrx = 'Y' ORDER BY oi.C_BPartner_ID, oi.C_Currency_ID, oi.C_Invoice_ID postgresql-2023-08-25_000000.log:2023-08-25 09:44:46 +04,3793 LOG: duration: 5299.177 ms execute : select pr.name as name, sum(coalesce(st.qtyonhand, 0) )as qty, pr.UPC as barcode, pr.m_product_id, sum(st.qtyreserved) as reserved, pr.unitsperpack, pc.name as proCategoryName, (coalesce(pr.group1,' ')||' '||coalesce(pr.group2,' ')) as group, coalesce(sum(st.qtyOrdered), 0) as qty_ordered, sum(coalesce(minl.pickedqty, 0) + coalesce(mmov.movementqty, 0) + coalesce(st.qtyintransit, 0)) as qtyintransit, coalesce(uomc.dividerate,1) as dividerate, uom.c_uom_id, uom.uomsymbol, uom.stdprecision,pr.sku as SKU, productAttribute(pr.m_attributesetinstance_id) AS nonInstanceAttribute ,null as firstAttributeValue , pbp.name as vendorname, pr.group1, pr.group2, pr.commodity_code,pr.classification as pclassification, case when pr.cw_uom_id > 0 then sum(coalesce(st.cwqtyonhand, 0)) else 0 end as cwqty, pr.hscode as hscode, pr.c_taxcategory_id as c_taxcategory_id, sum(coalesce(minl.pickedqty, 0)) venShippedQty FROM M_PRODUCT pr JOIN M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on pr.m_product_id = uomc.m_product_id LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN M_product_PO ppo on pr.m_product_id = ppo.m_product_id and ppo.iscurrentvendor='Y' LEFT JOIN C_Bpartner pbp on ppo.c_bpartner_id = pbp.c_bpartner_id JOIN c_taxcategory tc on tc.c_taxcategory_id = pr.c_taxcategory_id LEFT JOIN (SELECT SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.qtyonhand END), 0)) qtyonhand, SUM(COALESCE(s.qtyreserved, 0)) qtyreserved, SUM(COALESCE(s.qtyOrdered, 0)) qtyOrdered, SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN s.qtyonhand ELSE 0 END), 0)) qtyintransit, s.m_product_id , SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.cwqtyonhand END), 0)) cwqtyonhand FROM M_Storage s JOIN M_Locator loc ON loc.m_locator_id = s.m_locator_id JOIN M_Warehouse wr ON wr.m_warehouse_id = loc.m_warehouse_id WHERE s.m_locator_id in (select m_locator_id from m_locator where ad_org_id IN (0,0,1000000,1000002,1000001)) GROUP BY s.m_product_id) st ON (st.M_PRODUCT_ID=pr.M_PRODUCT_ID AND ((st.qtyonhand+st.qtyreserved+st.qtyordered+st.qtyintransit+st.cwqtyonhand) <> 0 OR st.qtyonhand <> 0 OR st.qtyreserved <> 0 OR st.qtyordered <> 0 OR st.qtyintransit<>0 OR st.cwqtyonhand <>0 )) left join (select sum(inl.pickedqty) as pickedqty, inl.m_product_id, inl.m_attributesetinstance_id from m_inoutline inl join m_inout min on inl.m_inout_id = min.m_inout_id where min.docstatus in ('IP') AND min.ad_org_id IN (0,0,1000000,1000002,1000001) group by m_product_id, inl.m_attributesetinstance_id) minl on pr.m_product_id = minl.m_product_id left join (select sum(m.movementqty) as movementqty, m.m_product_id, m.m_attributesetinstance_id from m_movementline m join m_movement mov on m.m_movement_id = mov.m_movement_id and mov.docstatus in ('IP')AND m.m_locatorto_id in (select m_locator_id from m_locator where ad_org_id IN (0,0,1000000,1000002,1000001)) group by m_product_id, m.m_attributesetinstance_id) mmov on pr.m_product_id = mmov.m_product_id where pr.isbaseproduct = 'N' AND pr.AD_CLIENT_ID = 1000000 and pr.isactive = 'Y' and lower(coalesce(pr.group1,'')) like lower($1) and pr.classification ='Ageing Stock' AND pr.ad_org_id IN (0,0,1000000,1000002,1000001) group by pr.m_product_id, pc.name, uomc.dividerate,uom.c_uom_id, firstAttributeValue,pbp.name having sum(st.qtyonhand)/coalesce(uomc.dividerate,1) > 25 order by name postgresql-2023-08-25_000000.log:2023-08-25 09:45:02 +04,3612 LOG: duration: 5339.646 ms execute : select pr.name as name, sum(coalesce(st.qtyonhand, 0) )as qty, pr.UPC as barcode, pr.m_product_id, sum(st.qtyreserved) as reserved, pr.unitsperpack, pc.name as proCategoryName, (coalesce(pr.group1,' ')||' '||coalesce(pr.group2,' ')) as group, coalesce(sum(st.qtyOrdered), 0) as qty_ordered, sum(coalesce(minl.pickedqty, 0) + coalesce(mmov.movementqty, 0) + coalesce(st.qtyintransit, 0)) as qtyintransit, coalesce(uomc.dividerate,1) as dividerate, uom.c_uom_id, uom.uomsymbol, uom.stdprecision,pr.sku as SKU, productAttribute(pr.m_attributesetinstance_id) AS nonInstanceAttribute ,null as firstAttributeValue , pbp.name as vendorname, pr.group1, pr.group2, pr.commodity_code,pr.classification as pclassification, case when pr.cw_uom_id > 0 then sum(coalesce(st.cwqtyonhand, 0)) else 0 end as cwqty, pr.hscode as hscode, pr.c_taxcategory_id as c_taxcategory_id, sum(coalesce(minl.pickedqty, 0)) venShippedQty FROM M_PRODUCT pr JOIN M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id LEFT JOIN LATERAL (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on pr.m_product_id = uomc.m_product_id LEFT JOIN c_uom as uom on uom.c_uom_id = coalesce(uomc.c_uom_to_id,pr.c_uom_id) LEFT JOIN M_product_PO ppo on pr.m_product_id = ppo.m_product_id and ppo.iscurrentvendor='Y' LEFT JOIN C_Bpartner pbp on ppo.c_bpartner_id = pbp.c_bpartner_id JOIN c_taxcategory tc on tc.c_taxcategory_id = pr.c_taxcategory_id LEFT JOIN (SELECT SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.qtyonhand END), 0)) qtyonhand, SUM(COALESCE(s.qtyreserved, 0)) qtyreserved, SUM(COALESCE(s.qtyOrdered, 0)) qtyOrdered, SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN s.qtyonhand ELSE 0 END), 0)) qtyintransit, s.m_product_id , SUM(COALESCE((CASE WHEN wr.isintransit='Y' AND wr.parentwarehouseid > 0 THEN 0 ELSE s.cwqtyonhand END), 0)) cwqtyonhand FROM M_Storage s JOIN M_Locator loc ON loc.m_locator_id = s.m_locator_id JOIN M_Warehouse wr ON wr.m_warehouse_id = loc.m_warehouse_id WHERE s.m_locator_id in (select m_locator_id from m_locator where ad_org_id IN (0,0,1000000,1000002,1000001)) GROUP BY s.m_product_id) st ON (st.M_PRODUCT_ID=pr.M_PRODUCT_ID AND ((st.qtyonhand+st.qtyreserved+st.qtyordered+st.qtyintransit+st.cwqtyonhand) <> 0 OR st.qtyonhand <> 0 OR st.qtyreserved <> 0 OR st.qtyordered <> 0 OR st.qtyintransit<>0 OR st.cwqtyonhand <>0 )) left join (select sum(inl.pickedqty) as pickedqty, inl.m_product_id, inl.m_attributesetinstance_id from m_inoutline inl join m_inout min on inl.m_inout_id = min.m_inout_id where min.docstatus in ('IP') AND min.ad_org_id IN (0,0,1000000,1000002,1000001) group by m_product_id, inl.m_attributesetinstance_id) minl on pr.m_product_id = minl.m_product_id left join (select sum(m.movementqty) as movementqty, m.m_product_id, m.m_attributesetinstance_id from m_movementline m join m_movement mov on m.m_movement_id = mov.m_movement_id and mov.docstatus in ('IP')AND m.m_locatorto_id in (select m_locator_id from m_locator where ad_org_id IN (0,0,1000000,1000002,1000001)) group by m_product_id, m.m_attributesetinstance_id) mmov on pr.m_product_id = mmov.m_product_id where pr.isbaseproduct = 'N' AND pr.AD_CLIENT_ID = 1000000 and pr.isactive = 'Y' and lower(coalesce(pr.group1,'')) like lower($1) and pr.classification ='Ageing Stock' AND pr.ad_org_id IN (0,0,1000000,1000002,1000001) group by pr.m_product_id, pc.name, uomc.dividerate,uom.c_uom_id, firstAttributeValue,pbp.name having sum(st.qtyonhand)/coalesce(uomc.dividerate,1) > 0 order by name postgresql-2023-08-25_000000.log:2023-08-25 09:45:18 +04,3794 LOG: duration: 31145.881 ms execute : select op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-25','YYYY-MM-DD') THEN 0 ELSE op.DISCOUNTAMT END AS discountamt,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID, CASE WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = 0 THEN 'Paid' WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = inv.GRANDTOTAL THEN 'UnPaid' ELSE 'Partially Paid' END AS status, CASE WHEN sign(op.OPENAMT) = -1 THEN 'overPaid' ELSE 'NULL' END AS sign, ord.poreference as ord_reference, inv.poreference as inv_reference,inv.c_charge_id, CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-25','YYYY-MM-DD') THEN 0 ELSE pt.discount END AS Trade_DiscountPercent, op.dateacct, bp.c_currency_id bpcurrency, bp.po_pricelist_id venPLId from RV_OPENITEM op JOIN C_Invoice inv on op.C_INVOICE_ID=inv.C_INVOICE_ID JOIN C_BPartner bp on op.C_BPARTNER_ID=bp.C_BPARTNER_ID JOIN C_PAYMENTTERM pt on op.C_PAYMENTTERM_ID=pt.C_PAYMENTTERM_ID left join c_cashline cl on op.C_INVOICE_ID=cl.C_INVOICE_ID JOIN C_CURRENCY cr on op.C_CURRENCY_ID=cr.C_CURRENCY_ID LEFT JOIN C_ORDER ord ON op.C_ORDER_ID=ord.C_ORDER_ID where op.AD_CLIENT_ID=1000000 and coalesce(ord.ordertype,'') <> 'Lay Buy Order' and op.issotrx='Y' and op.DATEINVOICED <= TO_TIMESTAMP('2023-08-25 23:59:59','YYYY-MM-DD HH24:MI:SS') and op.ad_org_id in (0,1000000,1000002,1000001) group by op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,op.DISCOUNTAMT ,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID,ord.poreference, inv.poreference,inv.c_charge_id, pt.discount, op.dateacct, bpcurrency, venPLId order by op.DATEINVOICED asc postgresql-2023-08-25_094520.log:2023-08-25 09:45:45 +04,3856 LOG: duration: 17555.210 ms execute : (select '1' as "ID",case when accounttype='R' then 'Revenue' when accounttype='E' then 'Expense' else 'Asset' end as "Account Type",to_char(round(sum(acctbalance(f.account_id,f.amtacctdr,f.amtacctcr)),0),'999,999,999,999,999') "Amount" postgresql-2023-08-25_094520.log:2023-08-25 09:45:59 +04,3859 LOG: duration: 32037.503 ms execute : select name as "Customer",cbp.value as ID,to_char(round(sum(invoiceopen(c_invoice_id,0)),0),'999,999,999,999,999') as "Open Amount" postgresql-2023-08-25_094520.log:2023-08-25 09:46:16 +04,3793 LOG: duration: 26552.932 ms execute : SELECT bp.C_BP_Group_ID, bp.C_BPartner_ID,oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID, oi.C_Currency_ID, oi.IsSOTrx, oi.DateInvoiced, oi.NetDays, oi.DueDate, oi.DaysDue,currencyConvert(oi.C_Conversion_Rate_ID,oi.GrandTotal,oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID), coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoicePaidToDate(oi.C_Invoice_ID, oi.C_Currency_ID, 1,TO_TIMESTAMP('2023-08-25','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) PaidAmt, coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,TO_TIMESTAMP('2023-08-25','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) OpenAmt,oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID,oi.AD_Org_ID FROM RV_OpenItemToDate oi INNER JOIN C_BPartner bp ON coalesce(oi.pay_bpartner_id,oi.C_BPartner_ID)=bp.C_BPartner_ID WHERE oi.AD_Client_ID IN(0,1000000) AND oi.AD_ORG_ID in (0,1000000,1000002,1000001) AND invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,'2023-08-25 23:59:59.0') <> 0 AND oi.isSoTrx = 'Y' ORDER BY oi.C_BPartner_ID, oi.C_Currency_ID, oi.C_Invoice_ID postgresql-2023-08-25_094520.log:2023-08-25 09:46:48 +04,3793 LOG: duration: 31165.661 ms execute : select op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-25','YYYY-MM-DD') THEN 0 ELSE op.DISCOUNTAMT END AS discountamt,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID, CASE WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = 0 THEN 'Paid' WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = inv.GRANDTOTAL THEN 'UnPaid' ELSE 'Partially Paid' END AS status, CASE WHEN sign(op.OPENAMT) = -1 THEN 'overPaid' ELSE 'NULL' END AS sign, ord.poreference as ord_reference, inv.poreference as inv_reference,inv.c_charge_id, CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-25','YYYY-MM-DD') THEN 0 ELSE pt.discount END AS Trade_DiscountPercent, op.dateacct, bp.c_currency_id bpcurrency, bp.po_pricelist_id venPLId from RV_OPENITEM op JOIN C_Invoice inv on op.C_INVOICE_ID=inv.C_INVOICE_ID JOIN C_BPartner bp on op.C_BPARTNER_ID=bp.C_BPARTNER_ID JOIN C_PAYMENTTERM pt on op.C_PAYMENTTERM_ID=pt.C_PAYMENTTERM_ID left join c_cashline cl on op.C_INVOICE_ID=cl.C_INVOICE_ID JOIN C_CURRENCY cr on op.C_CURRENCY_ID=cr.C_CURRENCY_ID LEFT JOIN C_ORDER ord ON op.C_ORDER_ID=ord.C_ORDER_ID where op.AD_CLIENT_ID=1000000 and coalesce(ord.ordertype,'') <> 'Lay Buy Order' and op.issotrx='Y' and op.DATEINVOICED <= TO_TIMESTAMP('2023-08-25 23:59:59','YYYY-MM-DD HH24:MI:SS') and op.ad_org_id in (0,1000000,1000002,1000001) group by op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,op.DISCOUNTAMT ,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID,ord.poreference, inv.poreference,inv.c_charge_id, pt.discount, op.dateacct, bpcurrency, venPLId order by op.DATEINVOICED asc postgresql-2023-08-25_094520.log:2023-08-25 09:47:12 +04,3852 LOG: duration: 26372.731 ms execute : SELECT bp.C_BP_Group_ID, bp.C_BPartner_ID,oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID, oi.C_Currency_ID, oi.IsSOTrx, oi.DateInvoiced, oi.NetDays, oi.DueDate, oi.DaysDue,currencyConvert(oi.C_Conversion_Rate_ID,oi.GrandTotal,oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID), coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoicePaidToDate(oi.C_Invoice_ID, oi.C_Currency_ID, 1,TO_TIMESTAMP('2023-08-25','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) PaidAmt, coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,TO_TIMESTAMP('2023-08-25','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) OpenAmt,oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID,oi.AD_Org_ID FROM RV_OpenItemToDate oi INNER JOIN C_BPartner bp ON coalesce(oi.pay_bpartner_id,oi.C_BPartner_ID)=bp.C_BPartner_ID WHERE oi.AD_Client_ID IN(0,1000000) AND oi.AD_ORG_ID in (0,1000000,1000002,1000001) AND invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,'2023-08-25 23:59:59.0') <> 0 AND oi.isSoTrx = 'Y' ORDER BY oi.C_BPartner_ID, oi.C_Currency_ID, oi.C_Invoice_ID postgresql-2023-08-25_094520.log:2023-08-25 09:47:44 +04,3852 LOG: duration: 30852.369 ms execute : select op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-25','YYYY-MM-DD') THEN 0 ELSE op.DISCOUNTAMT END AS discountamt,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID, CASE WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = 0 THEN 'Paid' WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = inv.GRANDTOTAL THEN 'UnPaid' ELSE 'Partially Paid' END AS status, CASE WHEN sign(op.OPENAMT) = -1 THEN 'overPaid' ELSE 'NULL' END AS sign, ord.poreference as ord_reference, inv.poreference as inv_reference,inv.c_charge_id, CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-25','YYYY-MM-DD') THEN 0 ELSE pt.discount END AS Trade_DiscountPercent, op.dateacct, bp.c_currency_id bpcurrency, bp.po_pricelist_id venPLId from RV_OPENITEM op JOIN C_Invoice inv on op.C_INVOICE_ID=inv.C_INVOICE_ID JOIN C_BPartner bp on op.C_BPARTNER_ID=bp.C_BPARTNER_ID JOIN C_PAYMENTTERM pt on op.C_PAYMENTTERM_ID=pt.C_PAYMENTTERM_ID left join c_cashline cl on op.C_INVOICE_ID=cl.C_INVOICE_ID JOIN C_CURRENCY cr on op.C_CURRENCY_ID=cr.C_CURRENCY_ID LEFT JOIN C_ORDER ord ON op.C_ORDER_ID=ord.C_ORDER_ID where op.AD_CLIENT_ID=1000000 and coalesce(ord.ordertype,'') <> 'Lay Buy Order' and op.issotrx='Y' and op.DATEINVOICED <= TO_TIMESTAMP('2023-08-25 23:59:59','YYYY-MM-DD HH24:MI:SS') and op.ad_org_id in (0,1000000,1000002,1000001) group by op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,op.DISCOUNTAMT ,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID,ord.poreference, inv.poreference,inv.c_charge_id, pt.discount, op.dateacct, bpcurrency, venPLId order by op.DATEINVOICED asc postgresql-2023-08-25_094520.log:2023-08-25 10:00:13 +04,4467 LOG: duration: 7417.334 ms execute : SELECT t.m_product_id,sum(movementqty),t.m_locator_id, t.m_attributesetinstance_id from M_Transaction t JOIN m_locator l ON t.m_locator_id = l.m_locator_id WHERE l.m_warehouse_id = $1 AND t.ad_client_id = 1000000 group by t.m_product_id, t.m_locator_id, t.m_attributesetinstance_id order by t.m_product_id,t.m_locator_id,t.m_attributesetinstance_id postgresql-2023-08-25_094520.log:2023-08-25 10:08:32 +04,4742 LOG: duration: 11787.518 ms execute : select pr.name as name, sum(st.qtyonhand) as qty ,pr.UPC,pr.m_product_id, sum(st.qtyreserved) as reserved ,pr.m_product_category_id as proCategoryId,pc.name as proCategoryName,(coalesce(pr.group1,' ')||' '||coalesce(pr.group2,' ')) as group, coalesce(sum(whpo.minqty),0) as min_qty, coalesce(sum(st.qtyOrdered), 0) as qty_ordered ,coalesce(sum(whpo.reorderqty),0) as minorder,pr.c_uom_id,pr.description,pr.unitsperpack,productAttribute(pr.m_attributesetinstance_id) as productAttribute, max(ss.mdate) as lastReceivedDate, sum(coalesce(intransit.qty, 0)) intransitQty, coalesce(uomc.dividerate,1) as dividerate, coalesce(uomc.c_uom_to_id,0) as c_uom_to_id, pr.group1, pr.group2, pr.commodity_code, pr.classification as pclassification, bp.name as vendor from M_PRODUCT pr join M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id left join m_product_po mpo on (pr.m_product_id = mpo.m_product_id and mpo.iscurrentvendor='Y' and mpo.isactive='Y') left join c_bpartner bp on bp.c_bpartner_id = mpo.c_bpartner_id left join lateral (select st.m_product_id, SUM(COALESCE((CASE WHEN w.isintransit='Y' AND w.parentwarehouseid > 0 THEN 0 ELSE st.qtyonhand END), 0)) qtyonhand,sum(st.qtyOrdered) qtyOrdered, sum(st.qtyreserved) qtyreserved from M_STORAGE st join m_locator l on l.m_locator_id=st.m_locator_id join m_warehouse w on l.m_warehouse_id=w.m_warehouse_id where st.M_PRODUCT_ID=pr.M_PRODUCT_ID AND w.AD_ORG_ID in (1000000) group by 1) st on st.M_PRODUCT_ID=pr.M_PRODUCT_ID left join lateral (select max(mn.movementdate) mdate, mnl.m_product_id from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where mnl.m_product_id = pr.m_product_id group by mnl.m_product_id) as ss on true left join lateral (select m_product_id,sum(minqty) minqty,sum(reorderqty) reorderqty from m_Warehouse_product_po whpo where isactive='Y' and pr.m_product_id = whpo.m_product_id group by 1) whpo on true left join lateral(select sum(mil.pickedqty) qty from m_inoutline mil join m_product mp on mp.m_product_id =mil.m_product_id join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and mil.m_product_id=pr.m_product_id group By mil.m_product_id) intransit on true left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pr.m_product_id) where pr.AD_CLIENT_ID=1000000 AND pr.isactive = 'Y' group by pr.m_product_id,pc.name, uomc.dividerate, uomc.c_uom_to_id, bp.name order by name postgresql-2023-08-25_094520.log:2023-08-25 10:12:22 +04,4784 LOG: duration: 11309.490 ms execute : select pr.name as name, sum(st.qtyonhand) as qty ,pr.UPC,pr.m_product_id, sum(st.qtyreserved) as reserved ,pr.m_product_category_id as proCategoryId,pc.name as proCategoryName,(coalesce(pr.group1,' ')||' '||coalesce(pr.group2,' ')) as group, coalesce(sum(whpo.minqty),0) as min_qty, coalesce(sum(st.qtyOrdered), 0) as qty_ordered ,coalesce(sum(whpo.reorderqty),0) as minorder,pr.c_uom_id,pr.description,pr.unitsperpack,productAttribute(pr.m_attributesetinstance_id) as productAttribute, max(ss.mdate) as lastReceivedDate, sum(coalesce(intransit.qty, 0)) intransitQty, coalesce(uomc.dividerate,1) as dividerate, coalesce(uomc.c_uom_to_id,0) as c_uom_to_id, pr.group1, pr.group2, pr.commodity_code, pr.classification as pclassification, bp.name as vendor from M_PRODUCT pr join M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id left join m_product_po mpo on (pr.m_product_id = mpo.m_product_id and mpo.iscurrentvendor='Y' and mpo.isactive='Y') left join c_bpartner bp on bp.c_bpartner_id = mpo.c_bpartner_id left join lateral (select st.m_product_id, SUM(COALESCE((CASE WHEN w.isintransit='Y' AND w.parentwarehouseid > 0 THEN 0 ELSE st.qtyonhand END), 0)) qtyonhand,sum(st.qtyOrdered) qtyOrdered, sum(st.qtyreserved) qtyreserved from M_STORAGE st join m_locator l on l.m_locator_id=st.m_locator_id join m_warehouse w on l.m_warehouse_id=w.m_warehouse_id where st.M_PRODUCT_ID=pr.M_PRODUCT_ID AND w.AD_ORG_ID in (1000000) group by 1) st on st.M_PRODUCT_ID=pr.M_PRODUCT_ID left join lateral (select max(mn.movementdate) mdate, mnl.m_product_id from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where mnl.m_product_id = pr.m_product_id group by mnl.m_product_id) as ss on true left join lateral (select m_product_id,sum(minqty) minqty,sum(reorderqty) reorderqty from m_Warehouse_product_po whpo where isactive='Y' and pr.m_product_id = whpo.m_product_id group by 1) whpo on true left join lateral(select sum(mil.pickedqty) qty from m_inoutline mil join m_product mp on mp.m_product_id =mil.m_product_id join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and mil.m_product_id=pr.m_product_id group By mil.m_product_id) intransit on true left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pr.m_product_id) where pr.AD_CLIENT_ID=1000000 AND pr.isactive = 'Y' group by pr.m_product_id,pc.name, uomc.dividerate, uomc.c_uom_to_id, bp.name order by name postgresql-2023-08-25_101500.log:2023-08-25 10:15:31 +04,5069 LOG: duration: 9236.943 ms execute : select pr.name as name, sum(st.qtyonhand) as qty ,pr.UPC,pr.m_product_id, sum(st.qtyreserved) as reserved ,pr.m_product_category_id as proCategoryId,pc.name as proCategoryName,(coalesce(pr.group1,' ')||' '||coalesce(pr.group2,' ')) as group, coalesce(sum(whpo.minqty),0) as min_qty, coalesce(sum(st.qtyOrdered), 0) as qty_ordered ,coalesce(sum(whpo.reorderqty),0) as minorder,pr.c_uom_id,pr.description,pr.unitsperpack,productAttribute(pr.m_attributesetinstance_id) as productAttribute, max(ss.mdate) as lastReceivedDate, sum(coalesce(intransit.qty, 0)) intransitQty, coalesce(uomc.dividerate,1) as dividerate, coalesce(uomc.c_uom_to_id,0) as c_uom_to_id, pr.group1, pr.group2, pr.commodity_code, pr.classification as pclassification, bp.name as vendor from M_PRODUCT pr join M_PRODUCT_CATEGORY pc on pr.m_product_category_id = pc.m_product_category_id left join m_product_po mpo on (pr.m_product_id = mpo.m_product_id and mpo.iscurrentvendor='Y' and mpo.isactive='Y') left join c_bpartner bp on bp.c_bpartner_id = mpo.c_bpartner_id left join lateral (select st.m_product_id, SUM(COALESCE((CASE WHEN w.isintransit='Y' AND w.parentwarehouseid > 0 THEN 0 ELSE st.qtyonhand END), 0)) qtyonhand,sum(st.qtyOrdered) qtyOrdered, sum(st.qtyreserved) qtyreserved from M_STORAGE st join m_locator l on l.m_locator_id=st.m_locator_id join m_warehouse w on l.m_warehouse_id=w.m_warehouse_id where st.M_PRODUCT_ID=pr.M_PRODUCT_ID AND w.AD_ORG_ID in (1000000) group by 1) st on st.M_PRODUCT_ID=pr.M_PRODUCT_ID left join lateral (select max(mn.movementdate) mdate, mnl.m_product_id from m_inoutline mnl join m_inout mn on (mn.m_inout_id = mnl.m_inout_id and mn.issotrx = 'N' and mn.docstatus in ('CO','CL') and mn.movementtype = 'V+') where mnl.m_product_id = pr.m_product_id group by mnl.m_product_id) as ss on true left join lateral (select m_product_id,sum(minqty) minqty,sum(reorderqty) reorderqty from m_Warehouse_product_po whpo where isactive='Y' and pr.m_product_id = whpo.m_product_id group by 1) whpo on true left join lateral(select sum(mil.pickedqty) qty from m_inoutline mil join m_product mp on mp.m_product_id =mil.m_product_id join m_inout mi on mi.m_inout_id=mil.m_inout_id where mi.docstatus='IP' and mil.m_product_id=pr.m_product_id group By mil.m_product_id) intransit on true left join lateral (SELECT DISTINCT ON (dividerate) dividerate, c_uom_to_id, m_product_id from c_uom_conversion WHERE isactive='Y' and m_product_id =pr.m_product_id ORDER BY dividerate DESC limit 1) uomc on (uomc.m_product_id = pr.m_product_id) where pc.m_product_category_id in (1015421,1000039,1000262,1001262,1005197,1015375,1015380,1015377,1015381,1015374,1015378,1015382,1015376,1015379,1000263,1000007,1000021,1000028,1000078,1000053,1000112,1000113,1000108,1000091,1000114,1000115,1000104,1000031,1000264,1001244,1000170,1001245,1000073,1001261,1005281,1005211,1005199,1005200,1005284,1005198,1005282,1005268,1001269,1005294,1005011,1004977,1004993,1005184,1005015,1005016,1015310,1015325,1005288,1015321,1000010,1015311,1015322,1015354,1015385,1015386,1015353,1015412,1015414,1015415,1015628,1015636,1015638,1000029,1000034,1000008,1000056,1000075,1000011,1000047,1000033,1000074,1000083,1000009,1000027,1000036,1000044,1000076,1000043,1000016,1000024,1000069,1000059,1000071,1000049,1000048,1000037,1000025,1000041,1000077,1000093,1000092,1000066,1000147,1000088,1000105,1000121,1000107,1000060,1000082,1000094,1000106,1000116,1000070,1000099,1000089,1000122,1000124,1000050,1000103,1000040,1000118,1000283,1000151,1000158,1000166,1000269,1000061,1000035,1000026,1000164,1015334,1000165,1000120,1004992,1000072,1000019,1000101,1000117,1000282,1000058,1000004,1000046,1000167,1000062,1000281,1000280,1000042,1000097,1000162,1000052,1000080,1000163,1001241,1001249,1001260,1000095,1001246,1001242,1000155,1001264,1001263,1001243,1001267,1001272,1001265,1001266,1001250,1001268,1001248,1001271,1001270,1005210,1005270,1005275,1001274,1001275,1001273,1005216,1005185,1005215,1001277,1004941,1005273,1001276,1005202,1005269,1000057,1005217,1003858,1005292,1005272,1005274,1005212,1000045,1005293,1005213,1005296,1004940,1004939,1005214,1005207,1004978,1004991,1004984,1005010,1004989,1004987,1005206,1005005,1004979,1005006,1004986,1004994,1005004,1005201,1005180,1005183,1004988,1004990,1015315,1015313,1015317,1000006,1000169,1015312,1015327,1015328,1004938,1001256,1000054,1015301,1000064,1004983,1015307,1015308,1015299,1015320,1015318,1000156,1001254,1015300,1000020,1015331,1015323,1015332,1015306,1015349,1015351,1015383,1015348,1015352,1000168,1015350,1015373,1015384,1015319,1015629,1015633,1000109,1000015,1000055,1000086,1000081,1000012,1000038,1000030,1000032,1000013,1000018,1000110,1000085,1000051,1000100,1000096,1000087,1000084,1000119,1000023,1000003,1000098,1000123,1000068,1000067,1000144,1000146,1000090,1000065,1000274,1000278,1000275,1000279,1000017,1000159,1000160,1000157,1000153,1000265,1000267,1000271,1000272,1000273,1000287,1000148,1000145,1000266,1001247,1000268,1000270,1001231,1001230,1001233,1001251,1001253,1001258,1001235,1001232,1001239,1001238,1001229,1001228,1001234,1001252,1000111,1001255,1001240,1001257,1000161,1005276,1005218,1005187,1005204,1005285,1001236,1005192,1001237,1005203,1005194,1005208,1005209,1005219,1000154,1005278,1005289,1005290,1005189,1005195,1005196,1005190,1005280,1005291,1005297,1005295,1004982,1005017,1004985,1004980,1005181,1005182,1001259,1005012,1005013,1005186,1005191,1005009,1005008,1005019,1005020,1005018,1005007,1005188,1005193,1005205,1004981,1005298,1015324,1005014,1005279,1015305,1015309,1015314,1015316,1005287,1015326,1005003,1000014,1000063,1005286) and pr.AD_CLIENT_ID=1000000 AND pr.isactive = 'Y' group by pr.m_product_id,pc.name, uomc.dividerate, uomc.c_uom_to_id, bp.name order by name postgresql-2023-08-25_101500.log:2023-08-25 10:17:58 +04,5141 LOG: duration: 26374.123 ms execute : SELECT bp.C_BP_Group_ID, bp.C_BPartner_ID,oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID, oi.C_Currency_ID, oi.IsSOTrx, oi.DateInvoiced, oi.NetDays, oi.DueDate, oi.DaysDue,currencyConvert(oi.C_Conversion_Rate_ID,oi.GrandTotal,oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID), coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoicePaidToDate(oi.C_Invoice_ID, oi.C_Currency_ID, 1,TO_TIMESTAMP('2023-08-25','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) PaidAmt, coalesce(currencyConvert(oi.C_Conversion_Rate_ID,invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,TO_TIMESTAMP('2023-08-25','YYYY-MM-DD')),oi.C_Currency_ID,238,oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID),0) OpenAmt,oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID,oi.AD_Org_ID FROM RV_OpenItemToDate oi INNER JOIN C_BPartner bp ON coalesce(oi.pay_bpartner_id,oi.C_BPartner_ID)=bp.C_BPartner_ID WHERE oi.AD_Client_ID IN(0,1000000) AND oi.AD_ORG_ID in (0,1000000,1000002,1000001) AND invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,'2023-08-25 23:59:59.0') <> 0 AND oi.isSoTrx = 'Y' ORDER BY oi.C_BPartner_ID, oi.C_Currency_ID, oi.C_Invoice_ID postgresql-2023-08-25_101500.log:2023-08-25 10:18:31 +04,5141 LOG: duration: 31350.732 ms execute : select op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-25','YYYY-MM-DD') THEN 0 ELSE op.DISCOUNTAMT END AS discountamt,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID, CASE WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = 0 THEN 'Paid' WHEN inv.GRANDTOTAL-COALESCE(sum(cl.AMOUNT),0) = inv.GRANDTOTAL THEN 'UnPaid' ELSE 'Partially Paid' END AS status, CASE WHEN sign(op.OPENAMT) = -1 THEN 'overPaid' ELSE 'NULL' END AS sign, ord.poreference as ord_reference, inv.poreference as inv_reference,inv.c_charge_id, CASE WHEN op.DISCOUNTDATE < TO_TIMESTAMP('2023-08-25','YYYY-MM-DD') THEN 0 ELSE pt.discount END AS Trade_DiscountPercent, op.dateacct, bp.c_currency_id bpcurrency, bp.po_pricelist_id venPLId from RV_OPENITEM op JOIN C_Invoice inv on op.C_INVOICE_ID=inv.C_INVOICE_ID JOIN C_BPartner bp on op.C_BPARTNER_ID=bp.C_BPARTNER_ID JOIN C_PAYMENTTERM pt on op.C_PAYMENTTERM_ID=pt.C_PAYMENTTERM_ID left join c_cashline cl on op.C_INVOICE_ID=cl.C_INVOICE_ID JOIN C_CURRENCY cr on op.C_CURRENCY_ID=cr.C_CURRENCY_ID LEFT JOIN C_ORDER ord ON op.C_ORDER_ID=ord.C_ORDER_ID where op.AD_CLIENT_ID=1000000 and coalesce(ord.ordertype,'') <> 'Lay Buy Order' and op.issotrx='Y' and op.DATEINVOICED <= TO_TIMESTAMP('2023-08-25 23:59:59','YYYY-MM-DD HH24:MI:SS') and op.ad_org_id in (0,1000000,1000002,1000001) group by op.DOCUMENTNO,op.C_INVOICE_ID,op.C_ORDER_ID,op.ISSOTRX,op.DATEINVOICED,op.NETDAYS,op.DUEDATE,op.DAYSDUE,op.DISCOUNTDATE,op.DISCOUNTAMT ,inv.GRANDTOTAL ,op.PAIDAMT,op.OPENAMT,op.C_CURRENCY_ID,op.C_PAYMENTTERM_ID ,op.C_INVOICEPAYSCHEDULE_ID,ord.DOCUMENTNO,cr.ISO_CODE,pt.NAME,bp.name|| ' ' || bp.name2,op.C_BPARTNER_ID,ord.poreference, inv.poreference,inv.c_charge_id, pt.discount, op.dateacct, bpcurrency, venPLId order by op.DATEINVOICED asc