When I add Vendor Invoice for Product "ABC" shouldn't it add Buying Price for "ABC" directly?

Awesome ERP System although developing is not as user friendly for non-technical users. Something I miss from other open source softwares like the SuiteCRM.
Anyway, lets focus on the question.

Every product page has a selling price & buying price tab.
We have customized it to work in a way where the selling price is influenced by the buying price. We have also added extra cost fields to add in the buying price tab.


Now, the problem I am facing is that when we add vendor invoices, we expect that the buying price tab to add the price at which we bought from the supplier.
It has all the information it requires from the vendor invoice, so why does that not automatically work?
*A little worried that we might have messed it up when customizing. Hoping for a way to make that happen. Can someone guide us?
Thank you for the help in advance!

Hola, la creación de nuevos campos en facturas proveedor, facturas detalle proveedor, no debería afectar en la recuperación del precio.
He verificado el funcionamiento del core, respecto a lo que menciones y funciona sin novedad.
Favor revisa en la configuración global del sistema

Esta opción debe estar en OFF, ya que es necesario para ejecutar código javascript

Dear Ramiroques,

Thank you for your response.
I am going to use Translator for the Spanish Translation.

That option is off at the moment. I have tried with off and on both the options.
Is there something else?
I am trying to add buying price automatically based on the vendor invoice.
Is it something that comes with the default instance?

Spanish Translation:
Querido Ramiroques,

