Cannot set default value for VAT

Hello all,

I’ve managed to configure multiple VAT values to chose from when creating line items inside a quote (Admin -> Studio -> Dropdown Editor -> vat_list).

The values in custom/include/language/de_DE.lang.php look fine to me:


[...]
$GLOBALS['app_list_strings']['vat_list']=array (
  19 => '19%',
  0 => '0%',
[...]

Now I’d like to set a default value, but that is not working. I can set a default (Admin -> Studio -> Studio -> Line Items -> Fields -> vat -> Default Value) from the values that I’ve entered using the Dropdown Editor. But this default is ignored.

Looking at custom/modules/AOS_Products_Quotes/Ext/Vardefs/vardefs.ext.php I can even see the value I entered:


[...]
 // created: 2018-06-19 15:32:10
$dictionary['AOS_Products_Quotes']['fields']['vat']['default']='19';
[...]

But when creating a new line item, VAT will always be set to 0.

Curently I’m on:

Version 7.7.8
Sugar Version 6.5.24 (Build 509)

Is there anything else I need to? Is this a bug?

Any help would be greatly appreciated!

Thanks and regards – Till

Hi tdoerges,

With regards to it not setting the default value, does it show any errors at all regarding this? These can be found in the suitecrm.log or through the admin panel, I can point you to them if you are not sure?

Thanks,
Ellis.

Hi e.reeley,

thanks for your replay.

I’ve found sugarcrm_06_2018.log, with a few errors from the last couple of days, but nothing is written to this file if I add a new line item.

Regards – Till

Just as a side question, when the files are added, does it update the file the following extension ‘custom/Extension/modules/[Your_Module]/Ext/Vardefs/…’.

Thanks,
Ellis.

Not sure, I understand the question.

I’m guessing the module is AOS_Products_Quotes, but I didn’t manually add any files to any module.

custom/Extension/modules/AOS_Products_Quotes/Ext/Vardefs/ contains exactly 1 file:

host:/.../crm # ls custom/Extension/modules/AOS_Products_Quotes/Ext/Vardefs/
sugarfield_vat.php

And that’s its content:

host:/.../crm # cat custom/Extension/modules/AOS_Products_Quotes/Ext/Vardefs/sugarfield_vat.php
<?php
 // created: 2018-06-19 15:32:10
$dictionary['AOS_Products_Quotes']['fields']['vat']['default']='19';
$dictionary['AOS_Products_Quotes']['fields']['vat']['inline_edit']=true;
$dictionary['AOS_Products_Quotes']['fields']['vat']['merge_filter']='disabled';
$dictionary['AOS_Products_Quotes']['fields']['vat']['help']='MwSt';

 ?>

Does this answer the question?

Thanks – Till

Hi all,

so perhaps this is a bug?

Thanks and regards – Till

Go to Dropdown editor,
Edit vat_list
Make your default VAT the first item in the list.

It already is for both languages configured. Looks like the order in the dropdown editor doesn’t influence what item is chosen as default.

Thanks – Till

Hi there,

I have exactly the same issue after upgrading to 7.10.27 from 7.8.2.
Even if I change the default value or the order of the items in studio, the default value is still ‘none’ when creating a new line item.

Could you manage to resolve your issue?

Thanks in advance for your help

PB

On 7.8.31 I fixed it via a dirty hack. Not sure whether/how it works on 7.10.x.

box:/path/to/crm # diff -c modules/AOS_Products_Quotes/Line_Items.php.orig modules/AOS_Products_Quotes/Line_Items.php
    *** modules/AOS_Products_Quotes/Line_Items.php.orig     Wed Dec 23 12:01:03 2020
    --- modules/AOS_Products_Quotes/Line_Items.php  Wed Dec 23 12:02:06 2020
    ***************
    *** 50,56 ****
                  $html .= "<input type=\"button\" tabindex=\"116\" class=\"button\" value=\"".$mod_strings['LBL_ADD_GROUP']."\" id=\"addGroup\" onclick=\"insertGroup(0)\" />";
                  $html .= "</div>";
              }
    !         $html .= '<input type="hidden" name="vathidden" id="vathidden" value="'.get_select_options_with_id($app_list_strings['vat_list'], '').'">
                                      <input type="hidden" name="discounthidden" id="discounthidden" value="'.get_select_options_with_id($app_list_strings['discount_list'], '').'">';
              if($focus->id != '') {
                  require_once('modules/AOS_Products_Quotes/AOS_Products_Quotes.php');
    --- 50,56 ----
                  $html .= "<input type=\"button\" tabindex=\"116\" class=\"button\" value=\"".$mod_strings['LBL_ADD_GROUP']."\" id=\"addGroup\" onclick=\"insertGroup(0)\" />";
                  $html .= "</div>";
              }
    !         $html .= '<input type="hidden" name="vathidden" id="vathidden" value="'.get_select_options_with_id($app_list_strings['vat_list'], '19').'">
                                      <input type="hidden" name="discounthidden" id="discounthidden" value="'.get_select_options_with_id($app_list_strings['discount_list'], '').'">';
              if($focus->id != '') {
                  require_once('modules/AOS_Products_Quotes/AOS_Products_Quotes.php');

The basic idea is to supply the desired default ('19' in my case) to the function get_select_options_with_id().

You could also do something like this before the above line:

require_once('custom/modules/AOS_Products_Quotes/Ext/Vardefs/vardefs.ext.php');
$def_vat=$dictionary['AOS_Products_Quotes']['fields']['vat']['default'];

And then instead of '19' you could put $def_vat. That way you’d even use the default you configured via studio.

But please be aware that this is just a dirty hack. It’s not upgrade safe or anything like that.

HTH