diff --git a/ChangeLog b/ChangeLog index 49fb3fcfa68361716a871f31f618a38120adf827..c06468f36298ed49bb1e1bb7f9c643a9f19fa9dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -73,6 +73,7 @@ For users: - Fix: [ bug #1506, #1507 ] ECM trigger error problem - Fix: [ bug #1469 ] Triggers CONTACT_MODIFY and CONTACT_DELETE duplicates error message - Fix: [ bug #1537 ] Difference between societe.nom and adherent.societe. +- New: Add dunning into accountancy report New experimental module: - New: Module Accounting Expert to manage accountancy diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php index 7751a1138c8604adc93a0bc4eb2fc7138b4e07a8..993eda5a0f7685bc369b12528cc1d6cd35012ff9 100644 --- a/htdocs/compta/dons/class/don.class.php +++ b/htdocs/compta/dons/class/don.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2009 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> + * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * * 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 @@ -209,38 +209,42 @@ class Don extends CommonObject */ function check($minimum=0) { + global $langs; + $langs->load('main'); + $langs->load('companies'); + $err = 0; if (dol_strlen(trim($this->societe)) == 0) { if ((dol_strlen(trim($this->lastname)) + dol_strlen(trim($this->firstname))) == 0) { - $error_string[$err] = "Vous devez saisir vos nom et prenom ou le nom de votre societe."; + $error_string[$err] = $langs->trans('ErrorFieldRequired',$langs->trans('Company').'/'.$langs->trans('Firstname').'-'.$langs->trans('Lastname')); $err++; } } if (dol_strlen(trim($this->address)) == 0) { - $error_string[$err] = "L'adresse saisie est invalide"; + $error_string[$err] = $langs->trans('ErrorFieldRequired',$langs->trans('Address')); $err++; } if (dol_strlen(trim($this->zip)) == 0) { - $error_string[$err] = "Le code postal saisi est invalide"; + $error_string[$err] = $langs->trans('ErrorFieldRequired',$langs->trans('Zip')); $err++; } if (dol_strlen(trim($this->town)) == 0) { - $error_string[$err] = "La ville saisie est invalide"; + $error_string[$err] = $langs->trans('ErrorFieldRequired',$langs->trans('Town')); $err++; } if (dol_strlen(trim($this->email)) == 0) { - $error_string[$err] = "L'email saisi est invalide"; + $error_string[$err] = $langs->trans('ErrorFieldRequired',$langs->trans('EMail')); $err++; } @@ -252,7 +256,7 @@ class Don extends CommonObject { if (!isset($map[substr($this->amount, $i, 1)] )) { - $error_string[$err] = "Le montant du don contient un/des caractere(s) invalide(s)"; + $error_string[$err] = $langs->trans('ErrorFieldRequired',$langs->trans('Amount')); $err++; $amount_invalid = 1; break; @@ -263,14 +267,14 @@ class Don extends CommonObject { if ($this->amount == 0) { - $error_string[$err] = "Le montant du don est null"; + $error_string[$err] = $langs->trans('ErrorFieldRequired',$langs->trans('Amount')); $err++; } else { if ($this->amount < $minimum && $minimum > 0) { - $error_string[$err] = "Le montant minimum du don est de $minimum"; + $error_string[$err] = $langs->trans('MinimumAmount',$langs->trans('$minimum')); $err++; } } diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 97e2db221c38c72253d46b7583febc420de02be1..d55930ef80ff443af94e6893affe60232ab57a8b 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * * 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 @@ -33,6 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("bills"); +$langs->load("donation"); +$langs->load("salaries"); $date_startmonth=GETPOST('date_startmonth'); $date_startday=GETPOST('date_startday'); @@ -555,7 +558,7 @@ if (! empty($date_start) && ! empty($date_end)) $sql.= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm"; $sql.= " ORDER BY u.firstname"; -dol_syslog("get payment salaries sql=".$sql); +dol_syslog("get payment salaries"); $result=$db->query($sql); $subtotal_ht = 0; $subtotal_ttc = 0; @@ -598,6 +601,64 @@ else { dol_print_error($db); } + +/* + * Dunning +*/ + +print '<tr><td colspan="4">'.$langs->trans("Donation").'</td></tr>'; +$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount"; +$sql.= " FROM ".MAIN_DB_PREFIX."don as p"; +$sql.= " WHERE p.entity = ".$conf->entity; +$sql.= " AND fk_statut=2"; +if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'"; +$sql.= " GROUP BY p.societe, p.firstname, p.lastname"; +$sql.= " ORDER BY p.societe, p.firstname, p.lastname"; + +dol_syslog("get dunning"); +$result=$db->query($sql); +$subtotal_ht = 0; +$subtotal_ttc = 0; +if ($result) +{ + $num = $db->num_rows($result); + $var=true; + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total_ht += $obj->amount; + $total_ttc += $obj->amount; + $subtotal_ht -= $obj->amount; + $subtotal_ttc -= $obj->amount; + + $var = !$var; + print "<tr ".$bc[$var]."><td> </td>"; + + print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/compta/dons/liste.php?search_company=".$obj->nom."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->nom. " ".$obj->firstname." ".$obj->lastname."</a></td>\n"; + + if ($modecompta == 'CREANCES-DETTES') print '<td align="right">'.price($obj->amount).'</td>'; + print '<td align="right">'.price($obj->amount).'</td>'; + print '</tr>'; + $i++; + } + } + else + { + $var = !$var; + print "<tr ".$bc[$var]."><td> </td>"; + print '<td colspan="3">'.$langs->trans("None").'</td>'; + print '</tr>'; + } +} +else +{ + dol_print_error($db); +} print '<tr class="liste_total">'; if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>'; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 74224c024b027af0661dc5e439b03d3df178aebf..05c3a93e0117e8066abeed9eab69ba07cee26d21 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * * 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 @@ -480,7 +481,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql.= " WHERE p.entity = ".$conf->entity; $sql.= " GROUP BY p.label, dm"; -dol_syslog("get social salaries payments sql=".$sql); +dol_syslog("get social salaries payments"); $result=$db->query($sql); if ($result) { @@ -508,6 +509,45 @@ else dol_print_error($db); } +/* + * get dunning paiement +*/ +$subtotal_ht = 0; +$subtotal_ttc = 0; +$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount"; +$sql.= " FROM ".MAIN_DB_PREFIX."don as p"; +$sql.= " WHERE p.entity = ".$conf->entity; +$sql.= " AND fk_statut=2"; +$sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm"; + +dol_syslog("get social salaries payments"); +$result=$db->query($sql); +if ($result) +{ + $num = $db->num_rows($result); + $var=false; + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + + if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0; + $encaiss[$obj->dm] += $obj->amount; + + if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0; + $encaiss_ttc[$obj->dm] += $obj->amount; + + $i++; + } + } +} +else +{ + dol_print_error($db); +} + /* * Show result array */ diff --git a/htdocs/langs/en_US/donations.lang b/htdocs/langs/en_US/donations.lang index 728661dfa0443f33597e8258c0adb2a25d30eedc..66ddea95a5c694d8044c40b7da05319d0b77a530 100644 --- a/htdocs/langs/en_US/donations.lang +++ b/htdocs/langs/en_US/donations.lang @@ -30,3 +30,4 @@ SearchADonation=Search a donation DonationRecipient=Donation recipient ThankYou=Thank You IConfirmDonationReception=The recipient declare reception, as a donation, of the following amount +MinimumAmount=Minimum amount is %s diff --git a/htdocs/langs/fr_FR/donations.lang b/htdocs/langs/fr_FR/donations.lang index 9af7a87a12d6d0eebb7940e201a650428a4346ce..2da59454571f352f44adc630850a3877761a83e0 100644 --- a/htdocs/langs/fr_FR/donations.lang +++ b/htdocs/langs/fr_FR/donations.lang @@ -37,4 +37,5 @@ IConfirmDonationReception=Le bénéficiaire reconnait avoir reçu au titre des d FrenchOptions=Options éligibles en France DONATION_ART200=Les dons ou versements reçus sont éligibles à l'article 200 du CGI DONATION_ART238=Les dons ou versements reçus sont éligibles à l'article 238bis du CGI -DONATION_ART885=Les dons ou versements reçus sont éligibles à l'article 885-0 V bis A du CGI \ No newline at end of file +DONATION_ART885=Les dons ou versements reçus sont éligibles à l'article 885-0 V bis A du CGI +MinimumAmount=Le montant minimum du don est de %s \ No newline at end of file