Gracias por su respuesta.
Voy a usar Translator para la traducción al español.
! [Captura de pantalla 2020-06-27 a las 1.09.15 PM | 690x89] (carga: //pJujRjurjjO8AiRovQBAUMgEA7R.jpeg)

Esa opción está desactivada en este momento. He intentado con off y on ambas opciones.
¿Hay algo más?
Estoy tratando de agregar el precio de compra automáticamente en función de la factura del proveedor.
¿Es algo que viene con la instancia predeterminada?

Esa opción debe estar en OFF (para hacer uso del javascript)
Borre el cache de su navegador
Utilice su navegador en modo incógnito,

I am facing is that when we add vendor invoices, we expect that the buying price tab to add the price at which we bought from the supplier.

Dear Ramiroques,

English:
Thank you for the effort.
Unfortunately, I tried all of it.
Still doesn’t work.
Any other work arounds maybe?

Spanish:
Gracias por el esfuerzo.
Desafortunadamente, lo intenté todo.
Aún no funciona.
¿Alguna otra solución, tal vez?

Dear aa6fisicapx,

I know, that is exactly what we need and that is something I thought came in with the default folder.
Unfortunately, that does’t seem to be the case.

Maybe we can see what are the similarities between our instances?

  • I am running the 11.0.4 version.
  • Using Xampp.
  • Did some customizations in products module.
    How about you?

Also I am going to backup and repair everything using the defaults folders.
If even after that we see the same behavior, then maybe this might be a missing feature.

Any updates from Anyone? (@eldy?)

Really need someone to guide us through.
Tell me how to code that if it isn’t a default behavior.
But this is something important to most business, so let’s get this processed!

Can someone atleast confirm if it should be working with default folders or not? Is this an out of the box feature or not?

Thanks in advance again.

The default behavior is that once you entered a buying price for a vendor V and product P, then when making an invoice for vendor V, when you add product P, the price defined is automatically selected.

Dear @eldy,

Thank you for the response.
What I am looking to understand is that the if the reciprocal is also true.
So that when we enter vendor invoice for Vendor V, will it add buying price for Product P?
This way, it is all in sync, so that we don’t have to individually add buying prices. This way, whenever we enter the invoice, it add the buying price as well.

We are interested in this behavior for two reasons.

  1. We have more than 2K products, adding buying price individually is a pain. (When we make a purchase, the prices might have changed as well. So going back to changing that again is also a little difficult to maintain. If we get it in sync, we won’t have to worry about it.)

  2. We have selling price that is dependent on the buying price. We have customized it to work that way through a developer. So now, we need to maintain the buying prices for this main reason. And this would help us a lot.

Can you guide us on how to get this done?
Adding buying price for Product P when adding Vendor Invoice for same product…

Thank you very much for your hard work.

I just found this:

It seems to enable an option to achieve the above by using the Other Setup options.
But one of the files needs to be changed.
Will test it out this weekend and update everyone here.

P.S - Not sure why dolibarr forum is not as active as the github dolibarr page.
Everyone should take a look there for such questions I guess.

As I understand this reply, it does not answer the question.

  1. User defines a buying price for a product from a vendor.
  2. When user creates the vendor invoice, the invoice uses the previously-defined buying price.
    Yes, that would be the basic processing.

But, since prices always change, it would also be logical to EDIT the automatically-inserted prices on the invoice to match the vendor real invoice, and subsequently (maybe optionally) UPDATE the stored prices when the invoice is accepted.

I am still using legacy software from 2009 which has this option. I am not working with DB yet, but would be very surprised if this feature is not available.

If not, we cannot use it until it does have this feature.

Dear @torvista,
Thank you for your response.
That is exactly what we are trying to add on to the current version of Dolibarr.
We have not been able to figure a way out yet. We are still working on it.
By the way, we are using V12.0.1.

Recently I came across the above mentioned GitHub link. But unfortunately, I am not able to make it work.
Has anyone else successfully implemented it?
I have changed the code and added the “SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT” = 1 in other setup.
But it still does not work.

Recently I came across the above mentioned GitHub link. But unfortunately, I am not able to make it work.
Has anyone else successfully implemented it?
I have changed the code and added the “SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT” = 1 in other setup.
But it still does not work. Any help would be appreciated.

@eldy,

Can you guide on how to implement the following in other setup page?
“SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT” = 1 in other setup.

Hi,

Please make a search, it is explained everywhere in the forum, wiki, etc…

Dear @ksar,

Apologies for the late response. I searched forum, wiki, GitHub, discussion & emailed many people. In short, I tried everything there was to try without paying someone for the resolution.
As per the link below, I followed all the steps & yet unable to add buying price directly from when receiving the order.

Thus, @eldy was mentioned in my response, since he made those changes, he would know a little more on what to try if the code does not prompt the expected behavior.
I can see the Update Price checkbox while receiving items in purchase order, but it is not reflected on the buying price tab for the product.

This is an important aspect to our business process and I am sure it is for others too.
We have more than 2200 product as of now and we cannot update prices for them every time we purchase from a different vendor or at a different price from the same vendor.

3 Likes

Dear, I looking for same solution, if you found please let me know @geettanna

Dear @Hashim,

Good to see some more traction on such important topics.
We did not find a solution to this problem directly but made a workaround in a way.

We created a button on the Purchase Order page, which allows adding a buying price directly.
I have added the following code to the file - \fourn\commande\card.php.

if($object->statut >=2 && $object->statut <= 3){     if($user->rights->fournisseur->commande->commander) {

> print '<input type="button" class="butAction" id="update_price"  value="Update Buying Price">';

} }

//GT Added Update Buying Price button --- KTI 
if($object->statut >=2 && $object->statut <= 3){     if($user->rights->fournisseur->commande->commander) {         
print '<input type="button" class="butAction" id="update_price"  value="Update Buying Price">';     
} 
}  
//GT added update product price --- KTI 
$count = 0; 
$nooflines = 0; 
foreach ($object->lines as $productrow) {
     ?>   
  <link rel="stylesheet" href="<?php echo DOL_URL_ROOT; ?>/includes/jquery/css/jquery-confirm.min.css">
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>
     <script type="text/javascript">         $(document).ready(function() {             $("#update_price").click(function ()             {                 $.confirm({                     title: 'Enter Delivery Delay Days!<?php echo "<center></br>".$productrow->ref; ?></center>',                     content: '' +                         '<form action="" class="formName">' +                         '<div class="form-group">' +                         '<label>Delivery Delay</label>' +                         '<input type="number" placeholder="Delivery Delay (Days)" class="delay-days form-control" required />' +                         '</div>' +                         '</form>',                     buttons: {                         formSubmit: {                             text: 'Submit',                             btnClass: 'btn-blue',                             action: function () {                                 var delaydays = this.$content.find('.delay-days').val();                                 if(!delaydays){                                     $.alert('provide a valid delivery delay days');                                     return false;                                 }                                  var thirdpartyid = "<?php echo $object->socid; ?>";                                 var productid = "<?php echo $productrow->fk_product; ?>";                                 var productref = "<?php echo $productrow->ref; ?>";                                 var price  = "<?php echo $productrow->pu_ht ?>";                                  var user_authorid = "<?php echo $object->user_author_id; ?>";                                 var tva_tx = "<?php echo $productrow->tva_tx; ?>";                                  var currentdate = new Date();                                 var datetime = (currentdate.getFullYear())  + "-"                                     + (currentdate.getMonth()+1) + "-"                                     + currentdate.getDate() + " "                                     + currentdate.getHours() + ":"                                     + currentdate.getMinutes() + ":"                                     + currentdate.getSeconds();                                  $.ajax({                                     type: 'POST',                                     url: 'update_buyingprice.php?thirdpartyid='+thirdpartyid+'&productid='+productid+'&price='+price+'&user_authorid='+user_authorid+'&tva_tx='+tva_tx+'&datetime='+datetime+'&productref='+productref+'&delaydays='+delaydays,                                     dataType: 'json',                                      success : function(response) {                                         //success msg                                     }                                 });                                 // alert("Buying Price Has Been Updated Successfully.....");                             }                          },                         cancel: function () {                             //close                         },                     }                 });             });         });     </script>     <?php     $count++;     $nooflines++;      if ($count > $nooflines)     {         break;     } }

And add the following file:
update_buyingprice.php (2.6 KB)

It will give you something like this on the Purchase Order Page:

When clicked it gives the following pop up to enter the dispatch delay for the product ref:

On submit it automatically adds or updates the buying price (based on if there is an buying from the vendor from the purchase order or not):

One last thing, if you plan to implement this, please remember, we have an extra field for adding active & inactive buying prices, so the code will have that as well, which you might want to remove before implementation so the query does not give any errors.
We have this extra field to add prices from multiple vendors, but still use only “active” buying prices for automatic selling price calculation.

Hope this helps.