[2026-05-04 00:09:38] [INFO] ===========================================
[2026-05-04 00:09:38] [INFO] Quotations Processor Log
[2026-05-04 00:09:38] [INFO] Record ID: 000019df-051a-7d98-a97a-e3a031073d9f
[2026-05-04 00:09:38] [INFO] Table: quotations
[2026-05-04 00:09:38] [INFO] Timestamp: 2026-05-04 00:09:38
[2026-05-04 00:09:38] [INFO] ===========================================
[2026-05-04 00:09:38] [INFO] ========== START: processQuotationSubmission ==========
[2026-05-04 00:09:38] [INFO] Function called for record ID: 000019df-051a-7d98-a97a-e3a031073d9f
[2026-05-04 00:09:38] [DEBUG] Form data received: {"table":"quotations","tenant_id":"019c929f-e781-71f8-eee3-b9e908128c68"}
[2026-05-04 00:09:38] [INFO] Detected table: quotations (Type: proforma)
[2026-05-04 00:09:38] [DEBUG] ID field: quotation_id, Number field: quotation_number
[2026-05-04 00:09:38] [DEBUG] STEP 1: Fetching quotation data from database
[2026-05-04 00:09:38] [DEBUG] QueryBuilder instance created
[2026-05-04 00:09:38] [DEBUG] Database query executed for quotation_id: 000019df-051a-7d98-a97a-e3a031073d9f
[2026-05-04 00:09:38] [DEBUG] Quotation found successfully
[2026-05-04 00:09:38] [INFO] quotation_type from record overrides invoiceType: proforma
[2026-05-04 00:09:38] [DEBUG] Using org_id: 019c929f-e781-71f8-eee3-b9e908128c68
[2026-05-04 00:09:38] [INFO] Fetched quotation data: {"quotation_id":"000019df-051a-7d98-a97a-e3a031073d9f","quotation_number":"00010","date":"2026-05-04","customer_id":"000019d8-4931-7fb5-46ea-efa0ca22f8de","org_id":"019c929f-e781-71f8-eee3-b9e908128c68","client_id":null,"line_items":"{\"row_0\": {\"quantity\": null, \"vat_rate\": \"\", \"line_total\": \"0\", \"product_id\": null, \"unit_price\": null, \"vat_amount\": \"0\", \"description\": \"Laundry for Vessel Vatulawa\", \"line_subtotal\": \"0\"}, \"row_1\": {\"quantity\": \"9\", \"vat_rate\": \"12.5\", \"line_total\": \"0\", \"product_id\": null, \"unit_price\": null, \"vat_amount\": \"0\", \"description\": \"Big Blanket\", \"line_subtotal\": \"0\"}, \"row_2\": {\"quantity\": \"5\", \"vat_rate\": \"12.5\", \"line_total\": \"67.5\", \"product_id\": null, \"unit_price\": \"12\", \"vat_amount\": \"7.5\", \"description\": \"Small Blankets\", \"line_subtotal\": \"60\"}, \"row_3\": {\"quantity\": \"9\", \"vat_rate\": \"12.5\", \"line_total\": \"15.19\", \"product_id\": null, \"unit_price\": \"1.50\", \"vat_amount\": \"1.69\", \"description\": \"Curtains\", \"line_subtotal\": \"13.5\"}, \"row_4\": {\"quantity\": \"15\", \"vat_rate\": \"12.5\", \"line_total\": \"16.88\", \"product_id\": null, \"unit_price\": \"1\", \"vat_amount\": \"1.88\", \"description\": \"Bedsheet\", \"line_subtotal\": \"15\"}, \"row_5\": {\"quantity\": \"13\", \"vat_rate\": \"12.5\", \"line_total\": \"10.97\", \"product_id\": null, \"unit_price\": \"0.75\", \"vat_amount\": \"1.22\", \"description\": \"Pillow Case\", \"line_subtotal\": \"9.75\"}, \"row_6\": {\"quantity\": \"2\", \"vat_rate\": \"12.5\", \"line_total\": \"2.25\", \"product_id\": null, \"unit_price\": \"1\", \"vat_amount\": \"0.25\", \"description\": \"Bed Cover\", \"line_subtotal\": \"2\"}}","note":null,"terms":null,"validity_days":30,"status":"draft","total_amount":"112.79","tax_amount":"12.54","template_id":null,"sent_at":null,"expires_at":"2026-05-10","accepted_at":null,"rejected_at":null,"rejection_reason":null,"converted_invoice_id":null,"created_by":null,"updated_by":null,"isdeleted":false,"updatedat":"2026-05-04 00:09:38.85448+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":"proforma"}
[2026-05-04 00:09:38] [DEBUG] STEP 2: Parsing line_items JSON
[2026-05-04 00:09:38] [DEBUG] Parsed 7 line items
[2026-05-04 00:09:38] [DEBUG] Line items: {"row_0":{"quantity":null,"vat_rate":"","line_total":"0","product_id":null,"unit_price":null,"vat_amount":"0","description":"Laundry for Vessel Vatulawa","line_subtotal":"0"},"row_1":{"quantity":"9","vat_rate":"12.5","line_total":"0","product_id":null,"unit_price":null,"vat_amount":"0","description":"Big Blanket","line_subtotal":"0"},"row_2":{"quantity":"5","vat_rate":"12.5","line_total":"67.5","product_id":null,"unit_price":"12","vat_amount":"7.5","description":"Small Blankets","line_subtotal":"60"},"row_3":{"quantity":"9","vat_rate":"12.5","line_total":"15.19","product_id":null,"unit_price":"1.50","vat_amount":"1.69","description":"Curtains","line_subtotal":"13.5"},"row_4":{"quantity":"15","vat_rate":"12.5","line_total":"16.88","product_id":null,"unit_price":"1","vat_amount":"1.88","description":"Bedsheet","line_subtotal":"15"},"row_5":{"quantity":"13","vat_rate":"12.5","line_total":"10.97","product_id":null,"unit_price":"0.75","vat_amount":"1.22","description":"Pillow Case","line_subtotal":"9.75"},"row_6":{"quantity":"2","vat_rate":"12.5","line_total":"2.25","product_id":null,"unit_price":"1","vat_amount":"0.25","description":"Bed Cover","line_subtotal":"2"}}
[2026-05-04 00:09:38] [DEBUG] STEP 3: Preparing items for TaxCore
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_0 -> {"quantity":null,"vat_rate":"","line_total":"0","product_id":null,"unit_price":null,"vat_amount":"0","description":"Laundry for Vessel Vatulawa","line_subtotal":"0"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 1, UnitPrice: 0, TotalAmount: 0
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_1 -> {"quantity":"9","vat_rate":"12.5","line_total":"0","product_id":null,"unit_price":null,"vat_amount":"0","description":"Big Blanket","line_subtotal":"0"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 9, UnitPrice: 0, TotalAmount: 0
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_2 -> {"quantity":"5","vat_rate":"12.5","line_total":"67.5","product_id":null,"unit_price":"12","vat_amount":"7.5","description":"Small Blankets","line_subtotal":"60"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 5, UnitPrice: 12, TotalAmount: 60
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_3 -> {"quantity":"9","vat_rate":"12.5","line_total":"15.19","product_id":null,"unit_price":"1.50","vat_amount":"1.69","description":"Curtains","line_subtotal":"13.5"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 9, UnitPrice: 1.5, TotalAmount: 13.5
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_4 -> {"quantity":"15","vat_rate":"12.5","line_total":"16.88","product_id":null,"unit_price":"1","vat_amount":"1.88","description":"Bedsheet","line_subtotal":"15"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 15, UnitPrice: 1, TotalAmount: 15
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_5 -> {"quantity":"13","vat_rate":"12.5","line_total":"10.97","product_id":null,"unit_price":"0.75","vat_amount":"1.22","description":"Pillow Case","line_subtotal":"9.75"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 13, UnitPrice: 0.75, TotalAmount: 9.75
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_6 -> {"quantity":"2","vat_rate":"12.5","line_total":"2.25","product_id":null,"unit_price":"1","vat_amount":"0.25","description":"Bed Cover","line_subtotal":"2"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 2, UnitPrice: 1, TotalAmount: 2
[2026-05-04 00:09:38] [DEBUG] Prepared 7 items for TaxCore
[2026-05-04 00:09:38] [INFO] TaxCore items: [{"name":"Laundry for Vessel Vatulawa","quantity":1,"unitPrice":"0.00","totalAmount":"0.00","Labels":["G"]},{"name":"Big Blanket","quantity":9,"unitPrice":"0.00","totalAmount":"0.00","Labels":["G"]},{"name":"Small Blankets","quantity":5,"unitPrice":"12.00","totalAmount":"60.00","Labels":["G"]},{"name":"Curtains","quantity":9,"unitPrice":"1.50","totalAmount":"13.50","Labels":["G"]},{"name":"Bedsheet","quantity":15,"unitPrice":"1.00","totalAmount":"15.00","Labels":["G"]},{"name":"Pillow Case","quantity":13,"unitPrice":"0.75","totalAmount":"9.75","Labels":["G"]},{"name":"Bed Cover","quantity":2,"unitPrice":"1.00","totalAmount":"2.00","Labels":["G"]}]
[2026-05-04 00:09:38] [DEBUG] STEP 4: Preparing payment method as Credit
[2026-05-04 00:09:38] [INFO] Payment prepared (Credit): [{"paymentType":"0","amount":112.79}]
[2026-05-04 00:09:38] [DEBUG] STEP 5: Fetching cashier information
[2026-05-04 00:09:38] [DEBUG] User ID from formData: 019c929f-e781-71f8-eee3-b9e908128c68
[2026-05-04 00:09:38] [DEBUG] Querying users table for user_id: 019c929f-e781-71f8-eee3-b9e908128c68
[2026-05-04 00:09:38] [INFO] Cashier name found: System
[2026-05-04 00:09:38] [DEBUG] STEP 6: Building TaxCore payload
[2026-05-04 00:09:38] [DEBUG] Base payload created with type=proforma
[2026-05-04 00:09:38] [DEBUG] STEP 7: Adding customer/buyer information
[2026-05-04 00:09:38] [DEBUG] Customer ID found: 000019d8-4931-7fb5-46ea-efa0ca22f8de
[2026-05-04 00:09:38] [DEBUG] Customer found: {"name":"Ministry Of Public Works,Meteorlogical Services & Transport ","tin":null}
[2026-05-04 00:09:38] [INFO] TaxCore payload prepared: {
    "items": [
        {
            "name": "Laundry for Vessel Vatulawa",
            "quantity": 1,
            "unitPrice": "0.00",
            "totalAmount": "0.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Big Blanket",
            "quantity": 9,
            "unitPrice": "0.00",
            "totalAmount": "0.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Small Blankets",
            "quantity": 5,
            "unitPrice": "12.00",
            "totalAmount": "60.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Curtains",
            "quantity": 9,
            "unitPrice": "1.50",
            "totalAmount": "13.50",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Bedsheet",
            "quantity": 15,
            "unitPrice": "1.00",
            "totalAmount": "15.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Pillow Case",
            "quantity": 13,
            "unitPrice": "0.75",
            "totalAmount": "9.75",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Bed Cover",
            "quantity": 2,
            "unitPrice": "1.00",
            "totalAmount": "2.00",
            "Labels": [
                "G"
            ]
        }
    ],
    "payment": [
        {
            "paymentType": "0",
            "amount": 112.79
        }
    ],
    "Cashier": "System",
    "type": "proforma",
    "invoiceNumber": "00010",
    "Buyer": {
        "Name": "Ministry Of Public Works,Meteorlogical Services & Transport "
    }
}
[2026-05-04 00:09:38] [DEBUG] STEP 8: Creating Journal Entry in Finance module
[2026-05-04 00:09:38] [INFO] --- createJournalEntry: Starting ---
[2026-05-04 00:09:38] [INFO] Is Cancelled/Refund: NO
[2026-05-04 00:09:38] [DEBUG] Calculated totals - Subtotal: 100.25, Tax: 12.53125, Total: 112.78125
[2026-05-04 00:09:38] [DEBUG] Looking for customer-specific AR account for: Ministry Of Public Works,Meteorlogical Services & Transport 
[2026-05-04 00:09:38] [INFO] Found customer-specific AR account: 1300-010 - AR - Ministry Of Public Works,Meteorlogical Services & Transport 
[2026-05-04 00:09:38] [DEBUG] Found GL accounts - Revenue: 4000, Tax: 2410, Receivables: 1300-010 (AR - Ministry Of Public Works,Meteorlogical Services & Transport )
[2026-05-04 00:09:38] [ERROR] ERROR creating journal entry: Undefined variable $orgId
[2026-05-04 00:09:38] [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(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(272): App\Controllers\SyncController->push()
#14 /var/www/POS/api/index.php(32): require_once('...')
#15 {main}
[2026-05-04 00:09:38] [WARN] WARNING: Journal entry creation failed: Undefined variable $orgId
[2026-05-04 00:09:38] [DEBUG] STEP 9: Checking if TaxCore integration is enabled
[2026-05-04 00:09:38] [DEBUG] Checking TaxCore integration status for org_id: 019c929f-e781-71f8-eee3-b9e908128c68 (table: quotations)
[2026-05-04 00:09:38] [INFO] Found quotation_taxcore_enabled in orgs.settings: false
[2026-05-04 00:09:38] [INFO] TaxCore integration enabled: NO
[2026-05-04 00:09:38] [INFO] TaxCore integration is disabled - skipping TaxCore submission
[2026-05-04 00:09:38] [INFO] TaxCore call completed successfully
[2026-05-04 00:09:38] [INFO] TaxCore response: {
    "skipped": true,
    "reason": "TaxCore integration disabled for this organization",
    "invoiceNumber": null
}
[2026-05-04 00:09:38] [DEBUG] STEP 10: Updating quotations record with TaxCore and Journal Entry details
[2026-05-04 00:09:38] [DEBUG] Update data prepared: {"quotation_id":"000019df-051a-7d98-a97a-e3a031073d9f"}
[2026-05-04 00:09:38] [INFO] Quotations record updated successfully
[2026-05-04 00:09:38] [INFO] Skipping sales_receipts insert - TaxCore disabled or submission failed
[2026-05-04 00:09:38] [DEBUG] STEP 12: Saving audit file to storage
[2026-05-04 00:09:38] [DEBUG] Storage file path: /var/www/POS/storage/quotations/quotation_000019df-051a-7d98-a97a-e3a031073d9f_2026-05-04_00-09-38.json
[2026-05-04 00:09:38] [INFO] Audit file saved successfully to: /var/www/POS/storage/quotations/quotation_000019df-051a-7d98-a97a-e3a031073d9f_2026-05-04_00-09-38.json
[2026-05-04 00:09:38] [DEBUG] STEP 13: Preparing final result
[2026-05-04 00:09:38] [INFO] ========== SUCCESS: Process completed ==========
[2026-05-04 00:09:38] [INFO] Final result: {"success":true,"message":"Quotations processed successfully (TaxCore disabled)","record_id":"000019df-051a-7d98-a97a-e3a031073d9f","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-05-04 00:09:38","saved_to":"\/var\/www\/POS\/storage\/quotations\/quotation_000019df-051a-7d98-a97a-e3a031073d9f_2026-05-04_00-09-38.json","log_file":"\/var\/www\/POS\/storage\/quotations\/logs\/quotation_000019df-051a-7d98-a97a-e3a031073d9f_2026-05-04_00-09-38.log"}
[2026-05-04 00:09:38] [INFO] ===========================================
[2026-05-04 00:09:38] [INFO] Quotations Processor Log
[2026-05-04 00:09:38] [INFO] Record ID: 000019df-051a-7d98-a97a-e3a031073d9f
[2026-05-04 00:09:38] [INFO] Table: quotations
[2026-05-04 00:09:38] [INFO] Timestamp: 2026-05-04 00:09:38
[2026-05-04 00:09:38] [INFO] ===========================================
[2026-05-04 00:09:38] [INFO] ========== START: processQuotationSubmission ==========
[2026-05-04 00:09:38] [INFO] Function called for record ID: 000019df-051a-7d98-a97a-e3a031073d9f
[2026-05-04 00:09:38] [DEBUG] Form data received: {"table":"quotations","tenant_id":"019c929f-e781-71f8-eee3-b9e908128c68"}
[2026-05-04 00:09:38] [INFO] Detected table: quotations (Type: proforma)
[2026-05-04 00:09:38] [DEBUG] ID field: quotation_id, Number field: quotation_number
[2026-05-04 00:09:38] [DEBUG] STEP 1: Fetching quotation data from database
[2026-05-04 00:09:38] [DEBUG] QueryBuilder instance created
[2026-05-04 00:09:38] [DEBUG] Database query executed for quotation_id: 000019df-051a-7d98-a97a-e3a031073d9f
[2026-05-04 00:09:38] [DEBUG] Quotation found successfully
[2026-05-04 00:09:38] [INFO] quotation_type from record overrides invoiceType: proforma
[2026-05-04 00:09:38] [DEBUG] Using org_id: 019c929f-e781-71f8-eee3-b9e908128c68
[2026-05-04 00:09:38] [INFO] Fetched quotation data: {"quotation_id":"000019df-051a-7d98-a97a-e3a031073d9f","quotation_number":"00010","date":"2026-05-04","customer_id":"000019d8-4931-7fb5-46ea-efa0ca22f8de","org_id":"019c929f-e781-71f8-eee3-b9e908128c68","client_id":null,"line_items":"{\"row_0\": {\"quantity\": null, \"vat_rate\": \"\", \"line_total\": \"0\", \"product_id\": null, \"unit_price\": null, \"vat_amount\": \"0\", \"description\": \"Laundry for Vessel Vatulawa\", \"line_subtotal\": \"0\"}, \"row_1\": {\"quantity\": \"9\", \"vat_rate\": \"12.5\", \"line_total\": \"0\", \"product_id\": null, \"unit_price\": null, \"vat_amount\": \"0\", \"description\": \"Big Blanket\", \"line_subtotal\": \"0\"}, \"row_2\": {\"quantity\": \"5\", \"vat_rate\": \"12.5\", \"line_total\": \"67.5\", \"product_id\": null, \"unit_price\": \"12\", \"vat_amount\": \"7.5\", \"description\": \"Small Blankets\", \"line_subtotal\": \"60\"}, \"row_3\": {\"quantity\": \"9\", \"vat_rate\": \"12.5\", \"line_total\": \"15.19\", \"product_id\": null, \"unit_price\": \"1.50\", \"vat_amount\": \"1.69\", \"description\": \"Curtains\", \"line_subtotal\": \"13.5\"}, \"row_4\": {\"quantity\": \"15\", \"vat_rate\": \"12.5\", \"line_total\": \"16.88\", \"product_id\": null, \"unit_price\": \"1\", \"vat_amount\": \"1.88\", \"description\": \"Bedsheet\", \"line_subtotal\": \"15\"}, \"row_5\": {\"quantity\": \"13\", \"vat_rate\": \"12.5\", \"line_total\": \"10.97\", \"product_id\": null, \"unit_price\": \"0.75\", \"vat_amount\": \"1.22\", \"description\": \"Pillow Case\", \"line_subtotal\": \"9.75\"}, \"row_6\": {\"quantity\": \"2\", \"vat_rate\": \"12.5\", \"line_total\": \"2.25\", \"product_id\": null, \"unit_price\": \"1\", \"vat_amount\": \"0.25\", \"description\": \"Bed Cover\", \"line_subtotal\": \"2\"}}","note":null,"terms":null,"validity_days":30,"status":"draft","total_amount":"112.79","tax_amount":"12.54","template_id":null,"sent_at":null,"expires_at":"2026-05-10","accepted_at":null,"rejected_at":null,"rejection_reason":null,"converted_invoice_id":null,"created_by":null,"updated_by":null,"isdeleted":false,"updatedat":"2026-05-04 00:09:38.887446+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":"proforma"}
[2026-05-04 00:09:38] [DEBUG] STEP 2: Parsing line_items JSON
[2026-05-04 00:09:38] [DEBUG] Parsed 7 line items
[2026-05-04 00:09:38] [DEBUG] Line items: {"row_0":{"quantity":null,"vat_rate":"","line_total":"0","product_id":null,"unit_price":null,"vat_amount":"0","description":"Laundry for Vessel Vatulawa","line_subtotal":"0"},"row_1":{"quantity":"9","vat_rate":"12.5","line_total":"0","product_id":null,"unit_price":null,"vat_amount":"0","description":"Big Blanket","line_subtotal":"0"},"row_2":{"quantity":"5","vat_rate":"12.5","line_total":"67.5","product_id":null,"unit_price":"12","vat_amount":"7.5","description":"Small Blankets","line_subtotal":"60"},"row_3":{"quantity":"9","vat_rate":"12.5","line_total":"15.19","product_id":null,"unit_price":"1.50","vat_amount":"1.69","description":"Curtains","line_subtotal":"13.5"},"row_4":{"quantity":"15","vat_rate":"12.5","line_total":"16.88","product_id":null,"unit_price":"1","vat_amount":"1.88","description":"Bedsheet","line_subtotal":"15"},"row_5":{"quantity":"13","vat_rate":"12.5","line_total":"10.97","product_id":null,"unit_price":"0.75","vat_amount":"1.22","description":"Pillow Case","line_subtotal":"9.75"},"row_6":{"quantity":"2","vat_rate":"12.5","line_total":"2.25","product_id":null,"unit_price":"1","vat_amount":"0.25","description":"Bed Cover","line_subtotal":"2"}}
[2026-05-04 00:09:38] [DEBUG] STEP 3: Preparing items for TaxCore
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_0 -> {"quantity":null,"vat_rate":"","line_total":"0","product_id":null,"unit_price":null,"vat_amount":"0","description":"Laundry for Vessel Vatulawa","line_subtotal":"0"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 1, UnitPrice: 0, TotalAmount: 0
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_1 -> {"quantity":"9","vat_rate":"12.5","line_total":"0","product_id":null,"unit_price":null,"vat_amount":"0","description":"Big Blanket","line_subtotal":"0"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 9, UnitPrice: 0, TotalAmount: 0
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_2 -> {"quantity":"5","vat_rate":"12.5","line_total":"67.5","product_id":null,"unit_price":"12","vat_amount":"7.5","description":"Small Blankets","line_subtotal":"60"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 5, UnitPrice: 12, TotalAmount: 60
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_3 -> {"quantity":"9","vat_rate":"12.5","line_total":"15.19","product_id":null,"unit_price":"1.50","vat_amount":"1.69","description":"Curtains","line_subtotal":"13.5"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 9, UnitPrice: 1.5, TotalAmount: 13.5
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_4 -> {"quantity":"15","vat_rate":"12.5","line_total":"16.88","product_id":null,"unit_price":"1","vat_amount":"1.88","description":"Bedsheet","line_subtotal":"15"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 15, UnitPrice: 1, TotalAmount: 15
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_5 -> {"quantity":"13","vat_rate":"12.5","line_total":"10.97","product_id":null,"unit_price":"0.75","vat_amount":"1.22","description":"Pillow Case","line_subtotal":"9.75"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 13, UnitPrice: 0.75, TotalAmount: 9.75
[2026-05-04 00:09:38] [DEBUG] Processing line item: row_6 -> {"quantity":"2","vat_rate":"12.5","line_total":"2.25","product_id":null,"unit_price":"1","vat_amount":"0.25","description":"Bed Cover","line_subtotal":"2"}
[2026-05-04 00:09:38] [DEBUG] Calculated - Quantity: 2, UnitPrice: 1, TotalAmount: 2
[2026-05-04 00:09:38] [DEBUG] Prepared 7 items for TaxCore
[2026-05-04 00:09:38] [INFO] TaxCore items: [{"name":"Laundry for Vessel Vatulawa","quantity":1,"unitPrice":"0.00","totalAmount":"0.00","Labels":["G"]},{"name":"Big Blanket","quantity":9,"unitPrice":"0.00","totalAmount":"0.00","Labels":["G"]},{"name":"Small Blankets","quantity":5,"unitPrice":"12.00","totalAmount":"60.00","Labels":["G"]},{"name":"Curtains","quantity":9,"unitPrice":"1.50","totalAmount":"13.50","Labels":["G"]},{"name":"Bedsheet","quantity":15,"unitPrice":"1.00","totalAmount":"15.00","Labels":["G"]},{"name":"Pillow Case","quantity":13,"unitPrice":"0.75","totalAmount":"9.75","Labels":["G"]},{"name":"Bed Cover","quantity":2,"unitPrice":"1.00","totalAmount":"2.00","Labels":["G"]}]
[2026-05-04 00:09:38] [DEBUG] STEP 4: Preparing payment method as Credit
[2026-05-04 00:09:38] [INFO] Payment prepared (Credit): [{"paymentType":"0","amount":112.79}]
[2026-05-04 00:09:38] [DEBUG] STEP 5: Fetching cashier information
[2026-05-04 00:09:38] [DEBUG] User ID from formData: 019c929f-e781-71f8-eee3-b9e908128c68
[2026-05-04 00:09:38] [DEBUG] Querying users table for user_id: 019c929f-e781-71f8-eee3-b9e908128c68
[2026-05-04 00:09:38] [INFO] Cashier name found: System
[2026-05-04 00:09:38] [DEBUG] STEP 6: Building TaxCore payload
[2026-05-04 00:09:38] [DEBUG] Base payload created with type=proforma
[2026-05-04 00:09:38] [DEBUG] STEP 7: Adding customer/buyer information
[2026-05-04 00:09:38] [DEBUG] Customer ID found: 000019d8-4931-7fb5-46ea-efa0ca22f8de
[2026-05-04 00:09:38] [DEBUG] Customer found: {"name":"Ministry Of Public Works,Meteorlogical Services & Transport ","tin":null}
[2026-05-04 00:09:38] [INFO] TaxCore payload prepared: {
    "items": [
        {
            "name": "Laundry for Vessel Vatulawa",
            "quantity": 1,
            "unitPrice": "0.00",
            "totalAmount": "0.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Big Blanket",
            "quantity": 9,
            "unitPrice": "0.00",
            "totalAmount": "0.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Small Blankets",
            "quantity": 5,
            "unitPrice": "12.00",
            "totalAmount": "60.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Curtains",
            "quantity": 9,
            "unitPrice": "1.50",
            "totalAmount": "13.50",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Bedsheet",
            "quantity": 15,
            "unitPrice": "1.00",
            "totalAmount": "15.00",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Pillow Case",
            "quantity": 13,
            "unitPrice": "0.75",
            "totalAmount": "9.75",
            "Labels": [
                "G"
            ]
        },
        {
            "name": "Bed Cover",
            "quantity": 2,
            "unitPrice": "1.00",
            "totalAmount": "2.00",
            "Labels": [
                "G"
            ]
        }
    ],
    "payment": [
        {
            "paymentType": "0",
            "amount": 112.79
        }
    ],
    "Cashier": "System",
    "type": "proforma",
    "invoiceNumber": "00010",
    "Buyer": {
        "Name": "Ministry Of Public Works,Meteorlogical Services & Transport "
    }
}
[2026-05-04 00:09:38] [DEBUG] STEP 8: Creating Journal Entry in Finance module
[2026-05-04 00:09:38] [INFO] --- createJournalEntry: Starting ---
[2026-05-04 00:09:38] [INFO] Is Cancelled/Refund: NO
[2026-05-04 00:09:38] [DEBUG] Calculated totals - Subtotal: 100.25, Tax: 12.53125, Total: 112.78125
[2026-05-04 00:09:38] [DEBUG] Looking for customer-specific AR account for: Ministry Of Public Works,Meteorlogical Services & Transport 
[2026-05-04 00:09:38] [INFO] Found customer-specific AR account: 1300-010 - AR - Ministry Of Public Works,Meteorlogical Services & Transport 
[2026-05-04 00:09:38] [DEBUG] Found GL accounts - Revenue: 4000, Tax: 2410, Receivables: 1300-010 (AR - Ministry Of Public Works,Meteorlogical Services & Transport )
[2026-05-04 00:09:38] [ERROR] ERROR creating journal entry: Undefined variable $orgId
[2026-05-04 00:09:38] [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(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(272): App\Controllers\SyncController->push()
#14 /var/www/POS/api/index.php(32): require_once('...')
#15 {main}
[2026-05-04 00:09:38] [WARN] WARNING: Journal entry creation failed: Undefined variable $orgId
[2026-05-04 00:09:38] [DEBUG] STEP 9: Checking if TaxCore integration is enabled
[2026-05-04 00:09:38] [DEBUG] Checking TaxCore integration status for org_id: 019c929f-e781-71f8-eee3-b9e908128c68 (table: quotations)
[2026-05-04 00:09:38] [INFO] Found quotation_taxcore_enabled in orgs.settings: false
[2026-05-04 00:09:38] [INFO] TaxCore integration enabled: NO
[2026-05-04 00:09:38] [INFO] TaxCore integration is disabled - skipping TaxCore submission
[2026-05-04 00:09:38] [INFO] TaxCore call completed successfully
[2026-05-04 00:09:38] [INFO] TaxCore response: {
    "skipped": true,
    "reason": "TaxCore integration disabled for this organization",
    "invoiceNumber": null
}
[2026-05-04 00:09:38] [DEBUG] STEP 10: Updating quotations record with TaxCore and Journal Entry details
[2026-05-04 00:09:38] [DEBUG] Update data prepared: {"quotation_id":"000019df-051a-7d98-a97a-e3a031073d9f"}
[2026-05-04 00:09:38] [INFO] Quotations record updated successfully
[2026-05-04 00:09:38] [INFO] Skipping sales_receipts insert - TaxCore disabled or submission failed
[2026-05-04 00:09:38] [DEBUG] STEP 12: Saving audit file to storage
[2026-05-04 00:09:38] [DEBUG] Storage file path: /var/www/POS/storage/quotations/quotation_000019df-051a-7d98-a97a-e3a031073d9f_2026-05-04_00-09-38.json
[2026-05-04 00:09:38] [INFO] Audit file saved successfully to: /var/www/POS/storage/quotations/quotation_000019df-051a-7d98-a97a-e3a031073d9f_2026-05-04_00-09-38.json
[2026-05-04 00:09:38] [DEBUG] STEP 13: Preparing final result
[2026-05-04 00:09:38] [INFO] ========== SUCCESS: Process completed ==========
[2026-05-04 00:09:38] [INFO] Final result: {"success":true,"message":"Quotations processed successfully (TaxCore disabled)","record_id":"000019df-051a-7d98-a97a-e3a031073d9f","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-05-04 00:09:38","saved_to":"\/var\/www\/POS\/storage\/quotations\/quotation_000019df-051a-7d98-a97a-e3a031073d9f_2026-05-04_00-09-38.json","log_file":"\/var\/www\/POS\/storage\/quotations\/logs\/quotation_000019df-051a-7d98-a97a-e3a031073d9f_2026-05-04_00-09-38.log"}
