Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
08a66c5
Restore setup_print_title helper
mapiolca Nov 27, 2025
fba060e
Add additional affected actions for price updates
mapiolca Nov 27, 2025
e2ed8a3
Add var_dump for update function and action
mapiolca Nov 27, 2025
fdd6327
Fix SQL column names for product associations
mapiolca Nov 28, 2025
4a7bbfc
Remove entity filtering from product association queries
mapiolca Nov 28, 2025
69ac049
Comment out type filter in SQL queries
mapiolca Nov 28, 2025
11724e6
Update dynamicsprices.lib.php
mapiolca Nov 28, 2025
53238c4
Create php.yml
mapiolca Dec 8, 2025
2afabee
Update interface_99_modDynamicsPrices_DynamicsPricesTriggers.class.php
mapiolca Dec 8, 2025
35a379b
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
d541570
Update modDynamicsPrices.class.php
mapiolca Dec 8, 2025
7250a82
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
19b9cbf
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
e6a1392
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
d271696
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
87075f8
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
ac4003c
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
47f6781
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
a70a2f3
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
69ae7a4
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
c59df9b
Update interface_99_modDynamicsPrices_DynamicsPricesTriggers.class.php
mapiolca Dec 8, 2025
4d151ae
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
26ac5bd
Update interface_99_modDynamicsPrices_DynamicsPricesTriggers.class.php
mapiolca Dec 8, 2025
0c71acc
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
83b5189
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
74c1861
Update dynamicsprices.lib.php
mapiolca Dec 8, 2025
1df4d20
Update interface_99_modDynamicsPrices_DynamicsPricesTriggers.class.php
mapiolca Dec 8, 2025
072f11e
Update interface_99_modDynamicsPrices_DynamicsPricesTriggers.class.php
mapiolca Dec 8, 2025
1a036c1
Update interface_99_modDynamicsPrices_DynamicsPricesTriggers.class.php
mapiolca Dec 8, 2025
0452ff0
Update interface_99_modDynamicsPrices_DynamicsPricesTriggers.class.php
mapiolca Dec 8, 2025
bb92305
Update interface_99_modDynamicsPrices_DynamicsPricesTriggers.class.php
mapiolca Dec 8, 2025
0b1dc45
Support kit pricing updates and bump version
mapiolca Dec 8, 2025
f63478d
Handle kit updates after components and skip services
mapiolca Dec 9, 2025
0acf68e
Update documentation for 2.0 release
mapiolca Dec 9, 2025
01c49ed
Add English sections to docs
mapiolca Dec 9, 2025
056bf08
Merge branch 'main' into 2.0
mapiolca Dec 9, 2025
e95321c
Update ChangeLog.md
mapiolca Dec 9, 2025
c98daac
Create composer.json
mapiolca Dec 9, 2025
9c1fa2e
Update composer.json
mapiolca Dec 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PHP Composer

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

# - name: Run test suite
# run: composer run-script test
28 changes: 16 additions & 12 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# CHANGELOG MODULE DYNAMICSPRICES FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)<br>
<br>
##1.1.1<br>
- Correction du filtre pour ignorer les services, seul les produits sont pris en compte. (29/09/2025)<br>
<br>

##1.1<br>
- Prise en charge des prix de revient pour l'actualisation des prix de vente. (17/09/2025)<br>
<br>
## 1.0<br>
<br>
Initial version<br>
# Changelog DynamicsPrices

## 2.0.0
- Ajout du support des kits : le prix d'un kit est recalculé après ses composants pour éviter les doublons et refléter le coût cumulé. / Added kit support: a kit price is recalculated after its components to avoid duplicates and reflect the cumulative cost.
- Correction des mises à jour intempestives des services : seuls les produits physiques sont recalculés (`fk_product_type = 0`). / Fixed unintended service updates: only physical products are recalculated (`fk_product_type = 0`).
- Extension de la couverture des triggers pour lancer les recalculs sur davantage d'événements Dolibarr. / Expanded trigger coverage to launch recalculations on more Dolibarr events.
- Calcul automatique des prix de revient via un dictionnaire dédié et la moyenne des prix d'achat. / Automatic cost-price computation via a dedicated dictionary and average purchase prices.

## 1.1.1
- Correction du filtre pour ignorer les services ; seuls les produits sont pris en compte. (29/09/2025) / Fixed the filter to ignore services; only products are taken into account. (29/09/2025)

## 1.1
- Prise en charge des prix de revient pour l'actualisation des prix de vente. (17/09/2025) / Added cost-price handling to refresh selling prices. (17/09/2025)

