« Extraprice/en » : différence entre les versions

De Documentations Patas-monkey
Aller à la navigation Aller à la recherche
Liam (discussion | contributions)
Page créée avec « Extraprice »
 
FuzzyBot (discussion | contributions)
Mise à jour pour être en accord avec la nouvelle version de la source de la page
 
(40 versions intermédiaires par 2 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
<languages/>
<languages/>
<div lang="fr" dir="ltr" class="mw-content-ltr">
{| class="wikitable"
{| class="wikitable"  
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| [[File:Extraprice250x250.jpg]]
| [[File:Extraprice250x250.jpg]]
| Ce module permet de définir une règle de calcul pour la détermination du prix de vente unitaire (par exemple en prenant des paramètres supplémentaires - extrafields), cette version premium ajoute le paramétrages de valeurs personnalisées par catégories (client et produit)
| This module allows you to define a calculation rule for determining the unit selling price (for example, by taking additional parameters - extrafields). This premium version adds the ability to configure custom values ​​by category (customer and product).
|}
|}
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
<span id="Présentation"></span>
== Présentation ==
== Presentation ==
</div>
 
'''Extraprice''' is a module for calculating the prices of a product based on a set of customizable parameters and a calculation formula
 
<span id="Pré-requis_d&#039;installation"></span>
== Installation Prerequisites ==


<div lang="fr" dir="ltr" class="mw-content-ltr">
The '''Extraprice''' module works with Dolibarr from version 3.5.x and a minimum php version of 5.3.
'''Extraprice''' est un module permettant de calculer les prix d'un produit en fonction d'un ensemble de paramètres et d'une formule de calcul personnalisables
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
It is installed like any Dolibarr module by unzipping the zip file into the /htdocs/custom folder.
== Pré-requis d'installation ==
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
<span id="Préambule_–_Avant_de_commencer"></span>
Le module '''Extraprice''' fonctionne avec Dolibarr à partir de la version 3.5.x et une version de php minimum 5.3.
== Preamble – Before you begin ==
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
Before starting to create an Extraprice formula, you should have some knowledge of PHP and be familiar with Dolibarr's table structure.
Il s'installe comme n'importe quel module Dolibarr en décompressant le fichier zip dans le dossier /htdocs/custom.
If you don't have this type of expertise, you can contact us on our website ([www.patas-monkey.fr](http://www.patas-monkey.fr/)) so that we can offer you a service to integrate this module according to your specifications.
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
{{Note| Warning: Dolibarr version 20.0.0 contains an anomaly that generates a VAT calculation error when using the price recalculation button. This problem can be resolved by updating Dolibarr to a later version (20.0.4 or 21.xx, ...) |warn}}
== Préambule – Avant de commencer ==
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
<span id="Configuration_du_module_Extraprice"></span>
Avant de lancer la création d'une formule '''d'Extraprice''' , il convient d'avoir des notions de langage php et de connaître la structuration des tables de Dolibarr.
== Configuration of the Extraprice module ==
Si vous n'avez pas ce genre de compétence, vous pouvez nous contactez sur notre site ([www.patas-monkey.fr](http://www.patas-monkey.fr/)) afin que nous vous proposions une prestation d&#39;intégration de ce module selon vos spécifications.
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
The configuration of the '''Extraprice''' module is done from the administration screen accessible from the list of modules.
{{Note| Attention: La version 20.0.0 de Dolibarr contient une anomalie qui génère une erreur de calcul sur la TVA quand on utilise le bouton de recalcul des prix. Ce problème se règle en réalisant une mise à jour de dolibarr vers une version postérieur (20.0.4 ou 21.xx, ...) |warn}}
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
== Configuration du module Extraprice ==
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
La configuration du module '''Extraprice''' se fait à partir de l'écran d'administration accessible depuis la liste des modules.
</div>


[[File:Extraprice-setting_en.png |900px]]


The first input area allows you to configure the calculation formula that will be used to determine the unit sales prices.


<div lang="fr" dir="ltr" class="mw-content-ltr">
Another feature of the module is that it is possible to define one or more products/services to collect VAT for transport companies.
{| class="wikitable"
|- style="vertical-align:top;"
| [[File:Extraprice-setting.png]]
| La première zone de saisie permet de paramétrer la formule de calcul qui sera utilisée pour déterminer les prix de vente unitaires.
Autre fonctionnalité du module, il est possible de définir un ou plusieurs produit/service pour saisir la TVA pour les société de transport
|}
|}
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
<span id="Fonctionnement_du_calcul_du_prix_dynamique"></span>
== Fonctionnement du calcul du prix dynamique ==
== How dynamic price calculation works ==
</div>
 
