diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 3f57f1a2e9f2c50f2dbca75726c1604d858dd513..0659b33058f30836fd93d770992bd7e201563ce7 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1971,10 +1971,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 16d76cc0ee56b916dc0b9958c4763bd957b532b2..f2347d2594fc025911b0de62bf3c0658deb3b8bd 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -35,8 +35,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"); @@ -108,6 +107,8 @@ if ($modecompta=="CREANCES-DETTES") $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>'; $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"); } @@ -136,14 +137,19 @@ print "</tr>\n"; */ print '<tr><td colspan="4">'.$langs->trans("CustomersInvoices").'</td></tr>'; -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) @@ -258,9 +264,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"; @@ -286,8 +296,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; @@ -305,7 +317,8 @@ if ($result) { $i++; } } - else { + else + { $var=!$var; print "<tr $bc[$var]><td> </td>"; print '<td colspan="3">'.$langs->trans("None").'</td>'; @@ -329,7 +342,8 @@ print '</tr>'; print '<tr><td colspan="4">'.$langs->trans("SocialContributions").'</td></tr>'; -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"; @@ -337,7 +351,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"; @@ -397,7 +412,8 @@ print '</tr>'; print '<tr><td colspan="4">'.$langs->trans("SocialContributions").'</td></tr>'; -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"; @@ -407,7 +423,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"; @@ -491,11 +508,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); @@ -508,9 +527,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++; } @@ -520,7 +539,7 @@ if ($modecompta == 'CREANCES-DETTES') } print "<tr $bc[$var]><td> </td>"; print "<td>".$langs->trans("VATToPay")."</td>\n"; - if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price($amount)."</td>\n"; + print "<td align=\"right\"> </td>\n"; print "<td align=\"right\">".price($amount)."</td>\n"; print "</tr>\n"; @@ -528,11 +547,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); @@ -545,9 +566,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++; @@ -558,7 +579,7 @@ if ($modecompta == 'CREANCES-DETTES') } print "<tr $bc[$var]><td> </td>"; print "<td>".$langs->trans("VATToCollect")."</td>\n"; - if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price($amount)."</td>\n"; + print "<td align=\"right\"> </td>\n"; print "<td align=\"right\">".price($amount)."</td>\n"; print "</tr>\n"; } @@ -649,7 +670,7 @@ else if ($mysoc->tva_assuj != 'franchise') // Assujeti { print '<tr class="liste_total">'; - if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right">'.price(price2num($subtotal_ht,'MT')).'</td>'; + if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right"> </td>'; print '<td colspan="3" align="right">'.price(price2num($subtotal_ttc,'MT')).'</td>'; print '</tr>'; } diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index df660159417f7c53c0c6cf3abea103add3992547..6ae37e3c985e3cb6aadbba355236bf39468c5c83 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -58,13 +58,15 @@ llxHeader(); $form=new Form($db); // Affiche en-tete du rapport -if ($modecompta=="CREANCES-DETTES") +if ($modecompta == 'CREANCES-DETTES') { $nom=$langs->trans("AnnualSummaryDueDebtMode"); $nom.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')'; $period="$year_start - $year_end"; $periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":""); $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"); } @@ -85,13 +87,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) @@ -129,7 +136,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"; @@ -169,11 +177,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"; @@ -212,13 +225,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); @@ -243,6 +259,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"; @@ -326,14 +344,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"; @@ -501,7 +521,8 @@ print '<tr class="liste_total"><td>'.$langs->trans("Profit").'</td>'; for ($annee = $year_start ; $annee <= $year_end ; $annee++) { print '<td align="right" colspan="2"> '; - if (isset($totentrees[$annee]) || isset($totsorties[$annee])) { + if (isset($totentrees[$annee]) || isset($totsorties[$annee])) + { print price($totentrees[$annee]-$totsorties[$annee]).'</td>'; // print '<td> </td>'; } @@ -510,8 +531,8 @@ print "</tr>\n"; print "</table>"; -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 74c8b6ec70727bea8048cc5664364e2dcb40202d..e2153f4d04110ff200d253b5af7daa9b9f7500d3 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -109,6 +109,8 @@ if ($modecompta=="CREANCES-DETTES") $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink="<a href='".$_SERVER["PHP_SELF"]."?year=".($year-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year+1)."&modecompta=".$modecompta."'>".img_next()."</a>"; $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"); } @@ -118,6 +120,7 @@ else { $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink="<a href='".$_SERVER["PHP_SELF"]."?year=".($year-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year+1)."&modecompta=".$modecompta."'>".img_next()."</a>"; $description=$langs->trans("RulesCAIn"); + $description.= $langs->trans("DepositsAreIncluded"); $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -134,13 +137,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 @@ -302,7 +301,8 @@ if (count($amount)) print "</table>"; -$db->close(); llxFooter(); + +$db->close(); ?> diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 10ae1903620873ab7995e80e34ca8be06427b97a..d25be01aa5013c1083dcfaeb574192769422890a 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -42,8 +42,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"); @@ -103,6 +102,7 @@ else llxHeader(); $form=new Form($db); +$thirdparty_static=new Societe($db); // Affiche en-tete de rapport if ($modecompta=="CREANCES-DETTES") @@ -112,6 +112,8 @@ if ($modecompta=="CREANCES-DETTES") $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>'; $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"); } @@ -121,6 +123,7 @@ else { $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>'; $description=$langs->trans("RulesCAIn"); + $description.= $langs->trans("DepositsAreIncluded"); $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -137,12 +140,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)."'"; } @@ -188,7 +187,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"; @@ -198,8 +197,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) @@ -221,6 +220,7 @@ if ($modecompta != 'CREANCES-DETTES') } +// Show array $i = 0; print "<table class=\"noborder\" width=\"100%\">"; print "<tr class=\"liste_titre\">"; @@ -261,7 +261,10 @@ if (count($amount)) // Third party $fullname=$name[$key]; if ($key > 0) { - $linkname='<a href="'.DOL_URL_ROOT.'/societe/soc.php?socid='.$key.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$fullname.'</a>'; + $thirdparty_static->id=$key; + $thirdparty_static->name=$fullname; + $thirdparty_static->client=1; + $linkname=$thirdparty_static->getNomUrl(1,'customer'); } else { $linkname=$langs->trans("PaymentsNotLinkedToInvoice"); @@ -309,7 +312,8 @@ if (count($amount)) print "</table>"; print '<br>'; -$db->close(); llxFooter(); + +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 420acbb93a2ee7fe0cf440c72947f82080b643c0..c546fd5c563905854c8d6e2151d820d608a5e6bc 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * * This program is free software; you can redistribute it and/or modify @@ -41,8 +41,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->global->COMPTA_MODE; @@ -64,6 +63,8 @@ if ($modecompta=="CREANCES-DETTES") $period="$year_start - $year_end"; $periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":""); $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"); } @@ -73,23 +74,23 @@ else { $period="$year_start - $year_end"; $periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":""); $description=$langs->trans("RulesCAIn"); + $description.= $langs->trans("DepositsAreIncluded"); $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink); -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) @@ -129,7 +130,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"; @@ -143,7 +145,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) @@ -158,7 +161,8 @@ if ($modecompta != 'CREANCES-DETTES') { $i++; } } - else { + else + { dol_print_error($db); } } @@ -494,8 +498,7 @@ print "</table>"; */ -$db->close(); - llxFooter(); +$db->close(); ?> diff --git a/htdocs/compta/stats/prev.php b/htdocs/compta/stats/prev.php deleted file mode 100644 index 0b3e6e6bdcf84d6592ac78b4c27053f7a8bcbedb..0000000000000000000000000000000000000000 --- a/htdocs/compta/stats/prev.php +++ /dev/null @@ -1,132 +0,0 @@ -<?php -/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -require('../../main.inc.php'); - -// Security check -if ($user->societe_id > 0) -{ - $socid = $user->societe_id; -} - - -function pt ($db, $sql, $title) { - global $bc; - global $langs,$conf; - - print '<table class="border" width="100%">'; - print '<tr class="liste_titre">'; - print "<td>$title</td>"; - print "<td align=\"right\">Montant</td>"; - print "</tr>\n"; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; $total = 0 ; - - $var=True; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $var=!$var; - print '<tr '.$bc[$var].'>'; - print '<td>'.$obj->dm.'</td>'; - print '<td align="right">'.price($obj->amount).'</td>'; - - print "</tr>\n"; - $total = $total + $obj->amount; - $i++; - } - print "<tr class=\"total\"><td colspan=\"2\" align=\"right\"><b>".$langs->trans("TotalHT").": ".price($total)."</b> ".$langs->trans("Currency".$conf->currency)."</td></tr>"; - - $db->free(); - } - else - { - dol_print_error($db); - - } - print "</table>"; - -} -/* - * - */ - -llxHeader(); - - -if ($sortfield == "") -{ - $sortfield="lower(p.label)"; -} -if ($sortorder == "") -{ - $sortorder="ASC"; -} - -$in = "(1,2,4)"; - -print_titre ("CA Pr�visionnel bas� sur les propositions <b>ouvertes</b> et <b>sign�es</b>"); - -print '<table width="100%">'; - -print '<tr><td valign="top">'; - -$sql = "SELECT sum(p.price) as amount, date_format(p.datep,'%Y-%m') as dm"; -$sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; -$sql.= " WHERE p.fk_statut in ".$in; -$sql.= " AND p.entity = ".$conf->entity; -if ($socid) $sql.= " AND p.fk_soc = ".$socid; -$sql.= " GROUP BY dm DESC"; - -pt($db, $sql, $langs->trans("Month")); - -print '</td><td valign="top">'; - -$sql = "SELECT sum(p.price) as amount, year(p.datep) as dm"; -$sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; -$sql.= " WHERE p.fk_statut in ".$in; -$sql.= " AND p.entity = ".$conf->entity; -if ($socid) $sql.= " AND p.fk_soc = ".$socid; -$sql.= " GROUP BY dm DESC"; - -pt($db, $sql, "Ann�e"); - -print "<br>"; - -$sql = "SELECT sum(p.price) as amount, month(p.datep) as dm"; -$sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; -$sql.= " WHERE p.fk_statut in ".$in; -$sql.= " AND p.entity = ".$conf->entity; -if ($socid) $sql.= " AND p.fk_soc = ".$socid; -$sql.= " GROUP BY dm"; - -pt($db, $sql, "Mois cumul�s"); - -print "</td></tr></table>"; - -$db->close(); - - -llxFooter(); -?> diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index c6ee70849bf206553949fbccccc1e0bde238e964..be5ab8163ab672da90d7db891155dcc1d9b876ee 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -113,10 +113,14 @@ if ($modetax==1) // Calculate on invoice for goods and services //$nom.='<br>('.$langs->trans("SeeVATReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=0">','</a>').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":""); - $description=$langs->trans("RulesVATDue"); + $description=$langs->trans("RulesVATDueServices"); + $description.='<br>'; + $description.=$langs->trans("RulesVATDueProducts"); //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); - if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded"); - $description.=$fsearch; + //if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='<br>'.$langs->trans("DepositsAreNotIncluded"); + else $description.='<br>'.$langs->trans("DepositsAreIncluded"); + $description.=$fsearch; $description.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); @@ -136,9 +140,14 @@ if ($modetax==0) // Invoice for goods, payment for services //$nom.='<br>('.$langs->trans("SeeVATReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=1">','</a>').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":""); - $description=$langs->trans("RulesVATIn"); + $description=$langs->trans("RulesVATInServices"); + $description.=' '.$langs->trans("DepositsAreIncluded"); + $description.='<br>'; + $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.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); - if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded"); + //if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded"); $description.=$fsearch; $description.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $builddate=time(); @@ -201,7 +210,8 @@ if (is_array($coll_list)) print "<td nowrap>".$i."</td>"; $company_static->id=$coll->socid; $company_static->nom=$coll->nom; - print '<td nowrap>'.$company_static->getNomUrl(1).'</td>'; + $company_static->client=1; + print '<td nowrap>'.$company_static->getNomUrl(1,'customer').'</td>'; $find = array(' ','.'); $replace = array('',''); print "<td nowrap>".$intra."</td>"; @@ -278,7 +288,8 @@ if (is_array($coll_list)) print "<td nowrap>".$i."</td>"; $company_static->id=$coll->socid; $company_static->nom=$coll->nom; - print '<td nowrap>'.$company_static->getNomUrl(1).'</td>'; + $company_static->fournisseur=1; + print '<td nowrap>'.$company_static->getNomUrl(1,'supplier').'</td>'; $find = array(' ','.'); $replace = array('',''); print "<td nowrap>".$intra."</td>"; @@ -323,7 +334,7 @@ else print '</table>'; -$db->close(); - llxFooter(); + +$db->close(); ?> diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index a74c8ae4a1eb2105e9e059a595cc1ffb8687bab7..62c3a1f052e77b3986bcc9de3c3c2afddbf0695b 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -133,9 +133,13 @@ if ($modetax==1) // Calculate on invoice for goods and services if ($nextquarter < 4) $nextquarter++; else { $nextquarter=1; $nextyear++; } //$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":""); - $description=$langs->trans("RulesVATDue"); + $description=$langs->trans("RulesVATDueServices"); + $description.='<br>'; + $description.=$langs->trans("RulesVATDueProducts"); //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); - if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded"); + //if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='<br>'.$langs->trans("DepositsAreNotIncluded"); + else $description.='<br>'.$langs->trans("DepositsAreIncluded"); $description.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $description.=$fsearch; $builddate=time(); @@ -163,9 +167,14 @@ if ($modetax==0) // Invoice for goods, payment for services if ($nextquarter < 4) $nextquarter++; else { $nextquarter=1; $nextyear++; } //$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":""); - $description=$langs->trans("RulesVATIn"); + $description=$langs->trans("RulesVATInServices"); + $description.=' '.$langs->trans("DepositsAreIncluded"); + $description.='<br>'; + $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.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); - if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded"); + //if ($conf->global->MAIN_MODULE_COMPTABILITE) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded"); $description.=$fsearch; $description.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $builddate=time(); @@ -349,6 +358,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 896b4e59922d541bb6f0f8c8a91021f889bf846b..4b97d84e205a076434ae8486b08a7e4b94e4b033 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2726,9 +2726,16 @@ class Form print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">'; print '<tr><td nowrap="nowrap">'; - //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 - 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->currency)).': '; + 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->currency)).': '; + } + 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->currency)).': '; + } $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/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index d05b52e5d565c6d04c7f7ba62e0f04e9b15bfe58..b088cdd3d42bbefd8be5ea54bc94a6361ceb6244 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -120,10 +120,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))."'"; @@ -159,10 +157,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))."'"; @@ -282,10 +278,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) { @@ -324,23 +318,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))."'"; @@ -451,10 +436,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) { @@ -501,10 +484,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; diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 473ef38580644fc089343329d5d22e9a3737ab84..e9422abc6935b543f117b7b7d5f32ac00a101a6e 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -109,8 +109,10 @@ SeeReportInInputOutputMode=See report <b>%sIncomes-Expenses%s</b> said <b>cash a SeeReportInDueDebtMode=See report <b>%sClaims-Debts%s</b> said <b>commitment accounting</b> for a calculation on issued invoices RulesResultDue=- Amounts shown are with all taxes included<br>- It includes outstanding invoices, expenses and VAT whether they are paid or not. <br>- 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<br>- It includes the real payments made on invoices, expenses and VAT. <br>- It is based on the payment dates of the invoices, expenses anf VAT.<br> -RulesCADue=- It includes the client's due invoices (except deposit invoices) whether they are paid or not. <br>- It is based on the validation date of these invoices. <br> +RulesCADue=- It includes the client's due invoices whether they are paid or not. <br>- It is based on the validation date of these invoices. <br> RulesCAIn=- It includes all the effective payments of invoices received from clients.<br>- It is based on the payment date of these invoices<br> +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) @@ -118,8 +120,10 @@ VATReportByQuartersInInputOutputMode=Report by rate of the VAT collected and pai VATReportByQuartersInDueDebtMode=Report by rate of the VAT collected and paid (VAT rate) SeeVATReportInInputOutputMode=See report <b>%sVAT encasement%s</b> for a standard calculation SeeVATReportInDueDebtMode=See report <b>%sVAT on flow%s</b> 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.<br>- 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.<br>- 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.<br>- 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 f4d2a469fb7417ffe3a4f8fab5cdc5bec5382467..f273d330fb82003e704732f68a293e0e72db4507 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -109,8 +109,10 @@ SeeReportInInputOutputMode=Voir le rapport <b>%sRecettes-Dépenses%s</b> dit <b> SeeReportInDueDebtMode=Voir le rapport <b>%sCréances-Dettes%s</b> dit <b>comptabilité d'engagement</b> pour un calcul sur les factures émises RulesResultDue=- Les montants affichés sont les montants taxe incluse<br>- Il inclut les factures, charges et tva dues, qu'elles soient payées ou non.<br>- Il se base sur la date de validation pour les factures et la tva et sur la date d'échéance pour les charges.<br> RulesResultInOut=- Les montants affichés sont les montants taxe incluse<br>- Il inclut les règlements effectivement réalisés pour les factures, les charges et la TVA.<br>- Il se base sur la date de règlement de ces factures, charges et TVA.<br> -RulesCADue=- Il inclut les factures clients dues (hors facture accompte), qu'elles soient payées ou non.<br>- Il se base sur la date de validation de ces factures.<br> +RulesCADue=- Il inclut les factures clients dues, qu'elles soient payées ou non.<br>- Il se base sur la date de validation de ces factures.<br> RulesCAIn=- Il inclut les règlements effectivement reçus des factures clients.<br>- Il se base sur la date de règlement de ces factures<br> +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) @@ -118,8 +120,10 @@ VATReportByQuartersInInputOutputMode=Rapport par taux des TVA collectées et pay VATReportByQuartersInDueDebtMode=Rapport par taux des TVA collectées et payées (TVA sur débit) SeeVATReportInInputOutputMode=Voir le rapport <b>%sTVA encaissement%s</b> pour mode de calcul standard SeeVATReportInDueDebtMode=Voir le rapport <b>%sTVA sur débit%s</b> 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.<br>- 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.<br>- 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