Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement UUID #32509

Open
mansouralali opened this issue Jan 3, 2025 · 4 comments
Open

implement UUID #32509

mansouralali opened this issue Jan 3, 2025 · 4 comments
Labels
Feature request This is a feature request

Comments

@mansouralali
Copy link

Feature Request

It will be great to implement UUID invoice and adding a hook to prevent modification of the invoice as longe as it is approved.

Use case

To implement UUID in the Dolibarr invoice module, you can use the casting feature to ensure unique identifiers for invoices. For preventing modifications to approved invoices, you can add a hook in the module's code. Refer to the Dolibarr hooks documentation for guidance on integrating hooks effectively. Implementing UUID in Dolibarr Invoice Module

UUID Generation:

Use PHP's ramsey/uuid library to generate a universally unique identifier (UUID) for each invoice.
Ensure that the UUID is stored in the database alongside the invoice data.
Database Modification:

Add a new column in the invoice table to store the UUID.
Update the invoice creation process to include the generation and storage of the UUID.
Adding a Hook to Prevent Modifications

Suggested implementation

Hook Creation:

Create a custom hook in the invoice module that checks the status of the invoice.
The hook should be triggered on any attempt to modify an invoice.
Modification Prevention Logic:

Implement logic within the hook to check if the invoice status is "approved."
If the invoice is approved, prevent any modifications and return an appropriate error message.

Suggested steps

Implementation Steps

Install UUID Library:

Use Composer to install the ramsey/uuid library in your Dolibarr environment.
Modify Invoice Table:

Execute SQL commands to add a UUID column to the invoice table.
Update Invoice Creation Logic:

Modify the invoice creation function to generate and save the UUID.
Create the Hook:

Define a new hook function in the invoice module that checks the invoice status before allowing modifications.
Testing:

Test the functionality by creating invoices, approving them, and attempting to modify them to ensure the hook works as intended.
Documentation:

Document the changes made to the module for future reference and maintenance.

@mansouralali mansouralali added the Feature request This is a feature request label Jan 3, 2025
@JonBendtsen
Copy link
Contributor

I would prefer a ULID

@mansouralali
Copy link
Author

I would prefer a ULID

I agree with you as long as having the same target

@sonikf
Copy link
Contributor

sonikf commented Jan 6, 2025

Is this AI generated?

@mansouralali
Copy link
Author

Is this AI generated?

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request This is a feature request
Projects
None yet
Development

No branches or pull requests

3 participants