[2026-01-30 05:39:44] [INFO] ===========================================
[2026-01-30 05:39:44] [INFO] Payments Processor Log
[2026-01-30 05:39:44] [INFO] Record ID: 019c0d6a-1e0e-73a9-a570-e2264991aa07
[2026-01-30 05:39:44] [INFO] Table: payments
[2026-01-30 05:39:44] [INFO] Timestamp: 2026-01-30 05:39:44
[2026-01-30 05:39:44] [INFO] ===========================================
[2026-01-30 05:39:44] [INFO] ========== START: processPaymentInsertion ==========
[2026-01-30 05:39:44] [INFO] Function called for payment ID: 019c0d6a-1e0e-73a9-a570-e2264991aa07
[2026-01-30 05:39:44] [DEBUG] Context data received: {"user_id":null,"org_id":null}
[2026-01-30 05:39:44] [DEBUG] STEP 1: Fetching payment data from database
[2026-01-30 05:39:44] [DEBUG] QueryBuilder instance created
[2026-01-30 05:39:44] [DEBUG] Database query executed for payment_id: 019c0d6a-1e0e-73a9-a570-e2264991aa07
[2026-01-30 05:39:44] [DEBUG] Payment found successfully
[2026-01-30 05:39:44] [INFO] Fetched payment data: {"payment_id":"019c0d6a-1e0e-73a9-a570-e2264991aa07","client_id":null,"org_id":"019b9c9c-9d60-79d0-3ec5-849b68cdb9da","invoice_id":"000019c0-b8f2-7d52-4d45-866375f8119b","reference_id":"000019c0-b8f2-7d52-4d45-866375f8119b","reference_table":"generic_invoices","payment_date":"2026-01-30","total_amount":"178.00","payment_method":"Cash","payments":null,"document_ids":null,"screenshot_ids":null,"notes":null,"status":"completed","isdeleted":false,"updatedat":"2026-01-30 05:39:44.270566+00"}
[2026-01-30 05:39:44] [DEBUG] STEP 2: Fetching payment items
[2026-01-30 05:39:44] [DEBUG] Found 1 payment items
[2026-01-30 05:39:44] [INFO] Payment items: [{"payment_item_id":"019c0d6a-1e15-7f3d-84db-abe5e09dde65","payment_id":"019c0d6a-1e0e-73a9-a570-e2264991aa07","method":"Cash","amount":"178.00","customer_id":null,"isdeleted":false,"updatedat":"2026-01-30 05:39:44.27733+00"}]
[2026-01-30 05:39:44] [DEBUG] STEP 3: Identifying payment reference
[2026-01-30 05:39:44] [INFO] Payment reference - Table: generic_invoices, ID: 000019c0-b8f2-7d52-4d45-866375f8119b, Invoice ID: 000019c0-b8f2-7d52-4d45-866375f8119b
[2026-01-30 05:39:44] [DEBUG] STEP 4: Processing payment hook - Refund original invoice and create new paid invoice
[2026-01-30 05:39:44] [INFO] Payment hook triggered successfully
[2026-01-30 05:39:44] [INFO] Payment ID: 019c0d6a-1e0e-73a9-a570-e2264991aa07
[2026-01-30 05:39:44] [INFO] Total Amount: 178.00
[2026-01-30 05:39:44] [INFO] Payment Date: 2026-01-30
[2026-01-30 05:39:44] [INFO] Payment Method: Cash
[2026-01-30 05:39:44] [INFO] Status: completed
[2026-01-30 05:39:44] [INFO] Fetching original invoice: 000019c0-b8f2-7d52-4d45-866375f8119b
[2026-01-30 05:39:44] [INFO] Original invoice found: {"invoice_id":"000019c0-b8f2-7d52-4d45-866375f8119b","invoice_number":279,"date":"2026-01-30","customer_id":"019ba621-a8c0-74a8-905e-a63b11552f98","org_id":"019b9c9c-9d60-79d0-3ec5-849b68cdb9da","client_id":null,"line_items":"{\"row_0\": {\"quantity\": \"15\", \"vat_rate\": \"VIP\", \"line_total\": \"135\", \"product_id\": \"000019bd-cfc1-730b-d3cb-09a3dc462594\", \"unit_price\": \"9.00\", \"vat_amount\": \"15\", \"description\": \"CREST SAUSAGES\", \"line_subtotal\": \"135\"}, \"row_1\": {\"quantity\": \"1\", \"vat_rate\": \"VIP\", \"line_total\": \"43\", \"product_id\": \"000019ba-60da-7ce2-07bf-e5f64ad1d144\", \"unit_price\": \"43.00\", \"vat_amount\": \"4.78\", \"description\": \"Rooster Feet 10kg\", \"line_subtotal\": \"43\"}}","note":null,"terms":null,"status":"draft","total_amount":null,"tax_amount":null,"amount_paid":"0.00","due_date":"2026-01-30","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-29 21:00:58.781772+00","journal_entry_id":null}
[2026-01-30 05:39:44] [WARN] WARNING: Original invoice not submitted to TaxCore yet, skipping refund/resale process
[2026-01-30 05:39:44] [DEBUG] STEP 5: Saving audit file to storage
[2026-01-30 05:39:44] [DEBUG] Storage file path: /var/www/POS/storage/payments/payment_019c0d6a-1e0e-73a9-a570-e2264991aa07_2026-01-30_05-39-44.json
[2026-01-30 05:39:44] [INFO] Audit file saved successfully to: /var/www/POS/storage/payments/payment_019c0d6a-1e0e-73a9-a570-e2264991aa07_2026-01-30_05-39-44.json
[2026-01-30 05:39:44] [DEBUG] STEP 6: Preparing final result
[2026-01-30 05:39:44] [INFO] ========== SUCCESS: Payment processing completed ==========
[2026-01-30 05:39:44] [INFO] Final result: {"success":true,"message":"Payment processed successfully","payment_id":"019c0d6a-1e0e-73a9-a570-e2264991aa07","total_amount":"178.00","reference_table":"generic_invoices","reference_id":"000019c0-b8f2-7d52-4d45-866375f8119b","invoice_id":"000019c0-b8f2-7d52-4d45-866375f8119b","taxcore_refund_invoice":null,"taxcore_new_sale_invoice":null,"processed_at":"2026-01-30 05:39:44","saved_to":"\/var\/www\/POS\/storage\/payments\/payment_019c0d6a-1e0e-73a9-a570-e2264991aa07_2026-01-30_05-39-44.json","log_file":"\/var\/www\/POS\/storage\/payments\/logs\/quotation_019c0d6a-1e0e-73a9-a570-e2264991aa07_2026-01-30_05-39-44.log","hook_triggered":true}
