New: La numérotation des factures de doit et des factures avoirs peut etre dissociées selon choix du module de numérotation.

This commit is contained in:
Laurent Destailleur 2006-12-16 16:30:41 +00:00
parent 0d20bf6bbc
commit 78d0bc8867
17 changed files with 111 additions and 76 deletions

View File

@ -241,12 +241,21 @@ while (($file = readdir($handle))!==false)
} }
print '</td>'; print '</td>';
$facture=new Facture($db);
// Info // Info
$htmltooltip=''; $htmltooltip='';
$nextval=$module->getNextValue($mysoc,''); $facture->type=0;
$nextval=$module->getNextValue($mysoc,$facture);
if ($nextval != $langs->trans("NotAvailable")) if ($nextval != $langs->trans("NotAvailable"))
{ {
$htmltooltip='<b>'.$langs->trans("NextValue").'</b>: '.$nextval; $htmltooltip.='<b>'.$langs->trans("NextValueForInvoices").'</b>: '.$nextval.'<br>';
}
$facture->type=2;
$nextval=$module->getNextValue($mysoc,$facture);
if ($nextval != $langs->trans("NotAvailable"))
{
$htmltooltip.='<b>'.$langs->trans("NextValueForCreditNotes").'</b>: '.$nextval;
} }
print '<td align="center">'; print '<td align="center">';
print $html->textwithhelp('',$htmltooltip,1,0); print $html->textwithhelp('',$htmltooltip,1,0);

View File

