Proposals Module - Margin by Line Item and other problems

Prerequisite information:

  • Ubuntu 20.04.6 LTS
  • Apache v2.4.41 (Ubuntu)
  • MariaDB v10.3.38
  • PHP 7.4.3-4ubuntu2.19 with Zend v3.4.0 and Zend Opcache v7.4.3-4ubuntu2.19
  • Dolibarr v17.0.2

Hi there,

I hope this is the correct space to post this in. If not, please redirect me. I’m American, so please forgive me for that. For the record, I didn’t vote for that orange dude in 2016, and won’t in 2024 either. I’m actually a dual American/UK citizen. :slight_smile:

My company is in the process of transitioning over to Dolibarr from another ERP/ERM product. With any amount of luck, if successful I have two customers who want to transition to Dolibarr as well, and we’re hoping we can become an official Dolibarr consultant here in the states.

As the lead technical person in our company, it’s fallen on me to set all the settings and make all the custom forms needed to make it function for us. There are a number of things that don’t apply to the US built into Dolibarr (example: VAT tax doesn’t exist as long as we’re selling inside the US), but I’m getting quite the education on how accounting works outside the states!

I’m presently working on the [Commercial] Proposals module. I have a number of questions, most of which can probably be answered easily, but Google has not helped me find the answers yet.

The biggest by far is that our sales staff often adjust the markup/margin of each individual item within a proposal. For instance, one item may have a 10% markup, but another item may have a 100% markup/margin if it’s a small enough item.

I could not find a way to do this per line in each proposal in Dolibarr. It seemed like I could set these settings “per customer” or “per item” (Buying price vs Selling price) in the Products & Services, but I could not set them “per proposal” or “per line.”

I tried playing with the “Disc.” field… for example, using “-10%” to increase the item’s cost by 10% over our cost… but this seems to compound on top of the product selling cost (more on that below). Also, the “discount” is advertised to the customer on the PDF, so we certainly don’t want that! So…

To get rid of the discount column above (and for other small tweaks to the proposal) I followed the directions to copy the pdf_azur.modules.php and make our own, which I called pdf_{ourcompanyname}_custom.modules.php. I renamed the class as instructed. Following through the directions, I found the discount column on ~ line 634 and commented out the entire section for the discount. Above that on ~ line 188 I changed “this->posxdiscount = 0” so the column just wouldn’t show up on the resulting PDF. This did get rid of the “Disc.” column. However…

… When I looked at my “U.P (net)” column and multiplied it by my “Qty” column, the resulting “Total (excl.)” column did not match. This is when I discovered that the “Disc.” (Margin/Markup) I applied was being compounded against my product selling price in the Products & Services section! So, that won’t do it!

I also discovered that when I removed the “Disc.” percentage from the line items in the proposal to prevent the compounding effect I mentioned above, suddenly I had no Quantity column and no Unit Price (U.P.) columns!

I then decided to go back a few steps and see what it looked like under the stock “azur” template and see what happened when I removed all the discounts. It looks pretty good, except there’s no way to edit the margin/markup “per line item.”

I looked into adding an additional field, but I get the impression this is overkill.

The last thing I want is sales guys using calculators or excel worksheets to calculate margins and type them into the proposals. Frankly, that’s bit us in the rear end too many times in the last 10 years to ever go back to that. I’d like Dolibarr to do the calculation, but I need the calculation to be correct! :slight_smile:

So, I’m giving up and asking for help. I think if I can figure this out, we’ll be good.

Thank you, in advance!

Hi,
Is this enabled in your instance?

You should use the Cyan pdf model, hack on that if you have to.

Thanks for the response!

Yes, The Margins module is enabled, but I don’t know that it’s configured properly. Here’s what my configuration looks like:

Screenshot 2023-07-15 185737

OK, so literally just changing a setting in the Margins module activated it, and I now have a margins column in my proposal building tool. I enabled “Display margin rates.” What a relief!

Of course, you know that once you solve one problem, you have questions about two more:

  1. In my unit price column, I’m seeing dollar figures that have 3 decimal points. Is there an easy way to get it to round up to the next cent?

  2. I’ve been hunting for where I can change “U.P. (Net)” and “Total (excl.)” to something a little easier to understand for our customers, but I can’t find the exact entry I need to modify in the Dictionary section. Any hints?

Also, acknowledged on the Azul template. I’ll work on it!

Thank you!

I’m responding to my own questions, as I’ve found answers to them. But my answers may not be the correct ones, so YMMV!

  1. This is defined in Setup > Limits and Accuracy > “Max decimals for ____ prices”. I set mine to 2 and 2 there. There’s also a step of rounding range. I still haven’t quite figured out how to say if the total is 182.551 that it should round UP to 182.56.

  2. I found these in DOCROOT/htdocs/langs/en_US/propal.lang and edited them. There may be a more appropriate way to do this where you don’t modify the file itself, but instead create a _custom file and put your changes in there. I also found something in main.lang that I edited, but I can’t remember what it was for the life of me now.

Thanks to @sonikf for the help!

That is the one, you should go with 3,2,3, examples are generated below.

In Setup → Translation


Then hit the plus icon in the next tab “Overwrite a translation string” and change it permanently for your instance

Ironically I remember this being an option in a previous version of Dolibarr, but I could not find it this time. Thanks for reminding me where it is!