Cash Receive Form Manual

A comprehensive guide detailing the UI functionality, code structure, and backend database integrations.

1. Introduction

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.

2. Architecture: Database Tables & Models

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.

3. Understanding the Controller

The form depends on VoucherMasterController.php. Below are the key functions handling this process.

The cashReceive() Method

This method prepares all requisite data to render the Blade view.

The voucherSave() Method

Once the user clicks Save, the form makes a POST request to the voucher-save URL, routed to voucherSave(Request $request).

Accounting Logic behind Cash Receive (CR): In the view, multiple items with Receive Amounts (Cr.) can be inputted. However, to balance the voucher, the controller sums all the Cr. Amounts and automatically creates a new debit (Dr.) line matching this sum under the selected Cash Account.
// 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');
}

4. Step-by-Step Form Details

Here is how a user interacts with cash-receive.blade.php along with the underlying code mapping.

1

Basic Master Information

The form begins with high-level details that apply to the entire voucher.

  • Date: (name="_date") Managed by a datetimepicker script calculating default today's date format via JavaScript.
  • Voucher Type: (name="_voucher_type") Bound to backend variable $voucher_types fetching specifically the 'CR' code.
  • Reference: (name="_transection_ref") An optional manual string referring to an external document or check.
  • Cash Accounts: (name="_defalut_ledger_id") A crucial field populated with cash groups. Determines where the total Debit amount will ultimately hit.
2

Adding Receive Details (The Grid)

Users enter specific transaction lines inside an appendable HTML table with id #area__voucher_details.

  • Ledger: Live search input (_search_ledger_id[]) that populates the hidden field (_ledger_id[]) containing the unique DB ID.
  • Branch & Cost Center: Select inputs hidden/displayed dynamically based on the current user's permissions ($permited_branch and $permited_costcenters size).
  • Short Narr.: A brief description distinct to that specific line item (_short_narr[]).
  • Receive Amount: Represents the Credit Amount (_cr_amount[]). Note: The Debit Amount input is hidden via class display_none since CR vouchers assume debit balancing automatically against Cash.
3

Total Calculation and Note

In the footer of the table, a totalizer script computes the entries dynamically.

  • Live Total Execution: Triggered globally by JavaScript hooks on keyup of _cr_amount computing to _total_cr_amount.
  • Note Field: (name="_note") A required primary description of the overall entry. Enforced with an asterisk and JS validation.
4

Save & Print Actions

The user finishes by selecting one of the final options.

  • Save: Submits POST via form action="voucher-save". Triggers basic insertion in DB.
  • Save & Print: Alters a hidden input _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.