Fix: fallback to numeric VAT rate match when default_vat_code is null (#37830)
* Fix: fallback to numeric VAT rate match when default_vat_code is not set on product * fix: restore VAT rate assignment for input box case alongside combo fallback --------- Co-authored-by: Zakaria Boushaba <z.boushaba@vold.africa>
This commit is contained in:
parent
5d56da3117
commit
e87e4eb187
1 changed files with 14 additions and 7 deletions
|
|
@ -943,13 +943,20 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) {
|
|||
<?php
|
||||
} ?>
|
||||
}
|
||||
// Set vat rate if field is an input box
|
||||
$('#tva_tx').val(tva_tx);
|
||||
// Set vat rate by selecting the combo
|
||||
//$('#tva_tx option').val(tva_tx); // This is bugged, it replaces the vat key of all options
|
||||
$('#tva_tx option').removeAttr('selected');
|
||||
console.log("stringforvatrateselection="+stringforvatrateselection+" -> value of option label for this key="+$('#tva_tx option[value="'+stringforvatrateselection+'"]').val());
|
||||
$('#tva_tx option[value="'+stringforvatrateselection+'"]').prop('selected', true);
|
||||
// Set vat rate: handle both input box and combo cases
|
||||
if ($('#tva_tx option').length) {
|
||||
// It is a combo: try exact match first (rate + code), fallback to numeric match
|
||||
if ($('#tva_tx option[value="' + stringforvatrateselection + '"]').length) {
|
||||
$('#tva_tx').val(stringforvatrateselection);
|
||||
} else {
|
||||
$('#tva_tx option').filter(function () {
|
||||
return parseFloat($(this).val()) === parseFloat(tva_tx);
|
||||
}).first().prop('selected', true);
|
||||
}
|
||||
} else {
|
||||
// It is an input box
|
||||
$('#tva_tx').val(tva_tx);
|
||||
}
|
||||
|
||||
<?php
|
||||
if (getDolGlobalInt('PRODUIT_AUTOFILL_DESC') == 1) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue