remove debug logging from vat allocation report
This commit is contained in:
parent
f6227567d4
commit
f5833e3a19
|
|
@ -8,11 +8,8 @@ from frappe.utils import flt
|
|||
|
||||
def execute(filters=None):
|
||||
"""Main function for report execution"""
|
||||
frappe.log_error(title="VAT Report Execute", message=f"Called with filters: {filters}")
|
||||
columns = get_columns()
|
||||
data = get_data(filters)
|
||||
frappe.log_error(title="VAT Report Execute Result",
|
||||
message=f"Returning {len(columns)} columns and {len(data)} rows\nFirst row: {data[0] if data else 'No data'}")
|
||||
return columns, data
|
||||
|
||||
|
||||
|
|
@ -81,30 +78,12 @@ def get_empty_row(vat_name=""):
|
|||
def get_data(filters):
|
||||
"""Get VAT allocation documents and calculate values"""
|
||||
|
||||
# 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)
|
||||
if not filters:
|
||||
frappe.log_error(title="VAT Report: No Filters", message="No filters provided, returning empty row")
|
||||
return [get_empty_row()]
|
||||
|
||||
# Validate filters - return empty row if incomplete
|
||||
if not filters.get('company'):
|
||||
frappe.log_error(title="VAT Report: No Company", message=f"No company in filters: {filters}\nReturning empty row")
|
||||
return [get_empty_row()]
|
||||
|
||||
# Support both direct year/month filters AND from_date/to_date (for Formula Editor)
|
||||
|
|
@ -114,7 +93,6 @@ def get_data(filters):
|
|||
# If year/month not provided, try to extract from from_date or to_date
|
||||
if not year or not month:
|
||||
date_to_use = filters.get('to_date') or filters.get('from_date')
|
||||
frappe.log_error(title="VAT Report: Extract Date", message=f"Year/month not provided. Extracting from date: {date_to_use}\nAll filters: {filters}")
|
||||
if date_to_use:
|
||||
from frappe.utils import getdate
|
||||
date_obj = getdate(date_to_use)
|
||||
|
|
@ -123,62 +101,21 @@ def get_data(filters):
|
|||
month_names = ['January', 'February', 'March', 'April', 'May', 'June',
|
||||
'July', 'August', 'September', 'October', 'November', 'December']
|
||||
month = month_names[date_obj.month - 1]
|
||||
frappe.log_error(title="VAT Report: Extracted", message=f"Successfully extracted:\nYear: {year}\nMonth: {month}\nFrom date: {date_to_use}")
|
||||
else:
|
||||
frappe.log_error(title="VAT Report: No Dates", message=f"No date filters (from_date/to_date) in: {filters}\nReturning empty row")
|
||||
return [get_empty_row()]
|
||||
|
||||
# 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