It is not possible in Dolibarr to have a price conditioned by anything other than the quantity of the product sold.


<div lang="fr" dir="ltr" class="mw-content-ltr">
'''Extraprice''' allows you to modify the unit sales price when creating the part lines (order, invoice and commercial proposal).
Il n'est pas possible dans Dolibarr d'avoir un prix conditionné par autre chose que la quantité du produit vendu.
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
For this, '''Extraprice''' uses:
'''Extraprice''' permet de modifier, lors de la création des lignes de pièces (commande, facture et proposition commerciale), le prix de vente unitaire.
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
- values ​​present in the various records (customer, product, parts, etc.)
Pour cela, '''Extraprice''' utilise :
- values ​​present in additional fields ("extrafields"), particularly those present on the part lines.
</div>
- a calculation formula written in PHP in the module's settings.


<div lang="fr" dir="ltr" class="mw-content-ltr">
{| class="wikitable" style="text-align:center"
- des valeurs présentes dans les différentes fiches (client, produit, pièces…)
! style="vertical-align:top; width:250px;" | '''Module configuration options'''
- des valeurs présentes dans des champs supplémentaires (« extrafields ») et en particulier ceux présents sur les lignes de pièces.
! style="vertical-align:top; width:250px;" | '''Result on invoice'''
- Une formule de calcul écrite en php dans le paramétrage du module.
|-
</div>
| style="vertical-align:top;" |
[[File:Extraprice-exemple_php_line_request.png |250px]]
| style="vertical-align:top;" |
[[File:Extraprice-example_result_en.png |250px]]
|}


