Fix: avoid to add line for event registration twice into invoice

This commit is contained in:
Laurent Destailleur 2021-09-21 15:30:34 +02:00
parent e2c389a4a9
commit 09fff2150e

View File

@ -330,6 +330,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
$thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithNameContactUs", $mysoc->email); $thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
} }
} }
}
if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) { if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) {
// Try to find thirdparty from the email only // Try to find thirdparty from the email only
$resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $emailcompany); $resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $emailcompany);
@ -389,7 +390,6 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
} }
} }
} }
}
// If price is empty, no need to create a thirdparty, so we force $resultfetchthirdparty as if we have already found thirdp party. // If price is empty, no need to create a thirdparty, so we force $resultfetchthirdparty as if we have already found thirdp party.
if (empty(floatval($project->price_registration))) { if (empty(floatval($project->price_registration))) {
@ -450,6 +450,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
} }
if (!$error) { if (!$error) {
// If the registration needs a payment
if (!empty(floatval($project->price_registration))) { if (!empty(floatval($project->price_registration))) {
$outputlangs = $langs; $outputlangs = $langs;
@ -515,6 +516,8 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
$date_start = $project->date_start; $date_start = $project->date_start;
$date_end = $project->date_end; $date_end = $project->date_end;
// If there is no lines yet, we add one
if (empty($facture->lines)) {
$result = $facture->addline($labelforproduct, floatval($project->price_registration), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, $date_start, $date_end, 0, 0, '', 'HT', 0, 1); $result = $facture->addline($labelforproduct, floatval($project->price_registration), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, $date_start, $date_end, 0, 0, '', 'HT', 0, 1);
if ($result <= 0) { if ($result <= 0) {
$confattendee->error = $facture->error; $confattendee->error = $facture->error;
@ -522,6 +525,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
$error++; $error++;
} }
} }
}
if (!$error) { if (!$error) {
$db->commit(); $db->commit();