FIX On recurring invoice, when generation is done manually from card,

counter of number of generation must be +1
This commit is contained in:
Laurent Destailleur 2016-06-04 14:08:57 +02:00
parent eb7a4c5ccf
commit 975d9357fa
3 changed files with 4 additions and 4 deletions

View File

@ -863,7 +863,7 @@ if (empty($reshook))
} }
} }
// Standard invoice or Deposit invoice created from a Predefined invoice // Standard invoice or Deposit invoice created from a Predefined template invoice
if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec') > 0) if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec') > 0)
{ {
$dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);

View File

@ -962,6 +962,7 @@ class FactureRec extends CommonInvoice
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->date_when = $date; $this->date_when = $date;
if ($increment_nb_gen_done>0) $_facrec->nb_gen_done++;
return 1; return 1;
} }
else else

View File

@ -309,13 +309,12 @@ class Facture extends CommonInvoice
$forceduedate = $this->calculate_date_lim_reglement(); $forceduedate = $this->calculate_date_lim_reglement();
// Update date and number of last generation of recurring template invoice, before inserting new invoice // For recurrn invoices, update date and number of last generation of recurring template invoice, before inserting new invoice
if ($_facrec->frequency > 0) if ($_facrec->frequency > 0)
{ {
$_facrec->nb_gen_done++;
$next_date = $_facrec->getNextDate(); // Calculate next date $next_date = $_facrec->getNextDate(); // Calculate next date
$_facrec->setValueFrom('date_last_gen', $now, '', null, 'date'); $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date');
$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1.
$_facrec->setNextDate($next_date,1); $_facrec->setNextDate($next_date,1);
} }
} }