<div lang="fr" dir="ltr" class="mw-content-ltr">
<span id="Remarque"></span>
=== Remarque ===
=== Note ===
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
The premium version of extraprice allows you to add variables to calculation formulas based on customer or product category.
La version premium d'extraprice permet d'ajouter des variables aux formules de calculs selon la catégorie cliente ou produit.
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
Ex: it is possible to create a discount coefficient per customer category which will be used for the final calculation of the unit sales price. To do this, you must create product categories, assign a value to a variable on the extraprice tab of the category (e.g. $coef=0.55) and then use this in the final calculation.
Ex : il est possible de créer un coefficient de remise par catégorie client qui sera utilisé pour le calcul final du prix de vente unitaire. il faut pour cela créer des catégories produits, d'affecter sur l'onglet d'extraprice de la catégorie une valeur à une variable (ex $coef=0.55 ) et puis d'utiliser celle-ci dans le calcul final
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
<span id="Saisie_d&#039;une_formule_de_calcul"></span>
=== Saisie d'une formule de calcul ===
=== Entering a calculation formula ===
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
Definition of variables that can be used in the extraprice formula.
Définition des variables utilisables dans la formule d'extraprice.
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
{| class="wikitable"
{| class="wikitable"  
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| '''$newprice'''
| '''$newprice'''  
| Price calculated by the formula
| Prix calculé par la formule
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| '''$origineprice'''
| '''$origineprice'''  
| Original price of the product. NOTE: If the product or service is a free product, this value will be zero (the base price must be entered elsewhere for calculation).
| Prix d'origine du produit, ATTENTION si on est sur un produit ou service libre, cette valeur sera à zéro (il faudra saisir le prix de base pour le calcul ailleurs).
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| '''$objectvalue'''
| '''$objectvalue'''  
| Object containing the additional fields associated with the part line.
| Objet contenant les champs supplémentaires associés à la ligne de la pièce
Example: To access the value defined in the 'length' field,
Ex : pour accéder à la valeur définie dans le champ 'longueur',
use the variable $objectvalue['options_allonge']
il faut utiliser la variable $objectvalue['options_longueur']  
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| '''$product'''
| '''$product'''  
| Object containing the values ​​associated with the product (reference, description, etc.)
| Objet contenant les valeurs associées au produit (référence, description...)
Example values:
Exemple de valeurs :  
* $product['price_min'] (minimum price) will be retrieved by the variable $product->price_min
* $product['price_min'] (prix minimum) sera récupéré par la variable $product->price_min
* $product['ref'] to retrieve/test the product reference. |
* $product['ref'] pour récupérer/tester la référence du produit|
Note: This object is only present if the price is defined from a product (not a free entry).
Attention : cette objet n'est présent que si il s'agit d'un prix défini à partir d'un produit (pas une saisie libre)
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| '''$mainelement'''
| '''$mainelement'''  
| Object containing the values ​​associated with the document (invoice, order, proposal)
| Objet contenant les valeurs associées à la pièce (facture, commande, proposition commerciale)  
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| '''$company'''
| '''$societe'''  
| Object containing the values ​​associated with the document's company (the invoice recipient)
| Objet contenant les valeurs associées à la société de la pièce (le destinataire de la facture)  
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| '''$object'''
| '''$object'''  
| Object containing the values ​​associated with the document line (invoice, order, or proposal)
| Objet contenant les valeurs associées à ligne de la pièce (facture, commande ou propale)  
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| '''$elementextravalue'''
| '''$elementextravalue'''  
| Object containing the additional fields associated with the document (invoice, order, proposal)
| Objet contenant les champs supplémentaire associé à la pièce (facture, commande, proposition commerciale)  
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| '''$societeextravalue'''
| '''$societeextravalue'''  
| Object containing the additional fields associated with the company.
| Objet contenant les champs supplémentaires associés à la société
Example: To access a value defined in the "coeff" field, use the variable $societeextravalue['options_coeff']
Ex : pour accéder à une valeur définie dans le champ "coeff", il faut utiliser la variable $societeextravalue['options_coeff']
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| '''$productextravalue'''
| '''$productextravalue'''  
| Object containing the additional fields associated with the product.
| Objet contenant les champs supplémentaires associés au produit
Example: To access a value defined in the "coeff" field, use the variable $productextravalue['options_coeff']
Ex : pour accéder à une valeur définie dans le champ "coeff", il faut utiliser la variable $productextravalue['options_coeff']
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| '''$categsocieteid'''
| '''$categsocieteid'''  
| Contains the identifier of the company category to which the company belongs.
| contient l'identifiant de la catégorie de société auquel appartient la société
|- style="vertical-align:top;"
|- style="vertical-align:top;"  
| '''$categproductid'''
| '''$categproductid'''  
| Contains the identifier of the product category to which the product belongs.
| contient l'identifiant de la catégorie de produit auquel appartient le produit
|}
|}
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
It is possible to create constants by going through Dolibarr's configuration/Miscellaneous.
il est possible d'avoir des constantes en passant par la configuration/Divers de Dolibarr
To do this, simply define a variable and its value.
il suffit pour cela de définir une variable et sa valeur
The entered value can be retrieved with $conf->global->LA_VARIABLE_DIVERSE.
La valeur saisie peut être récupérée avec la $conf->global->LA_VARIABLE_DIVERSE
 
</div>
<span id="Exemple_:_Détermination_du_prix_d&#039;un_produit_selon_la_surface_vendue"></span>
=== Example: Determining the price of a product based on the surface area sold ===
 
A product has a fixed price per square meter.
 
We add 2 additional fields (extrafields) named “length” and “width” corresponding to the dimensions of the surface sold.
 
In this case, the selling price of the product corresponds to the price per m² multiplied by the length and width
 
