add debug logging to vat allocation report
This commit is contained in:
parent
f595a4f4c1
commit
f6227567d4
|
|
@ -81,7 +81,20 @@ def get_empty_row(vat_name=""):
|
|||
def get_data(filters):
|
||||
"""Get VAT allocation documents and calculate values"""
|
||||
|
||||
# DEBUG: Log incoming filters
|
||||
# DEBUG: Log incoming filters (always log to file)
|
||||
import json
|
||||
debug_msg = f"VAT Report called with filters: {json.dumps(filters, default=str)}"
|
||||
|
||||
# Write to file for debugging
|
||||
try:
|
||||
with open('/tmp/vat_report_debug.log', 'a') as f:
|
||||
from datetime import datetime
|
||||
f.write(f"\n{'='*80}\n")
|
||||
f.write(f"Time: {datetime.now()}\n")
|
||||
f.write(f"{debug_msg}\n")
|
||||
except:
|
||||
pass
|
||||
|
||||
frappe.log_error(title="VAT Report Filters", message=f"Incoming filters: {filters}")
|
||||
|
||||
# Return empty row if filters are not provided (needed for Formula Editor)
|
||||
|
|
@ -117,20 +130,54 @@ def get_data(filters):
|
|||
|
||||
# Find VAT allocation document (max one result due to autoname format)
|
||||
vat_name = f"VAT-{year}-{month}"
|
||||
|
||||
# Log to file
|
||||
try:
|
||||
with open('/tmp/vat_report_debug.log', 'a') as f:
|
||||
f.write(f"Looking for document: {vat_name}\n")
|
||||
except:
|
||||
pass
|
||||
|
||||
frappe.log_error(title="VAT Report: Doc Search", message=f"Looking for document: {vat_name}")
|
||||
|
||||
if not frappe.db.exists("VAT allocation", vat_name):
|
||||
try:
|
||||
with open('/tmp/vat_report_debug.log', 'a') as f:
|
||||
f.write(f"Document NOT FOUND: {vat_name}\n")
|
||||
f.write(f"Returning empty row\n")
|
||||
except:
|
||||
pass
|
||||
frappe.log_error(title="VAT Report: Not Found", message=f"Document '{vat_name}' does not exist in database\nReturning empty row with name: {vat_name}")
|
||||
return [get_empty_row(vat_name)]
|
||||
|
||||
# Check if submitted
|
||||
docstatus = frappe.db.get_value("VAT allocation", vat_name, "docstatus")
|
||||
|
||||
try:
|
||||
with open('/tmp/vat_report_debug.log', 'a') as f:
|
||||
f.write(f"Document FOUND: {vat_name}, docstatus={docstatus}\n")
|
||||
except:
|
||||
pass
|
||||
|
||||
frappe.log_error(title="VAT Report: Doc Status", message=f"Document: {vat_name}\nDocstatus: {docstatus}\nSubmitted: {docstatus == 1}")
|
||||
if docstatus != 1:
|
||||
try:
|
||||
with open('/tmp/vat_report_debug.log', 'a') as f:
|
||||
f.write(f"Document NOT SUBMITTED (docstatus={docstatus})\n")
|
||||
except:
|
||||
pass
|
||||
frappe.log_error(title="VAT Report: Not Submitted", message=f"Document '{vat_name}' exists but not submitted (docstatus={docstatus})\nReturning empty row")
|
||||
return [get_empty_row(vat_name)]
|
||||
|
||||
row = calculate_row_data(vat_name)
|
||||
|
||||
try:
|
||||
with open('/tmp/vat_report_debug.log', 'a') as f:
|
||||
f.write(f"Calculated row data: {row}\n")
|
||||
f.write(f"{'='*80}\n")
|
||||
except:
|
||||
pass
|
||||
|
||||
frappe.log_error(title="VAT Report: Data Found", message=f"Document: {vat_name}\nCalculated row data:\n{row}")
|
||||
return [row] if row else [get_empty_row(vat_name)]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue