Bill Settings Controller Documentation
File: /controllers/billsettingsController.php
Purpose: Manages bill templates, bill names, and bill configuration settings
Last Updated: December 19, 2024
Total Functions: 11
Lines of Code: ~621
---
๐ Overview
The Bill Settings Controller is the core component for managing bill templates and configurations in the ERP system. It handles:
- โข Creating and editing bill templates (billnames)
- โข Managing bill properties and settings
- โข Configuring bill behavior and features
- โข POS and barcode integration settings
- โข Payment method configurations
- โข Tax and discount settings
- โข Bill copying and duplication
- โข Bulk operations on bill templates
- โข Bank account integration for payments
Primary Functions
- โ Create new bill templates with properties
- โ Edit existing bill templates and settings
- โ Copy bill templates with full configurations
- โ Soft delete/restore bill templates
- โ Bulk operations on multiple templates
- โ Property-based bill configuration
- โ POS integration settings
- โ Payment method setup
- โ Tax calculation configuration
- โ Bank account assignment for card payments
Related Controllers
- โข sellbillController.php - Sales operations using templates
- โข buyBillController.php - Purchase operations using templates
- โข userController.php - User management
- โข usergroupController.php - User group management
- โข bankaccountController.php - Bank account management
- โข billpropertyController.php - Bill property definitions
- โข billTemplateController.php - Bill template design
---
๐๏ธ Database Tables
Primary Tables (Direct Operations)
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **billname** | Bill templates/types | billnameid, name, billtype, billtype2, ordertype, saveeffect, storeeffect, conditions | |
| **billsettings** | Bill configurations | billsettingsid, billnameid, billpropertyid, billsettingsvalue | |
| **billproperty** | Property definitions | billpropertyid, billpropertyname, propertytype, conditions |
| Field Category | Purpose | Key Fields | |
|---|---|---|---|
| **Basic Settings** | Template info | name, billtype, billtype2, ordertype | |
| **Effects** | System impact | saveeffect, storeeffect | |
| **POS Integration** | Point of sale | posFlag, posCode, posType, posWeightPrice | |
| **Payment Methods** | Financial | defVisaAccount, isBankAccountTransfer | |
| **Tax Settings** | Calculations | taxOfDiscountVal, taxOfDiscountPrint, taxname | |
| **Discounts** | Pricing | extraDiscountPlace, extraDiscountFixed, extraDiscountPer | |
| **Security** | Approval | goodsReceiptApproval, checkDigit | |
| **Barcode** | Product lookup | parcodeType |
| Table Name | Purpose | Relationship | |
|---|---|---|---|
| **bankaccount** | Bank accounts | billname.defVisaAccount โ bankaccount.accountid | |
| **relusergroupproperties** | User permissions | Controls bill property access |
๐ง Key Functions
1. add() - Create New Bill Template
Location: Line 224
Purpose: Create a new bill template with complete property configuration
Function Signature:
function add()
Parameters (via $_POST):
- โข
name- Bill template name - โข
billType- Primary bill type (1=sales, 2=purchase, etc.) - โข
billType2- Secondary classification - โข
ordertype- Order processing type - โข
saveeffect- Cash register effect - โข
storeeffect- Inventory effect - โข
posFlag- POS integration flag - โข
posCode- POS identification code - โข
posType- POS system type - โข
posWeightPrice- Weight-based pricing - โข
checkDigit- Barcode check digit - โข
goodsReceiptApproval- Approval requirement - โข
parcodeType- Barcode type - โข
defVisaAccount- Default card payment account - โข
isBankAccountTransfer- Bank transfer flag - โข
taxOfDiscountVal- Tax on discount amount - โข
extraDiscountPer- Additional discount percentage - โข
countallBillproperty- Number of properties to process
Process Flow:
2. show() - Display All Bill Templates
Location: Line 316
Purpose: Retrieve and display all bill templates for management
3. edit() - Load Template for Editing
Location: Line 329
Purpose: Load bill template data and associated properties
Parameters:
- โข
id- Bill template ID from GET
Returns: Array containing:
- โข
[0]- Bill template data - โข
[1]- Property settings with current values
4. update() - Update Bill Template
Location: Line 348
Purpose: Update existing bill template and all property settings
Key Features:
- โข Updates both billname and billsettings tables
- โข Handles new property additions
- โข Manages existing property updates
- โข Preserves property relationships
5. copyBillSetting() - Duplicate Bill Template
Location: Line 595
Purpose: Create a complete copy of existing bill template
Parameters:
- โข
billnameid- Source template ID
Process Flow:
6. delete() - Soft Delete Template
Location: Line 452
Purpose: Temporarily disable bill template (conditions = 1)
7. ruturndelete() - Restore Template
Location: Line 492
Purpose: Restore soft-deleted bill template
8. execute() - Bulk Operations
Location: Line 524
Purpose: Perform bulk operations on multiple bill templates
Operations:
- โข
1- Temporary delete (soft delete) - โข
2- Return delete (restore)
9. getallBillproperty() - Load Properties
Location: Line 585
Purpose: Retrieve all available bill properties for configuration
---
๐ Business Logic Flow
Bill Template Creation Workflow
Property Configuration System
Bill Type Matrix
| Bill Type | Purpose | Store Effect | Save Effect | |
|---|---|---|---|---|
| 1 | Sales Bills | Decrease (-) | Increase (+) | |
| 2 | Purchase Bills | Increase (+) | Decrease (-) | |
| 3 | Return Sales | Increase (+) | Decrease (-) | |
| 4 | Return Purchase | Decrease (-) | Increase (+) | |
| 5 | Store Movement | Transfer | No Effect | |
| 6 | Quotations | No Effect | No Effect |
โ ๏ธ Common Issues
Property Synchronization
Issue: New properties don't appear in existing bill templates
// โ
SOLUTION: Line 342 - queryAllbillsettingsNotDeleted_f()
// Automatically includes new properties with default values
Bank Account Integration
Issue: Payment method configuration requires valid bank accounts
// โ
VALIDATION: Lines 101, 157 - Load available bank accounts
$bankAccounts = $bankAccountEX->queryWithOrder2ForVisaPayment();
POS Integration Settings
Issue: Barcode and weight configurations must be consistent
- โข
posWeightPrice- Must match POS system capabilities - โข
parcodeType- Must align with barcode scanner settings - โข
checkDigit- Required for EAN/UPC codes
---
๐ Dependencies
Required DAOs
- โข
BillnameMySqlDAO- Bill template database operations - โข
BillnameMySqlExtDAO- Extended bill template queries - โข
BillsettingsMySqlDAO- Bill settings operations - โข
BillsettingsMySqlExtDAO- Extended settings queries - โข
BillpropertyMySqlDAO- Bill property operations - โข
BankaccountMySqlExtDAO- Bank account queries - โข
RelusergrouppropertiesMySqlExtDAO- Permission validation
Required Files
- โข
../public/impOpreation.php- Core operations - โข
../public/config.php- Configuration - โข
../public/include_dao.php- DAO includes
Bill Property Categories
1. Display Properties - UI behavior, field visibility
2. Calculation Properties - Tax, discount, pricing rules
3. Workflow Properties - Approval, validation rules
4. Integration Properties - POS, payment, external systems
5. Security Properties - Access control, audit trails
---
๐ Performance Notes
- โข Property-based configuration requires JOIN queries
- โข Bulk operations for property settings use single INSERT
- โข Template copying uses bulk SQL for efficiency
- โข Bank account loading optimized for payment methods
- โข Property caching reduces repeated queries
The Bill Settings Controller serves as the foundation for all bill processing in the ERP system, providing flexible template-based configuration for diverse business scenarios.