For a product at €100 per square meter, if we sell a surface 50 cm long by 25 cm wide, the price will be €12.50 per unit (100 x 0.25 x 0.50)


<div lang="fr" dir="ltr" class="mw-content-ltr">
It is possible to add a specific cutting cost per product depending, for example, on its material: plastic, glass, etc.
=== Exemple : Détermination du prix d'un produit selon la surface vendue ===
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
In this case, it will be necessary to add an “extrafield” on the product to store the data of the unit cost of the cut which will be added to the unit sales price in the formula.
Un produit a un prix fixé au mètre carré.
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
For a product at €100 per square meter, and a cut at €20, if we sell a surface 50 cm long by 25 cm wide, the price will be €32.50 per unit (20 + 100 x 0.25 x 0.50)
Nous ajoutons 2 champs supplémentaires (extrafields) nommés « longueur » et « largeur » correspondant aux dimensions de la surface vendue.
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
<span id="TVA_transporteur_sur_facture_fournisseur"></span>
Dans ce cas, le prix de vente du produit correspond au prix au m² multiplié par la longueur et la largeur
== Carrier VAT on supplier invoice ==
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
<div lang="fr" dir="ltr" class="mw-content-ltr">
Pour un produit à 100 € le mètre carré, si on vend une surface de 50 cm de long par 25 cm de large, le prix sera de 12,50 € l'unité (100 x 0,25 x 0,50)
Il est également possible d’ajouter manuellement une TVA fournisseur en définissant le prix hors taxes (P.U. HT) correspondant à la TVA souhaitée.
</div>
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
<div lang="fr" dir="ltr" class="mw-content-ltr">
Il est possible de rajouter un coût spécifique de découpe par produit selon, par exemple, sa matière : plastique, verre…
Pour cela :
</div>
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
<div lang="fr" dir="ltr" class="mw-content-ltr">
Dans ce cas, il sera nécessaire de rajouter un « extrafield » sur le produit pour stocker la donnée du coût unitaire de la découpe qui sera ajouté au prix de vente unitaire dans la formule.
Créer un nouveau service avec comme libellé la TVA souhaitée.
</div>
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
<div lang="fr" dir="ltr" class="mw-content-ltr">
Pour un produit à 100 € le mètre carré, et une découpe à 20, si on vend une surface de 50 cm de long par 25 cm de large, le prix sera de 32,50 € l'unité (20 + 100 x 0,25 x 0,50)
Une fois le service créé, l’ajouter dans le paramétrage du module.
</div>
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
<div lang="fr" dir="ltr" class="mw-content-ltr">
== TVA transporteur sur facture fournisseur ==
Lors de la création d’une facture fournisseur, vous pourrez désormais ajouter ce service « TVA » et lui attribuer sa valeur monétaire exacte dans le champ P.U. HT.
</div>
</div>


<div lang="fr" dir="ltr" class="mw-content-ltr">
[[File:Extraprice-tva-transport_en.png|800px]]
[[File:Extraprice-tva-transport.png|800px]]
</div>

Dernière version du 5 novembre 2025 à 18:23

This module allows you to define a calculation rule for determining the unit selling price (for example, by taking additional parameters - extrafields). This premium version adds the ability to configure custom values ​​by category (customer and product).

Presentation

Extraprice is a module for calculating the prices of a product based on a set of customizable parameters and a calculation formula

Installation Prerequisites

The Extraprice module works with Dolibarr from version 3.5.x and a minimum php version of 5.3.

It is installed like any Dolibarr module by unzipping the zip file into the /htdocs/custom folder.

Preamble – Before you begin

