Invoicing
Overview
The invoicing feature allows users to generate and manage proforma invoices and student invoices. It includes functionality for creating invoices, viewing invoice details, filtering invoices by various criteria, and handling server-side operations for invoice data. T
Features
- Generate Proforma Invoice: Allows users to create a new proforma invoice with customer details, invoice items, and tax information.
- Generate Student Invoice: Retrieves and displays detailed financial information for a specific student.
- View All Proforma Invoices: Displays a list of all proforma invoices with filtering options.
- Filter Invoices: Provides filtering options by customer name, invoice number, status, and date range.
- View Invoice Details: Allows users to view detailed information of a specific invoice in a dialog.
Components and Logic
Generate Proforma Invoice
Workflow:
- User navigates to the "Generate Proforma Invoice" page.
- User fills out the form with customer details, billing and shipping addresses, and adds invoice items.
- User specifies the tax percentage.
- User clicks the "Generate" button to create the invoice.
- The system validates the form inputs.
- If validation passes, the system generates a unique invoice number and sends the data to the server.
- The server processes the data and stores the invoice in the database.
- A success message is displayed, and the user is redirected to the list of all invoices.
Components:
- GenerateProforma: The main component for generating invoices. It includes form fields for customer details, invoice items, and tax information.
- ProformaInvoice: A sub-component that displays the invoice preview as the user fills out the form.
Logic Flow:
+------------------+
| GenerateProforma |
+------------------+
|
v
+------------------+
| Validate Form |
+------------------+
|
Validation Passes|
v
+------------------+
| Generate Invoice |
| Number |
+------------------+
|
v
+------------------+
| Send Data to |
| Server |
+------------------+
|
v
+------------------+
| Store in Database|
+------------------+
|
v
+------------------+
| Redirect to List |
| of Invoices |
+------------------+
Generate Student Invoice
Workflow:
- User requests student invoice data by providing a student ID.
- The system retrieves the student’s financial data from the database, including program details, semester registrations, payments, and financial statements.
- The system calculates the total debit, total credit, latest balance, and balance remaining.
- The invoice data is returned to the user.
Logic Flow:
+-------------------------+
| getStudentInvoiceData |
+-------------------------+
|
v
+-------------------------+
| Retrieve Student Data |
| from Database |
+-------------------------+
|
v
+-------------------------+
| Calculate Financial |
| Details |
+-------------------------+
|
v
+-------------------------+
| Return Invoice Data |
+-------------------------+
View All Proforma Invoices
Workflow:
- User navigates to the "View Proforma Invoices" page.
- The page fetches all proforma invoices from the server.
- The invoices are displayed in a table with options to filter by customer name, invoice number, status, and date range.
- User can click on an invoice to view its details.
Components:
- ViewProforma: The main component that displays the list of invoices and handles filtering.
- InvoiceFilter: A sub-component that provides search and filter options.
- DialogProforma: A sub-component that displays invoice details in a dialog.
Logic Flow:
+------------------+
| ViewProforma |
+------------------+
|
v
+------------------+
| Fetch Invoices |
| from Server |
+------------------+
|
v
+------------------+
| Display Invoices |
| in Table |
+------------------+
|
v
+------------------+
| Apply Filters |
+------------------+
|
v
+------------------+
| Filtered Invoices|
+------------------+
Filter Invoices
Workflow:
- User enters search terms or selects filter options (status, date range) in the InvoiceFilter component.
- The filter component updates the filter criteria.
- The main ViewProforma component applies the filters to the list of invoices.
- The filtered list of invoices is displayed.
Components:
- InvoiceFilter: Handles search and filter input from the user.
- ViewProforma: Applies the filter criteria to the list of invoices.
Logic Flow:
+------------------+
| InvoiceFilter |
+------------------+
|
v
+------------------+
| Update Filters |
+------------------+
|
v
+------------------+
| ViewProforma |
| Applies Filters |
+------------------+
|
v
+------------------+
| Display Filtered |
| Invoices |
+------------------+
View Invoice Details
Workflow:
- User clicks the "View" button on an invoice in the list.
- The DialogProforma component is triggered and displays detailed information of the selected invoice.
- User can view the invoice details and close the dialog when done.
Components:
- DialogProforma: Displays detailed information of the selected invoice in a dialog.
Logic Flow:
+------------------+
| Click View |
| Button |
+------------------+
|
v
+------------------+
| DialogProforma |
| Shows Invoice |
| Details |
+------------------+
|
v
+------------------+
| User Views |
| Details |
+------------------+
|
v
+------------------+
| Close Dialog |
+------------------+
Server-Side Functions
generateProformaInvoice
Logic:
- Generate a unique invoice ID and invoice number.
- Calculate the total amount and total before tax.
- Insert the invoice and its items into the database.
- Return the generated invoice data.
Logic Flow:
+------------------+
| generateProforma |
| Invoice |
+------------------+
|
v
+------------------+
| Generate Unique |
| ID and Number |
+------------------+
|
v
+------------------+
| Calculate Amounts|
+------------------+
|
v
+------------------+
| Insert into |
| Database |
+------------------+
|
v
+------------------+
| Return Invoice |
| Data |
+------------------+
getAllProformaInvoices
Logic:
- Fetch all proforma invoices and their items from the database.
- Group the invoices by their IDs and include the items for each invoice.
- Return the grouped invoices.
Logic Flow:
+------------------+
| getAllProforma |
| Invoices |
+------------------+
|
v
+------------------+
| Fetch Invoices |
| and Items |
+------------------+
|
v
+------------------+
| Group by Invoice |
| ID |
+------------------+
|
v
+------------------+
| Return Grouped |
| Invoices |
+------------------+
getStudentInvoiceData
Logic:
- Validate the provided user ID.
- Retrieve student data from the database, including user details, program level, semester registrations, payments, and financial statements.
- Calculate financial details such as total debit, total credit, latest balance, and balance remaining.
- Return the invoice data or an error message if the user ID is invalid or no student is found.
Logic Flow:
+-------------------------+
| getStudentInvoiceData |
+-------------------------+
|
v
+-------------------------+
| Validate User ID |
+-------------------------+
|
v
+-------------------------+
| Retrieve Student Data |
| from Database |
+-------------------------+
|
v
+-------------------------+
| Calculate Financial |
| Details |
+-------------------------+
|
v
+-------------------------+
| Return Invoice Data |
+-------------------------+
Helper Functions
- convertAmountToMilliUnits: Converts an amount to milli-units.
- convertAmountFromMilliUnits: Converts an amount from milli-units to standard units.