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.
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.
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 |
|
| 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(). |
The form's behavior is dictated by AccountLedgerController.php. Below are the key methods
involved:
create() MethodThis method retrieves dependent dropdown data such that the user can properly file the ledger hierarchy and relationships.
store(Request $request) MethodSubmitting the form triggers the store() method, which processes the creation flow:
_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.DB::beginTransaction() to assure database
integrity if any linked insertion fails.AccountLedger
instance.opening_dr_amount or opening_cr_amount is > 0, the system
fetches the fundamental retained earnings/opening ledger settings from
GeneralSettings.VoucherMaster model.VoucherMasterDetail model to
reflect the opening impact on accounting equations.Accounts reporting
table using correct hierarchical keys (Type/Group/Ledger).DB::commit() and returns the user back with a
success notification.| 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. |
backend.layouts.app: The parent layout template which wraps the entire create form
module. Included using @extends('backend.layouts.app').backend.message.message: A partial included at the top of the form via
@include() used to gracefully display error blocks or success notification alerts.backend.account-ledger.index: The standard list view of Account Ledgers. Users can
pivot back to this list using the header button linked via route name
account-ledger.index.