ACBr Project Libraries

repository·master·Indexed 41 days ago

https://github.com/frones/acbr

A collection of libraries and Android/Flutter integration guides for ACBr, including ACBrLibBAL for scale communication, ACBrLibNFe for electronic invoicing, ACBrLibPIXCD, and ACBrLibCep. The documentation also covers the use of Delphi JSON parser libraries such as json4delphi and Json Data Objects for high-performance JSON manipulation across Windows and Android.

Tokens
12.9K
Snippets
55
Records
72
Agent score
52%

What's inside ACBr

  1. Features of Json Data Objects

    master

    Key features of this library include:

    • Dual Parser: Fast parser supporting UTF8 and UTF16 without conversion.
    • Automatic Management: Automatic creation of arrays and objects.
    • Access Modes: Easy access mode via implicit operators and faster access modes.
    • Output Modes: Supports both compact and formatted JSON output.
    • Type Handling: Supports Variants and automatic typecasting of null to value types if JsonSerializationConfig.NullConvertsToValueTypes is set to True.
    • Large Data Support: Progress callback support for loading large JSON strings.
    • Platform Support: Win32, Win64, and ARM Android (MacOS and iOS may work).
  2. Project Structure for ACBrLibNFe Flutter Demo

    master

    The demo project is organized into logical directories to separate concerns:

    • lib/model/: Contains Dart data models. Includes examples of using fromJson for JSON serialization (e.g., status_servico.dart).
    • lib/plugin/: Contains acbrnfe_plugin.dart, the Method Channel implementation that communicates with the native ACBrLibNFe functions.
    • lib/ui/: Contains the user interface components:
      • _core/: Global app colors and themes.
      • acbrlib_ini/: Screen for viewing the acbrlib.ini configuration file.
      • configuracoes/: Tabs for Geral, WebServices, Certificados, Arquivos, Email, and Documento Auxiliar.
      • home/: The main navigation screen where the library is initialized.
      • nfe/: Command menus for Envio, Consultas, Eventos, Inutilização, and Distribuição DFe.
    • lib/utils/: Utility functions, including the logic for unzipping schemas.zip and the acbrlib_nfe_helper.dart Singleton implementation.
  3. Project Structure for ACBrLibBAL Flutter Demo

    master

    The demo project is organized to separate native communication, UI, and utility logic:

    • lib/plugin/: Contains acbrbal_plugin.dart, the Method Channel implementation for native calls.
    • lib/utils/: Contains acbrlib_bal_helper.dart, which implements the Singleton pattern for the library instance.
    • lib/ui/: Contains the user interface components:
      • _core/: Global app colors and themes.
      • acbrlib_ini/: Screen for viewing the acbrlib.ini configuration file.
      • bal/: Scale simulation screen for interacting with commands.
      • configuracoes/: Scale settings screen.
      • home/: Main navigation screen where the initialization of ACBrLibBAL occurs.
  4. How ACBrLibNFe integrates with Flutter

    master

    The integration between Flutter and the native ACBrLibNFe library is achieved using Method Channels.

    • Method Channel: Acts as a bridge between the Dart code and the native Android code (Java/Kotlin).
    • Plugin Implementation: The acbrnfe_plugin.dart file serves as the core communication layer. It maps Dart calls to native functions.
    • Singleton Pattern: It is recommended to implement the plugin using a Singleton pattern (as seen in acbrlib_nfe_helper.dart) to ensure that only one instance of the library is active throughout the application lifecycle.
    • Data Handling: Use JSON serialization (e.g., via a fromJson method in your models) to convert JSON responses from the native side into usable Dart objects.
  5. How ACBrLibBAL communication works in Flutter

    master

    The integration between Flutter (Dart) and the native ACBrLibBAL library (Java/Kotlin) is achieved using a Method Channel.

    In the provided example project, this is implemented via:

    • lib/plugin/acbrbal_plugin.dart: Acts as the bridge, exposing native functions to Dart. Each function in this file corresponds to the official ACBrLibBAL documentation.
    • Singleton Pattern: To prevent multiple instances of the library from conflicting, the project uses a Singleton pattern via lib/utils/acbrlib_bal_helper.dart. This ensures only one instance of ACBrLibBAL is active throughout the application lifecycle.
  6. Install ZLibExGZ in Delphi

    master

    To use ZLibExGZ in your Delphi project, follow these steps:

    1. Copy all files from the archive into a local folder (e.g., C:\delphi\zlib).
    2. Add this folder to your Delphi Library Path within the Environment Options.
    3. Add the required units to your uses clause as needed.

    This library is compatible with Delphi 5 through Delphi XE3 for both Win32 and Win64 platforms.

    -- No specific command provided, follow manual steps above.
  7. Best practices for naming individual tests

    master

    Test names should be descriptive enough for non-developers (domain experts) to understand the intent, while remaining resilient to code refactoring.

    Guidelines:

    1. Be short but descriptive.
    2. Describe the action, the state of the object, and the objective of the test.
    3. Describe the expected result.
    4. Avoid over-reliance on technical entities: Instead of naming tests based on specific method names (which might change), describe the test as if explaining it to a domain expert (e.g., a salesperson or an accountant).

    Good examples:

    • Purchase_without_funds_is_not_possible
    • Delivery_with_a_past_date_is_invalid
    • Should_Increase_Balance_When_Deposit_Is_Made
    • Add_credit_updates_customer_balance
    Purchase_without_funds_is_not_possible
  8. Configure the ANDROID_HOME environment variable

    master

    React Native requires the Android SDK. You must set the ANDROID_HOME environment variable to the path of your Android SDK location.

    To find your SDK path in Android Studio: Go to Tools -> SDK Manager and look for Android SDK Location.

    Linux

    Set the variable in your shell:

    export ANDROID_HOME=sdk_path

    Windows

    Add ANDROID_HOME to your system's environment variables.

    export ANDROID_HOME=sdk_path
  9. Build the ACBrLibComum.jar file

    master

    To generate the ACBrLibComum.jar library file, you must run the Gradle task from the project root or the Comum folder. This process uses the Gradle wrapper to compile and package the necessary JAR files.

    Steps:

    1. Navigate to the project root folder or the Comum folder in your terminal.
    2. Execute the command gradlew createJar.
    3. Once the process completes, the resulting file ACBrLibComum.jar will be located in Comum\libs\jars.
    gradlew createJar