@ -166,7 +166,7 @@ if ($handle)
// Info // Info
$htmltooltip=''; $htmltooltip='';
$nextval=$module->getNextValue(); $nextval=$module->getNextValue($mysoc);
if ($nextval != $langs->trans("NotAvailable")) if ($nextval != $langs->trans("NotAvailable"))
{ {
$htmltooltip='<b>'.$langs->trans("NextValue").'</b>: '.$nextval; $htmltooltip='<b>'.$langs->trans("NextValue").'</b>: '.$nextval;

View File

@ -165,7 +165,7 @@ if ($handle)
// Info // Info
$htmltooltip=''; $htmltooltip='';
$nextval=$module->getNextValue(); $nextval=$module->getNextValue($mysoc);
if ($nextval != $langs->trans("NotAvailable")) if ($nextval != $langs->trans("NotAvailable"))
{ {
$htmltooltip='<b>'.$langs->trans("NextValue").'</b>: '.$nextval; $htmltooltip='<b>'.$langs->trans("NextValue").'</b>: '.$nextval;

View File

@ -187,7 +187,7 @@ if ($handle)
// Info // Info
$htmltooltip=''; $htmltooltip='';
$nextval=$module->getNextValue(); $nextval=$module->getNextValue($mysoc);
if ($nextval != $langs->trans("NotAvailable")) if ($nextval != $langs->trans("NotAvailable"))
{ {
$htmltooltip='<b>'.$langs->trans("NextValue").'</b>: '.$nextval; $htmltooltip='<b>'.$langs->trans("NextValue").'</b>: '.$nextval;

View File

@ -218,7 +218,7 @@ if ($handle)
// Info // Info
$htmltooltip=''; $htmltooltip='';
$nextval=$module->getNextValue(); $nextval=$module->getNextValue($mysoc);
if ($nextval != $langs->trans("NotAvailable")) if ($nextval != $langs->trans("NotAvailable"))
{ {
$htmltooltip='<b>'.$langs->trans("NextValue").'</b>: '.$nextval; $htmltooltip='<b>'.$langs->trans("NextValue").'</b>: '.$nextval;

View File

@ -20,7 +20,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** /**

View File

@ -20,7 +20,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/*! /*!

View File

@ -21,7 +21,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** /**

View File

@ -91,48 +91,49 @@ class ModelePDFFactures extends FPDF
\class ModeleNumRefFactures \class ModeleNumRefFactures
\brief Classe mère des modèles de numérotation des références de facture \brief Classe mère des modèles de numérotation des références de facture
*/ */
class ModeleNumRefFactures class ModeleNumRefFactures
{ {
var $error=''; var $error='';
/** \brief Renvoi la description par defaut du modele de numérotation /** \brief Renvoi la description par defaut du modele de numérotation
* \return string Texte descripif * \return string Texte descripif
*/ */
function info() function info()
{ {
global $langs; global $langs;
$langs->load("bills"); $langs->load("bills");
return $langs->trans("NoDescription"); return $langs->trans("NoDescription");
} }
/** \brief Renvoi un exemple de numérotation /** \brief Renvoi un exemple de numérotation
* \return string Example * \return string Example
*/ */
function getExample() function getExample()
{ {
global $langs; global $langs;
$langs->load("bills"); $langs->load("bills");
return $langs->trans("NoExample"); return $langs->trans("NoExample");
} }
/** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de /** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de
* de conflits qui empechera cette numérotation de fonctionner. * de conflits qui empechera cette numérotation de fonctionner.
* \return boolean false si conflit, true si ok * \return boolean false si conflit, true si ok
*/ */
function canBeActivated() function canBeActivated()
{ {
return true; return true;
} }
/** \brief Renvoi prochaine valeur attribuée /** \brief Renvoi prochaine valeur attribuée
* \return string Valeur * \param objsoc Objet societe
*/ * \param facture Objet facture
function getNextValue() * \return string Valeur
{ */
global $langs; function getNextValue($objsoc,$facture)
return $langs->trans("NotAvailable"); {
} global $langs;
return $langs->trans("NotAvailable");
}
} }

View File

@ -20,7 +20,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** /**
@ -82,7 +81,7 @@ class mod_facture_neptune extends ModeleNumRefFactures
* \param facture Objet facture * \param facture Objet facture
* \return string Texte descripif * \return string Texte descripif
*/ */
function getNextValue($objsoc=0,$facture) function getNextValue($objsoc,$facture)
{ {
global $db,$conf; global $db,$conf;

View File

@ -20,7 +20,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** /**

View File

@ -36,7 +36,8 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php")
class mod_facture_terre extends ModeleNumRefFactures class mod_facture_terre extends ModeleNumRefFactures
{ {
var $prefix='FA'; var $prefixinvoice='FA';
var $prefixcreditnote='AV';
var $error=''; var $error='';
/** \brief Renvoi la description du modele de numérotation /** \brief Renvoi la description du modele de numérotation
@ -48,7 +49,7 @@ class mod_facture_terre extends ModeleNumRefFactures
$langs->load("bills"); $langs->load("bills");
return $langs->trans('TerreNumRefModelDesc1',$this->prefix); return $langs->trans('TerreNumRefModelDesc1',$this->prefixinvoice,$this->prefixcreditnote);
} }
/** \brief Renvoi un exemple de numérotation /** \brief Renvoi un exemple de numérotation
@ -56,7 +57,7 @@ class mod_facture_terre extends ModeleNumRefFactures
*/ */
function getExample() function getExample()
{ {
return $this->prefix."0501-0001"; return $this->prefixinvoice."0501-0001";
} }
/** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de /** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de
@ -67,41 +68,65 @@ class mod_facture_terre extends ModeleNumRefFactures
{ {
global $langs; global $langs;
$langs->load("bills"); $langs->load("bills");
$fayymm=''; // Check invoice num
$fayymm='';
$sql = "SELECT MAX(facnumber)"; $sql = "SELECT MAX(facnumber)";
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber like '".$this->prefixinvoice."%'";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
if ($row) $fayymm = substr($row[0],0,6); if ($row) $fayymm = substr($row[0],0,6);
} }
if (! $fayymm || eregi($this->prefix.'[0-9][0-9][0-9][0-9]',$fayymm)) if ($fayymm && eregi($this->prefixinvoice.'[0-9][0-9][0-9][0-9]',$fayymm))
{
return true;
}
else
{ {
$this->error=$langs->trans('TerreNumRefModelError'); $this->error=$langs->trans('TerreNumRefModelError');
return false; return false;
} }
// Check credit note num
$fayymm='';
$sql = "SELECT MAX(facnumber)";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber like '".$this->prefixcreditnote."%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) $fayymm = substr($row[0],0,6);
}
if ($fayymm && eregi($this->prefixcreditnote.'[0-9][0-9][0-9][0-9]',$fayymm))
{
$this->error=$langs->trans('TerreNumRefModelError');
return false;
}
return true;
} }
/** \brief Renvoi prochaine valeur attribuée /** \brief Renvoi prochaine valeur attribuée
* \param objsoc Objet societe
* \param facture Objet facture * \param facture Objet facture
* \return string Valeur * \return string Valeur
*/ */
function getNextValue($facture) function getNextValue($objsoc,$facture)
{ {
global $db; global $db;
if ($facture->type == 2) $prefix=$this->prefixcreditnote;
else $prefix=$this->prefixinvoice;
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé) // D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
$fayymm=''; $fayymm='';
$sql = "SELECT MAX(facnumber)"; $sql = "SELECT MAX(facnumber)";
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber like '".$prefix."%'";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -115,7 +140,7 @@ class mod_facture_terre extends ModeleNumRefFactures
} }
// Si champ respectant le modèle a été trouvée // Si champ respectant le modèle a été trouvée
if (eregi('^'.$this->prefix.'[0-9][0-9][0-9][0-9]',$fayymm)) if (eregi('^'.$prefix.'[0-9][0-9][0-9][0-9]',$fayymm))
{ {
// Recherche rapide car restreint par un like sur champ indexé // Recherche rapide car restreint par un like sur champ indexé
$posindice=8; $posindice=8;
@ -136,8 +161,8 @@ class mod_facture_terre extends ModeleNumRefFactures
$yymm = strftime("%y%m",time()); $yymm = strftime("%y%m",time());
$num = sprintf("%04s",$max+1); $num = sprintf("%04s",$max+1);
dolibarr_syslog("mod_facture_terre::getNextValue return ".$this->prefix."$yymm-$num"); dolibarr_syslog("mod_facture_terre::getNextValue return ".$prefix."$yymm-$num");
return $this->prefix."$yymm-$num"; return $prefix."$yymm-$num";
} }
/** \brief Renvoie la référence de facture suivante non utilisée /** \brief Renvoie la référence de facture suivante non utilisée
@ -147,7 +172,7 @@ class mod_facture_terre extends ModeleNumRefFactures
*/ */
function getNumRef($objsoc=0,$facture) function getNumRef($objsoc=0,$facture)
{ {
return $this->getNextValue($facture); return $this->getNextValue($objsoc,$facture);
} }
} }

View File

@ -22,6 +22,8 @@ NotAvailableWhenAjaxDisabled=Not available when Ajax disabled
JavascriptDisabled=Javascript disabled JavascriptDisabled=Javascript disabled
UsePopupCalendar=Use popup for dates input UsePopupCalendar=Use popup for dates input
NextValue=Next value NextValue=Next value
NextValueForInvoices=Next value (invoices)
NextValueForCreditNotes=Next value (credit notes)
MustBeLowerThanPHPLimit=Note: your PHP limits upload size to <b>%s</b> %s, whatever is thi sparameter value MustBeLowerThanPHPLimit=Note: your PHP limits upload size to <b>%s</b> %s, whatever is thi sparameter value
NoMaxSizeByPHPLimit=Note: No limit are built in your PHP NoMaxSizeByPHPLimit=Note: No limit are built in your PHP
ComptaSetup=Accounting module setup ComptaSetup=Accounting module setup

View File

@ -14,9 +14,9 @@ InvoiceStandardDesc=This kind of invoice is the common invoice.
InvoiceReplacement=Replacement invoice. Must replace invoice with reference InvoiceReplacement=Replacement invoice. Must replace invoice with reference
InvoiceReplacementAsk=Replacement invoice for invoice InvoiceReplacementAsk=Replacement invoice for invoice
InvoiceReplacementDesc=<b>Replacement invoice</b> is used to cancel and replace completely an invoice with no paiement already recevided.<br>Reference of canceled invoice is required. InvoiceReplacementDesc=<b>Replacement invoice</b> is used to cancel and replace completely an invoice with no paiement already recevided.<br>Reference of canceled invoice is required.
InvoiceAvoir=Avoir invoice InvoiceAvoir=Credit note
InvoiceAvoirAsk=Avoir invoice to correct invoice InvoiceAvoirAsk=Credit note to correct invoice
InvoiceAvoirDesc=La <b>facture d'avoir</b> est une facture négative destinée à compenser une facture comportant un montant supérieur à ce qui a été ou sera réellement payé (toutes causes possibles). InvoiceAvoirDesc=The <b>credit note</b> is a negative invoice used to solve fact that an invoice has an higher amount that amount that was or will be payed (all possible reasons).
ReplaceInvoice=Replace invoice %s ReplaceInvoice=Replace invoice %s
ReplacedByInvoice=Replaced by invoice %s ReplacedByInvoice=Replaced by invoice %s
CorrectInvoice=Correct invoice %s CorrectInvoice=Correct invoice %s
@ -119,7 +119,7 @@ ConfirmClassifyPayedPartiallyReasonDiscountVat=Remainder to pay <b>(%s %s)</b> i
ConfirmClassifyPayedPartiallyReasonAbandon=Debit irremediably not recoverable (bad customer...) ConfirmClassifyPayedPartiallyReasonAbandon=Debit irremediably not recoverable (bad customer...)
ConfirmClassifyPayedPartiallyNoVat=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: « escompte net de taxe ») ConfirmClassifyPayedPartiallyNoVat=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: « escompte net de taxe »)
ConfirmClassifyPayedPartiallyVat=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: «seule la taxe correspondant au prix effectivement payé ouvre droit à déduction») ConfirmClassifyPayedPartiallyVat=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: «seule la taxe correspondant au prix effectivement payé ouvre droit à déduction»)
ConfirmClassifyPayedPartiallyAvoir=Ce choix est le choix à prendre si les autres ne sont pas applicables ConfirmClassifyPayedPartiallyAvoir=Use this choice if all other does not suit
ConfirmClassifyPayedPartiallyAbandon=Ce choix sera celui dans le cas d'un mauvais payeur sans aucun espoir de recouvrement ConfirmClassifyPayedPartiallyAbandon=Ce choix sera celui dans le cas d'un mauvais payeur sans aucun espoir de recouvrement
ConfirmCustomerPayment=Do you confirm this paiement input for <b>%s</b> %s ? ConfirmCustomerPayment=Do you confirm this paiement input for <b>%s</b> %s ?
ValidateBill=Validate invoice ValidateBill=Validate invoice
@ -128,7 +128,7 @@ NumberOfBillsByMonth=Nb of invoices by month
ShowBill=Show invoice ShowBill=Show invoice
ShowInvoice=Show invoice ShowInvoice=Show invoice
ShowInvoiceReplace=Show replacing invoice ShowInvoiceReplace=Show replacing invoice
ShowInvoiceAvoir=Show avoir invoice ShowInvoiceAvoir=Show credit note
ShowPayment=Show payment ShowPayment=Show payment
File=File File=File
AlreadyPayed=Already payed AlreadyPayed=Already payed

View File

@ -22,6 +22,8 @@ NotAvailableWhenAjaxDisabled=Non disponible quand Ajax d
JavascriptDisabled=Javascript désactivé JavascriptDisabled=Javascript désactivé
UsePopupCalendar=Utiliser les popups pour la saisie des dates UsePopupCalendar=Utiliser les popups pour la saisie des dates
NextValue=Prochaine valeur NextValue=Prochaine valeur
NextValueForInvoices=Prochaine valeur (factures)
NextValueForCreditNotes=Prochaine valeur (avoirs)
MustBeLowerThanPHPLimit=Remarque: Votre PHP limite naturellement la taille à <b>%s</b> %s maximum, quelque soit la valeur de ce paramètre MustBeLowerThanPHPLimit=Remarque: Votre PHP limite naturellement la taille à <b>%s</b> %s maximum, quelque soit la valeur de ce paramètre
NoMaxSizeByPHPLimit=Aucune limite interne à votre serveur PHP NoMaxSizeByPHPLimit=Aucune limite interne à votre serveur PHP
ComptaSetup=Configuration du module Comptabilité ComptaSetup=Configuration du module Comptabilité

View File

@ -315,7 +315,7 @@ OrionNumRefModelDesc3=D
OrionNumRefModelDesc4=Dans cette exemple nous aurons au 1er septembre 2006 une facture nommée FA0700354. OrionNumRefModelDesc4=Dans cette exemple nous aurons au 1er septembre 2006 une facture nommée FA0700354.
# terre # terre
TerreNumRefModelDesc1=Renvoie le numéro sous la forme %syymm-nnnn où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0 TerreNumRefModelDesc1=Renvoie le numéro sous la forme %syymm-nnnn pour les factures et %syymm-nnnn pour les avoirs où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0
TerreNumRefModelError=Une facture commençant par $fayymm existe en base et est incompatible avec cette numérotation. Supprimer la ou renommer la pour activer ce module. TerreNumRefModelError=Une facture commençant par $fayymm existe en base et est incompatible avec cette numérotation. Supprimer la ou renommer la pour activer ce module.
# titan # titan

View File

@ -73,7 +73,8 @@ if (isset($dolibarr_auto_user)) $authmode=array('auto');
$sessionname="DOLSESSID_".$dolibarr_main_db_name; $sessionname="DOLSESSID_".$dolibarr_main_db_name;
session_name($sessionname); session_name($sessionname);
session_start(); session_start();
//dolibarr_syslog("We are in a session. Session name=".$sessionname." Session id()=".session_id().", _SESSION['dol_login']=".$_SESSION["dol_login"]); dolibarr_syslog("Session name=".$sessionname." Session id()=".session_id().", _SESSION['dol_login']=".$_SESSION["dol_login"]);
dolibarr_syslog("Session name=".$sessionname." Session id()=".session_id().", _SESSION['dol_login']=".$_SESSION["dol_login"]);
// Si la demande du login a déjà eu lieu, on le récupère depuis la session // Si la demande du login a déjà eu lieu, on le récupère depuis la session
// sinon appel du module qui réalise sa demande. // sinon appel du module qui réalise sa demande.
@ -83,7 +84,7 @@ if (! session_id() || ! isset($_SESSION["dol_login"]))
{ {
// On est pas déjà authentifié, on demande le login/mot de passe // On est pas déjà authentifié, on demande le login/mot de passe
// A l'issu de cette demande, le login et un jeton doivent avoir été placé // A l'issu de cette demande, le login et un jeton doivent avoir été placé
// en session dans dol_login et dol_token et la page rappelée. // en session dans dol_login et la page rappelée.
// MODE AUTO // MODE AUTO
if (in_array('auto',$authmode) && ! $login) if (in_array('auto',$authmode) && ! $login)
@ -221,7 +222,7 @@ if (! isset($_SESSION["dol_login"]))
{ {
// Nouvelle session pour ce login // Nouvelle session pour ce login
$_SESSION["dol_login"]=$user->login; $_SESSION["dol_login"]=$user->login;
dolibarr_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"]); dolibarr_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"].' Session id='.session_id());
$user->update_last_login_date(); $user->update_last_login_date();
} }