Sales Invoice Form

Documentation for sales/create.blade.php & SalesController.php

1. Form Overview

The Sales Creation form is a dynamic interface designed for recording sales transactions. It supports direct sales (bypassing purchase stock) or store-based sales. The visibility of fields like Barcode, VAT, SD, and Warranty is toggled via the Sales Form Settings.

Dynamic Settings Uses $form_settings (SalesFormSetting model) to hide/show columns based on business requirements.
Multi-Module Integrates with Inventory to check stock and Accounts to update ledger balances.
Dynamic Grid

3. Item Details Grid

The heart of the form where items are added. Users can add multiple rows.

Field Name Functionality
_search_item_id Search item by name or barcode. Triggers item-sales-barcode-search.
_qty Sales quantity. System triggers stock validation on keyup.
_sales_rate Pre-fetched from price list but editable for custom pricing.
_vat / _sd Percentage-based calculations for Value Added Tax and Supplementary Duty.
_value Calculated as (Qty * Rate) + VAT + SD - Discount.

Barcode Support: If enabled, users can scan unique barcodes which automatically populate row details.

Accounting Logic

4. Financial Integration

Depending on the user's account type, the form loads different sub-views:

Dual Entry Processing: When saved, the system creates balanced entries in SalesAccount:
DR: Account Receivable (Customer)
CR: Sales Income
Backend API

5. Process Handling (SalesController@store)

1

Begin Transaction

Ensures atomicity using DB::beginTransaction(). If any step fails, the entire sale is rolled back.
2

Save Master (Sales Model)

Creates the sales table entry with _sub_total, _total_vat, and _total.
3

Inventory Deduction

Loops through items, updates ProductPriceList qty, and records movement in ItemInventory.
4

Account Posting

Calls account_data_save() to update ledger balances and reporting tables.

6. Footer & Finalization

The bottom section handles final calculations and saving: