Merge pull request #1896 from FHenry/develop
Add Dunning into accountancy report
This commit is contained in:
commit
2b69358c9c
@ -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
|
||||
|
||||
@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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>';
|
||||
|
||||
@ -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
|
||||
*/
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
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
|
||||
Loading…
Reference in New Issue
Block a user