[2026-04-14 02:45:35] [INFO] ===========================================
[2026-04-14 02:45:35] [INFO] Quotations Processor Log
[2026-04-14 02:45:35] [INFO] Record ID: 000019d8-9e13-7fa2-ffa8-7539ff83abe2
[2026-04-14 02:45:35] [INFO] Table: quotations
[2026-04-14 02:45:35] [INFO] Timestamp: 2026-04-14 02:45:35
[2026-04-14 02:45:35] [INFO] ===========================================
[2026-04-14 02:45:35] [INFO] ========== START: processQuotationSubmission ==========
[2026-04-14 02:45:35] [INFO] Function called for record ID: 000019d8-9e13-7fa2-ffa8-7539ff83abe2
[2026-04-14 02:45:35] [DEBUG] Form data received: {"table":"quotations","tenant_id":"019c6fa4-12e6-7bda-e3b6-3340a31436d2"}
[2026-04-14 02:45:35] [INFO] Detected table: quotations (Type: proforma)
[2026-04-14 02:45:35] [DEBUG] ID field: quotation_id, Number field: quotation_number
[2026-04-14 02:45:35] [DEBUG] STEP 1: Fetching quotation data from database
[2026-04-14 02:45:35] [DEBUG] QueryBuilder instance created
[2026-04-14 02:45:35] [DEBUG] Database query executed for quotation_id: 000019d8-9e13-7fa2-ffa8-7539ff83abe2
[2026-04-14 02:45:35] [DEBUG] Quotation found successfully
[2026-04-14 02:45:35] [INFO] quotation_type from record overrides invoiceType: proforma
[2026-04-14 02:45:35] [DEBUG] Using org_id: 019c6fa4-12e6-7bda-e3b6-3340a31436d2
[2026-04-14 02:45:35] [INFO] Fetched quotation data: {"quotation_id":"000019d8-9e13-7fa2-ffa8-7539ff83abe2","quotation_number":"00009","date":"2026-04-14","customer_id":"000019d8-9d6a-7cd0-6bba-d904655c77e7","org_id":"019c6fa4-12e6-7bda-e3b6-3340a31436d2","client_id":null,"line_items":"{\"row_0\": {\"quantity\": \"2\", \"vat_rate\": \"VIP\", \"line_total\": \"900\", \"product_id\": \"000019c6-fa96-7b3f-9359-8ac2da0c5bd8\", \"unit_price\": \"450.00\", \"vat_amount\": \"100\", \"description\": \"Room number 101\", \"line_subtotal\": \"900\"}, \"row_1\": {\"quantity\": \"2\", \"vat_rate\": \"VIP\", \"line_total\": \"400\", \"product_id\": \"000019c6-ffc2-7e03-06e6-84afc7b3f6db\", \"unit_price\": \"200.00\", \"vat_amount\": \"44.44\", \"description\": \"deluxe room\", \"line_subtotal\": \"400\"}, \"row_2\": {\"quantity\": \"2\", \"vat_rate\": \"VIP\", \"line_total\": \"400\", \"product_id\": \"000019c6-ffc7-741b-5ac1-b20a6c71e996\", \"unit_price\": \"200.00\", \"vat_amount\": \"44.44\", \"description\": \"deluxe room\", \"line_subtotal\": \"400\"}, \"row_3\": {\"quantity\": \"2\", \"vat_rate\": \"VIP\", \"line_total\": \"600\", \"product_id\": \"000019c6-ffe8-7c1b-092a-79e36d3c4ec0\", \"unit_price\": \"300.00\", \"vat_amount\": \"66.67\", \"description\": \"dormitory\", \"line_subtotal\": \"600\"}, \"row_4\": {\"quantity\": \"2\", \"vat_rate\": \"VIP\", \"line_total\": \"400\", \"product_id\": \"000019c6-ffee-7ccb-ac36-4e9f44a83c12\", \"unit_price\": \"200.00\", \"vat_amount\": \"44.44\", \"description\": \"Standard Double room\", \"line_subtotal\": \"400\"}}","note":null,"terms":null,"validity_days":30,"status":"expired","total_amount":"2700.00","tax_amount":"299.99","template_id":null,"sent_at":null,"expires_at":"2026-04-14","accepted_at":null,"rejected_at":null,"rejection_reason":null,"converted_invoice_id":null,"created_by":null,"updated_by":null,"isdeleted":false,"updatedat":"2026-04-14 02:45:35.572883+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":"ALL ROOMS ARE INCLUSIVE OF BREAKFAST..","payment_terms_details":"CHECK IN 23\/10\/2026  ..CHECK OUT 25\/10\/2026","quotation_type":"proforma"}
[2026-04-14 02:45:35] [DEBUG] STEP 2: Parsing line_items JSON
[2026-04-14 02:45:35] [DEBUG] Parsed 5 line items
[2026-04-14 02:45:35] [DEBUG] Line items: {"row_0":{"quantity":"2","vat_rate":"VIP","line_total":"900","product_id":"000019c6-fa96-7b3f-9359-8ac2da0c5bd8","unit_price":"450.00","vat_amount":"100","description":"Room number 101","line_subtotal":"900"},"row_1":{"quantity":"2","vat_rate":"VIP","line_total":"400","product_id":"000019c6-ffc2-7e03-06e6-84afc7b3f6db","unit_price":"200.00","vat_amount":"44.44","description":"deluxe room","line_subtotal":"400"},"row_2":{"quantity":"2","vat_rate":"VIP","line_total":"400","product_id":"000019c6-ffc7-741b-5ac1-b20a6c71e996","unit_price":"200.00","vat_amount":"44.44","description":"deluxe room","line_subtotal":"400"},"row_3":{"quantity":"2","vat_rate":"VIP","line_total":"600","product_id":"000019c6-ffe8-7c1b-092a-79e36d3c4ec0","unit_price":"300.00","vat_amount":"66.67","description":"dormitory","line_subtotal":"600"},"row_4":{"quantity":"2","vat_rate":"VIP","line_total":"400","product_id":"000019c6-ffee-7ccb-ac36-4e9f44a83c12","unit_price":"200.00","vat_amount":"44.44","description":"Standard Double room","line_subtotal":"400"}}
[2026-04-14 02:45:35] [DEBUG] STEP 3: Preparing items for TaxCore
[2026-04-14 02:45:35] [DEBUG] Processing line item: row_0 -> {"quantity":"2","vat_rate":"VIP","line_total":"900","product_id":"000019c6-fa96-7b3f-9359-8ac2da0c5bd8","unit_price":"450.00","vat_amount":"100","description":"Room number 101","line_subtotal":"900"}
[2026-04-14 02:45:35] [DEBUG] Calculated - Quantity: 2, UnitPrice: 450, TotalAmount: 900
[2026-04-14 02:45:35] [DEBUG] Processing line item: row_1 -> {"quantity":"2","vat_rate":"VIP","line_total":"400","product_id":"000019c6-ffc2-7e03-06e6-84afc7b3f6db","unit_price":"200.00","vat_amount":"44.44","description":"deluxe room","line_subtotal":"400"}
[2026-04-14 02:45:35] [DEBUG] Calculated - Quantity: 2, UnitPrice: 200, TotalAmount: 400
[2026-04-14 02:45:35] [DEBUG] Processing line item: row_2 -> {"quantity":"2","vat_rate":"VIP","line_total":"400","product_id":"000019c6-ffc7-741b-5ac1-b20a6c71e996","unit_price":"200.00","vat_amount":"44.44","description":"deluxe room","line_subtotal":"400"}
[2026-04-14 02:45:35] [DEBUG] Calculated - Quantity: 2, UnitPrice: 200, TotalAmount: 400
[2026-04-14 02:45:35] [DEBUG] Processing line item: row_3 -> {"quantity":"2","vat_rate":"VIP","line_total":"600","product_id":"000019c6-ffe8-7c1b-092a-79e36d3c4ec0","unit_price":"300.00","vat_amount":"66.67","description":"dormitory","line_subtotal":"600"}
[2026-04-14 02:45:35] [DEBUG] Calculated - Quantity: 2, UnitPrice: 300, TotalAmount: 600
[2026-04-14 02:45:35] [DEBUG] Processing line item: row_4 -> {"quantity":"2","vat_rate":"VIP","line_total":"400","product_id":"000019c6-ffee-7ccb-ac36-4e9f44a83c12","unit_price":"200.00","vat_amount":"44.44","description":"Standard Double room","line_subtotal":"400"}
[2026-04-14 02:45:35] [DEBUG] Calculated - Quantity: 2, UnitPrice: 200, TotalAmount: 400
[2026-04-14 02:45:35] [DEBUG] Prepared 5 items for TaxCore
[2026-04-14 02:45:35] [INFO] TaxCore items: [{"name":"Room number 101","quantity":2,"unitPrice":"450.00","totalAmount":"900.00","Labels":["G"]},{"name":"deluxe room","quantity":2,"unitPrice":"200.00","totalAmount":"400.00","Labels":["G"]},{"name":"deluxe room","quantity":2,"unitPrice":"200.00","totalAmount":"400.00","Labels":["G"]},{"name":"dormitory","quantity":2,"unitPrice":"300.00","totalAmount":"600.00","Labels":["G"]},{"name":"Standard Double room","quantity":2,"unitPrice":"200.00","totalAmount":"400.00","Labels":["G"]}]
[2026-04-14 02:45:35] [DEBUG] STEP 4: Preparing payment method as Credit
[2026-04-14 02:45:35] [INFO] Payment prepared (Credit): [{"paymentType":"0","amount":2700}]
[2026-04-14 02:45:35] [DEBUG] STEP 5: Fetching cashier information
[2026-04-14 02:45:35] [DEBUG] User ID from formData: 019c6fa4-12e6-7bda-e3b6-3340a31436d2
[2026-04-14 02:45:35] [DEBUG] Querying users table for user_id: 019c6fa4-12e6-7bda-e3b6-3340a31436d2
[2026-04-14 02:45:35] [INFO] Cashier name found: System
[2026-04-14 02:45:35] [DEBUG] STEP 6: Building TaxCore payload
[2026-04-14 02:45:35] [DEBUG] Base payload created with type=proforma
[2026-04-14 02:45:35] [DEBUG] STEP 7: Adding customer/buyer information
[2026-04-14 02:45:35] [DEBUG] Customer ID found: 000019d8-9d6a-7cd0-6bba-d904655c77e7
[2026-04-14 02:45:35] [DEBUG] Customer found: {"name":"65 years birth day party","tin":null}
[2026-04-14 02:45:35] [INFO] TaxCore payload prepared: {
    "items": [
        {
            "name": "Room number 101",
            "quantity": 2,
            "unitPrice": "450.00",
            "totalAmount": "900.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "deluxe room",
            "quantity": 2,
            "unitPrice": "200.00",
            "totalAmount": "400.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "deluxe room",
            "quantity": 2,
            "unitPrice": "200.00",
            "totalAmount": "400.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "dormitory",
            "quantity": 2,
            "unitPrice": "300.00",
            "totalAmount": "600.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Standard Double room",
            "quantity": 2,
            "unitPrice": "200.00",
            "totalAmount": "400.00",
            "Labels": [
                "G"
            ]
        }
    ],
    "payment": [
        {
            "paymentType": "0",
            "amount": 2700
        }
    ],
    "Cashier": "System",
    "type": "proforma",
    "invoiceNumber": "00009",
    "Buyer": {
        "Name": "65 years birth day party"
    }
}
[2026-04-14 02:45:35] [DEBUG] STEP 8: Creating Journal Entry in Finance module
[2026-04-14 02:45:35] [INFO] --- createJournalEntry: Starting ---
[2026-04-14 02:45:35] [INFO] Is Cancelled/Refund: NO
[2026-04-14 02:45:35] [DEBUG] Calculated totals - Subtotal: 2700, Tax: 337.5, Total: 3037.5
[2026-04-14 02:45:35] [DEBUG] Looking for customer-specific AR account for: 65 years birth day party
[2026-04-14 02:45:35] [INFO] Found customer-specific AR account: 1300-017 - AR - 65 years birth day party
[2026-04-14 02:45:35] [DEBUG] Found GL accounts - Revenue: 4000, Tax: 2410, Receivables: 1300-017 (AR - 65 years birth day party)
[2026-04-14 02:45:35] [ERROR] ERROR creating journal entry: Undefined variable $orgId
[2026-04-14 02:45:35] [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(507): App\Services\WorkflowSteps\CustomFunctionStep->execute()
#5 /var/www/POS/api/services/WorkflowEngine.php(766): App\Services\WorkflowEngine->executeStep()
#6 /var/www/POS/api/services/WorkflowEngine.php(143): App\Services\WorkflowEngine->runSteps()
#7 /var/www/POS/api/services/WorkflowEngine.php(176): App\Services\WorkflowEngine->handleEvent()
#8 /var/www/POS/api/services/WorkflowEngine.php(188): 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(202): App\Controllers\GenericController->processWorkflowEvents()
#11 /var/www/POS/api/controllers/SyncController.php(214): App\Controllers\GenericController@anonymous->exec()
#12 /var/www/POS/api/controllers/SyncController.php(1321): App\Controllers\SyncController->triggerWorkflow()
#13 /var/www/POS/api/router.php(270): App\Controllers\SyncController->push()
#14 /var/www/POS/api/index.php(32): require_once('...')
#15 {main}
[2026-04-14 02:45:35] [WARN] WARNING: Journal entry creation failed: Undefined variable $orgId
[2026-04-14 02:45:35] [DEBUG] STEP 9: Checking if TaxCore integration is enabled
[2026-04-14 02:45:35] [DEBUG] Checking TaxCore integration status for org_id: 019c6fa4-12e6-7bda-e3b6-3340a31436d2 (table: quotations)
[2026-04-14 02:45:35] [INFO] TIN found, TaxCore could be enabled but no explicit setting - defaulting to false for safety
[2026-04-14 02:45:35] [INFO] No TaxCore configuration found for org_id: 019c6fa4-12e6-7bda-e3b6-3340a31436d2, defaulting to disabled
[2026-04-14 02:45:35] [INFO] TaxCore integration enabled: NO
[2026-04-14 02:45:35] [INFO] TaxCore integration is disabled - skipping TaxCore submission
[2026-04-14 02:45:35] [INFO] TaxCore call completed successfully
[2026-04-14 02:45:35] [INFO] TaxCore response: {
    "skipped": true,
    "reason": "TaxCore integration disabled for this organization",
    "invoiceNumber": null
}
[2026-04-14 02:45:35] [DEBUG] STEP 10: Updating quotations record with TaxCore and Journal Entry details
[2026-04-14 02:45:35] [DEBUG] Update data prepared: {"quotation_id":"000019d8-9e13-7fa2-ffa8-7539ff83abe2"}
[2026-04-14 02:45:35] [INFO] Quotations record updated successfully
[2026-04-14 02:45:35] [INFO] Skipping sales_receipts insert - TaxCore disabled or submission failed
[2026-04-14 02:45:35] [DEBUG] STEP 12: Saving audit file to storage
[2026-04-14 02:45:35] [DEBUG] Storage file path: /var/www/POS/storage/quotations/quotation_000019d8-9e13-7fa2-ffa8-7539ff83abe2_2026-04-14_02-45-35.json
[2026-04-14 02:45:35] [INFO] Audit file saved successfully to: /var/www/POS/storage/quotations/quotation_000019d8-9e13-7fa2-ffa8-7539ff83abe2_2026-04-14_02-45-35.json
[2026-04-14 02:45:35] [DEBUG] STEP 13: Preparing final result
[2026-04-14 02:45:35] [INFO] ========== SUCCESS: Process completed ==========
[2026-04-14 02:45:35] [INFO] Final result: {"success":true,"message":"Quotations processed successfully (TaxCore disabled)","record_id":"000019d8-9e13-7fa2-ffa8-7539ff83abe2","table":"quotations","invoice_type":"proforma","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-04-14 02:45:35","saved_to":"\/var\/www\/POS\/storage\/quotations\/quotation_000019d8-9e13-7fa2-ffa8-7539ff83abe2_2026-04-14_02-45-35.json","log_file":"\/var\/www\/POS\/storage\/quotations\/logs\/quotation_000019d8-9e13-7fa2-ffa8-7539ff83abe2_2026-04-14_02-45-35.log"}
[2026-04-14 02:45:35] [INFO] ===========================================
[2026-04-14 02:45:35] [INFO] Quotations Processor Log
[2026-04-14 02:45:35] [INFO] Record ID: 000019d8-9e13-7fa2-ffa8-7539ff83abe2
[2026-04-14 02:45:35] [INFO] Table: quotations
[2026-04-14 02:45:35] [INFO] Timestamp: 2026-04-14 02:45:35
[2026-04-14 02:45:35] [INFO] ===========================================
[2026-04-14 02:45:35] [INFO] ========== START: processQuotationSubmission ==========
[2026-04-14 02:45:35] [INFO] Function called for record ID: 000019d8-9e13-7fa2-ffa8-7539ff83abe2
[2026-04-14 02:45:35] [DEBUG] Form data received: {"table":"quotations","tenant_id":"019c6fa4-12e6-7bda-e3b6-3340a31436d2"}
[2026-04-14 02:45:35] [INFO] Detected table: quotations (Type: proforma)
[2026-04-14 02:45:35] [DEBUG] ID field: quotation_id, Number field: quotation_number
[2026-04-14 02:45:35] [DEBUG] STEP 1: Fetching quotation data from database
[2026-04-14 02:45:35] [DEBUG] QueryBuilder instance created
[2026-04-14 02:45:35] [DEBUG] Database query executed for quotation_id: 000019d8-9e13-7fa2-ffa8-7539ff83abe2
[2026-04-14 02:45:35] [DEBUG] Quotation found successfully
[2026-04-14 02:45:35] [INFO] quotation_type from record overrides invoiceType: proforma
[2026-04-14 02:45:35] [DEBUG] Using org_id: 019c6fa4-12e6-7bda-e3b6-3340a31436d2
[2026-04-14 02:45:35] [INFO] Fetched quotation data: {"quotation_id":"000019d8-9e13-7fa2-ffa8-7539ff83abe2","quotation_number":"00009","date":"2026-04-14","customer_id":"000019d8-9d6a-7cd0-6bba-d904655c77e7","org_id":"019c6fa4-12e6-7bda-e3b6-3340a31436d2","client_id":null,"line_items":"{\"row_0\": {\"quantity\": \"2\", \"vat_rate\": \"VIP\", \"line_total\": \"900\", \"product_id\": \"000019c6-fa96-7b3f-9359-8ac2da0c5bd8\", \"unit_price\": \"450.00\", \"vat_amount\": \"100\", \"description\": \"Room number 101\", \"line_subtotal\": \"900\"}, \"row_1\": {\"quantity\": \"2\", \"vat_rate\": \"VIP\", \"line_total\": \"400\", \"product_id\": \"000019c6-ffc2-7e03-06e6-84afc7b3f6db\", \"unit_price\": \"200.00\", \"vat_amount\": \"44.44\", \"description\": \"deluxe room\", \"line_subtotal\": \"400\"}, \"row_2\": {\"quantity\": \"2\", \"vat_rate\": \"VIP\", \"line_total\": \"400\", \"product_id\": \"000019c6-ffc7-741b-5ac1-b20a6c71e996\", \"unit_price\": \"200.00\", \"vat_amount\": \"44.44\", \"description\": \"deluxe room\", \"line_subtotal\": \"400\"}, \"row_3\": {\"quantity\": \"2\", \"vat_rate\": \"VIP\", \"line_total\": \"600\", \"product_id\": \"000019c6-ffe8-7c1b-092a-79e36d3c4ec0\", \"unit_price\": \"300.00\", \"vat_amount\": \"66.67\", \"description\": \"dormitory\", \"line_subtotal\": \"600\"}, \"row_4\": {\"quantity\": \"2\", \"vat_rate\": \"VIP\", \"line_total\": \"400\", \"product_id\": \"000019c6-ffee-7ccb-ac36-4e9f44a83c12\", \"unit_price\": \"200.00\", \"vat_amount\": \"44.44\", \"description\": \"Standard Double room\", \"line_subtotal\": \"400\"}}","note":null,"terms":null,"validity_days":30,"status":"expired","total_amount":"2700.00","tax_amount":"299.99","template_id":null,"sent_at":null,"expires_at":"2026-04-14","accepted_at":null,"rejected_at":null,"rejection_reason":null,"converted_invoice_id":null,"created_by":null,"updated_by":null,"isdeleted":false,"updatedat":"2026-04-14 02:45:35.616849+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":"ALL ROOMS ARE INCLUSIVE OF BREAKFAST..","payment_terms_details":"CHECK IN 23\/10\/2026  ..CHECK OUT 25\/10\/2026","quotation_type":"proforma"}
[2026-04-14 02:45:35] [DEBUG] STEP 2: Parsing line_items JSON
[2026-04-14 02:45:35] [DEBUG] Parsed 5 line items
[2026-04-14 02:45:35] [DEBUG] Line items: {"row_0":{"quantity":"2","vat_rate":"VIP","line_total":"900","product_id":"000019c6-fa96-7b3f-9359-8ac2da0c5bd8","unit_price":"450.00","vat_amount":"100","description":"Room number 101","line_subtotal":"900"},"row_1":{"quantity":"2","vat_rate":"VIP","line_total":"400","product_id":"000019c6-ffc2-7e03-06e6-84afc7b3f6db","unit_price":"200.00","vat_amount":"44.44","description":"deluxe room","line_subtotal":"400"},"row_2":{"quantity":"2","vat_rate":"VIP","line_total":"400","product_id":"000019c6-ffc7-741b-5ac1-b20a6c71e996","unit_price":"200.00","vat_amount":"44.44","description":"deluxe room","line_subtotal":"400"},"row_3":{"quantity":"2","vat_rate":"VIP","line_total":"600","product_id":"000019c6-ffe8-7c1b-092a-79e36d3c4ec0","unit_price":"300.00","vat_amount":"66.67","description":"dormitory","line_subtotal":"600"},"row_4":{"quantity":"2","vat_rate":"VIP","line_total":"400","product_id":"000019c6-ffee-7ccb-ac36-4e9f44a83c12","unit_price":"200.00","vat_amount":"44.44","description":"Standard Double room","line_subtotal":"400"}}
[2026-04-14 02:45:35] [DEBUG] STEP 3: Preparing items for TaxCore
[2026-04-14 02:45:35] [DEBUG] Processing line item: row_0 -> {"quantity":"2","vat_rate":"VIP","line_total":"900","product_id":"000019c6-fa96-7b3f-9359-8ac2da0c5bd8","unit_price":"450.00","vat_amount":"100","description":"Room number 101","line_subtotal":"900"}
[2026-04-14 02:45:35] [DEBUG] Calculated - Quantity: 2, UnitPrice: 450, TotalAmount: 900
[2026-04-14 02:45:35] [DEBUG] Processing line item: row_1 -> {"quantity":"2","vat_rate":"VIP","line_total":"400","product_id":"000019c6-ffc2-7e03-06e6-84afc7b3f6db","unit_price":"200.00","vat_amount":"44.44","description":"deluxe room","line_subtotal":"400"}
[2026-04-14 02:45:35] [DEBUG] Calculated - Quantity: 2, UnitPrice: 200, TotalAmount: 400
[2026-04-14 02:45:35] [DEBUG] Processing line item: row_2 -> {"quantity":"2","vat_rate":"VIP","line_total":"400","product_id":"000019c6-ffc7-741b-5ac1-b20a6c71e996","unit_price":"200.00","vat_amount":"44.44","description":"deluxe room","line_subtotal":"400"}
[2026-04-14 02:45:35] [DEBUG] Calculated - Quantity: 2, UnitPrice: 200, TotalAmount: 400
[2026-04-14 02:45:35] [DEBUG] Processing line item: row_3 -> {"quantity":"2","vat_rate":"VIP","line_total":"600","product_id":"000019c6-ffe8-7c1b-092a-79e36d3c4ec0","unit_price":"300.00","vat_amount":"66.67","description":"dormitory","line_subtotal":"600"}
[2026-04-14 02:45:35] [DEBUG] Calculated - Quantity: 2, UnitPrice: 300, TotalAmount: 600
[2026-04-14 02:45:35] [DEBUG] Processing line item: row_4 -> {"quantity":"2","vat_rate":"VIP","line_total":"400","product_id":"000019c6-ffee-7ccb-ac36-4e9f44a83c12","unit_price":"200.00","vat_amount":"44.44","description":"Standard Double room","line_subtotal":"400"}
[2026-04-14 02:45:35] [DEBUG] Calculated - Quantity: 2, UnitPrice: 200, TotalAmount: 400
[2026-04-14 02:45:35] [DEBUG] Prepared 5 items for TaxCore
[2026-04-14 02:45:35] [INFO] TaxCore items: [{"name":"Room number 101","quantity":2,"unitPrice":"450.00","totalAmount":"900.00","Labels":["G"]},{"name":"deluxe room","quantity":2,"unitPrice":"200.00","totalAmount":"400.00","Labels":["G"]},{"name":"deluxe room","quantity":2,"unitPrice":"200.00","totalAmount":"400.00","Labels":["G"]},{"name":"dormitory","quantity":2,"unitPrice":"300.00","totalAmount":"600.00","Labels":["G"]},{"name":"Standard Double room","quantity":2,"unitPrice":"200.00","totalAmount":"400.00","Labels":["G"]}]
[2026-04-14 02:45:35] [DEBUG] STEP 4: Preparing payment method as Credit
[2026-04-14 02:45:35] [INFO] Payment prepared (Credit): [{"paymentType":"0","amount":2700}]
[2026-04-14 02:45:35] [DEBUG] STEP 5: Fetching cashier information
[2026-04-14 02:45:35] [DEBUG] User ID from formData: 019c6fa4-12e6-7bda-e3b6-3340a31436d2
[2026-04-14 02:45:35] [DEBUG] Querying users table for user_id: 019c6fa4-12e6-7bda-e3b6-3340a31436d2
[2026-04-14 02:45:35] [INFO] Cashier name found: System
[2026-04-14 02:45:35] [DEBUG] STEP 6: Building TaxCore payload
[2026-04-14 02:45:35] [DEBUG] Base payload created with type=proforma
[2026-04-14 02:45:35] [DEBUG] STEP 7: Adding customer/buyer information
[2026-04-14 02:45:35] [DEBUG] Customer ID found: 000019d8-9d6a-7cd0-6bba-d904655c77e7
[2026-04-14 02:45:35] [DEBUG] Customer found: {"name":"65 years birth day party","tin":null}
[2026-04-14 02:45:35] [INFO] TaxCore payload prepared: {
    "items": [
        {
            "name": "Room number 101",
            "quantity": 2,
            "unitPrice": "450.00",
            "totalAmount": "900.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "deluxe room",
            "quantity": 2,
            "unitPrice": "200.00",
            "totalAmount": "400.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "deluxe room",
            "quantity": 2,
            "unitPrice": "200.00",
            "totalAmount": "400.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "dormitory",
            "quantity": 2,
            "unitPrice": "300.00",
            "totalAmount": "600.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Standard Double room",
            "quantity": 2,
            "unitPrice": "200.00",
            "totalAmount": "400.00",
            "Labels": [
                "G"
            ]
        }
    ],
    "payment": [
        {
            "paymentType": "0",
            "amount": 2700
        }
    ],
    "Cashier": "System",
    "type": "proforma",
    "invoiceNumber": "00009",
    "Buyer": {
        "Name": "65 years birth day party"
    }
}
[2026-04-14 02:45:35] [DEBUG] STEP 8: Creating Journal Entry in Finance module
[2026-04-14 02:45:35] [INFO] --- createJournalEntry: Starting ---
[2026-04-14 02:45:35] [INFO] Is Cancelled/Refund: NO
[2026-04-14 02:45:35] [DEBUG] Calculated totals - Subtotal: 2700, Tax: 337.5, Total: 3037.5
[2026-04-14 02:45:35] [DEBUG] Looking for customer-specific AR account for: 65 years birth day party
[2026-04-14 02:45:35] [INFO] Found customer-specific AR account: 1300-017 - AR - 65 years birth day party
[2026-04-14 02:45:35] [DEBUG] Found GL accounts - Revenue: 4000, Tax: 2410, Receivables: 1300-017 (AR - 65 years birth day party)
[2026-04-14 02:45:35] [ERROR] ERROR creating journal entry: Undefined variable $orgId
[2026-04-14 02:45:35] [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(507): App\Services\WorkflowSteps\CustomFunctionStep->execute()
#5 /var/www/POS/api/services/WorkflowEngine.php(766): App\Services\WorkflowEngine->executeStep()
#6 /var/www/POS/api/services/WorkflowEngine.php(143): App\Services\WorkflowEngine->runSteps()
#7 /var/www/POS/api/services/WorkflowEngine.php(176): App\Services\WorkflowEngine->handleEvent()
#8 /var/www/POS/api/services/WorkflowEngine.php(188): 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(202): App\Controllers\GenericController->processWorkflowEvents()
#11 /var/www/POS/api/controllers/SyncController.php(214): App\Controllers\GenericController@anonymous->exec()
#12 /var/www/POS/api/controllers/SyncController.php(1321): App\Controllers\SyncController->triggerWorkflow()
#13 /var/www/POS/api/router.php(270): App\Controllers\SyncController->push()
#14 /var/www/POS/api/index.php(32): require_once('...')
#15 {main}
[2026-04-14 02:45:35] [WARN] WARNING: Journal entry creation failed: Undefined variable $orgId
[2026-04-14 02:45:35] [DEBUG] STEP 9: Checking if TaxCore integration is enabled
[2026-04-14 02:45:35] [DEBUG] Checking TaxCore integration status for org_id: 019c6fa4-12e6-7bda-e3b6-3340a31436d2 (table: quotations)
[2026-04-14 02:45:35] [INFO] TIN found, TaxCore could be enabled but no explicit setting - defaulting to false for safety
[2026-04-14 02:45:35] [INFO] No TaxCore configuration found for org_id: 019c6fa4-12e6-7bda-e3b6-3340a31436d2, defaulting to disabled
[2026-04-14 02:45:35] [INFO] TaxCore integration enabled: NO
[2026-04-14 02:45:35] [INFO] TaxCore integration is disabled - skipping TaxCore submission
[2026-04-14 02:45:35] [INFO] TaxCore call completed successfully
[2026-04-14 02:45:35] [INFO] TaxCore response: {
    "skipped": true,
    "reason": "TaxCore integration disabled for this organization",
    "invoiceNumber": null
}
[2026-04-14 02:45:35] [DEBUG] STEP 10: Updating quotations record with TaxCore and Journal Entry details
[2026-04-14 02:45:35] [DEBUG] Update data prepared: {"quotation_id":"000019d8-9e13-7fa2-ffa8-7539ff83abe2"}
[2026-04-14 02:45:35] [INFO] Quotations record updated successfully
[2026-04-14 02:45:35] [INFO] Skipping sales_receipts insert - TaxCore disabled or submission failed
[2026-04-14 02:45:35] [DEBUG] STEP 12: Saving audit file to storage
[2026-04-14 02:45:35] [DEBUG] Storage file path: /var/www/POS/storage/quotations/quotation_000019d8-9e13-7fa2-ffa8-7539ff83abe2_2026-04-14_02-45-35.json
[2026-04-14 02:45:35] [INFO] Audit file saved successfully to: /var/www/POS/storage/quotations/quotation_000019d8-9e13-7fa2-ffa8-7539ff83abe2_2026-04-14_02-45-35.json
[2026-04-14 02:45:35] [DEBUG] STEP 13: Preparing final result
[2026-04-14 02:45:35] [INFO] ========== SUCCESS: Process completed ==========
[2026-04-14 02:45:35] [INFO] Final result: {"success":true,"message":"Quotations processed successfully (TaxCore disabled)","record_id":"000019d8-9e13-7fa2-ffa8-7539ff83abe2","table":"quotations","invoice_type":"proforma","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-04-14 02:45:35","saved_to":"\/var\/www\/POS\/storage\/quotations\/quotation_000019d8-9e13-7fa2-ffa8-7539ff83abe2_2026-04-14_02-45-35.json","log_file":"\/var\/www\/POS\/storage\/quotations\/logs\/quotation_000019d8-9e13-7fa2-ffa8-7539ff83abe2_2026-04-14_02-45-35.log"}
