Storetransferrequest Documentation
Store Transfer Request Controller Documentation
File: /controllers/storetransferrequestController.php
Purpose: Manages inter-store product transfers with delivery tracking, approvals, and inventory management
Last Updated: December 21, 2024
Total Functions: 29
Lines of Code: ~2816
---
๐ Overview
The Store Transfer Request Controller is a comprehensive inventory transfer management system that handles product movement between stores with sophisticated approval workflows, delivery tracking, and financial integration. This is one of the most complex controllers in the system, providing:
- โข Inter-store product transfer requests and approvals
- โข Two-step transfer process (send request โ receive confirmation)
- โข Delivery driver assignment and tracking
- โข Size/color product variant support
- โข Operation numbering for batch tracking
- โข Comprehensive inventory quantity management
- โข Financial integration with daily entries (accounting)
- โข Store report generation for audit trails
- โข Complex approval workflows with user permissions
- โข Rollback functionality for failed transfers
- โข Product expiry date tracking for perishables
Primary Functions
- โ Create transfer requests between stores
- โ Approve/receive transfers with delivery tracking
- โ Manage inventory quantities across stores
- โ Track delivery status and driver assignments
- โ Handle size/color product variants
- โ Generate operation numbers for batching
- โ Create comprehensive audit trails
- โ Integrate with accounting system
- โ Support rollback operations
- โ Manage product serial numbers and expiry dates
Related Controllers
- โข storemovementController.php - Store movement operations
- โข storedetailController.php - Store inventory details
- โข productController.php - Product management
- โข dailyentryController.php - Accounting integration
---
๐๏ธ Database Tables
Primary Tables (Direct Operations)
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **storemovement** | Transfer records | transferproductid, storeidfrom, storeidto, productid, transferproductamount, operationnum, recieveType | |
| **storedetail** | Store inventory | storedetailid, productid, storeid, productquantity | |
| **storereport** | Audit trail | storereportid, productid, storeid, productquantity, tablename, processname |
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **product** | Product master | productId, productName, productCatId | |
| **sizecolorstoredetail** | Size/color variants | sizeid, colorid, productid, storeid, quantity | |
| **productserial** | Serial tracking | productserailid, productid, serialnumber, expireDate |
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **store** | Store master | storeId, storeName | |
| **user** | System users | userid, employeename, usergroupid | |
| **programsettings** | System config | programsettingsid, workerbetweenstores |
๐ Key Functions
Core Transfer Operations
1. Default Action - Transfer Interface
Location: Line 179
Purpose: Display the transfer request interface with store and driver selection
2. add() - Create Transfer Request
Location: Line 577
Purpose: Create transfer requests with inventory validation and operation numbering
Process Flow:
1. Validate inventory availability at source store
2. Create transfer records with unique operation number
3. Update source store inventory (decrease)
4. Update destination store inventory (increase) - if immediate mode
5. Create store reports for audit trail
6. Generate daily accounting entries
3. addDealWithStoreFromOnly() - Source Store Only Processing
Location: Line 823
Purpose: Handle transfers where only source store is processed immediately
4. addDealWithStoreToOnly() - Destination Store Processing
Location: Line 524
Purpose: Process destination store updates when transfers are received
Approval and Receiving
5. recieveproduct - Product Receiving
Location: Line 508
Purpose: Handle product receiving at destination stores with delivery confirmation
Process Flow:
1. Load transfer record
2. Validate receiving permissions
3. Update delivery information (driver, date)
4. Process destination store inventory updates
5. Create accounting entries for received goods
Display and Reporting
6. show - Transfer Display Interface
Location: Line 256
Purpose: Display transfer records with filtering options
7. showByoperationnum() - Operation-Based Display
Location: Multiple locations
Purpose: Display transfers grouped by operation number
8. showByDate() - Date-Based Display
Purpose: Display transfers within date ranges
Deletion and Rollback
9. returndelete() - Single Transfer Reversal
Purpose: Reverse individual transfer operations
10. returndelete2() - Batch Transfer Reversal
Purpose: Reverse entire operation batches
11. tempdelete() - Temporary Deletion
Purpose: Temporarily remove transfer records
Utility Functions
12. getStoredetailData() - Inventory Data Retrieval
Purpose: Get current inventory levels for products
13. insertStoredetail() - Inventory Record Creation
Purpose: Create new inventory records for products
14. insertStorereport() - Audit Trail Creation
Purpose: Create audit trail entries for all transfers
15. increaseProductQuantity() - Inventory Increase
Purpose: Increase product quantities at destination stores
16. decreaseProductQuantity() - Inventory Decrease
Purpose: Decrease product quantities at source stores
---
๐ Workflows
Workflow 1: Complete Transfer Process
Workflow 2: Size/Color Product Handling
---
๐ URL Routes & Actions
| URL Parameter | Function Called | Description | |
|---|---|---|---|
| `do=` (empty) | Default action | Display transfer interface | |
| `do=add` | `add()` | Create new transfer request | |
| `do=show` | Show interface | Display transfer records | |
| `do=showdetails` | Detail view | Show detailed transfer information | |
| `do=recieveproduct` | `recieveproduct` | Receive products at destination | |
| `do=returndelete` | `returndelete()` | Reverse single transfer | |
| `do=returndelete2` | `returndelete2()` | Reverse operation batch | |
| `do=tempdelete` | `tempdelete()` | Temporarily delete transfer | |
| `do=tempdelete2` | `tempdelete2()` | Temporarily delete batch | |
| `do=edit` | Edit interface | Edit transfer details | |
| `do=editprint` | Print edit | Print editable transfer | |
| `do=recieve` | Receive interface | Display receiving interface |
Create Transfer (do=add):
- โข
storeidfrom- Source store ID (via POST) - โข
storeidto- Destination store ID (via POST) - โข
productitr- Number of products being transferred (via POST) - โข
product{N}- Product ID for item N (via POST) - โข
productamount{N}- Transfer quantity for item N (via POST) - โข
operationnum- Operation number (via POST) - โข
recieveType- Receive type (1=immediate, 2=approval, via POST) - โข
driver- Driver ID if applicable (via POST)
Receive Products (do=recieveproduct):
- โข
id- Transfer record ID (via REQUEST) - โข
delivererid- Delivery person ID if applicable (via POST)
Show Transfers (do=show):
- โข
from- Start date filter (via REQUEST) - โข
to- End date filter (via REQUEST) - โข
operationnum- Operation number filter (via REQUEST) - โข
storeidto- Destination store filter (via POST)
---
๐งฎ Calculation Methods
Inventory Quantity Updates
Source Store Decrease:
$currentQuantity = $storeDetail->productquantity;
$newQuantity = $currentQuantity - $transferAmount;
$storeDetail->productquantity = $newQuantity;
Destination Store Increase:
$currentQuantity = $storeDetail->productquantity;
$newQuantity = $currentQuantity + $transferAmount;
$storeDetail->productquantity = $newQuantity;
Size/Color Variant Updates:
// Update both main inventory and variant inventory
$sizeColorDetail = $sizeColorDAO->load($sizeColorStoreDetailId);
$newVariantQty = $sizeColorDetail->quantity - $transferAmount;
$sizeColorDetail->quantity = $newVariantQty;
Operation Number Generation
// Get next operation number
$nextId = $myStoremovementEx->queryAlloperationnum();
$last_val = $nextId[0];
$operationNum = $last_val->operationnum + 1;
---
๐ Security & Permissions
Authentication
- โข All operations require authentication
- โข User permissions control store access
- โข Store supervisor permissions for receiving
Store Access Control
$userData = $userDAO->load($_SESSION['userid']);
$userData->storeSupervisorStores = explode(',', $userData->storeSupervisorStores);
Transaction Safety
- โข Database transactions ensure data integrity
- โข Rollback capability for failed operations
- โข Validation before inventory updates
---
๐ Performance Considerations
Critical Indexes Required
1. storemovement(operationnum, transferproductdate)
2. storedetail(productid, storeid)
3. sizecolorstoredetail(productid, storeid, sizeid, colorid)
4. storereport(tablename, recordid)
Optimization Tips
- โข Batch operations by operation number
- โข Use transactions for consistency
- โข Consider caching for frequently accessed stores/products
- โข Optimize size/color variant queries
---
๐ Common Issues & Troubleshooting
1. Inventory Sync Issues
Issue: Source and destination inventories don't balance
Cause: Transaction failures or partial updates
2. Operation Number Conflicts
Issue: Duplicate operation numbers generated
Cause: Concurrency in operation number generation
3. Size/Color Variant Problems
Issue: Complex product IDs not parsing correctly
Cause: Incorrect format or missing variant data
4. Approval Workflow Issues
Issue: Transfers stuck in pending state
Cause: Missing delivery confirmation or permission issues
---
๐ Related Documentation
- โข CLAUDE.md - PHP 8.2 migration guide
- โข storemovementController.php - Store movement operations
- โข storedetailController.php - Store inventory management
- โข dailyentryController.php - Accounting integration
---
Documented By: AI Assistant
Review Status: โ Complete
Next Review: When major changes occur