Merge pull request #20583 from altairisfr/sitfac

FIX : dont update object price on each iteration when updating situation on all lines
This commit is contained in:
Laurent Destailleur 2022-04-07 18:23:45 +02:00 committed by GitHub
commit 27b3209f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -2560,9 +2560,10 @@ if (empty($reshook)) {
setEventMessages($mesg, null, 'warnings'); setEventMessages($mesg, null, 'warnings');
$result = -1; $result = -1;
} else { } else {
$object->update_percent($line, GETPOST('all_progress')); $object->update_percent($line, GETPOST('all_progress'), false);
} }
} }
$object->update_price(1);
} }
} elseif ($action == 'updateline' && $usercancreate && !$cancel) { } elseif ($action == 'updateline' && $usercancreate && !$cancel) {
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // To show again edited page header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // To show again edited page

View File

@ -3725,11 +3725,12 @@ class Facture extends CommonInvoice
/** /**
* Update invoice line with percentage * Update invoice line with percentage
* *
* @param FactureLigne $line Invoice line * @param FactureLigne $line Invoice line
* @param int $percent Percentage * @param int $percent Percentage
* @param boolean $update_price Update object price
* @return void * @return void
*/ */
public function update_percent($line, $percent) public function update_percent($line, $percent, $update_price = true)
{ {
// phpcs:enable // phpcs:enable
global $mysoc, $user; global $mysoc, $user;
@ -3756,7 +3757,11 @@ class Facture extends CommonInvoice
$line->multicurrency_total_tva = $tabprice[17]; $line->multicurrency_total_tva = $tabprice[17];
$line->multicurrency_total_ttc = $tabprice[18]; $line->multicurrency_total_ttc = $tabprice[18];
$line->update($user); $line->update($user);
$this->update_price(1);
// sometimes it is better to not update price for each line, ie when updating situation on all lines
if ($update_price) {
$this->update_price(1);
}
} }
/** /**