diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index bc8e7dbbc69..2be2436d0dc 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -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='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'
'; } } +// 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='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'
'; + } +} +// 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='
'.$fac->error.'
'; + } + } +} /* * 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='
'.$fac->error.'
'; - } - } -} -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").'

'.$langs->trans("ConfirmClassifyPayedPartiallyVat"); - $close[1]['label']=$langs->trans("ConfirmClassifyPayedPartiallyBadCustomer"); - $close[2]['label']=$langs->trans("ConfirmClassifyPayedPartiallyOther"); + $close[0]['label']=$langs->trans("HelpEscompte").'

'.$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 '
'; } } /* - * 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 ''; // 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 ''; $resteapayeraffiche=$resteapayer; - // Escompte + // Payé partiellement 'escompte' if ($fac->close_code == 'escompte') { print ''; $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 ''; $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 ''; if ($i==0) print ''; else print ''; - print ''; - print ''; + print ''; $i++; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 53320336f86..b48498a655a 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -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 %s ? ConfirmClassifyPayedBill=Are you sure you want to change invoice %s to status payed ? ConfirmCancelBill=Are you sure you want to cancel invoice %s ? +ConfirmCancelBillQuestion=why do you want to classify this invoice 'abdandonned' ? ConfirmClassifyPayedPartially=Are you sure you want to change invoice %s to status payed ? ConfirmClassifyPayedPartiallyQuestion=This invoice has not been payed completely. What are reasons for you to close this invoice ? ConfirmClassifyPayedPartiallyReasonAvoir=Remainder to pay (%s %s) 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 (%s %s) ConfirmClassifyPayedPartiallyReasonDiscountVat=Remainder to pay (%s %s) 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 %s %s ? ValidateBill=Validate invoice NumberOfBills=Nb of invoices diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index e07f7eccf80..737d3504bd7 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -118,18 +118,21 @@ ConfirmDeleteBill= ConfirmValidateBill=Êtes-vous sûr de vouloir valider cette facture sous la référence %s ? ConfirmClassifyPayedBill=Êtes-vous sûr de vouloir classer la facture %s comme payée ? ConfirmCancelBill=Êtes-vous sûr de vouloir annuler la facture %s ? +ConfirmCancelBillQuestion=Pour quelle raison voulez-vous classer la facture abandonnée ? ConfirmClassifyPayedPartially=Êtes-vous sûr de vouloir classer la facture %s 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 (%s %s) est un trop facturé (car article retourné, oubli, escompte non défini...) régularisé par un avoir -ConfirmClassifyPayedPartiallyReasonDiscountNoVat=Le rest à payer (%s %s) est un escompte accordé après facture. J'accepte de perdre la TVA sur cet escompte +ConfirmClassifyPayedPartiallyReasonDiscountNoVat=Le reste à payer (%s %s) est un escompte accordé après facture. J'accepte de perdre la TVA sur cet escompte ConfirmClassifyPayedPartiallyReasonDiscountVat=Le reste à payer (%s %s) 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 %s %s ? ValidateBill=Valider facture NumberOfBills=Nb de factures diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 6a8aa5f2f90..e8ef1d5ec14 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -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); diff --git a/mysql/tables/llx_societe.sql b/mysql/tables/llx_societe.sql index d3afef3ea2c..27fe41e9810 100644 --- a/mysql/tables/llx_societe.sql +++ b/mysql/tables/llx_societe.sql @@ -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
'; @@ -1887,7 +1916,7 @@ else // Facturé print '
'.$langs->trans("Billed").' :'.price($fac->total_ttc).''.$langs->trans('Currency'.$conf->monnaie).'
'; @@ -1895,16 +1924,16 @@ else print ''.price($fac->total_ttc - $totalpaye).''.$langs->trans('Currency'.$conf->monnaie).'
'; print $html->textwithhelp($langs->trans("Abandoned").':',$langs->trans("HelpAbandonBadCustomer"),-1); print ''.price($fac->total_ttc - $totalpaye).''.$langs->trans('Currency'.$conf->monnaie).'
'; print $html->textwithhelp($langs->trans("Abandoned").':',$langs->trans("HelpAbandonOther"),-1); diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 649a4fe5c45..1b5cc0b3737 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -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 diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 613da1f37ba..e942b7c0086 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -1609,8 +1609,8 @@ class Form print '
'.$input['label'].' '; + print ''; print $selval; print '