[2026-09-04 00:06:51] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 00:16:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 00:26:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 00:36:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 00:46:53] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 00:56:53] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 01:06:53] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 01:16:54] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 01:26:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 01:36:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 01:46:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 01:56:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 02:06:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 02:16:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 02:26:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 02:36:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 02:46:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 02:56:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 03:06:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 03:16:59] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 03:26:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 03:36:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 03:46:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 03:56:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 04:06:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 04:16:45] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 04:26:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 04:36:45] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 04:46:45] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 04:56:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 05:07:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 05:17:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 05:26:51] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 05:36:45] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 05:47:03] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 05:56:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 06:07:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 06:17:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 06:27:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 06:37:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 06:47:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 06:57:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 07:07:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 07:17:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 07:27:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 07:37:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 07:47:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 07:57:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:07:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:16:51] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:18:13] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:18:15] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:19:19] live.INFO: === About to call saveProductNewUnitRelationships === {"product_id":335,"request_units":[{"actual_name":"pieces","unit_id":"246","short_name":"pcs","relation_unit_id":null,"relation_qty":"1","price":null}],"page_batch_id":"20260904_081812_6564"} 
[2026-09-04 08:19:19] live.INFO: === saveProductNewUnitRelationships START === {"product_id":335,"product_name":"xtest"} 
[2026-09-04 08:19:19] live.INFO: Units data received {"units_data":[{"actual_name":"pieces","unit_id":"246","short_name":"pcs","relation_unit_id":null,"relation_qty":"1","price":null}],"count":1} 
[2026-09-04 08:19:19] live.INFO: Processing unit index: 0 {"unit_data":{"actual_name":"pieces","unit_id":"246","short_name":"pcs","relation_unit_id":null,"relation_qty":"1","price":null}} 
[2026-09-04 08:19:19] live.INFO: Unit found by ID {"unit_id":246,"actual_name":"pieces"} 
[2026-09-04 08:19:19] live.INFO: Unit lookup result {"found":"yes","unit_id":246,"method":"by_id"} 
[2026-09-04 08:19:19] live.INFO: Updating existing unit {"unit_id":246} 
[2026-09-04 08:19:19] live.INFO: Updated allow_decimal {"new_allow_decimal":1} 
[2026-09-04 08:19:19] live.INFO: Unit updated successfully  
[2026-09-04 08:19:19] live.INFO: Setting as BASE unit {"unit_id":246} 
[2026-09-04 08:19:19] live.INFO: Base unit saved {"base_unit_id":246} 
[2026-09-04 08:19:19] live.INFO: First pass complete {"created_units_count":1,"base_unit_id":246} 
[2026-09-04 08:19:19] live.INFO: === SECOND PASS: Setting relations first ===  
[2026-09-04 08:19:19] live.INFO: === SECOND PASS: Calculating cumulative multipliers ===  
[2026-09-04 08:19:19] live.INFO: === saveProductNewUnitRelationships END ===  
[2026-09-04 08:19:19] live.INFO: OpeningStockController::add - Location Data {"product_id":"335","business_id":43,"locations":{"Illuminate\\Support\\Collection":{"39":"Greenfield Supermarket Ltd (BL0001)"}},"available_locations":[39]} 
[2026-09-04 08:19:19] live.INFO: OpeningStockController::add - Serial Numbers Check {"product_id":"335","business_id":43,"has_serial_numbers":{"39":false},"total_locations_with_serial":0} 
[2026-09-04 08:19:22] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:19:31] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:19:34] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:19:56] live.INFO: OpeningStockController::add - Location Data {"product_id":"335","business_id":43,"locations":{"Illuminate\\Support\\Collection":{"39":"Greenfield Supermarket Ltd (BL0001)"}},"available_locations":[39]} 
[2026-09-04 08:19:56] live.INFO: OpeningStockController::add - Serial Numbers Check {"product_id":"335","business_id":43,"has_serial_numbers":{"39":false},"total_locations_with_serial":0} 
[2026-09-04 08:20:13] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:20:34] live.INFO: === saveProductUnitRelationships START === {"product_id":335,"product_name":"xtest"} 
[2026-09-04 08:20:34] live.INFO: Units data received {"units_data":[{"actual_name":"246","unit_id":"246","short_name":"pcs","allow_decimal":"1","relation_unit_id":null,"relation_qty":"1","price":"0"}],"count":1} 
[2026-09-04 08:20:34] live.INFO: Processing unit index: 0 {"unit_data":{"actual_name":"246","unit_id":"246","short_name":"pcs","allow_decimal":"1","relation_unit_id":null,"relation_qty":"1","price":"0"}} 
[2026-09-04 08:20:34] live.INFO: Unit found by ID {"unit_id":246,"actual_name":"pieces"} 
[2026-09-04 08:20:34] live.WARNING: Skipping actual_name update - value looks like an ID {"actual_name":"246","unit_id":246} 
[2026-09-04 08:20:34] live.INFO: Setting as BASE unit {"unit_id":246} 
[2026-09-04 08:20:34] live.INFO: Unit saved {"unit_id":246,"unit_name":"pieces","is_base":true} 
[2026-09-04 08:20:34] live.INFO: First pass complete {"created_units_count":1,"unit_ids_to_keep":[246],"base_unit_id":246} 
[2026-09-04 08:20:34] live.INFO: === SECOND PASS: Setting relations first ===  
[2026-09-04 08:20:34] live.INFO: === SECOND PASS: Calculating cumulative multipliers ===  
[2026-09-04 08:20:34] live.INFO: === Cleaning up unused units === {"unit_ids_to_keep":[246],"base_unit_id":246,"page_batch_id":"20260904_081812_6564"} 
[2026-09-04 08:20:34] live.INFO: Units to delete {"count":0,"unit_ids":[]} 
[2026-09-04 08:20:34] live.INFO: === saveProductUnitRelationships END ===  
[2026-09-04 08:20:37] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:20:58] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:21:06] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:21:09] live.INFO: === saveProductUnitRelationships START === {"product_id":335,"product_name":"xtest"} 
[2026-09-04 08:21:09] live.INFO: Units data received {"units_data":[{"actual_name":"246","unit_id":"246","short_name":"pcs","allow_decimal":"1","relation_unit_id":null,"relation_qty":"1","price":"0"}],"count":1} 
[2026-09-04 08:21:09] live.INFO: Processing unit index: 0 {"unit_data":{"actual_name":"246","unit_id":"246","short_name":"pcs","allow_decimal":"1","relation_unit_id":null,"relation_qty":"1","price":"0"}} 
[2026-09-04 08:21:09] live.INFO: Unit found by ID {"unit_id":246,"actual_name":"pieces"} 
[2026-09-04 08:21:09] live.WARNING: Skipping actual_name update - value looks like an ID {"actual_name":"246","unit_id":246} 
[2026-09-04 08:21:09] live.INFO: Setting as BASE unit {"unit_id":246} 
[2026-09-04 08:21:09] live.INFO: Unit saved {"unit_id":246,"unit_name":"pieces","is_base":true} 
[2026-09-04 08:21:09] live.INFO: First pass complete {"created_units_count":1,"unit_ids_to_keep":[246],"base_unit_id":246} 
[2026-09-04 08:21:09] live.INFO: === SECOND PASS: Setting relations first ===  
[2026-09-04 08:21:09] live.INFO: === SECOND PASS: Calculating cumulative multipliers ===  
[2026-09-04 08:21:09] live.INFO: === Cleaning up unused units === {"unit_ids_to_keep":[246],"base_unit_id":246,"page_batch_id":"20260904_081812_6564"} 
[2026-09-04 08:21:09] live.INFO: Units to delete {"count":0,"unit_ids":[]} 
[2026-09-04 08:21:09] live.INFO: === saveProductUnitRelationships END ===  
[2026-09-04 08:21:21] live.INFO: filterProduct method called {"business_id":43,"search_term":"6972543687199","location_id":"39","not_for_selling":"0","price_group_id":"0","product_types":[],"search_fields":["name","sku","serial_number"],"check_qty":false,"search_type":"like"} 
[2026-09-04 08:21:21] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 08:21:21] live.DEBUG: Joining product_serial_numbers table for serial number search  
[2026-09-04 08:21:21] live.DEBUG: Serial numbers filtered by location {"location_id":"39"} 
[2026-09-04 08:21:21] live.DEBUG: Joining transaction_sell_lines and transactions to check if serial number is sold  
[2026-09-04 08:21:21] live.DEBUG: Added condition: keep products without serial numbers OR with available quantity > 0  
[2026-09-04 08:21:21] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 08:21:21] live.DEBUG: Applying search filters {"search_term":"6972543687199","search_type":"like","search_fields":["name","sku","serial_number"]} 
[2026-09-04 08:21:21] live.DEBUG: LIKE search conditions applied {"fields":["name","sku","serial_number"]} 
[2026-09-04 08:21:21] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 08:21:21] live.DEBUG: Added serial number, quantity, and transaction sell line fields with quantity details to select  
[2026-09-04 08:21:21] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"6972543687199"} 
[2026-09-04 08:21:22] live.INFO: Product Row Debug - RELOADED {"product_id":335,"product_name":"xtest","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":{"246":{"unit_id":246,"unit_name":"pieces","unit_price":null,"multiplier":1,"has_price":false}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 08:22:02] 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-04 08:22:02] live.DEBUG: Payment Calculation {"final_total":50.0,"curr_total_payment":50.0,"is_credit_sale":false,"payment_count":1} 
[2026-09-04 08:22:02] live.INFO: Credit Limit Check Skipped - Fully Paid {"final_total":50.0,"curr_total_payment":50.0} 
[2026-09-04 08:22:02] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-04 08:22:02] live.INFO: is_mpesa_sale value: true  
[2026-09-04 08:22:02] 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":1792} 
[2026-09-04 08:22:02] live.INFO: Journal Entry Case: FULL CASH PAYMENT {"transaction_id":1792,"final_total":50.0,"amount_paid":50.0,"balance_due":0} 
[2026-09-04 08:22:02] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1792,"entries":[{"transaction_id":1792,"created_by_id":293,"transaction_number":"TRX-6a9a557accbd07.07562045","payment_detail_id":1280,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 08:22:02","updated_at":"2026-09-04 08:22:02","chart_of_account_id":15441,"debit":null,"credit":50.0},{"transaction_id":1792,"created_by_id":293,"transaction_number":"TRX-6a9a557accbd07.07562045","payment_detail_id":1280,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 08:22:02","updated_at":"2026-09-04 08:22:02","chart_of_account_id":15445,"debit":50.0,"credit":null}]} 
[2026-09-04 08:22:02] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1148,"purchase_line_id":1566,"quantity":1.0,"created_at":"2026-09-04 08:22:02","updated_at":"2026-09-04 08:22:02"}]} 
[2026-09-04 08:22:02] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-04 08:22:02] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":30.0} 
[2026-09-04 08:22:02] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 08:22:03] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1792  
[2026-09-04 08:22:17] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:22:37] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:32:40] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:36:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:38:21] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:38:40] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:38:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:39:07] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"category_id":null,"sub_category_id":null,"brand_id":null,"unit_id":null},"permitted_locations":"all"} 
[2026-09-04 08:39:07] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 08:39: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-09-04') ) * (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-04'","bindings":["purchase_order",43]} 
[2026-09-04 08:39:07] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5994037.40800000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 08:39:07] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":true,"filters":{"category_id":null,"sub_category_id":null,"brand_id":null,"unit_id":null},"permitted_locations":"all"} 
[2026-09-04 08:39:07] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 08:39:07] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 08:39: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-09-04') ) * 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-04'","bindings":["purchase_order",43]} 
[2026-09-04 08:39:07] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6345770.00000000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 08:39:08] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:39:21] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:39:32] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:39:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:39:56] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 08:49:58] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 09:00:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 09:10:06] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 09:20:05] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 09:25:52] live.ERROR: Failed to send error alert email: Failed to authenticate on SMTP server with username "support@risetsystems.com" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".".  
[2026-09-04 09:25:57] live.ERROR: Failed to send error alert email: Failed to authenticate on SMTP server with username "support@risetsystems.com" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".".  
[2026-09-04 09:25:57] live.ERROR: Failed to send error alert email: Failed to authenticate on SMTP server with username "support@risetsystems.com" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".".  
[2026-09-04 09:25:57] live.ERROR: Failed to send error alert email: Failed to authenticate on SMTP server with username "support@risetsystems.com" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".".  
[2026-09-04 09:25:57] live.ERROR: Failed to send error alert email: Failed to authenticate on SMTP server with username "support@risetsystems.com" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".".  
[2026-09-04 09:25:57] live.ERROR: Failed to send error alert email: Failed to authenticate on SMTP server with username "support@risetsystems.com" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".".  
[2026-09-04 09:25:57] live.ERROR: Failed to send error alert email: Failed to authenticate on SMTP server with username "support@risetsystems.com" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".".  
[2026-09-04 09:25:58] live.ERROR: Failed to send error alert email: Failed to authenticate on SMTP server with username "support@risetsystems.com" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".".  
[2026-09-04 09:30:05] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 09:40:14] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 09:50:45] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:00:07] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:10:18] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:10:30] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 10:10:30] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 10:10:30] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 10:10:30] 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-03') ) * (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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 10:10:30] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5994057.40800000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 10:10:30] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 10:10:30] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 10:10:30] 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-04') ) * (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-04'","bindings":["purchase_order",43]} 
[2026-09-04 10:10:30] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5994037.40800000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 10:10:34] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:20:34] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:30:25] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:39:47] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:39:56] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:41:29] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:41:56] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:42:30] live.INFO: Digitax upload skipped: No tax number provided {"contact_id":868,"contact_name":"","contact_type":"supplier"} 
[2026-09-04 10:42:44] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:43:03] live.INFO: Digitax upload skipped: No tax number provided {"contact_id":869,"contact_name":"ken","contact_type":"customer"} 
[2026-09-04 10:43:29] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:43:57] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:44:04] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:47:39] live.INFO: === About to call saveProductNewUnitRelationships === {"product_id":336,"request_units":[{"actual_name":"pieces","unit_id":"248","short_name":"pcs","relation_unit_id":null,"relation_qty":"1","price":"300"}],"page_batch_id":"20260904_104359_8681"} 
[2026-09-04 10:47:39] live.INFO: === saveProductNewUnitRelationships START === {"product_id":336,"product_name":"ko 300ml"} 
[2026-09-04 10:47:39] live.INFO: Units data received {"units_data":[{"actual_name":"pieces","unit_id":"248","short_name":"pcs","relation_unit_id":null,"relation_qty":"1","price":"300"}],"count":1} 
[2026-09-04 10:47:39] live.INFO: Processing unit index: 0 {"unit_data":{"actual_name":"pieces","unit_id":"248","short_name":"pcs","relation_unit_id":null,"relation_qty":"1","price":"300"}} 
[2026-09-04 10:47:39] live.INFO: Unit found by ID {"unit_id":248,"actual_name":"pieces"} 
[2026-09-04 10:47:39] live.INFO: Unit lookup result {"found":"yes","unit_id":248,"method":"by_id"} 
[2026-09-04 10:47:39] live.INFO: Updating existing unit {"unit_id":248} 
[2026-09-04 10:47:39] live.INFO: Updated allow_decimal {"new_allow_decimal":1} 
[2026-09-04 10:47:39] live.INFO: Updated unit_price {"new_price":300.0} 
[2026-09-04 10:47:39] live.INFO: Unit updated successfully  
[2026-09-04 10:47:39] live.INFO: Setting as BASE unit {"unit_id":248} 
[2026-09-04 10:47:39] live.INFO: Base unit saved {"base_unit_id":248} 
[2026-09-04 10:47:39] live.INFO: First pass complete {"created_units_count":1,"base_unit_id":248} 
[2026-09-04 10:47:39] live.INFO: === SECOND PASS: Setting relations first ===  
[2026-09-04 10:47:39] live.INFO: === SECOND PASS: Calculating cumulative multipliers ===  
[2026-09-04 10:47:39] live.INFO: === saveProductNewUnitRelationships END ===  
[2026-09-04 10:47:40] live.INFO: OpeningStockController::add - Location Data {"product_id":"336","business_id":43,"locations":{"Illuminate\\Support\\Collection":{"39":"Greenfield Supermarket Ltd (BL0001)"}},"available_locations":[39]} 
[2026-09-04 10:47:40] live.INFO: OpeningStockController::add - Serial Numbers Check {"product_id":"336","business_id":43,"has_serial_numbers":{"39":false},"total_locations_with_serial":0} 
[2026-09-04 10:47:44] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:48:08] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:48:21] 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-04 10:48:21] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 10:48:21] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 10:48:21] live.DEBUG: Applying search filters {"search_term":"ko","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 10:48:21] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 10:48:21] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 10:48:21] live.INFO: filterProduct completed successfully {"result_count":3,"business_id":43,"search_term":"ko"} 
[2026-09-04 10:48:25] live.INFO: Product Row Debug - RELOADED {"product_id":336,"product_name":"ko 300ml","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":{"248":{"unit_id":248,"unit_name":"pieces","unit_price":300.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 10:48:32] 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-04 10:48:32] live.DEBUG: Payment Calculation {"final_total":300.0,"curr_total_payment":300.0,"is_credit_sale":false,"payment_count":1} 
[2026-09-04 10:48:32] live.INFO: Credit Limit Check Skipped - Fully Paid {"final_total":300.0,"curr_total_payment":300.0} 
[2026-09-04 10:48:32] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-04 10:48:32] live.INFO: is_mpesa_sale value: true  
[2026-09-04 10:48:32] 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":1794} 
[2026-09-04 10:48:32] live.INFO: Journal Entry Case: FULL CASH PAYMENT {"transaction_id":1794,"final_total":300.0,"amount_paid":300.0,"balance_due":0} 
[2026-09-04 10:48:32] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1794,"entries":[{"transaction_id":1794,"created_by_id":293,"transaction_number":"TRX-6a9a77d0d7c777.58143660","payment_detail_id":1281,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 10:48:32","updated_at":"2026-09-04 10:48:32","chart_of_account_id":15441,"debit":null,"credit":300.0},{"transaction_id":1794,"created_by_id":293,"transaction_number":"TRX-6a9a77d0d7c777.58143660","payment_detail_id":1281,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 10:48:32","updated_at":"2026-09-04 10:48:32","chart_of_account_id":15445,"debit":300.0,"credit":null}]} 
[2026-09-04 10:48:32] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1149,"purchase_line_id":1567,"quantity":1.0,"created_at":"2026-09-04 10:48:32","updated_at":"2026-09-04 10:48:32"}]} 
[2026-09-04 10:48:32] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-04 10:48:32] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":100.0} 
[2026-09-04 10:48:32] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 10:48:32] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1794  
[2026-09-04 10:48:49] 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-04 10:48:49] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 10:48:49] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 10:48:49] live.DEBUG: Applying search filters {"search_term":"ko","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 10:48:49] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 10:48:49] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 10:48:49] live.INFO: filterProduct completed successfully {"result_count":3,"business_id":43,"search_term":"ko"} 
[2026-09-04 10:48:51] live.INFO: Product Row Debug - RELOADED {"product_id":336,"product_name":"ko 300ml","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":{"248":{"unit_id":248,"unit_name":"pieces","unit_price":300.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 10:49:30] 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-04 10:49:30] live.DEBUG: Payment Calculation {"final_total":300.0,"curr_total_payment":300.0,"is_credit_sale":false,"payment_count":2} 
[2026-09-04 10:49:30] live.INFO: Credit Limit Check Skipped - Fully Paid {"final_total":300.0,"curr_total_payment":300.0} 
[2026-09-04 10:49:30] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-04 10:49:30] live.INFO: is_mpesa_sale value: true  
[2026-09-04 10:49:30] 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":1795} 
[2026-09-04 10:49:30] 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":1795} 
[2026-09-04 10:49:30] live.INFO: Journal Entry Case: PARTIAL PAYMENT {"transaction_id":1795,"final_total":300.0,"amount_paid":200.0,"balance_due":100.0} 
[2026-09-04 10:49:30] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1795,"entries":[{"transaction_id":1795,"created_by_id":293,"transaction_number":"TRX-6a9a780adbdc02.42343346","payment_detail_id":1282,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 10:49:30","updated_at":"2026-09-04 10:49:30","chart_of_account_id":15441,"debit":null,"credit":300.0},{"transaction_id":1795,"created_by_id":293,"transaction_number":"TRX-6a9a780adbdc02.42343346","payment_detail_id":1282,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 10:49:30","updated_at":"2026-09-04 10:49:30","chart_of_account_id":15445,"debit":200.0,"credit":null},{"transaction_id":1795,"created_by_id":293,"transaction_number":"TRX-6a9a780adbdc02.42343346","payment_detail_id":1282,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 10:49:30","updated_at":"2026-09-04 10:49:30","chart_of_account_id":15440,"debit":100.0,"credit":null}]} 
[2026-09-04 10:49:30] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1150,"purchase_line_id":1567,"quantity":1.0,"created_at":"2026-09-04 10:49:30","updated_at":"2026-09-04 10:49:30"}]} 
[2026-09-04 10:49:30] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-04 10:49:30] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":100.0} 
[2026-09-04 10:49:30] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 10:49:30] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1795  
[2026-09-04 10:49:59] 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-04 10:49:59] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 10:49:59] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 10:49:59] live.DEBUG: Applying search filters {"search_term":"ko","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 10:49:59] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 10:49:59] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 10:49:59] live.INFO: filterProduct completed successfully {"result_count":3,"business_id":43,"search_term":"ko"} 
[2026-09-04 10:50:00] live.INFO: Product Row Debug - RELOADED {"product_id":336,"product_name":"ko 300ml","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":{"248":{"unit_id":248,"unit_name":"pieces","unit_price":300.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 10:50:08] live.INFO: Credit Limit Check Started {"contact_id":"869","status":"final","final_total":"3000.00","is_credit_sale":"0","exclude_transaction_id":null} 
[2026-09-04 10:50:08] live.DEBUG: Payment Calculation {"final_total":3000.0,"curr_total_payment":0.0,"is_credit_sale":false,"payment_count":1} 
[2026-09-04 10:50:08] live.INFO: Credit Limit Check Skipped - No Credit Limit Set {"contact_id":"869","contact_name":"ken"} 
[2026-09-04 10:50:08] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-04 10:50:08] live.INFO: is_mpesa_sale value: true  
[2026-09-04 10:50:08] live.INFO: Journal Entry Case: FULL CREDIT SALE {"transaction_id":1796,"final_total":3000.0,"amount_paid":0.0,"balance_due":3000.0} 
[2026-09-04 10:50:08] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1796,"entries":[{"transaction_id":1796,"created_by_id":293,"transaction_number":"TRX-6a9a7830eaf3e8.35935670","payment_detail_id":1283,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 10:50:08","updated_at":"2026-09-04 10:50:08","chart_of_account_id":15441,"debit":null,"credit":3000.0},{"transaction_id":1796,"created_by_id":293,"transaction_number":"TRX-6a9a7830eaf3e8.35935670","payment_detail_id":1283,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 10:50:08","updated_at":"2026-09-04 10:50:08","chart_of_account_id":15440,"debit":3000.0,"credit":null}]} 
[2026-09-04 10:50:09] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1151,"purchase_line_id":1567,"quantity":10.0,"created_at":"2026-09-04 10:50:09","updated_at":"2026-09-04 10:50:09"}]} 
[2026-09-04 10:50:09] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-04 10:50:09] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":1000.0} 
[2026-09-04 10:50:09] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 10:50:09] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1796  
[2026-09-04 10:50:36] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:50:44] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:50:49] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:51:38] live.INFO: Purchases array from request {"purchases":[{"product_id":"336","variation_id":"341","quantity":"50","product_unit_id":"248","sub_unit_id":"248","pp_without_discount":"200.00","discount_percent":"0.00","purchase_price":"200.00","purchase_line_tax_id":"9","item_tax":"32.00","purchase_price_inc_tax":"232.00","profit_percent":"29.31","default_sell_price":"300.00","mfg_date":null,"exp_date":null,"imei_numbers":"[]","imei_count":"0"}],"purchases_json":"[{\"product_id\":\"336\",\"variation_id\":\"341\",\"quantity\":\"50\",\"product_unit_id\":\"248\",\"sub_unit_id\":\"248\",\"pp_without_discount\":\"200.00\",\"discount_percent\":\"0.00\",\"purchase_price\":\"200.00\",\"purchase_line_tax_id\":\"9\",\"item_tax\":\"32.00\",\"purchase_price_inc_tax\":\"232.00\",\"profit_percent\":\"29.31\",\"default_sell_price\":\"300.00\",\"mfg_date\":null,\"exp_date\":null,\"imei_numbers\":\"[]\",\"imei_count\":\"0\"}]"} 
[2026-09-04 10:51:38] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 10:51:38] live.INFO: Purchase lines created {"transaction_id":1797,"purchase_lines_count":1,"purchase_lines":[{"id":1568,"transaction_id":1797,"product_id":336,"variation_id":341,"quantity":50.0,"secondary_unit_quantity":"0.0000","pp_without_discount":"200.0000","discount_percent":"0.00","purchase_price":"200.0000","purchase_price_inc_tax":"232.0000","item_tax":"32.0000","tax_id":9,"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-04T07:51:38.000000Z","updated_at":"2026-09-04T07:51:38.000000Z"}]} 
[2026-09-04 10:51:38] live.INFO: Processing purchase row - 0 {"row_index":0,"product_id":"336","variation_id":"341","quantity":"50","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-04 10:51:38] live.INFO: IMEI Data - Parsed for row 0 {"row_index":0,"imei_count":0,"imei_data":[],"imei_json":"[]"} 
[2026-09-04 10:51:38] live.INFO: IMEI data is empty or invalid for row 0 {"imeiData":[]} 
[2026-09-04 10:51:38] 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":1797} 
[2026-09-04 10:51:38] live.INFO: Purchase created successfully with IMEI data {"transaction_id":1797,"ref_no":"PO2026/0013","final_total":11600.0} 
[2026-09-04 10:51:42] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:51:55] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:52:06] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:52:42] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:53:04] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:53:27] 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":1798} 
[2026-09-04 10:53:32] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:54:10] 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-04 10:54:10] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 10:54:10] 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-04 10:54: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) <= '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-04 10:54:10] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"2676190.08000000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 10:54:10] 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-04 10:54:10] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 10:54: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-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-04 10:54:10] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6707493.43600000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 10:54:11] 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-04 10:54:11] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 10:54:11] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 10:54:11] 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-04 10:54:11] 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-04 10:54:11] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"4051800.00000000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 10:54:11] 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-04 10:54:11] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 10:54:11] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 10:54:11] 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-04 10:54:11] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6363170.00000000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 10:54:12] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:54:21] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 10:54:21] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 10:54:21] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 10:54: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-03') ) * (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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 10:54:21] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5998697.40800000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 10:54:21] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 10:54:21] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 10:54: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-04') ) * (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-04'","bindings":["purchase_order",43]} 
[2026-09-04 10:54:21] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6707493.43600000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 10:54:21] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 10:54:21] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 10:54:21] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 10:54:21] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 10:54: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-03') ) * 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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 10:54:21] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6351820.00000000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 10:54:21] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 10:54:21] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 10:54:21] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 10:54: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-04') ) * 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-04'","bindings":["purchase_order",43]} 
[2026-09-04 10:54:21] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6363170.00000000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 10:55:39] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-08-05","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 10:55:39] live.INFO: Opening stock calculation - including all transactions {"date":"2026-08-05"} 
[2026-09-04 10:55:39] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-08-05')"} 
[2026-09-04 10:55:39] 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-08-05') ) * (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-08-05'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 10:55:39] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5998697.40800000","is_opening":true,"date":"2026-08-05"} 
[2026-09-04 10:55:39] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 10:55:39] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 10:55:39] 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-04') ) * (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-04'","bindings":["purchase_order",43]} 
[2026-09-04 10:55:39] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6707493.43600000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 10:55:40] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-08-05","location_id":null,"is_opening":true,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 10:55:40] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 10:55:40] live.INFO: Opening stock calculation - including all transactions {"date":"2026-08-05"} 
[2026-09-04 10:55:40] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-08-05')"} 
[2026-09-04 10:55:40] 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-08-05') ) * 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-08-05'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 10:55:40] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6351820.00000000","is_opening":true,"date":"2026-08-05"} 
[2026-09-04 10:55:40] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 10:55:40] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 10:55:40] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 10:55:40] 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-04') ) * 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-04'","bindings":["purchase_order",43]} 
[2026-09-04 10:55:40] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6363170.00000000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 10:55:46] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-07-31","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 10:55:46] live.INFO: Opening stock calculation - including all transactions {"date":"2026-07-31"} 
[2026-09-04 10:55:46] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-07-31')"} 
[2026-09-04 10:55:46] 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-07-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) <= '2026-07-31'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 10:55:46] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5885697.07840000","is_opening":true,"date":"2026-07-31"} 
[2026-09-04 10:55:46] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-08-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 10:55:46] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-08-31' (includes all types except purchase_order)"} 
[2026-09-04 10:55:46] 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-08-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-08-31'","bindings":["purchase_order",43]} 
[2026-09-04 10:55:46] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5993257.40800000","is_opening":false,"date":"2026-08-31"} 
[2026-09-04 10:55:47] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-07-31","location_id":null,"is_opening":true,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 10:55:47] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 10:55:47] live.INFO: Opening stock calculation - including all transactions {"date":"2026-07-31"} 
[2026-09-04 10:55:47] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-07-31')"} 
[2026-09-04 10:55:47] 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-07-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) <= '2026-07-31'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 10:55:47] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6355420.00000000","is_opening":true,"date":"2026-07-31"} 
[2026-09-04 10:55:47] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-08-31","location_id":null,"is_opening":false,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 10:55:47] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 10:55:47] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-08-31' (includes all types except purchase_order)"} 
[2026-09-04 10:55:47] 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-08-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-08-31'","bindings":["purchase_order",43]} 
[2026-09-04 10:55:47] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6343820.00000000","is_opening":false,"date":"2026-08-31"} 
[2026-09-04 10:56:02] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2025-08-31","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 10:56:02] live.INFO: Opening stock calculation - including all transactions {"date":"2025-08-31"} 
[2026-09-04 10:56:02] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2025-08-31')"} 
[2026-09-04 10:56:02] 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-08-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-08-31'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 10:56:02] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"2676190.08000000","is_opening":true,"date":"2025-08-31"} 
[2026-09-04 10:56:02] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2025-09-30","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 10:56:02] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2025-09-30' (includes all types except purchase_order)"} 
[2026-09-04 10:56:02] 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-09-30') ) * (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) <= '2025-09-30'","bindings":["purchase_order",43]} 
[2026-09-04 10:56:02] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":0,"is_opening":false,"date":"2025-09-30"} 
[2026-09-04 10:56:02] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2025-08-31","location_id":null,"is_opening":true,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 10:56:02] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 10:56:02] live.INFO: Opening stock calculation - including all transactions {"date":"2025-08-31"} 
[2026-09-04 10:56:02] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2025-08-31')"} 
[2026-09-04 10:56:02] 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-08-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-08-31'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 10:56:02] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"4051800.00000000","is_opening":true,"date":"2025-08-31"} 
[2026-09-04 10:56:02] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2025-09-30","location_id":null,"is_opening":false,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 10:56:02] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 10:56:02] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2025-09-30' (includes all types except purchase_order)"} 
[2026-09-04 10:56:02] 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-09-30') ) * 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) <= '2025-09-30'","bindings":["purchase_order",43]} 
[2026-09-04 10:56:02] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":0,"is_opening":false,"date":"2025-09-30"} 
[2026-09-04 10:56:09] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 10:56:09] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 10:56:09] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 10:56: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-03') ) * (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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 10:56:09] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5998697.40800000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 10:56:09] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 10:56:09] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 10:56: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-04') ) * (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-04'","bindings":["purchase_order",43]} 
[2026-09-04 10:56:09] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6707493.43600000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 10:56:10] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 10:56:10] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 10:56:10] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 10:56:10] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 10:56: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-03') ) * 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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 10:56:10] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6351820.00000000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 10:56:10] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 10:56:10] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 10:56:10] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 10:56: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-04') ) * 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-04'","bindings":["purchase_order",43]} 
[2026-09-04 10:56:10] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6363170.00000000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 10:57:19] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:57:40] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:58:30] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:58:44] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:59:45] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 10:59:54] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 11:00:00] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 11:00:34] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 11:00:50] live.ERROR: Failed to send error alert email: Failed to authenticate on SMTP server with username "support@risetsystems.com" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".".  
[2026-09-04 11:00:51] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 11:02:31] live.INFO: Digitax upload skipped: No tax number provided {"contact_id":870,"contact_name":"zip mart","contact_type":"customer"} 
[2026-09-04 11:02:35] 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-04 11:02:35] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 11:02:35] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 11:02:35] live.DEBUG: Applying search filters {"search_term":"ko","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 11:02:35] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 11:02:35] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 11:02:35] live.INFO: filterProduct completed successfully {"result_count":3,"business_id":43,"search_term":"ko"} 
[2026-09-04 11:02:37] live.INFO: Product Row Debug - RELOADED {"product_id":234,"product_name":"soko maize flour 1kg","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":100.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"50":{"unit_id":50,"unit_name":"pkt-24","unit_price":null,"multiplier":1,"has_price":false}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 11:02:50] 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-04 11:02:50] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 11:02:50] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 11:02:50] live.DEBUG: Applying search filters {"search_term":"ko","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 11:02:50] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 11:02:50] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 11:02:50] live.INFO: filterProduct completed successfully {"result_count":3,"business_id":43,"search_term":"ko"} 
[2026-09-04 11:02:53] live.INFO: Product Row Debug - RELOADED {"product_id":336,"product_name":"ko 300ml","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":{"248":{"unit_id":248,"unit_name":"pieces","unit_price":300.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 11:03:06] live.INFO: Credit Limit Check Started {"contact_id":"870","status":"final","final_total":"900.00","is_credit_sale":"0","exclude_transaction_id":null} 
[2026-09-04 11:03:06] live.DEBUG: Payment Calculation {"final_total":900.0,"curr_total_payment":0.0,"is_credit_sale":false,"payment_count":1} 
[2026-09-04 11:03:06] live.INFO: Credit Limit Check Skipped - No Credit Limit Set {"contact_id":"870","contact_name":"zip mart"} 
[2026-09-04 11:03:06] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-04 11:03:06] live.INFO: is_mpesa_sale value: true  
[2026-09-04 11:03:06] live.INFO: Journal Entry Case: FULL CREDIT SALE {"transaction_id":1799,"final_total":900.0,"amount_paid":0.0,"balance_due":900.0} 
[2026-09-04 11:03:06] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1799,"entries":[{"transaction_id":1799,"created_by_id":293,"transaction_number":"TRX-6a9a7b3a9004b7.86700647","payment_detail_id":1287,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 11:03:06","updated_at":"2026-09-04 11:03:06","chart_of_account_id":15441,"debit":null,"credit":900.0},{"transaction_id":1799,"created_by_id":293,"transaction_number":"TRX-6a9a7b3a9004b7.86700647","payment_detail_id":1287,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 11:03:06","updated_at":"2026-09-04 11:03:06","chart_of_account_id":15440,"debit":900.0,"credit":null}]} 
[2026-09-04 11:03:06] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1152,"purchase_line_id":1567,"quantity":3.0,"created_at":"2026-09-04 11:03:06","updated_at":"2026-09-04 11:03:06"}]} 
[2026-09-04 11:03:06] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-04 11:03:06] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":300.0} 
[2026-09-04 11:03:06] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 11:03:06] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1799  
[2026-09-04 11:03:21] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 11:04:13] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 11:04:13] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 11:04:13] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 11:04:13] 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-03') ) * (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-03'))","bindings":["purchase_order",8,"opening_stock","opening_stock"]} 
[2026-09-04 11:04:13] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 11:04:13] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 11:04:13] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 11:04:13] 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-04') ) * (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-04'","bindings":["purchase_order",8]} 
[2026-09-04 11:04:13] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 11:05:38] live.INFO: filterProduct method called {"business_id":8,"search_term":"tu","location_id":"9","not_for_selling":"0","price_group_id":"0","product_types":[],"search_fields":["name","sku","lot"],"check_qty":false,"search_type":"like"} 
[2026-09-04 11:05:38] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 11:05:38] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 11:05:38] live.DEBUG: Joining purchase_lines for lot number search  
[2026-09-04 11:05:38] live.DEBUG: Applying search filters {"search_term":"tu","search_type":"like","search_fields":["name","sku","lot"]} 
[2026-09-04 11:05:38] live.DEBUG: LIKE search conditions applied {"fields":["name","sku","lot"]} 
[2026-09-04 11:05:38] live.DEBUG: Applying location filter {"location_id":"9"} 
[2026-09-04 11:05:38] live.DEBUG: Added lot number fields to select  
[2026-09-04 11:05:38] live.INFO: filterProduct completed successfully {"result_count":2,"business_id":8,"search_term":"tu"} 
[2026-09-04 11:05:40] live.INFO: Product Row Debug - RELOADED {"product_id":334,"product_name":"tusker can 330ml","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":200.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"245":{"unit_id":245,"unit_name":"pcs","unit_price":200.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 11:05:44] live.ERROR: Failed to send error alert email: Failed to authenticate on SMTP server with username "support@risetsystems.com" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".".  
[2026-09-04 11:07:33] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:07:33] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 11:07:33] 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-04 11:07:33] 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",8,"opening_stock","opening_stock"]} 
[2026-09-04 11:07:33] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"58869373.22080000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 11:07:33] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-12-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:07:33] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:07:33] 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",8]} 
[2026-09-04 11:07:33] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 11:07:33] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":null,"is_opening":true,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 11:07:33] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 11:07:33] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 11:07:33] 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-04 11:07:33] 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",8,"opening_stock","opening_stock"]} 
[2026-09-04 11:07:33] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"79279760.00000000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 11:07:33] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-12-31","location_id":null,"is_opening":false,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 11:07:33] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 11:07:33] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:07:33] 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",8]} 
[2026-09-04 11:07:33] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"149116033.00000000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 11:10:35] live.INFO: Calculating receivables listing from: 2026-09-04 to: 2026-09-04  
[2026-09-04 11:10:35] live.INFO: Calculating payables listing from: 2026-09-04 to: 2026-09-04  
[2026-09-04 11:10:58] live.INFO: Calculating receivables listing from: 2026-01-01 to: 2026-09-04  
[2026-09-04 11:10:58] live.INFO: Calculating payables listing from: 2026-01-01 to: 2026-09-04  
[2026-09-04 11:11:02] live.INFO: Calculating receivables listing from: 2026-01-01 to: 2026-09-04  
[2026-09-04 11:11:19] live.INFO: Calculating payables listing from: 2026-01-01 to: 2026-09-04  
[2026-09-04 11:12:04] live.ERROR: Failed to send error alert email: Failed to authenticate on SMTP server with username "support@risetsystems.com" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 Incorrect authentication data".".  
[2026-09-04 11:14:25] live.INFO: === BALANCE SHEET REQUEST ===  
[2026-09-04 11:14:25] live.INFO: Business ID: 8  
[2026-09-04 11:14:25] live.INFO: Fiscal Year: 2026  
[2026-09-04 11:14:25] live.INFO: As Of Date: 2026-12-31  
[2026-09-04 11:14:25] live.INFO: Location ID: All  
[2026-09-04 11:14:25] live.INFO: --- Starting getBalanceSheetData ---  
[2026-09-04 11:14:25] live.INFO: Permitted locations: all  
[2026-09-04 11:14:25] live.INFO: Fiscal Year: 2026  
[2026-09-04 11:14:25] live.INFO: Fiscal Year Start: 2026-01-01  
[2026-09-04 11:14:25] live.INFO: As Of Date: 2026-12-31  
[2026-09-04 11:14:25] live.INFO: --- Getting Non-Current Assets ---  
[2026-09-04 11:14:25] live.INFO: Querying assets table for business_id: 8 with purchase_date <= 2026-12-31  
[2026-09-04 11:14:25] live.INFO: Found 1 assets purchased on or before 2026-12-31  
[2026-09-04 11:14:25] live.INFO: Asset: Machine A - Purchase Date: 2026-07-01, Purchase Cost: 800000  
[2026-09-04 11:14:25] live.INFO: Added to non-current assets: Machine A - Value: 800000  
[2026-09-04 11:14:25] live.INFO: Non-Current Assets Count: 1  
[2026-09-04 11:14:25] live.INFO: Non-Current Assets Total: 800000  
[2026-09-04 11:14:25] live.INFO: --- Getting Current Assets ---  
[2026-09-04 11:14:25] live.INFO: --- Getting Method Balances ---  
[2026-09-04 11:14:25] live.INFO: Getting method balances up to date: 2026-12-31 (converted to: 2026-12-31)  
[2026-09-04 11:14:25] live.INFO: Found 348 payment records  
[2026-09-04 11:14:25] live.INFO: Method Balances:  {"Cash":-35687201.0,"Paybill Saf":194090.0,"Mpesa Till":24136.0,"Paybill Equity":248837.0,"Bank transfer":-19488553.0,"Card":5.0,"Jambo Pay":20334.0,"Pochi La Biashara":8052.0,"card":20061.0,"Mpesa Agent":53.0} 
[2026-09-04 11:14:25] live.INFO: Added Liability - Cash Overdraft: 35687201  
[2026-09-04 11:14:25] live.INFO: Added Current Asset - Method: Paybill Saf, Balance: 194090  
[2026-09-04 11:14:25] live.INFO: Added Current Asset - Method: Mpesa Till, Balance: 24136  
[2026-09-04 11:14:25] live.INFO: Added Current Asset - Method: Paybill Equity, Balance: 248837  
[2026-09-04 11:14:25] live.INFO: Added Liability - Bank transfer Overdraft: 19488553  
[2026-09-04 11:14:25] live.INFO: Added Current Asset - Method: Card, Balance: 5  
[2026-09-04 11:14:25] live.INFO: Added Current Asset - Method: Jambo Pay, Balance: 20334  
[2026-09-04 11:14:25] live.INFO: Added Current Asset - Method: Pochi La Biashara, Balance: 8052  
[2026-09-04 11:14:25] live.INFO: Added Current Asset - Method: card, Balance: 20061  
[2026-09-04 11:14:25] live.INFO: Added Current Asset - Method: Mpesa Agent, Balance: 53  
[2026-09-04 11:14:25] live.INFO: --- Getting Receivables ---  
[2026-09-04 11:14:25] live.INFO: Calculating receivables up to date: 2026-12-31  
[2026-09-04 11:14:25] live.INFO: Total Receivables: 5138387.0000  
[2026-09-04 11:14:25] live.INFO: Accounts Receivable: 5138387  
[2026-09-04 11:14:25] live.INFO: --- Getting Inventory Closing Stock Value as of 2026-12-31 ---  
[2026-09-04 11:14:25] live.INFO: Calculating closing stock value as of: 2026-12-31  
[2026-09-04 11:14:25] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-12-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":[],"permitted_locations":"all"} 
[2026-09-04 11:14:25] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:14:25] 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",8]} 
[2026-09-04 11:14:25] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 11:14:25] live.INFO: Closing Stock Value (by purchase price): 147624925.83960000  
[2026-09-04 11:14:25] live.INFO: Inventory Closing Stock Value: 147624925.8396  
[2026-09-04 11:14:25] live.INFO: --- Getting Opening Stock Equity as of 2026-01-01 ---  
[2026-09-04 11:14:25] live.INFO: Calculating opening stock value as of: 2026-01-01  
[2026-09-04 11:14:25] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":[],"permitted_locations":"all"} 
[2026-09-04 11:14:25] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2025-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:14:25] 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 date(transaction_date) <= '2025-12-31'","bindings":["purchase_order",8]} 
[2026-09-04 11:14:25] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":0,"is_opening":false,"date":"2025-12-31"} 
[2026-09-04 11:14:25] live.INFO: Opening Stock Value (as of 2025-12-31): 0  
[2026-09-04 11:14:25] live.INFO: Opening Stock Equity: 0  
[2026-09-04 11:14:25] live.INFO: --- Getting Profit/Loss Details from TransactionUtil for Period ---  
[2026-09-04 11:14:25] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:14:25] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 11:14:25] 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-04 11:14:25] 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",8,"opening_stock","opening_stock"]} 
[2026-09-04 11:14:25] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"58869373.22080000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 11:14:25] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-12-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:14:25] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:14:25] 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",8]} 
[2026-09-04 11:14:25] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 11:14:25] live.INFO: Net Profit for Period 2026-01-01 to 2026-12-31: 3485343.18  
[2026-09-04 11:14:25] live.INFO: Added to Equity - Retained Earnings: 3485343.18  
[2026-09-04 11:14:25] live.INFO: --- Getting Payables ---  
[2026-09-04 11:14:25] live.INFO: Calculating payables up to date: 2026-12-31  
[2026-09-04 11:14:25] live.INFO: Total Payables: 2617835.7700  
[2026-09-04 11:14:25] live.INFO: Accounts Payable: 2617835.77  
[2026-09-04 11:14:25] live.INFO: === FINAL TOTALS ===  
[2026-09-04 11:14:25] live.INFO: Total Non-Current Assets: 800000  
[2026-09-04 11:14:25] live.INFO: Total Current Assets: 153278880.8396  
[2026-09-04 11:14:25] live.INFO: Total Assets: 154078880.8396  
[2026-09-04 11:14:25] live.INFO: Total Equity: 3485343.18  
[2026-09-04 11:14:25] live.INFO: Total Liabilities: 57793589.77  
[2026-09-04 11:14:25] live.INFO: Total Equity + Liabilities: 61278932.95  
[2026-09-04 11:14:25] live.INFO: Difference: 92799947.8896  
[2026-09-04 11:14:25] live.INFO: Is Balanced: No  
[2026-09-04 11:14:25] live.INFO: === BALANCE SHEET RESPONSE ===  
[2026-09-04 11:14:25] live.INFO: Total Assets: 154078880.8396  
[2026-09-04 11:14:25] live.INFO: Total Equity: 3485343.18  
[2026-09-04 11:14:25] live.INFO: Total Liabilities: 57793589.77  
[2026-09-04 11:14:25] live.INFO: Is Balanced: No  
[2026-09-04 11:14:31] live.INFO: === BALANCE SHEET REQUEST ===  
[2026-09-04 11:14:31] live.INFO: Business ID: 8  
[2026-09-04 11:14:31] live.INFO: Fiscal Year: 2026  
[2026-09-04 11:14:31] live.INFO: As Of Date: 2026-09-04  
[2026-09-04 11:14:31] live.INFO: Location ID: All  
[2026-09-04 11:14:31] live.INFO: --- Starting getBalanceSheetData ---  
[2026-09-04 11:14:31] live.INFO: Permitted locations: all  
[2026-09-04 11:14:31] live.INFO: Fiscal Year: 2026  
[2026-09-04 11:14:31] live.INFO: Fiscal Year Start: 2026-01-01  
[2026-09-04 11:14:31] live.INFO: As Of Date: 2026-09-04  
[2026-09-04 11:14:31] live.INFO: --- Getting Non-Current Assets ---  
[2026-09-04 11:14:31] live.INFO: Querying assets table for business_id: 8 with purchase_date <= 2026-09-04  
[2026-09-04 11:14:31] live.INFO: Found 1 assets purchased on or before 2026-09-04  
[2026-09-04 11:14:31] live.INFO: Asset: Machine A - Purchase Date: 2026-07-01, Purchase Cost: 800000  
[2026-09-04 11:14:31] live.INFO: Added to non-current assets: Machine A - Value: 800000  
[2026-09-04 11:14:31] live.INFO: Non-Current Assets Count: 1  
[2026-09-04 11:14:31] live.INFO: Non-Current Assets Total: 800000  
[2026-09-04 11:14:31] live.INFO: --- Getting Current Assets ---  
[2026-09-04 11:14:31] live.INFO: --- Getting Method Balances ---  
[2026-09-04 11:14:31] live.INFO: Getting method balances up to date: 2026-09-04 (converted to: 2026-09-04)  
[2026-09-04 11:14:31] live.INFO: Found 348 payment records  
[2026-09-04 11:14:31] live.INFO: Method Balances:  {"Cash":-35687201.0,"Paybill Saf":194090.0,"Mpesa Till":24136.0,"Paybill Equity":248837.0,"Bank transfer":-19488553.0,"Card":5.0,"Jambo Pay":20334.0,"Pochi La Biashara":8052.0,"card":20061.0,"Mpesa Agent":53.0} 
[2026-09-04 11:14:31] live.INFO: Added Liability - Cash Overdraft: 35687201  
[2026-09-04 11:14:31] live.INFO: Added Current Asset - Method: Paybill Saf, Balance: 194090  
[2026-09-04 11:14:31] live.INFO: Added Current Asset - Method: Mpesa Till, Balance: 24136  
[2026-09-04 11:14:31] live.INFO: Added Current Asset - Method: Paybill Equity, Balance: 248837  
[2026-09-04 11:14:31] live.INFO: Added Liability - Bank transfer Overdraft: 19488553  
[2026-09-04 11:14:31] live.INFO: Added Current Asset - Method: Card, Balance: 5  
[2026-09-04 11:14:31] live.INFO: Added Current Asset - Method: Jambo Pay, Balance: 20334  
[2026-09-04 11:14:31] live.INFO: Added Current Asset - Method: Pochi La Biashara, Balance: 8052  
[2026-09-04 11:14:31] live.INFO: Added Current Asset - Method: card, Balance: 20061  
[2026-09-04 11:14:31] live.INFO: Added Current Asset - Method: Mpesa Agent, Balance: 53  
[2026-09-04 11:14:31] live.INFO: --- Getting Receivables ---  
[2026-09-04 11:14:31] live.INFO: Calculating receivables up to date: 2026-09-04  
[2026-09-04 11:14:31] live.INFO: Total Receivables: 5138387.0000  
[2026-09-04 11:14:31] live.INFO: Accounts Receivable: 5138387  
[2026-09-04 11:14:31] live.INFO: --- Getting Inventory Closing Stock Value as of 2026-09-04 ---  
[2026-09-04 11:14:31] live.INFO: Calculating closing stock value as of: 2026-09-04  
[2026-09-04 11:14:31] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":[],"permitted_locations":"all"} 
[2026-09-04 11:14:31] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 11:14:31] 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-04') ) * (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-04'","bindings":["purchase_order",8]} 
[2026-09-04 11:14:31] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 11:14:31] live.INFO: Closing Stock Value (by purchase price): 147624925.83960000  
[2026-09-04 11:14:31] live.INFO: Inventory Closing Stock Value: 147624925.8396  
[2026-09-04 11:14:31] live.INFO: --- Getting Opening Stock Equity as of 2026-01-01 ---  
[2026-09-04 11:14:31] live.INFO: Calculating opening stock value as of: 2026-01-01  
[2026-09-04 11:14:31] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":[],"permitted_locations":"all"} 
[2026-09-04 11:14:31] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2025-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:14:31] 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 date(transaction_date) <= '2025-12-31'","bindings":["purchase_order",8]} 
[2026-09-04 11:14:31] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":0,"is_opening":false,"date":"2025-12-31"} 
[2026-09-04 11:14:31] live.INFO: Opening Stock Value (as of 2025-12-31): 0  
[2026-09-04 11:14:31] live.INFO: Opening Stock Equity: 0  
[2026-09-04 11:14:31] live.INFO: --- Getting Profit/Loss Details from TransactionUtil for Period ---  
[2026-09-04 11:14:31] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:14:31] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 11:14:31] 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-04 11:14:31] 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",8,"opening_stock","opening_stock"]} 
[2026-09-04 11:14:31] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"58869373.22080000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 11:14:31] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:14:31] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 11:14:31] 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-04') ) * (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-04'","bindings":["purchase_order",8]} 
[2026-09-04 11:14:31] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 11:14:31] live.INFO: Net Profit for Period 2026-01-01 to 2026-09-04: 3485343.18  
[2026-09-04 11:14:31] live.INFO: Added to Equity - Retained Earnings: 3485343.18  
[2026-09-04 11:14:31] live.INFO: --- Getting Payables ---  
[2026-09-04 11:14:31] live.INFO: Calculating payables up to date: 2026-09-04  
[2026-09-04 11:14:31] live.INFO: Total Payables: 2617835.7700  
[2026-09-04 11:14:31] live.INFO: Accounts Payable: 2617835.77  
[2026-09-04 11:14:31] live.INFO: === FINAL TOTALS ===  
[2026-09-04 11:14:31] live.INFO: Total Non-Current Assets: 800000  
[2026-09-04 11:14:31] live.INFO: Total Current Assets: 153278880.8396  
[2026-09-04 11:14:31] live.INFO: Total Assets: 154078880.8396  
[2026-09-04 11:14:31] live.INFO: Total Equity: 3485343.18  
[2026-09-04 11:14:31] live.INFO: Total Liabilities: 57793589.77  
[2026-09-04 11:14:31] live.INFO: Total Equity + Liabilities: 61278932.95  
[2026-09-04 11:14:31] live.INFO: Difference: 92799947.8896  
[2026-09-04 11:14:31] live.INFO: Is Balanced: No  
[2026-09-04 11:14:31] live.INFO: === BALANCE SHEET RESPONSE ===  
[2026-09-04 11:14:31] live.INFO: Total Assets: 154078880.8396  
[2026-09-04 11:14:31] live.INFO: Total Equity: 3485343.18  
[2026-09-04 11:14:31] live.INFO: Total Liabilities: 57793589.77  
[2026-09-04 11:14:31] live.INFO: Is Balanced: No  
[2026-09-04 11:14:48] live.INFO: === BALANCE SHEET REQUEST ===  
[2026-09-04 11:14:48] live.INFO: Business ID: 8  
[2026-09-04 11:14:48] live.INFO: Fiscal Year: 2026  
[2026-09-04 11:14:48] live.INFO: As Of Date: 2026-09-04  
[2026-09-04 11:14:48] live.INFO: Location ID: 9  
[2026-09-04 11:14:48] live.INFO: --- Starting getBalanceSheetData ---  
[2026-09-04 11:14:48] live.INFO: Permitted locations: all  
[2026-09-04 11:14:48] live.INFO: Fiscal Year: 2026  
[2026-09-04 11:14:48] live.INFO: Fiscal Year Start: 2026-01-01  
[2026-09-04 11:14:48] live.INFO: As Of Date: 2026-09-04  
[2026-09-04 11:14:48] live.INFO: --- Getting Non-Current Assets ---  
[2026-09-04 11:14:48] live.INFO: Querying assets table for business_id: 8 with purchase_date <= 2026-09-04  
[2026-09-04 11:14:48] live.INFO: Filtering assets by location_id: 9  
[2026-09-04 11:14:48] live.INFO: Found 1 assets purchased on or before 2026-09-04  
[2026-09-04 11:14:48] live.INFO: Asset: Machine A - Purchase Date: 2026-07-01, Purchase Cost: 800000  
[2026-09-04 11:14:48] live.INFO: Added to non-current assets: Machine A - Value: 800000  
[2026-09-04 11:14:48] live.INFO: Non-Current Assets Count: 1  
[2026-09-04 11:14:48] live.INFO: Non-Current Assets Total: 800000  
[2026-09-04 11:14:48] live.INFO: --- Getting Current Assets ---  
[2026-09-04 11:14:48] live.INFO: --- Getting Method Balances ---  
[2026-09-04 11:14:48] live.INFO: Getting method balances up to date: 2026-09-04 (converted to: 2026-09-04)  
[2026-09-04 11:14:48] live.INFO: Found 344 payment records  
[2026-09-04 11:14:48] live.INFO: Method Balances:  {"Cash":-35767276.0,"Paybill Saf":114090.0,"Mpesa Till":24136.0,"Paybill Equity":248837.0,"Bank transfer":-20038553.0,"Card":5.0,"Jambo Pay":20334.0,"Pochi La Biashara":8052.0,"card":20061.0,"Mpesa Agent":53.0} 
[2026-09-04 11:14:48] live.INFO: Added Liability - Cash Overdraft: 35767276  
[2026-09-04 11:14:48] live.INFO: Added Current Asset - Method: Paybill Saf, Balance: 114090  
[2026-09-04 11:14:48] live.INFO: Added Current Asset - Method: Mpesa Till, Balance: 24136  
[2026-09-04 11:14:48] live.INFO: Added Current Asset - Method: Paybill Equity, Balance: 248837  
[2026-09-04 11:14:48] live.INFO: Added Liability - Bank transfer Overdraft: 20038553  
[2026-09-04 11:14:48] live.INFO: Added Current Asset - Method: Card, Balance: 5  
[2026-09-04 11:14:48] live.INFO: Added Current Asset - Method: Jambo Pay, Balance: 20334  
[2026-09-04 11:14:48] live.INFO: Added Current Asset - Method: Pochi La Biashara, Balance: 8052  
[2026-09-04 11:14:48] live.INFO: Added Current Asset - Method: card, Balance: 20061  
[2026-09-04 11:14:48] live.INFO: Added Current Asset - Method: Mpesa Agent, Balance: 53  
[2026-09-04 11:14:48] live.INFO: --- Getting Receivables ---  
[2026-09-04 11:14:48] live.INFO: Calculating receivables up to date: 2026-09-04  
[2026-09-04 11:14:48] live.INFO: Total Receivables: 5138387.0000  
[2026-09-04 11:14:48] live.INFO: Accounts Receivable: 5138387  
[2026-09-04 11:14:48] live.INFO: --- Getting Inventory Closing Stock Value as of 2026-09-04 ---  
[2026-09-04 11:14:48] live.INFO: Calculating closing stock value as of: 2026-09-04  
[2026-09-04 11:14:48] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-09-04","location_id":"9","is_opening":false,"by_sale_price":false,"filters":[],"permitted_locations":"all"} 
[2026-09-04 11:14:48] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 11:14:48] live.DEBUG: Applied location filter {"location_id":"9"} 
[2026-09-04 11:14:48] 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-04') ) * (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-04' and `purchase`.`location_id` = ?","bindings":["purchase_order",8,"9"]} 
[2026-09-04 11:14:48] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"145066829.03960000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 11:14:48] live.INFO: Closing Stock Value (by purchase price): 145066829.03960000  
[2026-09-04 11:14:48] live.INFO: Inventory Closing Stock Value: 145066829.0396  
[2026-09-04 11:14:48] live.INFO: --- Getting Opening Stock Equity as of 2026-01-01 ---  
[2026-09-04 11:14:48] live.INFO: Calculating opening stock value as of: 2026-01-01  
[2026-09-04 11:14:48] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":"9","is_opening":false,"by_sale_price":false,"filters":[],"permitted_locations":"all"} 
[2026-09-04 11:14:48] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2025-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:14:48] live.DEBUG: Applied location filter {"location_id":"9"} 
[2026-09-04 11:14:48] 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 date(transaction_date) <= '2025-12-31' and `purchase`.`location_id` = ?","bindings":["purchase_order",8,"9"]} 
[2026-09-04 11:14:48] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":0,"is_opening":false,"date":"2025-12-31"} 
[2026-09-04 11:14:48] live.INFO: Opening Stock Value (as of 2025-12-31): 0  
[2026-09-04 11:14:48] live.INFO: Opening Stock Equity: 0  
[2026-09-04 11:14:48] live.INFO: --- Getting Profit/Loss Details from TransactionUtil for Period ---  
[2026-09-04 11:14:48] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":"9","is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:14:48] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 11:14:48] 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-04 11:14:48] live.DEBUG: Applied location filter {"location_id":"9"} 
[2026-09-04 11:14:48] 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')) and `purchase`.`location_id` = ?","bindings":["purchase_order",8,"opening_stock","opening_stock","9"]} 
[2026-09-04 11:14:48] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"57084566.42080000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 11:14:48] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-09-04","location_id":"9","is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:14:48] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 11:14:48] live.DEBUG: Applied location filter {"location_id":"9"} 
[2026-09-04 11:14:48] 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-04') ) * (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-04' and `purchase`.`location_id` = ?","bindings":["purchase_order",8,"9"]} 
[2026-09-04 11:14:48] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"145066829.03960000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 11:14:48] live.INFO: Net Profit for Period 2026-01-01 to 2026-09-04: 3589356.18  
[2026-09-04 11:14:48] live.INFO: Added to Equity - Retained Earnings: 3589356.18  
[2026-09-04 11:14:48] live.INFO: --- Getting Payables ---  
[2026-09-04 11:14:48] live.INFO: Calculating payables up to date: 2026-09-04  
[2026-09-04 11:14:48] live.INFO: Total Payables: 2477780.7700  
[2026-09-04 11:14:48] live.INFO: Accounts Payable: 2477780.77  
[2026-09-04 11:14:48] live.INFO: === FINAL TOTALS ===  
[2026-09-04 11:14:48] live.INFO: Total Non-Current Assets: 800000  
[2026-09-04 11:14:48] live.INFO: Total Current Assets: 150640784.0396  
[2026-09-04 11:14:48] live.INFO: Total Assets: 151440784.0396  
[2026-09-04 11:14:48] live.INFO: Total Equity: 3589356.18  
[2026-09-04 11:14:48] live.INFO: Total Liabilities: 58283609.77  
[2026-09-04 11:14:48] live.INFO: Total Equity + Liabilities: 61872965.95  
[2026-09-04 11:14:48] live.INFO: Difference: 89567818.0896  
[2026-09-04 11:14:48] live.INFO: Is Balanced: No  
[2026-09-04 11:14:48] live.INFO: === BALANCE SHEET RESPONSE ===  
[2026-09-04 11:14:48] live.INFO: Total Assets: 151440784.0396  
[2026-09-04 11:14:48] live.INFO: Total Equity: 3589356.18  
[2026-09-04 11:14:48] live.INFO: Total Liabilities: 58283609.77  
[2026-09-04 11:14:48] live.INFO: Is Balanced: No  
[2026-09-04 11:15:11] live.INFO: === TRIAL BALANCE REQUEST ===  
[2026-09-04 11:15:11] live.INFO: Business ID: 8  
[2026-09-04 11:15:11] live.INFO: Fiscal Year: 2026  
[2026-09-04 11:15:11] live.INFO: As Of Date: 2026-12-31  
[2026-09-04 11:15:11] live.INFO: Location ID: All  
[2026-09-04 11:15:11] live.INFO: --- Starting getTrialBalanceData ---  
[2026-09-04 11:15:11] live.INFO: Calculating Profit & Loss for Fiscal Year: 2026 as of: 2026-12-31  
[2026-09-04 11:15:11] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:15:11] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 11:15:11] 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-04 11:15:11] 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",8,"opening_stock","opening_stock"]} 
[2026-09-04 11:15:11] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"58869373.22080000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 11:15:11] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-12-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:15:11] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:15:11] 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",8]} 
[2026-09-04 11:15:11] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 11:15:11] live.INFO: Profit/Loss Details from TransactionUtil: {"opening_stock":"58869373.22080000","closing_stock":"147624925.83960000","total_purchase":"75571275.7700","total_sell":"19785137.8000","gross_profit":"4475955.98000000","net_profit":3485343.180000000633299350738525390625,"total_expense":628455.0} 
[2026-09-04 11:15:11] live.INFO: === BREAKDOWN OF total_expense ===  
[2026-09-04 11:15:11] live.INFO: From TransactionUtil total_expense: 628455  
[2026-09-04 11:15:11] live.INFO: From TransactionUtil total_adjustment: 266865.0000  
[2026-09-04 11:15:11] live.INFO: Added Payroll Expenses: 50000.0000  
[2026-09-04 11:15:11] live.INFO: === FINAL P&L CALCULATION ===  
[2026-09-04 11:15:11] live.INFO: Total Income: 19785312.8  
[2026-09-04 11:15:11] live.INFO: Total COGS: -13184276.8488  
[2026-09-04 11:15:11] live.INFO: Total Expenses: 678455  
[2026-09-04 11:15:11] live.INFO: Gross Profit: 4475955.98000000  
[2026-09-04 11:15:11] live.INFO: Net Profit: 3485343.18  
[2026-09-04 11:15:11] live.INFO: Getting method balances up to date: 2026-12-31 (converted to: 2026-12-31)  
[2026-09-04 11:15:11] live.INFO: Found 348 payment records  
[2026-09-04 11:15:11] live.INFO: Calculating receivables up to date: 2026-12-31  
[2026-09-04 11:15:11] live.INFO: Total Receivables: 5138387.0000  
[2026-09-04 11:15:11] live.INFO: Querying assets table for business_id: 8 with purchase_date <= 2026-12-31  
[2026-09-04 11:15:11] live.INFO: Found 1 assets purchased on or before 2026-12-31  
[2026-09-04 11:15:11] live.INFO: Asset: Machine A - Purchase Date: 2026-07-01, Purchase Cost: 800000  
[2026-09-04 11:15:11] live.INFO: Added to non-current assets: Machine A - Value: 800000  
[2026-09-04 11:15:11] live.INFO: Total Accumulated Depreciation: 0  
[2026-09-04 11:15:11] live.INFO: Calculating payables up to date: 2026-12-31  
[2026-09-04 11:15:11] live.INFO: Total Payables: 2617835.7700  
[2026-09-04 11:15:11] live.INFO: Total Sales Returns: 41975.0000  
[2026-09-04 11:15:11] live.INFO: Before adding Retained Earnings:  
[2026-09-04 11:15:11] live.INFO: Total Debits: 154799310.8396  
[2026-09-04 11:15:11] live.INFO: Total Credits: 136448275.7908  
[2026-09-04 11:15:11] live.INFO: Difference: 18351035.0488  
[2026-09-04 11:15:11] live.INFO: Net Profit from P&L: 3485343.18  
[2026-09-04 11:15:11] live.INFO: After adding Retained Earnings:  
[2026-09-04 11:15:11] live.INFO: Total Debits: 154799310.8396  
[2026-09-04 11:15:11] live.INFO: Total Credits: 139933618.9708  
[2026-09-04 11:15:11] live.INFO: === FINAL TRIAL BALANCE TOTALS ===  
[2026-09-04 11:15:11] live.INFO: Total Debits: 154799310.8396  
[2026-09-04 11:15:11] live.INFO: Total Credits: 139933618.9708  
[2026-09-04 11:15:11] live.INFO: Final Difference: 14865691.8688  
[2026-09-04 11:15:11] live.INFO: Is Balanced: No  
[2026-09-04 11:15:25] live.INFO: === PROFIT & LOSS REQUEST ===  
[2026-09-04 11:15:25] live.INFO: Business ID: 8  
[2026-09-04 11:15:25] live.INFO: Fiscal Year: 2026  
[2026-09-04 11:15:25] live.INFO: As Of Date: 2026-12-31  
[2026-09-04 11:15:25] live.INFO: Location ID: All  
[2026-09-04 11:15:25] live.INFO: Calculating Profit & Loss for Fiscal Year: 2026 as of: 2026-12-31  
[2026-09-04 11:15:25] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:15:25] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 11:15:25] 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-04 11:15:25] 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",8,"opening_stock","opening_stock"]} 
[2026-09-04 11:15:25] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"58869373.22080000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 11:15:25] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-12-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:15:25] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:15:25] 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",8]} 
[2026-09-04 11:15:25] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 11:15:25] live.INFO: Profit/Loss Details from TransactionUtil: {"opening_stock":"58869373.22080000","closing_stock":"147624925.83960000","total_purchase":"75571275.7700","total_sell":"19785137.8000","gross_profit":"4475955.98000000","net_profit":3485343.180000000633299350738525390625,"total_expense":628455.0} 
[2026-09-04 11:15:25] live.INFO: === BREAKDOWN OF total_expense ===  
[2026-09-04 11:15:25] live.INFO: From TransactionUtil total_expense: 628455  
[2026-09-04 11:15:25] live.INFO: From TransactionUtil total_adjustment: 266865.0000  
[2026-09-04 11:15:25] live.INFO: Added Payroll Expenses: 50000.0000  
[2026-09-04 11:15:25] live.INFO: === FINAL P&L CALCULATION ===  
[2026-09-04 11:15:25] live.INFO: Total Income: 19785312.8  
[2026-09-04 11:15:25] live.INFO: Total COGS: -13184276.8488  
[2026-09-04 11:15:25] live.INFO: Total Expenses: 678455  
[2026-09-04 11:15:25] live.INFO: Gross Profit: 4475955.98000000  
[2026-09-04 11:15:25] live.INFO: Net Profit: 3485343.18  
[2026-09-04 11:15:49] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:15:49] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 11:15:49] 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-04 11:15:49] 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",8,"opening_stock","opening_stock"]} 
[2026-09-04 11:15:49] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"58869373.22080000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 11:15:49] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-12-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:15:49] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:15:49] 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",8]} 
[2026-09-04 11:15:49] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 11:15:49] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":null,"is_opening":true,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 11:15:49] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 11:15:49] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 11:15:49] 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-04 11:15:49] 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",8,"opening_stock","opening_stock"]} 
[2026-09-04 11:15:49] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"79279760.00000000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 11:15:49] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-12-31","location_id":null,"is_opening":false,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 11:15:49] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 11:15:49] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:15:49] 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",8]} 
[2026-09-04 11:15:49] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"149116033.00000000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 11:18:36] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 11:18:36] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 11:18:36] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 11:18:36] 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-03') ) * (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-03'))","bindings":["purchase_order",8,"opening_stock","opening_stock"]} 
[2026-09-04 11:18:36] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 11:18:36] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 11:18:36] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 11:18:36] 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-04') ) * (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-04'","bindings":["purchase_order",8]} 
[2026-09-04 11:18:36] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 11:18:47] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 11:18:47] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 11:18:47] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 11:18:47] 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-03') ) * (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-03'))","bindings":["purchase_order",8,"opening_stock","opening_stock"]} 
[2026-09-04 11:18:47] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 11:18:47] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 11:18:47] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 11:18:47] 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-04') ) * (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-04'","bindings":["purchase_order",8]} 
[2026-09-04 11:18:47] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 11:19:30] live.INFO: === BALANCE SHEET REQUEST ===  
[2026-09-04 11:19:30] live.INFO: Business ID: 8  
[2026-09-04 11:19:30] live.INFO: Fiscal Year: 2026  
[2026-09-04 11:19:30] live.INFO: As Of Date: 2026-12-31  
[2026-09-04 11:19:30] live.INFO: Location ID: All  
[2026-09-04 11:19:30] live.INFO: --- Starting getBalanceSheetData ---  
[2026-09-04 11:19:30] live.INFO: Permitted locations: all  
[2026-09-04 11:19:30] live.INFO: Fiscal Year: 2026  
[2026-09-04 11:19:30] live.INFO: Fiscal Year Start: 2026-01-01  
[2026-09-04 11:19:30] live.INFO: As Of Date: 2026-12-31  
[2026-09-04 11:19:30] live.INFO: --- Getting Non-Current Assets ---  
[2026-09-04 11:19:30] live.INFO: Querying assets table for business_id: 8 with purchase_date <= 2026-12-31  
[2026-09-04 11:19:30] live.INFO: Found 1 assets purchased on or before 2026-12-31  
[2026-09-04 11:19:30] live.INFO: Asset: Machine A - Purchase Date: 2026-07-01, Purchase Cost: 800000  
[2026-09-04 11:19:30] live.INFO: Added to non-current assets: Machine A - Value: 800000  
[2026-09-04 11:19:30] live.INFO: Non-Current Assets Count: 1  
[2026-09-04 11:19:30] live.INFO: Non-Current Assets Total: 800000  
[2026-09-04 11:19:30] live.INFO: --- Getting Current Assets ---  
[2026-09-04 11:19:30] live.INFO: --- Getting Method Balances ---  
[2026-09-04 11:19:30] live.INFO: Getting method balances up to date: 2026-12-31 (converted to: 2026-12-31)  
[2026-09-04 11:19:30] live.INFO: Found 348 payment records  
[2026-09-04 11:19:30] live.INFO: Method Balances:  {"Cash":-35687201.0,"Paybill Saf":194090.0,"Mpesa Till":24136.0,"Paybill Equity":248837.0,"Bank transfer":-19488553.0,"Card":5.0,"Jambo Pay":20334.0,"Pochi La Biashara":8052.0,"card":20061.0,"Mpesa Agent":53.0} 
[2026-09-04 11:19:30] live.INFO: Added Liability - Cash Overdraft: 35687201  
[2026-09-04 11:19:30] live.INFO: Added Current Asset - Method: Paybill Saf, Balance: 194090  
[2026-09-04 11:19:30] live.INFO: Added Current Asset - Method: Mpesa Till, Balance: 24136  
[2026-09-04 11:19:30] live.INFO: Added Current Asset - Method: Paybill Equity, Balance: 248837  
[2026-09-04 11:19:30] live.INFO: Added Liability - Bank transfer Overdraft: 19488553  
[2026-09-04 11:19:30] live.INFO: Added Current Asset - Method: Card, Balance: 5  
[2026-09-04 11:19:30] live.INFO: Added Current Asset - Method: Jambo Pay, Balance: 20334  
[2026-09-04 11:19:30] live.INFO: Added Current Asset - Method: Pochi La Biashara, Balance: 8052  
[2026-09-04 11:19:30] live.INFO: Added Current Asset - Method: card, Balance: 20061  
[2026-09-04 11:19:30] live.INFO: Added Current Asset - Method: Mpesa Agent, Balance: 53  
[2026-09-04 11:19:30] live.INFO: --- Getting Receivables ---  
[2026-09-04 11:19:30] live.INFO: Calculating receivables up to date: 2026-12-31  
[2026-09-04 11:19:30] live.INFO: Total Receivables: 5138387.0000  
[2026-09-04 11:19:30] live.INFO: Accounts Receivable: 5138387  
[2026-09-04 11:19:30] live.INFO: --- Getting Inventory Closing Stock Value as of 2026-12-31 ---  
[2026-09-04 11:19:30] live.INFO: Calculating closing stock value as of: 2026-12-31  
[2026-09-04 11:19:30] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-12-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":[],"permitted_locations":"all"} 
[2026-09-04 11:19:30] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:19:30] 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",8]} 
[2026-09-04 11:19:30] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 11:19:30] live.INFO: Closing Stock Value (by purchase price): 147624925.83960000  
[2026-09-04 11:19:30] live.INFO: Inventory Closing Stock Value: 147624925.8396  
[2026-09-04 11:19:30] live.INFO: --- Getting Opening Stock Equity as of 2026-01-01 ---  
[2026-09-04 11:19:30] live.INFO: Calculating opening stock value as of: 2026-01-01  
[2026-09-04 11:19:30] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":[],"permitted_locations":"all"} 
[2026-09-04 11:19:30] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2025-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:19:30] 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 date(transaction_date) <= '2025-12-31'","bindings":["purchase_order",8]} 
[2026-09-04 11:19:30] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":0,"is_opening":false,"date":"2025-12-31"} 
[2026-09-04 11:19:30] live.INFO: Opening Stock Value (as of 2025-12-31): 0  
[2026-09-04 11:19:30] live.INFO: Opening Stock Equity: 0  
[2026-09-04 11:19:30] live.INFO: --- Getting Profit/Loss Details from TransactionUtil for Period ---  
[2026-09-04 11:19:30] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2025-12-31","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:19:30] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 11:19:30] 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-04 11:19:30] 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",8,"opening_stock","opening_stock"]} 
[2026-09-04 11:19:30] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"58869373.22080000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 11:19:30] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-12-31","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 11:19:30] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 11:19:30] 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",8]} 
[2026-09-04 11:19:30] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 11:19:30] live.INFO: Net Profit for Period 2026-01-01 to 2026-12-31: 3485343.18  
[2026-09-04 11:19:30] live.INFO: Added to Equity - Retained Earnings: 3485343.18  
[2026-09-04 11:19:30] live.INFO: --- Getting Payables ---  
[2026-09-04 11:19:30] live.INFO: Calculating payables up to date: 2026-12-31  
[2026-09-04 11:19:30] live.INFO: Total Payables: 2617835.7700  
[2026-09-04 11:19:30] live.INFO: Accounts Payable: 2617835.77  
[2026-09-04 11:19:30] live.INFO: === FINAL TOTALS ===  
[2026-09-04 11:19:30] live.INFO: Total Non-Current Assets: 800000  
[2026-09-04 11:19:30] live.INFO: Total Current Assets: 153278880.8396  
[2026-09-04 11:19:30] live.INFO: Total Assets: 154078880.8396  
[2026-09-04 11:19:30] live.INFO: Total Equity: 3485343.18  
[2026-09-04 11:19:30] live.INFO: Total Liabilities: 57793589.77  
[2026-09-04 11:19:30] live.INFO: Total Equity + Liabilities: 61278932.95  
[2026-09-04 11:19:30] live.INFO: Difference: 92799947.8896  
[2026-09-04 11:19:30] live.INFO: Is Balanced: No  
[2026-09-04 11:19:30] live.INFO: === BALANCE SHEET RESPONSE ===  
[2026-09-04 11:19:30] live.INFO: Total Assets: 154078880.8396  
[2026-09-04 11:19:30] live.INFO: Total Equity: 3485343.18  
[2026-09-04 11:19:30] live.INFO: Total Liabilities: 57793589.77  
[2026-09-04 11:19:30] live.INFO: Is Balanced: No  
[2026-09-04 11:29:39] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 11:29:39] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 11:29:39] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 11:29:39] 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-03') ) * (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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 11:29:39] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5998697.40800000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 11:29:39] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 11:29:39] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 11:29:39] 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-04') ) * (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-04'","bindings":["purchase_order",43]} 
[2026-09-04 11:29:39] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6706797.43600000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 11:29:56] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 11:39:56] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 11:50:04] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 12:00:06] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 12:10:08] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 12:20:16] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 12:29:59] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 12:40:44] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 12:50:47] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 13:00:05] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 13:10:05] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 13:20:04] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 13:30:03] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 13:37:17] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:12:39] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 14:12:39] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 14:12:39] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 14:12:39] 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-03') ) * (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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 14:12:39] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5998697.40800000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 14:12:39] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 14:12:39] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 14:12:39] 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-04') ) * (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-04'","bindings":["purchase_order",43]} 
[2026-09-04 14:12:39] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6706797.43600000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 14:12:40] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:12:47] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 14:12:47] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 14:12:47] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 14:12:47] 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-03') ) * (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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 14:12:47] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5998697.40800000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 14:12:47] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 14:12:47] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 14:12:47] 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-04') ) * (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-04'","bindings":["purchase_order",43]} 
[2026-09-04 14:12:47] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6706797.43600000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 14:12:48] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:13:27] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:13:30] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:13:42] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:14:22] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:14:31] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:15:29] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:15:53] live.INFO: Offline not allowed - triggering cleanup {"user_id":361,"business_id":43} 
[2026-09-04 14:16:32] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 14:16:32] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 14:16:32] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 14:16:32] 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-03') ) * (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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 14:16:32] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5998697.40800000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 14:16:32] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 14:16:32] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 14:16:32] 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-04') ) * (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-04'","bindings":["purchase_order",43]} 
[2026-09-04 14:16:32] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6706797.43600000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 14:16:33] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:17:06] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:17:26] live.INFO: Digitax upload skipped: No tax number provided {"contact_id":871,"contact_name":"","contact_type":"supplier"} 
[2026-09-04 14:17:31] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:17:39] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:17:58] live.INFO: Digitax upload skipped: No tax number provided {"contact_id":872,"contact_name":"kevin","contact_type":"customer"} 
[2026-09-04 14:18:16] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:18:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:18:58] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:22:09] live.INFO: === About to call saveProductNewUnitRelationships === {"product_id":337,"request_units":[{"actual_name":"tablets","unit_id":"249","short_name":"tbt","relation_unit_id":null,"relation_qty":"1","price":"10"}],"page_batch_id":"20260904_141854_6815"} 
[2026-09-04 14:22:09] live.INFO: === saveProductNewUnitRelationships START === {"product_id":337,"product_name":"Panadol"} 
[2026-09-04 14:22:09] live.INFO: Units data received {"units_data":[{"actual_name":"tablets","unit_id":"249","short_name":"tbt","relation_unit_id":null,"relation_qty":"1","price":"10"}],"count":1} 
[2026-09-04 14:22:09] live.INFO: Processing unit index: 0 {"unit_data":{"actual_name":"tablets","unit_id":"249","short_name":"tbt","relation_unit_id":null,"relation_qty":"1","price":"10"}} 
[2026-09-04 14:22:09] live.INFO: Unit found by ID {"unit_id":249,"actual_name":"tablets"} 
[2026-09-04 14:22:09] live.INFO: Unit lookup result {"found":"yes","unit_id":249,"method":"by_id"} 
[2026-09-04 14:22:09] live.INFO: Updating existing unit {"unit_id":249} 
[2026-09-04 14:22:09] live.INFO: Updated unit_price {"new_price":10.0} 
[2026-09-04 14:22:09] live.INFO: Unit updated successfully  
[2026-09-04 14:22:09] live.INFO: Setting as BASE unit {"unit_id":249} 
[2026-09-04 14:22:09] live.INFO: Base unit saved {"base_unit_id":249} 
[2026-09-04 14:22:09] live.INFO: First pass complete {"created_units_count":1,"base_unit_id":249} 
[2026-09-04 14:22:09] live.INFO: === SECOND PASS: Setting relations first ===  
[2026-09-04 14:22:09] live.INFO: === SECOND PASS: Calculating cumulative multipliers ===  
[2026-09-04 14:22:09] live.INFO: === saveProductNewUnitRelationships END ===  
[2026-09-04 14:22:10] live.INFO: OpeningStockController::add - Location Data {"product_id":"337","business_id":43,"locations":{"Illuminate\\Support\\Collection":{"39":"Greenfield Supermarket Ltd (BL0001)"}},"available_locations":[39]} 
[2026-09-04 14:22:10] live.INFO: OpeningStockController::add - Serial Numbers Check {"product_id":"337","business_id":43,"has_serial_numbers":{"39":false},"total_locations_with_serial":0} 
[2026-09-04 14:22:13] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:22:57] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:25:19] live.INFO: filterProduct method called {"business_id":43,"search_term":"panadol","location_id":"39","not_for_selling":"0","price_group_id":"0","product_types":[],"search_fields":["name","sku","serial_number"],"check_qty":false,"search_type":"like"} 
[2026-09-04 14:25:19] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:25:19] live.DEBUG: Joining product_serial_numbers table for serial number search  
[2026-09-04 14:25:19] live.DEBUG: Serial numbers filtered by location {"location_id":"39"} 
[2026-09-04 14:25:19] live.DEBUG: Joining transaction_sell_lines and transactions to check if serial number is sold  
[2026-09-04 14:25:19] live.DEBUG: Added condition: keep products without serial numbers OR with available quantity > 0  
[2026-09-04 14:25:19] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 14:25:19] live.DEBUG: Applying search filters {"search_term":"panadol","search_type":"like","search_fields":["name","sku","serial_number"]} 
[2026-09-04 14:25:19] live.DEBUG: LIKE search conditions applied {"fields":["name","sku","serial_number"]} 
[2026-09-04 14:25:19] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:25:19] live.DEBUG: Added serial number, quantity, and transaction sell line fields with quantity details to select  
[2026-09-04 14:25:19] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"panadol"} 
[2026-09-04 14:25:20] live.INFO: Product Row Debug - RELOADED {"product_id":337,"product_name":"Panadol","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":10.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"249":{"unit_id":249,"unit_name":"tablets","unit_price":10.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 14:25:28] live.INFO: Credit Limit Check Started {"contact_id":"703","status":"final","final_total":"100.00","is_credit_sale":"0","exclude_transaction_id":null} 
[2026-09-04 14:25:28] live.DEBUG: Payment Calculation {"final_total":100.0,"curr_total_payment":100.0,"is_credit_sale":false,"payment_count":1} 
[2026-09-04 14:25:28] live.INFO: Credit Limit Check Skipped - Fully Paid {"final_total":100.0,"curr_total_payment":100.0} 
[2026-09-04 14:25:28] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-04 14:25:28] live.INFO: is_mpesa_sale value: true  
[2026-09-04 14:25:28] 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":1801} 
[2026-09-04 14:25:28] live.INFO: Journal Entry Case: FULL CASH PAYMENT {"transaction_id":1801,"final_total":100.0,"amount_paid":100.0,"balance_due":0} 
[2026-09-04 14:25:28] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1801,"entries":[{"transaction_id":1801,"created_by_id":293,"transaction_number":"TRX-6a9aaaa89c9d01.40435051","payment_detail_id":1289,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 14:25:28","updated_at":"2026-09-04 14:25:28","chart_of_account_id":15441,"debit":null,"credit":100.0},{"transaction_id":1801,"created_by_id":293,"transaction_number":"TRX-6a9aaaa89c9d01.40435051","payment_detail_id":1289,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 14:25:28","updated_at":"2026-09-04 14:25:28","chart_of_account_id":15445,"debit":100.0,"credit":null}]} 
[2026-09-04 14:25:28] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1153,"purchase_line_id":1569,"quantity":10.0,"created_at":"2026-09-04 14:25:28","updated_at":"2026-09-04 14:25:28"}]} 
[2026-09-04 14:25:28] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-04 14:25:28] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":50.0} 
[2026-09-04 14:25:28] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 14:25:28] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1801  
[2026-09-04 14:25:49] live.INFO: filterProduct method called {"business_id":43,"search_term":"pana","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-04 14:25:49] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:25:49] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 14:25:49] live.DEBUG: Applying search filters {"search_term":"pana","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 14:25:49] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 14:25:49] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:25:49] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"pana"} 
[2026-09-04 14:25:50] live.INFO: Product Row Debug - RELOADED {"product_id":337,"product_name":"Panadol","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":10.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"249":{"unit_id":249,"unit_name":"tablets","unit_price":10.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 14:26:09] 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-04 14:26:09] live.INFO: STK Push Request Received. {"request_input":{"phone":"0723279116","amount":"50.00"}} 
[2026-09-04 14:26:09] live.INFO: Phone number formatted. {"formatted_phone":"254723279116"} 
[2026-09-04 14:26:09] live.INFO: Phone and Amount after formatting. {"phone":"254723279116","amount":50} 
[2026-09-04 14:26:09] live.INFO: Timestamp for STK Push: {"timestamp":"20260904140909"} 
[2026-09-04 14:26:09] live.INFO: Transaction type determined. {"transaction_type":"CustomerBuyGoodsOnline"} 
[2026-09-04 14:26:09] live.INFO: PartyB to be used in STK Push. {"type":"till","partyB":5699724,"short_code":"3582003","child_number":"3582003","till_no":5699724} 
[2026-09-04 14:26:09] live.INFO: Callback URLs set. {"callbackURL":"https://now.riset.cloud/api/payment/callback","validationURL":"https://now.riset.cloud/api/payment/validation"} 
[2026-09-04 14:26:09] 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-04 14:26:09] live.INFO: Generated password for M-Pesa STK Push. {"password":"MzU4MjAwMzhkZjliNGQ4NTViNzdhMjBiZDIyNTdlZTg2ZjJiNDgyYjE4MTYyMzdlMGUyNDhlMzlmZjhjYmQzZTczYWFiZmYyMDI2MDkwNDE0MDkwOQ=="} 
[2026-09-04 14:26:09] live.INFO: Payload prepared for STK Push. {"payload":{"BusinessShortCode":"3582003","Password":"MzU4MjAwMzhkZjliNGQ4NTViNzdhMjBiZDIyNTdlZTg2ZjJiNDgyYjE4MTYyMzdlMGUyNDhlMzlmZjhjYmQzZTczYWFiZmYyMDI2MDkwNDE0MDkwOQ==","Timestamp":"20260904140909","TransactionType":"CustomerBuyGoodsOnline","Amount":50,"PartyA":"254723279116","PartyB":5699724,"PhoneNumber":"254723279116","CallBackURL":"https://now.riset.cloud/api/payment/callback","AccountReference":12,"TransactionDesc":"Biz"}} 
[2026-09-04 14:26:09] 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-04 14:26:10] 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-04 14:26:10] live.INFO: Registering URLs. {"shortCode":"3582003","confirmationURL":"https://now.riset.cloud/api/payment/callback","validationURL":"https://now.riset.cloud/api/payment/validation"} 
[2026-09-04 14:26:12] live.INFO: URL registration response. {"response":"{
                    \"requestId\":\"9c45-4459-a3b9-fe2bb6ef3bb4315950\",
                    \"errorCode\": \"500.003.1001\",
                    \"errorMessage\": \"URLs are already registered\"
                }
            "} 
