FIX Price of purchase order and vendor invoice with multicurrency
FIX entering predefined product with a forced unit price
This commit is contained in:
parent
cc8f3f7258
commit
7d07c198bc
@ -476,8 +476,10 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
print '</script>';
|
print '</script>';
|
||||||
print '</td>';
|
?>
|
||||||
print "</tr>\n";
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
}
|
}
|
||||||
print "<script>\n";
|
print "<script>\n";
|
||||||
if (!empty($usemargins) && $user->rights->margins->creer)
|
if (!empty($usemargins) && $user->rights->margins->creer)
|
||||||
@ -621,21 +623,22 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
|||||||
/* When changing predefined product, we reload list of supplier prices required for margin combo */
|
/* When changing predefined product, we reload list of supplier prices required for margin combo */
|
||||||
$("#idprod, #idprodfournprice").change(function()
|
$("#idprod, #idprodfournprice").change(function()
|
||||||
{
|
{
|
||||||
console.log("#idprod, #idprodfournprice change triggered");
|
console.log("#idprod, #idprodfournprice change triggered this.val = "+$(this).val());
|
||||||
|
|
||||||
setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva
|
setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva
|
||||||
|
|
||||||
jQuery('#trlinefordates').show();
|
jQuery('#trlinefordates').show();
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT))
|
if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT) && empty($senderissupplier))
|
||||||
{
|
{
|
||||||
?>
|
?>
|
||||||
// get the HT price for the product and display it
|
// Get the HT price for the product and display it
|
||||||
$.post('<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php?action=fetch', { 'id': $(this).val(), 'socid' : <?php print $object->socid; ?> }, function(data) {
|
$.post('<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php?action=fetch',
|
||||||
jQuery("#price_ht").val(data.price_ht);
|
{ 'id': $(this).val(), 'socid' : <?php print $object->socid; ?> },
|
||||||
},
|
function(data) { jQuery("#price_ht").val(data.price_ht); },
|
||||||
'json');
|
'json'
|
||||||
|
);
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if (!empty($usemargins) && $user->rights->margins->creer)
|
if (!empty($usemargins) && $user->rights->margins->creer)
|
||||||
@ -815,5 +818,5 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
<?php
|
||||||
<!-- END PHP TEMPLATE objectline_create.tpl.php -->
|
print "<!-- END PHP TEMPLATE objectline_create.tpl.php -->\n";
|
||||||
|
|||||||
@ -361,7 +361,7 @@ if (empty($reshook))
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$idprod = GETPOST('idprod', 'int');
|
$idprod = GETPOST('idprod', 'int');
|
||||||
$price_ht = '';
|
$price_ht = GETPOST('price_ht');
|
||||||
$tva_tx = '';
|
$tva_tx = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,15 +420,14 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ecrase $pu par celui du produit
|
if ($prod_entry_mode != 'free' && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
|
||||||
// Ecrase $desc par celui du produit
|
|
||||||
// Ecrase $txtva par celui du produit
|
|
||||||
if (($prod_entry_mode != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
|
|
||||||
{
|
{
|
||||||
$productsupplier = new ProductFournisseur($db);
|
$productsupplier = new ProductFournisseur($db);
|
||||||
|
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
|
if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
|
||||||
|
|
||||||
|
$reg = array();
|
||||||
if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg))
|
if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg))
|
||||||
{
|
{
|
||||||
$idprod = $reg[1];
|
$idprod = $reg[1];
|
||||||
@ -470,7 +469,22 @@ if (empty($reshook))
|
|||||||
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
|
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
|
||||||
|
|
||||||
$type = $productsupplier->type;
|
$type = $productsupplier->type;
|
||||||
|
if ($price_ht != '' || $price_ht_devise != '') {
|
||||||
|
$price_base_type = 'HT';
|
||||||
|
$pu = price2num($price_ht, 'MU');
|
||||||
|
$pu_ht_devise = price2num($price_ht_devise, 'MU');
|
||||||
|
} else {
|
||||||
$price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT');
|
$price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT');
|
||||||
|
if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency
|
||||||
|
$pu = $productsupplier->fourn_pu;
|
||||||
|
$pu_ht_devise = 0;
|
||||||
|
} else {
|
||||||
|
$pu = $productsupplier->fourn_pu;
|
||||||
|
$pu_ht_devise = $productsupplier->fourn_multicurrency_unitprice;
|
||||||
|
/*var_dump($pu);
|
||||||
|
var_dump($pu_ht_devise);exit;*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$ref_supplier = $productsupplier->ref_supplier;
|
$ref_supplier = $productsupplier->ref_supplier;
|
||||||
|
|
||||||
@ -480,7 +494,6 @@ if (empty($reshook))
|
|||||||
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
|
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
|
||||||
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
|
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
|
||||||
|
|
||||||
$pu = $productsupplier->fourn_pu;
|
|
||||||
if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value
|
if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value
|
||||||
|
|
||||||
$result = $object->addline(
|
$result = $object->addline(
|
||||||
@ -503,7 +516,9 @@ if (empty($reshook))
|
|||||||
$date_end,
|
$date_end,
|
||||||
$array_options,
|
$array_options,
|
||||||
$productsupplier->fk_unit,
|
$productsupplier->fk_unit,
|
||||||
$productsupplier->fourn_multicurrency_unitprice
|
$pu_ht_devise,
|
||||||
|
'',
|
||||||
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($idprod == -99 || $idprod == 0)
|
if ($idprod == -99 || $idprod == 0)
|
||||||
@ -2200,7 +2215,7 @@ elseif (!empty($object->id))
|
|||||||
|
|
||||||
print '<table class="border tableforfield centpercent">';
|
print '<table class="border tableforfield centpercent">';
|
||||||
|
|
||||||
if (!empty($conf->multicurrency->enabled))
|
if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1)
|
||||||
{
|
{
|
||||||
// Multicurrency Amount HT
|
// Multicurrency Amount HT
|
||||||
print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>';
|
print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>';
|
||||||
|
|||||||
@ -101,6 +101,7 @@ $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture',
|
|||||||
|
|
||||||
$permissionnote = $user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php
|
$permissionnote = $user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php
|
||||||
$permissiondellink = $user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php
|
$permissiondellink = $user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php
|
||||||
|
$permissiontoedit = $user->rights->fournisseur->facture->creer; // Used by the include of actions_lineupdown.inc.php
|
||||||
$permissiontoadd = $user->rights->fournisseur->facture->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
$permissiontoadd = $user->rights->fournisseur->facture->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||||
|
|
||||||
|
|
||||||
@ -1143,7 +1144,7 @@ if (empty($reshook))
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$idprod = GETPOST('idprod', 'int');
|
$idprod = GETPOST('idprod', 'int');
|
||||||
$price_ht = '';
|
$price_ht = GETPOST('price_ht');
|
||||||
$tva_tx = '';
|
$tva_tx = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1209,6 +1210,7 @@ if (empty($reshook))
|
|||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
|
if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
|
||||||
|
|
||||||
|
$reg = array();
|
||||||
if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg))
|
if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg))
|
||||||
{
|
{
|
||||||
$idprod = $reg[1];
|
$idprod = $reg[1];
|
||||||
@ -1250,7 +1252,20 @@ if (empty($reshook))
|
|||||||
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
|
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
|
||||||
|
|
||||||
$type = $productsupplier->type;
|
$type = $productsupplier->type;
|
||||||
|
if ($price_ht != '' || $price_ht_devise != '') {
|
||||||
|
$price_base_type = 'HT';
|
||||||
|
$pu = price2num($price_ht, 'MU');
|
||||||
|
$pu_ht_devise = price2num($price_ht_devise, 'MU');
|
||||||
|
} else {
|
||||||
$price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT');
|
$price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT');
|
||||||
|
if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency
|
||||||
|
$pu = $productsupplier->fourn_pu;
|
||||||
|
$pu_ht_devise = 0;
|
||||||
|
} else {
|
||||||
|
$pu = $productsupplier->fourn_pu;
|
||||||
|
$pu_ht_devise = $productsupplier->fourn_multicurrency_unitprice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$ref_supplier = $productsupplier->ref_supplier;
|
$ref_supplier = $productsupplier->ref_supplier;
|
||||||
|
|
||||||
@ -1260,7 +1275,6 @@ if (empty($reshook))
|
|||||||
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
|
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
|
||||||
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
|
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
|
||||||
|
|
||||||
$pu = $productsupplier->fourn_pu;
|
|
||||||
if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value
|
if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value
|
||||||
|
|
||||||
$result = $object->addline(
|
$result = $object->addline(
|
||||||
@ -1283,8 +1297,9 @@ if (empty($reshook))
|
|||||||
$array_options,
|
$array_options,
|
||||||
$productsupplier->fk_unit,
|
$productsupplier->fk_unit,
|
||||||
0,
|
0,
|
||||||
$productsupplier->fourn_multicurrency_unitprice,
|
$pu_ht_devise,
|
||||||
$ref_supplier
|
$ref_supplier,
|
||||||
|
''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($idprod == -99 || $idprod == 0)
|
if ($idprod == -99 || $idprod == 0)
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/product/ajax/products.php
|
* \file htdocs/product/ajax/products.php
|
||||||
* \brief File to return Ajax response on product list request
|
* \brief File to return Ajax response on product list request.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
|
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
|
||||||
@ -59,6 +59,7 @@ dol_syslog(join(',', $_GET));
|
|||||||
|
|
||||||
if (!empty($action) && $action == 'fetch' && !empty($id))
|
if (!empty($action) && $action == 'fetch' && !empty($id))
|
||||||
{
|
{
|
||||||
|
// When action='fetch', id must be the product id.
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||||
|
|
||||||
$outjson = array();
|
$outjson = array();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user