[2026-06-14 20:18:16] [INFO] ===========================================
[2026-06-14 20:18:16] [INFO] Quotations Processor Log
[2026-06-14 20:18:16] [INFO] Record ID: 000019ec-7c8f-70b6-8573-518fbca598d3
[2026-06-14 20:18:16] [INFO] Table: quotations
[2026-06-14 20:18:16] [INFO] Timestamp: 2026-06-14 20:18:16
[2026-06-14 20:18:16] [INFO] ===========================================
[2026-06-14 20:18:16] [INFO] ========== START: processQuotationSubmission ==========
[2026-06-14 20:18:16] [INFO] Function called for record ID: 000019ec-7c8f-70b6-8573-518fbca598d3
[2026-06-14 20:18:16] [DEBUG] Form data received: {"table":"quotations","tenant_id":"019bafe2-05ad-7b4a-c449-ebcb1b933597"}
[2026-06-14 20:18:16] [INFO] Detected table: quotations (Type: proforma)
[2026-06-14 20:18:16] [DEBUG] ID field: quotation_id, Number field: quotation_number
[2026-06-14 20:18:16] [DEBUG] STEP 1: Fetching quotation data from database
[2026-06-14 20:18:16] [DEBUG] QueryBuilder instance created
[2026-06-14 20:18:16] [DEBUG] Database query executed for quotation_id: 000019ec-7c8f-70b6-8573-518fbca598d3
[2026-06-14 20:18:16] [DEBUG] Quotation found successfully
[2026-06-14 20:18:16] [INFO] quotation_type from record overrides invoiceType: proforma
[2026-06-14 20:18:16] [DEBUG] Using org_id: 019bafe2-05ad-7b4a-c449-ebcb1b933597
[2026-06-14 20:18:16] [INFO] Fetched quotation data: {"quotation_id":"000019ec-7c8f-70b6-8573-518fbca598d3","quotation_number":"00068","date":"2026-06-09","customer_id":"019bd483-6577-7a66-9ac3-652ee8c6e1e9","org_id":"019bafe2-05ad-7b4a-c449-ebcb1b933597","client_id":null,"line_items":"{\"row_0\": {\"quantity\": \"20.80\", \"vat_rate\": \"12.5\", \"line_total\": \"1017.9\", \"product_id\": \"000019e1-8cec-700b-fa54-8df3ba665cb2\", \"unit_price\": \"43.50\", \"vat_amount\": \"113.1\", \"description\": \"KG\", \"line_subtotal\": \"904.8\"}, \"row_1\": {\"quantity\": \"20.75\", \"vat_rate\": \"12.5\", \"line_total\": \"735.33\", \"product_id\": \"000019e1-8e31-79cd-f5bd-5650384751b6\", \"unit_price\": \"31.50\", \"vat_amount\": \"81.7\", \"description\": \"KG\", \"line_subtotal\": \"653.63\"}, \"row_2\": {\"quantity\": \"15.95\", \"vat_rate\": \"12.5\", \"line_total\": \"780.56\", \"product_id\": \"000019e1-8e84-7286-d73f-64c49ad2bdc6\", \"unit_price\": \"43.50\", \"vat_amount\": \"86.73\", \"description\": \"KG\", \"line_subtotal\": \"693.83\"}, \"row_3\": {\"quantity\": \"15.80\", \"vat_rate\": \"12.5\", \"line_total\": \"763.44\", \"product_id\": \"000019e1-8de6-7976-977e-abcfc93e7414\", \"unit_price\": \"42.95\", \"vat_amount\": \"84.83\", \"description\": \"KG\", \"line_subtotal\": \"678.61\"}, \"row_4\": {\"quantity\": \"15.65\", \"vat_rate\": \"12.5\", \"line_total\": \"625.03\", \"product_id\": \"000019e1-8f4b-7cd5-ec26-460a26217fd6\", \"unit_price\": \"35.50\", \"vat_amount\": \"69.45\", \"description\": \"KG\", \"line_subtotal\": \"555.58\"}, \"row_5\": {\"quantity\": \"10.90\", \"vat_rate\": \"12.5\", \"line_total\": \"478.24\", \"product_id\": \"000019e1-8fa7-7375-7f22-8df72135af6a\", \"unit_price\": \"39.00\", \"vat_amount\": \"53.14\", \"description\": \"KG\", \"line_subtotal\": \"425.1\"}}","note":null,"terms":null,"validity_days":30,"status":"draft","total_amount":"4400.50","tax_amount":"488.95","template_id":null,"sent_at":null,"expires_at":"2026-06-30","accepted_at":null,"rejected_at":null,"rejection_reason":null,"converted_invoice_id":null,"created_by":null,"updated_by":null,"isdeleted":false,"updatedat":"2026-06-14 20:18:16.099254+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":"PO 15153","notes_additional":null,"payment_terms_details":null,"quotation_type":"proforma"}
[2026-06-14 20:18:16] [DEBUG] STEP 2: Parsing line_items JSON
[2026-06-14 20:18:16] [DEBUG] Parsed 6 line items
[2026-06-14 20:18:16] [DEBUG] Line items: {"row_0":{"quantity":"20.80","vat_rate":"12.5","line_total":"1017.9","product_id":"000019e1-8cec-700b-fa54-8df3ba665cb2","unit_price":"43.50","vat_amount":"113.1","description":"KG","line_subtotal":"904.8"},"row_1":{"quantity":"20.75","vat_rate":"12.5","line_total":"735.33","product_id":"000019e1-8e31-79cd-f5bd-5650384751b6","unit_price":"31.50","vat_amount":"81.7","description":"KG","line_subtotal":"653.63"},"row_2":{"quantity":"15.95","vat_rate":"12.5","line_total":"780.56","product_id":"000019e1-8e84-7286-d73f-64c49ad2bdc6","unit_price":"43.50","vat_amount":"86.73","description":"KG","line_subtotal":"693.83"},"row_3":{"quantity":"15.80","vat_rate":"12.5","line_total":"763.44","product_id":"000019e1-8de6-7976-977e-abcfc93e7414","unit_price":"42.95","vat_amount":"84.83","description":"KG","line_subtotal":"678.61"},"row_4":{"quantity":"15.65","vat_rate":"12.5","line_total":"625.03","product_id":"000019e1-8f4b-7cd5-ec26-460a26217fd6","unit_price":"35.50","vat_amount":"69.45","description":"KG","line_subtotal":"555.58"},"row_5":{"quantity":"10.90","vat_rate":"12.5","line_total":"478.24","product_id":"000019e1-8fa7-7375-7f22-8df72135af6a","unit_price":"39.00","vat_amount":"53.14","description":"KG","line_subtotal":"425.1"}}
[2026-06-14 20:18:16] [DEBUG] STEP 3: Preparing items for TaxCore
[2026-06-14 20:18:16] [DEBUG] Processing line item: row_0 -> {"quantity":"20.80","vat_rate":"12.5","line_total":"1017.9","product_id":"000019e1-8cec-700b-fa54-8df3ba665cb2","unit_price":"43.50","vat_amount":"113.1","description":"KG","line_subtotal":"904.8"}
[2026-06-14 20:18:16] [DEBUG] Calculated - Quantity: 20.8, UnitPrice: 43.5, TotalAmount: 904.8
[2026-06-14 20:18:16] [DEBUG] Processing line item: row_1 -> {"quantity":"20.75","vat_rate":"12.5","line_total":"735.33","product_id":"000019e1-8e31-79cd-f5bd-5650384751b6","unit_price":"31.50","vat_amount":"81.7","description":"KG","line_subtotal":"653.63"}
[2026-06-14 20:18:16] [DEBUG] Calculated - Quantity: 20.75, UnitPrice: 31.5, TotalAmount: 653.625
[2026-06-14 20:18:16] [DEBUG] Processing line item: row_2 -> {"quantity":"15.95","vat_rate":"12.5","line_total":"780.56","product_id":"000019e1-8e84-7286-d73f-64c49ad2bdc6","unit_price":"43.50","vat_amount":"86.73","description":"KG","line_subtotal":"693.83"}
[2026-06-14 20:18:16] [DEBUG] Calculated - Quantity: 15.95, UnitPrice: 43.5, TotalAmount: 693.825
[2026-06-14 20:18:16] [DEBUG] Processing line item: row_3 -> {"quantity":"15.80","vat_rate":"12.5","line_total":"763.44","product_id":"000019e1-8de6-7976-977e-abcfc93e7414","unit_price":"42.95","vat_amount":"84.83","description":"KG","line_subtotal":"678.61"}
[2026-06-14 20:18:16] [DEBUG] Calculated - Quantity: 15.8, UnitPrice: 42.95, TotalAmount: 678.61
[2026-06-14 20:18:16] [DEBUG] Processing line item: row_4 -> {"quantity":"15.65","vat_rate":"12.5","line_total":"625.03","product_id":"000019e1-8f4b-7cd5-ec26-460a26217fd6","unit_price":"35.50","vat_amount":"69.45","description":"KG","line_subtotal":"555.58"}
[2026-06-14 20:18:16] [DEBUG] Calculated - Quantity: 15.65, UnitPrice: 35.5, TotalAmount: 555.575
[2026-06-14 20:18:16] [DEBUG] Processing line item: row_5 -> {"quantity":"10.90","vat_rate":"12.5","line_total":"478.24","product_id":"000019e1-8fa7-7375-7f22-8df72135af6a","unit_price":"39.00","vat_amount":"53.14","description":"KG","line_subtotal":"425.1"}
[2026-06-14 20:18:16] [DEBUG] Calculated - Quantity: 10.9, UnitPrice: 39, TotalAmount: 425.1
[2026-06-14 20:18:16] [DEBUG] Prepared 6 items for TaxCore
[2026-06-14 20:18:16] [INFO] TaxCore items: [{"name":"KG","quantity":20.8,"unitPrice":"43.50","totalAmount":"904.80","Labels":["G"]},{"name":"KG","quantity":20.75,"unitPrice":"31.50","totalAmount":"653.63","Labels":["G"]},{"name":"KG","quantity":15.95,"unitPrice":"43.50","totalAmount":"693.83","Labels":["G"]},{"name":"KG","quantity":15.8,"unitPrice":"42.95","totalAmount":"678.61","Labels":["G"]},{"name":"KG","quantity":15.65,"unitPrice":"35.50","totalAmount":"555.58","Labels":["G"]},{"name":"KG","quantity":10.9,"unitPrice":"39.00","totalAmount":"425.10","Labels":["G"]}]
[2026-06-14 20:18:16] [DEBUG] STEP 4: Preparing payment method as Credit
[2026-06-14 20:18:16] [INFO] Payment prepared (Credit): [{"paymentType":"0","amount":4400.5}]
[2026-06-14 20:18:16] [DEBUG] STEP 5: Fetching cashier information
[2026-06-14 20:18:16] [DEBUG] User ID from formData: 019bafe2-05ad-7b4a-c449-ebcb1b933597
[2026-06-14 20:18:16] [DEBUG] Querying users table for user_id: 019bafe2-05ad-7b4a-c449-ebcb1b933597
[2026-06-14 20:18:16] [INFO] Cashier name found: System
[2026-06-14 20:18:16] [DEBUG] STEP 6: Building TaxCore payload
[2026-06-14 20:18:16] [DEBUG] Base payload created with type=proforma
[2026-06-14 20:18:16] [DEBUG] STEP 7: Adding customer/buyer information
[2026-06-14 20:18:16] [DEBUG] Customer ID found: 019bd483-6577-7a66-9ac3-652ee8c6e1e9
[2026-06-14 20:18:16] [DEBUG] Customer found: {"name":"Vomo Fiji Island Resort","tin":"00"}
[2026-06-14 20:18:16] [INFO] Buyer TIN added: 00
[2026-06-14 20:18:16] [INFO] TaxCore payload prepared: {
    "items": [
        {
            "name": "KG",
            "quantity": 20.8,
            "unitPrice": "43.50",
            "totalAmount": "904.80",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "KG",
            "quantity": 20.75,
            "unitPrice": "31.50",
            "totalAmount": "653.63",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "KG",
            "quantity": 15.95,
            "unitPrice": "43.50",
            "totalAmount": "693.83",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "KG",
            "quantity": 15.8,
            "unitPrice": "42.95",
            "totalAmount": "678.61",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "KG",
            "quantity": 15.65,
            "unitPrice": "35.50",
            "totalAmount": "555.58",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "KG",
            "quantity": 10.9,
            "unitPrice": "39.00",
            "totalAmount": "425.10",
            "Labels": [
                "G"
            ]
        }
    ],
    "payment": [
        {
            "paymentType": "0",
            "amount": 4400.5
        }
    ],
    "Cashier": "System",
    "type": "proforma",
    "invoiceNumber": "00068",
    "Buyer": {
        "Name": "Vomo Fiji Island Resort"
    },
    "buyerId": "00"
}
[2026-06-14 20:18:16] [DEBUG] STEP 8: Creating Journal Entry in Finance module
[2026-06-14 20:18:16] [INFO] --- createJournalEntry: Starting ---
[2026-06-14 20:18:16] [INFO] Is Cancelled/Refund: NO
[2026-06-14 20:18:16] [DEBUG] Calculated totals - Subtotal: 3911.535, Tax: 488.941875, Total: 4400.476875
[2026-06-14 20:18:16] [DEBUG] Looking for customer-specific AR account for: Vomo Fiji Island Resort
[2026-06-14 20:18:16] [INFO] Found customer-specific AR account: 1300-010 - AR - Vomo Fiji Island Resort
[2026-06-14 20:18:16] [DEBUG] Found GL accounts - Revenue: 4000, Tax: 2410, Receivables: 1300-010 (AR - Vomo Fiji Island Resort)
[2026-06-14 20:18:16] [ERROR] ERROR creating journal entry: Undefined variable $orgId
[2026-06-14 20:18:16] [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(274): App\Controllers\SyncController->push()
#14 /var/www/POS/api/index.php(32): require_once('...')
#15 {main}
[2026-06-14 20:18:16] [WARN] WARNING: Journal entry creation failed: Undefined variable $orgId
[2026-06-14 20:18:16] [DEBUG] STEP 9: Checking if TaxCore integration is enabled
[2026-06-14 20:18:16] [DEBUG] Checking TaxCore integration status for org_id: 019bafe2-05ad-7b4a-c449-ebcb1b933597 (table: quotations)
[2026-06-14 20:18:16] [INFO] Found quotation_taxcore_enabled in orgs.settings: false
[2026-06-14 20:18:16] [INFO] TaxCore integration enabled: NO
[2026-06-14 20:18:16] [INFO] TaxCore integration is disabled - skipping TaxCore submission
[2026-06-14 20:18:16] [INFO] TaxCore call completed successfully
[2026-06-14 20:18:16] [INFO] TaxCore response: {
    "skipped": true,
    "reason": "TaxCore integration disabled for this organization",
    "invoiceNumber": null
}
[2026-06-14 20:18:16] [DEBUG] STEP 10: Updating quotations record with TaxCore and Journal Entry details
[2026-06-14 20:18:16] [DEBUG] Update data prepared: {"quotation_id":"000019ec-7c8f-70b6-8573-518fbca598d3"}
[2026-06-14 20:18:16] [INFO] Quotations record updated successfully
[2026-06-14 20:18:16] [INFO] Skipping sales_receipts insert - TaxCore disabled or submission failed
[2026-06-14 20:18:16] [DEBUG] STEP 12: Saving audit file to storage
[2026-06-14 20:18:16] [DEBUG] Storage file path: /var/www/POS/storage/quotations/quotation_000019ec-7c8f-70b6-8573-518fbca598d3_2026-06-14_20-18-16.json
[2026-06-14 20:18:16] [INFO] Audit file saved successfully to: /var/www/POS/storage/quotations/quotation_000019ec-7c8f-70b6-8573-518fbca598d3_2026-06-14_20-18-16.json
[2026-06-14 20:18:16] [DEBUG] STEP 13: Preparing final result
[2026-06-14 20:18:16] [INFO] ========== SUCCESS: Process completed ==========
[2026-06-14 20:18:16] [INFO] Final result: {"success":true,"message":"Quotations processed successfully (TaxCore disabled)","record_id":"000019ec-7c8f-70b6-8573-518fbca598d3","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-06-14 20:18:16","saved_to":"\/var\/www\/POS\/storage\/quotations\/quotation_000019ec-7c8f-70b6-8573-518fbca598d3_2026-06-14_20-18-16.json","log_file":"\/var\/www\/POS\/storage\/quotations\/logs\/quotation_000019ec-7c8f-70b6-8573-518fbca598d3_2026-06-14_20-18-16.log"}
[2026-06-14 20:18:16] [INFO] ===========================================
[2026-06-14 20:18:16] [INFO] Quotations Processor Log
[2026-06-14 20:18:16] [INFO] Record ID: 000019ec-7c8f-70b6-8573-518fbca598d3
[2026-06-14 20:18:16] [INFO] Table: quotations
[2026-06-14 20:18:16] [INFO] Timestamp: 2026-06-14 20:18:16
[2026-06-14 20:18:16] [INFO] ===========================================
[2026-06-14 20:18:16] [INFO] ========== START: processQuotationSubmission ==========
[2026-06-14 20:18:16] [INFO] Function called for record ID: 000019ec-7c8f-70b6-8573-518fbca598d3
[2026-06-14 20:18:16] [DEBUG] Form data received: {"table":"quotations","tenant_id":"019bafe2-05ad-7b4a-c449-ebcb1b933597"}
[2026-06-14 20:18:16] [INFO] Detected table: quotations (Type: proforma)
[2026-06-14 20:18:16] [DEBUG] ID field: quotation_id, Number field: quotation_number
[2026-06-14 20:18:16] [DEBUG] STEP 1: Fetching quotation data from database
[2026-06-14 20:18:16] [DEBUG] QueryBuilder instance created
[2026-06-14 20:18:16] [DEBUG] Database query executed for quotation_id: 000019ec-7c8f-70b6-8573-518fbca598d3
[2026-06-14 20:18:16] [DEBUG] Quotation found successfully
[2026-06-14 20:18:16] [INFO] quotation_type from record overrides invoiceType: proforma
[2026-06-14 20:18:16] [DEBUG] Using org_id: 019bafe2-05ad-7b4a-c449-ebcb1b933597
[2026-06-14 20:18:16] [INFO] Fetched quotation data: {"quotation_id":"000019ec-7c8f-70b6-8573-518fbca598d3","quotation_number":"00068","date":"2026-06-09","customer_id":"019bd483-6577-7a66-9ac3-652ee8c6e1e9","org_id":"019bafe2-05ad-7b4a-c449-ebcb1b933597","client_id":null,"line_items":"{\"row_0\": {\"quantity\": \"20.80\", \"vat_rate\": \"12.5\", \"line_total\": \"1017.9\", \"product_id\": \"000019e1-8cec-700b-fa54-8df3ba665cb2\", \"unit_price\": \"43.50\", \"vat_amount\": \"113.1\", \"description\": \"KG\", \"line_subtotal\": \"904.8\"}, \"row_1\": {\"quantity\": \"20.75\", \"vat_rate\": \"12.5\", \"line_total\": \"735.33\", \"product_id\": \"000019e1-8e31-79cd-f5bd-5650384751b6\", \"unit_price\": \"31.50\", \"vat_amount\": \"81.7\", \"description\": \"KG\", \"line_subtotal\": \"653.63\"}, \"row_2\": {\"quantity\": \"15.95\", \"vat_rate\": \"12.5\", \"line_total\": \"780.56\", \"product_id\": \"000019e1-8e84-7286-d73f-64c49ad2bdc6\", \"unit_price\": \"43.50\", \"vat_amount\": \"86.73\", \"description\": \"KG\", \"line_subtotal\": \"693.83\"}, \"row_3\": {\"quantity\": \"15.80\", \"vat_rate\": \"12.5\", \"line_total\": \"763.44\", \"product_id\": \"000019e1-8de6-7976-977e-abcfc93e7414\", \"unit_price\": \"42.95\", \"vat_amount\": \"84.83\", \"description\": \"KG\", \"line_subtotal\": \"678.61\"}, \"row_4\": {\"quantity\": \"15.65\", \"vat_rate\": \"12.5\", \"line_total\": \"625.03\", \"product_id\": \"000019e1-8f4b-7cd5-ec26-460a26217fd6\", \"unit_price\": \"35.50\", \"vat_amount\": \"69.45\", \"description\": \"KG\", \"line_subtotal\": \"555.58\"}, \"row_5\": {\"quantity\": \"10.90\", \"vat_rate\": \"12.5\", \"line_total\": \"478.24\", \"product_id\": \"000019e1-8fa7-7375-7f22-8df72135af6a\", \"unit_price\": \"39.00\", \"vat_amount\": \"53.14\", \"description\": \"KG\", \"line_subtotal\": \"425.1\"}}","note":null,"terms":null,"validity_days":30,"status":"draft","total_amount":"4400.50","tax_amount":"488.95","template_id":null,"sent_at":null,"expires_at":"2026-06-30","accepted_at":null,"rejected_at":null,"rejection_reason":null,"converted_invoice_id":null,"created_by":null,"updated_by":null,"isdeleted":false,"updatedat":"2026-06-14 20:18:16.131092+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":"PO 15153","notes_additional":null,"payment_terms_details":null,"quotation_type":"proforma"}
[2026-06-14 20:18:16] [DEBUG] STEP 2: Parsing line_items JSON
[2026-06-14 20:18:16] [DEBUG] Parsed 6 line items
[2026-06-14 20:18:16] [DEBUG] Line items: {"row_0":{"quantity":"20.80","vat_rate":"12.5","line_total":"1017.9","product_id":"000019e1-8cec-700b-fa54-8df3ba665cb2","unit_price":"43.50","vat_amount":"113.1","description":"KG","line_subtotal":"904.8"},"row_1":{"quantity":"20.75","vat_rate":"12.5","line_total":"735.33","product_id":"000019e1-8e31-79cd-f5bd-5650384751b6","unit_price":"31.50","vat_amount":"81.7","description":"KG","line_subtotal":"653.63"},"row_2":{"quantity":"15.95","vat_rate":"12.5","line_total":"780.56","product_id":"000019e1-8e84-7286-d73f-64c49ad2bdc6","unit_price":"43.50","vat_amount":"86.73","description":"KG","line_subtotal":"693.83"},"row_3":{"quantity":"15.80","vat_rate":"12.5","line_total":"763.44","product_id":"000019e1-8de6-7976-977e-abcfc93e7414","unit_price":"42.95","vat_amount":"84.83","description":"KG","line_subtotal":"678.61"},"row_4":{"quantity":"15.65","vat_rate":"12.5","line_total":"625.03","product_id":"000019e1-8f4b-7cd5-ec26-460a26217fd6","unit_price":"35.50","vat_amount":"69.45","description":"KG","line_subtotal":"555.58"},"row_5":{"quantity":"10.90","vat_rate":"12.5","line_total":"478.24","product_id":"000019e1-8fa7-7375-7f22-8df72135af6a","unit_price":"39.00","vat_amount":"53.14","description":"KG","line_subtotal":"425.1"}}
[2026-06-14 20:18:16] [DEBUG] STEP 3: Preparing items for TaxCore
[2026-06-14 20:18:16] [DEBUG] Processing line item: row_0 -> {"quantity":"20.80","vat_rate":"12.5","line_total":"1017.9","product_id":"000019e1-8cec-700b-fa54-8df3ba665cb2","unit_price":"43.50","vat_amount":"113.1","description":"KG","line_subtotal":"904.8"}
[2026-06-14 20:18:16] [DEBUG] Calculated - Quantity: 20.8, UnitPrice: 43.5, TotalAmount: 904.8
[2026-06-14 20:18:16] [DEBUG] Processing line item: row_1 -> {"quantity":"20.75","vat_rate":"12.5","line_total":"735.33","product_id":"000019e1-8e31-79cd-f5bd-5650384751b6","unit_price":"31.50","vat_amount":"81.7","description":"KG","line_subtotal":"653.63"}
[2026-06-14 20:18:16] [DEBUG] Calculated - Quantity: 20.75, UnitPrice: 31.5, TotalAmount: 653.625
[2026-06-14 20:18:16] [DEBUG] Processing line item: row_2 -> {"quantity":"15.95","vat_rate":"12.5","line_total":"780.56","product_id":"000019e1-8e84-7286-d73f-64c49ad2bdc6","unit_price":"43.50","vat_amount":"86.73","description":"KG","line_subtotal":"693.83"}
[2026-06-14 20:18:16] [DEBUG] Calculated - Quantity: 15.95, UnitPrice: 43.5, TotalAmount: 693.825
[2026-06-14 20:18:16] [DEBUG] Processing line item: row_3 -> {"quantity":"15.80","vat_rate":"12.5","line_total":"763.44","product_id":"000019e1-8de6-7976-977e-abcfc93e7414","unit_price":"42.95","vat_amount":"84.83","description":"KG","line_subtotal":"678.61"}
[2026-06-14 20:18:16] [DEBUG] Calculated - Quantity: 15.8, UnitPrice: 42.95, TotalAmount: 678.61
[2026-06-14 20:18:16] [DEBUG] Processing line item: row_4 -> {"quantity":"15.65","vat_rate":"12.5","line_total":"625.03","product_id":"000019e1-8f4b-7cd5-ec26-460a26217fd6","unit_price":"35.50","vat_amount":"69.45","description":"KG","line_subtotal":"555.58"}
[2026-06-14 20:18:16] [DEBUG] Calculated - Quantity: 15.65, UnitPrice: 35.5, TotalAmount: 555.575
[2026-06-14 20:18:16] [DEBUG] Processing line item: row_5 -> {"quantity":"10.90","vat_rate":"12.5","line_total":"478.24","product_id":"000019e1-8fa7-7375-7f22-8df72135af6a","unit_price":"39.00","vat_amount":"53.14","description":"KG","line_subtotal":"425.1"}
[2026-06-14 20:18:16] [DEBUG] Calculated - Quantity: 10.9, UnitPrice: 39, TotalAmount: 425.1
[2026-06-14 20:18:16] [DEBUG] Prepared 6 items for TaxCore
[2026-06-14 20:18:16] [INFO] TaxCore items: [{"name":"KG","quantity":20.8,"unitPrice":"43.50","totalAmount":"904.80","Labels":["G"]},{"name":"KG","quantity":20.75,"unitPrice":"31.50","totalAmount":"653.63","Labels":["G"]},{"name":"KG","quantity":15.95,"unitPrice":"43.50","totalAmount":"693.83","Labels":["G"]},{"name":"KG","quantity":15.8,"unitPrice":"42.95","totalAmount":"678.61","Labels":["G"]},{"name":"KG","quantity":15.65,"unitPrice":"35.50","totalAmount":"555.58","Labels":["G"]},{"name":"KG","quantity":10.9,"unitPrice":"39.00","totalAmount":"425.10","Labels":["G"]}]
[2026-06-14 20:18:16] [DEBUG] STEP 4: Preparing payment method as Credit
[2026-06-14 20:18:16] [INFO] Payment prepared (Credit): [{"paymentType":"0","amount":4400.5}]
[2026-06-14 20:18:16] [DEBUG] STEP 5: Fetching cashier information
[2026-06-14 20:18:16] [DEBUG] User ID from formData: 019bafe2-05ad-7b4a-c449-ebcb1b933597
[2026-06-14 20:18:16] [DEBUG] Querying users table for user_id: 019bafe2-05ad-7b4a-c449-ebcb1b933597
[2026-06-14 20:18:16] [INFO] Cashier name found: System
[2026-06-14 20:18:16] [DEBUG] STEP 6: Building TaxCore payload
[2026-06-14 20:18:16] [DEBUG] Base payload created with type=proforma
[2026-06-14 20:18:16] [DEBUG] STEP 7: Adding customer/buyer information
[2026-06-14 20:18:16] [DEBUG] Customer ID found: 019bd483-6577-7a66-9ac3-652ee8c6e1e9
[2026-06-14 20:18:16] [DEBUG] Customer found: {"name":"Vomo Fiji Island Resort","tin":"00"}
[2026-06-14 20:18:16] [INFO] Buyer TIN added: 00
[2026-06-14 20:18:16] [INFO] TaxCore payload prepared: {
    "items": [
        {
            "name": "KG",
            "quantity": 20.8,
            "unitPrice": "43.50",
            "totalAmount": "904.80",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "KG",
            "quantity": 20.75,
            "unitPrice": "31.50",
            "totalAmount": "653.63",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "KG",
            "quantity": 15.95,
            "unitPrice": "43.50",
            "totalAmount": "693.83",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "KG",
            "quantity": 15.8,
            "unitPrice": "42.95",
            "totalAmount": "678.61",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "KG",
            "quantity": 15.65,
            "unitPrice": "35.50",
            "totalAmount": "555.58",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "KG",
            "quantity": 10.9,
            "unitPrice": "39.00",
            "totalAmount": "425.10",
            "Labels": [
                "G"
            ]
        }
    ],
    "payment": [
        {
            "paymentType": "0",
            "amount": 4400.5
        }
    ],
    "Cashier": "System",
    "type": "proforma",
    "invoiceNumber": "00068",
    "Buyer": {
        "Name": "Vomo Fiji Island Resort"
    },
    "buyerId": "00"
}
[2026-06-14 20:18:16] [DEBUG] STEP 8: Creating Journal Entry in Finance module
[2026-06-14 20:18:16] [INFO] --- createJournalEntry: Starting ---
[2026-06-14 20:18:16] [INFO] Is Cancelled/Refund: NO
[2026-06-14 20:18:16] [DEBUG] Calculated totals - Subtotal: 3911.535, Tax: 488.941875, Total: 4400.476875
[2026-06-14 20:18:16] [DEBUG] Looking for customer-specific AR account for: Vomo Fiji Island Resort
[2026-06-14 20:18:16] [INFO] Found customer-specific AR account: 1300-010 - AR - Vomo Fiji Island Resort
[2026-06-14 20:18:16] [DEBUG] Found GL accounts - Revenue: 4000, Tax: 2410, Receivables: 1300-010 (AR - Vomo Fiji Island Resort)
[2026-06-14 20:18:16] [ERROR] ERROR creating journal entry: Undefined variable $orgId
[2026-06-14 20:18:16] [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(274): App\Controllers\SyncController->push()
#14 /var/www/POS/api/index.php(32): require_once('...')
#15 {main}
[2026-06-14 20:18:16] [WARN] WARNING: Journal entry creation failed: Undefined variable $orgId
[2026-06-14 20:18:16] [DEBUG] STEP 9: Checking if TaxCore integration is enabled
[2026-06-14 20:18:16] [DEBUG] Checking TaxCore integration status for org_id: 019bafe2-05ad-7b4a-c449-ebcb1b933597 (table: quotations)
[2026-06-14 20:18:16] [INFO] Found quotation_taxcore_enabled in orgs.settings: false
[2026-06-14 20:18:16] [INFO] TaxCore integration enabled: NO
[2026-06-14 20:18:16] [INFO] TaxCore integration is disabled - skipping TaxCore submission
[2026-06-14 20:18:16] [INFO] TaxCore call completed successfully
[2026-06-14 20:18:16] [INFO] TaxCore response: {
    "skipped": true,
    "reason": "TaxCore integration disabled for this organization",
    "invoiceNumber": null
}
[2026-06-14 20:18:16] [DEBUG] STEP 10: Updating quotations record with TaxCore and Journal Entry details
[2026-06-14 20:18:16] [DEBUG] Update data prepared: {"quotation_id":"000019ec-7c8f-70b6-8573-518fbca598d3"}
[2026-06-14 20:18:16] [INFO] Quotations record updated successfully
[2026-06-14 20:18:16] [INFO] Skipping sales_receipts insert - TaxCore disabled or submission failed
[2026-06-14 20:18:16] [DEBUG] STEP 12: Saving audit file to storage
[2026-06-14 20:18:16] [DEBUG] Storage file path: /var/www/POS/storage/quotations/quotation_000019ec-7c8f-70b6-8573-518fbca598d3_2026-06-14_20-18-16.json
[2026-06-14 20:18:16] [INFO] Audit file saved successfully to: /var/www/POS/storage/quotations/quotation_000019ec-7c8f-70b6-8573-518fbca598d3_2026-06-14_20-18-16.json
[2026-06-14 20:18:16] [DEBUG] STEP 13: Preparing final result
[2026-06-14 20:18:16] [INFO] ========== SUCCESS: Process completed ==========
[2026-06-14 20:18:16] [INFO] Final result: {"success":true,"message":"Quotations processed successfully (TaxCore disabled)","record_id":"000019ec-7c8f-70b6-8573-518fbca598d3","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-06-14 20:18:16","saved_to":"\/var\/www\/POS\/storage\/quotations\/quotation_000019ec-7c8f-70b6-8573-518fbca598d3_2026-06-14_20-18-16.json","log_file":"\/var\/www\/POS\/storage\/quotations\/logs\/quotation_000019ec-7c8f-70b6-8573-518fbca598d3_2026-06-14_20-18-16.log"}