[2026-09-04 14:26:12] live.INFO: STK Push response received. {"response":{"MerchantRequestID":"3642-45fc-8fda-303b6027b74669747","CheckoutRequestID":"ws_CO_04092026142612559723279116","ResponseCode":"0","ResponseDescription":"Success. Request accepted for processing","CustomerMessage":"Success. Request accepted for processing"}} 
[2026-09-04 14:26:40] live.INFO: filterProduct method called {"business_id":43,"search_term":"panadol","location_id":"39","not_for_selling":"0","price_group_id":"0","product_types":[],"search_fields":["name","sku","serial_number"],"check_qty":false,"search_type":"like"} 
[2026-09-04 14:26:40] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:26:40] live.DEBUG: Joining product_serial_numbers table for serial number search  
[2026-09-04 14:26:40] live.DEBUG: Serial numbers filtered by location {"location_id":"39"} 
[2026-09-04 14:26:40] live.DEBUG: Joining transaction_sell_lines and transactions to check if serial number is sold  
[2026-09-04 14:26:40] live.DEBUG: Added condition: keep products without serial numbers OR with available quantity > 0  
[2026-09-04 14:26:40] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 14:26:40] live.DEBUG: Applying search filters {"search_term":"panadol","search_type":"like","search_fields":["name","sku","serial_number"]} 
[2026-09-04 14:26:40] live.DEBUG: LIKE search conditions applied {"fields":["name","sku","serial_number"]} 
[2026-09-04 14:26:40] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:26:40] live.DEBUG: Added serial number, quantity, and transaction sell line fields with quantity details to select  
[2026-09-04 14:26:40] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"panadol"} 
[2026-09-04 14:26:40] live.INFO: Product Row Debug - RELOADED {"product_id":337,"product_name":"Panadol","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":10.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"249":{"unit_id":249,"unit_name":"tablets","unit_price":10.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 14:32:57] live.INFO: Credit Limit Check Started {"contact_id":"703","status":"final","final_total":"100.00","is_credit_sale":"0","exclude_transaction_id":null} 
[2026-09-04 14:32:57] live.DEBUG: Payment Calculation {"final_total":100.0,"curr_total_payment":100.0,"is_credit_sale":false,"payment_count":2} 
[2026-09-04 14:32:57] live.INFO: Credit Limit Check Skipped - Fully Paid {"final_total":100.0,"curr_total_payment":100.0} 
[2026-09-04 14:32:57] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-04 14:32:57] live.INFO: is_mpesa_sale value: true  
[2026-09-04 14:32:57] 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":1802} 
[2026-09-04 14:32:57] 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":1802} 
[2026-09-04 14:32:57] live.INFO: Journal Entry Case: PARTIAL PAYMENT {"transaction_id":1802,"final_total":100.0,"amount_paid":50.0,"balance_due":50.0} 
[2026-09-04 14:32:57] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1802,"entries":[{"transaction_id":1802,"created_by_id":293,"transaction_number":"TRX-6a9aac696d7c90.68848285","payment_detail_id":1290,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 14:32:57","updated_at":"2026-09-04 14:32:57","chart_of_account_id":15441,"debit":null,"credit":100.0},{"transaction_id":1802,"created_by_id":293,"transaction_number":"TRX-6a9aac696d7c90.68848285","payment_detail_id":1290,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 14:32:57","updated_at":"2026-09-04 14:32:57","chart_of_account_id":15445,"debit":50.0,"credit":null},{"transaction_id":1802,"created_by_id":293,"transaction_number":"TRX-6a9aac696d7c90.68848285","payment_detail_id":1290,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 14:32:57","updated_at":"2026-09-04 14:32:57","chart_of_account_id":15440,"debit":50.0,"credit":null}]} 
[2026-09-04 14:32:57] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1154,"purchase_line_id":1569,"quantity":10.0,"created_at":"2026-09-04 14:32:57","updated_at":"2026-09-04 14:32:57"}]} 
[2026-09-04 14:32:57] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-04 14:32:57] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":50.0} 
[2026-09-04 14:32:57] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 14:32:57] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1802  
[2026-09-04 14:33:07] live.INFO: filterProduct method called {"business_id":43,"search_term":"tab","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-04 14:33:07] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:33:07] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 14:33:07] live.DEBUG: Applying search filters {"search_term":"tab","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 14:33:07] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 14:33:07] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:33:07] live.INFO: filterProduct completed successfully {"result_count":0,"business_id":43,"search_term":"tab"} 
[2026-09-04 14:33:12] live.INFO: filterProduct method called {"business_id":43,"search_term":"pana","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-04 14:33:12] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:33:12] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 14:33:12] live.DEBUG: Applying search filters {"search_term":"pana","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 14:33:12] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 14:33:12] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:33:12] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"pana"} 
[2026-09-04 14:33:13] live.INFO: Product Row Debug - RELOADED {"product_id":337,"product_name":"Panadol","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":10.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"249":{"unit_id":249,"unit_name":"tablets","unit_price":10.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 14:33:45] live.INFO: Credit Limit Check Started {"contact_id":"703","status":"final","final_total":"100.00","is_credit_sale":"0","exclude_transaction_id":null} 
[2026-09-04 14:33:45] live.DEBUG: Payment Calculation {"final_total":100.0,"curr_total_payment":100.0,"is_credit_sale":false,"payment_count":2} 
[2026-09-04 14:33:45] live.INFO: Credit Limit Check Skipped - Fully Paid {"final_total":100.0,"curr_total_payment":100.0} 
[2026-09-04 14:33:45] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-04 14:33:45] live.INFO: is_mpesa_sale value: true  
[2026-09-04 14:33:45] 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":1803} 
[2026-09-04 14:33:45] 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":1803} 
[2026-09-04 14:33:45] live.INFO: Journal Entry Case: PARTIAL PAYMENT {"transaction_id":1803,"final_total":100.0,"amount_paid":50.0,"balance_due":50.0} 
[2026-09-04 14:33:45] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1803,"entries":[{"transaction_id":1803,"created_by_id":293,"transaction_number":"TRX-6a9aac993930a3.39491744","payment_detail_id":1291,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 14:33:45","updated_at":"2026-09-04 14:33:45","chart_of_account_id":15441,"debit":null,"credit":100.0},{"transaction_id":1803,"created_by_id":293,"transaction_number":"TRX-6a9aac993930a3.39491744","payment_detail_id":1291,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 14:33:45","updated_at":"2026-09-04 14:33:45","chart_of_account_id":15445,"debit":50.0,"credit":null},{"transaction_id":1803,"created_by_id":293,"transaction_number":"TRX-6a9aac993930a3.39491744","payment_detail_id":1291,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 14:33:45","updated_at":"2026-09-04 14:33:45","chart_of_account_id":15440,"debit":50.0,"credit":null}]} 
[2026-09-04 14:33:45] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1155,"purchase_line_id":1569,"quantity":10.0,"created_at":"2026-09-04 14:33:45","updated_at":"2026-09-04 14:33:45"}]} 
[2026-09-04 14:33:45] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-04 14:33:45] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":50.0} 
[2026-09-04 14:33:45] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 14:33:45] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1803  
[2026-09-04 14:34:27] live.INFO: filterProduct method called {"business_id":43,"search_term":"pand","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-04 14:34:27] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:34:27] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 14:34:27] live.DEBUG: Applying search filters {"search_term":"pand","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 14:34:27] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 14:34:27] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:34:27] live.INFO: filterProduct completed successfully {"result_count":0,"business_id":43,"search_term":"pand"} 
[2026-09-04 14:34:28] live.INFO: filterProduct method called {"business_id":43,"search_term":"pan","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-04 14:34:28] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:34:28] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 14:34:28] live.DEBUG: Applying search filters {"search_term":"pan","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 14:34:28] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 14:34:28] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:34:28] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"pan"} 
[2026-09-04 14:34:29] live.INFO: Product Row Debug - RELOADED {"product_id":337,"product_name":"Panadol","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":10.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"249":{"unit_id":249,"unit_name":"tablets","unit_price":10.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 14:34:30] live.INFO: filterProduct method called {"business_id":43,"search_term":"pa","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-04 14:34:30] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:34:30] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 14:34:30] live.DEBUG: Applying search filters {"search_term":"pa","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 14:34:30] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 14:34:30] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:34:30] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"pa"} 
[2026-09-04 14:34:31] live.INFO: Product Row Debug - RELOADED {"product_id":337,"product_name":"Panadol","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":10.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"249":{"unit_id":249,"unit_name":"tablets","unit_price":10.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 14:34:40] live.INFO: Credit Limit Check Started {"contact_id":"872","status":"final","final_total":"300.00","is_credit_sale":"0","exclude_transaction_id":null} 
[2026-09-04 14:34:40] live.DEBUG: Payment Calculation {"final_total":300.0,"curr_total_payment":0.0,"is_credit_sale":false,"payment_count":1} 
[2026-09-04 14:34:40] live.INFO: Credit Limit Check Skipped - No Credit Limit Set {"contact_id":"872","contact_name":"kevin"} 
[2026-09-04 14:34:40] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-04 14:34:40] live.INFO: is_mpesa_sale value: true  
[2026-09-04 14:34:40] live.INFO: Journal Entry Case: FULL CREDIT SALE {"transaction_id":1804,"final_total":300.0,"amount_paid":0.0,"balance_due":300.0} 
[2026-09-04 14:34:40] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1804,"entries":[{"transaction_id":1804,"created_by_id":293,"transaction_number":"TRX-6a9aacd07b8591.69579050","payment_detail_id":1292,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 14:34:40","updated_at":"2026-09-04 14:34:40","chart_of_account_id":15441,"debit":null,"credit":300.0},{"transaction_id":1804,"created_by_id":293,"transaction_number":"TRX-6a9aacd07b8591.69579050","payment_detail_id":1292,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 14:34:40","updated_at":"2026-09-04 14:34:40","chart_of_account_id":15440,"debit":300.0,"credit":null}]} 
[2026-09-04 14:34:40] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1156,"purchase_line_id":1569,"quantity":30.0,"created_at":"2026-09-04 14:34:40","updated_at":"2026-09-04 14:34:40"}]} 
[2026-09-04 14:34:40] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-04 14:34:40] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":150.0} 
[2026-09-04 14:34:40] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 14:34:40] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1804  
[2026-09-04 14:35:11] live.INFO: filterProduct method called {"business_id":43,"search_term":"pana","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-04 14:35:11] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:35:11] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 14:35:11] live.DEBUG: Applying search filters {"search_term":"pana","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 14:35:11] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 14:35:11] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:35:11] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"pana"} 
[2026-09-04 14:35:11] live.INFO: Product Row Debug - RELOADED {"product_id":337,"product_name":"Panadol","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":10.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"249":{"unit_id":249,"unit_name":"tablets","unit_price":10.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 14:35:26] 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-04 14:35:26] live.DEBUG: Payment Calculation {"final_total":300.0,"curr_total_payment":300.0,"is_credit_sale":false,"payment_count":1} 
[2026-09-04 14:35:26] live.INFO: Credit Limit Check Skipped - Fully Paid {"final_total":300.0,"curr_total_payment":300.0} 
[2026-09-04 14:35:26] live.INFO: mpesa_transaction_id value: NULL  
[2026-09-04 14:35:26] live.INFO: is_mpesa_sale value: true  
[2026-09-04 14:35:27] live.INFO: Journal Entry Case: FULL CASH PAYMENT {"transaction_id":1805,"final_total":300.0,"amount_paid":300.0,"balance_due":0} 
[2026-09-04 14:35:27] live.INFO: Journal Entries Inserted Successfully {"transaction_id":1805,"entries":[{"transaction_id":1805,"created_by_id":293,"transaction_number":"TRX-6a9aacff0adec2.94064097","payment_detail_id":1293,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 14:35:27","updated_at":"2026-09-04 14:35:27","chart_of_account_id":15441,"debit":null,"credit":300.0},{"transaction_id":1805,"created_by_id":293,"transaction_number":"TRX-6a9aacff0adec2.94064097","payment_detail_id":1293,"location_id":"39","currency_id":133,"transaction_type":"sell","date":"2026-09-04","month":9,"year":2026,"active":1,"reversed":0,"reversible":1,"manual_entry":1,"created_at":"2026-09-04 14:35:27","updated_at":"2026-09-04 14:35:27","chart_of_account_id":15445,"debit":300.0,"credit":null}]} 
[2026-09-04 14:35:27] live.INFO: Inserted purchase sell mapping {"count":1,"data":[{"sell_line_id":1157,"purchase_line_id":1569,"quantity":30.0,"created_at":"2026-09-04 14:35:27","updated_at":"2026-09-04 14:35:27"}]} 
[2026-09-04 14:35:27] live.INFO: Inserted COGS → Inventory journal entries {"count":2} 
[2026-09-04 14:35:27] live.INFO: Inserted Retained Earnings (profit) entries {"count":1,"total_profit":150.0} 
[2026-09-04 14:35:40] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:35:43] live.INFO: Credit Limit Check Started {"contact_id":"703","status":"final","final_total":"300.00","is_credit_sale":"0","exclude_transaction_id":"1805"} 
[2026-09-04 14:35:43] live.DEBUG: Payment Calculation {"final_total":300.0,"curr_total_payment":300.0,"is_credit_sale":false,"payment_count":1} 
[2026-09-04 14:35:43] live.INFO: Credit Limit Check Skipped - Fully Paid {"final_total":300.0,"curr_total_payment":300.0} 
[2026-09-04 14:35:43] 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":1805} 
[2026-09-04 14:35:43] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 14:35:43] live.WARNING: ETIMS WAIT: Timed out after 2 attempts for transaction ID: 1805  
[2026-09-04 14:36:03] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:36:10] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:36:15] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:37:11] live.INFO: Purchases array from request {"purchases":[{"product_id":"337","variation_id":"342","quantity":"200","product_unit_id":"249","sub_unit_id":"249","pp_without_discount":"5.00","discount_percent":"0.00","purchase_price":"5.00","purchase_line_tax_id":null,"item_tax":"0.00","purchase_price_inc_tax":"5.00","profit_percent":"100.00","default_sell_price":"10.00","mfg_date":null,"exp_date":null,"imei_numbers":"[]","imei_count":"0"}],"purchases_json":"[{\"product_id\":\"337\",\"variation_id\":\"342\",\"quantity\":\"200\",\"product_unit_id\":\"249\",\"sub_unit_id\":\"249\",\"pp_without_discount\":\"5.00\",\"discount_percent\":\"0.00\",\"purchase_price\":\"5.00\",\"purchase_line_tax_id\":null,\"item_tax\":\"0.00\",\"purchase_price_inc_tax\":\"5.00\",\"profit_percent\":\"100.00\",\"default_sell_price\":\"10.00\",\"mfg_date\":null,\"exp_date\":null,\"imei_numbers\":\"[]\",\"imei_count\":\"0\"}]"} 
[2026-09-04 14:37:11] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 14:37:11] live.INFO: Purchase lines created {"transaction_id":1806,"purchase_lines_count":1,"purchase_lines":[{"id":1570,"transaction_id":1806,"product_id":337,"variation_id":342,"quantity":200.0,"secondary_unit_quantity":"0.0000","pp_without_discount":"5.0000","discount_percent":"0.00","purchase_price":"5.0000","purchase_price_inc_tax":"5.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-04T11:37:11.000000Z","updated_at":"2026-09-04T11:37:11.000000Z"}]} 
[2026-09-04 14:37:11] live.INFO: Processing purchase row - 0 {"row_index":0,"product_id":"337","variation_id":"342","quantity":"200","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-04 14:37:11] live.INFO: IMEI Data - Parsed for row 0 {"row_index":0,"imei_count":0,"imei_data":[],"imei_json":"[]"} 
[2026-09-04 14:37:11] live.INFO: IMEI data is empty or invalid for row 0 {"imeiData":[]} 
[2026-09-04 14:37:11] live.INFO: M-Pesa sale evaluation {"is_mpesa_sale_raw":false,"is_valid_mpesa_sale":false,"payment_method_input":"bank_transfer","mpesa_transaction_id":null,"transaction_id":1806} 
[2026-09-04 14:37:12] live.INFO: Purchase created successfully with IMEI data {"transaction_id":1806,"ref_no":"PO2026/0014","final_total":1000.0} 
[2026-09-04 14:37:15] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:37:19] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:37:33] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:38:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:38:15] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:41:03] live.INFO: filterProduct method called {"business_id":43,"search_term":"pana","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-04 14:41:03] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:41:03] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 14:41:03] live.DEBUG: Applying search filters {"search_term":"pana","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 14:41:03] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 14:41:03] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:41:03] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"pana"} 
[2026-09-04 14:41:04] live.INFO: Product Row Debug - RELOADED {"product_id":337,"product_name":"Panadol","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":10.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"249":{"unit_id":249,"unit_name":"tablets","unit_price":10.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 14:41:15] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:41:23] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:41:27] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:41:35] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:41:57] live.INFO: Purchases array from request {"purchases":[{"product_id":"337","variation_id":"342","quantity":"30","product_unit_id":"249","sub_unit_id":"249","pp_without_discount":"7.00","discount_percent":"0.00","purchase_price":"7","purchase_line_tax_id":null,"item_tax":"0.00","purchase_price_inc_tax":"7.00","profit_percent":"114.29","default_sell_price":"15","mfg_date":null,"exp_date":null,"imei_numbers":"[]","imei_count":"0"}],"purchases_json":"[{\"product_id\":\"337\",\"variation_id\":\"342\",\"quantity\":\"30\",\"product_unit_id\":\"249\",\"sub_unit_id\":\"249\",\"pp_without_discount\":\"7.00\",\"discount_percent\":\"0.00\",\"purchase_price\":\"7\",\"purchase_line_tax_id\":null,\"item_tax\":\"0.00\",\"purchase_price_inc_tax\":\"7.00\",\"profit_percent\":\"114.29\",\"default_sell_price\":\"15\",\"mfg_date\":null,\"exp_date\":null,\"imei_numbers\":\"[]\",\"imei_count\":\"0\"}]"} 
[2026-09-04 14:41:57] live.ERROR: ETIMS settings not found for business ID: 43  
[2026-09-04 14:41:57] live.INFO: Purchase lines created {"transaction_id":1807,"purchase_lines_count":1,"purchase_lines":[{"id":1571,"transaction_id":1807,"product_id":337,"variation_id":342,"quantity":30.0,"secondary_unit_quantity":"0.0000","pp_without_discount":"7.0000","discount_percent":"0.00","purchase_price":"7.0000","purchase_price_inc_tax":"7.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-04T11:41:57.000000Z","updated_at":"2026-09-04T11:41:57.000000Z"}]} 
[2026-09-04 14:41:57] live.INFO: Processing purchase row - 0 {"row_index":0,"product_id":"337","variation_id":"342","quantity":"30","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-04 14:41:57] live.INFO: IMEI Data - Parsed for row 0 {"row_index":0,"imei_count":0,"imei_data":[],"imei_json":"[]"} 
[2026-09-04 14:41:57] live.INFO: IMEI data is empty or invalid for row 0 {"imeiData":[]} 
[2026-09-04 14:41:57] live.INFO: Purchase created successfully with IMEI data {"transaction_id":1807,"ref_no":"PO2026/0015","final_total":210.0} 
[2026-09-04 14:42:00] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:42:05] live.INFO: filterProduct method called {"business_id":43,"search_term":"pan","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-04 14:42:06] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:42:06] live.DEBUG: Filtering by not_for_selling {"not_for_selling":"0"} 
[2026-09-04 14:42:06] live.DEBUG: Applying search filters {"search_term":"pan","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 14:42:06] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 14:42:06] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:42:06] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"pan"} 
[2026-09-04 14:42:07] live.INFO: Product Row Debug - RELOADED {"product_id":337,"product_name":"Panadol","discount_allowed":false,"has_global_discount":false,"global_discount_type":"fixed","global_discount_amount":0,"discounts_count":0,"discounts":[],"base_price":15.0,"discounts_json":"[]","multiplier":1,"unit_prices":{"249":{"unit_id":249,"unit_name":"tablets","unit_price":10.0,"multiplier":1,"has_price":true}},"has_price_group":false,"price_group_id":null} 
[2026-09-04 14:42:07] live.INFO: Fetching tax rate for product ID: 337  
[2026-09-04 14:42:07] live.INFO: Product ID 337 has no tax assigned.  
[2026-09-04 14:42:18] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:42:45] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:43:11] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:43:15] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:43:42] 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":1808} 
[2026-09-04 14:43:45] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:44:08] 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-04 14:44:08] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 14:44:08] 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-04 14:44:08] 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-04 14:44:08] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"2676690.08000000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 14:44:08] 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-04 14:44:08] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 14:44:08] 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-04 14:44:08] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6708057.43600000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 14:44:08] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:44:09] 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-04 14:44:09] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 14:44:09] live.INFO: Opening stock calculation - including all transactions {"date":"2025-12-31"} 
[2026-09-04 14:44:09] 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-04 14:44: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) <= '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-04 14:44:09] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"4053300.00000000","is_opening":true,"date":"2025-12-31"} 
[2026-09-04 14:44:09] 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-04 14:44:09] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 14:44:09] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-12-31' (includes all types except purchase_order)"} 
[2026-09-04 14:44: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-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-04 14:44:09] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6365870.00000000","is_opening":false,"date":"2026-12-31"} 
[2026-09-04 14:44:15] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 14:44:15] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 14:44:15] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 14:44:15] 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-03') ) * (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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 14:44:15] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5999197.40800000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 14:44:15] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":"all"} 
[2026-09-04 14:44:15] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 14:44:15] 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-04') ) * (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-04'","bindings":["purchase_order",43]} 
[2026-09-04 14:44:15] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6708057.43600000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 14:44:16] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 14:44:16] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 14:44:16] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 14:44:16] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 14:44:16] 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-03') ) * 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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 14:44:16] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6353320.00000000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 14:44:16] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":true,"filters":"all","permitted_locations":null} 
[2026-09-04 14:44:16] live.DEBUG: Using sale price instead of purchase price {"price_query_part":"v.sell_price_inc_tax"} 
[2026-09-04 14:44:16] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 14:44:16] 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-04') ) * 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-04'","bindings":["purchase_order",43]} 
[2026-09-04 14:44:16] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6365870.00000000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 14:45:50] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:45:55] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:46:41] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:46:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:47:02] live.INFO: filterProduct method called {"business_id":43,"search_term":"pa","location_id":"39","not_for_selling":null,"price_group_id":null,"product_types":[],"search_fields":["name","sku"],"check_qty":false,"search_type":"like"} 
[2026-09-04 14:47:02] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:47:02] live.DEBUG: Applying search filters {"search_term":"pa","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 14:47:02] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 14:47:02] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:47:02] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"pa"} 
[2026-09-04 14:47:03] live.INFO: filterProduct method called {"business_id":43,"search_term":"pana","location_id":"39","not_for_selling":null,"price_group_id":null,"product_types":[],"search_fields":["name","sku"],"check_qty":false,"search_type":"like"} 
[2026-09-04 14:47:03] live.DEBUG: Initial query built with joins {"has_location":true} 
[2026-09-04 14:47:03] live.DEBUG: Applying search filters {"search_term":"pana","search_type":"like","search_fields":["name","sku"]} 
[2026-09-04 14:47:03] live.DEBUG: LIKE search conditions applied {"fields":["name","sku"]} 
[2026-09-04 14:47:03] live.DEBUG: Applying location filter {"location_id":"39"} 
[2026-09-04 14:47:03] live.INFO: filterProduct completed successfully {"result_count":1,"business_id":43,"search_term":"pana"} 
[2026-09-04 14:47:03] live.INFO: StockAdjustment - getProductRow - Serial Number Received {"variation_id":"342","serial_number":null,"serial_number_id":null,"serial_number_quantity":0,"serial_number_available":0,"all_request_data":{"row_index":"0","variation_id":"342","location_id":"39"}} 
[2026-09-04 14:47:17] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:47:24] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:47:34] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:48:00] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:48:09] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:48:26] live.ERROR: Error submitting stock counts: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'location_id' cannot be null (SQL: insert into `stockcounts` (`product_id`, `stock_count`, `business_id`, `location_id`, `added_by`, `ref_no`, `current_stock`, `created_at`, `updated_at`) values (337, 179, 43, ?, 293, ST005, 0, 2026-09-04 14:48:26, 2026-09-04 14:48:26))  
[2026-09-04 14:48:29] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:49:00] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:49:17] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:49:29] live.ERROR: Error submitting stock counts: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'location_id' cannot be null (SQL: insert into `stockcounts` (`product_id`, `stock_count`, `business_id`, `location_id`, `added_by`, `ref_no`, `current_stock`, `created_at`, `updated_at`) values (337, 200, 43, ?, 293, ST005, 0, 2026-09-04 14:49:29, 2026-09-04 14:49:29))  
[2026-09-04 14:49:32] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:49:43] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:50:12] live.INFO: Stock updates received: [{"productName":"Green Car Kids Toy","productSKU":"0046","stockCount":"1000","difference":"-37","type":"Increase"},{"productName":"LED bulbs","productSKU":"0144","stockCount":"100","difference":"-75","type":"Increase"},{"productName":"blue baby suit","productSKU":"0214","stockCount":"20","difference":"11","type":"Decrease"},{"productName":"Panadol","productSKU":"0337","stockCount":"200","difference":"35","type":"Decrease"}] 
[2026-09-04 14:50:12] live.WARNING: No variation_location_details found for product_id: 46, location_id: 39. Skipping product: Green Car Kids Toy  
[2026-09-04 14:50:12] live.WARNING: No variation_location_details found for product_id: 144, location_id: 39. Skipping product: LED bulbs  
[2026-09-04 14:50:12] live.WARNING: No variation_location_details found for product_id: 214, location_id: 39. Skipping product: blue baby suit  
[2026-09-04 14:50:12] live.INFO: Stock adjustment: Panadol - difference: 35, direction: reduce, quantity: 35  
[2026-09-04 14:50:12] live.INFO: Stock adjustment prepared for product: Panadol, variation_id: 342, direction: reduce, quantity: 35, unit_price: 7.0000  
[2026-09-04 14:50:12] live.INFO: Updated variation_location_details for variation_id: 342, location_id: 39, new qty_available: 200  
[2026-09-04 14:50:12] live.INFO: Transaction created with ID: 1810 for ref_no: ST005, final_total: 245  
[2026-09-04 14:50:12] live.INFO: Stock adjustment lines inserted: 1  
[2026-09-04 14:50:17] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:50:48] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:50:58] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:52:33] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:52:49] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:53:38] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 14:54:02] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 14:54:02] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 14:54:02] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 14:54:02] 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-03') ) * (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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 14:54:02] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5999172.40800000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 14:54:02] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 14:54:02] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 14:54:02] 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-04') ) * (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-04'","bindings":["purchase_order",43]} 
[2026-09-04 14:54:02] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6708032.43600000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 14:54:04] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 15:57:13] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 16:13:28] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 16:13:28] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 16:13:28] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 16:13:28] 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-03') ) * (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-03'))","bindings":["purchase_order",43,"opening_stock","opening_stock"]} 
[2026-09-04 16:13:28] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"5999172.40800000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 16:13:28] live.INFO: === getOpeningClosingStock START === {"business_id":43,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 16:13:28] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 16:13:28] 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-04') ) * (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-04'","bindings":["purchase_order",43]} 
[2026-09-04 16:13:28] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"6708032.43600000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 16:13:30] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 16:13:35] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 16:19:02] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-09-03","location_id":null,"is_opening":true,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 16:19:02] live.INFO: Opening stock calculation - including all transactions {"date":"2026-09-03"} 
[2026-09-04 16:19:02] live.INFO: Applied opening stock condition {"condition":"purchase.type = 'opening_stock' OR (purchase.type != 'opening_stock' AND date(transaction_date) <= '2026-09-03')"} 
[2026-09-04 16:19:02] 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-03') ) * (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-03'))","bindings":["purchase_order",8,"opening_stock","opening_stock"]} 
[2026-09-04 16:19:02] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":true,"date":"2026-09-03"} 
[2026-09-04 16:19:02] live.INFO: === getOpeningClosingStock START === {"business_id":8,"date":"2026-09-04","location_id":null,"is_opening":false,"by_sale_price":false,"filters":{"user_id":null},"permitted_locations":null} 
[2026-09-04 16:19:02] live.INFO: Applied closing stock condition {"condition":"date(transaction_date) <= '2026-09-04' (includes all types except purchase_order)"} 
[2026-09-04 16:19:02] 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-04') ) * (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-04'","bindings":["purchase_order",8]} 
[2026-09-04 16:19:02] live.INFO: === getOpeningClosingStock RESULT === {"calculated_stock":"147624925.83960000","is_opening":false,"date":"2026-09-04"} 
[2026-09-04 16:23:35] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 16:30:29] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 16:32:06] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 16:32:22] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 16:42:22] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 16:52:22] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 17:02:22] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 17:12:22] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 17:22:22] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 17:32:22] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 17:42:43] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 17:52:43] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 18:03:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 18:13:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 18:23:05] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 18:33:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 18:43:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 18:53:03] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 19:02:42] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 19:13:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 19:23:03] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 19:32:42] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 19:42:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 19:52:42] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 20:03:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 20:13:03] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 20:22:42] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 20:32:42] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 20:42:42] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 20:53:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 21:02:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 21:12:47] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 21:22:42] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 21:32:51] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 21:43:02] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 21:53:03] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 22:02:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 22:12:56] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 22:22:41] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 22:32:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 22:42:52] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 22:52:41] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 23:02:46] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 23:12:41] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 23:22:41] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 23:32:41] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 23:43:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
[2026-09-04 23:53:01] live.INFO: Offline not allowed - triggering cleanup {"user_id":293,"business_id":43} 