Before starting to create an Extraprice formula, you should have some knowledge of PHP and be familiar with Dolibarr's table structure. If you don't have this type of expertise, you can contact us on our website ([www.patas-monkey.fr](http://www.patas-monkey.fr/)) so that we can offer you a service to integrate this module according to your specifications.

Warning: Dolibarr version 20.0.0 contains an anomaly that generates a VAT calculation error when using the price recalculation button. This problem can be resolved by updating Dolibarr to a later version (20.0.4 or 21.xx, ...)

Configuration of the Extraprice module

The configuration of the Extraprice module is done from the administration screen accessible from the list of modules.


The first input area allows you to configure the calculation formula that will be used to determine the unit sales prices.

Another feature of the module is that it is possible to define one or more products/services to collect VAT for transport companies. |}

How dynamic price calculation works

It is not possible in Dolibarr to have a price conditioned by anything other than the quantity of the product sold.

Extraprice allows you to modify the unit sales price when creating the part lines (order, invoice and commercial proposal).

For this, Extraprice uses:

- values ​​present in the various records (customer, product, parts, etc.) - values ​​present in additional fields ("extrafields"), particularly those present on the part lines. - a calculation formula written in PHP in the module's settings.

Module configuration options Result on invoice

Note

The premium version of extraprice allows you to add variables to calculation formulas based on customer or product category.

Ex: it is possible to create a discount coefficient per customer category which will be used for the final calculation of the unit sales price. To do this, you must create product categories, assign a value to a variable on the extraprice tab of the category (e.g. $coef=0.55) and then use this in the final calculation.

Entering a calculation formula

Definition of variables that can be used in the extraprice formula.

$newprice Price calculated by the formula
$origineprice Original price of the product. NOTE: If the product or service is a free product, this value will be zero (the base price must be entered elsewhere for calculation).
$objectvalue Object containing the additional fields associated with the part line.

Example: To access the value defined in the 'length' field, use the variable $objectvalue['options_allonge']

$product Object containing the values ​​associated with the product (reference, description, etc.)

Example values:

  • $product['price_min'] (minimum price) will be retrieved by the variable $product->price_min
  • $product['ref'] to retrieve/test the product reference. |

Note: This object is only present if the price is defined from a product (not a free entry).

$mainelement Object containing the values ​​associated with the document (invoice, order, proposal)
$company Object containing the values ​​associated with the document's company (the invoice recipient)
$object Object containing the values ​​associated with the document line (invoice, order, or proposal)
$elementextravalue Object containing the additional fields associated with the document (invoice, order, proposal)
$societeextravalue Object containing the additional fields associated with the company.

Example: To access a value defined in the "coeff" field, use the variable $societeextravalue['options_coeff']

$productextravalue Object containing the additional fields associated with the product.

Example: To access a value defined in the "coeff" field, use the variable $productextravalue['options_coeff']

$categsocieteid Contains the identifier of the company category to which the company belongs.
$categproductid Contains the identifier of the product category to which the product belongs.

It is possible to create constants by going through Dolibarr's configuration/Miscellaneous. To do this, simply define a variable and its value. The entered value can be retrieved with $conf->global->LA_VARIABLE_DIVERSE.

Example: Determining the price of a product based on the surface area sold

A product has a fixed price per square meter.

We add 2 additional fields (extrafields) named “length” and “width” corresponding to the dimensions of the surface sold.

In this case, the selling price of the product corresponds to the price per m² multiplied by the length and width

For a product at €100 per square meter, if we sell a surface 50 cm long by 25 cm wide, the price will be €12.50 per unit (100 x 0.25 x 0.50)

It is possible to add a specific cutting cost per product depending, for example, on its material: plastic, glass, etc.

In this case, it will be necessary to add an “extrafield” on the product to store the data of the unit cost of the cut which will be added to the unit sales price in the formula.

For a product at €100 per square meter, and a cut at €20, if we sell a surface 50 cm long by 25 cm wide, the price will be €32.50 per unit (20 + 100 x 0.25 x 0.50)

Carrier VAT on supplier invoice

Il est également possible d’ajouter manuellement une TVA fournisseur en définissant le prix hors taxes (P.U. HT) correspondant à la TVA souhaitée.

Pour cela :

Créer un nouveau service avec comme libellé la TVA souhaitée.

Une fois le service créé, l’ajouter dans le paramétrage du module.

Lors de la création d’une facture fournisseur, vous pourrez désormais ajouter ce service « TVA » et lui attribuer sa valeur monétaire exacte dans le champ P.U. HT.