Merge remote-tracking branch 'origin/3.4' into 3.5

Conflicts:
	ChangeLog
	htdocs/compta/stats/cabyprodserv.php
	htdocs/compta/stats/casoc.php
This commit is contained in:
Laurent Destailleur 2014-01-03 18:28:00 +01:00
commit f0503dfaa9
3 changed files with 117 additions and 86 deletions

View File

@ -136,55 +136,59 @@ parameter. All methods addline in this case were modified to remove this paramet
***** ChangeLog for 3.4.2 compared to 3.4.1 ***** ***** ChangeLog for 3.4.2 compared to 3.4.1 *****
Fix: field's problem into company's page (RIB) Fix: field's problem into company's page (RIB).
Fix: Document cerfa doesn't contained firstname & lastname from donator Fix: Document cerfa doesn't contained firstname & lastname from donator.
Fix: Bad rounding on margin calculations and display. Fix: Bad rounding on margin calculations and display.
Fix: Option drop table into backup was broken. Fix: Option drop table into backup was broken.
Fix: [ bug #1105 ] Searching Boxes other search option Fix: [ bug #1105 ] Searching Boxes other search option.
Fix: wrong buy price update Fix: wrong buy price update.
Fix: [ bug #1142 ] Set paiement on invoice (PGSql) Fix: [ bug #1142 ] Set paiement on invoice (PGSql).
Fix: [ bug #1145 ] Agenda button list type do not display Fix: [ bug #1145 ] Agenda button list type do not display.
Fix: [ bug #1148 ] Product consomation : supplier order bad status Fix: [ bug #1148 ] Product consomation : supplier order bad status.
Fix: [ bug #1159 ] Commercial search "other" give p.note do not exists Fix: [ bug #1159 ] Commercial search "other" give p.note do not exists.
Fix: [ bug #1174 ] Product translated description not good into PDF Fix: [ bug #1174 ] Product translated description not good into PDF.
Fix: [ bug #1163 ] SQL Error when searching for supplier orders Fix: [ bug #1163 ] SQL Error when searching for supplier orders.
Fix: [ bug #1162 ] Translaction for morning and afternoon Fix: [ bug #1162 ] Translaction for morning and afternoon.
Fix: [ bug #1161 ] Search on product label Fix: [ bug #1161 ] Search on product label.
Fix: [ bug #1075 ] POS module doesn't decrement stock of products in delayed payment mode. Fix: [ bug #1075 ] POS module doesn't decrement stock of products in delayed payment mode.
Fix: [ bug #1171 ] Documents lost in interventions after validating Fix: [ bug #1171 ] Documents lost in interventions after validating.
Fix: fix unsubscribe URL into mailing when sending manually (not by script) Fix: fix unsubscribe URL into mailing when sending manually (not by script).
Fix: [ bug #1182 ] ODT company_country tag is htmlencoded Fix: [ bug #1182 ] ODT company_country tag is htmlencoded.
Fix: [ bug #1196 ] Product barcode search does not expect 13th digit on EAN13 type Fix: [ bug #1196 ] Product barcode search does not expect 13th digit on EAN13 type.
Fix: [ bug #1202 ] Wrong amount in deposit % invoice from proposal Fix: [ bug #1202 ] Wrong amount in deposit % invoice from proposal.
Fix: Removed analytics tags into doc page.
Fix: Call Image on this instead of pdf.
Fix: Missing parameter for photo.
Fix: Bad SQL request for turnover report.
***** ChangeLog for 3.4.1 compared to 3.4.0 ***** ***** ChangeLog for 3.4.1 compared to 3.4.0 *****
Fix: Display buying price on line edit when no supplier price is defined Fix: Display buying price on line edit when no supplier price is defined.
Fix: Retrieving of margin info when invoice created automatically from order Fix: Retrieving of margin info when invoice created automatically from order.
Fix: Reordering supplier products in list by supplier or supplier ref was crashing Fix: Reordering supplier products in list by supplier or supplier ref was crashing.
Fix: [ bug #1029 ] Tulip numbering mask Fix: [ bug #1029 ] Tulip numbering mask.
Fix: Supplier invoice and supplier order are not displayed into object link into agenda event card Fix: Supplier invoice and supplier order are not displayed into object link into agenda event card.
Fix: [ bug #1033 ] SUPPLIER REF disappeared Fix: [ bug #1033 ] SUPPLIER REF disappeared.
Fix: update extrafield do not display immediately after update Fix: update extrafield do not display immediatly after update.
Fix: Fix bug with canvas thirdparty Fix: Fix bug with canvas thirdparty.
Fix: [ bug #1037 ] Consumption> Supplier invoices related Fix: [ bug #1037 ] Consumption> Supplier invoices related.
Fix: User group name do not display in card (view or edit mode) Fix: User group name do not display in card (view or edit mode).
Fix: Link "Show all supplier invoice" on supplier card not working Fix: Link "Show all supplier invoice" on suplier card not working.
Fix: [ bug #1039 ] Pre-defined invoices conversion Fix: [ bug #1039 ] Pre-defined invoices conversion.
Fix: If only service module is activated, it's impossible to delete service Fix: If only service module is activated, it's impossible to delete service.
Fix: [ bug #1043 ] Bad interventions ref numbering Fix: [ bug #1043 ] Bad interventions ref numbering.
Fix: Mailing module : if an email is already in destinaires list all other email from selector was not inserted Fix: Mailing module : if an email is already in destinaires list all other email from selector was not inserted.
Fix: Localtaxes balance not showing Fix: Localtaxes balance not showing.
Fix: Intervention box links to contracts id Fix: Intervention box links to contracts id.
Fix: Compatibility with multicompany module Fix: Compatiblity with multicompany module.
Fix: Edit propal line was losing product supplier price id Fix: Edit propal line was losing product supplier price id.
Fix: Delete linked element to supplier invoice when deleted Fix: Delete linked element to supplier invoice when deleted.
Fix: [ bug #1061 ] Bad info shipped products Fix: [ bug #1061 ] Bad info shipped products.
Fix: [ bug #1062 ] Documents lost in propals and contracts validating Fix: [ bug #1062 ] Documents lost in propals and contracts validating.
Fix: Supplier price displayed on document lines and margin infos didnt take discount Fix: Supplier price displayed on document lines and margin infos didnt take discount.
Fix: sorting on qty did not work in supplier product list Fix: sorting on qty did not work in supplier product list.
Fix: there was no escaping on filter fields in supplier product list Fix: there was no escaping on filter fields in supplier product list.
Fix: bugs on margin reports and better margin calculation on credit notes Fix: bugs on margin reports and better margin calculation on credit notes.
Qual: Add travis-ci integration Qual: Add travis-ci integration.
***** ChangeLog for 3.4 compared to 3.3.* ***** ***** ChangeLog for 3.4 compared to 3.3.* *****
For users: For users:

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2013 Antoine Iauch <aiauch@gpcsolutions.fr> /* Copyright (C) 2013 Antoine Iauch <aiauch@gpcsolutions.fr>
* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -173,23 +174,21 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl
// SQL request // SQL request
$catotal=0; $catotal=0;
if ($modecompta == 'CREANCES-DETTES') { if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label,"; $sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label,";
$sql.= " sum(l.total_ht) as amount, sum(l.total_ttc) as amount_ttc"; $sql.= " sum(l.total_ht) as amount, sum(l.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as l, ".MAIN_DB_PREFIX."product as p";
$sql.= " JOIN ".MAIN_DB_PREFIX."facturedet as l"; if ($selected_cat === -2) // Without any category
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON l.fk_facture = f.rowid"; {
if ($selected_cat === -2) { $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product";
$sql.=" LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; }
} else if ($selected_cat) // Into a specific category
if ($selected_cat && $selected_cat !== -2) { {
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = " . $selected_cat; $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp";
if ($subcat) {
$sql.=" OR c.fk_parent = " . $selected_cat;
} }
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE l.fk_product = p.rowid"; $sql.= " WHERE l.fk_product = p.rowid";
$sql.= " AND l.fk_facture = f.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)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql.= " AND f.type IN (0,1,2)"; $sql.= " AND f.type IN (0,1,2)";
@ -199,16 +198,21 @@ if ($modecompta == 'CREANCES-DETTES') {
if ($date_start && $date_end) { if ($date_start && $date_end) {
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
} }
if ($selected_cat === -2) { if ($selected_cat === -2) // Without any category
$sql.=" AND cp.fk_product is null"; {
} $sql.=" AND cp.fk_product is null";
if ($selected_cat && $selected_cat !== -2) { }
$sql.= " AND cp.fk_product = p.rowid"; else if ($selected_cat) { // Into a specific category
} $sql.= " AND (c.rowid = ".$selected_cat;
if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat;
$sql.= ")";
$sql.= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid";
}
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
$sql.= " GROUP BY p.rowid "; $sql.= " GROUP BY p.rowid";
$sql.= "ORDER BY p.ref "; $sql.= " ORDER BY p.ref";
dol_syslog("cabyprodserv sql=".$sql);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
@ -384,7 +388,10 @@ if ($modecompta == 'CREANCES-DETTES') {
print '</form>'; print '</form>';
} else { } else {
// $modecompta != 'CREANCES-DETTES' // $modecompta != 'CREANCES-DETTES'
print '<br>'.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant") . '<br>'; // "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an
// invoice with 2 product (product A for 10 euros and product B for 20 euros), what is part of paiment for product A and part of paiment for product B ?
// Because there is no way to know this, this report is not relevant.
print '<br>'.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant") . '<br>';
} }
llxFooter(); llxFooter();

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2013 Antoine Iauch <aiauch@gpcsolutions.fr> * Copyright (C) 2013 Antoine Iauch <aiauch@gpcsolutions.fr>
@ -180,17 +180,14 @@ $catotal=0;
if ($modecompta == 'CREANCES-DETTES') { if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT DISTINCT s.rowid as socid, s.nom as name,"; $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name,";
$sql.= " sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; $sql.= " sum(f.total) as amount, sum(f.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
$sql.= " JOIN ".MAIN_DB_PREFIX."facture as f"; if ($selected_cat === -2) // Without any category
if ($selected_cat === -2) { {
$sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_societe"; $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_societe";
} }
if ($selected_cat && $selected_cat !== -2) { else if ($selected_cat) // Into a specific category
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = ".$selected_cat; {
if ($subcat) { $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs";
$sql.=" OR c.fk_parent = " . $selected_cat;
}
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON cs.fk_categorie = c.rowid";
} }
$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)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
@ -202,28 +199,50 @@ if ($modecompta == 'CREANCES-DETTES') {
if ($date_start && $date_end) { if ($date_start && $date_end) {
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
} }
if ($selected_cat === -2) { if ($selected_cat === -2) // Without any category
{
$sql.=" AND cs.fk_societe is null"; $sql.=" AND cs.fk_societe is null";
} }
if ($selected_cat && $selected_cat !== -2) { else if ($selected_cat) { // Into a specific category
$sql.= " AND cs.fk_societe = s.rowid"; $sql.= " AND (c.rowid = ".$selected_cat;
if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat;
$sql.= ")";
$sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_societe = s.rowid";
} }
} else { } else {
/* /*
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * 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) * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
*/ */
$sql = "SELECT s.rowid as socid, s.nom as name, sum(pf.amount) as amount_ttc"; $sql = "SELECT s.rowid as socid, s.nom as name, sum(pf.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf"; $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
$sql.= ", ".MAIN_DB_PREFIX."paiement as p"; $sql.= ", ".MAIN_DB_PREFIX."paiement as p";
$sql .= " WHERE p.rowid = pf.fk_paiement"; $sql.= ", ".MAIN_DB_PREFIX."societe as s";
if ($selected_cat === -2) // Without any category
{
$sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_societe";
}
else if ($selected_cat) // Into a specific category
{
$sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs";
}
$sql.= " WHERE p.rowid = pf.fk_paiement";
$sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND pf.fk_facture = f.rowid";
$sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.fk_soc = s.rowid";
if ($date_start && $date_end) { if ($date_start && $date_end) {
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
} }
if ($selected_cat === -2) // Without any category
{
$sql.=" AND cs.fk_societe is null";
}
else if ($selected_cat) { // Into a specific category
$sql.= " AND (c.rowid = ".$selected_cat;
if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat;
$sql.= ")";
$sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_societe = s.rowid";
}
} }
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid; if ($socid) $sql.= " AND f.fk_soc = ".$socid;
@ -231,6 +250,7 @@ $sql.= " GROUP BY s.rowid, s.nom";
$sql.= " ORDER BY s.rowid"; $sql.= " ORDER BY s.rowid";
//echo $sql; //echo $sql;
dol_syslog("casoc sql=".$sql);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
@ -251,7 +271,7 @@ if ($result) {
// On ajoute les paiements anciennes version, non lies par paiement_facture // On ajoute les paiements anciennes version, non lies par paiement_facture
if ($modecompta != 'CREANCES-DETTES') { if ($modecompta != 'CREANCES-DETTES') {
$sql = "SELECT '0' as socid, 'Autres' as name, sum(DISTINCT 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.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= ", ".MAIN_DB_PREFIX."paiement as p"; $sql.= ", ".MAIN_DB_PREFIX."paiement as p";
@ -483,4 +503,4 @@ print '</form>';
llxFooter(); llxFooter();
$db->close(); $db->close();
?> ?>