Budget Management Add-On
The SubloginBudget add-on provides comprehensive budget management with flexible budget types, automatic tracking, and enforcement.
Overview
The Budget Management add-on extends the base Sublogin module with:
- 7 Budget Types: Day, Daily, Month, Monthly, Year, Yearly, Per Order
- Automatic Tracking: Monitors spending from orders
- Budget Enforcement: Blocks checkout when budget exceeded
- Pay on Budget: Optional payment method
- Cron Automation: Auto-expires budgets
Installation
composer config bearer.repo.softwaresilo.io composer config repositories.softwaresilo composer https://repo.softwaresilo.io/ composer require mageb2b/sublogin-budget:* php bin/magento module:enable MageB2B_SubloginBudget php bin/magento setup:upgrade php bin/magento cache:flush Budget Types
1. Day (One-Time Daily Budget)
Type ID: 5
Validity: Valid only on the specified day
Valid From: 2024-01-15 Amount: €500Behavior:
- Active only on January 15, 2024
- Expires automatically after that day
- Used for special one-day events or promotions
Use Case: Special event purchasing (trade show, conference)
2. Daily (Recurring Daily Budget)
Type ID: 6
Validity: Valid from start date, renews daily
Valid From: 2024-01-01 Amount: €200Behavior:
- Active every day starting January 1, 2024
- Resets at midnight each day
- No expiration date
Use Case: Daily employee spending limit
3. Month (One-Time Monthly Budget)
Type ID: 3
Validity: Valid for the entire month from start date
Valid From: 2024-01-15 Amount: €5000Behavior:
- Active for entire January 2024 (even if starting mid-month)
- Expires at end of January
- Covers whole month regardless of start date
Use Case: Project budget for specific month
4. Monthly (Recurring Monthly Budget)
Type ID: 4
Validity: Valid from start date, renews monthly
Valid From: 2024-01-01 Amount: €10000Behavior:
- Active every month starting January 2024
- Resets on 1st of each month
- No expiration date
Use Case: Department monthly budget
5. Year (One-Time Yearly Budget)
Type ID: 1
Validity: Valid for the entire year from start date
Valid From: 2024-01-01 Amount: €50000Behavior:
- Active for entire year 2024
- Expires at end of 2024
- Covers whole year
Use Case: Annual project budget
6. Yearly (Recurring Yearly Budget)
Type ID: 2
Validity: Valid from start date, renews yearly
Valid From: 2024-01-01 Amount: €100000Behavior:
- Active every year starting 2024
- Resets on January 1st each year
- No expiration date
Use Case: Annual department budget
7. Per Order
Type ID: 7
Validity: Applies to each individual order
Per Order Limit: €1000Behavior:
- Checks each order individually
- No time period
- Always active
Use Case: Maximum order value limit
Creating Budgets
Method 1: Admin Panel
- Navigate to Customers >All Customers
- Edit customer
- Go to Sublogins tab
- Edit a sublogin
- Scroll to Budget section
- Click Add Budget
Budget Form:
Budget Type: Monthly Amount: 5000.00 Per Order Limit: 1000.00 Valid From Date: 2024-01-01 Status: Active- Click Save Budget
Method 2: Customer Account (if enabled)
- Log in as customer
- Go to My Sublogins
- Edit sublogin
- Manage budgets
- Add/edit budgets
Budget Calculation
Calculation Basis
Configure in Stores >Configuration > MageB2B > Sublogin Budget:
Option 1: Subtotal
Order Subtotal: €1000 Tax: €200 Shipping: €50 Grand Total: €1250 Budget Used: €1000 (subtotal only)Option 2: Grand Total
Order Subtotal: €1000 Tax: €200 Shipping: €50 Grand Total: €1250 Budget Used: €1250 (full amount)Order Status Filtering
Configure which order statuses count toward budget:
- Pending
- Processing
- Complete
- (Exclude: Canceled, Closed)
Multiple Budget Stacking
If multiple budget types apply, they stack (sum):
Day Budget: €300 Daily Budget: €500 Total Available Today: €800Example:
- Sublogin has Daily budget of €500
- Special Day budget of €300 for today
- Can spend up to €800 today
Budget Enforcement
Checkout Blocking
When budget would be exceeded:
- Cart total is calculated
- System checks available budget
- If exceeded, checkout is blocked
- Error message displayed:
We are sorry, the checkout is not possible. Your budget limit for this Month of €5000.00 will be exceeded by €250.00.Error Message Customization
Configure in Stores >Configuration > MageB2B > Sublogin Budget:
Budget Error Message: We are sorry, the checkout is not possible. Your budget limit for this %1 of %2 will be exceeded by %3. Variables: %1 = Budget period (Day, Month, Year) %2 = Budget limit %3 = Amount exceededPer Order Limit
Separate from period budgets:
Monthly Budget: €10000 (remaining: €8000) Per Order Limit: €1000 Order Total: €1200 Result: BLOCKED (exceeds per order limit) Order Total: €900 Result: ALLOWED (within per order limit and monthly budget)Pay on Budget Payment Method
Overview
Optional payment method that deducts from budget.
Configuration
- Go to Stores >Configuration > Sales > Payment Methods
- Find Pay on Budget
- Enable and configure:
- Title: "Pay from Budget"
- Sort Order: 10
- Applicable Countries: All
Behavior
- Only shown if order is within budget
- Automatically hidden if budget insufficient
- Order is marked as "paid from budget"
Budget Calculation Options
Option 1: Count All Orders
All orders in configured statuses count toward budgetOption 2: Count Only "Pay on Budget" Orders
Only orders paid with "Pay on Budget" method count Other payment methods don't affect budgetConfigure in Stores >Configuration > MageB2B > Sublogin Budget:
Use only Pay on Budget orders for budget usage: Yes/NoCron Jobs
Auto-Expire Budgets
Runs daily to disable expired budgets:
Cron Schedule: 0 2 * * * (2 AM daily)What it does:
- Checks all active budgets
- Disables Day budgets after their date
- Disables Month budgets at end of month
- Disables Year budgets at end of year
- Sets status = 0 (inactive)
Manual Cron Execution
php bin/magento cron:run --group=defaultBudget Reports
Frontend Budget Summary
Enable in Stores >Configuration > MageB2B > Sublogin Budget:
Enable Budget Summary in Frontend for Customer: YesDisplays:
- Current budget limits
- Used budget
- Remaining budget
- Budget period
- Expiration date
Admin Budget Overview
Navigate to Customers >All Customers > Edit Customer > Sublogins > Edit Sublogin > Budget
Shows:
- All budgets for sublogin
- Budget type
- Amount and used amount
- Valid from date
- Status
- Actions (Edit, Delete)
Practical Examples
Example 1: Department Monthly Budget
Scenario: Marketing department with €10,000/month Budget Type: Monthly Amount: 10000.00 Per Order Limit: 2000.00 Valid From: 2024-01-01 Status: Active Behavior: - Resets on 1st of each month - Maximum €2000 per order - Tracks all orders in "Processing" and "Complete" statusExample 2: Employee Daily Limit
Scenario: Employee with €200/day spending limit Budget Type: Daily Amount: 200.00 Per Order Limit: 200.00 Valid From: 2024-01-01 Status: Active Behavior: - Resets at midnight each day - Cannot exceed €200 per day - Cannot exceed €200 per orderExample 3: Project Budget
Scenario: 6-month project with €30,000 budget Budget Type: Month (one-time) Amount: 30000.00 Valid From: 2024-01-01 Status: Active Note: Create 6 separate Month budgets for Jan-Jun Or use Year budget with €30,000 for entire yearExample 4: Special Event
Scenario: Trade show with €5000 budget for one day Budget Type: Day Amount: 5000.00 Valid From: 2024-03-15 Status: Active Behavior: - Active only on March 15, 2024 - Auto-expires after that day - Combined with Daily budget if existsTroubleshooting
Budget Not Enforcing
- Check budget status is Active
- Verify valid from date is in past
- Check budget type is correct
- Ensure order status is in configured list
- Clear cache
Budget Calculation Wrong
- Check calculation basis (Subtotal vs Grand Total)
- Verify order statuses configuration
- Check if "Pay on Budget only" is enabled
- Review order history
Cron Not Running
- Check cron is configured:
crontab -l - Run manually:
php bin/magento cron:run - Check
cron_scheduletable - Review
var/log/system.log
Pay on Budget Not Showing
- Verify payment method is enabled
- Check budget is sufficient
- Ensure cart total is within budget
- Clear cache
Configuration Reference
General Settings
Stores >Configuration > MageB2B > Sublogin Budget - Enable Budget System: Yes/No - Budget Calculation Basis: Subtotal / Grand Total - Order Statuses for Budget: Pending, Processing, Complete - Use only Pay on Budget orders: Yes/No - Enable Budget Summary in Frontend: Yes/NoError Messages
- Budget Exceeded Message - Per Order Limit Exceeded Message - Budget Expired MessageEmail Notifications
- Budget Warning Threshold: 80% - Budget Warning Email Template - Budget Exceeded Email Template