Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Copyright (c) 2024, AgriTheory and contributors
<!-- Copyright (c) 2025, AgriTheory and contributors
For license information, please see license.txt-->

# CHANGELOG
Expand Down
21 changes: 21 additions & 0 deletions beam/docs/developer/architecture/demand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Demand Design

### SQLite
Beam uses SQLite in parallel with MariaDB for specific data separation and performance optimization.

**Architecture Pattern:**
- Beam maintains dual database connections:
- MariaDB (via Frappe): Core ERP data, transactions, master data
- SQLite: Demand planning, receiving operations, analytics

**Demand and Receiving Tables:**
- **Demand Planning Data**: SQLite stores demand forecasting calculations and planning data
- **Receiving Operations**: Real-time receiving data and processing queues
- **Separation of Concerns**: Isolates high-frequency demand operations from core ERP data
- **Performance Benefits**: Faster read/write operations for demand-specific workloads

**Use Cases:**
- Demand forecasting calculations
- Receiving workflow data
- Temporary processing queues
- Analytics and reporting aggregations
78 changes: 78 additions & 0 deletions beam/docs/developer/architecture/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
## Development Guide

### Setup

**Prerequisites:**
```bash
# Frappe Framework requirements
python >= 3.8
node >= 16.x
npm >= 8.x
mariadb >= 10.3
redis-server

# For development with SQLite
sqlite3
```

**Frappe Bench Installation:**
```bash
# Install Frappe bench
pip install frappe-bench

# Create new site
bench new-site beam.local
bench get-app beam https://github.com/agritheory/beam.git
bench --site beam.local install-app beam

# Start development
bench start
```

**Frontend Development Setup:**
```bash
# Navigate to Beam app
cd apps/beam

# Install Node dependencies
npm install

# Start Vite development server with HMR
npm run dev

# Build for production
npm run build

# Register Beam resolvers
npm run register
```

**Environment Configuration:**
```python
# site_config.json
{
"db_name": "beam_development",
"db_password": "password",
"developer_mode": 1,
"auto_reload": 1,
"disable_website_cache": 1
}
```

**Development Workflow:**
```bash
# Backend development (Python/Frappe)
bench start

# Frontend development (Vue/TypeScript)
npm run dev

# Watch mode for frontend builds
npm run build:watch
```

**Scan Matrix Development:**
- Edit `/beam/scan/__init__.py` for scan logic
- Modify `listview` and `frm` dictionaries for action definitions
- Use `beam_listview` and `beam_frm` hooks for custom overrides
- Test scan actions via Beam PWA interface
53 changes: 53 additions & 0 deletions beam/docs/developer/architecture/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## Beam System Overview

### Component Structure
Beam's Vue.js PWA frontend is built with modular components using the Stonecrop library:

**Core Vue Components:**
- **Scan Components**: Barcode scanning interface components
- **Form Components**: Dynamic form rendering using @stonecrop/aform
- **List Components**: Data listing and filtering components
- **Navigation Components**: PWA navigation and routing
- **Mobile Components**: Touch-optimized mobile interfaces

**Stonecrop Integration:**
- `@stonecrop/beam` - Core Beam-specific components
- `@stonecrop/aform` - Advanced form handling components

### Decision Matrix
Beam's scan matrix system defines actions and responses based on both the barcode scanned and the current context (list view or form). This allows for dynamic behavior based on user interactions.

The response action is determined by:
- **Barcode Type**: Item, Handling Unit, Warehouse, etc.
- **Current Context**: Whether the scan occurs in a list view or a form
- **Target Doctype**: The document type being interacted with
- **Current Document State**: Whether the document is new, draft, or submitted
- **Custom Hooks**: Overrides defined in the `hooks.py` file

The default scan matrix defines the following actions:

**List View Actions:**
- **Filter Actions**: Apply filters to list views based on scanned items
- **Route Actions**: Navigate to specific document views

**Form Actions:**
- **`add_or_increment`**: Add new items or increment existing quantities
- **`add_or_associate`**: Associate scanned items with form fields
- **`set_item_code_and_handling_unit`**: Set item and handling unit fields
- **`set_warehouse`**: Set warehouse fields

### Built-in Functions

