diff --git a/ChangeLog b/ChangeLog index 06266a52bb4..94926a0c0e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ $Id:$ ***** ChangeLog for 3.1.1 compared to 3.1.0 ***** +- New: Add option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS - Fix: Removed warnings during install diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 2687e318a4e..4711ecf7c60 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1946,10 +1946,16 @@ else if ($object->paye) $resteapayer=0; $resteapayeraffiche=$resteapayer; - //$filterabsolutediscount="fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - //$filtercreditnote="fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - $filterabsolutediscount="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')"; - $filtercreditnote="fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + { + $filterabsolutediscount="fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + $filtercreditnote="fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + } + else + { + $filterabsolutediscount="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')"; + $filtercreditnote="fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'"; + } $absolute_discount=$soc->getAvailableDiscounts('',$filterabsolutediscount); $absolute_creditnote=$soc->getAvailableDiscounts('',$filtercreditnote); diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 999409cfb36..3e81f7e3a16 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -36,8 +36,7 @@ $langs->load("bills"); // Security check $socid = GETPOST("socid"); if ($user->societe_id > 0) $socid = $user->societe_id; -if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire) -accessforbidden(); +if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire) accessforbidden(); // Date range $year=GETPOST("year"); @@ -109,6 +108,8 @@ if ($modecompta=="CREANCES-DETTES") $period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=''.img_previous().' '.img_next().''; $description=$langs->trans("RulesResultDue"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); + else $description.= $langs->trans("DepositsAreIncluded"); $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -137,14 +138,19 @@ print "\n"; */ print ''.$langs->trans("CustomersInvoices").''; -if ($modecompta == 'CREANCES-DETTES') { +if ($modecompta == 'CREANCES-DETTES') +{ $sql = "SELECT s.nom, s.rowid as socid, sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.fk_statut in (1,2)"; + $sql.= " AND f.fk_statut IN (1,2)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; -} else { +} +else +{ /* * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) @@ -274,9 +280,13 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.fk_statut in (1,2)"; + $sql.= " AND f.fk_statut IN (1,2)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; -} else { +} +else +{ $sql = "SELECT s.nom, s.rowid as socid, date_format(p.datep,'%Y-%m') as dm, sum(pf.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p"; $sql.= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf"; @@ -302,8 +312,10 @@ if ($result) { $num = $db->num_rows($result); $i = 0; $var=true; - if ($num > 0) { - while ($i < $num) { + if ($num > 0) + { + while ($i < $num) + { $objp = $db->fetch_object($result); $var=!$var; @@ -321,7 +333,8 @@ if ($result) { $i++; } } - else { + else + { $var=!$var; print " "; print ''.$langs->trans("None").''; @@ -345,7 +358,8 @@ print ''; print ''.$langs->trans("SocialContributions").''; -if ($modecompta == 'CREANCES-DETTES') { +if ($modecompta == 'CREANCES-DETTES') +{ $sql = "SELECT c.libelle as nom, sum(s.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as s"; @@ -353,7 +367,8 @@ if ($modecompta == 'CREANCES-DETTES') { $sql.= " AND c.deductible = 0"; if ($date_start && $date_end) $sql.= " AND s.date_ech >= '".$db->idate($date_start)."' AND s.date_ech <= '".$db->idate($date_end)."'"; } -else { +else +{ $sql = "SELECT c.libelle as nom, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as s"; @@ -413,7 +428,8 @@ print ''; print ''.$langs->trans("SocialContributions").''; -if ($modecompta == 'CREANCES-DETTES') { +if ($modecompta == 'CREANCES-DETTES') +{ $sql = "SELECT c.libelle as nom, sum(s.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as s"; @@ -423,7 +439,8 @@ if ($modecompta == 'CREANCES-DETTES') { $sql.= " AND s.entity = ".$conf->entity; $sql.= " GROUP BY c.libelle DESC"; } -else { +else +{ $sql = "SELECT c.libelle as nom, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as s"; @@ -507,11 +524,13 @@ if ($modecompta == 'CREANCES-DETTES') $amount=0; $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.tva) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.fk_statut in (1,2)"; + $sql.= " WHERE f.fk_statut IN (1,2)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " GROUP BY dm"; - $sql.= " ORDER BY dm DESC"; + $sql.= " ORDER BY dm"; dol_syslog("get vat to pay sql=".$sql); $result=$db->query($sql); @@ -524,9 +543,9 @@ if ($modecompta == 'CREANCES-DETTES') $obj = $db->fetch_object($result); $amount = $amount - $obj->amount; - $total_ht = $total_ht - $obj->amount; + //$total_ht = $total_ht - $obj->amount; $total_ttc = $total_ttc - $obj->amount; - $subtotal_ht = $subtotal_ht - $obj->amount; + //$subtotal_ht = $subtotal_ht - $obj->amount; $subtotal_ttc = $subtotal_ttc - $obj->amount; $i++; } @@ -536,7 +555,7 @@ if ($modecompta == 'CREANCES-DETTES') } print " "; print "".$langs->trans("VATToPay")."\n"; - if ($modecompta == 'CREANCES-DETTES') print "".price($amount)."\n"; + print " \n"; print "".price($amount)."\n"; print "\n"; @@ -544,11 +563,13 @@ if ($modecompta == 'CREANCES-DETTES') $amount=0; $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql.= " WHERE f.fk_statut in (1,2)"; + $sql.= " WHERE f.fk_statut IN (1,2)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " GROUP BY dm"; - $sql.= " ORDER BY dm DESC"; + $sql.= " ORDER BY dm"; dol_syslog("get vat received back sql=".$sql); $result=$db->query($sql); @@ -561,9 +582,9 @@ if ($modecompta == 'CREANCES-DETTES') $obj = $db->fetch_object($result); $amount = $amount + $obj->amount; - $total_ht = $total_ht + $obj->amount; + //$total_ht = $total_ht + $obj->amount; $total_ttc = $total_ttc + $obj->amount; - $subtotal_ht = $subtotal_ht + $obj->amount; + //$subtotal_ht = $subtotal_ht + $obj->amount; $subtotal_ttc = $subtotal_ttc + $obj->amount; $i++; @@ -574,7 +595,7 @@ if ($modecompta == 'CREANCES-DETTES') } print " "; print "".$langs->trans("VATToCollect")."\n"; - if ($modecompta == 'CREANCES-DETTES') print "".price($amount)."\n"; + print " \n"; print "".price($amount)."\n"; print "\n"; } @@ -663,8 +684,8 @@ else if ($mysoc->tva_assuj != 'franchise') // Assujeti { print ''; - if ($modecompta == 'CREANCES-DETTES') print ''.price(price2num($subtotal_ht)).''; - print ''.price(price2num($subtotal_ttc)).''; + if ($modecompta == 'CREANCES-DETTES') print ' '; + print ''.price(price2num($subtotal_ttc,'MT')).''; print ''; } diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 1e7925f7a2b..4fd454dc3e3 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -59,13 +59,15 @@ llxHeader(); $html=new Form($db); // Affiche en-tete du rapport -if ($modecompta=="CREANCES-DETTES") +if ($modecompta == 'CREANCES-DETTES') { $nom=$langs->trans("AnnualSummaryDueDebtMode"); $nom.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period="$year_start - $year_end"; $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesResultDue"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); + else $description.= $langs->trans("DepositsAreIncluded"); $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -86,13 +88,18 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl */ $subtotal_ht = 0; $subtotal_ttc = 0; -if ($modecompta == 'CREANCES-DETTES') { +if ($modecompta == 'CREANCES-DETTES') +{ $sql = "SELECT sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.fk_statut in (1,2)"; -} else { + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; +} +else +{ /* * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) @@ -130,7 +137,8 @@ else { } // On ajoute les paiements clients anciennes version, non lies par paiement_facture -if ($modecompta != 'CREANCES-DETTES') { +if ($modecompta != 'CREANCES-DETTES') +{ $sql = "SELECT sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; @@ -170,11 +178,16 @@ if ($modecompta != 'CREANCES-DETTES') { $subtotal_ht = 0; $subtotal_ttc = 0; -if ($modecompta == 'CREANCES-DETTES') { +if ($modecompta == 'CREANCES-DETTES') +{ $sql = "SELECT sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql.= " WHERE f.fk_statut IN (1,2)"; -} else { + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; +} +else +{ $sql = "SELECT sum(pf.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p"; $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; @@ -213,13 +226,16 @@ else { */ $subtotal_ht = 0; $subtotal_ttc = 0; -if ($modecompta == 'CREANCES-DETTES') { +if ($modecompta == 'CREANCES-DETTES') +{ // TVA a payer $sql = "SELECT sum(f.tva) as amount, date_format(f.datef,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_statut IN (1,2)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; $sql.= " AND f.entity = ".$conf->entity; - $sql.= " GROUP BY dm DESC"; + $sql.= " GROUP BY dm"; dol_syslog("get vat to pay sql=".$sql); $result=$db->query($sql); @@ -244,6 +260,8 @@ if ($modecompta == 'CREANCES-DETTES') { $sql = "SELECT sum(f.total_tva) as amount, date_format(f.datef,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql.= " WHERE f.fk_statut IN (1,2)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " GROUP BY dm"; @@ -327,14 +345,16 @@ else { */ $subtotal_ht = 0; $subtotal_ttc = 0; -if ($modecompta == 'CREANCES-DETTES') { +if ($modecompta == 'CREANCES-DETTES') +{ $sql = "SELECT c.libelle as nom, date_format(s.date_ech,'%Y-%m') as dm, sum(s.amount) as amount_ht, sum(s.amount) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as s"; $sql.= " WHERE s.fk_type = c.id"; $sql.= " AND c.deductible = 0"; } -else { +else +{ $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount_ht, sum(p.amount) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as s"; @@ -502,7 +522,8 @@ print ''.$langs->trans("Profit").''; for ($annee = $year_start ; $annee <= $year_end ; $annee++) { print ' '; - if (isset($totentrees[$annee]) || isset($totsorties[$annee])) { + if (isset($totentrees[$annee]) || isset($totsorties[$annee])) + { print price($totentrees[$annee]-$totsorties[$annee]).''; // print ' '; } @@ -511,8 +532,8 @@ print "\n"; print ""; -$db->close(); llxFooter('$Date: 2011/08/03 00:46:31 $ - $Revision: 1.49 $'); +$db->close(); ?> diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index af711fe9af8..3207b931ea0 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -110,6 +110,8 @@ if ($modecompta=="CREANCES-DETTES") $period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink="".img_previous()." ".img_next().""; $description=$langs->trans("RulesCADue"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); + else $description.= $langs->trans("DepositsAreIncluded"); $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -119,6 +121,7 @@ else { $period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink="".img_previous()." ".img_next().""; $description=$langs->trans("RulesCAIn"); + $description.= $langs->trans("DepositsAreIncluded"); $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -135,13 +138,9 @@ if ($modecompta == 'CREANCES-DETTES') $sql = "SELECT u.rowid as rowid, u.name as name, u.firstname as firstname, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.fk_user_author = u.rowid"; - $sql.= " WHERE f.fk_statut in (1,2) "; - $sql.= " AND ("; - $sql.= " f.type = 0"; // Standard - $sql.= " OR f.type = 1"; // Replacement - $sql.= " OR f.type = 2"; // Credit note - $sql.= " OR f.type = 3"; // Deposit - $sql.= ")"; + $sql.= " WHERE f.fk_statut in (1,2)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } else @@ -303,7 +302,8 @@ if (sizeof($amount)) print ""; -$db->close(); -llxFooter('$Date: 2011/07/31 22:23:13 $ - $Revision: 1.41 $'); +llxFooter(); + +$db->close(); ?> diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index d1e9507bc57..4d916425b39 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -43,8 +43,7 @@ if (! $sortfield) $sortfield="nom"; // Security check $socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:''; if ($user->societe_id > 0) $socid = $user->societe_id; -if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire) -accessforbidden(); +if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire) accessforbidden(); // Date range $year=GETPOST("year"); @@ -104,6 +103,7 @@ else llxHeader(); $html=new Form($db); +$thirdparty_static=new Societe($db); // Affiche en-tete de rapport if ($modecompta=="CREANCES-DETTES") @@ -113,6 +113,8 @@ if ($modecompta=="CREANCES-DETTES") $period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=''.img_previous().' '.img_next().''; $description=$langs->trans("RulesCADue"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); + else $description.= $langs->trans("DepositsAreIncluded"); $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -122,6 +124,7 @@ else { $period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=''.img_previous().' '.img_next().''; $description=$langs->trans("RulesCAIn"); + $description.= $langs->trans("DepositsAreIncluded"); $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -138,12 +141,8 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_statut in (1,2)"; - $sql.= " AND ("; - $sql.= " f.type = 0"; // Standard - $sql.= " OR f.type = 1"; // Replacement - $sql.= " OR f.type = 2"; // Credit note - $sql.= " OR f.type = 3"; // Deposit - $sql.= ")"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; $sql.= " AND f.fk_soc = s.rowid"; if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } @@ -189,7 +188,7 @@ else { // On ajoute les paiements anciennes version, non lies par paiement_facture if ($modecompta != 'CREANCES-DETTES') { - $sql = "SELECT 'Autres' as nom, '0' as idp, sum(p.amount) as amount_ttc"; + $sql = "SELECT '0' as socid, 'Autres' as name, sum(p.amount) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; @@ -199,8 +198,8 @@ if ($modecompta != 'CREANCES-DETTES') $sql.= " AND b.fk_account = ba.rowid"; $sql.= " AND ba.entity = ".$conf->entity; if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; - $sql.= " GROUP BY nom, idp"; - $sql.= " ORDER BY nom"; + $sql.= " GROUP BY socid, name"; + $sql.= " ORDER BY name"; $result = $db->query($sql); if ($result) @@ -222,6 +221,7 @@ if ($modecompta != 'CREANCES-DETTES') } +// Show array $i = 0; print ""; print ""; @@ -262,7 +262,10 @@ if (sizeof($amount)) // Third party $fullname=$name[$key]; if ($key > 0) { - $linkname=''.img_object($langs->trans("ShowCompany"),'company').' '.$fullname.''; + $thirdparty_static->id=$key; + $thirdparty_static->name=$fullname; + $thirdparty_static->client=1; + $linkname=$thirdparty_static->getNomUrl(1,'customer'); } else { $linkname=$langs->trans("PaymentsNotLinkedToInvoice"); @@ -310,7 +313,8 @@ if (sizeof($amount)) print "
"; print '
'; -$db->close(); -llxFooter('$Date: 2011/07/31 22:23:14 $ - $Revision: 1.49 $'); +llxFooter(); + +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index ee2a025e013..ecd9a8aa512 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -42,8 +42,7 @@ $userid=GETPOST('userid'); $socid=GETPOST('socid'); // Security check if ($user->societe_id > 0) $socid = $user->societe_id; -if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire) -accessforbidden(); +if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire) accessforbidden(); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') $modecompta = $conf->compta->mode; @@ -65,6 +64,8 @@ if ($modecompta=="CREANCES-DETTES") $period="$year_start - $year_end"; $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesCADue"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); + else $description.= $langs->trans("DepositsAreIncluded"); $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -74,6 +75,7 @@ else { $period="$year_start - $year_end"; $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesCAIn"); + $description.= $langs->trans("DepositsAreIncluded"); $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -82,17 +84,16 @@ if (! empty($modecompta)) $moreparam['modecompta']=$modecompta; report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$moreparam); -if ($modecompta == 'CREANCES-DETTES') { +if ($modecompta == 'CREANCES-DETTES') +{ $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.fk_statut in (1,2)"; - $sql.= " AND ("; - $sql.= " f.type = 0"; // Standard - $sql.= " OR f.type = 1"; // Replacement - $sql.= " OR f.type = 2"; // Credit note - $sql.= " OR f.type = 3"; // Deposit - $sql.= ")"; -} else { + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; +} +else +{ /* * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) @@ -132,7 +133,8 @@ else { } // On ajoute les paiements anciennes version, non lies par paiement_facture -if ($modecompta != 'CREANCES-DETTES') { +if ($modecompta != 'CREANCES-DETTES') +{ $sql = "SELECT date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; @@ -146,7 +148,8 @@ if ($modecompta != 'CREANCES-DETTES') { $sql.= " ORDER BY dm"; $result = $db->query($sql); - if ($result) { + if ($result) + { $num = $db->num_rows($result); $i = 0; while ($i < $num) @@ -161,7 +164,8 @@ if ($modecompta != 'CREANCES-DETTES') { $i++; } } - else { + else + { dol_print_error($db); } } @@ -497,8 +501,7 @@ print ""; */ +llxFooter(); + $db->close(); - -llxFooter('$Date: 2011/07/31 22:23:13 $ - $Revision: 1.51 $'); - ?> diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index 19e74cde4c7..ea8196b47e8 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -114,10 +114,14 @@ if ($modetax==1) // Calculate on invoice for goods and services //$nom.='
('.$langs->trans("SeeVATReportInInputOutputMode",'','').')'; $period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=($year_start?"".img_previous()." ".img_next()."":""); - $description=$langs->trans("RulesVATDue"); + $description=$langs->trans("RulesVATDueServices"); + $description.='
'; + $description.=$langs->trans("RulesVATDueProducts"); //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='
'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); - if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); - $description.=$fsearch; + //if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='
'.$langs->trans("DepositsAreNotIncluded"); + else $description.='
'.$langs->trans("DepositsAreIncluded"); + $description.=$fsearch; $description.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); @@ -137,9 +141,14 @@ if ($modetax==0) // Invoice for goods, payment for services //$nom.='
('.$langs->trans("SeeVATReportInDueDebtMode",'','').')'; $period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=($year_start?"".img_previous()." ".img_next()."":""); - $description=$langs->trans("RulesVATIn"); + $description=$langs->trans("RulesVATInServices"); + $description.=' '.$langs->trans("DepositsAreIncluded"); + $description.='
'; + $description.=$langs->trans("RulesVATInProducts"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.=' '.$langs->trans("DepositsAreNotIncluded"); + else $description.=' '.$langs->trans("DepositsAreIncluded"); //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='
'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); - if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); + //if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); $description.=$fsearch; $description.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $builddate=time(); @@ -202,7 +211,8 @@ if (is_array($coll_list)) print "".$i.""; $company_static->id=$coll->socid; $company_static->nom=$coll->nom; - print ''.$company_static->getNomUrl(1).''; + $company_static->client=1; + print ''.$company_static->getNomUrl(1,'customer').''; $find = array(' ','.'); $replace = array('',''); print "".$intra.""; @@ -279,7 +289,8 @@ if (is_array($coll_list)) print "".$i.""; $company_static->id=$coll->socid; $company_static->nom=$coll->nom; - print ''.$company_static->getNomUrl(1).''; + $company_static->fournisseur=1; + print ''.$company_static->getNomUrl(1,'supplier').''; $find = array(' ','.'); $replace = array('',''); print "".$intra.""; @@ -324,7 +335,7 @@ else print ''; -$db->close(); +llxFooter(); -llxFooter('$Date: 2011/08/03 00:46:25 $ - $Revision: 1.32 $'); +$db->close(); ?> diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index ec609a45c01..778a0b7b33d 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -134,9 +134,13 @@ if ($modetax==1) // Calculate on invoice for goods and services if ($nextquarter < 4) $nextquarter++; else { $nextquarter=1; $nextyear++; } //$periodlink=($prevyear?"".img_previous()." ".img_next()."":""); - $description=$langs->trans("RulesVATDue"); + $description=$langs->trans("RulesVATDueServices"); + $description.='
'; + $description.=$langs->trans("RulesVATDueProducts"); //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='
'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); - if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); + //if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='
'.$langs->trans("DepositsAreNotIncluded"); + else $description.='
'.$langs->trans("DepositsAreIncluded"); $description.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $description.=$fsearch; $builddate=time(); @@ -164,9 +168,14 @@ if ($modetax==0) // Invoice for goods, payment for services if ($nextquarter < 4) $nextquarter++; else { $nextquarter=1; $nextyear++; } //$periodlink=($prevyear?"".img_previous()." ".img_next()."":""); - $description=$langs->trans("RulesVATIn"); + $description=$langs->trans("RulesVATInServices"); + $description.=' '.$langs->trans("DepositsAreIncluded"); + $description.='
'; + $description.=$langs->trans("RulesVATInProducts"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.=' '.$langs->trans("DepositsAreNotIncluded"); + else $description.=' '.$langs->trans("DepositsAreIncluded"); //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='
'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); - if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); + //if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); $description.=$fsearch; $description.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $builddate=time(); @@ -350,6 +359,12 @@ else { if ($type) $text = img_object($langs->trans('Service'),'service'); else $text = img_object($langs->trans('Product'),'product'); + if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) + { + if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); + elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); + else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); + } print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); // Show range diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c45632b1837..6a050a98490 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2447,10 +2447,16 @@ class Form print ''; print ''; print '
'; - //if (! $filter || $filter=="fk_facture_source IS NULL") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount),$langs->transnoentities("Currency".$conf->monnaie)).': '; // If we want deposit to be substracted to payments only and not to total of final invoice - if (! $filter || $filter=="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount),$langs->transnoentities("Currency".$conf->monnaie)).': '; - else print $langs->trans("CompanyHasCreditNote",price($amount),$langs->transnoentities("Currency".$conf->monnaie)).': '; - // print $langs->trans("AvailableGlobalDiscounts").': '; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + { + if (! $filter || $filter=="fk_facture_source IS NULL") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount),$langs->transnoentities("Currency".$conf->currency)).': '; // If we want deposit to be substracted to payments only and not to total of final invoice + else print $langs->trans("CompanyHasCreditNote",price($amount),$langs->transnoentities("Currency".$conf->monnaie)).': '; + } + else + { + if (! $filter || $filter=="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount),$langs->transnoentities("Currency".$conf->currency)).': '; + else print $langs->trans("CompanyHasCreditNote",price($amount),$langs->transnoentities("Currency".$conf->monnaie)).': '; + } $newfilter='fk_facture IS NULL AND fk_facture_line IS NULL'; // Remises disponibles if ($filter) $newfilter.=' AND ('.$filter.')'; $nbqualifiedlines=$this->select_remises($selected,$htmlname,$newfilter,$socid,$maxvalue); diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index b1e399af7ef..de69bd50c39 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -102,16 +102,21 @@ SeeReportInInputOutputMode=See report %sIncomes-Expenses%s said cash a SeeReportInDueDebtMode=See report %sClaims-Debts%s said commitment accounting for a calculation on issued invoices RulesResultDue=- Amounts shown are with all taxes included
- It includes outstanding invoices, expenses and VAT whether they are paid or not.
- It is based on the validation date of invoices and VAT and on the due date for expenses. RulesResultInOut=- Amounts shown are with all taxes included
- It includes the real payments made on invoices, expenses and VAT.
- It is based on the payment dates of the invoices, expenses anf VAT.
-RulesCADue=- It includes the client's due invoices (except deposit invoices) whether they are paid or not.
- It is based on the validation date of these invoices.
+RulesCADue=- It includes the client's due invoices whether they are paid or not.
- It is based on the validation date of these invoices.
RulesCAIn=- It includes all the effective payments of invoices received from clients.
- It is based on the payment date of these invoices
+DepositsAreNotIncluded=- Deposit invoices are nor included +DepositsAreIncluded=- Deposit invoices are included +LT2ReportByCustomersInInputOutputModeES=Report by third party IRPF VATReportByCustomersInInputOutputMode=Report by the customer VAT collected and paid (VAT receipt) VATReportByCustomersInDueDebtMode=Report by the customer VAT collected and paid (VAT rate) VATReportByQuartersInInputOutputMode=Report by rate of the VAT collected and paid (VAT receipt) VATReportByQuartersInDueDebtMode=Report by rate of the VAT collected and paid (VAT rate) SeeVATReportInInputOutputMode=See report %sVAT encasement%s for a standard calculation SeeVATReportInDueDebtMode=See report %sVAT on flow%s for a calculation with an option on the flow -RulesVATIn=For services, the report includes the VAT regulations actually received or issued on the basis of the date of payment.
- For material assets, it includes the VAT invoices on the basis of the invoice date. -RulesVATDue=For services, the report includes VAT invoices due, paid or not, based on the invoice date.
- For material assets, it includes the VAT invoices, based on the invoice date. +RulesVATInServices=- For services, the report includes the VAT regulations actually received or issued on the basis of the date of payment.
- For material assets, it includes the VAT invoices on the basis of the invoice date. +RulesVATInProducts=- For material assets, it includes the VAT invoices on the basis of the invoice date. +RulesVATDueServices=- For services, the report includes VAT invoices due, paid or not, based on the invoice date. +RulesVATDueProducts=- For material assets, it includes the VAT invoices, based on the invoice date. OptionVatInfoModuleComptabilite=Note: For material assets, it should use the date of delivery to be more fair. PercentOfInvoice=%%/invoice NotUsedForGoods=Not used on goods diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index 1bd9a474680..c9000d7d7af 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -102,16 +102,21 @@ SeeReportInInputOutputMode=Voir le rapport %sRecettes-Dépenses%s dit SeeReportInDueDebtMode=Voir le rapport %sCréances-Dettes%s dit comptabilité d'engagement pour un calcul sur les factures émises RulesResultDue=- Les montants affichés sont les montants taxe incluse
- Il inclut les factures, charges et tva dues, qu'elles soient payées ou non.
- Il se base sur la date de validation pour les factures et la tva et sur la date d'échéance pour les charges.
RulesResultInOut=- Les montants affichés sont les montants taxe incluse
- Il inclut les règlements effectivement réalisés pour les factures, les charges et la TVA.
- Il se base sur la date de règlement de ces factures, charges et TVA.
-RulesCADue=- Il inclut les factures clients dues (hors facture accompte), qu'elles soient payées ou non.
- Il se base sur la date de validation de ces factures.
+RulesCADue=- Il inclut les factures clients dues, qu'elles soient payées ou non.
- Il se base sur la date de validation de ces factures.
RulesCAIn=- Il inclut les règlements effectivement reçus des factures clients.
- Il se base sur la date de règlement de ces factures
+DepositsAreNotIncluded=- Les factures d'accomptes ne sont pas incluses +DepositsAreIncluded=- Les factures d'accomptes sont incluses +LT2ReportByCustomersInInputOutputModeES=Rapport par client des IRPF VATReportByCustomersInInputOutputMode=Rapport par client des TVA collectées et payées (TVA sur encaissement) VATReportByCustomersInDueDebtMode=Rapport par client des TVA collectées et payées (TVA sur débit) VATReportByQuartersInInputOutputMode=Rapport par taux des TVA collectées et payées (TVA sur encaissement) VATReportByQuartersInDueDebtMode=Rapport par taux des TVA collectées et payées (TVA sur débit) SeeVATReportInInputOutputMode=Voir le rapport %sTVA encaissement%s pour mode de calcul standard SeeVATReportInDueDebtMode=Voir le rapport %sTVA sur débit%s pour mode de calcul avec option sur les débits -RulesVATIn=- Pour les services, le rapport inclut les TVA des règlements effectivement reçus ou émis en se basant sur la date du règlement.
- Pour les biens matériels, il inclut les TVA des factures en se basant sur la date de facture. -RulesVATDue=- Pour les services, le rapport inclut les TVA des factures dues, payées ou non en se basant sur la date de facture.
- Pour les biens matériels, il inclut les TVA des factures en se basant sur la date de facture. +RulesVATInServices=- Pour les services, le rapport inclut les TVA des règlements effectivement reçus ou émis en se basant sur la date du règlement. +RulesVATInProducts=- Pour les biens matériels, il inclut les TVA des factures en se basant sur la date de facture. +RulesVATDueServices=- Pour les services, le rapport inclut les TVA des factures dues, payées ou non en se basant sur la date de facture. +RulesVATDueProducts=- Pour les biens matériels, il inclut les TVA des factures en se basant sur la date de facture. OptionVatInfoModuleComptabilite=Remarque : Pour les biens matériels, il faudrait utiliser la date de livraison pour être plus juste. PercentOfInvoice=%%/facture NotUsedForGoods=Non utilisé pour les biens diff --git a/htdocs/lib/tax.lib.php b/htdocs/lib/tax.lib.php index 806f6793c55..4b7e681daf6 100644 --- a/htdocs/lib/tax.lib.php +++ b/htdocs/lib/tax.lib.php @@ -81,10 +81,8 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction $sql.= " ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE f.entity = " . $conf->entity; $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - $sql.= " AND (f.type = 0"; // Standard - $sql.= " OR f.type = 1"; // Replacement - $sql.= " OR f.type = 2)"; // Credit note - //$sql.= " OR f.type = 3"; // We do not include deposit + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; if ($y && $m) { $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; @@ -120,10 +118,8 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicetable." as fd, ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE "; $sql.= " f.fk_statut in (2)"; // Paid (partially or completely) - $sql.= " AND (f.type = 0"; // Standard - $sql.= " OR f.type = 1"; // Replacement - $sql.= " OR f.type = 2)"; // Credit note - //$sql.= " OR f.type = 3"; // We do not include deposit + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; if ($y && $m) { $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; @@ -238,10 +234,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; $sql.= " WHERE f.entity = " . $conf->entity; $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - $sql.= " AND (f.type = 0"; // Standard - $sql.= " OR f.type = 1"; // Replacement - $sql.= " OR f.type = 2)"; // Credit note - //$sql.= " OR f.type = 3"; // We do not include deposit + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; $sql.= " AND f.rowid = d.".$fk_facture; if ($y && $m) { @@ -279,23 +273,14 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,"; $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; $sql.= " 0 as payment_id, 0 as payment_amount"; -// $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount"; $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; -// $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; -// $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; $sql.= " WHERE f.entity = " . $conf->entity; $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - $sql.= " AND (f.type = 0"; // Standard - $sql.= " OR f.type = 1"; // Replacement - $sql.= " OR f.type = 2)"; // Credit note - //$sql.= " OR f.type = 3"; // We do not include deposit + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; $sql.= " AND f.rowid = d.".$fk_facture; -// $sql.= " AND pf.".$fk_facture2." = f.rowid"; -// $sql.= " AND pa.rowid = pf.".$fk_payment; -// $sql.= " AND pa.datep >= '".$y."0101000000' AND pa.datep <= '".$y."1231235959'"; -// $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; if ($y && $m) { $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; @@ -399,10 +384,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; $sql.= " WHERE f.entity = " . $conf->entity; $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - $sql.= " AND (f.type = 0"; // Standard - $sql.= " OR f.type = 1"; // Replacement - $sql.= " OR f.type = 2)"; // Credit note - //$sql.= " OR f.type = 3"; // We do not include deposit + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; $sql.= " AND f.rowid = d.".$fk_facture; if ($y && $m) { @@ -448,10 +431,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; $sql.= " WHERE f.entity = " . $conf->entity; $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) - $sql.= " AND (f.type = 0"; // Standard - $sql.= " OR f.type = 1"; // Replacement - $sql.= " OR f.type = 2)"; // Credit note - //$sql.= " OR f.type = 3"; // We do not include deposit + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; + else $sql.= " AND f.type IN (0,1,2,3)"; $sql.= " AND f.rowid = d.".$fk_facture;; $sql.= " AND pf.".$fk_facture2." = f.rowid"; $sql.= " AND pa.rowid = pf.".$fk_payment;