A comprehensive guide detailing the UI functionality, code structure, and backend database integrations.
The Cash Receive form is used to register incoming cash transactions from clients,
customers, or other income sources. The front-end view is generated using Laravel Blade at
resources/views/backend/voucher/cash-receive.blade.php and processes data through the
VoucherMasterController.php.
The cash receive operation heavily interacts with the following backend structures to ensure accurate double-entry accounting.
| Model | Database Table | Purpose |
|---|---|---|
VoucherMaster |
voucher_masters |
Stores the primary header details of the voucher (e.g., date, voucher type, reference, total amount). |
VoucherMasterDetail |
voucher_master_details |
Stores individual ledger items (debits and credits) that belong to a single voucher. |
AccountLedger |
account_ledgers |
Stores individual account/customer ledgers that are searched and selected in the details grid. |
VoucherType |
voucher_types |
Defines the type of the voucher (e.g., "CR" for Cash Receive). |
Branch & CostCenter |
branches & cost_centers |
Used for segregation of accounts and analytical reporting. |
The form depends on VoucherMasterController.php. Below are the key
functions handling this process.
cashReceive() MethodThis method prepares all requisite data to render the Blade view.
"Cash Receive".'CR')._cash_group.backend.voucher.cash-receive with the compacted
variables.voucherSave() MethodOnce the user clicks Save, the form makes a POST request to the
voucher-save URL, routed to voucherSave(Request $request).
// Example from VoucherMasterController@voucherSave
if($_voucher_type =="CR"){
// 1. Calculate sum of all credit amounts inserted by the user
$_total_dr_amount = array_sum($_cr_amount);
// 2. Automatically push the Debit balance
array_push($_dr_amount, $_total_dr_amount);
array_push($_cr_amount, 0);
// 3. Assign this debit entry to the Cash Ledger chosen in the top dropdown
array_push($_ledger_id, $request->_defalut_ledger_id);
array_push($_cost_center, $request->_cost_center_id ?? 1);
array_push($_branch_id_detail, $request->_branch_id ?? 1);
array_push($_short_narr, 'N/A');
}
Here is how a user interacts with cash-receive.blade.php along with the underlying code
mapping.
The form begins with high-level details that apply to the entire voucher.
name="_date") Managed by a datetimepicker script
calculating default today's date format via JavaScript.name="_voucher_type") Bound to backend variable
$voucher_types fetching specifically the 'CR' code.name="_transection_ref") An optional manual string
referring to an external document or check.name="_defalut_ledger_id") A crucial field
populated with cash groups. Determines where the total Debit amount will ultimately hit.
Users enter specific transaction lines inside an appendable HTML table with id
#area__voucher_details.
_search_ledger_id[]) that populates
the hidden field (_ledger_id[]) containing the unique DB ID.$permited_branch and
$permited_costcenters size)._short_narr[])._cr_amount[]).
Note: The Debit Amount input is hidden via class display_none since CR
vouchers assume debit balancing automatically against Cash.In the footer of the table, a totalizer script computes the entries dynamically.
keyup of _cr_amount computing to _total_cr_amount.
name="_note") A required primary description of
the overall entry. Enforced with an asterisk and JS validation.The user finishes by selecting one of the final options.
action="voucher-save". Triggers
basic insertion in DB._save_and_print_value to
1 via JavaScript class _save_and_print. On page reload, an
injected inline script opens a new window directly outputting the receipt generated.