Operationstotalreport Documentation
Operations Total Report Controller Documentation
File: /controllers/operationstotalreport.php
Purpose: Comprehensive dashboard showing all business operations totals including sales, purchases, inventory, and financial summaries
Last Updated: December 20, 2024
Total Functions: 20+
Lines of Code: ~1,921
---
๐ Overview
The Operations Total Report Controller serves as a comprehensive business dashboard, aggregating data from all major business operations into a single view. It provides real-time totals for sales, purchases, returns, payments, collections, inventory, and financial positions.
Primary Functions
- โ Comprehensive business operations dashboard
- โ Sales and returns analysis
- โ Purchase and return tracking
- โ Cash register and payment summaries
- โ Customer and supplier debt tracking
- โ Inventory valuation reporting
- โ Expense tracking by categories
- โ Date range filtering with automatic period detection
- โ YouTube tutorial integration
Related Controllers
- โข sellbillController.md - Sales operations
- โข buyBillController.md - Purchase operations
- โข saveController.md - Cash management
- โข clientReportsController.md - Customer reports
---
๐๏ธ Database Tables
Primary Operations Tables
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **sellbill** | Sales transactions | sellbillid, sellbilldate, sellbillaftertotalbill, sellbilltotalpayed, conditions | |
| **returnsellbill** | Sales returns | returnsellbillid, returnsellbilldate, returnsellbillaftertotalbill, conditions | |
| **buybill** | Purchase transactions | buybillid, buybilldate, buybillaftertotalbill, conditions | |
| **returnbuybill** | Purchase returns | returnbuybillid, returnbuybilldate, returnbuybillaftertotalbill, conditions | |
| **savedaily** | Cash register movements | savedailyid, savedailydate, savedailychangeamount, savedailychangetype | |
| **clientdebtchange** | Customer debt changes | clientdebtchangeid, clientdebtchangedate, clientdebtchangeamount | |
| **supplierdebtchange** | Supplier debt changes | supplierdebtchangeid, supplierdebtchangedate, supplierdebtchangeamount |
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **client** | Customer balances | clientid, clientdebt, conditions | |
| **supplier** | Supplier balances | supplierid, suppliercurrentDebt, conditions | |
| **expenses** | Expense records | expensesid, expensesdate, expensesValue, expensestypeid | |
| **storedetail** | Inventory details | storedetailid, storedetailquantity, productid |
๐ Key Functions
1. Default Dashboard - Complete Operations Summary
Location: Lines 423-507
Purpose: Generate comprehensive business operations dashboard
Process Flow:
1. Date Range Processing: Auto-detect business day based on settings
2. Cash Register Summary: Call search() for cash movements
3. Sales Analysis: Call showAll() for sales totals
4. Returns Tracking: Call returnshowAll() for return totals
5. Purchase Analysis: Call showBuyBill() for purchase totals
6. Purchase Returns: Call showBuyReturn() for purchase return totals
7. Collections Summary: Call showx() for customer collections
8. Payments Summary: Call showxDofat() for supplier payments
9. Debt Calculations: Calculate customer and supplier debt totals
10. Inventory Valuation: Calculate total inventory value (if enabled)
11. Expense Tracking: Sum expenses for the period
Key Variables:
- โข
$start/$end- Calculated business day range - โข
$totalclientdebt- Total customer debt - โข
$totalsupplierdebt- Total supplier debt - โข
$totalprice- Total inventory value - โข
$totalExpense- Total expenses for period
---
2. search() - Cash Register Analysis
Location: Lines 516-877
Purpose: Analyze cash register movements and calculate totals
Function Signature:
function search($saveid, $processid, $startDate, $endDate)
Key Features:
- โข Bill integration for optical sales
- โข Net view processing with
$bureparameter - โข Running balance calculations
- โข User and client name resolution
---
3. showAll() - Sales Analysis
Location: Lines 895-1082
Purpose: Comprehensive sales bill analysis with discount and tax calculations
Key Calculations:
- โข Total bills amount
- โข Total quantity sold
- โข Total tax amounts
- โข Total discount amounts
- โข Handles both regular and combined bill types
---
4. returnshowAll() - Returns Analysis
Location: Lines 1085-1300
Purpose: Sales return analysis with detailed calculations
---
5. showBuyBill() - Purchase Analysis
Location: Lines 1303-1484
Purpose: Purchase bill analysis with supplier tracking
---
6. Debt Tracking Functions
Location: Lines 1852-1873
function clientdebt() // Customer debt totals
function supplierdebt() // Supplier debt totals
7. totalproduct() - Inventory Valuation
Location: Lines 1876-1919
Purpose: Calculate total inventory value using configurable pricing methods
Pricing Methods:
- โข
first- First purchase price - โข
last- Last purchase price - โข
mean- Average purchase price - โข
last_discount- Last price with discount - โข
mean_discount- Average price with discount - โข
tax- Last price with tax - โข
mean_tax- Average price with tax
---
๐ Workflows
Main Dashboard Workflow
---
๐งฎ Calculation Methods
Business Day Calculation
if (date('H') < $Programsetting->reportsPlusHours) {
$start = $startYesterday;
$end = $endYesterday;
} else {
$start = $startToday;
$end = $endToday;
}
Inventory Valuation
switch ($Programsettingdata->Inventoryevaluation) {
case "first":
$priceColumnName = 'productBuyPrice';
break;
case "last":
$priceColumnName = 'lastbuyprice';
break;
case "mean":
$priceColumnName = 'meanbuyprice';
break;
// ... additional methods
}
$totalprice = (float) $myStoredetailEx->getM5zonPrice($priceColumnName);
---
๐ Security & Performance
Performance Considerations
- โข Multiple Heavy Queries: Dashboard executes 10+ analysis functions
- โข Large Dataset Handling: Date range filtering critical for performance
- โข Inventory Calculation: Can be disabled via
showM5zonsetting - โข Concurrent Execution: All analyses run in sequence, consider caching
Required Indexes
- โข Date-based indexes on all transaction tables
- โข Customer/supplier debt indexes
- โข Product and inventory indexes
---
๐ Related Documentation
- โข CLAUDE.md - PHP 8.2 migration guide
- โข sellbillController.md - Sales operations
- โข buyBillController.md - Purchase operations
---
Documented By: AI Assistant
Review Status: โ Complete
Next Review: When major changes occur