[2026-09-11 12:30:04] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-10","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-11 12:30:04] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-10"} 
[2026-09-11 12:30:04] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-10')"} 
[2026-09-11 12:30:04] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-09-10') ) * (purchase_lines.purchase_price + 
                        COALESCE(purchase_lines.item_tax, 0))
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and (`purchase`.`type` = ? or (`purchase`.`type` != ? and date(transaction_date) <= '2026-09-10'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-11 12:30:04] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6706627.43600000","is_opening":true,"date":"2026-09-10"} 
[2026-09-11 12:30:04] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-11","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-11 12:30:04] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-11' (includes all types except purchase_order)"} 
[2026-09-11 12:30:04] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-09-11') ) * (purchase_lines.purchase_price + 
                        COALESCE(purchase_lines.item_tax, 0))
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and date(transaction_date) <= '2026-09-11'","bindings":["purchase_order",43]} 
[2026-09-11 12:30:04] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6706627.43600000","is_opening":false,"date":"2026-09-11"} 
[2026-09-11 12:30:05] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 12:30:11] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 12:30:15] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 13:06:09] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-10","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-11 13:06:09] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-10"} 
[2026-09-11 13:06:09] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-10')"} 
[2026-09-11 13:06:09] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-09-10') ) * (purchase_lines.purchase_price + 
                        COALESCE(purchase_lines.item_tax, 0))
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and (`purchase`.`type` = ? or (`purchase`.`type` != ? and date(transaction_date) <= '2026-09-10'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-11 13:06:09] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6706627.43600000","is_opening":true,"date":"2026-09-10"} 
[2026-09-11 13:06:09] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-11","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-11 13:06:09] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-11' (includes all types except purchase_order)"} 
[2026-09-11 13:06:09] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-09-11') ) * (purchase_lines.purchase_price + 
                        COALESCE(purchase_lines.item_tax, 0))
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and date(transaction_date) <= '2026-09-11'","bindings":["purchase_order",43]} 
[2026-09-11 13:06:09] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6706627.43600000","is_opening":false,"date":"2026-09-11"} 
[2026-09-11 13:06:10] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 13:06:14] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 13:07:32] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 13:07:47] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 13:07:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 13:08:00] live.INFO: filterProduct method called {"business_id":43,"search_term":"mu","location_id":"39","not_for_selling":"0","price_group_id":"0","product_types":[],"search_fields":["name","sku"],"check_qty":false,"search_type":"like"} 
[2026-09-11 13:08:00] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-11 13:08:00] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-11 13:08:00] live.DEBUG: Applying search filters {"search_term":"mu","search_type":"like","search_fields":["name","sku"]} 
[2026-09-11 13:08:00] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-11 13:08:00] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-11 13:08:00] live.INFO: filterProduct completed successfully {"result_count":5,"business_id":43,"search_term":"mu"} 
[2026-09-11 13:08:04] live.INFO: filterProduct method called {"business_id":43,"search_term":"mil","location_id":"39","not_for_selling":"0","price_group_id":"0","product_types":[],"search_fields":["name","sku"],"check_qty":false,"search_type":"like"} 
[2026-09-11 13:08:04] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-11 13:08:04] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-11 13:08:04] live.DEBUG: Applying search filters {"search_term":"mil","search_type":"like","search_fields":["name","sku"]} 
[2026-09-11 13:08:04] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-11 13:08:04] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-11 13:08:04] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"mil"} 
[2026-09-11 13:08:05] live.INFO: Product Row Debug - RELOADED {"product_id":174,"product_name":"kinangop milk 250g","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":50.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"39":{"unit_id":39,"unit_name":"Pieces","unit_price":null,"multiplier":1,"has_price":false}},"has_price_group":false,"price_group_id":null} 
[2026-09-11 13:08:14] live.INFO: Credit Limit Check Started {"contact_id":"703","status":"final","final_total":"50.00","is_credit_sale":"0","exclude_transaction_id":null} 
[2026-09-11 13:08:14] live.DEBUG: Payment Calculation {"final_total":50.0,"curr_total_payment":50.0,"is_credit_sale":false,"payment_count":1} 
[2026-09-11 13:08:14] live.INFO: Credit Limit Check Skipped - Fully Paid {"final_total":50.0,"curr_total_payment":50.0} 
[2026-09-11 13:08:14] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-11 13:08:14] live.INFO: is_mpesa_sale value: true  
[2026-09-11 13:08:14] live.INFO: Journal Entry Case: FULL CASH PAYMENT {"transaction_id":1829,"final_total":50.0,"amount_paid":50.0,"balance_due":0} 
[2026-09-11 13:08:14] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1829,"entries":[{"transaction_id":1829,"created_by_id":293,"transaction_number":"TRX-6aa3d30edda3d4.40630018","payment_detail_id":1310,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-11","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-11 13:08:14","updated_at":"2026-09-11 13:08:14","chart_of_account_id":15441,"debit":null,"credit":50.0},{"transaction_id":1829,"created_by_id":293,"transaction_number":"TRX-6aa3d30edda3d4.40630018","payment_detail_id":1310,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-11","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-11 13:08:14","updated_at":"2026-09-11 13:08:14","chart_of_account_id":15445,"debit":50.0,"credit":null}]} 
[2026-09-11 13:08:14] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1171,"purchase_line_id":1322,"quantity":1.0,"created_at":"2026-09-11 13:08:14","updated_at":"2026-09-11 13:08:14"}]} 
[2026-09-11 13:08:14] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-11 13:08:14] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":25.0} 
[2026-09-11 13:08:15] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1829  
[2026-09-11 13:13:27] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 13:13:35] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 13:14:48] live.INFO: === About to call saveProductNewUnitRelationships === {"product_id":342,"request_units":[{"actual_name":"Pc","unit_id":"265","short_name":"Pc","relation_unit_id":null,"relation_qty":"1","price":"23000"}],"page_batch_id":"20260911_131332_9689"} 
[2026-09-11 13:14:48] live.INFO: === saveProductNewUnitRelationships START === {"product_id":342,"product_name":"Hp 830 G4 core i5"} 
[2026-09-11 13:14:48] live.INFO: Units data received {"units_data":[{"actual_name":"Pc","unit_id":"265","short_name":"Pc","relation_unit_id":null,"relation_qty":"1","price":"23000"}],"count":1} 
[2026-09-11 13:14:48] live.INFO: Processing unit index: 0 {"unit_data":{"actual_name":"Pc","unit_id":"265","short_name":"Pc","relation_unit_id":null,"relation_qty":"1","price":"23000"}} 
[2026-09-11 13:14:48] live.INFO: Unit found by ID {"unit_id":265,"actual_name":"Pc"} 
[2026-09-11 13:14:48] live.INFO: Unit lookup result {"found":"yes","unit_id":265,"method":"by_id"} 
[2026-09-11 13:14:48] live.INFO: Updating existing unit {"unit_id":265} 
[2026-09-11 13:14:48] live.INFO: Updated unit_price {"new_price":23000.0} 
[2026-09-11 13:14:48] live.INFO: Unit updated successfully  
[2026-09-11 13:14:48] live.INFO: Setting as BASE unit {"unit_id":265} 
[2026-09-11 13:14:48] live.INFO: Base unit saved {"base_unit_id":265} 
[2026-09-11 13:14:48] live.INFO: First pass complete {"created_units_count":1,"base_unit_id":265} 
[2026-09-11 13:14:48] live.INFO: === SECOND PASS: Setting relations first ===  
[2026-09-11 13:14:48] live.INFO: === SECOND PASS: Calculating cumulative multipliers ===  
[2026-09-11 13:14:48] live.INFO: === saveProductNewUnitRelationships END ===  
[2026-09-11 13:14:48] live.INFO: OpeningStockController::add - Location Data {"product_id":"342","business_id":43,"locations":{"Illuminate\\Support\\Collection":{"39":"Greenfield Supermarket Ltd (BL0001)"}},"available_locations":[39]} 
[2026-09-11 13:14:48] live.INFO: OpeningStockController::add - Serial Numbers Check {"product_id":"342","business_id":43,"has_serial_numbers":{"39":false},"total_locations_with_serial":0} 
[2026-09-11 13:14:50] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 13:16:10] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 13:16:35] live.INFO: filterProduct method called {"business_id":43,"search_term":"hp","location_id":"39","not_for_selling":"0","price_group_id":"0","product_types":[],"search_fields":["name","sku"],"check_qty":false,"search_type":"like"} 
[2026-09-11 13:16:35] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-11 13:16:35] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-11 13:16:35] live.DEBUG: Applying search filters {"search_term":"hp","search_type":"like","search_fields":["name","sku"]} 
[2026-09-11 13:16:35] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-11 13:16:35] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-11 13:16:35] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"hp"} 
[2026-09-11 13:16:35] live.INFO: Product Row Debug - RELOADED {"product_id":342,"product_name":"Hp 830 G4 core i5","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":240000.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"265":{"unit_id":265,"unit_name":"Pc","unit_price":23000.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-11 13:16:36] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:36] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:44] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:44] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:45] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:45] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:45] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:45] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:46] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:46] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:47] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:47] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:47] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:47] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:48] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:48] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:48] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:48] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:49] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:49] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:50] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:50] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:50] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:50] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:51] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:51] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:51] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:51] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:52] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:52] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:52] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:52] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:53] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:53] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:54] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:54] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:54] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:54] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:55] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:55] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:56] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:56] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:56] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:56] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:57] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:57] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:58] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:58] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:58] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:58] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:59] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:59] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:16:59] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:16:59] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:17:00] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:17:00] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:17:00] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:17:00] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:17:01] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:17:01] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:17:02] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:17:02] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:17:02] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:17:02] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:17:03] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:17:03] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:17:03] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:17:03] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:17:04] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:17:04] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:17:05] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:17:05] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 13:17:05] live.INFO: Fetching tax rate for product ID: 342  
[2026-09-11 13:17:05] live.INFO: Product ID 342 has no tax assigned.  
[2026-09-11 14:19:19] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 14:19:29] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 14:29:31] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 14:39:32] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 14:49:38] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 14:59:29] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 15:09:28] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:37:21] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-10","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-11 16:37:21] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-10"} 
[2026-09-11 16:37:21] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-10')"} 
[2026-09-11 16:37:21] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-09-10') ) * (purchase_lines.purchase_price + 
                        COALESCE(purchase_lines.item_tax, 0))
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and (`purchase`.`type` = ? or (`purchase`.`type` != ? and date(transaction_date) <= '2026-09-10'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-11 16:37:21] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6786627.43600000","is_opening":true,"date":"2026-09-10"} 
[2026-09-11 16:37:21] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-11","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-11 16:37:21] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-11' (includes all types except purchase_order)"} 
[2026-09-11 16:37:21] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-09-11') ) * (purchase_lines.purchase_price + 
                        COALESCE(purchase_lines.item_tax, 0))
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and date(transaction_date) <= '2026-09-11'","bindings":["purchase_order",43]} 
[2026-09-11 16:37:21] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6786602.43600000","is_opening":false,"date":"2026-09-11"} 
[2026-09-11 16:37:22] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:37:39] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:37:42] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:38:10] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:38:30] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:38:33] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:39:25] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:41:24] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:42:16] live.INFO: Digitax upload skipped: No tax number provided {"contact_id":875,"contact_name":"musyoka wines","contact_type":"customer"} 
[2026-09-11 16:43:14] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:44:00] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:44:24] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:46:02] live.INFO: === About to call saveProductNewUnitRelationships === {"product_id":343,"request_units":[{"actual_name":"pcs","unit_id":"266","short_name":"pcs","relation_unit_id":null,"relation_qty":"1","price":"300"}],"page_batch_id":"20260911_164412_3763"} 
[2026-09-11 16:46:02] live.INFO: === saveProductNewUnitRelationships START === {"product_id":343,"product_name":"ko 500ml"} 
[2026-09-11 16:46:02] live.INFO: Units data received {"units_data":[{"actual_name":"pcs","unit_id":"266","short_name":"pcs","relation_unit_id":null,"relation_qty":"1","price":"300"}],"count":1} 
[2026-09-11 16:46:02] live.INFO: Processing unit index: 0 {"unit_data":{"actual_name":"pcs","unit_id":"266","short_name":"pcs","relation_unit_id":null,"relation_qty":"1","price":"300"}} 
[2026-09-11 16:46:02] live.INFO: Unit found by ID {"unit_id":266,"actual_name":"pcs"} 
[2026-09-11 16:46:02] live.INFO: Unit lookup result {"found":"yes","unit_id":266,"method":"by_id"} 
[2026-09-11 16:46:02] live.INFO: Updating existing unit {"unit_id":266} 
[2026-09-11 16:46:02] live.INFO: Updated unit_price {"new_price":300.0} 
[2026-09-11 16:46:02] live.INFO: Unit updated successfully  
[2026-09-11 16:46:02] live.INFO: Setting as BASE unit {"unit_id":266} 
[2026-09-11 16:46:02] live.INFO: Base unit saved {"base_unit_id":266} 
[2026-09-11 16:46:02] live.INFO: First pass complete {"created_units_count":1,"base_unit_id":266} 
[2026-09-11 16:46:02] live.INFO: === SECOND PASS: Setting relations first ===  
[2026-09-11 16:46:02] live.INFO: === SECOND PASS: Calculating cumulative multipliers ===  
[2026-09-11 16:46:02] live.INFO: === saveProductNewUnitRelationships END ===  
[2026-09-11 16:46:03] live.INFO: OpeningStockController::add - Location Data {"product_id":"343","business_id":43,"locations":{"Illuminate\\Support\\Collection":{"39":"Greenfield Supermarket Ltd (BL0001)"}},"available_locations":[39]} 
[2026-09-11 16:46:03] live.INFO: OpeningStockController::add - Serial Numbers Check {"product_id":"343","business_id":43,"has_serial_numbers":{"39":false},"total_locations_with_serial":0} 
[2026-09-11 16:46:09] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:46:34] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:47:11] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:48:55] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:49:17] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:49:37] live.INFO: Digitax upload skipped: No tax number provided {"contact_id":876,"contact_name":"","contact_type":"customer"} 
[2026-09-11 16:49:48] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:50:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:50:16] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:50:30] live.INFO: filterProduct method called {"business_id":43,"search_term":"KO","location_id":"39","not_for_selling":"0","price_group_id":"0","product_types":[],"search_fields":["name","sku"],"check_qty":false,"search_type":"like"} 
[2026-09-11 16:50:30] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-11 16:50:30] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-11 16:50:30] live.DEBUG: Applying search filters {"search_term":"KO","search_type":"like","search_fields":["name","sku"]} 
[2026-09-11 16:50:30] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-11 16:50:30] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-11 16:50:30] live.INFO: filterProduct completed successfully {"result_count":4,"business_id":43,"search_term":"KO"} 
[2026-09-11 16:50:33] live.INFO: Product Row Debug - RELOADED {"product_id":343,"product_name":"ko 500ml","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":300.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"266":{"unit_id":266,"unit_name":"pcs","unit_price":300.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-11 16:50:52] live.INFO: filterProduct method called {"business_id":43,"search_term":"KO","location_id":"39","not_for_selling":"0","price_group_id":"34","product_types":[],"search_fields":["name","sku"],"check_qty":false,"search_type":"like"} 
[2026-09-11 16:50:52] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-11 16:50:52] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-11 16:50:52] live.DEBUG: Joining variation_group_prices for price group {"price_group_id":"34"} 
[2026-09-11 16:50:52] live.DEBUG: Applying search filters {"search_term":"KO","search_type":"like","search_fields":["name","sku"]} 
[2026-09-11 16:50:52] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-11 16:50:52] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-11 16:50:52] live.DEBUG: Added price group calculation to select {"price_group_id":"34"} 
[2026-09-11 16:50:52] live.INFO: filterProduct completed successfully {"result_count":4,"business_id":43,"search_term":"KO"} 
[2026-09-11 16:50:54] live.INFO: Product Row Debug - RELOADED {"product_id":343,"product_name":"ko 500ml","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":"200.0000","discounts_json":"[]","multiplier":1,"unit_prices":{"266":{"unit_id":266,"unit_name":"pcs","unit_price":300.0,"multiplier":1,"has_price":true}},"has_price_group":true,"price_group_id":"34"} 
[2026-09-11 16:52:56] live.INFO: filterProduct method called {"business_id":43,"search_term":"KO","location_id":"39","not_for_selling":"0","price_group_id":"0","product_types":[],"search_fields":["name","sku"],"check_qty":false,"search_type":"like"} 
[2026-09-11 16:52:56] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-11 16:52:56] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-11 16:52:56] live.DEBUG: Applying search filters {"search_term":"KO","search_type":"like","search_fields":["name","sku"]} 
[2026-09-11 16:52:56] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-11 16:52:56] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-11 16:52:56] live.INFO: filterProduct completed successfully {"result_count":4,"business_id":43,"search_term":"KO"} 
[2026-09-11 16:52:58] live.INFO: Product Row Debug - RELOADED {"product_id":343,"product_name":"ko 500ml","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":300.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"266":{"unit_id":266,"unit_name":"pcs","unit_price":300.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-11 16:53:15] live.INFO: Credit Limit Check Started {"contact_id":"703","status":"final","final_total":"3000.00","is_credit_sale":"0","exclude_transaction_id":null} 
[2026-09-11 16:53:15] live.DEBUG: Payment Calculation {"final_total":3000.0,"curr_total_payment":3000.0,"is_credit_sale":false,"payment_count":1} 
[2026-09-11 16:53:15] live.INFO: Credit Limit Check Skipped - Fully Paid {"final_total":3000.0,"curr_total_payment":3000.0} 
[2026-09-11 16:53:15] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-11 16:53:15] live.INFO: is_mpesa_sale value: true  
[2026-09-11 16:53:15] live.INFO: M-Pesa sale evaluation {"is_mpesa_sale_raw":true,"is_valid_mpesa_sale":false,"payment_method_input":"cash","mpesa_transaction_id":null,"transaction_id":1832} 
[2026-09-11 16:53:15] live.INFO: Journal Entry Case: FULL CASH PAYMENT {"transaction_id":1832,"final_total":3000.0,"amount_paid":3000.0,"balance_due":0} 
[2026-09-11 16:53:15] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1832,"entries":[{"transaction_id":1832,"created_by_id":293,"transaction_number":"TRX-6aa407cb69f780.08874008","payment_detail_id":1311,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-11","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-11 16:53:15","updated_at":"2026-09-11 16:53:15","chart_of_account_id":15441,"debit":null,"credit":3000.0},{"transaction_id":1832,"created_by_id":293,"transaction_number":"TRX-6aa407cb69f780.08874008","payment_detail_id":1311,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-11","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-11 16:53:15","updated_at":"2026-09-11 16:53:15","chart_of_account_id":15445,"debit":3000.0,"credit":null}]} 
[2026-09-11 16:53:15] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1172,"purchase_line_id":1579,"quantity":10.0,"created_at":"2026-09-11 16:53:15","updated_at":"2026-09-11 16:53:15"}]} 
[2026-09-11 16:53:15] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-11 16:53:15] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":600.0} 
[2026-09-11 16:53:15] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-11 16:53:15] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1832  
[2026-09-11 16:53:45] live.INFO: filterProduct method called {"business_id":43,"search_term":"KO","location_id":"39","not_for_selling":"0","price_group_id":"0","product_types":[],"search_fields":["name","sku"],"check_qty":false,"search_type":"like"} 
[2026-09-11 16:53:45] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-11 16:53:45] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-11 16:53:45] live.DEBUG: Applying search filters {"search_term":"KO","search_type":"like","search_fields":["name","sku"]} 
[2026-09-11 16:53:45] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-11 16:53:45] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-11 16:53:45] live.INFO: filterProduct completed successfully {"result_count":4,"business_id":43,"search_term":"KO"} 
[2026-09-11 16:53:47] live.INFO: Product Row Debug - RELOADED {"product_id":343,"product_name":"ko 500ml","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":300.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"266":{"unit_id":266,"unit_name":"pcs","unit_price":300.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-11 16:54:27] live.INFO: Loaded Payment Settings: {"type":"till","short_code":"3582003","child_number":"3582003","till_no":5699724,"passkey":"8df9b4d855b77a20bd2257ee86f2b482b1816237e0e248e39ff8cbd3e73aabff","consumer_key":"W9AyBGwLeBRq0FAkn2FG3g9EJK9fF3nKwGTzG2pNtByd5tnQ","consumer_secret":"nziTooyd6JS0GC08ZG7456Ab531RVYOI1AyeZNXpDKha0xQ6mEvbFtOiAVAjlhyc","site_url":"https://now.riset.cloud/","payment_options":"[\"custom_pay_1\"]"} 
[2026-09-11 16:54:27] live.INFO: STK Push Request Received. {"request_input":{"phone":"0726269617","amount":"300.00"}} 
[2026-09-11 16:54:27] live.INFO: Phone number formatted. {"formatted_phone":"254726269617"} 
[2026-09-11 16:54:27] live.INFO: Phone and Amount after formatting. {"phone":"254726269617","amount":300} 
[2026-09-11 16:54:27] live.INFO: Timestamp for STK Push: {"timestamp":"20260911160927"} 
[2026-09-11 16:54:27] live.INFO: Transaction type determined. {"transaction_type":"CustomerBuyGoodsOnline"} 
[2026-09-11 16:54:27] live.INFO: PartyB to be used in STK Push. {"type":"till","partyB":5699724,"short_code":"3582003","child_number":"3582003","till_no":5699724} 
[2026-09-11 16:54:27] live.INFO: Callback URLs set. {"callbackURL":"https://now.riset.cloud/api/payment/callback","validationURL":"https://now.riset.cloud/api/payment/validation"} 
[2026-09-11 16:54:27] live.INFO: Loaded Payment Settings: {"type":"till","short_code":"3582003","child_number":"3582003","till_no":5699724,"passkey":"8df9b4d855b77a20bd2257ee86f2b482b1816237e0e248e39ff8cbd3e73aabff","consumer_key":"W9AyBGwLeBRq0FAkn2FG3g9EJK9fF3nKwGTzG2pNtByd5tnQ","consumer_secret":"nziTooyd6JS0GC08ZG7456Ab531RVYOI1AyeZNXpDKha0xQ6mEvbFtOiAVAjlhyc","site_url":"https://now.riset.cloud/","payment_options":"[\"custom_pay_1\"]"} 
[2026-09-11 16:54:27] live.INFO: Generated password for M-Pesa STK Push. {"password":"MzU4MjAwMzhkZjliNGQ4NTViNzdhMjBiZDIyNTdlZTg2ZjJiNDgyYjE4MTYyMzdlMGUyNDhlMzlmZjhjYmQzZTczYWFiZmYyMDI2MDkxMTE2MDkyNw=="} 
[2026-09-11 16:54:27] live.INFO: Payload prepared for STK Push. {"payload":{"BusinessShortCode":"3582003","Password":"MzU4MjAwMzhkZjliNGQ4NTViNzdhMjBiZDIyNTdlZTg2ZjJiNDgyYjE4MTYyMzdlMGUyNDhlMzlmZjhjYmQzZTczYWFiZmYyMDI2MDkxMTE2MDkyNw==","Timestamp":"20260911160927","TransactionType":"CustomerBuyGoodsOnline","Amount":300,"PartyA":"254726269617","PartyB":5699724,"PhoneNumber":"254726269617","CallBackURL":"https://now.riset.cloud/api/payment/callback","AccountReference":12,"TransactionDesc":"Biz"}} 
[2026-09-11 16:54:27] live.INFO: Loaded Payment Settings: {"type":"till","short_code":"3582003","child_number":"3582003","till_no":5699724,"passkey":"8df9b4d855b77a20bd2257ee86f2b482b1816237e0e248e39ff8cbd3e73aabff","consumer_key":"W9AyBGwLeBRq0FAkn2FG3g9EJK9fF3nKwGTzG2pNtByd5tnQ","consumer_secret":"nziTooyd6JS0GC08ZG7456Ab531RVYOI1AyeZNXpDKha0xQ6mEvbFtOiAVAjlhyc","site_url":"https://now.riset.cloud/","payment_options":"[\"custom_pay_1\"]"} 
[2026-09-11 16:54:28] live.INFO: Loaded Payment Settings: {"type":"till","short_code":"3582003","child_number":"3582003","till_no":5699724,"passkey":"8df9b4d855b77a20bd2257ee86f2b482b1816237e0e248e39ff8cbd3e73aabff","consumer_key":"W9AyBGwLeBRq0FAkn2FG3g9EJK9fF3nKwGTzG2pNtByd5tnQ","consumer_secret":"nziTooyd6JS0GC08ZG7456Ab531RVYOI1AyeZNXpDKha0xQ6mEvbFtOiAVAjlhyc","site_url":"https://now.riset.cloud/","payment_options":"[\"custom_pay_1\"]"} 
[2026-09-11 16:54:28] live.INFO: Registering URLs. {"shortCode":"3582003","confirmationURL":"https://now.riset.cloud/api/payment/callback","validationURL":"https://now.riset.cloud/api/payment/validation"} 
[2026-09-11 16:54:30] live.INFO: URL registration response. {"response":"{
                    \"requestId\":\"a1d4-457e-8ca7-f0f60a7863d34564479\",
                    \"errorCode\": \"500.003.1001\",
                    \"errorMessage\": \"URLs are already registered\"
                }
            "} 
[2026-09-11 16:54:34] live.INFO: STK Push response received. {"response":{"MerchantRequestID":"2f6a-4e96-ba14-229266a4419e4717829","CheckoutRequestID":"ws_CO_11092026165433510726269617","ResponseCode":"0","ResponseDescription":"Success. Request accepted for processing","CustomerMessage":"Success. Request accepted for processing"}} 
[2026-09-11 16:55:16] live.INFO: Credit Limit Check Started {"contact_id":"703","status":"final","final_total":"300.00","is_credit_sale":"0","exclude_transaction_id":null} 
[2026-09-11 16:55:16] live.DEBUG: Payment Calculation {"final_total":300.0,"curr_total_payment":500.0,"is_credit_sale":false,"payment_count":1} 
[2026-09-11 16:55:16] live.INFO: Credit Limit Check Skipped - Fully Paid {"final_total":300.0,"curr_total_payment":500.0} 
[2026-09-11 16:55:16] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-11 16:55:16] live.INFO: is_mpesa_sale value: true  
[2026-09-11 16:55:16] live.INFO: M-Pesa sale evaluation {"is_mpesa_sale_raw":true,"is_valid_mpesa_sale":false,"payment_method_input":"cash","mpesa_transaction_id":null,"transaction_id":1833} 
[2026-09-11 16:55:16] live.INFO: M-Pesa sale evaluation {"is_mpesa_sale_raw":true,"is_valid_mpesa_sale":false,"payment_method_input":"cash","mpesa_transaction_id":null,"transaction_id":1833} 
[2026-09-11 16:55:16] live.INFO: Journal Entry Case: FULL CASH PAYMENT {"transaction_id":1833,"final_total":300.0,"amount_paid":500.0,"balance_due":0} 
[2026-09-11 16:55:16] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1833,"entries":[{"transaction_id":1833,"created_by_id":293,"transaction_number":"TRX-6aa40844396f03.22227048","payment_detail_id":1312,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-11","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-11 16:55:16","updated_at":"2026-09-11 16:55:16","chart_of_account_id":15441,"debit":null,"credit":300.0},{"transaction_id":1833,"created_by_id":293,"transaction_number":"TRX-6aa40844396f03.22227048","payment_detail_id":1312,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-11","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-11 16:55:16","updated_at":"2026-09-11 16:55:16","chart_of_account_id":15445,"debit":300.0,"credit":null}]} 
[2026-09-11 16:55:16] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1173,"purchase_line_id":1579,"quantity":1.0,"created_at":"2026-09-11 16:55:16","updated_at":"2026-09-11 16:55:16"}]} 
[2026-09-11 16:55:16] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-11 16:55:16] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":60.0} 
[2026-09-11 16:55:16] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-11 16:55:16] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1833  
[2026-09-11 16:55:33] live.INFO: filterProduct method called {"business_id":43,"search_term":"KO","location_id":"39","not_for_selling":"0","price_group_id":"0","product_types":[],"search_fields":["name","sku"],"check_qty":false,"search_type":"like"} 
[2026-09-11 16:55:33] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-11 16:55:33] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-11 16:55:33] live.DEBUG: Applying search filters {"search_term":"KO","search_type":"like","search_fields":["name","sku"]} 
[2026-09-11 16:55:33] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-11 16:55:33] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-11 16:55:33] live.INFO: filterProduct completed successfully {"result_count":4,"business_id":43,"search_term":"KO"} 
[2026-09-11 16:55:36] live.INFO: Product Row Debug - RELOADED {"product_id":343,"product_name":"ko 500ml","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":300.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"266":{"unit_id":266,"unit_name":"pcs","unit_price":300.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-11 16:55:58] live.INFO: Credit Limit Check Started {"contact_id":"703","status":"final","final_total":"3000.00","is_credit_sale":"0","exclude_transaction_id":null} 
[2026-09-11 16:55:58] live.DEBUG: Payment Calculation {"final_total":3000.0,"curr_total_payment":3000.0,"is_credit_sale":false,"payment_count":2} 
[2026-09-11 16:55:58] live.INFO: Credit Limit Check Skipped - Fully Paid {"final_total":3000.0,"curr_total_payment":3000.0} 
[2026-09-11 16:55:58] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-11 16:55:58] live.INFO: is_mpesa_sale value: true  
[2026-09-11 16:55:58] live.INFO: M-Pesa sale evaluation {"is_mpesa_sale_raw":true,"is_valid_mpesa_sale":false,"payment_method_input":"cash","mpesa_transaction_id":null,"transaction_id":1834} 
[2026-09-11 16:55:58] live.INFO: M-Pesa sale evaluation {"is_mpesa_sale_raw":true,"is_valid_mpesa_sale":false,"payment_method_input":"custom_pay_1","mpesa_transaction_id":null,"transaction_id":1834} 
[2026-09-11 16:55:58] live.INFO: Journal Entry Case: PARTIAL PAYMENT {"transaction_id":1834,"final_total":3000.0,"amount_paid":2000.0,"balance_due":1000.0} 
[2026-09-11 16:55:58] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1834,"entries":[{"transaction_id":1834,"created_by_id":293,"transaction_number":"TRX-6aa4086e6d2292.59499289","payment_detail_id":1313,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-11","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-11 16:55:58","updated_at":"2026-09-11 16:55:58","chart_of_account_id":15441,"debit":null,"credit":3000.0},{"transaction_id":1834,"created_by_id":293,"transaction_number":"TRX-6aa4086e6d2292.59499289","payment_detail_id":1313,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-11","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-11 16:55:58","updated_at":"2026-09-11 16:55:58","chart_of_account_id":15445,"debit":2000.0,"credit":null},{"transaction_id":1834,"created_by_id":293,"transaction_number":"TRX-6aa4086e6d2292.59499289","payment_detail_id":1313,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-11","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-11 16:55:58","updated_at":"2026-09-11 16:55:58","chart_of_account_id":15440,"debit":1000.0,"credit":null}]} 
[2026-09-11 16:55:58] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1174,"purchase_line_id":1579,"quantity":10.0,"created_at":"2026-09-11 16:55:58","updated_at":"2026-09-11 16:55:58"}]} 
[2026-09-11 16:55:58] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-11 16:55:58] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":600.0} 
[2026-09-11 16:55:58] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-11 16:55:58] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1834  
[2026-09-11 16:56:25] live.INFO: filterProduct method called {"business_id":43,"search_term":"KO","location_id":"39","not_for_selling":"0","price_group_id":"0","product_types":[],"search_fields":["name","sku"],"check_qty":false,"search_type":"like"} 
[2026-09-11 16:56:25] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-11 16:56:25] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-11 16:56:25] live.DEBUG: Applying search filters {"search_term":"KO","search_type":"like","search_fields":["name","sku"]} 
[2026-09-11 16:56:25] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-11 16:56:25] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-11 16:56:25] live.INFO: filterProduct completed successfully {"result_count":4,"business_id":43,"search_term":"KO"} 
[2026-09-11 16:56:27] live.INFO: Product Row Debug - RELOADED {"product_id":343,"product_name":"ko 500ml","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":300.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"266":{"unit_id":266,"unit_name":"pcs","unit_price":300.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-11 16:56:47] live.INFO: Credit Limit Check Started {"contact_id":"875","status":"final","final_total":"1800.00","is_credit_sale":"0","exclude_transaction_id":null} 
[2026-09-11 16:56:47] live.DEBUG: Payment Calculation {"final_total":1800.0,"curr_total_payment":0.0,"is_credit_sale":false,"payment_count":1} 
[2026-09-11 16:56:47] live.INFO: Credit Limit Check Skipped - No Credit Limit Set {"contact_id":"875","contact_name":"musyoka wines"} 
[2026-09-11 16:56:47] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-11 16:56:47] live.INFO: is_mpesa_sale value: true  
[2026-09-11 16:56:47] live.INFO: Journal Entry Case: FULL CREDIT SALE {"transaction_id":1835,"final_total":1800.0,"amount_paid":0.0,"balance_due":1800.0} 
[2026-09-11 16:56:47] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1835,"entries":[{"transaction_id":1835,"created_by_id":293,"transaction_number":"TRX-6aa4089fcd6154.22076743","payment_detail_id":1314,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-11","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-11 16:56:47","updated_at":"2026-09-11 16:56:47","chart_of_account_id":15441,"debit":null,"credit":1800.0},{"transaction_id":1835,"created_by_id":293,"transaction_number":"TRX-6aa4089fcd6154.22076743","payment_detail_id":1314,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-11","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-11 16:56:47","updated_at":"2026-09-11 16:56:47","chart_of_account_id":15440,"debit":1800.0,"credit":null}]} 
[2026-09-11 16:56:47] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1175,"purchase_line_id":1579,"quantity":6.0,"created_at":"2026-09-11 16:56:47","updated_at":"2026-09-11 16:56:47"}]} 
[2026-09-11 16:56:47] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-11 16:56:47] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":360.0} 
[2026-09-11 16:56:47] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-11 16:56:48] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1835  
[2026-09-11 16:57:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:57:09] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:57:14] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:58:11] live.INFO: Purchases array from request {"purchases":[{"product_id":"343","variation_id":"348","quantity":"100","product_unit_id":"266","sub_unit_id":"266","pp_without_discount":"240.00","discount_percent":"0.00","purchase_price":"240.00","purchase_line_tax_id":null,"item_tax":"0.00","purchase_price_inc_tax":"240.00","profit_percent":"25.00","default_sell_price":"300.00","mfg_date":null,"exp_date":null,"imei_numbers":"[]","imei_count":"0"},{"product_id":"300","variation_id":"305","quantity":"20","product_unit_id":"39","sub_unit_id":"39","pp_without_discount":"300.00","discount_percent":"0.00","purchase_price":"300.00","purchase_line_tax_id":null,"item_tax":"0.00","purchase_price_inc_tax":"300.00","profit_percent":"50.00","default_sell_price":"450.00","mfg_date":null,"exp_date":null,"imei_numbers":"[]","imei_count":"0"}],"purchases_json":"[{\"product_id\":\"343\",\"variation_id\":\"348\",\"quantity\":\"100\",\"product_unit_id\":\"266\",\"sub_unit_id\":\"266\",\"pp_without_discount\":\"240.00\",\"discount_percent\":\"0.00\",\"purchase_price\":\"240.00\",\"purchase_line_tax_id\":null,\"item_tax\":\"0.00\",\"purchase_price_inc_tax\":\"240.00\",\"profit_percent\":\"25.00\",\"default_sell_price\":\"300.00\",\"mfg_date\":null,\"exp_date\":null,\"imei_numbers\":\"[]\",\"imei_count\":\"0\"},{\"product_id\":\"300\",\"variation_id\":\"305\",\"quantity\":\"20\",\"product_unit_id\":\"39\",\"sub_unit_id\":\"39\",\"pp_without_discount\":\"300.00\",\"discount_percent\":\"0.00\",\"purchase_price\":\"300.00\",\"purchase_line_tax_id\":null,\"item_tax\":\"0.00\",\"purchase_price_inc_tax\":\"300.00\",\"profit_percent\":\"50.00\",\"default_sell_price\":\"450.00\",\"mfg_date\":null,\"exp_date\":null,\"imei_numbers\":\"[]\",\"imei_count\":\"0\"}]"} 
[2026-09-11 16:58:11] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-11 16:58:11] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-11 16:58:11] live.INFO: Purchase lines created {"transaction_id":1836,"purchase_lines_count":2,"purchase_lines":[{"id":1580,"transaction_id":1836,"product_id":343,"variation_id":348,"quantity":100.0,"secondary_unit_quantity":"0.0000","pp_without_discount":"240.0000","discount_percent":"0.00","purchase_price":"240.0000","purchase_price_inc_tax":"240.0000","item_tax":"0.0000","tax_id":null,"purchase_requisition_line_id":null,"purchase_order_line_id":null,"quantity_sold":"0.0000","quantity_adjusted":"0.0000","quantity_returned":"0.0000","po_quantity_purchased":"0.0000","mfg_quantity_used":"0.0000","mfg_date":null,"exp_date":null,"lot_number":null,"sub_unit_id":null,"created_at":"2026-09-11T13:58:11.000000Z","updated_at":"2026-09-11T13:58:11.000000Z"},{"id":1581,"transaction_id":1836,"product_id":300,"variation_id":305,"quantity":20.0,"secondary_unit_quantity":"0.0000","pp_without_discount":"300.0000","discount_percent":"0.00","purchase_price":"300.0000","purchase_price_inc_tax":"300.0000","item_tax":"0.0000","tax_id":null,"purchase_requisition_line_id":null,"purchase_order_line_id":null,"quantity_sold":"0.0000","quantity_adjusted":"0.0000","quantity_returned":"0.0000","po_quantity_purchased":"0.0000","mfg_quantity_used":"0.0000","mfg_date":null,"exp_date":null,"lot_number":null,"sub_unit_id":null,"created_at":"2026-09-11T13:58:11.000000Z","updated_at":"2026-09-11T13:58:11.000000Z"}]} 
[2026-09-11 16:58:11] live.INFO: Processing purchase row - 0 {"row_index":0,"product_id":"343","variation_id":"348","quantity":"100","has_imei":true,"imei_raw":"[]","purchase_data_keys":["product_id","variation_id","quantity","product_unit_id","sub_unit_id","pp_without_discount","discount_percent","purchase_price","purchase_line_tax_id","item_tax","purchase_price_inc_tax","profit_percent","default_sell_price","mfg_date","exp_date","imei_numbers","imei_count"]} 
[2026-09-11 16:58:11] live.INFO: IMEI Data - Parsed for row 0 {"row_index":0,"imei_count":0,"imei_data":[],"imei_json":"[]"} 
[2026-09-11 16:58:11] live.INFO: IMEI data is empty or invalid for row 0 {"imeiData":[]} 
[2026-09-11 16:58:11] live.INFO: Processing purchase row - 1 {"row_index":1,"product_id":"300","variation_id":"305","quantity":"20","has_imei":true,"imei_raw":"[]","purchase_data_keys":["product_id","variation_id","quantity","product_unit_id","sub_unit_id","pp_without_discount","discount_percent","purchase_price","purchase_line_tax_id","item_tax","purchase_price_inc_tax","profit_percent","default_sell_price","mfg_date","exp_date","imei_numbers","imei_count"]} 
[2026-09-11 16:58:11] live.INFO: IMEI Data - Parsed for row 1 {"row_index":1,"imei_count":0,"imei_data":[],"imei_json":"[]"} 
[2026-09-11 16:58:11] live.INFO: IMEI data is empty or invalid for row 1 {"imeiData":[]} 
[2026-09-11 16:58:11] live.INFO: M-Pesa sale evaluation {"is_mpesa_sale_raw":false,"is_valid_mpesa_sale":false,"payment_method_input":"custom_pay_1","mpesa_transaction_id":null,"transaction_id":1836} 
[2026-09-11 16:58:11] live.INFO: Purchase created successfully with IMEI data {"transaction_id":1836,"ref_no":"PO2026/0016","final_total":30000.0} 
[2026-09-11 16:58:15] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:58:23] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:58:30] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:58:45] live.INFO: M-Pesa sale evaluation {"is_mpesa_sale_raw":false,"is_valid_mpesa_sale":false,"payment_method_input":"cash","mpesa_transaction_id":null,"transaction_id":1837} 
[2026-09-11 16:58:48] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:59:06] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2025-12-31","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-11 16:59:06] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-11 16:59:06] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2025-12-31')"} 
[2026-09-11 16:59:06] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2025-12-31') ) * (purchase_lines.purchase_price + 
                        COALESCE(purchase_lines.item_tax, 0))
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and (`purchase`.`type` = ? or (`purchase`.`type` != ? and date(transaction_date) <= '2025-12-31'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-11 16:59:06] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"2763865.08000000","is_opening":true,"date":"2025-12-31"} 
[2026-09-11 16:59:06] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-12-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-11 16:59:06] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-11 16:59:06] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-12-31') ) * (purchase_lines.purchase_price + 
                        COALESCE(purchase_lines.item_tax, 0))
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and date(transaction_date) <= '2026-12-31'","bindings":["purchase_order",43]} 
[2026-09-11 16:59:06] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"8844862.43600000","is_opening":false,"date":"2026-12-31"} 
[2026-09-11 16:59:06] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 16:59:07] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2025-12-31","location_id":null,"is_opening":true,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-11 16:59:07] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-11 16:59:07] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-11 16:59:07] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2025-12-31')"} 
[2026-09-11 16:59:07] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2025-12-31') ) * v.sell_price_inc_tax
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and (`purchase`.`type` = ? or (`purchase`.`type` != ? and date(transaction_date) <= '2025-12-31'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-11 16:59:07] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5022225.00000000","is_opening":true,"date":"2025-12-31"} 
[2026-09-11 16:59:07] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-12-31","location_id":null,"is_opening":false,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-11 16:59:07] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-11 16:59:07] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-11 16:59:07] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-12-31') ) * v.sell_price_inc_tax
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and date(transaction_date) <= '2026-12-31'","bindings":["purchase_order",43]} 
[2026-09-11 16:59:07] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"7363630.00000000","is_opening":false,"date":"2026-12-31"} 
[2026-09-11 16:59:09] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-10","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-11 16:59:09] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-10"} 
[2026-09-11 16:59:09] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-10')"} 
[2026-09-11 16:59:09] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-09-10') ) * (purchase_lines.purchase_price + 
                        COALESCE(purchase_lines.item_tax, 0))
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and (`purchase`.`type` = ? or (`purchase`.`type` != ? and date(transaction_date) <= '2026-09-10'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-11 16:59:09] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6793827.43600000","is_opening":true,"date":"2026-09-10"} 
[2026-09-11 16:59:09] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-11","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-11 16:59:09] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-11' (includes all types except purchase_order)"} 
[2026-09-11 16:59:09] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-09-11') ) * (purchase_lines.purchase_price + 
                        COALESCE(purchase_lines.item_tax, 0))
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and date(transaction_date) <= '2026-09-11'","bindings":["purchase_order",43]} 
[2026-09-11 16:59:09] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"8844862.43600000","is_opening":false,"date":"2026-09-11"} 
[2026-09-11 16:59:10] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-10","location_id":null,"is_opening":true,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-11 16:59:10] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-11 16:59:10] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-10"} 
[2026-09-11 16:59:10] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-10')"} 
[2026-09-11 16:59:10] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-09-10') ) * v.sell_price_inc_tax
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and (`purchase`.`type` = ? or (`purchase`.`type` != ? and date(transaction_date) <= '2026-09-10'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-11 16:59:10] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"7332780.00000000","is_opening":true,"date":"2026-09-10"} 
[2026-09-11 16:59:10] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-11","location_id":null,"is_opening":false,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-11 16:59:10] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-11 16:59:10] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-11' (includes all types except purchase_order)"} 
[2026-09-11 16:59:10] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-09-11') ) * v.sell_price_inc_tax
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and date(transaction_date) <= '2026-09-11'","bindings":["purchase_order",43]} 
[2026-09-11 16:59:10] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"7363630.00000000","is_opening":false,"date":"2026-09-11"} 
[2026-09-11 16:59:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 17:00:14] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 17:00:48] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 17:01:35] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 17:01:56] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 17:03:16] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 17:03:30] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 17:03:34] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 17:04:58] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-10","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-11 17:04:58] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-10"} 
[2026-09-11 17:04:58] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-10')"} 
[2026-09-11 17:04:58] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-09-10') ) * (purchase_lines.purchase_price + 
                        COALESCE(purchase_lines.item_tax, 0))
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and (`purchase`.`type` = ? or (`purchase`.`type` != ? and date(transaction_date) <= '2026-09-10'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-11 17:04:58] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6793827.43600000","is_opening":true,"date":"2026-09-10"} 
[2026-09-11 17:04:58] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-11","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-11 17:04:58] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-11' (includes all types except purchase_order)"} 
[2026-09-11 17:04:58] live.DEBUG: Final SQL Query {"sql":"select SUM((purchase_lines.quantity - purchase_lines.quantity_returned - purchase_lines.quantity_adjusted -
                        (SELECT COALESCE(SUM(tspl.quantity - tspl.qty_returned), 0) FROM 
                        transaction_sell_lines_purchase_lines AS tspl
                        JOIN transaction_sell_lines as tsl ON 
                        tspl.sell_line_id=tsl.id 
                        JOIN transactions as sale ON 
                        tsl.transaction_id=sale.id 
                        WHERE tspl.purchase_line_id = purchase_lines.id AND 
                        date(sale.transaction_date) <= '2026-09-11') ) * (purchase_lines.purchase_price + 
                        COALESCE(purchase_lines.item_tax, 0))
                    ) as stock from `purchase_lines` inner join `transactions` as `purchase` on `purchase_lines`.`transaction_id` = `purchase`.`id` left join `variations` as `v` on `v`.`id` = `purchase_lines`.`variation_id` left join `products` as `p` on `p`.`id` = `purchase_lines`.`product_id` where `purchase`.`type` != ? and `purchase`.`business_id` = ? and date(transaction_date) <= '2026-09-11'","bindings":["purchase_order",43]} 
[2026-09-11 17:04:58] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"8844862.43600000","is_opening":false,"date":"2026-09-11"} 
[2026-09-11 17:04:59] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 17:05:07] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 17:05:17] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 17:06:05] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-11 17:06:28] live.INFO: Offline not allowed - triggering cleanup {"user_id":362,"business_id":43} 
[2026-09-11 17:06:59] live.INFO: Offline not allowed - triggering cleanup {"user_id":362,"business_id":43} 
[2026-09-11 17:07:03] live.INFO: Offline not allowed - triggering cleanup {"user_id":362,"business_id":43} 
[2026-09-11 17:07:20] live.INFO: filterProduct method called {"business_id":43,"search_term":"ko","location_id":"39","not_for_selling":"0","price_group_id":null,"product_types":[],"search_fields":["name","sku"],"check_qty":false,"search_type":"like"} 
[2026-09-11 17:07:20] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-11 17:07:20] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-11 17:07:20] live.DEBUG: Applying search filters {"search_term":"ko","search_type":"like","search_fields":["name","sku"]} 
[2026-09-11 17:07:20] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-11 17:07:20] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-11 17:07:20] live.INFO: filterProduct completed successfully {"result_count":4,"business_id":43,"search_term":"ko"} 
