Fix: avoid to add line for event registration twice into invoice
This commit is contained in:
parent
e2c389a4a9
commit
09fff2150e
@ -330,63 +330,63 @@ 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)) {
|
}
|
||||||
// Try to find thirdparty from the email only
|
if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) {
|
||||||
$resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $emailcompany);
|
// Try to find thirdparty from the email only
|
||||||
if ($resultfetchthirdparty > 0) {
|
$resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $emailcompany);
|
||||||
// We found a unique result with that email only, so we set the fk_soc of attendee
|
if ($resultfetchthirdparty > 0) {
|
||||||
$confattendee->fk_soc = $thirdparty->id;
|
// We found a unique result with that email only, so we set the fk_soc of attendee
|
||||||
$confattendee->update($user);
|
$confattendee->fk_soc = $thirdparty->id;
|
||||||
} elseif ($resultfetchthirdparty == -2) {
|
$confattendee->update($user);
|
||||||
$thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
|
} elseif ($resultfetchthirdparty == -2) {
|
||||||
}
|
$thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
|
||||||
}
|
}
|
||||||
if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) {
|
}
|
||||||
// Try to find thirdparty from the email only
|
if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) {
|
||||||
$resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email);
|
// Try to find thirdparty from the email only
|
||||||
if ($resultfetchthirdparty > 0) {
|
$resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email);
|
||||||
// We found a unique result with that email only, so we set the fk_soc of attendee
|
if ($resultfetchthirdparty > 0) {
|
||||||
$confattendee->fk_soc = $thirdparty->id;
|
// We found a unique result with that email only, so we set the fk_soc of attendee
|
||||||
$confattendee->update($user);
|
$confattendee->fk_soc = $thirdparty->id;
|
||||||
} elseif ($resultfetchthirdparty == -2) {
|
$confattendee->update($user);
|
||||||
$thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
|
} elseif ($resultfetchthirdparty == -2) {
|
||||||
}
|
$thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
|
||||||
}
|
}
|
||||||
if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) {
|
}
|
||||||
// Try to find thirdparty from the generic mail only
|
if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) {
|
||||||
$resultfetchthirdparty = $thirdparty->fetch('', $genericcompanyname, '', '', '', '', '', '', '', '', '');
|
// Try to find thirdparty from the generic mail only
|
||||||
if ($resultfetchthirdparty > 0) {
|
$resultfetchthirdparty = $thirdparty->fetch('', $genericcompanyname, '', '', '', '', '', '', '', '', '');
|
||||||
// We found a unique result with that name + email, so we set the fk_soc of attendee
|
if ($resultfetchthirdparty > 0) {
|
||||||
$confattendee->fk_soc = $thirdparty->id;
|
// We found a unique result with that name + email, so we set the fk_soc of attendee
|
||||||
$confattendee->update($user);
|
$confattendee->fk_soc = $thirdparty->id;
|
||||||
} elseif ($resultfetchthirdparty == -2) {
|
$confattendee->update($user);
|
||||||
$thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
|
} elseif ($resultfetchthirdparty == -2) {
|
||||||
}
|
$thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Add more tests on a VAT number, profid or a name ?
|
// TODO Add more tests on a VAT number, profid or a name ?
|
||||||
|
|
||||||
if ($resultfetchthirdparty <= 0 && !empty($email)) {
|
if ($resultfetchthirdparty <= 0 && !empty($email)) {
|
||||||
// Try to find the thirdparty from the contact
|
// Try to find the thirdparty from the contact
|
||||||
$resultfetchcontact = $contact->fetch('', null, '', $email);
|
$resultfetchcontact = $contact->fetch('', null, '', $email);
|
||||||
if ($resultfetchcontact > 0 && $contact->fk_soc > 0) {
|
if ($resultfetchcontact > 0 && $contact->fk_soc > 0) {
|
||||||
$thirdparty->fetch($contact->fk_soc);
|
$thirdparty->fetch($contact->fk_soc);
|
||||||
$confattendee->fk_soc = $thirdparty->id;
|
$confattendee->fk_soc = $thirdparty->id;
|
||||||
$confattendee->update($user);
|
$confattendee->update($user);
|
||||||
$resultfetchthirdparty = 1;
|
$resultfetchthirdparty = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($resultfetchthirdparty <= 0 && !empty($societe)) {
|
if ($resultfetchthirdparty <= 0 && !empty($societe)) {
|
||||||
// Try to find thirdparty from the company name only
|
// Try to find thirdparty from the company name only
|
||||||
$resultfetchthirdparty = $thirdparty->fetch('', $societe, '', '', '', '', '', '', '', '', '');
|
$resultfetchthirdparty = $thirdparty->fetch('', $societe, '', '', '', '', '', '', '', '', '');
|
||||||
if ($resultfetchthirdparty > 0) {
|
if ($resultfetchthirdparty > 0) {
|
||||||
// We found a unique result with that name only, so we set the fk_soc of attendee
|
// We found a unique result with that name only, so we set the fk_soc of attendee
|
||||||
$confattendee->fk_soc = $thirdparty->id;
|
$confattendee->fk_soc = $thirdparty->id;
|
||||||
$confattendee->update($user);
|
$confattendee->update($user);
|
||||||
} elseif ($resultfetchthirdparty == -2) {
|
} elseif ($resultfetchthirdparty == -2) {
|
||||||
$thirdparty->error = "ErrorSeveralCompaniesWithNameContactUs";
|
$thirdparty->error = "ErrorSeveralCompaniesWithNameContactUs";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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,11 +516,14 @@ 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;
|
||||||
|
|
||||||
$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 there is no lines yet, we add one
|
||||||
if ($result <= 0) {
|
if (empty($facture->lines)) {
|
||||||
$confattendee->error = $facture->error;
|
$result = $facture->addline($labelforproduct, floatval($project->price_registration), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, $date_start, $date_end, 0, 0, '', 'HT', 0, 1);
|
||||||
$confattendee->errors = $facture->errors;
|
if ($result <= 0) {
|
||||||
$error++;
|
$confattendee->error = $facture->error;
|
||||||
|
$confattendee->errors = $facture->errors;
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user