From a845921850af6296e97ff9f9d54b9235b3282eb2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Mar 2007 03:07:46 +0000 Subject: [PATCH] Suite gestion des avoirs. --- dev/skeletons/skeleton_class.class.php | 11 +- htdocs/compta/facture.php | 119 ++++++++++++------ htdocs/compta/paiement.php | 11 +- htdocs/contrat/contrat.class.php | 2 +- htdocs/discount.class.php | 61 ++++++++- htdocs/facture.class.php | 29 +++-- htdocs/fourn/fiche-stats.php | 2 +- .../modules/facture/pdf_crabe.modules.php | 8 +- htdocs/langs/en_US/bills.lang | 20 +-- htdocs/langs/fr_FR/bills.lang | 18 +-- htdocs/societe.class.php | 39 +++--- .../company/sync_contacts_dolibarr2ldap.php | 2 +- 12 files changed, 219 insertions(+), 103 deletions(-) diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index 6406d4f54f5..0c557c066f6 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -90,7 +90,7 @@ class Skeleton_class $resql=$this->update($user, 1); if ($resql < 0) { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -2; } @@ -106,7 +106,7 @@ class Skeleton_class } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); dolibarr_syslog("Skeleton_class::create ".$this->error); return -1; } @@ -136,7 +136,7 @@ class Skeleton_class $resql = $this->db->query($sql); if (! $resql) { - $this->error=$this->db->error().' sql='.$sql; + $this->error=$this->db->lasterror().' sql='.$sql; return -1; } @@ -185,7 +185,7 @@ class Skeleton_class } else { - $this->error="Error ".$this->db->error(); + $this->error="Error ".$this->db->lasterror(); dolibarr_syslog("Skeleton_class::fetch ".$this->error); return -1; } @@ -204,10 +204,11 @@ class Skeleton_class $sql = "DELETE FROM ".MAIN_DB_PREFIX."mytable"; $sql.= " WHERE rowid=".$this->id; + dolibarr_syslog("Skeleton_class::delete sql=".$sql); $resql = $this->db->query($sql); if (! $resql) { - $this->error=$this->db->error().' sql='.$sql; + $this->error=$this->db->lasterror().' sql='.$sql; return -1; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c035fd8158c..f6d05865aab 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Éric Seigne - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2007 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -34,6 +34,7 @@ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php"); require_once(DOL_DOCUMENT_ROOT.'/facture.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/discount.class.php'); require_once(DOL_DOCUMENT_ROOT.'/paiement.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); @@ -75,6 +76,7 @@ if ($_GET["projetid"]) $NBLINES=4; + /* * Actions */ @@ -178,9 +180,9 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user-> { $fac = new Facture($db); $fac->fetch($_GET['facid']); - $soc = new Societe($db); - $soc->fetch($fac->socid); - $result = $fac->set_valid($fac->id, $user, $soc); + $fac->fetch_client(); + + $result = $fac->set_valid($fac->id, $user); if ($result >= 0) { if ($_REQUEST['lang_id']) @@ -311,6 +313,29 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes') } } +// Convertir en reduc +if ($_POST['action'] == 'confirm_converttoreduc' && $_POST['confirm'] == 'yes' && $user->rights->facture->creer) +{ + $db->begin(); + + $fac = new Facture($db); + $fac->fetch($_GET['facid']); + $fac->fetch_client(); + + $result=$fac->set_payed($user); + + // TODO A completer + $discount = new DiscountAbsolute($db); + $result=$discount->create($user); + + $langs->load("other"); + $mesg=$langs->trans("FeatureNotYetAvailable"); + + $db->rollback(); +} + + + /* * Insertion facture */ @@ -620,8 +645,7 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && { $fac = new Facture($db); $ret=$fac->fetch($_POST['facid']); - $soc = new Societe($db); - $ret=$soc->fetch($fac->socid); + $ret=$fac->fetch_client(); $date_start=''; $date_end=''; @@ -666,9 +690,9 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && // multiprix if ($conf->global->PRODUIT_MULTIPRICES == 1) { - $pu = $prod->multiprices[$soc->price_level]; - $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; - $price_base_type = $prod->multiprices_base_type[$soc->price_level]; + $pu = $prod->multiprices[$fac->client->price_level]; + $pu_ttc = $prod->multiprices_ttc[$fac->client->price_level]; + $price_base_type = $prod->multiprices_base_type[$fac->client->price_level]; } else { @@ -685,7 +709,7 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && $desc = $prod->description; } - $tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx); + $tva_tx = get_default_tva($mysoc,$fac->client,$prod->tva_tx); } else { @@ -1057,11 +1081,12 @@ if ($_GET['action'] == 'create') { $propal = New Propal($db); $propal->fetch($_GET['propalid']); - $societe_id = $propal->socid; + $propal->fetch_client(); + $projetid=$propal->projetidp; $ref_client=$propal->ref_client; - $soc->fetch($societe_id); + $soc=$propal->client; $cond_reglement_id = $propal->cond_reglement_id; $mode_reglement_id = $propal->mode_reglement_id; $remise_percent = $propal->remise_percent; @@ -1071,11 +1096,12 @@ if ($_GET['action'] == 'create') { $commande = New Commande($db); $commande->fetch($_GET['commandeid']); - $societe_id = $commande->socid; - $projetid=$commande-> projet_id; + $commande->fetch_client(); + + $projetid=$commande->projet_id; $ref_client=$commande->ref_client; - $soc->fetch($societe_id); + $soc=$commande->client; $cond_reglement_id = $commande->cond_reglement_id; $mode_reglement_id = $commande->mode_reglement_id; $remise_percent = $commande->remise_percent; @@ -1085,10 +1111,11 @@ if ($_GET['action'] == 'create') { $contrat = New Contrat($db); $contrat->fetch($_GET['contratid']); - $societe_id = $contrat->societe->id; + $contrat->fetch_client(); + $projetid=$contrat->fk_projet; - $soc=$contrat->societe; + $soc=$contrat->client; $cond_reglement_id = $soc->cond_reglement; $mode_reglement_id = $soc->mod_reglement; $remise_percent = $soc->remise_client; @@ -1096,9 +1123,7 @@ if ($_GET['action'] == 'create') } else { - $societe_id=$socid; - - $soc->fetch($societe_id); + $soc->fetch($socid); $cond_reglement_id = $soc->cond_reglement; $mode_reglement_id = $soc->mode_reglement; $remise_percent = $soc->remise_client; @@ -1290,7 +1315,7 @@ if ($_GET['action'] == 'create') { $langs->load('projects'); print ''.$langs->trans('Project').''; - $html->select_projects($societe_id, $projetid, 'projetid'); + $html->select_projects($soc->id, $projetid, 'projetid'); print ''; } @@ -1633,8 +1658,18 @@ else dolibarr_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer')); /* - * Confirmation de la suppression de la facture - */ + * Confirmation de la conversion de l'avoir en reduc + */ + if ($_GET['action'] == 'converttoreduc') + { + $text=$langs->trans('ConfirmConvertToReduc'); + $html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$fac->id,$langs->trans('ConvertToReduc'),$text,'confirm_converttoreduc'); + print '
'; + } + + /* + * Confirmation de la suppression de la facture + */ if ($_GET['action'] == 'delete') { $text=$langs->trans('ConfirmDeleteBill'); @@ -1643,8 +1678,8 @@ else } /* - * Confirmation de la validation - */ + * Confirmation de la validation + */ if ($_GET['action'] == 'valid') { // on vérifie si la facture est en numérotation provisoire @@ -1898,12 +1933,16 @@ else $i = 0; print ''; + // Liste des paiements ou remboursements + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($fac->type != 2) { - // Liste des paiements - print ''; - print ''; - $var=True; while ($i < $num) { @@ -2364,7 +2403,7 @@ else $html->select_tva('tva_tx',$conf->defaulttx,$mysoc,$soc); print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -2398,7 +2437,7 @@ else if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -2513,13 +2552,19 @@ else } } - // Emettre remboursement -/* Pas encore géré - if ($fac->type == 2 && $fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement) + // Emettre remboursement ou Convertir en reduc + if ($fac->type == 2) { - print ''.$langs->trans('DoPaymentBack').''; + if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement) + { + print ''.$langs->trans('DoPaymentBack').''; + } + + if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->creer && $fac->getSommePaiement() == 0) + { + print ''.$langs->trans('ConvertToReduc').''; + } } -*/ // Classer 'payé' if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement && @@ -2545,8 +2590,6 @@ else else { print ''.$langs->trans('ClassifyCanceled').''; - // \todo - // Ajouter bouton "Annuler et Créer facture remplacement" } } } diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 0ba7812a41e..53bdcfdb913 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2007 Franky Van Liedekerke * @@ -241,7 +241,14 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P if ($facture->type == 2) $title.=$langs->trans("EnterPaymentDueToCustomer"); print_fiche_titre($title); - + // Bouchon + if ($facture->type == 2) + { + print $langs->trans("FeatureNotYetAvailable"); + llxFooter(); + exit; + } + // Initialise donnees pour page de confirmation if ($_POST["action"] == 'add_paiement') { diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index c30d3c07798..bbb7f5ee5ef 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -303,7 +303,7 @@ class Contrat extends CommonObject $this->fk_projet = $result["fk_projet"]; $this->socid = $result["fk_soc"]; - $this->societe->fetch($result["fk_soc"]); + $this->societe->fetch($result["fk_soc"]); // TODO A virer car la societe doit etre chargé par appel de fetch_client() $this->db->free($resql); diff --git a/htdocs/discount.class.php b/htdocs/discount.class.php index f8cf2707486..174820ecd53 100644 --- a/htdocs/discount.class.php +++ b/htdocs/discount.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -61,7 +61,8 @@ class DiscountAbsolute $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; $sql.= " WHERE rowid=".$rowid; - $resql = $this->db->query($sql); + dolibarr_syslog("DiscountAbsolute::fetch sql=".$sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -92,6 +93,62 @@ class DiscountAbsolute } } + + /** + * \brief Create in database + * \param user User that create + * \return int <0 si ko, >0 si ok + */ + function create($user) + { + global $conf, $langs; + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except "; + $sql .= " (datec, fk_soc, amount_ht, fk_user, description)"; + $sql .= " VALUES (now(),".$this->fk_soc.",'".$this->amount_ht."',".$user->id.",'".addslashes($this->desc)."')"; + + dolibarr_syslog("DiscountAbsolute::create sql=".$sql); + $resql=$this->db->query($sql); + if ($resql) + { + $rowid=$this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except"); + return $rowid; + } + else + { + $this->error=$this->db->lasterror(); + dolibarr_syslog("Skeleton_class::create ".$this->error); + return -1; + } + } + + + /* + * \brief Delete object in database + * \return int <0 if KO, >0 if OK + */ + function delete() + { + global $conf, $langs; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; + $sql.= " WHERE rowid = ".$this->id." AND fk_facture IS NULL"; + + dolibarr_syslog("DiscountAbsolute::delete sql=".$sql); + if (! $this->db->query($sql)) + { + $this->error=$this->db->lasterror().' sql='.$sql; + return -1; + } + else + { + return 1; + } + } + + + /** * \brief Link the discount to a particular invoice * \param rowid Invoice id diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 05c8d2b41b7..5e55a49052c 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -980,14 +980,14 @@ class Facture extends CommonObject } /** - * \brief Tag la facture comme validée + appel trigger BILL_VALIDATE - * \param rowid Id de la facture à valider - * \param user Utilisateur qui valide la facture - * \param soc Objet societe - * \param force_number Référence à forcer de la facture + * \brief Tag la facture comme validée + appel trigger BILL_VALIDATE + * \param rowid Id de la facture à valider + * \param user Utilisateur qui valide la facture + * \param soc Ne sert plus \\TODO A virer + * \param force_number Référence à forcer de la facture * \return int <0 si ko, >0 si ok */ - function set_valid($rowid, $user, $soc, $force_number='') + function set_valid($rowid, $user, $soc='', $force_number='') { global $conf,$langs; @@ -996,6 +996,8 @@ class Facture extends CommonObject { $this->db->begin(); + $this->fetch_client(); + // Verification paramètres if ($this->type == 1) // si facture de remplacement { @@ -1046,8 +1048,8 @@ class Facture extends CommonObject $numfa = $force_number; } else if ($facref == 'PROV') - { - $numfa = $this->getNextNumRef($soc); + { + $numfa = $this->getNextNumRef($this->client); } else { @@ -1200,9 +1202,7 @@ class Facture extends CommonObject if (! $error) { // Classe la société rattachée comme client - $soc=new Societe($this->db); - $soc->id = $this->socid; - $result=$soc->set_as_client(); + $result=$this->client->set_as_client(); $this->ref = $numfa; @@ -1357,6 +1357,13 @@ class Facture extends CommonObject $pu = price2num($pu); $txtva=price2num($txtva); + // Si facture de type avoir, le montant est forcé négatif + if ($this->type == 2) + { +// $pu=-abs($pu); +// $txtva=-abs($txtva); + } + // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker diff --git a/htdocs/fourn/fiche-stats.php b/htdocs/fourn/fiche-stats.php index 0555145fe1e..6fbd4dcdcc5 100644 --- a/htdocs/fourn/fiche-stats.php +++ b/htdocs/fourn/fiche-stats.php @@ -100,7 +100,7 @@ if ( $societe->fetch($socid) ) print "
'.($fac->type == 2 ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).''.$langs->trans('Type').''.$langs->trans('Amount').' 
'.$langs->trans('Payments').''.$langs->trans('Type').''.$langs->trans('Amount').' 
%
 %

"; - print ''; + print '
'; print '
'; $file = get_exdir($societe->id, 3) . "ca_genere-".$societe->id.".png"; diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index fe8552ecd8f..562a6b91e7f 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -651,7 +651,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_ht + $object->remise)), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); // Remise globale if ($object->remise > 0) @@ -666,7 +666,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("WithDiscountTotalHT"), 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * 2); - $pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_ht)), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht), 0, 'R', 1); $index = 2; } @@ -690,7 +690,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT").' '.abs($tvakey).'%'.$tvacompl, 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price(abs($tvaval)), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); } } if (! $this->atleastoneratenotnull) @@ -700,7 +700,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_tva)), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); } $useborder=0; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 202b7ec46a5..4ca2e1538cb 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -13,10 +13,10 @@ InvoiceStandardAsk=Standard invoice InvoiceStandardDesc=This kind of invoice is the common invoice. InvoiceReplacement=Replacement invoice. Must replace invoice with reference InvoiceReplacementAsk=Replacement invoice for invoice -InvoiceReplacementDesc=Replacement invoice is used to cancel and replace completely an invoice with no paiement already recevided.
Reference of canceled invoice is required. +InvoiceReplacementDesc=Replacement invoice is used to cancel and replace completely an invoice with no paiement already received.

Note: Only invoice with payment on it can be replaced. If not closed, it will be automatically closed to 'abandonned'. InvoiceAvoir=Credit note InvoiceAvoirAsk=Credit note to correct invoice -InvoiceAvoirDesc=The credit note is a negative invoice used to solve fact that an invoice has an higher amount that should be (all possible reasons) or a product returned after invoice was payed. +InvoiceAvoirDesc=The credit note is a negative invoice used to solve fact that an invoice has an amount that differs than amount really payed (because customer payed too much by error, or will not payed completely since he returned some products for example).

Note: Original invoice must already be closed ('payed' or 'payed partially') to allow creation of a credit note on it. ReplaceInvoice=Replace invoice %s ReplacementInvoice=Replacement invoice ReplacedByInvoice=Replaced by invoice %s @@ -40,9 +40,12 @@ SupplierBill=Supplier invoice SupplierBills=suppliers invoices BillContacts=Invoice contacts Payment=Payment +PaymentBack=Payment back Payments=Payments +PaymentsBack=Payments back DeletePayment=Delete payment ConfirmDeletePayment=Are you sure you want to delete this payment ? +ConfirmConvertToReduc=Do you want to convert this credit note into absolute discount ?
The amount of this credit note will so be saved among all discounts and could be used as a discount for a future invoice for this customer. ReceivedPayments=Received payments ReceivedCustomersPayments=Payments received from customers ReceivedCustomersPaymentsToValid=Received customers payments to validate @@ -60,7 +63,7 @@ ClassifyPayedPartially=Classify 'Payed partially' ClassifyCanceled=Classify 'Abandonned' ClassifyClosed=Classify 'Closed' CreateBill=Create Invoice -AddBill=Add invoice +AddBill=Add invoice or credit note DeleteBill=Delete invoice SearchABill=Search an invoice CancelBill=Cancel an invoice @@ -68,6 +71,7 @@ SendByMail=EMail SendRemindByMail=EMail reminder DoPayment=Do payment DoPaymentBack=Do payment back +ConvertToReduc=Convert into future discount EnterPaymentReceivedFromCustomer=Enter payment received from customer EnterPaymentDueToCustomer=Make payment due to customer VAT=VAT @@ -126,13 +130,13 @@ 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 ConfirmClassifyPayedPartiallyReasonProductReturned=Products partially returned -ConfirmClassifyPayedPartiallyReasonOther=Debit irremediably not recoverable (other reason) +ConfirmClassifyPayedPartiallyReasonOther=Amount abandonned for other reason 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 -ConfirmClassifyPayedPartiallyReasonProductReturnedDesc=This choice is used when apyment is not complete because some of products were returned -ConfirmClassifyPayedPartiallyReasonOtherDesc=Use this choice if all other does not suit +ConfirmClassifyPayedPartiallyReasonBadCustomerDesc=A bad customers is a customer that refuse to pay his debt. +ConfirmClassifyPayedPartiallyReasonProductReturnedDesc=This choice is used when payment is not complete because some of products were returned +ConfirmClassifyPayedPartiallyReasonOtherDesc=Use this choice if all other does not suit, for example in following situation:
- payment not complete because some products were shipped back
- amount claimed too important because a discount was forgotten
In all cases, amount over-claimed must be corrected in accountancy system by creating a credit note. ConfirmCustomerPayment=Do you confirm this paiement input for %s %s ? ValidateBill=Validate invoice NumberOfBills=Nb of invoices @@ -204,7 +208,7 @@ DiscountAlreadyCounted=Discount already counted BillAddress=Bill address HelpEscompte=This discount is a discount granted to customer because its paiement was made before term. HelpAbandonBadCustomer=This amount has been abandoned (customer said to be a bad customer) and is considered as an exceptionnal loose. -HelpAbandonOther=This amount has been abandoned and is considered as an exceptionnal loose. +HelpAbandonOther=This amount has been abandoned since it was an error. It must be corrected in accountancy system by creating a credit note. # PaymentConditions PaymentConditionShortRECEP=Immediate PaymentConditionRECEP=Immediate diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index c3bac9acf00..2d74ccdcbfa 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -13,10 +13,10 @@ InvoiceStandardAsk=Facture standard InvoiceStandardDesc=Ce type de facture est la facture traditionnelle. On l'appelle aussi facture de doit (du verbe devoir). InvoiceReplacement=Facture de remplacement InvoiceReplacementAsk=Facture de remplacement de la facture -InvoiceReplacementDesc=La facture de remplacement sert à annuler et remplacer une facture existante sur laquelle aucun paiement n'a encore eu lieu.
La référence de la facture qui doit être annulée est obligatoire. +InvoiceReplacementDesc=La facture de remplacement sert à annuler et remplacer une facture existante sur laquelle aucun paiement n'a encore eu lieu.

Rem: Seule une facture sans aucun paiement peut être remplacée. Si cette dernière n'est pas fermée, elle le sera automatiquement au statut 'abandonnée'. InvoiceAvoir=Facture avoir InvoiceAvoirAsk=Facture avoir pour correction de la facture -InvoiceAvoirDesc=La facture d'avoir est une facture négative destinée à compenser une facture comportant un montant supérieur à ce qui aurait du (toutes causes possibles) ou parce qu'un produit a été retourné après que la facture soit payée. +InvoiceAvoirDesc=La facture d'avoir est une facture négative destinée à compenser un montant de facture qui diffère du montant réellement versé (suite à une trop versé par le client par erreur ou un manque non versé par le client suite à une retour produit par exemple).

Rem: Notons que la facture originale à corriger doit avoir fermé ('payée' ou 'payée partiellement') pour pouvoir faire l'avoir. ReplaceInvoice=Remplace la facture %s ReplacementInvoice=Remplacement facture ReplacedByInvoice=Remplacée par la facture %s @@ -40,9 +40,12 @@ SupplierBill=Facture fournisseur SupplierBills=Factures fournisseurs BillContacts=Contacts facture Payment=Réglement +PaymentBack=Remboursement Payments=Réglements +PaymentsBack=Remboursements DeletePayment=Supprimer le paiement ConfirmDeletePayment=Etes vous sur de vouloir supprimer ce paiement ? +ConfirmConvertToReduc=Voulez-vous convertir cet avoir en réduction future ?
Le montant de cet avoir sera alors stocké en réduction fixe en attente pour le client. Cette dernière pourra être utilisée pour réduire le montant d'une prochaine facture de ce client. ReceivedPayments=Réglements reçus ReceivedCustomersPayments=Réglements reçus du client ReceivedCustomersPaymentsToValid=Réglements clients reçus à valider @@ -60,7 +63,7 @@ ClassifyPayedPartially=Classer 'Pay ClassifyCanceled=Classer 'Abandonnée' ClassifyClosed=Classer 'Fermée' CreateBill=Créer Facture -AddBill=Créer facture +AddBill=Créer facture ou avoir DeleteBill=Supprimer facture SearchABill=Rechercher une facture CancelBill=Annuler une facture @@ -68,6 +71,7 @@ SendByMail=Envoyer SendRemindByMail=Envoyer rappel DoPayment=Émettre réglement DoPaymentBack=Émettre remboursement +ConvertToReduc=Convertir en réduction future EnterPaymentReceivedFromCustomer=Saisie d'un réglement reçu du client EnterPaymentDueToCustomer=Réaliser réglement d'avoirs dus au client VAT=TVA @@ -126,13 +130,13 @@ ConfirmClassifyPayedPartiallyReasonDiscountNoVat=Le reste ConfirmClassifyPayedPartiallyReasonDiscountVat=Le reste à payer (%s %s) est un escompte ConfirmClassifyPayedPartiallyReasonBadCustomer=Mauvais payeur ConfirmClassifyPayedPartiallyReasonProductReturned=Produits en partie retournés -ConfirmClassifyPayedPartiallyReasonOther=Créance définitivement abandonnée (tout autre cas) +ConfirmClassifyPayedPartiallyReasonOther=Créance abandonnée pour autre raison 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 +ConfirmClassifyPayedPartiallyReasonBadCustomerDesc=Un mauvais payeur est un client qui refuse de régler sa dète. ConfirmClassifyPayedPartiallyReasonProductReturnedDesc=Ce choix sera celui dans le cas paiement incomplet suite à retour d'une partie des produits -ConfirmClassifyPayedPartiallyReasonOtherDesc=Ce choix sera celui dans tout autre cas.
Par exemple, dans le cas d'un paiement partiel car une partie des produits a été retourné. +ConfirmClassifyPayedPartiallyReasonOtherDesc=Ce choix sera celui dans tout autre cas, par exemple, dans les cas suivant:
- paiement partiel car une partie des produits a été retourné.
- trop réclamé suite à oubli d'une remise
Dans tous les cas, le trop réclamé doit etre régularisé en compta et envers le client par un avoir. 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 ? @@ -206,7 +210,7 @@ DiscountAlreadyCounted=Remises fixes d BillAddress=Adresse de facturation HelpEscompte=Un escompte est une remise accordée, sur une facture donnée, à un client car ce dernier a réalisé son réglement bien avant l'échéance. HelpAbandonBadCustomer=Ce montant a été abandonné (client jugé mauvais payeur) et est considéré comme un perte exceptionnelle. -HelpAbandonOther=Ce montant a été abandonné et est considéré comme un perte exceptionnelle. +HelpAbandonOther=Ce montant a été abandonné car il s'agissait d'un trop réclamé (oubli de remise ou retour produit du client). Il doit être régularisé en compta par la saisie d'un avoir. # PaymentConditions PaymentConditionShortRECEP=A réception PaymentConditionRECEP=A réception de facture diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 78d06eac387..22c3832d610 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2003 Brian Fraval * Copyright (C) 2006 Andre Cianfarani @@ -30,6 +30,8 @@ \version $Revision$ */ +require_once(DOL_DOCUMENT_ROOT.'/discount.class.php'); + /** \class Societe @@ -961,20 +963,19 @@ class Societe if ($this->id) { - $remise = price2num($remise); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except "; - $sql .= " (datec, fk_soc, amount_ht, fk_user, description)"; - $sql .= " VALUES (now(),".$this->id.",'".$remise."',".$user->id.",'".addslashes($desc)."')"; - - if (! $this->db->query($sql) ) + $discount = new DiscountAbsolute($this->db); + $discount->fk_soc=$this->id; + $discount->amount_ht=$remise; + $discount->desc=$desc; + $result=$discount->create($user); + if ($result > 0) { - $this->error=$this->db->lasterror(); - return -3; + return $result; } else { - return $this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except"); + $this->error=$discount->error; + return -3; } } else return 0; @@ -989,18 +990,10 @@ class Societe { if ($this->id) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; - $sql.= " WHERE rowid = ".$id." AND fk_facture IS NULL"; - - if (! $this->db->query($sql)) - { - $this->error=$this->db->lasterror(); - return -1; - } - else - { - return 1; - } + $discount = new DiscountAbsolute($this->db); + $discount->fetch($id); + $result=$discount->delete(); + return $result; } else return 0; } diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index 107a4b409f1..86e64ce71a2 100644 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -26,7 +26,7 @@ \brief Script de mise a jour des contacts dans LDAP depuis base Dolibarr */ -// Test si mode batch +// Test si mode CLI $sapi_type = php_sapi_name(); $script_file=__FILE__; if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1];