From 975d9357fac0a389aab5665064318d6d428ce76b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 4 Jun 2016 14:08:57 +0200 Subject: [PATCH] FIX On recurring invoice, when generation is done manually from card, counter of number of generation must be +1 --- htdocs/compta/facture.php | 2 +- htdocs/compta/facture/class/facture-rec.class.php | 1 + htdocs/compta/facture/class/facture.class.php | 5 ++--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index a94448f5c12..9dd01b7162c 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -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) { $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 3ef9d716bfb..f1cae70fec5 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -962,6 +962,7 @@ class FactureRec extends CommonInvoice if ($this->db->query($sql)) { $this->date_when = $date; + if ($increment_nb_gen_done>0) $_facrec->nb_gen_done++; return 1; } else diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6e46ead1da5..10251d631f7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -309,13 +309,12 @@ class Facture extends CommonInvoice $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) { - $_facrec->nb_gen_done++; $next_date = $_facrec->getNextDate(); // Calculate next 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); } }