html Purchase Controller User Manual

Material Receipt (Purchase) Manual

A Comprehensive Guide to the PurchaseController Workflow and Architecture

Project Overview

The PurchaseController manages the entire lifecycle of material receiving into the system. This includes managing suppliers, item inventories, accounting ledgers, and barcode generation. It is a critical component for inventory management and financial tracking.

Core Functions

  • Record New Purchases
  • Update Stock Inventories
  • Generate Accounting Entries
  • Automated Barcode Management

Security

  • Permission-based indexing
  • Auto-locking of records
  • User & Branch wise isolation

Related Database Tables

The system uses a normalized database structure to ensure data integrity across purchases, inventory, and accounts.

Table Name Description Key Fields
purchases Master table for purchase headers. _order_number, _ledger_id, _total
purchase_details Line items for each purchase invoice. _item_id, _qty, _rate, _barcode
purchase_accounts Accounting entries related to the purchase. _ledger_id, _dr_amount, _cr_amount
item_inventories Stock movement ledger entries. _item_id, _qty, _transection
product_price_list Maintains current stock & pricing for barcodes. _barcode, _pur_rate, _qty
accounts Global financial transaction journal (referenced as Model Accounts). _ref_master_id, _account_ledger

Models & Relationships

Models are mapped using Eloquent for seamless database interactions.

Controller Logic Details

The PurchaseController handles complex multi-step transactions using database commits and rollbacks for safety.

Method Route Type Core Functionality
index() GET Lists all purchases with advanced filters (date, branch, user).
create() GET Initializes the form with ledger and item dropdowns.
store() POST Critical method: Saves Master, Details, Inventory, and Ledger entries.
edit($id) GET Retrieves an existing purchase for modification.
update() POST Clears old entries and re-processes the entire transaction.
purchasePrint($id) GET Generates PDF/Printable invoice using one of 4 templates.

Pro-Tip: The store() and update() methods automatically update the supplier's balance and generate accounting vouchers (Debit/Credit) across involved ledgers.

User Interface (Views)

The interface is split into specialized Blade components for better maintainability.

View Path Purpose
backend.purchase.index Overview dashboard and search interface.
backend.purchase.create Dynamic entry form with AJAX barcode and item search.
backend.purchase.edit Record editing interface.
backend.purchase.print Invoice template selector (System Default).
backend.purchase.money_receipt Generates payment vouchers for the transaction.

Step-by-Step Workflow

Step 1: Initiation

Navigate to Material Receipt > Create New. Choose the Branch, Cost Center, and Date. Select the Main Ledger (Supplier).

Step 2: Adding Items

Search or barcode-scan items. Enter Quantity, Purchase Rate, and Sales Rate. The system handles VAT and Discounts per line item.

Step 3: Verification

Check the Sub-Total and Grand Total. Ensure Account Ledger entries (Debit/Credit) for payments (if any) are correctly mapped in the account section below the items.

Step 4: Submission

Click "Save Information". The controller will:
1. Generate an Invoice Number.
2. Add stock to item_inventories.
3. Deduct/Credit supplier ledger.
4. (Optional) Send an SMS to the supplier.

Step 5: Documentation

Use the Print action to download the invoice or the Money Receipt action for financial proof.