[2026-01-29 07:35:30] [INFO] ===========================================
[2026-01-29 07:35:30] [INFO] Payments Processor Log
[2026-01-29 07:35:30] [INFO] Record ID: 019c08ad-be4a-7fcf-92e9-95d4e6c92212
[2026-01-29 07:35:30] [INFO] Table: payments
[2026-01-29 07:35:30] [INFO] Timestamp: 2026-01-29 07:35:30
[2026-01-29 07:35:30] [INFO] ===========================================
[2026-01-29 07:35:30] [INFO] ========== START: processPaymentInsertion ==========
[2026-01-29 07:35:30] [INFO] Function called for payment ID: 019c08ad-be4a-7fcf-92e9-95d4e6c92212
[2026-01-29 07:35:30] [DEBUG] Context data received: {"user_id":null,"org_id":null}
[2026-01-29 07:35:30] [DEBUG] STEP 1: Fetching payment data from database
[2026-01-29 07:35:30] [DEBUG] QueryBuilder instance created
[2026-01-29 07:35:30] [DEBUG] Database query executed for payment_id: 019c08ad-be4a-7fcf-92e9-95d4e6c92212
[2026-01-29 07:35:30] [DEBUG] Payment found successfully
[2026-01-29 07:35:30] [INFO] Fetched payment data: {"payment_id":"019c08ad-be4a-7fcf-92e9-95d4e6c92212","client_id":null,"org_id":"019b9c9c-9d60-79d0-3ec5-849b68cdb9da","invoice_id":"000019c0-6691-7ec6-078e-8bc20bda8aa4","reference_id":"000019c0-6691-7ec6-078e-8bc20bda8aa4","reference_table":"generic_invoices","payment_date":"2026-01-29","total_amount":"87.16","payment_method":"Cash","payments":null,"document_ids":null,"screenshot_ids":null,"notes":null,"status":"completed","isdeleted":false,"updatedat":"2026-01-29 07:35:30.122343+00"}
[2026-01-29 07:35:30] [DEBUG] STEP 2: Fetching payment items
[2026-01-29 07:35:30] [DEBUG] Found 1 payment items
[2026-01-29 07:35:30] [INFO] Payment items: [{"payment_item_id":"019c08ad-be55-77b1-97b7-a605b57ecf90","payment_id":"019c08ad-be4a-7fcf-92e9-95d4e6c92212","method":"Cash","amount":"87.16","customer_id":null,"isdeleted":false,"updatedat":"2026-01-29 07:35:30.13332+00"}]
[2026-01-29 07:35:30] [DEBUG] STEP 3: Identifying payment reference
[2026-01-29 07:35:30] [INFO] Payment reference - Table: generic_invoices, ID: 000019c0-6691-7ec6-078e-8bc20bda8aa4, Invoice ID: 000019c0-6691-7ec6-078e-8bc20bda8aa4
[2026-01-29 07:35:30] [DEBUG] STEP 4: Processing payment hook - Refund original invoice and create new paid invoice
[2026-01-29 07:35:30] [INFO] Payment hook triggered successfully
[2026-01-29 07:35:30] [INFO] Payment ID: 019c08ad-be4a-7fcf-92e9-95d4e6c92212
[2026-01-29 07:35:30] [INFO] Total Amount: 87.16
[2026-01-29 07:35:30] [INFO] Payment Date: 2026-01-29
[2026-01-29 07:35:30] [INFO] Payment Method: Cash
[2026-01-29 07:35:30] [INFO] Status: completed
[2026-01-29 07:35:30] [INFO] Fetching original invoice: 000019c0-6691-7ec6-078e-8bc20bda8aa4
[2026-01-29 07:35:30] [INFO] Original invoice found: {"invoice_id":"000019c0-6691-7ec6-078e-8bc20bda8aa4","invoice_number":252,"date":"2026-01-29","customer_id":"019bb59f-1279-74bd-a7e9-531b0c4ceaf6","org_id":"019b9c9c-9d60-79d0-3ec5-849b68cdb9da","client_id":null,"line_items":"{\"row_0\": {\"quantity\": \"1\", \"vat_rate\": \"VIP\", \"line_total\": \"87.16\", \"product_id\": \"000019ba-60c9-793a-2e57-55ac82f7d61e\", \"unit_price\": \"87.16\", \"vat_amount\": \"9.68\", \"description\": \"Rooster sp\", \"line_subtotal\": \"87.16\"}}","note":null,"terms":null,"status":"draft","total_amount":null,"tax_amount":null,"amount_paid":"0.00","due_date":"2026-01-29","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-28 21:01:18.869009+00","journal_entry_id":null}
[2026-01-29 07:35:30] [WARN] WARNING: Original invoice not submitted to TaxCore yet, skipping refund/resale process
[2026-01-29 07:35:30] [DEBUG] STEP 5: Saving audit file to storage
[2026-01-29 07:35:30] [DEBUG] Storage file path: /var/www/POS/storage/payments/payment_019c08ad-be4a-7fcf-92e9-95d4e6c92212_2026-01-29_07-35-30.json
[2026-01-29 07:35:30] [INFO] Audit file saved successfully to: /var/www/POS/storage/payments/payment_019c08ad-be4a-7fcf-92e9-95d4e6c92212_2026-01-29_07-35-30.json
[2026-01-29 07:35:30] [DEBUG] STEP 6: Preparing final result
[2026-01-29 07:35:30] [INFO] ========== SUCCESS: Payment processing completed ==========
[2026-01-29 07:35:30] [INFO] Final result: {"success":true,"message":"Payment processed successfully","payment_id":"019c08ad-be4a-7fcf-92e9-95d4e6c92212","total_amount":"87.16","reference_table":"generic_invoices","reference_id":"000019c0-6691-7ec6-078e-8bc20bda8aa4","invoice_id":"000019c0-6691-7ec6-078e-8bc20bda8aa4","taxcore_refund_invoice":null,"taxcore_new_sale_invoice":null,"processed_at":"2026-01-29 07:35:30","saved_to":"\/var\/www\/POS\/storage\/payments\/payment_019c08ad-be4a-7fcf-92e9-95d4e6c92212_2026-01-29_07-35-30.json","log_file":"\/var\/www\/POS\/storage\/payments\/logs\/quotation_019c08ad-be4a-7fcf-92e9-95d4e6c92212_2026-01-29_07-35-30.log","hook_triggered":true}
