[2026-06-11 04:44:06] [INFO] ===========================================
[2026-06-11 04:44:06] [INFO] Quotations Processor Log
[2026-06-11 04:44:06] [INFO] Record ID: 097379d6-4f03-43aa-bfbb-45a3124d4e55
[2026-06-11 04:44:06] [INFO] Table: quotations
[2026-06-11 04:44:06] [INFO] Timestamp: 2026-06-11 04:44:06
[2026-06-11 04:44:06] [INFO] ===========================================
[2026-06-11 04:44:06] [INFO] ========== START: processQuotationSubmission ==========
[2026-06-11 04:44:06] [INFO] Function called for record ID: 097379d6-4f03-43aa-bfbb-45a3124d4e55
[2026-06-11 04:44:06] [DEBUG] Form data received: {"table":"quotations","tenant_id":"019c358b-5fe1-7e90-c3cc-a17b42a96622"}
[2026-06-11 04:44:06] [INFO] Detected table: quotations (Type: proforma)
[2026-06-11 04:44:06] [DEBUG] ID field: quotation_id, Number field: quotation_number
[2026-06-11 04:44:06] [DEBUG] STEP 1: Fetching quotation data from database
[2026-06-11 04:44:06] [DEBUG] QueryBuilder instance created
[2026-06-11 04:44:06] [DEBUG] Database query executed for quotation_id: 097379d6-4f03-43aa-bfbb-45a3124d4e55
[2026-06-11 04:44:06] [DEBUG] Quotation found successfully
[2026-06-11 04:44:06] [INFO] quotation_type from record overrides invoiceType: training
[2026-06-11 04:44:06] [DEBUG] Using org_id: 019c358b-5fe1-7e90-c3cc-a17b42a96622
[2026-06-11 04:44:06] [INFO] Fetched quotation data: {"quotation_id":"097379d6-4f03-43aa-bfbb-45a3124d4e55","quotation_number":"00023","date":"2026-06-11","customer_id":"000019ca-b8de-79c7-f5c6-87991a2c1b98","org_id":"019c358b-5fe1-7e90-c3cc-a17b42a96622","client_id":null,"line_items":"[{\"quantity\": \"2\", \"vat_rate\": \"VIP\", \"line_total\": \"7.98\", \"product_id\": \"000019cf-eac0-7231-6dd4-380ea234b5a2\", \"unit_price\": \"3.99\", \"vat_amount\": \"0.89\", \"description\": \"palmolive shamphoo 340ml \", \"line_subtotal\": \"7.98\"}]","note":null,"terms":null,"validity_days":30,"status":"expired","total_amount":"0.00","tax_amount":"0.00","template_id":null,"sent_at":null,"expires_at":"2026-06-11","accepted_at":null,"rejected_at":null,"rejection_reason":null,"converted_invoice_id":null,"created_by":null,"updated_by":null,"isdeleted":false,"updatedat":"2026-06-11 04:44:06.42166+00","taxcore_submission_id":null,"taxcore_submission_id_fk":null,"taxcore_receipt_data":null,"taxcore_submitted_at":null,"taxcore_verification_url":null,"taxcore_qr_code":null,"journal_entry_id":null,"converted_to_invoice_id":null,"po_number":null,"notes_additional":null,"payment_terms_details":null,"quotation_type":"training"}
[2026-06-11 04:44:06] [DEBUG] STEP 2: Parsing line_items JSON
[2026-06-11 04:44:06] [DEBUG] Parsed 1 line items
[2026-06-11 04:44:06] [DEBUG] Line items: [{"quantity":"2","vat_rate":"VIP","line_total":"7.98","product_id":"000019cf-eac0-7231-6dd4-380ea234b5a2","unit_price":"3.99","vat_amount":"0.89","description":"palmolive shamphoo 340ml ","line_subtotal":"7.98"}]
[2026-06-11 04:44:06] [DEBUG] STEP 3: Preparing items for TaxCore
[2026-06-11 04:44:06] [DEBUG] Processing line item: 0 -> {"quantity":"2","vat_rate":"VIP","line_total":"7.98","product_id":"000019cf-eac0-7231-6dd4-380ea234b5a2","unit_price":"3.99","vat_amount":"0.89","description":"palmolive shamphoo 340ml ","line_subtotal":"7.98"}
[2026-06-11 04:44:06] [DEBUG] Calculated - Quantity: 2, UnitPrice: 3.99, TotalAmount: 7.98
[2026-06-11 04:44:06] [DEBUG] Prepared 1 items for TaxCore
[2026-06-11 04:44:06] [INFO] TaxCore items: [{"name":"palmolive shamphoo 340ml ","quantity":2,"unitPrice":"3.99","totalAmount":"7.98","Labels":["G"]}]
[2026-06-11 04:44:06] [DEBUG] STEP 4: Preparing payment method as Credit
[2026-06-11 04:44:06] [INFO] Payment prepared (Credit): [{"paymentType":"0","amount":0}]
[2026-06-11 04:44:06] [DEBUG] STEP 5: Fetching cashier information
[2026-06-11 04:44:06] [DEBUG] User ID from formData: 019c358b-5fe1-7e90-c3cc-a17b42a96622
[2026-06-11 04:44:06] [DEBUG] Querying users table for user_id: 019c358b-5fe1-7e90-c3cc-a17b42a96622
[2026-06-11 04:44:06] [INFO] Cashier name found: System
[2026-06-11 04:44:06] [DEBUG] STEP 6: Building TaxCore payload
[2026-06-11 04:44:06] [DEBUG] Base payload created with type=training
[2026-06-11 04:44:06] [DEBUG] STEP 7: Adding customer/buyer information
[2026-06-11 04:44:06] [DEBUG] Customer ID found: 000019ca-b8de-79c7-f5c6-87991a2c1b98
[2026-06-11 04:44:06] [DEBUG] Customer found: {"name":"Test 1 Test 1jkjshfkjds","tin":null}
[2026-06-11 04:44:06] [INFO] TaxCore payload prepared: {
    "items": [
        {
            "name": "palmolive shamphoo 340ml ",
            "quantity": 2,
            "unitPrice": "3.99",
            "totalAmount": "7.98",
            "Labels": [
                "G"
            ]
        }
    ],
    "payment": [
        {
            "paymentType": "0",
            "amount": 0
        }
    ],
    "Cashier": "System",
    "type": "training",
    "invoiceNumber": "00023",
    "Buyer": {
        "Name": "Test 1 Test 1jkjshfkjds"
    }
}
[2026-06-11 04:44:06] [DEBUG] STEP 8: Creating Journal Entry in Finance module
[2026-06-11 04:44:06] [INFO] --- createJournalEntry: Starting ---
[2026-06-11 04:44:06] [INFO] Is Cancelled/Refund: NO
[2026-06-11 04:44:06] [DEBUG] Calculated totals - Subtotal: 7.98, Tax: 0.9975, Total: 8.9775
[2026-06-11 04:44:06] [DEBUG] Looking for customer-specific AR account for: Test 1 Test 1jkjshfkjds
[2026-06-11 04:44:06] [DEBUG] Customer-specific AR account not found, using parent AR account
[2026-06-11 04:44:06] [DEBUG] Found GL accounts - Revenue: 4000, Tax: 2410, Receivables: 1300 (Accounts Receivable)
[2026-06-11 04:44:06] [ERROR] ERROR creating journal entry: Undefined variable $orgId
[2026-06-11 04:44:06] [ERROR] Stack trace: #0 /var/www/POS/api/services/QuotationsProcessor.php(632): {closure}()
#1 /var/www/POS/api/services/QuotationsProcessor.php(301): App\Services\QuotationsProcessor::createJournalEntry()
#2 [internal function]: App\Services\QuotationsProcessor::processQuotationSubmission()
#3 /var/www/POS/api/services/workflow_steps/CustomFunctionStep.php(121): call_user_func_array()
#4 /var/www/POS/api/services/WorkflowEngine.php(508): App\Services\WorkflowSteps\CustomFunctionStep->execute()
#5 /var/www/POS/api/services/WorkflowEngine.php(767): App\Services\WorkflowEngine->executeStep()
#6 /var/www/POS/api/services/WorkflowEngine.php(144): App\Services\WorkflowEngine->runSteps()
#7 /var/www/POS/api/services/WorkflowEngine.php(177): App\Services\WorkflowEngine->handleEvent()
#8 /var/www/POS/api/services/WorkflowEngine.php(189): App\Services\WorkflowEngine->emit()
#9 /var/www/POS/api/controllers/GenericController.php(373): App\Services\WorkflowEngine::trigger()
#10 /var/www/POS/api/controllers/SyncController.php(212): App\Controllers\GenericController->processWorkflowEvents()
#11 /var/www/POS/api/controllers/SyncController.php(224): App\Controllers\GenericController@anonymous->exec()
#12 /var/www/POS/api/controllers/SyncController.php(1330): App\Controllers\SyncController->triggerWorkflow()
#13 /var/www/POS/api/router.php(272): App\Controllers\SyncController->push()
#14 /var/www/POS/api/index.php(32): require_once('...')
#15 {main}
[2026-06-11 04:44:06] [WARN] WARNING: Journal entry creation failed: Undefined variable $orgId
[2026-06-11 04:44:06] [DEBUG] STEP 9: Checking if TaxCore integration is enabled
[2026-06-11 04:44:06] [DEBUG] Checking TaxCore integration status for org_id: 019c358b-5fe1-7e90-c3cc-a17b42a96622 (table: quotations)
[2026-06-11 04:44:06] [INFO] Found quotation_taxcore_enabled in orgs.settings: false
[2026-06-11 04:44:06] [INFO] TaxCore integration enabled: NO
[2026-06-11 04:44:06] [INFO] TaxCore integration is disabled - skipping TaxCore submission
[2026-06-11 04:44:06] [INFO] TaxCore call completed successfully
[2026-06-11 04:44:06] [INFO] TaxCore response: {
    "skipped": true,
    "reason": "TaxCore integration disabled for this organization",
    "invoiceNumber": null
}
[2026-06-11 04:44:06] [DEBUG] STEP 10: Updating quotations record with TaxCore and Journal Entry details
[2026-06-11 04:44:06] [DEBUG] Update data prepared: {"quotation_id":"097379d6-4f03-43aa-bfbb-45a3124d4e55"}
[2026-06-11 04:44:06] [INFO] Quotations record updated successfully
[2026-06-11 04:44:06] [INFO] Skipping sales_receipts insert - TaxCore disabled or submission failed
[2026-06-11 04:44:06] [DEBUG] STEP 12: Saving audit file to storage
[2026-06-11 04:44:06] [DEBUG] Storage file path: /var/www/POS/storage/quotations/quotation_097379d6-4f03-43aa-bfbb-45a3124d4e55_2026-06-11_04-44-06.json
[2026-06-11 04:44:06] [INFO] Audit file saved successfully to: /var/www/POS/storage/quotations/quotation_097379d6-4f03-43aa-bfbb-45a3124d4e55_2026-06-11_04-44-06.json
[2026-06-11 04:44:06] [DEBUG] STEP 13: Preparing final result
[2026-06-11 04:44:06] [INFO] ========== SUCCESS: Process completed ==========
[2026-06-11 04:44:06] [INFO] Final result: {"success":true,"message":"Quotations processed successfully (TaxCore disabled)","record_id":"097379d6-4f03-43aa-bfbb-45a3124d4e55","table":"quotations","invoice_type":"training","taxcore_enabled":false,"journal_entry_id":null,"journal_entry_number":null,"taxcore_invoice_number":null,"taxcore_verification_url":null,"taxcore_skipped":true,"processed_at":"2026-06-11 04:44:06","saved_to":"\/var\/www\/POS\/storage\/quotations\/quotation_097379d6-4f03-43aa-bfbb-45a3124d4e55_2026-06-11_04-44-06.json","log_file":"\/var\/www\/POS\/storage\/quotations\/logs\/quotation_097379d6-4f03-43aa-bfbb-45a3124d4e55_2026-06-11_04-44-06.log"}
[2026-06-11 04:44:06] [INFO] ===========================================
[2026-06-11 04:44:06] [INFO] Quotations Processor Log
[2026-06-11 04:44:06] [INFO] Record ID: 097379d6-4f03-43aa-bfbb-45a3124d4e55
[2026-06-11 04:44:06] [INFO] Table: quotations
[2026-06-11 04:44:06] [INFO] Timestamp: 2026-06-11 04:44:06
[2026-06-11 04:44:06] [INFO] ===========================================
[2026-06-11 04:44:06] [INFO] ========== START: processQuotationSubmission ==========
[2026-06-11 04:44:06] [INFO] Function called for record ID: 097379d6-4f03-43aa-bfbb-45a3124d4e55
[2026-06-11 04:44:06] [DEBUG] Form data received: {"table":"quotations","tenant_id":"019c358b-5fe1-7e90-c3cc-a17b42a96622"}
[2026-06-11 04:44:06] [INFO] Detected table: quotations (Type: proforma)
[2026-06-11 04:44:06] [DEBUG] ID field: quotation_id, Number field: quotation_number
[2026-06-11 04:44:06] [DEBUG] STEP 1: Fetching quotation data from database
[2026-06-11 04:44:06] [DEBUG] QueryBuilder instance created
[2026-06-11 04:44:06] [DEBUG] Database query executed for quotation_id: 097379d6-4f03-43aa-bfbb-45a3124d4e55
[2026-06-11 04:44:06] [DEBUG] Quotation found successfully
[2026-06-11 04:44:06] [INFO] quotation_type from record overrides invoiceType: training
[2026-06-11 04:44:06] [DEBUG] Using org_id: 019c358b-5fe1-7e90-c3cc-a17b42a96622
[2026-06-11 04:44:06] [INFO] Fetched quotation data: {"quotation_id":"097379d6-4f03-43aa-bfbb-45a3124d4e55","quotation_number":"00023","date":"2026-06-11","customer_id":"000019ca-b8de-79c7-f5c6-87991a2c1b98","org_id":"019c358b-5fe1-7e90-c3cc-a17b42a96622","client_id":null,"line_items":"[{\"quantity\": \"2\", \"vat_rate\": \"VIP\", \"line_total\": \"7.98\", \"product_id\": \"000019cf-eac0-7231-6dd4-380ea234b5a2\", \"unit_price\": \"3.99\", \"vat_amount\": \"0.89\", \"description\": \"palmolive shamphoo 340ml \", \"line_subtotal\": \"7.98\"}]","note":null,"terms":null,"validity_days":30,"status":"expired","total_amount":"0.00","tax_amount":"0.00","template_id":null,"sent_at":null,"expires_at":"2026-06-11","accepted_at":null,"rejected_at":null,"rejection_reason":null,"converted_invoice_id":null,"created_by":null,"updated_by":null,"isdeleted":false,"updatedat":"2026-06-11 04:44:06.452102+00","taxcore_submission_id":null,"taxcore_submission_id_fk":null,"taxcore_receipt_data":null,"taxcore_submitted_at":null,"taxcore_verification_url":null,"taxcore_qr_code":null,"journal_entry_id":null,"converted_to_invoice_id":null,"po_number":null,"notes_additional":null,"payment_terms_details":null,"quotation_type":"training"}
[2026-06-11 04:44:06] [DEBUG] STEP 2: Parsing line_items JSON
[2026-06-11 04:44:06] [DEBUG] Parsed 1 line items
[2026-06-11 04:44:06] [DEBUG] Line items: [{"quantity":"2","vat_rate":"VIP","line_total":"7.98","product_id":"000019cf-eac0-7231-6dd4-380ea234b5a2","unit_price":"3.99","vat_amount":"0.89","description":"palmolive shamphoo 340ml ","line_subtotal":"7.98"}]
[2026-06-11 04:44:06] [DEBUG] STEP 3: Preparing items for TaxCore
[2026-06-11 04:44:06] [DEBUG] Processing line item: 0 -> {"quantity":"2","vat_rate":"VIP","line_total":"7.98","product_id":"000019cf-eac0-7231-6dd4-380ea234b5a2","unit_price":"3.99","vat_amount":"0.89","description":"palmolive shamphoo 340ml ","line_subtotal":"7.98"}
[2026-06-11 04:44:06] [DEBUG] Calculated - Quantity: 2, UnitPrice: 3.99, TotalAmount: 7.98
[2026-06-11 04:44:06] [DEBUG] Prepared 1 items for TaxCore
[2026-06-11 04:44:06] [INFO] TaxCore items: [{"name":"palmolive shamphoo 340ml ","quantity":2,"unitPrice":"3.99","totalAmount":"7.98","Labels":["G"]}]
[2026-06-11 04:44:06] [DEBUG] STEP 4: Preparing payment method as Credit
[2026-06-11 04:44:06] [INFO] Payment prepared (Credit): [{"paymentType":"0","amount":0}]
[2026-06-11 04:44:06] [DEBUG] STEP 5: Fetching cashier information
[2026-06-11 04:44:06] [DEBUG] User ID from formData: 019c358b-5fe1-7e90-c3cc-a17b42a96622
[2026-06-11 04:44:06] [DEBUG] Querying users table for user_id: 019c358b-5fe1-7e90-c3cc-a17b42a96622
[2026-06-11 04:44:06] [INFO] Cashier name found: System
[2026-06-11 04:44:06] [DEBUG] STEP 6: Building TaxCore payload
[2026-06-11 04:44:06] [DEBUG] Base payload created with type=training
[2026-06-11 04:44:06] [DEBUG] STEP 7: Adding customer/buyer information
[2026-06-11 04:44:06] [DEBUG] Customer ID found: 000019ca-b8de-79c7-f5c6-87991a2c1b98
[2026-06-11 04:44:06] [DEBUG] Customer found: {"name":"Test 1 Test 1jkjshfkjds","tin":null}
[2026-06-11 04:44:06] [INFO] TaxCore payload prepared: {
    "items": [
        {
            "name": "palmolive shamphoo 340ml ",
            "quantity": 2,
            "unitPrice": "3.99",
            "totalAmount": "7.98",
            "Labels": [
                "G"
            ]
        }
    ],
    "payment": [
        {
            "paymentType": "0",
            "amount": 0
        }
    ],
    "Cashier": "System",
    "type": "training",
    "invoiceNumber": "00023",
    "Buyer": {
        "Name": "Test 1 Test 1jkjshfkjds"
    }
}
[2026-06-11 04:44:06] [DEBUG] STEP 8: Creating Journal Entry in Finance module
[2026-06-11 04:44:06] [INFO] --- createJournalEntry: Starting ---
[2026-06-11 04:44:06] [INFO] Is Cancelled/Refund: NO
[2026-06-11 04:44:06] [DEBUG] Calculated totals - Subtotal: 7.98, Tax: 0.9975, Total: 8.9775
[2026-06-11 04:44:06] [DEBUG] Looking for customer-specific AR account for: Test 1 Test 1jkjshfkjds
[2026-06-11 04:44:06] [DEBUG] Customer-specific AR account not found, using parent AR account
[2026-06-11 04:44:06] [DEBUG] Found GL accounts - Revenue: 4000, Tax: 2410, Receivables: 1300 (Accounts Receivable)
[2026-06-11 04:44:06] [ERROR] ERROR creating journal entry: Undefined variable $orgId
[2026-06-11 04:44:06] [ERROR] Stack trace: #0 /var/www/POS/api/services/QuotationsProcessor.php(632): {closure}()
#1 /var/www/POS/api/services/QuotationsProcessor.php(301): App\Services\QuotationsProcessor::createJournalEntry()
#2 [internal function]: App\Services\QuotationsProcessor::processQuotationSubmission()
#3 /var/www/POS/api/services/workflow_steps/CustomFunctionStep.php(121): call_user_func_array()
#4 /var/www/POS/api/services/WorkflowEngine.php(508): App\Services\WorkflowSteps\CustomFunctionStep->execute()
#5 /var/www/POS/api/services/WorkflowEngine.php(767): App\Services\WorkflowEngine->executeStep()
#6 /var/www/POS/api/services/WorkflowEngine.php(144): App\Services\WorkflowEngine->runSteps()
#7 /var/www/POS/api/services/WorkflowEngine.php(177): App\Services\WorkflowEngine->handleEvent()
#8 /var/www/POS/api/services/WorkflowEngine.php(189): App\Services\WorkflowEngine->emit()
#9 /var/www/POS/api/controllers/GenericController.php(373): App\Services\WorkflowEngine::trigger()
#10 /var/www/POS/api/controllers/SyncController.php(212): App\Controllers\GenericController->processWorkflowEvents()
#11 /var/www/POS/api/controllers/SyncController.php(224): App\Controllers\GenericController@anonymous->exec()
#12 /var/www/POS/api/controllers/SyncController.php(1330): App\Controllers\SyncController->triggerWorkflow()
#13 /var/www/POS/api/router.php(272): App\Controllers\SyncController->push()
#14 /var/www/POS/api/index.php(32): require_once('...')
#15 {main}
[2026-06-11 04:44:06] [WARN] WARNING: Journal entry creation failed: Undefined variable $orgId
[2026-06-11 04:44:06] [DEBUG] STEP 9: Checking if TaxCore integration is enabled
[2026-06-11 04:44:06] [DEBUG] Checking TaxCore integration status for org_id: 019c358b-5fe1-7e90-c3cc-a17b42a96622 (table: quotations)
[2026-06-11 04:44:06] [INFO] Found quotation_taxcore_enabled in orgs.settings: false
[2026-06-11 04:44:06] [INFO] TaxCore integration enabled: NO
[2026-06-11 04:44:06] [INFO] TaxCore integration is disabled - skipping TaxCore submission
[2026-06-11 04:44:06] [INFO] TaxCore call completed successfully
[2026-06-11 04:44:06] [INFO] TaxCore response: {
    "skipped": true,
    "reason": "TaxCore integration disabled for this organization",
    "invoiceNumber": null
}
[2026-06-11 04:44:06] [DEBUG] STEP 10: Updating quotations record with TaxCore and Journal Entry details
[2026-06-11 04:44:06] [DEBUG] Update data prepared: {"quotation_id":"097379d6-4f03-43aa-bfbb-45a3124d4e55"}
[2026-06-11 04:44:06] [INFO] Quotations record updated successfully
[2026-06-11 04:44:06] [INFO] Skipping sales_receipts insert - TaxCore disabled or submission failed
[2026-06-11 04:44:06] [DEBUG] STEP 12: Saving audit file to storage
[2026-06-11 04:44:06] [DEBUG] Storage file path: /var/www/POS/storage/quotations/quotation_097379d6-4f03-43aa-bfbb-45a3124d4e55_2026-06-11_04-44-06.json
[2026-06-11 04:44:06] [INFO] Audit file saved successfully to: /var/www/POS/storage/quotations/quotation_097379d6-4f03-43aa-bfbb-45a3124d4e55_2026-06-11_04-44-06.json
[2026-06-11 04:44:06] [DEBUG] STEP 13: Preparing final result
[2026-06-11 04:44:06] [INFO] ========== SUCCESS: Process completed ==========
[2026-06-11 04:44:06] [INFO] Final result: {"success":true,"message":"Quotations processed successfully (TaxCore disabled)","record_id":"097379d6-4f03-43aa-bfbb-45a3124d4e55","table":"quotations","invoice_type":"training","taxcore_enabled":false,"journal_entry_id":null,"journal_entry_number":null,"taxcore_invoice_number":null,"taxcore_verification_url":null,"taxcore_skipped":true,"processed_at":"2026-06-11 04:44:06","saved_to":"\/var\/www\/POS\/storage\/quotations\/quotation_097379d6-4f03-43aa-bfbb-45a3124d4e55_2026-06-11_04-44-06.json","log_file":"\/var\/www\/POS\/storage\/quotations\/logs\/quotation_097379d6-4f03-43aa-bfbb-45a3124d4e55_2026-06-11_04-44-06.log"}
