Uniformize supplier invoice code with customer invoice code.
This commit is contained in:
parent
05cc92e3db
commit
843123d84a
@ -8,6 +8,7 @@ For users:
|
|||||||
- New: task #10113 : Show list of emailing on clicking on "number of mass emailing received"
|
- New: task #10113 : Show list of emailing on clicking on "number of mass emailing received"
|
||||||
- New: Add default language for third parties and use it when multilang is enabled
|
- New: Add default language for third parties and use it when multilang is enabled
|
||||||
to define default language for document generation.
|
to define default language for document generation.
|
||||||
|
- New: Can reopen a closed supplier invoice.
|
||||||
- Fix: Formant number as wrong for ar_AR language.
|
- Fix: Formant number as wrong for ar_AR language.
|
||||||
|
|
||||||
For developers:
|
For developers:
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
/**
|
/**
|
||||||
* \file htdocs/comm/propal.php
|
* \file htdocs/comm/propal.php
|
||||||
* \ingroup propale
|
* \ingroup propale
|
||||||
* \brief Page liste des propales (vision commercial)
|
* \brief Page of commercial proposals card and list
|
||||||
* \version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -162,10 +162,13 @@ if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' &
|
|||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
if (! empty($_REQUEST['lang_id']))
|
$newlang='';
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$propal->client->default_lang;
|
||||||
|
if (! empty($newlang))
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate("",$conf);
|
$outputlangs = new Translate("",$conf);
|
||||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
}
|
}
|
||||||
propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs);
|
propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1113,16 +1113,19 @@ class Facture extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* \brief Tag la facture comme paye completement (close_code non renseigne) ou partiellement (close_code renseigne) + appel trigger BILL_PAYED
|
* \brief Tag la facture comme paye completement (close_code non renseigne) ou partiellement (close_code renseigne) + appel trigger BILL_PAYED
|
||||||
* \param user Objet utilisateur qui modifie
|
* \param user Objet utilisateur qui modifie
|
||||||
* \param close_code Code renseigne si on classe a payee completement alors que paiement incomplet (cas ecompte par exemple)
|
* \param close_code Code renseigne si on classe a payee completement alors que paiement incomplet (cas ecompte par exemple)
|
||||||
* \param close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas ecompte par exemple)
|
* \param close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas ecompte par exemple)
|
||||||
* \return int <0 si ok, >0 si ok
|
* \return int <0 si ok, >0 si ok
|
||||||
*/
|
*/
|
||||||
function set_paid($user,$close_code='',$close_note='')
|
function set_paid($user,$close_code='',$close_note='')
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
$error=0;
|
||||||
|
|
||||||
if ($this->paye != 1)
|
if ($this->paye != 1)
|
||||||
{
|
{
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
dol_syslog("Facture::set_paid rowid=".$this->id, LOG_DEBUG);
|
dol_syslog("Facture::set_paid rowid=".$this->id, LOG_DEBUG);
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET';
|
||||||
$sql.= ' fk_statut=2';
|
$sql.= ' fk_statut=2';
|
||||||
@ -1143,8 +1146,23 @@ class Facture extends CommonObject
|
|||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
dol_print_error($this->db);
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1163,8 +1181,10 @@ class Facture extends CommonObject
|
|||||||
function set_unpaid($user)
|
function set_unpaid($user)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
dol_syslog("Facture::set_unpaid rowid=".$this->id, LOG_DEBUG);
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
||||||
$sql.= ' SET paye=0, fk_statut=1, close_code=null, close_note=null';
|
$sql.= ' SET paye=0, fk_statut=1, close_code=null, close_note=null';
|
||||||
$sql.= ' WHERE rowid = '.$this->id;
|
$sql.= ' WHERE rowid = '.$this->id;
|
||||||
@ -1182,18 +1202,33 @@ class Facture extends CommonObject
|
|||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
dol_print_error($this->db);
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Tag la facture comme abandonnee, sans paiement dessus (exemple car facture de remplacement) + appel trigger BILL_CANCEL
|
* \brief Tag la facture comme abandonnee, sans paiement dessus (exemple car facture de remplacement) + appel trigger BILL_CANCEL
|
||||||
\param user Objet utilisateur qui modifie
|
* \param user Objet utilisateur qui modifie
|
||||||
\param close_code Code de fermeture
|
* \param close_code Code de fermeture
|
||||||
\param close_note Commentaire de fermeture
|
* \param close_note Commentaire de fermeture
|
||||||
\return int <0 si ok, >0 si ok
|
* \return int <0 si ok, >0 si ok
|
||||||
*/
|
*/
|
||||||
function set_canceled($user,$close_code='',$close_note='')
|
function set_canceled($user,$close_code='',$close_note='')
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|||||||
@ -445,6 +445,27 @@ if ($_GET['action'] == 'edit' && $user->rights->fournisseur->facture->creer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_GET['action'] == 'reopen' && $user->rights->fournisseur->facture->creer)
|
||||||
|
{
|
||||||
|
$fac = new FactureFournisseur($db);
|
||||||
|
$result = $fac->fetch($_GET['facid']);
|
||||||
|
if ($fac->statut == 2
|
||||||
|
|| ($fac->statut == 3 && $fac->close_code != 'replaced'))
|
||||||
|
{
|
||||||
|
$result = $fac->set_unpaid($user);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$_GET['facid']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesg='<div class="error">'.$fac->error.'</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1165,6 +1186,20 @@ else
|
|||||||
|
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
|
// Reopen a standard paid invoice
|
||||||
|
if ($fac->type == 1 && $fac->statut == 2) // A paid invoice (partially or completely)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&action=reopen">'.$langs->trans('ReOpen').'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reopen a classified invoice
|
||||||
|
if (($fac->statut == 2 || $fac->statut == 3) && // Closed invoice
|
||||||
|
$fac->getIdReplacingInvoice() == 0 && // Not replaced by another invoice
|
||||||
|
$fac->close_code != 'replaced') // Not replaced by another invoice
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&action=reopen">'.$langs->trans('ReOpen').'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
if ($_GET['action'] != 'edit' && $fac->statut <= 1 && $fac->getSommePaiement() <= 0 && $user->rights->fournisseur->facture->creer)
|
if ($_GET['action'] != 'edit' && $fac->statut <= 1 && $fac->getSommePaiement() <= 0 && $user->rights->fournisseur->facture->creer)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&action=edit">'.$langs->trans('Modify').'</a>';
|
print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&action=edit">'.$langs->trans('Modify').'</a>';
|
||||||
|
|||||||
@ -52,9 +52,9 @@ class FactureFournisseur extends Facture
|
|||||||
//! 0=Standard invoice, 1=Replacement invoice, 2=Credit note invoice, 3=Deposit invoice, 4=Proformat invoice
|
//! 0=Standard invoice, 1=Replacement invoice, 2=Credit note invoice, 3=Deposit invoice, 4=Proformat invoice
|
||||||
var $type;
|
var $type;
|
||||||
//! 0=draft,
|
//! 0=draft,
|
||||||
//! 1=validated,
|
//! 1=validated
|
||||||
//! TODO Ce statut doit etre 2 et non 1 classee payee partiellement (close_code='discount_vat','badcustomer') ou completement (close_code=null),
|
//! 2=classified paid partially (close_code='discount_vat','badcustomer') or completely (close_code=null),
|
||||||
//! TODO Ce statut doit etre 2 et non 1 classee abandonnee et aucun paiement n'a eu lieu (close_code='badcustomer','abandon' ou 'replaced')
|
//! Also 2, should be 3=classified abandoned and no payment done (close_code='badcustomer','abandon' ou 'replaced')
|
||||||
var $statut;
|
var $statut;
|
||||||
//! 1 si facture payee COMPLETEMENT, 0 sinon (ce champ ne devrait plus servir car insuffisant)
|
//! 1 si facture payee COMPLETEMENT, 0 sinon (ce champ ne devrait plus servir car insuffisant)
|
||||||
var $paye;
|
var $paye;
|
||||||
@ -419,10 +419,10 @@ class FactureFournisseur extends Facture
|
|||||||
{
|
{
|
||||||
if ($user->rights->fournisseur->facture->creer)
|
if ($user->rights->fournisseur->facture->creer)
|
||||||
{
|
{
|
||||||
dol_syslog('FactureFournisseur::set_ref_supplier this->id='.$this->id.', ref_supplier='.$ref_supplier);
|
|
||||||
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn SET facnumber = '.(empty($ref_supplier) ? 'NULL' : '\''.addslashes($ref_supplier).'\'');
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn SET facnumber = '.(empty($ref_supplier) ? 'NULL' : '\''.addslashes($ref_supplier).'\'');
|
||||||
$sql.= ' WHERE rowid = '.$this->id;
|
$sql.= ' WHERE rowid = '.$this->id;
|
||||||
|
|
||||||
|
dol_syslog("FactureFournisseur::set_ref_supplier sql=".$sql);
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
$this->ref_supplier = $ref_supplier;
|
$this->ref_supplier = $ref_supplier;
|
||||||
@ -448,21 +448,99 @@ class FactureFournisseur extends Facture
|
|||||||
*/
|
*/
|
||||||
function set_paid($user)
|
function set_paid($user)
|
||||||
{
|
{
|
||||||
|
global $conf,$langs;
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn';
|
||||||
$sql.= ' SET paye = 1';
|
$sql.= ' SET paye = 1, fk_statut=2';
|
||||||
$sql.= ' WHERE rowid = '.$this->id;
|
$sql.= ' WHERE rowid = '.$this->id;
|
||||||
|
|
||||||
|
dol_syslog("FactureFournisseur::set_paid sql=".$sql);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
|
||||||
|
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('BILL_SUPPLIER_PAYED',$this,$user,$langs,$conf);
|
||||||
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
|
// Fin appel triggers
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Tag la facture comme non payee completement + appel trigger BILL_UNPAYED
|
||||||
|
* Fonction utilisee quand un paiement prelevement est refuse,
|
||||||
|
* ou quand une facture annulee et reouverte.
|
||||||
|
* \param user Object user that change status
|
||||||
|
* \return int <0 si ok, >0 si ok
|
||||||
|
*/
|
||||||
|
function set_unpaid($user)
|
||||||
|
{
|
||||||
|
global $conf,$langs;
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
dol_syslog("FactureFournisseur::set_unpaid rowid=".$this->id, LOG_DEBUG);
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn';
|
||||||
|
$sql.= ' SET paye=0, fk_statut=1, close_code=null, close_note=null';
|
||||||
|
$sql.= ' WHERE rowid = '.$this->id;
|
||||||
|
|
||||||
|
dol_syslog("FactureFournisseur::set_unpaid sql=".$sql);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
|
||||||
|
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('BILL_SUPPLIER_UNPAYED',$this,$user,$langs,$conf);
|
||||||
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
|
// Fin appel triggers
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
dol_print_error($this->db);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set invoice status as validated
|
* \brief Set invoice status as validated
|
||||||
* \param user Object user
|
* \param user Object user
|
||||||
@ -487,7 +565,7 @@ class FactureFournisseur extends Facture
|
|||||||
$sql.= " SET fk_statut = 1, fk_user_valid = ".$user->id;
|
$sql.= " SET fk_statut = 1, fk_user_valid = ".$user->id;
|
||||||
$sql.= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
dol_syslog("FactureFournisseur::set_valid sql=".$sql, LOG_DEBUG);
|
dol_syslog("FactureFournisseur::set_valid sql=".$sql);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -22,3 +22,8 @@ alter table llx_mailing add column joined_file1 varchar(255);
|
|||||||
alter table llx_mailing add column joined_file2 varchar(255);
|
alter table llx_mailing add column joined_file2 varchar(255);
|
||||||
alter table llx_mailing add column joined_file3 varchar(255);
|
alter table llx_mailing add column joined_file3 varchar(255);
|
||||||
alter table llx_mailing add column joined_file4 varchar(255);
|
alter table llx_mailing add column joined_file4 varchar(255);
|
||||||
|
|
||||||
|
update llx_facture_fourn set fk_statut=2 where fk_statut=1 AND paye=1;
|
||||||
|
|
||||||
|
alter table llx_facture_fourn add column close_code varchar(16) after remise;
|
||||||
|
alter table llx_facture_fourn add column close_note varchar(128) after close_code;
|
||||||
|
|||||||
@ -35,6 +35,10 @@ create table llx_facture_fourn
|
|||||||
paye smallint DEFAULT 0 NOT NULL,
|
paye smallint DEFAULT 0 NOT NULL,
|
||||||
amount double(24,8) DEFAULT 0 NOT NULL,
|
amount double(24,8) DEFAULT 0 NOT NULL,
|
||||||
remise double(24,8) DEFAULT 0,
|
remise double(24,8) DEFAULT 0,
|
||||||
|
|
||||||
|
close_code varchar(16), -- Code motif cloture sans paiement complet
|
||||||
|
close_note varchar(128), -- Commentaire cloture sans paiement complet
|
||||||
|
|
||||||
tva double(24,8) DEFAULT 0,
|
tva double(24,8) DEFAULT 0,
|
||||||
total double(24,8) DEFAULT 0,
|
total double(24,8) DEFAULT 0,
|
||||||
total_ht double(24,8) DEFAULT 0,
|
total_ht double(24,8) DEFAULT 0,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user