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

De Documentations Patas-monkey
Aller à la navigation Aller à la recherche
Liam (discussion | contributions)
Aucun résumé des modifications
FuzzyBot (discussion | contributions)
Mise à jour pour être en accord avec la nouvelle version de la source de la page
 
(2 versions intermédiaires par un autre utilisateur non affichées)
Ligne 58 : Ligne 58 :
|-
|-
| style="vertical-align:top;" |
| style="vertical-align:top;" |
[[File:Extraprice-example_php_line_request.png |250px]]
[[File:Extraprice-exemple_php_line_request.png |250px]]
| style="vertical-align:top;" |
| style="vertical-align:top;" |
[[File:Extraprice-example_result_en.png |250px]]
[[File:Extraprice-example_result_en.png |250px]]
Ligne 147 : Ligne 147 :
== Carrier VAT on supplier invoice ==
== Carrier VAT on supplier invoice ==


[[File:Extraprice-tva-transport.png|800px]]
<div lang="fr" dir="ltr" class="mw-content-ltr">
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 lang="fr" dir="ltr" class="mw-content-ltr">
Pour cela :
</div>
 
<div lang="fr" dir="ltr" class="mw-content-ltr">
Créer un nouveau service avec comme libellé la TVA souhaitée.
</div>
 
<div lang="fr" dir="ltr" class="mw-content-ltr">
Une fois le service créé, l’ajouter dans le paramétrage du module.
</div>
 
<div lang="fr" dir="ltr" class="mw-content-ltr">
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>
 
[[File:Extraprice-tva-transport_en.png|800px]]

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.