**Form Functions:**
- `scan()` - The public API endpoint for handling barcode scans
- `get_barcode_context()` - Resolve barcode to document context
- `get_handling_unit()` - Retrieve handling unit details
- `get_stock_entry_item_details()` - Stock entry specific item processing
- `get_list_action()` - Generate list view actions
- `get_form_action()` - Generate form actions

**Mobile Functions:**
- PWA offline capabilities via Workbox
- OnScan.js integration for barcode scanning
- Vue Toast notifications for user feedback
- Pinia state management for offline data sync
99 changes: 99 additions & 0 deletions beam/docs/developer/extending_beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!-- Copyright (c) 2025, AgriTheory and contributors
For license information, please see license.txt-->

# Extending BEAM

### Schema / Hooks
Beam extends Frappe's hook system with custom hooks for different contexts:

**Beam-specific Hooks:**
- **`beam_client`**: Additional client-side functions
- **`beam_listview`**: Custom list view scan actions
- **`beam_frm`**: Custom form scan actions
- **`beam_mobile`**: Custom mobile-specific components and route definitions
- **`demand`**: Demand planning and forecasting hooks

**Hook Override System:**
```python
# Custom scan actions for forms via hooks
beam_override = frappe.get_hooks("beam_frm")
override_doctype = beam_override.get(barcode_doc.doc.doctype)
override_action = override_doctype.get(context.frm)
```

#### Examples

```python
# hooks.py

# To make scanning available on a custom doctype, add a table field
# for "Item Barcode" directly in the doctype or via customize form.
# Then add a key that is a peer with "Item" in the example below.

# To extend scanning functionality within a doctype, add a key that
# is a peer with "Delivery Note" in the example below.

beam_listview = {
"Item": {
"Delivery Note": [
{
"action": "filter",
"doctype": "Delivery Note Item",
"field": "item_code"
},
{
"action": "filter",
"doctype": "Packed Item",
"field": "item_code"
}
],
},
...
}

beam_frm = {
"Item": {
"Delivery Note": [
{
"action": "add_or_increment",
"doctype": "Delivery Note Item",
"field": "item_code",
"target": "target.item_code",
},
{
"action": "add_or_increment",
"doctype": "Delivery Note Item",
"field": "uom",
"target": "target.uom",
},
]
},
...
}

# To add a custom JavaScript function, use the following hook:
beam_client = {"show_message": "custom_app.show_message"}
```

## Adding Custom Vue Components

- Why
- What
- How

```python
beam_mobile = {
"components": {
"Consume": "./custom_app/custom_app/public/js/Consume.vue",
},
"routes": [
{
"path": "/consume",
"name": "consume",
"component": "Consume",
"meta": {"requiresAuth": True, "doctype": "Stock Entry", "view": "form"},
},
],
}

```
28 changes: 28 additions & 0 deletions beam/docs/developer/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!-- Copyright (c) 2025, AgriTheory and contributors
For license information, please see license.txt-->

## Beam Developer Documentation

Welcome to the Beam developer documentation. This guide provides comprehensive information for developers working with the Beam application.

### Documentation Structure

- **[Architecture](./architecture/overview.md)** - System overview, demand design and development guide
- **[Overview](./architecture/overview.md)** - High-level architecture, components, and data flow
- **[Demand Design](./architecture/demand.md)** - Demand planning, forecasting, and scan action design
- **[Development](./architecture/development.md)** - Setup instructions, development workflow, and environment configuration
- **[Extending Beam](./extending_beam.md)** - Hook system, custom actions, and mobile development
- **[Print Integration](./print_integrations.md)** - Print server setup, ZPL development, and custom formats

### Getting Help

- Check the troubleshooting sections in each guide
- Review the examples and code samples

### Contributing

When contributing to Beam:
- Follow the established architecture patterns
- Use the hook system for extensions
- Add tests for new functionality
- Update documentation for new features
File renamed without changes.
19 changes: 0 additions & 19 deletions beam/docs/form.md

This file was deleted.

52 changes: 0 additions & 52 deletions beam/docs/hooks.md

This file was deleted.

18 changes: 0 additions & 18 deletions beam/docs/testing.md

This file was deleted.

Loading
Loading