[2026-01-21 07:02:33] [INFO] ===========================================
[2026-01-21 07:02:33] [INFO] Payments Processor Log
[2026-01-21 07:02:33] [INFO] Record ID: 019bdf5c-b4d1-7c45-962f-9181b02909d3
[2026-01-21 07:02:33] [INFO] Table: payments
[2026-01-21 07:02:33] [INFO] Timestamp: 2026-01-21 07:02:33
[2026-01-21 07:02:33] [INFO] ===========================================
[2026-01-21 07:02:33] [INFO] ========== START: processPaymentInsertion ==========
[2026-01-21 07:02:33] [INFO] Function called for payment ID: 019bdf5c-b4d1-7c45-962f-9181b02909d3
[2026-01-21 07:02:33] [DEBUG] Context data received: {"user_id":null,"org_id":null}
[2026-01-21 07:02:33] [DEBUG] STEP 1: Fetching payment data from database
[2026-01-21 07:02:33] [DEBUG] QueryBuilder instance created
[2026-01-21 07:02:33] [DEBUG] Database query executed for payment_id: 019bdf5c-b4d1-7c45-962f-9181b02909d3
[2026-01-21 07:02:33] [DEBUG] Payment found successfully
[2026-01-21 07:02:33] [INFO] Fetched payment data: {"payment_id":"019bdf5c-b4d1-7c45-962f-9181b02909d3","client_id":null,"org_id":"019b9c9c-9d60-79d0-3ec5-849b68cdb9da","invoice_id":"000019bd-d4f8-7dd7-5d88-5fb923c0e2e5","reference_id":"000019bd-d4f8-7dd7-5d88-5fb923c0e2e5","reference_table":"generic_invoices","payment_date":"2026-01-21","total_amount":"69.75","payment_method":"Cash","payments":null,"document_ids":null,"screenshot_ids":null,"notes":null,"status":"completed","isdeleted":false,"updatedat":"2026-01-21 07:02:33.425315+00"}
[2026-01-21 07:02:33] [DEBUG] STEP 2: Fetching payment items
[2026-01-21 07:02:33] [DEBUG] Found 1 payment items
[2026-01-21 07:02:33] [INFO] Payment items: [{"payment_item_id":"019bdf5c-b4d9-78bd-bff4-309823b70677","payment_id":"019bdf5c-b4d1-7c45-962f-9181b02909d3","method":"Cash","amount":"69.75","customer_id":null,"isdeleted":false,"updatedat":"2026-01-21 07:02:33.433212+00"}]
[2026-01-21 07:02:33] [DEBUG] STEP 3: Identifying payment reference
[2026-01-21 07:02:33] [INFO] Payment reference - Table: generic_invoices, ID: 000019bd-d4f8-7dd7-5d88-5fb923c0e2e5, Invoice ID: 000019bd-d4f8-7dd7-5d88-5fb923c0e2e5
[2026-01-21 07:02:33] [DEBUG] STEP 4: Processing payment hook - Refund original invoice and create new paid invoice
[2026-01-21 07:02:33] [INFO] Payment hook triggered successfully
[2026-01-21 07:02:33] [INFO] Payment ID: 019bdf5c-b4d1-7c45-962f-9181b02909d3
[2026-01-21 07:02:33] [INFO] Total Amount: 69.75
[2026-01-21 07:02:33] [INFO] Payment Date: 2026-01-21
[2026-01-21 07:02:33] [INFO] Payment Method: Cash
[2026-01-21 07:02:33] [INFO] Status: completed
[2026-01-21 07:02:33] [INFO] Fetching original invoice: 000019bd-d4f8-7dd7-5d88-5fb923c0e2e5
[2026-01-21 07:02:33] [INFO] Original invoice found: {"invoice_id":"000019bd-d4f8-7dd7-5d88-5fb923c0e2e5","invoice_number":114,"date":"2026-01-21","customer_id":"019ba619-1af7-7ef1-a910-fa5b9ae1edfa","org_id":"019b9c9c-9d60-79d0-3ec5-849b68cdb9da","client_id":null,"line_items":"{\"row_0\": {\"quantity\": \"5\", \"vat_rate\": \"VIP\", \"line_total\": \"69.75\", \"product_id\": \"000019ba-e898-7882-6a4a-129b525a6613\", \"unit_price\": \"13.95\", \"vat_amount\": \"7.75\", \"description\": \"1.5l\", \"line_subtotal\": \"69.75\"}}","note":null,"terms":null,"status":"draft","total_amount":"0.00","tax_amount":"0.00","amount_paid":"0.00","due_date":"2026-01-21","template_id":null,"quotation_id":null,"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,"created_by":null,"updated_by":null,"isdeleted":false,"updatedat":"2026-01-20 21:29:54.698168+00"}
[2026-01-21 07:02:33] [WARN] WARNING: Original invoice not submitted to TaxCore yet, skipping refund/resale process
[2026-01-21 07:02:33] [DEBUG] STEP 5: Saving audit file to storage
[2026-01-21 07:02:33] [DEBUG] Storage file path: /var/www/POS/storage/payments/payment_019bdf5c-b4d1-7c45-962f-9181b02909d3_2026-01-21_07-02-33.json
[2026-01-21 07:02:33] [INFO] Audit file saved successfully to: /var/www/POS/storage/payments/payment_019bdf5c-b4d1-7c45-962f-9181b02909d3_2026-01-21_07-02-33.json
[2026-01-21 07:02:33] [DEBUG] STEP 6: Preparing final result
[2026-01-21 07:02:33] [INFO] ========== SUCCESS: Payment processing completed ==========
[2026-01-21 07:02:33] [INFO] Final result: {"success":true,"message":"Payment processed successfully","payment_id":"019bdf5c-b4d1-7c45-962f-9181b02909d3","total_amount":"69.75","reference_table":"generic_invoices","reference_id":"000019bd-d4f8-7dd7-5d88-5fb923c0e2e5","invoice_id":"000019bd-d4f8-7dd7-5d88-5fb923c0e2e5","taxcore_refund_invoice":null,"taxcore_new_sale_invoice":null,"processed_at":"2026-01-21 07:02:33","saved_to":"\/var\/www\/POS\/storage\/payments\/payment_019bdf5c-b4d1-7c45-962f-9181b02909d3_2026-01-21_07-02-33.json","log_file":"\/var\/www\/POS\/storage\/payments\/logs\/quotation_019bdf5c-b4d1-7c45-962f-9181b02909d3_2026-01-21_07-02-33.log","hook_triggered":true}
