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: €500

Behavior:

  • 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: €200

Behavior:

  • 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: €5000

Behavior:

  • 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: €10000

Behavior:

  • 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: €50000

Behavior:

  • 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: €100000

Behavior:

  • 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: €1000

Behavior:

  • Checks each order individually
  • No time period
  • Always active

Use Case: Maximum order value limit

Creating Budgets

Method 1: Admin Panel

  1. Navigate to Customers >All Customers
  2. Edit customer
  3. Go to Sublogins tab
  4. Edit a sublogin
  5. Scroll to Budget section
  6. Click Add Budget

Budget Form:

Budget Type: Monthly Amount: 5000.00 Per Order Limit: 1000.00 Valid From Date: 2024-01-01 Status: Active
  1. Click Save Budget

Method 2: Customer Account (if enabled)

  1. Log in as customer
  2. Go to My Sublogins
  3. Edit sublogin
  4. Manage budgets
  5. 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: €800

Example:

  • 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:

  1. Cart total is calculated
  2. System checks available budget
  3. If exceeded, checkout is blocked
  4. 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 exceeded

Per 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

  1. Go to Stores >Configuration > Sales > Payment Methods
  2. Find Pay on Budget
  3. 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 budget

Option 2: Count Only "Pay on Budget" Orders

Only orders paid with "Pay on Budget" method count Other payment methods don't affect budget

Configure in Stores >Configuration > MageB2B > Sublogin Budget:

Use only Pay on Budget orders for budget usage: Yes/No

Cron 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=default

Budget Reports

Frontend Budget Summary

Enable in Stores >Configuration > MageB2B > Sublogin Budget:

Enable Budget Summary in Frontend for Customer: Yes

Displays:

  • 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" status

Example 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 order

Example 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 year

Example 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 exists

Troubleshooting

Budget Not Enforcing

  1. Check budget status is Active
  2. Verify valid from date is in past
  3. Check budget type is correct
  4. Ensure order status is in configured list
  5. Clear cache

Budget Calculation Wrong

  1. Check calculation basis (Subtotal vs Grand Total)
  2. Verify order statuses configuration
  3. Check if "Pay on Budget only" is enabled
  4. Review order history

Cron Not Running

  1. Check cron is configured: crontab -l
  2. Run manually: php bin/magento cron:run
  3. Check cron_schedule table
  4. Review var/log/system.log

Pay on Budget Not Showing

  1. Verify payment method is enabled
  2. Check budget is sufficient
  3. Ensure cart total is within budget
  4. 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/No

Error Messages

- Budget Exceeded Message - Per Order Limit Exceeded Message - Budget Expired Message

Email Notifications

- Budget Warning Threshold: 80% - Budget Warning Email Template - Budget Exceeded Email Template

Next Steps

Found an issue with this documentation? Let us know