Advanced Reporting - Custom Reports and Scripts

Advanced Reporting - Custom Reports and Scripts

Introduction

While iVendNext provides pre-built operational reports, businesses often need tailored analytics to address unique challenges. This guide explores advanced reporting tools—including custom Report Builder templates, SQL Query Reports, and Python Script Reports—to unlock deeper insights.




When to Use Advanced Reporting

Use these tools when you need:
Data beyond standard reports (e.g., profit margins by region).
Complex calculations (e.g., inventory turnover ratios).
Automated workflows (e.g., low-stock alerts).




1. Custom Reports with Report Builder

Key Features

  • No coding required – Drag-and-drop interface.

  • Child table support – Pull data from linked tables (e.g., invoice items).

  • Save & reuse – Create templates for recurring needs.


Step-by-Step: Build a Custom Sales Report

  1. Navigate to Home > Customizations > Reports > Report Builder.

  2. Click New, select "Sales Invoice" as the doctype.

  3. Add fields:

    • Parent table: Customer Name, Grand Total.

    • Child table (Invoice Items): Item Code, Qty, Rate.

  4. Apply filters (e.g., "Status = Paid").

  5. Save as "High-Value Sales Report."





2. SQL Query Reports (For Technical Users)

Use Cases

  • Multi-table joins (e.g., sales + inventory data).

  • Custom aggregations (e.g., average basket size by store).


Example: Top-Selling Items by Revenue

SELECT 

  item.item_name, 

  SUM(invoice_item.amount) AS total_revenue

FROM `tabSales Invoice Item` AS invoice_item

JOIN `tabItem` AS item ON invoice_item.item_code = item.item_code

GROUP BY item.item_name

ORDER BY total_revenue DESC

LIMIT 10;


Steps to Implement:


  1. Go to Home > Customizations > Reports > Query Report.

  2. Paste the SQL query, test with "Run."

  3. Save as "Top 10 Products by Revenue."


NotesNote: Requires read access to database tables.




3. Python Script Reports (Maximum Flexibility)

When to Use

  • Dynamic logic (e.g., apply discounts based on rules).

  • External integrations (e.g., pull weather data for sales correlation).


Example: Low-Stock Alert Report

def execute(filters=None):

  columns = ["Item", "Warehouse", "Qty", "Reorder Level"]

  data = frappe.db.sql("""

    SELECT item.item_name, bin.warehouse, bin.actual_qty, item.reorder_level

    FROM `tabBin` AS bin

    JOIN `tabItem` AS item ON bin.item_code = item.item_code

    WHERE bin.actual_qty < item.reorder_level

  """)

  return columns, data


Steps to Implement:


  1. Navigate to Script Report under Customizations.

  2. Enter the Python code, set filters (e.g., warehouse).

  3. Schedule to run daily and email to managers.




Comparison of Advanced Reporting Tools

Tool

Best For

Coding Needed?

Report Builder

Simple custom columns/filters

No

SQL Reports

Complex joins/aggregations

Yes (SQL)

Python Scripts

Dynamic logic, external APIs

Yes (Python)




Pro Tips for Advanced Reporting

🔹 Reuse Scripts – Save frequently used queries as templates.
🔹 Limit Data – Use filters to avoid slow performance.
🔹 Test Safely – Run scripts in development mode first.


AlertWarning: Always back up data before running write-access scripts.




Conclusion

iVendNext’s advanced tools—Report Builder, SQL Queries, and Python Scripts—let you:
Build reports tailored to your workflows.
Automate data-driven decisions.
Go beyond standard analytics.




    • Related Articles

    • Creating Custom Reports Using Report Builder

      Introduction The Report Builder in iVendNext is a powerful yet user-friendly tool that allows you to create customized reports without needing advanced technical skills. Whether you need sales summaries, inventory status updates, or purchase invoice ...
    • Creating and Managing Custom Reports

      Introduction In today’s data-driven business environment, having access to accurate and insightful reports is crucial for making informed decisions. iVendNext offers robust reporting capabilities, allowing businesses to create and manage custom ...
    • Operational Reports

      This article provides an overview of the key reports available in iVendNext. It also shows how to create custom reports and explains how to add, remove, and rearrange columns, apply both predefined and custom filters, and sort the data. Introduction ...
    • Advanced Features in iVendNext Selling

      Overview The iVendNext Selling Module is a comprehensive tool designed to streamline your sales processes, enhance customer relationship management, and improve overall business efficiency. While the basic features of the Selling module are powerful ...
    • Reporting and Analytics

      Introduction Reporting and analytics are essential for making informed business decisions, tracking performance, and ensuring compliance. iVendNext provides a robust suite of reporting and analytics tools that allow you to generate detailed reports, ...