|
@@ -126,6 +126,9 @@ if ($id > 0 || !empty($ref)) {
|
|
|
$fetch_situation = true;
|
|
|
}
|
|
|
$ret = $object->fetch($id, $ref, '', '', $fetch_situation);
|
|
|
+ if ($ret > 0 && isset($object->fk_project)) {
|
|
|
+ $ret = $object->fetch_project();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2378,11 +2381,11 @@ if (empty($reshook)) {
|
|
|
|
|
|
// Check price is not lower than minimum (check is done only for standard or replacement invoices)
|
|
|
if ($usermustrespectpricemin && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT)) {
|
|
|
- if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) {
|
|
|
+ if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min)) && $price_base_type == 'HT') {
|
|
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
|
|
setEventMessages($mesg, null, 'errors');
|
|
|
$error++;
|
|
|
- } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
|
|
+ } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') {
|
|
|
$mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
|
|
setEventMessages($mesg, null, 'errors');
|
|
|
$error++;
|
|
@@ -2594,12 +2597,12 @@ if (empty($reshook)) {
|
|
|
|
|
|
// Check price is not lower than minimum (check is done only for standard or replacement invoices)
|
|
|
if ($usermustrespectpricemin && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT)) {
|
|
|
- if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - (float) $remise_percent / 100)) < (float) price2num($price_min))) {
|
|
|
+ if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - (float) $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') {
|
|
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
|
|
setEventMessages($mesg, null, 'errors');
|
|
|
$error++;
|
|
|
$action = 'editline';
|
|
|
- } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < price2num($price_min_ttc))) {
|
|
|
+ } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < price2num($price_min_ttc)) && $price_base_type == 'TTC') {
|
|
|
$mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
|
|
setEventMessages($mesg, null, 'errors');
|
|
|
$error++;
|