Skip to content
deadboy18 edited this page Aug 12, 2024 · 1 revision

eInvoice Technical Documentation

Table of Contents

Overview

eInvoice is a web-based invoicing application built using PHP and the Laravel framework. The system allows users to generate and manage invoices, offering features such as JSON/XML generation and API key testing. It is designed for development and testing purposes, with the potential to be integrated into larger systems, such as a hotel Property Management System (PMS), to automate invoicing processes.

System Requirements

To successfully run the eInvoice application, ensure that your environment meets the following requirements:

  • Operating System: Windows 10 or later.
  • PHP: Version 8.1 or higher.
  • Web Server: Apache (included with XAMPP).
  • Database: MySQL (included with XAMPP).
  • Composer: A dependency manager for PHP.

Installation and Setup

Step 1: Install XAMPP

  1. Download XAMPP: Visit the official XAMPP website and download the version that includes PHP 8.1 or higher.
  2. Install XAMPP: Run the installer and follow the prompts to install XAMPP on your system.
  3. Verify PHP Installation: After installation, open the Command Prompt and navigate to the PHP directory within XAMPP:
    cd C:\xampp\php
    php -v
    Ensure that the PHP version is 8.1 or higher.

Step 2: Install Composer

  1. Download Composer: Visit the Composer website and download the Windows installer.
  2. Install Composer: Run the installer and ensure it is configured to work with your PHP installation.
  3. Verify Composer Installation: In the Command Prompt, run:
    composer -V

Step 3: Clone the Repository

  1. Fork and Clone the Repository:
    • Fork the eInvoice repository to your GitHub account.
    • Clone the forked repository to your local machine:
      git clone https://github.com/yourusername/eInvoice.git
      cd eInvoice

Step 4: Configure PHP Extensions

  1. Enable Required Extensions: Open the php.ini file located in the XAMPP installation directory (C:\xampp\php\php.ini) and enable the following extensions by removing the semicolon (;) in front of each:
    extension=intl
    extension=xsl
    extension=sodium
    extension=zip
  2. Restart Apache: Use the XAMPP Control Panel to stop and start the Apache service to apply the changes.

Step 5: Set Up Environment Variables

  1. Create .env File: In the project directory, rename the .env.example file to .env:
    mv .env.example .env
  2. Generate Application Key: Run the following command to generate a unique application key:
    php artisan key:generate

Step 6: Install Dependencies

  1. Install PHP Dependencies: Use Composer to install the necessary dependencies:
    composer install
  2. Update Dependencies (If Needed): If there are issues with the lock file, update the dependencies:
    composer update

Running the Application

  1. Start the Development Server:
    php artisan serve
  2. Access the Application: Open a web browser and navigate to http://localhost:8000 to view the eInvoice application.

Understanding the eInvoice System

JSON/XML Generation

The eInvoice system is capable of generating invoice data in both JSON and XML formats. This feature is useful for integrating with other systems or for exporting data in standardized formats.

  • How It Works: The system retrieves invoice data from the database, processes it, and outputs it in either JSON or XML format, depending on the user's choice.
  • Potential Use Cases:
    • Data Export: Export invoices for archival or integration with other accounting systems.
    • API Integration: Utilize the generated JSON/XML for communication with external systems, such as a PMS.

API Key Testing

The eInvoice application includes a feature for testing API keys. This is essential when integrating with external APIs, such as those provided by the Malaysian Inland Revenue Board (LHDN) for e-invoicing.

  • How It Works: Users can input their API keys and test them against predefined endpoints to ensure they are valid and functioning correctly.
  • Integration: This feature is particularly useful for testing integration with LHDN’s MyInvois system.

Code Structure

Key Components

  • Controllers: Handle incoming HTTP requests, process them, and return responses. Located in the app/Http/Controllers directory.
  • Models: Represent the application's data structure and business logic. Found in the app/Models directory.
  • Views: Handle the presentation logic and are usually HTML templates with embedded PHP. Stored in the resources/views directory.
  • Routes: Define the application's endpoints and map them to controller actions. Defined in the routes/web.php file.

Important Files

  • artisan: The Laravel command-line interface that helps manage and run the application.
  • .env: Contains environment-specific configuration, such as database credentials and API keys. It is essential for setting up the application.
  • composer.json: Lists the PHP packages required by the application and their versions.
  • php.ini: Configuration file for PHP, where extensions are enabled and other PHP settings are configured.

Integration with Hotel PMS

Use Case: Automated Invoice Generation

Integrating the eInvoice system with a hotel Property Management System (PMS) can automate the generation of invoices based on hotel transactions. This would streamline the billing process and reduce the need for manual data entry.

  • How It Works: The PMS would trigger the eInvoice system to generate an invoice whenever a transaction is completed (e.g., room booking, additional services). The invoice can be automatically saved or sent to the customer.

Potential API Integrations

The eInvoice system can be extended to integrate with external APIs for enhanced functionality. One such integration could be with LHDN’s MyInvois system, which is part of Malaysia’s e-invoicing initiative.

Security Considerations

  • Environment Variables: Ensure that sensitive information, such as API keys and database credentials stored in the .env file, is secured and not shared publicly.
  • Production Readiness: The eInvoice application is intended for development and testing. If considering production deployment, additional security measures must be implemented, such as securing routes, validating inputs, and enabling HTTPS.

References and Resources

: Watch video tutorials on the MyInvois LHDN YouTube Channel for a better understanding of how to use the e-invoicing system.