===Start time =02:49:03pm===
Database connected
Current date : 2025-12-12 14 49 03

Database name : microlabslive_summary


=====CronScriptStartTime=====INSERT INTO cron_script_execution(pid,cronid,`date`,start_time,success,deleted) VALUES('','3','2025-12-12','2025-12-12 02:49:03',0,0)

====Star time :'1765531143.1193'

====Started at :'Friday 12th of December 2025 02:49:03 PM'

===Current year :2025

************For Month = 10

************For Year = 2025

drop table if exists temp_sales_details

create table temp_sales_details select salesdetails.division,sales.smownerid,space(1000) as stockistname,space(1000) as stockistcode,sales.stockistmasterid, salesdetails.productid, space(50) as product_code, space(1000) as product_name, sum(salesdetails.sales) as sales, sum(salesdetails.salesvalue) as value, sum(salesdetails.closing) as closing, sum(salesdetails.stockvalue) as clvalue , sales.patch as territory_code, salesdetails.price as unit_price, sales.month, sales.year from microlablive.salesdetails, microlablive.sales where salesdetails.mainid =sales.mainid and salesdetails.deleted =0 and sales.deleted =0 and sales.month ='10' and sales.year='2025' group by salesdetails.division, sales.stockistmasterid,salesdetails.productid ORDER BY territory_code

CREATE INDEX stockistmasterid ON temp_sales_details (stockistmasterid)

CREATE INDEX productid ON temp_sales_details (productid)

update temp_sales_details, microlablive.sales, microlablive.patches set temp_sales_details.territory_code = sales.patch where temp_sales_details.stockistmasterid =sales.stockistmasterid and sales.patch=patches.patchsapcode and temp_sales_details.division = patches.division and sales.deleted =0 and sales.month ='10' and sales.year='2025' and patches.patch_deleted=0

update temp_sales_details,microlablive.stckcontactmaster set temp_sales_details.stockistname = trim(stckcontactmaster.stockistname), temp_sales_details.stockistcode=trim(stckcontactmaster.stockistcode) where temp_sales_details.stockistmasterid =stckcontactmaster.masterid

update temp_sales_details, microlablive.products set temp_sales_details.product_code = products.productcode, temp_sales_details.product_name=trim(products.productname) where temp_sales_details.productid = products.productid

delete from territory_secondarystckwise where `month`='10' and `year`='2025'del_data failed