From 14ab058f34147859f1935ac51ee06bd28f680f98 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 16 Sep 2014 21:05:57 +0200 Subject: [PATCH 1/4] Add Dunning into compta report --- ChangeLog | 1 + htdocs/compta/dons/class/don.class.php | 22 +++-- htdocs/compta/resultat/clientfourn.php | 124 +++++++++++++++++++++++++ htdocs/compta/resultat/index.php | 79 ++++++++++++++++ htdocs/langs/en_US/donations.lang | 1 + htdocs/langs/fr_FR/donations.lang | 3 +- 6 files changed, 220 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6cecbc2b752..fb593d3722c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -58,6 +58,7 @@ For users: - New: [ task #1204 ] add a External reference to contract - New: [ task #1204 ] add Numering contrat module free (like leopard in product module) - New: Enable supplier price log table +- New: Add dunning into compta Report For translators: - Update language files. diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php index 7751a1138c8..993eda5a0f7 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 * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2009 Regis Houssin - * Copyright (C) 2013 Florian Henry + * Copyright (C) 2014 Florian Henry * * 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 5dcd09814ad..3d72b15804b 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -3,6 +3,8 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Florian Henry * * 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 @@ -32,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'); @@ -538,6 +542,126 @@ if ($mysoc->tva_assuj == 'franchise') // Non assujeti print ''; } +/* + * Salaries + */ + +print ''.$langs->trans("Salaries").''; +$sql = "SELECT p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount, u.firstname, u.lastname, p.fk_user"; +$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; +$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; +$sql.= " WHERE p.entity = ".$conf->entity; +if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + +$sql.= " GROUP BY u.rowid"; +$sql.= " ORDER BY u.firstname"; + +dol_syslog("get payment salaries"); +$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 " "; + + print "".$langs->trans("Salaries")." fk_user."\">".$obj->firstname." ".$obj->lastname."\n"; + + if ($modecompta == 'CREANCES-DETTES') print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount).''; + print ''; + $i++; + } + } + else + { + $var = !$var; + print " "; + print ''.$langs->trans("None").''; + print ''; + } +} +else +{ + dol_print_error($db); +} +/* + * Dunning +*/ + +print ''.$langs->trans("Donation").''; +$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 " "; + + print "".$langs->trans("Donation")." nom."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->nom. " ".$obj->firstname." ".$obj->lastname."\n"; + + if ($modecompta == 'CREANCES-DETTES') print ''.price($obj->amount).''; + print ''.price($obj->amount).''; + print ''; + $i++; + } + } + else + { + $var = !$var; + print " "; + print ''.$langs->trans("None").''; + print ''; + } +} +else +{ + dol_print_error($db); +} +print ''; +if ($modecompta == 'CREANCES-DETTES') + print ''.price(-$subtotal_ht).''; +print ''.price(-$subtotal_ttc).''; +print ''; /* * VAT diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index c61c8b76e08..17b408af1d6 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -3,6 +3,8 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Florian Henry * * 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 @@ -469,6 +471,83 @@ $parameters["mode"] = $modecompta; $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +/* + * Salaries + */ +$subtotal_ht = 0; +$subtotal_ttc = 0; +$sql = "SELECT p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; +$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"); +$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($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; + $decaiss_ttc[$obj->dm] += $obj->amount; + + $i++; + } + } +} +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($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; + $decaiss[$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 728661dfa04..66ddea95a5c 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 9af7a87a12d..2da59454571 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 From 32c777a78bc1a639c1ebef8f0fcc9e41afe348c7 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 16 Sep 2014 21:17:22 +0200 Subject: [PATCH 2/4] Fix bad merge --- htdocs/compta/resultat/clientfourn.php | 4 ++-- htdocs/compta/resultat/index.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 7892704a41c..da30c04d53d 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -547,14 +547,14 @@ if ($mysoc->tva_assuj == 'franchise') // Non assujeti */ print ''.$langs->trans("Salaries").''; -$sql = "SELECT p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount, u.firstname, u.lastname, p.fk_user"; +$sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; $sql.= " WHERE p.entity = ".$conf->entity; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; -$sql.= " GROUP BY u.rowid"; +$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"); diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 17b408af1d6..05c3a93e011 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -494,8 +494,8 @@ if ($result) { $obj = $db->fetch_object($result); - if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0; - $encaiss[$obj->dm] += $obj->amount; + if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; + $decaiss[$obj->dm] += $obj->amount; if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; $decaiss_ttc[$obj->dm] += $obj->amount; @@ -533,8 +533,8 @@ if ($result) { $obj = $db->fetch_object($result); - if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; - $decaiss[$obj->dm] += $obj->amount; + 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; From fc65421b2eda7dea72004ae0d87d0ed2f4f1c99f Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 16 Sep 2014 21:19:07 +0200 Subject: [PATCH 3/4] bad merge --- htdocs/compta/resultat/clientfourn.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index da30c04d53d..1d8a05984e3 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -542,11 +542,12 @@ if ($mysoc->tva_assuj == 'franchise') // Non assujeti print ''; } + /* * Salaries */ -print ''.$langs->trans("Salaries").''; +print ''.$langs->trans("Salaries").''; $sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; @@ -556,7 +557,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"); $result=$db->query($sql); $subtotal_ht = 0; @@ -579,9 +580,9 @@ if ($result) $var = !$var; print " "; - + print "".$langs->trans("Salaries")." fk_user."\">".$obj->firstname." ".$obj->lastname."\n"; - + if ($modecompta == 'CREANCES-DETTES') print ''.price(-$obj->amount).''; print ''.price(-$obj->amount).''; print ''; From 15d680ea4b64c035c9853a8560aea1c4abaa6bc4 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 16 Sep 2014 21:19:52 +0200 Subject: [PATCH 4/4] bad mege --- htdocs/compta/resultat/clientfourn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 1d8a05984e3..d55930ef80f 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -554,7 +554,7 @@ $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; $sql.= " WHERE p.entity = ".$conf->entity; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; - + $sql.= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm"; $sql.= " ORDER BY u.firstname";