User Manual: Account Ledger Create Form

This document provides a step-by-step explanation of the Account Ledger creation form (resources/views/backend/account-ledger/create.blade.php) and its backend functionality.

1. Form Overview and Structure

The form is designed to add a new Account Ledger into the accounting system. It uses Laravel Collective's form builder component {!! Form::open(['route' => 'account-ledger.store', 'method'=>'POST']) !!} to submit the POST request to the store method of the AccountLedgerController.

The form captures essential ledger information including account classification (Type/Group), associated branch/organization, contact information, and initial opening balances.

2. Step-by-Step Form Details

Below is a breakdown of all input fields presented to the user on this form:

Field Name Input Type / ID Requirement Description
Account Type Select (_account_head_id) Required Dropdown loaded with data from AccountHead model. Represents the root classification (e.g., Asset, Liability).
Account Group Select (_account_group_id) Required Dropdown populated via AccountGroup model. Represents the sub-category under the account type.
Organization Select (organization_id) Conditional Visible if the user has permissions for multiple organizations. Associates the ledger with a specific company branch/organization.
Branch Select (_branch_id) Required Associates the ledger with a specific software module branch. Loaded from Branch model.
Cost Center Select (_cost_center_id) Conditional Visible if the user has multiple cost center permissions.
Ledger Name Text Input (_name) Required The unique name characterizing the ledger (e.g., "John Doe - Supplier"). Must be unique in the system.
Address / Note Textarea (_address, _note) Optional Physical address and additional descriptions or remarks.
Proprietor Text Input (_alious) Optional The name of the business owner or alias.
Email / Phone Input (_email, _phone) Optional Contact information related to this ledger.
Code / NID Text Input (_code, _nid) Optional A custom accounting software code and National ID Number for the ledgers.
Credit Limit Number Input (_credit_limit) Optional Maximum allowable credit (default is 0).
Visibility Flags Select Logic
  • Is Sales Form: Determine if visible on sales invoice module.
  • Is Purchase Form: Determine if visible on purchase entry module.
  • Search For All Branch: Allow usage across multiple branches.
Opening Balance Number Input (opening_dr_amount, opening_cr_amount) Logic Specifies the initial debt (Dr.) or credit (Cr.) balance carried forward.
Status Select (_status) Required Defines if the ledger is Active or Inactive. Loaded from a system helper common_status().

3. Code Structure & Controller Guidance

The form's behavior is dictated by AccountLedgerController.php. Below are the key methods involved:

The create() Method

This method retrieves dependent dropdown data such that the user can properly file the ledger hierarchy and relationships.

public function create() { $page_name = $this->page_name; // Load parent models for dropdown selections $account_types = AccountHead::select('id','_name')->orderBy('_name','asc')->get(); $account_groups = AccountGroup::select('id','_name')->orderBy('_name','asc')->get(); $branchs = Branch::orderBy('_name','asc')->get(); return view('backend.account-ledger.create',compact('account_types','page_name','account_groups','branchs')); }

The store(Request $request) Method

Submitting the form triggers the store() method, which processes the creation flow:

  1. Validation: Ensures that _account_head_id, _account_group_id, _branch_id, _name, and _status are provided. Specifically validates that the _name is strictly unique in the account_ledgers table.
  2. Transaction: Initiates DB::beginTransaction() to assure database integrity if any linked insertion fails.
  3. Primary Creation: Saves mapped Request fields into a new AccountLedger instance.
  4. Opening Balance Processing:
    • If opening_dr_amount or opening_cr_amount is > 0, the system fetches the fundamental retained earnings/opening ledger settings from GeneralSettings.
    • It creates an auto-generated Journal Voucher (JV) inside the VoucherMaster model.
    • It adds detailed debit/credit legs inside the VoucherMasterDetail model to reflect the opening impact on accounting equations.
    • It replicates these financial entries down into the granular Accounts reporting table using correct hierarchical keys (Type/Group/Ledger).
  5. Commitment: Executes DB::commit() and returns the user back with a success notification.

4. Related Database Tables and Models

Model Name Database Table (Expected) Purpose within Context
AccountLedger account_ledgers The core table holding the newly submitted ledger record along with its contact and status settings.
AccountHead account_heads Holds high-level account types (e.g., Asset, Liability) linked via foreign key _account_head_id.
AccountGroup account_groups Holds sub-category accounting groups linked via foreign key _account_group_id.
Branch branches Company sub-divisions list fetched to tie the ledger via _branch_id.
GeneralSettings general_settings Fetched solely to check backend configurations for standard _opening_ledger ID binding.
VoucherMaster & VoucherMasterDetail voucher_masters / voucher_master_details Creates a journal entry record when a ledger is created initialized with an opening balance.
Accounts accounts The central ledger reporting log table. Captures the generated Journal Voucher lines to render Trial Balances.

5. Related Views