New: Gestion de 2 regles de gestion de facturation supplmentaire (UCIN06 et UCIN07, voir http://www.dolibarr.com/wikidev/index.php/Facturation#Exemples_de_cas_d.27utilisations)
This commit is contained in:
parent
b3ff7c79ac
commit
9a816c6ac8
@ -259,6 +259,7 @@ if ($_POST['action'] == 'confirm_payed' && $_POST['confirm'] == 'yes' && $user->
|
||||
$fac->fetch($_GET['facid']);
|
||||
$result = $fac->set_payed($user);
|
||||
}
|
||||
// Classe à "payée partiellement"
|
||||
if ($_POST['action'] == 'confirm_payed_partially' && $_POST['confirm'] == 'yes' && $user->rights->facture->paiement)
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
@ -274,6 +275,41 @@ if ($_POST['action'] == 'confirm_payed_partially' && $_POST['confirm'] == 'yes'
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'</div>';
|
||||
}
|
||||
}
|
||||
// Classe à "abandonnée"
|
||||
if ($_POST['action'] == 'confirm_canceled' && $_POST['confirm'] == 'yes')
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($_GET['facid']);
|
||||
$close_code=$_POST["close_code"];
|
||||
$close_note=$_POST["close_note"];
|
||||
if ($close_code)
|
||||
{
|
||||
$result = $fac->set_canceled($user,$close_code,$close_note);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'</div>';
|
||||
}
|
||||
}
|
||||
// Supprimer
|
||||
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
||||
{
|
||||
if ($user->rights->facture->supprimer)
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$result = $fac->fetch($_GET['facid']);
|
||||
$result = $fac->delete();
|
||||
if ($result > 0)
|
||||
{
|
||||
Header('Location: '.$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$fac->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Insertion facture
|
||||
@ -739,34 +775,7 @@ if ($_GET['action'] == 'deleteline' && $user->rights->facture->creer && ! $conf-
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
||||
{
|
||||
if ($user->rights->facture->supprimer)
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$result = $fac->fetch($_GET['facid']);
|
||||
$result = $fac->delete();
|
||||
if ($result > 0)
|
||||
{
|
||||
Header('Location: '.$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$fac->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'confirm_canceled' && $_POST['confirm'] == 'yes')
|
||||
{
|
||||
if ($user->rights->facture->supprimer)
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($_GET['facid']);
|
||||
$result = $fac->set_canceled($user);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Ordonnancement des lignes
|
||||
@ -1677,9 +1686,9 @@ else
|
||||
$close[1]['code']='badcustomer';
|
||||
$close[2]['code']='abandon';
|
||||
// Help
|
||||
$close[0]['label']=$langs->trans("HelpEscompte").'<br><br>'.$langs->trans("ConfirmClassifyPayedPartiallyVat");
|
||||
$close[1]['label']=$langs->trans("ConfirmClassifyPayedPartiallyBadCustomer");
|
||||
$close[2]['label']=$langs->trans("ConfirmClassifyPayedPartiallyOther");
|
||||
$close[0]['label']=$langs->trans("HelpEscompte").'<br><br>'.$langs->trans("ConfirmClassifyPayedPartiallyReasonDiscountVatDesc");
|
||||
$close[1]['label']=$langs->trans("ConfirmClassifyPayedPartiallyReasonBadCustomerDesc");
|
||||
$close[2]['label']=$langs->trans("ConfirmClassifyPayedPartiallyReasonOtherDesc");
|
||||
// Texte
|
||||
$close[0]['reason']=$html->textwithhelp($langs->transnoentities("ConfirmClassifyPayedPartiallyReasonDiscountVat",$resteapayer,$langs->trans("Currency".$conf->monnaie)),$close[0]['label'],1);
|
||||
$close[1]['reason']=$html->textwithhelp($langs->transnoentities("ConfirmClassifyPayedPartiallyReasonBadCustomer",$resteapayer,$langs->trans("Currency".$conf->monnaie)),$close[1]['label'],1);
|
||||
@ -1719,14 +1728,34 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$fac->id,$langs->trans('CancelBill'),$langs->trans('ConfirmCancelBill',$fac->ref),'confirm_canceled');
|
||||
// Code
|
||||
$close[1]['code']='badcustomer';
|
||||
$close[2]['code']='abandon';
|
||||
// Help
|
||||
$close[1]['label']=$langs->trans("ConfirmClassifyPayedPartiallyReasonBadCustomerDesc");
|
||||
$close[2]['label']=$langs->trans("ConfirmClassifyAbandonReasonOtherDesc");
|
||||
// Texte
|
||||
$close[1]['reason']=$html->textwithhelp($langs->transnoentities("ConfirmClassifyPayedPartiallyReasonBadCustomer",$fac->ref),$close[1]['label'],1);
|
||||
$close[2]['reason']=$html->textwithhelp($langs->transnoentities("ConfirmClassifyAbandonReasonOther"),$close[2]['label'],1);
|
||||
// arrayreasons
|
||||
$arrayreasons[$close[1]['code']]=$close[1]['reason'];
|
||||
$arrayreasons[$close[2]['code']]=$close[2]['reason'];
|
||||
|
||||
// Crée un tableau formulaire
|
||||
$formquestion=array(
|
||||
'text' => $langs->trans("ConfirmCancelBillQuestion"),
|
||||
array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons),
|
||||
array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'size' => '100')
|
||||
);
|
||||
|
||||
$html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$fac->id,$langs->trans('CancelBill'),$langs->trans('ConfirmCancelBill',$fac->ref),'confirm_canceled',$formquestion);
|
||||
print '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression d'une ligne produit
|
||||
*/
|
||||
* Confirmation de la suppression d'une ligne produit
|
||||
*/
|
||||
if ($_GET['action'] == 'delete_product_line' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
||||
{
|
||||
$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id.'&rowid='.$_GET["rowid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline');
|
||||
@ -1734,8 +1763,8 @@ else
|
||||
}
|
||||
|
||||
/*
|
||||
* Facture
|
||||
*/
|
||||
* Facture
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Reference
|
||||
@ -1747,7 +1776,7 @@ else
|
||||
L'info "Reference commande client" est une carac de la commande et non de la facture.
|
||||
Elle devrait donc etre stockée sur l'objet commande lié à la facture et non sur la facture.
|
||||
Pour ceux qui utilisent ainsi, positionner la constante FAC_USE_CUSTOMER_ORDER_REF à 1.
|
||||
*/
|
||||
*/
|
||||
if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF)
|
||||
{
|
||||
print '<tr><td>';
|
||||
@ -1887,7 +1916,7 @@ else
|
||||
// Facturé
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($fac->total_ttc).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
$resteapayeraffiche=$resteapayer;
|
||||
// Escompte
|
||||
// Payé partiellement 'escompte'
|
||||
if ($fac->close_code == 'escompte')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
@ -1895,16 +1924,16 @@ else
|
||||
print '</td><td align="right">'.price($fac->total_ttc - $totalpaye).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
$resteapayeraffiche=0;
|
||||
}
|
||||
// Abandon bad customer
|
||||
if ($fac->close_code == 'badcustomer')
|
||||
// Payé partiellement ou Abandon 'badcustomer'
|
||||
if (($fac->fk_statut == 2 || $fac->fk_statut == 3) && $fac->close_code == 'badcustomer')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
print $html->textwithhelp($langs->trans("Abandoned").':',$langs->trans("HelpAbandonBadCustomer"),-1);
|
||||
print '</td><td align="right">'.price($fac->total_ttc - $totalpaye).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
$resteapayeraffiche=0;
|
||||
}
|
||||
// Abandon other
|
||||
if ($fac->close_code == 'abandon')
|
||||
// Abandon 'abandon'
|
||||
if (($fac->fk_statut == 2 || $fac->fk_statut == 3) && $fac->close_code == 'abandon')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
print $html->textwithhelp($langs->trans("Abandoned").':',$langs->trans("HelpAbandonOther"),-1);
|
||||
|
||||
@ -66,7 +66,10 @@ class Facture extends CommonObject
|
||||
var $total;
|
||||
var $note;
|
||||
var $note_public;
|
||||
//! 0=brouillon, 1=validée, 2=classée payée partiellement ou complètement, 3=classée abandonnée
|
||||
//! 0=brouillon,
|
||||
//! 1=validée,
|
||||
//! 2=classée payée partiellement (close_code='discount_vat','bad_customer') ou complètement (close_code=null),
|
||||
//! 3=classée abandonnée (close_code='abandon')
|
||||
var $statut;
|
||||
//! 1 si facture payée COMPLETEMENT, 0 sinon (ce champ ne devrait plus servir car insuffisant)
|
||||
var $paye;
|
||||
@ -124,7 +127,7 @@ class Facture extends CommonObject
|
||||
\param user Object utilisateur qui crée
|
||||
\return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function Create($user)
|
||||
function create($user)
|
||||
{
|
||||
global $langs,$conf,$mysoc;
|
||||
|
||||
@ -388,7 +391,7 @@ class Facture extends CommonObject
|
||||
\param societe_id id de societe
|
||||
\return int >0 si ok, <0 si ko
|
||||
*/
|
||||
function Fetch($rowid, $societe_id=0)
|
||||
function fetch($rowid, $societe_id=0)
|
||||
{
|
||||
dolibarr_syslog("Facture::Fetch rowid=".$rowid.", societe_id=".$societe_id, LOG_DEBUG);
|
||||
|
||||
@ -2257,7 +2260,7 @@ class Facture extends CommonObject
|
||||
|
||||
/**
|
||||
\brief Renvoi liste des factures remplacables
|
||||
Statut validée + aucun paiement + non payée + pas deja remplacée
|
||||
Statut validée ou abandonnée pour raison autre + non payée + aucun paiement + pas deja remplacée
|
||||
\param socid Id societe
|
||||
\return array Tableau des factures ('id'=>id, 'ref'=>ref, 'statut'=>status)
|
||||
*/
|
||||
@ -2272,7 +2275,7 @@ class Facture extends CommonObject
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source";
|
||||
$sql.= " WHERE f.fk_statut = 1";
|
||||
$sql.= " WHERE (f.fk_statut = 1 OR (f.fk_statut = 3 AND f.close_code = 'abandon'))";
|
||||
$sql.= " AND f.paye = 0"; // Pas classée payée complètement
|
||||
$sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait
|
||||
$sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement
|
||||
|
||||
@ -1609,8 +1609,8 @@ class Form
|
||||
print '<tr>';
|
||||
if ($i==0) print '<td valign="top">'.$input['label'].'</td>';
|
||||
else print '<td> </td>';
|
||||
print '<td valign="top"><input type="radio" class="flat" name="'.$input['name'].'" value="'.$selkey.'"></td>';
|
||||
print '<td valign="top">';
|
||||
print '<td valign="top" width="20"><input type="radio" class="flat" name="'.$input['name'].'" value="'.$selkey.'"></td>';
|
||||
print '<td valign="top" align="left">';
|
||||
print $selval;
|
||||
print '</td></tr>';
|
||||
$i++;
|
||||
|
||||
@ -118,6 +118,7 @@ ConfirmDeleteBill=Are you sure you want to delete this invoice ?
|
||||
ConfirmValidateBill=Are you sure you want to validate this invoice with reference <b>%s</b> ?
|
||||
ConfirmClassifyPayedBill=Are you sure you want to change invoice <b>%s</b> to status payed ?
|
||||
ConfirmCancelBill=Are you sure you want to cancel invoice <b>%s</b> ?
|
||||
ConfirmCancelBillQuestion=why do you want to classify this invoice 'abdandonned' ?
|
||||
ConfirmClassifyPayedPartially=Are you sure you want to change invoice <b>%s</b> to status payed ?
|
||||
ConfirmClassifyPayedPartiallyQuestion=This invoice has not been payed completely. What are reasons for you to close this invoice ?
|
||||
ConfirmClassifyPayedPartiallyReasonAvoir=Remainder to pay <b>(%s %s)</b> is a discount granted because payment was made before term. Je régularise la TVA par un avoir.
|
||||
@ -125,11 +126,11 @@ ConfirmClassifyPayedPartiallyReasonDiscountNoVat=Remainder to pay <b>(%s %s)</b>
|
||||
ConfirmClassifyPayedPartiallyReasonDiscountVat=Remainder to pay <b>(%s %s)</b> is a discount granted because payment was made before term. Je récupère la TVA sur cet escompte sans avoir.
|
||||
ConfirmClassifyPayedPartiallyReasonBadCustomer=Bad customer
|
||||
ConfirmClassifyPayedPartiallyReasonOther=Debit irremediably not recoverable (other reason)
|
||||
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»)
|
||||
ConfirmClassifyPayedPartiallyAvoir=Use this choice if all other does not suit
|
||||
ConfirmClassifyPayedPartiallyBadCustomer=This choice will be use for bad customers with no hope to be paied
|
||||
ConfirmClassifyPayedPartiallyOther=Use this choice if all other does not suit
|
||||
ConfirmClassifyPayedPartiallyReasonDiscountNoVatDesc=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: « escompte net de taxe »)
|
||||
ConfirmClassifyPayedPartiallyReasonDiscountVatDesc=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»)
|
||||
ConfirmClassifyPayedPartiallyReasonAvoirDesc=Use this choice if all other does not suit
|
||||
ConfirmClassifyPayedPartiallyReasonBadCustomerDesc=This choice will be use for bad customers with no hope to be paied
|
||||
ConfirmClassifyPayedPartiallyReasonOtherDesc=Use this choice if all other does not suit
|
||||
ConfirmCustomerPayment=Do you confirm this paiement input for <b>%s</b> %s ?
|
||||
ValidateBill=Validate invoice
|
||||
NumberOfBills=Nb of invoices
|
||||
|
||||
@ -118,18 +118,21 @@ ConfirmDeleteBill=
|
||||
ConfirmValidateBill=Êtes-vous sûr de vouloir valider cette facture sous la référence <b>%s</b> ?
|
||||
ConfirmClassifyPayedBill=Êtes-vous sûr de vouloir classer la facture <b>%s</b> comme payée ?
|
||||
ConfirmCancelBill=Êtes-vous sûr de vouloir annuler la facture <b>%s</b> ?
|
||||
ConfirmCancelBillQuestion=Pour quelle raison voulez-vous classer la facture abandonnée ?
|
||||
ConfirmClassifyPayedPartially=Êtes-vous sûr de vouloir classer la facture <b>%s</b> comme payée ?
|
||||
ConfirmClassifyPayedPartiallyQuestion=Cette facture n'a pas été payée à hauteur du montant initial. Pour quelle raison voulez-vous la classer magré tout ?
|
||||
ConfirmClassifyPayedPartiallyReasonAvoir=Le reste à payer <b>(%s %s)</b> est un trop facturé (car article retourné, oubli, escompte non défini...) régularisé par un avoir
|
||||
ConfirmClassifyPayedPartiallyReasonDiscountNoVat=Le rest à payer <b>(%s %s)</b> est un escompte accordé après facture. J'accepte de perdre la TVA sur cet escompte
|
||||
ConfirmClassifyPayedPartiallyReasonDiscountNoVat=Le reste à payer <b>(%s %s)</b> est un escompte accordé après facture. J'accepte de perdre la TVA sur cet escompte
|
||||
ConfirmClassifyPayedPartiallyReasonDiscountVat=Le reste à payer <b>(%s %s)</b> est un escompte
|
||||
ConfirmClassifyPayedPartiallyReasonBadCustomer=Mauvais payeur
|
||||
ConfirmClassifyPayedPartiallyReasonOther=Créance définitivement abandonnée (tout autre cas)
|
||||
ConfirmClassifyPayedPartiallyAvoir=Ce choix est le choix à prendre si les autres ne sont pas applicables
|
||||
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: mention définissant l'escompte ou du genre «seule la taxe correspondant au prix effectivement payé ouvre droit à déduction»)
|
||||
ConfirmClassifyPayedPartiallyBadCustomer=Ce choix sera celui dans le cas d'un mauvais payeur
|
||||
ConfirmClassifyPayedPartiallyOther=Ce choix sera celui dans tout autre cas
|
||||
ConfirmClassifyPayedPartiallyReasonDiscountNoVatDesc=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: «escompte net de taxe»)
|
||||
ConfirmClassifyPayedPartiallyReasonDiscountVatDesc=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: mention définissant l'escompte ou du genre «seule la taxe correspondant au prix effectivement payé ouvre droit à déduction»)
|
||||
ConfirmClassifyPayedPartiallyReasonAvoirDesc=Ce choix est le choix à prendre si les autres ne sont pas applicables
|
||||
ConfirmClassifyPayedPartiallyReasonBadCustomerDesc=Ce choix sera celui dans le cas d'un mauvais payeur
|
||||
ConfirmClassifyPayedPartiallyReasonOtherDesc=Ce choix sera celui dans tout autre cas
|
||||
ConfirmClassifyAbandonReasonOther=Autre
|
||||
ConfirmClassifyAbandonReasonOtherDesc=Ce choix sera celui dans tout autre cas. Par exemple suite à intention de créer une facture de remplacement.
|
||||
ConfirmCustomerPayment=Confirmez-vous la saisie de ce réglement de <b>%s</b> %s ?
|
||||
ValidateBill=Valider facture
|
||||
NumberOfBills=Nb de factures
|
||||
|
||||
@ -53,6 +53,10 @@ ALTER TABLE llx_societe modify services tinyint DEFAULT 0;
|
||||
ALTER TABLE llx_societe modify client tinyint DEFAULT 0;
|
||||
ALTER TABLE llx_societe modify fournisseur tinyint DEFAULT 0;
|
||||
|
||||
ALTER TABLE llx_societe add customer_bad tinyint DEFAULT 0 after fournisseur;
|
||||
ALTER TABLE llx_societe add customer_rate real DEFAULT 0 after customer_bad;
|
||||
ALTER TABLE llx_societe add supplier_rate real DEFAULT 0 after customer_rate;
|
||||
|
||||
ALTER TABLE llx_societe modify siren varchar(16);
|
||||
ALTER TABLE llx_societe modify siret varchar(16);
|
||||
ALTER TABLE llx_societe modify ape varchar(16);
|
||||
|
||||
@ -58,7 +58,10 @@ create table llx_societe
|
||||
services tinyint DEFAULT 0, --
|
||||
prefix_comm varchar(5), -- prefix commercial
|
||||
client tinyint DEFAULT 0, -- client 0/1/2
|
||||
fournisseur tinyint DEFAULT 0, -- fournisseur 0/1
|
||||
fournisseur tinyint DEFAULT 0, -- fournisseur 0/1
|
||||
customer_bad tinyint DEFAULT 0, -- mauvais payeur 0/1
|
||||
customer_rate real DEFAULT 0, -- taux fiabilié client (0 à 1)
|
||||
supplier_rate real DEFAULT 0, -- taux fiabilié fournisseur (0 à 1)
|
||||
rubrique varchar(255), -- champ rubrique libre
|
||||
fk_user_creat integer, -- utilisateur qui a créé l'info
|
||||
fk_user_modif integer, -- utilisateur qui a modifié l'info
|
||||
|
||||
Loading…
Reference in New Issue
Block a user