## 1.0
- Version initiale. / Initial release.
169 changes: 113 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,153 @@
# DYNAMICSPRICES FOR [DOLIBARR ERP & CRM](https://www.dolibarr.org)
# DynamicsPrices

## Features
## Présentation (FR)

Ce module permet de mettre à jour les prix de vente en fonction du prix d'achat moyen unitaire chez les fournisseurs et des coefficients de prix définis dans un dictionnaire dédié.
Module Dolibarr pour la mise à jour dynamique des prix de vente à partir des coûts d'achat et des coefficients configurables.

<!--
![Screenshot dynamicsprices](img/screenshot_dynamicsprices.png?raw=true "DynamicsPrices"){imgmd}
-->
### Aperçu

Other external modules are available on [Dolistore.com](https://www.dolistore.com).
DynamicsPrices automatise le recalcul des prix des produits en s'appuyant sur les prix d'achat moyens, les coefficients de marge et les relations entre produits (composants, kits). Les déclencheurs du module s'occupent d'appliquer les nouveaux prix de vente au bon moment, tout en respectant les spécificités des produits et services Dolibarr.

## Translations
### Fonctionnalités clés

Translations can be completed manually by editing files in the module directories under `langs`.
- Mise à jour automatique des prix de vente en fonction du prix d'achat moyen et d'un dictionnaire de coefficients dédié.
- Recalcul des kits après leurs composants pour éviter les doublons de prix de vente et refléter le coût cumulé des sous-produits et services.
- Filtrage des services : seuls les produits physiques (`fk_product_type = 0`) sont recalculés pour éviter les mises à jour intempestives.
- Plus grand nombre de triggers pour couvrir les actions courantes (création, modification, réception d'achat, etc.).
- Calcul automatique des prix de revient à partir des nouveaux dictionnaires et de la moyenne des prix d'achat.

<!--
This module contains also a sample configuration for Transifex, under the hidden directory [.tx](.tx), so it is possible to manage translation using this service.
### Compatibilité

For more information, see the [translator's documentation](https://wiki.dolibarr.org/index.php/Translator_documentation).
- Dolibarr ≥ 19.0 (minimum recommandé).
- Module externe installable dans `htdocs/custom/dynamicsprices`.

There is a [Transifex project](https://transifex.com/projects/p/dolibarr-module-template) for this module.
-->
### Installation

#### Depuis une archive ZIP

## Installation
1. Télécharger l'archive `module_dynamicsprices-x.y.z.zip`.
2. Déployer l'archive via le menu **Accueil > Configuration > Modules > Déployer un module externe**.
3. Activer le module **DynamicsPrices** dans **Configuration > Modules/Applications**.

Prerequisites: You must have Dolibarr ERP & CRM software installed. You can download it from [Dolistore.org](https://www.dolibarr.org).
You can also get a ready-to-use instance in the cloud from https://saas.dolibarr.org
#### Depuis un dépôt Git

```bash
cd htdocs/custom
git clone [email protected]:gitlogin/dynamicsprices.git dynamicsprices
```

Puis activer le module dans Dolibarr comme décrit ci-dessus.

### Mise à jour

1. Sauvegarder la base de données et le répertoire du module.
2. Installer la nouvelle version (ZIP ou Git) dans `htdocs/custom/dynamicsprices`.
3. Lancer les scripts de migration proposés par Dolibarr si nécessaire.

### Configuration

- **Dictionnaire des coefficients** : définir les coefficients de marge dans **Dictionnaires > Coefficients DynamicsPrices**.
- **Triggers** : les déclencheurs DynamicsPrices mettent à jour les prix lors des actions standards (création de produit, réception fournisseur, modification de prix, etc.).
- **Kits** : le prix de vente d'un kit est recalculé uniquement après mise à jour des prix de ses composants pour éviter toute duplication.

### Utilisation

- Créer ou mettre à jour un produit avec un prix d'achat renseigné.
- Les triggers calculent automatiquement le prix de revient et le prix de vente suivant le coefficient applicable.
- Les services et produits non physiques (`fk_product_type != 0`) sont ignorés par les mises à jour automatiques.

### Permissions et sécurité

- Les actions de mise à jour sont soumises aux permissions Dolibarr standard sur les produits et dictionnaires.
- Les écrans du module masquent automatiquement les actions non autorisées.

### From the ZIP file and GUI interface
### Traductions

If the module is a ready-to-deploy zip file, so with a name `module_xxx-version.zip` (e.g., when downloading it from a marketplace like [Dolistore](https://www.dolistore.com)),
go to menu `Home> Setup> Modules> Deploy external module` and upload the zip file.
Les fichiers de langue sont disponibles dans `langs/`. Complétez ou ajustez les traductions en `en_US` et `fr_FR` pour tout nouveau libellé.

<!--
### Support

Note: If this screen tells you that there is no "custom" directory, check that your setup is correct:
- Documentation et support Dolibarr : [https://wiki.dolibarr.org](https://wiki.dolibarr.org)
- Autres modules externes : [Dolistore.com](https://www.dolistore.com)

- In your Dolibarr installation directory, edit the `htdocs/conf/conf.php` file and check that following lines are not commented:
### Licence

```php
//$dolibarr_main_url_root_alt ...
//$dolibarr_main_document_root_alt ...
```
- Code : GPLv3 ou ultérieure (voir `COPYING`).
- Documentation : GFDL (voir la licence correspondante).

- Uncomment them if necessary (delete the leading `//`) and assign the proper value according to your Dolibarr installation
---

For example :
## Overview (EN)

- UNIX:
```php
$dolibarr_main_url_root_alt = '/custom';
$dolibarr_main_document_root_alt = '/var/www/Dolibarr/htdocs/custom';
```
Dolibarr module for dynamically updating selling prices based on purchase costs and configurable margins.

- Windows:
```php
$dolibarr_main_url_root_alt = '/custom';
$dolibarr_main_document_root_alt = 'C:/My Web Sites/Dolibarr/htdocs/custom';
```
-->
### Summary

<!--
DynamicsPrices automates price recalculations using average purchase prices, margin coefficients, and relationships between products (components, kits). Module triggers apply new selling prices at the right time while respecting Dolibarr product and service specifics.

### From a GIT repository
### Key features

Clone the repository in `$dolibarr_main_document_root_alt/dynamicsprices`
- Automatic selling-price updates driven by average purchase price and a dedicated coefficient dictionary.
- Kits recalculated after their components to avoid duplicate selling prices and to reflect cumulative component and service costs.
- Service filtering: only physical products (`fk_product_type = 0`) are recalculated to avoid unintended updates.
- Expanded trigger coverage for common actions (creation, modification, purchase receipt, etc.).
- Automatic cost-price computation from dedicated dictionaries and purchase-price averages.

```shell
cd ....../custom
### Compatibility

- Dolibarr ≥ 19.0 (recommended minimum).
- External module installable in `htdocs/custom/dynamicsprices`.

### Installation

#### From a ZIP archive

1. Download the `module_dynamicsprices-x.y.z.zip` archive.
2. Deploy it via **Home > Setup > Modules > Deploy an external module**.
3. Enable the **DynamicsPrices** module in **Setup > Modules/Applications**.

#### From a Git repository

```bash
cd htdocs/custom
git clone [email protected]:gitlogin/dynamicsprices.git dynamicsprices
```

-->
Then enable the module in Dolibarr as described above.

### Upgrade

1. Back up the database and the module directory.
2. Install the new version (ZIP or Git) in `htdocs/custom/dynamicsprices`.
3. Run any migration scripts proposed by Dolibarr if needed.

### Configuration

- **Coefficient dictionary**: define margin coefficients in **Dictionaries > DynamicsPrices Coefficients**.
- **Triggers**: DynamicsPrices triggers update prices during standard actions (product creation, supplier receipt, price edits, etc.).
- **Kits**: a kit's selling price is recalculated only after updating its component prices to prevent duplication.

### Final steps
### Usage

Using your browser:
- Create or update a product with a purchase price filled in.
- Triggers automatically compute cost price and selling price using the applicable coefficient.
- Services and non-physical products (`fk_product_type != 0`) are ignored by automated updates.

- Log into Dolibarr as a super-administrator
- Go to "Setup"> "Modules"
- You should now be able to find and enable the module
### Permissions and security

- Update actions follow Dolibarr standard permissions for products and dictionaries.
- Module screens automatically hide actions that the user is not allowed to perform.

### Translations

## Licenses
Language files live under `langs/`. Complete or adjust translations in `en_US` and `fr_FR` for any new labels.

### Main code
### Support

GPLv3 or (at your option) any later version. See file COPYING for more information.
- Dolibarr documentation and support: [https://wiki.dolibarr.org](https://wiki.dolibarr.org)
- Other external modules: [Dolistore.com](https://www.dolistore.com)

### Documentation
### License

All texts and readme's are licensed under [GFDL](https://www.gnu.org/licenses/fdl-1.3.en.html).
- Code: GPLv3 or later (see `COPYING`).
- Documentation: GFDL (see the corresponding license).
Loading